Physics Constraint Hinge
App: apps/physics_constraint_hinge/
Demonstrates a hinge constraint: a door body anchored at its hinge point. Press Space to apply an impulse to a sphere that pushes the door open. Uses an FPS camera (WASD + mouse look) loaded from a blend.
Run from root
Section titled “Run from root”% ./plume3d physics_constraint_hingeControls
Section titled “Controls”| Key | Action |
|---|---|
| WASD | Move FPS camera |
| Mouse drag | Look around |
| Space | Launch sphere / push door |
What it does
Section titled “What it does”- Loads
Models/HingeExample.blendand instantiates GameCamera, GameLight, Environment (static walls/floor), Door (hinge-constrained dynamic body), and Sphere. - Finds the door node by
Scene.findNodeById("door"). - Space launches the sphere toward the door; the hinge constraint limits rotation to one axis so the door swings open.
- Uses
Physics.addImpulseAtPointto apply an off-center impulse that creates swing torque. - FPS camera from blend via
FPSCamera.fromCamera. - Shadow mapping enabled.
Key pattern
Section titled “Key pattern”// Apply impulse at a point offset from door centerif (Input.keyJustPressed("space")) { var pos = _doorNode.getPosition() Physics.addImpulseAtPoint(_doorNode, 0, 0, -50, // impulse direction pos[0] + 2, pos[1], pos[2]) // off-center point}Blend setup
Section titled “Blend setup”Create Models/HingeExample.blend with the Plume3D addon:
| Object | Class | Rigid Body | Notes |
|---|---|---|---|
| Environment | Environment collection | Static walls/floor | — |
| Door | Door object | Active, Box | Add a Rigid Body Constraint: Hinge, anchored at door edge |
| Sphere | Sphere object | Active, Sphere | Launched by Space |
| Camera | GameCamera | — | Tag: game_camera |
| Light | GameLight | — | Tag: game_light |