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,407 @@
|
|
|
1
|
+
// Photo-statistics look guard runner and YAML baseline comparison.
|
|
2
|
+
// Captures fixed cameras and scripted scene beats across a world's lands, measures in-browser photo statistics
|
|
3
|
+
// (roamwright/tools/look-stats.cjs), writes look.yaml and contact sheets, and checks threshold warnings and drift
|
|
4
|
+
// against a kept YAML baseline.
|
|
5
|
+
'use strict';
|
|
6
|
+
const fs = require('fs'),
|
|
7
|
+
path = require('path');
|
|
8
|
+
const { parseYaml, stringifyYaml } = require('./yaml.cjs');
|
|
9
|
+
const { compareViewStats, evaluateThresholds, measureLookStatsSource } = require('./look-stats.cjs');
|
|
10
|
+
const { writeContactSheet } = require('./contact-sheet.cjs');
|
|
11
|
+
const { seekSceneInPage, waitSceneReady } = require('./scene-run.cjs');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Filters a world's land/scene suites by optional land, substring, lands-only, or scenes-only selectors.
|
|
15
|
+
*
|
|
16
|
+
* @param {Array<object>} suites
|
|
17
|
+
* @param {object} [options]
|
|
18
|
+
* @param {string} [options.landFilter='']
|
|
19
|
+
* @param {string} [options.onlyFilter='']
|
|
20
|
+
* @param {boolean} [options.landsOnly=false]
|
|
21
|
+
* @param {boolean} [options.scenesOnly=false]
|
|
22
|
+
* @returns {Array<object>}
|
|
23
|
+
*/
|
|
24
|
+
function filterLookSuites(suites, { landFilter = '', onlyFilter = '', landsOnly = false, scenesOnly = false } = {}) {
|
|
25
|
+
return suites
|
|
26
|
+
.filter(suite => !landFilter || suite.land === landFilter)
|
|
27
|
+
.map(suite => ({
|
|
28
|
+
...suite,
|
|
29
|
+
views: scenesOnly ? [] : (suite.views || []).filter(v => !onlyFilter || v.id.includes(onlyFilter)),
|
|
30
|
+
scenes: landsOnly
|
|
31
|
+
? []
|
|
32
|
+
: (suite.scenes || [])
|
|
33
|
+
.map(sc => ({
|
|
34
|
+
...sc,
|
|
35
|
+
beats: (sc.beats || []).filter(b => !onlyFilter || b.id.includes(onlyFilter) || sc.eventId.includes(onlyFilter)),
|
|
36
|
+
}))
|
|
37
|
+
.filter(sc => sc.beats.length > 0),
|
|
38
|
+
}))
|
|
39
|
+
.filter(suite => suite.views.length > 0 || suite.scenes.length > 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Formats the single-line photo-statistics caption drawn under a look-guard contact sheet tile.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} id
|
|
46
|
+
* @param {object} stats
|
|
47
|
+
* @param {string[]} warnings
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
function formatLookCaption(id, stats, warnings) {
|
|
51
|
+
const clipPct = (stats.clipped * 100).toFixed(1),
|
|
52
|
+
crushPct = (stats.crushed * 100).toFixed(1),
|
|
53
|
+
warnTag = warnings.length ? ` [WARN: ${warnings.join('; ')}]` : '';
|
|
54
|
+
return `${id} L:${stats.brightness.toFixed(2)} C:${stats.contrast.toFixed(2)} S:${stats.saturation.toFixed(2)} clip:${clipPct}% crush:${crushPct}% flat:${stats.bottomFlatness.toFixed(2)}${warnTag}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function measureCanvasStats(page, canvasSelector) {
|
|
58
|
+
const pngBuffer = await page.locator(canvasSelector).screenshot({ type: 'png' });
|
|
59
|
+
const pngBase64 = pngBuffer.toString('base64');
|
|
60
|
+
const stats = await page.evaluate(
|
|
61
|
+
async ([b64, fnSrc]) => {
|
|
62
|
+
const measure = (0, eval)('(' + fnSrc + ')');
|
|
63
|
+
const bmp = await createImageBitmap(await (await fetch('data:image/png;base64,' + b64)).blob());
|
|
64
|
+
const canvas = new OffscreenCanvas(bmp.width, bmp.height),
|
|
65
|
+
ctx = canvas.getContext('2d');
|
|
66
|
+
ctx.drawImage(bmp, 0, 0);
|
|
67
|
+
const { data } = ctx.getImageData(0, 0, bmp.width, bmp.height);
|
|
68
|
+
return measure(data, bmp.width, bmp.height);
|
|
69
|
+
},
|
|
70
|
+
[pngBase64, measureLookStatsSource],
|
|
71
|
+
);
|
|
72
|
+
return { pngBase64, stats };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function recordMeasuredView(results, images, id, meta, pngBase64, stats) {
|
|
76
|
+
const warnings = evaluateThresholds(stats);
|
|
77
|
+
results[id] = { ...meta, ...stats };
|
|
78
|
+
images[id] = {
|
|
79
|
+
land: meta.land,
|
|
80
|
+
dataUrl: 'data:image/png;base64,' + pngBase64,
|
|
81
|
+
caption: formatLookCaption(id, stats, warnings),
|
|
82
|
+
warned: warnings.length > 0,
|
|
83
|
+
};
|
|
84
|
+
console.log(
|
|
85
|
+
(warnings.length ? 'WARN ' : 'OK ') +
|
|
86
|
+
id.padEnd(24) +
|
|
87
|
+
` L=${stats.brightness.toFixed(3)} C=${stats.contrast.toFixed(3)} S=${stats.saturation.toFixed(3)} clip=${(stats.clipped * 100).toFixed(1)}% crush=${(stats.crushed * 100).toFixed(1)}% grn=${stats.greenHueSpread.toFixed(1)}d/${stats.greenLightSpread.toFixed(3)} tb=${stats.topBottomDelta.toFixed(3)} flat=${stats.bottomFlatness.toFixed(3)}` +
|
|
88
|
+
(warnings.length ? ` [${warnings.join(', ')}]` : ''),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function captureSuiteOnBase(driver, browser, baseUrl, suites, { routePrefix = 'location/' } = {}) {
|
|
93
|
+
const results = {},
|
|
94
|
+
images = {},
|
|
95
|
+
canvasId = driver.canvasSelector.replace(/^#/, '');
|
|
96
|
+
let gpuName = '';
|
|
97
|
+
|
|
98
|
+
for (const suite of suites) {
|
|
99
|
+
const context = await browser.newContext({ viewport: { width: 1280, height: 720 }, deviceScaleFactor: 1 });
|
|
100
|
+
await driver.applyStorage(context, { quality: 'high', 'quality-fit': 'high', muted: '1' });
|
|
101
|
+
const page = await context.newPage();
|
|
102
|
+
page.on('pageerror', e => console.log('PAGE ERROR', e.message.slice(0, 220)));
|
|
103
|
+
|
|
104
|
+
const url = driver.routeUrl(routePrefix + suite.address, { base: baseUrl });
|
|
105
|
+
await driver.enter(page, url, { titledMs: 180000 });
|
|
106
|
+
await page.waitForTimeout(1800);
|
|
107
|
+
|
|
108
|
+
if (!gpuName) {
|
|
109
|
+
gpuName = await page.evaluate(d => {
|
|
110
|
+
const gl = window[d].renderer.getContext(),
|
|
111
|
+
ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
112
|
+
return ext ? gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) : '';
|
|
113
|
+
}, driver.debug);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await page.evaluate(
|
|
117
|
+
([d, cId]) => {
|
|
118
|
+
for (const el of document.body.children) if (el.id !== cId) el.style.visibility = 'hidden';
|
|
119
|
+
window[d].holdQuality(true);
|
|
120
|
+
window[d].env.flow = false;
|
|
121
|
+
},
|
|
122
|
+
[driver.debug, canvasId],
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
for (const view of suite.views) {
|
|
126
|
+
await page.evaluate(
|
|
127
|
+
({ d, setupCode, hour }) => {
|
|
128
|
+
const app = window[d],
|
|
129
|
+
P = app.P,
|
|
130
|
+
W = app.CONFIG.world,
|
|
131
|
+
g = (x, z) => app.space.ground(x, z);
|
|
132
|
+
void P;
|
|
133
|
+
void W;
|
|
134
|
+
void g;
|
|
135
|
+
const spec = eval(setupCode);
|
|
136
|
+
app.state.mode = 'play';
|
|
137
|
+
app.placePlayer(spec.pos[0], spec.pos[2], 0);
|
|
138
|
+
app.env.time = hour;
|
|
139
|
+
app.state.mode = 'inspect';
|
|
140
|
+
app.camera.position.set(spec.pos[0], spec.pos[1], spec.pos[2]);
|
|
141
|
+
app.camera.lookAt(spec.look[0], spec.look[1], spec.look[2]);
|
|
142
|
+
},
|
|
143
|
+
{ d: driver.debug, setupCode: view.setup, hour: view.hour },
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
await page.evaluate(async d => {
|
|
147
|
+
const app = window[d],
|
|
148
|
+
wait = ms => new Promise(r => setTimeout(r, ms));
|
|
149
|
+
for (let i = 0; i < 24; i++) {
|
|
150
|
+
await app.bench(3);
|
|
151
|
+
await wait(75);
|
|
152
|
+
if (i >= 8 && (!app.quarters || app.quarters.every(q => !q.job))) break;
|
|
153
|
+
}
|
|
154
|
+
}, driver.debug);
|
|
155
|
+
if (await driver.clearView(page)) {
|
|
156
|
+
await page.evaluate(d => window[d].bench(4), driver.debug);
|
|
157
|
+
}
|
|
158
|
+
await page.evaluate(d => {
|
|
159
|
+
const app = window[d];
|
|
160
|
+
app.state.measuring = true;
|
|
161
|
+
app.draw();
|
|
162
|
+
app.draw();
|
|
163
|
+
app.state.measuring = false;
|
|
164
|
+
}, driver.debug);
|
|
165
|
+
|
|
166
|
+
const { pngBase64, stats } = await measureCanvasStats(page, driver.canvasSelector);
|
|
167
|
+
recordMeasuredView(results, images, view.id, { kind: 'land', land: suite.land, hour: view.hour }, pngBase64, stats);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
for (const sceneSpec of suite.scenes) {
|
|
171
|
+
await page.evaluate(
|
|
172
|
+
([d, sceneId]) => {
|
|
173
|
+
const app = window[d];
|
|
174
|
+
app.state.mode = 'play';
|
|
175
|
+
app.env.flow = true;
|
|
176
|
+
const ev = app.CONFIG.events.find(e => e.id === sceneId);
|
|
177
|
+
app.startScene(ev, true);
|
|
178
|
+
},
|
|
179
|
+
[driver.debug, sceneSpec.eventId],
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const started = await waitSceneReady(page, driver.debug, 120000);
|
|
183
|
+
if (!started) {
|
|
184
|
+
console.error(`look-guard: scene '${sceneSpec.eventId}' failed to start`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
await page.evaluate(cId => {
|
|
188
|
+
for (const el of document.body.children) if (el.id !== cId) el.style.visibility = 'hidden';
|
|
189
|
+
}, canvasId);
|
|
190
|
+
|
|
191
|
+
for (const beat of sceneSpec.beats) {
|
|
192
|
+
await page.evaluate(seekSceneInPage, {
|
|
193
|
+
debug: driver.debug,
|
|
194
|
+
targetSeconds: beat.t,
|
|
195
|
+
settleSeconds: 1.1,
|
|
196
|
+
clearAllLog: true,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
await page.waitForFunction(
|
|
200
|
+
([d, s]) => {
|
|
201
|
+
const dir = window[d].director;
|
|
202
|
+
return !dir.ev || dir.ending || dir.t >= s;
|
|
203
|
+
},
|
|
204
|
+
[driver.debug, beat.t],
|
|
205
|
+
{ timeout: 180000 },
|
|
206
|
+
);
|
|
207
|
+
await page.evaluate(d => {
|
|
208
|
+
window[d].state.measuring = true;
|
|
209
|
+
}, driver.debug);
|
|
210
|
+
const { pngBase64, stats } = await measureCanvasStats(page, driver.canvasSelector);
|
|
211
|
+
await page.evaluate(
|
|
212
|
+
d =>
|
|
213
|
+
new Promise(resolve =>
|
|
214
|
+
requestAnimationFrame(() =>
|
|
215
|
+
setTimeout(() => {
|
|
216
|
+
window[d].state.measuring = false;
|
|
217
|
+
resolve();
|
|
218
|
+
}, 120),
|
|
219
|
+
),
|
|
220
|
+
),
|
|
221
|
+
driver.debug,
|
|
222
|
+
);
|
|
223
|
+
const sceneHour = await page.evaluate(d => +window[d].env.time.toFixed(3), driver.debug);
|
|
224
|
+
recordMeasuredView(
|
|
225
|
+
results,
|
|
226
|
+
images,
|
|
227
|
+
beat.id,
|
|
228
|
+
{ kind: 'scene', land: suite.land, scene: sceneSpec.eventId, beat: beat.t, hour: sceneHour },
|
|
229
|
+
pngBase64,
|
|
230
|
+
stats,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
await page.evaluate(d => {
|
|
235
|
+
if (window[d].director.ev) window[d].endScene();
|
|
236
|
+
}, driver.debug);
|
|
237
|
+
await page.waitForFunction(d => window[d].state.mode === 'play' && !window[d].director.ev, driver.debug, { timeout: 60000 });
|
|
238
|
+
await page.waitForTimeout(250);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
await context.close();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return { gpu: gpuName, views: results, images };
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Runs the full look guard over a world's suites, writing `look.yaml` and contact sheets into `driver.OUT`.
|
|
249
|
+
*
|
|
250
|
+
* @param {object} driver Page driver from `createPageDriver`.
|
|
251
|
+
* @param {object} options
|
|
252
|
+
* @param {Array<object>} options.suites Land/scene camera suites.
|
|
253
|
+
* @param {string} [options.commit='']
|
|
254
|
+
* @param {string} [options.landFilter='']
|
|
255
|
+
* @param {string} [options.onlyFilter='']
|
|
256
|
+
* @param {boolean} [options.landsOnly=false]
|
|
257
|
+
* @param {boolean} [options.scenesOnly=false]
|
|
258
|
+
* @param {string} [options.base2=''] Optional comparison build URL for side-by-side contact sheet.
|
|
259
|
+
* @param {string} [options.routePrefix='location/']
|
|
260
|
+
*/
|
|
261
|
+
async function runLookGuard(
|
|
262
|
+
driver,
|
|
263
|
+
{
|
|
264
|
+
suites: allSuites,
|
|
265
|
+
commit = '',
|
|
266
|
+
landFilter = '',
|
|
267
|
+
onlyFilter = '',
|
|
268
|
+
landsOnly = false,
|
|
269
|
+
scenesOnly = false,
|
|
270
|
+
base2 = '',
|
|
271
|
+
routePrefix = 'location/',
|
|
272
|
+
},
|
|
273
|
+
) {
|
|
274
|
+
const suites = filterLookSuites(allSuites, { landFilter, onlyFilter, landsOnly, scenesOnly });
|
|
275
|
+
if (!suites.length) {
|
|
276
|
+
console.error('look-guard: no views or scenes matched filter');
|
|
277
|
+
process.exit(2);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const browser = await driver.chromium.launch({ executablePath: driver.shell, ...driver.GPU });
|
|
281
|
+
fs.mkdirSync(driver.OUT, { recursive: true });
|
|
282
|
+
|
|
283
|
+
const current = await captureSuiteOnBase(driver, browser, driver.BASE, suites, { routePrefix });
|
|
284
|
+
const record = {
|
|
285
|
+
when: new Date().toISOString(),
|
|
286
|
+
commit,
|
|
287
|
+
gpu: current.gpu,
|
|
288
|
+
views: current.views,
|
|
289
|
+
};
|
|
290
|
+
fs.writeFileSync(path.join(driver.OUT, 'look.yaml'), stringifyYaml(record));
|
|
291
|
+
|
|
292
|
+
if (base2) {
|
|
293
|
+
console.log('look-guard: capturing comparison build at', base2);
|
|
294
|
+
const reference = await captureSuiteOnBase(driver, browser, base2, suites, { routePrefix });
|
|
295
|
+
fs.writeFileSync(
|
|
296
|
+
path.join(driver.OUT, 'look-ref.yaml'),
|
|
297
|
+
stringifyYaml({ when: new Date().toISOString(), base: base2, gpu: reference.gpu, views: reference.views }),
|
|
298
|
+
);
|
|
299
|
+
const sideBySide = [];
|
|
300
|
+
for (const id of Object.keys(current.images)) {
|
|
301
|
+
if (reference.images[id]) {
|
|
302
|
+
sideBySide.push({ ...reference.images[id], caption: 'REF ' + reference.images[id].caption });
|
|
303
|
+
}
|
|
304
|
+
sideBySide.push({ ...current.images[id], caption: 'NOW ' + current.images[id].caption });
|
|
305
|
+
}
|
|
306
|
+
const comparePath = path.join(driver.OUT, 'look-compare.jpg');
|
|
307
|
+
await writeContactSheet(browser, sideBySide, comparePath, { columns: 2 });
|
|
308
|
+
console.log('look-guard: wrote side-by-side A/B contact sheet', comparePath);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const allCells = Object.values(current.images);
|
|
312
|
+
const sheetPath = path.join(driver.OUT, 'look-sheet.jpg');
|
|
313
|
+
await writeContactSheet(browser, allCells, sheetPath, { columns: 2 });
|
|
314
|
+
for (const suite of suites) {
|
|
315
|
+
const ids = [...suite.views.map(v => v.id), ...suite.scenes.flatMap(sc => sc.beats.map(b => b.id))];
|
|
316
|
+
const landCells = ids.map(id => current.images[id]).filter(Boolean);
|
|
317
|
+
if (landCells.length) {
|
|
318
|
+
await writeContactSheet(browser, landCells, path.join(driver.OUT, `look-${suite.land}.jpg`), { columns: 2 });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
console.log(`look-guard: measured ${allCells.length} views/scenes across ${suites.length} land(s); contact sheet: ${sheetPath}`);
|
|
322
|
+
await driver.closeBrowser(browser);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Compares a measured look YAML file against a baseline YAML file (or keeps it when `mode === 'keep'`).
|
|
327
|
+
*
|
|
328
|
+
* @param {object} options
|
|
329
|
+
* @param {string} options.measuredPath
|
|
330
|
+
* @param {string} options.baselinePath
|
|
331
|
+
* @param {string} [options.mode=''] `''`, `'keep'`, or `'--strict'`.
|
|
332
|
+
* @param {string} [options.updateCmd='look-guard.sh keep'] Command printed in baseline header and drift hint.
|
|
333
|
+
* @returns {{ exitCode: number, thresholdWarnCount: number, driftCount: number, lines: string[] }}
|
|
334
|
+
*/
|
|
335
|
+
function compareLookFiles({ measuredPath, baselinePath, mode = '', updateCmd = 'look-guard.sh keep' }) {
|
|
336
|
+
const now = parseYaml(fs.readFileSync(measuredPath, 'utf8'));
|
|
337
|
+
const views = now.views || {};
|
|
338
|
+
const viewIds = Object.keys(views);
|
|
339
|
+
const lines = [];
|
|
340
|
+
|
|
341
|
+
let thresholdWarnCount = 0;
|
|
342
|
+
for (const id of viewIds) {
|
|
343
|
+
const warnings = evaluateThresholds(views[id]);
|
|
344
|
+
if (warnings.length) {
|
|
345
|
+
thresholdWarnCount++;
|
|
346
|
+
lines.push(`WARN threshold ${id.padEnd(24)} ${warnings.join(', ')}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (mode === 'keep' || !fs.existsSync(baselinePath)) {
|
|
351
|
+
const existing = fs.existsSync(baselinePath) ? parseYaml(fs.readFileSync(baselinePath, 'utf8')) : { views: {} };
|
|
352
|
+
const mergedViews = { ...(existing.views || {}), ...views };
|
|
353
|
+
const saved = {
|
|
354
|
+
when: now.when,
|
|
355
|
+
commit: now.commit || existing.commit || '',
|
|
356
|
+
gpu: now.gpu || existing.gpu || '',
|
|
357
|
+
views: mergedViews,
|
|
358
|
+
};
|
|
359
|
+
fs.writeFileSync(
|
|
360
|
+
baselinePath,
|
|
361
|
+
`# Photo-statistics look baseline (updated via \`${updateCmd}\`; no reference photos committed)\n` + stringifyYaml(saved),
|
|
362
|
+
);
|
|
363
|
+
lines.push(
|
|
364
|
+
`look-guard: baseline kept (${saved.commit || 'working tree'}, ${saved.when}): ${Object.keys(mergedViews).length} views (${thresholdWarnCount} threshold warning(s))`,
|
|
365
|
+
);
|
|
366
|
+
return { exitCode: 0, thresholdWarnCount, driftCount: 0, lines };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const base = parseYaml(fs.readFileSync(baselinePath, 'utf8'));
|
|
370
|
+
const baseViews = base.views || {};
|
|
371
|
+
let driftCount = 0;
|
|
372
|
+
|
|
373
|
+
lines.push(`look-guard: ${now.commit || 'this build'} (${now.when}) vs baseline ${base.commit || '?'} (${base.when})`);
|
|
374
|
+
for (const id of viewIds) {
|
|
375
|
+
const cur = views[id],
|
|
376
|
+
was = baseViews[id];
|
|
377
|
+
if (!was) {
|
|
378
|
+
lines.push(`NEW ${id.padEnd(24)} L=${cur.brightness.toFixed(3)} C=${cur.contrast.toFixed(3)} S=${cur.saturation.toFixed(3)}`);
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
const drifts = compareViewStats(cur, was);
|
|
382
|
+
if (drifts.length) {
|
|
383
|
+
driftCount++;
|
|
384
|
+
const summary = drifts.map(d => `${d.metric} ${d.was}->${d.is} (${d.delta >= 0 ? '+' : ''}${d.delta})`).join('; ');
|
|
385
|
+
lines.push(`DRIFT ${id.padEnd(24)} ${summary}`);
|
|
386
|
+
} else {
|
|
387
|
+
lines.push(
|
|
388
|
+
` ${id.padEnd(24)} L ${was.brightness.toFixed(3)}->${cur.brightness.toFixed(3)} C ${was.contrast.toFixed(3)}->${cur.contrast.toFixed(3)} S ${was.saturation.toFixed(3)}->${cur.saturation.toFixed(3)} flat ${was.bottomFlatness.toFixed(3)}->${cur.bottomFlatness.toFixed(3)}`,
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
lines.push(
|
|
394
|
+
`look-guard: ${viewIds.length} views checked, ${thresholdWarnCount} threshold warning(s), ${driftCount} baseline drift(s)` +
|
|
395
|
+
(driftCount ? ` (update with \`${updateCmd}\` when intentional)` : ''),
|
|
396
|
+
);
|
|
397
|
+
const exitCode = mode === '--strict' && (thresholdWarnCount > 0 || driftCount > 0) ? 1 : 0;
|
|
398
|
+
return { exitCode, thresholdWarnCount, driftCount, lines };
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
module.exports = {
|
|
402
|
+
captureSuiteOnBase,
|
|
403
|
+
compareLookFiles,
|
|
404
|
+
filterLookSuites,
|
|
405
|
+
formatLookCaption,
|
|
406
|
+
runLookGuard,
|
|
407
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const fs = require('fs'),
|
|
5
|
+
os = require('os'),
|
|
6
|
+
path = require('path');
|
|
7
|
+
const { stringifyYaml } = require('./yaml.cjs');
|
|
8
|
+
const { compareLookFiles, filterLookSuites, formatLookCaption } = require('./look-guard.cjs');
|
|
9
|
+
const { diffRgbaFrames, measureFrameSteadiness } = require('./look-compare.cjs');
|
|
10
|
+
|
|
11
|
+
test('filterLookSuites narrows by land, substring, lands-only, and scenes-only', () => {
|
|
12
|
+
const suites = [
|
|
13
|
+
{
|
|
14
|
+
land: 'north',
|
|
15
|
+
address: 'harbour',
|
|
16
|
+
views: [{ id: 'north-harbour-noon' }, { id: 'north-forest-dawn' }],
|
|
17
|
+
scenes: [{ eventId: 'arrival', beats: [{ id: 'scene-arrival-wide', t: 10 }] }],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
land: 'south',
|
|
21
|
+
address: 'oasis',
|
|
22
|
+
views: [{ id: 'south-oasis-dusk' }],
|
|
23
|
+
scenes: [],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
assert.equal(filterLookSuites(suites, { landFilter: 'south' }).length, 1);
|
|
27
|
+
assert.equal(filterLookSuites(suites, { onlyFilter: 'harbour' })[0].views.length, 1);
|
|
28
|
+
assert.equal(filterLookSuites(suites, { landsOnly: true })[0].scenes.length, 0);
|
|
29
|
+
const scenesOnly = filterLookSuites(suites, { scenesOnly: true });
|
|
30
|
+
assert.equal(scenesOnly.length, 1);
|
|
31
|
+
assert.equal(scenesOnly[0].views.length, 0);
|
|
32
|
+
assert.equal(scenesOnly[0].scenes[0].beats.length, 1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('formatLookCaption and compareLookFiles report OK, drift, strict failure, and keep mode', () => {
|
|
36
|
+
const sample = {
|
|
37
|
+
brightness: 0.42,
|
|
38
|
+
contrast: 0.18,
|
|
39
|
+
saturation: 0.31,
|
|
40
|
+
clipped: 0.01,
|
|
41
|
+
crushed: 0.02,
|
|
42
|
+
greenHueSpread: 12,
|
|
43
|
+
greenLightSpread: 0.06,
|
|
44
|
+
topBottomDelta: 0.12,
|
|
45
|
+
bottomFlatness: 0.25,
|
|
46
|
+
};
|
|
47
|
+
assert.match(formatLookCaption('harbour-noon', sample, []), /harbour-noon L:0\.42/);
|
|
48
|
+
assert.match(formatLookCaption('harbour-noon', sample, ['clipped 8%']), /\[WARN: clipped 8%\]/);
|
|
49
|
+
|
|
50
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'look-guard-test-'));
|
|
51
|
+
try {
|
|
52
|
+
const measured = path.join(dir, 'look.yaml'),
|
|
53
|
+
baseline = path.join(dir, 'baseline.yaml');
|
|
54
|
+
fs.writeFileSync(
|
|
55
|
+
measured,
|
|
56
|
+
stringifyYaml({ when: '2026-12-01T00:00:00Z', commit: 'abc123', gpu: 'TestGPU', views: { 'harbour-noon': sample } }),
|
|
57
|
+
);
|
|
58
|
+
const kept = compareLookFiles({ measuredPath: measured, baselinePath: baseline, mode: 'keep' });
|
|
59
|
+
assert.equal(kept.exitCode, 0);
|
|
60
|
+
assert.ok(fs.existsSync(baseline));
|
|
61
|
+
|
|
62
|
+
const clean = compareLookFiles({ measuredPath: measured, baselinePath: baseline, mode: '--strict' });
|
|
63
|
+
assert.equal(clean.exitCode, 0);
|
|
64
|
+
assert.equal(clean.driftCount, 0);
|
|
65
|
+
|
|
66
|
+
const driftedSample = { ...sample, brightness: 0.65 };
|
|
67
|
+
fs.writeFileSync(
|
|
68
|
+
measured,
|
|
69
|
+
stringifyYaml({ when: '2026-12-01T00:01:00Z', commit: 'def456', gpu: 'TestGPU', views: { 'harbour-noon': driftedSample } }),
|
|
70
|
+
);
|
|
71
|
+
const drifted = compareLookFiles({ measuredPath: measured, baselinePath: baseline, mode: '--strict' });
|
|
72
|
+
assert.equal(drifted.exitCode, 1);
|
|
73
|
+
assert.equal(drifted.driftCount, 1);
|
|
74
|
+
} finally {
|
|
75
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('diffRgbaFrames and measureFrameSteadiness compute exact pixel deltas', () => {
|
|
80
|
+
const a = new Uint8Array(4 * 4 * 4).fill(100);
|
|
81
|
+
const b = new Uint8Array(a);
|
|
82
|
+
b[(2 * 4 + 1) * 4] = 120; // pixel (1, 2) differs by 20 in red
|
|
83
|
+
const diff = diffRgbaFrames(a, b, 4, 4, 2);
|
|
84
|
+
assert.deepEqual(diff, { pixels: 16, width: 4, differ: 1, most: 20, box: [1, 2, 1, 2] });
|
|
85
|
+
|
|
86
|
+
const c = new Uint8Array(a);
|
|
87
|
+
c[(2 * 4 + 1) * 4] = 190; // channel R +90 => luma average +30 (> 24)
|
|
88
|
+
const steady = measureFrameSteadiness([a, b, c], 4, 4, [0, 0, 1, 1]);
|
|
89
|
+
assert.equal(steady.pixels, 16);
|
|
90
|
+
assert.equal(steady.over8, 1);
|
|
91
|
+
assert.equal(steady.over24, 1);
|
|
92
|
+
assert.equal(steady.most, 30);
|
|
93
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Photo statistics of a rendered frame and checks against thresholds and a kept baseline, for a guard of a world's look.
|
|
2
|
+
// Pure RGBA8 pixel analyzer that runs both inside Chromium (via Function/eval) and in Node tests.
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const LOOK_THRESHOLDS = {
|
|
6
|
+
clippedMax: 0.06, // L > 0.985 share above 6% warns of blown highlights
|
|
7
|
+
crushedMax: 0.12, // L < 0.02 share above 12% warns of crushed shadows
|
|
8
|
+
saturationMax: 0.68, // mean saturation above 0.68 warns of oversaturated/garish colour
|
|
9
|
+
contrastMin: 0.09, // luminance std-dev below 0.09 warns of washed-out / fogged-flat frames
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const LOOK_DRIFT_SLACK = {
|
|
13
|
+
brightness: 0.08,
|
|
14
|
+
contrast: 0.04,
|
|
15
|
+
saturation: 0.1,
|
|
16
|
+
clipped: 0.03,
|
|
17
|
+
crushed: 0.05,
|
|
18
|
+
greenHueSpread: 5.0,
|
|
19
|
+
greenLightSpread: 0.04,
|
|
20
|
+
topBottomDelta: 0.1,
|
|
21
|
+
bottomFlatness: 0.15,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Measures photographic statistics from an sRGB RGBA8 Uint8Array / Uint8ClampedArray of size width * height * 4.
|
|
25
|
+
function measureLookStats(rgba, width, height) {
|
|
26
|
+
const totalPixels = width * height;
|
|
27
|
+
if (!totalPixels || rgba.length < totalPixels * 4) {
|
|
28
|
+
throw new Error(`measureLookStats: invalid buffer (${rgba.length} bytes for ${width}x${height})`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let sumL = 0,
|
|
32
|
+
sumL2 = 0,
|
|
33
|
+
sumSat = 0,
|
|
34
|
+
clippedCount = 0,
|
|
35
|
+
crushedCount = 0,
|
|
36
|
+
greenCount = 0,
|
|
37
|
+
greenSumHue = 0,
|
|
38
|
+
greenSumHue2 = 0,
|
|
39
|
+
greenSumL = 0,
|
|
40
|
+
greenSumL2 = 0,
|
|
41
|
+
topSumL = 0,
|
|
42
|
+
topCount = 0,
|
|
43
|
+
botSumL = 0,
|
|
44
|
+
botCount = 0,
|
|
45
|
+
botFlatCount = 0,
|
|
46
|
+
botPairCount = 0;
|
|
47
|
+
|
|
48
|
+
const topEnd = Math.floor(height / 3),
|
|
49
|
+
botStart = Math.floor((2 * height) / 3),
|
|
50
|
+
prevRowL = new Float32Array(width);
|
|
51
|
+
|
|
52
|
+
let idx = 0;
|
|
53
|
+
for (let y = 0; y < height; y++) {
|
|
54
|
+
let prevL = 0;
|
|
55
|
+
const inTop = y < topEnd,
|
|
56
|
+
inBot = y >= botStart;
|
|
57
|
+
for (let x = 0; x < width; x++, idx += 4) {
|
|
58
|
+
const sr = rgba[idx] / 255,
|
|
59
|
+
sg = rgba[idx + 1] / 255,
|
|
60
|
+
sb = rgba[idx + 2] / 255;
|
|
61
|
+
// Rec. 709 perceptual luma over display sRGB channels in [0, 1].
|
|
62
|
+
const lum = 0.2126 * sr + 0.7152 * sg + 0.0722 * sb;
|
|
63
|
+
sumL += lum;
|
|
64
|
+
sumL2 += lum * lum;
|
|
65
|
+
if (lum > 0.985) clippedCount++;
|
|
66
|
+
if (lum < 0.02) crushedCount++;
|
|
67
|
+
|
|
68
|
+
const maxC = sr > sg ? (sr > sb ? sr : sb) : sg > sb ? sg : sb,
|
|
69
|
+
minC = sr < sg ? (sr < sb ? sr : sb) : sg < sb ? sg : sb,
|
|
70
|
+
chroma = maxC - minC,
|
|
71
|
+
// Floor denominator at 0.04 so near-black 8-bit quantization noise does not read as 100% saturated.
|
|
72
|
+
sat = chroma / (maxC > 0.04 ? maxC : 0.04);
|
|
73
|
+
sumSat += sat;
|
|
74
|
+
|
|
75
|
+
// Green vegetation/turf pixels (yellow-green crop through cool pine, [55 deg, 165 deg]).
|
|
76
|
+
if (chroma > 0.035 && sat > 0.12 && lum > 0.025 && lum < 0.96) {
|
|
77
|
+
let hue;
|
|
78
|
+
if (maxC === sr) hue = ((((sg - sb) / chroma) % 6) + 6) % 6;
|
|
79
|
+
else if (maxC === sg) hue = (sb - sr) / chroma + 2;
|
|
80
|
+
else hue = (sr - sg) / chroma + 4;
|
|
81
|
+
const hueDeg = hue * 60;
|
|
82
|
+
if (hueDeg >= 55 && hueDeg <= 165) {
|
|
83
|
+
greenCount++;
|
|
84
|
+
greenSumHue += hueDeg;
|
|
85
|
+
greenSumHue2 += hueDeg * hueDeg;
|
|
86
|
+
greenSumL += lum;
|
|
87
|
+
greenSumL2 += lum * lum;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (inTop) {
|
|
92
|
+
topSumL += lum;
|
|
93
|
+
topCount++;
|
|
94
|
+
} else if (inBot) {
|
|
95
|
+
botSumL += lum;
|
|
96
|
+
botCount++;
|
|
97
|
+
if (x > 0 && y > botStart) {
|
|
98
|
+
const dx = Math.abs(lum - prevL),
|
|
99
|
+
dy = Math.abs(lum - prevRowL[x]);
|
|
100
|
+
if ((dx > dy ? dx : dy) < 0.004) botFlatCount++;
|
|
101
|
+
botPairCount++;
|
|
102
|
+
}
|
|
103
|
+
prevRowL[x] = lum;
|
|
104
|
+
prevL = lum;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const brightness = sumL / totalPixels,
|
|
110
|
+
contrast = Math.sqrt(Math.max(0, sumL2 / totalPixels - brightness * brightness)),
|
|
111
|
+
saturation = sumSat / totalPixels,
|
|
112
|
+
clipped = clippedCount / totalPixels,
|
|
113
|
+
crushed = crushedCount / totalPixels,
|
|
114
|
+
greenShare = greenCount / totalPixels,
|
|
115
|
+
greenMeanHue = greenCount >= 32 ? greenSumHue / greenCount : 0,
|
|
116
|
+
greenHueSpread = greenCount >= 32 ? Math.sqrt(Math.max(0, greenSumHue2 / greenCount - greenMeanHue * greenMeanHue)) : 0,
|
|
117
|
+
greenMeanL = greenCount >= 32 ? greenSumL / greenCount : 0,
|
|
118
|
+
greenLightSpread = greenCount >= 32 ? Math.sqrt(Math.max(0, greenSumL2 / greenCount - greenMeanL * greenMeanL)) : 0,
|
|
119
|
+
topThirdLum = topCount ? topSumL / topCount : 0,
|
|
120
|
+
bottomThirdLum = botCount ? botSumL / botCount : 0,
|
|
121
|
+
topBottomDelta = topThirdLum - bottomThirdLum,
|
|
122
|
+
bottomFlatness = botPairCount ? botFlatCount / botPairCount : 0;
|
|
123
|
+
|
|
124
|
+
const round4 = v => +v.toFixed(4);
|
|
125
|
+
return {
|
|
126
|
+
brightness: round4(brightness),
|
|
127
|
+
contrast: round4(contrast),
|
|
128
|
+
saturation: round4(saturation),
|
|
129
|
+
clipped: round4(clipped),
|
|
130
|
+
crushed: round4(crushed),
|
|
131
|
+
greenShare: round4(greenShare),
|
|
132
|
+
greenHueSpread: +greenHueSpread.toFixed(2),
|
|
133
|
+
greenLightSpread: round4(greenLightSpread),
|
|
134
|
+
topThirdLum: round4(topThirdLum),
|
|
135
|
+
bottomThirdLum: round4(bottomThirdLum),
|
|
136
|
+
topBottomDelta: round4(topBottomDelta),
|
|
137
|
+
bottomFlatness: round4(bottomFlatness),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function evaluateThresholds(stats, thresholds = LOOK_THRESHOLDS) {
|
|
142
|
+
const warnings = [];
|
|
143
|
+
if (stats.clipped > thresholds.clippedMax) {
|
|
144
|
+
warnings.push(`clipped ${(stats.clipped * 100).toFixed(1)}% > ${(thresholds.clippedMax * 100).toFixed(0)}%`);
|
|
145
|
+
}
|
|
146
|
+
if (stats.crushed > thresholds.crushedMax) {
|
|
147
|
+
warnings.push(`crushed ${(stats.crushed * 100).toFixed(1)}% > ${(thresholds.crushedMax * 100).toFixed(0)}%`);
|
|
148
|
+
}
|
|
149
|
+
if (stats.saturation > thresholds.saturationMax) {
|
|
150
|
+
warnings.push(`saturation ${stats.saturation.toFixed(3)} > ${thresholds.saturationMax}`);
|
|
151
|
+
}
|
|
152
|
+
if (stats.contrast < thresholds.contrastMin) {
|
|
153
|
+
warnings.push(`contrast ${stats.contrast.toFixed(3)} < ${thresholds.contrastMin}`);
|
|
154
|
+
}
|
|
155
|
+
return warnings;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function compareViewStats(nowStats, baseStats, slack = LOOK_DRIFT_SLACK) {
|
|
159
|
+
const drifts = [];
|
|
160
|
+
if (!baseStats) return drifts;
|
|
161
|
+
for (const [metric, limit] of Object.entries(slack)) {
|
|
162
|
+
const isVal = nowStats[metric],
|
|
163
|
+
wasVal = baseStats[metric];
|
|
164
|
+
if (typeof isVal !== 'number' || typeof wasVal !== 'number') continue;
|
|
165
|
+
const delta = isVal - wasVal;
|
|
166
|
+
if (Math.abs(delta) > limit) {
|
|
167
|
+
drifts.push({
|
|
168
|
+
metric,
|
|
169
|
+
was: wasVal,
|
|
170
|
+
is: isVal,
|
|
171
|
+
delta: +delta.toFixed(4),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return drifts;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
module.exports = {
|
|
179
|
+
LOOK_DRIFT_SLACK,
|
|
180
|
+
LOOK_THRESHOLDS,
|
|
181
|
+
compareViewStats,
|
|
182
|
+
evaluateThresholds,
|
|
183
|
+
measureLookStats,
|
|
184
|
+
measureLookStatsSource: measureLookStats.toString(),
|
|
185
|
+
};
|