Box
Creates a box aligned with the body's local axes.
Use it for crates, walls, floors, and simple objects. x, y, and z are the world-space centre. Dynamic, Static, and Kinematic are supported.
Syntax#
jolt_box_create_dynamic(x, y, z, width, depth, height, options=undefined)
jolt_box_create_static(x, y, z, width, depth, height, options=undefined)
jolt_box_create_kinematic(x, y, z, width, depth, height, options=undefined)Instance helper#
jolt_box_create_dynamic_for_instance(instance, width, depth, height, options=undefined)Arguments#
| Argument | Type | Description |
|---|---|---|
| x, y, z | Real | World-space centre. |
| width | Real | Full X size; finite and > 0. |
| depth | Real | Full Y size; finite and > 0. |
| height | Real | Full Z size; finite and > 0. |
| options | Struct | Optional shared body options. |
Return and behaviour#
Returns a JoltBody or undefined. It supports the standard JoltBody properties, collision layers, sensor mode, contacts, and raycasts; motion-type restrictions still apply to forces, mass, and velocity. Invalid positions, dimensions, options, or native shape creation are rejected. The pivot stays centred; rotation can be supplied through options or body methods. Debug draw uses the full dimensions and transform.
Reusable JoltShape#
var shape = jolt_shape_box(width, depth, height, cache_key=undefined);
var dynamic_body = shape.create_dynamic(x, y, z, options);
var static_body = shape.create_static(x, y, z, options);
var kinematic_body = shape.create_kinematic(x, y, z, options);Dimensions must be finite and positive. cache_key is ASCII up to 255 characters. Resources can be shared; shape.destroy() is idempotent and created bodies retain their native reference. jolt_shape_load(path, cache_key) supports valid Box .jcol assets.
Example#
jolt_start();
var floor = jolt_box_create_static(0, 0, -0.5, 20, 20, 1, {friction:0.8});
var crate = jolt_box_create_dynamic(0, 0, 4, 1, 1, 1, {mass:2, restitution:0.1});The floor's top is at Z=0 and the Dynamic crate falls onto it during simulation.
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_box_create_dynamic_for_instance | jolt_box_create_dynamic_for_instance(instance, width, depth, height, options = undefined) | Creates a Dynamic box for an existing instance and binds it; returns JoltBody/undefined. Use explicit sync to write physics transform into the instance. |