roamwright 0.20.1 → 0.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 +139 -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/cast-actors.js +379 -0
- package/motion/cast-manager.js +321 -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 +46 -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/cast-stage.js +299 -0
- 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/nameplate-groups.js +84 -0
- package/rendering/nameplates.js +386 -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,154 @@
|
|
|
1
|
+
import { NO_ANIMAL_OPTIONS } from '../geometry/animal-options.js';
|
|
2
|
+
import { buildCamel } from '../rendering/animal-camel-figure.js';
|
|
3
|
+
import { buildCattle } from '../rendering/animal-cattle-figure.js';
|
|
4
|
+
import { canineHerd } from './animal-canine-cast.js';
|
|
5
|
+
import { gatherPlan, gatherWith } from '../geometry/grid-gather.js';
|
|
6
|
+
import { henHerd } from '../geometry/animal-hen.js';
|
|
7
|
+
import { castBeast, herdFrames } from './animal-bearing.js';
|
|
8
|
+
import { rigHorse } from '../rendering/animal-horse-figure.js';
|
|
9
|
+
|
|
10
|
+
// A herd uses the middle skin even from the air: the visitor can walk among these same instances. A herd may be drawn in lighter
|
|
11
|
+
// levels further off, its far skin as it is or gathered on a grid (geometry/grid-gather.js).
|
|
12
|
+
const DETAIL = 1;
|
|
13
|
+
|
|
14
|
+
// A herd's beast of the four-legged kinds the horse's bearing poses (animal-bearing.js): a camel for the build 'camel' (and with a
|
|
15
|
+
// caravan's load, 'pack camel'), cattle of `build` when coat is null, else an unsaddled horse of that coat. Its skins: the middle
|
|
16
|
+
// one, and the far one only if a level is drawn from it.
|
|
17
|
+
function hoofedHerd({ build, coat, speed, moments, levels }, options) {
|
|
18
|
+
const detail = [DETAIL, levels.some(l => l.skin) ? 0 : DETAIL],
|
|
19
|
+
H =
|
|
20
|
+
build === 'camel' || build === 'pack camel'
|
|
21
|
+
? buildCamel(detail, build === 'pack camel', options)
|
|
22
|
+
: coat === null
|
|
23
|
+
? buildCattle(build, detail, options)
|
|
24
|
+
: rigHorse(null, coat, 0x6a2a26, false, build, false, detail, null, options);
|
|
25
|
+
return {
|
|
26
|
+
skins: [H.near, H.far],
|
|
27
|
+
skin: k => castBeast(H, k ? H.far : H.near),
|
|
28
|
+
frames: cast => {
|
|
29
|
+
const { heads, walk } = herdFrames(H, speed, moments, 4, cast);
|
|
30
|
+
return { rests: [heads], walk };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The beast a herd's input names: a hen, a canine of a look (a street dog, a cat), or one of the hoofed kinds.
|
|
36
|
+
const sourceOf = (input, options) =>
|
|
37
|
+
input.build === 'hen' ? henHerd(input) : input.look ? canineHerd(input, options) : hoofedHerd(input, options);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A herd's beast cast as arrays, on a pool's workers or on the page where there are none: its levels, each with what every pose
|
|
41
|
+
* of it shares (colours and tags), its rests (each a series of poses from standing to the full of what it does at a halt:
|
|
42
|
+
* grazing, nosing at the ground, sitting, lying, pecking, settling), the moments of its walk at `speed` (metres a second), and
|
|
43
|
+
* its distance. Only positions, normals and bounds change with a pose.
|
|
44
|
+
* @param {object} input The beast: `build` ('hen', 'camel', 'pack camel', a cattle build with `coat` null, or a horse build with
|
|
45
|
+
* its coat), or a canine's `look` with its `size` and `rests`; its `speed` and walk's `moments`; and its `levels`, each
|
|
46
|
+
* { skin: 0 near or 1 far, cell: metres of the grid it is gathered on or none, from: metres off beyond which it is drawn,
|
|
47
|
+
* most: how many of a herd it draws at once, the rest going on to the next level (optional) }.
|
|
48
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options]
|
|
49
|
+
*/
|
|
50
|
+
function herdArrays(input, options = NO_ANIMAL_OPTIONS) {
|
|
51
|
+
const source = sourceOf(input, options),
|
|
52
|
+
levels = input.levels,
|
|
53
|
+
plans = levels.map(l => (l.cell ? gatherPlan(source.skins[l.skin], l.cell) : null)),
|
|
54
|
+
welds = levels.map((l, i) => (plans[i] ? null : weldOf(source.skins[l.skin]))),
|
|
55
|
+
// every level of the pose the source is in now, each skin cast once
|
|
56
|
+
cast = () => {
|
|
57
|
+
const skins = [];
|
|
58
|
+
return levels.map((l, i) => {
|
|
59
|
+
const geo = (skins[l.skin] ??= source.skin(l.skin));
|
|
60
|
+
return plans[i] ? gatherWith(plans[i], geo) : geo;
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
{ rests, walk } = source.frames(cast);
|
|
64
|
+
// a skin not on bones (a hen's) is built anew for each pose: its weld stands only if it holds in every one
|
|
65
|
+
levels.forEach((l, k) => {
|
|
66
|
+
if (
|
|
67
|
+
welds[k] &&
|
|
68
|
+
!welds[k].boned &&
|
|
69
|
+
!rests
|
|
70
|
+
.flat()
|
|
71
|
+
.concat(walk.frames)
|
|
72
|
+
.every(pose => holds(welds[k], pose[k]))
|
|
73
|
+
)
|
|
74
|
+
welds[k] = null;
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
levels: levels.map((l, k) => ({
|
|
78
|
+
...skinArrays(null, rests[0][0][k], welds[k]),
|
|
79
|
+
rests: rests.map(series => series.map(pose => packPose(pose[k], welds[k]))),
|
|
80
|
+
walk: { frames: walk.frames.map(pose => packPose(pose[k], welds[k])), stride: walk.stride },
|
|
81
|
+
from: l.from,
|
|
82
|
+
most: l.most ?? Infinity,
|
|
83
|
+
})),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The points of a skin that are one point: the same place, normal, colour, tag and bones (a beast's tubes repeat each point of
|
|
88
|
+
// their grid for every triangle that meets there), and so, on bones, the same in every pose. Gives the first of each (first),
|
|
89
|
+
// each point's number among those (index), and whether the skin is on bones (boned: else see holds).
|
|
90
|
+
function weldOf(geo) {
|
|
91
|
+
const A = geo.attributes,
|
|
92
|
+
arrays = ['position', 'normal', 'color', 'aTag', 'skinIndex', 'skinWeight'].filter(name => A[name]).map(name => A[name]),
|
|
93
|
+
n = A.position.count,
|
|
94
|
+
ids = new Map(),
|
|
95
|
+
first = [],
|
|
96
|
+
at = new Uint32Array(n);
|
|
97
|
+
for (let i = 0; i < n; i++) {
|
|
98
|
+
let key = '';
|
|
99
|
+
for (const a of arrays) for (let c = 0; c < a.itemSize; c++) key += a.array[i * a.itemSize + c] + ',';
|
|
100
|
+
let id = ids.get(key);
|
|
101
|
+
if (id === undefined) {
|
|
102
|
+
id = first.length;
|
|
103
|
+
ids.set(key, id);
|
|
104
|
+
first.push(i);
|
|
105
|
+
}
|
|
106
|
+
at[i] = id;
|
|
107
|
+
}
|
|
108
|
+
return { first: Uint32Array.from(first), index: first.length < 65535 ? Uint16Array.from(at) : at, at, boned: !!A.skinIndex };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Whether a pose keeps a weld: every point where the first of its kind is, and turned the same way.
|
|
112
|
+
function holds(weld, geo) {
|
|
113
|
+
const { position, normal } = geo.attributes,
|
|
114
|
+
{ first, at } = weld;
|
|
115
|
+
for (let i = 0; i < at.length; i++) {
|
|
116
|
+
const f = first[at[i]];
|
|
117
|
+
for (let c = 0; c < 3; c++)
|
|
118
|
+
if (position.array[i * 3 + c] !== position.array[f * 3 + c] || normal.array[i * 3 + c] !== normal.array[f * 3 + c]) return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// An attribute's array at the welded points only (all of it, without a weld).
|
|
124
|
+
function welded(attribute, weld) {
|
|
125
|
+
if (!weld) return attribute.array;
|
|
126
|
+
const s = attribute.itemSize,
|
|
127
|
+
src = attribute.array,
|
|
128
|
+
out = new src.constructor(weld.first.length * s);
|
|
129
|
+
weld.first.forEach((i, k) => {
|
|
130
|
+
for (let c = 0; c < s; c++) out[k * s + c] = src[i * s + c];
|
|
131
|
+
});
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// One cast pose as the arrays that change with a pose: positions, normals and its bounds; at the welded points, with a weld.
|
|
136
|
+
function packPose(geo, weld = null) {
|
|
137
|
+
geo.computeBoundingSphere();
|
|
138
|
+
const { center, radius } = geo.boundingSphere;
|
|
139
|
+
return {
|
|
140
|
+
position: welded(geo.attributes.position, weld),
|
|
141
|
+
normal: welded(geo.attributes.normal, weld),
|
|
142
|
+
sphere: [center.x, center.y, center.z, radius],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// What every pose of a beast's skin shares: its colours and tags (of its far skin, or of the geometry given); with a weld, at its
|
|
146
|
+
// points, and the triangles' index into them.
|
|
147
|
+
function skinArrays(beast, geo = beast.far, weld = null) {
|
|
148
|
+
const { color, aTag } = geo.attributes,
|
|
149
|
+
shared = { color: welded(color, weld), aTag: welded(aTag, weld) };
|
|
150
|
+
if (weld) shared.index = weld.index;
|
|
151
|
+
return shared;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { herdArrays, packPose, skinArrays, weldOf };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { EYE_TAG } from '../geometry/animal-skin.js';
|
|
3
|
+
import { NO_ANIMAL_OPTIONS, cachePerOptions } from '../geometry/animal-options.js';
|
|
4
|
+
import { rigHorse } from '../rendering/animal-horse-figure.js';
|
|
5
|
+
import { horsePose } from './animal-bearing.js';
|
|
6
|
+
|
|
7
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
8
|
+
// A horse that does not move, written into a builder of plain geometry (a camp's, a battlefield's): the same horse a
|
|
9
|
+
// rider sits, posed on its skeleton and cast. At a picket line it stands as horses stand: a hind leg rested, an ear
|
|
10
|
+
// turned, its head up or down at its fodder; on a battlefield it lies on its side.
|
|
11
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
12
|
+
const MODELS = 3, // horses to cast from, each with its own white markings
|
|
13
|
+
POINTS = [0.03, 0.026, 0.024],
|
|
14
|
+
COAT_GAIN = 1.5, // a coded coat's colour is lifted by this, to match a ridden horse's
|
|
15
|
+
WHITE = [0.62, 0.6, 0.56],
|
|
16
|
+
HALF_BARREL = 0.26, // metres from a lying horse's spine line to the ground under its flank
|
|
17
|
+
SPINE_UP = 1.1, // and from a standing horse's hooves to its spine line, the line it rolls over about
|
|
18
|
+
LIE_ROLL = 1.5, // radians a fallen horse lies over on its side
|
|
19
|
+
modelsOf = cachePerOptions(),
|
|
20
|
+
_m = new THREE.Matrix4(),
|
|
21
|
+
_r = new THREE.Matrix4(),
|
|
22
|
+
_b = new THREE.Matrix4(),
|
|
23
|
+
_c = new THREE.Matrix4();
|
|
24
|
+
// what one step of a stored number is worth: a compact geometry keeps colours and bone weights as bytes (geometry/builder.js)
|
|
25
|
+
const unitOf = attribute => (attribute.normalized ? 1 / (attribute.array instanceof Uint8Array ? 255 : 65535) : 1);
|
|
26
|
+
let boneRows = new Float64Array(0); // each bone's pose as twelve numbers (three rows of a 4 x 4 matrix), refilled for every horse
|
|
27
|
+
|
|
28
|
+
// The models are made the first time a still horse is wanted, for each world's options: unsaddled, in a coded coat (codedCoat of
|
|
29
|
+
// geometry/animal-horse-coat.js), at the detail between near and far; only posed and cast, so they have no material.
|
|
30
|
+
function model(i, options) {
|
|
31
|
+
return (modelsOf(options)[i] ??= rigHorse(null, null, 0, false, 'riding', i, [1, 1], null, options));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Lets the models go: each horse is posed from where the one before it on its model left the skeleton, so a place's builders
|
|
35
|
+
* that must cast the same horses wherever and however often they run begin from new models.
|
|
36
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options] The world whose models go.
|
|
37
|
+
*/
|
|
38
|
+
function forgetStillHorses(options = NO_ANIMAL_OPTIONS) {
|
|
39
|
+
const models = modelsOf(options);
|
|
40
|
+
for (const i in models) delete models[i];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Casts a horse at (x, y, z), facing yaw, into a builder, or into a kit's builders: its hide into the cloth's and its eyes into
|
|
45
|
+
* the glass's, which is dark and wet and catches the sky.
|
|
46
|
+
* @param {object} into A `GeometryBuilder`, or { cloth, glass } builders.
|
|
47
|
+
* @param {number} x Metres.
|
|
48
|
+
* @param {number} y Metres.
|
|
49
|
+
* @param {number} z Metres.
|
|
50
|
+
* @param {number} yaw Radians.
|
|
51
|
+
* @param {number[]} col Its coat, linear [r, g, b].
|
|
52
|
+
* @param {() => number} R A random source for which horse it is and how it stands.
|
|
53
|
+
* @param {boolean} [graze] Its head down.
|
|
54
|
+
* @param {boolean} [fallen] Lying dead on a side (HALF_BARREL, SPINE_UP and LIE_ROLL say how it lies).
|
|
55
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options]
|
|
56
|
+
*/
|
|
57
|
+
function stillHorse(into, x, y, z, yaw, col, R, graze = false, fallen = false, options = NO_ANIMAL_OPTIONS) {
|
|
58
|
+
const gb = into.cloth ?? into,
|
|
59
|
+
wet = into.glass ?? into;
|
|
60
|
+
col = col.map(v => v * COAT_GAIN);
|
|
61
|
+
const H = model(Math.floor(R() * MODELS) % MODELS, options),
|
|
62
|
+
Q = H.rig,
|
|
63
|
+
mesh = H.mesh,
|
|
64
|
+
geo = H.near,
|
|
65
|
+
P = geo.attributes.position,
|
|
66
|
+
N = geo.attributes.normal,
|
|
67
|
+
C = geo.attributes.color,
|
|
68
|
+
max = Math.max(...col),
|
|
69
|
+
grey = max - Math.min(...col) < 0.08 * (max + 0.05) + 0.012,
|
|
70
|
+
red = !grey && R() < 0.35, // a chestnut's mane and legs are its own colour
|
|
71
|
+
points = grey ? col.map(v => v * 0.55) : red ? col.map(v => v * 0.85) : POINTS,
|
|
72
|
+
M0 = gb.M,
|
|
73
|
+
W0 = wet.M;
|
|
74
|
+
// a few moments of standing, from a moment of its own, settle the legs, the ears and the tail
|
|
75
|
+
H.graze = graze ? 1 : 0;
|
|
76
|
+
H.down = fallen ? 1 : 0;
|
|
77
|
+
Q.seed = R() * 100;
|
|
78
|
+
Q.px = null;
|
|
79
|
+
mesh.updateMatrixWorld(true);
|
|
80
|
+
for (let i = 0, t = R() * 60; i < 40; i++) horsePose(H, 0.1, (t += 0.1), 0);
|
|
81
|
+
mesh.updateMatrixWorld(true);
|
|
82
|
+
mesh.skeleton.update();
|
|
83
|
+
_m.makeTranslation(x, y, z).multiply(_r.makeRotationY(yaw));
|
|
84
|
+
if (fallen)
|
|
85
|
+
_m.multiply(_r.makeTranslation(0, HALF_BARREL, 0))
|
|
86
|
+
.multiply(_r.makeRotationZ((R() < 0.5 ? 1 : -1) * LIE_ROLL))
|
|
87
|
+
.multiply(_r.makeTranslation(0, -SPINE_UP, 0));
|
|
88
|
+
// Each vertex is posed by its bones' matrices blended by its weights, read straight from the arrays (Three.js's
|
|
89
|
+
// applyBoneTransform makes a matrix product a vertex and held the page for 370 ms in a camp of 60 horses). A bone's matrix
|
|
90
|
+
// takes a point of the skin to where its bone has carried it; `_c` then sets the posed horse where it stands.
|
|
91
|
+
const bones = mesh.skeleton.bones,
|
|
92
|
+
inverses = mesh.skeleton.boneInverses,
|
|
93
|
+
skin = mesh.geometry.attributes,
|
|
94
|
+
joint = skin.skinIndex.array,
|
|
95
|
+
weight = skin.skinWeight.array,
|
|
96
|
+
tags = geo.attributes.aTag.array,
|
|
97
|
+
p = P.array,
|
|
98
|
+
n = N.array, // a normal's scale does not matter: it is turned, then made one long
|
|
99
|
+
c = C.array,
|
|
100
|
+
colourUnit = unitOf(C),
|
|
101
|
+
weightUnit = unitOf(skin.skinWeight);
|
|
102
|
+
if (boneRows.length < bones.length * 12) boneRows = new Float64Array(bones.length * 12);
|
|
103
|
+
for (let b = 0; b < bones.length; b++) {
|
|
104
|
+
const e = _b.multiplyMatrices(bones[b].matrixWorld, inverses[b]).multiply(mesh.bindMatrix).elements;
|
|
105
|
+
for (let row = 0; row < 3; row++) for (let col = 0; col < 4; col++) boneRows[b * 12 + row * 4 + col] = e[col * 4 + row];
|
|
106
|
+
}
|
|
107
|
+
const T = _c.multiplyMatrices(_m, mesh.bindMatrixInverse).elements;
|
|
108
|
+
gb.M = wet.M = null;
|
|
109
|
+
for (let i = 0; i < P.count; i++) {
|
|
110
|
+
const k = i * 3,
|
|
111
|
+
px = p[k],
|
|
112
|
+
py = p[k + 1],
|
|
113
|
+
pz = p[k + 2],
|
|
114
|
+
nx = n[k],
|
|
115
|
+
ny = n[k + 1],
|
|
116
|
+
nz = n[k + 2];
|
|
117
|
+
let qx = 0,
|
|
118
|
+
qy = 0,
|
|
119
|
+
qz = 0,
|
|
120
|
+
qw = 0,
|
|
121
|
+
mx = 0,
|
|
122
|
+
my = 0,
|
|
123
|
+
mz = 0;
|
|
124
|
+
for (let j = i * 4; j < i * 4 + 4; j++) {
|
|
125
|
+
const w = weight[j] * weightUnit;
|
|
126
|
+
if (w === 0) continue;
|
|
127
|
+
const r = joint[j] * 12;
|
|
128
|
+
qx += w * (boneRows[r] * px + boneRows[r + 1] * py + boneRows[r + 2] * pz + boneRows[r + 3]);
|
|
129
|
+
qy += w * (boneRows[r + 4] * px + boneRows[r + 5] * py + boneRows[r + 6] * pz + boneRows[r + 7]);
|
|
130
|
+
qz += w * (boneRows[r + 8] * px + boneRows[r + 9] * py + boneRows[r + 10] * pz + boneRows[r + 11]);
|
|
131
|
+
qw += w;
|
|
132
|
+
mx += w * (boneRows[r] * nx + boneRows[r + 1] * ny + boneRows[r + 2] * nz);
|
|
133
|
+
my += w * (boneRows[r + 4] * nx + boneRows[r + 5] * ny + boneRows[r + 6] * nz);
|
|
134
|
+
mz += w * (boneRows[r + 8] * nx + boneRows[r + 9] * ny + boneRows[r + 10] * nz);
|
|
135
|
+
}
|
|
136
|
+
// a normal is turned by the matrices as a point just off the skin is, without their shift
|
|
137
|
+
const wx = T[0] * mx + T[4] * my + T[8] * mz,
|
|
138
|
+
wy = T[1] * mx + T[5] * my + T[9] * mz,
|
|
139
|
+
wz = T[2] * mx + T[6] * my + T[10] * mz,
|
|
140
|
+
length = Math.hypot(wx, wy, wz) || 1,
|
|
141
|
+
body = c[k] * colourUnit,
|
|
142
|
+
dark = c[k + 1] * colourUnit,
|
|
143
|
+
white = c[k + 2] * colourUnit,
|
|
144
|
+
eye = tags[i] === EYE_TAG;
|
|
145
|
+
(eye ? wet : gb).raw(
|
|
146
|
+
T[0] * qx + T[4] * qy + T[8] * qz + T[12] * qw,
|
|
147
|
+
T[1] * qx + T[5] * qy + T[9] * qz + T[13] * qw,
|
|
148
|
+
T[2] * qx + T[6] * qy + T[10] * qz + T[14] * qw,
|
|
149
|
+
wx / length,
|
|
150
|
+
wy / length,
|
|
151
|
+
wz / length,
|
|
152
|
+
eye ? 0 : col[0] * body + points[0] * dark + WHITE[0] * white, // a black pane: no lamplight behind it
|
|
153
|
+
eye ? 0 : col[1] * body + points[1] * dark + WHITE[1] * white,
|
|
154
|
+
eye ? 0 : col[2] * body + points[2] * dark + WHITE[2] * white,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
gb.M = M0;
|
|
158
|
+
wet.M = W0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { HALF_BARREL, LIE_ROLL, SPINE_UP, forgetStillHorses, stillHorse };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { NO_ANIMAL_OPTIONS } from '../geometry/animal-options.js';
|
|
2
|
+
import { buildCattle } from '../rendering/animal-cattle-figure.js';
|
|
3
|
+
import { packPose, skinArrays, weldOf } from './animal-herd-cast.js';
|
|
4
|
+
import { strideFrames } from './animal-bearing.js';
|
|
5
|
+
import { rigHorse } from '../rendering/animal-horse-figure.js';
|
|
6
|
+
|
|
7
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
8
|
+
// A marching troop's beasts (a column of riders, its baggage oxen) as the moments they are drawn from, cast as arrays on a pool's
|
|
9
|
+
// workers or, where there are none, on the page: its saddled horse standing, fallen and at the moments of each pace, or its ox standing and
|
|
10
|
+
// at the moments of its walk, from the skin of detail q (0 the far one, 1 the middle one, for a beast close by).
|
|
11
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
12
|
+
const SADDLE_CLOTH = 0x5a3a2e, // a brown cloth, unless the world gives its troops their own (`troop` of animal-options.js)
|
|
13
|
+
PALE_COAT = 0xa9a39a; // a pale coat, which each horse's tint colours
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A troop's saddled horse or ox cast as arrays: the skin's colours and tags, the beast standing (and, a horse, fallen) with how
|
|
17
|
+
* high its back stands, and each pace's moments with how far one stride carries it and, at each moment, its back's rise and
|
|
18
|
+
* pitch and the stride's phase (for a rider to sit).
|
|
19
|
+
* @param {{ beast: string, q: number, paces: number[][] }} input beast: 'horse' or a cattle build ('ox'); q: the skin's detail
|
|
20
|
+
* (0 the far one, 1 the middle one, for a beast close by); paces: [[speed in metres a second, moments], ...].
|
|
21
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options] The troop's saddle cloth and coat, and the world's
|
|
22
|
+
* builds.
|
|
23
|
+
*/
|
|
24
|
+
function troopArrays({ beast, q, paces }, options = NO_ANIMAL_OPTIONS) {
|
|
25
|
+
const cloth = options.troop?.saddleCloth ?? SADDLE_CLOTH,
|
|
26
|
+
coat = options.troop?.coat ?? PALE_COAT,
|
|
27
|
+
H = beast === 'horse' ? rigHorse(null, coat, cloth, true, 'riding', false, [q, q], null, options) : buildCattle(beast, [q, q], options);
|
|
28
|
+
H.graze = 0;
|
|
29
|
+
const stand = strideFrames(H, 0, 1),
|
|
30
|
+
weld = weldOf(H.far); // the skin's repeated points drawn once (animal-herd-cast.js)
|
|
31
|
+
return {
|
|
32
|
+
...skinArrays(H, H.far, weld),
|
|
33
|
+
stand: packPose(stand.frames[0], weld),
|
|
34
|
+
standRise: stand.rises[0],
|
|
35
|
+
fallen: beast === 'horse' ? packPose(strideFrames(H, 0, 1, true).frames[0], weld) : null,
|
|
36
|
+
paces: paces.map(([speed, moments]) => {
|
|
37
|
+
const { frames, stride, rises, pitches, phases } = strideFrames(H, speed, moments);
|
|
38
|
+
return { frames: frames.map(frame => packPose(frame, weld)), stride, rises, pitches, phases };
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { troopArrays };
|
package/motion/arm-reach.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { wrapRadians } from '../math/periodic.js';
|
|
1
2
|
import * as THREE from 'three';
|
|
2
3
|
import { clamp } from '../math/scalar.js';
|
|
3
4
|
|
|
@@ -46,9 +47,9 @@ export function createArmReach({ elbowDirection, minBend, maxBend }) {
|
|
|
46
47
|
cosReachAngle = clamp((localGrip.x * localGrip.x + l1 * l1 + rho * rho - far * far) / (2 * l1 * rho), -1, 1),
|
|
47
48
|
turn = Math.acos(cosReachAngle);
|
|
48
49
|
let bend = turn - phi;
|
|
49
|
-
bend =
|
|
50
|
+
bend = wrapRadians(bend);
|
|
50
51
|
if (bend > maxBend || bend < minBend) {
|
|
51
|
-
const other =
|
|
52
|
+
const other = wrapRadians(-turn - phi);
|
|
52
53
|
if (Math.abs(other - (maxBend + minBend) / 2) < Math.abs(bend - (maxBend + minBend) / 2)) bend = other;
|
|
53
54
|
}
|
|
54
55
|
bend = clamp(bend, minBend, maxBend);
|
package/motion/ballistic-arc.js
CHANGED
|
@@ -1,11 +1,191 @@
|
|
|
1
|
+
import { clamp } from '../math/scalar.js';
|
|
2
|
+
|
|
3
|
+
const _inverseTarget = {
|
|
4
|
+
elements: new Float64Array(16),
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// Inverts a 4x4 column-major affine matrix (such as a Three.js Matrix4) into `out` without allocating.
|
|
8
|
+
// Returns false if the matrix is singular.
|
|
9
|
+
function invertMatrix4(elements, out) {
|
|
10
|
+
const n11 = elements[0],
|
|
11
|
+
n21 = elements[1],
|
|
12
|
+
n31 = elements[2],
|
|
13
|
+
n41 = elements[3],
|
|
14
|
+
n12 = elements[4],
|
|
15
|
+
n22 = elements[5],
|
|
16
|
+
n32 = elements[6],
|
|
17
|
+
n42 = elements[7],
|
|
18
|
+
n13 = elements[8],
|
|
19
|
+
n23 = elements[9],
|
|
20
|
+
n33 = elements[10],
|
|
21
|
+
n43 = elements[11],
|
|
22
|
+
n14 = elements[12],
|
|
23
|
+
n24 = elements[13],
|
|
24
|
+
n34 = elements[14],
|
|
25
|
+
n44 = elements[15];
|
|
26
|
+
|
|
27
|
+
const t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
|
|
28
|
+
t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
|
|
29
|
+
t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
|
|
30
|
+
t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
|
|
31
|
+
|
|
32
|
+
const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
|
|
33
|
+
if (Math.abs(det) < 1e-14) return false;
|
|
34
|
+
const invDet = 1 / det;
|
|
35
|
+
|
|
36
|
+
out[0] = t11 * invDet;
|
|
37
|
+
out[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * invDet;
|
|
38
|
+
out[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * invDet;
|
|
39
|
+
out[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * invDet;
|
|
40
|
+
|
|
41
|
+
out[4] = t12 * invDet;
|
|
42
|
+
out[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * invDet;
|
|
43
|
+
out[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * invDet;
|
|
44
|
+
out[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * invDet;
|
|
45
|
+
|
|
46
|
+
out[8] = t13 * invDet;
|
|
47
|
+
out[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * invDet;
|
|
48
|
+
out[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * invDet;
|
|
49
|
+
out[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * invDet;
|
|
50
|
+
|
|
51
|
+
out[12] = t14 * invDet;
|
|
52
|
+
out[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * invDet;
|
|
53
|
+
out[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * invDet;
|
|
54
|
+
out[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * invDet;
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function transformPoint(out, x, y, z, elements) {
|
|
59
|
+
out.x = elements[0] * x + elements[4] * y + elements[8] * z + elements[12];
|
|
60
|
+
out.y = elements[1] * x + elements[5] * y + elements[9] * z + elements[13];
|
|
61
|
+
out.z = elements[2] * x + elements[6] * y + elements[10] * z + elements[14];
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function transformUnitDirection(out, dx, dy, dz, elements) {
|
|
66
|
+
const rx = elements[0] * dx + elements[4] * dy + elements[8] * dz,
|
|
67
|
+
ry = elements[1] * dx + elements[5] * dy + elements[9] * dz,
|
|
68
|
+
rz = elements[2] * dx + elements[6] * dy + elements[10] * dz,
|
|
69
|
+
len = Math.hypot(rx, ry, rz);
|
|
70
|
+
if (len > 1e-8) {
|
|
71
|
+
out.x = rx / len;
|
|
72
|
+
out.y = ry / len;
|
|
73
|
+
out.z = rz / len;
|
|
74
|
+
} else {
|
|
75
|
+
out.x = 0;
|
|
76
|
+
out.y = 0;
|
|
77
|
+
out.z = 1;
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
|
|
1
82
|
/**
|
|
2
83
|
* Position between two endpoints at a fraction of the flight duration.
|
|
3
|
-
* Coordinates use positive y up and gravity is a positive acceleration.
|
|
84
|
+
* Coordinates use positive y up and gravity is a positive acceleration (m/s^2).
|
|
4
85
|
* The destination may move between samples. The supplied vector is reused.
|
|
5
86
|
*/
|
|
6
87
|
export function sampleBallisticArc(position, from, to, phase, duration, gravity = 9.81) {
|
|
7
|
-
const progress =
|
|
88
|
+
const progress = clamp(phase, 0, 1);
|
|
8
89
|
position.lerpVectors(from, to, progress);
|
|
9
90
|
position.y += 0.5 * gravity * duration * duration * progress * (1 - progress);
|
|
10
91
|
return position;
|
|
11
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Samples both world position and unit tangent direction `(position, direction)` along a ballistic arc
|
|
96
|
+
* from `from` to `to` at normalized `phase` in `[0, 1]` over `duration` seconds.
|
|
97
|
+
* Supports downward gravity sag and lateral crosswind bow without allocating.
|
|
98
|
+
*/
|
|
99
|
+
export function sampleBallisticFlight(
|
|
100
|
+
position,
|
|
101
|
+
direction,
|
|
102
|
+
from,
|
|
103
|
+
to,
|
|
104
|
+
phase,
|
|
105
|
+
duration,
|
|
106
|
+
{ gravity = 9.81, windX = 0, windZ = 0, windDrag = 0.08 } = {},
|
|
107
|
+
) {
|
|
108
|
+
const u = clamp(phase, 0, 1),
|
|
109
|
+
spanSeconds = Math.max(1e-4, duration),
|
|
110
|
+
dx = to.x - from.x,
|
|
111
|
+
dy = to.y - from.y,
|
|
112
|
+
dz = to.z - from.z,
|
|
113
|
+
arcLift = 0.5 * gravity * spanSeconds * spanSeconds,
|
|
114
|
+
windBowX = windX * windDrag * spanSeconds * spanSeconds,
|
|
115
|
+
windBowZ = windZ * windDrag * spanSeconds * spanSeconds,
|
|
116
|
+
arch = u * (1 - u),
|
|
117
|
+
slope = 1 - 2 * u;
|
|
118
|
+
|
|
119
|
+
position.x = from.x + dx * u + windBowX * arch;
|
|
120
|
+
position.y = from.y + dy * u + arcLift * arch;
|
|
121
|
+
position.z = from.z + dz * u + windBowZ * arch;
|
|
122
|
+
|
|
123
|
+
const vx = dx + windBowX * slope,
|
|
124
|
+
vy = dy + arcLift * slope,
|
|
125
|
+
vz = dz + windBowZ * slope,
|
|
126
|
+
speed = Math.hypot(vx, vy, vz);
|
|
127
|
+
if (speed > 1e-8) {
|
|
128
|
+
direction.x = vx / speed;
|
|
129
|
+
direction.y = vy / speed;
|
|
130
|
+
direction.z = vz / speed;
|
|
131
|
+
} else {
|
|
132
|
+
direction.x = 0;
|
|
133
|
+
direction.y = 0;
|
|
134
|
+
direction.z = 1;
|
|
135
|
+
}
|
|
136
|
+
return position;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Computes the lodged sticking point and unit orientation in a target's local frame (or world space when
|
|
141
|
+
* `targetMatrixWorld` is null) so an arrow, bolt, or thrown blade stays embedded in a moving bone, shield, or surface.
|
|
142
|
+
*/
|
|
143
|
+
export function solveBallisticLodge(
|
|
144
|
+
localPosition,
|
|
145
|
+
localDirection,
|
|
146
|
+
worldImpact,
|
|
147
|
+
worldDirection,
|
|
148
|
+
targetMatrixWorld = null,
|
|
149
|
+
penetrationMeters = 0.06,
|
|
150
|
+
) {
|
|
151
|
+
const dirLen = Math.hypot(worldDirection.x, worldDirection.y, worldDirection.z),
|
|
152
|
+
ux = dirLen > 1e-8 ? worldDirection.x / dirLen : 0,
|
|
153
|
+
uy = dirLen > 1e-8 ? worldDirection.y / dirLen : 0,
|
|
154
|
+
uz = dirLen > 1e-8 ? worldDirection.z / dirLen : 1,
|
|
155
|
+
wx = worldImpact.x + ux * penetrationMeters,
|
|
156
|
+
wy = worldImpact.y + uy * penetrationMeters,
|
|
157
|
+
wz = worldImpact.z + uz * penetrationMeters;
|
|
158
|
+
|
|
159
|
+
if (targetMatrixWorld?.elements && invertMatrix4(targetMatrixWorld.elements, _inverseTarget.elements)) {
|
|
160
|
+
transformPoint(localPosition, wx, wy, wz, _inverseTarget.elements);
|
|
161
|
+
transformUnitDirection(localDirection, ux, uy, uz, _inverseTarget.elements);
|
|
162
|
+
return localPosition;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
localPosition.x = wx;
|
|
166
|
+
localPosition.y = wy;
|
|
167
|
+
localPosition.z = wz;
|
|
168
|
+
localDirection.x = ux;
|
|
169
|
+
localDirection.y = uy;
|
|
170
|
+
localDirection.z = uz;
|
|
171
|
+
return localPosition;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Evaluates a previously solved lodged projectile into world-space `worldPosition` and `worldDirection`
|
|
176
|
+
* without allocating. Pass the current `targetMatrixWorld` of the struck shield, bone, or object, or null for static ground.
|
|
177
|
+
*/
|
|
178
|
+
export function evaluateBallisticLodge(worldPosition, worldDirection, localPosition, localDirection, targetMatrixWorld = null) {
|
|
179
|
+
if (targetMatrixWorld?.elements) {
|
|
180
|
+
transformPoint(worldPosition, localPosition.x, localPosition.y, localPosition.z, targetMatrixWorld.elements);
|
|
181
|
+
transformUnitDirection(worldDirection, localDirection.x, localDirection.y, localDirection.z, targetMatrixWorld.elements);
|
|
182
|
+
return worldPosition;
|
|
183
|
+
}
|
|
184
|
+
worldPosition.x = localPosition.x;
|
|
185
|
+
worldPosition.y = localPosition.y;
|
|
186
|
+
worldPosition.z = localPosition.z;
|
|
187
|
+
worldDirection.x = localDirection.x;
|
|
188
|
+
worldDirection.y = localDirection.y;
|
|
189
|
+
worldDirection.z = localDirection.z;
|
|
190
|
+
return worldPosition;
|
|
191
|
+
}
|
package/motion/biped-cycle.js
CHANGED
|
@@ -11,7 +11,8 @@ import { ankleOffset, solePitch, solveBipedLeg } from './biped-leg.js';
|
|
|
11
11
|
export function createBipedCycle({ rig, foot }) {
|
|
12
12
|
const leg = () => ({ thigh: 0, knee: 0, foot: 0, forward: 0, height: 0 });
|
|
13
13
|
const pose = { hipHeight: 0, left: leg(), right: leg() };
|
|
14
|
-
const ankle = [0, 0],
|
|
14
|
+
const ankle = [0, 0],
|
|
15
|
+
angles = [0, 0];
|
|
15
16
|
const reach = rig.thigh + rig.shin - 0.0005;
|
|
16
17
|
|
|
17
18
|
function target(leg, phase, stride, duty, clearance, grade, slope, roll, stagger) {
|
|
@@ -33,7 +34,8 @@ export function createBipedCycle({ rig, foot }) {
|
|
|
33
34
|
leg.foot -= leg.thigh + leg.knee;
|
|
34
35
|
}
|
|
35
36
|
return function sample(phase, stride, duty, clearance, grade, hipHeight, roll = 1, stagger = 0) {
|
|
36
|
-
const cyclePhase = phase - Math.floor(phase),
|
|
37
|
+
const cyclePhase = phase - Math.floor(phase),
|
|
38
|
+
slope = -Math.atan(grade);
|
|
37
39
|
pose.hipHeight = hipHeight;
|
|
38
40
|
target(pose.left, cyclePhase, stride, duty, clearance, grade, slope, roll, -stagger);
|
|
39
41
|
target(pose.right, (cyclePhase + 0.5) % 1, stride, duty, clearance, grade, slope, roll, stagger);
|
package/motion/biped-leg.js
CHANGED
|
@@ -23,7 +23,10 @@ export function solePitch(foot, u, duty, back, strike, push) {
|
|
|
23
23
|
export function ankleOffset(out, rig, pitch, slope) {
|
|
24
24
|
const cosPitch = Math.cos(pitch),
|
|
25
25
|
sinPitch = Math.sin(pitch),
|
|
26
|
-
forward =
|
|
26
|
+
forward =
|
|
27
|
+
pitch >= 0
|
|
28
|
+
? rig.ballOffset - rig.ballOffset * cosPitch + rig.ankleHeight * sinPitch
|
|
29
|
+
: -rig.heelOffset + rig.heelOffset * cosPitch + rig.ankleHeight * sinPitch,
|
|
27
30
|
up = pitch >= 0 ? rig.ballOffset * sinPitch + rig.ankleHeight * cosPitch : -rig.heelOffset * sinPitch + rig.ankleHeight * cosPitch;
|
|
28
31
|
if (slope) {
|
|
29
32
|
const cosSlope = Math.cos(slope),
|