Prelude Module
Auto-opened convenience module re-exporting all scripting functions. Referencing the assembly makes all helpers, builders, and lifecycle functions available without qualification.
Functions and values
| Function or value |
Description
|
Full Usage:
batchAdd arg1 arg2
Parameters:
Session
arg1 : SimulationCommand list
Returns: BatchResult
|
Sends commands in auto-chunked batches of 100. Returns per-command success/failure results.
|
|
Bouncy material: friction 0.4, high recovery 8.0, spring 60 Hz / 0.5 damping.
|
Full Usage:
makeAngularMotorCmd id bodyA bodyB targetVelocity maxForce
Parameters:
string
bodyA : string
bodyB : string
targetVelocity : float * float * float
maxForce : float
Returns: SimulationCommand
|
Builds an angular-motor constraint — drives rotation.
|
Full Usage:
makeBallSocketCmd id bodyA bodyB offsetA offsetB
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
First body ID.
bodyB : string
-
Second body ID.
offsetA : float * float * float
-
Local offset on body A (x, y, z).
offsetB : float * float * float
-
Local offset on body B (x, y, z).
Returns: SimulationCommand
|
Builds a ball-socket constraint — free rotation around anchor.
|
Full Usage:
makeBoxCmd id pos halfExtents mass
Parameters:
string
-
Unique ID. Use nextId "box" for auto-generated.
pos : float * float * float
-
Position (x, y, z). Box center; set Y to half-height to rest on ground.
halfExtents : float * float * float
-
Half-dimensions (hx, hy, hz). (0.5,0.5,0.5)=1m cube. Reference: crate=(0.5,0.5,0.5), brick=(0.2,0.1,0.05), domino=(0.1,0.3,0.02).
mass : float
-
Mass in kg. 0=static walls/floors. Reference: die=0.03, brick=3, crate=20.
Returns: SimulationCommand
|
Builds a box AddBody command.
|
Full Usage:
makeCapsuleCmd id pos radius length mass
Parameters:
string
-
Unique ID. Use nextId "capsule" for auto-generated.
pos : float * float * float
-
Position (x, y, z). Capsule center.
radius : float
-
Capsule radius in meters. Reference: limb=0.05, pipe=0.1, barrel=0.25.
length : float
-
Cylinder portion length in meters (total = length + 2*radius). Reference: limb=0.3, pole=2.0.
mass : float
-
Mass in kg. 0=static.
Returns: SimulationCommand
|
Builds a capsule AddBody command.
|
|
Creates a Color from RGBA (each 0.0–1.0). 1.0 alpha = opaque.
|
Full Usage:
makeCylinderCmd id pos radius length mass
Parameters:
string
-
Unique ID. Use nextId "cylinder" for auto-generated.
pos : float * float * float
-
Position (x, y, z). Cylinder center.
radius : float
-
Cylinder radius in meters. Reference: coin=0.01, can=0.03, barrel=0.25.
length : float
-
Cylinder height in meters. Reference: coin=0.002, can=0.12, barrel=0.9.
mass : float
-
Mass in kg. 0=static.
Returns: SimulationCommand
|
Builds a cylinder AddBody command.
|
Full Usage:
makeDistanceLimitCmd id bodyA bodyB minDist maxDist
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
First body ID.
bodyB : string
-
Second body ID.
minDist : float
-
Minimum distance in meters.
maxDist : float
-
Maximum distance in meters.
Returns: SimulationCommand
|
Builds a distance-limit constraint — keeps bodies within min/max distance.
|
Full Usage:
makeDistanceSpringCmd id bodyA bodyB offsetA offsetB targetDistance
Parameters:
string
bodyA : string
bodyB : string
offsetA : float * float * float
offsetB : float * float * float
targetDistance : float
Returns: SimulationCommand
|
Builds a distance-spring constraint — pulls bodies toward a target distance.
|
Full Usage:
makeHingeCmd id bodyA bodyB axis offsetA offsetB
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
First body ID.
bodyB : string
-
Second body ID.
axis : float * float * float
-
Hinge axis direction (x, y, z).
offsetA : float * float * float
-
Local offset on body A.
offsetB : float * float * float
-
Local offset on body B.
Returns: SimulationCommand
|
Builds a hinge constraint — rotation around a single axis.
|
Full Usage:
makeImpulseCmd bodyId impulse
Parameters:
string
-
Target body ID.
impulse : float * float * float
-
Impulse (x, y, z) in N·s. Typical: (0,5,0) nudge, (0,50,0) launch, (10,0,0) push.
Returns: SimulationCommand
|
Builds an impulse command — instantaneous velocity change.
|
Full Usage:
makeLinearAxisMotorCmd id bodyA bodyB offsetA offsetB axis targetVelocity maxForce
Parameters:
string
bodyA : string
bodyB : string
offsetA : float * float * float
offsetB : float * float * float
axis : float * float * float
targetVelocity : float
maxForce : float
Returns: SimulationCommand
|
Builds a linear-axis-motor constraint — drives linear motion along an axis.
|
Full Usage:
makeMaterialProperties friction maxRecovery springFreq springDamping
Parameters:
float
-
Coulomb friction. 0=ice, 0.5=wood, 1.0=rubber.
maxRecovery : float
-
Max recovery velocity m/s. Higher=bouncier.
springFreq : float
-
Contact spring frequency Hz.
springDamping : float
-
Contact spring damping ratio. 1.0=critical.
Returns: MaterialProperties
|
Creates MaterialProperties from physical parameters.
|
Full Usage:
makePointOnLineCmd id bodyA bodyB origin direction offset
Parameters:
string
bodyA : string
bodyB : string
origin : float * float * float
direction : float * float * float
offset : float * float * float
Returns: SimulationCommand
|
Builds a point-on-line constraint — constrains a point to slide along a line.
|
Full Usage:
makeRemoveConstraintCmd constraintId
Parameters:
string
-
ID of the constraint to remove.
Returns: SimulationCommand
|
Builds a remove-constraint command.
|
Full Usage:
makeSetBodyPoseCmd bodyId pos
Parameters:
string
pos : float * float * float
Returns: SimulationCommand
|
Builds a SetBodyPose command to teleport/reposition a body.
|
Full Usage:
makeSphereCmd id pos radius mass
Parameters:
string
-
Unique ID. Use nextId "sphere" for auto-generated.
pos : float * float * float
-
Position (x, y, z). Ground at Y=0.
radius : float
-
Radius in meters. Reference: marble=0.01, bowling ball=0.11, beach ball=0.2, boulder=0.5.
mass : float
-
Mass in kg. 0=static. Reference: marble=0.005, bowling ball=6.35, boulder=200.
Returns: SimulationCommand
|
Builds a sphere AddBody command.
|
Full Usage:
makeSwingLimitCmd id bodyA bodyB axisA axisB maxAngle
Parameters:
string
bodyA : string
bodyB : string
axisA : float * float * float
axisB : float * float * float
maxAngle : float
Returns: SimulationCommand
|
Builds a swing-limit constraint — limits angle between two axes.
|
Full Usage:
makeTorqueCmd bodyId torque
Parameters:
string
-
Target body ID.
torque : float * float * float
-
Torque (x, y, z) in N·m. Axis = rotation direction, magnitude = strength. Typical: (0,5,0) gentle spin, (0,50,0) fast spin.
Returns: SimulationCommand
|
Builds a torque command — rotational force.
|
Full Usage:
makeTwistLimitCmd id bodyA bodyB axisA axisB minAngle maxAngle
Parameters:
string
bodyA : string
bodyB : string
axisA : float * float * float
axisB : float * float * float
minAngle : float
maxAngle : float
Returns: SimulationCommand
|
Builds a twist-limit constraint — limits rotation around an axis to an angle range.
|
Full Usage:
makeWeldCmd id bodyA bodyB
Parameters:
string
-
Unique constraint ID.
bodyA : string
-
First body ID.
bodyB : string
-
Second body ID.
Returns: SimulationCommand
|
Builds a weld constraint — rigidly joins two bodies.
|
Full Usage:
nextId arg1
Parameters:
string
Returns: string
|
Generates sequential body ID like
|
Unwraps an
|
|
Full Usage:
overlapSphere session radius position
Parameters:
Session
radius : float
position : float * float * float
Returns: string list
|
Tests for overlapping bodies using a sphere. Returns overlapping body IDs.
|
Full Usage:
raycast session origin direction maxDistance
Parameters:
Session
-
Active session.
origin : float * float * float
-
Ray origin (x, y, z).
direction : float * float * float
-
Ray direction (x, y, z).
maxDistance : float
-
Maximum ray distance.
Returns: (string * (float * float * float) * (float * float * float) * float) list
|
Casts a ray and returns hit results as (bodyId, position, normal, distance) tuples.
|
Full Usage:
raycastAll session origin direction maxDistance
Parameters:
Session
origin : float * float * float
direction : float * float * float
maxDistance : float
Returns: (string * (float * float * float) * (float * float * float) * float) list
|
Casts a ray and returns all hits along the ray.
|
|
Resets simulation: pause, clear bodies, reset IDs, add ground plane, set gravity -9.81, wait 100ms.
|
|
Runs simulation for N seconds then pauses. 60 Hz timestep, so 3.0s = 180 steps.
|
Full Usage:
sleep arg1
Parameters:
int
|
Pauses the current thread for the specified milliseconds.
|
|
Slippery material: friction 0.01, recovery 2.0, spring 30 Hz / 1.0 damping.
|
|
Sticky material: friction 2.0, low recovery 0.5, spring 30 Hz / 1.0 damping.
|
Full Usage:
sweepSphere session radius startPosition direction maxDistance
Parameters:
Session
radius : float
startPosition : float * float * float
direction : float * float * float
maxDistance : float
Returns: (string * (float * float * float) * (float * float * float) * float) option
|
Performs a sphere sweep cast. Returns Some (bodyId, position, normal, distance) or None.
|
Full Usage:
timed arg1 arg2
Parameters:
string
arg1 : unit -> 'a
Returns: 'a
|
Times a function and prints elapsed duration. Output:
|
|
|
|
Creates a protobuf Vec3 from
|
PhysicsSandbox