-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
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
RapierPhysics: Rapier physics example Improvement #28203
base: dev
Are you sure you want to change the base?
Conversation
### Description - Migrate the **old function** implementation to the **class** version - `Expose` more Rapier properties (`rigidBody`, `collider`, ...) - Store more `RAPIER` props in the `WeakMap` - Add comments (with types support) using `JsDoc`
### Description - Use `addToWorld` instead of `addSceneToWorld` - Add Window `keyboard` event to apply impulse to objects (to shake)
afcd62e
to
5a2d9fb
Compare
Love the shake! |
I just pushed a small fix for the |
const radius = parameters.radius !== undefined ? parameters.radius : 1; | ||
return RAPIER.ColliderDesc.ball( radius ); | ||
|
||
export class Physic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be "Physics" instead of "Physic"?
There are a few other instances of "Physic" in other variable names...
matrix_scale.mp4Recently, I used the physics helper to build the above example. I had to update the code a little on my end to be able to In the for (let j = 0; j < bodies.length; j++) {
const physicProperties = bodies[j];
const position = new Vector3().copy(physicProperties.rigidBody.translation());
this._quaternion.copy(physicProperties.rigidBody.rotation());
const scale = (physicProperties.rigidBody.userData as { scale?: Vector3 })?.scale ?? this._scale; // <--- This line
this._matrix.compose(position, this._quaternion, scale);
this._matrix.toArray(array, j * 16);
} I passed a It could help others by being able to control the scale!
|
Agree and it makes sense! |
Hey @mrdoob, I just update it I added a button to shake. And I updated the We can now do the following: boxeMatrix.scale( new THREE.Vector3( 2,2,2 ) ); // Selected box matrix
boxes.setMatrixAt( i, mat ); And the helper will use the 2 2 2 for that specific Matrix |
Don't forget this! Perhaps do a Ctrl+H to replace |
Description
I was working on one of my projects based on the
Rapier3D.js
, and I noticed that @mrdoob recently added an example usingRapier
andInstancedMesh
which were exactly what I was working on.Unfortunately, the existing Rapier addon was a bit restrictive to me at some point (and in the example page as well).
collider
,colliderDesc
, ...;rigidBody
, and we're necessarily retrained to use it to get amesh
meshes
Because I updated it on my side and where using it, I decided to share my version based and following the original version of the RapierPhysics.
What are the changes
addToWorld
instead ofaddSceneToWorld
| Example preview.OrbitControl
to auto-rotate | Example preview.keyboard
event to apply impulse to objects (to shake) | Example preview.addToWorld()
method to add only one object (and return a bunch of Rapier properties).RapierPhysics
but expose theRapierPhysics.step()
method;RapierPhysics
function implementation to the class version.rigidBody
,collider
, ...). accessible from theWeakMap
storeJsDoc
.Here's the updated version coming with this PR
rapier-instancing.-.Made.with.Clipchamp.mp4