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

Unable to retrieve locked rotation and locked translation state of a created rigid body #292

Open
iamarkdev opened this issue Sep 10, 2024 · 3 comments

Comments

@iamarkdev
Copy link

I've dug through the docs and the type definition files, I need to determine the current rotation and translation lock state of an a rigid body that has already been added to the simulation (RigidBody, not RigidBodyDesc).

There does not seem to be a way to get this information from the RigidBody type. Is this intentional or a feature not yet supported in the JS / TS api?

@LeXXik
Copy link

LeXXik commented Sep 10, 2024

@iamarkdev
Copy link
Author

iamarkdev commented Sep 10, 2024

I've dug through the docs and the type definition files

?

https://rapier.rs/javascript3d/classes/RigidBody.html#translation https://rapier.rs/javascript3d/classes/RigidBody.html#rotation

This is the rotation and translation vector/quat, not if translations or rotations for a given axes are locked. I need to know what axes for rotations and translations are locked.

@doppl3r
Copy link

doppl3r commented Sep 10, 2024

I recommend you keep your rigidBodyDesc and rigidBody components together in an "Entity" class so you can access their properties after being created. Here is an example I've created for storing the components in an Entity class:
https://github.com/doppl3r/kinematic-character-controller-example/blob/master/src/js/entities/Entity.js

The "locked" or "enabled" states are stored in the rigidBodyDesc object and can be accessed directly:

// Locked translation states
rigidBodyDesc.translationsEnabledX;
rigidBodyDesc.translationsEnabledY;
rigidBodyDesc.translationsEnabledZ;

// Locked rotation states
rigidBodyDesc.rotationsEnabledX;
rigidBodyDesc.rotationsEnabledY;
rigidBodyDesc.rotationsEnabledZ; 

You can modify these by running these functions:

rigidBodyDesc.enabledRotations(true, true, true);
rigidBodyDesc.enabledTranslations(true, true, true);

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

3 participants