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,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure cast actor records, deterministic name seeding, home placement (ground anchors,
|
|
3
|
+
* interior spaces, moving reference frames and orbits), and scene-state transitions.
|
|
4
|
+
* Free of Three.js so workers and Node tests can evaluate actor placement directly.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from '../math/random.js';
|
|
8
|
+
import { TAU } from '../math/scalar.js';
|
|
9
|
+
import { figureActor } from './figure-pose.js';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_HASH = createHash(0);
|
|
12
|
+
const DEFAULT_ORBIT_RISE = 9; // metres a circling flier rises and falls over one cycle
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Computes a repeatable 32-bit FNV-1a seed from an actor identifier so a character
|
|
16
|
+
* always generates the same procedural appearance regardless of load order.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} id - Stable actor identifier.
|
|
19
|
+
* @returns {number} Unsigned 32-bit integer seed.
|
|
20
|
+
*/
|
|
21
|
+
export function actorNameSeed(id) {
|
|
22
|
+
let seed = 2166136261;
|
|
23
|
+
for (let i = 0; i < id.length; i++) seed = Math.imul(seed ^ id.charCodeAt(i), 16777619);
|
|
24
|
+
return seed >>> 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Normalizes a character definition's `home` field into an array of home descriptors.
|
|
29
|
+
* The first entry is the primary actor's home; each further entry spawns an echo figure.
|
|
30
|
+
*
|
|
31
|
+
* @param {object} def - Character definition record.
|
|
32
|
+
* @returns {object[]} Zero or more home descriptors.
|
|
33
|
+
*/
|
|
34
|
+
export function homesOf(def) {
|
|
35
|
+
return Array.isArray(def.home) ? def.home : def.home ? [def.home] : [];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const NULL_PART_KEYS = [
|
|
39
|
+
'legL',
|
|
40
|
+
'legR',
|
|
41
|
+
'cloak',
|
|
42
|
+
'cloakLow',
|
|
43
|
+
'capeL',
|
|
44
|
+
'capeR',
|
|
45
|
+
'foreL',
|
|
46
|
+
'foreR',
|
|
47
|
+
'shinL',
|
|
48
|
+
'shinR',
|
|
49
|
+
'footL',
|
|
50
|
+
'footR',
|
|
51
|
+
'toesL',
|
|
52
|
+
'toesR',
|
|
53
|
+
'head',
|
|
54
|
+
'sheaths',
|
|
55
|
+
'hi',
|
|
56
|
+
'lo',
|
|
57
|
+
'root',
|
|
58
|
+
'pelvis',
|
|
59
|
+
'chest',
|
|
60
|
+
'rig',
|
|
61
|
+
'lid',
|
|
62
|
+
'jaw',
|
|
63
|
+
'face',
|
|
64
|
+
'elbowL',
|
|
65
|
+
'elbowR',
|
|
66
|
+
'wristL',
|
|
67
|
+
'wristR',
|
|
68
|
+
'fingersL',
|
|
69
|
+
'fingersR',
|
|
70
|
+
'neck',
|
|
71
|
+
'tail',
|
|
72
|
+
'limbs',
|
|
73
|
+
'handL',
|
|
74
|
+
'handR',
|
|
75
|
+
'openR',
|
|
76
|
+
'openL',
|
|
77
|
+
'gripR',
|
|
78
|
+
'gripL',
|
|
79
|
+
'hold',
|
|
80
|
+
'hairBone',
|
|
81
|
+
'bow',
|
|
82
|
+
'wear',
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Extracts the scene-graph and skeleton part handles from a built figure or stand-in
|
|
87
|
+
* so an actor record can be initialized or promoted in place without leaking stale fields.
|
|
88
|
+
*
|
|
89
|
+
* @param {object} figure - Built figure (from an assembler or creature builder) or stand-in.
|
|
90
|
+
* @returns {object} Flat map of figure part references and LOD metadata.
|
|
91
|
+
*/
|
|
92
|
+
export function extractFigureParts(figure) {
|
|
93
|
+
const f = figure;
|
|
94
|
+
const parts = {
|
|
95
|
+
group: f.group,
|
|
96
|
+
armL: f.armL,
|
|
97
|
+
armR: f.armR,
|
|
98
|
+
height: f.height,
|
|
99
|
+
kind: f.kind,
|
|
100
|
+
itemR: f.itemR,
|
|
101
|
+
itemL: f.itemL,
|
|
102
|
+
worn: f.worn,
|
|
103
|
+
sheath: f.sheath,
|
|
104
|
+
robe: !!f.robe,
|
|
105
|
+
armClear: f.armClear || 0,
|
|
106
|
+
nearBuilt: f.nearBuilt ?? true,
|
|
107
|
+
nearLater: f.nearBuilt !== undefined,
|
|
108
|
+
lx: f.lx || 0.1,
|
|
109
|
+
lidA: f.lidA || 0,
|
|
110
|
+
itemSize: f.itemSize ?? 1,
|
|
111
|
+
hair: f.hair || '',
|
|
112
|
+
gearSwings: !!f.gearSwings,
|
|
113
|
+
mount: f.mount ? { y: f.mount.seat, H: f.mount } : null,
|
|
114
|
+
};
|
|
115
|
+
for (let i = 0; i < NULL_PART_KEYS.length; i++) {
|
|
116
|
+
const key = NULL_PART_KEYS[i];
|
|
117
|
+
parts[key] = f[key] || null;
|
|
118
|
+
}
|
|
119
|
+
return parts;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Creates a cast actor record built on {@link figureActor} with additional cast lifecycle,
|
|
124
|
+
* worker order, home, echo, and nameplate state initialized in one monomorphic shape.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} id - Actor identifier (or echo identifier such as `'id@1'`).
|
|
127
|
+
* @param {object} def - Character definition containing at least `{ look }`.
|
|
128
|
+
* @param {object} standIn - Lightweight placeholder figure (`{ group, kind, height }`).
|
|
129
|
+
* @param {number} index - Zero-based enlistment index used to seed repeatable idle variation.
|
|
130
|
+
* @param {object} [options]
|
|
131
|
+
* @param {(x: number, y: number, salt?: number) => number} [options.hash] - Seeded 2D hash in `[0, 1)`.
|
|
132
|
+
* @param {number} [options.defaultRange=8] - Default nameplate reading distance (metres).
|
|
133
|
+
* @param {string} [options.defaultSpace='world'] - Initial space identifier.
|
|
134
|
+
* @returns {object} Monomorphic cast actor record ready for `createCastManager`.
|
|
135
|
+
*/
|
|
136
|
+
export function createCastActor(id, def, standIn, index, { hash = DEFAULT_HASH, defaultRange = 8, defaultSpace = 'world' } = {}) {
|
|
137
|
+
const actor = figureActor(standIn, {
|
|
138
|
+
id,
|
|
139
|
+
look: def.look,
|
|
140
|
+
phase: hash(index, 3, 9) * TAU,
|
|
141
|
+
seed: hash(index + 1, 5, 11),
|
|
142
|
+
weightRate: TAU / (9 + 8 * hash(index + 1, 7, 13)),
|
|
143
|
+
blinkIn: 1 + 4 * hash(index + 1, 9, 17),
|
|
144
|
+
breath: hash(index + 1, 11, 19) * TAU,
|
|
145
|
+
});
|
|
146
|
+
Object.assign(actor, extractFigureParts(standIn), {
|
|
147
|
+
def,
|
|
148
|
+
built: false,
|
|
149
|
+
preparing: false,
|
|
150
|
+
order: null,
|
|
151
|
+
nearOrder: null,
|
|
152
|
+
figureSeed: 0,
|
|
153
|
+
active: false,
|
|
154
|
+
space: defaultSpace,
|
|
155
|
+
met: false,
|
|
156
|
+
plate: null,
|
|
157
|
+
plateOnCard: false,
|
|
158
|
+
plateA: 0,
|
|
159
|
+
plateBeside: false,
|
|
160
|
+
dist: 0,
|
|
161
|
+
sx: 0,
|
|
162
|
+
sy: 0,
|
|
163
|
+
ph: 0,
|
|
164
|
+
range: defaultRange,
|
|
165
|
+
hs: null,
|
|
166
|
+
home: null,
|
|
167
|
+
});
|
|
168
|
+
return actor;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Clears transient scene action state when an actor enters a fresh pose or returns home.
|
|
173
|
+
*
|
|
174
|
+
* @param {object} actor - Cast actor record.
|
|
175
|
+
*/
|
|
176
|
+
export function atRest(actor) {
|
|
177
|
+
actor.act = actor.watch = null;
|
|
178
|
+
actor.drawn = actor.forward = actor.awake = actor.carryingProp = false;
|
|
179
|
+
actor.effort = 0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Resets locomotion velocity, turn target, and foot-plant state after teleporting an actor.
|
|
184
|
+
*
|
|
185
|
+
* @param {object} actor - Cast actor record.
|
|
186
|
+
*/
|
|
187
|
+
export function standStill(actor) {
|
|
188
|
+
actor.px = actor.x;
|
|
189
|
+
actor.pz = actor.z;
|
|
190
|
+
actor.turn = actor.hip = NaN;
|
|
191
|
+
actor.feet = null;
|
|
192
|
+
actor.spin = actor.speed = actor.fwd = actor.side = actor.slope = 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Places an actor immediately at `(x, z)` facing `yaw` (radians), on the ground or at `y`.
|
|
197
|
+
*
|
|
198
|
+
* @param {object} actor - Cast actor record.
|
|
199
|
+
* @param {number} x - World X coordinate (metres).
|
|
200
|
+
* @param {number} z - World Z coordinate (metres).
|
|
201
|
+
* @param {number} [yaw] - Optional facing angle (radians, 0 faces +Z).
|
|
202
|
+
* @param {number} [y] - Optional fixed Y elevation (metres); omit to follow ground.
|
|
203
|
+
*/
|
|
204
|
+
export function placeCastActor(actor, x, z, yaw, y) {
|
|
205
|
+
actor.x = x;
|
|
206
|
+
actor.z = z;
|
|
207
|
+
if (yaw !== undefined) actor.yaw = yaw;
|
|
208
|
+
actor.fixY = y === undefined ? null : y;
|
|
209
|
+
actor.move = null;
|
|
210
|
+
actor.active = true;
|
|
211
|
+
standStill(actor);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Snaps an actor into its current `pose` without easing, updates unconscious eyelid state,
|
|
216
|
+
* and clears transient action flags.
|
|
217
|
+
*
|
|
218
|
+
* @param {object} actor - Cast actor record.
|
|
219
|
+
* @param {(actor: object) => void} takePose - Immediate pose setter from the figure pose pipeline.
|
|
220
|
+
*/
|
|
221
|
+
export function settleCastPose(actor, takePose) {
|
|
222
|
+
takePose(actor);
|
|
223
|
+
actor.unconscious = actor.pose === 'dead' || ((actor.pose === 'lie' || actor.pose === 'prone') && !actor.awake) ? 1 : 0;
|
|
224
|
+
atRest(actor);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Resolves an actor's position and heading on or orbiting a registered moving reference frame.
|
|
229
|
+
* Returns `false` when the frame is unregistered or has no walkable ground under the anchor.
|
|
230
|
+
*
|
|
231
|
+
* @param {object} actor - Cast actor record with `actor.home.on`.
|
|
232
|
+
* @param {Record<string, { origin: { x: number, y: number, z: number }, turn: () => number, ground: (x: number, z: number) => number }>} frames - Registered moving frames by name.
|
|
233
|
+
* @param {number} t - Elapsed world time (seconds).
|
|
234
|
+
* @param {number} [orbitRise=9] - Vertical bobbing amplitude (metres) for orbiting fliers.
|
|
235
|
+
* @returns {boolean} True when the actor was placed on or around the frame.
|
|
236
|
+
*/
|
|
237
|
+
export function homeOnFrame(actor, frames, t, orbitRise = DEFAULT_ORBIT_RISE) {
|
|
238
|
+
const h = actor.home,
|
|
239
|
+
frame = frames[h.on];
|
|
240
|
+
if (!frame) return false;
|
|
241
|
+
const o = frame.origin;
|
|
242
|
+
if (h.orbit) {
|
|
243
|
+
const [r, up, per, ph] = h.orbit,
|
|
244
|
+
an = ph + (t * TAU) / per;
|
|
245
|
+
actor.x = o.x + Math.cos(an) * r;
|
|
246
|
+
actor.z = o.z + Math.sin(an) * r;
|
|
247
|
+
actor.fixY = o.y + up + Math.sin(t * 0.21 + ph * 3) * orbitRise;
|
|
248
|
+
actor.yaw = Math.atan2(-Math.sin(an) * Math.sign(per), Math.cos(an) * Math.sign(per));
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
const cos = Math.cos(frame.turn()),
|
|
252
|
+
sin = Math.sin(frame.turn()),
|
|
253
|
+
at = (u, v, k) => (k ? o.z - sin * u + cos * v : o.x + cos * u + sin * v);
|
|
254
|
+
const x = at(h.d[0], h.d[1], 0),
|
|
255
|
+
z = at(h.d[0], h.d[1], 1),
|
|
256
|
+
y = frame.ground(x, z);
|
|
257
|
+
if (!Number.isFinite(y)) return false;
|
|
258
|
+
actor.x = x;
|
|
259
|
+
actor.z = z;
|
|
260
|
+
actor.fixY = y + (h.y || 0);
|
|
261
|
+
const lx = h.look ? at(h.look[0], h.look[1], 0) : o.x,
|
|
262
|
+
lz = h.look ? at(h.look[0], h.look[1], 1) : o.z;
|
|
263
|
+
actor.yaw = Math.atan2(lx - x, lz - z);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Places an actor inside an interior space when that space is built, or deactivates it until then.
|
|
269
|
+
*
|
|
270
|
+
* @param {object} actor - Cast actor record.
|
|
271
|
+
* @param {object} home - Interior home descriptor `{ in, d, look?, y? }`.
|
|
272
|
+
* @param {object} options
|
|
273
|
+
* @param {(spaceId: string) => boolean} options.isSpaceBuilt - Reports whether a space has been built.
|
|
274
|
+
* @param {(spaceId: string) => { origin: { x: number, z: number }, ground: (x: number, z: number) => number }} options.getSpace - Looks up a built space by id.
|
|
275
|
+
*/
|
|
276
|
+
export function placeActorInside(actor, home, { isSpaceBuilt, getSpace }) {
|
|
277
|
+
if (!isSpaceBuilt(home.in)) {
|
|
278
|
+
actor.active = false;
|
|
279
|
+
actor.group.visible = false;
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const sp = getSpace(home.in),
|
|
283
|
+
x = sp.origin.x + home.d[0],
|
|
284
|
+
z = sp.origin.z + home.d[1],
|
|
285
|
+
to = home.look ?? [0, 0];
|
|
286
|
+
actor.space = home.in;
|
|
287
|
+
actor.active = true;
|
|
288
|
+
actor.pose = 'idle';
|
|
289
|
+
actor.x = x;
|
|
290
|
+
actor.z = z;
|
|
291
|
+
actor.yaw = Math.atan2(sp.origin.x + to[0] - x, sp.origin.z + to[1] - z);
|
|
292
|
+
actor.fixY = home.y === undefined ? null : sp.ground(x, z) + home.y;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Sends an actor back to its home (interior space, moving frame, or outdoor ground anchor),
|
|
297
|
+
* clearing any active scene or movement state.
|
|
298
|
+
*
|
|
299
|
+
* @param {object} actor - Cast actor record.
|
|
300
|
+
* @param {object} options
|
|
301
|
+
* @param {(spaceId: string) => boolean} options.isSpaceBuilt - Reports whether a space is currently built.
|
|
302
|
+
* @param {(spaceId: string) => object} options.getSpace - Returns a built space by id.
|
|
303
|
+
* @param {(key: string) => (number | { x: number, y?: number, z: number })} options.resolvePlace - Resolves named place anchors.
|
|
304
|
+
* @param {(x: number, z: number) => number} options.worldGround - Samples ground height (metres) in the default world space.
|
|
305
|
+
* @param {number} [options.defaultRange=8] - Restored nameplate reading distance (metres).
|
|
306
|
+
* @param {string} [options.worldSpaceId='world'] - Space identifier for outdoor ground homes.
|
|
307
|
+
* @param {(actor: object, onFoot: boolean) => void} [options.setAfoot] - Resets rider/dismount state.
|
|
308
|
+
* @param {(actor: object) => string} [options.idlePoseOf] - Returns the resting pose for an outdoor actor (`'idle'` by default).
|
|
309
|
+
*/
|
|
310
|
+
export function placeActorAtHome(
|
|
311
|
+
actor,
|
|
312
|
+
{
|
|
313
|
+
isSpaceBuilt,
|
|
314
|
+
getSpace,
|
|
315
|
+
resolvePlace,
|
|
316
|
+
worldGround,
|
|
317
|
+
defaultRange = 8,
|
|
318
|
+
worldSpaceId = 'world',
|
|
319
|
+
setAfoot = null,
|
|
320
|
+
idlePoseOf = () => 'idle',
|
|
321
|
+
},
|
|
322
|
+
) {
|
|
323
|
+
const h = actor.home;
|
|
324
|
+
if (setAfoot) setAfoot(actor, false);
|
|
325
|
+
actor.inScene = false;
|
|
326
|
+
actor.move = null;
|
|
327
|
+
actor.range = defaultRange;
|
|
328
|
+
actor.lookAt = null;
|
|
329
|
+
actor.turn = NaN;
|
|
330
|
+
atRest(actor);
|
|
331
|
+
if (h?.in) return placeActorInside(actor, h, { isSpaceBuilt, getSpace });
|
|
332
|
+
if (!h || !isSpaceBuilt(worldSpaceId)) {
|
|
333
|
+
actor.active = false;
|
|
334
|
+
actor.group.visible = false;
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
actor.space = worldSpaceId;
|
|
338
|
+
actor.active = true;
|
|
339
|
+
actor.pose = idlePoseOf(actor);
|
|
340
|
+
if (h.on) {
|
|
341
|
+
actor.fixY = null;
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const p = resolvePlace(h.at),
|
|
345
|
+
x = p.x + h.d[0],
|
|
346
|
+
z = p.z + h.d[1];
|
|
347
|
+
let yaw = 0;
|
|
348
|
+
if (h.look) yaw = Math.atan2(p.x + h.look[0] - x, p.z + h.look[1] - z);
|
|
349
|
+
else yaw = Math.atan2(p.x - x, p.z - z);
|
|
350
|
+
actor.x = x;
|
|
351
|
+
actor.z = z;
|
|
352
|
+
actor.yaw = yaw;
|
|
353
|
+
if (h.y === undefined) actor.fixY = null;
|
|
354
|
+
else if (typeof h.y === 'number') actor.fixY = worldGround(x, z) + h.y;
|
|
355
|
+
else {
|
|
356
|
+
const target = resolvePlace(h.y);
|
|
357
|
+
actor.fixY = typeof target === 'number' ? target : target.y;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Determines whether an actor is active in `spaceId` on this frame, hiding echoes whose
|
|
363
|
+
* primary actor is currently playing in a scene and updating moving-frame anchors.
|
|
364
|
+
*
|
|
365
|
+
* @param {object} actor - Cast actor record.
|
|
366
|
+
* @param {number} t - Elapsed world time (seconds).
|
|
367
|
+
* @param {string} spaceId - Space identifier to test against.
|
|
368
|
+
* @param {Record<string, object>} frames - Registered moving reference frames.
|
|
369
|
+
* @param {number} [orbitRise=9] - Orbit vertical oscillation amplitude (metres).
|
|
370
|
+
* @returns {boolean} True when the actor should be updated and considered for visibility.
|
|
371
|
+
*/
|
|
372
|
+
export function isActorInPlay(actor, t, spaceId, frames, orbitRise = DEFAULT_ORBIT_RISE) {
|
|
373
|
+
return !(
|
|
374
|
+
!actor.active ||
|
|
375
|
+
actor.space !== spaceId ||
|
|
376
|
+
(actor.primary && actor.primary.inScene) ||
|
|
377
|
+
(actor.home && actor.home.on && !actor.inScene && !actor.move && !homeOnFrame(actor, frames, t, orbitRise))
|
|
378
|
+
);
|
|
379
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cast manager for a procedural world: enlists actors and multi-home echoes, manages home
|
|
3
|
+
* placement across ground anchors, interior spaces and moving frames, coordinates worker
|
|
4
|
+
* prefetching and LOD switching, emits contact shadows, and drives the per-frame actor loop.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from '../math/random.js';
|
|
8
|
+
import { withinDetailRange } from '../rendering/detail-range.js';
|
|
9
|
+
import { pending } from '../runtime/figure-orders.js';
|
|
10
|
+
import { actorNameSeed, createCastActor, homesOf, isActorInPlay, placeActorAtHome, placeCastActor, settleCastPose } from './cast-actors.js';
|
|
11
|
+
|
|
12
|
+
const DEFAULT_HASH = createHash(0);
|
|
13
|
+
const DEFAULT_ORDER_AHEAD = 40; // metres beyond sight distance to order worker bodies
|
|
14
|
+
const DEFAULT_SEEN_WITHIN = 230; // metres within which an outdoor actor is visible
|
|
15
|
+
const DEFAULT_SEEN_IN_SCENE = 420; // metres within which a scene cast member stays visible
|
|
16
|
+
const DEFAULT_BODY_RANGE = Object.freeze([18.8, 21.2]); // near-mesh enter/leave hysteresis (metres at unit lens)
|
|
17
|
+
const DEFAULT_NEAR_RAISE = 32; // metres at unit lens within which a near body is ordered/built
|
|
18
|
+
const DEFAULT_NEAR_DROP = 90; // metres at unit lens beyond which an idle near body is disposed
|
|
19
|
+
const DEFAULT_ORBIT_RISE = 9; // metres a circling flier rises and falls
|
|
20
|
+
|
|
21
|
+
const withGrip = def => ({ ...def, look: { ...def.look, grip: true } });
|
|
22
|
+
|
|
23
|
+
function createHeadlessStage() {
|
|
24
|
+
return {
|
|
25
|
+
standIn(look) {
|
|
26
|
+
const kind = look.kind || 'human',
|
|
27
|
+
size = look.h || 1;
|
|
28
|
+
return { group: { visible: false, scale: { x: size, y: size, z: size } }, kind, height: 1.9 * size };
|
|
29
|
+
},
|
|
30
|
+
orderActor() {},
|
|
31
|
+
orderCast: () => null,
|
|
32
|
+
releaseCast() {},
|
|
33
|
+
raiseActor(actor) {
|
|
34
|
+
actor.built = true;
|
|
35
|
+
},
|
|
36
|
+
raiseNear(actor) {
|
|
37
|
+
actor.nearBuilt = true;
|
|
38
|
+
},
|
|
39
|
+
dropNear(actor) {
|
|
40
|
+
actor.nearBuilt = false;
|
|
41
|
+
},
|
|
42
|
+
prepareCast: () => Promise.resolve(),
|
|
43
|
+
warmDefaultPrograms() {},
|
|
44
|
+
readyWorkerBodies() {},
|
|
45
|
+
buildVisibleActor(actor) {
|
|
46
|
+
actor.built = true;
|
|
47
|
+
},
|
|
48
|
+
buildNearBody(actor) {
|
|
49
|
+
actor.nearBuilt = true;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates a world-scoped cast manager holding the actor dictionary (`actors`), dense array
|
|
56
|
+
* (`actorList`), and moving reference frames, with zero per-frame allocations in `updateActors`.
|
|
57
|
+
*
|
|
58
|
+
* @param {object} config
|
|
59
|
+
* @param {object} [config.stage] - Rendering/GPU staging controller (`createCastStage`), or a headless default.
|
|
60
|
+
* @param {{ position: { x: number, y: number, z: number } }} config.camera - Active world camera.
|
|
61
|
+
* @param {() => number} config.getElapsed - Returns elapsed world time (seconds).
|
|
62
|
+
* @param {() => number} [config.getDetailLens] - Returns current perspective magnification relative to the reference FOV.
|
|
63
|
+
* @param {() => string} [config.getSpaceId] - Returns the active space identifier.
|
|
64
|
+
* @param {(spaceId: string) => object} [config.getSpace] - Looks up a space descriptor by identifier.
|
|
65
|
+
* @param {(spaceId: string) => boolean} [config.isSpaceBuilt] - Reports whether a space has been built.
|
|
66
|
+
* @param {string} [config.worldSpaceId='world'] - Space identifier for outdoor ground homes.
|
|
67
|
+
* @param {(key: string) => any} [config.resolvePlace] - Resolves named place anchors referenced by homes.
|
|
68
|
+
* @param {(x: number, z: number) => number} [config.worldGround] - Samples ground elevation (metres) in `worldSpaceId`.
|
|
69
|
+
* @param {(x: number, y: number, salt?: number) => number} [config.hash] - Seeded 2D hash in `[0, 1)`.
|
|
70
|
+
* @param {number} [config.defaultRange=8] - Default nameplate reading distance (metres).
|
|
71
|
+
* @param {object} config.motion - Pose/locomotion callbacks from `createFigurePose` (`applyActorLinks`, `clearActorLinks`, `faceTo`, `newMove`, `poseActor`, `setAfoot`, `takePose`, `travel`).
|
|
72
|
+
* @param {((x: number, y: number, z: number, size: number, d2: number, intensityScale?: number) => void)|null} [config.onFootShade=null] - Contact shadow callback for visible grounded actors.
|
|
73
|
+
* @param {(actor: object) => string} [config.idlePoseOf] - Resting pose for an outdoor actor (`'idle'` by default).
|
|
74
|
+
* @param {object} [config.sight] - Distance and LOD thresholds (all in metres).
|
|
75
|
+
* @param {number} [config.sight.orderAhead=40] - Margin beyond visibility at which worker bodies are requested.
|
|
76
|
+
* @param {number} [config.sight.seenWithin=230] - Visibility radius for idle actors at home.
|
|
77
|
+
* @param {number} [config.sight.seenInScene=420] - Visibility radius for actors participating in a scene.
|
|
78
|
+
* @param {Record<string, number>} [config.sight.kindRanges] - Per-kind visibility radius overrides (metres).
|
|
79
|
+
* @param {readonly [number, number]} [config.sight.bodyRange=[18.8, 21.2]] - Near-mesh enter/leave hysteresis (metres at unit lens).
|
|
80
|
+
* @param {number} [config.sight.nearRaise=32] - Reach (metres at unit lens) within which near geometry is ordered/raised.
|
|
81
|
+
* @param {number} [config.sight.nearDrop=90] - Reach (metres at unit lens) beyond which idle near geometry is disposed.
|
|
82
|
+
* @param {number} [config.sight.orbitRise=9] - Vertical oscillation amplitude (metres) for orbiting frame homes.
|
|
83
|
+
* @param {object} [config.shadows] - Per-kind contact shadow categories.
|
|
84
|
+
* @param {Iterable<string>} [config.shadows.unshadedKinds] - Airborne/unshaded kinds omitted from ground contact shadows.
|
|
85
|
+
* @param {Iterable<string>} [config.shadows.wideFootKinds] - Large quadruped/beast kinds given a wider contact shadow footprint.
|
|
86
|
+
*/
|
|
87
|
+
export function createCastManager({
|
|
88
|
+
stage = createHeadlessStage(),
|
|
89
|
+
camera,
|
|
90
|
+
getElapsed,
|
|
91
|
+
getDetailLens = () => 1,
|
|
92
|
+
getSpaceId = () => 'world',
|
|
93
|
+
getSpace = () => null,
|
|
94
|
+
isSpaceBuilt = () => true,
|
|
95
|
+
worldSpaceId = 'world',
|
|
96
|
+
resolvePlace = () => null,
|
|
97
|
+
worldGround = () => 0,
|
|
98
|
+
hash = DEFAULT_HASH,
|
|
99
|
+
defaultRange = 8,
|
|
100
|
+
motion,
|
|
101
|
+
onFootShade = null,
|
|
102
|
+
idlePoseOf = () => 'idle',
|
|
103
|
+
sight = {},
|
|
104
|
+
shadows = {},
|
|
105
|
+
}) {
|
|
106
|
+
const actors = {},
|
|
107
|
+
actorList = [],
|
|
108
|
+
frames = {};
|
|
109
|
+
const orderAhead = sight.orderAhead ?? DEFAULT_ORDER_AHEAD,
|
|
110
|
+
seenWithin = sight.seenWithin ?? DEFAULT_SEEN_WITHIN,
|
|
111
|
+
seenInScene = sight.seenInScene ?? DEFAULT_SEEN_IN_SCENE,
|
|
112
|
+
kindRanges = sight.kindRanges ?? {},
|
|
113
|
+
bodyRange = sight.bodyRange ?? DEFAULT_BODY_RANGE,
|
|
114
|
+
nearRaise = sight.nearRaise ?? DEFAULT_NEAR_RAISE,
|
|
115
|
+
nearDrop = sight.nearDrop ?? DEFAULT_NEAR_DROP,
|
|
116
|
+
orbitRise = sight.orbitRise ?? DEFAULT_ORBIT_RISE;
|
|
117
|
+
const unshadedKinds = new Set(shadows.unshadedKinds ?? []),
|
|
118
|
+
wideFootKinds = new Set(shadows.wideFootKinds ?? []);
|
|
119
|
+
|
|
120
|
+
const homeOptions = {
|
|
121
|
+
isSpaceBuilt,
|
|
122
|
+
getSpace,
|
|
123
|
+
resolvePlace,
|
|
124
|
+
worldGround,
|
|
125
|
+
defaultRange,
|
|
126
|
+
worldSpaceId,
|
|
127
|
+
setAfoot: motion.setAfoot,
|
|
128
|
+
idlePoseOf,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const sightDistance = actor => kindRanges[actor.kind] ?? (actor.inScene ? seenInScene : seenWithin);
|
|
132
|
+
|
|
133
|
+
function setHomeFrame(name, frame) {
|
|
134
|
+
frames[name] = frame;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function actorHome(actor) {
|
|
138
|
+
placeActorAtHome(actor, homeOptions);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function onSpaceBuilt(spaceId) {
|
|
142
|
+
for (let i = 0; i < actorList.length; i++) {
|
|
143
|
+
const a = actorList[i];
|
|
144
|
+
if (a.home?.in === spaceId && !a.inScene) actorHome(a);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function buildActors(definitions, { hasGrip = () => false } = {}) {
|
|
149
|
+
let n = 0;
|
|
150
|
+
const echoes = [];
|
|
151
|
+
const enlist = (id, def, seed, home) => {
|
|
152
|
+
const a = createCastActor(id, def, stage.standIn(def.look), n++, { hash, defaultRange, defaultSpace: worldSpaceId });
|
|
153
|
+
a.figureSeed = seed;
|
|
154
|
+
a.home = home;
|
|
155
|
+
actorList.push(a);
|
|
156
|
+
return a;
|
|
157
|
+
};
|
|
158
|
+
for (const id in definitions) {
|
|
159
|
+
const own = definitions[id],
|
|
160
|
+
def = hasGrip(id, own) ? withGrip(own) : own,
|
|
161
|
+
homes = homesOf(def),
|
|
162
|
+
a = enlist(id, def, actorNameSeed(id), homes[0] || null);
|
|
163
|
+
actors[id] = a;
|
|
164
|
+
actorHome(a);
|
|
165
|
+
for (let k = 1; k < homes.length; k++) echoes.push([a, homes[k], k]);
|
|
166
|
+
}
|
|
167
|
+
if (actorList.some(a => a.active)) stage.warmDefaultPrograms();
|
|
168
|
+
stage.readyWorkerBodies();
|
|
169
|
+
for (const [person, home, k] of echoes) {
|
|
170
|
+
const e = enlist(person.id + '@' + k, person.def, person.figureSeed, home);
|
|
171
|
+
e.primary = person;
|
|
172
|
+
actorHome(e);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function actorPlace(actor, x, z, yaw, y) {
|
|
177
|
+
placeCastActor(actor, x, z, yaw, y);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function actorMoveTo(actor, x, z, dur, y, how) {
|
|
181
|
+
actor.move = motion.newMove(actor, x, z, dur, y, how);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const turnActor = motion.faceTo;
|
|
185
|
+
|
|
186
|
+
function settlePose(actor) {
|
|
187
|
+
settleCastPose(actor, motion.takePose);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const raiseActor = (actor, near = true) => stage.raiseActor(actor, near);
|
|
191
|
+
const orderCast = ids => stage.orderCast(actors, ids);
|
|
192
|
+
const prepareCast = ids => stage.prepareCast(actors, ids);
|
|
193
|
+
const releaseCast = ids => stage.releaseCast(actors, ids);
|
|
194
|
+
|
|
195
|
+
async function raiseInSight() {
|
|
196
|
+
const lens = getDetailLens(),
|
|
197
|
+
due = actorList.filter(a => !a.built && a.dist < sightDistance(a)),
|
|
198
|
+
near = a => a.dist < nearRaise * lens * a.group.scale.y;
|
|
199
|
+
for (const a of due) stage.orderActor(a, near(a));
|
|
200
|
+
await Promise.all(due.flatMap(a => [a.order?.done, a.nearOrder?.done]));
|
|
201
|
+
for (const a of due) stage.raiseActor(a, near(a));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function orderSeenFrom(land, x, y, z) {
|
|
205
|
+
const t = getElapsed();
|
|
206
|
+
for (let i = 0; i < actorList.length; i++) {
|
|
207
|
+
const a = actorList[i];
|
|
208
|
+
if (a.built || !isActorInPlay(a, t, land, frames, orbitRise)) continue;
|
|
209
|
+
const reach = Math.hypot(a.x - x, a.y - y, a.z - z);
|
|
210
|
+
if (reach < sightDistance(a)) stage.orderActor(a, reach / a.group.scale.y < nearRaise);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function nearBodyFor(a, reach) {
|
|
215
|
+
if (reach < nearRaise) stage.orderActor(a, true);
|
|
216
|
+
if (a.nearBuilt) {
|
|
217
|
+
if (reach > nearDrop && !a.inScene) stage.dropNear(a);
|
|
218
|
+
} else if (a.nearOrder?.bodies) {
|
|
219
|
+
if (reach > nearDrop) a.nearOrder = a.nearOrder.cast ? a.nearOrder : null;
|
|
220
|
+
else stage.buildNearBody(a);
|
|
221
|
+
} else if (reach < nearRaise && !pending(a.nearOrder)) stage.buildNearBody(a);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function nearOrFar(a, d2, scale) {
|
|
225
|
+
const near = a.nearBuilt && (a.inScene || withinDetailRange(d2, a.hi.visible, scale, bodyRange));
|
|
226
|
+
if (a.hi.visible !== near) {
|
|
227
|
+
a.hi.visible = near;
|
|
228
|
+
a.lo.visible = !near;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function emitContactShadow(a, d2) {
|
|
233
|
+
if (!onFootShade || a.home?.on || (a.link && a.link.kind !== 'holdBack') || unshadedKinds.has(a.kind)) return;
|
|
234
|
+
const sy = a.group.scale.y;
|
|
235
|
+
if (a.mount) {
|
|
236
|
+
const hx = Math.sin(a.yaw) * 0.52,
|
|
237
|
+
hz = Math.cos(a.yaw) * 0.52;
|
|
238
|
+
onFootShade(a.x + hx, a.y, a.z + hz, 1.35, d2, 0.92);
|
|
239
|
+
onFootShade(a.x - hx, a.y, a.z - hz, 1.35, d2, 0.92);
|
|
240
|
+
} else if (a.pose === 'dead' || a.pose === 'lie' || a.pose === 'prone') {
|
|
241
|
+
const dir = (a.fall || 1) * 0.42 * sy,
|
|
242
|
+
bx = Math.sin(a.yaw) * dir,
|
|
243
|
+
bz = Math.cos(a.yaw) * dir;
|
|
244
|
+
onFootShade(a.x - bx * 0.5, a.y, a.z - bz * 0.5, sy * 1.15, d2, 1.05);
|
|
245
|
+
onFootShade(a.x - bx * 1.65, a.y, a.z - bz * 1.65, sy * 1.05, d2, 0.95);
|
|
246
|
+
} else if (wideFootKinds.has(a.kind)) {
|
|
247
|
+
onFootShade(a.x, a.y, a.z, sy * 1.45, d2, 0.95);
|
|
248
|
+
} else {
|
|
249
|
+
onFootShade(a.x, a.y, a.z, sy * (a.pose === 'sit' || a.pose === 'sittalk' ? 1.18 : 1), d2);
|
|
250
|
+
}
|
|
251
|
+
const extraMount = a.loose || a.beside;
|
|
252
|
+
if (extraMount?.H?.mesh?.parent) {
|
|
253
|
+
const mp = extraMount.H.mesh.position;
|
|
254
|
+
onFootShade(mp.x, mp.y, mp.z, 1.55, d2, 0.9);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function updateActors(dt) {
|
|
259
|
+
const t = getElapsed(),
|
|
260
|
+
lens = getDetailLens(),
|
|
261
|
+
currentSpace = getSpaceId(),
|
|
262
|
+
cx = camera.position.x,
|
|
263
|
+
cy = camera.position.y,
|
|
264
|
+
cz = camera.position.z;
|
|
265
|
+
for (let i = 0; i < actorList.length; i++) {
|
|
266
|
+
const a = actorList[i];
|
|
267
|
+
if (!isActorInPlay(a, t, currentSpace, frames, orbitRise)) {
|
|
268
|
+
if (!a.preparing && a.group.visible) a.group.visible = false;
|
|
269
|
+
a.dist = 1e9;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (a.home && a.home.on && !a.inScene && !a.move) {
|
|
273
|
+
a.px = a.x;
|
|
274
|
+
a.pz = a.z;
|
|
275
|
+
}
|
|
276
|
+
motion.travel(a, dt);
|
|
277
|
+
const dx = a.x - cx,
|
|
278
|
+
dy = a.y - cy,
|
|
279
|
+
dz = a.z - cz,
|
|
280
|
+
d2 = dx * dx + dy * dy + dz * dz,
|
|
281
|
+
d = (a.dist = Math.sqrt(d2)),
|
|
282
|
+
scale = lens * a.group.scale.y,
|
|
283
|
+
reach = d / scale;
|
|
284
|
+
const limit = sightDistance(a),
|
|
285
|
+
seen = d < limit;
|
|
286
|
+
if (!a.built) {
|
|
287
|
+
if (d < limit + orderAhead) stage.orderActor(a, reach < nearRaise);
|
|
288
|
+
if (seen && !pending(a.order)) stage.buildVisibleActor(a, reach < nearRaise && !pending(a.nearOrder));
|
|
289
|
+
}
|
|
290
|
+
if (!a.built) continue;
|
|
291
|
+
if (a.group.visible !== seen) a.group.visible = seen;
|
|
292
|
+
if (!seen) continue;
|
|
293
|
+
emitContactShadow(a, d2);
|
|
294
|
+
if (a.nearLater) nearBodyFor(a, reach);
|
|
295
|
+
if (a.lo) nearOrFar(a, d2, scale);
|
|
296
|
+
motion.poseActor(a, i, dt, t);
|
|
297
|
+
}
|
|
298
|
+
motion.applyActorLinks(dt);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
actorHome,
|
|
303
|
+
actorList,
|
|
304
|
+
actorMoveTo,
|
|
305
|
+
actorPlace,
|
|
306
|
+
actors,
|
|
307
|
+
buildActors,
|
|
308
|
+
clearActorLinks: motion.clearActorLinks,
|
|
309
|
+
onSpaceBuilt,
|
|
310
|
+
orderCast,
|
|
311
|
+
orderSeenFrom,
|
|
312
|
+
prepareCast,
|
|
313
|
+
raiseActor,
|
|
314
|
+
raiseInSight,
|
|
315
|
+
releaseCast,
|
|
316
|
+
setHomeFrame,
|
|
317
|
+
settlePose,
|
|
318
|
+
turnActor,
|
|
319
|
+
updateActors,
|
|
320
|
+
};
|
|
321
|
+
}
|