@origingame/engine 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/og.mjs +25 -0
- package/dist/web/origin-engine.d.ts +1233 -0
- package/dist/web/origin-engine.js +8628 -0
- package/dist/web/origin-engine_bg.wasm +0 -0
- package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
- package/dist/web-publish/origin-engine-lanes.js +8509 -0
- package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish/origin-engine.d.ts +1176 -0
- package/dist/web-publish/origin-engine.js +8313 -0
- package/dist/web-publish/origin-engine_bg.wasm +0 -0
- package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
- package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
- package/dist/web-publish-2d/origin-engine.js +8313 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/knowledge/README.md +31 -0
- package/knowledge/knowledge.json +13 -0
- package/knowledge/looks/catalogue.json +1871 -0
- package/knowledge/package.json +33 -0
- package/knowledge/rules/platform.json +329 -0
- package/knowledge/scaffold/README.md +27 -0
- package/knowledge/scaffold/distribution.json +48 -0
- package/knowledge/scaffold/origin-engine.json +19 -0
- package/knowledge/scaffold/template/.origin/setup +14 -0
- package/knowledge/scaffold/template/LICENSES.md +23 -0
- package/knowledge/scaffold/template/README.md +37 -0
- package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
- package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
- package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
- package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
- package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
- package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
- package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
- package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
- package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
- package/knowledge/scaffold/template/gitattributes +22 -0
- package/knowledge/scaffold/template/gitignore +8 -0
- package/knowledge/scaffold/template/package.json +18 -0
- package/knowledge/scaffold/template/project.ogt +25 -0
- package/knowledge/scaffold/template/src/main.ts +246 -0
- package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
- package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
- package/knowledge/scaffold/template/tsconfig.json +17 -0
- package/knowledge/scripts/lib.ts +207 -0
- package/knowledge/scripts/mount.ts +210 -0
- package/knowledge/scripts/pack.ts +25 -0
- package/knowledge/scripts/scaffold.ts +72 -0
- package/knowledge/scripts/validate.ts +749 -0
- package/knowledge/skills/og-ai/SKILL.md +386 -0
- package/knowledge/skills/og-audio/SKILL.md +191 -0
- package/knowledge/skills/og-build/SKILL.md +330 -0
- package/knowledge/skills/og-core/SKILL.md +285 -0
- package/knowledge/skills/og-feel/SKILL.md +385 -0
- package/knowledge/skills/og-game/SKILL.md +1479 -0
- package/knowledge/skills/og-i18n/SKILL.md +220 -0
- package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
- package/knowledge/skills/og-taste/SKILL.md +537 -0
- package/knowledge/skills/og-ui/SKILL.md +444 -0
- package/knowledge/wiki/ai.md +627 -0
- package/knowledge/wiki/anim.md +1187 -0
- package/knowledge/wiki/atmosphere.md +636 -0
- package/knowledge/wiki/audio.md +732 -0
- package/knowledge/wiki/camera.md +711 -0
- package/knowledge/wiki/commands.md +357 -0
- package/knowledge/wiki/game.md +220 -0
- package/knowledge/wiki/i18n.md +213 -0
- package/knowledge/wiki/index.md +1027 -0
- package/knowledge/wiki/input.md +1714 -0
- package/knowledge/wiki/load.md +1280 -0
- package/knowledge/wiki/math.md +166 -0
- package/knowledge/wiki/nav.md +1154 -0
- package/knowledge/wiki/physics.md +3142 -0
- package/knowledge/wiki/platform.md +857 -0
- package/knowledge/wiki/probe.md +1692 -0
- package/knowledge/wiki/reflect.md +285 -0
- package/knowledge/wiki/render.md +3511 -0
- package/knowledge/wiki/rng.md +393 -0
- package/knowledge/wiki/stream.md +376 -0
- package/knowledge/wiki/system.md +197 -0
- package/knowledge/wiki/systems.md +43 -0
- package/knowledge/wiki/terrain.md +727 -0
- package/knowledge/wiki/tilemap.md +422 -0
- package/knowledge/wiki/time.md +150 -0
- package/knowledge/wiki/transform.md +230 -0
- package/knowledge/wiki/tween.md +580 -0
- package/knowledge/wiki/ui.md +8000 -0
- package/knowledge/wiki/world.md +909 -0
- package/package.json +68 -4
- package/schema/api.schema.json +29675 -0
- package/shell/README.md +22 -0
- package/shell/brand/README.md +23 -0
- package/shell/brand/icon-192.png +0 -0
- package/shell/brand/icon-512.png +0 -0
- package/shell/brand/mark-on-paper.svg +6 -0
- package/shell/brand/origin-mark.svg +5 -0
- package/shell/brand/origin-motion.css +251 -0
- package/shell/brand/tokens.css +20 -0
- package/shell/brand.ts +132 -0
- package/shell/page.ts +715 -0
- package/shell/platform.ts +203 -0
- package/shell/player.ts +238 -0
- package/shell/shell.css +185 -0
- package/shell/sw.ts +177 -0
- package/shell/transport.ts +515 -0
- package/shell/wire.ts +369 -0
- package/src/e6.ts +69 -0
- package/src/env.d.ts +100 -0
- package/src/generated/abi.ts +980 -0
- package/src/index.ts +193 -0
- package/src/node/audio.ts +86 -0
- package/src/node/build.ts +109 -0
- package/src/node/device.ts +981 -0
- package/src/node/doctor.ts +60 -0
- package/src/node/index.ts +102 -0
- package/src/node/platform.ts +24 -0
- package/src/node/playtest-run.ts +249 -0
- package/src/node/png.ts +130 -0
- package/src/node/polish.ts +976 -0
- package/src/node/run.ts +373 -0
- package/src/node/web-build.ts +808 -0
- package/src/p2.ts +35 -0
- package/src/platform-local.ts +211 -0
- package/src/playtest.ts +131 -0
- package/src/runtime.ts +1509 -0
- package/src/systems/cameras.ts +247 -0
- package/src/ui-kit/bind.ts +141 -0
- package/src/ui-kit/huds.ts +303 -0
- package/src/ui-kit/index.ts +36 -0
- package/src/ui-kit/menus.ts +187 -0
- package/src/ui-kit/settings.ts +131 -0
- package/src/ui-kit/store.ts +222 -0
- package/src/ui-kit/story.ts +89 -0
- package/src/ui-kit/util.ts +106 -0
- package/src/web/a11y.ts +429 -0
- package/src/web/audio-worklet.ts +193 -0
- package/src/web/audio.ts +307 -0
- package/src/web/basis.ts +239 -0
- package/src/web/gamepad.ts +123 -0
- package/src/web/host.ts +166 -0
- package/src/web/input.ts +237 -0
- package/src/web/lanes.ts +21 -0
- package/src/web/play.ts +20 -0
- package/src/web/rpc-ring.ts +110 -0
- package/src/web/settle.ts +122 -0
- package/src/web/shell.ts +643 -0
- package/src/web/text-input.ts +248 -0
- package/src/web/worker.ts +1002 -0
- package/types/bindings.json +13654 -0
- package/types/index.d.ts +20090 -0
- package/vendor/basis/LICENSE +201 -0
- package/vendor/basis/NOTICE +15 -0
- package/vendor/basis/README.md +18 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/README.md +0 -3
|
@@ -0,0 +1,3142 @@
|
|
|
1
|
+
<!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
|
|
2
|
+
|
|
3
|
+
# The `physics` module
|
|
4
|
+
|
|
5
|
+
Rigid bodies over rapier (rapier3d in the 3D profile, rapier2d in 2D, both with enhanced determinism): game code owns the components, the engine's og.physics system steps them after the game's systems and writes the dynamic bodies back.
|
|
6
|
+
|
|
7
|
+
The profile is the project's (`profile "2d"` or `"3d"` in project.ogt). In 2D, bodies move in the xy plane and rotate about z; a transform keeps its z. A collider without a RigidBody is static at its transform.
|
|
8
|
+
|
|
9
|
+
The rapier world persists between ticks and is world state: snapshots, restore and the world hash cover the whole simulation. Events sent in tick N are read in tick N + 1.
|
|
10
|
+
|
|
11
|
+
- **TypeScript**: functions are the namespace `og.physics`; components, resources and events are tokens on `og`.
|
|
12
|
+
- **Publish builds**: kept (members may override).
|
|
13
|
+
- **Skill**: `og-game`, which teaches the module (how much of it to use, and how to prove it).
|
|
14
|
+
- **Index**: [every module and name](index.md).
|
|
15
|
+
|
|
16
|
+
```ogt
|
|
17
|
+
module physics {
|
|
18
|
+
# declarations follow, each quoted below
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
<sub>`api.ogt` line 3696</sub>
|
|
22
|
+
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
| Name | Kind | Summary |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| [`BODY_DYNAMIC`](#const-BODY_DYNAMIC) | constant | RigidBody.kind: moved by the solver; its Transform and Velocity are written back every tick. |
|
|
28
|
+
| [`BODY_STATIC`](#const-BODY_STATIC) | constant | RigidBody.kind: never moves; collides with dynamic bodies. |
|
|
29
|
+
| [`BODY_KINEMATIC`](#const-BODY_KINEMATIC) | constant | RigidBody.kind: not moved by the solver. With an og.Velocity the step moves it by it each tick and writes its Transform back (a lift, a conveyor, a turning gear); a Transform game code writes moves it there first (a teleport). Without one it stays where its Transform puts it. Either way it pushes dynamic bodies and carries the controllers standing on it. |
|
|
30
|
+
| [`LOCK_TRANSLATION_X`](#const-LOCK_TRANSLATION_X) | constant | RigidBody.lock bit: no translation along x. |
|
|
31
|
+
| [`LOCK_TRANSLATION_Y`](#const-LOCK_TRANSLATION_Y) | constant | RigidBody.lock bit: no translation along y. |
|
|
32
|
+
| [`LOCK_TRANSLATION_Z`](#const-LOCK_TRANSLATION_Z) | constant | RigidBody.lock bit: no translation along z. |
|
|
33
|
+
| [`LOCK_ROTATION_X`](#const-LOCK_ROTATION_X) | constant | RigidBody.lock bit: no rotation about x. |
|
|
34
|
+
| [`LOCK_ROTATION_Y`](#const-LOCK_ROTATION_Y) | constant | RigidBody.lock bit: no rotation about y. |
|
|
35
|
+
| [`LOCK_ROTATION_Z`](#const-LOCK_ROTATION_Z) | constant | RigidBody.lock bit: no rotation about z (the 2D profile's only rotation). |
|
|
36
|
+
| [`SHAPE_BOX`](#const-SHAPE_BOX) | constant | Collider.shape: a box of `size` (both profiles). |
|
|
37
|
+
| [`SHAPE_SPHERE`](#const-SHAPE_SPHERE) | constant | Collider.shape: a sphere of `radius` (a circle in 2D). |
|
|
38
|
+
| [`SHAPE_CAPSULE`](#const-SHAPE_CAPSULE) | constant | Collider.shape: a capsule along y of `radius`, with `height` between the cap centres (both profiles). |
|
|
39
|
+
| [`SHAPE_CYLINDER`](#const-SHAPE_CYLINDER) | constant | Collider.shape: a cylinder along y of `radius` and `height` (3D only). |
|
|
40
|
+
| [`SHAPE_CONVEX`](#const-SHAPE_CONVEX) | constant | Collider.shape: the convex hull of the vertices of `mesh` (3D), or of their xy (a convex polygon, 2D). |
|
|
41
|
+
| [`SHAPE_TRIMESH`](#const-SHAPE_TRIMESH) | constant | Collider.shape: the triangles of `mesh` (3D only; for static and kinematic bodies). |
|
|
42
|
+
| [`SHAPE_HEIGHTFIELD`](#const-SHAPE_HEIGHTFIELD) | constant | Collider.shape: the height field registered as `mesh`, centred on the entity (3D only; a terrain: og.terrain.load's TerrainInfo.geometry). |
|
|
43
|
+
| [`PROFILE_2D`](#const-PROFILE_2D) | constant | Physics.profile: rapier2d, bodies in the xy plane rotating about z. |
|
|
44
|
+
| [`PROFILE_3D`](#const-PROFILE_3D) | constant | Physics.profile: rapier3d. |
|
|
45
|
+
| [`og.RigidBody`](#record-RigidBody) | component | A body the physics step simulates. It needs an og.Transform and usually has an og.Collider; a dynamic body without an og.Velocity gets one. |
|
|
46
|
+
| [`og.Collider`](#record-Collider) | component | The shape an entity collides with, attached to its RigidBody (or, without one, a static collider at its Transform). Sizes are scaled by og.Transform.scale. |
|
|
47
|
+
| [`og.Velocity`](#record-Velocity) | component | Linear and angular velocity. Written for dynamic bodies every tick (added to them by the step when missing); a kinematic body moves by it each tick (never added, never written). Set it to launch or stop a body; push one with og.physics.applyForce, applyImpulse, applyTorque or applyTorqueImpulse. |
|
|
48
|
+
| [`og.Physics`](#record-Physics) | resource | The physics settings of the world. The profile is the project's; the same components serve both profiles. |
|
|
49
|
+
| [`og.CollisionStarted`](#record-CollisionStarted) | event | Two solid colliders started touching during the tick. |
|
|
50
|
+
| [`og.CollisionEnded`](#record-CollisionEnded) | event | Two solid colliders stopped touching, or one of them went away. |
|
|
51
|
+
| [`og.SensorEntered`](#record-SensorEntered) | event | A collider started overlapping a sensor. |
|
|
52
|
+
| [`og.SensorExited`](#record-SensorExited) | event | A collider stopped overlapping a sensor, or one of them went away. |
|
|
53
|
+
| [`og.Contact`](#record-Contact) | event | One pair in contact at the end of a step, sent every tick for every touching pair: how a game asks what is touching what right now. |
|
|
54
|
+
| [`JOINT_FIXED`](#const-JOINT_FIXED) | constant | `Joint.kind`: the two bodies move as one. |
|
|
55
|
+
| [`JOINT_REVOLUTE`](#const-JOINT_REVOLUTE) | constant | `Joint.kind`: a hinge about `axis` (2D: about z), with optional limits and a motor. |
|
|
56
|
+
| [`JOINT_PRISMATIC`](#const-JOINT_PRISMATIC) | constant | `Joint.kind`: a slider along `axis`, with optional limits and a motor. |
|
|
57
|
+
| [`JOINT_SPRING`](#const-JOINT_SPRING) | constant | `Joint.kind`: a damped spring pulling the anchors to `restLength` apart. |
|
|
58
|
+
| [`JOINT_ROPE`](#const-JOINT_ROPE) | constant | `Joint.kind`: a rope: the anchors stay at most `length` apart, free inside it. |
|
|
59
|
+
| [`JOINT_BALL`](#const-JOINT_BALL) | constant | `Joint.kind`: a ball and socket (3D; the 2D profile treats it as a hinge). |
|
|
60
|
+
| [`MOTOR_NONE`](#const-MOTOR_NONE) | constant | `Joint.motor`: no motor. |
|
|
61
|
+
| [`MOTOR_VELOCITY`](#const-MOTOR_VELOCITY) | constant | `Joint.motor`: drive towards `motorTarget` speed (rad/s or m/s). |
|
|
62
|
+
| [`MOTOR_POSITION`](#const-MOTOR_POSITION) | constant | `Joint.motor`: spring towards `motorTarget` angle or position (a servo). |
|
|
63
|
+
| [`og.Joint`](#record-Joint) | component | A joint between two bodies (or a body and a point of the world). The component may sit on one of the bodies (`body` 0) or on an entity of its own, so one body can have several joints. Anchors are in each body's frame (rotated and moved with it, not scaled); without `other` the second anchor is a world point. A joint whose bodies are not both `og.RigidBody` entities does nothing until they are. |
|
|
64
|
+
| [`og.CharacterController`](#record-CharacterController) | component | A kinematic character (3D, or top-down 2D): the entity's capsule (or any og.Collider) moved by `move` each tick, sliding along walls, climbing slopes up to `maxSlope` and steps up to `stepHeight`, snapped to the ground, carried by the moving platform it stands on and falling by gravity. It keeps `skin` off every surface, standing that far over the ground; a step is climbed when the ground beyond it is at most `stepHeight` over the ground it stands on. What blocks it is every solid collider its og.Collider's `layers` and `mask` interact with (each one's layers meeting the other's mask), as for bodies. The entity needs an og.Transform and an og.Collider; the step makes it a kinematic body and pushes dynamic bodies it walks into. |
|
|
65
|
+
| [`og.PlatformerController`](#record-PlatformerController) | component | A 2D platformer character (the 2D profile): run, jump and fall with designer units (jump height and time to apex, not gravity), coyote time, jump buffering, variable jump height (releasing jump while rising cuts the jump), apex hang, air jumps, wall slide and wall jump, one-way platforms (colliders on `oneWayLayers` are solid from above only; hold `down` to drop through), moving platforms (it rides what it stands on) and corner correction (a jump that clips a ceiling corner by less than `cornerCorrection` slides past it). It keeps `skin` off every surface; what blocks it is every solid collider its og.Collider's `layers` and `mask` interact with (each one's layers meeting the other's mask), as for bodies. The entity needs an og.Transform and an og.Collider (a box or capsule); it becomes a kinematic body. |
|
|
66
|
+
| [`CHARACTER_JUMPED`](#const-CHARACTER_JUMPED) | constant | `CharacterEvent.kind`: a jump from the ground (or in coyote time). |
|
|
67
|
+
| [`CHARACTER_LANDED`](#const-CHARACTER_LANDED) | constant | `CharacterEvent.kind`: touched the ground after being in the air. |
|
|
68
|
+
| [`CHARACTER_WALL_JUMPED`](#const-CHARACTER_WALL_JUMPED) | constant | `CharacterEvent.kind`: a jump off a wall. |
|
|
69
|
+
| [`CHARACTER_AIR_JUMPED`](#const-CHARACTER_AIR_JUMPED) | constant | `CharacterEvent.kind`: a jump in the air (PlatformerController.airJumps). |
|
|
70
|
+
| [`CHARACTER_LEFT_GROUND`](#const-CHARACTER_LEFT_GROUND) | constant | `CharacterEvent.kind`: left the ground without jumping (ran off an edge). |
|
|
71
|
+
| [`CHARACTER_BUMPED`](#const-CHARACTER_BUMPED) | constant | `CharacterEvent.kind`: hit a ceiling while rising. |
|
|
72
|
+
| [`og.CharacterEvent`](#record-CharacterEvent) | event | Something a CharacterController or PlatformerController did this step: the hooks for dust, squash, sounds and camera kicks. Read the next tick. |
|
|
73
|
+
| [`DRIVE_REAR`](#const-DRIVE_REAR) | constant | `Vehicle.drive`: the rear wheels drive. |
|
|
74
|
+
| [`DRIVE_FRONT`](#const-DRIVE_FRONT) | constant | `Vehicle.drive`: the front wheels drive. |
|
|
75
|
+
| [`DRIVE_ALL`](#const-DRIVE_ALL) | constant | `Vehicle.drive`: every wheel drives. |
|
|
76
|
+
| [`og.Vehicle`](#record-Vehicle) | component | A car on a dynamic chassis (the entity's og.RigidBody and og.Collider). 3D: a raycast car with four wheels (suspension, grip, steering on the front axle); its forward is the chassis's local +z (three.js Object3D.lookAt aims +z). 2D: two wheel bodies on sprung wheel joints (front at +x), driven by a motor. The wheels are not entities: og.physics.vehicleWheels gives their poses (and each tyre's slip) for drawing, smoke and skid marks. |
|
|
77
|
+
| [`og.Rope`](#record-Rope) | component | A Verlet rope: `segments` links from the entity's world position (its og.Transform after its parents'; plus `offset`) to `end` (an entity, plus `endOffset`) or hanging free, swung by gravity and wind, colliding with every solid collider at `radius`. It moves nothing (one-way: a rope joint ties bodies together, og.Joint JOINT_ROPE). Its points are world state (the og.physics state block); og.physics.ropePoints reads them and the renderer draws the rope as a strip of `width` and `color`. |
|
|
78
|
+
| [`PIN_TOP`](#const-PIN_TOP) | constant | `Cloth.pins` bit: the whole top row is pinned. |
|
|
79
|
+
| [`PIN_TOP_CORNERS`](#const-PIN_TOP_CORNERS) | constant | `Cloth.pins` bit: the top-left and top-right corners are pinned. |
|
|
80
|
+
| [`PIN_LEFT`](#const-PIN_LEFT) | constant | `Cloth.pins` bit: the whole left column is pinned (a flag on a pole). |
|
|
81
|
+
| [`PIN_TOP_RINGS`](#const-PIN_TOP_RINGS) | constant | `Cloth.pins` bit: every fourth point of the top row (curtain rings). |
|
|
82
|
+
| [`og.Cloth`](#record-Cloth) | component | A Verlet cloth: a `columns` × `rows` grid of points, `spacing` apart, hanging from the entity's world position (its og.Transform after its parents': its top-left corner, the grid laid out along the entity's local x and down -y), pinned by `pins` (pinned points follow the entity), with stretch and shear constraints, gravity, wind, collision against every solid collider and, with `thickness`, against itself. One-way like og.Rope; its points are world state. Drawn as a double-sided mesh with `material` (og.render.standardMaterial; 0: a plain cloth colour). |
|
|
83
|
+
| [`og.Fluid2D`](#record-Fluid2D) | component | A 2D particle fluid (any profile, in the xy plane): `count` particles spawned in a `size` box centred on the entity, simulated with double density relaxation (Clavet et al. 2005: pressure, near pressure, viscosity) on a fixed grid in a fixed order, so it is deterministic and part of the og.physics state block. Particles collide with every solid collider (pushed out of bodies; they push nothing back) and stay inside `bounds` around the entity when it is set. Fluids of one `group` interact: by `density` they layer, by `mixing` they blend. Drawn as metaballs: the particles blurred into a field the renderer thresholds into one surface of `color`, on sprite layer `layer`. |
|
|
84
|
+
| [`og.Fluid3D`](#record-Fluid3D) | component | A 3D particle fluid (the 3D profile): `count` particles spawned in a `size` box centred on the entity, simulated with double density relaxation (Clavet et al. 2005: pressure, near pressure that gives surface tension, viscosity) over a spatial hash in a fixed order, so it is deterministic and part of the og.physics state block. Particles collide with every solid collider, the terrain's height field included (pushed out; they push nothing back), and stay inside `bounds` around the entity when it is set. An emitter adds particles at `emitRate` up to `maxCount`; a sink box removes those that enter it. Fluids of one `group` interact: by `density` they layer, by `mixing` they blend. Drawn as a screen-space surface: the particles' depth smoothed into one surface, refracting what is behind by its thickness and reflecting the sky, lit by the scene's lights. Cost: about 0.9 ms of CPU a tick for 2000 particles at 1 substep, 1.8 ms at 2 (native and wasm alike), growing with the particles; keep a scene's fluids to a few thousand particles. The surface costs about 1.1 ms of GPU (an Apple M4 Pro, the fluid covering a third of a 1280×720 frame) whatever the particle count, growing with the pixels it covers. |
|
|
85
|
+
| [`og.WaterSurface`](#record-WaterSurface) | component | Height-field water (3D): a `resolution` × `resolution` grid of heights over a `size` square centred on the entity (its y is the rest level), waves travelling at `waveSpeed` and fading by `damping`. Dynamic bodies crossing it push waves (splashes; og.Splash events) and float by `buoyancy`. The heights are world state; an og.Water on the same entity draws them. |
|
|
86
|
+
| [`og.WaterLine`](#record-WaterLine) | component | 2D water for side-scrollers: a `width` × `depth` pool whose top edge (at the entity's y, centred on its x) is `columns` springs, each pulled to its rest height by `tension`, damped by `damping` and passing waves to its neighbours by `spread`. Bodies (and characters) crossing the surface splash it (og.Splash events) and float by `buoyancy`. The springs are world state; an og.Water2D on the same entity draws it. |
|
|
87
|
+
| [`og.Splash`](#record-Splash) | event | Something crossed a water surface (og.WaterSurface or og.WaterLine): for splash particles and sounds. Read the next tick. |
|
|
88
|
+
| [`og.Ragdoll`](#record-Ragdoll) | component | A ragdoll over an og.Skeleton: a capsule body per bone with a parent, joints with limits between them (ball joints with cone limits in 3D; in 2D hinges about z, the bones rapier2d bodies in the xy plane at their animated z, for a skeleton laid out in that plane), built from the skeleton's rest pose. `weight` is where the pose comes from: 0 the animation (the bodies follow it kinematically), 1 the physics (the bodies are dynamic, starting with the animation's velocity); the pose drawn blends between them over `blendTime`, both ways. The bodies are world state (the og.physics state block), not entities. |
|
|
89
|
+
| [`QueryFilter`](#type-QueryFilter) | desc struct | Which colliders a scene query considers. The zero value considers every solid collider on every layer. |
|
|
90
|
+
| [`RaycastDesc`](#type-RaycastDesc) | desc struct | A ray for og.physics.raycast. |
|
|
91
|
+
| [`RaycastHit`](#type-RaycastHit) | struct | The nearest collider a ray meets. |
|
|
92
|
+
| [`ShapeDesc`](#type-ShapeDesc) | desc struct | The shape of a shape cast or an overlap test: the shape fields of a Collider. The zero value is a 1 m box. |
|
|
93
|
+
| [`ShapeCastDesc`](#type-ShapeCastDesc) | desc struct | A shape swept along a direction for og.physics.shapeCast. |
|
|
94
|
+
| [`ShapeCastHit`](#type-ShapeCastHit) | struct | The first collider a swept shape meets. |
|
|
95
|
+
| [`OverlapDesc`](#type-OverlapDesc) | desc struct | A shape placed in the world for og.physics.overlap. |
|
|
96
|
+
| [`MeshDesc`](#type-MeshDesc) | desc struct | Geometry for convex and triangle-mesh colliders, in the mesh's own space. |
|
|
97
|
+
| [`og.physics.raycast`](#fn-raycast) | function | The nearest collider along a ray. Inside a system it sees the colliders as they were at the start of the tick (og.physics.queries records them before the game's systems); between ticks, as the world holds them. |
|
|
98
|
+
| [`og.physics.shapeCast`](#fn-shapeCast) | function | The first collider a shape meets when swept along a direction; the same view of the colliders as raycast. |
|
|
99
|
+
| [`og.physics.overlap`](#fn-overlap) | function | Every collider overlapping a shape, sorted by entity id; the same view of the colliders as raycast. |
|
|
100
|
+
| [`og.physics.applyForce`](#fn-applyForce) | function | Push a dynamic body with a force (N, world axes) over the next physics step, at a world point or its centre of mass: call it every tick for a steady force (thrust, wind, a car's downforce or an anti-roll assist). Applied by the og.physics step after the systems, in the order given, then gone; a hit stop drops it. Kinematic and static bodies ignore it. Pushes not yet applied are world state (in snapshots and the hash). |
|
|
101
|
+
| [`og.physics.applyImpulse`](#fn-applyImpulse) | function | Give a dynamic body an impulse (N·s, world axes) at a world point or its centre of mass: a sudden change of momentum (a kick, a hit, a jump: its velocity changes by impulse / mass), applied by the next physics step (after a hit stop ends). As applyForce otherwise. |
|
|
102
|
+
| [`og.physics.applyTorque`](#fn-applyTorque) | function | Turn a dynamic body with a torque (N·m about each world axis; 2D uses z) over the next physics step, as applyForce: call it every tick for a steady twist. |
|
|
103
|
+
| [`og.physics.applyTorqueImpulse`](#fn-applyTorqueImpulse) | function | Give a dynamic body an angular impulse (N·m·s about each world axis; 2D uses z): its spin changes at once, as applyImpulse. |
|
|
104
|
+
| [`og.physics.setMesh`](#fn-setMesh) | function | Register (or replace) the geometry a convex or triangle-mesh Collider names by its mesh handle. Loaded glTF geometries are registered under their own handles already; meshes are assets, not world state: world.snapshot carries a mesh, convex-hull or height-field collider by its handle and scale, not its triangles, and world.restore rebuilds the collider from the geometry registered then (so load or register it before restoring; a save naming one that is not is refused). |
|
|
105
|
+
| [`WheelPose`](#type-WheelPose) | struct | A wheel of an og.Vehicle as the last step left it, for drawing. |
|
|
106
|
+
| [`RagdollBoneDesc`](#type-RagdollBoneDesc) | desc struct | One bone of a ragdoll rig: a capsule from the bone's position along `axis` for `length`. |
|
|
107
|
+
| [`RagdollRigDesc`](#type-RagdollRigDesc) | desc struct | The bones of a ragdoll, parents first, for og.physics.setRagdollRig; og.physics.ragdollRigFromSkeleton makes one from a model's skeleton. |
|
|
108
|
+
| [`BonePose`](#type-BonePose) | struct | A ragdoll bone's pose as the last step left it (blended with the animation by og.Ragdoll.weight). |
|
|
109
|
+
| [`og.physics.ropePoints`](#fn-ropePoints) | function | An og.Rope's points after the last step, from its entity to its end (empty before its first step). The engine draws visible ropes itself; this is for game logic and custom drawing. |
|
|
110
|
+
| [`og.physics.clothPoints`](#fn-clothPoints) | function | An og.Cloth's points after the last step, row by row (`columns` per row, rows downwards from the top edge). |
|
|
111
|
+
| [`og.physics.fluidParticles`](#fn-fluidParticles) | function | An og.Fluid2D's particle positions after the last step, in world space. |
|
|
112
|
+
| [`og.physics.fluid3dParticles`](#fn-fluid3dParticles) | function | An og.Fluid3D's particle positions after the last step, in world space (emitted particles last, in the order they appeared). |
|
|
113
|
+
| [`og.physics.waterHeight`](#fn-waterHeight) | function | The surface height of an og.WaterSurface (world y) or an og.WaterLine (world y at `x`; `z` ignored) at a point, as the last step left it: for boats that bob and spray that starts on the surface. |
|
|
114
|
+
| [`og.physics.vehicleWheels`](#fn-vehicleWheels) | function | An og.Vehicle's wheels after the last step (front left, front right, rear left, rear right), for drawing wheel models. |
|
|
115
|
+
| [`og.physics.ragdollRigFromSkeleton`](#fn-ragdollRigFromSkeleton) | function | A ragdoll rig from a loaded skeleton (og.load.animation's `skeleton`): a bone per joint of its first skin, parents first, each from its joint's rest pose to its first child joint, every bone naming its joint and the rig naming the skeleton. Pass it to og.physics.setRagdollRig, edited or not. |
|
|
116
|
+
| [`og.physics.setRagdollRig`](#fn-setRagdollRig) | function | Give an entity with an og.Ragdoll its bones (and, from og.physics.ragdollRigFromSkeleton, the skeleton they stand for: its og.Model is then drawn blended from the animation towards the bones by og.Ragdoll.blend). While weight is 0 the bones follow the rig's rest pose at the entity. Rigs are assets, not world state: kept by the engine and given again to a reloaded world. |
|
|
117
|
+
| [`og.physics.ragdollPose`](#fn-ragdollPose) | function | An og.Ragdoll's bones after the last step, in rig order (empty before its first step). |
|
|
118
|
+
| [`PhysicsPhase`](#type-PhysicsPhase) | struct | One phase of the last physics step, for og.physics.stats. |
|
|
119
|
+
| [`PhysicsStats`](#type-PhysicsStats) | struct | What the last physics step cost, phase by phase, and where it ran: for finding where physics time goes. Timings are wall clock and vary run to run; the simulation never reads them. |
|
|
120
|
+
| [`og.physics.stats`](#fn-stats) | function | What the last physics step cost: each phase's time and whether it ran on the lanes pool. All zero before the first step. |
|
|
121
|
+
|
|
122
|
+
## Functions
|
|
123
|
+
|
|
124
|
+
<a id="fn-raycast"></a>
|
|
125
|
+
|
|
126
|
+
### `og.physics.raycast`
|
|
127
|
+
|
|
128
|
+
The nearest collider along a ray. Inside a system it sees the colliders as they were at the start of the tick (og.physics.queries records them before the game's systems); between ticks, as the world holds them.
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
og.physics.raycast(world: World, desc?: RaycastDesc): Result<RaycastHit | null>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
| Parameter | Type | Optional | Doc |
|
|
135
|
+
|---|---|---|---|
|
|
136
|
+
| `world` | `World` | no | The world. |
|
|
137
|
+
| `desc` | `RaycastDesc` | yes | The ray and the filter. |
|
|
138
|
+
|
|
139
|
+
**Returns** `Result<RaycastHit | null>`: The hit, or null when nothing is hit; refused for a zero direction.
|
|
140
|
+
|
|
141
|
+
Binding symbol `og_physics_raycast` · publish builds: kept
|
|
142
|
+
|
|
143
|
+
```ogt
|
|
144
|
+
fn raycast {
|
|
145
|
+
doc "The nearest collider along a ray. Inside a system it sees the colliders as they were at the start of the tick (og.physics.queries records them before the game's systems); between ticks, as the world holds them."
|
|
146
|
+
param world World "The world."
|
|
147
|
+
param desc RaycastDesc "The ray and the filter."
|
|
148
|
+
returns Result.Option.RaycastHit "The hit, or null when nothing is hit; refused for a zero direction."
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
<sub>`api.ogt` line 5004</sub>
|
|
153
|
+
|
|
154
|
+
<a id="fn-shapeCast"></a>
|
|
155
|
+
|
|
156
|
+
### `og.physics.shapeCast`
|
|
157
|
+
|
|
158
|
+
The first collider a shape meets when swept along a direction; the same view of the colliders as raycast.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
og.physics.shapeCast(world: World, desc?: ShapeCastDesc): Result<ShapeCastHit | null>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Parameter | Type | Optional | Doc |
|
|
165
|
+
|---|---|---|---|
|
|
166
|
+
| `world` | `World` | no | The world. |
|
|
167
|
+
| `desc` | `ShapeCastDesc` | yes | The shape, its sweep and the filter. |
|
|
168
|
+
|
|
169
|
+
**Returns** `Result<ShapeCastHit | null>`: The hit, or null; refused for a zero direction or an unknown mesh.
|
|
170
|
+
|
|
171
|
+
Binding symbol `og_physics_shape_cast` · publish builds: kept
|
|
172
|
+
|
|
173
|
+
```ogt
|
|
174
|
+
fn shapeCast {
|
|
175
|
+
doc "The first collider a shape meets when swept along a direction; the same view of the colliders as raycast."
|
|
176
|
+
param world World "The world."
|
|
177
|
+
param desc ShapeCastDesc "The shape, its sweep and the filter."
|
|
178
|
+
returns Result.Option.ShapeCastHit "The hit, or null; refused for a zero direction or an unknown mesh."
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
<sub>`api.ogt` line 5011</sub>
|
|
183
|
+
|
|
184
|
+
<a id="fn-overlap"></a>
|
|
185
|
+
|
|
186
|
+
### `og.physics.overlap`
|
|
187
|
+
|
|
188
|
+
Every collider overlapping a shape, sorted by entity id; the same view of the colliders as raycast.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
og.physics.overlap(world: World, desc?: OverlapDesc): Result<readonly Entity[]>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
| Parameter | Type | Optional | Doc |
|
|
195
|
+
|---|---|---|---|
|
|
196
|
+
| `world` | `World` | no | The world. |
|
|
197
|
+
| `desc` | `OverlapDesc` | yes | The shape, its placement and the filter. |
|
|
198
|
+
|
|
199
|
+
**Returns** `Result<readonly Entity[]>`.
|
|
200
|
+
|
|
201
|
+
Binding symbol `og_physics_overlap` · publish builds: kept
|
|
202
|
+
|
|
203
|
+
```ogt
|
|
204
|
+
fn overlap {
|
|
205
|
+
doc "Every collider overlapping a shape, sorted by entity id; the same view of the colliders as raycast."
|
|
206
|
+
param world World "The world."
|
|
207
|
+
param desc OverlapDesc "The shape, its placement and the filter."
|
|
208
|
+
returns Result.List.Entity
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
<sub>`api.ogt` line 5018</sub>
|
|
213
|
+
|
|
214
|
+
<a id="fn-applyForce"></a>
|
|
215
|
+
|
|
216
|
+
### `og.physics.applyForce`
|
|
217
|
+
|
|
218
|
+
Push a dynamic body with a force (N, world axes) over the next physics step, at a world point or its centre of mass: call it every tick for a steady force (thrust, wind, a car's downforce or an anti-roll assist). Applied by the og.physics step after the systems, in the order given, then gone; a hit stop drops it. Kinematic and static bodies ignore it. Pushes not yet applied are world state (in snapshots and the hash).
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
og.physics.applyForce(world: World, entity: Entity, force: Vector3, point?: Vector3): Result<void>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
| Parameter | Type | Optional | Doc |
|
|
225
|
+
|---|---|---|---|
|
|
226
|
+
| `world` | `World` | no | The world. |
|
|
227
|
+
| `entity` | `Entity` | no | The body's entity (an og.RigidBody). |
|
|
228
|
+
| `force` | `Vector3` | no | The force in newtons (2D uses x and y). |
|
|
229
|
+
| `point` | `Vector3` | yes | Where it acts, in world space; omitted is the centre of mass (no spin). |
|
|
230
|
+
|
|
231
|
+
**Returns** `Result<void>`: Refused for an entity without an og.RigidBody, or a force or point that is not finite.
|
|
232
|
+
|
|
233
|
+
Binding symbol `og_physics_apply_force` · publish builds: kept
|
|
234
|
+
|
|
235
|
+
```ogt
|
|
236
|
+
fn applyForce {
|
|
237
|
+
doc "Push a dynamic body with a force (N, world axes) over the next physics step, at a world point or its centre of mass: call it every tick for a steady force (thrust, wind, a car's downforce or an anti-roll assist). Applied by the og.physics step after the systems, in the order given, then gone; a hit stop drops it. Kinematic and static bodies ignore it. Pushes not yet applied are world state (in snapshots and the hash)."
|
|
238
|
+
param world World "The world."
|
|
239
|
+
param entity Entity "The body's entity (an og.RigidBody)."
|
|
240
|
+
param force Vector3 "The force in newtons (2D uses x and y)."
|
|
241
|
+
param point Vector3 "Where it acts, in world space; omitted is the centre of mass (no spin)." {
|
|
242
|
+
optional true
|
|
243
|
+
}
|
|
244
|
+
returns Result.Void "Refused for an entity without an og.RigidBody, or a force or point that is not finite."
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
<sub>`api.ogt` line 5025</sub>
|
|
249
|
+
|
|
250
|
+
<a id="fn-applyImpulse"></a>
|
|
251
|
+
|
|
252
|
+
### `og.physics.applyImpulse`
|
|
253
|
+
|
|
254
|
+
Give a dynamic body an impulse (N·s, world axes) at a world point or its centre of mass: a sudden change of momentum (a kick, a hit, a jump: its velocity changes by impulse / mass), applied by the next physics step (after a hit stop ends). As applyForce otherwise.
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
og.physics.applyImpulse(world: World, entity: Entity, impulse: Vector3, point?: Vector3): Result<void>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
| Parameter | Type | Optional | Doc |
|
|
261
|
+
|---|---|---|---|
|
|
262
|
+
| `world` | `World` | no | The world. |
|
|
263
|
+
| `entity` | `Entity` | no | The body's entity (an og.RigidBody). |
|
|
264
|
+
| `impulse` | `Vector3` | no | The impulse in newton-seconds (2D uses x and y). |
|
|
265
|
+
| `point` | `Vector3` | yes | Where it acts, in world space; omitted is the centre of mass. |
|
|
266
|
+
|
|
267
|
+
**Returns** `Result<void>`: Refused for an entity without an og.RigidBody, or an impulse or point that is not finite.
|
|
268
|
+
|
|
269
|
+
Binding symbol `og_physics_apply_impulse` · publish builds: kept
|
|
270
|
+
|
|
271
|
+
```ogt
|
|
272
|
+
fn applyImpulse {
|
|
273
|
+
doc "Give a dynamic body an impulse (N·s, world axes) at a world point or its centre of mass: a sudden change of momentum (a kick, a hit, a jump: its velocity changes by impulse / mass), applied by the next physics step (after a hit stop ends). As applyForce otherwise."
|
|
274
|
+
param world World "The world."
|
|
275
|
+
param entity Entity "The body's entity (an og.RigidBody)."
|
|
276
|
+
param impulse Vector3 "The impulse in newton-seconds (2D uses x and y)."
|
|
277
|
+
param point Vector3 "Where it acts, in world space; omitted is the centre of mass." {
|
|
278
|
+
optional true
|
|
279
|
+
}
|
|
280
|
+
returns Result.Void "Refused for an entity without an og.RigidBody, or an impulse or point that is not finite."
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
<sub>`api.ogt` line 5036</sub>
|
|
285
|
+
|
|
286
|
+
<a id="fn-applyTorque"></a>
|
|
287
|
+
|
|
288
|
+
### `og.physics.applyTorque`
|
|
289
|
+
|
|
290
|
+
Turn a dynamic body with a torque (N·m about each world axis; 2D uses z) over the next physics step, as applyForce: call it every tick for a steady twist.
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
og.physics.applyTorque(world: World, entity: Entity, torque: Vector3): Result<void>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
| Parameter | Type | Optional | Doc |
|
|
297
|
+
|---|---|---|---|
|
|
298
|
+
| `world` | `World` | no | The world. |
|
|
299
|
+
| `entity` | `Entity` | no | The body's entity (an og.RigidBody). |
|
|
300
|
+
| `torque` | `Vector3` | no | The torque in newton-metres. |
|
|
301
|
+
|
|
302
|
+
**Returns** `Result<void>`: Refused for an entity without an og.RigidBody, or a torque that is not finite.
|
|
303
|
+
|
|
304
|
+
Binding symbol `og_physics_apply_torque` · publish builds: kept
|
|
305
|
+
|
|
306
|
+
```ogt
|
|
307
|
+
fn applyTorque {
|
|
308
|
+
doc "Turn a dynamic body with a torque (N·m about each world axis; 2D uses z) over the next physics step, as applyForce: call it every tick for a steady twist."
|
|
309
|
+
param world World "The world."
|
|
310
|
+
param entity Entity "The body's entity (an og.RigidBody)."
|
|
311
|
+
param torque Vector3 "The torque in newton-metres."
|
|
312
|
+
returns Result.Void "Refused for an entity without an og.RigidBody, or a torque that is not finite."
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
<sub>`api.ogt` line 5047</sub>
|
|
317
|
+
|
|
318
|
+
<a id="fn-applyTorqueImpulse"></a>
|
|
319
|
+
|
|
320
|
+
### `og.physics.applyTorqueImpulse`
|
|
321
|
+
|
|
322
|
+
Give a dynamic body an angular impulse (N·m·s about each world axis; 2D uses z): its spin changes at once, as applyImpulse.
|
|
323
|
+
|
|
324
|
+
```ts
|
|
325
|
+
og.physics.applyTorqueImpulse(world: World, entity: Entity, torque: Vector3): Result<void>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
| Parameter | Type | Optional | Doc |
|
|
329
|
+
|---|---|---|---|
|
|
330
|
+
| `world` | `World` | no | The world. |
|
|
331
|
+
| `entity` | `Entity` | no | The body's entity (an og.RigidBody). |
|
|
332
|
+
| `torque` | `Vector3` | no | The angular impulse in newton-metre-seconds. |
|
|
333
|
+
|
|
334
|
+
**Returns** `Result<void>`: Refused for an entity without an og.RigidBody, or a value that is not finite.
|
|
335
|
+
|
|
336
|
+
Binding symbol `og_physics_apply_torque_impulse` · publish builds: kept
|
|
337
|
+
|
|
338
|
+
```ogt
|
|
339
|
+
fn applyTorqueImpulse {
|
|
340
|
+
doc "Give a dynamic body an angular impulse (N·m·s about each world axis; 2D uses z): its spin changes at once, as applyImpulse."
|
|
341
|
+
param world World "The world."
|
|
342
|
+
param entity Entity "The body's entity (an og.RigidBody)."
|
|
343
|
+
param torque Vector3 "The angular impulse in newton-metre-seconds."
|
|
344
|
+
returns Result.Void "Refused for an entity without an og.RigidBody, or a value that is not finite."
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
<sub>`api.ogt` line 5055</sub>
|
|
349
|
+
|
|
350
|
+
<a id="fn-setMesh"></a>
|
|
351
|
+
|
|
352
|
+
### `og.physics.setMesh`
|
|
353
|
+
|
|
354
|
+
Register (or replace) the geometry a convex or triangle-mesh Collider names by its mesh handle. Loaded glTF geometries are registered under their own handles already; meshes are assets, not world state: world.snapshot carries a mesh, convex-hull or height-field collider by its handle and scale, not its triangles, and world.restore rebuilds the collider from the geometry registered then (so load or register it before restoring; a save naming one that is not is refused).
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
og.physics.setMesh(world: World, mesh: Geometry, desc?: MeshDesc): Result<void>
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
| Parameter | Type | Optional | Doc |
|
|
361
|
+
|---|---|---|---|
|
|
362
|
+
| `world` | `World` | no | The world. |
|
|
363
|
+
| `mesh` | `Geometry` | no | The handle colliders name in Collider.mesh. |
|
|
364
|
+
| `desc` | `MeshDesc` | yes | Positions and triangles. |
|
|
365
|
+
|
|
366
|
+
**Returns** `Result<void>`: Refused for an empty, non-finite or out-of-range mesh.
|
|
367
|
+
|
|
368
|
+
Binding symbol `og_physics_set_mesh` · publish builds: kept
|
|
369
|
+
|
|
370
|
+
```ogt
|
|
371
|
+
fn setMesh {
|
|
372
|
+
doc "Register (or replace) the geometry a convex or triangle-mesh Collider names by its mesh handle. Loaded glTF geometries are registered under their own handles already; meshes are assets, not world state: world.snapshot carries a mesh, convex-hull or height-field collider by its handle and scale, not its triangles, and world.restore rebuilds the collider from the geometry registered then (so load or register it before restoring; a save naming one that is not is refused)."
|
|
373
|
+
param world World "The world."
|
|
374
|
+
param mesh Geometry "The handle colliders name in Collider.mesh."
|
|
375
|
+
param desc MeshDesc "Positions and triangles."
|
|
376
|
+
returns Result.Void "Refused for an empty, non-finite or out-of-range mesh."
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
<sub>`api.ogt` line 5063</sub>
|
|
381
|
+
|
|
382
|
+
<a id="fn-ropePoints"></a>
|
|
383
|
+
|
|
384
|
+
### `og.physics.ropePoints`
|
|
385
|
+
|
|
386
|
+
An og.Rope's points after the last step, from its entity to its end (empty before its first step). The engine draws visible ropes itself; this is for game logic and custom drawing.
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
og.physics.ropePoints(world: World, entity: Entity): Result<readonly Vector3[]>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
| Parameter | Type | Optional | Doc |
|
|
393
|
+
|---|---|---|---|
|
|
394
|
+
| `world` | `World` | no | The world. |
|
|
395
|
+
| `entity` | `Entity` | no | The rope's entity. |
|
|
396
|
+
|
|
397
|
+
**Returns** `Result<readonly Vector3[]>`: Refused for an entity without an og.Rope.
|
|
398
|
+
|
|
399
|
+
Binding symbol `og_physics_rope_points` · publish builds: kept
|
|
400
|
+
|
|
401
|
+
```ogt
|
|
402
|
+
fn ropePoints {
|
|
403
|
+
doc "An og.Rope's points after the last step, from its entity to its end (empty before its first step). The engine draws visible ropes itself; this is for game logic and custom drawing."
|
|
404
|
+
param world World "The world."
|
|
405
|
+
param entity Entity "The rope's entity."
|
|
406
|
+
returns Result.List.Vector3 "Refused for an entity without an og.Rope."
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
<sub>`api.ogt` line 5124</sub>
|
|
411
|
+
|
|
412
|
+
<a id="fn-clothPoints"></a>
|
|
413
|
+
|
|
414
|
+
### `og.physics.clothPoints`
|
|
415
|
+
|
|
416
|
+
An og.Cloth's points after the last step, row by row (`columns` per row, rows downwards from the top edge).
|
|
417
|
+
|
|
418
|
+
```ts
|
|
419
|
+
og.physics.clothPoints(world: World, entity: Entity): Result<readonly Vector3[]>
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
| Parameter | Type | Optional | Doc |
|
|
423
|
+
|---|---|---|---|
|
|
424
|
+
| `world` | `World` | no | The world. |
|
|
425
|
+
| `entity` | `Entity` | no | The cloth's entity. |
|
|
426
|
+
|
|
427
|
+
**Returns** `Result<readonly Vector3[]>`: Refused for an entity without an og.Cloth.
|
|
428
|
+
|
|
429
|
+
Binding symbol `og_physics_cloth_points` · publish builds: kept
|
|
430
|
+
|
|
431
|
+
```ogt
|
|
432
|
+
fn clothPoints {
|
|
433
|
+
doc "An og.Cloth's points after the last step, row by row (`columns` per row, rows downwards from the top edge)."
|
|
434
|
+
param world World "The world."
|
|
435
|
+
param entity Entity "The cloth's entity."
|
|
436
|
+
returns Result.List.Vector3 "Refused for an entity without an og.Cloth."
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
<sub>`api.ogt` line 5131</sub>
|
|
441
|
+
|
|
442
|
+
<a id="fn-fluidParticles"></a>
|
|
443
|
+
|
|
444
|
+
### `og.physics.fluidParticles`
|
|
445
|
+
|
|
446
|
+
An og.Fluid2D's particle positions after the last step, in world space.
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
og.physics.fluidParticles(world: World, entity: Entity): Result<readonly Vector2[]>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
| Parameter | Type | Optional | Doc |
|
|
453
|
+
|---|---|---|---|
|
|
454
|
+
| `world` | `World` | no | The world. |
|
|
455
|
+
| `entity` | `Entity` | no | The fluid's entity. |
|
|
456
|
+
|
|
457
|
+
**Returns** `Result<readonly Vector2[]>`: Refused for an entity without an og.Fluid2D.
|
|
458
|
+
|
|
459
|
+
Binding symbol `og_physics_fluid_particles` · publish builds: kept
|
|
460
|
+
|
|
461
|
+
```ogt
|
|
462
|
+
fn fluidParticles {
|
|
463
|
+
doc "An og.Fluid2D's particle positions after the last step, in world space."
|
|
464
|
+
param world World "The world."
|
|
465
|
+
param entity Entity "The fluid's entity."
|
|
466
|
+
returns Result.List.Vector2 "Refused for an entity without an og.Fluid2D."
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
<sub>`api.ogt` line 5138</sub>
|
|
471
|
+
|
|
472
|
+
<a id="fn-fluid3dParticles"></a>
|
|
473
|
+
|
|
474
|
+
### `og.physics.fluid3dParticles`
|
|
475
|
+
|
|
476
|
+
An og.Fluid3D's particle positions after the last step, in world space (emitted particles last, in the order they appeared).
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
og.physics.fluid3dParticles(world: World, entity: Entity): Result<readonly Vector3[]>
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
| Parameter | Type | Optional | Doc |
|
|
483
|
+
|---|---|---|---|
|
|
484
|
+
| `world` | `World` | no | The world. |
|
|
485
|
+
| `entity` | `Entity` | no | The fluid's entity. |
|
|
486
|
+
|
|
487
|
+
**Returns** `Result<readonly Vector3[]>`: Refused for an entity without an og.Fluid3D.
|
|
488
|
+
|
|
489
|
+
Binding symbol `og_physics_fluid3d_particles` · publish builds: kept
|
|
490
|
+
|
|
491
|
+
```ogt
|
|
492
|
+
fn fluid3dParticles {
|
|
493
|
+
doc "An og.Fluid3D's particle positions after the last step, in world space (emitted particles last, in the order they appeared)."
|
|
494
|
+
param world World "The world."
|
|
495
|
+
param entity Entity "The fluid's entity."
|
|
496
|
+
returns Result.List.Vector3 "Refused for an entity without an og.Fluid3D."
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
<sub>`api.ogt` line 5145</sub>
|
|
501
|
+
|
|
502
|
+
<a id="fn-waterHeight"></a>
|
|
503
|
+
|
|
504
|
+
### `og.physics.waterHeight`
|
|
505
|
+
|
|
506
|
+
The surface height of an og.WaterSurface (world y) or an og.WaterLine (world y at `x`; `z` ignored) at a point, as the last step left it: for boats that bob and spray that starts on the surface.
|
|
507
|
+
|
|
508
|
+
```ts
|
|
509
|
+
og.physics.waterHeight(world: World, entity: Entity, x: number, z: number): Result<number>
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
| Parameter | Type | Optional | Doc |
|
|
513
|
+
|---|---|---|---|
|
|
514
|
+
| `world` | `World` | no | The world. |
|
|
515
|
+
| `entity` | `Entity` | no | The water's entity. |
|
|
516
|
+
| `x` | `number` | no | World x, in metres. |
|
|
517
|
+
| `z` | `number` | no | World z, in metres (3D). |
|
|
518
|
+
|
|
519
|
+
**Returns** `Result<number>`: Refused for an entity without water; outside the water, its rest level.
|
|
520
|
+
|
|
521
|
+
Binding symbol `og_physics_water_height` · publish builds: kept
|
|
522
|
+
|
|
523
|
+
```ogt
|
|
524
|
+
fn waterHeight {
|
|
525
|
+
doc "The surface height of an og.WaterSurface (world y) or an og.WaterLine (world y at `x`; `z` ignored) at a point, as the last step left it: for boats that bob and spray that starts on the surface."
|
|
526
|
+
param world World "The world."
|
|
527
|
+
param entity Entity "The water's entity."
|
|
528
|
+
param x f32 "World x, in metres."
|
|
529
|
+
param z f32 "World z, in metres (3D)."
|
|
530
|
+
returns Result.f32 "Refused for an entity without water; outside the water, its rest level."
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
<sub>`api.ogt` line 5152</sub>
|
|
535
|
+
|
|
536
|
+
<a id="fn-vehicleWheels"></a>
|
|
537
|
+
|
|
538
|
+
### `og.physics.vehicleWheels`
|
|
539
|
+
|
|
540
|
+
An og.Vehicle's wheels after the last step (front left, front right, rear left, rear right), for drawing wheel models.
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
og.physics.vehicleWheels(world: World, entity: Entity): Result<readonly WheelPose[]>
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
| Parameter | Type | Optional | Doc |
|
|
547
|
+
|---|---|---|---|
|
|
548
|
+
| `world` | `World` | no | The world. |
|
|
549
|
+
| `entity` | `Entity` | no | The vehicle's entity. |
|
|
550
|
+
|
|
551
|
+
**Returns** `Result<readonly WheelPose[]>`: Refused for an entity without a vehicle.
|
|
552
|
+
|
|
553
|
+
Binding symbol `og_physics_vehicle_wheels` · publish builds: kept
|
|
554
|
+
|
|
555
|
+
```ogt
|
|
556
|
+
fn vehicleWheels {
|
|
557
|
+
doc "An og.Vehicle's wheels after the last step (front left, front right, rear left, rear right), for drawing wheel models."
|
|
558
|
+
param world World "The world."
|
|
559
|
+
param entity Entity "The vehicle's entity."
|
|
560
|
+
returns Result.List.WheelPose "Refused for an entity without a vehicle."
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
<sub>`api.ogt` line 5161</sub>
|
|
565
|
+
|
|
566
|
+
<a id="fn-ragdollRigFromSkeleton"></a>
|
|
567
|
+
|
|
568
|
+
### `og.physics.ragdollRigFromSkeleton`
|
|
569
|
+
|
|
570
|
+
A ragdoll rig from a loaded skeleton (og.load.animation's `skeleton`): a bone per joint of its first skin, parents first, each from its joint's rest pose to its first child joint, every bone naming its joint and the rig naming the skeleton. Pass it to og.physics.setRagdollRig, edited or not.
|
|
571
|
+
|
|
572
|
+
```ts
|
|
573
|
+
og.physics.ragdollRigFromSkeleton(world: World, skeleton: SkeletonAsset): Result<RagdollRigDesc>
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
| Parameter | Type | Optional | Doc |
|
|
577
|
+
|---|---|---|---|
|
|
578
|
+
| `world` | `World` | no | The world. |
|
|
579
|
+
| `skeleton` | `SkeletonAsset` | no | The skeleton. |
|
|
580
|
+
|
|
581
|
+
**Returns** `Result<RagdollRigDesc>`: Refused for a skeleton that is not loaded or has no skin.
|
|
582
|
+
|
|
583
|
+
Binding symbol `og_physics_ragdoll_rig_from_skeleton` · publish builds: kept
|
|
584
|
+
|
|
585
|
+
```ogt
|
|
586
|
+
fn ragdollRigFromSkeleton {
|
|
587
|
+
doc "A ragdoll rig from a loaded skeleton (og.load.animation's `skeleton`): a bone per joint of its first skin, parents first, each from its joint's rest pose to its first child joint, every bone naming its joint and the rig naming the skeleton. Pass it to og.physics.setRagdollRig, edited or not."
|
|
588
|
+
param world World "The world."
|
|
589
|
+
param skeleton SkeletonAsset "The skeleton."
|
|
590
|
+
returns Result.RagdollRigDesc "Refused for a skeleton that is not loaded or has no skin."
|
|
591
|
+
}
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
<sub>`api.ogt` line 5168</sub>
|
|
595
|
+
|
|
596
|
+
<a id="fn-setRagdollRig"></a>
|
|
597
|
+
|
|
598
|
+
### `og.physics.setRagdollRig`
|
|
599
|
+
|
|
600
|
+
Give an entity with an og.Ragdoll its bones (and, from og.physics.ragdollRigFromSkeleton, the skeleton they stand for: its og.Model is then drawn blended from the animation towards the bones by og.Ragdoll.blend). While weight is 0 the bones follow the rig's rest pose at the entity. Rigs are assets, not world state: kept by the engine and given again to a reloaded world.
|
|
601
|
+
|
|
602
|
+
```ts
|
|
603
|
+
og.physics.setRagdollRig(world: World, entity: Entity, desc?: RagdollRigDesc): Result<void>
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
| Parameter | Type | Optional | Doc |
|
|
607
|
+
|---|---|---|---|
|
|
608
|
+
| `world` | `World` | no | The world. |
|
|
609
|
+
| `entity` | `Entity` | no | The ragdoll's entity. |
|
|
610
|
+
| `desc` | `RagdollRigDesc` | yes | The bones, parents first. |
|
|
611
|
+
|
|
612
|
+
**Returns** `Result<void>`: Refused for an empty rig or a parent that does not come before its child.
|
|
613
|
+
|
|
614
|
+
Binding symbol `og_physics_set_ragdoll_rig` · publish builds: kept
|
|
615
|
+
|
|
616
|
+
```ogt
|
|
617
|
+
fn setRagdollRig {
|
|
618
|
+
doc "Give an entity with an og.Ragdoll its bones (and, from og.physics.ragdollRigFromSkeleton, the skeleton they stand for: its og.Model is then drawn blended from the animation towards the bones by og.Ragdoll.blend). While weight is 0 the bones follow the rig's rest pose at the entity. Rigs are assets, not world state: kept by the engine and given again to a reloaded world."
|
|
619
|
+
param world World "The world."
|
|
620
|
+
param entity Entity "The ragdoll's entity."
|
|
621
|
+
param desc RagdollRigDesc "The bones, parents first."
|
|
622
|
+
returns Result.Void "Refused for an empty rig or a parent that does not come before its child."
|
|
623
|
+
}
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
<sub>`api.ogt` line 5175</sub>
|
|
627
|
+
|
|
628
|
+
<a id="fn-ragdollPose"></a>
|
|
629
|
+
|
|
630
|
+
### `og.physics.ragdollPose`
|
|
631
|
+
|
|
632
|
+
An og.Ragdoll's bones after the last step, in rig order (empty before its first step).
|
|
633
|
+
|
|
634
|
+
```ts
|
|
635
|
+
og.physics.ragdollPose(world: World, entity: Entity): Result<readonly BonePose[]>
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
| Parameter | Type | Optional | Doc |
|
|
639
|
+
|---|---|---|---|
|
|
640
|
+
| `world` | `World` | no | The world. |
|
|
641
|
+
| `entity` | `Entity` | no | The ragdoll's entity. |
|
|
642
|
+
|
|
643
|
+
**Returns** `Result<readonly BonePose[]>`: Refused for an entity without a ragdoll.
|
|
644
|
+
|
|
645
|
+
Binding symbol `og_physics_ragdoll_pose` · publish builds: kept
|
|
646
|
+
|
|
647
|
+
```ogt
|
|
648
|
+
fn ragdollPose {
|
|
649
|
+
doc "An og.Ragdoll's bones after the last step, in rig order (empty before its first step)."
|
|
650
|
+
param world World "The world."
|
|
651
|
+
param entity Entity "The ragdoll's entity."
|
|
652
|
+
returns Result.List.BonePose "Refused for an entity without a ragdoll."
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
<sub>`api.ogt` line 5183</sub>
|
|
657
|
+
|
|
658
|
+
<a id="fn-stats"></a>
|
|
659
|
+
|
|
660
|
+
### `og.physics.stats`
|
|
661
|
+
|
|
662
|
+
What the last physics step cost: each phase's time and whether it ran on the lanes pool. All zero before the first step.
|
|
663
|
+
|
|
664
|
+
```ts
|
|
665
|
+
og.physics.stats(world: World): Result<PhysicsStats>
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
| Parameter | Type | Optional | Doc |
|
|
669
|
+
|---|---|---|---|
|
|
670
|
+
| `world` | `World` | no | The world. |
|
|
671
|
+
|
|
672
|
+
**Returns** `Result<PhysicsStats>`: Refused for an engine without physics.
|
|
673
|
+
|
|
674
|
+
Binding symbol `og_physics_stats` · publish builds: kept
|
|
675
|
+
|
|
676
|
+
```ogt
|
|
677
|
+
fn stats {
|
|
678
|
+
doc "What the last physics step cost: each phase's time and whether it ran on the lanes pool. All zero before the first step."
|
|
679
|
+
param world World "The world."
|
|
680
|
+
returns Result.PhysicsStats "Refused for an engine without physics."
|
|
681
|
+
}
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
<sub>`api.ogt` line 5211</sub>
|
|
685
|
+
|
|
686
|
+
## Components, resources and events
|
|
687
|
+
|
|
688
|
+
<a id="record-RigidBody"></a>
|
|
689
|
+
|
|
690
|
+
### `og.RigidBody` (component)
|
|
691
|
+
|
|
692
|
+
A body the physics step simulates. It needs an og.Transform and usually has an og.Collider; a dynamic body without an og.Velocity gets one.
|
|
693
|
+
|
|
694
|
+
Changing a RigidBody, a Collider or Transform.scale rebuilds the body (it loses its contacts' warm starts); a Transform or Velocity that game code changed moves it (a teleport).
|
|
695
|
+
|
|
696
|
+
Token `og.RigidBody`, registered under the schema name `og.RigidBody`; its value type is `RigidBody`.
|
|
697
|
+
|
|
698
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
699
|
+
|---|---|---|---|---|---|---|
|
|
700
|
+
| `kind` | `number` | `0` | 0 … 2 | — | label “Kind” | BODY_DYNAMIC (0, simulated and written back), BODY_STATIC (1, never moves) or BODY_KINEMATIC (2, moved by its Velocity each tick, or by game code through its Transform). |
|
|
701
|
+
| `mass` | `number` | `0` | ≥ 0 | `kg` | tunable | Mass; 0 derives it from the collider's density and volume. |
|
|
702
|
+
| `linearDamping` | `number` | `0` | 0 … 100 | `perSecond` | tunable | How fast linear velocity decays (0: none). |
|
|
703
|
+
| `angularDamping` | `number` | `0` | 0 … 100 | `perSecond` | tunable | How fast angular velocity decays (0: none). |
|
|
704
|
+
| `gravityScale` | `number` | `1` | -10 … 10 | — | tunable | Multiplies Physics.gravity for this body: 0 floats, 1 is normal. |
|
|
705
|
+
| `lock` | `number` | `0` | 0 … 63 | — | — | Locked axes, a sum of the LOCK_* bits: 1, 2, 4 no translation along x, y, z; 8, 16, 32 no rotation about x, y, z (2D uses 1, 2 and 32). |
|
|
706
|
+
| `ccd` | `number` | `0` | 0 … 1 | — | — | 1 enables continuous collision detection, for fast small bodies that must not tunnel; 0 off. |
|
|
707
|
+
| `centerOfMass` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | tunable | Moves the centre of mass from where the collider puts it (its shape's centre), in the entity's own frame and scaled by og.Transform.scale like Collider.offset; the inertia stays the shape's. A car's lowered below its wheel mounts keeps it on its wheels at full lock; a weight at a toy's base rights it. Needs an og.Collider. |
|
|
708
|
+
|
|
709
|
+
```ogt
|
|
710
|
+
component RigidBody {
|
|
711
|
+
doc "A body the physics step simulates. It needs an og.Transform and usually has an og.Collider; a dynamic body without an og.Velocity gets one."
|
|
712
|
+
doc "Changing a RigidBody, a Collider or Transform.scale rebuilds the body (it loses its contacts' warm starts); a Transform or Velocity that game code changed moves it (a teleport)."
|
|
713
|
+
field kind u32 "BODY_DYNAMIC (0, simulated and written back), BODY_STATIC (1, never moves) or BODY_KINEMATIC (2, moved by its Velocity each tick, or by game code through its Transform)." {
|
|
714
|
+
min 0
|
|
715
|
+
max 2
|
|
716
|
+
label "Kind"
|
|
717
|
+
}
|
|
718
|
+
field mass f32 "Mass; 0 derives it from the collider's density and volume." {
|
|
719
|
+
min 0
|
|
720
|
+
unit kg
|
|
721
|
+
tunable true
|
|
722
|
+
}
|
|
723
|
+
field linearDamping f32 "How fast linear velocity decays (0: none)." {
|
|
724
|
+
min 0
|
|
725
|
+
max 100
|
|
726
|
+
unit perSecond
|
|
727
|
+
tunable true
|
|
728
|
+
}
|
|
729
|
+
field angularDamping f32 "How fast angular velocity decays (0: none)." {
|
|
730
|
+
min 0
|
|
731
|
+
max 100
|
|
732
|
+
unit perSecond
|
|
733
|
+
tunable true
|
|
734
|
+
}
|
|
735
|
+
field gravityScale f32 "Multiplies Physics.gravity for this body: 0 floats, 1 is normal." {
|
|
736
|
+
default 1
|
|
737
|
+
min -10
|
|
738
|
+
max 10
|
|
739
|
+
tunable true
|
|
740
|
+
}
|
|
741
|
+
field lock u32 "Locked axes, a sum of the LOCK_* bits: 1, 2, 4 no translation along x, y, z; 8, 16, 32 no rotation about x, y, z (2D uses 1, 2 and 32)." {
|
|
742
|
+
min 0
|
|
743
|
+
max 63
|
|
744
|
+
}
|
|
745
|
+
field ccd u32 "1 enables continuous collision detection, for fast small bodies that must not tunnel; 0 off." {
|
|
746
|
+
min 0
|
|
747
|
+
max 1
|
|
748
|
+
}
|
|
749
|
+
field centerOfMass Vector3 "Moves the centre of mass from where the collider puts it (its shape's centre), in the entity's own frame and scaled by og.Transform.scale like Collider.offset; the inertia stays the shape's. A car's lowered below its wheel mounts keeps it on its wheels at full lock; a weight at a toy's base rights it. Needs an og.Collider." {
|
|
750
|
+
unit m
|
|
751
|
+
tunable true
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
<sub>`api.ogt` line 3721</sub>
|
|
757
|
+
|
|
758
|
+
<a id="record-Collider"></a>
|
|
759
|
+
|
|
760
|
+
### `og.Collider` (component)
|
|
761
|
+
|
|
762
|
+
The shape an entity collides with, attached to its RigidBody (or, without one, a static collider at its Transform). Sizes are scaled by og.Transform.scale.
|
|
763
|
+
|
|
764
|
+
Token `og.Collider`, registered under the schema name `og.Collider`; its value type is `Collider`.
|
|
765
|
+
|
|
766
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
767
|
+
|---|---|---|---|---|---|---|
|
|
768
|
+
| `shape` | `number` | `0` | 0 … 6 | — | label “Shape” | One of the SHAPE_* codes: 0 box, 1 sphere (a circle in 2D), 2 capsule, 3 cylinder (3D), 4 convex hull of `mesh` (a polygon in 2D), 5 triangle mesh of `mesh` (3D), 6 the height field `mesh` (3D: a terrain). |
|
|
769
|
+
| `size` | `Vector3` | `{ x: 1, y: 1, z: 1 }` | ≥ 0 | `m` | tunable | Full extents of a box, as three.js BoxGeometry(width, height, depth). |
|
|
770
|
+
| `radius` | `number` | `0.5` | ≥ 0 | `m` | tunable | Radius of a sphere, circle, capsule or cylinder. |
|
|
771
|
+
| `height` | `number` | `1` | ≥ 0 | `m` | tunable | A capsule's distance between its cap centres (three.js CapsuleGeometry length); a cylinder's height. |
|
|
772
|
+
| `mesh` | `Geometry` | `0` | — | — | — | The geometry whose vertices a convex or triangle-mesh shape uses: a loaded glTF's geometry (registered automatically) or one given to og.physics.setMesh; for SHAPE_HEIGHTFIELD, a terrain's height field (og.terrain.load's TerrainInfo.geometry). |
|
|
773
|
+
| `offset` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Position of the shape relative to the entity. |
|
|
774
|
+
| `rotation` | `Quaternion` | `{ x: 0, y: 0, z: 0, w: 1 }` | — | — | — | Rotation of the shape relative to the entity. |
|
|
775
|
+
| `friction` | `number` | `0.5` | 0 … 2 | — | tunable | Coulomb friction (0 is ice, 1 rubber); a pair uses the mean of both colliders. |
|
|
776
|
+
| `restitution` | `number` | `0` | 0 … 1 | — | tunable | Bounciness (0 no bounce, 1 elastic); a pair uses the mean of both colliders. |
|
|
777
|
+
| `density` | `number` | `1` | ≥ 0 | `kgPerM3` | tunable | Density, used when RigidBody.mass is 0. |
|
|
778
|
+
| `sensor` | `number` | `0` | 0 … 1 | — | — | 1 makes this a sensor: it reports SensorEntered and SensorExited and pushes nothing; 0 a solid. |
|
|
779
|
+
| `layers` | `number` | `1` | — | — | — | The collision layers this collider is on, as bits. |
|
|
780
|
+
| `mask` | `number` | `4294967295` | — | — | — | The layers it collides with, as bits. Two colliders interact when each one's layers meet the other's mask. |
|
|
781
|
+
|
|
782
|
+
```ogt
|
|
783
|
+
component Collider {
|
|
784
|
+
doc "The shape an entity collides with, attached to its RigidBody (or, without one, a static collider at its Transform). Sizes are scaled by og.Transform.scale."
|
|
785
|
+
field shape u32 "One of the SHAPE_* codes: 0 box, 1 sphere (a circle in 2D), 2 capsule, 3 cylinder (3D), 4 convex hull of `mesh` (a polygon in 2D), 5 triangle mesh of `mesh` (3D), 6 the height field `mesh` (3D: a terrain)." {
|
|
786
|
+
min 0
|
|
787
|
+
max 6
|
|
788
|
+
label "Shape"
|
|
789
|
+
}
|
|
790
|
+
field size Vector3 "Full extents of a box, as three.js BoxGeometry(width, height, depth)." {
|
|
791
|
+
default 1 1 1
|
|
792
|
+
min 0
|
|
793
|
+
unit m
|
|
794
|
+
tunable true
|
|
795
|
+
}
|
|
796
|
+
field radius f32 "Radius of a sphere, circle, capsule or cylinder." {
|
|
797
|
+
default 0.5
|
|
798
|
+
min 0
|
|
799
|
+
unit m
|
|
800
|
+
tunable true
|
|
801
|
+
}
|
|
802
|
+
field height f32 "A capsule's distance between its cap centres (three.js CapsuleGeometry length); a cylinder's height." {
|
|
803
|
+
default 1
|
|
804
|
+
min 0
|
|
805
|
+
unit m
|
|
806
|
+
tunable true
|
|
807
|
+
}
|
|
808
|
+
field mesh Geometry "The geometry whose vertices a convex or triangle-mesh shape uses: a loaded glTF's geometry (registered automatically) or one given to og.physics.setMesh; for SHAPE_HEIGHTFIELD, a terrain's height field (og.terrain.load's TerrainInfo.geometry)."
|
|
809
|
+
field offset Vector3 "Position of the shape relative to the entity." {
|
|
810
|
+
unit m
|
|
811
|
+
}
|
|
812
|
+
field rotation Quaternion "Rotation of the shape relative to the entity."
|
|
813
|
+
field friction f32 "Coulomb friction (0 is ice, 1 rubber); a pair uses the mean of both colliders." {
|
|
814
|
+
default 0.5
|
|
815
|
+
min 0
|
|
816
|
+
max 2
|
|
817
|
+
tunable true
|
|
818
|
+
}
|
|
819
|
+
field restitution f32 "Bounciness (0 no bounce, 1 elastic); a pair uses the mean of both colliders." {
|
|
820
|
+
min 0
|
|
821
|
+
max 1
|
|
822
|
+
tunable true
|
|
823
|
+
}
|
|
824
|
+
field density f32 "Density, used when RigidBody.mass is 0." {
|
|
825
|
+
default 1
|
|
826
|
+
min 0
|
|
827
|
+
unit kgPerM3
|
|
828
|
+
tunable true
|
|
829
|
+
}
|
|
830
|
+
field sensor u32 "1 makes this a sensor: it reports SensorEntered and SensorExited and pushes nothing; 0 a solid." {
|
|
831
|
+
min 0
|
|
832
|
+
max 1
|
|
833
|
+
}
|
|
834
|
+
field layers u32 "The collision layers this collider is on, as bits." {
|
|
835
|
+
default 1
|
|
836
|
+
}
|
|
837
|
+
field mask u32 "The layers it collides with, as bits. Two colliders interact when each one's layers meet the other's mask." {
|
|
838
|
+
default 4294967295
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
<sub>`api.ogt` line 3766</sub>
|
|
844
|
+
|
|
845
|
+
<a id="record-Velocity"></a>
|
|
846
|
+
|
|
847
|
+
### `og.Velocity` (component)
|
|
848
|
+
|
|
849
|
+
Linear and angular velocity. Written for dynamic bodies every tick (added to them by the step when missing); a kinematic body moves by it each tick (never added, never written). Set it to launch or stop a body; push one with og.physics.applyForce, applyImpulse, applyTorque or applyTorqueImpulse.
|
|
850
|
+
|
|
851
|
+
Token `og.Velocity`, registered under the schema name `og.Velocity`; its value type is `Velocity`.
|
|
852
|
+
|
|
853
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
854
|
+
|---|---|---|---|---|---|---|
|
|
855
|
+
| `linear` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps` | tunable | The linear velocity (2D uses x and y). |
|
|
856
|
+
| `angular` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `radps` | tunable | The angular velocity about each axis (2D uses z). |
|
|
857
|
+
|
|
858
|
+
```ogt
|
|
859
|
+
component Velocity {
|
|
860
|
+
doc "Linear and angular velocity. Written for dynamic bodies every tick (added to them by the step when missing); a kinematic body moves by it each tick (never added, never written). Set it to launch or stop a body; push one with og.physics.applyForce, applyImpulse, applyTorque or applyTorqueImpulse."
|
|
861
|
+
field linear Vector3 "The linear velocity (2D uses x and y)." {
|
|
862
|
+
unit mps
|
|
863
|
+
tunable true
|
|
864
|
+
}
|
|
865
|
+
field angular Vector3 "The angular velocity about each axis (2D uses z)." {
|
|
866
|
+
unit radps
|
|
867
|
+
tunable true
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
<sub>`api.ogt` line 3825</sub>
|
|
873
|
+
|
|
874
|
+
<a id="record-Physics"></a>
|
|
875
|
+
|
|
876
|
+
### `og.Physics` (resource)
|
|
877
|
+
|
|
878
|
+
The physics settings of the world. The profile is the project's; the same components serve both profiles.
|
|
879
|
+
|
|
880
|
+
Token `og.Physics`, registered under the schema name `og.Physics`; its value type is `Physics`.
|
|
881
|
+
|
|
882
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
883
|
+
|---|---|---|---|---|---|---|
|
|
884
|
+
| `profile` | `number` | `3` | 2 … 3 | — | label “Profile” | PROFILE_2D (2: rapier2d, the xy plane, rotation about z) or PROFILE_3D (3: rapier3d), from project.ogt. Set the other one at run time to change profile: the next step builds that profile's simulation from the components (contacts, joints' warm starts, ropes, cloth, fluids and ragdoll bodies start again), so a 3D game can play a 2D scene and back. |
|
|
885
|
+
| `gravity` | `Vector3` | `{ x: 0, y: -9.81, z: 0 }` | — | `mps2` | tunable | The acceleration of every dynamic body, times its gravityScale; 2D uses x and y. |
|
|
886
|
+
| `substeps` | `number` | `1` | 1 … 16 | — | tunable | Physics steps per tick, each of dt / substeps: more is stiffer stacks and less tunnelling, at more cost. |
|
|
887
|
+
| `solverIterations` | `number` | `4` | 1 … 32 | — | tunable | Solver iterations per step. |
|
|
888
|
+
| `restSpeed` | `number` | `0.02` | 0 … 1 | `mps` | tunable | A dynamic body touching something, supported with at most 2 mm of overlap and slower than this before and after a step, keeps its pose and loses its residual velocity (the same number in m/s and rad/s); 0 disables it. |
|
|
889
|
+
|
|
890
|
+
```ogt
|
|
891
|
+
resource Physics {
|
|
892
|
+
doc "The physics settings of the world. The profile is the project's; the same components serve both profiles."
|
|
893
|
+
field profile u32 "PROFILE_2D (2: rapier2d, the xy plane, rotation about z) or PROFILE_3D (3: rapier3d), from project.ogt. Set the other one at run time to change profile: the next step builds that profile's simulation from the components (contacts, joints' warm starts, ropes, cloth, fluids and ragdoll bodies start again), so a 3D game can play a 2D scene and back." {
|
|
894
|
+
default 3
|
|
895
|
+
min 2
|
|
896
|
+
max 3
|
|
897
|
+
label "Profile"
|
|
898
|
+
}
|
|
899
|
+
field gravity Vector3 "The acceleration of every dynamic body, times its gravityScale; 2D uses x and y." {
|
|
900
|
+
default 0 -9.81 0
|
|
901
|
+
unit mps2
|
|
902
|
+
tunable true
|
|
903
|
+
}
|
|
904
|
+
field substeps u32 "Physics steps per tick, each of dt / substeps: more is stiffer stacks and less tunnelling, at more cost." {
|
|
905
|
+
default 1
|
|
906
|
+
min 1
|
|
907
|
+
max 16
|
|
908
|
+
tunable true
|
|
909
|
+
}
|
|
910
|
+
field solverIterations u32 "Solver iterations per step." {
|
|
911
|
+
default 4
|
|
912
|
+
min 1
|
|
913
|
+
max 32
|
|
914
|
+
tunable true
|
|
915
|
+
}
|
|
916
|
+
field restSpeed f32 "A dynamic body touching something, supported with at most 2 mm of overlap and slower than this before and after a step, keeps its pose and loses its residual velocity (the same number in m/s and rad/s); 0 disables it." {
|
|
917
|
+
default 0.02
|
|
918
|
+
min 0
|
|
919
|
+
max 1
|
|
920
|
+
unit mps
|
|
921
|
+
tunable true
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
<sub>`api.ogt` line 3837</sub>
|
|
927
|
+
|
|
928
|
+
<a id="record-CollisionStarted"></a>
|
|
929
|
+
|
|
930
|
+
### `og.CollisionStarted` (event)
|
|
931
|
+
|
|
932
|
+
Two solid colliders started touching during the tick.
|
|
933
|
+
|
|
934
|
+
Token `og.CollisionStarted`, registered under the schema name `og.CollisionStarted`; its value type is `CollisionStarted`.
|
|
935
|
+
|
|
936
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
937
|
+
|---|---|---|---|---|---|---|
|
|
938
|
+
| `a` | `Entity` | `0` | — | — | — | The entity with the lower id. |
|
|
939
|
+
| `b` | `Entity` | `0` | — | — | — | The entity with the higher id. |
|
|
940
|
+
| `point` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | The deepest contact point in world space (z is 0 in 2D). |
|
|
941
|
+
| `normal` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | The contact normal, from a towards b. |
|
|
942
|
+
|
|
943
|
+
```ogt
|
|
944
|
+
event CollisionStarted {
|
|
945
|
+
doc "Two solid colliders started touching during the tick."
|
|
946
|
+
field a Entity "The entity with the lower id."
|
|
947
|
+
field b Entity "The entity with the higher id."
|
|
948
|
+
field point Vector3 "The deepest contact point in world space (z is 0 in 2D)."
|
|
949
|
+
field normal Vector3 "The contact normal, from a towards b."
|
|
950
|
+
}
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
<sub>`api.ogt` line 3871</sub>
|
|
954
|
+
|
|
955
|
+
<a id="record-CollisionEnded"></a>
|
|
956
|
+
|
|
957
|
+
### `og.CollisionEnded` (event)
|
|
958
|
+
|
|
959
|
+
Two solid colliders stopped touching, or one of them went away.
|
|
960
|
+
|
|
961
|
+
Token `og.CollisionEnded`, registered under the schema name `og.CollisionEnded`; its value type is `CollisionEnded`.
|
|
962
|
+
|
|
963
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
964
|
+
|---|---|---|---|---|---|---|
|
|
965
|
+
| `a` | `Entity` | `0` | — | — | — | The entity with the lower id. |
|
|
966
|
+
| `b` | `Entity` | `0` | — | — | — | The entity with the higher id. |
|
|
967
|
+
|
|
968
|
+
```ogt
|
|
969
|
+
event CollisionEnded {
|
|
970
|
+
doc "Two solid colliders stopped touching, or one of them went away."
|
|
971
|
+
field a Entity "The entity with the lower id."
|
|
972
|
+
field b Entity "The entity with the higher id."
|
|
973
|
+
}
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
<sub>`api.ogt` line 3879</sub>
|
|
977
|
+
|
|
978
|
+
<a id="record-SensorEntered"></a>
|
|
979
|
+
|
|
980
|
+
### `og.SensorEntered` (event)
|
|
981
|
+
|
|
982
|
+
A collider started overlapping a sensor.
|
|
983
|
+
|
|
984
|
+
Token `og.SensorEntered`, registered under the schema name `og.SensorEntered`; its value type is `SensorEntered`.
|
|
985
|
+
|
|
986
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
987
|
+
|---|---|---|---|---|---|---|
|
|
988
|
+
| `sensor` | `Entity` | `0` | — | — | — | The entity whose collider is the sensor. |
|
|
989
|
+
| `other` | `Entity` | `0` | — | — | — | The entity that entered it. |
|
|
990
|
+
|
|
991
|
+
```ogt
|
|
992
|
+
event SensorEntered {
|
|
993
|
+
doc "A collider started overlapping a sensor."
|
|
994
|
+
field sensor Entity "The entity whose collider is the sensor."
|
|
995
|
+
field other Entity "The entity that entered it."
|
|
996
|
+
}
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
<sub>`api.ogt` line 3885</sub>
|
|
1000
|
+
|
|
1001
|
+
<a id="record-SensorExited"></a>
|
|
1002
|
+
|
|
1003
|
+
### `og.SensorExited` (event)
|
|
1004
|
+
|
|
1005
|
+
A collider stopped overlapping a sensor, or one of them went away.
|
|
1006
|
+
|
|
1007
|
+
Token `og.SensorExited`, registered under the schema name `og.SensorExited`; its value type is `SensorExited`.
|
|
1008
|
+
|
|
1009
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1010
|
+
|---|---|---|---|---|---|---|
|
|
1011
|
+
| `sensor` | `Entity` | `0` | — | — | — | The entity whose collider is the sensor. |
|
|
1012
|
+
| `other` | `Entity` | `0` | — | — | — | The entity that left it. |
|
|
1013
|
+
|
|
1014
|
+
```ogt
|
|
1015
|
+
event SensorExited {
|
|
1016
|
+
doc "A collider stopped overlapping a sensor, or one of them went away."
|
|
1017
|
+
field sensor Entity "The entity whose collider is the sensor."
|
|
1018
|
+
field other Entity "The entity that left it."
|
|
1019
|
+
}
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
<sub>`api.ogt` line 3891</sub>
|
|
1023
|
+
|
|
1024
|
+
<a id="record-Contact"></a>
|
|
1025
|
+
|
|
1026
|
+
### `og.Contact` (event)
|
|
1027
|
+
|
|
1028
|
+
One pair in contact at the end of a step, sent every tick for every touching pair: how a game asks what is touching what right now.
|
|
1029
|
+
|
|
1030
|
+
Token `og.Contact`, registered under the schema name `og.Contact`; its value type is `Contact`.
|
|
1031
|
+
|
|
1032
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1033
|
+
|---|---|---|---|---|---|---|
|
|
1034
|
+
| `a` | `Entity` | `0` | — | — | — | The entity with the lower id. |
|
|
1035
|
+
| `b` | `Entity` | `0` | — | — | — | The entity with the higher id. |
|
|
1036
|
+
| `sensor` | `number` | `0` | — | — | — | 0 for two solids; an overlap with a sensor otherwise: 1 a is the sensor, 2 b is, 3 both are. |
|
|
1037
|
+
|
|
1038
|
+
```ogt
|
|
1039
|
+
event Contact {
|
|
1040
|
+
doc "One pair in contact at the end of a step, sent every tick for every touching pair: how a game asks what is touching what right now."
|
|
1041
|
+
field a Entity "The entity with the lower id."
|
|
1042
|
+
field b Entity "The entity with the higher id."
|
|
1043
|
+
field sensor u32 "0 for two solids; an overlap with a sensor otherwise: 1 a is the sensor, 2 b is, 3 both are."
|
|
1044
|
+
}
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
<sub>`api.ogt` line 3897</sub>
|
|
1048
|
+
|
|
1049
|
+
<a id="record-Joint"></a>
|
|
1050
|
+
|
|
1051
|
+
### `og.Joint` (component)
|
|
1052
|
+
|
|
1053
|
+
A joint between two bodies (or a body and a point of the world). The component may sit on one of the bodies (`body` 0) or on an entity of its own, so one body can have several joints. Anchors are in each body's frame (rotated and moved with it, not scaled); without `other` the second anchor is a world point. A joint whose bodies are not both `og.RigidBody` entities does nothing until they are.
|
|
1054
|
+
|
|
1055
|
+
Token `og.Joint`, registered under the schema name `og.Joint`; its value type is `Joint`.
|
|
1056
|
+
|
|
1057
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1058
|
+
|---|---|---|---|---|---|---|
|
|
1059
|
+
| `kind` | `number` | `0` | 0 … 5 | — | label “Kind” | JOINT_FIXED 0, JOINT_REVOLUTE 1 (hinge), JOINT_PRISMATIC 2 (slider), JOINT_SPRING 3, JOINT_ROPE 4, JOINT_BALL 5. |
|
|
1060
|
+
| `body` | `Entity` | `0` | — | — | — | The first body; 0 is this entity. |
|
|
1061
|
+
| `other` | `Entity` | `0` | — | — | — | The second body; 0 joins the first one to the world at `otherAnchor`. |
|
|
1062
|
+
| `anchor` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Where the joint sits on the first body, in its frame. |
|
|
1063
|
+
| `otherAnchor` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Where it sits on the second body, in its frame (a world point without `other`). |
|
|
1064
|
+
| `axis` | `Vector3` | `{ x: 1, y: 0, z: 0 }` | — | — | — | The hinge or slide axis in the first body's frame (a hinge in 2D turns about z). |
|
|
1065
|
+
| `limits` | `boolean` | `false` | — | — | — | Whether `min`..`max` bound the hinge angle (rad) or the slide (m). |
|
|
1066
|
+
| `min` | `number` | `0` | — | — | — | The lower limit: radians for a hinge, metres for a slider. |
|
|
1067
|
+
| `max` | `number` | `0` | — | — | — | The upper limit. |
|
|
1068
|
+
| `motor` | `number` | `0` | 0 … 2 | — | — | MOTOR_NONE 0, MOTOR_VELOCITY 1 (drive at motorTarget speed), MOTOR_POSITION 2 (spring to motorTarget). |
|
|
1069
|
+
| `motorTarget` | `number` | `0` | — | — | tunable | The motor's target speed (rad/s, m/s) or angle or position (rad, m). |
|
|
1070
|
+
| `motorStiffness` | `number` | `50` | ≥ 0 | — | tunable | A position motor's stiffness; a velocity motor's strength. |
|
|
1071
|
+
| `motorDamping` | `number` | `5` | ≥ 0 | — | tunable | A position motor's damping. |
|
|
1072
|
+
| `motorMaxForce` | `number` | `0` | ≥ 0 | — | tunable | The most force (or torque) the motor applies; 0 is unbounded. |
|
|
1073
|
+
| `restLength` | `number` | `1` | ≥ 0 | `m` | tunable | A spring's rest length. |
|
|
1074
|
+
| `stiffness` | `number` | `40` | ≥ 0 | — | tunable | A spring's stiffness (N/m). |
|
|
1075
|
+
| `damping` | `number` | `2` | ≥ 0 | — | tunable | A spring's damping (N·s/m). |
|
|
1076
|
+
| `length` | `number` | `2` | ≥ 0 | `m` | tunable | A rope's longest distance between the anchors. |
|
|
1077
|
+
| `collide` | `boolean` | `false` | — | — | — | Whether the two bodies still collide with each other. |
|
|
1078
|
+
| `value` | `number` | `0` | — | — | read only | Written: the hinge angle (rad) or the slide (m) after the step; the anchors' distance for springs and ropes. |
|
|
1079
|
+
|
|
1080
|
+
```ogt
|
|
1081
|
+
component Joint {
|
|
1082
|
+
doc "A joint between two bodies (or a body and a point of the world). The component may sit on one of the bodies (`body` 0) or on an entity of its own, so one body can have several joints. Anchors are in each body's frame (rotated and moved with it, not scaled); without `other` the second anchor is a world point. A joint whose bodies are not both `og.RigidBody` entities does nothing until they are."
|
|
1083
|
+
field kind u32 "JOINT_FIXED 0, JOINT_REVOLUTE 1 (hinge), JOINT_PRISMATIC 2 (slider), JOINT_SPRING 3, JOINT_ROPE 4, JOINT_BALL 5." {
|
|
1084
|
+
min 0
|
|
1085
|
+
max 5
|
|
1086
|
+
label "Kind"
|
|
1087
|
+
}
|
|
1088
|
+
field body Entity "The first body; 0 is this entity."
|
|
1089
|
+
field other Entity "The second body; 0 joins the first one to the world at `otherAnchor`."
|
|
1090
|
+
field anchor Vector3 "Where the joint sits on the first body, in its frame." {
|
|
1091
|
+
unit m
|
|
1092
|
+
}
|
|
1093
|
+
field otherAnchor Vector3 "Where it sits on the second body, in its frame (a world point without `other`)." {
|
|
1094
|
+
unit m
|
|
1095
|
+
}
|
|
1096
|
+
field axis Vector3 "The hinge or slide axis in the first body's frame (a hinge in 2D turns about z)." {
|
|
1097
|
+
default 1 0 0
|
|
1098
|
+
}
|
|
1099
|
+
field limits bool "Whether `min`..`max` bound the hinge angle (rad) or the slide (m)."
|
|
1100
|
+
field min f32 "The lower limit: radians for a hinge, metres for a slider."
|
|
1101
|
+
field max f32 "The upper limit."
|
|
1102
|
+
field motor u32 "MOTOR_NONE 0, MOTOR_VELOCITY 1 (drive at motorTarget speed), MOTOR_POSITION 2 (spring to motorTarget)." {
|
|
1103
|
+
min 0
|
|
1104
|
+
max 2
|
|
1105
|
+
}
|
|
1106
|
+
field motorTarget f32 "The motor's target speed (rad/s, m/s) or angle or position (rad, m)." {
|
|
1107
|
+
tunable true
|
|
1108
|
+
}
|
|
1109
|
+
field motorStiffness f32 "A position motor's stiffness; a velocity motor's strength." {
|
|
1110
|
+
default 50
|
|
1111
|
+
min 0
|
|
1112
|
+
tunable true
|
|
1113
|
+
}
|
|
1114
|
+
field motorDamping f32 "A position motor's damping." {
|
|
1115
|
+
default 5
|
|
1116
|
+
min 0
|
|
1117
|
+
tunable true
|
|
1118
|
+
}
|
|
1119
|
+
field motorMaxForce f32 "The most force (or torque) the motor applies; 0 is unbounded." {
|
|
1120
|
+
min 0
|
|
1121
|
+
tunable true
|
|
1122
|
+
}
|
|
1123
|
+
field restLength f32 "A spring's rest length." {
|
|
1124
|
+
default 1
|
|
1125
|
+
min 0
|
|
1126
|
+
unit m
|
|
1127
|
+
tunable true
|
|
1128
|
+
}
|
|
1129
|
+
field stiffness f32 "A spring's stiffness (N/m)." {
|
|
1130
|
+
default 40
|
|
1131
|
+
min 0
|
|
1132
|
+
tunable true
|
|
1133
|
+
}
|
|
1134
|
+
field damping f32 "A spring's damping (N·s/m)." {
|
|
1135
|
+
default 2
|
|
1136
|
+
min 0
|
|
1137
|
+
tunable true
|
|
1138
|
+
}
|
|
1139
|
+
field length f32 "A rope's longest distance between the anchors." {
|
|
1140
|
+
default 2
|
|
1141
|
+
min 0
|
|
1142
|
+
unit m
|
|
1143
|
+
tunable true
|
|
1144
|
+
}
|
|
1145
|
+
field collide bool "Whether the two bodies still collide with each other."
|
|
1146
|
+
field value f32 "Written: the hinge angle (rad) or the slide (m) after the step; the anchors' distance for springs and ropes." {
|
|
1147
|
+
readonly true
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
<sub>`api.ogt` line 3914</sub>
|
|
1153
|
+
|
|
1154
|
+
<a id="record-CharacterController"></a>
|
|
1155
|
+
|
|
1156
|
+
### `og.CharacterController` (component)
|
|
1157
|
+
|
|
1158
|
+
A kinematic character (3D, or top-down 2D): the entity's capsule (or any og.Collider) moved by `move` each tick, sliding along walls, climbing slopes up to `maxSlope` and steps up to `stepHeight`, snapped to the ground, carried by the moving platform it stands on and falling by gravity. It keeps `skin` off every surface, standing that far over the ground; a step is climbed when the ground beyond it is at most `stepHeight` over the ground it stands on. What blocks it is every solid collider its og.Collider's `layers` and `mask` interact with (each one's layers meeting the other's mask), as for bodies. The entity needs an og.Transform and an og.Collider; the step makes it a kinematic body and pushes dynamic bodies it walks into.
|
|
1159
|
+
|
|
1160
|
+
Token `og.CharacterController`, registered under the schema name `og.CharacterController`; its value type is `CharacterController`.
|
|
1161
|
+
|
|
1162
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1163
|
+
|---|---|---|---|---|---|---|
|
|
1164
|
+
| `move` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps` | — | The wanted velocity across the ground (m/s, world space; y is ignored unless gravityScale is 0). Set it every tick. |
|
|
1165
|
+
| `jump` | `boolean` | `false` | — | — | — | Held to jump: a jump starts on the tick it becomes true while grounded (or in coyote time). |
|
|
1166
|
+
| `jumpSpeed` | `number` | `6` | ≥ 0 | `mps` | tunable | The upward speed of a jump. |
|
|
1167
|
+
| `gravityScale` | `number` | `1` | 0 … 10 | — | tunable | Multiplies og.Physics.gravity; 0 for top-down movement in any direction. |
|
|
1168
|
+
| `maxSlope` | `number` | `45` | 0 … 89 | `deg` | tunable | The steepest slope it walks up. |
|
|
1169
|
+
| `stepHeight` | `number` | `0.3` | ≥ 0 | `m` | tunable | The highest step it climbs without jumping (0: none). |
|
|
1170
|
+
| `snapDistance` | `number` | `0.2` | ≥ 0 | `m` | tunable | How far below it the ground still holds it (stairs down, slopes): 0 lets it leave every edge. |
|
|
1171
|
+
| `skin` | `number` | `0.02` | ≥ 0.001 | `m` | — | The gap kept between it and every surface. |
|
|
1172
|
+
| `coyoteTime` | `number` | `0.1` | ≥ 0 | `s` | tunable | After leaving an edge, a jump still starts within this time. |
|
|
1173
|
+
| `maxFallSpeed` | `number` | `40` | ≥ 0 | `mps` | tunable | The fastest fall. |
|
|
1174
|
+
| `pushBodies` | `boolean` | `true` | — | — | — | Push dynamic bodies it walks into. |
|
|
1175
|
+
| `grounded` | `boolean` | `false` | — | — | read only | Written: standing on walkable ground after the step. |
|
|
1176
|
+
| `sliding` | `boolean` | `false` | — | — | read only | Written: sliding down a slope steeper than maxSlope. |
|
|
1177
|
+
| `velocity` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps` | read only | Written: the velocity it moved at this tick (the platform's carry included). |
|
|
1178
|
+
| `groundNormal` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | read only | Written: the ground's normal (zero in the air). |
|
|
1179
|
+
| `coyote` | `number` | `0` | — | — | read only | Written: seconds left in which a jump may still start (coyote time). |
|
|
1180
|
+
| `jumpWasHeld` | `boolean` | `false` | — | — | read only | Written: `jump` as the last step saw it (a jump starts on its rising edge). |
|
|
1181
|
+
| `ground` | `Entity` | `0` | — | — | read only | Written: the entity it stands on (0 in the air); a moving one carries it. |
|
|
1182
|
+
|
|
1183
|
+
```ogt
|
|
1184
|
+
component CharacterController {
|
|
1185
|
+
doc "A kinematic character (3D, or top-down 2D): the entity's capsule (or any og.Collider) moved by `move` each tick, sliding along walls, climbing slopes up to `maxSlope` and steps up to `stepHeight`, snapped to the ground, carried by the moving platform it stands on and falling by gravity. It keeps `skin` off every surface, standing that far over the ground; a step is climbed when the ground beyond it is at most `stepHeight` over the ground it stands on. What blocks it is every solid collider its og.Collider's `layers` and `mask` interact with (each one's layers meeting the other's mask), as for bodies. The entity needs an og.Transform and an og.Collider; the step makes it a kinematic body and pushes dynamic bodies it walks into."
|
|
1186
|
+
field move Vector3 "The wanted velocity across the ground (m/s, world space; y is ignored unless gravityScale is 0). Set it every tick." {
|
|
1187
|
+
unit mps
|
|
1188
|
+
}
|
|
1189
|
+
field jump bool "Held to jump: a jump starts on the tick it becomes true while grounded (or in coyote time)."
|
|
1190
|
+
field jumpSpeed f32 "The upward speed of a jump." {
|
|
1191
|
+
default 6
|
|
1192
|
+
min 0
|
|
1193
|
+
unit mps
|
|
1194
|
+
tunable true
|
|
1195
|
+
}
|
|
1196
|
+
field gravityScale f32 "Multiplies og.Physics.gravity; 0 for top-down movement in any direction." {
|
|
1197
|
+
default 1
|
|
1198
|
+
min 0
|
|
1199
|
+
max 10
|
|
1200
|
+
tunable true
|
|
1201
|
+
}
|
|
1202
|
+
field maxSlope f32 "The steepest slope it walks up." {
|
|
1203
|
+
default 45
|
|
1204
|
+
min 0
|
|
1205
|
+
max 89
|
|
1206
|
+
unit deg
|
|
1207
|
+
tunable true
|
|
1208
|
+
}
|
|
1209
|
+
field stepHeight f32 "The highest step it climbs without jumping (0: none)." {
|
|
1210
|
+
default 0.3
|
|
1211
|
+
min 0
|
|
1212
|
+
unit m
|
|
1213
|
+
tunable true
|
|
1214
|
+
}
|
|
1215
|
+
field snapDistance f32 "How far below it the ground still holds it (stairs down, slopes): 0 lets it leave every edge." {
|
|
1216
|
+
default 0.2
|
|
1217
|
+
min 0
|
|
1218
|
+
unit m
|
|
1219
|
+
tunable true
|
|
1220
|
+
}
|
|
1221
|
+
field skin f32 "The gap kept between it and every surface." {
|
|
1222
|
+
default 0.02
|
|
1223
|
+
min 0.001
|
|
1224
|
+
unit m
|
|
1225
|
+
}
|
|
1226
|
+
field coyoteTime f32 "After leaving an edge, a jump still starts within this time." {
|
|
1227
|
+
default 0.1
|
|
1228
|
+
min 0
|
|
1229
|
+
unit s
|
|
1230
|
+
tunable true
|
|
1231
|
+
}
|
|
1232
|
+
field maxFallSpeed f32 "The fastest fall." {
|
|
1233
|
+
default 40
|
|
1234
|
+
min 0
|
|
1235
|
+
unit mps
|
|
1236
|
+
tunable true
|
|
1237
|
+
}
|
|
1238
|
+
field pushBodies bool "Push dynamic bodies it walks into." {
|
|
1239
|
+
default true
|
|
1240
|
+
}
|
|
1241
|
+
field grounded bool "Written: standing on walkable ground after the step." {
|
|
1242
|
+
readonly true
|
|
1243
|
+
}
|
|
1244
|
+
field sliding bool "Written: sliding down a slope steeper than maxSlope." {
|
|
1245
|
+
readonly true
|
|
1246
|
+
}
|
|
1247
|
+
field velocity Vector3 "Written: the velocity it moved at this tick (the platform's carry included)." {
|
|
1248
|
+
unit mps
|
|
1249
|
+
readonly true
|
|
1250
|
+
}
|
|
1251
|
+
field groundNormal Vector3 "Written: the ground's normal (zero in the air)." {
|
|
1252
|
+
readonly true
|
|
1253
|
+
}
|
|
1254
|
+
field coyote f32 "Written: seconds left in which a jump may still start (coyote time)." {
|
|
1255
|
+
readonly true
|
|
1256
|
+
}
|
|
1257
|
+
field jumpWasHeld bool "Written: `jump` as the last step saw it (a jump starts on its rising edge)." {
|
|
1258
|
+
readonly true
|
|
1259
|
+
}
|
|
1260
|
+
field ground Entity "Written: the entity it stands on (0 in the air); a moving one carries it." {
|
|
1261
|
+
readonly true
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
```
|
|
1265
|
+
|
|
1266
|
+
<sub>`api.ogt` line 3984</sub>
|
|
1267
|
+
|
|
1268
|
+
<a id="record-PlatformerController"></a>
|
|
1269
|
+
|
|
1270
|
+
### `og.PlatformerController` (component)
|
|
1271
|
+
|
|
1272
|
+
A 2D platformer character (the 2D profile): run, jump and fall with designer units (jump height and time to apex, not gravity), coyote time, jump buffering, variable jump height (releasing jump while rising cuts the jump), apex hang, air jumps, wall slide and wall jump, one-way platforms (colliders on `oneWayLayers` are solid from above only; hold `down` to drop through), moving platforms (it rides what it stands on) and corner correction (a jump that clips a ceiling corner by less than `cornerCorrection` slides past it). It keeps `skin` off every surface; what blocks it is every solid collider its og.Collider's `layers` and `mask` interact with (each one's layers meeting the other's mask), as for bodies. The entity needs an og.Transform and an og.Collider (a box or capsule); it becomes a kinematic body.
|
|
1273
|
+
|
|
1274
|
+
Token `og.PlatformerController`, registered under the schema name `og.PlatformerController`; its value type is `PlatformerController`.
|
|
1275
|
+
|
|
1276
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1277
|
+
|---|---|---|---|---|---|---|
|
|
1278
|
+
| `moveX` | `number` | `0` | -1 … 1 | — | — | The run input, -1 (left) to 1 (right). Set it every tick. |
|
|
1279
|
+
| `jump` | `boolean` | `false` | — | — | — | Held to jump: a press is buffered for jumpBuffer; releasing while rising cuts the jump. |
|
|
1280
|
+
| `down` | `boolean` | `false` | — | — | — | Held to drop through a one-way platform. |
|
|
1281
|
+
| `impulse` | `Vector2` | `{ x: 0, y: 0 }` | — | `mps` | — | A velocity change to take on the next step (a knock-back, a spring, a recoil): added to `velocity`, then set back to zero. One with an upward y leaves the ground; the run's acceleration and gravity act on the result from then on, so a knock-back is `{ x: away * 6, y: 7 }` with `moveX` 0 for its few ticks. |
|
|
1282
|
+
| `maxSpeed` | `number` | `8` | ≥ 0 | `mps` | tunable | The top running speed. |
|
|
1283
|
+
| `acceleration` | `number` | `70` | ≥ 0 | `mps2` | tunable | How fast it reaches maxSpeed on the ground. |
|
|
1284
|
+
| `deceleration` | `number` | `80` | ≥ 0 | `mps2` | tunable | How fast it stops on the ground without input. |
|
|
1285
|
+
| `airAcceleration` | `number` | `45` | ≥ 0 | `mps2` | tunable | Acceleration in the air. |
|
|
1286
|
+
| `airDeceleration` | `number` | `25` | ≥ 0 | `mps2` | tunable | Deceleration in the air without input. |
|
|
1287
|
+
| `jumpHeight` | `number` | `3.2` | ≥ 0 | `m` | tunable | How high a full jump goes. |
|
|
1288
|
+
| `timeToApex` | `number` | `0.4` | ≥ 0.05 | `s` | tunable | How long a full jump takes to reach its height (sets gravity and the jump speed). |
|
|
1289
|
+
| `fallGravity` | `number` | `1.8` | ≥ 0 | — | tunable | Gravity multiplier while falling (snappier landings above 1). |
|
|
1290
|
+
| `jumpCut` | `number` | `2.5` | ≥ 1 | — | tunable | Gravity multiplier while rising with jump released (variable jump height; 1 disables it). |
|
|
1291
|
+
| `apexGravity` | `number` | `0.6` | 0 … 1 | — | tunable | Gravity multiplier near the apex while jump is held (hang time; 1 disables it). |
|
|
1292
|
+
| `apexThreshold` | `number` | `1.5` | ≥ 0 | `mps` | tunable | The vertical speed below which the apex multiplier applies. |
|
|
1293
|
+
| `maxFallSpeed` | `number` | `20` | ≥ 0 | `mps` | tunable | The fastest fall. |
|
|
1294
|
+
| `coyoteTime` | `number` | `0.1` | ≥ 0 | `s` | tunable | After running off an edge, a jump still starts within this time. |
|
|
1295
|
+
| `jumpBuffer` | `number` | `0.12` | ≥ 0 | `s` | tunable | A jump pressed this long before landing starts on landing. |
|
|
1296
|
+
| `airJumps` | `number` | `0` | 0 … 8 | — | — | Extra jumps in the air (1: a double jump). |
|
|
1297
|
+
| `wallJumps` | `boolean` | `true` | — | — | — | Slide down walls it pushes against (and jump off them). |
|
|
1298
|
+
| `wallSlideSpeed` | `number` | `3` | ≥ 0 | `mps` | tunable | The fastest slide down a wall. |
|
|
1299
|
+
| `wallJump` | `Vector2` | `{ x: 8, y: 12 }` | — | `mps` | tunable | A wall jump's velocity: x away from the wall, y up. |
|
|
1300
|
+
| `wallJumpLock` | `number` | `0.14` | ≥ 0 | `s` | tunable | After a wall jump, the run input is ignored for this long (so it leaves the wall). |
|
|
1301
|
+
| `oneWayLayers` | `number` | `0` | — | — | — | The collision layers that are one-way platforms (solid from above), as bits. |
|
|
1302
|
+
| `cornerCorrection` | `number` | `0.15` | ≥ 0 | `m` | tunable | How far a rising jump is nudged sideways past a ceiling corner (0: never). |
|
|
1303
|
+
| `maxSlope` | `number` | `50` | 0 … 89 | `deg` | tunable | The steepest slope it runs up. |
|
|
1304
|
+
| `snapDistance` | `number` | `0.1` | ≥ 0 | `m` | tunable | How far below it the ground still holds it (slopes, small drops). |
|
|
1305
|
+
| `skin` | `number` | `0.01` | ≥ 0.001 | `m` | — | The gap kept between it and every surface. |
|
|
1306
|
+
| `grounded` | `boolean` | `false` | — | — | read only | Written: standing on ground after the step. |
|
|
1307
|
+
| `onWall` | `number` | `0` | -1 … 1 | — | read only | Written: -1 sliding on a wall to its left, 1 to its right, 0 none. |
|
|
1308
|
+
| `facing` | `number` | `1` | -1 … 1 | — | read only | Written: -1 facing left, 1 right (the last run direction). |
|
|
1309
|
+
| `velocity` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps` | read only | Written: the velocity after the step (the platform's carry excluded). |
|
|
1310
|
+
| `jumping` | `boolean` | `false` | — | — | read only | Written: rising from a jump (until the apex or a release cut). |
|
|
1311
|
+
| `airJumpsLeft` | `number` | `0` | — | — | read only | Written: air jumps left before landing. |
|
|
1312
|
+
| `coyote` | `number` | `0` | — | — | read only | Written: seconds of coyote time left. |
|
|
1313
|
+
| `buffer` | `number` | `0` | — | — | read only | Written: seconds a buffered jump press stays valid. |
|
|
1314
|
+
| `wallLock` | `number` | `0` | — | — | read only | Written: seconds the run input stays locked after a wall jump. |
|
|
1315
|
+
| `dropTime` | `number` | `0` | — | — | read only | Written: seconds one-way platforms stay passable after dropping through. |
|
|
1316
|
+
| `jumpWasHeld` | `boolean` | `false` | — | — | read only | Written: `jump` as the last step saw it. |
|
|
1317
|
+
| `ground` | `Entity` | `0` | — | — | read only | Written: the entity it stands on (0 in the air); a moving one carries it. |
|
|
1318
|
+
|
|
1319
|
+
```ogt
|
|
1320
|
+
component PlatformerController {
|
|
1321
|
+
doc "A 2D platformer character (the 2D profile): run, jump and fall with designer units (jump height and time to apex, not gravity), coyote time, jump buffering, variable jump height (releasing jump while rising cuts the jump), apex hang, air jumps, wall slide and wall jump, one-way platforms (colliders on `oneWayLayers` are solid from above only; hold `down` to drop through), moving platforms (it rides what it stands on) and corner correction (a jump that clips a ceiling corner by less than `cornerCorrection` slides past it). It keeps `skin` off every surface; what blocks it is every solid collider its og.Collider's `layers` and `mask` interact with (each one's layers meeting the other's mask), as for bodies. The entity needs an og.Transform and an og.Collider (a box or capsule); it becomes a kinematic body."
|
|
1322
|
+
field moveX f32 "The run input, -1 (left) to 1 (right). Set it every tick." {
|
|
1323
|
+
min -1
|
|
1324
|
+
max 1
|
|
1325
|
+
}
|
|
1326
|
+
field jump bool "Held to jump: a press is buffered for jumpBuffer; releasing while rising cuts the jump."
|
|
1327
|
+
field down bool "Held to drop through a one-way platform."
|
|
1328
|
+
field impulse Vector2 "A velocity change to take on the next step (a knock-back, a spring, a recoil): added to `velocity`, then set back to zero. One with an upward y leaves the ground; the run's acceleration and gravity act on the result from then on, so a knock-back is `{ x: away * 6, y: 7 }` with `moveX` 0 for its few ticks." {
|
|
1329
|
+
unit mps
|
|
1330
|
+
}
|
|
1331
|
+
field maxSpeed f32 "The top running speed." {
|
|
1332
|
+
default 8
|
|
1333
|
+
min 0
|
|
1334
|
+
unit mps
|
|
1335
|
+
tunable true
|
|
1336
|
+
}
|
|
1337
|
+
field acceleration f32 "How fast it reaches maxSpeed on the ground." {
|
|
1338
|
+
default 70
|
|
1339
|
+
min 0
|
|
1340
|
+
unit mps2
|
|
1341
|
+
tunable true
|
|
1342
|
+
}
|
|
1343
|
+
field deceleration f32 "How fast it stops on the ground without input." {
|
|
1344
|
+
default 80
|
|
1345
|
+
min 0
|
|
1346
|
+
unit mps2
|
|
1347
|
+
tunable true
|
|
1348
|
+
}
|
|
1349
|
+
field airAcceleration f32 "Acceleration in the air." {
|
|
1350
|
+
default 45
|
|
1351
|
+
min 0
|
|
1352
|
+
unit mps2
|
|
1353
|
+
tunable true
|
|
1354
|
+
}
|
|
1355
|
+
field airDeceleration f32 "Deceleration in the air without input." {
|
|
1356
|
+
default 25
|
|
1357
|
+
min 0
|
|
1358
|
+
unit mps2
|
|
1359
|
+
tunable true
|
|
1360
|
+
}
|
|
1361
|
+
field jumpHeight f32 "How high a full jump goes." {
|
|
1362
|
+
default 3.2
|
|
1363
|
+
min 0
|
|
1364
|
+
unit m
|
|
1365
|
+
tunable true
|
|
1366
|
+
}
|
|
1367
|
+
field timeToApex f32 "How long a full jump takes to reach its height (sets gravity and the jump speed)." {
|
|
1368
|
+
default 0.4
|
|
1369
|
+
min 0.05
|
|
1370
|
+
unit s
|
|
1371
|
+
tunable true
|
|
1372
|
+
}
|
|
1373
|
+
field fallGravity f32 "Gravity multiplier while falling (snappier landings above 1)." {
|
|
1374
|
+
default 1.8
|
|
1375
|
+
min 0
|
|
1376
|
+
tunable true
|
|
1377
|
+
}
|
|
1378
|
+
field jumpCut f32 "Gravity multiplier while rising with jump released (variable jump height; 1 disables it)." {
|
|
1379
|
+
default 2.5
|
|
1380
|
+
min 1
|
|
1381
|
+
tunable true
|
|
1382
|
+
}
|
|
1383
|
+
field apexGravity f32 "Gravity multiplier near the apex while jump is held (hang time; 1 disables it)." {
|
|
1384
|
+
default 0.6
|
|
1385
|
+
min 0
|
|
1386
|
+
max 1
|
|
1387
|
+
tunable true
|
|
1388
|
+
}
|
|
1389
|
+
field apexThreshold f32 "The vertical speed below which the apex multiplier applies." {
|
|
1390
|
+
default 1.5
|
|
1391
|
+
min 0
|
|
1392
|
+
unit mps
|
|
1393
|
+
tunable true
|
|
1394
|
+
}
|
|
1395
|
+
field maxFallSpeed f32 "The fastest fall." {
|
|
1396
|
+
default 20
|
|
1397
|
+
min 0
|
|
1398
|
+
unit mps
|
|
1399
|
+
tunable true
|
|
1400
|
+
}
|
|
1401
|
+
field coyoteTime f32 "After running off an edge, a jump still starts within this time." {
|
|
1402
|
+
default 0.1
|
|
1403
|
+
min 0
|
|
1404
|
+
unit s
|
|
1405
|
+
tunable true
|
|
1406
|
+
}
|
|
1407
|
+
field jumpBuffer f32 "A jump pressed this long before landing starts on landing." {
|
|
1408
|
+
default 0.12
|
|
1409
|
+
min 0
|
|
1410
|
+
unit s
|
|
1411
|
+
tunable true
|
|
1412
|
+
}
|
|
1413
|
+
field airJumps u32 "Extra jumps in the air (1: a double jump)." {
|
|
1414
|
+
min 0
|
|
1415
|
+
max 8
|
|
1416
|
+
}
|
|
1417
|
+
field wallJumps bool "Slide down walls it pushes against (and jump off them)." {
|
|
1418
|
+
default true
|
|
1419
|
+
}
|
|
1420
|
+
field wallSlideSpeed f32 "The fastest slide down a wall." {
|
|
1421
|
+
default 3
|
|
1422
|
+
min 0
|
|
1423
|
+
unit mps
|
|
1424
|
+
tunable true
|
|
1425
|
+
}
|
|
1426
|
+
field wallJump Vector2 "A wall jump's velocity: x away from the wall, y up." {
|
|
1427
|
+
default 8 12
|
|
1428
|
+
unit mps
|
|
1429
|
+
tunable true
|
|
1430
|
+
}
|
|
1431
|
+
field wallJumpLock f32 "After a wall jump, the run input is ignored for this long (so it leaves the wall)." {
|
|
1432
|
+
default 0.14
|
|
1433
|
+
min 0
|
|
1434
|
+
unit s
|
|
1435
|
+
tunable true
|
|
1436
|
+
}
|
|
1437
|
+
field oneWayLayers u32 "The collision layers that are one-way platforms (solid from above), as bits."
|
|
1438
|
+
field cornerCorrection f32 "How far a rising jump is nudged sideways past a ceiling corner (0: never)." {
|
|
1439
|
+
default 0.15
|
|
1440
|
+
min 0
|
|
1441
|
+
unit m
|
|
1442
|
+
tunable true
|
|
1443
|
+
}
|
|
1444
|
+
field maxSlope f32 "The steepest slope it runs up." {
|
|
1445
|
+
default 50
|
|
1446
|
+
min 0
|
|
1447
|
+
max 89
|
|
1448
|
+
unit deg
|
|
1449
|
+
tunable true
|
|
1450
|
+
}
|
|
1451
|
+
field snapDistance f32 "How far below it the ground still holds it (slopes, small drops)." {
|
|
1452
|
+
default 0.1
|
|
1453
|
+
min 0
|
|
1454
|
+
unit m
|
|
1455
|
+
tunable true
|
|
1456
|
+
}
|
|
1457
|
+
field skin f32 "The gap kept between it and every surface." {
|
|
1458
|
+
default 0.01
|
|
1459
|
+
min 0.001
|
|
1460
|
+
unit m
|
|
1461
|
+
}
|
|
1462
|
+
field grounded bool "Written: standing on ground after the step." {
|
|
1463
|
+
readonly true
|
|
1464
|
+
}
|
|
1465
|
+
field onWall i32 "Written: -1 sliding on a wall to its left, 1 to its right, 0 none." {
|
|
1466
|
+
min -1
|
|
1467
|
+
max 1
|
|
1468
|
+
readonly true
|
|
1469
|
+
}
|
|
1470
|
+
field facing i32 "Written: -1 facing left, 1 right (the last run direction)." {
|
|
1471
|
+
default 1
|
|
1472
|
+
min -1
|
|
1473
|
+
max 1
|
|
1474
|
+
readonly true
|
|
1475
|
+
}
|
|
1476
|
+
field velocity Vector3 "Written: the velocity after the step (the platform's carry excluded)." {
|
|
1477
|
+
unit mps
|
|
1478
|
+
readonly true
|
|
1479
|
+
}
|
|
1480
|
+
field jumping bool "Written: rising from a jump (until the apex or a release cut)." {
|
|
1481
|
+
readonly true
|
|
1482
|
+
}
|
|
1483
|
+
field airJumpsLeft u32 "Written: air jumps left before landing." {
|
|
1484
|
+
readonly true
|
|
1485
|
+
}
|
|
1486
|
+
field coyote f32 "Written: seconds of coyote time left." {
|
|
1487
|
+
readonly true
|
|
1488
|
+
}
|
|
1489
|
+
field buffer f32 "Written: seconds a buffered jump press stays valid." {
|
|
1490
|
+
readonly true
|
|
1491
|
+
}
|
|
1492
|
+
field wallLock f32 "Written: seconds the run input stays locked after a wall jump." {
|
|
1493
|
+
readonly true
|
|
1494
|
+
}
|
|
1495
|
+
field dropTime f32 "Written: seconds one-way platforms stay passable after dropping through." {
|
|
1496
|
+
readonly true
|
|
1497
|
+
}
|
|
1498
|
+
field jumpWasHeld bool "Written: `jump` as the last step saw it." {
|
|
1499
|
+
readonly true
|
|
1500
|
+
}
|
|
1501
|
+
field ground Entity "Written: the entity it stands on (0 in the air); a moving one carries it." {
|
|
1502
|
+
readonly true
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
```
|
|
1506
|
+
|
|
1507
|
+
<sub>`api.ogt` line 4065</sub>
|
|
1508
|
+
|
|
1509
|
+
<a id="record-CharacterEvent"></a>
|
|
1510
|
+
|
|
1511
|
+
### `og.CharacterEvent` (event)
|
|
1512
|
+
|
|
1513
|
+
Something a CharacterController or PlatformerController did this step: the hooks for dust, squash, sounds and camera kicks. Read the next tick.
|
|
1514
|
+
|
|
1515
|
+
Token `og.CharacterEvent`, registered under the schema name `og.CharacterEvent`; its value type is `CharacterEvent`.
|
|
1516
|
+
|
|
1517
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1518
|
+
|---|---|---|---|---|---|---|
|
|
1519
|
+
| `entity` | `Entity` | `0` | — | — | — | The character. |
|
|
1520
|
+
| `kind` | `number` | `0` | 0 … 6 | — | — | CHARACTER_JUMPED 1, LANDED 2, WALL_JUMPED 3, AIR_JUMPED 4, LEFT_GROUND 5, BUMPED 6. |
|
|
1521
|
+
| `speed` | `number` | `0` | — | `mps` | — | The vertical speed at the moment (a landing's impact speed is negative). |
|
|
1522
|
+
|
|
1523
|
+
```ogt
|
|
1524
|
+
event CharacterEvent {
|
|
1525
|
+
doc "Something a CharacterController or PlatformerController did this step: the hooks for dust, squash, sounds and camera kicks. Read the next tick."
|
|
1526
|
+
field entity Entity "The character."
|
|
1527
|
+
field kind u32 "CHARACTER_JUMPED 1, LANDED 2, WALL_JUMPED 3, AIR_JUMPED 4, LEFT_GROUND 5, BUMPED 6." {
|
|
1528
|
+
min 0
|
|
1529
|
+
max 6
|
|
1530
|
+
}
|
|
1531
|
+
field speed f32 "The vertical speed at the moment (a landing's impact speed is negative)." {
|
|
1532
|
+
unit mps
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
```
|
|
1536
|
+
|
|
1537
|
+
<sub>`api.ogt` line 4258</sub>
|
|
1538
|
+
|
|
1539
|
+
<a id="record-Vehicle"></a>
|
|
1540
|
+
|
|
1541
|
+
### `og.Vehicle` (component)
|
|
1542
|
+
|
|
1543
|
+
A car on a dynamic chassis (the entity's og.RigidBody and og.Collider). 3D: a raycast car with four wheels (suspension, grip, steering on the front axle); its forward is the chassis's local +z (three.js Object3D.lookAt aims +z). 2D: two wheel bodies on sprung wheel joints (front at +x), driven by a motor. The wheels are not entities: og.physics.vehicleWheels gives their poses (and each tyre's slip) for drawing, smoke and skid marks.
|
|
1544
|
+
|
|
1545
|
+
The defaults drive a road car of about 1,000 kg: give the chassis that mass (og.RigidBody.mass 1000), since a car-sized box at the collider's density 1 weighs a few kilograms and the engine's and brakes' newtons would throw it. The suspension and the grip scale with the chassis's mass (Bullet's units), the engine and the brakes do not: a heavier car wants proportionally more engineForce and brakeForce. og-feel §12 has the numbers a game starts from.
|
|
1546
|
+
|
|
1547
|
+
The wheel rays meet what the chassis's collider would (its og.Collider layers against the other's mask, and the other's layers against its mask), so two cars on layers that do not meet (a ghost beside the player) pass through each other.
|
|
1548
|
+
|
|
1549
|
+
Token `og.Vehicle`, registered under the schema name `og.Vehicle`; its value type is `Vehicle`.
|
|
1550
|
+
|
|
1551
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1552
|
+
|---|---|---|---|---|---|---|
|
|
1553
|
+
| `throttle` | `number` | `0` | -1 … 1 | — | — | The accelerator, -1 (reverse) to 1. Set it every tick. |
|
|
1554
|
+
| `steer` | `number` | `0` | -1 … 1 | — | — | The steering, -1 (left) to 1 (right); 3D only. |
|
|
1555
|
+
| `brake` | `number` | `0` | 0 … 1 | — | — | The brake, 0 to 1. |
|
|
1556
|
+
| `wheelBase` | `number` | `2.6` | ≥ 0 | `m` | tunable | The distance between the front and rear axles. |
|
|
1557
|
+
| `track` | `number` | `1.6` | ≥ 0 | `m` | tunable | The distance between the left and right wheels (3D). |
|
|
1558
|
+
| `wheelRadius` | `number` | `0.4` | ≥ 0.01 | `m` | tunable | The wheels' radius. |
|
|
1559
|
+
| `mountHeight` | `number` | `0.2` | — | `m` | tunable | The height of the wheel mounts below the chassis centre. |
|
|
1560
|
+
| `suspensionRest` | `number` | `0.35` | ≥ 0 | `m` | tunable | The suspension's length at rest. |
|
|
1561
|
+
| `suspensionTravel` | `number` | `0.25` | ≥ 0 | `m` | tunable | How far the suspension compresses or extends from rest. |
|
|
1562
|
+
| `suspensionStiffness` | `number` | `30` | ≥ 0 | — | tunable | The suspension's stiffness. |
|
|
1563
|
+
| `suspensionDamping` | `number` | `4` | ≥ 0 | — | tunable | The suspension's damping. |
|
|
1564
|
+
| `grip` | `number` | `2` | ≥ 0 | — | tunable | The tyres' grip (3D: the friction slip, how much of its load a tyre holds before it slides: 2 grips a road car through a bend, below 1 it slides like a drift car; 2D: the wheels' friction). |
|
|
1565
|
+
| `engineForce` | `number` | `2500` | ≥ 0 | — | tunable | The engine's force at full throttle (3D: per driven wheel, in newtons: 2,500 on the two rear wheels push 1,000 kg at 5 m/s²; 2D: the motor's torque, N·m). |
|
|
1566
|
+
| `maxSpeed` | `number` | `40` | ≥ 0 | `mps` | tunable | The top speed: the engine's force fades out towards it (throttle against the motion brakes first). |
|
|
1567
|
+
| `brakeForce` | `number` | `2000` | ≥ 0 | — | tunable | The brakes' force at full brake (3D: per wheel, in newtons, every wheel braking: 2,000 stop 1,000 kg at 8 m/s²; 2D: the wheels' braking torque). |
|
|
1568
|
+
| `maxSteer` | `number` | `0.55` | 0 … 1.2 | `rad` | tunable | The front wheels' largest steering angle (3D). |
|
|
1569
|
+
| `drive` | `number` | `0` | 0 … 2 | — | — | DRIVE_REAR 0, DRIVE_FRONT 1, DRIVE_ALL 2. |
|
|
1570
|
+
| `wheelMass` | `number` | `20` | ≥ 0.01 | `kg` | tunable | The wheels' mass (2D: the wheel bodies; 3D ignores it). |
|
|
1571
|
+
| `rollInfluence` | `number` | `0` | 0 … 1 | — | tunable | How much the tyres' sideways grip rolls the chassis in a bend (3D): 0 pushes at the centre of mass's height, so the car corners flat and never tips over from steering (an arcade car); towards 1 at the road, the roll that tips a tall car over (rapier's own car uses 0.1, which rolls a 1,000 kg car at full lock above about 20 m/s). Raise it a little for body roll, with og.RigidBody.centerOfMass lowered to keep the car on its wheels. |
|
|
1572
|
+
| `speed` | `number` | `0` | — | `mps` | read only | Written: the forward speed (m/s; negative reversing). |
|
|
1573
|
+
| `contacts` | `number` | `0` | — | — | read only | Written: how many wheels touch the ground. |
|
|
1574
|
+
| `slip` | `number` | `0` | 0 … 1 | — | read only | Written: the largest slip of its wheels (og.physics.vehicleWheels' `slip`): 0 every tyre grips, towards 1 one slides; for a squeal's volume or smoke without reading the wheels (3D; 0 in 2D). |
|
|
1575
|
+
|
|
1576
|
+
```ogt
|
|
1577
|
+
component Vehicle {
|
|
1578
|
+
doc "A car on a dynamic chassis (the entity's og.RigidBody and og.Collider). 3D: a raycast car with four wheels (suspension, grip, steering on the front axle); its forward is the chassis's local +z (three.js Object3D.lookAt aims +z). 2D: two wheel bodies on sprung wheel joints (front at +x), driven by a motor. The wheels are not entities: og.physics.vehicleWheels gives their poses (and each tyre's slip) for drawing, smoke and skid marks."
|
|
1579
|
+
doc "The defaults drive a road car of about 1,000 kg: give the chassis that mass (og.RigidBody.mass 1000), since a car-sized box at the collider's density 1 weighs a few kilograms and the engine's and brakes' newtons would throw it. The suspension and the grip scale with the chassis's mass (Bullet's units), the engine and the brakes do not: a heavier car wants proportionally more engineForce and brakeForce. og-feel §12 has the numbers a game starts from."
|
|
1580
|
+
doc "The wheel rays meet what the chassis's collider would (its og.Collider layers against the other's mask, and the other's layers against its mask), so two cars on layers that do not meet (a ghost beside the player) pass through each other."
|
|
1581
|
+
field throttle f32 "The accelerator, -1 (reverse) to 1. Set it every tick." {
|
|
1582
|
+
min -1
|
|
1583
|
+
max 1
|
|
1584
|
+
}
|
|
1585
|
+
field steer f32 "The steering, -1 (left) to 1 (right); 3D only." {
|
|
1586
|
+
min -1
|
|
1587
|
+
max 1
|
|
1588
|
+
}
|
|
1589
|
+
field brake f32 "The brake, 0 to 1." {
|
|
1590
|
+
min 0
|
|
1591
|
+
max 1
|
|
1592
|
+
}
|
|
1593
|
+
field wheelBase f32 "The distance between the front and rear axles." {
|
|
1594
|
+
default 2.6
|
|
1595
|
+
min 0
|
|
1596
|
+
unit m
|
|
1597
|
+
tunable true
|
|
1598
|
+
}
|
|
1599
|
+
field track f32 "The distance between the left and right wheels (3D)." {
|
|
1600
|
+
default 1.6
|
|
1601
|
+
min 0
|
|
1602
|
+
unit m
|
|
1603
|
+
tunable true
|
|
1604
|
+
}
|
|
1605
|
+
field wheelRadius f32 "The wheels' radius." {
|
|
1606
|
+
default 0.4
|
|
1607
|
+
min 0.01
|
|
1608
|
+
unit m
|
|
1609
|
+
tunable true
|
|
1610
|
+
}
|
|
1611
|
+
field mountHeight f32 "The height of the wheel mounts below the chassis centre." {
|
|
1612
|
+
default 0.2
|
|
1613
|
+
unit m
|
|
1614
|
+
tunable true
|
|
1615
|
+
}
|
|
1616
|
+
field suspensionRest f32 "The suspension's length at rest." {
|
|
1617
|
+
default 0.35
|
|
1618
|
+
min 0
|
|
1619
|
+
unit m
|
|
1620
|
+
tunable true
|
|
1621
|
+
}
|
|
1622
|
+
field suspensionTravel f32 "How far the suspension compresses or extends from rest." {
|
|
1623
|
+
default 0.25
|
|
1624
|
+
min 0
|
|
1625
|
+
unit m
|
|
1626
|
+
tunable true
|
|
1627
|
+
}
|
|
1628
|
+
field suspensionStiffness f32 "The suspension's stiffness." {
|
|
1629
|
+
default 30
|
|
1630
|
+
min 0
|
|
1631
|
+
tunable true
|
|
1632
|
+
}
|
|
1633
|
+
field suspensionDamping f32 "The suspension's damping." {
|
|
1634
|
+
default 4
|
|
1635
|
+
min 0
|
|
1636
|
+
tunable true
|
|
1637
|
+
}
|
|
1638
|
+
field grip f32 "The tyres' grip (3D: the friction slip, how much of its load a tyre holds before it slides: 2 grips a road car through a bend, below 1 it slides like a drift car; 2D: the wheels' friction)." {
|
|
1639
|
+
default 2
|
|
1640
|
+
min 0
|
|
1641
|
+
tunable true
|
|
1642
|
+
}
|
|
1643
|
+
field engineForce f32 "The engine's force at full throttle (3D: per driven wheel, in newtons: 2,500 on the two rear wheels push 1,000 kg at 5 m/s²; 2D: the motor's torque, N·m)." {
|
|
1644
|
+
default 2500
|
|
1645
|
+
min 0
|
|
1646
|
+
tunable true
|
|
1647
|
+
}
|
|
1648
|
+
field maxSpeed f32 "The top speed: the engine's force fades out towards it (throttle against the motion brakes first)." {
|
|
1649
|
+
default 40
|
|
1650
|
+
min 0
|
|
1651
|
+
unit mps
|
|
1652
|
+
tunable true
|
|
1653
|
+
}
|
|
1654
|
+
field brakeForce f32 "The brakes' force at full brake (3D: per wheel, in newtons, every wheel braking: 2,000 stop 1,000 kg at 8 m/s²; 2D: the wheels' braking torque)." {
|
|
1655
|
+
default 2000
|
|
1656
|
+
min 0
|
|
1657
|
+
tunable true
|
|
1658
|
+
}
|
|
1659
|
+
field maxSteer f32 "The front wheels' largest steering angle (3D)." {
|
|
1660
|
+
default 0.55
|
|
1661
|
+
min 0
|
|
1662
|
+
max 1.2
|
|
1663
|
+
unit rad
|
|
1664
|
+
tunable true
|
|
1665
|
+
}
|
|
1666
|
+
field drive u32 "DRIVE_REAR 0, DRIVE_FRONT 1, DRIVE_ALL 2." {
|
|
1667
|
+
min 0
|
|
1668
|
+
max 2
|
|
1669
|
+
}
|
|
1670
|
+
field wheelMass f32 "The wheels' mass (2D: the wheel bodies; 3D ignores it)." {
|
|
1671
|
+
default 20
|
|
1672
|
+
min 0.01
|
|
1673
|
+
unit kg
|
|
1674
|
+
tunable true
|
|
1675
|
+
}
|
|
1676
|
+
field rollInfluence f32 "How much the tyres' sideways grip rolls the chassis in a bend (3D): 0 pushes at the centre of mass's height, so the car corners flat and never tips over from steering (an arcade car); towards 1 at the road, the roll that tips a tall car over (rapier's own car uses 0.1, which rolls a 1,000 kg car at full lock above about 20 m/s). Raise it a little for body roll, with og.RigidBody.centerOfMass lowered to keep the car on its wheels." {
|
|
1677
|
+
min 0
|
|
1678
|
+
max 1
|
|
1679
|
+
tunable true
|
|
1680
|
+
}
|
|
1681
|
+
field speed f32 "Written: the forward speed (m/s; negative reversing)." {
|
|
1682
|
+
unit mps
|
|
1683
|
+
readonly true
|
|
1684
|
+
}
|
|
1685
|
+
field contacts u32 "Written: how many wheels touch the ground." {
|
|
1686
|
+
readonly true
|
|
1687
|
+
}
|
|
1688
|
+
field slip f32 "Written: the largest slip of its wheels (og.physics.vehicleWheels' `slip`): 0 every tyre grips, towards 1 one slides; for a squeal's volume or smoke without reading the wheels (3D; 0 in 2D)." {
|
|
1689
|
+
min 0
|
|
1690
|
+
max 1
|
|
1691
|
+
readonly true
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
```
|
|
1695
|
+
|
|
1696
|
+
<sub>`api.ogt` line 4274</sub>
|
|
1697
|
+
|
|
1698
|
+
<a id="record-Rope"></a>
|
|
1699
|
+
|
|
1700
|
+
### `og.Rope` (component)
|
|
1701
|
+
|
|
1702
|
+
A Verlet rope: `segments` links from the entity's world position (its og.Transform after its parents'; plus `offset`) to `end` (an entity, plus `endOffset`) or hanging free, swung by gravity and wind, colliding with every solid collider at `radius`. It moves nothing (one-way: a rope joint ties bodies together, og.Joint JOINT_ROPE). Its points are world state (the og.physics state block); og.physics.ropePoints reads them and the renderer draws the rope as a strip of `width` and `color`.
|
|
1703
|
+
|
|
1704
|
+
Token `og.Rope`, registered under the schema name `og.Rope`; its value type is `Rope`.
|
|
1705
|
+
|
|
1706
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1707
|
+
|---|---|---|---|---|---|---|
|
|
1708
|
+
| `segments` | `number` | `16` | 1 … 256 | — | — | The number of links (points minus one). |
|
|
1709
|
+
| `length` | `number` | `4` | ≥ 0 | `m` | tunable | The rope's length at rest. |
|
|
1710
|
+
| `offset` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The start's offset from the entity's position (world axes). |
|
|
1711
|
+
| `end` | `Entity` | `0` | — | — | — | The entity the far end is tied to; 0 leaves it free. |
|
|
1712
|
+
| `endOffset` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The far end's offset from `end`'s position. |
|
|
1713
|
+
| `iterations` | `number` | `12` | 1 … 64 | — | tunable | Constraint passes per step: more is stiffer, at more cost. |
|
|
1714
|
+
| `damping` | `number` | `0.99` | 0 … 1 | — | tunable | How much of its velocity each point keeps per tick (1: none lost). |
|
|
1715
|
+
| `gravityScale` | `number` | `1` | -10 … 10 | — | tunable | Multiplies og.Physics.gravity. |
|
|
1716
|
+
| `wind` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps2` | tunable | A steady acceleration (wind). |
|
|
1717
|
+
| `radius` | `number` | `0.05` | ≥ 0 | `m` | tunable | The thickness it collides at (0: no collision). |
|
|
1718
|
+
| `width` | `number` | `0.08` | ≥ 0 | `m` | — | The drawn width. |
|
|
1719
|
+
| `color` | `Vector3` | `{ x: 0.55, y: 0.42, z: 0.28 }` | — | — | — | The drawn linear colour. |
|
|
1720
|
+
| `visible` | `boolean` | `true` | — | — | — | Whether the renderer draws it. |
|
|
1721
|
+
|
|
1722
|
+
```ogt
|
|
1723
|
+
component Rope {
|
|
1724
|
+
doc "A Verlet rope: `segments` links from the entity's world position (its og.Transform after its parents'; plus `offset`) to `end` (an entity, plus `endOffset`) or hanging free, swung by gravity and wind, colliding with every solid collider at `radius`. It moves nothing (one-way: a rope joint ties bodies together, og.Joint JOINT_ROPE). Its points are world state (the og.physics state block); og.physics.ropePoints reads them and the renderer draws the rope as a strip of `width` and `color`."
|
|
1725
|
+
field segments u32 "The number of links (points minus one)." {
|
|
1726
|
+
default 16
|
|
1727
|
+
min 1
|
|
1728
|
+
max 256
|
|
1729
|
+
}
|
|
1730
|
+
field length f32 "The rope's length at rest." {
|
|
1731
|
+
default 4
|
|
1732
|
+
min 0
|
|
1733
|
+
unit m
|
|
1734
|
+
tunable true
|
|
1735
|
+
}
|
|
1736
|
+
field offset Vector3 "The start's offset from the entity's position (world axes)." {
|
|
1737
|
+
unit m
|
|
1738
|
+
}
|
|
1739
|
+
field end Entity "The entity the far end is tied to; 0 leaves it free."
|
|
1740
|
+
field endOffset Vector3 "The far end's offset from `end`'s position." {
|
|
1741
|
+
unit m
|
|
1742
|
+
}
|
|
1743
|
+
field iterations u32 "Constraint passes per step: more is stiffer, at more cost." {
|
|
1744
|
+
default 12
|
|
1745
|
+
min 1
|
|
1746
|
+
max 64
|
|
1747
|
+
tunable true
|
|
1748
|
+
}
|
|
1749
|
+
field damping f32 "How much of its velocity each point keeps per tick (1: none lost)." {
|
|
1750
|
+
default 0.99
|
|
1751
|
+
min 0
|
|
1752
|
+
max 1
|
|
1753
|
+
tunable true
|
|
1754
|
+
}
|
|
1755
|
+
field gravityScale f32 "Multiplies og.Physics.gravity." {
|
|
1756
|
+
default 1
|
|
1757
|
+
min -10
|
|
1758
|
+
max 10
|
|
1759
|
+
tunable true
|
|
1760
|
+
}
|
|
1761
|
+
field wind Vector3 "A steady acceleration (wind)." {
|
|
1762
|
+
unit mps2
|
|
1763
|
+
tunable true
|
|
1764
|
+
}
|
|
1765
|
+
field radius f32 "The thickness it collides at (0: no collision)." {
|
|
1766
|
+
default 0.05
|
|
1767
|
+
min 0
|
|
1768
|
+
unit m
|
|
1769
|
+
tunable true
|
|
1770
|
+
}
|
|
1771
|
+
field width f32 "The drawn width." {
|
|
1772
|
+
default 0.08
|
|
1773
|
+
min 0
|
|
1774
|
+
unit m
|
|
1775
|
+
}
|
|
1776
|
+
field color Vector3 "The drawn linear colour." {
|
|
1777
|
+
default 0.55 0.42 0.28
|
|
1778
|
+
}
|
|
1779
|
+
field visible bool "Whether the renderer draws it." {
|
|
1780
|
+
default true
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
```
|
|
1784
|
+
|
|
1785
|
+
<sub>`api.ogt` line 4392</sub>
|
|
1786
|
+
|
|
1787
|
+
<a id="record-Cloth"></a>
|
|
1788
|
+
|
|
1789
|
+
### `og.Cloth` (component)
|
|
1790
|
+
|
|
1791
|
+
A Verlet cloth: a `columns` × `rows` grid of points, `spacing` apart, hanging from the entity's world position (its og.Transform after its parents': its top-left corner, the grid laid out along the entity's local x and down -y), pinned by `pins` (pinned points follow the entity), with stretch and shear constraints, gravity, wind, collision against every solid collider and, with `thickness`, against itself. One-way like og.Rope; its points are world state. Drawn as a double-sided mesh with `material` (og.render.standardMaterial; 0: a plain cloth colour).
|
|
1792
|
+
|
|
1793
|
+
Token `og.Cloth`, registered under the schema name `og.Cloth`; its value type is `Cloth`.
|
|
1794
|
+
|
|
1795
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1796
|
+
|---|---|---|---|---|---|---|
|
|
1797
|
+
| `columns` | `number` | `12` | 2 … 64 | — | — | Points across. |
|
|
1798
|
+
| `rows` | `number` | `12` | 2 … 64 | — | — | Points down. |
|
|
1799
|
+
| `spacing` | `number` | `0.15` | ≥ 0.001 | `m` | tunable | The rest distance between neighbouring points. |
|
|
1800
|
+
| `pins` | `number` | `1` | — | — | — | Which points are pinned, a sum of PIN_* bits (1 top row, 2 top corners, 4 left column, 8 top rings). |
|
|
1801
|
+
| `iterations` | `number` | `8` | 1 … 64 | — | tunable | Constraint passes per step. |
|
|
1802
|
+
| `damping` | `number` | `0.985` | 0 … 1 | — | tunable | How much of its velocity each point keeps per tick. |
|
|
1803
|
+
| `gravityScale` | `number` | `1` | -10 … 10 | — | tunable | Multiplies og.Physics.gravity. |
|
|
1804
|
+
| `wind` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps2` | tunable | A steady acceleration (wind); the cloth flutters with it. |
|
|
1805
|
+
| `gust` | `number` | `0.6` | 0 … 2 | — | tunable | How much the wind varies over the cloth and the tick (0: steady). |
|
|
1806
|
+
| `radius` | `number` | `0.04` | ≥ 0 | `m` | tunable | The thickness it collides at (0: no collision). |
|
|
1807
|
+
| `thickness` | `number` | `0` | ≥ 0 | `m` | tunable | Self-collision: how far apart its points keep from the points of the cloth that are not their near neighbours (0: none). About `spacing` keeps a cloth that folds or piles up from passing through itself. |
|
|
1808
|
+
| `substeps` | `number` | `1` | 1 … 16 | — | — | Simulation steps per tick, each integrating and then solving `iterations` passes; with self-collision enough that a point moves less than `thickness` per step (a point moves at most half the thickness a step). |
|
|
1809
|
+
| `friction` | `number` | `0` | 0 … 1 | — | tunable | How much of its sliding a point touching a solid loses each step (0: it slides freely; near 1 it sticks where it lands, so a cloth lowered onto the floor folds instead of spreading). |
|
|
1810
|
+
| `material` | `Material` | `0` | — | — | — | The material it is drawn with (og.render.standardMaterial); 0 is a plain cloth. |
|
|
1811
|
+
| `visible` | `boolean` | `true` | — | — | — | Whether the renderer draws it. |
|
|
1812
|
+
|
|
1813
|
+
```ogt
|
|
1814
|
+
component Cloth {
|
|
1815
|
+
doc "A Verlet cloth: a `columns` × `rows` grid of points, `spacing` apart, hanging from the entity's world position (its og.Transform after its parents': its top-left corner, the grid laid out along the entity's local x and down -y), pinned by `pins` (pinned points follow the entity), with stretch and shear constraints, gravity, wind, collision against every solid collider and, with `thickness`, against itself. One-way like og.Rope; its points are world state. Drawn as a double-sided mesh with `material` (og.render.standardMaterial; 0: a plain cloth colour)."
|
|
1816
|
+
field columns u32 "Points across." {
|
|
1817
|
+
default 12
|
|
1818
|
+
min 2
|
|
1819
|
+
max 64
|
|
1820
|
+
}
|
|
1821
|
+
field rows u32 "Points down." {
|
|
1822
|
+
default 12
|
|
1823
|
+
min 2
|
|
1824
|
+
max 64
|
|
1825
|
+
}
|
|
1826
|
+
field spacing f32 "The rest distance between neighbouring points." {
|
|
1827
|
+
default 0.15
|
|
1828
|
+
min 0.001
|
|
1829
|
+
unit m
|
|
1830
|
+
tunable true
|
|
1831
|
+
}
|
|
1832
|
+
field pins u32 "Which points are pinned, a sum of PIN_* bits (1 top row, 2 top corners, 4 left column, 8 top rings)." {
|
|
1833
|
+
default 1
|
|
1834
|
+
}
|
|
1835
|
+
field iterations u32 "Constraint passes per step." {
|
|
1836
|
+
default 8
|
|
1837
|
+
min 1
|
|
1838
|
+
max 64
|
|
1839
|
+
tunable true
|
|
1840
|
+
}
|
|
1841
|
+
field damping f32 "How much of its velocity each point keeps per tick." {
|
|
1842
|
+
default 0.985
|
|
1843
|
+
min 0
|
|
1844
|
+
max 1
|
|
1845
|
+
tunable true
|
|
1846
|
+
}
|
|
1847
|
+
field gravityScale f32 "Multiplies og.Physics.gravity." {
|
|
1848
|
+
default 1
|
|
1849
|
+
min -10
|
|
1850
|
+
max 10
|
|
1851
|
+
tunable true
|
|
1852
|
+
}
|
|
1853
|
+
field wind Vector3 "A steady acceleration (wind); the cloth flutters with it." {
|
|
1854
|
+
unit mps2
|
|
1855
|
+
tunable true
|
|
1856
|
+
}
|
|
1857
|
+
field gust f32 "How much the wind varies over the cloth and the tick (0: steady)." {
|
|
1858
|
+
default 0.6
|
|
1859
|
+
min 0
|
|
1860
|
+
max 2
|
|
1861
|
+
tunable true
|
|
1862
|
+
}
|
|
1863
|
+
field radius f32 "The thickness it collides at (0: no collision)." {
|
|
1864
|
+
default 0.04
|
|
1865
|
+
min 0
|
|
1866
|
+
unit m
|
|
1867
|
+
tunable true
|
|
1868
|
+
}
|
|
1869
|
+
field thickness f32 "Self-collision: how far apart its points keep from the points of the cloth that are not their near neighbours (0: none). About `spacing` keeps a cloth that folds or piles up from passing through itself." {
|
|
1870
|
+
min 0
|
|
1871
|
+
unit m
|
|
1872
|
+
tunable true
|
|
1873
|
+
}
|
|
1874
|
+
field substeps u32 "Simulation steps per tick, each integrating and then solving `iterations` passes; with self-collision enough that a point moves less than `thickness` per step (a point moves at most half the thickness a step)." {
|
|
1875
|
+
default 1
|
|
1876
|
+
min 1
|
|
1877
|
+
max 16
|
|
1878
|
+
}
|
|
1879
|
+
field friction f32 "How much of its sliding a point touching a solid loses each step (0: it slides freely; near 1 it sticks where it lands, so a cloth lowered onto the floor folds instead of spreading)." {
|
|
1880
|
+
min 0
|
|
1881
|
+
max 1
|
|
1882
|
+
tunable true
|
|
1883
|
+
}
|
|
1884
|
+
field material Material "The material it is drawn with (og.render.standardMaterial); 0 is a plain cloth."
|
|
1885
|
+
field visible bool "Whether the renderer draws it." {
|
|
1886
|
+
default true
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
```
|
|
1890
|
+
|
|
1891
|
+
<sub>`api.ogt` line 4458</sub>
|
|
1892
|
+
|
|
1893
|
+
<a id="record-Fluid2D"></a>
|
|
1894
|
+
|
|
1895
|
+
### `og.Fluid2D` (component)
|
|
1896
|
+
|
|
1897
|
+
A 2D particle fluid (any profile, in the xy plane): `count` particles spawned in a `size` box centred on the entity, simulated with double density relaxation (Clavet et al. 2005: pressure, near pressure, viscosity) on a fixed grid in a fixed order, so it is deterministic and part of the og.physics state block. Particles collide with every solid collider (pushed out of bodies; they push nothing back) and stay inside `bounds` around the entity when it is set. Fluids of one `group` interact: by `density` they layer, by `mixing` they blend. Drawn as metaballs: the particles blurred into a field the renderer thresholds into one surface of `color`, on sprite layer `layer`.
|
|
1898
|
+
|
|
1899
|
+
Token `og.Fluid2D`, registered under the schema name `og.Fluid2D`; its value type is `Fluid2D`.
|
|
1900
|
+
|
|
1901
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
1902
|
+
|---|---|---|---|---|---|---|
|
|
1903
|
+
| `count` | `number` | `1000` | 1 … 8192 | — | — | How many particles (spawned when the component appears or count changes). |
|
|
1904
|
+
| `size` | `Vector2` | `{ x: 4, y: 3 }` | — | `m` | — | The spawn box, centred on the entity. |
|
|
1905
|
+
| `bounds` | `Vector2` | `{ x: 0, y: 0 }` | — | `m` | — | The container around the entity (0 0: none; colliders still hold it). |
|
|
1906
|
+
| `radius` | `number` | `0.18` | ≥ 0.01 | `m` | tunable | The interaction radius: particles closer than this push and drag each other. |
|
|
1907
|
+
| `restDensity` | `number` | `1` | ≥ 0 | — | tunable | The density it settles at (neighbours within radius, weighted). |
|
|
1908
|
+
| `stiffness` | `number` | `0.1` | ≥ 0 | — | tunable | The pressure's strength (above about 0.15 it gets springy, then unstable). |
|
|
1909
|
+
| `nearStiffness` | `number` | `0.5` | ≥ 0 | — | tunable | The near pressure's strength (keeps particles apart, gives surface tension). |
|
|
1910
|
+
| `viscosity` | `number` | `0.15` | 0 … 4 | — | tunable | Linear viscosity (honey above 1). |
|
|
1911
|
+
| `group` | `number` | `0` | — | — | — | Fluids sharing a group above 0 push, drag and (by `mixing`) mix with each other as one fluid, at most four to a group (in entity order; a fifth is simulated alone), and are drawn as one surface whose colour follows the mix; 0 keeps the fluid to itself. |
|
|
1912
|
+
| `density` | `number` | `1` | 0.05 … 20 | — | tunable | How heavy its particles are against the group's other fluids: a heavier fluid sinks under a lighter one. |
|
|
1913
|
+
| `mixing` | `number` | `0` | 0 … 1 | — | tunable | How readily it mixes with the group's other fluids: 0 keeps them apart in layers (the boundary held), 1 blends them where they touch (their mix, colour and weight even out). |
|
|
1914
|
+
| `gravityScale` | `number` | `1` | -10 … 10 | — | tunable | Multiplies og.Physics.gravity. |
|
|
1915
|
+
| `substeps` | `number` | `2` | 1 … 8 | — | — | Simulation steps per tick. |
|
|
1916
|
+
| `seed` | `number` | `0` | — | — | — | The seed of the spawn jitter. |
|
|
1917
|
+
| `color` | `Vector3` | `{ x: 0.15, y: 0.45, z: 0.95 }` | — | — | — | The surface's linear colour. |
|
|
1918
|
+
| `opacity` | `number` | `0.9` | 0 … 1 | — | — | The surface's opacity. |
|
|
1919
|
+
| `blobScale` | `number` | `1.6` | 0.1 … 4 | — | — | The drawn size of each particle's blob (times radius). |
|
|
1920
|
+
| `threshold` | `number` | `0.45` | 0.01 … 4 | — | — | The field value where the surface starts (higher: thinner, separate drops). |
|
|
1921
|
+
| `layer` | `number` | `0` | — | — | — | The sprite layer it is drawn on. |
|
|
1922
|
+
| `visible` | `boolean` | `true` | — | — | — | Whether the renderer draws it. |
|
|
1923
|
+
|
|
1924
|
+
```ogt
|
|
1925
|
+
component Fluid2D {
|
|
1926
|
+
doc "A 2D particle fluid (any profile, in the xy plane): `count` particles spawned in a `size` box centred on the entity, simulated with double density relaxation (Clavet et al. 2005: pressure, near pressure, viscosity) on a fixed grid in a fixed order, so it is deterministic and part of the og.physics state block. Particles collide with every solid collider (pushed out of bodies; they push nothing back) and stay inside `bounds` around the entity when it is set. Fluids of one `group` interact: by `density` they layer, by `mixing` they blend. Drawn as metaballs: the particles blurred into a field the renderer thresholds into one surface of `color`, on sprite layer `layer`."
|
|
1927
|
+
field count u32 "How many particles (spawned when the component appears or count changes)." {
|
|
1928
|
+
default 1000
|
|
1929
|
+
min 1
|
|
1930
|
+
max 8192
|
|
1931
|
+
}
|
|
1932
|
+
field size Vector2 "The spawn box, centred on the entity." {
|
|
1933
|
+
default 4 3
|
|
1934
|
+
unit m
|
|
1935
|
+
}
|
|
1936
|
+
field bounds Vector2 "The container around the entity (0 0: none; colliders still hold it)." {
|
|
1937
|
+
unit m
|
|
1938
|
+
}
|
|
1939
|
+
field radius f32 "The interaction radius: particles closer than this push and drag each other." {
|
|
1940
|
+
default 0.18
|
|
1941
|
+
min 0.01
|
|
1942
|
+
unit m
|
|
1943
|
+
tunable true
|
|
1944
|
+
}
|
|
1945
|
+
field restDensity f32 "The density it settles at (neighbours within radius, weighted)." {
|
|
1946
|
+
default 1
|
|
1947
|
+
min 0
|
|
1948
|
+
tunable true
|
|
1949
|
+
}
|
|
1950
|
+
field stiffness f32 "The pressure's strength (above about 0.15 it gets springy, then unstable)." {
|
|
1951
|
+
default 0.1
|
|
1952
|
+
min 0
|
|
1953
|
+
tunable true
|
|
1954
|
+
}
|
|
1955
|
+
field nearStiffness f32 "The near pressure's strength (keeps particles apart, gives surface tension)." {
|
|
1956
|
+
default 0.5
|
|
1957
|
+
min 0
|
|
1958
|
+
tunable true
|
|
1959
|
+
}
|
|
1960
|
+
field viscosity f32 "Linear viscosity (honey above 1)." {
|
|
1961
|
+
default 0.15
|
|
1962
|
+
min 0
|
|
1963
|
+
max 4
|
|
1964
|
+
tunable true
|
|
1965
|
+
}
|
|
1966
|
+
field group u32 "Fluids sharing a group above 0 push, drag and (by `mixing`) mix with each other as one fluid, at most four to a group (in entity order; a fifth is simulated alone), and are drawn as one surface whose colour follows the mix; 0 keeps the fluid to itself."
|
|
1967
|
+
field density f32 "How heavy its particles are against the group's other fluids: a heavier fluid sinks under a lighter one." {
|
|
1968
|
+
default 1
|
|
1969
|
+
min 0.05
|
|
1970
|
+
max 20
|
|
1971
|
+
tunable true
|
|
1972
|
+
}
|
|
1973
|
+
field mixing f32 "How readily it mixes with the group's other fluids: 0 keeps them apart in layers (the boundary held), 1 blends them where they touch (their mix, colour and weight even out)." {
|
|
1974
|
+
min 0
|
|
1975
|
+
max 1
|
|
1976
|
+
tunable true
|
|
1977
|
+
}
|
|
1978
|
+
field gravityScale f32 "Multiplies og.Physics.gravity." {
|
|
1979
|
+
default 1
|
|
1980
|
+
min -10
|
|
1981
|
+
max 10
|
|
1982
|
+
tunable true
|
|
1983
|
+
}
|
|
1984
|
+
field substeps u32 "Simulation steps per tick." {
|
|
1985
|
+
default 2
|
|
1986
|
+
min 1
|
|
1987
|
+
max 8
|
|
1988
|
+
}
|
|
1989
|
+
field seed u32 "The seed of the spawn jitter."
|
|
1990
|
+
field color Vector3 "The surface's linear colour." {
|
|
1991
|
+
default 0.15 0.45 0.95
|
|
1992
|
+
}
|
|
1993
|
+
field opacity f32 "The surface's opacity." {
|
|
1994
|
+
default 0.9
|
|
1995
|
+
min 0
|
|
1996
|
+
max 1
|
|
1997
|
+
}
|
|
1998
|
+
field blobScale f32 "The drawn size of each particle's blob (times radius)." {
|
|
1999
|
+
default 1.6
|
|
2000
|
+
min 0.1
|
|
2001
|
+
max 4
|
|
2002
|
+
}
|
|
2003
|
+
field threshold f32 "The field value where the surface starts (higher: thinner, separate drops)." {
|
|
2004
|
+
default 0.45
|
|
2005
|
+
min 0.01
|
|
2006
|
+
max 4
|
|
2007
|
+
}
|
|
2008
|
+
field layer i32 "The sprite layer it is drawn on."
|
|
2009
|
+
field visible bool "Whether the renderer draws it." {
|
|
2010
|
+
default true
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
```
|
|
2014
|
+
|
|
2015
|
+
<sub>`api.ogt` line 4534</sub>
|
|
2016
|
+
|
|
2017
|
+
<a id="record-Fluid3D"></a>
|
|
2018
|
+
|
|
2019
|
+
### `og.Fluid3D` (component)
|
|
2020
|
+
|
|
2021
|
+
A 3D particle fluid (the 3D profile): `count` particles spawned in a `size` box centred on the entity, simulated with double density relaxation (Clavet et al. 2005: pressure, near pressure that gives surface tension, viscosity) over a spatial hash in a fixed order, so it is deterministic and part of the og.physics state block. Particles collide with every solid collider, the terrain's height field included (pushed out; they push nothing back), and stay inside `bounds` around the entity when it is set. An emitter adds particles at `emitRate` up to `maxCount`; a sink box removes those that enter it. Fluids of one `group` interact: by `density` they layer, by `mixing` they blend. Drawn as a screen-space surface: the particles' depth smoothed into one surface, refracting what is behind by its thickness and reflecting the sky, lit by the scene's lights. Cost: about 0.9 ms of CPU a tick for 2000 particles at 1 substep, 1.8 ms at 2 (native and wasm alike), growing with the particles; keep a scene's fluids to a few thousand particles. The surface costs about 1.1 ms of GPU (an Apple M4 Pro, the fluid covering a third of a 1280×720 frame) whatever the particle count, growing with the pixels it covers.
|
|
2022
|
+
|
|
2023
|
+
Token `og.Fluid3D`, registered under the schema name `og.Fluid3D`; its value type is `Fluid3D`.
|
|
2024
|
+
|
|
2025
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2026
|
+
|---|---|---|---|---|---|---|
|
|
2027
|
+
| `count` | `number` | `2000` | ≤ 32768 | — | — | How many particles to spawn in the box (when the component appears or count or seed changes; 0: none, the emitter fills it). |
|
|
2028
|
+
| `size` | `Vector3` | `{ x: 2, y: 1, z: 2 }` | — | `m` | — | The spawn box, centred on the entity. |
|
|
2029
|
+
| `bounds` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The container around the entity (0 on an axis: open on that axis; colliders and the terrain still hold it). |
|
|
2030
|
+
| `radius` | `number` | `0.2` | ≥ 0.02 | `m` | tunable | The interaction radius: particles closer than this push and drag each other. Cost grows with the particles, not the radius. |
|
|
2031
|
+
| `restDensity` | `number` | `10` | ≥ 0 | — | tunable | The density it settles at (neighbours within radius, weighted). |
|
|
2032
|
+
| `stiffness` | `number` | `0.02` | ≥ 0 | — | tunable | The pressure's strength (above about 0.05 it jitters, then springs apart). |
|
|
2033
|
+
| `nearStiffness` | `number` | `0.4` | ≥ 0 | — | tunable | The near pressure's strength (keeps particles apart, gives surface tension). |
|
|
2034
|
+
| `viscosity` | `number` | `0.4` | 0 … 4 | — | tunable | Linear viscosity (it also calms the surface; honey above 1). |
|
|
2035
|
+
| `group` | `number` | `0` | — | — | — | Fluids sharing a group above 0 push, drag and (by `mixing`) mix with each other as one fluid, at most four to a group (in entity order; a fifth is simulated alone); 0 keeps the fluid to itself. |
|
|
2036
|
+
| `density` | `number` | `1` | 0.05 … 20 | — | tunable | How heavy its particles are against the group's other fluids: a heavier fluid sinks under a lighter one. |
|
|
2037
|
+
| `mixing` | `number` | `0` | 0 … 1 | — | tunable | How readily it mixes with the group's other fluids: 0 keeps them apart in layers (the boundary held), 1 blends them where they touch (their mix, colour and weight even out). |
|
|
2038
|
+
| `gravityScale` | `number` | `1` | -10 … 10 | — | tunable | Multiplies og.Physics.gravity. |
|
|
2039
|
+
| `substeps` | `number` | `2` | 1 … 8 | — | — | Simulation steps per tick (each costs a full pass over the particles). |
|
|
2040
|
+
| `seed` | `number` | `0` | — | — | — | The seed of the spawn and emitter jitter. |
|
|
2041
|
+
| `maxCount` | `number` | `8192` | 1 … 32768 | — | — | The most particles alive at once (the emitter stops there). |
|
|
2042
|
+
| `emitRate` | `number` | `0` | 0 … 20000 | — | tunable | Particles the emitter adds per second (0: no emitter). |
|
|
2043
|
+
| `emitOffset` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Where the emitter is, from the entity (world axes). |
|
|
2044
|
+
| `emitVelocity` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps` | tunable | The velocity emitted particles start with. |
|
|
2045
|
+
| `emitRadius` | `number` | `0.1` | ≥ 0 | `m` | tunable | The half-size of the cube new particles appear in around the emitter. |
|
|
2046
|
+
| `sinkOffset` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The sink's centre, from the entity (world axes). |
|
|
2047
|
+
| `sinkSize` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The sink box: particles that enter it are removed (0 0 0: no sink). |
|
|
2048
|
+
| `color` | `Vector3` | `{ x: 0.2, y: 0.55, z: 0.9 }` | — | — | — | The fluid's linear colour (what light passing through it keeps). |
|
|
2049
|
+
| `opacity` | `number` | `0.6` | 0 … 1 | — | — | How opaque a metre of it is (0: clear as glass, 1: opaque). |
|
|
2050
|
+
| `reflectivity` | `number` | `1` | 0 … 2 | — | — | How much it reflects (scales the Fresnel term). |
|
|
2051
|
+
| `refraction` | `number` | `1` | 0 … 4 | — | — | How far refraction bends what is seen through it. |
|
|
2052
|
+
| `drawScale` | `number` | `0.6` | 0.1 … 2 | — | — | The drawn size of each particle (times radius). |
|
|
2053
|
+
| `smoothing` | `number` | `1` | 0 … 2 | — | — | How much the surface is smoothed (0: beads, 1: one surface). |
|
|
2054
|
+
| `visible` | `boolean` | `true` | — | — | — | Whether the renderer draws it. |
|
|
2055
|
+
|
|
2056
|
+
```ogt
|
|
2057
|
+
component Fluid3D {
|
|
2058
|
+
doc "A 3D particle fluid (the 3D profile): `count` particles spawned in a `size` box centred on the entity, simulated with double density relaxation (Clavet et al. 2005: pressure, near pressure that gives surface tension, viscosity) over a spatial hash in a fixed order, so it is deterministic and part of the og.physics state block. Particles collide with every solid collider, the terrain's height field included (pushed out; they push nothing back), and stay inside `bounds` around the entity when it is set. An emitter adds particles at `emitRate` up to `maxCount`; a sink box removes those that enter it. Fluids of one `group` interact: by `density` they layer, by `mixing` they blend. Drawn as a screen-space surface: the particles' depth smoothed into one surface, refracting what is behind by its thickness and reflecting the sky, lit by the scene's lights. Cost: about 0.9 ms of CPU a tick for 2000 particles at 1 substep, 1.8 ms at 2 (native and wasm alike), growing with the particles; keep a scene's fluids to a few thousand particles. The surface costs about 1.1 ms of GPU (an Apple M4 Pro, the fluid covering a third of a 1280×720 frame) whatever the particle count, growing with the pixels it covers."
|
|
2059
|
+
field count u32 "How many particles to spawn in the box (when the component appears or count or seed changes; 0: none, the emitter fills it)." {
|
|
2060
|
+
default 2000
|
|
2061
|
+
max 32768
|
|
2062
|
+
}
|
|
2063
|
+
field size Vector3 "The spawn box, centred on the entity." {
|
|
2064
|
+
default 2 1 2
|
|
2065
|
+
unit m
|
|
2066
|
+
}
|
|
2067
|
+
field bounds Vector3 "The container around the entity (0 on an axis: open on that axis; colliders and the terrain still hold it)." {
|
|
2068
|
+
unit m
|
|
2069
|
+
}
|
|
2070
|
+
field radius f32 "The interaction radius: particles closer than this push and drag each other. Cost grows with the particles, not the radius." {
|
|
2071
|
+
default 0.2
|
|
2072
|
+
min 0.02
|
|
2073
|
+
unit m
|
|
2074
|
+
tunable true
|
|
2075
|
+
}
|
|
2076
|
+
field restDensity f32 "The density it settles at (neighbours within radius, weighted)." {
|
|
2077
|
+
default 10
|
|
2078
|
+
min 0
|
|
2079
|
+
tunable true
|
|
2080
|
+
}
|
|
2081
|
+
field stiffness f32 "The pressure's strength (above about 0.05 it jitters, then springs apart)." {
|
|
2082
|
+
default 0.02
|
|
2083
|
+
min 0
|
|
2084
|
+
tunable true
|
|
2085
|
+
}
|
|
2086
|
+
field nearStiffness f32 "The near pressure's strength (keeps particles apart, gives surface tension)." {
|
|
2087
|
+
default 0.4
|
|
2088
|
+
min 0
|
|
2089
|
+
tunable true
|
|
2090
|
+
}
|
|
2091
|
+
field viscosity f32 "Linear viscosity (it also calms the surface; honey above 1)." {
|
|
2092
|
+
default 0.4
|
|
2093
|
+
min 0
|
|
2094
|
+
max 4
|
|
2095
|
+
tunable true
|
|
2096
|
+
}
|
|
2097
|
+
field group u32 "Fluids sharing a group above 0 push, drag and (by `mixing`) mix with each other as one fluid, at most four to a group (in entity order; a fifth is simulated alone); 0 keeps the fluid to itself."
|
|
2098
|
+
field density f32 "How heavy its particles are against the group's other fluids: a heavier fluid sinks under a lighter one." {
|
|
2099
|
+
default 1
|
|
2100
|
+
min 0.05
|
|
2101
|
+
max 20
|
|
2102
|
+
tunable true
|
|
2103
|
+
}
|
|
2104
|
+
field mixing f32 "How readily it mixes with the group's other fluids: 0 keeps them apart in layers (the boundary held), 1 blends them where they touch (their mix, colour and weight even out)." {
|
|
2105
|
+
min 0
|
|
2106
|
+
max 1
|
|
2107
|
+
tunable true
|
|
2108
|
+
}
|
|
2109
|
+
field gravityScale f32 "Multiplies og.Physics.gravity." {
|
|
2110
|
+
default 1
|
|
2111
|
+
min -10
|
|
2112
|
+
max 10
|
|
2113
|
+
tunable true
|
|
2114
|
+
}
|
|
2115
|
+
field substeps u32 "Simulation steps per tick (each costs a full pass over the particles)." {
|
|
2116
|
+
default 2
|
|
2117
|
+
min 1
|
|
2118
|
+
max 8
|
|
2119
|
+
}
|
|
2120
|
+
field seed u32 "The seed of the spawn and emitter jitter."
|
|
2121
|
+
field maxCount u32 "The most particles alive at once (the emitter stops there)." {
|
|
2122
|
+
default 8192
|
|
2123
|
+
min 1
|
|
2124
|
+
max 32768
|
|
2125
|
+
}
|
|
2126
|
+
field emitRate f32 "Particles the emitter adds per second (0: no emitter)." {
|
|
2127
|
+
min 0
|
|
2128
|
+
max 20000
|
|
2129
|
+
tunable true
|
|
2130
|
+
}
|
|
2131
|
+
field emitOffset Vector3 "Where the emitter is, from the entity (world axes)." {
|
|
2132
|
+
unit m
|
|
2133
|
+
}
|
|
2134
|
+
field emitVelocity Vector3 "The velocity emitted particles start with." {
|
|
2135
|
+
unit mps
|
|
2136
|
+
tunable true
|
|
2137
|
+
}
|
|
2138
|
+
field emitRadius f32 "The half-size of the cube new particles appear in around the emitter." {
|
|
2139
|
+
default 0.1
|
|
2140
|
+
min 0
|
|
2141
|
+
unit m
|
|
2142
|
+
tunable true
|
|
2143
|
+
}
|
|
2144
|
+
field sinkOffset Vector3 "The sink's centre, from the entity (world axes)." {
|
|
2145
|
+
unit m
|
|
2146
|
+
}
|
|
2147
|
+
field sinkSize Vector3 "The sink box: particles that enter it are removed (0 0 0: no sink)." {
|
|
2148
|
+
unit m
|
|
2149
|
+
}
|
|
2150
|
+
field color Vector3 "The fluid's linear colour (what light passing through it keeps)." {
|
|
2151
|
+
default 0.2 0.55 0.9
|
|
2152
|
+
}
|
|
2153
|
+
field opacity f32 "How opaque a metre of it is (0: clear as glass, 1: opaque)." {
|
|
2154
|
+
default 0.6
|
|
2155
|
+
min 0
|
|
2156
|
+
max 1
|
|
2157
|
+
}
|
|
2158
|
+
field reflectivity f32 "How much it reflects (scales the Fresnel term)." {
|
|
2159
|
+
default 1
|
|
2160
|
+
min 0
|
|
2161
|
+
max 2
|
|
2162
|
+
}
|
|
2163
|
+
field refraction f32 "How far refraction bends what is seen through it." {
|
|
2164
|
+
default 1
|
|
2165
|
+
min 0
|
|
2166
|
+
max 4
|
|
2167
|
+
}
|
|
2168
|
+
field drawScale f32 "The drawn size of each particle (times radius)." {
|
|
2169
|
+
default 0.6
|
|
2170
|
+
min 0.1
|
|
2171
|
+
max 2
|
|
2172
|
+
}
|
|
2173
|
+
field smoothing f32 "How much the surface is smoothed (0: beads, 1: one surface)." {
|
|
2174
|
+
default 1
|
|
2175
|
+
min 0
|
|
2176
|
+
max 2
|
|
2177
|
+
}
|
|
2178
|
+
field visible bool "Whether the renderer draws it." {
|
|
2179
|
+
default true
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
```
|
|
2183
|
+
|
|
2184
|
+
<sub>`api.ogt` line 4623</sub>
|
|
2185
|
+
|
|
2186
|
+
<a id="record-WaterSurface"></a>
|
|
2187
|
+
|
|
2188
|
+
### `og.WaterSurface` (component)
|
|
2189
|
+
|
|
2190
|
+
Height-field water (3D): a `resolution` × `resolution` grid of heights over a `size` square centred on the entity (its y is the rest level), waves travelling at `waveSpeed` and fading by `damping`. Dynamic bodies crossing it push waves (splashes; og.Splash events) and float by `buoyancy`. The heights are world state; an og.Water on the same entity draws them.
|
|
2191
|
+
|
|
2192
|
+
Token `og.WaterSurface`, registered under the schema name `og.WaterSurface`; its value type is `WaterSurface`.
|
|
2193
|
+
|
|
2194
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2195
|
+
|---|---|---|---|---|---|---|
|
|
2196
|
+
| `resolution` | `number` | `64` | 8 … 256 | — | — | Grid points along each side. |
|
|
2197
|
+
| `size` | `number` | `16` | ≥ 0.1 | `m` | tunable | The side of the square of water. |
|
|
2198
|
+
| `waveSpeed` | `number` | `3` | ≥ 0 | `mps` | tunable | How fast waves travel. |
|
|
2199
|
+
| `damping` | `number` | `0.4` | 0 … 1 | — | tunable | How much of a wave survives a second (1: no loss). |
|
|
2200
|
+
| `splash` | `number` | `1` | ≥ 0 | — | tunable | How strongly bodies push waves. |
|
|
2201
|
+
| `buoyancy` | `number` | `9.81` | ≥ 0 | — | tunable | The upward force on a submerged body per cubic metre of its box under water (0: bodies sink). |
|
|
2202
|
+
| `drag` | `number` | `1.5` | ≥ 0 | `perSecond` | tunable | How much a submerged body's velocity is slowed. |
|
|
2203
|
+
|
|
2204
|
+
```ogt
|
|
2205
|
+
component WaterSurface {
|
|
2206
|
+
doc "Height-field water (3D): a `resolution` × `resolution` grid of heights over a `size` square centred on the entity (its y is the rest level), waves travelling at `waveSpeed` and fading by `damping`. Dynamic bodies crossing it push waves (splashes; og.Splash events) and float by `buoyancy`. The heights are world state; an og.Water on the same entity draws them."
|
|
2207
|
+
field resolution u32 "Grid points along each side." {
|
|
2208
|
+
default 64
|
|
2209
|
+
min 8
|
|
2210
|
+
max 256
|
|
2211
|
+
}
|
|
2212
|
+
field size f32 "The side of the square of water." {
|
|
2213
|
+
default 16
|
|
2214
|
+
min 0.1
|
|
2215
|
+
unit m
|
|
2216
|
+
tunable true
|
|
2217
|
+
}
|
|
2218
|
+
field waveSpeed f32 "How fast waves travel." {
|
|
2219
|
+
default 3
|
|
2220
|
+
min 0
|
|
2221
|
+
unit mps
|
|
2222
|
+
tunable true
|
|
2223
|
+
}
|
|
2224
|
+
field damping f32 "How much of a wave survives a second (1: no loss)." {
|
|
2225
|
+
default 0.4
|
|
2226
|
+
min 0
|
|
2227
|
+
max 1
|
|
2228
|
+
tunable true
|
|
2229
|
+
}
|
|
2230
|
+
field splash f32 "How strongly bodies push waves." {
|
|
2231
|
+
default 1
|
|
2232
|
+
min 0
|
|
2233
|
+
tunable true
|
|
2234
|
+
}
|
|
2235
|
+
field buoyancy f32 "The upward force on a submerged body per cubic metre of its box under water (0: bodies sink)." {
|
|
2236
|
+
default 9.81
|
|
2237
|
+
min 0
|
|
2238
|
+
tunable true
|
|
2239
|
+
}
|
|
2240
|
+
field drag f32 "How much a submerged body's velocity is slowed." {
|
|
2241
|
+
default 1.5
|
|
2242
|
+
min 0
|
|
2243
|
+
unit perSecond
|
|
2244
|
+
tunable true
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
```
|
|
2248
|
+
|
|
2249
|
+
<sub>`api.ogt` line 4749</sub>
|
|
2250
|
+
|
|
2251
|
+
<a id="record-WaterLine"></a>
|
|
2252
|
+
|
|
2253
|
+
### `og.WaterLine` (component)
|
|
2254
|
+
|
|
2255
|
+
2D water for side-scrollers: a `width` × `depth` pool whose top edge (at the entity's y, centred on its x) is `columns` springs, each pulled to its rest height by `tension`, damped by `damping` and passing waves to its neighbours by `spread`. Bodies (and characters) crossing the surface splash it (og.Splash events) and float by `buoyancy`. The springs are world state; an og.Water2D on the same entity draws it.
|
|
2256
|
+
|
|
2257
|
+
Token `og.WaterLine`, registered under the schema name `og.WaterLine`; its value type is `WaterLine`.
|
|
2258
|
+
|
|
2259
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2260
|
+
|---|---|---|---|---|---|---|
|
|
2261
|
+
| `width` | `number` | `12` | ≥ 0.1 | `m` | tunable | The pool's width. |
|
|
2262
|
+
| `depth` | `number` | `3` | ≥ 0 | `m` | tunable | The pool's depth below the surface. |
|
|
2263
|
+
| `columns` | `number` | `96` | 4 … 512 | — | — | Springs along the surface. |
|
|
2264
|
+
| `tension` | `number` | `60` | ≥ 0 | — | tunable | How hard each spring pulls back to rest. |
|
|
2265
|
+
| `damping` | `number` | `2.5` | ≥ 0 | — | tunable | How fast a spring's motion dies. |
|
|
2266
|
+
| `spread` | `number` | `0.25` | 0 … 0.5 | — | tunable | How much of a spring's height its neighbours feel each pass (waves travel). |
|
|
2267
|
+
| `splash` | `number` | `0.04` | ≥ 0 | — | tunable | How strongly crossing bodies splash. |
|
|
2268
|
+
| `buoyancy` | `number` | `12` | ≥ 0 | — | tunable | The upward force on a submerged body per square metre of its box under water (0: bodies sink). |
|
|
2269
|
+
| `drag` | `number` | `2` | ≥ 0 | `perSecond` | tunable | How much a submerged body's velocity is slowed. |
|
|
2270
|
+
|
|
2271
|
+
```ogt
|
|
2272
|
+
component WaterLine {
|
|
2273
|
+
doc "2D water for side-scrollers: a `width` × `depth` pool whose top edge (at the entity's y, centred on its x) is `columns` springs, each pulled to its rest height by `tension`, damped by `damping` and passing waves to its neighbours by `spread`. Bodies (and characters) crossing the surface splash it (og.Splash events) and float by `buoyancy`. The springs are world state; an og.Water2D on the same entity draws it."
|
|
2274
|
+
field width f32 "The pool's width." {
|
|
2275
|
+
default 12
|
|
2276
|
+
min 0.1
|
|
2277
|
+
unit m
|
|
2278
|
+
tunable true
|
|
2279
|
+
}
|
|
2280
|
+
field depth f32 "The pool's depth below the surface." {
|
|
2281
|
+
default 3
|
|
2282
|
+
min 0
|
|
2283
|
+
unit m
|
|
2284
|
+
tunable true
|
|
2285
|
+
}
|
|
2286
|
+
field columns u32 "Springs along the surface." {
|
|
2287
|
+
default 96
|
|
2288
|
+
min 4
|
|
2289
|
+
max 512
|
|
2290
|
+
}
|
|
2291
|
+
field tension f32 "How hard each spring pulls back to rest." {
|
|
2292
|
+
default 60
|
|
2293
|
+
min 0
|
|
2294
|
+
tunable true
|
|
2295
|
+
}
|
|
2296
|
+
field damping f32 "How fast a spring's motion dies." {
|
|
2297
|
+
default 2.5
|
|
2298
|
+
min 0
|
|
2299
|
+
tunable true
|
|
2300
|
+
}
|
|
2301
|
+
field spread f32 "How much of a spring's height its neighbours feel each pass (waves travel)." {
|
|
2302
|
+
default 0.25
|
|
2303
|
+
min 0
|
|
2304
|
+
max 0.5
|
|
2305
|
+
tunable true
|
|
2306
|
+
}
|
|
2307
|
+
field splash f32 "How strongly crossing bodies splash." {
|
|
2308
|
+
default 0.04
|
|
2309
|
+
min 0
|
|
2310
|
+
tunable true
|
|
2311
|
+
}
|
|
2312
|
+
field buoyancy f32 "The upward force on a submerged body per square metre of its box under water (0: bodies sink)." {
|
|
2313
|
+
default 12
|
|
2314
|
+
min 0
|
|
2315
|
+
tunable true
|
|
2316
|
+
}
|
|
2317
|
+
field drag f32 "How much a submerged body's velocity is slowed." {
|
|
2318
|
+
default 2
|
|
2319
|
+
min 0
|
|
2320
|
+
unit perSecond
|
|
2321
|
+
tunable true
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
```
|
|
2325
|
+
|
|
2326
|
+
<sub>`api.ogt` line 4792</sub>
|
|
2327
|
+
|
|
2328
|
+
<a id="record-Splash"></a>
|
|
2329
|
+
|
|
2330
|
+
### `og.Splash` (event)
|
|
2331
|
+
|
|
2332
|
+
Something crossed a water surface (og.WaterSurface or og.WaterLine): for splash particles and sounds. Read the next tick.
|
|
2333
|
+
|
|
2334
|
+
Token `og.Splash`, registered under the schema name `og.Splash`; its value type is `Splash`.
|
|
2335
|
+
|
|
2336
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2337
|
+
|---|---|---|---|---|---|---|
|
|
2338
|
+
| `water` | `Entity` | `0` | — | — | — | The water's entity. |
|
|
2339
|
+
| `entity` | `Entity` | `0` | — | — | — | What crossed it. |
|
|
2340
|
+
| `point` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Where it crossed the surface. |
|
|
2341
|
+
| `speed` | `number` | `0` | — | `mps` | — | Its vertical speed (negative going in). |
|
|
2342
|
+
|
|
2343
|
+
```ogt
|
|
2344
|
+
event Splash {
|
|
2345
|
+
doc "Something crossed a water surface (og.WaterSurface or og.WaterLine): for splash particles and sounds. Read the next tick."
|
|
2346
|
+
field water Entity "The water's entity."
|
|
2347
|
+
field entity Entity "What crossed it."
|
|
2348
|
+
field point Vector3 "Where it crossed the surface." {
|
|
2349
|
+
unit m
|
|
2350
|
+
}
|
|
2351
|
+
field speed f32 "Its vertical speed (negative going in)." {
|
|
2352
|
+
unit mps
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
```
|
|
2356
|
+
|
|
2357
|
+
<sub>`api.ogt` line 4845</sub>
|
|
2358
|
+
|
|
2359
|
+
<a id="record-Ragdoll"></a>
|
|
2360
|
+
|
|
2361
|
+
### `og.Ragdoll` (component)
|
|
2362
|
+
|
|
2363
|
+
A ragdoll over an og.Skeleton: a capsule body per bone with a parent, joints with limits between them (ball joints with cone limits in 3D; in 2D hinges about z, the bones rapier2d bodies in the xy plane at their animated z, for a skeleton laid out in that plane), built from the skeleton's rest pose. `weight` is where the pose comes from: 0 the animation (the bodies follow it kinematically), 1 the physics (the bodies are dynamic, starting with the animation's velocity); the pose drawn blends between them over `blendTime`, both ways. The bodies are world state (the og.physics state block), not entities.
|
|
2364
|
+
|
|
2365
|
+
Token `og.Ragdoll`, registered under the schema name `og.Ragdoll`; its value type is `Ragdoll`.
|
|
2366
|
+
|
|
2367
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2368
|
+
|---|---|---|---|---|---|---|
|
|
2369
|
+
| `weight` | `number` | `0` | 0 … 1 | — | tunable | 0 animated, 1 ragdoll. Set it to 1 on a hit; back to 0 to recover. |
|
|
2370
|
+
| `blendTime` | `number` | `0.25` | ≥ 0 | `s` | tunable | How long the blend between animation and physics takes, both ways. |
|
|
2371
|
+
| `mass` | `number` | `60` | ≥ 0.1 | `kg` | tunable | The whole body's mass, shared by the bones by length. |
|
|
2372
|
+
| `thickness` | `number` | `0.22` | 0.01 … 1 | — | tunable | A bone capsule's radius as a fraction of its length. |
|
|
2373
|
+
| `jointLimit` | `number` | `0.9` | 0 … 3.1 | `rad` | tunable | How far each joint bends from the rest pose. |
|
|
2374
|
+
| `damping` | `number` | `0.6` | 0 … 20 | `perSecond` | tunable | How much of their motion the bones lose per second. |
|
|
2375
|
+
| `impulse` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | An impulse given to every bone when weight first goes up (a hit). |
|
|
2376
|
+
| `blend` | `number` | `0` | — | — | read only | Written: the blend in use (0 animation .. 1 physics). |
|
|
2377
|
+
|
|
2378
|
+
```ogt
|
|
2379
|
+
component Ragdoll {
|
|
2380
|
+
doc "A ragdoll over an og.Skeleton: a capsule body per bone with a parent, joints with limits between them (ball joints with cone limits in 3D; in 2D hinges about z, the bones rapier2d bodies in the xy plane at their animated z, for a skeleton laid out in that plane), built from the skeleton's rest pose. `weight` is where the pose comes from: 0 the animation (the bodies follow it kinematically), 1 the physics (the bodies are dynamic, starting with the animation's velocity); the pose drawn blends between them over `blendTime`, both ways. The bodies are world state (the og.physics state block), not entities."
|
|
2381
|
+
field weight f32 "0 animated, 1 ragdoll. Set it to 1 on a hit; back to 0 to recover." {
|
|
2382
|
+
min 0
|
|
2383
|
+
max 1
|
|
2384
|
+
tunable true
|
|
2385
|
+
}
|
|
2386
|
+
field blendTime f32 "How long the blend between animation and physics takes, both ways." {
|
|
2387
|
+
default 0.25
|
|
2388
|
+
min 0
|
|
2389
|
+
unit s
|
|
2390
|
+
tunable true
|
|
2391
|
+
}
|
|
2392
|
+
field mass f32 "The whole body's mass, shared by the bones by length." {
|
|
2393
|
+
default 60
|
|
2394
|
+
min 0.1
|
|
2395
|
+
unit kg
|
|
2396
|
+
tunable true
|
|
2397
|
+
}
|
|
2398
|
+
field thickness f32 "A bone capsule's radius as a fraction of its length." {
|
|
2399
|
+
default 0.22
|
|
2400
|
+
min 0.01
|
|
2401
|
+
max 1
|
|
2402
|
+
tunable true
|
|
2403
|
+
}
|
|
2404
|
+
field jointLimit f32 "How far each joint bends from the rest pose." {
|
|
2405
|
+
default 0.9
|
|
2406
|
+
min 0
|
|
2407
|
+
max 3.1
|
|
2408
|
+
unit rad
|
|
2409
|
+
tunable true
|
|
2410
|
+
}
|
|
2411
|
+
field damping f32 "How much of their motion the bones lose per second." {
|
|
2412
|
+
default 0.6
|
|
2413
|
+
min 0
|
|
2414
|
+
max 20
|
|
2415
|
+
unit perSecond
|
|
2416
|
+
tunable true
|
|
2417
|
+
}
|
|
2418
|
+
field impulse Vector3 "An impulse given to every bone when weight first goes up (a hit)."
|
|
2419
|
+
field blend f32 "Written: the blend in use (0 animation .. 1 physics)." {
|
|
2420
|
+
readonly true
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
```
|
|
2424
|
+
|
|
2425
|
+
<sub>`api.ogt` line 4857</sub>
|
|
2426
|
+
|
|
2427
|
+
## Types
|
|
2428
|
+
|
|
2429
|
+
<a id="type-QueryFilter"></a>
|
|
2430
|
+
|
|
2431
|
+
### `QueryFilter` (desc struct)
|
|
2432
|
+
|
|
2433
|
+
Which colliders a scene query considers. The zero value considers every solid collider on every layer.
|
|
2434
|
+
|
|
2435
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2436
|
+
|
|
2437
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2438
|
+
|---|---|---|---|---|---|---|
|
|
2439
|
+
| `mask` | `number` | `0` | — | — | — | Layers to consider: a collider counts when its layers meet this; 0 means every layer. |
|
|
2440
|
+
| `includeSensors` | `boolean` | `false` | — | — | — | Also report sensors. |
|
|
2441
|
+
| `exclude` | `Entity \| null` | `null` | — | — | — | An entity to ignore, such as the caster itself. |
|
|
2442
|
+
|
|
2443
|
+
```ogt
|
|
2444
|
+
struct QueryFilter {
|
|
2445
|
+
doc "Which colliders a scene query considers. The zero value considers every solid collider on every layer."
|
|
2446
|
+
desc true
|
|
2447
|
+
field mask u32 "Layers to consider: a collider counts when its layers meet this; 0 means every layer."
|
|
2448
|
+
field includeSensors bool "Also report sensors."
|
|
2449
|
+
field exclude Option.Entity "An entity to ignore, such as the caster itself."
|
|
2450
|
+
}
|
|
2451
|
+
```
|
|
2452
|
+
|
|
2453
|
+
<sub>`api.ogt` line 4902</sub>
|
|
2454
|
+
|
|
2455
|
+
<a id="type-RaycastDesc"></a>
|
|
2456
|
+
|
|
2457
|
+
### `RaycastDesc` (desc struct)
|
|
2458
|
+
|
|
2459
|
+
A ray for og.physics.raycast.
|
|
2460
|
+
|
|
2461
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2462
|
+
|
|
2463
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2464
|
+
|---|---|---|---|---|---|---|
|
|
2465
|
+
| `origin` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Where the ray starts. |
|
|
2466
|
+
| `direction` | `Vector3` | `{ x: 0, y: -1, z: 0 }` | — | — | — | Where it points; it need not be normalised and must not be zero (in 2D, not zero in xy). |
|
|
2467
|
+
| `maxDistance` | `number` | `0` | ≥ 0 | `m` | — | How far it reaches; 0 is unbounded. |
|
|
2468
|
+
| `filter` | `QueryFilter` | `{}` | — | — | — | Which colliders count. |
|
|
2469
|
+
|
|
2470
|
+
```ogt
|
|
2471
|
+
struct RaycastDesc {
|
|
2472
|
+
doc "A ray for og.physics.raycast."
|
|
2473
|
+
desc true
|
|
2474
|
+
field origin Vector3 "Where the ray starts." {
|
|
2475
|
+
unit m
|
|
2476
|
+
}
|
|
2477
|
+
field direction Vector3 "Where it points; it need not be normalised and must not be zero (in 2D, not zero in xy)." {
|
|
2478
|
+
default 0 -1 0
|
|
2479
|
+
}
|
|
2480
|
+
field maxDistance f32 "How far it reaches; 0 is unbounded." {
|
|
2481
|
+
min 0
|
|
2482
|
+
unit m
|
|
2483
|
+
}
|
|
2484
|
+
field filter QueryFilter "Which colliders count."
|
|
2485
|
+
}
|
|
2486
|
+
```
|
|
2487
|
+
|
|
2488
|
+
<sub>`api.ogt` line 4910</sub>
|
|
2489
|
+
|
|
2490
|
+
<a id="type-RaycastHit"></a>
|
|
2491
|
+
|
|
2492
|
+
### `RaycastHit` (struct)
|
|
2493
|
+
|
|
2494
|
+
The nearest collider a ray meets.
|
|
2495
|
+
|
|
2496
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2497
|
+
|---|---|---|---|---|---|---|
|
|
2498
|
+
| `entity` | `Entity` | `0` | — | — | — | The collider's entity. |
|
|
2499
|
+
| `distance` | `number` | `0` | — | `m` | — | From the origin along the normalised direction. |
|
|
2500
|
+
| `point` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | Where the ray meets the collider. |
|
|
2501
|
+
| `normal` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | The surface normal there (z is 0 in 2D). |
|
|
2502
|
+
|
|
2503
|
+
```ogt
|
|
2504
|
+
struct RaycastHit {
|
|
2505
|
+
doc "The nearest collider a ray meets."
|
|
2506
|
+
field entity Entity "The collider's entity."
|
|
2507
|
+
field distance f32 "From the origin along the normalised direction." {
|
|
2508
|
+
unit m
|
|
2509
|
+
}
|
|
2510
|
+
field point Vector3 "Where the ray meets the collider."
|
|
2511
|
+
field normal Vector3 "The surface normal there (z is 0 in 2D)."
|
|
2512
|
+
}
|
|
2513
|
+
```
|
|
2514
|
+
|
|
2515
|
+
<sub>`api.ogt` line 4926</sub>
|
|
2516
|
+
|
|
2517
|
+
<a id="type-ShapeDesc"></a>
|
|
2518
|
+
|
|
2519
|
+
### `ShapeDesc` (desc struct)
|
|
2520
|
+
|
|
2521
|
+
The shape of a shape cast or an overlap test: the shape fields of a Collider. The zero value is a 1 m box.
|
|
2522
|
+
|
|
2523
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2524
|
+
|
|
2525
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2526
|
+
|---|---|---|---|---|---|---|
|
|
2527
|
+
| `shape` | `number` | `0` | 0 … 5 | — | — | One of the SHAPE_* codes. |
|
|
2528
|
+
| `size` | `Vector3` | `{ x: 1, y: 1, z: 1 }` | — | `m` | — | Full extents of a box. |
|
|
2529
|
+
| `radius` | `number` | `0.5` | — | `m` | — | Radius of a sphere, circle, capsule or cylinder. |
|
|
2530
|
+
| `height` | `number` | `1` | — | `m` | — | Capsule or cylinder height. |
|
|
2531
|
+
| `mesh` | `Geometry` | `0` | — | — | — | The geometry of a convex or triangle-mesh shape. |
|
|
2532
|
+
|
|
2533
|
+
```ogt
|
|
2534
|
+
struct ShapeDesc {
|
|
2535
|
+
doc "The shape of a shape cast or an overlap test: the shape fields of a Collider. The zero value is a 1 m box."
|
|
2536
|
+
desc true
|
|
2537
|
+
field shape u32 "One of the SHAPE_* codes." {
|
|
2538
|
+
min 0
|
|
2539
|
+
max 5
|
|
2540
|
+
}
|
|
2541
|
+
field size Vector3 "Full extents of a box." {
|
|
2542
|
+
default 1 1 1
|
|
2543
|
+
unit m
|
|
2544
|
+
}
|
|
2545
|
+
field radius f32 "Radius of a sphere, circle, capsule or cylinder." {
|
|
2546
|
+
default 0.5
|
|
2547
|
+
unit m
|
|
2548
|
+
}
|
|
2549
|
+
field height f32 "Capsule or cylinder height." {
|
|
2550
|
+
default 1
|
|
2551
|
+
unit m
|
|
2552
|
+
}
|
|
2553
|
+
field mesh Geometry "The geometry of a convex or triangle-mesh shape."
|
|
2554
|
+
}
|
|
2555
|
+
```
|
|
2556
|
+
|
|
2557
|
+
<sub>`api.ogt` line 4936</sub>
|
|
2558
|
+
|
|
2559
|
+
<a id="type-ShapeCastDesc"></a>
|
|
2560
|
+
|
|
2561
|
+
### `ShapeCastDesc` (desc struct)
|
|
2562
|
+
|
|
2563
|
+
A shape swept along a direction for og.physics.shapeCast.
|
|
2564
|
+
|
|
2565
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2566
|
+
|
|
2567
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2568
|
+
|---|---|---|---|---|---|---|
|
|
2569
|
+
| `shape` | `ShapeDesc` | `{}` | — | — | — | The swept shape. |
|
|
2570
|
+
| `position` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Where the sweep starts. |
|
|
2571
|
+
| `rotation` | `Quaternion` | `{ x: 0, y: 0, z: 0, w: 1 }` | — | — | — | The shape's rotation; a zero quaternion is no rotation. |
|
|
2572
|
+
| `direction` | `Vector3` | `{ x: 0, y: -1, z: 0 }` | — | — | — | Where it sweeps; it need not be normalised and must not be zero. |
|
|
2573
|
+
| `maxDistance` | `number` | `0` | ≥ 0 | `m` | — | How far it sweeps; 0 is unbounded. |
|
|
2574
|
+
| `filter` | `QueryFilter` | `{}` | — | — | — | Which colliders count. |
|
|
2575
|
+
|
|
2576
|
+
```ogt
|
|
2577
|
+
struct ShapeCastDesc {
|
|
2578
|
+
doc "A shape swept along a direction for og.physics.shapeCast."
|
|
2579
|
+
desc true
|
|
2580
|
+
field shape ShapeDesc "The swept shape."
|
|
2581
|
+
field position Vector3 "Where the sweep starts." {
|
|
2582
|
+
unit m
|
|
2583
|
+
}
|
|
2584
|
+
field rotation Quaternion "The shape's rotation; a zero quaternion is no rotation."
|
|
2585
|
+
field direction Vector3 "Where it sweeps; it need not be normalised and must not be zero." {
|
|
2586
|
+
default 0 -1 0
|
|
2587
|
+
}
|
|
2588
|
+
field maxDistance f32 "How far it sweeps; 0 is unbounded." {
|
|
2589
|
+
min 0
|
|
2590
|
+
unit m
|
|
2591
|
+
}
|
|
2592
|
+
field filter QueryFilter "Which colliders count."
|
|
2593
|
+
}
|
|
2594
|
+
```
|
|
2595
|
+
|
|
2596
|
+
<sub>`api.ogt` line 4958</sub>
|
|
2597
|
+
|
|
2598
|
+
<a id="type-ShapeCastHit"></a>
|
|
2599
|
+
|
|
2600
|
+
### `ShapeCastHit` (struct)
|
|
2601
|
+
|
|
2602
|
+
The first collider a swept shape meets.
|
|
2603
|
+
|
|
2604
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2605
|
+
|---|---|---|---|---|---|---|
|
|
2606
|
+
| `entity` | `Entity` | `0` | — | — | — | The collider's entity. |
|
|
2607
|
+
| `distance` | `number` | `0` | — | `m` | — | How far the shape travelled before touching. |
|
|
2608
|
+
| `point` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | The contact point on the hit collider, in world space. |
|
|
2609
|
+
| `normal` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | The hit collider's surface normal there, in world space. |
|
|
2610
|
+
|
|
2611
|
+
```ogt
|
|
2612
|
+
struct ShapeCastHit {
|
|
2613
|
+
doc "The first collider a swept shape meets."
|
|
2614
|
+
field entity Entity "The collider's entity."
|
|
2615
|
+
field distance f32 "How far the shape travelled before touching." {
|
|
2616
|
+
unit m
|
|
2617
|
+
}
|
|
2618
|
+
field point Vector3 "The contact point on the hit collider, in world space."
|
|
2619
|
+
field normal Vector3 "The hit collider's surface normal there, in world space."
|
|
2620
|
+
}
|
|
2621
|
+
```
|
|
2622
|
+
|
|
2623
|
+
<sub>`api.ogt` line 4976</sub>
|
|
2624
|
+
|
|
2625
|
+
<a id="type-OverlapDesc"></a>
|
|
2626
|
+
|
|
2627
|
+
### `OverlapDesc` (desc struct)
|
|
2628
|
+
|
|
2629
|
+
A shape placed in the world for og.physics.overlap.
|
|
2630
|
+
|
|
2631
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2632
|
+
|
|
2633
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2634
|
+
|---|---|---|---|---|---|---|
|
|
2635
|
+
| `shape` | `ShapeDesc` | `{}` | — | — | — | The shape. |
|
|
2636
|
+
| `position` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Where it is. |
|
|
2637
|
+
| `rotation` | `Quaternion` | `{ x: 0, y: 0, z: 0, w: 1 }` | — | — | — | Its rotation; a zero quaternion is no rotation. |
|
|
2638
|
+
| `filter` | `QueryFilter` | `{}` | — | — | — | Which colliders count. |
|
|
2639
|
+
|
|
2640
|
+
```ogt
|
|
2641
|
+
struct OverlapDesc {
|
|
2642
|
+
doc "A shape placed in the world for og.physics.overlap."
|
|
2643
|
+
desc true
|
|
2644
|
+
field shape ShapeDesc "The shape."
|
|
2645
|
+
field position Vector3 "Where it is." {
|
|
2646
|
+
unit m
|
|
2647
|
+
}
|
|
2648
|
+
field rotation Quaternion "Its rotation; a zero quaternion is no rotation."
|
|
2649
|
+
field filter QueryFilter "Which colliders count."
|
|
2650
|
+
}
|
|
2651
|
+
```
|
|
2652
|
+
|
|
2653
|
+
<sub>`api.ogt` line 4986</sub>
|
|
2654
|
+
|
|
2655
|
+
<a id="type-MeshDesc"></a>
|
|
2656
|
+
|
|
2657
|
+
### `MeshDesc` (desc struct)
|
|
2658
|
+
|
|
2659
|
+
Geometry for convex and triangle-mesh colliders, in the mesh's own space.
|
|
2660
|
+
|
|
2661
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2662
|
+
|
|
2663
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2664
|
+
|---|---|---|---|---|---|---|
|
|
2665
|
+
| `positions` | `readonly Vector3[]` | `[]` | — | — | — | Vertex positions (2D polygons use x and y). |
|
|
2666
|
+
| `indices` | `readonly number[]` | `[]` | — | — | — | Triangles as triples of indices into positions; a convex hull ignores them. |
|
|
2667
|
+
|
|
2668
|
+
```ogt
|
|
2669
|
+
struct MeshDesc {
|
|
2670
|
+
doc "Geometry for convex and triangle-mesh colliders, in the mesh's own space."
|
|
2671
|
+
desc true
|
|
2672
|
+
field positions List.Vector3 "Vertex positions (2D polygons use x and y)."
|
|
2673
|
+
field indices List.u32 "Triangles as triples of indices into positions; a convex hull ignores them."
|
|
2674
|
+
}
|
|
2675
|
+
```
|
|
2676
|
+
|
|
2677
|
+
<sub>`api.ogt` line 4997</sub>
|
|
2678
|
+
|
|
2679
|
+
<a id="type-WheelPose"></a>
|
|
2680
|
+
|
|
2681
|
+
### `WheelPose` (struct)
|
|
2682
|
+
|
|
2683
|
+
A wheel of an og.Vehicle as the last step left it, for drawing.
|
|
2684
|
+
|
|
2685
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2686
|
+
|---|---|---|---|---|---|---|
|
|
2687
|
+
| `position` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The wheel's centre in world space. |
|
|
2688
|
+
| `rotation` | `Quaternion` | `{ x: 0, y: 0, z: 0, w: 1 }` | — | — | — | Its rotation (steering and spin) in world space. |
|
|
2689
|
+
| `contact` | `boolean` | `false` | — | — | — | Whether it touches the ground. |
|
|
2690
|
+
| `slip` | `number` | `0` | 0 … 1 | — | — | How much the tyre slides (rapier's skid info turned round): 0 it grips, towards 1 it asks for more than its grip holds (0.5 is twice as much); 0 in the air and in 2D. Start smoke and skid marks above about 0.2, and fade a squeal in with it. |
|
|
2691
|
+
| `sideSpeed` | `number` | `0` | — | `mps` | — | How fast the tyre's contact moves sideways over the ground (along its axle; 0 in the air and in 2D): a slide's speed, for the squeal's pitch or a skid mark's darkness. |
|
|
2692
|
+
|
|
2693
|
+
```ogt
|
|
2694
|
+
struct WheelPose {
|
|
2695
|
+
doc "A wheel of an og.Vehicle as the last step left it, for drawing."
|
|
2696
|
+
field position Vector3 "The wheel's centre in world space." {
|
|
2697
|
+
unit m
|
|
2698
|
+
}
|
|
2699
|
+
field rotation Quaternion "Its rotation (steering and spin) in world space."
|
|
2700
|
+
field contact bool "Whether it touches the ground."
|
|
2701
|
+
field slip f32 "How much the tyre slides (rapier's skid info turned round): 0 it grips, towards 1 it asks for more than its grip holds (0.5 is twice as much); 0 in the air and in 2D. Start smoke and skid marks above about 0.2, and fade a squeal in with it." {
|
|
2702
|
+
min 0
|
|
2703
|
+
max 1
|
|
2704
|
+
}
|
|
2705
|
+
field sideSpeed f32 "How fast the tyre's contact moves sideways over the ground (along its axle; 0 in the air and in 2D): a slide's speed, for the squeal's pitch or a skid mark's darkness." {
|
|
2706
|
+
unit mps
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
```
|
|
2710
|
+
|
|
2711
|
+
<sub>`api.ogt` line 5071</sub>
|
|
2712
|
+
|
|
2713
|
+
<a id="type-RagdollBoneDesc"></a>
|
|
2714
|
+
|
|
2715
|
+
### `RagdollBoneDesc` (desc struct)
|
|
2716
|
+
|
|
2717
|
+
One bone of a ragdoll rig: a capsule from the bone's position along `axis` for `length`.
|
|
2718
|
+
|
|
2719
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2720
|
+
|
|
2721
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2722
|
+
|---|---|---|---|---|---|---|
|
|
2723
|
+
| `parent` | `number` | `-1` | — | — | — | The parent bone's index (it must come earlier); -1 for the root. |
|
|
2724
|
+
| `position` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The bone's rest position relative to the entity. |
|
|
2725
|
+
| `rotation` | `Quaternion` | `{ x: 0, y: 0, z: 0, w: 1 }` | — | — | — | The bone's rest rotation relative to the entity; a zero quaternion is no rotation. |
|
|
2726
|
+
| `length` | `number` | `0.25` | — | `m` | — | How long the bone is (to its child). |
|
|
2727
|
+
| `axis` | `Vector3` | `{ x: 0, y: 1, z: 0 }` | — | — | — | The direction the bone points in its own frame (towards its child). |
|
|
2728
|
+
| `joint` | `number` | `-1` | — | — | — | The skeleton joint (its index in the skin) the bone stands for, so the model is drawn with it; -1 for none. |
|
|
2729
|
+
|
|
2730
|
+
```ogt
|
|
2731
|
+
struct RagdollBoneDesc {
|
|
2732
|
+
doc "One bone of a ragdoll rig: a capsule from the bone's position along `axis` for `length`."
|
|
2733
|
+
desc true
|
|
2734
|
+
field parent i32 "The parent bone's index (it must come earlier); -1 for the root." {
|
|
2735
|
+
default -1
|
|
2736
|
+
}
|
|
2737
|
+
field position Vector3 "The bone's rest position relative to the entity." {
|
|
2738
|
+
unit m
|
|
2739
|
+
}
|
|
2740
|
+
field rotation Quaternion "The bone's rest rotation relative to the entity; a zero quaternion is no rotation."
|
|
2741
|
+
field length f32 "How long the bone is (to its child)." {
|
|
2742
|
+
default 0.25
|
|
2743
|
+
unit m
|
|
2744
|
+
}
|
|
2745
|
+
field axis Vector3 "The direction the bone points in its own frame (towards its child)." {
|
|
2746
|
+
default 0 1 0
|
|
2747
|
+
}
|
|
2748
|
+
field joint i32 "The skeleton joint (its index in the skin) the bone stands for, so the model is drawn with it; -1 for none." {
|
|
2749
|
+
default -1
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
```
|
|
2753
|
+
|
|
2754
|
+
<sub>`api.ogt` line 5087</sub>
|
|
2755
|
+
|
|
2756
|
+
<a id="type-RagdollRigDesc"></a>
|
|
2757
|
+
|
|
2758
|
+
### `RagdollRigDesc` (desc struct)
|
|
2759
|
+
|
|
2760
|
+
The bones of a ragdoll, parents first, for og.physics.setRagdollRig; og.physics.ragdollRigFromSkeleton makes one from a model's skeleton.
|
|
2761
|
+
|
|
2762
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
2763
|
+
|
|
2764
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2765
|
+
|---|---|---|---|---|---|---|
|
|
2766
|
+
| `bones` | `readonly RagdollBoneDesc[]` | `[]` | — | — | — | The bones. |
|
|
2767
|
+
| `skeleton` | `SkeletonAsset` | `0` | — | — | — | The skeleton the bones' joints belong to (0: none): the entity's posed model is drawn blended towards the bones by og.Ragdoll.blend. |
|
|
2768
|
+
|
|
2769
|
+
```ogt
|
|
2770
|
+
struct RagdollRigDesc {
|
|
2771
|
+
doc "The bones of a ragdoll, parents first, for og.physics.setRagdollRig; og.physics.ragdollRigFromSkeleton makes one from a model's skeleton."
|
|
2772
|
+
desc true
|
|
2773
|
+
field bones List.RagdollBoneDesc "The bones."
|
|
2774
|
+
field skeleton SkeletonAsset "The skeleton the bones' joints belong to (0: none): the entity's posed model is drawn blended towards the bones by og.Ragdoll.blend."
|
|
2775
|
+
}
|
|
2776
|
+
```
|
|
2777
|
+
|
|
2778
|
+
<sub>`api.ogt` line 5109</sub>
|
|
2779
|
+
|
|
2780
|
+
<a id="type-BonePose"></a>
|
|
2781
|
+
|
|
2782
|
+
### `BonePose` (struct)
|
|
2783
|
+
|
|
2784
|
+
A ragdoll bone's pose as the last step left it (blended with the animation by og.Ragdoll.weight).
|
|
2785
|
+
|
|
2786
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2787
|
+
|---|---|---|---|---|---|---|
|
|
2788
|
+
| `position` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The bone's position in world space. |
|
|
2789
|
+
| `rotation` | `Quaternion` | `{ x: 0, y: 0, z: 0, w: 1 }` | — | — | — | Its rotation in world space. |
|
|
2790
|
+
|
|
2791
|
+
```ogt
|
|
2792
|
+
struct BonePose {
|
|
2793
|
+
doc "A ragdoll bone's pose as the last step left it (blended with the animation by og.Ragdoll.weight)."
|
|
2794
|
+
field position Vector3 "The bone's position in world space." {
|
|
2795
|
+
unit m
|
|
2796
|
+
}
|
|
2797
|
+
field rotation Quaternion "Its rotation in world space."
|
|
2798
|
+
}
|
|
2799
|
+
```
|
|
2800
|
+
|
|
2801
|
+
<sub>`api.ogt` line 5116</sub>
|
|
2802
|
+
|
|
2803
|
+
<a id="type-PhysicsPhase"></a>
|
|
2804
|
+
|
|
2805
|
+
### `PhysicsPhase` (struct)
|
|
2806
|
+
|
|
2807
|
+
One phase of the last physics step, for og.physics.stats.
|
|
2808
|
+
|
|
2809
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2810
|
+
|---|---|---|---|---|---|---|
|
|
2811
|
+
| `name` | `string` | `""` | — | — | — | gather (reading the components), sync (bodies and static colliders into rapier), joints (joints and vehicles), ragdolls, water (buoyancy before the step), rapier (rapier's step, every substep), readout (touching pairs and bodies read back, the rest rule), controllers (characters and platformers), soft (ropes and cloths), fluids (2D), fluids3d or writeBack (components and events written back). |
|
|
2812
|
+
| `ms` | `number` | `0` | — | `ms` | — | Wall-clock time it took (0 where the host has no clock); never world state. |
|
|
2813
|
+
| `split` | `boolean` | `false` | — | — | — | Whether any of its work ran on the lanes pool: rapier's stages when the step went to the pool, the other phases when they split by bodies, contact pairs, ragdolls, soft bodies or particles. |
|
|
2814
|
+
|
|
2815
|
+
```ogt
|
|
2816
|
+
struct PhysicsPhase {
|
|
2817
|
+
doc "One phase of the last physics step, for og.physics.stats."
|
|
2818
|
+
field name String "gather (reading the components), sync (bodies and static colliders into rapier), joints (joints and vehicles), ragdolls, water (buoyancy before the step), rapier (rapier's step, every substep), readout (touching pairs and bodies read back, the rest rule), controllers (characters and platformers), soft (ropes and cloths), fluids (2D), fluids3d or writeBack (components and events written back)."
|
|
2819
|
+
field ms f64 "Wall-clock time it took (0 where the host has no clock); never world state." {
|
|
2820
|
+
unit ms
|
|
2821
|
+
}
|
|
2822
|
+
field split bool "Whether any of its work ran on the lanes pool: rapier's stages when the step went to the pool, the other phases when they split by bodies, contact pairs, ragdolls, soft bodies or particles."
|
|
2823
|
+
}
|
|
2824
|
+
```
|
|
2825
|
+
|
|
2826
|
+
<sub>`api.ogt` line 5190</sub>
|
|
2827
|
+
|
|
2828
|
+
<a id="type-PhysicsStats"></a>
|
|
2829
|
+
|
|
2830
|
+
### `PhysicsStats` (struct)
|
|
2831
|
+
|
|
2832
|
+
What the last physics step cost, phase by phase, and where it ran: for finding where physics time goes. Timings are wall clock and vary run to run; the simulation never reads them.
|
|
2833
|
+
|
|
2834
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
2835
|
+
|---|---|---|---|---|---|---|
|
|
2836
|
+
| `tick` | `number` | `0` | — | — | — | The tick the step ran (0 before the first). |
|
|
2837
|
+
| `bodies` | `number` | `0` | — | — | — | The rapier bodies it stepped (with ragdoll bones and vehicle wheels). |
|
|
2838
|
+
| `threads` | `number` | `0` | — | — | — | The lanes pool's threads at the time (1: lanes off or single-threaded). |
|
|
2839
|
+
| `pool` | `boolean` | `false` | — | — | — | Whether the whole step ran on the lanes pool (from a number of bodies per thread count), where rapier splits its broad phase, narrow phase and solver. |
|
|
2840
|
+
| `ms` | `number` | `0` | — | `ms` | — | Wall-clock time of the whole og.physics system, gather to write-back. |
|
|
2841
|
+
| `phases` | `readonly PhysicsPhase[]` | `[]` | — | — | — | Every phase, in the order they run. |
|
|
2842
|
+
|
|
2843
|
+
```ogt
|
|
2844
|
+
struct PhysicsStats {
|
|
2845
|
+
doc "What the last physics step cost, phase by phase, and where it ran: for finding where physics time goes. Timings are wall clock and vary run to run; the simulation never reads them."
|
|
2846
|
+
field tick f64 "The tick the step ran (0 before the first)."
|
|
2847
|
+
field bodies u32 "The rapier bodies it stepped (with ragdoll bones and vehicle wheels)."
|
|
2848
|
+
field threads u32 "The lanes pool's threads at the time (1: lanes off or single-threaded)."
|
|
2849
|
+
field pool bool "Whether the whole step ran on the lanes pool (from a number of bodies per thread count), where rapier splits its broad phase, narrow phase and solver."
|
|
2850
|
+
field ms f64 "Wall-clock time of the whole og.physics system, gather to write-back." {
|
|
2851
|
+
unit ms
|
|
2852
|
+
}
|
|
2853
|
+
field phases List.PhysicsPhase "Every phase, in the order they run."
|
|
2854
|
+
}
|
|
2855
|
+
```
|
|
2856
|
+
|
|
2857
|
+
<sub>`api.ogt` line 5199</sub>
|
|
2858
|
+
|
|
2859
|
+
## Constants
|
|
2860
|
+
|
|
2861
|
+
| Constant | Type | Value | Doc |
|
|
2862
|
+
|---|---|---|---|
|
|
2863
|
+
| <a id="const-BODY_DYNAMIC"></a>`BODY_DYNAMIC` | `number` | `0` | RigidBody.kind: moved by the solver; its Transform and Velocity are written back every tick. |
|
|
2864
|
+
| <a id="const-BODY_STATIC"></a>`BODY_STATIC` | `number` | `1` | RigidBody.kind: never moves; collides with dynamic bodies. |
|
|
2865
|
+
| <a id="const-BODY_KINEMATIC"></a>`BODY_KINEMATIC` | `number` | `2` | RigidBody.kind: not moved by the solver. With an og.Velocity the step moves it by it each tick and writes its Transform back (a lift, a conveyor, a turning gear); a Transform game code writes moves it there first (a teleport). Without one it stays where its Transform puts it. Either way it pushes dynamic bodies and carries the controllers standing on it. |
|
|
2866
|
+
| <a id="const-LOCK_TRANSLATION_X"></a>`LOCK_TRANSLATION_X` | `number` | `1` | RigidBody.lock bit: no translation along x. |
|
|
2867
|
+
| <a id="const-LOCK_TRANSLATION_Y"></a>`LOCK_TRANSLATION_Y` | `number` | `2` | RigidBody.lock bit: no translation along y. |
|
|
2868
|
+
| <a id="const-LOCK_TRANSLATION_Z"></a>`LOCK_TRANSLATION_Z` | `number` | `4` | RigidBody.lock bit: no translation along z. |
|
|
2869
|
+
| <a id="const-LOCK_ROTATION_X"></a>`LOCK_ROTATION_X` | `number` | `8` | RigidBody.lock bit: no rotation about x. |
|
|
2870
|
+
| <a id="const-LOCK_ROTATION_Y"></a>`LOCK_ROTATION_Y` | `number` | `16` | RigidBody.lock bit: no rotation about y. |
|
|
2871
|
+
| <a id="const-LOCK_ROTATION_Z"></a>`LOCK_ROTATION_Z` | `number` | `32` | RigidBody.lock bit: no rotation about z (the 2D profile's only rotation). |
|
|
2872
|
+
| <a id="const-SHAPE_BOX"></a>`SHAPE_BOX` | `number` | `0` | Collider.shape: a box of `size` (both profiles). |
|
|
2873
|
+
| <a id="const-SHAPE_SPHERE"></a>`SHAPE_SPHERE` | `number` | `1` | Collider.shape: a sphere of `radius` (a circle in 2D). |
|
|
2874
|
+
| <a id="const-SHAPE_CAPSULE"></a>`SHAPE_CAPSULE` | `number` | `2` | Collider.shape: a capsule along y of `radius`, with `height` between the cap centres (both profiles). |
|
|
2875
|
+
| <a id="const-SHAPE_CYLINDER"></a>`SHAPE_CYLINDER` | `number` | `3` | Collider.shape: a cylinder along y of `radius` and `height` (3D only). |
|
|
2876
|
+
| <a id="const-SHAPE_CONVEX"></a>`SHAPE_CONVEX` | `number` | `4` | Collider.shape: the convex hull of the vertices of `mesh` (3D), or of their xy (a convex polygon, 2D). |
|
|
2877
|
+
| <a id="const-SHAPE_TRIMESH"></a>`SHAPE_TRIMESH` | `number` | `5` | Collider.shape: the triangles of `mesh` (3D only; for static and kinematic bodies). |
|
|
2878
|
+
| <a id="const-SHAPE_HEIGHTFIELD"></a>`SHAPE_HEIGHTFIELD` | `number` | `6` | Collider.shape: the height field registered as `mesh`, centred on the entity (3D only; a terrain: og.terrain.load's TerrainInfo.geometry). |
|
|
2879
|
+
| <a id="const-PROFILE_2D"></a>`PROFILE_2D` | `number` | `2` | Physics.profile: rapier2d, bodies in the xy plane rotating about z. |
|
|
2880
|
+
| <a id="const-PROFILE_3D"></a>`PROFILE_3D` | `number` | `3` | Physics.profile: rapier3d. |
|
|
2881
|
+
| <a id="const-JOINT_FIXED"></a>`JOINT_FIXED` | `number` | `0` | `Joint.kind`: the two bodies move as one. |
|
|
2882
|
+
| <a id="const-JOINT_REVOLUTE"></a>`JOINT_REVOLUTE` | `number` | `1` | `Joint.kind`: a hinge about `axis` (2D: about z), with optional limits and a motor. |
|
|
2883
|
+
| <a id="const-JOINT_PRISMATIC"></a>`JOINT_PRISMATIC` | `number` | `2` | `Joint.kind`: a slider along `axis`, with optional limits and a motor. |
|
|
2884
|
+
| <a id="const-JOINT_SPRING"></a>`JOINT_SPRING` | `number` | `3` | `Joint.kind`: a damped spring pulling the anchors to `restLength` apart. |
|
|
2885
|
+
| <a id="const-JOINT_ROPE"></a>`JOINT_ROPE` | `number` | `4` | `Joint.kind`: a rope: the anchors stay at most `length` apart, free inside it. |
|
|
2886
|
+
| <a id="const-JOINT_BALL"></a>`JOINT_BALL` | `number` | `5` | `Joint.kind`: a ball and socket (3D; the 2D profile treats it as a hinge). |
|
|
2887
|
+
| <a id="const-MOTOR_NONE"></a>`MOTOR_NONE` | `number` | `0` | `Joint.motor`: no motor. |
|
|
2888
|
+
| <a id="const-MOTOR_VELOCITY"></a>`MOTOR_VELOCITY` | `number` | `1` | `Joint.motor`: drive towards `motorTarget` speed (rad/s or m/s). |
|
|
2889
|
+
| <a id="const-MOTOR_POSITION"></a>`MOTOR_POSITION` | `number` | `2` | `Joint.motor`: spring towards `motorTarget` angle or position (a servo). |
|
|
2890
|
+
| <a id="const-CHARACTER_JUMPED"></a>`CHARACTER_JUMPED` | `number` | `1` | `CharacterEvent.kind`: a jump from the ground (or in coyote time). |
|
|
2891
|
+
| <a id="const-CHARACTER_LANDED"></a>`CHARACTER_LANDED` | `number` | `2` | `CharacterEvent.kind`: touched the ground after being in the air. |
|
|
2892
|
+
| <a id="const-CHARACTER_WALL_JUMPED"></a>`CHARACTER_WALL_JUMPED` | `number` | `3` | `CharacterEvent.kind`: a jump off a wall. |
|
|
2893
|
+
| <a id="const-CHARACTER_AIR_JUMPED"></a>`CHARACTER_AIR_JUMPED` | `number` | `4` | `CharacterEvent.kind`: a jump in the air (PlatformerController.airJumps). |
|
|
2894
|
+
| <a id="const-CHARACTER_LEFT_GROUND"></a>`CHARACTER_LEFT_GROUND` | `number` | `5` | `CharacterEvent.kind`: left the ground without jumping (ran off an edge). |
|
|
2895
|
+
| <a id="const-CHARACTER_BUMPED"></a>`CHARACTER_BUMPED` | `number` | `6` | `CharacterEvent.kind`: hit a ceiling while rising. |
|
|
2896
|
+
| <a id="const-DRIVE_REAR"></a>`DRIVE_REAR` | `number` | `0` | `Vehicle.drive`: the rear wheels drive. |
|
|
2897
|
+
| <a id="const-DRIVE_FRONT"></a>`DRIVE_FRONT` | `number` | `1` | `Vehicle.drive`: the front wheels drive. |
|
|
2898
|
+
| <a id="const-DRIVE_ALL"></a>`DRIVE_ALL` | `number` | `2` | `Vehicle.drive`: every wheel drives. |
|
|
2899
|
+
| <a id="const-PIN_TOP"></a>`PIN_TOP` | `number` | `1` | `Cloth.pins` bit: the whole top row is pinned. |
|
|
2900
|
+
| <a id="const-PIN_TOP_CORNERS"></a>`PIN_TOP_CORNERS` | `number` | `2` | `Cloth.pins` bit: the top-left and top-right corners are pinned. |
|
|
2901
|
+
| <a id="const-PIN_LEFT"></a>`PIN_LEFT` | `number` | `4` | `Cloth.pins` bit: the whole left column is pinned (a flag on a pole). |
|
|
2902
|
+
| <a id="const-PIN_TOP_RINGS"></a>`PIN_TOP_RINGS` | `number` | `8` | `Cloth.pins` bit: every fourth point of the top row (curtain rings). |
|
|
2903
|
+
|
|
2904
|
+
```ogt
|
|
2905
|
+
const BODY_DYNAMIC u32 0 "RigidBody.kind: moved by the solver; its Transform and Velocity are written back every tick."
|
|
2906
|
+
```
|
|
2907
|
+
|
|
2908
|
+
<sub>`api.ogt` line 3702</sub>
|
|
2909
|
+
|
|
2910
|
+
```ogt
|
|
2911
|
+
const BODY_STATIC u32 1 "RigidBody.kind: never moves; collides with dynamic bodies."
|
|
2912
|
+
```
|
|
2913
|
+
|
|
2914
|
+
<sub>`api.ogt` line 3703</sub>
|
|
2915
|
+
|
|
2916
|
+
```ogt
|
|
2917
|
+
const BODY_KINEMATIC u32 2 "RigidBody.kind: not moved by the solver. With an og.Velocity the step moves it by it each tick and writes its Transform back (a lift, a conveyor, a turning gear); a Transform game code writes moves it there first (a teleport). Without one it stays where its Transform puts it. Either way it pushes dynamic bodies and carries the controllers standing on it."
|
|
2918
|
+
```
|
|
2919
|
+
|
|
2920
|
+
<sub>`api.ogt` line 3704</sub>
|
|
2921
|
+
|
|
2922
|
+
```ogt
|
|
2923
|
+
const LOCK_TRANSLATION_X u32 1 "RigidBody.lock bit: no translation along x."
|
|
2924
|
+
```
|
|
2925
|
+
|
|
2926
|
+
<sub>`api.ogt` line 3705</sub>
|
|
2927
|
+
|
|
2928
|
+
```ogt
|
|
2929
|
+
const LOCK_TRANSLATION_Y u32 2 "RigidBody.lock bit: no translation along y."
|
|
2930
|
+
```
|
|
2931
|
+
|
|
2932
|
+
<sub>`api.ogt` line 3706</sub>
|
|
2933
|
+
|
|
2934
|
+
```ogt
|
|
2935
|
+
const LOCK_TRANSLATION_Z u32 4 "RigidBody.lock bit: no translation along z."
|
|
2936
|
+
```
|
|
2937
|
+
|
|
2938
|
+
<sub>`api.ogt` line 3707</sub>
|
|
2939
|
+
|
|
2940
|
+
```ogt
|
|
2941
|
+
const LOCK_ROTATION_X u32 8 "RigidBody.lock bit: no rotation about x."
|
|
2942
|
+
```
|
|
2943
|
+
|
|
2944
|
+
<sub>`api.ogt` line 3708</sub>
|
|
2945
|
+
|
|
2946
|
+
```ogt
|
|
2947
|
+
const LOCK_ROTATION_Y u32 16 "RigidBody.lock bit: no rotation about y."
|
|
2948
|
+
```
|
|
2949
|
+
|
|
2950
|
+
<sub>`api.ogt` line 3709</sub>
|
|
2951
|
+
|
|
2952
|
+
```ogt
|
|
2953
|
+
const LOCK_ROTATION_Z u32 32 "RigidBody.lock bit: no rotation about z (the 2D profile's only rotation)."
|
|
2954
|
+
```
|
|
2955
|
+
|
|
2956
|
+
<sub>`api.ogt` line 3710</sub>
|
|
2957
|
+
|
|
2958
|
+
```ogt
|
|
2959
|
+
const SHAPE_BOX u32 0 "Collider.shape: a box of `size` (both profiles)."
|
|
2960
|
+
```
|
|
2961
|
+
|
|
2962
|
+
<sub>`api.ogt` line 3711</sub>
|
|
2963
|
+
|
|
2964
|
+
```ogt
|
|
2965
|
+
const SHAPE_SPHERE u32 1 "Collider.shape: a sphere of `radius` (a circle in 2D)."
|
|
2966
|
+
```
|
|
2967
|
+
|
|
2968
|
+
<sub>`api.ogt` line 3712</sub>
|
|
2969
|
+
|
|
2970
|
+
```ogt
|
|
2971
|
+
const SHAPE_CAPSULE u32 2 "Collider.shape: a capsule along y of `radius`, with `height` between the cap centres (both profiles)."
|
|
2972
|
+
```
|
|
2973
|
+
|
|
2974
|
+
<sub>`api.ogt` line 3713</sub>
|
|
2975
|
+
|
|
2976
|
+
```ogt
|
|
2977
|
+
const SHAPE_CYLINDER u32 3 "Collider.shape: a cylinder along y of `radius` and `height` (3D only)."
|
|
2978
|
+
```
|
|
2979
|
+
|
|
2980
|
+
<sub>`api.ogt` line 3714</sub>
|
|
2981
|
+
|
|
2982
|
+
```ogt
|
|
2983
|
+
const SHAPE_CONVEX u32 4 "Collider.shape: the convex hull of the vertices of `mesh` (3D), or of their xy (a convex polygon, 2D)."
|
|
2984
|
+
```
|
|
2985
|
+
|
|
2986
|
+
<sub>`api.ogt` line 3715</sub>
|
|
2987
|
+
|
|
2988
|
+
```ogt
|
|
2989
|
+
const SHAPE_TRIMESH u32 5 "Collider.shape: the triangles of `mesh` (3D only; for static and kinematic bodies)."
|
|
2990
|
+
```
|
|
2991
|
+
|
|
2992
|
+
<sub>`api.ogt` line 3716</sub>
|
|
2993
|
+
|
|
2994
|
+
```ogt
|
|
2995
|
+
const SHAPE_HEIGHTFIELD u32 6 "Collider.shape: the height field registered as `mesh`, centred on the entity (3D only; a terrain: og.terrain.load's TerrainInfo.geometry)."
|
|
2996
|
+
```
|
|
2997
|
+
|
|
2998
|
+
<sub>`api.ogt` line 3717</sub>
|
|
2999
|
+
|
|
3000
|
+
```ogt
|
|
3001
|
+
const PROFILE_2D u32 2 "Physics.profile: rapier2d, bodies in the xy plane rotating about z."
|
|
3002
|
+
```
|
|
3003
|
+
|
|
3004
|
+
<sub>`api.ogt` line 3718</sub>
|
|
3005
|
+
|
|
3006
|
+
```ogt
|
|
3007
|
+
const PROFILE_3D u32 3 "Physics.profile: rapier3d."
|
|
3008
|
+
```
|
|
3009
|
+
|
|
3010
|
+
<sub>`api.ogt` line 3719</sub>
|
|
3011
|
+
|
|
3012
|
+
```ogt
|
|
3013
|
+
const JOINT_FIXED u32 0 "`Joint.kind`: the two bodies move as one."
|
|
3014
|
+
```
|
|
3015
|
+
|
|
3016
|
+
<sub>`api.ogt` line 3904</sub>
|
|
3017
|
+
|
|
3018
|
+
```ogt
|
|
3019
|
+
const JOINT_REVOLUTE u32 1 "`Joint.kind`: a hinge about `axis` (2D: about z), with optional limits and a motor."
|
|
3020
|
+
```
|
|
3021
|
+
|
|
3022
|
+
<sub>`api.ogt` line 3905</sub>
|
|
3023
|
+
|
|
3024
|
+
```ogt
|
|
3025
|
+
const JOINT_PRISMATIC u32 2 "`Joint.kind`: a slider along `axis`, with optional limits and a motor."
|
|
3026
|
+
```
|
|
3027
|
+
|
|
3028
|
+
<sub>`api.ogt` line 3906</sub>
|
|
3029
|
+
|
|
3030
|
+
```ogt
|
|
3031
|
+
const JOINT_SPRING u32 3 "`Joint.kind`: a damped spring pulling the anchors to `restLength` apart."
|
|
3032
|
+
```
|
|
3033
|
+
|
|
3034
|
+
<sub>`api.ogt` line 3907</sub>
|
|
3035
|
+
|
|
3036
|
+
```ogt
|
|
3037
|
+
const JOINT_ROPE u32 4 "`Joint.kind`: a rope: the anchors stay at most `length` apart, free inside it."
|
|
3038
|
+
```
|
|
3039
|
+
|
|
3040
|
+
<sub>`api.ogt` line 3908</sub>
|
|
3041
|
+
|
|
3042
|
+
```ogt
|
|
3043
|
+
const JOINT_BALL u32 5 "`Joint.kind`: a ball and socket (3D; the 2D profile treats it as a hinge)."
|
|
3044
|
+
```
|
|
3045
|
+
|
|
3046
|
+
<sub>`api.ogt` line 3909</sub>
|
|
3047
|
+
|
|
3048
|
+
```ogt
|
|
3049
|
+
const MOTOR_NONE u32 0 "`Joint.motor`: no motor."
|
|
3050
|
+
```
|
|
3051
|
+
|
|
3052
|
+
<sub>`api.ogt` line 3910</sub>
|
|
3053
|
+
|
|
3054
|
+
```ogt
|
|
3055
|
+
const MOTOR_VELOCITY u32 1 "`Joint.motor`: drive towards `motorTarget` speed (rad/s or m/s)."
|
|
3056
|
+
```
|
|
3057
|
+
|
|
3058
|
+
<sub>`api.ogt` line 3911</sub>
|
|
3059
|
+
|
|
3060
|
+
```ogt
|
|
3061
|
+
const MOTOR_POSITION u32 2 "`Joint.motor`: spring towards `motorTarget` angle or position (a servo)."
|
|
3062
|
+
```
|
|
3063
|
+
|
|
3064
|
+
<sub>`api.ogt` line 3912</sub>
|
|
3065
|
+
|
|
3066
|
+
```ogt
|
|
3067
|
+
const CHARACTER_JUMPED u32 1 "`CharacterEvent.kind`: a jump from the ground (or in coyote time)."
|
|
3068
|
+
```
|
|
3069
|
+
|
|
3070
|
+
<sub>`api.ogt` line 4251</sub>
|
|
3071
|
+
|
|
3072
|
+
```ogt
|
|
3073
|
+
const CHARACTER_LANDED u32 2 "`CharacterEvent.kind`: touched the ground after being in the air."
|
|
3074
|
+
```
|
|
3075
|
+
|
|
3076
|
+
<sub>`api.ogt` line 4252</sub>
|
|
3077
|
+
|
|
3078
|
+
```ogt
|
|
3079
|
+
const CHARACTER_WALL_JUMPED u32 3 "`CharacterEvent.kind`: a jump off a wall."
|
|
3080
|
+
```
|
|
3081
|
+
|
|
3082
|
+
<sub>`api.ogt` line 4253</sub>
|
|
3083
|
+
|
|
3084
|
+
```ogt
|
|
3085
|
+
const CHARACTER_AIR_JUMPED u32 4 "`CharacterEvent.kind`: a jump in the air (PlatformerController.airJumps)."
|
|
3086
|
+
```
|
|
3087
|
+
|
|
3088
|
+
<sub>`api.ogt` line 4254</sub>
|
|
3089
|
+
|
|
3090
|
+
```ogt
|
|
3091
|
+
const CHARACTER_LEFT_GROUND u32 5 "`CharacterEvent.kind`: left the ground without jumping (ran off an edge)."
|
|
3092
|
+
```
|
|
3093
|
+
|
|
3094
|
+
<sub>`api.ogt` line 4255</sub>
|
|
3095
|
+
|
|
3096
|
+
```ogt
|
|
3097
|
+
const CHARACTER_BUMPED u32 6 "`CharacterEvent.kind`: hit a ceiling while rising."
|
|
3098
|
+
```
|
|
3099
|
+
|
|
3100
|
+
<sub>`api.ogt` line 4256</sub>
|
|
3101
|
+
|
|
3102
|
+
```ogt
|
|
3103
|
+
const DRIVE_REAR u32 0 "`Vehicle.drive`: the rear wheels drive."
|
|
3104
|
+
```
|
|
3105
|
+
|
|
3106
|
+
<sub>`api.ogt` line 4270</sub>
|
|
3107
|
+
|
|
3108
|
+
```ogt
|
|
3109
|
+
const DRIVE_FRONT u32 1 "`Vehicle.drive`: the front wheels drive."
|
|
3110
|
+
```
|
|
3111
|
+
|
|
3112
|
+
<sub>`api.ogt` line 4271</sub>
|
|
3113
|
+
|
|
3114
|
+
```ogt
|
|
3115
|
+
const DRIVE_ALL u32 2 "`Vehicle.drive`: every wheel drives."
|
|
3116
|
+
```
|
|
3117
|
+
|
|
3118
|
+
<sub>`api.ogt` line 4272</sub>
|
|
3119
|
+
|
|
3120
|
+
```ogt
|
|
3121
|
+
const PIN_TOP u32 1 "`Cloth.pins` bit: the whole top row is pinned."
|
|
3122
|
+
```
|
|
3123
|
+
|
|
3124
|
+
<sub>`api.ogt` line 4453</sub>
|
|
3125
|
+
|
|
3126
|
+
```ogt
|
|
3127
|
+
const PIN_TOP_CORNERS u32 2 "`Cloth.pins` bit: the top-left and top-right corners are pinned."
|
|
3128
|
+
```
|
|
3129
|
+
|
|
3130
|
+
<sub>`api.ogt` line 4454</sub>
|
|
3131
|
+
|
|
3132
|
+
```ogt
|
|
3133
|
+
const PIN_LEFT u32 4 "`Cloth.pins` bit: the whole left column is pinned (a flag on a pole)."
|
|
3134
|
+
```
|
|
3135
|
+
|
|
3136
|
+
<sub>`api.ogt` line 4455</sub>
|
|
3137
|
+
|
|
3138
|
+
```ogt
|
|
3139
|
+
const PIN_TOP_RINGS u32 8 "`Cloth.pins` bit: every fourth point of the top row (curtain rings)."
|
|
3140
|
+
```
|
|
3141
|
+
|
|
3142
|
+
<sub>`api.ogt` line 4456</sub>
|