Answer the question
In order to leave comments, you need to log in
ThreeJs object movement around its axis?
How to make the movement of each object around its own axis?
It turns out for some reason only around the center of the scene.
For example, this is how, object.rotation.y += 1;
in theory, the object should rotate around its axis, but it rotates relative to the center of the scene.
Example
In the example, you can see how the Y-axis of the cube changes, but it does not rotate around its axis.
Answer the question
In order to leave comments, you need to log in
I did something like this, unfortunately I don’t remember all the subtleties
, this example was made to implement bones, but the methods that were used in it might help.
// получаем мировую матрицу родительского объекта
var m = E.uid[obj.eparent].mWorld.clone();
// делаем параллельный перенос
m.multiply(new THREE.Matrix4().setPosition(obj.pos));
// поворачиваем
m.multiply(new THREE.Matrix4().makeRotationFromQuaternion(obj.ang));
// устанавливаем опорную точку
m.multiply(new THREE.Matrix4().setPosition(obj.basis));
// сохраняем трансформированную матрицу объекта для потомка
obj.mWorld = m.clone();
// масштабируем
m.scale(obj.escale);
// сбрасываем
obj.matrix.identity();
// применяем трансформированную матрицу к объекту
obj.applyMatrix(m.clone());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question