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,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auxiliary bone poses and forward-kinematics solver for the 17-bone instanced crowd rig:
|
|
3
|
+
* well windlass cranking, hanging, writhing, riding, melee combat, ready formation, fallen sprawl,
|
|
4
|
+
* kneeling (including fire-tending), ground sitting, and zero-allocation Euler bone walking.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { clamp, lerp, sstep, TAU } from '../math/scalar.js';
|
|
9
|
+
import { createHash } from '../math/random.js';
|
|
10
|
+
import { ANKLE, BOOT_HEEL, BOOT_TOE, HIPS, SHANK, THIGH } from './figure-bones.js';
|
|
11
|
+
import { solveBipedLeg } from './biped-leg.js';
|
|
12
|
+
import { CROWD_BONES } from '../geometry/crowd-weld.js';
|
|
13
|
+
|
|
14
|
+
const defaultHash = createHash(42);
|
|
15
|
+
|
|
16
|
+
/** Standard well crank axle height above ground (metres). */
|
|
17
|
+
export const WELL_CRANK = 1.45;
|
|
18
|
+
/** Standard well crank handle radius (metres). */
|
|
19
|
+
export const WELL_ARM = 0.25;
|
|
20
|
+
/** Distance (metres) a crowd figure stands in front of a well crank axle. */
|
|
21
|
+
export const WELL_STAND = 0.66;
|
|
22
|
+
|
|
23
|
+
const WELL_RAISE = 11;
|
|
24
|
+
const WELL_DROP = 3.5;
|
|
25
|
+
const WELL_TURNS = 7;
|
|
26
|
+
const wellState = { angle: 0, up: 0, turning: false };
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Evaluates a shared well windlass cycle (winding up over 11 s in 7 turns, then lowering over 3.5 s).
|
|
30
|
+
* Returns a shared scratch object `{ angle, up, turning }`.
|
|
31
|
+
*
|
|
32
|
+
* @param {number} t Clock time in seconds.
|
|
33
|
+
* @param {number} phase Per-well phase offset in seconds.
|
|
34
|
+
* @returns {{ angle: number, up: number, turning: boolean }}
|
|
35
|
+
*/
|
|
36
|
+
export function windlass(t, phase) {
|
|
37
|
+
const c = (t + phase) % (WELL_RAISE + WELL_DROP);
|
|
38
|
+
if (c < WELL_RAISE) {
|
|
39
|
+
const u = c / WELL_RAISE;
|
|
40
|
+
wellState.angle = u * WELL_TURNS * TAU;
|
|
41
|
+
wellState.up = u;
|
|
42
|
+
wellState.turning = true;
|
|
43
|
+
} else {
|
|
44
|
+
const u = sstep(0, 1, (c - WELL_RAISE) / WELL_DROP);
|
|
45
|
+
wellState.angle = (1 - u) * WELL_TURNS * TAU;
|
|
46
|
+
wellState.up = 1 - u;
|
|
47
|
+
wellState.turning = false;
|
|
48
|
+
}
|
|
49
|
+
return wellState;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const SHOULDER_Y = 1.36;
|
|
53
|
+
const UPPER_ARM = 0.3;
|
|
54
|
+
const FOREARM = 0.3;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Solves a two-bone reach placing both hands on a rotating well crank handle in front of the figure.
|
|
58
|
+
*
|
|
59
|
+
* @param {object[]} b Crowd rig bones.
|
|
60
|
+
* @param {object} head Head bone.
|
|
61
|
+
* @param {number} t Clock time in seconds.
|
|
62
|
+
* @param {number} phase Windlass phase in seconds.
|
|
63
|
+
* @param {number} [wellStand=WELL_STAND] Distance from crank axle (metres).
|
|
64
|
+
* @param {number} [wellArm=WELL_ARM] Crank radius (metres).
|
|
65
|
+
* @param {number} [wellCrank=WELL_CRANK] Crank axle height (metres).
|
|
66
|
+
* @returns {boolean} True while actively turning the crank.
|
|
67
|
+
*/
|
|
68
|
+
export function crankPose(b, head, t, phase, wellStand = WELL_STAND, wellArm = WELL_ARM, wellCrank = WELL_CRANK) {
|
|
69
|
+
const w = windlass(t, phase);
|
|
70
|
+
if (!w.turning) return false;
|
|
71
|
+
const forward = wellStand - wellArm * Math.cos(w.angle),
|
|
72
|
+
rise = wellCrank + wellArm * Math.sin(w.angle) - SHOULDER_Y,
|
|
73
|
+
reach = clamp(Math.hypot(forward, rise), 0.15, UPPER_ARM + FOREARM - 0.01),
|
|
74
|
+
bend = Math.PI - Math.acos(clamp((UPPER_ARM ** 2 + FOREARM ** 2 - reach ** 2) / (2 * UPPER_ARM * FOREARM), -1, 1)),
|
|
75
|
+
toward = Math.atan2(forward, -rise),
|
|
76
|
+
lag = Math.atan2(FOREARM * Math.sin(bend), UPPER_ARM + FOREARM * Math.cos(bend));
|
|
77
|
+
b[0].rotation.x = 0.12 + 0.06 * Math.cos(w.angle);
|
|
78
|
+
head.rotation.x = 0.2;
|
|
79
|
+
for (let i = 0; i < 2; i++) {
|
|
80
|
+
const s = i ? 1 : -1;
|
|
81
|
+
b[2 + i * 2].rotation.set(-(toward - lag), -s * 0.05, -s * 0.12);
|
|
82
|
+
b[3 + i * 2].rotation.x = -bend;
|
|
83
|
+
b[13 + i].rotation.set(-0.1, 0, 0);
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Suspended pose with arms spread and raised, head hanging, and legs straight.
|
|
90
|
+
* @param {object[]} b Crowd rig bones.
|
|
91
|
+
* @param {object} head Head bone.
|
|
92
|
+
*/
|
|
93
|
+
export function hangPose(b, head) {
|
|
94
|
+
b[0].position.set(0, 0, 0);
|
|
95
|
+
b[0].rotation.set(0.06, 0, 0);
|
|
96
|
+
head.rotation.set(0.55, 0.25, 0.1);
|
|
97
|
+
for (let i = 0; i < 2; i++) {
|
|
98
|
+
const s = i ? 1 : -1;
|
|
99
|
+
b[2 + i * 2].rotation.set(0, 0, -s * 1.95);
|
|
100
|
+
b[3 + i * 2].rotation.x = -0.12;
|
|
101
|
+
b[13 + i].rotation.set(0.3, 0, 0);
|
|
102
|
+
b[6 + i * 2].rotation.set(0.05, 0, 0);
|
|
103
|
+
b[7 + i * 2].rotation.x = 0.12;
|
|
104
|
+
b[15 + i].rotation.x = 0.55;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const WRITHE_SLOW = 0.55;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Bound-and-struggling pose with wrists raised above the head and asynchronous head/knee motion.
|
|
112
|
+
* @param {object[]} b Crowd rig bones.
|
|
113
|
+
* @param {object} head Head bone.
|
|
114
|
+
* @param {number} t Clock time in seconds.
|
|
115
|
+
* @param {number} ph Individual phase seed.
|
|
116
|
+
*/
|
|
117
|
+
export function writhePose(b, head, t, ph) {
|
|
118
|
+
const lift = Math.max(0, Math.sin(t * WRITHE_SLOW + ph)) ** 2,
|
|
119
|
+
strain = Math.sin(t * WRITHE_SLOW * 1.7 + ph * 1.3),
|
|
120
|
+
knee = Math.max(0, Math.sin(t * WRITHE_SLOW * 0.8 + ph * 0.7));
|
|
121
|
+
b[0].position.set(0, -0.02 - 0.03 * knee, 0);
|
|
122
|
+
b[0].rotation.set(0.04 - 0.05 * lift, 0.09 * strain, 0.05 * strain);
|
|
123
|
+
head.rotation.set(0.62 - 0.6 * lift, 0.35 * Math.sin(t * WRITHE_SLOW * 0.6 + ph * 2), 0.12 * strain);
|
|
124
|
+
for (let i = 0; i < 2; i++) {
|
|
125
|
+
const s = i ? 1 : -1,
|
|
126
|
+
drawn = i ? knee : 0.3 * knee;
|
|
127
|
+
b[2 + i * 2].rotation.set(0.08, 0, -s * (2.62 + 0.06 * s * strain));
|
|
128
|
+
b[3 + i * 2].rotation.x = -0.25 - 0.15 * lift;
|
|
129
|
+
b[13 + i].rotation.set(0.2, 0, 0);
|
|
130
|
+
b[6 + i * 2].rotation.set(-0.5 * drawn, 0, s * 0.06);
|
|
131
|
+
b[7 + i * 2].rotation.x = 0.1 + 0.9 * drawn;
|
|
132
|
+
b[15 + i].rotation.x = 0.5 - 0.3 * drawn;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Seated-astride-a-mount pose rocked by the mount's stride pitch `rock` (radians).
|
|
138
|
+
* @param {object[]} b Crowd rig bones.
|
|
139
|
+
* @param {object} head Head bone.
|
|
140
|
+
* @param {number} rest Idle breath sway.
|
|
141
|
+
* @param {number} shift Idle look shift.
|
|
142
|
+
* @param {number} rock Forward/back stride rock (radians).
|
|
143
|
+
*/
|
|
144
|
+
export function ridePose(b, head, rest, shift, rock) {
|
|
145
|
+
b[0].position.set(0, -0.47, 0);
|
|
146
|
+
b[0].rotation.set(0.07 + 0.02 * rest + rock, 0.05 * shift, 0);
|
|
147
|
+
head.rotation.set(0.03 - 0.6 * rock, 0.22 * shift, 0);
|
|
148
|
+
for (let i = 0; i < 2; i++) {
|
|
149
|
+
const s = i ? 1 : -1;
|
|
150
|
+
b[6 + i * 2].rotation.set(-1.0, 0, s * 0.44);
|
|
151
|
+
b[7 + i * 2].rotation.x = 1.2;
|
|
152
|
+
b[15 + i].rotation.x = -0.12;
|
|
153
|
+
b[2 + i * 2].rotation.set(-0.4, 0, -s * 0.1);
|
|
154
|
+
b[3 + i * 2].rotation.x = -0.95;
|
|
155
|
+
b[13 + i].rotation.set(-0.1, 0, 0);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const BLOWS = 0.54;
|
|
160
|
+
const PARRY_END = 0.74;
|
|
161
|
+
const STRUCK = 0.1;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Melee combat pose with four stances (shield-wall, heavy cut, point thrust, skirmisher) and
|
|
165
|
+
* asynchronous strikes, parries, and struck recoils.
|
|
166
|
+
*
|
|
167
|
+
* @param {object[]} b Crowd rig bones.
|
|
168
|
+
* @param {object} head Head bone.
|
|
169
|
+
* @param {object} g Crowd figure (`ph`, `vary`).
|
|
170
|
+
* @param {number} t Clock time in seconds.
|
|
171
|
+
* @param {number} walking Walk blend `[0, 1]`.
|
|
172
|
+
* @param {(x: number, y: number, salt?: number) => number} [hash] Seeded 2D hash returning `[0, 1)`.
|
|
173
|
+
*/
|
|
174
|
+
export function fightPose(b, head, g, t, walking, hash = defaultHash) {
|
|
175
|
+
const cadence = 0.42 + 0.46 * ((g.ph * 7.31) % 1),
|
|
176
|
+
at = t * cadence + g.ph,
|
|
177
|
+
n = Math.floor(at),
|
|
178
|
+
beat = at - n,
|
|
179
|
+
pick = hash(n, (g.ph * 13) | 0, 91),
|
|
180
|
+
blow = pick < BLOWS ? 1 : 0,
|
|
181
|
+
parry = !blow && pick < PARRY_END ? Math.sin(Math.PI * sstep(0.08, 0.78, beat)) : 0,
|
|
182
|
+
struck = pick > 1 - STRUCK ? Math.sin(Math.PI * sstep(0.1, 0.75, beat)) : 0,
|
|
183
|
+
style = (g.ph * 5.71) % 1,
|
|
184
|
+
shieldWall = style < 0.35,
|
|
185
|
+
heavyCut = style >= 0.35 && style < 0.65,
|
|
186
|
+
point = style >= 0.65 && style < 0.85,
|
|
187
|
+
wind = blow * sstep(0.05, 0.42, beat) * (1 - sstep(0.48, 0.57, beat)),
|
|
188
|
+
cut = blow * sstep(0.48, 0.57, beat) * (1 - sstep(0.72, 1, beat)),
|
|
189
|
+
weave = (1 - blow) * Math.sin(t * (1.4 + 0.8 * g.vary) + g.ph * 5);
|
|
190
|
+
|
|
191
|
+
const basePitch = shieldWall ? 0.16 : point ? 0.14 : 0.08;
|
|
192
|
+
const baseTwist = shieldWall ? 0.42 : heavyCut ? 0.22 : point ? 0.35 : 0.28;
|
|
193
|
+
b[0].rotation.x += basePitch + (point ? 0.3 : heavyCut ? 0.24 : 0.18) * cut - 0.1 * wind - 0.32 * struck + 0.08 * parry;
|
|
194
|
+
b[0].rotation.y += baseTwist - (point ? 0.35 : heavyCut ? 0.65 : 0.48) * wind + (heavyCut ? 0.32 : 0.2) * cut - 0.18 * parry;
|
|
195
|
+
head.rotation.set(0.05 + 0.08 * parry - 0.36 * struck, -baseTwist * 0.75 + 0.3 * wind, 0.15 * struck - 0.06 * parry);
|
|
196
|
+
|
|
197
|
+
if (point) {
|
|
198
|
+
b[4].rotation.set(-0.88 + 0.38 * wind - 0.72 * cut + 0.08 * weave + 0.12 * parry, 0.1, -0.15);
|
|
199
|
+
b[5].rotation.x = -1.05 - 0.9 * wind + 1.0 * cut - 0.2 * parry;
|
|
200
|
+
b[14].rotation.set(0.32 * wind - 0.28 * cut, 0, 0);
|
|
201
|
+
} else if (shieldWall) {
|
|
202
|
+
b[4].rotation.set(-0.62 - 0.85 * wind - 0.35 * cut + 0.06 * weave + 0.15 * parry, 0.22, -0.14 - 0.12 * wind);
|
|
203
|
+
b[5].rotation.x = -0.95 - 0.55 * wind + 0.75 * cut - 0.25 * parry;
|
|
204
|
+
b[14].rotation.set(-0.18 + 0.3 * wind - 0.18 * cut, 0, 0);
|
|
205
|
+
} else if (heavyCut) {
|
|
206
|
+
b[4].rotation.set(-0.78 - 1.95 * wind + 0.35 * cut + 0.09 * weave, 0.12, -0.22 - 0.38 * wind);
|
|
207
|
+
b[5].rotation.x = -0.35 - 0.95 * wind + 0.15 * cut;
|
|
208
|
+
b[14].rotation.set(-0.38 + 0.55 * wind - 0.12 * cut, 0, 0);
|
|
209
|
+
} else {
|
|
210
|
+
b[4].rotation.set(-0.92 - 1.25 * wind + 0.18 * cut + 0.16 * weave - 0.2 * parry, 0.18, -0.28 - 0.24 * wind);
|
|
211
|
+
b[5].rotation.x = -0.62 - 0.65 * wind + 0.45 * cut - 0.3 * parry;
|
|
212
|
+
b[14].rotation.set(-0.22 + 0.38 * wind, 0, 0);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const shieldLift = (shieldWall ? -0.78 : -0.52) - 0.38 * parry - 0.48 * struck + 0.12 * wind;
|
|
216
|
+
const shieldAcross = (shieldWall ? 0.98 : 0.78) + 0.22 * parry - 0.2 * wind;
|
|
217
|
+
b[2].rotation.set(shieldLift, shieldAcross, (shieldWall ? 0.05 : 0.14) + 0.38 * struck - 0.12 * parry);
|
|
218
|
+
b[3].rotation.x = (shieldWall ? -1.48 : -1.24) + 0.2 * cut + 0.58 * struck - 0.16 * parry;
|
|
219
|
+
|
|
220
|
+
if (walking > 0.5) return;
|
|
221
|
+
const lunge = point ? cut : shieldWall ? 0.55 * cut : 0.45 * cut;
|
|
222
|
+
const crouch = (shieldWall ? 0.09 : 0.055) + 0.055 * lunge + 0.045 * parry;
|
|
223
|
+
b[0].position.y -= crouch;
|
|
224
|
+
b[0].position.z += 0.09 * lunge - 0.065 * struck - 0.03 * parry;
|
|
225
|
+
b[6].rotation.x = -0.42 - 0.12 * (shieldWall ? 1 : 0) - 0.32 * lunge - 0.12 * parry;
|
|
226
|
+
b[7].rotation.x = 0.52 + 0.14 * (shieldWall ? 1 : 0) + 0.32 * lunge + 0.14 * parry;
|
|
227
|
+
b[15].rotation.x = -0.1;
|
|
228
|
+
b[8].rotation.x = 0.18 + 0.16 * lunge;
|
|
229
|
+
b[9].rotation.x = 0.34 + 0.12 * lunge + 0.08 * parry;
|
|
230
|
+
b[16].rotation.x = -0.48;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Armed formation-ready stance with varied shield heights, weapon rests, and alert weight shifts.
|
|
235
|
+
* @param {object[]} b Crowd rig bones.
|
|
236
|
+
* @param {object} head Head bone.
|
|
237
|
+
* @param {object} g Crowd figure (`ph`, `vary`).
|
|
238
|
+
* @param {number} t Clock time in seconds.
|
|
239
|
+
* @param {number} walking Walk blend `[0, 1]`.
|
|
240
|
+
*/
|
|
241
|
+
export function readyPose(b, head, g, t, walking) {
|
|
242
|
+
if (walking > 0.45) {
|
|
243
|
+
b[2].rotation.x = lerp(b[2].rotation.x, -0.42, walking);
|
|
244
|
+
b[2].rotation.y = lerp(b[2].rotation.y, 0.45, walking);
|
|
245
|
+
b[3].rotation.x = lerp(b[3].rotation.x, -0.85, walking);
|
|
246
|
+
b[4].rotation.x = lerp(b[4].rotation.x, -0.25, walking);
|
|
247
|
+
b[5].rotation.x = lerp(b[5].rotation.x, -0.55, walking);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const breath = Math.sin(t * (0.85 + 0.35 * g.vary) + g.ph),
|
|
251
|
+
scan = Math.sin(t * (0.35 + 0.2 * g.vary) + g.ph * 2.3),
|
|
252
|
+
stance = (g.ph * 4.13) % 1;
|
|
253
|
+
const braced = stance < 0.38,
|
|
254
|
+
relaxed = stance >= 0.72;
|
|
255
|
+
b[0].position.y -= braced ? 0.045 : relaxed ? 0.01 : 0.025;
|
|
256
|
+
b[0].rotation.x += (braced ? 0.07 : 0.03) + 0.018 * breath;
|
|
257
|
+
b[0].rotation.y += (braced ? 0.24 : relaxed ? -0.08 : 0.12) + 0.04 * scan;
|
|
258
|
+
head.rotation.set(0.02 + 0.04 * breath, 0.22 * scan - (braced ? 0.15 : 0), 0.02 * breath);
|
|
259
|
+
|
|
260
|
+
b[2].rotation.set(braced ? -0.56 : relaxed ? -0.22 : -0.38, braced ? 0.76 : relaxed ? 0.28 : 0.52, braced ? 0.08 : -0.14);
|
|
261
|
+
b[3].rotation.x = (braced ? -1.28 : relaxed ? -0.52 : -0.92) + 0.04 * breath;
|
|
262
|
+
|
|
263
|
+
if (braced) {
|
|
264
|
+
b[4].rotation.set(-0.62 + 0.04 * breath, 0.12, -0.18);
|
|
265
|
+
b[5].rotation.x = -0.85;
|
|
266
|
+
b[14].rotation.set(-0.12, 0, 0);
|
|
267
|
+
} else if (relaxed) {
|
|
268
|
+
b[4].rotation.set(-0.18 + 0.03 * breath, 0.05, 0.22);
|
|
269
|
+
b[5].rotation.x = -0.36;
|
|
270
|
+
b[14].rotation.set(0.08, 0, 0);
|
|
271
|
+
} else {
|
|
272
|
+
b[4].rotation.set(-0.92 + 0.05 * breath, 0.08, -0.12);
|
|
273
|
+
b[5].rotation.x = -1.25;
|
|
274
|
+
b[14].rotation.set(0.18, 0, 0);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const lead = braced ? 0.22 : 0.1;
|
|
278
|
+
b[6].rotation.x = -lead;
|
|
279
|
+
b[7].rotation.x = lead * 1.35;
|
|
280
|
+
b[15].rotation.x = -lead * 0.35;
|
|
281
|
+
b[8].rotation.x = lead * 0.55;
|
|
282
|
+
b[9].rotation.x = lead * 0.65;
|
|
283
|
+
b[16].rotation.x = -lead * 0.9;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Uneven fallen casualty sprawl blended onto the current pose as `g.fall` increases.
|
|
288
|
+
* @param {object[]} b Crowd rig bones.
|
|
289
|
+
* @param {object} head Head bone.
|
|
290
|
+
* @param {object} g Crowd figure (`ph`, `vary`, `fall`).
|
|
291
|
+
* @param {number} blend Sprawl blend weight `[0, 1]`.
|
|
292
|
+
*/
|
|
293
|
+
export function fallenPose(b, head, g, blend) {
|
|
294
|
+
const s1 = Math.sin(g.ph * 3.17),
|
|
295
|
+
s2 = Math.cos(g.ph * 5.43),
|
|
296
|
+
faceDown = g.fall < 0;
|
|
297
|
+
b[0].rotation.x = lerp(b[0].rotation.x, faceDown ? 0.08 : -0.05, blend);
|
|
298
|
+
b[0].rotation.y = lerp(b[0].rotation.y, 0.28 * s1, blend);
|
|
299
|
+
head.rotation.x = lerp(head.rotation.x, faceDown ? -0.25 : 0.22, blend);
|
|
300
|
+
head.rotation.y = lerp(head.rotation.y, (0.55 + 0.35 * Math.abs(s2)) * (s1 >= 0 ? 1 : -1), blend);
|
|
301
|
+
head.rotation.z = lerp(head.rotation.z, 0.18 * s2, blend);
|
|
302
|
+
|
|
303
|
+
b[2].rotation.set(
|
|
304
|
+
lerp(b[2].rotation.x, -0.35 - 0.55 * Math.abs(s1), blend),
|
|
305
|
+
lerp(b[2].rotation.y, 0.25 * s2, blend),
|
|
306
|
+
lerp(b[2].rotation.z, -0.55 - 0.65 * g.vary, blend),
|
|
307
|
+
);
|
|
308
|
+
b[3].rotation.x = lerp(b[3].rotation.x, -0.45 - 0.75 * Math.abs(s2), blend);
|
|
309
|
+
b[4].rotation.set(
|
|
310
|
+
lerp(b[4].rotation.x, -0.25 - 0.8 * g.vary, blend),
|
|
311
|
+
lerp(b[4].rotation.y, -0.2 * s1, blend),
|
|
312
|
+
lerp(b[4].rotation.z, 0.45 + 0.75 * Math.abs(s1), blend),
|
|
313
|
+
);
|
|
314
|
+
b[5].rotation.x = lerp(b[5].rotation.x, -0.3 - 0.85 * g.vary, blend);
|
|
315
|
+
|
|
316
|
+
const drawLeft = s1 > 0;
|
|
317
|
+
const kneeBend = 0.35 + 0.75 * g.vary;
|
|
318
|
+
b[6].rotation.set(
|
|
319
|
+
lerp(b[6].rotation.x, drawLeft ? -kneeBend * 0.55 : -0.08, blend),
|
|
320
|
+
0,
|
|
321
|
+
lerp(b[6].rotation.z, -0.14 - 0.16 * g.vary, blend),
|
|
322
|
+
);
|
|
323
|
+
b[7].rotation.x = lerp(b[7].rotation.x, drawLeft ? kneeBend : 0.15, blend);
|
|
324
|
+
b[8].rotation.set(
|
|
325
|
+
lerp(b[8].rotation.x, drawLeft ? -0.1 : -kneeBend * 0.55, blend),
|
|
326
|
+
0,
|
|
327
|
+
lerp(b[8].rotation.z, 0.14 + 0.16 * Math.abs(s2), blend),
|
|
328
|
+
);
|
|
329
|
+
b[9].rotation.x = lerp(b[9].rotation.x, drawLeft ? 0.18 : kneeBend, blend);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const KNEEL = { thigh: 0.35, shin: 0.06, foot: 0.8, drop: 0.47, bow: 0.22, head: 0.32, cloak: 0.75 };
|
|
333
|
+
const FEED = { arm: [-0.9, 0.06], fore: -0.5, wrist: [0.15, 1.45] };
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Kneeling pose on open ground; when `firewood` is true, reaches forward with the right hand to tend a fire.
|
|
337
|
+
* @param {object[]} b Crowd rig bones.
|
|
338
|
+
* @param {object} head Head bone.
|
|
339
|
+
* @param {object|null} cloak Cloak bone, if present.
|
|
340
|
+
* @param {number} rest Idle breath sway.
|
|
341
|
+
* @param {number} shift Idle look shift.
|
|
342
|
+
* @param {boolean} [firewood=false] True to reach forward holding firewood.
|
|
343
|
+
*/
|
|
344
|
+
export function kneelPose(b, head, cloak, rest, shift, firewood = false) {
|
|
345
|
+
const bow = KNEEL.bow + 0.03 * rest;
|
|
346
|
+
b[0].position.set(0, -KNEEL.drop, 0.02);
|
|
347
|
+
b[0].rotation.set(bow, 0.04 * shift, 0);
|
|
348
|
+
head.rotation.set(KNEEL.head + 0.04 * rest, 0.08 * shift, 0);
|
|
349
|
+
for (let i = 0; i < 2; i++) {
|
|
350
|
+
const s = i ? 1 : -1;
|
|
351
|
+
b[6 + i * 2].rotation.set(-KNEEL.thigh - bow, 0, s * 0.06);
|
|
352
|
+
b[7 + i * 2].rotation.x = Math.PI / 2 + KNEEL.thigh - KNEEL.shin;
|
|
353
|
+
b[15 + i].rotation.x = KNEEL.foot;
|
|
354
|
+
b[2 + i * 2].rotation.set(-0.3, -s * 0.1, -s * 0.12);
|
|
355
|
+
b[3 + i * 2].rotation.x = -0.75 - 0.04 * rest;
|
|
356
|
+
b[13 + i].rotation.set(-0.1, 0, 0);
|
|
357
|
+
}
|
|
358
|
+
if (firewood) {
|
|
359
|
+
b[4].rotation.set(FEED.arm[0] + 0.05 * rest, 0, -FEED.arm[1]);
|
|
360
|
+
b[5].rotation.x = FEED.fore;
|
|
361
|
+
b[14].rotation.set(FEED.wrist[0], FEED.wrist[1], 0);
|
|
362
|
+
}
|
|
363
|
+
if (cloak) cloak.rotation.set(KNEEL.cloak, 0, 0);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** Shared rigid-boot leg rig constants used by crowd gait and ground-sitting poses. */
|
|
367
|
+
export const CROWD_LEG_RIG = { thigh: THIGH, shin: SHANK, ankleHeight: ANKLE, heelOffset: BOOT_HEEL, ballOffset: BOOT_TOE };
|
|
368
|
+
|
|
369
|
+
const GROUND = { drop: 0.82, ankle: 0.42, lean: 0.3, splay: 0.16, cloak: 0.9 };
|
|
370
|
+
const GROUND_LEG = [0, 0];
|
|
371
|
+
solveBipedLeg(GROUND_LEG, CROWD_LEG_RIG, GROUND.ankle, GROUND.drop - (HIPS - ANKLE));
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Sitting on bare ground with knees drawn up and forearms resting over them.
|
|
375
|
+
* @param {object[]} b Crowd rig bones.
|
|
376
|
+
* @param {object} head Head bone.
|
|
377
|
+
* @param {object|null} cloak Cloak bone, if present.
|
|
378
|
+
* @param {number} rest Idle breath sway.
|
|
379
|
+
* @param {number} shift Idle look shift.
|
|
380
|
+
*/
|
|
381
|
+
export function groundPose(b, head, cloak, rest, shift) {
|
|
382
|
+
const lean = GROUND.lean + 0.03 * rest;
|
|
383
|
+
b[0].position.set(0, -GROUND.drop, 0);
|
|
384
|
+
b[0].rotation.set(lean, 0.05 * shift, 0);
|
|
385
|
+
head.rotation.set(0.08 + 0.05 * rest, 0.16 * shift, 0.03 * rest);
|
|
386
|
+
for (let i = 0; i < 2; i++) {
|
|
387
|
+
const s = i ? 1 : -1;
|
|
388
|
+
b[6 + i * 2].rotation.set(GROUND_LEG[0] - lean, 0, s * GROUND.splay);
|
|
389
|
+
b[7 + i * 2].rotation.x = GROUND_LEG[1];
|
|
390
|
+
b[15 + i].rotation.x = -GROUND_LEG[0] - GROUND_LEG[1];
|
|
391
|
+
b[2 + i * 2].rotation.set(-0.55 - 0.04 * i, -s * 0.1, -s * 0.2);
|
|
392
|
+
b[3 + i * 2].rotation.x = -0.85 - 0.06 * rest;
|
|
393
|
+
b[13 + i].rotation.set(0.1, 0, 0);
|
|
394
|
+
}
|
|
395
|
+
if (cloak) cloak.rotation.set(GROUND.cloak, 0, 0);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const _local = new Float64Array(9);
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Evaluates world-space transforms (three basis columns + translation, 12 numbers per bone)
|
|
402
|
+
* for all 17 bones of a crowd rig using plain XYZ Euler angles, writing into `out`.
|
|
403
|
+
*
|
|
404
|
+
* @param {{ bones: object[], parentOf: number[], order: number[], base: { elements: ArrayLike<number> } }} rig Crowd rig (`crowdRig`).
|
|
405
|
+
* @param {Float64Array} out Output buffer of length at least `CROWD_BONES * 12`.
|
|
406
|
+
*/
|
|
407
|
+
export function walkBones(rig, out) {
|
|
408
|
+
const { bones, parentOf, order, base } = rig,
|
|
409
|
+
W = out,
|
|
410
|
+
L = _local,
|
|
411
|
+
P = base.elements;
|
|
412
|
+
for (let n = 0; n < CROWD_BONES; n++) {
|
|
413
|
+
const i = order[n],
|
|
414
|
+
bone = bones[i],
|
|
415
|
+
r = bone.rotation,
|
|
416
|
+
p = bone.position,
|
|
417
|
+
sc = bone.scale,
|
|
418
|
+
a = r.x ? Math.cos(r.x) : 1,
|
|
419
|
+
b = r.x ? Math.sin(r.x) : 0,
|
|
420
|
+
c = r.y ? Math.cos(r.y) : 1,
|
|
421
|
+
d = r.y ? Math.sin(r.y) : 0,
|
|
422
|
+
e = r.z ? Math.cos(r.z) : 1,
|
|
423
|
+
f = r.z ? Math.sin(r.z) : 0,
|
|
424
|
+
ae = a * e,
|
|
425
|
+
af = a * f,
|
|
426
|
+
be = b * e,
|
|
427
|
+
bf = b * f;
|
|
428
|
+
L[0] = c * e * sc.x;
|
|
429
|
+
L[1] = (af + be * d) * sc.x;
|
|
430
|
+
L[2] = (bf - ae * d) * sc.x;
|
|
431
|
+
L[3] = -c * f * sc.y;
|
|
432
|
+
L[4] = (ae - bf * d) * sc.y;
|
|
433
|
+
L[5] = (be + af * d) * sc.y;
|
|
434
|
+
L[6] = d * sc.z;
|
|
435
|
+
L[7] = -b * c * sc.z;
|
|
436
|
+
L[8] = a * c * sc.z;
|
|
437
|
+
const up = parentOf[i],
|
|
438
|
+
o = i * 12;
|
|
439
|
+
let x0, x1, x2, y0, y1, y2, z0, z1, z2, t0, t1, t2;
|
|
440
|
+
if (up < 0) {
|
|
441
|
+
x0 = P[0];
|
|
442
|
+
x1 = P[1];
|
|
443
|
+
x2 = P[2];
|
|
444
|
+
y0 = P[4];
|
|
445
|
+
y1 = P[5];
|
|
446
|
+
y2 = P[6];
|
|
447
|
+
z0 = P[8];
|
|
448
|
+
z1 = P[9];
|
|
449
|
+
z2 = P[10];
|
|
450
|
+
t0 = P[12];
|
|
451
|
+
t1 = P[13];
|
|
452
|
+
t2 = P[14];
|
|
453
|
+
} else {
|
|
454
|
+
const q = up * 12;
|
|
455
|
+
x0 = W[q];
|
|
456
|
+
x1 = W[q + 1];
|
|
457
|
+
x2 = W[q + 2];
|
|
458
|
+
y0 = W[q + 3];
|
|
459
|
+
y1 = W[q + 4];
|
|
460
|
+
y2 = W[q + 5];
|
|
461
|
+
z0 = W[q + 6];
|
|
462
|
+
z1 = W[q + 7];
|
|
463
|
+
z2 = W[q + 8];
|
|
464
|
+
t0 = W[q + 9];
|
|
465
|
+
t1 = W[q + 10];
|
|
466
|
+
t2 = W[q + 11];
|
|
467
|
+
}
|
|
468
|
+
for (let col = 0; col < 3; col++) {
|
|
469
|
+
const lx = L[col * 3],
|
|
470
|
+
ly = L[col * 3 + 1],
|
|
471
|
+
lz = L[col * 3 + 2],
|
|
472
|
+
k = o + col * 3;
|
|
473
|
+
W[k] = x0 * lx + y0 * ly + z0 * lz;
|
|
474
|
+
W[k + 1] = x1 * lx + y1 * ly + z1 * lz;
|
|
475
|
+
W[k + 2] = x2 * lx + y2 * ly + z2 * lz;
|
|
476
|
+
}
|
|
477
|
+
W[o + 9] = x0 * p.x + y0 * p.y + z0 * p.z + t0;
|
|
478
|
+
W[o + 10] = x1 * p.x + y1 * p.y + z1 * p.z + t1;
|
|
479
|
+
W[o + 11] = x2 * p.x + y2 * p.y + z2 * p.z + t2;
|
|
480
|
+
}
|
|
481
|
+
}
|
package/motion/crowd-routine.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { wrapRadians } from '../math/periodic.js';
|
|
1
2
|
import { sstep } from '../math/scalar.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -26,13 +27,24 @@ export function walkRound(points, speed, { retrace = false, clearAt, rng: random
|
|
|
26
27
|
if (!points.length || !Number.isFinite(speed) || speed <= 0) throw new RangeError('Expected waypoints and a positive walking speed');
|
|
27
28
|
const seq = retrace ? points.concat(points.slice(1, -1).reverse()) : points;
|
|
28
29
|
const legs = [];
|
|
29
|
-
let time = 0,
|
|
30
|
+
let time = 0,
|
|
31
|
+
distance = 0;
|
|
30
32
|
for (let i = 0; i < seq.length; i++) {
|
|
31
|
-
const startPoint = seq[i],
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const startPoint = seq[i],
|
|
34
|
+
endPoint = seq[(i + 1) % seq.length];
|
|
35
|
+
if (
|
|
36
|
+
!Number.isFinite(startPoint.x) ||
|
|
37
|
+
!Number.isFinite(startPoint.z) ||
|
|
38
|
+
!Number.isFinite(endPoint.x) ||
|
|
39
|
+
!Number.isFinite(endPoint.z) ||
|
|
40
|
+
!Number.isFinite(endPoint.w ?? 0) ||
|
|
41
|
+
(endPoint.w ?? 0) < 0
|
|
42
|
+
)
|
|
43
|
+
throw new RangeError('Invalid waypoint');
|
|
44
|
+
const dx = endPoint.x - startPoint.x,
|
|
45
|
+
dz = endPoint.z - startPoint.z;
|
|
46
|
+
const len = Math.hypot(dx, dz),
|
|
47
|
+
tw = len / speed;
|
|
36
48
|
if (clearAt) {
|
|
37
49
|
const steps = Math.max(1, Math.ceil(len / 0.5));
|
|
38
50
|
for (let j = 0; j <= steps; j++) {
|
|
@@ -40,16 +52,37 @@ export function walkRound(points, speed, { retrace = false, clearAt, rng: random
|
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
legs.push({
|
|
43
|
-
x0: startPoint.x,
|
|
44
|
-
|
|
55
|
+
x0: startPoint.x,
|
|
56
|
+
z0: startPoint.z,
|
|
57
|
+
dx,
|
|
58
|
+
dz,
|
|
59
|
+
len,
|
|
60
|
+
travel: distance,
|
|
61
|
+
t0: time,
|
|
62
|
+
tw,
|
|
63
|
+
dir: Math.atan2(dx, dz),
|
|
64
|
+
yaw: endPoint.yaw,
|
|
65
|
+
hide: endPoint.hide,
|
|
66
|
+
start: startPoint.w > 0,
|
|
67
|
+
stop: endPoint.w > 0,
|
|
68
|
+
role: endPoint.role,
|
|
45
69
|
});
|
|
46
70
|
time += tw + (endPoint.w || 0);
|
|
47
71
|
distance += len;
|
|
48
72
|
}
|
|
49
73
|
const { x, z } = seq[0];
|
|
50
74
|
return {
|
|
51
|
-
ax: x,
|
|
52
|
-
|
|
75
|
+
ax: x,
|
|
76
|
+
az: z,
|
|
77
|
+
bx: x,
|
|
78
|
+
bz: z,
|
|
79
|
+
sp: 0,
|
|
80
|
+
walkSpeed: speed,
|
|
81
|
+
legs: time ? legs : null,
|
|
82
|
+
distance,
|
|
83
|
+
T: time,
|
|
84
|
+
ph: random ? random() * time : 0,
|
|
85
|
+
s: random ? size + random() * spread : size,
|
|
53
86
|
};
|
|
54
87
|
}
|
|
55
88
|
|
|
@@ -201,12 +234,9 @@ export function createWalkFit({ collideIn, hit, onDeck, worldSpace }, { body = 0
|
|
|
201
234
|
};
|
|
202
235
|
}
|
|
203
236
|
|
|
204
|
-
// Kept for applications importing the crowd selector from its original module.
|
|
205
|
-
export { detailLevel } from '../rendering/detail-range.js';
|
|
206
|
-
|
|
207
237
|
/** Turns a heading `dir` towards `want` at `rate` a second over `gap` seconds, at once after a gap of more than `snap` seconds. */
|
|
208
238
|
export function easeHeading(dir, want, gap, rate, snap = 0.2) {
|
|
209
239
|
if (gap > snap || gap < 0) return want;
|
|
210
240
|
const turn = want - dir;
|
|
211
|
-
return dir +
|
|
241
|
+
return dir + wrapRadians(turn) * Math.min(1, gap * rate);
|
|
212
242
|
}
|