How to move a mesh in x,y,z as a rigid body?

Is the following valid?

myX = myMesh.position.getComponent(0);
myY = myMesh.position.getComponent(1);
myZ = myMesh.position.getComponent(2);

myX = myX + deltaX;
myY = myY + deltaY;
myZ = myZ + deltaZ;

myMesh.position.set(myX, myY, myZ);

Does this take effect automatically or are various update, needUpdate, etc. calls also needed?

OLDMAN

Im guessing you want to update the position based on time(delta).

If so, be sure to make the updates withing the animation loop. (Google threejs animation loop to really understand where to start).

If not, then whatever you update will run once and thats it. You might even miss the change completely.

rigidbody as in a physics simulation? if so then you do not move it because physics is already moving and you would have two places pulling on one object. you would move it indirectly with an impulse.

Yes, it is.

Yes, the position will be changed immediately. However, you will not see the change until the next render. Also, if you work with matrices, they might not be updated until render time or until you force their update.

For a general animation nothing more is needed. In some special cases (e.g. if you need the matrix of the transformation), you need to call methods like .updateMatrix, .updateMatrixWorld and .updateWorldMatrix.

Also, you could write shorter code:

myX = myMesh.position.x;
myY = myMesh.position.y;
myZ = myMesh.position.z;

myX = myX + deltaX;
myY = myY + deltaY;
myZ = myZ + deltaZ;

myMesh.position.set(myX, myY, myZ);

or:

myX = myMesh.position.x + deltaX;
myY = myMesh.position.y + deltaY;
myZ = myMesh.position.z + deltaZ;

myMesh.position.set(myX, myY, myZ);

or even:

myMesh.position.x += deltaX;
myMesh.position.y += deltaY;
myMesh.position.z += deltaZ;

and if the deltas and in a vector, then:

myMesh.position.add( delta );