eulerjs API / @eulerjs/scene / ScenePhysics
ScenePhysics
Defined in: packages/scene/src/ScenePhysics.ts:54
Makes the bodies for a three.js scene from what its objects say about themselves, in userData.physics (see PhysicsData). Use it with world.use(new ScenePhysics()).
Each object with userData.physics becomes one body, whatever else it holds: a mesh, or a group of them (a glTF node of several primitives, say), together with the meshes under it that don't have physics of their own. It starts where it is drawn, nested in moved groups or not, and moves its object as it goes. An InstancedMesh becomes a body for each instance.
What it collides as: three.js's box, sphere, cylinder, cone and capsule geometries as those shapes, while they are still the shape three.js made them; anything else as its convex hull if it moves, or as its very triangles if it doesn't. A moving body's mass properties come from its meshes when they are closed, else from its collider.
Implements
Constructors
Constructor
new ScenePhysics(): ScenePhysics;Returns
ScenePhysics
Properties
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
name | readonly | "scene" | 'scene' | packages/scene/src/ScenePhysics.ts:55 |
Methods
addObject()
addObject(object, physics?):
| Body
| Body[];Defined in: packages/scene/src/ScenePhysics.ts:86
Makes the body for one object, as physics says (its userData.physics unless given), and notes it there as body: for an InstancedMesh, the list of its instances' bodies.
Parameters
| Parameter | Type |
|---|---|
object | Object3D |
physics? | PhysicsData |
Returns
addScene()
addScene(root): Body[];Defined in: packages/scene/src/ScenePhysics.ts:70
Makes a body for every object in root (and root itself) whose userData.physics is set, in the tree's order, skipping any that already has one. Returns the bodies made.
Parameters
| Parameter | Type |
|---|---|
root | Object3D |
Returns
Body[]
dispose()
dispose(): void;Defined in: packages/scene/src/ScenePhysics.ts:62
Called by world.removePlugin(plugin) and world.dispose().
Returns
void
Implementation of
install()
install(world): void;Defined in: packages/scene/src/ScenePhysics.ts:58
Called once by world.use(plugin).
Parameters
| Parameter | Type |
|---|---|
world | World |
Returns
void
Implementation of
removeObject()
removeObject(object): void;Defined in: packages/scene/src/ScenePhysics.ts:114
Takes an object's body, or its instances' bodies, out of the world, and forgets them in its userData.physics.
Parameters
| Parameter | Type |
|---|---|
object | Object3D |
Returns
void
