vasturiano / three-globe

WebGL Globe Data Visualization as a ThreeJS reusable 3D object
https://vasturiano.github.io/three-globe/example/links/
MIT License
1.22k stars 147 forks source link

when updating to three.js 0.121.1 atmosphere does not longer work #67

Open zen85 opened 1 year ago

zen85 commented 1 year ago

the atmosphere is not rendering and the three-globe library throws this in the console:

"three-globe:2 Uncaught TypeError: Cannot read properties of undefined (reading 'position')
    at ir (three-globe:2:58765)
    at A.atmosphereObj.backside (three-globe:2:61042)
    at Function.update (three-globe:2:61110)
    at three-globe:2:7703
    at l (three-globe:2:5265)"

if i include my libraries like that (as you can see i also switched the tbcontrols with the OrbitControls):

<script src="https://cdn.jsdelivr.net/npm/three@0.121.1/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.121.1/examples/js/controls/OrbitControls.js"></script>
<script src="//unpkg.com/three-globe"></script>
            const orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
            orbitControls.enableZoom = true;
            orbitControls.maxDistance = 400;
            orbitControls.minDistance = 101;
            orbitControls.maxPolarAngle = Math.PI / 2;

it works but just has problems with the atmosphere apparently.

vasturiano commented 1 year ago

@zen85 thanks for reaching out.

This is essentially because on v0.125 of ThreeJS there was a breaking API change introduced. Plain geometries were deprecated, and what was previously called buffer geometries started being called just geometries. You can find the details of that release here: https://github.com/mrdoob/three.js/releases/tag/r125

The result is that the code in this module expects a sphere buffer geometry to create the glow, which in the new spec is simply called SphereGeometry. While in versions prior to 125, SphereGeometry was not a buffer geometry that's why the code chokes.

So, unfortunately there's not really much choice other the upgrading the three version to at least 125 if you want it to be compatible with the latest version of this module.

I am also updating the min version in peerDependencies to reflect this.