wallhammer-web 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +92 -2
- package/dist/base/data.d.ts +67 -0
- package/dist/base/data.js +10 -0
- package/dist/base/destructible.d.ts +167 -0
- package/dist/base/destructible.js +47 -0
- package/dist/base/env-slot.d.ts +101 -0
- package/dist/base/env-slot.js +8 -0
- package/dist/base/frames.d.ts +138 -0
- package/dist/base/frames.js +459 -0
- package/dist/base/index.d.ts +21 -0
- package/dist/base/index.js +11 -0
- package/dist/base/mat34.d.ts +46 -0
- package/dist/base/mat34.js +173 -0
- package/dist/base/material.d.ts +87 -0
- package/dist/base/material.js +6 -0
- package/dist/base/math.d.ts +27 -0
- package/dist/base/math.js +60 -0
- package/dist/base/progress.d.ts +38 -0
- package/dist/base/progress.js +81 -0
- package/dist/base/rig.d.ts +177 -0
- package/dist/base/rig.js +97 -0
- package/dist/base/trig.d.ts +29 -0
- package/dist/base/trig.js +169 -0
- package/dist/base/up.d.ts +26 -0
- package/dist/base/up.js +40 -0
- package/dist/base/view.d.ts +128 -0
- package/dist/base/view.js +136 -0
- package/dist/camera/camera.d.ts +99 -0
- package/dist/camera/camera.js +228 -0
- package/dist/camera/follow.d.ts +120 -0
- package/dist/camera/follow.js +320 -0
- package/dist/camera/free.d.ts +153 -0
- package/dist/camera/free.js +359 -0
- package/dist/camera/index.d.ts +10 -0
- package/dist/camera/index.js +6 -0
- package/dist/camera/orbit.d.ts +93 -0
- package/dist/camera/orbit.js +261 -0
- package/dist/camera/path.d.ts +48 -0
- package/dist/camera/path.js +179 -0
- package/dist/core/ballistic.d.ts +66 -0
- package/dist/core/ballistic.js +104 -0
- package/dist/core/bodies.d.ts +77 -0
- package/dist/core/bodies.js +125 -0
- package/dist/core/clock.d.ts +37 -0
- package/dist/core/clock.js +87 -0
- package/dist/core/cover-fade.d.ts +14 -0
- package/dist/core/cover-fade.js +38 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +8 -0
- package/dist/core/kepler.d.ts +74 -0
- package/dist/core/kepler.js +108 -0
- package/dist/core/level-fade.d.ts +66 -0
- package/dist/core/level-fade.js +123 -0
- package/dist/core/palette.d.ts +15 -0
- package/dist/core/palette.js +47 -0
- package/dist/env/atmosphere.d.ts +129 -0
- package/dist/env/atmosphere.js +707 -0
- package/dist/env/cloud-field.d.ts +44 -0
- package/dist/env/cloud-field.js +111 -0
- package/dist/env/environment.d.ts +217 -0
- package/dist/env/environment.js +441 -0
- package/dist/env/frame-block.d.ts +29 -0
- package/dist/env/frame-block.js +152 -0
- package/dist/env/glsl.d.ts +35 -0
- package/dist/env/glsl.js +246 -0
- package/dist/env/index.d.ts +13 -0
- package/dist/env/index.js +9 -0
- package/dist/env/sky.d.ts +48 -0
- package/dist/env/sky.js +227 -0
- package/dist/env/sun.d.ts +31 -0
- package/dist/env/sun.js +42 -0
- package/dist/gen-arch/build.d.ts +17 -0
- package/dist/gen-arch/build.js +414 -0
- package/dist/gen-arch/damage/damaged.d.ts +44 -0
- package/dist/gen-arch/damage/damaged.js +1119 -0
- package/dist/gen-arch/damage/fall-material.d.ts +10 -0
- package/dist/gen-arch/damage/fall-material.js +47 -0
- package/dist/gen-arch/damage/fall.d.ts +78 -0
- package/dist/gen-arch/damage/fall.js +797 -0
- package/dist/gen-arch/damage/rubble.d.ts +22 -0
- package/dist/gen-arch/damage/rubble.js +188 -0
- package/dist/gen-arch/index.d.ts +25 -0
- package/dist/gen-arch/index.js +16 -0
- package/dist/gen-arch/interior/interior-plan.d.ts +114 -0
- package/dist/gen-arch/interior/interior-plan.js +615 -0
- package/dist/gen-arch/interior/interior.d.ts +97 -0
- package/dist/gen-arch/interior/interior.js +966 -0
- package/dist/gen-arch/structure/building-shader.d.ts +25 -0
- package/dist/gen-arch/structure/building-shader.js +946 -0
- package/dist/gen-arch/structure/buildings.d.ts +248 -0
- package/dist/gen-arch/structure/buildings.js +294 -0
- package/dist/gen-arch/structure/dims.d.ts +77 -0
- package/dist/gen-arch/structure/dims.js +39 -0
- package/dist/gen-arch/structure/distant.d.ts +62 -0
- package/dist/gen-arch/structure/distant.js +316 -0
- package/dist/gen-arch/structure/env-slots.d.ts +18 -0
- package/dist/gen-arch/structure/env-slots.js +47 -0
- package/dist/gen-arch/structure/facade.d.ts +193 -0
- package/dist/gen-arch/structure/facade.js +159 -0
- package/dist/gen-arch/structure/parts.d.ts +31 -0
- package/dist/gen-arch/structure/parts.js +69 -0
- package/dist/gen-arch/structure/roof.d.ts +76 -0
- package/dist/gen-arch/structure/roof.js +568 -0
- package/dist/gen-arch/structure/structure-material.d.ts +23 -0
- package/dist/gen-arch/structure/structure-material.js +55 -0
- package/dist/gen-arch/structure/writer.d.ts +94 -0
- package/dist/gen-arch/structure/writer.js +195 -0
- package/dist/gen-core/cell.d.ts +138 -0
- package/dist/gen-core/cell.js +150 -0
- package/dist/gen-core/cube-sphere.d.ts +57 -0
- package/dist/gen-core/cube-sphere.js +159 -0
- package/dist/gen-core/field.d.ts +55 -0
- package/dist/gen-core/field.js +154 -0
- package/dist/gen-core/geometry.d.ts +31 -0
- package/dist/gen-core/geometry.js +231 -0
- package/dist/gen-core/hash.d.ts +18 -0
- package/dist/gen-core/hash.js +58 -0
- package/dist/gen-core/height-field.d.ts +33 -0
- package/dist/gen-core/height-field.js +137 -0
- package/dist/gen-core/index.d.ts +22 -0
- package/dist/gen-core/index.js +17 -0
- package/dist/gen-core/instance-cells.d.ts +37 -0
- package/dist/gen-core/instance-cells.js +72 -0
- package/dist/gen-core/near-scatter.d.ts +56 -0
- package/dist/gen-core/near-scatter.js +120 -0
- package/dist/gen-core/noise.d.ts +23 -0
- package/dist/gen-core/noise.js +72 -0
- package/dist/gen-core/occupancy.d.ts +21 -0
- package/dist/gen-core/occupancy.js +104 -0
- package/dist/gen-core/sphere-patch.d.ts +138 -0
- package/dist/gen-core/sphere-patch.js +544 -0
- package/dist/gen-core/strip-surface.d.ts +34 -0
- package/dist/gen-core/strip-surface.js +246 -0
- package/dist/gen-core/strip.d.ts +102 -0
- package/dist/gen-core/strip.js +817 -0
- package/dist/gen-ground/env-slots.d.ts +48 -0
- package/dist/gen-ground/env-slots.js +78 -0
- package/dist/gen-ground/ground.d.ts +78 -0
- package/dist/gen-ground/ground.js +208 -0
- package/dist/gen-ground/index.d.ts +9 -0
- package/dist/gen-ground/index.js +7 -0
- package/dist/gen-ground/markings.d.ts +46 -0
- package/dist/gen-ground/markings.js +124 -0
- package/dist/gen-ground/materials.d.ts +18 -0
- package/dist/gen-ground/materials.js +22 -0
- package/dist/gen-ground/terrain-shader.d.ts +5 -0
- package/dist/gen-ground/terrain-shader.js +151 -0
- package/dist/gen-mesh/bare-shapes.d.ts +194 -0
- package/dist/gen-mesh/bare-shapes.js +596 -0
- package/dist/gen-mesh/bisect-surface.d.ts +47 -0
- package/dist/gen-mesh/bisect-surface.js +261 -0
- package/dist/gen-mesh/box.d.ts +18 -0
- package/dist/gen-mesh/box.js +2 -0
- package/dist/gen-mesh/cell-morph-mesh.d.ts +52 -0
- package/dist/gen-mesh/cell-morph-mesh.js +258 -0
- package/dist/gen-mesh/cell-surface-mesh.d.ts +32 -0
- package/dist/gen-mesh/cell-surface-mesh.js +140 -0
- package/dist/gen-mesh/chunk-mesh.d.ts +25 -0
- package/dist/gen-mesh/chunk-mesh.js +112 -0
- package/dist/gen-mesh/drape-mesh.d.ts +36 -0
- package/dist/gen-mesh/drape-mesh.js +98 -0
- package/dist/gen-mesh/height-field-mesh.d.ts +14 -0
- package/dist/gen-mesh/height-field-mesh.js +98 -0
- package/dist/gen-mesh/index.d.ts +26 -0
- package/dist/gen-mesh/index.js +15 -0
- package/dist/gen-mesh/line-mesh.d.ts +25 -0
- package/dist/gen-mesh/line-mesh.js +62 -0
- package/dist/gen-mesh/mesh-builder.d.ts +115 -0
- package/dist/gen-mesh/mesh-builder.js +315 -0
- package/dist/gen-mesh/packed-mesh.d.ts +53 -0
- package/dist/gen-mesh/packed-mesh.js +205 -0
- package/dist/gen-mesh/prism-mesh.d.ts +33 -0
- package/dist/gen-mesh/prism-mesh.js +176 -0
- package/dist/gen-mesh/rig-mesh.d.ts +9 -0
- package/dist/gen-mesh/rig-mesh.js +135 -0
- package/dist/gen-mesh/strip-mesh.d.ts +45 -0
- package/dist/gen-mesh/strip-mesh.js +258 -0
- package/dist/gen-plan/drain.d.ts +58 -0
- package/dist/gen-plan/drain.js +270 -0
- package/dist/gen-plan/grid.d.ts +37 -0
- package/dist/gen-plan/grid.js +182 -0
- package/dist/gen-plan/horizon.d.ts +50 -0
- package/dist/gen-plan/horizon.js +185 -0
- package/dist/gen-plan/index.d.ts +15 -0
- package/dist/gen-plan/index.js +13 -0
- package/dist/gen-plan/line-tiles.d.ts +35 -0
- package/dist/gen-plan/line-tiles.js +190 -0
- package/dist/gen-plan/lines.d.ts +31 -0
- package/dist/gen-plan/lines.js +183 -0
- package/dist/gen-plan/plots.d.ts +40 -0
- package/dist/gen-plan/plots.js +282 -0
- package/dist/gen-plan/route.d.ts +55 -0
- package/dist/gen-plan/route.js +297 -0
- package/dist/gen-plan/sites.d.ts +32 -0
- package/dist/gen-plan/sites.js +209 -0
- package/dist/gen-tex/code-stamp.d.ts +31 -0
- package/dist/gen-tex/code-stamp.js +137 -0
- package/dist/gen-tex/index.d.ts +7 -0
- package/dist/gen-tex/index.js +5 -0
- package/dist/gen-tex/light-horizon.d.ts +47 -0
- package/dist/gen-tex/light-horizon.js +180 -0
- package/dist/gen-tex/textures.d.ts +8 -0
- package/dist/gen-tex/textures.js +49 -0
- package/dist/gen-tex/value-textures.d.ts +46 -0
- package/dist/gen-tex/value-textures.js +102 -0
- package/dist/gen-vegetation/env-slots.d.ts +20 -0
- package/dist/gen-vegetation/env-slots.js +29 -0
- package/dist/gen-vegetation/index.d.ts +8 -0
- package/dist/gen-vegetation/index.js +7 -0
- package/dist/gen-vegetation/materials.d.ts +7 -0
- package/dist/gen-vegetation/materials.js +17 -0
- package/dist/gen-vegetation/planting.d.ts +170 -0
- package/dist/gen-vegetation/planting.js +363 -0
- package/dist/gen-vegetation/tree-shader.d.ts +23 -0
- package/dist/gen-vegetation/tree-shader.js +229 -0
- package/dist/gen-vegetation/trees.d.ts +59 -0
- package/dist/gen-vegetation/trees.js +329 -0
- package/dist/gpu/device.d.ts +286 -0
- package/dist/gpu/device.js +1157 -0
- package/dist/gpu/gl.d.ts +134 -0
- package/dist/gpu/gl.js +276 -0
- package/dist/gpu/index.d.ts +4 -0
- package/dist/gpu/index.js +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +13 -0
- package/dist/motion/graph.d.ts +244 -0
- package/dist/motion/graph.js +739 -0
- package/dist/motion/index.d.ts +8 -0
- package/dist/motion/index.js +8 -0
- package/dist/motion/pose-ops.d.ts +30 -0
- package/dist/motion/pose-ops.js +232 -0
- package/dist/motion/reach.d.ts +45 -0
- package/dist/motion/reach.js +264 -0
- package/dist/motion/skeleton.d.ts +49 -0
- package/dist/motion/skeleton.js +99 -0
- package/dist/platform/byte-store.d.ts +21 -0
- package/dist/platform/byte-store.js +137 -0
- package/dist/platform/canvas.d.ts +29 -0
- package/dist/platform/canvas.js +76 -0
- package/dist/platform/context-loss.d.ts +8 -0
- package/dist/platform/context-loss.js +17 -0
- package/dist/platform/free-input.d.ts +51 -0
- package/dist/platform/free-input.js +100 -0
- package/dist/platform/index.d.ts +18 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/input.d.ts +48 -0
- package/dist/platform/input.js +117 -0
- package/dist/platform/keys.d.ts +12 -0
- package/dist/platform/keys.js +29 -0
- package/dist/platform/loop.d.ts +41 -0
- package/dist/platform/loop.js +84 -0
- package/dist/platform/walk-input.d.ts +74 -0
- package/dist/platform/walk-input.js +226 -0
- package/dist/platform/worker.d.ts +51 -0
- package/dist/platform/worker.js +170 -0
- package/dist/render/bone-instances.d.ts +24 -0
- package/dist/render/bone-instances.js +74 -0
- package/dist/render/cells.d.ts +70 -0
- package/dist/render/cells.js +144 -0
- package/dist/render/glsl.d.ts +66 -0
- package/dist/render/glsl.js +173 -0
- package/dist/render/index.d.ts +26 -0
- package/dist/render/index.js +16 -0
- package/dist/render/instance-sets.d.ts +97 -0
- package/dist/render/instance-sets.js +241 -0
- package/dist/render/near-instances.d.ts +75 -0
- package/dist/render/near-instances.js +219 -0
- package/dist/render/particles.d.ts +63 -0
- package/dist/render/particles.js +215 -0
- package/dist/render/pieces.d.ts +57 -0
- package/dist/render/pieces.js +151 -0
- package/dist/render/point-lights.d.ts +97 -0
- package/dist/render/point-lights.js +243 -0
- package/dist/render/renderer.d.ts +447 -0
- package/dist/render/renderer.js +1100 -0
- package/dist/render/rig.d.ts +74 -0
- package/dist/render/rig.js +576 -0
- package/dist/render/shadow-areas.d.ts +49 -0
- package/dist/render/shadow-areas.js +125 -0
- package/dist/render/shadow-glsl.d.ts +12 -0
- package/dist/render/shadow-glsl.js +146 -0
- package/dist/render/transient.d.ts +61 -0
- package/dist/render/transient.js +213 -0
- package/dist/render/value-glsl.d.ts +17 -0
- package/dist/render/value-glsl.js +208 -0
- package/dist/render/value-layers.d.ts +180 -0
- package/dist/render/value-layers.js +333 -0
- package/dist/runtime/atmosphere.d.ts +37 -0
- package/dist/runtime/atmosphere.js +304 -0
- package/dist/runtime/cloud-shell.d.ts +29 -0
- package/dist/runtime/cloud-shell.js +158 -0
- package/dist/runtime/engine.d.ts +155 -0
- package/dist/runtime/engine.js +305 -0
- package/dist/runtime/environment-link.d.ts +22 -0
- package/dist/runtime/environment-link.js +49 -0
- package/dist/runtime/index.d.ts +13 -0
- package/dist/runtime/index.js +12 -0
- package/dist/runtime/precipitation-glsl.d.ts +2 -0
- package/dist/runtime/precipitation-glsl.js +70 -0
- package/dist/runtime/precipitation.d.ts +11 -0
- package/dist/runtime/precipitation.js +78 -0
- package/dist/runtime/sky.d.ts +30 -0
- package/dist/runtime/sky.js +114 -0
- package/dist/runtime/streaming.d.ts +245 -0
- package/dist/runtime/streaming.js +602 -0
- package/dist/sim/agenda.d.ts +167 -0
- package/dist/sim/agenda.js +425 -0
- package/dist/sim/bytes.d.ts +34 -0
- package/dist/sim/bytes.js +125 -0
- package/dist/sim/destruction/apply.d.ts +59 -0
- package/dist/sim/destruction/apply.js +243 -0
- package/dist/sim/destruction/cell-states.d.ts +54 -0
- package/dist/sim/destruction/cell-states.js +198 -0
- package/dist/sim/destruction/index.d.ts +11 -0
- package/dist/sim/destruction/index.js +10 -0
- package/dist/sim/destruction/int-geometry.d.ts +17 -0
- package/dist/sim/destruction/int-geometry.js +131 -0
- package/dist/sim/destruction/pick.d.ts +13 -0
- package/dist/sim/destruction/pick.js +59 -0
- package/dist/sim/destruction/rubble.d.ts +8 -0
- package/dist/sim/destruction/rubble.js +159 -0
- package/dist/sim/destruction/state.d.ts +15 -0
- package/dist/sim/destruction/state.js +83 -0
- package/dist/sim/destruction/structure.d.ts +30 -0
- package/dist/sim/destruction/structure.js +139 -0
- package/dist/sim/events.d.ts +37 -0
- package/dist/sim/events.js +106 -0
- package/dist/sim/fixed.d.ts +21 -0
- package/dist/sim/fixed.js +64 -0
- package/dist/sim/flow-probe.d.ts +58 -0
- package/dist/sim/flow-probe.js +158 -0
- package/dist/sim/flow.d.ts +257 -0
- package/dist/sim/flow.js +967 -0
- package/dist/sim/index.d.ts +28 -0
- package/dist/sim/index.js +20 -0
- package/dist/sim/interlock.d.ts +47 -0
- package/dist/sim/interlock.js +252 -0
- package/dist/sim/movers.d.ts +228 -0
- package/dist/sim/movers.js +1083 -0
- package/dist/sim/nav.d.ts +72 -0
- package/dist/sim/nav.js +292 -0
- package/dist/sim/paths.d.ts +80 -0
- package/dist/sim/paths.js +197 -0
- package/dist/sim/regions.d.ts +87 -0
- package/dist/sim/regions.js +517 -0
- package/dist/sim/simulation.d.ts +114 -0
- package/dist/sim/simulation.js +291 -0
- package/dist/sim/states.d.ts +23 -0
- package/dist/sim/states.js +54 -0
- package/dist/sim/table.d.ts +49 -0
- package/dist/sim/table.js +126 -0
- package/dist/sim/zones.d.ts +11 -0
- package/dist/sim/zones.js +196 -0
- package/dist/tools/collision-lines.d.ts +12 -0
- package/dist/tools/collision-lines.js +50 -0
- package/dist/tools/data-view-glsl.d.ts +3 -0
- package/dist/tools/data-view-glsl.js +63 -0
- package/dist/tools/data-view-layers.d.ts +20 -0
- package/dist/tools/data-view-layers.js +60 -0
- package/dist/tools/debug-view.d.ts +30 -0
- package/dist/tools/debug-view.js +4 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/mesh-checks.d.ts +67 -0
- package/dist/tools/mesh-checks.js +188 -0
- package/dist/tools/profile.d.ts +85 -0
- package/dist/tools/profile.js +173 -0
- package/dist/world/cell-cache.d.ts +32 -0
- package/dist/world/cell-cache.js +60 -0
- package/dist/world/cell-format.d.ts +25 -0
- package/dist/world/cell-format.js +232 -0
- package/dist/world/collide.d.ts +192 -0
- package/dist/world/collide.js +822 -0
- package/dist/world/index.d.ts +16 -0
- package/dist/world/index.js +12 -0
- package/dist/world/mesh-solids.d.ts +48 -0
- package/dist/world/mesh-solids.js +169 -0
- package/dist/world/pick.d.ts +34 -0
- package/dist/world/pick.js +177 -0
- package/dist/world/providers.d.ts +66 -0
- package/dist/world/providers.js +83 -0
- package/dist/world/sphere.d.ts +69 -0
- package/dist/world/sphere.js +271 -0
- package/dist/world/streaming.d.ts +288 -0
- package/dist/world/streaming.js +801 -0
- package/dist/world/walker.d.ts +145 -0
- package/dist/world/walker.js +502 -0
- package/docs/architecture.md +111 -0
- package/docs/cameras.md +302 -0
- package/docs/concepts.md +123 -0
- package/docs/destruction.md +127 -0
- package/docs/frames.md +199 -0
- package/docs/generators.md +575 -0
- package/docs/getting-started.md +123 -0
- package/docs/headless.md +50 -0
- package/docs/motion.md +160 -0
- package/docs/planet.md +152 -0
- package/docs/recipes.md +521 -0
- package/docs/reference.md +364 -0
- package/docs/rendering.md +823 -0
- package/docs/rigs.md +203 -0
- package/docs/simulation.md +235 -0
- package/docs/streaming.md +590 -0
- package/docs/system.md +166 -0
- package/docs/tools.md +175 -0
- package/docs/walking.md +262 -0
- package/package.json +131 -3
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Pose } from './skeleton.ts';
|
|
2
|
+
import type { BoneMask, Skeleton } from './skeleton.ts';
|
|
3
|
+
/** A motion is a pure function written by the game. `t` is seconds or a phase, as the source declares. */
|
|
4
|
+
export interface MotionSource<P = void> {
|
|
5
|
+
sample(out: Pose, t: number, params: P): void;
|
|
6
|
+
/** Seconds of one pass; undefined = endless (time-driven). */
|
|
7
|
+
readonly duration?: number;
|
|
8
|
+
/** Repeats after a pass. Default true; false holds the end of the pass. */
|
|
9
|
+
readonly loop?: boolean;
|
|
10
|
+
/** Named points on the timeline as a share 0–1 of one pass (a foot touching down, a strike). */
|
|
11
|
+
readonly marks?: readonly {
|
|
12
|
+
name: string;
|
|
13
|
+
at: number;
|
|
14
|
+
}[];
|
|
15
|
+
/** Speeds this motion covers: [min, ideal, max]; used to weight motions of one state automatically. */
|
|
16
|
+
readonly speed?: readonly [number, number, number];
|
|
17
|
+
/**
|
|
18
|
+
* What `t` means: `'seconds'` (default) into the pass, or with no `duration` since the state was entered;
|
|
19
|
+
* `'phase'` the share 0–1 of the pass.
|
|
20
|
+
*/
|
|
21
|
+
readonly unit?: 'seconds' | 'phase';
|
|
22
|
+
}
|
|
23
|
+
/** How a transition's weight grows: `'linear'` or `'smooth'` (3t² − 2t³). */
|
|
24
|
+
export type MotionEase = 'linear' | 'smooth';
|
|
25
|
+
/** A test of one parameter. */
|
|
26
|
+
export interface MotionCondition {
|
|
27
|
+
param: string;
|
|
28
|
+
op: '<' | '<=' | '>' | '>=' | '==' | '!=';
|
|
29
|
+
value: number;
|
|
30
|
+
}
|
|
31
|
+
export interface MotionStateDesc<P = void> {
|
|
32
|
+
name: string;
|
|
33
|
+
/** One motion. A state with neither `source` nor `sources` passes the layer's input through (adds nothing). */
|
|
34
|
+
source?: MotionSource<P> | null;
|
|
35
|
+
/** Several motions weighted by the parameter `by` through their `speed` ranges (continuous, sum 1). */
|
|
36
|
+
sources?: readonly MotionSource<P>[];
|
|
37
|
+
/** Parameter the `sources` are weighted by (and that scales their playback within their speed ranges). */
|
|
38
|
+
by?: string;
|
|
39
|
+
/** Playback rate: a number or the name of a parameter. Default 1. */
|
|
40
|
+
rate?: number | string;
|
|
41
|
+
/** Phase from a parameter instead of time: phase = parameter / `per` (a distance per pass). */
|
|
42
|
+
drive?: {
|
|
43
|
+
param: string;
|
|
44
|
+
per: number;
|
|
45
|
+
};
|
|
46
|
+
/** States of one group keep the phase across a transition between them. */
|
|
47
|
+
sync?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface MotionTransitionDesc {
|
|
50
|
+
/** A state name, or `'*'` for any state. */
|
|
51
|
+
from: string;
|
|
52
|
+
to: string;
|
|
53
|
+
/** Seconds of the cross-fade; 0 switches at once. */
|
|
54
|
+
seconds: number;
|
|
55
|
+
/** Default `'smooth'`. */
|
|
56
|
+
ease?: MotionEase;
|
|
57
|
+
/** All must hold. */
|
|
58
|
+
when?: readonly MotionCondition[];
|
|
59
|
+
/** A trigger that must be set (and is consumed by the transition). */
|
|
60
|
+
trigger?: string;
|
|
61
|
+
/** Only once the current state's phase has reached this many passes (1 = the end of the first pass). */
|
|
62
|
+
after?: number;
|
|
63
|
+
/** Allows a transition into the state that is current (it starts again). Default false. */
|
|
64
|
+
restart?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface MotionLayerDesc<P = void> {
|
|
67
|
+
name: string;
|
|
68
|
+
/** `'override'` (default) blends the layer's pose over what the layers before it made; `'additive'` adds it. */
|
|
69
|
+
mode?: 'override' | 'additive';
|
|
70
|
+
/** Per-bone weights; default every bone 1. */
|
|
71
|
+
mask?: BoneMask | null;
|
|
72
|
+
/** Layer weight: a number or the name of a parameter. Default 1. */
|
|
73
|
+
weight?: number | string;
|
|
74
|
+
states: readonly MotionStateDesc<P>[];
|
|
75
|
+
/** Default: the first state. */
|
|
76
|
+
initial?: string;
|
|
77
|
+
/** Checked in order every update; the first that applies is taken (one per layer and update). */
|
|
78
|
+
transitions?: readonly MotionTransitionDesc[];
|
|
79
|
+
}
|
|
80
|
+
export interface MotionGraphDesc<P = void> {
|
|
81
|
+
skeleton: Skeleton;
|
|
82
|
+
/** Parameters and their start values. Names used elsewhere in the description are added with 0. */
|
|
83
|
+
params?: Readonly<Record<string, number>>;
|
|
84
|
+
/** Names of one-shot triggers (at most 31). Names used by transitions are added. */
|
|
85
|
+
triggers?: readonly string[];
|
|
86
|
+
layers: readonly MotionLayerDesc<P>[];
|
|
87
|
+
/** Active states per layer at most. Default 4. */
|
|
88
|
+
maxBlend?: number;
|
|
89
|
+
/** Events kept between two `drainEvents` calls. Default 32; more are counted in `droppedEvents`. */
|
|
90
|
+
maxEvents?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Kinds of events. */
|
|
93
|
+
export type MotionEventKind = 'mark' | 'enter' | 'leave';
|
|
94
|
+
interface CState<P> {
|
|
95
|
+
name: string;
|
|
96
|
+
sources: readonly MotionSource<P>[];
|
|
97
|
+
/** Parameter index of `by`, −1 none. */
|
|
98
|
+
by: number;
|
|
99
|
+
rate: number;
|
|
100
|
+
rateParam: number;
|
|
101
|
+
driveParam: number;
|
|
102
|
+
per: number;
|
|
103
|
+
sync: number;
|
|
104
|
+
loop: boolean;
|
|
105
|
+
/** Marks of each source, sorted by `at`, with their name indices. */
|
|
106
|
+
marks: {
|
|
107
|
+
at: Float64Array;
|
|
108
|
+
name: Int32Array;
|
|
109
|
+
}[];
|
|
110
|
+
}
|
|
111
|
+
interface CTransition {
|
|
112
|
+
from: number;
|
|
113
|
+
to: number;
|
|
114
|
+
seconds: number;
|
|
115
|
+
smooth: boolean;
|
|
116
|
+
trigger: number;
|
|
117
|
+
after: number;
|
|
118
|
+
restart: boolean;
|
|
119
|
+
conds: {
|
|
120
|
+
param: number;
|
|
121
|
+
op: number;
|
|
122
|
+
value: number;
|
|
123
|
+
}[];
|
|
124
|
+
}
|
|
125
|
+
interface CLayer<P> {
|
|
126
|
+
name: string;
|
|
127
|
+
additive: boolean;
|
|
128
|
+
mask: BoneMask | null;
|
|
129
|
+
weight: number;
|
|
130
|
+
weightParam: number;
|
|
131
|
+
states: CState<P>[];
|
|
132
|
+
initial: number;
|
|
133
|
+
transitions: CTransition[];
|
|
134
|
+
/** Offset of the layer's block in the state array. */
|
|
135
|
+
at: number;
|
|
136
|
+
}
|
|
137
|
+
/** A compiled description: shared by every figure that uses it. Holds the scratch poses of evaluation. */
|
|
138
|
+
export declare class MotionGraphDef<P = void> {
|
|
139
|
+
readonly skeleton: Skeleton;
|
|
140
|
+
readonly paramNames: readonly string[];
|
|
141
|
+
readonly paramStart: Float64Array;
|
|
142
|
+
readonly triggerNames: readonly string[];
|
|
143
|
+
readonly maxBlend: number;
|
|
144
|
+
readonly maxEvents: number;
|
|
145
|
+
/** Numbers of one figure's state (parameters, triggers, layers). */
|
|
146
|
+
readonly stateSize: number;
|
|
147
|
+
/** @internal */ readonly layers: readonly CLayer<P>[];
|
|
148
|
+
/** Event names: state names first (by layer), then mark names. @internal */
|
|
149
|
+
readonly eventNames: string[];
|
|
150
|
+
/** @internal */ readonly scratch: [Pose, Pose, Pose];
|
|
151
|
+
/** @internal */ readonly weights: Float64Array;
|
|
152
|
+
private readonly params;
|
|
153
|
+
private readonly triggers;
|
|
154
|
+
constructor(desc: MotionGraphDesc<P>);
|
|
155
|
+
/** @internal Index of the first state name of each layer in `eventNames`. */
|
|
156
|
+
readonly stateNameBase: readonly number[];
|
|
157
|
+
/** Index of a parameter, −1 when there is none. */
|
|
158
|
+
param(name: string): number;
|
|
159
|
+
/** Index of a trigger, −1 when there is none. */
|
|
160
|
+
trigger(name: string): number;
|
|
161
|
+
/** Index of a layer by name (−1 none). */
|
|
162
|
+
layer(name: string): number;
|
|
163
|
+
}
|
|
164
|
+
/** Compiles a description once; pass the result to every figure's `MotionGraph`. */
|
|
165
|
+
export declare function compileMotionGraph<P = void>(desc: MotionGraphDesc<P>): MotionGraphDef<P>;
|
|
166
|
+
/**
|
|
167
|
+
* Weights of motions by their speed ranges at `value` into `out` (one per range): the two motions whose ideal
|
|
168
|
+
* speeds enclose the value share the weight linearly; below the lowest ideal the slowest motion has it all, above the
|
|
169
|
+
* highest the fastest. Continuous in `value`, sum 1. Allocates nothing.
|
|
170
|
+
*/
|
|
171
|
+
export declare function speedWeights(speeds: readonly (readonly [number, number, number] | undefined)[], value: number, out: {
|
|
172
|
+
[i: number]: number;
|
|
173
|
+
}): void;
|
|
174
|
+
/**
|
|
175
|
+
* One figure's motion: the shared compiled description and this figure's small state. `input` is handed to every
|
|
176
|
+
* source's `sample` as its `params` (the game's own per-figure data; set it once, change its fields freely).
|
|
177
|
+
*/
|
|
178
|
+
export declare class MotionGraph<P = void> {
|
|
179
|
+
readonly def: MotionGraphDef<P>;
|
|
180
|
+
/** Passed to the sources' `sample` as `params`. */
|
|
181
|
+
input: P;
|
|
182
|
+
/** Parameters, triggers and active states; `save` and `restore` copy it. */
|
|
183
|
+
readonly data: Float64Array;
|
|
184
|
+
/** Events that did not fit between two `drainEvents` calls (counted, then lost). */
|
|
185
|
+
droppedEvents: number;
|
|
186
|
+
private readonly events;
|
|
187
|
+
private eventCount;
|
|
188
|
+
private readonly bytes;
|
|
189
|
+
constructor(def: MotionGraphDef<P> | MotionGraphDesc<P>, input?: P);
|
|
190
|
+
/** Start values of the parameters, every layer in its initial state at time and phase 0. */
|
|
191
|
+
reset(): void;
|
|
192
|
+
/** Sets a parameter: the ONLY way game logic steers motion. */
|
|
193
|
+
setParam(name: string, value: number): void;
|
|
194
|
+
getParam(name: string): number;
|
|
195
|
+
/** A one-shot signal: lives until a transition consumes it or the next `update` ends. */
|
|
196
|
+
trigger(name: string): void;
|
|
197
|
+
/** Advances states, transitions and timelines by `dt` seconds; deterministic, allocates nothing. */
|
|
198
|
+
update(dt: number): void;
|
|
199
|
+
/** Writes the pose of all layers into `out`. Allocates nothing (scratch poses belong to the shared description). */
|
|
200
|
+
evaluate(out: Pose): void;
|
|
201
|
+
/**
|
|
202
|
+
* Marks crossed and states entered or left since the last call, oldest first: kind, name (of the mark or the
|
|
203
|
+
* state), state (the state it happened in) and layer. No allocation per call.
|
|
204
|
+
*/
|
|
205
|
+
drainEvents(fn: (kind: MotionEventKind, name: string, state: string, layer: string) => void): void;
|
|
206
|
+
/** Name of the current (newest) state of a layer; default the first layer. */
|
|
207
|
+
state(layer?: string): string;
|
|
208
|
+
/** Phase (passes) of the current state of a layer. */
|
|
209
|
+
phase(layer?: string): number;
|
|
210
|
+
/** Seconds (times rate) since the current state of a layer was entered. */
|
|
211
|
+
time(layer?: string): number;
|
|
212
|
+
/** The share 0–1 a state has in its layer's pose now (its cross-fades included); 0 when it is not active. */
|
|
213
|
+
weightOf(state: string, layer?: string): number;
|
|
214
|
+
/**
|
|
215
|
+
* Makes `state` the only active state of a layer at once, `time` seconds into it (seconds times its rate, as `time()`
|
|
216
|
+
* reads them; the phase follows from its sources' durations and the parameters as they are now, or from its driving
|
|
217
|
+
* parameter). For a figure that starts or comes back into view in the middle of something: it neither begins every
|
|
218
|
+
* loop at its start nor fades in from the layer's initial state. No cross-fade, no events (marks before `time` are not
|
|
219
|
+
* reported). Allocates nothing.
|
|
220
|
+
*/
|
|
221
|
+
setState(state: string, layer?: string, time?: number): void;
|
|
222
|
+
/** Bytes of the state (a copy, or written into `out` at `offset`). Drain the events first: they are not saved. */
|
|
223
|
+
save(out?: Uint8Array, offset?: number): Uint8Array;
|
|
224
|
+
/** Brings back a state saved by `save` of a figure with the same description. */
|
|
225
|
+
restore(bytes: Uint8Array, offset?: number): void;
|
|
226
|
+
/** Bytes `save` writes. */
|
|
227
|
+
get byteLength(): number;
|
|
228
|
+
private layerOf;
|
|
229
|
+
/** Starts a transition in layer `li` to state `to`; `curAt` is the entry of the current state. */
|
|
230
|
+
private push;
|
|
231
|
+
/** Advances one entry's time and phase; returns the source whose marks count (the heaviest), −1 none. */
|
|
232
|
+
private advance;
|
|
233
|
+
/** Passes per second (before the rate) of a state's weighted sources; `weigh(s)` must have run. */
|
|
234
|
+
private passesPerSecond;
|
|
235
|
+
/** Weights of a state's sources into `def.weights`; returns the heaviest source with marks, −1 none. */
|
|
236
|
+
private weigh;
|
|
237
|
+
/** Reports the marks crossed between phases p0 and p1 (either direction), in the order they were crossed. */
|
|
238
|
+
private marks;
|
|
239
|
+
/** Queues one event; false (and counted as dropped) when the queue is full. */
|
|
240
|
+
private event;
|
|
241
|
+
/** The pose of one active entry of layer `l` into `dst`; `input` is the pose made by the layers before. */
|
|
242
|
+
private sampleState;
|
|
243
|
+
}
|
|
244
|
+
export {};
|