【发布时间】:2017-09-11 17:52:49
【问题描述】:
我正在使用 Three.js 四元数,我无法为四元数保存我的对象属性。
GLmol.prototype.initializeScene = function() {
this.scene = new THREE.Scene();
this.scene.fog = new THREE.Fog(this.bgColor, 100, 200);
this.modelGroup = new THREE.Object3D();
this.rotationGroup = new THREE.Object3D();
this.rotationGroup.useQuaternion = true;
this.rotationGroup.quaternion = new THREE.Quaternion(0.7235552851867599, -0.004228243257681183 , 0.004646778667168487, 0.6902378421133389);
console.log(this.rotationGroup.quaternion)
this.rotationGroup.add(this.modelGroup);
this.scene.add(this.rotationGroup);
this.setupLights(this.scene);
};
我遇到的问题是,当我设置 this.rotationGroup.quaternion = new THREE.Quaternion() 时,它不会保存 Quaternion 对象。当我查看输出时,我得到了
THREE.Quaternion (w:1 x:0 y:0 z:0)
你认为为什么会这样?
【问题讨论】:
-
你调用
initializeScene()函数了吗? -
是的,之所以调用它是因为我从 console.log(this.rotationGroup.quaternion) 获得了输出,但是它不是之前在该行中设置的值。
-
另外,如果我创建一个名为 var test = new THREE.Quaternion(3, 3, 3, 3) 和 console.log(test) 的变量,它可以正常工作。
标签: javascript three.js