module Eagle::Physics3D

Overview

3D rigid-body physics in pure Crystal: spheres and oriented boxes, stacking, friction, raycasts, overlap queries and kinematic character movement.

It mirrors Physics2D. Most games use the 3D physics nodes (RigidBody3D, StaticBody3D, KinematicBody3D, Area3D, RayCast3D), which share Physics3D.world. Units are meters and seconds, and gravity defaults to 9.81 m/s² downward.

world = Physics3D::World.new
world.add(Physics3D::BodyType::Static, v3(0, -0.5, 0), Physics3D::Cuboid.new(v3(20, 1, 20)))
ball = world.add(Physics3D::BodyType::Dynamic, v3(0, 5, 0), Physics3D::Sphere.new(0.5))
120.times { world.step(1_f32 / 60) }
nearby = world.query_sphere(ball.position, 2)

Defined in:

eagle/physics/physics3d.cr

Class Method Summary

Class Method Detail

def self.active? : Bool #

True when the shared world has bodies.


def self.reset : Nil #

Replaces the shared world with an empty one.


def self.world : World #

The shared world used by the 3D physics nodes.


def self.world=(w : World) #

Replaces the shared world.