roamwright 0.4.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +21 -14
- package/README.md +38 -42
- package/examples/animals.html +49 -0
- package/examples/animals.js +209 -0
- package/examples/crowds.html +50 -0
- package/examples/crowds.js +268 -0
- package/examples/effects.html +53 -0
- package/examples/effects.js +343 -0
- package/examples/figure-motion.html +55 -0
- package/examples/figure-motion.js +265 -0
- package/examples/figure.html +49 -0
- package/examples/figure.js +238 -0
- package/examples/fliers.html +53 -0
- package/examples/fliers.js +292 -0
- package/examples/fortification.html +54 -0
- package/examples/fortification.js +288 -0
- package/examples/house-kit.html +48 -0
- package/examples/house-kit.js +175 -0
- package/examples/index.html +26 -16
- package/examples/island.html +48 -0
- package/examples/island.js +134 -52
- package/examples/land.html +54 -0
- package/examples/land.js +392 -0
- package/examples/props-and-plants.html +53 -0
- package/examples/props-and-plants.js +275 -0
- package/examples/rooms.html +48 -0
- package/examples/rooms.js +242 -0
- package/examples/ships.html +51 -0
- package/examples/ships.js +235 -0
- package/examples/showcase.css +320 -0
- package/examples/small-world-land.js +151 -0
- package/examples/small-world-life.js +160 -0
- package/examples/small-world-town.js +127 -0
- package/examples/small-world.html +57 -0
- package/examples/small-world.js +226 -0
- package/examples/soundscape.html +138 -0
- package/examples/soundscape.js +467 -0
- package/examples/stage-kits.js +300 -0
- package/examples/stage.js +374 -0
- package/examples/towns.html +50 -0
- package/examples/towns.js +325 -0
- package/examples/viaduct-camera.js +8 -4
- package/examples/viaduct-landscape.js +28 -17
- package/examples/viaduct.html +45 -43
- package/examples/viaduct.js +68 -92
- package/geometry/animal-camel-body.js +410 -0
- package/geometry/animal-camel-head.js +118 -0
- package/geometry/animal-canine-body.js +361 -0
- package/geometry/animal-canine-breeds.js +316 -0
- package/geometry/animal-canine-head.js +337 -0
- package/geometry/animal-cattle-body.js +391 -0
- package/geometry/animal-cattle-coat.js +42 -0
- package/geometry/animal-cattle-head.js +152 -0
- package/geometry/animal-hen.js +248 -0
- package/geometry/animal-horse-body.js +446 -0
- package/geometry/animal-horse-bridle.js +171 -0
- package/geometry/animal-horse-coat.js +68 -0
- package/geometry/animal-horse-face.js +162 -0
- package/geometry/animal-horse-hair.js +304 -0
- package/geometry/animal-horse-head.js +133 -0
- package/geometry/animal-horse-tack.js +157 -0
- package/geometry/animal-options.js +59 -0
- package/geometry/animal-shapes.js +21 -0
- package/geometry/animal-skin.js +390 -0
- package/geometry/bedding.js +141 -0
- package/geometry/builder-cells.js +50 -0
- package/geometry/builder-frame.js +48 -0
- package/geometry/builder.js +200 -177
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cell-mask.js +25 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +40 -35
- package/geometry/crowd-dress.js +315 -0
- package/geometry/crowd-far.js +174 -0
- package/geometry/crowd-look.js +42 -0
- package/geometry/crowd-weld.js +218 -0
- package/geometry/ear.js +44 -39
- package/geometry/erosion.js +71 -45
- package/geometry/face-grid.js +85 -65
- package/geometry/field-map.js +59 -0
- package/geometry/figure-arms.js +339 -0
- package/geometry/figure-beard.js +250 -0
- package/geometry/figure-body.js +297 -0
- package/geometry/figure-bow.js +105 -0
- package/geometry/figure-cloak.js +189 -0
- package/geometry/figure-clothes.js +337 -0
- package/geometry/figure-face-grids.js +75 -0
- package/geometry/figure-gear.js +446 -0
- package/geometry/figure-hair-far.js +151 -0
- package/geometry/figure-hair-hangs.js +108 -0
- package/geometry/figure-hair-patch.js +66 -0
- package/geometry/figure-hair.js +320 -0
- package/geometry/figure-hands.js +321 -0
- package/geometry/figure-head-features.js +280 -0
- package/geometry/figure-head.js +375 -0
- package/geometry/figure-headwear.js +223 -0
- package/geometry/figure-legs.js +231 -0
- package/geometry/figure-limbs.js +39 -0
- package/geometry/figure-sculpt.js +82 -0
- package/geometry/figure-skin.js +97 -0
- package/geometry/figure-skirts.js +303 -0
- package/geometry/figure-trunk.js +411 -0
- package/geometry/flier-corvid-body.js +322 -0
- package/geometry/flier-corvid-wings.js +154 -0
- package/geometry/flier-long-body.js +195 -0
- package/geometry/flier-shapes.js +219 -0
- package/geometry/flier-soaring-bird.js +84 -0
- package/geometry/foliage.js +187 -14
- package/geometry/fort-city-walls.js +479 -0
- package/geometry/fort-gate-approach.js +233 -0
- package/geometry/fort-great-walls.js +280 -0
- package/geometry/fort-keep.js +297 -0
- package/geometry/fort-parts.js +261 -0
- package/geometry/fort-polyline.js +261 -0
- package/geometry/fort-portal.js +96 -0
- package/geometry/fort-ring-wall.js +267 -0
- package/geometry/fort-seawall.js +104 -0
- package/geometry/fort-terrace-gates.js +323 -0
- package/geometry/fort-terrace-plan.js +250 -0
- package/geometry/fort-terrace-wall.js +345 -0
- package/geometry/garment-tags.js +11 -3
- package/geometry/grid-gather.js +69 -0
- package/geometry/grid-sample.js +185 -0
- package/geometry/hair-gathers.js +57 -42
- package/geometry/hair-locks.js +42 -42
- package/geometry/hair-patch.js +24 -20
- package/geometry/hair-shell.js +43 -31
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +26 -15
- package/geometry/head-shape.js +123 -95
- package/geometry/heightfield.js +50 -24
- package/geometry/horizon-angles.js +166 -0
- package/geometry/house-kit-body.js +195 -0
- package/geometry/house-kit-courtyard-parts.js +340 -0
- package/geometry/house-kit-courtyard-roof.js +223 -0
- package/geometry/house-kit-courtyard.js +409 -0
- package/geometry/house-kit-cut.js +29 -0
- package/geometry/house-kit-extras.js +192 -0
- package/geometry/house-kit-forms.js +298 -0
- package/geometry/house-kit-frame.js +74 -0
- package/geometry/house-kit-marks.js +93 -0
- package/geometry/house-kit-openings.js +193 -0
- package/geometry/house-kit-palette.js +54 -0
- package/geometry/house-kit-pool.js +71 -0
- package/geometry/house-kit-roofs.js +151 -0
- package/geometry/house-kit.js +202 -0
- package/geometry/index-parts.js +2 -2
- package/geometry/instance-visibility.js +12 -12
- package/geometry/instances.js +17 -17
- package/geometry/lamp-wash.js +65 -0
- package/geometry/land-clearings.js +83 -0
- package/geometry/land-ditches.js +290 -0
- package/geometry/land-dry-basin.js +327 -0
- package/geometry/land-dunes.js +150 -0
- package/geometry/land-earthworks.js +432 -0
- package/geometry/land-edge.js +292 -0
- package/geometry/land-mound-faces.js +349 -0
- package/geometry/land-near-relief.js +102 -0
- package/geometry/land-sheet.js +220 -0
- package/geometry/land-town-ground.js +256 -0
- package/geometry/land-waters.js +228 -0
- package/geometry/land-wildness.js +123 -0
- package/geometry/lathed-vessel.js +293 -0
- package/geometry/outline-grid.js +11 -10
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +38 -3
- package/geometry/path-field.js +98 -34
- package/geometry/placement.js +52 -52
- package/geometry/planked-floor.js +149 -0
- package/geometry/plant-broadleaf.js +268 -0
- package/geometry/plant-shrub.js +198 -0
- package/geometry/plant-tints.js +80 -0
- package/geometry/plant-trees.js +453 -0
- package/geometry/plant-tussock.js +107 -0
- package/geometry/point-buckets.js +50 -0
- package/geometry/primitives.js +117 -59
- package/geometry/prop-battlefield.js +69 -0
- package/geometry/prop-camp.js +175 -0
- package/geometry/prop-door.js +26 -0
- package/geometry/prop-harbour.js +105 -0
- package/geometry/prop-haycock.js +60 -0
- package/geometry/prop-sacks.js +74 -0
- package/geometry/prop-sheaf.js +68 -0
- package/geometry/prop-street.js +69 -0
- package/geometry/prop-tents.js +396 -0
- package/geometry/prop-tombs.js +80 -0
- package/geometry/prop-trade.js +393 -0
- package/geometry/prop-vehicles.js +218 -0
- package/geometry/props.js +58 -0
- package/geometry/room-arcade.js +134 -0
- package/geometry/room-dome.js +188 -0
- package/geometry/room-flames.js +138 -0
- package/geometry/room-frame.js +106 -0
- package/geometry/room-furniture.js +260 -0
- package/geometry/room-hearth.js +98 -0
- package/geometry/room-kit.js +59 -0
- package/geometry/room-openings.js +142 -0
- package/geometry/room-stairs.js +180 -0
- package/geometry/room-surfaces.js +272 -0
- package/geometry/sagging-tube.js +27 -27
- package/geometry/sampled-surface.js +123 -77
- package/geometry/scatter-grid.js +49 -6
- package/geometry/sculpt.js +97 -93
- package/geometry/ship-fittings.js +350 -0
- package/geometry/ship-hull.js +460 -0
- package/geometry/ship-kit.js +208 -0
- package/geometry/ship-lines.js +69 -0
- package/geometry/ship-oars.js +150 -0
- package/geometry/ship-presets.js +131 -0
- package/geometry/ship-rig.js +374 -0
- package/geometry/ship-sails.js +148 -0
- package/geometry/shore-grid.js +81 -34
- package/geometry/strata-field.js +131 -98
- package/geometry/strata-tiles.js +108 -94
- package/geometry/stream.js +96 -59
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +216 -123
- package/geometry/terrain-extension.js +29 -13
- package/geometry/town-courtyard-inn.js +272 -0
- package/geometry/town-ground.js +76 -0
- package/geometry/town-houses.js +343 -0
- package/geometry/town-lights.js +254 -0
- package/geometry/town-lots.js +172 -0
- package/geometry/town-plan.js +370 -0
- package/geometry/town-works.js +465 -0
- package/geometry/village-layout.js +181 -0
- package/geometry/village-yards.js +167 -0
- package/geometry/wall-runs.js +64 -0
- package/index.js +138 -2
- package/math/cell-edge.js +16 -16
- package/math/cell-key.js +6 -0
- package/math/circle-clearances.js +19 -0
- package/math/cloth-textures.js +6 -6
- package/math/cloud-textures.js +22 -26
- package/math/color.js +14 -14
- package/math/curve.js +26 -22
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +379 -205
- package/math/noise.js +101 -49
- package/math/particle-noise.js +28 -28
- package/math/periodic.js +11 -5
- package/math/random.js +24 -15
- package/math/rectangles.js +58 -0
- package/math/rock-texture.js +22 -17
- package/math/scalar.js +5 -5
- package/math/surface-textures.js +74 -59
- package/math/wandering-path.js +40 -0
- package/math/ways.js +120 -0
- package/motion/action-dynamics.js +398 -0
- package/motion/animal-bearing.js +247 -0
- package/motion/animal-canine-bearing.js +178 -0
- package/motion/animal-canine-cast.js +131 -0
- package/motion/animal-cattle-cast.js +64 -0
- package/motion/animal-herd-cast.js +154 -0
- package/motion/animal-horse-still.js +161 -0
- package/motion/animal-troop-cast.js +43 -0
- package/motion/arm-reach.js +27 -26
- package/motion/ballistic-arc.js +191 -0
- package/motion/biped-cycle.js +46 -0
- package/motion/biped-leg.js +40 -0
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +226 -140
- package/motion/boat-sailing.js +214 -0
- package/motion/contact-transition.js +32 -0
- package/motion/crowd-alarms.js +72 -42
- package/motion/crowd-attention.js +108 -0
- package/motion/crowd-beasts.js +203 -0
- package/motion/crowd-camp.js +295 -0
- package/motion/crowd-figure.js +100 -0
- package/motion/crowd-herd.js +86 -0
- package/motion/crowd-hold.js +130 -0
- package/motion/crowd-pose.js +296 -0
- package/motion/crowd-poses.js +481 -0
- package/motion/crowd-routine.js +126 -67
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/daily-clock.js +9 -9
- package/motion/deck-surface.js +40 -0
- package/motion/figure-acts.js +411 -0
- package/motion/figure-arms.js +437 -0
- package/motion/figure-blade-slide.js +149 -0
- package/motion/figure-body-place.js +180 -0
- package/motion/figure-bones.js +118 -0
- package/motion/figure-bow-draw.js +70 -0
- package/motion/figure-fingers.js +215 -0
- package/motion/figure-gaze.js +205 -0
- package/motion/figure-gestures.js +452 -0
- package/motion/figure-grip.js +134 -0
- package/motion/figure-head.js +287 -0
- package/motion/figure-legs.js +264 -0
- package/motion/figure-links.js +293 -0
- package/motion/figure-locomotion.js +391 -0
- package/motion/figure-mount-up.js +180 -0
- package/motion/figure-mount.js +201 -0
- package/motion/figure-pose-frame.js +375 -0
- package/motion/figure-pose-table.js +156 -0
- package/motion/figure-pose.js +343 -0
- package/motion/figure-seat.js +267 -0
- package/motion/figure-sway.js +125 -0
- package/motion/flier-corvid-pose.js +74 -0
- package/motion/flier-flight-air.js +122 -0
- package/motion/flier-flight-echelon.js +164 -0
- package/motion/flier-flight-roost.js +131 -0
- package/motion/flier-swarm-flight.js +252 -0
- package/motion/formation.js +193 -0
- package/motion/ground-lookahead.js +5 -5
- package/motion/instance-sight.js +15 -8
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +41 -32
- package/motion/quadruped.js +244 -168
- package/motion/spaces.js +90 -38
- package/motion/speech-cadence.js +304 -0
- package/motion/vessel-motion.js +57 -0
- package/motion/walk-grid.js +235 -0
- package/motion/weather.js +133 -26
- package/motion/wind.js +58 -13
- package/package.json +33 -6
- package/rendering/alpha-mips.js +340 -0
- package/rendering/animal-camel-figure.js +29 -0
- package/rendering/animal-canine-figure.js +59 -0
- package/rendering/animal-cattle-figure.js +36 -0
- package/rendering/animal-horse-figure.js +49 -0
- package/rendering/atmosphere.js +86 -0
- package/rendering/camera-track.js +156 -0
- package/rendering/cart-track.js +92 -0
- package/rendering/caster-motion.js +6 -5
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +754 -113
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +30 -30
- package/rendering/cloud-field.js +2 -2
- package/rendering/compilation-schedule.js +79 -14
- package/rendering/contact-shadows.js +7 -4
- package/rendering/context.js +57 -6
- package/rendering/crowd-batches.js +420 -0
- package/rendering/crowd-herd.js +198 -0
- package/rendering/crowd-rig.js +132 -0
- package/rendering/crowd-skinning.js +62 -19
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/crust.js +18 -12
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +4 -6
- package/rendering/detail-range.js +29 -0
- package/rendering/dispose-meshes.js +18 -0
- package/rendering/dof.js +20 -13
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/eye-adapt.js +14 -14
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +89 -62
- package/rendering/field-surface.js +138 -0
- package/rendering/figure-shield.js +105 -0
- package/rendering/figure-skeleton.js +329 -0
- package/rendering/fire-light-watch.js +197 -0
- package/rendering/fire-pools.js +148 -0
- package/rendering/flame-sources.js +86 -0
- package/rendering/flier-bird-looks.js +97 -0
- package/rendering/flier-corvid-figure.js +67 -0
- package/rendering/flier-long-body-company.js +169 -0
- package/rendering/flier-swarm.js +186 -0
- package/rendering/flocks.js +82 -78
- package/rendering/garment-material.js +147 -51
- package/rendering/glow-lines.js +13 -13
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +45 -31
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +164 -22
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +56 -0
- package/rendering/label-range.js +41 -0
- package/rendering/lamp-light-map.js +159 -0
- package/rendering/lamp-maps.js +62 -0
- package/rendering/lamp-wash.js +51 -0
- package/rendering/light-budget.js +71 -55
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +39 -8
- package/rendering/material-lod.js +49 -50
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +135 -99
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +212 -101
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +298 -11
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +806 -103
- package/rendering/plant-cells.js +122 -0
- package/rendering/plant-reeds.js +113 -0
- package/rendering/plant-shade-trees.js +239 -0
- package/rendering/plant-tuft-patch.js +122 -0
- package/rendering/post-shaders.js +98 -31
- package/rendering/post.js +107 -87
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/rain-streaks.js +67 -0
- package/rendering/room-light.js +250 -0
- package/rendering/room-materials.js +78 -0
- package/rendering/room-space.js +111 -0
- package/rendering/scene-lights.js +106 -0
- package/rendering/sea-shaders.js +94 -37
- package/rendering/settlement-approach.js +226 -0
- package/rendering/settlement-dissolve.js +89 -0
- package/rendering/settlement-quarter-warm.js +55 -0
- package/rendering/settlement-quarter.js +477 -0
- package/rendering/settlement-switch.js +42 -0
- package/rendering/settlement-town.js +110 -0
- package/rendering/shader-warmup.js +101 -44
- package/rendering/shadow-alignment.js +4 -4
- package/rendering/shadow-depth.js +47 -25
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +56 -29
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +126 -54
- package/rendering/smoke-shadows.js +201 -0
- package/rendering/stage-framing.js +182 -0
- package/rendering/stage-lights.js +46 -39
- package/rendering/stain-material.js +74 -0
- package/rendering/static-point-shadow.js +65 -26
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +12 -12
- package/rendering/stream-flow.js +10 -10
- package/rendering/street-lamps.js +166 -0
- package/rendering/sunbeam-motes.js +670 -0
- package/rendering/surface-light.js +65 -6
- package/rendering/surface-material.js +306 -0
- package/rendering/surface-projection.js +32 -0
- package/rendering/surface-snippets.js +314 -0
- package/rendering/taa.js +75 -44
- package/rendering/talus.js +15 -15
- package/rendering/terrain-rock.js +7 -7
- package/rendering/texture-fills.js +8 -8
- package/rendering/textures.js +28 -28
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/wakes.js +24 -24
- package/rendering/water-material.js +304 -103
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +38 -40
- package/ruff.toml +20 -0
- package/runtime/cue-cursor.js +21 -0
- package/runtime/device-quality.js +13 -2
- package/runtime/device.js +73 -0
- package/runtime/diagnostic-log.js +12 -4
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +36 -28
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +47 -0
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +15 -11
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +44 -5
- package/runtime/hand-over.js +47 -24
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +73 -17
- package/runtime/quality-fit.js +60 -28
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +26 -22
- package/runtime/settlement-reach.js +42 -0
- package/runtime/sound-calls.js +113 -0
- package/runtime/sound-impacts.js +297 -0
- package/runtime/sound-voices.js +194 -0
- package/runtime/soundscape.js +282 -0
- package/runtime/spatial-audio.js +79 -30
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +46 -0
- package/runtime/worker.js +7 -0
- package/scripts/app-parts.mjs +118 -0
- package/scripts/bake-revisions.mjs +81 -0
- package/scripts/browser-scripts.mjs +64 -0
- package/scripts/bundle.mjs +192 -0
- package/scripts/check-app.sh +26 -0
- package/scripts/eslint-config.mjs +119 -0
- package/scripts/format.sh +92 -0
- package/scripts/keep-builds.mjs +158 -0
- package/scripts/layers.mjs +112 -0
- package/scripts/lint.sh +49 -0
- package/scripts/module-graph.mjs +123 -0
- package/scripts/pre-commit.sh +38 -0
- package/scripts/serve.py +5 -3
- package/scripts/site.mjs +358 -0
- package/scripts/test-runner.sh +42 -0
- package/scripts/vendor.mjs +221 -0
- package/scripts/verify-publish.mjs +175 -0
- package/scripts/world.mk +59 -0
- package/tools/README.md +73 -0
- package/tools/contact-sheet.cjs +137 -0
- package/tools/cpu-profile.cjs +275 -0
- package/tools/cpu-profile.test.cjs +98 -0
- package/tools/first-draws.cjs +395 -0
- package/tools/flight-guard.cjs +482 -0
- package/tools/flight-guard.test.cjs +153 -0
- package/tools/flight-profile.cjs +145 -0
- package/tools/frame-bench.cjs +336 -0
- package/tools/frame-parts.cjs +365 -0
- package/tools/ios-sim.sh +145 -0
- package/tools/load-audit.cjs +201 -0
- package/tools/look-compare.cjs +304 -0
- package/tools/look-guard.cjs +407 -0
- package/tools/look-guard.test.cjs +93 -0
- package/tools/look-stats.cjs +185 -0
- package/tools/look-stats.test.cjs +71 -0
- package/tools/memory-audit.cjs +323 -0
- package/tools/page-driver.cjs +320 -0
- package/tools/page-driver.test.cjs +219 -0
- package/tools/program-census-report.cjs +191 -0
- package/tools/program-census.cjs +465 -0
- package/tools/program-census.test.cjs +332 -0
- package/tools/remote-runner.sh +265 -0
- package/tools/runners.test.cjs +59 -0
- package/tools/scene-audit-beat.cjs +344 -0
- package/tools/scene-audit-sheet.cjs +282 -0
- package/tools/scene-audit.cjs +471 -0
- package/tools/scene-audit.test.cjs +201 -0
- package/tools/scene-batch.cjs +219 -0
- package/tools/scene-bench.cjs +149 -0
- package/tools/scene-bench.test.cjs +33 -0
- package/tools/scene-run.cjs +443 -0
- package/tools/scene-run.test.cjs +94 -0
- package/tools/servers.sh +59 -0
- package/tools/shader-arrival.cjs +316 -0
- package/tools/shader-renewal.cjs +53 -0
- package/tools/shader-renewal.test.cjs +115 -0
- package/tools/speed-guard.cjs +258 -0
- package/tools/stills.cjs +492 -0
- package/tools/stills.test.cjs +49 -0
- package/tools/turns.sh +7 -0
- package/tools/yaml.cjs +158 -0
- package/examples/viaduct.css +0 -75
- package/rendering/light-shafts.js +0 -131
- package/rendering/road-surface.js +0 -63
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Woven architectural cloth material (awnings, tents, sails, banners) with triplanar weave
|
|
3
|
+
* and crumple relief, distance-faded normal perturbation, backlit translucency, and optional
|
|
4
|
+
* street-lamp bounce at night.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as THREE from 'three';
|
|
9
|
+
import { LOW_LIGHT_REFLECTANCE } from './low-light.js';
|
|
10
|
+
import { thinSurfaceLight } from './surface-light.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates a procedural woven-cloth `MeshStandardMaterial` for architectural awnings, tents, banners, and sails.
|
|
14
|
+
*
|
|
15
|
+
* @param {object} options
|
|
16
|
+
* @param {THREE.Texture} options.weaveTexture Tileable woven cloth texture.
|
|
17
|
+
* @param {THREE.Texture} options.crumpleTexture Tileable fold/crumple relief texture (blue channel used for height).
|
|
18
|
+
* @param {object} [options.uniforms] Shared uniform wrappers (`uSunLight`, and when `lampWash` is true: `uNight`, `uGas`, `uGasWash`, `uLampMap`, `uLampR`).
|
|
19
|
+
* @param {boolean} [options.lampWash=false] Include night street-lamp and window bounce reflected off paving below canopies.
|
|
20
|
+
* @param {{ sky?: number, sun?: number }} [options.backlight] Backlit sky and sunlight transmission weights.
|
|
21
|
+
* @param {boolean} [options.shadowedTranslucency=true] Gate backlit sunlight by `sunShadow()` (`installFarShadowShader`).
|
|
22
|
+
* @param {number} [options.roughness=0.88] Base fabric roughness.
|
|
23
|
+
* @param {string} [options.cacheKey] Explicit program cache key.
|
|
24
|
+
* @returns {THREE.MeshStandardMaterial}
|
|
25
|
+
*/
|
|
26
|
+
export function createClothMaterial({
|
|
27
|
+
weaveTexture,
|
|
28
|
+
crumpleTexture,
|
|
29
|
+
uniforms = {},
|
|
30
|
+
lampWash = false,
|
|
31
|
+
backlight = {},
|
|
32
|
+
shadowedTranslucency = true,
|
|
33
|
+
roughness = 0.88,
|
|
34
|
+
cacheKey = lampWash ? 'kitcloth-weave-gas-bounce' : 'kitcloth-weave',
|
|
35
|
+
} = {}) {
|
|
36
|
+
const sky = backlight.sky ?? 0.32;
|
|
37
|
+
const sun = backlight.sun ?? 0.22;
|
|
38
|
+
const uSunLight = uniforms.uSunLight ?? { value: 1 };
|
|
39
|
+
const uNight = uniforms.uNight ?? { value: 0 };
|
|
40
|
+
const uGas = uniforms.uGas ?? { value: new THREE.Color(1, 0.72, 0.38) };
|
|
41
|
+
const uGasWash = uniforms.uGasWash ?? { value: 0 };
|
|
42
|
+
const uLampMap = uniforms.uLampMap ?? { value: null };
|
|
43
|
+
const uLampR = uniforms.uLampR ?? { value: new THREE.Vector4(0, 0, 0, 0) };
|
|
44
|
+
|
|
45
|
+
const through = thinSurfaceLight({
|
|
46
|
+
sky,
|
|
47
|
+
sun,
|
|
48
|
+
sunlight: shadowedTranslucency ? 'sunSeen * uSunLight' : 'uSunLight',
|
|
49
|
+
shadowed: shadowedTranslucency,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const material = new THREE.MeshStandardMaterial({ vertexColors: true, roughness });
|
|
53
|
+
material.onBeforeCompile = sh => {
|
|
54
|
+
sh.uniforms.uClothTex = { value: weaveTexture };
|
|
55
|
+
sh.uniforms.uClothCrumple = { value: crumpleTexture };
|
|
56
|
+
if (lampWash) {
|
|
57
|
+
sh.uniforms.uNight = uNight;
|
|
58
|
+
sh.uniforms.uGas = uGas;
|
|
59
|
+
sh.uniforms.uGasWash = uGasWash;
|
|
60
|
+
sh.uniforms.uLampMap = uLampMap;
|
|
61
|
+
sh.uniforms.uLampR = uLampR;
|
|
62
|
+
}
|
|
63
|
+
sh.uniforms.uSunLight = uSunLight;
|
|
64
|
+
sh.vertexShader = sh.vertexShader.replace('#include <common>', '#include <common>\nvarying vec3 vWc; varying vec3 vClothN;').replace(
|
|
65
|
+
'#include <project_vertex>',
|
|
66
|
+
`/* glsl */
|
|
67
|
+
#include <project_vertex>
|
|
68
|
+
vec4 wc = vec4(transformed, 1.0);
|
|
69
|
+
vec3 wn = objectNormal;
|
|
70
|
+
#ifdef USE_INSTANCING
|
|
71
|
+
wc = instanceMatrix * wc;
|
|
72
|
+
wn = mat3(instanceMatrix) * wn;
|
|
73
|
+
#endif
|
|
74
|
+
vWc = (modelMatrix * wc).xyz;
|
|
75
|
+
vClothN = normalize(mat3(modelMatrix) * wn);`,
|
|
76
|
+
);
|
|
77
|
+
const commonDecl = lampWash
|
|
78
|
+
? '#include <common>\nvarying vec3 vWc; varying vec3 vClothN; uniform sampler2D uClothTex, uClothCrumple; uniform float uNight, uGasWash; uniform vec3 uGas; uniform sampler2D uLampMap; uniform vec4 uLampR; uniform float uSunLight; float gClothH = 0.5;' +
|
|
79
|
+
LOW_LIGHT_REFLECTANCE
|
|
80
|
+
: '#include <common>\nvarying vec3 vWc; varying vec3 vClothN; uniform sampler2D uClothTex, uClothCrumple; uniform float uSunLight; float gClothH = 0.5;';
|
|
81
|
+
const nightBounce = lampWash
|
|
82
|
+
? `/* glsl */
|
|
83
|
+
if (uNight > 0.0) {
|
|
84
|
+
vec2 lampUv = (vWc.xz - uLampR.xy) * uLampR.zw;
|
|
85
|
+
if (all(greaterThan(lampUv, vec2(0.0))) && all(lessThan(lampUv, vec2(1.0)))) {
|
|
86
|
+
vec2 pools = texture2D(uLampMap, lampUv).rg;
|
|
87
|
+
float up = (vec4(normal, 0.0) * viewMatrix).y;
|
|
88
|
+
// The paving below a canopy reflects the lamps into the yarn and across the folded hem.
|
|
89
|
+
float lamp = pools.r + 0.1 * sqrt(pools.r) + 0.022 * uGasWash;
|
|
90
|
+
vec3 bounce = (uGas * lamp + vec3(1.0, 0.63, 0.33) * pools.g * 0.28) * ((0.83 - 0.29 * up) * uNight);
|
|
91
|
+
outgoingLight += diffuseTextileBounce(diffuseColor.rgb, bounce, 0.48);
|
|
92
|
+
}
|
|
93
|
+
}`
|
|
94
|
+
: '';
|
|
95
|
+
sh.fragmentShader = sh.fragmentShader
|
|
96
|
+
.replace('#include <common>', commonDecl)
|
|
97
|
+
.replace(
|
|
98
|
+
'#include <map_fragment>',
|
|
99
|
+
`/* glsl */
|
|
100
|
+
#include <map_fragment>
|
|
101
|
+
{
|
|
102
|
+
vec3 bw = abs(vClothN); bw *= bw; bw /= max(bw.x + bw.y + bw.z, 1e-4);
|
|
103
|
+
vec3 weave = texture2D(uClothTex, vWc.zy * 2.35).rgb * bw.x + texture2D(uClothTex, vWc.xz * 2.35).rgb * bw.y + texture2D(uClothTex, vWc.xy * 2.35).rgb * bw.z;
|
|
104
|
+
vec3 crumple = texture2D(uClothCrumple, vWc.zy * 0.44).rgb * bw.x + texture2D(uClothCrumple, vWc.xz * 0.44).rgb * bw.y + texture2D(uClothCrumple, vWc.xy * 0.44).rgb * bw.z;
|
|
105
|
+
float closeFade = 1.0 - smoothstep(10.0, 42.0, length(vViewPosition));
|
|
106
|
+
gClothH = mix(0.5, dot(weave, vec3(0.333)) * 0.55 + crumple.b * 0.45, closeFade);
|
|
107
|
+
diffuseColor.rgb *= mix(1.0, (0.72 + 0.52 * dot(weave, vec3(0.333))) * (0.86 + 0.26 * crumple.b), closeFade * 0.85);
|
|
108
|
+
}`,
|
|
109
|
+
)
|
|
110
|
+
.replace(
|
|
111
|
+
'#include <roughnessmap_fragment>',
|
|
112
|
+
`/* glsl */
|
|
113
|
+
#include <roughnessmap_fragment>
|
|
114
|
+
roughnessFactor = clamp(roughnessFactor + 0.14 * (0.5 - gClothH), 0.38, 0.98);`,
|
|
115
|
+
)
|
|
116
|
+
.replace(
|
|
117
|
+
'#include <normal_fragment_maps>',
|
|
118
|
+
`/* glsl */
|
|
119
|
+
#include <normal_fragment_maps>
|
|
120
|
+
{
|
|
121
|
+
float clothRelief = 2.6 * (1.0 - smoothstep(10.0, 36.0, length(vViewPosition)));
|
|
122
|
+
if (clothRelief > 0.01) {
|
|
123
|
+
vec3 sgx = dFdx(-vViewPosition), sgy = dFdy(-vViewPosition);
|
|
124
|
+
float lx = length(sgx), ly = length(sgy);
|
|
125
|
+
if (lx > 1e-7 && ly > 1e-7) {
|
|
126
|
+
sgx /= lx; sgy /= ly;
|
|
127
|
+
vec3 r1 = cross(sgy, normal), r2 = cross(normal, sgx);
|
|
128
|
+
float det = dot(sgx, r1);
|
|
129
|
+
vec3 nb = abs(det) * normal - clothRelief * sign(det) * (dFdx(gClothH) * r1 + dFdy(gClothH) * r2);
|
|
130
|
+
float l2 = dot(nb, nb);
|
|
131
|
+
if (l2 > 1e-8) normal = nb * inversesqrt(l2);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}`,
|
|
135
|
+
)
|
|
136
|
+
.replace('#include <opaque_fragment>', nightBounce + through);
|
|
137
|
+
};
|
|
138
|
+
material.customProgramCacheKey = () => cacheKey;
|
|
139
|
+
return material;
|
|
140
|
+
}
|
package/rendering/cloud-dome.js
CHANGED
|
@@ -25,7 +25,7 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
25
25
|
JUMP = 0.6, // the viewer carried further than this in one frame (the field's units) is a cut: the clouds are drawn whole at once
|
|
26
26
|
TURNED = 0.96, // and so is a light that turned by more than this cosine,
|
|
27
27
|
CHANGED = 0.1; // or a sky whose threshold moved by more
|
|
28
|
-
const
|
|
28
|
+
const formatFloat = (v, digits = 4) => v.toFixed(digits);
|
|
29
29
|
|
|
30
30
|
const DOME_FS = `/* glsl */
|
|
31
31
|
precision highp float; precision highp sampler3D;
|
|
@@ -43,15 +43,15 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
43
43
|
const float ERODE = 0.12; // how far the creases between billows eat into the body, and
|
|
44
44
|
const float FINER = 0.42; // the finer ones, as a share of that
|
|
45
45
|
// Where a point lies in the block of billows: p from the viewer in the field's units, h its height in the layer.
|
|
46
|
-
vec3 inBlock(vec2 p, float h) { return vec3(uAt * ${
|
|
46
|
+
vec3 inBlock(vec2 p, float h) { return vec3(uAt * ${formatFloat(CLOUD_SHEET, 1)} + p, h * ${formatFloat(DEPTH)}).xzy * ${formatFloat(BLOCKS)}; }
|
|
47
47
|
// How far inside a cloud's body a point lies, in the field's value: 0 at its edge, SOFT and more in full cloud, below 0 in
|
|
48
48
|
// clear air. p: from the viewer in the field's units; h: its height in the layer (0 the base, 1 the top). over: how far the
|
|
49
49
|
// field stands over the threshold there; base: what the cloud's underside leaves of it there (0 below it, 1 well above);
|
|
50
50
|
// rough: how far the billows eat into it there.
|
|
51
51
|
float bodyAt(vec2 p, float h, float lod, out float over, out float base, out float rough) {
|
|
52
|
-
vec4 texel = textureLod(uCloudField, uAt + p * ${
|
|
52
|
+
vec4 texel = textureLod(uCloudField, uAt + p * ${formatFloat(1 / CLOUD_SHEET, 6)}, lod);
|
|
53
53
|
over = cloudField(texel) - uCloud;
|
|
54
|
-
float h2 = h * h, body = over - ${
|
|
54
|
+
float h2 = h * h, body = over - ${formatFloat(SPAN)} * h2 * h2;
|
|
55
55
|
rough = ERODE * (0.45 + 0.55 * smoothstep(0.0, 0.3, h)); // a cloud's base is smoother than its sides and top
|
|
56
56
|
// the base is level but for shallow hollows between hanging bulges (the sheet's finer lumps), deeper under a closed sky
|
|
57
57
|
base = smoothstep(0.0, BASE_SOFT, h - (BASE_HOLLOW + BASE_HOLLOW_CLOSED * smoothstep(0.25, 0.6, over)) * (1.0 - texel.g));
|
|
@@ -60,22 +60,22 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
60
60
|
}
|
|
61
61
|
// The share of a stretch that is cloud when its two ends lie a and b inside the body, the body taken to change evenly between
|
|
62
62
|
// them: a cloud's edge is found where it lies between two steps, not at the nearer step (which drew it in terraces).
|
|
63
|
-
float filled(float
|
|
64
|
-
vec2
|
|
65
|
-
return abs(
|
|
63
|
+
float filled(float startDensity, float endDensity) {
|
|
64
|
+
vec2 densities = max(vec2(startDensity, endDensity), 0.0), sum = mix(densities * densities * ${formatFloat(0.5)} / SOFT, densities - 0.5 * SOFT, step(SOFT, densities));
|
|
65
|
+
return abs(endDensity - startDensity) > 1e-4 ? clamp((sum.y - sum.x) / (endDensity - startDensity), 0.0, 1.0) : clamp(startDensity / SOFT, 0.0, 1.0);
|
|
66
66
|
}
|
|
67
67
|
void main() {
|
|
68
|
-
vec2 r = (vUv - 0.5) * ${
|
|
68
|
+
vec2 r = (vUv - 0.5) * ${formatFloat(2 * RIM)};
|
|
69
69
|
float r2 = dot(r, r);
|
|
70
|
-
if (r2 >= ${
|
|
70
|
+
if (r2 >= ${formatFloat(RIM * RIM)}) { gl_FragColor = vec4(0.0); return; }
|
|
71
71
|
float up = (1.0 - r2) / (1.0 + r2); // the direction's height: 1 overhead, 0 at the horizon
|
|
72
|
-
if (up < ${
|
|
73
|
-
vec2 q = r * (1.0 + up) / (max(up, 0.0) + ${
|
|
72
|
+
if (up < ${formatFloat(LOWEST - 0.012)}) { gl_FragColor = vec4(0.0); return; } // no cloud is drawn that low in the sky (cloud-field.js)
|
|
73
|
+
vec2 q = r * (1.0 + up) / (max(up, 0.0) + ${formatFloat(DIP)}); // how far the ray runs level for each unit it climbs
|
|
74
74
|
float reach = length(q), slope = sqrt(1.0 + reach * reach);
|
|
75
75
|
int steps = int(min(float(STEPS) + 9.0 * reach, float(MAX_STEPS))); // a ray near the horizon runs long through the layer
|
|
76
76
|
float dh = 1.0 / float(steps);
|
|
77
77
|
// the sheet's level of detail: a step is not finer than the way it travels, or a far cloud showed as a stack of slivers
|
|
78
|
-
float lod = clamp(log2(max(reach * dh * ${
|
|
78
|
+
float lod = clamp(log2(max(reach * dh * ${formatFloat(DEPTH * TEXELS)}, 0.01)) - 0.5, 0.0, 3.0);
|
|
79
79
|
float finer = FINER * (1.0 - lod / 1.5); // the finer billows fade out where a step is too long to show them
|
|
80
80
|
// each ray's steps stand a little higher or lower than its neighbours', so what is left of the layer's levels in a cloud's
|
|
81
81
|
// shading does not run on as lines
|
|
@@ -85,7 +85,7 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
85
85
|
for (int i = 0; i < MAX_STEPS; i++) {
|
|
86
86
|
if (i >= steps) break;
|
|
87
87
|
float h = (float(i) + shift) * dh;
|
|
88
|
-
vec2 p = q * (${
|
|
88
|
+
vec2 p = q * (${formatFloat(FLARE)} * (1.0 + h * ${formatFloat(THICK)}));
|
|
89
89
|
float body = bodyAt(p, h, lod, over, base, rough), cloud;
|
|
90
90
|
#if FINE
|
|
91
91
|
if (finer > 0.0 && max(was, body) > 0.0) {
|
|
@@ -94,7 +94,7 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
94
94
|
for (int k = 1; k <= 3; k++) {
|
|
95
95
|
float t = float(k) / 3.0, hk = h - (1.0 - t) * dh, part = mix(was, body, t);
|
|
96
96
|
if (part > 0.0) {
|
|
97
|
-
vec3 small = textureLod(uBillows, inBlock(q * (${
|
|
97
|
+
vec3 small = textureLod(uBillows, inBlock(q * (${formatFloat(FLARE)} * (1.0 + hk * ${formatFloat(THICK)})), hk) * 4.0 + uChurn.zxy * 3.0, lod).rgb;
|
|
98
98
|
part -= rough * finer * (1.0 - dot(small, vec3(0.5, 0.3, 0.2)));
|
|
99
99
|
}
|
|
100
100
|
cloud += filled(wasFine, part);
|
|
@@ -115,9 +115,9 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
115
115
|
if (cloud < 0.003) continue;
|
|
116
116
|
// the cloud between this point and the light, in steps that lengthen
|
|
117
117
|
float between = 0.0, gone = 0.0, span = float(L_FIRST);
|
|
118
|
-
vec2 from = q * (${
|
|
118
|
+
vec2 from = q * (${formatFloat(FLARE)} * (1.0 + lit * ${formatFloat(THICK)}));
|
|
119
119
|
for (int j = 0; j < LIGHT_STEPS; j++) {
|
|
120
|
-
float l = gone + 0.5 * span, hl = lit + uLight.y * l * ${
|
|
120
|
+
float l = gone + 0.5 * span, hl = lit + uLight.y * l * ${formatFloat(1 / DEPTH)};
|
|
121
121
|
if (hl <= 0.0 || hl >= 1.0) break;
|
|
122
122
|
between += clamp(bodyAt(from + uLight.xz * l, hl, max(lod, 0.5) + 0.5 * float(j), none, base, rough) / SOFT, 0.0, 1.0) * base * span;
|
|
123
123
|
gone += span; span *= float(L_GROW);
|
|
@@ -125,17 +125,17 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
125
125
|
between *= SIGMA;
|
|
126
126
|
float once = exp(-between); // light that comes straight through
|
|
127
127
|
float many = 0.7 * exp(-between * 0.3) + 0.3 * exp(-between * 0.1); // and light passed on from drop to drop, which reaches deeper
|
|
128
|
-
float top = sqrt(sqrt(clamp(over * ${
|
|
128
|
+
float top = sqrt(sqrt(clamp(over * ${formatFloat(1 / SPAN)}, 0.0, 1.0)));
|
|
129
129
|
// the sky's light: from above, less the deeper under the cloud's top, and a little from below on its base
|
|
130
130
|
float sky = 0.84 * exp(-3.0 * max(top - lit, 0.0)) * (0.5 + 0.5 * lit) + 0.16 * exp(-5.0 * lit);
|
|
131
|
-
float a = 1.0 - exp(-cloud * (SIGMA * ${
|
|
131
|
+
float a = 1.0 - exp(-cloud * (SIGMA * ${formatFloat(DEPTH)}) * dh * slope);
|
|
132
132
|
sum += seen * a * vec3(many, once, sky);
|
|
133
133
|
seen *= 1.0 - a;
|
|
134
134
|
if (seen < 0.02) break;
|
|
135
135
|
}
|
|
136
136
|
// each is kept in a byte: a grain of half a step of it hides the steps between
|
|
137
137
|
float grain = fract(52.9829189 * fract(dot(gl_FragCoord.xy, vec2(0.06711056, 0.00583715)))) - 0.5;
|
|
138
|
-
gl_FragColor = vec4(sum, min((1.0 - seen) * ${
|
|
138
|
+
gl_FragColor = vec4(sum, min((1.0 - seen) * ${formatFloat(1 / 0.98)}, 1.0)) + grain * ${formatFloat(1 / 255, 6)};
|
|
139
139
|
}`;
|
|
140
140
|
|
|
141
141
|
// For the sky's shader: declares cloudDome(d), the clouds' picture in a direction above the horizon (r, g, b, a as above).
|
|
@@ -143,11 +143,11 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
143
143
|
uniform sampler2D uDome, uDomeNext; uniform vec4 uDomeShift; uniform float uDomeMix;
|
|
144
144
|
// where a ray that runs q level for each unit it climbs lies in a map
|
|
145
145
|
vec2 domeUv(vec2 q) {
|
|
146
|
-
float Q = dot(q, q), up = (sqrt(1.0 + Q * ${
|
|
147
|
-
return 0.5 + q * ((up + ${
|
|
146
|
+
float Q = dot(q, q), up = (sqrt(1.0 + Q * ${formatFloat(1 - DIP * DIP, 6)}) - Q * ${formatFloat(DIP)}) / (1.0 + Q);
|
|
147
|
+
return 0.5 + q * ((up + ${formatFloat(DIP)}) / (1.0 + up) * ${formatFloat(0.5 / RIM, 6)});
|
|
148
148
|
}
|
|
149
149
|
vec4 cloudDome(vec3 d) {
|
|
150
|
-
vec2 q = d.xz / (max(d.y, 0.0) + ${
|
|
150
|
+
vec2 q = d.xz / (max(d.y, 0.0) + ${formatFloat(DIP)});
|
|
151
151
|
vec4 c = textureLod(uDome, domeUv(q + uDomeShift.xy), 0.0);
|
|
152
152
|
if (uDomeMix > 0.0) c = mix(c, textureLod(uDomeNext, domeUv(q + uDomeShift.zw), 0.0), uDomeMix);
|
|
153
153
|
return c;
|
|
@@ -200,12 +200,12 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
200
200
|
function equalBands(size, bands) {
|
|
201
201
|
const below = y => 0.5 + (y * Math.sqrt(1 - y * y) + Math.asin(y)) / Math.PI, // the share of a circle below y (-1 its foot, 1 its top)
|
|
202
202
|
rows = [0];
|
|
203
|
-
for (let
|
|
203
|
+
for (let bandIndex = 1; bandIndex < bands; bandIndex++) {
|
|
204
204
|
let low = -1,
|
|
205
205
|
high = 1;
|
|
206
206
|
for (let i = 0; i < 30; i++) {
|
|
207
207
|
const mid = (low + high) / 2;
|
|
208
|
-
if (below(mid) <
|
|
208
|
+
if (below(mid) < bandIndex / bands) low = mid;
|
|
209
209
|
else high = mid;
|
|
210
210
|
}
|
|
211
211
|
rows.push(Math.round(((low + 1) / 2) * size));
|
|
@@ -222,7 +222,7 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
222
222
|
map.scissorTest = true;
|
|
223
223
|
return map;
|
|
224
224
|
};
|
|
225
|
-
// Sets the
|
|
225
|
+
// Sets the level of cloud detail (3, 4 or 5): the maps' size and the steps of their drawing.
|
|
226
226
|
let pending = Promise.resolve(),
|
|
227
227
|
disposed = false;
|
|
228
228
|
function setCloudDetail(level) {
|
|
@@ -241,8 +241,8 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
241
241
|
STEPS: level.steps,
|
|
242
242
|
MAX_STEPS: level.most,
|
|
243
243
|
LIGHT_STEPS: level.light,
|
|
244
|
-
L_FIRST:
|
|
245
|
-
L_GROW:
|
|
244
|
+
L_FIRST: formatFloat(level.first),
|
|
245
|
+
L_GROW: formatFloat(level.grow),
|
|
246
246
|
FINE: level.fine,
|
|
247
247
|
});
|
|
248
248
|
domeMat.needsUpdate = true;
|
|
@@ -293,11 +293,11 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
293
293
|
// sky where the maps lie. light: towards the sun or the moon, whichever lights the clouds; threshold: the field's value
|
|
294
294
|
// where cloud begins; seconds: the world's time; bright: how strong that light is now (a dark one may turn unseen, as when
|
|
295
295
|
// the moon takes over from the sun that has set).
|
|
296
|
-
function updateCloudDome(
|
|
296
|
+
function updateCloudDome(deltaSeconds, light, threshold, seconds, bright, region) {
|
|
297
297
|
const { level, last } = dome,
|
|
298
298
|
sheet = cloudU.uCloudField.value,
|
|
299
299
|
billows = cloudBillows.value;
|
|
300
|
-
if (!level || !sheet?.version || !billows?.version) return; // no
|
|
300
|
+
if (!level || !sheet?.version || !billows?.version) return; // no level set yet, or the workers have not filled the sheet and the block
|
|
301
301
|
const cut =
|
|
302
302
|
!dome.whole ||
|
|
303
303
|
last.space !== region ||
|
|
@@ -320,7 +320,7 @@ export function createCloudDome({ renderer, field, warmProgram }) {
|
|
|
320
320
|
dome.band = 0;
|
|
321
321
|
dome.mix = 0;
|
|
322
322
|
} else if (dome.fading) {
|
|
323
|
-
dome.mix +=
|
|
323
|
+
dome.mix += deltaSeconds / FADE;
|
|
324
324
|
if (dome.mix >= 1) {
|
|
325
325
|
const shown = dome.next,
|
|
326
326
|
at = dome.nextAt;
|
package/rendering/cloud-field.js
CHANGED
|
@@ -53,10 +53,10 @@ export function createCloudField({
|
|
|
53
53
|
const driftX = drift.x * ALOFT * FIELD_PER_METRE,
|
|
54
54
|
driftZ = drift.y * ALOFT * FIELD_PER_METRE,
|
|
55
55
|
slant = (FLARE * (1 + SHADOW_AT * THICK)) / (Math.max(light.y, 0) + DIP),
|
|
56
|
-
|
|
56
|
+
cloudShadow = cloudU.uCloudSh.value;
|
|
57
57
|
overhead.x = x * FIELD_PER_METRE + driftX;
|
|
58
58
|
overhead.z = z * FIELD_PER_METRE + driftZ;
|
|
59
|
-
|
|
59
|
+
cloudShadow.set(
|
|
60
60
|
wrap((driftX + light.x * slant) / CLOUD_SHEET),
|
|
61
61
|
wrap((driftZ + light.z * slant) / CLOUD_SHEET),
|
|
62
62
|
threshold + SHADOW_FROM,
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Coordinate shader compilation and first use across an application's render passes.
|
|
3
|
+
* During loading, await `warmShaders(roots, { blocking: true })` to pass the blocking
|
|
4
|
+
* flag to `beginCompiles` and submit shader programs together. During play, omit
|
|
5
|
+
* the flag to follow the application's incremental schedule. The roots can be one
|
|
6
|
+
* subtree or several disjoint subtrees that share a lighting environment.
|
|
7
|
+
*/
|
|
8
|
+
export function createCompilationSchedule({ renderer, scene, beginCompiles, putToUse, useProgram, timeoutMs = 20000, onError = () => {} }) {
|
|
4
9
|
let warmed = false;
|
|
10
|
+
const interrupted = new WeakMap();
|
|
5
11
|
const programs = () => renderer.info.programs;
|
|
6
12
|
const addedSince = known => programs().filter(program => !known.has(program));
|
|
7
13
|
function beginWarm() {
|
|
@@ -10,25 +16,84 @@ export function createCompilationSchedule({renderer, scene, beginCompiles, putTo
|
|
|
10
16
|
try {
|
|
11
17
|
const done = beginCompiles(scene, warmed);
|
|
12
18
|
const added = addedSince(known);
|
|
13
|
-
return Promise.resolve(done)
|
|
14
|
-
|
|
19
|
+
return Promise.resolve(done)
|
|
20
|
+
.then(() => putToUse(added.filter(program => programs().includes(program))))
|
|
21
|
+
.catch(onError);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
onError(error);
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
|
-
|
|
26
|
+
// Disjoint subtrees of one scene can share a pass without being reparented. A blocking load
|
|
27
|
+
// may submit them together and initialize the programs before its first draw.
|
|
28
|
+
async function warmShaders(root = scene, { blocking = false, signal, retryKey = root } = {}) {
|
|
29
|
+
signal?.throwIfAborted();
|
|
30
|
+
if (Array.isArray(root)) {
|
|
31
|
+
const roots = root;
|
|
32
|
+
if (!roots.length) return;
|
|
33
|
+
root = {
|
|
34
|
+
traverse(visit) {
|
|
35
|
+
for (const tree of roots) tree.traverse(visit);
|
|
36
|
+
},
|
|
37
|
+
traverseVisible(visit) {
|
|
38
|
+
// The target scene already contributes its visible lights. Only detached roots
|
|
39
|
+
// bring additional lights to Three's compile pass.
|
|
40
|
+
for (const tree of roots) {
|
|
41
|
+
let parent = tree;
|
|
42
|
+
while (parent && parent !== scene) parent = parent.parent;
|
|
43
|
+
if (!parent) tree.traverseVisible(visit);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
17
48
|
const known = new Set(programs());
|
|
18
|
-
|
|
49
|
+
const unfinished = signal && interrupted.get(retryKey);
|
|
50
|
+
if (unfinished) for (const program of known) if (unfinished.has(program)) known.delete(program);
|
|
51
|
+
let timer, onAbort;
|
|
52
|
+
const deadline = signal && new AbortController();
|
|
53
|
+
const active = signal && AbortSignal.any([signal, deadline.signal]);
|
|
19
54
|
try {
|
|
20
|
-
const done = beginCompiles(root, warmed);
|
|
21
|
-
if (root !== scene && !warmed) {
|
|
55
|
+
const done = beginCompiles(root, warmed, blocking, active);
|
|
56
|
+
if (root !== scene && !warmed && !blocking && !signal) {
|
|
22
57
|
Promise.resolve(done).catch(onError);
|
|
23
58
|
return;
|
|
24
59
|
}
|
|
25
|
-
|
|
60
|
+
const limit = new Promise((resolve, reject) => {
|
|
61
|
+
if (!active) {
|
|
62
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
onAbort = () => reject(active.reason);
|
|
66
|
+
if (active.aborted) {
|
|
67
|
+
onAbort();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
active.addEventListener('abort', onAbort, { once: true });
|
|
71
|
+
timer = setTimeout(() => deadline.abort(new Error('Shader preparation timed out')), timeoutMs);
|
|
72
|
+
});
|
|
73
|
+
await Promise.race([done, limit]);
|
|
74
|
+
active?.throwIfAborted();
|
|
26
75
|
if (root === scene) {
|
|
27
76
|
for (const program of programs()) useProgram(program);
|
|
28
77
|
warmed = true;
|
|
29
|
-
} else
|
|
30
|
-
|
|
31
|
-
|
|
78
|
+
} else if (blocking) {
|
|
79
|
+
for (const program of addedSince(known)) useProgram(program);
|
|
80
|
+
} else await putToUse(addedSince(known), active);
|
|
81
|
+
if (unfinished) interrupted.delete(retryKey);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (signal) {
|
|
84
|
+
const unclaimed = unfinished || new WeakSet();
|
|
85
|
+
for (const program of addedSince(known)) unclaimed.add(program);
|
|
86
|
+
interrupted.set(retryKey, unclaimed);
|
|
87
|
+
// Other passes in the same preparation may still have an incremental submission queued.
|
|
88
|
+
deadline.abort(error);
|
|
89
|
+
if (signal.aborted) throw signal.reason;
|
|
90
|
+
}
|
|
91
|
+
onError(error);
|
|
92
|
+
if (signal) throw error;
|
|
93
|
+
} finally {
|
|
94
|
+
clearTimeout(timer);
|
|
95
|
+
if (onAbort) active.removeEventListener('abort', onAbort);
|
|
96
|
+
}
|
|
32
97
|
}
|
|
33
|
-
return {beginWarm, warmShaders};
|
|
98
|
+
return { beginWarm, warmShaders };
|
|
34
99
|
}
|
|
@@ -16,8 +16,11 @@ export class ContactShadows {
|
|
|
16
16
|
geometry.setAttribute('intensity', new THREE.InstancedBufferAttribute(new Float32Array(capacity), 1).setUsage(THREE.DynamicDrawUsage));
|
|
17
17
|
geometry.instanceCount = 0;
|
|
18
18
|
const material = new THREE.ShaderMaterial({
|
|
19
|
-
transparent: true,
|
|
20
|
-
|
|
19
|
+
transparent: true,
|
|
20
|
+
depthWrite: false,
|
|
21
|
+
polygonOffset: true,
|
|
22
|
+
polygonOffsetFactor: -2,
|
|
23
|
+
polygonOffsetUnits: -6,
|
|
21
24
|
uniforms: { opacityScale: { value: opacity }, lift: { value: lift } },
|
|
22
25
|
vertexShader: `
|
|
23
26
|
attribute vec4 contact;
|
|
@@ -28,8 +31,8 @@ export class ContactShadows {
|
|
|
28
31
|
void main() {
|
|
29
32
|
offset = position.xz;
|
|
30
33
|
weight = intensity;
|
|
31
|
-
vec3
|
|
32
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(
|
|
34
|
+
vec3 contactPosition = contact.xyz + vec3(position.x * contact.w, lift, position.z * contact.w);
|
|
35
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(contactPosition, 1.0);
|
|
33
36
|
}`,
|
|
34
37
|
fragmentShader: `
|
|
35
38
|
uniform float opacityScale;
|
package/rendering/context.js
CHANGED
|
@@ -1,18 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create the Three.js renderer, scenes and camera used by a Roamwright world, and define
|
|
3
|
+
* the default Three.js visibility layer numbers shared across rendering passes.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import * as THREE from 'three';
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Default Three.js layer numbers reserved by Roamwright's rendering passes.
|
|
11
|
+
* Every pass accepts a `layer` / `maskLayer` / `extraLayer` option to override its slot.
|
|
12
|
+
*
|
|
13
|
+
* - `main` (`0`): default scene objects reflected in planar water mirrors.
|
|
14
|
+
* - `unmirrored` (`1`): objects visible to the main camera but excluded from planar reflections unless enabled.
|
|
15
|
+
* - `stillCasters` (`2`): static shadow casters cached by `createStaticPointShadow` and `still-casters.js`.
|
|
16
|
+
* - `heightProbe` (`3`): temporary layer used during offscreen `createHeightProbe` depth measurements.
|
|
17
|
+
* - `reflectionMask` (`30`): water-visibility stencil mask drawn only by the planar reflection camera.
|
|
18
|
+
*/
|
|
19
|
+
export const RENDER_LAYERS = Object.freeze({
|
|
20
|
+
main: 0,
|
|
21
|
+
unmirrored: 1,
|
|
22
|
+
stillCasters: 2,
|
|
23
|
+
heightProbe: 3,
|
|
24
|
+
reflectionMask: 30,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create a shadow-enabled renderer, a perspective camera and a group for world objects.
|
|
29
|
+
* Size the renderer to the canvas and update the camera aspect ratio before rendering.
|
|
30
|
+
* @param {HTMLCanvasElement} canvas - Drawing surface for the WebGL renderer.
|
|
31
|
+
* @param {object} [options]
|
|
32
|
+
* @param {boolean} [options.antialias=true] - Hardware antialiasing on the drawing buffer.
|
|
33
|
+
* @param {number} [options.fov=68] - Vertical field of view in degrees.
|
|
34
|
+
* @param {number} [options.near=0.25] - Near clipping plane in world units.
|
|
35
|
+
* @param {number} [options.far=7000] - Far clipping plane in world units.
|
|
36
|
+
* @param {THREE.ToneMapping} [options.toneMapping=THREE.ACESFilmicToneMapping] - Renderer tone-mapping operator.
|
|
37
|
+
* @param {number} [options.toneMappingExposure=1.0] - Renderer tone-mapping exposure.
|
|
38
|
+
* @param {THREE.EulerOrder} [options.rotationOrder='YXZ'] - Camera Euler rotation order.
|
|
39
|
+
* @param {number[]} [options.enabledLayers=[RENDER_LAYERS.unmirrored]] - Additional camera layers enabled alongside layer 0.
|
|
40
|
+
* @returns The renderer, main scene, camera, world group and a separate scene for effects.
|
|
41
|
+
*/
|
|
42
|
+
export function createRenderContext(
|
|
43
|
+
canvas,
|
|
44
|
+
{
|
|
45
|
+
antialias = true,
|
|
46
|
+
fov = 68,
|
|
47
|
+
near = 0.25,
|
|
48
|
+
far = 7000,
|
|
49
|
+
toneMapping = THREE.ACESFilmicToneMapping,
|
|
50
|
+
toneMappingExposure = 1.0,
|
|
51
|
+
rotationOrder = 'YXZ',
|
|
52
|
+
enabledLayers = [RENDER_LAYERS.unmirrored],
|
|
53
|
+
} = {},
|
|
54
|
+
) {
|
|
4
55
|
const renderer = new THREE.WebGLRenderer({ canvas, antialias, powerPreference: 'high-performance', stencil: false });
|
|
5
56
|
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
6
|
-
renderer.toneMapping =
|
|
7
|
-
renderer.toneMappingExposure =
|
|
57
|
+
renderer.toneMapping = toneMapping;
|
|
58
|
+
renderer.toneMappingExposure = toneMappingExposure;
|
|
8
59
|
renderer.shadowMap.enabled = true;
|
|
9
|
-
renderer.shadowMap.type =
|
|
60
|
+
renderer.shadowMap.type = THREE.PCFShadowMap;
|
|
10
61
|
renderer.info.autoReset = false;
|
|
11
62
|
const scene = new THREE.Scene();
|
|
12
63
|
const camera = new THREE.PerspectiveCamera(fov, 1, near, far);
|
|
13
|
-
camera.rotation.order =
|
|
64
|
+
camera.rotation.order = rotationOrder;
|
|
14
65
|
scene.add(camera);
|
|
15
|
-
camera.layers.enable(
|
|
66
|
+
for (let i = 0; i < enabledLayers.length; i++) camera.layers.enable(enabledLayers[i]);
|
|
16
67
|
const worldGroup = new THREE.Group();
|
|
17
68
|
scene.add(worldGroup);
|
|
18
69
|
const fxScene = new THREE.Scene();
|