Hey all,
Relatively new to three.js. So as i Understand stuff. object.position.x+=incrementVariable
is used inside an animateLoop
to animate an object. But what if I want to update the absolute position of an object inside a render loop rather than increment it, For Example: I have a variable by name valueX
which has the value of X-coordinate and is calculated and updated continuously inside the render
loop. I can’t seem to implement:
object.position.x = valueX
inside the render loop.
Hope i made sense… How do i go about it?
Thanks in advance!
I’m afraid it’s not clear what you are looking for. Do you mind creating live example for more clarity?
You Live Example is a perfect. In your animate
function:
function animate() {
requestAnimationFrame( animate );
mesh.position.x += 0.01;
mesh.position.y += 0.02;
renderer.render( scene, camera );
}
So here in this case, the position of mesh gets incremented by 0.01 and 0.02 in X
and Y
directions respectively. I want my render loop to be something like this
Instead of:
mesh.position.x += 0.01;
mesh.position.y += 0.02;
I want to update the absolute position of the mesh inside renderloop as shown in my fiddle like:
mesh.position.x = _x;