I built a threejs scene in 2018 with the Sun as a transparent PNG on a SpriteMaterial. Around the sun were semi-transparent orbits that used LineBasic Material.
I built a new version of the same piece with the a newer version of threeJS, using the exact same code to create the objects, and now the sprite acts differently. The front side of the Venus orbit draws in front as expected but the sun sprite clips the back side.
Mercury’s orbit visually works ok because it’s offset from (0,0,0). If you spin the scene around the same thing happens though and the backside of Mercury’s orbit gets masked.
Here is a live version of 2018:
https://www.bluecorallearning.com/prod/guides/science/solar_system/
Here is a temp version of 2020 (ignore title screen name):
This is the code to create each, this was copied right out of the old version:
Sun Object
var sunGroup = new THREE.Object3D() entireSolar.add(sunGroup) var sunMap = manifestData.sunrays.imageData var sunMat = new THREE.SpriteMaterial( { map: sunMap, color: 0xffffff, fog: true } ); sunMat.transparent = true; sunMat.opacity = 1; var sunObject = new THREE.Sprite( sunMat ); sunObject.scale.set(13.2, 13.2, 1) sunGroup.add(sunObject)
Orbit Object
var venusOrbitGroup = new THREE.Object3D() entireSolar.add(venusOrbitGroup) var venusOrbitGeom = new THREE.CircleGeometry( 17, 200 ); venusOrbitGeom.vertices.shift(); venusOrbitGeom.scale(1, 1, 1) var venusOrbitMat = new THREE.LineBasicMaterial( { color:planetOrbitColor } ); venusOrbitMat.transparent = true; venusOrbitMat.opacity = planetOpacity; var venusOrbitObject = new THREE.LineLoop( venusOrbitGeom, venusOrbitMat ) venusOrbitGroup.add(venusOrbitObject)
If I set the sun to depthWrite = true now the Venus orbit writes over in front and in back. This happens in both versions (I’d expect this to be the case).
If I take the transparency off the orbit everything works. You can see in all examples it doesn’t clip the Asteroid belt, which is also a transparent PNG on a geometric plane.
Did something change in how threejs renders this transparency combo?