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 and over small bumps, one up to half its radius at a slow walk and up to most of its radius at a run,
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, up to 64
steps a frame, so one moving more than 32 radii a frame may
- Particles with collideLevel hit it, render3D.pick and the camera's wall test hit its triangles, both sides
- A V between two steep faces, a gully, holds an object standing in it only when both faces are in one
MeshCollider: a gully made of two, or of a MeshCollider beside a HeightMap, lets it sink into the sides and is
never ground, so make a gully one collider, or a HeightMap
- An object walking across a steep gully, into one of its sides, rides a little up that side and drops back, so it
is on the ground only part of the time and a jump there may not come; walking along a gully holds it, so make
one wide enough, or its sides gentle enough, that a body is not pushed into a side to cross it
- A gap that closes on an object, a V floor rising under a ceiling, squeezes it through one or the other, as no
collider can hold a body in less room than it has; leave a level room for its bodies
- To be a lift, it moves by its velocity3D, which moves it before the objects and carries what stands on it; one
moved by setting pos3D, or in its own update, leaves a rider behind, a fast one dropping it through
- A body walking down over a crest keeps the ground from one level shape onto another and from one solid onto
another, but from a level shape onto a solid ramp going down, or a solid onto one, it hops down, in the air for
a few frames; join a slope to a level shape with a level shape
Make a mesh a level shape, it joins the level's collision
mesh Meshpos3D Vector3 optional
const level = await loadOBJ('level-collision.obj');
new MeshCollider(level.mesh);
Destroy it, it leaves the level's collision
immediate boolean optional
Take the triangles from the mesh again, after it changed
It draws nothing, the game draws what it wants seen
Draws its edges while Debug Physics is on, called automatically each frame