roamwright 0.20.1 → 0.54.0
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/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +19 -14
- package/README.md +35 -16
- package/examples/animals.html +49 -0
- package/examples/animals.js +209 -0
- package/examples/crowds.html +50 -0
- package/examples/crowds.js +268 -0
- package/examples/effects.html +53 -0
- package/examples/effects.js +343 -0
- package/examples/figure-motion.html +55 -0
- package/examples/figure-motion.js +265 -0
- package/examples/figure.html +49 -0
- package/examples/figure.js +238 -0
- package/examples/fliers.html +53 -0
- package/examples/fliers.js +292 -0
- package/examples/fortification.html +54 -0
- package/examples/fortification.js +288 -0
- package/examples/house-kit.html +48 -0
- package/examples/house-kit.js +175 -0
- package/examples/index.html +26 -16
- package/examples/island.html +48 -0
- package/examples/island.js +134 -52
- package/examples/land.html +54 -0
- package/examples/land.js +392 -0
- package/examples/props-and-plants.html +53 -0
- package/examples/props-and-plants.js +275 -0
- package/examples/rooms.html +48 -0
- package/examples/rooms.js +242 -0
- package/examples/ships.html +51 -0
- package/examples/ships.js +235 -0
- package/examples/showcase.css +320 -0
- package/examples/small-world-land.js +151 -0
- package/examples/small-world-life.js +160 -0
- package/examples/small-world-town.js +127 -0
- package/examples/small-world.html +57 -0
- package/examples/small-world.js +226 -0
- package/examples/soundscape.html +138 -0
- package/examples/soundscape.js +467 -0
- package/examples/stage-kits.js +300 -0
- package/examples/stage.js +374 -0
- package/examples/towns.html +50 -0
- package/examples/towns.js +325 -0
- package/examples/viaduct-camera.js +8 -4
- package/examples/viaduct-landscape.js +28 -17
- package/examples/viaduct.html +45 -43
- package/examples/viaduct.js +68 -92
- package/geometry/animal-camel-body.js +410 -0
- package/geometry/animal-camel-head.js +118 -0
- package/geometry/animal-canine-body.js +361 -0
- package/geometry/animal-canine-breeds.js +316 -0
- package/geometry/animal-canine-head.js +337 -0
- package/geometry/animal-cattle-body.js +391 -0
- package/geometry/animal-cattle-coat.js +42 -0
- package/geometry/animal-cattle-head.js +152 -0
- package/geometry/animal-hen.js +248 -0
- package/geometry/animal-horse-body.js +446 -0
- package/geometry/animal-horse-bridle.js +171 -0
- package/geometry/animal-horse-coat.js +68 -0
- package/geometry/animal-horse-face.js +162 -0
- package/geometry/animal-horse-hair.js +304 -0
- package/geometry/animal-horse-head.js +133 -0
- package/geometry/animal-horse-tack.js +157 -0
- package/geometry/animal-options.js +59 -0
- package/geometry/animal-shapes.js +21 -0
- package/geometry/animal-skin.js +390 -0
- package/geometry/builder-cells.js +10 -2
- package/geometry/builder-frame.js +2 -1
- package/geometry/builder.js +15 -4
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +7 -2
- package/geometry/crowd-dress.js +315 -0
- package/geometry/crowd-far.js +174 -0
- package/geometry/crowd-look.js +42 -0
- package/geometry/crowd-weld.js +218 -0
- package/geometry/ear.js +9 -4
- package/geometry/erosion.js +7 -4
- package/geometry/face-grid.js +26 -6
- package/geometry/field-map.js +59 -0
- package/geometry/figure-arms.js +339 -0
- package/geometry/figure-beard.js +250 -0
- package/geometry/figure-body.js +297 -0
- package/geometry/figure-bow.js +105 -0
- package/geometry/figure-cloak.js +189 -0
- package/geometry/figure-clothes.js +337 -0
- package/geometry/figure-face-grids.js +75 -0
- package/geometry/figure-gear.js +446 -0
- package/geometry/figure-hair-far.js +151 -0
- package/geometry/figure-hair-hangs.js +108 -0
- package/geometry/figure-hair-patch.js +66 -0
- package/geometry/figure-hair.js +320 -0
- package/geometry/figure-hands.js +321 -0
- package/geometry/figure-head-features.js +280 -0
- package/geometry/figure-head.js +375 -0
- package/geometry/figure-headwear.js +223 -0
- package/geometry/figure-legs.js +231 -0
- package/geometry/figure-limbs.js +39 -0
- package/geometry/figure-sculpt.js +82 -0
- package/geometry/figure-skin.js +97 -0
- package/geometry/figure-skirts.js +303 -0
- package/geometry/figure-trunk.js +411 -0
- package/geometry/flier-corvid-body.js +322 -0
- package/geometry/flier-corvid-wings.js +154 -0
- package/geometry/flier-long-body.js +195 -0
- package/geometry/flier-shapes.js +219 -0
- package/geometry/flier-soaring-bird.js +84 -0
- package/geometry/foliage.js +177 -4
- package/geometry/fort-city-walls.js +479 -0
- package/geometry/fort-gate-approach.js +233 -0
- package/geometry/fort-great-walls.js +280 -0
- package/geometry/fort-keep.js +297 -0
- package/geometry/fort-parts.js +261 -0
- package/geometry/fort-polyline.js +261 -0
- package/geometry/fort-portal.js +96 -0
- package/geometry/fort-ring-wall.js +267 -0
- package/geometry/fort-seawall.js +104 -0
- package/geometry/fort-terrace-gates.js +323 -0
- package/geometry/fort-terrace-plan.js +250 -0
- package/geometry/fort-terrace-wall.js +345 -0
- package/geometry/garment-tags.js +11 -3
- package/geometry/grid-gather.js +69 -0
- package/geometry/grid-sample.js +185 -0
- package/geometry/hair-gathers.js +19 -4
- package/geometry/hair-locks.js +1 -1
- package/geometry/hair-patch.js +6 -2
- package/geometry/hair-shell.js +14 -2
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +13 -2
- package/geometry/head-shape.js +51 -23
- package/geometry/heightfield.js +26 -9
- package/geometry/horizon-angles.js +166 -0
- package/geometry/house-kit-body.js +195 -0
- package/geometry/house-kit-courtyard-parts.js +340 -0
- package/geometry/house-kit-courtyard-roof.js +223 -0
- package/geometry/house-kit-courtyard.js +409 -0
- package/geometry/house-kit-cut.js +29 -0
- package/geometry/house-kit-extras.js +192 -0
- package/geometry/house-kit-forms.js +298 -0
- package/geometry/house-kit-frame.js +74 -0
- package/geometry/house-kit-marks.js +93 -0
- package/geometry/house-kit-openings.js +193 -0
- package/geometry/house-kit-palette.js +54 -0
- package/geometry/house-kit-pool.js +71 -0
- package/geometry/house-kit-roofs.js +151 -0
- package/geometry/house-kit.js +202 -0
- package/geometry/instances.js +4 -4
- package/geometry/lamp-wash.js +65 -0
- package/geometry/land-clearings.js +83 -0
- package/geometry/land-ditches.js +290 -0
- package/geometry/land-dry-basin.js +327 -0
- package/geometry/land-dunes.js +150 -0
- package/geometry/land-earthworks.js +432 -0
- package/geometry/land-edge.js +292 -0
- package/geometry/land-mound-faces.js +349 -0
- package/geometry/land-near-relief.js +102 -0
- package/geometry/land-sheet.js +220 -0
- package/geometry/land-town-ground.js +256 -0
- package/geometry/land-waters.js +228 -0
- package/geometry/land-wildness.js +123 -0
- package/geometry/lathed-vessel.js +293 -0
- package/geometry/outline-grid.js +5 -4
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +35 -0
- package/geometry/path-field.js +35 -1
- package/geometry/planked-floor.js +149 -0
- package/geometry/plant-broadleaf.js +268 -0
- package/geometry/plant-shrub.js +198 -0
- package/geometry/plant-tints.js +80 -0
- package/geometry/plant-trees.js +453 -0
- package/geometry/plant-tussock.js +107 -0
- package/geometry/primitives.js +65 -23
- package/geometry/prop-battlefield.js +69 -0
- package/geometry/prop-camp.js +175 -0
- package/geometry/prop-door.js +26 -0
- package/geometry/prop-harbour.js +105 -0
- package/geometry/prop-haycock.js +60 -0
- package/geometry/prop-sacks.js +74 -0
- package/geometry/prop-sheaf.js +68 -0
- package/geometry/prop-street.js +69 -0
- package/geometry/prop-tents.js +396 -0
- package/geometry/prop-tombs.js +80 -0
- package/geometry/prop-trade.js +393 -0
- package/geometry/prop-vehicles.js +218 -0
- package/geometry/props.js +58 -0
- package/geometry/room-arcade.js +134 -0
- package/geometry/room-dome.js +188 -0
- package/geometry/room-flames.js +138 -0
- package/geometry/room-frame.js +106 -0
- package/geometry/room-furniture.js +260 -0
- package/geometry/room-hearth.js +98 -0
- package/geometry/room-kit.js +59 -0
- package/geometry/room-openings.js +142 -0
- package/geometry/room-stairs.js +180 -0
- package/geometry/room-surfaces.js +272 -0
- package/geometry/sampled-surface.js +24 -10
- package/geometry/scatter-grid.js +6 -3
- package/geometry/sculpt.js +5 -1
- package/geometry/ship-fittings.js +350 -0
- package/geometry/ship-hull.js +460 -0
- package/geometry/ship-kit.js +208 -0
- package/geometry/ship-lines.js +69 -0
- package/geometry/ship-oars.js +150 -0
- package/geometry/ship-presets.js +131 -0
- package/geometry/ship-rig.js +374 -0
- package/geometry/ship-sails.js +148 -0
- package/geometry/shore-grid.js +5 -1
- package/geometry/strata-field.js +44 -11
- package/geometry/strata-tiles.js +20 -6
- package/geometry/stream.js +32 -17
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +139 -51
- package/geometry/terrain-extension.js +24 -8
- package/geometry/town-courtyard-inn.js +272 -0
- package/geometry/town-ground.js +76 -0
- package/geometry/town-houses.js +343 -0
- package/geometry/town-lights.js +254 -0
- package/geometry/town-lots.js +172 -0
- package/geometry/town-plan.js +370 -0
- package/geometry/town-works.js +465 -0
- package/geometry/village-layout.js +181 -0
- package/geometry/village-yards.js +167 -0
- package/geometry/wall-runs.js +64 -0
- package/index.js +134 -3
- package/math/cloud-textures.js +3 -7
- package/math/curve.js +5 -1
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +177 -54
- package/math/periodic.js +6 -0
- package/math/rectangles.js +8 -2
- package/math/rock-texture.js +17 -12
- package/math/surface-textures.js +24 -9
- package/math/wandering-path.js +40 -0
- package/math/ways.js +120 -0
- package/motion/action-dynamics.js +398 -0
- package/motion/animal-bearing.js +247 -0
- package/motion/animal-canine-bearing.js +178 -0
- package/motion/animal-canine-cast.js +131 -0
- package/motion/animal-cattle-cast.js +64 -0
- package/motion/animal-herd-cast.js +154 -0
- package/motion/animal-horse-still.js +161 -0
- package/motion/animal-troop-cast.js +43 -0
- package/motion/arm-reach.js +3 -2
- package/motion/ballistic-arc.js +182 -2
- package/motion/biped-cycle.js +4 -2
- package/motion/biped-leg.js +4 -1
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +142 -32
- package/motion/boat-sailing.js +214 -0
- package/motion/contact-transition.js +5 -6
- package/motion/crowd-alarms.js +36 -6
- package/motion/crowd-attention.js +108 -0
- package/motion/crowd-beasts.js +203 -0
- package/motion/crowd-camp.js +295 -0
- package/motion/crowd-figure.js +100 -0
- package/motion/crowd-herd.js +86 -0
- package/motion/crowd-hold.js +130 -0
- package/motion/crowd-pose.js +296 -0
- package/motion/crowd-poses.js +481 -0
- package/motion/crowd-routine.js +44 -14
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/deck-surface.js +4 -2
- package/motion/figure-acts.js +411 -0
- package/motion/figure-arms.js +437 -0
- package/motion/figure-blade-slide.js +149 -0
- package/motion/figure-body-place.js +180 -0
- package/motion/figure-bones.js +118 -0
- package/motion/figure-bow-draw.js +70 -0
- package/motion/figure-fingers.js +215 -0
- package/motion/figure-gaze.js +205 -0
- package/motion/figure-gestures.js +452 -0
- package/motion/figure-grip.js +134 -0
- package/motion/figure-head.js +287 -0
- package/motion/figure-legs.js +264 -0
- package/motion/figure-links.js +293 -0
- package/motion/figure-locomotion.js +391 -0
- package/motion/figure-mount-up.js +180 -0
- package/motion/figure-mount.js +201 -0
- package/motion/figure-pose-frame.js +375 -0
- package/motion/figure-pose-table.js +156 -0
- package/motion/figure-pose.js +343 -0
- package/motion/figure-seat.js +267 -0
- package/motion/figure-sway.js +125 -0
- package/motion/flier-corvid-pose.js +74 -0
- package/motion/flier-flight-air.js +122 -0
- package/motion/flier-flight-echelon.js +164 -0
- package/motion/flier-flight-roost.js +131 -0
- package/motion/flier-swarm-flight.js +252 -0
- package/motion/formation.js +193 -0
- package/motion/instance-sight.js +8 -1
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +7 -6
- package/motion/quadruped.js +109 -33
- package/motion/spaces.js +58 -6
- package/motion/speech-cadence.js +304 -0
- package/motion/vessel-motion.js +57 -0
- package/motion/walk-grid.js +235 -0
- package/motion/weather.js +70 -12
- package/motion/wind.js +27 -1
- package/package.json +27 -4
- package/rendering/alpha-mips.js +340 -0
- package/rendering/animal-camel-figure.js +29 -0
- package/rendering/animal-canine-figure.js +59 -0
- package/rendering/animal-cattle-figure.js +36 -0
- package/rendering/animal-horse-figure.js +49 -0
- package/rendering/atmosphere.js +86 -0
- package/rendering/camera-track.js +156 -0
- package/rendering/{road-surface.js → cart-track.js} +40 -11
- package/rendering/caster-motion.js +2 -1
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +665 -80
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +2 -2
- package/rendering/compilation-schedule.js +18 -10
- package/rendering/contact-shadows.js +5 -2
- package/rendering/context.js +47 -8
- package/rendering/crowd-batches.js +420 -0
- package/rendering/crowd-herd.js +198 -0
- package/rendering/crowd-rig.js +132 -0
- package/rendering/crowd-skinning.js +52 -9
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +1 -3
- package/rendering/detail-range.js +6 -5
- package/rendering/dof.js +11 -4
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +81 -54
- package/rendering/field-surface.js +138 -0
- package/rendering/figure-shield.js +105 -0
- package/rendering/figure-skeleton.js +329 -0
- package/rendering/fire-light-watch.js +197 -0
- package/rendering/fire-pools.js +148 -0
- package/rendering/flame-sources.js +86 -0
- package/rendering/flier-bird-looks.js +97 -0
- package/rendering/flier-corvid-figure.js +67 -0
- package/rendering/flier-long-body-company.js +169 -0
- package/rendering/flier-swarm.js +186 -0
- package/rendering/flocks.js +6 -2
- package/rendering/garment-material.js +145 -49
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +38 -24
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +15 -3
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +13 -3
- package/rendering/label-range.js +5 -2
- package/rendering/lamp-light-map.js +159 -0
- package/rendering/lamp-maps.js +62 -0
- package/rendering/lamp-wash.js +51 -0
- package/rendering/light-budget.js +19 -3
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +27 -7
- package/rendering/material-lod.js +5 -6
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +61 -25
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +134 -34
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +282 -6
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +780 -77
- package/rendering/plant-cells.js +122 -0
- package/rendering/plant-reeds.js +113 -0
- package/rendering/plant-shade-trees.js +239 -0
- package/rendering/plant-tuft-patch.js +122 -0
- package/rendering/post-shaders.js +84 -21
- package/rendering/post.js +39 -19
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/room-light.js +250 -0
- package/rendering/room-materials.js +78 -0
- package/rendering/room-space.js +111 -0
- package/rendering/scene-lights.js +106 -0
- package/rendering/sea-shaders.js +83 -26
- package/rendering/settlement-approach.js +226 -0
- package/rendering/settlement-dissolve.js +89 -0
- package/rendering/settlement-quarter-warm.js +55 -0
- package/rendering/settlement-quarter.js +477 -0
- package/rendering/settlement-switch.js +42 -0
- package/rendering/settlement-town.js +110 -0
- package/rendering/shader-warmup.js +80 -36
- package/rendering/shadow-depth.js +40 -18
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +42 -15
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +112 -50
- package/rendering/smoke-shadows.js +201 -0
- package/rendering/stage-framing.js +182 -0
- package/rendering/stage-lights.js +46 -39
- package/rendering/stain-material.js +74 -0
- package/rendering/static-point-shadow.js +62 -23
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +2 -2
- package/rendering/street-lamps.js +166 -0
- package/rendering/sunbeam-motes.js +670 -0
- package/rendering/surface-light.js +65 -6
- package/rendering/surface-material.js +306 -0
- package/rendering/surface-projection.js +32 -0
- package/rendering/surface-snippets.js +314 -0
- package/rendering/taa.js +49 -18
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/water-material.js +270 -82
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +0 -2
- package/ruff.toml +20 -0
- package/runtime/cue-cursor.js +21 -0
- package/runtime/device-quality.js +13 -2
- package/runtime/device.js +73 -0
- package/runtime/diagnostic-log.js +11 -3
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +8 -5
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +18 -4
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +8 -4
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +5 -5
- package/runtime/hand-over.js +7 -2
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +17 -3
- package/runtime/quality-fit.js +59 -27
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +6 -2
- package/runtime/settlement-reach.js +42 -0
- package/runtime/sound-calls.js +113 -0
- package/runtime/sound-impacts.js +297 -0
- package/runtime/sound-voices.js +194 -0
- package/runtime/soundscape.js +282 -0
- package/runtime/spatial-audio.js +69 -20
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +19 -8
- package/scripts/app-parts.mjs +118 -0
- package/scripts/bake-revisions.mjs +81 -0
- package/scripts/browser-scripts.mjs +64 -0
- package/scripts/bundle.mjs +192 -0
- package/scripts/check-app.sh +26 -0
- package/scripts/eslint-config.mjs +119 -0
- package/scripts/format.sh +92 -0
- package/scripts/keep-builds.mjs +158 -0
- package/scripts/layers.mjs +112 -0
- package/scripts/lint.sh +49 -0
- package/scripts/module-graph.mjs +123 -0
- package/scripts/pre-commit.sh +38 -0
- package/scripts/serve.py +5 -3
- package/scripts/site.mjs +358 -0
- package/scripts/test-runner.sh +42 -0
- package/scripts/vendor.mjs +221 -0
- package/scripts/verify-publish.mjs +175 -0
- package/scripts/world.mk +59 -0
- package/tools/README.md +73 -0
- package/tools/contact-sheet.cjs +137 -0
- package/tools/cpu-profile.cjs +275 -0
- package/tools/cpu-profile.test.cjs +98 -0
- package/tools/first-draws.cjs +395 -0
- package/tools/flight-guard.cjs +482 -0
- package/tools/flight-guard.test.cjs +153 -0
- package/tools/flight-profile.cjs +145 -0
- package/tools/frame-bench.cjs +336 -0
- package/tools/frame-parts.cjs +365 -0
- package/tools/ios-sim.sh +145 -0
- package/tools/load-audit.cjs +201 -0
- package/tools/look-compare.cjs +304 -0
- package/tools/look-guard.cjs +407 -0
- package/tools/look-guard.test.cjs +93 -0
- package/tools/look-stats.cjs +185 -0
- package/tools/look-stats.test.cjs +71 -0
- package/tools/memory-audit.cjs +323 -0
- package/tools/page-driver.cjs +320 -0
- package/tools/page-driver.test.cjs +219 -0
- package/tools/program-census-report.cjs +191 -0
- package/tools/program-census.cjs +465 -0
- package/tools/program-census.test.cjs +332 -0
- package/tools/remote-runner.sh +265 -0
- package/tools/runners.test.cjs +59 -0
- package/tools/scene-audit-beat.cjs +344 -0
- package/tools/scene-audit-sheet.cjs +282 -0
- package/tools/scene-audit.cjs +471 -0
- package/tools/scene-audit.test.cjs +201 -0
- package/tools/scene-batch.cjs +219 -0
- package/tools/scene-bench.cjs +149 -0
- package/tools/scene-bench.test.cjs +33 -0
- package/tools/scene-run.cjs +443 -0
- package/tools/scene-run.test.cjs +94 -0
- package/tools/servers.sh +59 -0
- package/tools/shader-arrival.cjs +316 -0
- package/tools/shader-renewal.cjs +53 -0
- package/tools/shader-renewal.test.cjs +115 -0
- package/tools/speed-guard.cjs +258 -0
- package/tools/stills.cjs +492 -0
- package/tools/stills.test.cjs +49 -0
- package/tools/turns.sh +7 -0
- package/tools/yaml.cjs +158 -0
- package/examples/viaduct.css +0 -75
- package/rendering/light-shafts.js +0 -131
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gaze: where people's heads turn. In a scene everyone looks at whoever last spoke, moved or struck (the director names them
|
|
3
|
+
* with `heed`), and that person looks at whoever held the stage before, or at the nearest of the others: so in a closer shot
|
|
4
|
+
* the speaker looks at the one spoken to, not past the lens. Someone with nobody to watch glances about now and then, each on a
|
|
5
|
+
* rhythm of their own. A script can also say what somebody looks at (`a.watch`: the moon, a coin spinning in the air). A head
|
|
6
|
+
* turns as far as a neck allows; what is behind is left alone. Angles are radians, distances metres.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { TAU, clamp } from '../math/scalar.js';
|
|
10
|
+
import { createHash } from '../math/random.js';
|
|
11
|
+
|
|
12
|
+
const SIDEWAYS = 0.95, // as far as a head turns to either side, in radians
|
|
13
|
+
BEHIND = 1.9, // beyond this off the facing, a thing is behind and not looked at
|
|
14
|
+
UP = 0.45, // as far as a head tips up, and down
|
|
15
|
+
DOWN = 0.38,
|
|
16
|
+
TOO_NEAR = 1.2, // metres within which a thing is not looked at (it is the looker's own place)
|
|
17
|
+
IN_EARSHOT = 14, // the one spoken to is within this many metres
|
|
18
|
+
THREAT_NEAR = 8.5, // metres within which a sudden weapon draw or lunge startles onlookers
|
|
19
|
+
EYES = 0.88, // the eyes' height, as a share of the figure's
|
|
20
|
+
GLANCE_EVERY = 3.2, // seconds between glances, at the least, and how much longer for the most placid
|
|
21
|
+
GLANCE_SPREAD = 3.5,
|
|
22
|
+
GLANCE = 0.55; // how far a glance goes to either side
|
|
23
|
+
const MAX_CAST = 64;
|
|
24
|
+
/**
|
|
25
|
+
* The gaze of a world's people: one stage, on which a scene's players watch each other.
|
|
26
|
+
* @param {object} [options]
|
|
27
|
+
* @param {function(number, number, number=): number} [options.hash] - A repeatable hash in [0, 1) of two integers and a seed
|
|
28
|
+
* (math/random.js createHash), which times each one's glances. Defaults to createHash(0).
|
|
29
|
+
* @returns {object} gaze: the stage ({ on, at, cast, who, was, ... }, read by those who place onlookers); heed(a): actor a does
|
|
30
|
+
* something now and holds the stage; setGaze(cast, at): a scene begins with its players (and the point its camera looks at,
|
|
31
|
+
* for when nobody has acted yet), or ends (null); lookOf(a, i, t): where the head of actor a (the i-th) turns at time t
|
|
32
|
+
* (seconds) from its body's facing ({ yaw, pitch, handoffAge, threatAge, threatYaw }, shared by every call). An actor's
|
|
33
|
+
* `x`, `y`, `z`, `yaw`, `height`, `pose`, `seed`, `inScene`, `active`, `space`, `watch`, `lookAt`, `act`, `fx_` and
|
|
34
|
+
* `armed` are read.
|
|
35
|
+
*/
|
|
36
|
+
function createFigureGaze({ hash = createHash() } = {}) {
|
|
37
|
+
const gaze = {
|
|
38
|
+
on: false, // a scene is playing
|
|
39
|
+
at: null, // what its camera looks at, for when nobody has acted yet
|
|
40
|
+
cast: [], // its players
|
|
41
|
+
who: null, // the one who holds the stage,
|
|
42
|
+
was: null, // and the one who held it before
|
|
43
|
+
seq: 0, // incremented on each speaker/action handoff after the first
|
|
44
|
+
seenSeq: 0,
|
|
45
|
+
handoffAt: -10, // scene clock when the active speaker last changed
|
|
46
|
+
threatAt: -10, // scene clock when a nearby cast member last drew a blade or lunged
|
|
47
|
+
threatWho: null,
|
|
48
|
+
threatX: 0,
|
|
49
|
+
threatZ: 0,
|
|
50
|
+
};
|
|
51
|
+
const look = { yaw: 0, pitch: 0, handoffAge: -1, threatAge: -1, threatYaw: 0 }; // where a head turns and reacts, as lookOf leaves it
|
|
52
|
+
const _castFlags = new Uint8Array(MAX_CAST);
|
|
53
|
+
let _frameTime = -1,
|
|
54
|
+
_castPrimed = false;
|
|
55
|
+
|
|
56
|
+
// The director: actor a does something now, and holds the stage.
|
|
57
|
+
function heed(a) {
|
|
58
|
+
if (!a || a === gaze.who) return;
|
|
59
|
+
if (gaze.who) gaze.seq++;
|
|
60
|
+
gaze.was = gaze.who;
|
|
61
|
+
gaze.who = a;
|
|
62
|
+
}
|
|
63
|
+
// A scene begins (with its players) or ends (with none).
|
|
64
|
+
function setGaze(cast, at) {
|
|
65
|
+
gaze.on = !!cast;
|
|
66
|
+
gaze.cast = cast || [];
|
|
67
|
+
gaze.at = at || null;
|
|
68
|
+
gaze.who = gaze.was = null;
|
|
69
|
+
gaze.seq = gaze.seenSeq = 0;
|
|
70
|
+
gaze.handoffAt = gaze.threatAt = -10;
|
|
71
|
+
gaze.threatWho = null;
|
|
72
|
+
_frameTime = -1;
|
|
73
|
+
_castPrimed = false;
|
|
74
|
+
_castFlags.fill(0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Tracks speaker handoff timestamps and detects newly started weapon draws or strikes once per frame.
|
|
78
|
+
function pollStageEvents(t) {
|
|
79
|
+
if (t === _frameTime) return;
|
|
80
|
+
_frameTime = t;
|
|
81
|
+
if (gaze.seq !== gaze.seenSeq) {
|
|
82
|
+
gaze.seenSeq = gaze.seq;
|
|
83
|
+
gaze.handoffAt = t;
|
|
84
|
+
}
|
|
85
|
+
const cast = gaze.cast,
|
|
86
|
+
count = Math.min(cast.length, MAX_CAST);
|
|
87
|
+
for (let k = 0; k < count; k++) {
|
|
88
|
+
const o = cast[k];
|
|
89
|
+
if (!o) continue;
|
|
90
|
+
const drawing = o.act && o.act.A && o.act.A.slide && o.act.A.slide.out > 0 ? 1 : 0,
|
|
91
|
+
striking = o.pose === 'strike' || !!(o.fx_ && o.fx_.busy) ? 2 : 0,
|
|
92
|
+
armed = o.armed ? 4 : 0,
|
|
93
|
+
mask = drawing | striking | armed,
|
|
94
|
+
prev = _castFlags[k];
|
|
95
|
+
if (_castPrimed && o.active && ((mask & 3 & ~prev) !== 0 || ((mask & 4) !== 0 && (prev & 4) === 0))) {
|
|
96
|
+
gaze.threatAt = t;
|
|
97
|
+
gaze.threatWho = o;
|
|
98
|
+
gaze.threatX = o.x;
|
|
99
|
+
gaze.threatZ = o.z;
|
|
100
|
+
}
|
|
101
|
+
_castFlags[k] = mask;
|
|
102
|
+
}
|
|
103
|
+
_castPrimed = true;
|
|
104
|
+
}
|
|
105
|
+
const watchable = (o, a) => o && o !== a && o.active && o.space === a.space;
|
|
106
|
+
// Whom the one who holds the stage looks at: the one who held it before, if near, or else the nearest of the others.
|
|
107
|
+
function addressed(a) {
|
|
108
|
+
if (watchable(gaze.was, a) && Math.hypot(gaze.was.x - a.x, gaze.was.z - a.z) < IN_EARSHOT) return gaze.was;
|
|
109
|
+
let best = null,
|
|
110
|
+
near = IN_EARSHOT;
|
|
111
|
+
for (const o of gaze.cast) {
|
|
112
|
+
if (!watchable(o, a) || o.pose === 'dead') continue;
|
|
113
|
+
const d = Math.hypot(o.x - a.x, o.z - a.z);
|
|
114
|
+
if (d < near) {
|
|
115
|
+
near = d;
|
|
116
|
+
best = o;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return best;
|
|
120
|
+
}
|
|
121
|
+
// Where the head of actor a (the i-th) turns at time t, from its body's facing: look.yaw to the side, look.pitch up,
|
|
122
|
+
// plus active speaker-handoff and nearby threat timing for whole-body listening and startle micro-reactions.
|
|
123
|
+
function lookOf(a, i, t) {
|
|
124
|
+
look.yaw = look.pitch = look.threatYaw = 0;
|
|
125
|
+
look.handoffAge = look.threatAge = -1;
|
|
126
|
+
if (a.pose === 'dead') return look;
|
|
127
|
+
if (a.inScene && gaze.on) {
|
|
128
|
+
pollStageEvents(t);
|
|
129
|
+
if (a !== gaze.who && gaze.handoffAt >= 0 && t >= gaze.handoffAt) look.handoffAge = t - gaze.handoffAt;
|
|
130
|
+
const threatAge = gaze.threatAt >= 0 && t >= gaze.threatAt ? t - gaze.threatAt : -1;
|
|
131
|
+
if (threatAge >= 0 && threatAge < 0.75 && gaze.threatWho !== a && !(a.fx_ && a.fx_.busy)) {
|
|
132
|
+
const tx = gaze.threatX - a.x,
|
|
133
|
+
tz = gaze.threatZ - a.z,
|
|
134
|
+
td = Math.hypot(tx, tz);
|
|
135
|
+
if (td > 0.2 && td < THREAT_NEAR) {
|
|
136
|
+
let rel = Math.atan2(tx, tz) - a.yaw;
|
|
137
|
+
rel -= Math.round(rel / TAU) * TAU;
|
|
138
|
+
if (Math.abs(rel) < BEHIND) {
|
|
139
|
+
look.threatAge = threatAge;
|
|
140
|
+
look.threatYaw = rel;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const n = Math.floor(t / (GLANCE_EVERY + GLANCE_SPREAD * a.seed) + a.seed * 17);
|
|
146
|
+
look.yaw = hash(n, i, 31) < 0.45 ? 0 : (hash(n, i, 32) - 0.5) * 2 * GLANCE;
|
|
147
|
+
let x = 0,
|
|
148
|
+
y = 0,
|
|
149
|
+
z = 0,
|
|
150
|
+
found = false;
|
|
151
|
+
if (a.watch) {
|
|
152
|
+
// told by the script what to look at: a person, or a point in the air
|
|
153
|
+
x = a.watch.x;
|
|
154
|
+
z = a.watch.z;
|
|
155
|
+
y = a.watch.height ? a.watch.y + a.watch.height * EYES : a.watch.y;
|
|
156
|
+
found = true;
|
|
157
|
+
} else if (a.inScene && gaze.on) {
|
|
158
|
+
// Listeners linger briefly on the previous speaker across a handoff and occasionally check back during dialogue.
|
|
159
|
+
const lingerPrev =
|
|
160
|
+
a !== gaze.who && a !== gaze.was && look.handoffAge >= 0 && look.handoffAge < 0.14 + 0.1 * a.seed && watchable(gaze.was, a),
|
|
161
|
+
checkOther = a !== gaze.who && (lingerPrev || (hash(n, i, 37) < 0.22 && watchable(gaze.was, a))),
|
|
162
|
+
threatFocus = look.threatAge >= 0 && look.threatAge < 0.42 && watchable(gaze.threatWho, a),
|
|
163
|
+
o = threatFocus ? gaze.threatWho : a === gaze.who ? addressed(a) : checkOther ? gaze.was : gaze.who;
|
|
164
|
+
if (watchable(o, a)) {
|
|
165
|
+
x = o.x;
|
|
166
|
+
z = o.z;
|
|
167
|
+
const eyeShare =
|
|
168
|
+
o.pose === 'dead' || o.pose === 'lie' || o.pose === 'prone'
|
|
169
|
+
? 0.12
|
|
170
|
+
: o.pose === 'kneel' || o.pose === 'sit' || o.pose === 'sittalk'
|
|
171
|
+
? 0.62
|
|
172
|
+
: o.pose === 'crouch' || o.pose === 'rest' || o.pose === 'cower'
|
|
173
|
+
? 0.55
|
|
174
|
+
: EYES;
|
|
175
|
+
y = o.y + o.height * eyeShare;
|
|
176
|
+
found = true;
|
|
177
|
+
} else if (gaze.at && a !== gaze.who) {
|
|
178
|
+
x = gaze.at.x;
|
|
179
|
+
y = gaze.at.y;
|
|
180
|
+
z = gaze.at.z;
|
|
181
|
+
found = true;
|
|
182
|
+
}
|
|
183
|
+
} else if (a.lookAt) {
|
|
184
|
+
x = a.lookAt.x;
|
|
185
|
+
z = a.lookAt.z;
|
|
186
|
+
y = a.lookAt.y ?? a.y + a.height * EYES;
|
|
187
|
+
found = true;
|
|
188
|
+
}
|
|
189
|
+
if (!found) return look;
|
|
190
|
+
const dx = x - a.x,
|
|
191
|
+
dz = z - a.z,
|
|
192
|
+
far = Math.hypot(dx, dz);
|
|
193
|
+
if (far < TOO_NEAR) return look;
|
|
194
|
+
let off = Math.atan2(dx, dz) - a.yaw;
|
|
195
|
+
off -= Math.round(off / TAU) * TAU;
|
|
196
|
+
if (Math.abs(off) > BEHIND) return look;
|
|
197
|
+
look.yaw = look.yaw * 0.2 + clamp(off, -SIDEWAYS, SIDEWAYS) * 0.9;
|
|
198
|
+
look.pitch = clamp(Math.atan2(y - (a.y + a.height * EYES), far), -DOWN, UP) * 0.85;
|
|
199
|
+
return look;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return { gaze, heed, lookOf, setGaze };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export { createFigureGaze };
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gestures: what the arms, the trunk and the head of a person's figure do in a pose beyond holding it. A pose
|
|
3
|
+
* (figure-pose-table.js) is a stance; this gives it life: someone speaking marks their words with one hand and then the other
|
|
4
|
+
* way, from a small store of gestures taken in an order of their own; hands that reach work at what they reach for; a load is
|
|
5
|
+
* cradled on bent arms; a pointing arm goes out straight while the other hand rests; a crossbow is levelled, hands are held to
|
|
6
|
+
* a fire, a page is read. Every channel moves on a damped spring with proximal-to-distal lag so shoulders lead elbows and
|
|
7
|
+
* wrists in natural arcs. Angles are radians; lengths figure units (a figure of full size stands 1.9 m).
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { stepGestureSprings } from './action-dynamics.js';
|
|
11
|
+
import { createHash } from '../math/random.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The parts a gesture (and an act, figure-acts.js) moves, as places in its array of PARTS values:
|
|
15
|
+
* upper arms (left, right; less is further forward and up), arms out from the sides (left: more is inward; right: less is),
|
|
16
|
+
* elbows (less is more bent), the trunk's lean forward, the head's nod; the upper arms' turn about their own length (left:
|
|
17
|
+
* more turns the forearm inward; right: less does), the head's turn and tilt, the trunk's twist, the hips lowered (SINK, in
|
|
18
|
+
* figure units) and shifted forward (SHIFT), the shoulders lifted (SHRUG, 0 to 1), the thighs of legs that are not standing
|
|
19
|
+
* (a climber's, a crawler's), and the trunk bent forward at the
|
|
20
|
+
* waist over hips that stay where they are (BEND: a bow, a stoop; LEAN tips the whole figure from the feet, as a run does).
|
|
21
|
+
*/
|
|
22
|
+
const LA = 0,
|
|
23
|
+
RA = 1,
|
|
24
|
+
LZ = 2,
|
|
25
|
+
RZ = 3,
|
|
26
|
+
FL = 4,
|
|
27
|
+
FR = 5,
|
|
28
|
+
LEAN = 6,
|
|
29
|
+
NOD = 7,
|
|
30
|
+
LY = 8,
|
|
31
|
+
RY = 9,
|
|
32
|
+
TURN = 10,
|
|
33
|
+
TILT = 11,
|
|
34
|
+
TWIST = 12,
|
|
35
|
+
SINK = 13,
|
|
36
|
+
SHIFT = 14,
|
|
37
|
+
SHRUG = 15,
|
|
38
|
+
LL = 16,
|
|
39
|
+
LR = 17,
|
|
40
|
+
BEND = 18,
|
|
41
|
+
PARTS = 19;
|
|
42
|
+
|
|
43
|
+
// Per-channel spring frequency multipliers: trunk leads, shoulders follow, elbows and forearm/wrist turns trail slightly.
|
|
44
|
+
const CHANNEL_SCALE = new Float32Array([
|
|
45
|
+
0.98, // LA
|
|
46
|
+
0.98, // RA
|
|
47
|
+
0.96, // LZ
|
|
48
|
+
0.96, // RZ
|
|
49
|
+
0.84, // FL
|
|
50
|
+
0.84, // FR
|
|
51
|
+
1.08, // LEAN
|
|
52
|
+
0.92, // NOD
|
|
53
|
+
0.75, // LY
|
|
54
|
+
0.75, // RY
|
|
55
|
+
0.9, // TURN
|
|
56
|
+
0.88, // TILT
|
|
57
|
+
1.08, // TWIST
|
|
58
|
+
1.05, // SINK
|
|
59
|
+
1.05, // SHIFT
|
|
60
|
+
0.95, // SHRUG
|
|
61
|
+
0.95, // LL
|
|
62
|
+
0.95, // LR
|
|
63
|
+
1.0, // BEND
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
// What someone speaking does with the hands, a beat at a time: [right upper arm, right elbow, left upper arm, left elbow, right arm out, nod, right turn].
|
|
67
|
+
// People talking keep their elbows by their sides and speak with their forearms: the hand works between the belt and the
|
|
68
|
+
// breastbone, a forearm's length before the body, and falls back to the side between thoughts. An upper arm lifted from the
|
|
69
|
+
// shoulder holds the hand up at the height of the face, where it reads as a hand holding something up.
|
|
70
|
+
const SPOKEN = [
|
|
71
|
+
[-0.16, -1.15, 0, 0, -0.05, 0.05, -0.3], // the open hand offered, at the belt
|
|
72
|
+
[-0.26, -0.95, 0, 0, -0.03, 0.1, -0.12], // a point made, the hand coming down on it
|
|
73
|
+
[-0.14, -1.1, -0.14, -1.05, -0.08, 0.03, -0.26], // both hands, weighing
|
|
74
|
+
[-0.03, -0.18, 0, 0, 0, -0.03, 0], // the hand let fall between two thoughts
|
|
75
|
+
[-0.2, -1.95, 0, 0, 0.1, 0.06, -0.75], // the hand to the chest
|
|
76
|
+
[-0.08, -0.8, -0.06, -0.7, -0.12, 0, -0.3], // a shrug of the forearms
|
|
77
|
+
],
|
|
78
|
+
BEAT = 2.4, // seconds a spoken gesture is held, give or take a third
|
|
79
|
+
SPOKEN_REST = 0.45, // the share of beats in which the hands rest while the voice goes on
|
|
80
|
+
FREQ = 10.2, // spring natural frequency (rad/s) for brisk gestures,
|
|
81
|
+
FREQ_SPOKEN = 5.6, // and one made while speaking, which flows from the last
|
|
82
|
+
FREQ_HABIT = 4.4, // and a habit of someone at ease, which is in no hurry
|
|
83
|
+
GUARD_WEAVE = 0.07, // how far a guard's arm drifts, up and down and at the elbow
|
|
84
|
+
GUARD_ELBOW = -1.02; // and how far its elbow is bent beyond a hanging arm's
|
|
85
|
+
// What someone standing at ease does with the hands now and then:
|
|
86
|
+
// [left upper arm, left elbow, left out, left turn, right upper arm, right elbow, right out, right turn, nod]
|
|
87
|
+
const HABITS = [
|
|
88
|
+
[-0.1, -0.85, -0.1, 0.25, 0, 0, 0, 0, 0], // a hand at the belt
|
|
89
|
+
[-0.1, -0.85, -0.1, 0.25, -0.1, -0.85, 0.1, -0.25, 0], // both thumbs in the belt
|
|
90
|
+
[0, 0, 0, 0, -0.52, -2.3, 0, -0.5, 0.07], // a hand to the chin
|
|
91
|
+
[-0.4, -1.6, 0.04, 1.0, -0.34, -1.68, -0.04, -1.0, 0], // the arms folded
|
|
92
|
+
[0.32, -0.7, 0.04, 1.45, 0.32, -0.7, -0.04, -1.45, -0.03], // the hands clasped behind the back
|
|
93
|
+
],
|
|
94
|
+
HABITS_IN_SCENE = 0, // while a scene plays, none: what a hand does there is the script's to say, and a forearm held out at the belt reads as a hand holding something
|
|
95
|
+
HABIT_EVERY = 11, // seconds between habits at the least, and how much longer for the most placid
|
|
96
|
+
HABIT_SPREAD = 13,
|
|
97
|
+
HABIT_HELD = 0.42; // the share of that time a habit is kept
|
|
98
|
+
/**
|
|
99
|
+
* The gestures of a world's people, which draw what each does when from a seeded hash.
|
|
100
|
+
* @param {object} [options]
|
|
101
|
+
* @param {function(number, number, number=): number} [options.hash] - A repeatable hash in [0, 1) of two integers and a seed
|
|
102
|
+
* (math/random.js createHash); the world's own makes its people's habits its own. Defaults to createHash(0).
|
|
103
|
+
* @returns {{gestureOf: function(object, number, number, boolean, boolean): Float32Array}} gestureOf(a, t, dt, other,
|
|
104
|
+
* walking): the gesture of actor a at time t (seconds), eased by dt: an array of PARTS values to add to its pose (kept on
|
|
105
|
+
* the actor as `a.ges`). `other` is true when the right hand is taken (a planted staff): the left then does what the right
|
|
106
|
+
* would; `walking` while it strides. The actor's `pose`, `seed`, `phase`, `inScene`, `mount`, `move`, `feet` and `hip` are
|
|
107
|
+
* read; `ges` and `gesDraw` are kept on it.
|
|
108
|
+
*/
|
|
109
|
+
function createFigureGestures({ hash = createHash() } = {}) {
|
|
110
|
+
const _to = new Float32Array(PARTS);
|
|
111
|
+
// The draws and spring velocities a gesture keeps on the actor (a.gesDraw) with zero per-frame allocations.
|
|
112
|
+
const drawsOf = a => (a.gesDraw ??= { beat: NaN, spoken: NaN, turn: NaN, rest: NaN, habit: NaN, vel: new Float32Array(PARTS) });
|
|
113
|
+
|
|
114
|
+
// Both arms, mirrored: the upper arms to `arm`, out from the sides by `out`, the elbows to `elbow`, turned in by `turn`.
|
|
115
|
+
function bothArms(arm, elbow, out = 0, turn = 0) {
|
|
116
|
+
_to[LA] = _to[RA] = arm;
|
|
117
|
+
_to[FL] = _to[FR] = elbow;
|
|
118
|
+
_to[LZ] = -out;
|
|
119
|
+
_to[RZ] = out;
|
|
120
|
+
_to[LY] = turn;
|
|
121
|
+
_to[RY] = -turn;
|
|
122
|
+
}
|
|
123
|
+
// What a person at ease does this moment, if anything: one of their two habits, for a while, then nothing for a longer while.
|
|
124
|
+
function habit(a, t) {
|
|
125
|
+
const every = HABIT_EVERY + HABIT_SPREAD * a.seed,
|
|
126
|
+
at = t / every + a.seed * 5,
|
|
127
|
+
n = Math.floor(at);
|
|
128
|
+
if (at - n > HABIT_HELD) return;
|
|
129
|
+
const d = drawsOf(a);
|
|
130
|
+
if (d.turn !== n) {
|
|
131
|
+
d.turn = n;
|
|
132
|
+
d.rest = hash(n, a.seed * 53);
|
|
133
|
+
d.habit = hash(n % 2, a.seed * 71);
|
|
134
|
+
}
|
|
135
|
+
if (d.rest < 0.3) return;
|
|
136
|
+
const store = a.inScene ? HABITS_IN_SCENE : HABITS.length;
|
|
137
|
+
if (!store) return;
|
|
138
|
+
const h = HABITS[Math.floor(d.habit * store) % store];
|
|
139
|
+
_to[LA] = h[0];
|
|
140
|
+
_to[FL] = h[1];
|
|
141
|
+
_to[LZ] = h[2];
|
|
142
|
+
_to[LY] = h[3];
|
|
143
|
+
_to[RA] = h[4];
|
|
144
|
+
_to[FR] = h[5];
|
|
145
|
+
_to[RZ] = h[6];
|
|
146
|
+
_to[RY] = h[7];
|
|
147
|
+
_to[NOD] = h[8];
|
|
148
|
+
}
|
|
149
|
+
// The gesture of actor a at time t, eased by dt (see createFigureGestures).
|
|
150
|
+
function gestureOf(a, t, dt, other, walking) {
|
|
151
|
+
const g = (a.ges ??= new Float32Array(PARTS)),
|
|
152
|
+
d = drawsOf(a),
|
|
153
|
+
pose = walking && a.pose !== 'carry' && a.pose !== 'crawl' && a.pose !== 'climb' && a.pose !== 'guard' ? 'walk' : a.pose;
|
|
154
|
+
if (a.feet === null && Number.isNaN(a.hip)) d.vel.fill(0);
|
|
155
|
+
let freq = FREQ;
|
|
156
|
+
_to.fill(0);
|
|
157
|
+
if (pose === 'talk') {
|
|
158
|
+
const beat = BEAT * (0.75 + 0.5 * a.seed),
|
|
159
|
+
beats = t / beat + a.seed * 7,
|
|
160
|
+
at = Math.floor(beats),
|
|
161
|
+
frac = beats - at;
|
|
162
|
+
if (d.beat !== at) {
|
|
163
|
+
d.beat = at;
|
|
164
|
+
d.spoken = hash(at, a.seed * 91);
|
|
165
|
+
}
|
|
166
|
+
const pick = d.spoken,
|
|
167
|
+
s = pick < SPOKEN_REST ? SPOKEN[3] : SPOKEN[Math.floor(((pick - SPOKEN_REST) / (1 - SPOKEN_REST)) * SPOKEN.length) % SPOKEN.length],
|
|
168
|
+
anticipation = frac < 0.14 ? -Math.sin((frac / 0.14) * Math.PI) * 0.045 : 0,
|
|
169
|
+
stress = Math.max(0, Math.sin(frac * Math.PI)) ** 2; // each gesture gathers, swells, and settles
|
|
170
|
+
_to[RA] = s[0] - 0.04 * stress - anticipation;
|
|
171
|
+
_to[FR] = s[1] - 0.14 * stress + anticipation * 0.8;
|
|
172
|
+
_to[LA] = s[2];
|
|
173
|
+
_to[FL] = s[3];
|
|
174
|
+
_to[RZ] = s[4];
|
|
175
|
+
_to[RY] = s[6] * (0.65 + 0.35 * stress);
|
|
176
|
+
_to[LY] = s[2] < -0.1 ? -s[6] * 0.6 : 0;
|
|
177
|
+
_to[NOD] = s[5] * stress;
|
|
178
|
+
_to[LEAN] = 0.03 + 0.02 * stress;
|
|
179
|
+
freq = FREQ_SPOKEN;
|
|
180
|
+
if (other) {
|
|
181
|
+
_to[LA] = _to[RA];
|
|
182
|
+
_to[FL] = _to[FR];
|
|
183
|
+
_to[LZ] = -_to[RZ];
|
|
184
|
+
_to[LY] = -_to[RY];
|
|
185
|
+
_to[RA] = _to[FR] = _to[RZ] = _to[RY] = 0;
|
|
186
|
+
}
|
|
187
|
+
} else if (pose === 'guard') {
|
|
188
|
+
// on guard nobody stands still: the point weaves a little, the weight rides on bent knees, the shoulders turn to the foe
|
|
189
|
+
const s = a.seed * 40;
|
|
190
|
+
// The sword hand is held before the belt with the elbow bent and the point up towards the foe's throat, the free hand back
|
|
191
|
+
// by the hip: a blade held out at arm's length, with the other hand out beside it, is a child's guard, and puts two
|
|
192
|
+
// fighters' hands almost together.
|
|
193
|
+
_to[RA] = GUARD_WEAVE * Math.sin(t * 1.3 + s);
|
|
194
|
+
_to[FR] = GUARD_ELBOW + GUARD_WEAVE * Math.sin(t * 1.1 + s * 0.7);
|
|
195
|
+
_to[LA] = 0.5 * GUARD_WEAVE * Math.sin(t * 0.9 + s * 1.3);
|
|
196
|
+
_to[FL] = -0.55;
|
|
197
|
+
_to[LY] = 0.3;
|
|
198
|
+
_to[SINK] = -0.012 - 0.01 * Math.sin(t * 2.1 + s);
|
|
199
|
+
_to[TWIST] = -0.12 + 0.05 * Math.sin(t * 0.7 + s * 0.4);
|
|
200
|
+
_to[NOD] = 0.06;
|
|
201
|
+
freq = FREQ_HABIT;
|
|
202
|
+
} else if (pose === 'reach') {
|
|
203
|
+
// one dominant hand reaches purposefully forward while the off-hand stays bent low as a counterbalance
|
|
204
|
+
const s = a.seed * 20,
|
|
205
|
+
drift = Math.sin(t * 0.9 + s);
|
|
206
|
+
_to[RA] = -0.08 + 0.09 * drift;
|
|
207
|
+
_to[FR] = -0.34 - 0.1 * Math.cos(t * 1.15 + s);
|
|
208
|
+
_to[RY] = -0.18;
|
|
209
|
+
_to[LA] = 0.08 - 0.04 * drift;
|
|
210
|
+
_to[FL] = -0.78;
|
|
211
|
+
_to[LY] = 0.24;
|
|
212
|
+
_to[TWIST] = 0.16 + 0.03 * drift;
|
|
213
|
+
_to[LEAN] = 0.05 + 0.02 * drift;
|
|
214
|
+
_to[NOD] = 0.14;
|
|
215
|
+
if (other) {
|
|
216
|
+
_to[LA] = -0.95 + 0.09 * drift;
|
|
217
|
+
_to[FL] = _to[FR];
|
|
218
|
+
_to[LY] = 0.18;
|
|
219
|
+
_to[RA] = _to[FR] = _to[RY] = 0;
|
|
220
|
+
_to[TWIST] = -_to[TWIST];
|
|
221
|
+
}
|
|
222
|
+
} else if (pose === 'cast') {
|
|
223
|
+
// asymmetric sorcerous channeling: the lead hand shapes the working high while the off-hand anchors lower
|
|
224
|
+
const s = a.seed * 29,
|
|
225
|
+
weave = Math.sin(t * 0.95 + s),
|
|
226
|
+
pulse = Math.cos(t * 1.35 + s * 0.7);
|
|
227
|
+
_to[RA] = 0.14 * weave;
|
|
228
|
+
_to[FR] = -0.58 - 0.16 * pulse;
|
|
229
|
+
_to[RY] = -0.35 + 0.2 * weave;
|
|
230
|
+
_to[LA] = 0.12 - 0.1 * pulse;
|
|
231
|
+
_to[FL] = -1.05 + 0.14 * weave;
|
|
232
|
+
_to[LY] = 0.42;
|
|
233
|
+
_to[TWIST] = -0.14 + 0.06 * weave;
|
|
234
|
+
_to[NOD] = -0.08 + 0.04 * pulse;
|
|
235
|
+
freq = FREQ_SPOKEN;
|
|
236
|
+
} else if (pose === 'strike') {
|
|
237
|
+
// about to cut: the sword arm's elbow bent so the blade lies back over the shoulder, the body coiled away from the foe
|
|
238
|
+
_to[FR] = -1.15;
|
|
239
|
+
_to[FL] = -0.5;
|
|
240
|
+
_to[TWIST] = -0.3;
|
|
241
|
+
_to[NOD] = 0.05;
|
|
242
|
+
} else if (pose === 'cower') {
|
|
243
|
+
// asymmetric defensive cover: one forearm crossed high shielding brow and temple, the other guarding the ribs
|
|
244
|
+
const s = a.seed * 31,
|
|
245
|
+
side = a.seed >= 0.5 ? 1 : -1,
|
|
246
|
+
tremor = Math.sin(t * 6.2 + s) * 0.025;
|
|
247
|
+
_to[LA] = -0.18 + tremor;
|
|
248
|
+
_to[FL] = -1.78;
|
|
249
|
+
_to[LY] = 0.88;
|
|
250
|
+
_to[RA] = 0.08 - tremor;
|
|
251
|
+
_to[FR] = -1.54;
|
|
252
|
+
_to[RY] = -0.66;
|
|
253
|
+
_to[SHRUG] = 0.72;
|
|
254
|
+
_to[TWIST] = 0.22 * side;
|
|
255
|
+
_to[NOD] = 0.34;
|
|
256
|
+
_to[TURN] = 0.32 * side;
|
|
257
|
+
_to[TILT] = 0.14 * side;
|
|
258
|
+
} else if (pose === 'slump' || pose === 'wounded') {
|
|
259
|
+
// wounded or spent: one forearm clutched across the ribs, the other hanging slack, head bowed with heavy breaths
|
|
260
|
+
const s = a.seed * 19,
|
|
261
|
+
heave = Math.sin(t * 1.6 + s);
|
|
262
|
+
_to[LA] = -0.08;
|
|
263
|
+
_to[FL] = -1.58;
|
|
264
|
+
_to[LY] = 0.95;
|
|
265
|
+
_to[FR] = -0.34;
|
|
266
|
+
_to[TWIST] = -0.12;
|
|
267
|
+
_to[SINK] = -0.018 * heave;
|
|
268
|
+
_to[NOD] = 0.28 + 0.04 * heave;
|
|
269
|
+
_to[TILT] = 0.14;
|
|
270
|
+
freq = FREQ_SPOKEN;
|
|
271
|
+
} else if (pose === 'suspended') {
|
|
272
|
+
// held off the ground by sorcery: arched spine, arms drawn out with slack elbows, legs hanging unevenly
|
|
273
|
+
const s = a.seed * 23,
|
|
274
|
+
sway = Math.sin(t * 1.15 + s),
|
|
275
|
+
strain = Math.cos(t * 1.7 + s);
|
|
276
|
+
_to[LA] = 0.1 * sway;
|
|
277
|
+
_to[RA] = -0.08 * strain;
|
|
278
|
+
_to[FL] = -0.58 + 0.1 * strain;
|
|
279
|
+
_to[FR] = -0.44 - 0.1 * sway;
|
|
280
|
+
_to[LL] = -0.22 + 0.08 * sway;
|
|
281
|
+
_to[LR] = 0.08 - 0.07 * strain;
|
|
282
|
+
_to[NOD] = -0.28 + 0.07 * sway;
|
|
283
|
+
_to[TURN] = 0.16 * strain;
|
|
284
|
+
_to[TWIST] = 0.08 * sway;
|
|
285
|
+
freq = FREQ_SPOKEN;
|
|
286
|
+
} else if (pose === 'bound' || pose === 'crucified') {
|
|
287
|
+
// nailed or bound by the wrists along a crossbeam: head sunk on the chest, straining up only for a rare breath
|
|
288
|
+
const s = a.seed * 37,
|
|
289
|
+
lift = Math.max(0, Math.sin(t * 0.52 + s)) ** 3,
|
|
290
|
+
strain = Math.sin(t * 0.85 + s * 1.3);
|
|
291
|
+
_to[FL] = -0.18 - 0.1 * lift;
|
|
292
|
+
_to[FR] = -0.22 - 0.1 * lift;
|
|
293
|
+
_to[LL] = -0.12 - 0.12 * lift;
|
|
294
|
+
_to[LR] = -0.24 - 0.08 * lift;
|
|
295
|
+
_to[NOD] = 0.54 - 0.42 * lift;
|
|
296
|
+
_to[TURN] = 0.22 * strain;
|
|
297
|
+
_to[TILT] = 0.12;
|
|
298
|
+
_to[SHRUG] = 0.45 - 0.2 * lift;
|
|
299
|
+
freq = FREQ_HABIT;
|
|
300
|
+
} else if (pose === 'search') {
|
|
301
|
+
// rummaging through shelves, desks, or packs: one hand steadying while the other shifts and the eyes scan
|
|
302
|
+
const s = a.seed * 27,
|
|
303
|
+
scan = Math.sin(t * 0.95 + s),
|
|
304
|
+
reach = Math.cos(t * 1.45 + s);
|
|
305
|
+
_to[FL] = -0.68;
|
|
306
|
+
_to[LY] = 0.32;
|
|
307
|
+
_to[RA] = -0.16 + 0.22 * scan;
|
|
308
|
+
_to[FR] = -0.84 + 0.26 * reach;
|
|
309
|
+
_to[RY] = -0.28 + 0.2 * scan;
|
|
310
|
+
_to[TWIST] = 0.14 * scan;
|
|
311
|
+
_to[NOD] = 0.24 + 0.07 * reach;
|
|
312
|
+
_to[TURN] = 0.28 * scan;
|
|
313
|
+
freq = FREQ_SPOKEN;
|
|
314
|
+
} else if (pose === 'restrain') {
|
|
315
|
+
// braced lunge holding someone back by shoulder and chest
|
|
316
|
+
const s = a.seed * 17,
|
|
317
|
+
strain = Math.sin(t * 1.9 + s) * 0.04;
|
|
318
|
+
_to[FL] = -0.58 + strain;
|
|
319
|
+
_to[FR] = -0.76 - strain;
|
|
320
|
+
_to[LY] = 0.36;
|
|
321
|
+
_to[RY] = -0.42;
|
|
322
|
+
_to[TWIST] = -0.14;
|
|
323
|
+
_to[NOD] = 0.08;
|
|
324
|
+
} else if (pose === 'lean') {
|
|
325
|
+
// forearms resting along a rail, parapet, or table edge with unhurried weight shifts
|
|
326
|
+
const s = a.seed * 33,
|
|
327
|
+
drift = Math.sin(t * 0.48 + s);
|
|
328
|
+
_to[FL] = -1.22;
|
|
329
|
+
_to[FR] = -1.28;
|
|
330
|
+
_to[LY] = 0.52;
|
|
331
|
+
_to[RY] = -0.48;
|
|
332
|
+
_to[TWIST] = 0.07 * drift;
|
|
333
|
+
_to[NOD] = 0.06 + 0.03 * Math.cos(t * 0.62 + s);
|
|
334
|
+
_to[TILT] = 0.04 * drift;
|
|
335
|
+
freq = FREQ_HABIT;
|
|
336
|
+
} else if (pose === 'carry') {
|
|
337
|
+
// the load lies on the forearms, held against the body
|
|
338
|
+
_to[LA] = _to[RA] = 0.72;
|
|
339
|
+
_to[FL] = _to[FR] = -1.12;
|
|
340
|
+
_to[LEAN] = -0.05;
|
|
341
|
+
} else if (pose === 'point') {
|
|
342
|
+
// the arm straight out to what is shown, the other hand resting at the belt
|
|
343
|
+
_to[FR] = 0.22;
|
|
344
|
+
_to[LA] = -0.12;
|
|
345
|
+
_to[FL] = -0.85;
|
|
346
|
+
_to[LZ] = -0.1;
|
|
347
|
+
_to[LEAN] = 0.03;
|
|
348
|
+
} else if (pose === 'aim') {
|
|
349
|
+
// a crossbow levelled: the stock to the shoulder, the other hand under it, the head down to the sight
|
|
350
|
+
_to[LA] = -1.15;
|
|
351
|
+
_to[FL] = -0.75;
|
|
352
|
+
_to[LY] = 0.5;
|
|
353
|
+
_to[RA] = -1.02;
|
|
354
|
+
_to[FR] = -1.4;
|
|
355
|
+
_to[RY] = -0.35;
|
|
356
|
+
_to[TWIST] = -0.28;
|
|
357
|
+
_to[NOD] = 0.08;
|
|
358
|
+
_to[TILT] = 0.08;
|
|
359
|
+
} else if (pose === 'shoot') {
|
|
360
|
+
// a bow drawn: the bow arm straight out, the string hand back at the jaw, the body side on to the mark
|
|
361
|
+
_to[LA] = -1.5;
|
|
362
|
+
_to[FL] = -0.04;
|
|
363
|
+
_to[RA] = -1.5;
|
|
364
|
+
_to[FR] = -2.35;
|
|
365
|
+
_to[RZ] = -0.3;
|
|
366
|
+
_to[TWIST] = -0.55;
|
|
367
|
+
_to[LEAN] = -0.04;
|
|
368
|
+
} else if (pose === 'read') {
|
|
369
|
+
// a page held up in both hands, the head bent to it, the eyes going down it
|
|
370
|
+
bothArms(-0.72, -1.5, 0, 0.35);
|
|
371
|
+
_to[NOD] = 0.3 + 0.04 * Math.sin(t * 0.6 + a.seed * 9);
|
|
372
|
+
_to[TURN] = 0.07 * Math.sin(t * 1.4 + a.seed * 9);
|
|
373
|
+
} else if (pose === 'write') {
|
|
374
|
+
// the page steadied with one hand, the other moving across it and back
|
|
375
|
+
const line = (t * 0.45 + a.seed) % 1;
|
|
376
|
+
_to[LA] = -0.62;
|
|
377
|
+
_to[FL] = -1.05;
|
|
378
|
+
_to[LY] = 0.5;
|
|
379
|
+
_to[RA] = -0.66 + 0.02 * Math.sin(t * 13);
|
|
380
|
+
_to[FR] = -1.08 + 0.03 * Math.sin(t * 17);
|
|
381
|
+
_to[RY] = -0.42 + 0.3 * line;
|
|
382
|
+
_to[LEAN] = 0.16;
|
|
383
|
+
_to[NOD] = 0.34;
|
|
384
|
+
} else if (pose === 'warm') {
|
|
385
|
+
// the hands held out to a fire, turned and rubbed together now and then
|
|
386
|
+
const rub = Math.max(0, Math.sin(t * 0.5 + a.seed * 30)) ** 4;
|
|
387
|
+
bothArms(-1.02, -0.5, 0, 0.25);
|
|
388
|
+
_to[FL] -= 0.5 * rub;
|
|
389
|
+
_to[FR] -= 0.5 * rub;
|
|
390
|
+
_to[LZ] += 0.08 * rub;
|
|
391
|
+
_to[RZ] -= 0.08 * rub;
|
|
392
|
+
_to[LY] += 0.5 * rub;
|
|
393
|
+
_to[RY] -= 0.5 * rub;
|
|
394
|
+
_to[FL] += 0.1 * rub * Math.sin(t * 9);
|
|
395
|
+
_to[FR] -= 0.1 * rub * Math.sin(t * 9);
|
|
396
|
+
_to[LEAN] = 0.1;
|
|
397
|
+
_to[NOD] = 0.12;
|
|
398
|
+
} else if (pose === 'embrace') {
|
|
399
|
+
// the arms round another, the head beside theirs
|
|
400
|
+
bothArms(-1.25, -1.05, 0.1, 0.95);
|
|
401
|
+
_to[RA] = -1.4;
|
|
402
|
+
_to[LEAN] = 0.1;
|
|
403
|
+
_to[TURN] = 0.35;
|
|
404
|
+
_to[TILT] = 0.14;
|
|
405
|
+
_to[NOD] = 0.1;
|
|
406
|
+
} else if (pose === 'rest') {
|
|
407
|
+
// sitting on the ground, the forearms on the raised knees
|
|
408
|
+
bothArms(-0.95, -0.55, 0, 0.3);
|
|
409
|
+
_to[NOD] = 0.08;
|
|
410
|
+
} else if (pose === 'kneel') {
|
|
411
|
+
// on one knee: the hand of the raised knee's side rests on that knee, the arm a little bent; the other hangs by the hip
|
|
412
|
+
_to[FL] = -0.42;
|
|
413
|
+
_to[LY] = 0.15;
|
|
414
|
+
_to[FR] = -0.22;
|
|
415
|
+
_to[NOD] = 0.06;
|
|
416
|
+
freq = FREQ_HABIT;
|
|
417
|
+
} else if (pose === 'crouch') {
|
|
418
|
+
// down on the haunches, one hand to the ground
|
|
419
|
+
_to[LA] = -0.5;
|
|
420
|
+
_to[FL] = -0.3;
|
|
421
|
+
_to[RA] = -0.75;
|
|
422
|
+
_to[FR] = -1.2;
|
|
423
|
+
_to[NOD] = -0.2;
|
|
424
|
+
} else if (pose === 'crawl' || pose === 'climb') {
|
|
425
|
+
// hand over hand, and the opposite knee with each: over the ground, or up a wall, a ladder or a rope
|
|
426
|
+
const going = walking || a.move ? 1 : 0,
|
|
427
|
+
beat = Math.sin(a.phase * (pose === 'crawl' ? 0.45 : 0.6)) * going,
|
|
428
|
+
up = pose === 'climb';
|
|
429
|
+
_to[LA] = (up ? 0.45 : 0.34) * beat;
|
|
430
|
+
_to[RA] = -_to[LA];
|
|
431
|
+
_to[FL] = up ? -0.75 + 0.6 * beat : -0.1;
|
|
432
|
+
_to[FR] = up ? -0.75 - 0.6 * beat : -0.1;
|
|
433
|
+
_to[LL] = (up ? -0.55 : 0) + (up ? 0.5 : 0.3) * beat;
|
|
434
|
+
_to[LR] = (up ? -0.55 : 0) - (up ? 0.5 : 0.3) * beat;
|
|
435
|
+
_to[NOD] = up ? -0.3 : -0.55;
|
|
436
|
+
freq = 16;
|
|
437
|
+
} else if (pose === 'idle' || pose === 'walk') {
|
|
438
|
+
// nobody's arms hang quite alike: a little more or less bend at each elbow
|
|
439
|
+
_to[FL] = -0.16 * a.seed;
|
|
440
|
+
_to[FR] = -0.16 * (1 - a.seed);
|
|
441
|
+
if (pose === 'idle' && !a.mount) {
|
|
442
|
+
habit(a, t);
|
|
443
|
+
freq = FREQ_HABIT;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
stepGestureSprings(g, d.vel, _to, PARTS, dt, freq, CHANNEL_SCALE);
|
|
447
|
+
return g;
|
|
448
|
+
}
|
|
449
|
+
return { gestureOf };
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export { BEND, FL, FR, LA, LEAN, LL, LR, LY, LZ, NOD, PARTS, RA, RY, RZ, SHIFT, SHRUG, SINK, TILT, TURN, TWIST, createFigureGestures };
|