LittleJS 1.30.0

Render3D

MeshCollider

MeshCollider - A level shape made of a mesh's triangles, which objects with collideLevel land on, slide along and walk up, as on a HeightMap: a level's floors, walls, ramps and rocks, often a low poly mesh made for collision

  • It draws nothing: make an EngineObject3D with the same mesh to see it, or with a mesh of its own to show more than collides; Debug Physics on the debug overlay draws its edges
  • An object collides with it as a capsule as tall as its height and as wide as its narrowest side, so it rides up a step lower than its round foot and over small bumps, and one with collideAsSphere3D as its sphere; a flat wide object, as a plank, is a sphere as thick as it is, at its middle, and its turn is not taken into account
  • Its triangles are taken from the mesh in world space where it is, through its pos3D, rotation3D and scale3D, and taken again when it moves; call rebuild() after changing the mesh
  • Any mesh works, a strip, an indexed one, a loaded model or one given its vertex data; both sides of a triangle collide
  • A fast object is moved in steps no longer than half its radius, so it does not go through a thin wall
  • Particles with collideLevel hit it, render3D.pick and the camera's wall test hit its triangles, both sides

Extends EngineObject3D

Constructor

new MeshCollider(mesh, pos3D)render3dExtras.js:721

Make a mesh a level shape, it joins the level's collision

mesh Mesh
pos3D Vector3 optional
const level = await loadOBJ('level-collision.obj');
new MeshCollider(level.mesh);

Members

Methods

Inherited from EngineObject3D

Inherited from EngineObject

Members

bakedMatrix : Float64Array|undefinedrender3dExtras.js:736
grid : Object|undefinedrender3dExtras.js:739
normals : Float64Arrayrender3dExtras.js:733
triangles : Float64Arrayrender3dExtras.js:731

Methods

destroy(immediate)render3dExtras.js:832

Destroy it, it leaves the level's collision

immediate boolean optional

Take the triangles from the mesh again, after it changed

render3D() → voidrender3dExtras.js:748

It draws nothing, the game draws what it wants seen

Draws its edges while Debug Physics is on, called automatically each frame