std-physics2d
Level: Atom | Entity: PhysicsBody | Persistence: runtime
2 states, 5 events, 6 transitions
Live Preview
orbital PhysicsBodyOrbital {
entity PhysicsBody [runtime] {
id : string
name : string
description : string
status : string
createdAt : string
x : number
y : number
vx : number
vy : number
forceX : number
forceY : number
physicsStatus : string
}
trait PhysicsBodyPhysics -> PhysicsBody [interaction] {
initial: idle
state idle {
INIT -> idle
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "simulation-canvas", preset: "spring", width: 800, height: 400, running: false, speed: 1 }, { type: "button", label: "Start", event: "START", variant: "primary", icon: "play" }] })
START -> simulating
(set @entity.physicsStatus simulating)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "simulation-canvas", preset: "spring", width: 800, height: 400, running: true, speed: 1 }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Apply Force", event: "APPLY_FORCE", variant: "secondary", icon: "move" }, { type: "button", label: "Stop", event: "STOP", variant: "ghost", icon: "square" }] }] })
}
state simulating {
TICK -> simulating
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "simulation-canvas", preset: "spring", width: 800, height: 400, running: true, speed: 1 }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Apply Force", event: "APPLY_FORCE", variant: "secondary", icon: "move" }, { type: "button", label: "Stop", event: "STOP", variant: "ghost", icon: "square" }] }] })
APPLY_FORCE -> simulating
(set @entity.forceX @payload.forceX)
(set @entity.forceY @payload.forceY)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "simulation-canvas", preset: "spring", width: 800, height: 400, running: true, speed: 1 }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Apply Force", event: "APPLY_FORCE", variant: "secondary", icon: "move" }, { type: "button", label: "Stop", event: "STOP", variant: "ghost", icon: "square" }] }] })
STOP -> idle
(set @entity.physicsStatus idle)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "simulation-canvas", preset: "spring", width: 800, height: 400, running: false, speed: 1 }, { type: "button", label: "Start", event: "START", variant: "primary", icon: "play" }] })
INIT -> simulating
(render-ui main { type: "stack", direction: "vertical", gap: "lg", align: "center", children: [{ type: "simulation-canvas", preset: "spring", width: 800, height: 400, running: true, speed: 1 }, { type: "stack", direction: "horizontal", gap: "sm", justify: "center", children: [{ type: "button", label: "Apply Force", event: "APPLY_FORCE", variant: "secondary", icon: "move" }, { type: "button", label: "Stop", event: "STOP", variant: "ghost", icon: "square" }] }] })
}
}
page "/physicsbodys/physics" -> PhysicsBodyPhysics
}
Loading preview...
Orbital Visualization
Loading visualization...
Entity Fields
| Field | Type | Default |
|---|---|---|
| id | string | - |
| name | string | - |
| description | string | - |
| status | string | "active" |
| createdAt | string | - |
| x | number | 0 |
| y | number | 0 |
| vx | number | 0 |
| vy | number | 0 |
| forceX | number | 0 |
| forceY | number | 0 |
| physicsStatus | string | "idle" |
States
| State | Type |
|---|---|
| idle | Initial |
| simulating | - |
Events
| Event | Payload |
|---|---|
| INIT | - |
| START | - |
| STOP | - |
| TICK | - |
| APPLY_FORCE | forceX: number, forceY: number |
Transitions
| From | Event | To | Effects |
|---|---|---|---|
| idle | INIT | idle | 1 effect |
| idle | START | simulating | 2 effects |
| simulating | TICK | simulating | 1 effect |
| simulating | APPLY_FORCE | simulating | 3 effects |
| simulating | STOP | idle | 2 effects |
| simulating | INIT | simulating | 1 effect |