Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rotation not what is set #407

Open
stevedekorte opened this issue Nov 7, 2022 · 1 comment
Open

rotation not what is set #407

stevedekorte opened this issue Nov 7, 2022 · 1 comment

Comments

@stevedekorte
Copy link

stevedekorte commented Nov 7, 2022

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!

@suddenly4
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants