After spending the entire weekend attempting to rotate an obj mtl in the animation function, I've reached a dead end. Despite exhaustively searching through all related postings on this issue and making various changes, nothing seems to work.
The code in question is written using threejs, with all necessary libraries included and the objmtl object declared globally. Surprisingly, the object can be rotated successfully in the initial code snippet:
loader1 = new THREE.OBJMTLLoader();
loader1.load( 'head_no_eyes.obj', 'head_no_eyes.mtl',
function ( object1 ) {
object1.position.y = - 10;
object1.rotation.x = Math.PI/15.;
scene.add( object1 );
animate();
} );
However, when attempting the rotation within the animation routine, it fails to produce the desired effect:
function animate() {
requestAnimationFrame(animate);
camera.position.x += ( mouseX - camera.position.x ) * 0.5;
camera.position.y += ( - mouseY - camera.position.y ) * .05;
// object1.rotation.y += 0.07; // this line makes it fail
camera.lookAt(scene.position);
renderer.render(scene, camera); }
The reason behind this inability remains unclear to me. Is there anyone who might have insights into why this isn't working as expected?
Your assistance would be greatly appreciated.