ammo.js icon indicating copy to clipboard operation
ammo.js copied to clipboard

rotation not what is set

Open stevedekorte opened this issue 3 years ago • 1 comments

Example:

const a = [-0.0000064798259700182825, -0.0013201627880334854, 0.0000027575993044592906, 0.9999991059303284]
const t = new Ammo.btTransform();
t.setIdentity();
t.setRotation(new Ammo.btQuaternion(a[0], a[1], a[2], a[3]));
const r = t.getRotation()
// a is (very slightly) not equal to [r.x(), r.y(), r.z(), r.w()]

Any suggestions would be welcome. Thanks!

stevedekorte avatar Nov 07 '22 01:11 stevedekorte

Example:

const a = [-0.0000064798259700182825, -0.0013201627880334854, 0.0000027575993044592906, 0.9999991059303284]
const t = new Ammo.btTransform();
t.setIdentity();
t.setRotation(new Ammo.btQuaternion(a[0], a[1], a[2], a[3]));
const r = t.getRotation()
// a is (very slightly) not equal to [r.x(), r.y(), r.z(), r.w()]

Any suggestions would be welcome. Thanks!

const quat = new THREE.Quaternion(); quat.setFromUnitVectors(new THREE.Vector3(0, r++, 0), new THREE.Vector3( camDir.x, 0, camDir.z)); // for example

const ammoQuaternion = new Ammo.btQuaternion(quat.x, quat.y, quat.z, quat.w); let tempTransform = ball.userData.physicsBody.getWorldTransform(); tempTransform.setRotation(ammoQuaternion); ball.userData.physicsBody.setWorldTransform(tempTransform);

Ammo.destroy(ammoQuaternion);

suddenly4 avatar Dec 18 '24 01:12 suddenly4