roamwright 0.4.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +21 -14
- package/README.md +38 -42
- 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/bedding.js +141 -0
- package/geometry/builder-cells.js +50 -0
- package/geometry/builder-frame.js +48 -0
- package/geometry/builder.js +200 -177
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cell-mask.js +25 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +40 -35
- 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 +44 -39
- package/geometry/erosion.js +71 -45
- package/geometry/face-grid.js +85 -65
- 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 +187 -14
- 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 +57 -42
- package/geometry/hair-locks.js +42 -42
- package/geometry/hair-patch.js +24 -20
- package/geometry/hair-shell.js +43 -31
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +26 -15
- package/geometry/head-shape.js +123 -95
- package/geometry/heightfield.js +50 -24
- 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/index-parts.js +2 -2
- package/geometry/instance-visibility.js +12 -12
- package/geometry/instances.js +17 -17
- 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 +11 -10
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +38 -3
- package/geometry/path-field.js +98 -34
- package/geometry/placement.js +52 -52
- 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/point-buckets.js +50 -0
- package/geometry/primitives.js +117 -59
- 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/sagging-tube.js +27 -27
- package/geometry/sampled-surface.js +123 -77
- package/geometry/scatter-grid.js +49 -6
- package/geometry/sculpt.js +97 -93
- 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 +81 -34
- package/geometry/strata-field.js +131 -98
- package/geometry/strata-tiles.js +108 -94
- package/geometry/stream.js +96 -59
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +216 -123
- package/geometry/terrain-extension.js +29 -13
- 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 +138 -2
- package/math/cell-edge.js +16 -16
- package/math/cell-key.js +6 -0
- package/math/circle-clearances.js +19 -0
- package/math/cloth-textures.js +6 -6
- package/math/cloud-textures.js +22 -26
- package/math/color.js +14 -14
- package/math/curve.js +26 -22
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +379 -205
- package/math/noise.js +101 -49
- package/math/particle-noise.js +28 -28
- package/math/periodic.js +11 -5
- package/math/random.js +24 -15
- package/math/rectangles.js +58 -0
- package/math/rock-texture.js +22 -17
- package/math/scalar.js +5 -5
- package/math/surface-textures.js +74 -59
- 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 +27 -26
- package/motion/ballistic-arc.js +191 -0
- package/motion/biped-cycle.js +46 -0
- package/motion/biped-leg.js +40 -0
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +226 -140
- package/motion/boat-sailing.js +214 -0
- package/motion/contact-transition.js +32 -0
- package/motion/crowd-alarms.js +72 -42
- 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 +126 -67
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/daily-clock.js +9 -9
- package/motion/deck-surface.js +40 -0
- 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/ground-lookahead.js +5 -5
- package/motion/instance-sight.js +15 -8
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +41 -32
- package/motion/quadruped.js +244 -168
- package/motion/spaces.js +90 -38
- 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 +133 -26
- package/motion/wind.js +58 -13
- package/package.json +33 -6
- 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/cart-track.js +92 -0
- package/rendering/caster-motion.js +6 -5
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +754 -113
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +30 -30
- package/rendering/cloud-field.js +2 -2
- package/rendering/compilation-schedule.js +79 -14
- package/rendering/contact-shadows.js +7 -4
- package/rendering/context.js +57 -6
- 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 +62 -19
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/crust.js +18 -12
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +4 -6
- package/rendering/detail-range.js +29 -0
- package/rendering/dispose-meshes.js +18 -0
- package/rendering/dof.js +20 -13
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/eye-adapt.js +14 -14
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +89 -62
- 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 +82 -78
- package/rendering/garment-material.js +147 -51
- package/rendering/glow-lines.js +13 -13
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +45 -31
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +164 -22
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +56 -0
- package/rendering/label-range.js +41 -0
- 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 +71 -55
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +39 -8
- package/rendering/material-lod.js +49 -50
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +135 -99
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +212 -101
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +298 -11
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +806 -103
- 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 +98 -31
- package/rendering/post.js +107 -87
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/rain-streaks.js +67 -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 +94 -37
- 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 +101 -44
- package/rendering/shadow-alignment.js +4 -4
- package/rendering/shadow-depth.js +47 -25
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +56 -29
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +126 -54
- 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 +65 -26
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +12 -12
- package/rendering/stream-flow.js +10 -10
- 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 +75 -44
- package/rendering/talus.js +15 -15
- package/rendering/terrain-rock.js +7 -7
- package/rendering/texture-fills.js +8 -8
- package/rendering/textures.js +28 -28
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/wakes.js +24 -24
- package/rendering/water-material.js +304 -103
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +38 -40
- 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 +12 -4
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +36 -28
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +47 -0
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +15 -11
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +44 -5
- package/runtime/hand-over.js +47 -24
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +73 -17
- package/runtime/quality-fit.js +60 -28
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +26 -22
- 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 +79 -30
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +46 -0
- package/runtime/worker.js +7 -0
- 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
- package/rendering/road-surface.js +0 -63
package/runtime/first-use.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
export function createFirstUse({ renderer, waitMs = 250, now = () => performance.now() }) {
|
|
7
7
|
const initialized = new WeakSet();
|
|
8
8
|
const waiting = [];
|
|
9
|
-
const asked = [];
|
|
10
9
|
let frameBegan = -Infinity;
|
|
11
10
|
|
|
12
11
|
function useProgram(program) {
|
|
@@ -21,42 +20,51 @@ export function createFirstUse({ renderer, waitMs = 250, now = () => performance
|
|
|
21
20
|
renderer.debug.checkShaderErrors = previous;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
const [programs, resolve] = asked[i];
|
|
27
|
-
if (programs.some(p => waiting.includes(p))) continue;
|
|
28
|
-
asked.splice(i, 1);
|
|
29
|
-
resolve();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function putToUse(programs) {
|
|
23
|
+
function putToUse(programs, signal) {
|
|
24
|
+
if (signal?.aborted) return Promise.reject(signal.reason);
|
|
33
25
|
if (!programs.length) return Promise.resolve();
|
|
34
26
|
if (now() - frameBegan > waitMs) {
|
|
35
27
|
programs.forEach(useProgram);
|
|
36
28
|
return Promise.resolve();
|
|
37
29
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const request = { remaining: programs.length, finish, fail };
|
|
32
|
+
const timer = setTimeout(drainRequest, waitMs * (programs.length + 1));
|
|
33
|
+
for (const program of programs) waiting.push({ program, request });
|
|
34
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
35
|
+
function finish() {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
signal?.removeEventListener('abort', abort);
|
|
38
|
+
resolve();
|
|
39
|
+
}
|
|
40
|
+
function fail(error) {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
signal?.removeEventListener('abort', abort);
|
|
43
|
+
for (let i = waiting.length - 1; i >= 0; i--) if (waiting[i].request === request) waiting.splice(i, 1);
|
|
44
|
+
reject(error);
|
|
45
|
+
}
|
|
46
|
+
function abort() {
|
|
47
|
+
fail(signal.reason);
|
|
48
|
+
}
|
|
49
|
+
function drainRequest() {
|
|
50
|
+
for (let i = 0; i < waiting.length; ) {
|
|
51
|
+
if (waiting[i].request === request) useOne(waiting.splice(i, 1)[0]);
|
|
52
|
+
else i++;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
53
55
|
});
|
|
54
56
|
}
|
|
57
|
+
function useOne({ program, request }) {
|
|
58
|
+
try {
|
|
59
|
+
useProgram(program);
|
|
60
|
+
if (--request.remaining === 0) request.finish();
|
|
61
|
+
} catch (error) {
|
|
62
|
+
request.fail(error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
55
65
|
function useAtFrameStart() {
|
|
56
66
|
frameBegan = now();
|
|
57
|
-
if (
|
|
58
|
-
useProgram(waiting.shift());
|
|
59
|
-
settle();
|
|
67
|
+
if (waiting.length) useOne(waiting.shift());
|
|
60
68
|
}
|
|
61
69
|
return { putToUse, useAtFrameStart, useProgram };
|
|
62
70
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sound of a scripted scene's steps as they fire: a blade drawn or sheathed, a bow loosed, the rustle of a sudden movement,
|
|
3
|
+
* a guard taken or a knee bent, a splash or a heavy fall where a burst is thrown. Each is played where it happens, through a
|
|
4
|
+
* soundscape (`createSoundscape`), and only while it can sound.
|
|
5
|
+
*
|
|
6
|
+
* A step is `[seconds, verb, who, …]` as a scene's script holds it:
|
|
7
|
+
* - `['act', who, act]`: an act of a walker (`drawActs`, `sheatheActs`, `looseActs`, `rustleActs`);
|
|
8
|
+
* - `['pose', who, pose]`: a walker taking a pose (`guardPose` draws a sheathed weapon, `lowPoses` rustle);
|
|
9
|
+
* - `['beam', kind, from, to, seconds]`: told to `onBeam` at its middle;
|
|
10
|
+
* - `['burst', kind, at, _, size]`: `spray` splashes, a large `dust` thuds, any other kind is told to `onBurst`.
|
|
11
|
+
*
|
|
12
|
+
* Points (`from`, `to`, `at`) are found by the world's `pointOf`: a walker's name, or a place in the scene.
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { clamp } from '../math/scalar.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Acts after which a walker's clothes and gear rustle, by default.
|
|
20
|
+
* @type {ReadonlySet<string>}
|
|
21
|
+
*/
|
|
22
|
+
export const RUSTLE_ACTS = new Set(['recoil', 'flinch', 'throw', 'punch', 'bow', 'cheer', 'lift', 'setDown']);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Makes the sound of a scene's steps.
|
|
26
|
+
*
|
|
27
|
+
* @param {object} options
|
|
28
|
+
* @param {object} options.sound A soundscape (`createSoundscape`).
|
|
29
|
+
* @param {(who: string) => object | undefined} options.walkerOf The walker a step names, if there is one: `x`, `y`, `z` (metres).
|
|
30
|
+
* @param {(spec: unknown, anchor: object, out: { x: number, y: number, z: number }) => boolean} options.pointOf Writes where a
|
|
31
|
+
* step's point is into `out`, from the scene's anchor; false if it is nowhere.
|
|
32
|
+
* @param {(walker: object) => boolean} [options.active] Whether a walker is in the scene now.
|
|
33
|
+
* @param {(walker: object) => boolean} [options.heavy] Whether a walker's weapon is heavy (a deeper draw and sheathe).
|
|
34
|
+
* @param {(walker: object) => boolean} [options.armoured] Whether a walker wears armour or metal gear (a clink in its rustle).
|
|
35
|
+
* @param {(walker: object) => boolean} [options.sheathed] Whether a walker carries a weapon sheathed, drawn on taking guard.
|
|
36
|
+
* @param {(kind: string, seconds: number, x: number, y: number, z: number) => void} [options.onBeam] Plays a beam of a kind,
|
|
37
|
+
* lasting `seconds`, at its middle.
|
|
38
|
+
* @param {(kind: string, size: number, x: number, y: number, z: number) => void} [options.onBurst] Plays a burst of a kind the
|
|
39
|
+
* engine does not sound itself.
|
|
40
|
+
* @param {Iterable<string>} [options.drawActs=['draw', 'drawBack']]
|
|
41
|
+
* @param {Iterable<string>} [options.sheatheActs=['sheathe', 'sheatheBack']]
|
|
42
|
+
* @param {Iterable<string>} [options.looseActs=['loose', 'looseBow']]
|
|
43
|
+
* @param {Iterable<string>} [options.rustleActs=RUSTLE_ACTS]
|
|
44
|
+
* @param {string} [options.guardPose='guard']
|
|
45
|
+
* @param {Iterable<string>} [options.lowPoses=['kneel', 'crouch', 'cower']]
|
|
46
|
+
* @param {number} [options.heavyDust=2.4] The size from which a burst of dust is a heavy fall, heard as a thud.
|
|
47
|
+
* @returns {(step: unknown[], anchor: object) => void} Plays a step's sound as it fires.
|
|
48
|
+
*/
|
|
49
|
+
export function createScriptFoley({
|
|
50
|
+
sound,
|
|
51
|
+
walkerOf,
|
|
52
|
+
pointOf,
|
|
53
|
+
active = () => true,
|
|
54
|
+
heavy = () => false,
|
|
55
|
+
armoured = () => false,
|
|
56
|
+
sheathed = () => false,
|
|
57
|
+
onBeam = () => {},
|
|
58
|
+
onBurst = () => {},
|
|
59
|
+
drawActs = ['draw', 'drawBack'],
|
|
60
|
+
sheatheActs = ['sheathe', 'sheatheBack'],
|
|
61
|
+
looseActs = ['loose', 'looseBow'],
|
|
62
|
+
rustleActs = RUSTLE_ACTS,
|
|
63
|
+
guardPose = 'guard',
|
|
64
|
+
lowPoses = ['kneel', 'crouch', 'cower'],
|
|
65
|
+
heavyDust = 2.4,
|
|
66
|
+
}) {
|
|
67
|
+
const drawing = new Set(drawActs),
|
|
68
|
+
sheathing = new Set(sheatheActs),
|
|
69
|
+
loosing = new Set(looseActs),
|
|
70
|
+
rustling = new Set(rustleActs),
|
|
71
|
+
low = new Set(lowPoses),
|
|
72
|
+
from = { x: 0, y: 0, z: 0 },
|
|
73
|
+
to = { x: 0, y: 0, z: 0 };
|
|
74
|
+
|
|
75
|
+
return function scriptFoley(step, anchor) {
|
|
76
|
+
if (!sound.ready()) return;
|
|
77
|
+
const verb = step[1],
|
|
78
|
+
a = typeof step[2] === 'string' ? walkerOf(step[2]) : null;
|
|
79
|
+
|
|
80
|
+
if (verb === 'act' && a && active(a)) {
|
|
81
|
+
const act = step[3],
|
|
82
|
+
y = a.y + 1.1;
|
|
83
|
+
if (drawing.has(act)) {
|
|
84
|
+
const weighty = heavy(a);
|
|
85
|
+
sound.placed(a.x, y, a.z, () => sound.drawBlade(weighty), 65);
|
|
86
|
+
} else if (sheathing.has(act)) {
|
|
87
|
+
const weighty = heavy(a);
|
|
88
|
+
sound.placed(a.x, y, a.z, () => sound.sheatheBlade(weighty), 65);
|
|
89
|
+
} else if (loosing.has(act)) {
|
|
90
|
+
sound.placed(a.x, y + 0.3, a.z, () => sound.bowLoose(false), 90);
|
|
91
|
+
} else if (rustling.has(act)) {
|
|
92
|
+
const metal = armoured(a);
|
|
93
|
+
sound.placed(a.x, y, a.z, () => sound.rustle(metal), 42);
|
|
94
|
+
}
|
|
95
|
+
} else if (verb === 'pose' && a && active(a)) {
|
|
96
|
+
const pose = step[3];
|
|
97
|
+
if (pose === guardPose && sheathed(a)) {
|
|
98
|
+
const weighty = heavy(a);
|
|
99
|
+
sound.placed(a.x, a.y + 1.1, a.z, () => sound.drawBlade(weighty), 60);
|
|
100
|
+
} else if (low.has(pose)) {
|
|
101
|
+
const metal = armoured(a);
|
|
102
|
+
sound.placed(a.x, a.y + 0.7, a.z, () => sound.rustle(metal), 35);
|
|
103
|
+
}
|
|
104
|
+
} else if (verb === 'beam') {
|
|
105
|
+
const kind = step[2],
|
|
106
|
+
seconds = step[5] || 1;
|
|
107
|
+
const hasFrom = pointOf(step[3], anchor, from),
|
|
108
|
+
hasTo = pointOf(step[4], anchor, to);
|
|
109
|
+
if (!hasFrom && !hasTo) return;
|
|
110
|
+
const mx = hasFrom && hasTo ? (from.x + to.x) * 0.5 : hasFrom ? from.x : to.x,
|
|
111
|
+
my = hasFrom && hasTo ? (from.y + to.y) * 0.5 : hasFrom ? from.y : to.y,
|
|
112
|
+
mz = hasFrom && hasTo ? (from.z + to.z) * 0.5 : hasFrom ? from.z : to.z;
|
|
113
|
+
onBeam(kind, seconds, mx, my, mz);
|
|
114
|
+
} else if (verb === 'burst') {
|
|
115
|
+
const kind = step[2],
|
|
116
|
+
size = step[5] || 1;
|
|
117
|
+
if (!pointOf(step[3], anchor, from)) return;
|
|
118
|
+
if (kind === 'spray') sound.placed(from.x, from.y, from.z, () => sound.splash(size), 120);
|
|
119
|
+
else if (kind === 'dust' && size >= heavyDust) {
|
|
120
|
+
sound.placed(from.x, from.y, from.z, () => sound.thud(clamp(size * 0.08, 0.14, 0.35)), 140);
|
|
121
|
+
} else onBurst(kind, size, from.x, from.y, from.z);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footfalls of a scene's cast, seen and heard: each walker is followed by the distance it covers, and at every stride (a boot's,
|
|
3
|
+
* or a hoof's in a four-beat gait) the ground under that foot answers by its kind: a splash in shallow water, mud flecks and a
|
|
4
|
+
* wet print in mud, a puff of dust or ash and a print in sand, ash or earth, sparks off stone under a galloping hoof. The same
|
|
5
|
+
* footfall is heard through a soundscape (`createSoundscape`) when it can sound; the dust and prints come whether it can or not.
|
|
6
|
+
* Lunges and falls raise the same kinds of dust (`scuff`, `bodyFall`), and aboard a ship the timbers creak now and then.
|
|
7
|
+
*
|
|
8
|
+
* The world tells the ground's kind under a point (`surfaceAt`), and draws the bursts and prints (`burst`, `print`): the kinds
|
|
9
|
+
* of burst asked for are `spray`, `mud`, `dust`, `ash` and `gold` (sparks), as `createParticleBursts` knows them. Nothing is
|
|
10
|
+
* allocated in `update`.
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { clamp } from '../math/scalar.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The ground under a point, as `surfaceAt` tells it.
|
|
18
|
+
* @typedef {object} FoleySurface
|
|
19
|
+
* @property {'water' | 'mud' | 'ash' | 'sand' | 'earth' | 'stone' | 'wood' | string} kind What a foot meets.
|
|
20
|
+
* @property {'earth' | 'sand' | 'stone' | 'wood'} audioKind How a footfall on it sounds (`footstep`).
|
|
21
|
+
* @property {number} waterY The water's surface over it, metres, where `kind` is `water`.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Makes the footfalls of a scene's cast. Call `begin()` and `follow(walker)` for each of the cast when a scene starts,
|
|
26
|
+
* `update(dt)` once a frame while it plays, and `clear()` when it ends. A walker is any record with `x`, `y`, `z` (metres, its
|
|
27
|
+
* feet) and `yaw` (radians, turned from +z towards +x).
|
|
28
|
+
*
|
|
29
|
+
* @param {object} options
|
|
30
|
+
* @param {object} options.sound A soundscape (`createSoundscape`): `ready`, `placed`, `footstep`, `splash`, `timberCreak`.
|
|
31
|
+
* @param {(x: number, y: number, z: number) => FoleySurface} options.surfaceAt The ground under a foot at (x, y, z); the record may
|
|
32
|
+
* be reused between calls.
|
|
33
|
+
* @param {(x: number, z: number) => number} options.groundAt The ground's height at (x, z), metres.
|
|
34
|
+
* @param {() => { x: number, z: number }} options.listenerAt Where the camera is: footfalls far from it are not shown or heard.
|
|
35
|
+
* @param {(kind: string, x: number, y: number, z: number, count: number, size: number, speed: number) => void} options.burst
|
|
36
|
+
* Throws out a burst of particles of a kind.
|
|
37
|
+
* @param {(kind: 'boot' | 'hoof', x: number, y: number, z: number, yaw: number, scale: number, wet: boolean) => void} options.print
|
|
38
|
+
* Leaves a print in the ground.
|
|
39
|
+
* @param {(walker: object, dust: number, sweat: number) => void} [options.wear] Adds dust and sweat to a walker's clothes.
|
|
40
|
+
* @param {(x: number, y: number, z: number, strength: number) => void} [options.shake] Shakes a camera near a galloping hoof.
|
|
41
|
+
* @param {(walker: object) => boolean} [options.active] Whether a walker is in the scene now (a storm's dust settles on it).
|
|
42
|
+
* @param {(walker: object) => boolean} [options.tracks] Whether a walker's feet raise footfalls now: not one lying dead, carried,
|
|
43
|
+
* or flying.
|
|
44
|
+
* @param {(walker: object) => 'feet' | 'hooves' | 'none'} [options.gait] How a walker goes: on two feet, on hooves (a horse and its
|
|
45
|
+
* rider), or on feet that leave no mark worth showing.
|
|
46
|
+
* @param {(walker: object) => number} [options.bodyScale] A walker's size against a grown person's (its prints' and step's scale).
|
|
47
|
+
* @param {() => number} [options.dustStorm] How thick a storm's dust is (0: none); it settles on the cast at 0.025 of it a second.
|
|
48
|
+
* @param {() => boolean} [options.aboard] Whether the scene is on a ship's deck (its timbers creak).
|
|
49
|
+
* @param {() => number} [options.gust] The wind's gust, 0 to 1: the timbers creak more often and louder in it.
|
|
50
|
+
* @param {() => number} [options.random] Numbers in [0, 1) (Math.random by default).
|
|
51
|
+
* @param {number} [options.stepStride=0.82] Metres between two footfalls of a walker.
|
|
52
|
+
* @param {number} [options.hoofStride=1.05] Metres between two hoof beats of a mount.
|
|
53
|
+
* @param {number} [options.stepHeard=38] Metres within which a footfall is heard.
|
|
54
|
+
* @param {number} [options.stepShown=54] Metres within which a footfall raises dust, splashes or prints.
|
|
55
|
+
* @param {number} [options.hoofShown=76] Metres within which a hoof does.
|
|
56
|
+
* @param {number} [options.heardPerFrame=2] Footfalls heard in one frame at most, however large the cast.
|
|
57
|
+
* @param {number} [options.shownPerFrame=6] Footfalls that throw a burst in one frame at most.
|
|
58
|
+
* @returns {{ begin: () => void, follow: (walker: object) => void, update: (dt: number) => void, clear: () => void,
|
|
59
|
+
* scuff: (x: number, y: number, z: number, intensity?: number) => void, bodyFall: (x: number, y: number, z: number) => void }}
|
|
60
|
+
*/
|
|
61
|
+
export function createStrideFoley({
|
|
62
|
+
sound,
|
|
63
|
+
surfaceAt,
|
|
64
|
+
groundAt,
|
|
65
|
+
listenerAt,
|
|
66
|
+
burst,
|
|
67
|
+
print,
|
|
68
|
+
wear = () => {},
|
|
69
|
+
shake = () => {},
|
|
70
|
+
active = () => true,
|
|
71
|
+
tracks = () => true,
|
|
72
|
+
gait = () => 'feet',
|
|
73
|
+
bodyScale = () => 1,
|
|
74
|
+
dustStorm = () => 0,
|
|
75
|
+
aboard = () => false,
|
|
76
|
+
gust = () => 0,
|
|
77
|
+
random = () => Math.random(),
|
|
78
|
+
stepStride = 0.82,
|
|
79
|
+
hoofStride = 1.05,
|
|
80
|
+
stepHeard = 38,
|
|
81
|
+
stepShown = 54,
|
|
82
|
+
hoofShown = 76,
|
|
83
|
+
heardPerFrame = 2,
|
|
84
|
+
shownPerFrame = 6,
|
|
85
|
+
}) {
|
|
86
|
+
const followed = new WeakMap(), // walker -> { x, z, gone, side, beat }, made once a walker and reused
|
|
87
|
+
cast = [],
|
|
88
|
+
counts = { heard: 0, shown: 0 };
|
|
89
|
+
let creakIn = 1.6;
|
|
90
|
+
|
|
91
|
+
// A boot's fall: the foot on the side it is now, a hand's breadth off the walker's line.
|
|
92
|
+
function bootStep(a, rec, speed, distSq, canHear) {
|
|
93
|
+
rec.side = -rec.side;
|
|
94
|
+
const scale = bodyScale(a),
|
|
95
|
+
cos = Math.cos(a.yaw),
|
|
96
|
+
sin = Math.sin(a.yaw),
|
|
97
|
+
fx = a.x + cos * 0.1 * rec.side * scale,
|
|
98
|
+
fz = a.z - sin * 0.1 * rec.side * scale,
|
|
99
|
+
surf = surfaceAt(fx, a.y, fz),
|
|
100
|
+
running = speed > 2.4;
|
|
101
|
+
|
|
102
|
+
wear(
|
|
103
|
+
a,
|
|
104
|
+
surf.kind === 'sand' || surf.kind === 'ash' ? 0.015 : surf.kind === 'mud' ? 0.022 : surf.kind === 'earth' ? 0.008 : 0,
|
|
105
|
+
running ? 0.012 : 0.003,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
if (distSq <= stepShown * stepShown && counts.shown < shownPerFrame) {
|
|
109
|
+
if (surf.kind === 'water') {
|
|
110
|
+
burst('spray', fx, surf.waterY + 0.03, fz, running ? 6 : 3, running ? 0.34 : 0.22, running ? 2.4 : 1.5);
|
|
111
|
+
counts.shown++;
|
|
112
|
+
} else if (surf.kind === 'mud') {
|
|
113
|
+
burst('mud', fx, a.y + 0.04, fz, running ? 5 : 2, 0.22, running ? 2.1 : 1.3);
|
|
114
|
+
print('boot', fx, a.y, fz, a.yaw, scale, true);
|
|
115
|
+
counts.shown++;
|
|
116
|
+
} else if (surf.kind === 'sand') {
|
|
117
|
+
burst('dust', fx, a.y + 0.05, fz, running ? 3 : 1, running ? 0.42 : 0.25, running ? 0.95 : 0.52);
|
|
118
|
+
print('boot', fx, a.y, fz, a.yaw, scale, false);
|
|
119
|
+
counts.shown++;
|
|
120
|
+
} else if (surf.kind === 'ash') {
|
|
121
|
+
burst('ash', fx, a.y + 0.05, fz, running ? 3 : 2, running ? 0.44 : 0.28, running ? 0.9 : 0.5);
|
|
122
|
+
print('boot', fx, a.y, fz, a.yaw, scale, false);
|
|
123
|
+
counts.shown++;
|
|
124
|
+
} else if (surf.kind === 'earth') {
|
|
125
|
+
print('boot', fx, a.y, fz, a.yaw, scale, false);
|
|
126
|
+
if (running) {
|
|
127
|
+
burst('dust', fx, a.y + 0.05, fz, 2, 0.32, 0.72);
|
|
128
|
+
counts.shown++;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (canHear && distSq <= stepHeard * stepHeard && counts.heard < heardPerFrame) {
|
|
134
|
+
const weight = clamp(0.65 + speed * 0.12, 0.65, 1.15);
|
|
135
|
+
if (surf.kind === 'water') sound.placed(fx, surf.waterY, fz, () => sound.splash(0.32), stepHeard);
|
|
136
|
+
else sound.placed(fx, a.y, fz, () => sound.footstep(surf.audioKind, weight), stepHeard);
|
|
137
|
+
counts.heard++;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// A hoof's strike, the next of a four-beat gait: fore and hind, left and right, about the mount's middle.
|
|
142
|
+
function hoofStep(a, rec, speed, distSq, canHear) {
|
|
143
|
+
const beat = (rec.beat = (rec.beat + 1) & 3),
|
|
144
|
+
fore = beat < 2 ? 0.46 : -0.46,
|
|
145
|
+
across = beat & 1 ? 0.18 : -0.18,
|
|
146
|
+
cos = Math.cos(a.yaw),
|
|
147
|
+
sin = Math.sin(a.yaw),
|
|
148
|
+
hx = a.x + sin * fore + cos * across,
|
|
149
|
+
hz = a.z + cos * fore - sin * across,
|
|
150
|
+
hy = groundAt(hx, hz),
|
|
151
|
+
surf = surfaceAt(hx, hy, hz),
|
|
152
|
+
gallop = clamp((speed - 2.2) / 4.5, 0, 1);
|
|
153
|
+
|
|
154
|
+
wear(a, surf.kind === 'sand' || surf.kind === 'ash' ? 0.014 : surf.kind === 'mud' ? 0.02 : 0.006, 0.004 + 0.01 * gallop);
|
|
155
|
+
|
|
156
|
+
if (beat === 0 && gallop > 0.45 && distSq < 28 * 28) shake(hx, hy, hz, clamp((speed - 3.2) * 0.045, 0.08, 0.24));
|
|
157
|
+
|
|
158
|
+
if (distSq <= hoofShown * hoofShown && counts.shown < shownPerFrame) {
|
|
159
|
+
if (surf.kind === 'water') {
|
|
160
|
+
burst('spray', hx, surf.waterY + 0.04, hz, 5 + Math.round(6 * gallop), 0.32 + 0.24 * gallop, 2.2 + 1.8 * gallop);
|
|
161
|
+
if (canHear && distSq <= stepHeard * stepHeard) {
|
|
162
|
+
sound.placed(hx, surf.waterY, hz, () => sound.splash(0.45 + 0.3 * gallop), stepHeard);
|
|
163
|
+
}
|
|
164
|
+
counts.shown++;
|
|
165
|
+
} else if (surf.kind === 'mud') {
|
|
166
|
+
burst('mud', hx, hy + 0.06, hz, 4 + Math.round(5 * gallop), 0.28 + 0.14 * gallop, 1.9 + 1.6 * gallop);
|
|
167
|
+
print('hoof', hx, hy, hz, a.yaw, 1.05, true);
|
|
168
|
+
counts.shown++;
|
|
169
|
+
} else if (surf.kind === 'sand' || surf.kind === 'ash') {
|
|
170
|
+
burst(
|
|
171
|
+
surf.kind === 'ash' ? 'ash' : 'dust',
|
|
172
|
+
hx,
|
|
173
|
+
hy + 0.08,
|
|
174
|
+
hz,
|
|
175
|
+
2 + Math.round(4 * gallop),
|
|
176
|
+
0.38 + 0.38 * gallop,
|
|
177
|
+
0.85 + 1.1 * gallop,
|
|
178
|
+
);
|
|
179
|
+
print('hoof', hx, hy, hz, a.yaw, 1, false);
|
|
180
|
+
counts.shown++;
|
|
181
|
+
} else if (surf.kind === 'earth') {
|
|
182
|
+
print('hoof', hx, hy, hz, a.yaw, 0.96, false);
|
|
183
|
+
if (speed > 2.1) {
|
|
184
|
+
burst('dust', hx, hy + 0.07, hz, 2 + Math.round(3 * gallop), 0.32 + 0.3 * gallop, 0.75 + 0.95 * gallop);
|
|
185
|
+
counts.shown++;
|
|
186
|
+
}
|
|
187
|
+
} else if (surf.kind === 'stone' && gallop > 0.4 && beat === 0) {
|
|
188
|
+
burst('gold', hx, hy + 0.04, hz, 3, 0.04, 2.2);
|
|
189
|
+
counts.shown++;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
/** Starts a new scene: no walker is followed until `follow`, and the timbers' next creak is a second or two off. */
|
|
196
|
+
begin() {
|
|
197
|
+
cast.length = 0;
|
|
198
|
+
creakIn = 1.2 + random() * 1.5;
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Follows a walker of the scene from where it stands now, its first footfall half a stride off.
|
|
203
|
+
* @param {object} walker
|
|
204
|
+
*/
|
|
205
|
+
follow(walker) {
|
|
206
|
+
cast.push(walker);
|
|
207
|
+
let rec = followed.get(walker);
|
|
208
|
+
if (!rec) {
|
|
209
|
+
rec = { x: walker.x, z: walker.z, gone: stepStride * 0.5, side: 1, beat: 0 };
|
|
210
|
+
followed.set(walker, rec);
|
|
211
|
+
} else {
|
|
212
|
+
rec.x = walker.x;
|
|
213
|
+
rec.z = walker.z;
|
|
214
|
+
rec.gone = stepStride * 0.5;
|
|
215
|
+
rec.side = 1;
|
|
216
|
+
rec.beat = 0;
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Once a frame: the footfalls of every walker that covered a stride, a storm's dust on the cast, and the timbers aboard.
|
|
222
|
+
* @param {number} dt Seconds since the last frame.
|
|
223
|
+
*/
|
|
224
|
+
update(dt) {
|
|
225
|
+
const canHear = sound.ready(),
|
|
226
|
+
at = listenerAt(),
|
|
227
|
+
cx = at.x,
|
|
228
|
+
cz = at.z,
|
|
229
|
+
storm = dustStorm(),
|
|
230
|
+
stormDust = storm > 0 ? storm * dt * 0.025 : 0;
|
|
231
|
+
counts.heard = 0;
|
|
232
|
+
counts.shown = 0;
|
|
233
|
+
|
|
234
|
+
for (let i = 0; i < cast.length; i++) {
|
|
235
|
+
const a = cast[i],
|
|
236
|
+
rec = followed.get(a);
|
|
237
|
+
if (!rec) continue;
|
|
238
|
+
if (stormDust && active(a)) wear(a, stormDust, 0);
|
|
239
|
+
const dx = a.x - rec.x,
|
|
240
|
+
dz = a.z - rec.z;
|
|
241
|
+
rec.x = a.x;
|
|
242
|
+
rec.z = a.z;
|
|
243
|
+
if (!tracks(a)) continue;
|
|
244
|
+
const moved = Math.hypot(dx, dz);
|
|
245
|
+
if (moved < 0.004 || moved > 2.8) continue; // idle jitter, or a walker set down somewhere else at once
|
|
246
|
+
const way = gait(a),
|
|
247
|
+
stride = way === 'hooves' ? hoofStride : stepStride;
|
|
248
|
+
rec.gone += moved;
|
|
249
|
+
if (rec.gone < stride) continue;
|
|
250
|
+
rec.gone -= stride;
|
|
251
|
+
if (rec.gone > stride) rec.gone = 0;
|
|
252
|
+
const distSq = (a.x - cx) * (a.x - cx) + (a.z - cz) * (a.z - cz),
|
|
253
|
+
speed = moved / Math.max(dt, 0.016);
|
|
254
|
+
if (way === 'hooves') hoofStep(a, rec, speed, distSq, canHear);
|
|
255
|
+
else if (way === 'feet') bootStep(a, rec, speed, distSq, canHear);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// The timbers and rigging of a ship creak now and then, more often in a gust, somewhere along its deck: the deck lies
|
|
259
|
+
// along z with its middle at the origin, as a ship's own space is built.
|
|
260
|
+
if (canHear && aboard()) {
|
|
261
|
+
const g = gust();
|
|
262
|
+
creakIn -= dt * (1 + 0.5 * g);
|
|
263
|
+
if (creakIn <= 0) {
|
|
264
|
+
creakIn = 2.6 + random() * 2.8;
|
|
265
|
+
const side = random() < 0.5 ? -1 : 1,
|
|
266
|
+
along = (random() - 0.5) * 18,
|
|
267
|
+
height = random() < 0.45 ? 4.5 : 0.6,
|
|
268
|
+
strength = 0.65 + 0.5 * gust();
|
|
269
|
+
sound.placed(side * 2.8, height, along, () => sound.timberCreak(strength), 60);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
/** Ends the scene: no walker is followed. */
|
|
275
|
+
clear() {
|
|
276
|
+
cast.length = 0;
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The ground's answer to a foot planted hard at (x, y, z), in a lunge, a parry or a dodge: a splash, mud and a wet print,
|
|
281
|
+
* ash or dust and a print; nothing on boards, a little dust off stone only at full force.
|
|
282
|
+
* @param {number} x Metres.
|
|
283
|
+
* @param {number} y Metres.
|
|
284
|
+
* @param {number} z Metres.
|
|
285
|
+
* @param {number} [intensity=1] 0 to 1.
|
|
286
|
+
*/
|
|
287
|
+
scuff(x, y, z, intensity = 1) {
|
|
288
|
+
const s = surfaceAt(x, y, z);
|
|
289
|
+
if (s.kind === 'wood') return;
|
|
290
|
+
if (s.kind === 'water') {
|
|
291
|
+
burst('spray', x, s.waterY + 0.03, z, Math.ceil(5 * intensity), 0.28 * intensity, 2.1);
|
|
292
|
+
} else if (s.kind === 'mud') {
|
|
293
|
+
burst('mud', x, y + 0.06, z, Math.ceil(5 * intensity), 0.26 * intensity, 1.9);
|
|
294
|
+
print('boot', x, y, z, random() * 6.28, 1.05, true);
|
|
295
|
+
} else if (s.kind === 'ash') {
|
|
296
|
+
burst('ash', x, y + 0.09, z, Math.ceil(4 * intensity), 0.52 * intensity, 0.9);
|
|
297
|
+
print('boot', x, y, z, random() * 6.28, 1.05, false);
|
|
298
|
+
} else if (s.kind === 'sand') {
|
|
299
|
+
burst('dust', x, y + 0.09, z, Math.ceil(4 * intensity), 0.55 * intensity, 0.95);
|
|
300
|
+
print('boot', x, y, z, random() * 6.28, 1.05, false);
|
|
301
|
+
} else if (s.kind === 'earth') {
|
|
302
|
+
burst('dust', x, y + 0.08, z, Math.ceil(3 * intensity), 0.46 * intensity, 0.85);
|
|
303
|
+
print('boot', x, y, z, random() * 6.28, 1, false);
|
|
304
|
+
} else if (intensity > 0.85) {
|
|
305
|
+
burst('dust', x, y + 0.06, z, 2, 0.34, 0.7);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* The ground's answer to a body falling at (x, y, z): a great splash, mud thrown up, a plume of ash or dust.
|
|
311
|
+
* @param {number} x Metres.
|
|
312
|
+
* @param {number} y Metres.
|
|
313
|
+
* @param {number} z Metres.
|
|
314
|
+
*/
|
|
315
|
+
bodyFall(x, y, z) {
|
|
316
|
+
const s = surfaceAt(x, y, z);
|
|
317
|
+
if (s.kind === 'water') {
|
|
318
|
+
burst('spray', x, s.waterY + 0.04, z, 16, 0.65, 3.2);
|
|
319
|
+
} else if (s.kind === 'mud') {
|
|
320
|
+
burst('mud', x, y + 0.1, z, 12, 0.48, 2.5);
|
|
321
|
+
burst('dust', x, y + 0.12, z, 4, 0.75, 0.75);
|
|
322
|
+
} else if (s.kind === 'ash') {
|
|
323
|
+
burst('ash', x, y + 0.14, z, 9, 1.15, 0.95);
|
|
324
|
+
} else if (s.kind === 'wood') {
|
|
325
|
+
burst('dust', x, y + 0.1, z, 3, 0.55, 0.65);
|
|
326
|
+
} else if (s.kind === 'stone') {
|
|
327
|
+
burst('dust', x, y + 0.1, z, 4, 0.7, 0.75);
|
|
328
|
+
} else {
|
|
329
|
+
burst('dust', x, y + 0.14, z, 8, 1.18, 0.95);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track consecutive slow windows using displayed frame intervals in milliseconds.
|
|
3
|
+
* For each frame call `sample(frameMs)`. After the requested number of slow
|
|
4
|
+
* windows, `onSlow(averageFps, elapsedMs)` fires once. A healthy window rearms
|
|
5
|
+
* the monitor. Call `reset()` when pausing or changing views.
|
|
6
|
+
*/
|
|
7
|
+
export function createFramePacingMonitor({ minimumFps, windowMs = 1000, windows = 3, onSlow }) {
|
|
8
|
+
if (
|
|
9
|
+
!(
|
|
10
|
+
Number.isFinite(minimumFps) &&
|
|
11
|
+
minimumFps > 0 &&
|
|
12
|
+
Number.isFinite(windowMs) &&
|
|
13
|
+
windowMs > 0 &&
|
|
14
|
+
Number.isInteger(windows) &&
|
|
15
|
+
windows > 0 &&
|
|
16
|
+
typeof onSlow === 'function'
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
throw new RangeError('Invalid frame pacing options');
|
|
20
|
+
let elapsed = 0,
|
|
21
|
+
frames = 0,
|
|
22
|
+
misses = 0,
|
|
23
|
+
slowFrames = 0,
|
|
24
|
+
slowMs = 0;
|
|
25
|
+
|
|
26
|
+
function reset() {
|
|
27
|
+
elapsed = frames = misses = slowFrames = slowMs = 0;
|
|
28
|
+
}
|
|
29
|
+
function sample(frameMs) {
|
|
30
|
+
if (!(Number.isFinite(frameMs) && frameMs > 0)) return;
|
|
31
|
+
elapsed += frameMs;
|
|
32
|
+
frames++;
|
|
33
|
+
if (elapsed < windowMs) return;
|
|
34
|
+
if (frames * 1000 >= minimumFps * elapsed) {
|
|
35
|
+
reset();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (misses < windows) {
|
|
39
|
+
slowFrames += frames;
|
|
40
|
+
slowMs += elapsed;
|
|
41
|
+
misses++;
|
|
42
|
+
if (misses === windows) onSlow((slowFrames * 1000) / slowMs, slowMs);
|
|
43
|
+
}
|
|
44
|
+
elapsed = frames = 0;
|
|
45
|
+
}
|
|
46
|
+
return { sample, reset };
|
|
47
|
+
}
|
package/runtime/frame-yield.js
CHANGED
|
@@ -12,3 +12,21 @@ export const nextFrame = (maxWaitMs = 50) =>
|
|
|
12
12
|
// A promise kept once the next frame has been painted: a task queued from the frame's own callback runs after its paint. What
|
|
13
13
|
// was just put on the page is then on the screen before a long job begins.
|
|
14
14
|
export const painted = (maxWaitMs = 50) => nextFrame(maxWaitMs).then(() => new Promise(resolve => setTimeout(resolve, 0)));
|
|
15
|
+
// Watches the frames drawn from now until the function it gives is called, which gives the longest time between two of them
|
|
16
|
+
// in milliseconds: what a job run meanwhile cost the eye, whichever of its parts held the page. Frames are not drawn on a
|
|
17
|
+
// hidden page, so a caller leaves a hidden page's answer out.
|
|
18
|
+
export function watchFrames(now = () => performance.now()) {
|
|
19
|
+
let last = now(),
|
|
20
|
+
longest = 0,
|
|
21
|
+
frame;
|
|
22
|
+
const tick = (t = now()) => {
|
|
23
|
+
longest = Math.max(longest, t - last); // by the frames' own times, which are the display's: no jitter of when the callback ran
|
|
24
|
+
last = t;
|
|
25
|
+
frame = requestAnimationFrame(tick);
|
|
26
|
+
};
|
|
27
|
+
frame = requestAnimationFrame(tick);
|
|
28
|
+
return () => {
|
|
29
|
+
cancelAnimationFrame(frame);
|
|
30
|
+
return Math.max(longest, now() - last);
|
|
31
|
+
};
|
|
32
|
+
}
|