three.js how to make double sided object

In your case, you add the following to your callback function: objects.traverse( function( node ) { if( node.material ) { node.material.side = THREE.DoubleSide; } }); The doubleSided property of Mesh is deprecated. It was replaced with the side property of Material Also, it is best to learn from three.js examples that work with the current … Read more

Display wireframe and solid color

To render both a model and its wireframe, you can use a pattern like this one: // mesh var material = new THREE.MeshPhongMaterial( { color: 0xff0000, polygonOffset: true, polygonOffsetFactor: 1, // positive value pushes polygon further away polygonOffsetUnits: 1 } ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ) // wireframe var … Read more

Three.js png texture – alpha renders as white instead as transparent

the opacity attribute of material does the trick for you. Follows, example code snippet: var materialArray = []; materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( ‘images/xpos.png’ ), transparent: true, opacity: 0.5, color: 0xFF0000 })); materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( ‘images/xneg.png’ ), transparent: true, opacity: 0.5, color: 0xFF0000 })); materialArray.push(new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( ‘images/ypos.png’ ), transparent: true, … Read more

Moving the camera, lookAt and rotations in three.js

To fix the problem you can specify the up vector for the camera before executing the lookAt() command. // Place camera on x axis camera.position.set(30,0,0); camera.up = new THREE.Vector3(0,0,1); camera.lookAt(new THREE.Vector3(0,0,0)); Change the vector to your needs. You can even turn it upside down by specifying a negative value: (0,0,-1). It is important to set … Read more

Transparent objects in Three.js

Both your spheres are transparent, and are remaining so. What is happening is that the smaller sphere is not being rendered at all. Transparency in WebGL is tricky. You can google the issue to find out more about it. But you have stumbled upon an issue related to how three.js in particular handles transparency. The … Read more