Ollin

Physics

This group covers bodies inside the scene, rigid and soft: stacks and joints, cloth, rope, and floating. A Jolt-backed World3D is stepped each frame (import OllinPhysics), and every body is drawn from its pose with withBody. See the 3D physics reference.

SketchWhat it shows
StackA crate pyramid on a floor. Click to fire a heavy ball from the camera and knock it down, and press space to rebuild it. Shows addBody, ground, and an opening velocity.
TumbleA rain of mixed solids (boxes, balls, capsules, drums) piling up. Drag any shape to fling it. Shows the Collider3D catalog plus grabBody/dragGrab.
ChainA wrecking ball on a chain of capsule links, each joined by a .ball joint. Drag it back and let it swing into the crates. Shows connect and the joint kinds.
WindmillA motored blade cross batting balls through swing gates that springs hold shut. Space cuts the power, and friction slows it to a stop. Shows .compound bodies, drive(at:)/drive(to:), limits, and softenLimits.
RockslideRocks tumbling down an eroded mountainside. The collider traces the same surface the mesh draws. Shows the .heightfield collider over a generated Heightfield.
TriggerBalls dropped through a scoring hoop into a tray. The tray lights up with its load, and each knock rings at the speed the ball landed. Shows contact events (world.contacts) and sensor bodies (isSensor).
StrollWalk a figure over an eroded island. Use the arrows or WASD to move and space to jump. Stairs lead up to a lookout that lights as you arrive. Shows addCharacter, move/jump, stepHeight, and withCharacter.
CrawlerA machine on tracks working a quarry. Use the arrows or WASD to drive, and hold both to spin it on the spot. The gearing, the track grip, and the springs are on live sliders. Its track bands are drawn as links that scroll at the speed the solver reports. Shows tracked:, trackSpeed, and wheels(on:).
JoyrideDrive a car over an eroded island. Use the arrows or WASD to drive and space for the hand brake. The gearing, the springs, and the tire grip are on live sliders. Shows addVehicle, Wheel3D, throttle/steering/handBrake, and withWheel.
RagdollA skinned figure given weight. It stands and waves while its joints are powered, and collapses when they are not. Either way you can drag it around by an arm. Shows addRagdoll, scene.apply(ragdoll), drive(toward:), and withLimb.
DrapeA washing line in the wind: a banner pegged along its top edge that flaps, a sheet thrown over a crate, and a beach ball you can let the air out of. Drag any of them. Shows addSoftBody, pinned:, pressure, applyForce, drawSoftBody, and grabSoftBody.
RiggingThree lines hanging from a gantry, all built from a polyline. One is a limp rope. One is a chain whose links interlock, because every other link is rolled a quarter turn about the rope's own axis. One is a vine stiff enough to hold a curve, with leaves carried along it. Drag any of them, and press space to stop the wind. Shows addRope, Rope3D.segments, withSegment, and bend.
TensegrityThree tensegrities dropped onto a floor: a three-strut prism, the six-strut icosahedron, and a mast of stacked prisms. Each lands, bounces on its own cables, and stands, because every strut pushes as hard as the cables around it pull. Drag a strut and the whole form follows and rights itself. Shows Tensegrity, addTensegrity, the .cable joint, and prestress.
CapeA figure striding with a cape clasped at the neck. The collar is carried by the skeleton under the skin, and everything below it hangs and swings. Space collapses the figure, and the cape comes down with it. F cuts the leash. Shows skinnedTo:, carriedBy:, sway:, backStop:, maxStretch:, and follow(_:).
RaftA raft made of cloth floating on a swell with cargo on it. Drag the deck under a sounding line that stops at it, or through a harbour gate that reports the raft passing. This is a soft body as a member of the world. Shows SoftBody3D.density, world.contacts naming a cloth, raft.touching, and raycast seeing a cloth.
FlotsamA harbour after a spill. Crates from cork-light to nearly waterlogged float on a swell, each at its own depth. A stone anchor sits on the bottom, and a current carries the lot past. Drag a crate under and let go. Shows world.water, Water.Waves, density, waterMesh, and flow.
SightlinesA yard under watch. A lamp lights only the crates in its line of sight. A drone holds its clearance over whatever passes below, and a pulse pushes everything inside a sphere. Drag a crate into cover. Shows raycast, sweep, and bodiesOverlapping.
SieveBeads of three colors sorted down one ramp. Each window in the ramp is told to ignore one color, so that color falls through it and the rest roll over. Space withdraws the rules, and everything rolls to the end. Shows group:, ignoreCollisions(between:and:), and raycast(as:).
BagatelleA pin table in a 3D world with its third dimension removed. Every ball is held to the board's plane, so the machine works however hard the pins knock the ball about. Turn that off and the balls wander out of the board. Space fires a shot fast enough to pass through a thin rail unless its path is checked. Shows freedom:, gravityScale, and checksPath.
ContraptionA workshop of machines, each built on a joint a hinge cannot make: a gear pair driving a rack through the same shaft, a rope over two hooks trading a tray for a counterweight, a platter allowed only to rise and spin, and a cart threaded onto a track. Space loads the tray. Shows .gear, .rackAndPinion, .pulley, .allowing, and .path.
ImportedA scene whose physics was written down in a file. yard.usda says which prims fall, what shape they collide as, how heavy they are, and where the hinges go, and one call builds the lot. The scene holds a seesaw, a stack, a hammer that is one body with two shapes, and a sign hinged to the world. Shows world.addBodies(from:).
YardA whole yard saved and restored: a truck you drive with the arrows, a figure pacing across it, a second figure lying where it fell, and a banner strung up over it. S writes the lot to a file, and L reads it back, so a restore comes back mid-drive and mid-stride. The terrain floor and the cloth are named rather than held, and the figure's skin stays the sketch's own asset. R also puts back the exact arrangement the yard settled into, before anything is saved. Shows snapshot(), assetName, restore(_:resolving:), world.vehicles, world.characters, world.ragdolls, and world.softBodies.
BurstSolids thrown up through the view, each breaking at the top of its arc into pieces that tumble back down. Nobody hits them: every one comes apart on its own. What falls is exactly what went up, with no gap and no overlap. Click a solid to break it early, and space clears the view. Shows Mesh.fractured cutting a solid into convex cells around the point where it gave way. Each cell becomes a body at its own centroid.

Run one with swift run Example-3D-Physics-<Name>, for example swift run Example-3D-Physics-Stack.

↑↓ move ↩ open