Angular drag is a force that resists the rotation of the rigid-body. It is applied to the center-of-mass of the rigid-body.
When true the mass will be automatically calculated by the attached colliders
The center of mass is the point around which the mass of the rigid-body is evenly distributed. It is used to compute the torque applied to the rigid-body when forces are applied to it.
Constraints are used to lock the position or rotation of an object in a specific axis.
Detect collisions is a flag that can be set to false to disable collision detection for a specific rigid-body.
Rigidbodies with higher dominance will be immune to forces originating from contacts with rigidbodies of lower dominance.
Drag is a force that resists the motion of the rigid-body. It is applied to the center-of-mass of the rigid-body.
the object this component is attached to. Note that this is a threejs Object3D with some additional features
the unique identifier for this component
IsKinematic is a flag that can be set to true to make a rigid-body kinematic. Kinematic rigid-bodies are not affected by forces and collisions. They are meant to be animated by the user.
The sleeping threshold is the minimum velocity below which a dynamic rigid-body will be put to sleep by the physics engine.
Optional
sourceholds the source identifier this object was created with/from (e.g. if it was part of a glTF file the sourceId holds the url to the glTF)
Use gravity is a flag that can be set to false to disable gravity for a specific rigid-body.
true if the object is enabled and active in the hierarchy
true if this component was destroyed (this.destroy()
) or the whole object this component was part of
Gravity is such a common force that it is implemented as a special case (even if it could easily be implemented by the user using force application). Note however that a change of gravity won't automatically wake-up the sleeping bodies so keep in mind that you may want to wake them up manually before a gravity change.
It is possible to change the way gravity affects a specific rigid-body by setting the rigid-body's gravity scale to a value other than 1.0. The magnitude of the gravity applied to this body will be multiplied by this scaling factor. Therefore, a gravity scale set to 0.0 will disable gravity for the rigid-body whereas a gravity scale set to 2.0 will make it twice as strong. A negative value will flip the direction of the gravity for this rigid-body.
the layer of the gameObject this component is attached to
By default the mass will be automatically calculated (see autoMass
) by the physics engine using the collider sizes
To set the mass manually you can either set the mass
value or set autoMass
to false
the name of the gameObject this component is attached to
shorthand for this.context.scene
the scene of the context
Is the gameObject marked as static
the tag of the gameObject this component is attached to
Forces affect the rigid-body's acceleration whereas impulses affect the rigid-body's velocity the acceleration change is equal to the force divided by the mass:
Optional
_rel: Vector3Optional
earlyOptional
lateOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onCallback when this component joins a xr session (or becomes active in a running XR session)
Optional
onCallback when this component exists a xr session (or when it becomes inactive in a running XR session)
Optional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onOptional
onCallback when a xr session updates (while it is still active in XR session)
Optional
onXRControllerCallback when a controller is connected/added while in a XR session
OR when the component joins a running XR session that has already connected controllers
OR when the component becomes active during a running XR session that has already connected controllers
Optional
onXRControllerOptional
resolveOptional
startstarts a coroutine (javascript generator function)yield
will wait for the next frame:
yield WaitForSeconds(1)
to wait for 1 second.yield WaitForFrames(10)
to wait for 10 frames.yield new Promise(...)
to wait for a promise to resolve.generator function to start
event to register the coroutine for (default: FrameEvent.Update). Note that all coroutine FrameEvent callbacks are invoked after the matching regular component callbacks. For example FrameEvent.Update
will be called after regular component update()
methods)
the generator function (use it to stop the coroutine with stopCoroutine
)
onEnable() { this.startCoroutine(this.myCoroutine()); }
private *myCoroutine() {
while(this.activeAndEnabled) {
console.log("Hello World", this.context.time.frame);
// wait for 5 frames
for(let i = 0; i < 5; i++) yield;
}
}
Stop a coroutine that was previously started with startCoroutine
the routine to be stopped
the frame event to unregister the routine from (default: FrameEvent.Update)
Optional
supportsXROptional callback, you can implement this to only get callbacks for VR or AR sessions if necessary.
true if the mode is supported (if false the mode is not supported by this component and it will not receive XR callbacks for this mode)
Teleport the rigidbody to a new position in the world.
Will reset forces before setting the object world position
The new position to teleport the object to (world space)
When true the object will be teleported in local space, otherwise in world space
Optional
updateWhen a dynamic rigid-body doesn't move (or moves very slowly) during a few seconds, it will be marked as sleeping by the physics pipeline. Rigid-bodies marked as sleeping are no longer simulated by the physics engine until they are woken up. That way the physics engine doesn't waste any computational resources simulating objects that don't actually move. They are woken up automatically whenever another non-sleeping rigid-body starts interacting with them (either with a joint, or with one of its attached colliders generating contacts).
Generated using TypeDoc
A Rigidbody is used together with a Collider to create physical interactions between objects in the scene.