Skip to content

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 ​

PropertyModifierTypeDescriptionDefined in
scenereadonlyScenePhysicsThe plugin that makes the bodies, for more than the API below offers.packages/scene/src/EulerPhysics.ts:21
worldreadonlyWorld-packages/scene/src/EulerPhysics.ts:19

Methods ​

addHeightfield() ​

ts
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 ​

ParameterType
meshMesh
widthnumber
depthnumber
heightsArrayLike<number>
scale{ x: number; y: number; z: number; }
scale.xnumber
scale.ynumber
scale.znumber

Returns ​

Body


addMesh() ​

ts
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 ​

ParameterType
meshMesh
mass?number
restitution?number

Returns ​

void


addScene() ​

ts
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 ​

ParameterType
sceneObject3D

Returns ​

void


applyImpulse() ​

ts
applyImpulse(
   mesh, 
   impulse, 
   index?
): void;

Defined in: packages/scene/src/EulerPhysics.ts:33

Parameters ​

ParameterType
meshMesh
impulseVector3
index?number

Returns ​

void


dispose() ​

ts
dispose(): void;

Defined in: packages/scene/src/EulerPhysics.ts:42

Stops stepping and frees the world.

Returns ​

void


removeMesh() ​

ts
removeMesh(mesh): void;

Defined in: packages/scene/src/EulerPhysics.ts:29

Parameters ​

ParameterType
meshMesh

Returns ​

void


setMeshPosition() ​

ts
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 ​

ParameterType
meshMesh
positionVector3
index?number

Returns ​

void


setMeshVelocity() ​

ts
setMeshVelocity(
   mesh, 
   velocity, 
   index?
): void;

Defined in: packages/scene/src/EulerPhysics.ts:32

Parameters ​

ParameterType
meshMesh
velocityVector3
index?number

Returns ​

void

Released under the MIT License.