Skip to content

marble3 / StaticMesh

Class: StaticMesh ​

Defined in: src/entity/static-mesh.ts:24

A static body whose collision is the triangles of a Three object: a loaded level, a terrain mesh. root is drawn as well, unless a visual is given: then root is only the collision (a simplified proxy, say) and visual is what is drawn, and the two must share one transform.

The collision is baked at construction: scale and arrange root first, then move the entity as a whole with position. A geometry placed several times at one scale is stored once.

Extends ​

Constructors ​

Constructor ​

new StaticMesh(root, visual?, __namedParameters?): StaticMesh

Defined in: src/entity/static-mesh.ts:32

Parameters ​

root ​

Object3D

visual? ​

Object3D<Object3DEventMap>

__namedParameters? ​

StaticMeshOptions = {}

Returns ​

StaticMesh

Overrides ​

PhysicEntity.constructor

Properties ​

body ​

body: btRigidBody

Defined in: src/entity/physic.ts:55

Inherited from ​

PhysicEntity.body


disposed ​

protected disposed: boolean = false

Defined in: src/entity/graphic.ts:19

Inherited from ​

PhysicEntity.disposed


id ​

id: string

Defined in: src/entity/graphic.ts:16

Unique per entity. Keys FPS.entities, and is stamped on collision shapes so a ray or contact hit resolves back to its entity.

Inherited from ​

PhysicEntity.id


mass ​

mass: number

Defined in: src/entity/physic.ts:57

Inherited from ​

PhysicEntity.mass


mesh? ​

protected optional mesh?: Mesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap>

Defined in: src/entity/physic.ts:59

Inherited from ​

PhysicEntity.mesh


shape ​

shape: btCollisionShape

Defined in: src/entity/physic.ts:56

Inherited from ​

PhysicEntity.shape


storedTriangles ​

readonly storedTriangles: number

Defined in: src/entity/static-mesh.ts:28

Triangles held in memory: a geometry placed several times counts once.


three ​

three: Group

Defined in: src/entity/graphic.ts:18

The entity's node in the scene; FPS.add() puts it there. Add your meshes under it.

Inherited from ​

PhysicEntity.three


triangles ​

readonly triangles: number

Defined in: src/entity/static-mesh.ts:26

Triangles the world collides with, counting every placement of a shared geometry.

Accessors ​

position ​

Get Signature ​

get position(): Vector3

Defined in: src/entity/physic.ts:137

Where the body is, as a new vector. Setting it teleports the body and its mesh, and leaves the body's velocity as it was.

Returns ​

Vector3

Set Signature ​

set position(position): void

Defined in: src/entity/physic.ts:143

Parameters ​
position ​

Vector3

Returns ​

void

Inherited from ​

PhysicEntity.position

Methods ​

dispose() ​

dispose(): void

Defined in: src/entity/static-mesh.ts:52

Frees the body, its motion state and the shape, then the Three resources. The body must already be out of the world: use FPS.remove(), which does both.

Returns ​

void

Overrides ​

PhysicEntity.dispose


registerPhysics() ​

registerPhysics(world): void

Defined in: src/entity/static-mesh.ts:42

Parameters ​

world ​

btDiscreteDynamicsWorld

Returns ​

void

Overrides ​

PhysicEntity.registerPhysics


unregisterPhysics() ​

unregisterPhysics(world): void

Defined in: src/entity/static-mesh.ts:47

Parameters ​

world ​

btDiscreteDynamicsWorld

Returns ​

void

Overrides ​

PhysicEntity.unregisterPhysics


update() ​

update(_delta?, _engine?): void

Defined in: src/entity/physic.ts:151

Called every frame the world is not paused, with the seconds since the last frame and the FPS the entity lives in (for its world and entities).

Parameters ​

_delta? ​

number = 0

_engine? ​

FPS

Returns ​

void

Inherited from ​

PhysicEntity.update