The maximum velocity iterations the velocity-based constraint solver can make to attempt to remove the energy introduced by constraint stabilization.
Sets the maximum number of velocity iterations for stabilization (default: 1).
The new maximum number of velocity iterations.
The maximum velocity iterations the velocity-based friction constraint solver can make.
Sets the maximum number of velocity iterations for friction (default: 8).
The greater this value is, the most realistic friction will be. However a greater number of iterations is more computationally intensive.
The new maximum number of velocity iterations.
The maximum velocity iterations the velocity-based force constraint solver can make.
Sets the maximum number of velocity iterations (default: 4).
The greater this value is, the most rigid and realistic the physics simulation will be. However a greater number of iterations is more computationally intensive.
The new maximum number of velocity iterations.
The current simulation timestep.
Sets the new simulation timestep.
The simulation timestep governs by how much the physics state of the world will be integrated. A simulation timestep should:
The timestep length, in seconds.
Find the closest intersection between a ray and the physics world.
The ray to cast.
The maximum time-of-impact that can be reported by this cast. This effectively
limits the length of the ray to ray.dir.norm() * maxToi
.
If false
then the ray will attempt to hit the boundary of a shape, even if its
origin already lies inside of a shape. In other terms, true
implies that all shapes are plain,
whereas false
implies that all shapes are hollow for this ray-cast.
Find the closest intersection between a ray and the physics world.
This also computes the normal at the hit point.
The ray to cast.
The maximum time-of-impact that can be reported by this cast. This effectively
limits the length of the ray to ray.dir.norm() * maxToi
.
If false
then the ray will attempt to hit the boundary of a shape, even if its
origin already lies inside of a shape. In other terms, true
implies that all shapes are plain,
whereas false
implies that all shapes are hollow for this ray-cast.
Casts a shape at a constant linear velocity and retrieve the first collider it hits. This is similar to ray-casting except that we are casting a whole shape instead of just a point (the ray origin).
The initial position of the shape to cast.
The initial rotation of the shape to cast.
The constant velocity of the shape to cast (i.e. the cast direction).
The shape to cast.
The maximum time-of-impact that can be reported by this cast. This effectively
limits the distance traveled by the shape to shapeVel.norm() * maxToi
.
If set to false
, the linear shape-cast won’t immediately stop if
the shape is penetrating another shape at its starting point and its trajectory is such
that it’s on a path to exist that penetration state.
Finds the handles of all the colliders with an AABB intersecting the given AABB.
The center of the AABB to test.
The half-extents of the AABB to test.
The callback that will be called with the handles of all the colliders currently intersecting the given AABB.
Iterates through all the contact manifolds between the given pair of colliders.
The first collider involved in the contact.
The second collider involved in the contact.
Closure that will be called on each contact manifold between the two colliders. If the second argument
passed to this closure is true
, then the contact manifold data is flipped, i.e., methods like localNormal1
actually apply to the collider2
and fields like localNormal2
apply to the collider1
.
Enumerates all the colliders potentially in contact with the given collider.
The second collider involved in the contact.
Closure that will be called on each collider that is in contact with collider1
.
Creates a new character controller.
The artificial gap added between the character’s chape and its environment.
Creates a new collider.
The description of the collider.
The rigid-body this collider is attached to.
Creates a new impulse joint from the given joint descriptor.
The description of the joint to create.
The first rigid-body attached to this joint.
The second rigid-body attached to this joint.
Should the attached rigid-bodies be awakened?
Creates a new multibody joint from the given joint descriptor.
The description of the joint to create.
The first rigid-body attached to this joint.
The second rigid-body attached to this joint.
Should the attached rigid-bodies be awakened?
Creates a new rigid-body from the given rigd-body descriptior.
The description of the rigid-body to create.
Computes all the lines (and their colors) needed to render the scene.
Applies the given closure to each active rigid-body managed by this physics world.
After a short time of inactivity, a rigid-body is automatically deactivated ("asleep") by the physics engine in order to save computational power. A sleeping rigid-body never moves unless it is moved manually by the user.
The function to apply to each active rigid-body managed by this physics world. Called as f(collider)
.
Release the WASM memory occupied by this physics world.
All the fields of this physics world will be freed as well,
so there is no need to call their .free()
methods individually.
Retrieves a collider from its handle.
The integer handle of the collider to retrieve.
Retrieves an impulse joint from its handle.
The integer handle of the impulse joint to retrieve.
Retrieves an multibody joint from its handle.
The integer handle of the multibody joint to retrieve.
Retrieves a rigid-body from its handle.
The integer handle of the rigid-body to retrieve.
Gets the handle of up to one collider intersecting the given shape.
The position of the shape used for the intersection test.
The orientation of the shape used for the intersection test.
The shape used for the intersection test.
Find all the colliders containing the given point.
The point used for the containment test.
A function called with the handles of each collider with a shape
containing the point
.
Cast a ray and collects all the intersections between a ray and the scene.
The ray to cast.
The maximum time-of-impact that can be reported by this cast. This effectively
limits the length of the ray to ray.dir.norm() * maxToi
.
If false
then the ray will attempt to hit the boundary of a shape, even if its
origin already lies inside of a shape. In other terms, true
implies that all shapes are plain,
whereas false
implies that all shapes are hollow for this ray-cast.
The callback called once per hit (in no particular order) between a ray and a collider.
If this callback returns false
, then the cast will stop and no further hits will be detected/reported.
Retrieve all the colliders intersecting the given shape.
The position of the shape to test.
The orientation of the shape to test.
The shape to test.
A function called with the handles of each collider intersecting the shape
.
Find the projection of a point on the closest collider.
The point to project.
If this is set to true
then the collider shapes are considered to
be plain (if the point is located inside of a plain shape, its projection is the point
itself). If it is set to false
the collider shapes are considered to be hollow
(if the point is located inside of an hollow shape, it is projected on the shape's
boundary).
Find the projection of a point on the closest collider.
The point to project.
Removes a character controller from this world.
The character controller to remove.
Removes the given collider from this physics world.
The collider to remove.
If set to true
, the rigid-body this collider is attached to will be awaken.
Removes the given impulse joint from this physics world.
The impulse joint to remove.
If set to true
, the rigid-bodies attached by this joint will be awaken.
Removes the given multibody joint from this physics world.
The multibody joint to remove.
If set to true
, the rigid-bodies attached by this joint will be awaken.
Removes the given rigid-body from this physics world.
This will remove this rigid-body as well as all its attached colliders and joints. Every other bodies touching or attached by joints to this rigid-body will be woken-up.
The rigid-body to remove.
Advance the simulation by one time step.
All events generated by the physics engine are ignored.
Takes a snapshot of this world.
Use World.restoreSnapshot
to create a new physics world with a state identical to
the state when .takeSnapshot()
is called.
Creates a new physics world from a snapshot.
This new physics world will be an identical copy of the snapshoted physics world.
Generated using TypeDoc
The physics world.
This contains all the data-structures necessary for creating and simulating bodies with contacts, joints, and external forces.