0

I have a cube, I know how to rotate it, but I want it rotates not around its center, but around one of its side. How can I do it? In the code below I change the positions of cubes via quaternions. But this code change positions of figures relative to its center, I need around one of cube side.

function applyMove(quaternions, cubes){ 
            cubes.forEach((cube, idx) => cube.quaternion.copy(quaternions[idx]));
}
gman
  • 100,619
  • 31
  • 269
  • 393
IWProgrammer
  • 155
  • 1
  • 9
  • @gman nooo, it is not an answer. There they group object, but if I bind them together, I will be able move all of them, but not a single one if I want – IWProgrammer Apr 23 '20 at 14:57
  • An alternative solution is demonstrated here: https://stackoverflow.com/questions/12835361/three-js-move-custom-geometry-to-origin/12835749#12835749 – Mugen87 Apr 23 '20 at 15:10
  • You don't have to put them under the same object. See [this](https://threejsfundamentals.org/threejs/lessons/threejs-scenegraph.html) – gman Apr 23 '20 at 18:35
  • How can you move by `quaternion` ? The quaternion is representing rotation not translation... You can create translation vector from it and add it to your transform matrix but that is not what your code suggest you're doing. Use [4x4 homogenous transform matrices](https://stackoverflow.com/a/28084380/2521214) Translate so the center of rotation becomes `(0,0,0)` , apply rotation and then translate back to original position. ... – Spektre Apr 24 '20 at 07:43

0 Answers0