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,201 @@
|
|
|
1
|
+
// Load timing (`runReady`), stalled-load diagnostics (`runLoadDiag`), and invalid WebGL program watch (`runGlWatch`).
|
|
2
|
+
'use strict';
|
|
3
|
+
const { renewShaders, renewalFlags, saltFor } = require('./shader-renewal.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Measures step-by-step time to ready and post-entry long frames across rounds, addresses, and optional comparison
|
|
7
|
+
* build, with `--fresh` / `--parallel` shader renewal flags.
|
|
8
|
+
*
|
|
9
|
+
* @param {object} driver Page driver from `createPageDriver`.
|
|
10
|
+
* @param {object} [options]
|
|
11
|
+
* @param {string[]} [options.argv=[]]
|
|
12
|
+
* @param {string} [options.base2='']
|
|
13
|
+
* @param {string} [options.quality='']
|
|
14
|
+
*/
|
|
15
|
+
async function runReady(driver, { argv = [], base2 = '', quality = '' } = {}) {
|
|
16
|
+
driver.longRun(3600);
|
|
17
|
+
const renewal = renewalFlags(argv),
|
|
18
|
+
rounds = +renewal.rest[0] || 3,
|
|
19
|
+
addresses = renewal.rest.slice(1),
|
|
20
|
+
bases = [driver.BASE, base2].filter(Boolean);
|
|
21
|
+
if (!addresses.length) addresses.push('');
|
|
22
|
+
const browser = await driver.chromium.launch({ executablePath: driver.shell, ...driver.GPU });
|
|
23
|
+
let load = 0;
|
|
24
|
+
for (const address of addresses) {
|
|
25
|
+
for (let r = 0; r < rounds; r++) {
|
|
26
|
+
for (const base of bases) {
|
|
27
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 720 } });
|
|
28
|
+
await ctx.addInitScript(renewShaders, { salt: renewal.fresh ? saltFor(renewal, load++) : 0, parallel: renewal.parallel });
|
|
29
|
+
const page = await ctx.newPage(),
|
|
30
|
+
errs = [];
|
|
31
|
+
page.on('pageerror', e => errs.push(e.message.slice(0, 160)));
|
|
32
|
+
page.on('console', m => (m.type() === 'error' || /WebGL|INVALID/.test(m.text())) && errs.push(m.text().slice(0, 160)));
|
|
33
|
+
if (quality) await driver.applyStorage(page, { quality });
|
|
34
|
+
await page.addInitScript(d => {
|
|
35
|
+
window.__ready = 0;
|
|
36
|
+
window.__gaps = [];
|
|
37
|
+
const watch = setInterval(() => {
|
|
38
|
+
const b = document.getElementById('start');
|
|
39
|
+
if (b && !b.disabled && window[d] && !window.__clicked) {
|
|
40
|
+
window.__clicked = performance.now();
|
|
41
|
+
b.click();
|
|
42
|
+
}
|
|
43
|
+
if (window[d]?.state?.mode !== 'play') return;
|
|
44
|
+
clearInterval(watch);
|
|
45
|
+
window.__ready = performance.now();
|
|
46
|
+
window.__p0 = window[d].renderer.info.programs.length;
|
|
47
|
+
window.__usedAtReady = window[d].renderer.info.programs.filter(p => p.usedTimes > 0).length;
|
|
48
|
+
let last = performance.now();
|
|
49
|
+
const tick = now => {
|
|
50
|
+
window.__gaps.push(Math.round(now - last));
|
|
51
|
+
last = now;
|
|
52
|
+
if (now - window.__ready < 2000) requestAnimationFrame(tick);
|
|
53
|
+
};
|
|
54
|
+
requestAnimationFrame(tick);
|
|
55
|
+
}, 4);
|
|
56
|
+
}, driver.debug);
|
|
57
|
+
await page.goto(base + address + (address.includes('?') ? '&' : '?') + 'v=' + Date.now() + r);
|
|
58
|
+
await page.waitForFunction(() => window.__ready && performance.now() - window.__ready > 2200, null, { timeout: 120000 });
|
|
59
|
+
const out = await page.evaluate(d => {
|
|
60
|
+
const app = window[d];
|
|
61
|
+
return {
|
|
62
|
+
ready: app.loadTimes.ready,
|
|
63
|
+
open: Math.round(window.__ready),
|
|
64
|
+
steps: app.loadTimes.map(s => s[1]),
|
|
65
|
+
names: app.loadTimes.map(s => s[0].slice(0, 12) + ' ' + s[1]),
|
|
66
|
+
gaps: window.__gaps.filter(g => g > 40),
|
|
67
|
+
programs: window.__p0 + ' at ready, ' + app.renderer.info.programs.length + ' 2 s later',
|
|
68
|
+
post: app.post.on,
|
|
69
|
+
direct: app.env.direct,
|
|
70
|
+
quality: app.state.quality,
|
|
71
|
+
};
|
|
72
|
+
}, driver.debug);
|
|
73
|
+
console.log(
|
|
74
|
+
(base === driver.BASE ? 'this ' : 'other ') + (address || '/').padEnd(18) + (renewal.fresh ? ' first visit' : ''),
|
|
75
|
+
'ready',
|
|
76
|
+
String(out.ready).padStart(5),
|
|
77
|
+
'open to world',
|
|
78
|
+
String(out.open).padStart(5),
|
|
79
|
+
'steps',
|
|
80
|
+
String(out.steps.reduce((a, b) => a + b, 0)).padStart(5),
|
|
81
|
+
JSON.stringify(out.names),
|
|
82
|
+
'long frames after',
|
|
83
|
+
JSON.stringify(out.gaps),
|
|
84
|
+
'programs',
|
|
85
|
+
out.programs,
|
|
86
|
+
out.quality,
|
|
87
|
+
'post',
|
|
88
|
+
out.post,
|
|
89
|
+
errs.length ? 'ERRORS ' + JSON.stringify(errs.slice(0, 4)) : '',
|
|
90
|
+
);
|
|
91
|
+
await ctx.close();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
await browser.close();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Diagnoses a page load even if it stalls before becoming ready, printing console errors/warnings, the last
|
|
100
|
+
* loading-bar step, and the page's diagnostic log.
|
|
101
|
+
*
|
|
102
|
+
* @param {object} driver Page driver from `createPageDriver`.
|
|
103
|
+
* @param {object} [options]
|
|
104
|
+
* @param {string} [options.address='']
|
|
105
|
+
* @param {number} [options.waitSeconds=90]
|
|
106
|
+
* @param {string} [options.quality='high']
|
|
107
|
+
* @param {string} [options.defaultLabel='the title’s land']
|
|
108
|
+
*/
|
|
109
|
+
async function runLoadDiag(driver, { address = '', waitSeconds = 90, quality = 'high', defaultLabel = 'the title’s land' } = {}) {
|
|
110
|
+
const waitSec = Math.min(600, Math.max(10, +waitSeconds || 90));
|
|
111
|
+
const mostKept = 40;
|
|
112
|
+
const browser = await driver.chromium.launch({ executablePath: driver.shell, ...driver.GPU });
|
|
113
|
+
const context = await browser.newContext({ viewport: { width: 1280, height: 720 } });
|
|
114
|
+
await driver.applyStorage(context, { muted: '1', quality });
|
|
115
|
+
const page = await context.newPage(),
|
|
116
|
+
said = [],
|
|
117
|
+
note = (kind, text, where) => {
|
|
118
|
+
if (said.length < mostKept) said.push({ kind, text: text.slice(0, 600), where });
|
|
119
|
+
};
|
|
120
|
+
page.on('pageerror', e => note('page error', e.message + '\n' + (e.stack || '').split('\n').slice(1, 7).join('\n'), ''));
|
|
121
|
+
page.on('console', m => {
|
|
122
|
+
if (m.type() === 'error' || m.type() === 'warning') {
|
|
123
|
+
const at = m.location();
|
|
124
|
+
note(m.type(), m.text(), at.url ? `${at.url.split('/').pop()}:${at.lineNumber}` : '');
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const began = Date.now();
|
|
129
|
+
await page.goto(driver.routeUrl(address), { waitUntil: 'domcontentloaded' });
|
|
130
|
+
const world = () => page.waitForFunction(d => window[d]?.state?.mode === 'play', driver.debug, { polling: 500, timeout: waitSec * 1000 });
|
|
131
|
+
let ready = true;
|
|
132
|
+
if (address) await world().catch(() => (ready = false));
|
|
133
|
+
else {
|
|
134
|
+
await page
|
|
135
|
+
.waitForFunction(() => !document.getElementById('t-enter')?.hidden, null, { timeout: waitSec * 1000 })
|
|
136
|
+
.catch(() => (ready = false));
|
|
137
|
+
if (ready) {
|
|
138
|
+
await page.evaluate(() => document.getElementById('start').click());
|
|
139
|
+
await world().catch(() => (ready = false));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const seconds = ((Date.now() - began) / 1000).toFixed(1);
|
|
143
|
+
|
|
144
|
+
if (ready) console.log(`READY after ${seconds} s (${address || defaultLabel}, quality ${quality})`);
|
|
145
|
+
else {
|
|
146
|
+
console.log(`NOT READY after ${seconds} s (${address || defaultLabel}, quality ${quality})`);
|
|
147
|
+
const stopped = await page
|
|
148
|
+
.evaluate(
|
|
149
|
+
d => ({
|
|
150
|
+
mode: window[d]?.state?.mode ?? '(no engine)',
|
|
151
|
+
step: document.getElementById('load-text')?.textContent ?? '',
|
|
152
|
+
full: document.getElementById('load-bar')?.style.width ?? '',
|
|
153
|
+
onPage: document.body.classList.contains('crossing') ? 'the loading page' : 'some other page',
|
|
154
|
+
}),
|
|
155
|
+
driver.debug,
|
|
156
|
+
)
|
|
157
|
+
.catch(() => ({ mode: 'the page did not answer' }));
|
|
158
|
+
console.log(` mode ${stopped.mode}; last step "${stopped.step ?? ''}" at ${stopped.full ?? '?'} of the bar; ${stopped.onPage ?? ''}`);
|
|
159
|
+
}
|
|
160
|
+
for (const s of said) console.log(`${s.kind.toUpperCase()}: ${s.text}${s.where ? `\n at ${s.where}` : ''}`);
|
|
161
|
+
if (!said.length) console.log('nothing was said on the console');
|
|
162
|
+
await driver.printLog(page);
|
|
163
|
+
await browser.close();
|
|
164
|
+
return { ready, seconds: +seconds, said };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Watches `gl.getProgramParameter` for calls made on deleted/invalid WebGLProgram handles and prints stacks and
|
|
169
|
+
* WebGL console warnings.
|
|
170
|
+
*
|
|
171
|
+
* @param {object} driver Page driver from `createPageDriver`.
|
|
172
|
+
* @param {object} [options]
|
|
173
|
+
* @param {string} [options.address='']
|
|
174
|
+
* @param {number} [options.waitMs=8000]
|
|
175
|
+
*/
|
|
176
|
+
async function runGlWatch(driver, { address = '', waitMs = 8000 } = {}) {
|
|
177
|
+
const browser = await driver.chromium.launch({ executablePath: driver.shell, ...driver.GPU });
|
|
178
|
+
const ctx = await browser.newContext({ viewport: { width: 1400, height: 800 } });
|
|
179
|
+
await driver.applyStorage(ctx, { quality: 'high' });
|
|
180
|
+
await ctx.addInitScript(() => {
|
|
181
|
+
window.__bad = [];
|
|
182
|
+
for (const C of [WebGL2RenderingContext, WebGLRenderingContext]) {
|
|
183
|
+
const own = C.prototype.getProgramParameter;
|
|
184
|
+
C.prototype.getProgramParameter = function (p, what) {
|
|
185
|
+
if (!this.isProgram(p) && window.__bad.length < 12)
|
|
186
|
+
window.__bad.push(what + ' ' + new Error().stack.split('\n').slice(2, 9).join(' | '));
|
|
187
|
+
return own.call(this, p, what);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const page = await ctx.newPage();
|
|
192
|
+
page.on('console', m => /WebGL|INVALID/.test(m.text()) && console.log('CONSOLE', m.type(), m.text().slice(0, 160)));
|
|
193
|
+
await driver.enter(page, driver.routeUrl(address));
|
|
194
|
+
await page.waitForTimeout(+waitMs);
|
|
195
|
+
const bad = await page.evaluate(() => window.__bad);
|
|
196
|
+
for (const b of bad) console.log('BAD', b);
|
|
197
|
+
await driver.closeBrowser(browser);
|
|
198
|
+
return bad;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = { runGlWatch, runLoadDiag, runReady };
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// Single-page A/B frame diffing (`runAB`) and temporal steadiness / flicker checking (`runSteady`),
|
|
2
|
+
// plus pure RGBA pixel diff helpers usable in both Node tests and Chromium pages.
|
|
3
|
+
'use strict';
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Compares two RGBA8 frames of the same size, counting pixels whose max RGB channel difference exceeds `threshold`
|
|
8
|
+
* and returning the bounding box of all differing pixels.
|
|
9
|
+
*
|
|
10
|
+
* @param {Uint8Array|Uint8ClampedArray} rgbaA
|
|
11
|
+
* @param {Uint8Array|Uint8ClampedArray} rgbaB
|
|
12
|
+
* @param {number} width
|
|
13
|
+
* @param {number} height
|
|
14
|
+
* @param {number} [threshold=2]
|
|
15
|
+
* @returns {{ pixels: number, width: number, differ: number, most: number, box: number[]|null }}
|
|
16
|
+
*/
|
|
17
|
+
function diffRgbaFrames(rgbaA, rgbaB, width, height, threshold = 2) {
|
|
18
|
+
let differ = 0,
|
|
19
|
+
most = 0,
|
|
20
|
+
x0 = 1e9,
|
|
21
|
+
x1 = -1,
|
|
22
|
+
y0 = 1e9,
|
|
23
|
+
y1 = -1;
|
|
24
|
+
const total = width * height;
|
|
25
|
+
for (let i = 0; i < total * 4; i += 4) {
|
|
26
|
+
const d = Math.max(Math.abs(rgbaA[i] - rgbaB[i]), Math.abs(rgbaA[i + 1] - rgbaB[i + 1]), Math.abs(rgbaA[i + 2] - rgbaB[i + 2]));
|
|
27
|
+
if (d > threshold) {
|
|
28
|
+
differ++;
|
|
29
|
+
const p = i / 4,
|
|
30
|
+
x = p % width,
|
|
31
|
+
y = (p - x) / width;
|
|
32
|
+
if (x < x0) x0 = x;
|
|
33
|
+
if (x > x1) x1 = x;
|
|
34
|
+
if (y < y0) y0 = y;
|
|
35
|
+
if (y > y1) y1 = y;
|
|
36
|
+
}
|
|
37
|
+
if (d > most) most = d;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
pixels: total,
|
|
41
|
+
width,
|
|
42
|
+
differ,
|
|
43
|
+
most,
|
|
44
|
+
box: differ ? [x0, y0, x1, y1] : null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Measures per-pixel temporal luminance range across a sequence of RGBA8 frames inside a normalized rectangle
|
|
50
|
+
* `[fx0, fy0, fx1, fy1]`.
|
|
51
|
+
*
|
|
52
|
+
* @param {Array<Uint8Array|Uint8ClampedArray>} frames
|
|
53
|
+
* @param {number} width
|
|
54
|
+
* @param {number} height
|
|
55
|
+
* @param {[number, number, number, number]} rect Fractional `[x0, y0, x1, y1]`.
|
|
56
|
+
* @returns {{ pixels: number, over8: number, over24: number, most: number, share8: string, share24: string }}
|
|
57
|
+
*/
|
|
58
|
+
function measureFrameSteadiness(frames, width, height, rect) {
|
|
59
|
+
const [fx0, fy0, fx1, fy1] = rect,
|
|
60
|
+
x0 = Math.round(fx0 * width),
|
|
61
|
+
x1 = Math.round(fx1 * width),
|
|
62
|
+
y0 = Math.round(fy0 * height),
|
|
63
|
+
y1 = Math.round(fy1 * height);
|
|
64
|
+
let over8 = 0,
|
|
65
|
+
over24 = 0,
|
|
66
|
+
most = 0,
|
|
67
|
+
n = 0;
|
|
68
|
+
for (let y = y0; y < y1; y++) {
|
|
69
|
+
for (let x = x0; x < x1; x++) {
|
|
70
|
+
const i = (y * width + x) * 4;
|
|
71
|
+
let lo = 255,
|
|
72
|
+
hi = 0;
|
|
73
|
+
for (const frame of frames) {
|
|
74
|
+
const v = (frame[i] + frame[i + 1] + frame[i + 2]) / 3;
|
|
75
|
+
if (v < lo) lo = v;
|
|
76
|
+
if (v > hi) hi = v;
|
|
77
|
+
}
|
|
78
|
+
const d = hi - lo;
|
|
79
|
+
n++;
|
|
80
|
+
if (d > 8) over8++;
|
|
81
|
+
if (d > 24) over24++;
|
|
82
|
+
if (d > most) most = d;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
pixels: n,
|
|
87
|
+
over8,
|
|
88
|
+
over24,
|
|
89
|
+
most: Math.round(most),
|
|
90
|
+
share8: +((over8 / n) * 100).toFixed(2) + '%',
|
|
91
|
+
share24: +((over24 / n) * 100).toFixed(3) + '%',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Draws the same view before and after a single-page setting or shader cut change, saving `<OUT>/<name>-a.jpg`
|
|
97
|
+
* and `<OUT>/<name>-b.jpg` and printing pixel diff counts.
|
|
98
|
+
*
|
|
99
|
+
* @param {object} driver Page driver from `createPageDriver`.
|
|
100
|
+
* @param {object} options
|
|
101
|
+
* @param {string} options.name Output filename stem.
|
|
102
|
+
* @param {string} options.view Script setting up the view.
|
|
103
|
+
* @param {string} options.change Script switching the setting or shader cut.
|
|
104
|
+
* @param {string} [options.address='']
|
|
105
|
+
* @param {Array<string[]>} [options.cuts=[]] Optional shader cuts (`[holds, where, glsl]`).
|
|
106
|
+
* @param {string} [options.quality='high']
|
|
107
|
+
* @param {string|number} [options.hour='']
|
|
108
|
+
*/
|
|
109
|
+
async function runAB(driver, { name, view, change, address = '', cuts = [], quality = 'high', hour = '' }) {
|
|
110
|
+
const browser = await driver.chromium.launch({ executablePath: driver.shell, ...driver.GPU });
|
|
111
|
+
const ctx = await browser.newContext({ viewport: { width: 1728, height: 1117 } });
|
|
112
|
+
await driver.applyStorage(ctx, { quality });
|
|
113
|
+
if (cuts.length) await ctx.addInitScript(driver.installCuts, cuts);
|
|
114
|
+
const page = await ctx.newPage();
|
|
115
|
+
page.on('pageerror', e => console.log('PAGE ERROR', e.message.slice(0, 300)));
|
|
116
|
+
page.on('console', m => m.type() === 'error' && console.log('CONSOLE', m.text().slice(0, 300)));
|
|
117
|
+
await driver.enter(page, driver.routeUrl(address));
|
|
118
|
+
await page.waitForTimeout(4000);
|
|
119
|
+
if (cuts.length) console.log('cuts made in', JSON.stringify(await page.evaluate(() => window.cutsMade)), 'fragment shaders');
|
|
120
|
+
await page.evaluate(
|
|
121
|
+
([d, v, hr]) => {
|
|
122
|
+
const app = window[d];
|
|
123
|
+
app.holdQuality(true);
|
|
124
|
+
app.env.flow = false;
|
|
125
|
+
if (hr) app.env.time = +hr;
|
|
126
|
+
app.state.mode = 'inspect';
|
|
127
|
+
window.setCut &&= window.setCut.bind(null, app.renderer.getContext(), app.renderer.info.programs);
|
|
128
|
+
return (0, eval)(v);
|
|
129
|
+
},
|
|
130
|
+
[driver.debug, view, String(hour)],
|
|
131
|
+
);
|
|
132
|
+
await page.waitForTimeout(5000);
|
|
133
|
+
const still = async tag => {
|
|
134
|
+
await page.waitForTimeout(700);
|
|
135
|
+
const b = await page.locator(driver.canvasSelector).screenshot({ type: 'png' });
|
|
136
|
+
await page.locator(driver.canvasSelector).screenshot({ path: `${driver.OUT}/${name}-${tag}.jpg`, type: 'jpeg', quality: 85 });
|
|
137
|
+
return b.toString('base64');
|
|
138
|
+
};
|
|
139
|
+
const canvasId = driver.canvasSelector.replace(/^#/, '');
|
|
140
|
+
await page.evaluate(
|
|
141
|
+
([d, cId]) => {
|
|
142
|
+
const app = window[d];
|
|
143
|
+
for (const el of document.body.children) if (el.id !== cId) el.style.visibility = 'hidden';
|
|
144
|
+
app.state.measuring = true;
|
|
145
|
+
window.drawSettled = () => {
|
|
146
|
+
for (let i = 0; i < 16; i++) app.draw();
|
|
147
|
+
};
|
|
148
|
+
window.drawSettled();
|
|
149
|
+
},
|
|
150
|
+
[driver.debug, canvasId],
|
|
151
|
+
);
|
|
152
|
+
const a = await still('a');
|
|
153
|
+
await page.evaluate(
|
|
154
|
+
([d, c]) => {
|
|
155
|
+
const app = window[d];
|
|
156
|
+
app.partA = app.mirror?.rt && app.mirror.rt.scissor.toArray().join(',');
|
|
157
|
+
(0, eval)(c);
|
|
158
|
+
window.drawSettled();
|
|
159
|
+
},
|
|
160
|
+
[driver.debug, change],
|
|
161
|
+
);
|
|
162
|
+
const b = await still('b');
|
|
163
|
+
const diff = await page.evaluate(
|
|
164
|
+
async ([d, aB64, bB64, fnSrc]) => {
|
|
165
|
+
const app = window[d],
|
|
166
|
+
diffFrames = (0, eval)('(' + fnSrc + ')');
|
|
167
|
+
const px = async s => {
|
|
168
|
+
const bmp = await createImageBitmap(await (await fetch('data:image/png;base64,' + s)).blob());
|
|
169
|
+
const c = new OffscreenCanvas(bmp.width, bmp.height),
|
|
170
|
+
g = c.getContext('2d');
|
|
171
|
+
g.drawImage(bmp, 0, 0);
|
|
172
|
+
return { w: bmp.width, h: bmp.height, data: g.getImageData(0, 0, bmp.width, bmp.height).data };
|
|
173
|
+
};
|
|
174
|
+
const A = await px(aB64),
|
|
175
|
+
B = await px(bB64),
|
|
176
|
+
res = diffFrames(A.data, B.data, A.w, A.h, 2);
|
|
177
|
+
return {
|
|
178
|
+
...res,
|
|
179
|
+
partA: app.partA,
|
|
180
|
+
part: app.mirror?.rt && [app.mirror.rt.width, app.mirror.rt.height, ...app.mirror.rt.scissor.toArray()],
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
[driver.debug, a, b, diffRgbaFrames.toString()],
|
|
184
|
+
);
|
|
185
|
+
console.log(name, JSON.stringify(diff));
|
|
186
|
+
await browser.close();
|
|
187
|
+
return diff;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Checks whether a fixed view holds still over multiple frames, reporting pixels whose luminance drifts by >8 or >24
|
|
192
|
+
* of 255 and optionally writing a red-highlighted diff map.
|
|
193
|
+
*
|
|
194
|
+
* @param {object} driver Page driver from `createPageDriver`.
|
|
195
|
+
* @param {object} options
|
|
196
|
+
* @param {string} options.address Route address.
|
|
197
|
+
* @param {string} options.view Script setting up the view.
|
|
198
|
+
* @param {string} options.rect Comma-separated fractional rectangle `'x0,y0,x1,y1'`.
|
|
199
|
+
* @param {number} [options.frames=6]
|
|
200
|
+
* @param {boolean} [options.still=false] Also freezes wind drift (`windU.uWindDrift`).
|
|
201
|
+
* @param {string} [options.mapName=''] When set, saves `steady-<mapName>-map.png` and `steady-<mapName>-0.png`.
|
|
202
|
+
*/
|
|
203
|
+
async function runSteady(driver, { address, view, rect, frames = 6, still = false, mapName = '' }) {
|
|
204
|
+
const browser = await driver.chromium.launch({ executablePath: driver.shell, ...driver.GPU });
|
|
205
|
+
const ctx = await browser.newContext({ viewport: { width: 1728, height: 1117 } });
|
|
206
|
+
await driver.applyStorage(ctx, { quality: 'high', muted: '1' });
|
|
207
|
+
const page = await ctx.newPage();
|
|
208
|
+
page.on('pageerror', e => console.log('PAGE ERROR', e.message.slice(0, 300)));
|
|
209
|
+
await driver.enter(page, driver.routeUrl(address));
|
|
210
|
+
await page.waitForTimeout(4000);
|
|
211
|
+
await page.evaluate(
|
|
212
|
+
([d, v]) => {
|
|
213
|
+
const app = window[d];
|
|
214
|
+
app.holdQuality(true);
|
|
215
|
+
app.env.flow = false;
|
|
216
|
+
app.state.mode = 'inspect';
|
|
217
|
+
return (0, eval)(v);
|
|
218
|
+
},
|
|
219
|
+
[driver.debug, view],
|
|
220
|
+
);
|
|
221
|
+
if (still) {
|
|
222
|
+
await page.evaluate(d => {
|
|
223
|
+
const drift = window[d].windU.uWindDrift.value,
|
|
224
|
+
[x, y] = [drift.x, drift.y];
|
|
225
|
+
for (const [k, v] of [
|
|
226
|
+
['x', x],
|
|
227
|
+
['y', y],
|
|
228
|
+
])
|
|
229
|
+
Object.defineProperty(drift, k, { get: () => v, set() {} });
|
|
230
|
+
}, driver.debug);
|
|
231
|
+
}
|
|
232
|
+
await page.waitForTimeout(6000);
|
|
233
|
+
const canvasId = driver.canvasSelector.replace(/^#/, '');
|
|
234
|
+
await page.evaluate(cId => {
|
|
235
|
+
for (const el of document.body.children) if (el.id !== cId) el.style.visibility = 'hidden';
|
|
236
|
+
}, canvasId);
|
|
237
|
+
const shots = [];
|
|
238
|
+
for (let i = 0; i < +frames; i++) {
|
|
239
|
+
await page.waitForTimeout(400);
|
|
240
|
+
shots.push((await page.locator(driver.canvasSelector).screenshot({ type: 'png' })).toString('base64'));
|
|
241
|
+
}
|
|
242
|
+
const rectNums = typeof rect === 'string' ? rect.split(',').map(Number) : rect;
|
|
243
|
+
const res = await page.evaluate(
|
|
244
|
+
async ([shotList, rectArr, mapped, fnSrc]) => {
|
|
245
|
+
const measure = (0, eval)('(' + fnSrc + ')');
|
|
246
|
+
const px = async s => {
|
|
247
|
+
const bmp = await createImageBitmap(await (await fetch('data:image/png;base64,' + s)).blob());
|
|
248
|
+
const c = new OffscreenCanvas(bmp.width, bmp.height),
|
|
249
|
+
g = c.getContext('2d');
|
|
250
|
+
g.drawImage(bmp, 0, 0);
|
|
251
|
+
return { w: bmp.width, h: bmp.height, d: g.getImageData(0, 0, bmp.width, bmp.height).data };
|
|
252
|
+
};
|
|
253
|
+
const all = [];
|
|
254
|
+
for (const s of shotList) all.push(await px(s));
|
|
255
|
+
const { w, h } = all[0];
|
|
256
|
+
const counts = measure(
|
|
257
|
+
all.map(a => a.d),
|
|
258
|
+
w,
|
|
259
|
+
h,
|
|
260
|
+
rectArr,
|
|
261
|
+
);
|
|
262
|
+
if (!mapped) return { counts };
|
|
263
|
+
const m = new OffscreenCanvas(w, h),
|
|
264
|
+
mg = m.getContext('2d'),
|
|
265
|
+
img = mg.createImageData(w, h);
|
|
266
|
+
for (let i = 0; i < w * h; i++) {
|
|
267
|
+
let lo = 255,
|
|
268
|
+
hi = 0;
|
|
269
|
+
for (const a of all) {
|
|
270
|
+
const v = (a.d[i * 4] + a.d[i * 4 + 1] + a.d[i * 4 + 2]) / 3;
|
|
271
|
+
if (v < lo) lo = v;
|
|
272
|
+
if (v > hi) hi = v;
|
|
273
|
+
}
|
|
274
|
+
const d = Math.min(255, (hi - lo) * 12),
|
|
275
|
+
b = all[0].d[i * 4 + 1] * 0.5;
|
|
276
|
+
img.data[i * 4] = Math.max(d, b);
|
|
277
|
+
img.data[i * 4 + 1] = b;
|
|
278
|
+
img.data[i * 4 + 2] = b;
|
|
279
|
+
img.data[i * 4 + 3] = 255;
|
|
280
|
+
}
|
|
281
|
+
mg.putImageData(img, 0, 0);
|
|
282
|
+
const buf = new Uint8Array(await (await m.convertToBlob({ type: 'image/png' })).arrayBuffer());
|
|
283
|
+
let bin = '';
|
|
284
|
+
for (let i = 0; i < buf.length; i++) bin += String.fromCharCode(buf[i]);
|
|
285
|
+
return { counts, map: btoa(bin) };
|
|
286
|
+
},
|
|
287
|
+
[shots, rectNums, !!mapName, measureFrameSteadiness.toString()],
|
|
288
|
+
);
|
|
289
|
+
console.log(address, still ? "with the wind's drift held" : '', JSON.stringify(res.counts));
|
|
290
|
+
if (mapName) {
|
|
291
|
+
fs.writeFileSync(`${driver.OUT}/steady-${mapName}-map.png`, Buffer.from(res.map, 'base64'));
|
|
292
|
+
fs.writeFileSync(`${driver.OUT}/steady-${mapName}-0.png`, Buffer.from(shots[0], 'base64'));
|
|
293
|
+
console.log('saved', `steady-${mapName}-map`);
|
|
294
|
+
}
|
|
295
|
+
await driver.closeBrowser(browser);
|
|
296
|
+
return res.counts;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
module.exports = {
|
|
300
|
+
diffRgbaFrames,
|
|
301
|
+
measureFrameSteadiness,
|
|
302
|
+
runAB,
|
|
303
|
+
runSteady,
|
|
304
|
+
};
|