Class PhysicsViewer
Constructors
constructor
-
new PhysicsViewer(
scene?: Scene,
size?: number,
utilityLayer?: UtilityLayerRenderer,
): PhysicsViewerCreates a new PhysicsViewer
Parameters
Optionalscene: Scenedefines the hosting scene
Optionalsize: numberPhysics V2 size scalar
- utilityLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer
The utility layer the viewer will be added to
Returns PhysicsViewer
Methods
dispose
-
Clean up physics debug display
Returns void
hide Body
-
Hides a body from the physics engine.
Parameters
- body: Nullable<PhysicsBody>
The body to hide.
Returns boolean
true if body actually removed
This function is useful for hiding a body from the physics engine. It removes the body from the utility layer scene and disposes the mesh associated with it. It also unregisters the render function if the number of bodies is 0. This is useful for hiding a body from the physics engine without deleting it.
- body: Nullable<PhysicsBody>
hide Constraint
-
Hide a physics constraint from the viewer utility layer
Parameters
- constraint: Nullable<PhysicsConstraint>
the constraint to hide
Returns void
- constraint: Nullable<PhysicsConstraint>
hide Impostor
-
Hides an impostor from the scene.
Parameters
- impostor: Nullable<PhysicsImpostor>
The impostor to hide.
This method is useful for hiding an impostor from the scene. It removes the impostor from the utility layer scene, disposes the mesh, and removes the impostor from the list of impostors. If the impostor is the last one in the list, it also unregisters the render function.
Returns void
- impostor: Nullable<PhysicsImpostor>
hide Inertia
-
Hides a body's inertia from the viewer utility layer
Parameters
- body: Nullable<PhysicsBody>
the body to hide
Returns boolean
true if inertia actually removed
- body: Nullable<PhysicsBody>
show Body
-
Shows a debug mesh for a given physics body.
Parameters
- body: PhysicsBody
The physics body to show.
Returns Nullable<AbstractMesh>
The debug mesh, or null if the body is already shown.
This function is useful for visualizing the physics body in the scene. It creates a debug mesh for the given body and adds it to the scene. It also registers a before render function to update the debug mesh position and rotation.
- body: PhysicsBody
show Constraint
-
Shows a debug mesh for a given physics constraint.
Parameters
- constraint: PhysicsConstraint
the physics constraint to show
Returns Nullable<AbstractMesh>
the debug mesh, or null if the constraint is already shown
- constraint: PhysicsConstraint
show Impostor
-
Renders a specified physic impostor
Parameters
- impostor: PhysicsImpostor
defines the impostor to render
OptionaltargetMesh: Meshdefines the mesh represented by the impostor
Returns Nullable<AbstractMesh>
the new debug mesh used to render the impostor
- impostor: PhysicsImpostor
show Inertia
-
Shows a debug box corresponding to the inertia of a given body
Parameters
- body: PhysicsBody
the physics body used to get the inertia
Returns Nullable<AbstractMesh>
the debug mesh used to show the inertia, or null if the body is already shown
- body: PhysicsBody
Used to show the physics impostor around the specific mesh