This release updates to Rapier 0.11.1 which contains several bug fixes.
- Fix a bug causing large moving colliders to miss some collisions after some time.
- Fix invalid forces generated by contacts with position-based kinematic bodies.
- Fix a bug where two colliders without parent would not have their collision computed even if the appropriate flags were set.
- Fixed an issue where a collider with no parent attached would not be created under some conditions.
This release was broken and has been unpublished.
- The
collider.halfExtents()
methods now returns a valid value for round cuboids.
- The
rapier-compat
packages don’t need theBuffer
polyfill anymore.
- Update to use Rapier 0.11.0.
- The
rapier-compat
packages are now generated by rollup.
The typescripts bindings for Rapier have a brand new user-guide covering all the features of the physics engine!
- The
World.castRay
andWorld.castRayAndGetNormal
methods have a different signature now, making them more flexible. - Rename
ActiveHooks::FILTER_CONTACT_PAIR
toActiveHooks.FILTER_CONTACT_PAIRS
. - Rename
ActiveHooks::FILTER_INTERSECTION_PAIR
toActiveHooks.FILTER_INTERSECTION_PAIRS
. - Rename
BodyStatus
toRigidBodyType
. - Rename
RigidBody.bodyStatus()
toRigidBody.bodyType()
. - Rename
RigidBodyDesc.setMassProperties
toRigidBodyDesc.setAdditionalMassProperties
. - Rename
RigidBodyDesc.setPrincipalAngularInertia
toRigidBodyDesc.setAdditionalPrincipalAngularInertia
. - Rename
ColliderDesc.setIsSensor
to `ColliderDesc.setSensor.
- Add
Ray.pointAt(t)
that conveniently computesray.origin + ray.dir * t
. - Add access to joint motors by defining each joint with its own class deriving from
Joint
. Each joint now have its relevant motor configuration methods:configurMotorModel, configureMotorVelocity, configureMotorPosition, configureMotor
. - Add
World.collidersWithAabbIntersectingAabb
for retrieving the handles of all the colliders intersecting the given AABB. - Add many missing methods for reading/modifying a rigid-body state after its creation:
RigidBody.lockTranslations
RigidBody.lockRotations
RigidBody.restrictRotations
RigidBody.dominanceGroup
RigidBody.setDominanceGroup
RigidBody.enableCcd
- Add
RigidBodyDesc.setDominanceGroup
for setting the dominance group of the rigid-body being built. - Add many missing methods for reading/modifying a collider state after its creation:
Collider.setSendor
Collider.setShape
Collider.setRestitution
Collider.setFriction
Collider.frictionCombineRule
Collider.setFrictionCombineRule
Collider.restitutionCombineRule
Collider.setRestitutionCombineRule
Collider.setCollisionGroups
Collider.setSolverGroups
Collider.activeHooks
Collider.setActiveHooks
Collider.activeEvents
Collider.setActiveEvents
Collider.activeCollisionTypes
Collider.setTranslation
Collider.setTranslationWrtParent
Collider.setRotation
Collider.setRotationWrtParent
- Add
ColliderDesc.setMassProperties
for setting explicitly the mass properties of the collider being built (instead of relying on density).
- Colliders are no longer required to be attached to a rigid-body. Therefore, the second argument of
World.createCollider
is now optional.
- The
BodyStatus::Kinematic
variant has been replaced byBodyStatus::KinematicPositionBased
andBodyStatus::KinematicVelocityBased
. Position-based kinematic bodies are controlled by setting (at each frame) the next kinematic position of the rigid-body (just like before), and the velocity-based kinematic bodies are controlled by setting (at each frame) the velocity of the rigid-body. - The
RigidBodyDesc.newKinematic
has been replaced byRigidBodyDesc.newKinematicPositionBased
andRigidBodyDesc.newKinematicVelocityBased
in order to build a position-based or velocity-based kinematic body. - All contact and intersection events are now disabled by default. The can be enabled for each collider individually
by setting its
ActiveEvents
:ColliderDesc.setActiveEvents(ActiveEvents.PROXIMITY_EVENTS | ActiveEvents.ContactEvents)
.
- It is now possible to read contact information from the narrow-phase using:
world.narrowPhase.contactsWith(collider1, callback)
world.narrowPhase.intersectionsWith(collider1, callback)
world.narrowPhase.contactPair(collider1, collider2, callback)
world.narrowPhase.intersectionPair(collider1, collider2, callback)
- It is now possible to apply custom collision-detection filtering rules (more flexible than collision groups)
based on a JS object by doing the following:
- Enable physics hooks for the colliders you want the custom rules to apply to:
ColliderDesc.setActiveHooks(ActiveHooks.FILTER_CONTACT_PAIR | ActiveHooks.FILTER_CONTACT_PAIR)
- Define an object that implements the
PhysicsHooks
interface. - Pass and instance of your physics hooks object as the second argument of the
World.step
method.
- Enable physics hooks for the colliders you want the custom rules to apply to:
- It is now possible to enable collision-detection between two non-dynamic bodies (e.g. between a kinematic
body and a static body) by setting the active collision types of a collider:
ColliderDesc.setActiveCollisionTypes(ActiveCollisionTypes.ALL)
- Fix a crash when loading the WASM file on iOS safari.
- Fix a crash that could happen after adding and then removing a collider right away, before stepping the simulation.
- Fix a determinism issue after snapshot restoration.
- Significantly improve the broad-phase performances when very large colliders are used.
- Add
RigidBodyDesc::setCcdEnabled
to enable Continuous Collision Detection (CCD) for this rigid-body. CCD ensures that a fast-moving rigid-body doesn't miss a collision (the tunneling problem).
- Removed multiple fields from
IntegrationParameters
. These were unused parameters.
- Fix a bug in ball/convex shape collision detection causing the ball to ignore penetrations with depths greater than its radius.
Breaking changes:
- Removed
IntegrationParameters.restitutionVelocityThreshold
andIntegrationParameters.set_restitutionVelocityThreshold
.
- Fix crash happening when creating a collider with a
ColliderDesc.convexHull
shape. - Actually remove the second argument of
RigidBodyDesc.setMass
as mentioned in the 0.3.0 changelog. - Improve snapshotting performances.
- Added a
RAPIER.version()
function at the root of the package to retrieve the version of Rapier as a string.
Several geometric queries have been added (the same methods have been added to the
QueryPipeline
too):
World.intersectionsWithRay
: get all colliders intersecting a ray.World.intersectionWithShape
: get one collider intersecting a shape.World.projectPoint
: get the projection of a point on the closest collider.World.intersectionsWithPoint
: get all the colliders containing a point.World.castShape
: get the first collider intersecting a shape moving linearly (aka. sweep test).World.intersectionsWithShape
: get all the colliders intersecting a shape.
Several new shape types are now supported:
RoundCuboid
,Segment
,Triangle
,RoundTriangle
,Polyline
,ConvexPolygon
(2D only),RoundConvexPolygon
(2D only),ConvexPolyhedron
(3D only),RoundConvexPolyhedron
(3D only),RoundCone
(3D only).
It is possible to build ColliderDesc
using these new shapes:
ColliderDesc.roundCuboid
,ColliderDesc.segment
,ColliderDesc.triangle
,ColliderDesc.roundTriangle
,ColliderDesc.convexHull
,ColliderDesc.roundConvexHull
,ColliderDesc.Polyline
,ColliderDesc.convexPolyline
(2D only),ColliderDesc.roundConvexPolyline
(2D only),ColliderDesc.convexMesh
(3D only),ColliderDesc.roundConvexMesh
(3D only),ColliderDesc.roundCone
(3D only).
It is possible to specify different rules for combining friction and restitution coefficients of the two colliders involved in a contact with:
ColliderDesc.frictionCombineRule
, andColliderDesc.restitutionCombineRule
.
Various RigidBody-related getter and setters have been added:
RigidBodyDesc.newStatic
,RigidBodyDesc.newDynamic
, andRigidBodyDesc.newKinematic
are new static method, short equivalent tonew RigidBodyDesc(BodyStatus.Static)
, etc.RigidBodyDesc.setGravityScale
,RigidBody.gravityScale
,RigidBody.setGravityScale
to get/set the scale factor applied to the gravity affecting a rigid-body. Setting this to 0.0 will make the rigid-body ignore gravity.RigidBody.setLinearDamping
andRigidBody.setAngularDamping
to set the linear and angular damping of the rigid-body.RigidBodyDesc.restrictRotations
to prevent rotations along specific coordinate axes. This replaces the three boolean arguments previously passed to.setPrincipalAngularInertia
.
Breaking changes related to rigid-bodies:
- The
RigidBodyDesc.setTranslation
andRigidBodyDesc.setLinvel
methods now take the components of the translation directly as arguments instead of a singleVector
. - The
RigidBodyDesc.setMass
takes only one argument now. UseRigidBodyDesc.lockTranslations
to lock the translational motion of the rigid-body. - The
RigidBodyDesc.setPrincipalAngularInertia
no longer have boolean parameters to lock rotations. UseRigidBodyDesc.lockRotations
orRigidBodyDesc.restrictRotations
to lock the rotational motion of the rigid-body.
Breaking changes related to colliders:
- The
ColliderDesc.setTranslation
method now take the components of the translation directly as arguments instead of a singleVector
. - The
roundRadius
fields have been renamedborderRadius
. - The
RawShapeType.Polygon
no longer exists. For a 2D convex polygon, useRawShapeType.ConvexPolygon
instead. - All occurrences of
Trimesh
have been replaced byTriMesh
(note the change in case).
Breaking changes related to events:
- Rename all occurrences of
Proximity
toIntersection
. - The
Proximity
enum has been removed. - The
drainIntersectionEvents
(previously calleddrainProximityEvent
) will now call a callback with arguments(number, number, boolean)
: two collider handles, and a boolean indicating if they are intersecting.
Breaking changes related to scene queries:
- The
QueryPipeline.castRay
method now takes two additional parameters: a boolean indicating if the ray should not propagate if it starts inside of a shape, and a bit mask indicating the group the ray is part of and these it interacts with. - The
World.castRay
andQueryPipeline.castRay
now return a struct of typeRayColliderToi
which no longer contains the normal at the hit point. Use the new methodsWorld.castRayAndGetNormal
orQueryPipeline.castRayAndGetNormal
in order to retrieve the normal too.
- Fix a bug where
RigidBodyDesc.setMass(m)
withm != 0.0
would cause the rotations of the created rigid-body to be locked.
- Add a boolean argument to
RigidBodyDesc.setMass
to indicate if the mass contribution of colliders should be enabled for this rigid-body or not. - Add a
RigidBody.lockRotations
method to lock all the rigid-body rotations resulting from forces. - Add a
RigidBody.lockTranslations
method to lock all the rigid-body translations resulting from forces. - Add a
RigidBody.setPrincipalAngularInertia
method to set the principal inertia of the rigid-body. This gives the ability to lock individual rotation axes of one rigid-body.
- Fix a bug where removing when immediately adding a collider would cause collisions to fail with the new collider.
- Fix a regression causing some colliders added after a few timesteps not to be properly taken into account.
- Fix a bug where removing a collider would result in a rigid-body being removed instead.
- Fix a determinism issue when running simulation on the Apple M1 processor.
- Add
JointParams.prismatic
andJointParams.fixed
for creating prismatic joint or fixed joints.
- Add
RigidBody.setLinvel
to set the linear velocity of a rigid-body. - Add
RigidBody.setAngvel
to set the angular velocity of a rigid-body.
- Add
RigidBodySet.remove
to remove a rigid-body from the set. - Add
ColliderSet.remove
to remove a collider from the set. - Add
JointSet.remove
to remove a joint from the set. - Add
RigidBodyDesc.setLinearDamping
andRigidBodyDesc.setAngularDamping
for setting the linear and angular damping coefficient of the rigid-body to create. - Add
RigidBodyDesc.setMass
, andRigidBodyDesc.setMassProperties
for setting the initial mass properties of a rigid-body. - Add
ColliderDesc.setCollisionGroups
to use bit-masks for collision filtering between some pairs of colliders. - Add
ColliderDesc.setSolverGroups
to use bit-masks for making the constraints solver ignore contacts between some pairs of colliders. - Add
ColliderDesc.heightfield
to build a collider with an heightfield shape. - Add
ColliderDesc.trimesh
to build a collider with a triangle mesh shape.
- Reduce snapshot size and computation times.
- Fix bug causing an unbounded memory usage when an objects falls indefinitely.
- Fix wrong result given by
RigidBody.isKinematic()
andRigidBody.isDynamic()
.
- Add the support for round cylinder colliders (i.e. cylinders with round edges).
- Add the support for cone, cylinder, and capsule colliders.
- Fix regression causing the density and
isSensor
properties ofColliderDesc
to not be taken into account. - Throw an exception when the parent handle passed to
world.createCollider
is not a number.
This is a significant rewrite of the JavaScript bindings for rapier. The objective of this rewrite is to make the API closer to Rapier's and remove most need for manual memory management.
- Calling
.free()
is now required only for objects that live for the whole duration of the simulation. This means that it is no longer necessary to.free()
vectors, rays, ray intersections, colliders, rigid-bodies, etc. Object that continue to require an explicit.free()
are:World
andEventQueue
.- Or, if you are not using the
World
directly:RigidBodySet
,ColliderSet
,JointSet
,IntegrationParameters
,PhysicsPipeline
,QueryPipeline
,SerializationPipeline
, andEventQueue
.
- Collider.parent() now returns the
RigidBodyHandle
of its parent (instead of theRigidBody
directly). - Colliders are now built with
world.createCollider
, i.e.,body.createCollider(colliderDesc)
becomesworld.createCollider(colliderDesc, bodyHandle)
. - Shape types are not an enumeration instead of strings:
ShapeType.Ball
andShapeType.Cuboid
instead of"ball"
and"cuboid"
. collider.handle
is now a field instead of a function.body.handle
is now a field instead of a function.- The world's gravity is now a
Vector
instead of individual components, i.e.,let world = new RAPIER.World(x, y, z);
becomeslet world = new RAPIER.World(new RAPIER.Vector3(x, y, z))
. - Most methods that took individual components as argument (
setPosition
,setKinematicPosition
,setRotation
, etc.) now take aVector
orRotation
structure instead. For examplerigid_body.setKinematicPosition(x, y, z)
becomesrigid_body.setKinematicPosition(new RAPIER.Vector3(x, y, z))
. world.stepWithEvents
becomesworld.step
(the event queue is the last optional argument).RigidBodyDesc
andColliderDesc
now use the builder pattern. For examplelet bodyDesc = new RAPIER.RigidBodyDesc("dynamic"); bodyDesc.setTranslation(x, y, z)
becomesnew RigidBodyDesc(BodyStatus.Dynamic).setTranslation(new Vector(x, y, z))
.ray.dir
andray.origin
are now fields instead of methods.- 2D rotations are now just a
number
instead of aRotation
struct. So instead of doingrotation.angle
, single use the number as the rotation angle. - 3D rotations are now represented by the interface
Rotation
(with fields{x,y,z,w}
) or the classQuaternion
. Any object with these{x, y, z, w}
fields can be used wherever aRotation
is required. - 2D vectors are now represented by the interface
Vector
(with fields{x,y}
) or the classVector2
). Any object with these{x,y}
fields can be used wherever aVector
is required. - 3D vectors are now represented by the interface
Vector
(with fields{x,y,z}
) or the classVector3
). Any object with these{x,y,z}
fields can be used wherever aVector
is required.
See changelogs for v0.2.1 instead. The NPM package for v0.2.0 were missing some files.
- Fix bug when ghost forces and/or crashes could be observed when a kinematic body touches a static body.
- Fix kinematic rigid-body not waking up dynamic bodies it touches.
- Added
new Ray(origin, direction)
constructor instead ofRay.new(origin, direction)
.
- Fix crash when removing a kinematic rigid-body from the World.
- Fix issues where force application functions took ownership of the JS vector, preventing the user from freeing
with
Vector.free()
afterwards.
- Added
rigidBody.setNextKinematicTranslation
to set the translation of a kinematic rigid-body at the next timestep. - Added
rigidBody.setNextKinematicRotation
to set the rotation of a kinematic rigid-body at the next timestep. - Added
rigidBody.predictedTranslation
to get the translation of a kinematic rigid-body at the next timestep. - Added
rigidBody.predictedRotation
to set the rotation of a kinematic rigid-body at the next timestep. - Added
Ray
andRayIntersection
structures for ray-casting. - Added
world.castRay
to compute the first hit of a ray with the physics scene. - Fix a bug causing a kinematic rigid-body not to teleport as expected after a
rigidBody.setPosition
.
- Added
world.removeCollider(collider)
to remove a collider from the physics world. - Added
colliderDesc.setTranslation(...)
to set the relative translation of the collider to build wrt. the rigid-body it is attached to. - Added
colliderDesc.setRotation(...)
to set the relative rotation of the collider to build wrt. the rigid-body it is attached to.
- Fix a bug causing a crash when the broad-phase proxy handles were recycled.
- Fix a determinism problem that could cause rigid-body handle allocation to be non-deterministic after a snapshot restoration.
- Added
world.getCollider(handle)
that retrieves a collider from its integer handle. - Added
joint.handle()
that returns the integer handle of the joint.
- Added
world.forEachRigidBodyHandle(f)
to apply a closure on the integer handle of each rigid-body on the world. - Added
world.forEachActiveRigidBody(f)
to apply a closure on each rigid-body on the world. - Added
world.forEachActiveRigidBodyHandle(f)
to apply a closure on the integer handle of each rigid-body on the world. - Added
rigidBody.applyForce
,.applyTorque
,.applyImpulse
,.applyTorqueImpulse
,.applyForceAtPoint
, and.applyImpulseAtPoint
to apply a manual force or torque to a rigid-body. - Added the
EventQueue
structure that can be used to collect and iterate through physics events. - Added the
Proximity
enum that represents the proximity state of a sensor collider and another collider. - Added the
world.stepWithEvents(eventQueue)
which executes a physics timestep and collects the physics events into the given event queue.
- Added
world.getRigidBody(handle)
to retrieve a rigid-body from its handle. - Added
world.getJoint(handle)
to retrieve a joint from its handle. - Added
rigidBody.rotation()
to retrieve its world-space orientation as a quaternion. - Added
rigidBody.setTranslation(...)
to set the translation of a rigid-body. - Added
rigidBody.setRotation(...)
to set the orientation of a rigid-body. - Added
rigidBody.wakeUp()
to manually wake up a rigid-body. - Added
rigidBody_desc.setRotation(...)
to set tho orientation of the rigid-body to be created.
- Added
world.removeRigidBody(...)
to remove a rigid-body from the world.