As represented in the image below, I have a THREE.Scene
with a simple cube. Attached to the cube is a CANNON.Body
for Physics (represented in the green wireframe).
The CANNON.Body
is offset from the cube by a couple of units. For rotation, this offset will be the radius.
When I rotate the cube, I want the CANNON.Body
to rotate around the cube based on the angle and radius. On the right hand side of the image, I rotated the cube with an angle of 45 degrees (I also have radians available). However, the CANNON.Body
does not rotate around the cube, only around it's own center. I need it to rotate around the cube for all axes x, y and z.
Is there a built-in function in THREE.js
or should I use my own mathematical equation for this? If so, what would that be?
Thanks!
P.S. I've seen solutions for pure THREE.js
Scene's where the geometry is translated to manipulate the pivot point. Since I don't have geometry in my CANNON.Body
, this will not be possible.
Object3D
to the scene, but leave its position at the center of rotation. Add theCANNON.Body
not to the scene but to thatObject3D
. Move theCANNON.Body
as you did before to shift it, and instead rotate theObject3D
. – LeeftTHREE.Math
has someradToDeg
anddegToRad
helpers). There's nothing wrong with creating some (otherwise empty)Object3D
to group or offset things in your scene though, and in fact the scene itself is essentially anObject3D
which has severalObject3D
as its children (such as your lights, objects, etc). – Leeft