How can I use quaternions?
Below is an example of using quaternion in Three.js. http://jsdo.it/cx20/qqSi
// rotate
mesh1.rotation.x += Math.PI / 180;
mesh1.rotation.y += Math.PI / 180;
mesh1.rotation.z += Math.PI / 180;
// quaternion
var axis = new THREE.Vector3(1,1,1).normalize();
angle += Math.PI / 180;
var q = new THREE.Quaternion();
q.setFromAxisAngle(axis,angle);
mesh2.quaternion.copy(q);
How do I write the code in CZPG.js to do the same thing as above?
@cx20 Hi.
I am not implement many quaternion functions right now, but you can set quaternion for Model and Node, like
model.quaternion = [0,0,0,1];
sceneNode.quaternion = [0,0,0,1];
So maybe you have to compute target quaternion by yourself right now...
I will mention you after implement quaternion functions :)
@PrincessGod I tried using model.quaternion as a trial. However, it seems to be an infinite loop.
http://jsdo.it/cx20/MZ4J
model.quaternion = [q.x, q.y, q.z, q.w];
czpg.js:1
Uncaught RangeError: Maximum call stack size exceeded
at Model.setQuaternion (VM261 czpg.js:1)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
at Model.setQuaternion (VM261 czpg.js:4416)
setQuaternion( ...args ) {
if ( args[ 0 ] instanceof Transform )
return this.setQuaternion( ...( args[ 0 ].quaternion.getArray() ) );
this.setQuaternion( ...args ); // infinite loop?
return this;
},
@cx20 ha! Another bug!
fixed 09174620778f9605fc3b7cf91786cb5a8cc7b20a
@PrincessGod Thanks! I confirmed that it will function properly.
http://jsdo.it/cx20/MZ4J

Also, I added the sample of this CZPG.js to the following physical operation sample list. https://qiita.com/cx20/items/3ebed669fb9c9e797935
I think that I will transplant other samples in the future.