我正在使用Three.js四元数,并且无法保存我的对象的四元数属性。JavaScript对象属性不会更新变量集
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 =新THREE.Quaternion(),它不保存四元数的对象。当我看到我得到的输出时
THREE.Quaternion (w:1 x:0 y:0 z:0)
为什么你认为这是发生?
您是否调用了'initializeScene()'函数? – adricadar
是的,它被调用是因为我从console.log(this.rotationGroup.quaternion)获得了输出,但是它不是在前一行中设置的值。 – Kyle
另外,如果我创建一个名为var test = new THREE.Quaternion(3,3,3,3)和console.log(test)的变量,它可以正常工作。 – Kyle