Is there a way to make my text mesh rotate continuously, without being affected by the TrackballControls (mouse movements)? Currently, my mesh only rotates when I move the mouse. Can someone help me identify what's causing this issue?
Here's the code snippet:
// Setting up basic Three components
var scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.z = 500;
// Configuring camera controls
var controls = new THREE.TrackballControls( camera );
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.2;
controls.panSpeed = 0.8;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;
controls.keys = [ 65, 83, 68 ];
controls.addEventListener( 'change', render );
// Initializing the renderer
var renderer = new THREE.WebGLRenderer( { antialias: false } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
// Adding a text element
var materialT1 = new THREE.MeshNormalMaterial();
var textGeom = new THREE.TextGeometry( 'Sitescope', {
font: 'optimer',
weight: 'normal',
size: 20
});
var textMesh = new THREE.Mesh( textGeom, materialT1 );
textMesh.position.set(-40,60,50)
scene.add( textMesh );
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
controls.handleResize();
render();
}
function animate() {
requestAnimationFrame( animate );
controls.update();
}
function render() {
textMesh.rotation.x += 0.05; // Adjust rotation speed here
renderer.render( scene, camera );
}
animate();
render();