Mesh
Creates potentially concave triangle collision geometry for Static bodies.
Use Mesh for levels, rooms, rocks, and detailed immovable geometry. Jolt meshes do not have solid volume like convex shapes, are one-sided, and are costlier and less robust for moving objects; use a primitive, Convex, or Compound instead.
Syntax#
jolt_mesh_create_static(vertices, indices, x=0, y=0, z=0, options=undefined)vertices#
An array of 3..65536 local [x,y,z] or {x,y,z} points with finite components. Creator x,y,z is a world origin added to vertices, not an automatically calculated geometric centre.
indices, triangles, and winding#
[a0,b0,c0, a1,b1,c1, ...]- Each index is an integer in 0..array_length(vertices)-1.
- 1..131072 triangles are allowed: 3..393216 indices, with a count divisible by three.
- Use counter-clockwise winding when viewed from the front.
- Simulation and public raycast are one-sided; raycast uses IgnoreBackFaces.
- Jolt removes duplicate and degenerate triangles. At least one usable triangle must remain; no extra simplification or convex decomposition is performed.
Options, return, and restrictions#
Returns a Static JoltBody or undefined. Relevant options are rotation, rotation_euler, friction, restitution, layer, and sensor. Dynamic-only mass or velocity fails and destroys the new body. Mesh supports filtering, sensor events, contacts, and raycasts. Debug draw uses metadata edges and a regular stride above 2048 triangles.
Reusable JoltShape#
var shape = jolt_shape_mesh(vertices, indices, cache_key=undefined);
var level = shape.create_static(x, y, z, options);shape.create_dynamic() and create_kinematic() return undefined. jolt_shape_load() supports Mesh .jcol and a resource is recommended for repeated maps.
BBMOD#
var shape = jolt_shape_mesh_from_bbmod(model);
var body = shape.create_static(0, 0, 0, {friction:0.8});Use a loaded BBMOD model before freezing its buffers.
Low-Level / Advanced API#
No ergonomic low-level array creator exists. jolt_world_geometry_create() needs an internal versioned base64 payload and private jolt_world_shape_command() is only reusable-shape transport.
Example#
var vertices = [[-3,-3,0], [3,-3,0], [3,3,0], [-3,3,0]];
var indices = [0,1,2, 0,2,3]; // CCW from above, +Z normal
var level_mesh = jolt_mesh_create_static(vertices, indices, 0, 0, 0, {friction:0.85});Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| jolt_mesh_create_static | jolt_mesh_create_static(vertices = [[-0.5,-0.5,0],[0.5,-0.5,0],[0.5,0.5,0],[-0.5,0.5,0]], indices = [0,1,2,0,2,3], x = 0, y = 0, z = 0, options = undefined) | Static triangle mesh; local vertices/indices, default XY square with2 triangles. Limits as jolt_shape_mesh, position defaults 0. JoltBody/undefined; no Dynamic/Kinematic variant. |