eulerjs API / @eulerjs/core/extend
@eulerjs/core/extend
@eulerjs/core/extend: for plugins that teach the JavaScript backend new collider shapes, such as @eulerjs/bvh's triangle meshes. A new shape is a Collider subclass with its own shape name, plus either collision tests against the shapes it meets, or, for a shape made of triangles, a description of which triangles lie where, from which the engine derives its collisions with every convex shape, ray casts, shape casts and overlap tests.
Interfaces
| Interface | Description |
|---|---|
| ContactPoint | Where two colliders touch, or nearly do. normal is a unit vector from B toward A (the way A must move to separate), pointA and pointB are the closest (or deepest) points of each, and depth is how far they overlap along the normal, (pointB - pointA) · normal: negative for a gap, which a contact within the margin can have. |
| SweepHit | Where a ray or swept shape first touches a collider. |
| TriangleShape | A shape made of triangles, such as a heightfield or a mesh, described by the triangles it has in a region. |
Type Aliases
| Type Alias | Description |
|---|---|
| CollisionTest | Adds the contacts between two colliders to contacts, including points still up to margin apart: the bodies may close that gap during the step. |
| RayTest | A ray or shape registered by a plugin with its own way of casting against a shape, such as a mesh's bounding volume tree. |
| TriangleTest | Adds the contacts between the collider it was made for and the triangle (first, second, third), counting points up to margin apart. A one-sided triangle, such as a piece of terrain, only ever pushes out of the side its corners wind anticlockwise around. |
| TriangleVisitor | Receives one triangle in world space, wound anticlockwise seen from its front, and its active edges (see TriangleTest). |
Variables
| Variable | Description |
|---|---|
| ALL_EDGES | All three edges active. |
Functions
| Function | Description |
|---|---|
| collide | Every contact between two colliders at the given poses, counting points up to margin apart. None if they don't touch or no test is registered for the pair of shapes. |
| isActiveEdge | Whether the edge from start to end of a triangle with unit normal normal should push on its own: yes on the border of a surface (no neighbour), and where the surface folds away from the triangle's front by more than a few degrees, a ridge; no where it is nearly flat, or folds up into a valley, where the faces either side do all the pushing. |
| rayTriangle | Where a ray meets a triangle (Möller and Trumbore 1997), from the front only if oneSided. |
| registerCollisionTest | Teaches the engine how two shapes collide. Register each pair once; the reverse order is handled for you. |
| registerRayTest | Gives a shape a ray cast of its own, used instead of the general one. |
| registerTriangleShape | Teaches the engine a shape made of triangles: from the triangles it gives in a region, it collides with every convex shape, and scene queries (ray casts, shape casts, overlaps) work against it. |
| triangleTestFor | The test of collider at pose against triangles, set up once to be run on many: undefined for shapes that can't collide with triangles, such as planes and other triangle shapes. |
