eulerjs API / @eulerjs/scene / EulerPhysicsAPI
EulerPhysicsAPI
Defined in: packages/scene/src/EulerPhysics.ts:18
What EulerPhysics() hands back: three.js's RapierPhysics, JoltPhysics and AmmoPhysics API, on eulerjs.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
scene | readonly | ScenePhysics | The plugin that makes the bodies, for more than the API below offers. | packages/scene/src/EulerPhysics.ts:21 |
world | readonly | World | - | packages/scene/src/EulerPhysics.ts:19 |
Methods
addHeightfield()
addHeightfield(
mesh,
width,
depth,
heights,
scale
): Body;Defined in: packages/scene/src/EulerPhysics.ts:40
Adds terrain under the mesh's origin: width by depth cells along x and z, whose (width + 1) × (depth + 1) heights run along x first, then row after row along z, as a rotated PlaneGeometry's vertices do; scale.x and scale.z are its whole width and depth, and scale.y scales the heights. Returns its body.
Parameters
| Parameter | Type |
|---|---|
mesh | Mesh |
width | number |
depth | number |
heights | ArrayLike<number> |
scale | { x: number; y: number; z: number; } |
scale.x | number |
scale.y | number |
scale.z | number |
Returns
addMesh()
addMesh(
mesh,
mass?,
restitution?
): void;Defined in: packages/scene/src/EulerPhysics.ts:28
Adds one mesh, mass kg (0 keeps it still) with restitution (0 to 1) for how bouncy it is.
Parameters
| Parameter | Type |
|---|---|
mesh | Mesh |
mass? | number |
restitution? | number |
Returns
void
addScene()
addScene(scene): void;Defined in: packages/scene/src/EulerPhysics.ts:26
Adds the objects in scene (and scene itself) whose userData.physics is set, such as box.userData.physics = { mass: 1, restitution: 0 }. A mass of 0, or none, keeps one still.
Parameters
| Parameter | Type |
|---|---|
scene | Object3D |
Returns
void
applyImpulse()
applyImpulse(
mesh,
impulse,
index?
): void;Defined in: packages/scene/src/EulerPhysics.ts:33
Parameters
| Parameter | Type |
|---|---|
mesh | Mesh |
impulse | Vector3 |
index? | number |
Returns
void
dispose()
dispose(): void;Defined in: packages/scene/src/EulerPhysics.ts:42
Stops stepping and frees the world.
Returns
void
removeMesh()
removeMesh(mesh): void;Defined in: packages/scene/src/EulerPhysics.ts:29
Parameters
| Parameter | Type |
|---|---|
mesh | Mesh |
Returns
void
setMeshPosition()
setMeshPosition(
mesh,
position,
index?
): void;Defined in: packages/scene/src/EulerPhysics.ts:31
Moves the mesh, or instance index of an InstancedMesh, to position and stops it.
Parameters
| Parameter | Type |
|---|---|
mesh | Mesh |
position | Vector3 |
index? | number |
Returns
void
setMeshVelocity()
setMeshVelocity(
mesh,
velocity,
index?
): void;Defined in: packages/scene/src/EulerPhysics.ts:32
Parameters
| Parameter | Type |
|---|---|
mesh | Mesh |
velocity | Vector3 |
index? | number |
Returns
void
