I'm trying to create a very simple scene containing a triangular planar face continuously rotating about the x axis.
Here's the code creating the geometry object, as indicated in this previous SO question:
// create triangular plane geometry
var geometry_1 = new THREE.Geometry();
var v1 = new THREE.Vector3(0,0,0);
var v2 = new THREE.Vector3(3,0,0);
var v3 = new THREE.Vector3(0,3,0);
geometry_1.vertices.push(v1);
geometry_1.vertices.push(v2);
geometry_1.vertices.push(v3);
geometry_1.faces.push(new THREE.Face3(0, 1, 2));
The animation function renders the scene and adds a small rotation to the mesh:
function animate() {
requestAnimationFrame( animate );
mesh_1.rotation.x += 0.005;
renderer.render( scene, camera );
}
Everything works fine until the value of mesh.rotation.x
goes into the [Math.PI, 2*Math.PI]
interval, at which point it disappears for exactly half of the cycle. This JSFiddle replicates the behavior I'm observing.
- This is not a
light
problem, as there are an ambient light and a directional light supposed to illuminate the mesh at all points of it revolution. - This should not be a
material
problem, as I did set itsside
property toTHREE.DoubleSide
and in fact in the intervalmesh.rotation.x
into[0, Math.PI]
I already observe both faces. - I tried adding another face to the same geometry with
geometry_1.faces.push(new THREE.Face3(0, 2, 1));
but that still didn't solve the problem. - Adding a second geometry with an opposite face
geometry_2.faces.push(new THREE.Face3(0, 2, 1));
and having the mesh rotate negativelymesh_2.rotation.x -= 0.005;
allows me to observe the desired result because the two geometries are now disappearing in opposite halves of the[0, 2*Math.PI]
interval. This however is a hacky and not ideal solution.
So what is going on? How can I solve it? Thanks!