struct

Flock::Collision::RigidBody3D

Inherits Flock::Component < Struct < Value < Object

3D rigid body dynamics. Reuses BodyType (Static/Dynamic/Kinematic).

orientation is the physics source of truth for rotation (a quaternion); the step integrates it and writes the result into the entity's Transform3D (position + matrix_override) each frame. NOTE: the 3D pipeline (step3d, raycast3d, queries) reads rotation ONLY from this field and IGNORES Transform3D.rotation. A rotated static collider must therefore be given its orientation via RigidBody3D.static(orientation:), and every entity that participates in 3D collision MUST carry a RigidBody3D — a bare Collider3D + Transform3D is invisible to the 3D collision system.

inv_inertia is the DIAGONAL inverse inertia in the body frame (0 locks that axis). Sphere/box/capsule all have diagonal body-frame inertia, so the solver can apply the world inverse inertia as q * (Ibody^-1 * (q^-1 * v)) without materialising a 3x3 matrix.

Constructors

box(mass : Number, half : Flock::Vec3, restitution : Number = 0.2, friction : Number = 0.5, velocity : Flock::Vec3 = Flock::Vec3.new) : RigidBody3D

Solid box with half-extents half. I_axis = 1/3 m (sum of the other two half-extents squared) using full extents (2*half).

Source
dynamic(mass : Number = 1.0, inertia : Flock::Vec3 = Flock::Vec3.new(1, 1, 1), restitution : Number = 0.2, friction : Number = 0.5, velocity : Flock::Vec3 = Flock::Vec3.new, angular_vel : Flock::Vec3 = Flock::Vec3.new, orientation : Flock::Quaternion = Flock::Quaternion.identity, ccd : Bool = false) : RigidBody3D

Movable body with an explicit diagonal inertia (principal moments; <= 0 locks that axis). A mass <= 0 is clamped to a tiny positive value (1e-6), keeping the body a valid Dynamic body that still feels gravity/impulses rather than an infinite-mass body that silently skips gravity.

Source
kinematic(velocity : Flock::Vec3 = Flock::Vec3.new, angular_vel : Flock::Vec3 = Flock::Vec3.new, restitution : Number = 0.2, friction : Number = 0.5, orientation : Flock::Quaternion = Flock::Quaternion.identity) : RigidBody3D

Driven purely by its own velocity (moving platforms): pushes dynamic bodies but is unaffected by gravity or impulses.

Source
new(velocity : Flock::Vec3 = Flock::Vec3.new, angular_vel : Flock::Vec3 = Flock::Vec3.new, orientation : Flock::Quaternion = Flock::Quaternion.identity, inv_mass : Number = 1.0, inv_inertia : Flock::Vec3 = Flock::Vec3.new(1, 1, 1), restitution : Number = 0.2, friction : Number = 0.5, body_type : BodyType = BodyType::Dynamic, sleeping : Bool = false, sleep_timer : Float32 = 0.0_f32, ccd : Bool = false)
Source
sphere(mass : Number, radius : Number, restitution : Number = 0.2, friction : Number = 0.5, velocity : Flock::Vec3 = Flock::Vec3.new, ccd : Bool = false) : RigidBody3D

Solid sphere: I = 2/5 m r^2 on every axis.

Source
static(restitution : Number = 0.2, friction : Number = 0.5, orientation : Flock::Quaternion = Flock::Quaternion.identity) : RigidBody3D

An immovable body (walls, floors). Pass orientation: to rotate static geometry — the 3D pipeline ignores Transform3D.rotation, so this is the only way to orient a static collider.

Source

Class methods

component_id

Instance methods

angular_vel
Source
angular_vel=(angular_vel : Flock::Vec3)
Source
body_type
Source
body_type=(body_type : BodyType)
Source
ccd=(ccd : Bool)
Source
friction
Source
friction=(friction : Float32)
Source
inv_inertia
Source
inv_inertia=(inv_inertia : Flock::Vec3)
Source
inv_mass
Source
inv_mass=(inv_mass : Float32)
Source
orientation
Source
orientation=(orientation : Flock::Quaternion)
Source
restitution
Source
restitution=(restitution : Float32)
Source
sleep_timer
Source
sleep_timer=(sleep_timer : Float32)
Source
sleeping

Sleeping state (managed by the physics step).

Source
sleeping=(sleeping : Bool)

Sleeping state (managed by the physics step).

Source
velocity
Source
velocity=(velocity : Flock::Vec3)
Source