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,344 @@
|
|
|
1
|
+
// Pure helpers, constants, and page-side beat inspection for `scene-audit.cjs`.
|
|
2
|
+
// Measures whether active cast members are visible, on screen, submitted to the renderer,
|
|
3
|
+
// contributing frame triangles, and changing pixels above the temporal anti-aliasing noise floor.
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
/** Default fractional timestamps along each scene's duration. */
|
|
7
|
+
const DEFAULT_BEATS = [0.1, 0.35, 0.6, 0.85];
|
|
8
|
+
/** Default scenes per contact sheet before splitting into numbered parts. */
|
|
9
|
+
const ROWS_PER_SHEET = 20;
|
|
10
|
+
/** Flag for a beat with active cast but zero figures on screen or zero cast triangles. */
|
|
11
|
+
const NO_CAST_DRAWN = 'NO-CAST-DRAWN';
|
|
12
|
+
/** Flag for cast triangles drawn whose hiding changed no more pixels than frame noise. */
|
|
13
|
+
const NO_CAST_PIXELS = 'NO-CAST-PIXELS';
|
|
14
|
+
/** Flag for errors or warnings in the page log or console during a scene. */
|
|
15
|
+
const PAGE_ERROR = 'PAGE-ERROR';
|
|
16
|
+
/** Flag for a scene that timed out or threw while playing. */
|
|
17
|
+
const FAILED = 'FAILED';
|
|
18
|
+
/** Log entry kinds treated as page errors. */
|
|
19
|
+
const ERROR_KINDS = ['error', 'warn', 'console'];
|
|
20
|
+
/** Temporal anti-aliasing lens jitter cycle length in frames. */
|
|
21
|
+
const LENS_CYCLE = 8;
|
|
22
|
+
/** Frames to keep the cast hidden so temporal history clears cleanly (two lens cycles). */
|
|
23
|
+
const HIDDEN_FRAMES = 16;
|
|
24
|
+
/** Per-channel RGB delta threshold (0..255) above which a pixel counts as changed. */
|
|
25
|
+
const PIXEL_DELTA = 20;
|
|
26
|
+
|
|
27
|
+
const splitList = text =>
|
|
28
|
+
String(text)
|
|
29
|
+
.split(',')
|
|
30
|
+
.map(s => s.trim())
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Formats an error into a compact single-line summary.
|
|
35
|
+
*
|
|
36
|
+
* @param {unknown} error
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
function describeError(error) {
|
|
40
|
+
return String(error?.message || error)
|
|
41
|
+
.replace(/\s+/g, ' ')
|
|
42
|
+
.slice(0, 240);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Parses CLI flags for the scene audit tool.
|
|
47
|
+
*
|
|
48
|
+
* @param {string[]} argv Raw CLI arguments.
|
|
49
|
+
* @param {object} [options]
|
|
50
|
+
* @param {Record<string, string>} [options.landAliases] Optional map from CLI alias to canonical land id.
|
|
51
|
+
* @returns {{ list: boolean, lands: string[], only: string[], beats: number[], rows: number }}
|
|
52
|
+
*/
|
|
53
|
+
function parseAuditArgs(argv, { landAliases = {} } = {}) {
|
|
54
|
+
const flags = argv.filter(a => a.startsWith('--'));
|
|
55
|
+
const unknown = flags.filter(f => !/^--(lands|only|beats|rows|list)(=|$)/.test(f));
|
|
56
|
+
if (unknown.length) throw new Error(`unknown option ${unknown.join(', ')}`);
|
|
57
|
+
const bare = flags.filter(f => f !== '--list' && !f.includes('='));
|
|
58
|
+
if (bare.length) throw new Error(`${bare.join(', ')} wants a value, as --only=scene1,scene2`);
|
|
59
|
+
const valueOf = name => {
|
|
60
|
+
const flag = flags.find(f => f.startsWith(`--${name}=`));
|
|
61
|
+
return flag ? flag.slice(name.length + 3) : '';
|
|
62
|
+
};
|
|
63
|
+
const beats = valueOf('beats') ? splitList(valueOf('beats')).map(Number) : DEFAULT_BEATS;
|
|
64
|
+
if (!beats.length || beats.some(b => !(b > 0 && b < 1))) {
|
|
65
|
+
throw new Error('--beats wants fractions of a scene between 0 and 1, as 0.1,0.35,0.6,0.85');
|
|
66
|
+
}
|
|
67
|
+
const rows = Number(valueOf('rows')) || ROWS_PER_SHEET;
|
|
68
|
+
return {
|
|
69
|
+
list: flags.includes('--list'),
|
|
70
|
+
lands: splitList(valueOf('lands')).map(land => landAliases[land] ?? land),
|
|
71
|
+
only: splitList(valueOf('only')),
|
|
72
|
+
beats: [...beats].sort((a, b) => a - b),
|
|
73
|
+
rows: Math.max(1, Math.floor(rows)),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Converts fractional beat positions into deduplicated timestamps rounded to a tenth of a second.
|
|
79
|
+
*
|
|
80
|
+
* @param {number} dur Scene duration in seconds.
|
|
81
|
+
* @param {number[]} beats Fractional positions in (0, 1).
|
|
82
|
+
* @returns {number[]}
|
|
83
|
+
*/
|
|
84
|
+
function beatTimes(dur, beats) {
|
|
85
|
+
return [...new Set(beats.map(b => Math.round(dur * b * 10) / 10))];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Formats the still filename for a scene beat (`<id>-<t>.jpg`, decimal point replaced by underscore).
|
|
90
|
+
*
|
|
91
|
+
* @param {string} id Scene identifier.
|
|
92
|
+
* @param {number} t Beat timestamp in seconds.
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
function stillName(id, t) {
|
|
96
|
+
return `${id}-${String(t).replace('.', '_')}.jpg`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Classifies visibility defects on a single beat's measurements.
|
|
101
|
+
*
|
|
102
|
+
* @param {{ active: number, onScreen: number, tris: number, px: number, noise: number }} beat
|
|
103
|
+
* @returns {string[]}
|
|
104
|
+
*/
|
|
105
|
+
function flagsOfBeat(beat) {
|
|
106
|
+
if (beat.active > 0 && (beat.onScreen === 0 || beat.tris <= 0)) return [NO_CAST_DRAWN];
|
|
107
|
+
if (beat.active > 0 && beat.px >= 0 && beat.px <= beat.noise * 1.2 + 24) return [NO_CAST_PIXELS];
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Aggregates beat and page-log flags for an audited scene result.
|
|
113
|
+
*
|
|
114
|
+
* @param {{ status: string, beats: object[], problems: Array<{ kind: string }> }} result
|
|
115
|
+
* @returns {string[]}
|
|
116
|
+
*/
|
|
117
|
+
function flagsOfScene(result) {
|
|
118
|
+
if (result.status !== 'ok') return [FAILED];
|
|
119
|
+
const flags = [...new Set(result.beats.flatMap(flagsOfBeat))];
|
|
120
|
+
if (result.problems.some(p => ERROR_KINDS.includes(p.kind))) flags.push(PAGE_ERROR);
|
|
121
|
+
return flags;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Holds the frame loop, counts visible/on-screen/submitted cast members, and captures two baseline
|
|
126
|
+
* frames one lens cycle apart to establish the temporal noise floor.
|
|
127
|
+
* Passed to `page.evaluate`; must remain self-contained.
|
|
128
|
+
*
|
|
129
|
+
* @param {{ debug?: string, token: number, lensCycle: number, holdKey?: string, auditKey?: string }} arg
|
|
130
|
+
* @returns {object}
|
|
131
|
+
*/
|
|
132
|
+
function beginBeatInPage({ debug = 'APP', token, lensCycle, holdKey = '__sceneAuditHold', auditKey = '__sceneAudit' }) {
|
|
133
|
+
const CHEST_M = 1.2;
|
|
134
|
+
const MARGIN = 1.05;
|
|
135
|
+
const LEAST_TALL_PX = 4;
|
|
136
|
+
const G = window[debug];
|
|
137
|
+
const director = G.director;
|
|
138
|
+
const ev = director.ev;
|
|
139
|
+
window[holdKey] = token;
|
|
140
|
+
G.state.measuring = true;
|
|
141
|
+
const cam = G.camera;
|
|
142
|
+
cam.updateMatrixWorld();
|
|
143
|
+
cam.matrixWorldInverse.copy(cam.matrixWorld).invert();
|
|
144
|
+
const gl = G.renderer.getContext();
|
|
145
|
+
const width = gl.drawingBufferWidth;
|
|
146
|
+
const height = gl.drawingBufferHeight;
|
|
147
|
+
const halfTan = Math.tan((cam.fov * Math.PI) / 360);
|
|
148
|
+
const V = G.THREE.Vector3;
|
|
149
|
+
const feet = new V();
|
|
150
|
+
const chest = new V();
|
|
151
|
+
const crown = new V();
|
|
152
|
+
const view = new V();
|
|
153
|
+
const chestN = new V();
|
|
154
|
+
const crownN = new V();
|
|
155
|
+
const project = (world, out) => {
|
|
156
|
+
view.copy(world).applyMatrix4(cam.matrixWorldInverse);
|
|
157
|
+
if (view.z >= 0) return false;
|
|
158
|
+
out.copy(world).project(cam);
|
|
159
|
+
return out.z > -1 && out.z < 1;
|
|
160
|
+
};
|
|
161
|
+
const inFrame = p => Math.abs(p.x) <= MARGIN && Math.abs(p.y) <= MARGIN;
|
|
162
|
+
const frustum = new G.THREE.Frustum().setFromProjectionMatrix(
|
|
163
|
+
new G.THREE.Matrix4().multiplyMatrices(cam.projectionMatrix, cam.matrixWorldInverse),
|
|
164
|
+
);
|
|
165
|
+
const isBone = bone => Boolean(bone) && typeof bone.getWorldPosition === 'function';
|
|
166
|
+
const ids = ev ? Object.keys(ev.cast || {}) : [];
|
|
167
|
+
const actors = [];
|
|
168
|
+
const live = [];
|
|
169
|
+
let active = 0;
|
|
170
|
+
let shown = 0;
|
|
171
|
+
let onScreen = 0;
|
|
172
|
+
let submitted = 0;
|
|
173
|
+
let missing = 0;
|
|
174
|
+
for (const id of ids) {
|
|
175
|
+
const a = G.actors[id];
|
|
176
|
+
if (!a || !a.group) {
|
|
177
|
+
missing++;
|
|
178
|
+
actors.push({ id, missing: true });
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
let seen = Boolean(a.active);
|
|
182
|
+
for (let o = a.group; seen && o; o = o.parent) if (!o.visible) seen = false;
|
|
183
|
+
a.group.getWorldPosition(feet);
|
|
184
|
+
if (isBone(a.chest)) a.chest.getWorldPosition(chest);
|
|
185
|
+
else chest.copy(feet).setY(feet.y + CHEST_M);
|
|
186
|
+
if (isBone(a.head)) a.head.getWorldPosition(crown);
|
|
187
|
+
else crown.copy(feet).setY(feet.y + (a.height || 1.8));
|
|
188
|
+
const chestIn = project(chest, chestN);
|
|
189
|
+
const crownIn = project(crown, crownN);
|
|
190
|
+
const tall = ((a.height || 1.8) * height * 0.5) / (Math.max(0.05, cam.position.distanceTo(chest)) * halfTan);
|
|
191
|
+
const inSight = seen && tall >= LEAST_TALL_PX && ((chestIn && inFrame(chestN)) || (crownIn && inFrame(crownN)));
|
|
192
|
+
let draws = 0;
|
|
193
|
+
a.group.traverse(o => {
|
|
194
|
+
if (!o.isMesh || !o.geometry || !o.layers.test(cam.layers)) return;
|
|
195
|
+
for (let p = o; p; p = p.parent) if (!p.visible) return;
|
|
196
|
+
if (!o.frustumCulled || frustum.intersectsObject(o)) draws++;
|
|
197
|
+
});
|
|
198
|
+
if (a.active) {
|
|
199
|
+
active++;
|
|
200
|
+
live.push([a, a.group.visible]);
|
|
201
|
+
if (seen) shown++;
|
|
202
|
+
if (draws) submitted++;
|
|
203
|
+
}
|
|
204
|
+
if (inSight) onScreen++;
|
|
205
|
+
actors.push({
|
|
206
|
+
id,
|
|
207
|
+
active: Boolean(a.active),
|
|
208
|
+
shown: Boolean(a.active && seen),
|
|
209
|
+
onScreen: inSight,
|
|
210
|
+
submitted: draws > 0,
|
|
211
|
+
tall: Math.round(tall),
|
|
212
|
+
chestFromFeet: +chest.distanceTo(feet).toFixed(1),
|
|
213
|
+
at: [+chestN.x.toFixed(2), +chestN.y.toFixed(2), +chestN.z.toFixed(2)],
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const grab = () => {
|
|
217
|
+
const pixels = new Uint8Array(width * height * 4);
|
|
218
|
+
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
|
|
219
|
+
return pixels;
|
|
220
|
+
};
|
|
221
|
+
const lightOf = pixels => {
|
|
222
|
+
let sum = 0;
|
|
223
|
+
for (let i = 1; i < pixels.length; i += 4) sum += pixels[i];
|
|
224
|
+
return Math.round(sum / (pixels.length / 4));
|
|
225
|
+
};
|
|
226
|
+
let first = null;
|
|
227
|
+
let second = null;
|
|
228
|
+
let light = -1;
|
|
229
|
+
let unread = '';
|
|
230
|
+
try {
|
|
231
|
+
G.draw();
|
|
232
|
+
first = grab();
|
|
233
|
+
for (let i = 0; i < lensCycle; i++) G.draw();
|
|
234
|
+
second = grab();
|
|
235
|
+
light = lightOf(second);
|
|
236
|
+
if (light === 0) unread = 'the image read back is black';
|
|
237
|
+
} catch (error) {
|
|
238
|
+
first = second = null;
|
|
239
|
+
light = -1;
|
|
240
|
+
unread = String(error?.message || error).slice(0, 160);
|
|
241
|
+
}
|
|
242
|
+
window[auditKey] = { live, first, second, light, unread, trisOn: G.renderer.info.render.triangles };
|
|
243
|
+
return {
|
|
244
|
+
at: +director.t.toFixed(2),
|
|
245
|
+
playing: Boolean(ev && director.ready && !director.ending && G.state.mode === 'scene'),
|
|
246
|
+
fps: Number(G.perf.fps.toFixed(1)),
|
|
247
|
+
active,
|
|
248
|
+
shown,
|
|
249
|
+
onScreen,
|
|
250
|
+
submitted,
|
|
251
|
+
missing,
|
|
252
|
+
actors,
|
|
253
|
+
unread,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Hides active cast groups while freezing shadows, reads back pixel delta against the baseline frame,
|
|
259
|
+
* then measures triangle contribution and restores cast visibility and shadow updates.
|
|
260
|
+
* Passed to `page.evaluate`; must remain self-contained.
|
|
261
|
+
*
|
|
262
|
+
* @param {{ debug?: string, hiddenFrames: number, pixelDelta: number, auditKey?: string }} arg
|
|
263
|
+
* @returns {{ px: number, noise: number, tris: number, unread: string }}
|
|
264
|
+
*/
|
|
265
|
+
function endBeatInPage({ debug = 'APP', hiddenFrames, pixelDelta, auditKey = '__sceneAudit' }) {
|
|
266
|
+
const REDRAWS = 8;
|
|
267
|
+
const G = window[debug];
|
|
268
|
+
const audit = window[auditKey];
|
|
269
|
+
const live = audit.live;
|
|
270
|
+
const shadows = G.renderer.shadowMap;
|
|
271
|
+
const shadowsWere = shadows.autoUpdate;
|
|
272
|
+
const gl = G.renderer.getContext();
|
|
273
|
+
const width = gl.drawingBufferWidth;
|
|
274
|
+
const height = gl.drawingBufferHeight;
|
|
275
|
+
const hide = () => {
|
|
276
|
+
for (const [a] of live) a.group.visible = false;
|
|
277
|
+
};
|
|
278
|
+
const restore = () => {
|
|
279
|
+
for (const [a, was] of live) a.group.visible = was;
|
|
280
|
+
};
|
|
281
|
+
const changed = (p, q) => {
|
|
282
|
+
let count = 0;
|
|
283
|
+
for (let i = 0; i < p.length; i += 4) {
|
|
284
|
+
const delta = Math.max(Math.abs(p[i] - q[i]), Math.abs(p[i + 1] - q[i + 1]), Math.abs(p[i + 2] - q[i + 2]));
|
|
285
|
+
if (delta > pixelDelta) count++;
|
|
286
|
+
}
|
|
287
|
+
return count;
|
|
288
|
+
};
|
|
289
|
+
const out = { px: -1, noise: -1, tris: 0, unread: '' };
|
|
290
|
+
try {
|
|
291
|
+
if (audit.second && audit.light > 0) {
|
|
292
|
+
shadows.autoUpdate = false;
|
|
293
|
+
try {
|
|
294
|
+
hide();
|
|
295
|
+
for (let i = 0; i < hiddenFrames; i++) G.draw();
|
|
296
|
+
const hidden = new Uint8Array(width * height * 4);
|
|
297
|
+
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, hidden);
|
|
298
|
+
out.px = changed(audit.second, hidden);
|
|
299
|
+
if (audit.first) out.noise = changed(audit.first, audit.second);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
out.px = out.noise = -1;
|
|
302
|
+
out.unread = String(error?.message || error).slice(0, 160);
|
|
303
|
+
} finally {
|
|
304
|
+
restore();
|
|
305
|
+
shadows.autoUpdate = shadowsWere;
|
|
306
|
+
}
|
|
307
|
+
} else out.unread = audit.unread || '';
|
|
308
|
+
try {
|
|
309
|
+
hide();
|
|
310
|
+
G.draw();
|
|
311
|
+
G.draw();
|
|
312
|
+
out.tris = Math.max(0, audit.trisOn - G.renderer.info.render.triangles);
|
|
313
|
+
} finally {
|
|
314
|
+
restore();
|
|
315
|
+
}
|
|
316
|
+
} finally {
|
|
317
|
+
restore();
|
|
318
|
+
shadows.autoUpdate = shadowsWere;
|
|
319
|
+
for (let i = 0; i < REDRAWS; i++) G.draw();
|
|
320
|
+
window[auditKey] = null;
|
|
321
|
+
}
|
|
322
|
+
return out;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
module.exports = {
|
|
326
|
+
DEFAULT_BEATS,
|
|
327
|
+
ROWS_PER_SHEET,
|
|
328
|
+
NO_CAST_DRAWN,
|
|
329
|
+
NO_CAST_PIXELS,
|
|
330
|
+
PAGE_ERROR,
|
|
331
|
+
FAILED,
|
|
332
|
+
ERROR_KINDS,
|
|
333
|
+
LENS_CYCLE,
|
|
334
|
+
HIDDEN_FRAMES,
|
|
335
|
+
PIXEL_DELTA,
|
|
336
|
+
describeError,
|
|
337
|
+
parseAuditArgs,
|
|
338
|
+
beatTimes,
|
|
339
|
+
stillName,
|
|
340
|
+
flagsOfBeat,
|
|
341
|
+
flagsOfScene,
|
|
342
|
+
beginBeatInPage,
|
|
343
|
+
endBeatInPage,
|
|
344
|
+
};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// Contact sheet rendering and console/JSON reporting for `scene-audit.cjs`.
|
|
2
|
+
'use strict';
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { ERROR_KINDS, FAILED, NO_CAST_DRAWN, NO_CAST_PIXELS, PAGE_ERROR, describeError } = require('./scene-audit-beat.cjs');
|
|
6
|
+
|
|
7
|
+
const SHEET_WIDEST_PX = 4000;
|
|
8
|
+
const CELL_W = 640;
|
|
9
|
+
const LABEL_H = 28;
|
|
10
|
+
const PAD = 10;
|
|
11
|
+
const HEADER_H = 92;
|
|
12
|
+
|
|
13
|
+
/** Colour palette used to highlight flagged and failed tiles on audit contact sheets. */
|
|
14
|
+
const TONE = {
|
|
15
|
+
plain: { bar: '#1b2028', text: '#e6edf3' },
|
|
16
|
+
[NO_CAST_DRAWN]: { bar: '#5a1f1f', text: '#ffd7d5' },
|
|
17
|
+
[NO_CAST_PIXELS]: { bar: '#5a4a16', text: '#ffe9a8' },
|
|
18
|
+
failed: { bar: '#5a1f1f', text: '#ffd7d5' },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const imageAsDataUrl = file => 'data:image/jpeg;base64,' + fs.readFileSync(file).toString('base64');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Draws one labelled audit contact sheet onto a 2D canvas inside a blank page and returns base64 JPEG.
|
|
25
|
+
* Passed to `page.evaluate`; must remain self-contained.
|
|
26
|
+
*
|
|
27
|
+
* @param {object} sheet Layout, header, rows, and tone palette.
|
|
28
|
+
* @returns {Promise<string>}
|
|
29
|
+
*/
|
|
30
|
+
function drawAuditSheetInPage(sheet) {
|
|
31
|
+
const { rows, cols, cellW, cellH, labelH, pad, headerH, heading, legend, tone, fonts } = sheet;
|
|
32
|
+
const canvas = document.createElement('canvas');
|
|
33
|
+
canvas.width = sheet.width;
|
|
34
|
+
canvas.height = sheet.height;
|
|
35
|
+
const g = canvas.getContext('2d');
|
|
36
|
+
g.fillStyle = '#0f1216';
|
|
37
|
+
g.fillRect(0, 0, canvas.width, canvas.height);
|
|
38
|
+
g.textBaseline = 'middle';
|
|
39
|
+
g.font = fonts.heading;
|
|
40
|
+
g.fillStyle = '#e6edf3';
|
|
41
|
+
g.fillText(heading, pad, pad + 14);
|
|
42
|
+
g.font = fonts.note;
|
|
43
|
+
g.fillStyle = '#9aa7b4';
|
|
44
|
+
g.fillText(legend, pad, pad + 46);
|
|
45
|
+
const wrap = (text, maxW) => {
|
|
46
|
+
const lines = [];
|
|
47
|
+
let line = '';
|
|
48
|
+
for (const word of text.split(' ')) {
|
|
49
|
+
if (line && g.measureText(line + ' ' + word).width > maxW) {
|
|
50
|
+
lines.push(line);
|
|
51
|
+
line = word;
|
|
52
|
+
} else line = line ? line + ' ' + word : word;
|
|
53
|
+
}
|
|
54
|
+
if (line) lines.push(line);
|
|
55
|
+
return lines;
|
|
56
|
+
};
|
|
57
|
+
return (async () => {
|
|
58
|
+
for (let r = 0; r < rows.length; r++) {
|
|
59
|
+
const row = rows[r];
|
|
60
|
+
const y = headerH + r * (cellH + labelH + pad);
|
|
61
|
+
for (let c = 0; c < cols; c++) {
|
|
62
|
+
const x = pad + c * (cellW + pad);
|
|
63
|
+
const cell = row.cells ? row.cells[c] : null;
|
|
64
|
+
g.fillStyle = '#07080a';
|
|
65
|
+
g.fillRect(x, y, cellW, cellH);
|
|
66
|
+
if (cell?.image) {
|
|
67
|
+
const img = new Image();
|
|
68
|
+
img.src = cell.image;
|
|
69
|
+
await img.decode();
|
|
70
|
+
g.drawImage(img, x, y, cellW, cellH);
|
|
71
|
+
}
|
|
72
|
+
const colors = tone[cell?.tone] || tone.plain;
|
|
73
|
+
g.fillStyle = colors.bar;
|
|
74
|
+
g.fillRect(x, y + cellH, cellW, labelH);
|
|
75
|
+
g.fillStyle = colors.text;
|
|
76
|
+
g.font = fonts.note;
|
|
77
|
+
g.fillText(cell?.label ?? '', x + 8, y + cellH + labelH / 2);
|
|
78
|
+
}
|
|
79
|
+
if (row.note) {
|
|
80
|
+
const free = row.cells ? row.cells.findIndex(cell => !cell) : 0;
|
|
81
|
+
const x = pad + Math.max(0, free) * (cellW + pad);
|
|
82
|
+
g.font = fonts.note;
|
|
83
|
+
const lines = wrap(row.note, cellW - 24).slice(0, 5);
|
|
84
|
+
g.fillStyle = 'rgba(15, 18, 22, 0.92)';
|
|
85
|
+
g.fillRect(x + 6, y + 6, cellW - 12, 20 + lines.length * 20);
|
|
86
|
+
g.fillStyle = tone.failed.text;
|
|
87
|
+
lines.forEach((line, i) => g.fillText(line, x + 14, y + 26 + i * 20));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return canvas.toDataURL('image/jpeg', 0.85).split(',')[1];
|
|
91
|
+
})();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Renders one or more labelled contact sheets for a land's audited scenes from stills on disk.
|
|
96
|
+
*
|
|
97
|
+
* @param {object} options
|
|
98
|
+
* @param {object} options.browser Playwright browser instance.
|
|
99
|
+
* @param {Function} options.within Timeout helper `(ms, label, promise) => Promise`.
|
|
100
|
+
* @param {string} options.outDir Output directory for JPEG sheets.
|
|
101
|
+
* @param {{ width: number, height: number }} options.viewport Captured still dimensions.
|
|
102
|
+
* @param {string} options.land Land identifier.
|
|
103
|
+
* @param {object[]} options.results Audited scene results for this land.
|
|
104
|
+
* @param {object} options.report Overall audit report metadata (`beats`, `rows`, `at`).
|
|
105
|
+
* @returns {Promise<string[]>} Paths of written sheet files.
|
|
106
|
+
*/
|
|
107
|
+
async function writeAuditSheets({ browser, within, outDir, viewport, land, results, report }) {
|
|
108
|
+
const cols = report.beats.length;
|
|
109
|
+
const cellW = Math.max(160, Math.min(CELL_W, Math.floor((SHEET_WIDEST_PX - PAD * (cols + 1)) / cols)));
|
|
110
|
+
const cellH = Math.round((cellW * viewport.height) / viewport.width);
|
|
111
|
+
const split = results.length > report.rows;
|
|
112
|
+
const files = [];
|
|
113
|
+
const sheetContext = await within(30000, 'a blank page for the sheets', browser.newContext({ viewport: { width: 1480, height: 900 } }));
|
|
114
|
+
try {
|
|
115
|
+
const sheetPage = await sheetContext.newPage();
|
|
116
|
+
for (let from = 0, part = 1; from < results.length; from += report.rows, part++) {
|
|
117
|
+
const partResults = results.slice(from, from + report.rows);
|
|
118
|
+
const rows = partResults.map(result => ({
|
|
119
|
+
cells: report.beats.map((_, i) => {
|
|
120
|
+
const beat = result.beats[i];
|
|
121
|
+
if (!beat?.still) return null;
|
|
122
|
+
const label =
|
|
123
|
+
`${result.id} @ ${beat.t} s cast ${beat.active}/${beat.onScreen}/${beat.tris} ${Math.round(beat.fps)} fps` +
|
|
124
|
+
` shown ${beat.shown}${beat.px < 0 ? '' : ` px ${beat.px}`}`;
|
|
125
|
+
return { label, tone: beat.flags?.[0] || 'plain', image: imageAsDataUrl(beat.still) };
|
|
126
|
+
}),
|
|
127
|
+
note: result.status === 'ok' ? '' : `${result.id} FAILED: ${result.reason}`,
|
|
128
|
+
}));
|
|
129
|
+
const sheet = {
|
|
130
|
+
rows,
|
|
131
|
+
cols,
|
|
132
|
+
cellW,
|
|
133
|
+
cellH,
|
|
134
|
+
labelH: LABEL_H,
|
|
135
|
+
pad: PAD,
|
|
136
|
+
headerH: HEADER_H,
|
|
137
|
+
tone: TONE,
|
|
138
|
+
fonts: { heading: '600 22px system-ui, -apple-system, sans-serif', note: '600 15px system-ui, -apple-system, sans-serif' },
|
|
139
|
+
width: PAD + cols * (cellW + PAD),
|
|
140
|
+
height: HEADER_H + rows.length * (cellH + LABEL_H + PAD) + PAD,
|
|
141
|
+
heading: `scene audit · land ${land} · scenes ${from + 1}-${from + partResults.length} of ${results.length} · ${report.at}`,
|
|
142
|
+
legend:
|
|
143
|
+
'cast active/on-screen/triangles fps shown: figures not hidden px: pixels the cast covers (at the noise floor with triangles drawn: drawn but not seen)' +
|
|
144
|
+
' red: NO-CAST-DRAWN amber: NO-CAST-PIXELS',
|
|
145
|
+
};
|
|
146
|
+
const file = path.join(outDir, split ? `audit-${land}-${part}.jpg` : `audit-${land}.jpg`);
|
|
147
|
+
const encoded = await within(180000, 'the sheet being drawn', sheetPage.evaluate(drawAuditSheetInPage, sheet)).catch(error => {
|
|
148
|
+
console.log(` sheet ${path.basename(file)} could not be drawn: ${describeError(error)}`);
|
|
149
|
+
return null;
|
|
150
|
+
});
|
|
151
|
+
if (!encoded) continue;
|
|
152
|
+
fs.writeFileSync(file, Buffer.from(encoded, 'base64'));
|
|
153
|
+
files.push(file);
|
|
154
|
+
}
|
|
155
|
+
} finally {
|
|
156
|
+
await sheetContext.close().catch(() => {});
|
|
157
|
+
}
|
|
158
|
+
return files;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Formats one scene's audit line for console output.
|
|
163
|
+
*
|
|
164
|
+
* @param {object} result Scene audit result record.
|
|
165
|
+
* @param {number} seconds Wall seconds spent auditing the scene.
|
|
166
|
+
* @returns {string}
|
|
167
|
+
*/
|
|
168
|
+
function formatAuditRow(result, seconds) {
|
|
169
|
+
const beats = result.beats.map(beat => {
|
|
170
|
+
const pixels = beat.px >= 0 ? ` px${beat.px}` : beat.unread ? ` px unread: ${beat.unread.slice(0, 60)}` : '';
|
|
171
|
+
const mark = !beat.flags?.length ? '' : beat.flags.includes(NO_CAST_DRAWN) ? ' !' : ' ~';
|
|
172
|
+
return `(${beat.t}: ${beat.active}/${beat.onScreen}/${beat.tris} ${Math.round(beat.fps)}fps${pixels})${mark}`;
|
|
173
|
+
});
|
|
174
|
+
const shown = result.beats.map(beat => beat.shown);
|
|
175
|
+
const hidden = result.beats.some((beat, i) => shown[i] < beat.active) ? ` shown ${shown.join('/')}` : '';
|
|
176
|
+
const errored = result.problems.some(p => ERROR_KINDS.includes(p.kind)) ? ' !' : '';
|
|
177
|
+
const problems = result.beats.length ? ` problems: ${result.problems.length}${errored}` : '';
|
|
178
|
+
const head = `${result.id.padEnd(18)}${result.land.padEnd(6)}${String(result.dur).padStart(3)}s `;
|
|
179
|
+
return result.status === 'ok'
|
|
180
|
+
? `${head}${beats.join(' ')}${hidden}${problems} ${seconds.toFixed(1)}s`
|
|
181
|
+
: `${head}${beats.join(' ')}${hidden} FAILED: ${result.reason}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Prints the formatted summary of all audited scenes and flagged defects.
|
|
186
|
+
*
|
|
187
|
+
* @param {object} report Complete audit report object.
|
|
188
|
+
* @param {string} outDir Output directory path.
|
|
189
|
+
* @param {Function} [log=console.log]
|
|
190
|
+
*/
|
|
191
|
+
function printAuditSummary(report, outDir, log = console.log) {
|
|
192
|
+
const results = report.scenes;
|
|
193
|
+
const beats = results.flatMap(r => r.beats);
|
|
194
|
+
const slow = results.filter(r => r.status === 'ok' && r.problems.some(p => p.kind === 'perf'));
|
|
195
|
+
log(
|
|
196
|
+
`\n== summary: ${results.length} scenes in ${report.lands.length} lands, ${beats.length} beats read, ` +
|
|
197
|
+
`${results.filter(r => r.status !== 'ok').length} failed, wall ${report.wall.toFixed(1)} min`,
|
|
198
|
+
);
|
|
199
|
+
log(`stills: ${outDir} readings: ${path.join(outDir, 'audit.json')}`);
|
|
200
|
+
log(`sheets: ${report.sheets.map(file => path.basename(file)).join(' ') || 'none'}`);
|
|
201
|
+
for (const [flag, title] of [
|
|
202
|
+
[NO_CAST_DRAWN, 'a beat with a cast active but no cast figure on screen or no cast triangle in the frame'],
|
|
203
|
+
[NO_CAST_PIXELS, "cast triangles in the frame, but hiding the cast changed no more pixels than the frame's own flicker"],
|
|
204
|
+
[PAGE_ERROR, 'errors or warnings in the page log or console while the scene played'],
|
|
205
|
+
]) {
|
|
206
|
+
const found = results.filter(r => r.flags.includes(flag));
|
|
207
|
+
log(`\n${flag}: ${found.length} scenes (${title})`);
|
|
208
|
+
for (const r of found) {
|
|
209
|
+
const detail =
|
|
210
|
+
flag === PAGE_ERROR
|
|
211
|
+
? r.problems
|
|
212
|
+
.filter(p => ERROR_KINDS.includes(p.kind))
|
|
213
|
+
.slice(0, 3)
|
|
214
|
+
.map(p => `${p.kind}${p.n > 1 ? ` x${p.n}` : ''}: ${p.text.slice(0, 150)}`)
|
|
215
|
+
.join('\n' + ' '.repeat(18))
|
|
216
|
+
: r.beats
|
|
217
|
+
.filter(b => b.flags.includes(flag))
|
|
218
|
+
.map(
|
|
219
|
+
b =>
|
|
220
|
+
`${b.t}s: ${b.onScreen} of ${b.active} on screen, ${b.shown} shown, ${b.submitted} submitted, ${b.tris} tris${
|
|
221
|
+
b.px < 0 ? '' : `, px ${b.px} (noise ${b.noise})`
|
|
222
|
+
}`,
|
|
223
|
+
)
|
|
224
|
+
.join('; ');
|
|
225
|
+
log(` ${r.id.padEnd(18)}${detail}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (slow.length) {
|
|
229
|
+
log(
|
|
230
|
+
`\nperf notes in the page log (slow frames, slow loading; not errors): ${slow.reduce((n, r) => n + r.problems.filter(p => p.kind === 'perf').length, 0)} in ${slow.length} scenes`,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const failed = results.filter(r => r.status !== 'ok');
|
|
234
|
+
if (failed.length) {
|
|
235
|
+
log(`\nFAILED: ${failed.length} scenes`);
|
|
236
|
+
for (const r of failed) log(` ${r.id.padEnd(18)}${r.reason}`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Atomically writes the audit JSON report to `<outDir>/audit.json`.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} outDir
|
|
244
|
+
* @param {object} report
|
|
245
|
+
*/
|
|
246
|
+
function saveAuditReport(outDir, report) {
|
|
247
|
+
const file = path.join(outDir, 'audit.json');
|
|
248
|
+
fs.writeFileSync(file + '.tmp', JSON.stringify(report, null, 1));
|
|
249
|
+
fs.renameSync(file + '.tmp', file);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Constructs a standardised failed scene record.
|
|
254
|
+
*
|
|
255
|
+
* @param {object} scene Catalog scene entry.
|
|
256
|
+
* @param {string} reason Failure reason text.
|
|
257
|
+
* @returns {object}
|
|
258
|
+
*/
|
|
259
|
+
function failedAuditResult(scene, reason) {
|
|
260
|
+
return {
|
|
261
|
+
id: scene.id,
|
|
262
|
+
land: scene.land,
|
|
263
|
+
space: scene.space,
|
|
264
|
+
dur: scene.dur,
|
|
265
|
+
title: scene.title,
|
|
266
|
+
status: 'failed',
|
|
267
|
+
reason,
|
|
268
|
+
beats: [],
|
|
269
|
+
problems: [],
|
|
270
|
+
flags: [FAILED],
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
module.exports = {
|
|
275
|
+
TONE,
|
|
276
|
+
drawAuditSheetInPage,
|
|
277
|
+
writeAuditSheets,
|
|
278
|
+
formatAuditRow,
|
|
279
|
+
printAuditSummary,
|
|
280
|
+
saveAuditReport,
|
|
281
|
+
failedAuditResult,
|
|
282
|
+
};
|