Three.js 围绕给定轴和角度的轴点正确旋转对象
在Three.js中,似乎有相当多的旋转方式,我个人并不觉得很直观。参见示例Three.js 围绕给定轴和角度的轴点正确旋转对象,three.js,rotation,inverse-kinematics,Three.js,Rotation,Inverse Kinematics,在Three.js中,似乎有相当多的旋转方式,我个人并不觉得很直观。参见示例 当我将旋转应用于多个对象时,会得到非常奇怪的意外效果。例如,当我旋转已添加到彼此的对象并开始旋转父对象时,单个对象将由于彼此放置的位置不同而突然发生变化,而它们最初位于何处。我现在正在尝试分组,希望避免同样的效果 有关当前状态和源代码,请参阅 因此,我按照不同的API选项搜索适当的示例: 旋转 function renderScene() { stats.update(); //side1.rotat
当我将旋转应用于多个对象时,会得到非常奇怪的意外效果。例如,当我旋转已添加到彼此的对象并开始旋转父对象时,单个对象将由于彼此放置的位置不同而突然发生变化,而它们最初位于何处。我现在正在尝试分组,希望避免同样的效果 有关当前状态和源代码,请参阅 因此,我按照不同的API选项搜索适当的示例: 旋转
function renderScene() {
stats.update();
//side1.rotation.z += 0.02;
pivot.rotation.z += 0.02;
quaternion = new THREE.Quaternion().setFromAxisAngle( axisOfRotation, angleOfRotation );
object.rotation.setEulerFromQuaternion( quaternion );
object.rotateAroundWorldAxis(p, ax, r * Math.PI * 2 / frames);
object.rotateOnWorldAxis( axis, angle );
object.rotateAroundWorldAxis(p, ax, r * Math.PI * 2 / frames);
object.rotateOnWorldAxis( axis, angle );
object.rotateAroundWorldAxis(p, ax, r * Math.PI * 2 / frames);
object.rotateOnWorldAxis( axis, angle );
function renderScene() {
stats.update();
//side1.rotation.z += 0.02;
pivot.rotation.z += 0.02;
quaternion = new THREE.Quaternion().setFromAxisAngle( axisOfRotation, angleOfRotation );
object.rotation.setEulerFromQuaternion( quaternion );
this.mesh.updateMatrixWorld(); // important !
childPart.mesh.applyMatrix(new THREE.Matrix4().getInverse(this.mesh.matrixWorld))
cylinder.position.set( options.x, 15, options.z );
pivot.position.x=options.x;
pivot.position.z=options.z;
看
问题b)
看
关键是正确设置位置。而不是在本例中计算尺寸的提案
// create the pivot to rotate around/about
this.pivot = new THREE.Group();
this.pivot.add(this.mesh);
// shift the pivot position to fit my size + the size of the joint
this.pivot.position.set(
x,
y + this.size.y / 2 + this.pivotr,
z + this.size.z / 2
);
// reposition the mesh accordingly
this.mesh.position.set(0, this.size.y / 2, 0);
这是迄今为止我发现的最有帮助的答案。请参阅更详细的讨论和示例项目