physics library

Physics for flutter_scene, an optional pluggable-backend contract.

The generic scene-graph components (PhysicsWorld, RigidBody, Collider, the joints, KinematicCharacterController) plus the re-exported scene contract they drive. Attach a backend, PhysicsWorld( RapierWorld()) from package:flutter_scene_rapier, or BasicSimulation() for pure-Dart queries and triggers. Import this only when a build needs physics; the core package:flutter_scene/scene.dart does not carry it.

For a backend feature beyond the shared contract, downcast PhysicsWorld.simulation and drive it by RigidBody.handle / Collider.handles / Joint.handle; the components are subclassable for typed backend companions.

Classes

BasicSimulation
Pure-Dart PhysicsSimulation suitable for picking, area triggers, and kinematic-only gameplay.
BoxShape
An axis-aligned box of the given halfExtents centered at the collider's local origin.
CapsuleShape
A capsule aligned with the local Y axis. halfHeight is the half length of the cylindrical section, excluding the hemispherical caps.
CharacterMovement
Result of one kinematic character move-and-slide.
Collider Physics
A collision volume attached to a Node.
CollisionBegan Physics
Two solid colliders began touching.
CollisionEnded Physics
Two solid colliders stopped touching.
CollisionEvent Physics
Collision lifecycle events for a PhysicsWorld's bodies, resolved to scene nodes and collider components.
CompoundChild
One child of a CompoundShape: a shape positioned by localPose relative to the compound's origin.
CompoundShape
A union of children, each positioned by its own local pose.
ContactPoint
One contact within a collision manifold.
ConvexHullShape
The convex hull of points, stored as packed xyz triplets.
CylinderShape
A cylinder aligned with the local Y axis. halfHeight is half the total height.
FixedJoint Physics
Welds the two bodies' current relative pose.
GenericJoint Physics
A six-degree-of-freedom constraint with per-axis motion configs.
HeightFieldShape
A row-major heightfield of width x depth samples, scaled by scale. Heights are sampled in the local XZ plane and offset along Y.
Joint Physics
A constraint between this node's RigidBody and otherNode's (or the world, when otherNode is null).
JointAxisConfig
Motion allowance for one axis of a generic joint.
JointMotor
Drives a joint axis toward a target position and/or velocity.
KinematicCharacterController Physics
Kinematic move-and-slide against the world's colliders.
NodePoseTarget
Adapts a Node's world transform to the simulation's pose seam.
OverlapHit Physics
One collider returned by an overlap query (sphere or box).
PhysicsMaterial
Surface properties (friction, restitution, density) of a collider.
PhysicsSimulation
The backend driver contract, a physics engine addressed by integer handles, decoupled from any scene graph through PoseTargets.
PhysicsWorld Physics
The simulation world for a subtree of the scene graph.
PoseTarget
Where a simulated body reads and writes its world pose.
PrismaticJoint Physics
A slider along localAxisA/localAxisB, optionally limited and motorized.
RaycastHit Physics
The closest collider intersected by a Ray, or one entry of a raycast-all result list.
RevoluteJoint Physics
A hinge about localAxisA/localAxisB, optionally limited and motorized.
RigidBody Physics
A simulated rigid body attached to a Node.
Shape
Geometric description of a collider's volume.
ShapeCastHit Physics
The first collider intersected by a shape cast, with the same fields as RaycastHit plus the cast direction's hit distance.
SimplePoseTarget
A plain mutable pose.
SphereShape
A sphere centered at the collider's local origin.
SphericalJoint Physics
A ball-and-socket constraint.
TriggerEntered Physics
A collider entered a trigger volume.
TriggerExited Physics
A collider left a trigger volume.
TriMeshShape
A triangle mesh defined by vertices (packed xyz triplets) and indices (groups of three vertex indices forming one triangle each).

Enums

BodyType
Simulation mode for a body.
CombineRule
How a per-contact friction or restitution value is derived from the two participating materials.
JointAxis
One of the six relative degrees of freedom a generic joint constrains.
JointAxisMotion
How a single axis of a GenericJointDesc is constrained.
JointMotorModel
How a joint motor's strength is interpreted.

Functions

findAncestorWorld(Node start) PhysicsWorld? Physics
The nearest PhysicsWorld on start or its ancestors, or null.