I make a scene, where I want want to animate cube, but it keeps giving me a error : TypeError: Cannot read property 'rotation' of undefined
function animate() {
requestAnimationFrame( animate );
render();
}
function render() {
var time = Date.now() * 0.005;
camera.position.x += ( mouseX - camera.position.x ) * 0.05;
camera.position.y += ( - mouseY - camera.position.y ) * 0.05;
camera.lookAt( scene.position );
for ( i = 0; i < scene.children.length; i ++ ) {
var object = scene.children[ i ];
if ( object instanceof THREE.PointCloud ) {
object.rotation.y += 0.01 ;
}
}
cube.rotation.y = time* 0.01;
renderer.render( scene, camera );
}
PoinCloud works perfectly, but for the cure it gives me an error.
Could anyone help me to solve the problem?
cubea local or global variable? - gaitatcubehas the valueundefined. Since we can't see wherecubehas been initialised, you might want to look into what's happening with that. - Qantas 94 Heavy