Bodies
Sphere
Creates a sphere defined by its radius.
x, y, and z are its exact world-space centre. Rotation does not alter its collision geometry, although the body quaternion remains available. Dynamic, Static, and Kinematic are supported.
Syntax#
jolt_sphere_create_dynamic(x, y, z, radius, options=undefined)
jolt_sphere_create_static(x, y, z, radius, options=undefined)
jolt_sphere_create_kinematic(x, y, z, radius, options=undefined)Arguments and return#
| Argument | Type | Description |
|---|---|---|
| x, y, z | Real | World-space centre. |
| radius | Real | Finite radius > 0; diameter is 2*radius. |
| options | Struct | Shared options struct. |
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. Debug draw renders a wire sphere around the transformed centre.
Reusable JoltShape#
var shape = jolt_shape_sphere(radius, cache_key=undefined);
shape.create_dynamic(x, y, z, options);
shape.create_static(x, y, z, options);
shape.create_kinematic(x, y, z, options);jolt_shape_load() supports Sphere .jcol.
Example#
var ball = jolt_sphere_create_dynamic(-3, 0, 4, 0.6, {
mass:1, restitution:0.7, friction:0.3
});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_sphere_create_dynamic | jolt_sphere_create_dynamic(x = 0, y = 0, z = 0, radius = 0.5, options = undefined) | Factory for the named motion type, XYZ position defaults 0m plus options. radius >0 m, default.5. Returns JoltBody/undefined; options failure cleans up the new body. Finite dimensions; set_ changes preserve identity. |
| jolt_sphere_create_kinematic | jolt_sphere_create_kinematic(x = 0, y = 0, z = 0, radius = 0.5, options = undefined) | Factory for the named motion type, XYZ position defaults 0m plus options. radius >0 m, default.5. Returns JoltBody/undefined; options failure cleans up the new body. Finite dimensions; set_ changes preserve identity. |
| jolt_sphere_create_static | jolt_sphere_create_static(x = 0, y = 0, z = 0, radius = 0.5, options = undefined) | Factory for the named motion type, XYZ position defaults 0m plus options. radius >0 m, default.5. Returns JoltBody/undefined; options failure cleans up the new body. Finite dimensions; set_ changes preserve identity. |