roamwright 0.20.1 → 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 +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 +134 -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/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 +27 -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/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/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
package/rendering/far-shadow.js
CHANGED
|
@@ -1,48 +1,39 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { createShadowSnap } from './shadow-alignment.js';
|
|
3
|
+
import { glslFloat } from './glsl-literal.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Default tuning for the far directional shadow cascade: `edgeFade` (`[start, end]` normalized near-map
|
|
7
|
+
* fade bounds), `reliefSteps` (terrain grid samples per axis), `spanDivisions` (sub-divisions of the
|
|
8
|
+
* shadow span), `minElevationSin` (minimum sun sine before clamping), and `lowMargin` (metres below
|
|
9
|
+
* sampled terrain floor).
|
|
10
|
+
*/
|
|
11
|
+
export const FAR_SHADOW_DEFAULTS = Object.freeze({
|
|
12
|
+
edgeFade: [0.8, 0.97],
|
|
13
|
+
reliefSteps: 8,
|
|
14
|
+
spanDivisions: 4,
|
|
15
|
+
minElevationSin: 0.05,
|
|
16
|
+
lowMargin: 10,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Patch Three.js directional-shadow shader chunks to blend a near and far directional shadow map
|
|
21
|
+
* and expose `float sunSeen` after `lights_fragment_begin`. Call before compiling standard materials.
|
|
22
|
+
*
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {number} options.nearDepth Total depth range of the near shadow camera, in metres.
|
|
25
|
+
* @param {number} options.farDepth Total depth range of the far shadow camera, in metres.
|
|
26
|
+
* @param {[number, number]} [options.edgeFade=FAR_SHADOW_DEFAULTS.edgeFade] Normalized near-cascade `[start, end]` fade range.
|
|
27
|
+
* @param {object} [options.chunks=THREE.ShaderChunk] Shader chunk table to patch.
|
|
28
|
+
*/
|
|
29
|
+
export function installFarShadowShader({
|
|
30
|
+
nearDepth: NEAR_DEPTH,
|
|
31
|
+
farDepth: FAR_DEPTH,
|
|
32
|
+
edgeFade = FAR_SHADOW_DEFAULTS.edgeFade,
|
|
33
|
+
chunks = THREE.ShaderChunk,
|
|
34
|
+
}) {
|
|
8
35
|
if (chunks.shadowmap_pars_fragment.includes('float sunShadow()')) throw Error('Far shadow shader already installed');
|
|
9
36
|
const SUN_SHADOW = /* glsl */ `
|
|
10
|
-
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 1
|
|
11
|
-
float farSunShadow( out float gap ) {
|
|
12
|
-
DirectionalLightShadow fs = directionalLightShadows[ 1 ];
|
|
13
|
-
vec3 c = vDirectionalShadowCoord[ 1 ].xyz / vDirectionalShadowCoord[ 1 ].w;
|
|
14
|
-
c.z += fs.shadowBias;
|
|
15
|
-
gap = 0.0;
|
|
16
|
-
if ( any( lessThan( c, vec3( 0.0 ) ) ) || any( greaterThan( c, vec3( 1.0 ) ) ) ) return 1.0;
|
|
17
|
-
vec2 t = c.xy * fs.shadowMapSize - 0.5, b = floor( t ), k = t - b, px = 1.0 / fs.shadowMapSize, uv = ( b + 0.5 ) * px;
|
|
18
|
-
vec4 d = vec4(
|
|
19
|
-
unpackRGBAToDepth( texture2D( directionalShadowMap[ 1 ], uv ) ),
|
|
20
|
-
unpackRGBAToDepth( texture2D( directionalShadowMap[ 1 ], uv + vec2( px.x, 0.0 ) ) ),
|
|
21
|
-
unpackRGBAToDepth( texture2D( directionalShadowMap[ 1 ], uv + vec2( 0.0, px.y ) ) ),
|
|
22
|
-
unpackRGBAToDepth( texture2D( directionalShadowMap[ 1 ], uv + px ) ) );
|
|
23
|
-
vec4 lit = step( vec4( c.z ), d );
|
|
24
|
-
gap = ( c.z - min( min( d.x, d.y ), min( d.z, d.w ) ) ) * ${FAR_DEPTH.toFixed(1)};
|
|
25
|
-
return mix( 1.0, mix( mix( lit.x, lit.y, k.x ), mix( lit.z, lit.w, k.x ), k.y ), fs.shadowIntensity );
|
|
26
|
-
}
|
|
27
|
-
float sunShadow() {
|
|
28
|
-
float gap, farS = farSunShadow( gap );
|
|
29
|
-
vec4 nc = vDirectionalShadowCoord[ 0 ];
|
|
30
|
-
vec2 edge = abs( nc.xy / nc.w - 0.5 ) * 2.0;
|
|
31
|
-
float inner = ( 1.0 - smoothstep( 0.8, 0.97, max( edge.x, edge.y ) ) ) * step( nc.z, 1.0 );
|
|
32
|
-
if ( inner <= 0.0 ) return farS;
|
|
33
|
-
DirectionalLightShadow ns = directionalLightShadows[ 0 ];
|
|
34
|
-
float nearS = getShadow( directionalShadowMap[ 0 ], ns.shadowMapSize, ns.shadowIntensity, ns.shadowBias, ns.shadowRadius, nc );
|
|
35
|
-
float reach = nc.z * ${NEAR_DEPTH.toFixed(1)};
|
|
36
|
-
return mix( farS, min( nearS, mix( 1.0, farS, smoothstep( reach - 25.0, reach, gap ) ) ), inner );
|
|
37
|
-
}
|
|
38
|
-
#elif defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
39
|
-
float sunShadow() {
|
|
40
|
-
DirectionalLightShadow ns = directionalLightShadows[ 0 ];
|
|
41
|
-
return getShadow( directionalShadowMap[ 0 ], ns.shadowMapSize, ns.shadowIntensity, ns.shadowBias, ns.shadowRadius, vDirectionalShadowCoord[ 0 ] );
|
|
42
|
-
}
|
|
43
|
-
#endif
|
|
44
|
-
`;
|
|
45
|
-
const nativeDepth = /* glsl */ `
|
|
46
37
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 1
|
|
47
38
|
float farVisibility(vec4 coord) {
|
|
48
39
|
DirectionalLightShadow farLight = directionalLightShadows[1];
|
|
@@ -53,7 +44,7 @@ export function installFarShadowShader({nearDepth: NEAR_DEPTH, farDepth: FAR_DEP
|
|
|
53
44
|
vec4 nearCoord = vDirectionalShadowCoord[0], farCoord = vDirectionalShadowCoord[1];
|
|
54
45
|
vec3 nd = nearCoord.xyz / nearCoord.w;
|
|
55
46
|
vec2 edge = abs(nd.xy - 0.5) * 2.0;
|
|
56
|
-
float inside = (1.0 - smoothstep(0
|
|
47
|
+
float inside = (1.0 - smoothstep(${glslFloat(edgeFade[0])}, ${glslFloat(edgeFade[1])}, max(edge.x, edge.y))) * step(0.0,nd.z) * step(nd.z,1.0);
|
|
57
48
|
float distant = farVisibility(farCoord);
|
|
58
49
|
if (inside <= 0.0) return distant;
|
|
59
50
|
DirectionalLightShadow ns = directionalLightShadows[0];
|
|
@@ -84,9 +75,20 @@ export function installFarShadowShader({nearDepth: NEAR_DEPTH, farDepth: FAR_DEP
|
|
|
84
75
|
getDirectionalLightInfo( directionalLight, directLight );
|
|
85
76
|
#if defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX == 0 && NUM_DIR_LIGHT_SHADOWS > 0
|
|
86
77
|
sunSeen = ( directLight.visible && receiveShadow && dot( geometryNormal, directLight.direction ) > 0.0 ) ? sunShadow() : 1.0;
|
|
78
|
+
#ifdef HAS_HORIZON_SUN
|
|
79
|
+
sunSeen *= vHorizonSun;
|
|
80
|
+
#endif
|
|
81
|
+
directLight.color *= sunSeen;
|
|
82
|
+
#elif defined( HAS_HORIZON_SUN ) && UNROLLED_LOOP_INDEX == 0
|
|
83
|
+
sunSeen = vHorizonSun;
|
|
87
84
|
directLight.color *= sunSeen;
|
|
88
85
|
#endif
|
|
86
|
+
#if UNROLLED_LOOP_INDEX == 0
|
|
89
87
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
88
|
+
#else
|
|
89
|
+
// A further directional light dimmed to nothing (a moon by day) adds nothing: its uniform colour spares every pixel its shading.
|
|
90
|
+
if ( directionalLight.color != vec3( 0.0 ) ) RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
91
|
+
#endif
|
|
90
92
|
#endif
|
|
91
93
|
}
|
|
92
94
|
#pragma unroll_loop_end
|
|
@@ -95,12 +97,38 @@ export function installFarShadowShader({nearDepth: NEAR_DEPTH, farDepth: FAR_DEP
|
|
|
95
97
|
const dirLoop = /#if \( NUM_DIR_LIGHTS > 0 \) && defined\( RE_Direct \)[\s\S]*?#if \( NUM_RECT_AREA_LIGHTS > 0 \)/;
|
|
96
98
|
if (!dirLoop.test(chunks.lights_fragment_begin)) throw new Error('far-shadow: Three.js lighting chunk not as expected');
|
|
97
99
|
chunks.lights_fragment_begin = chunks.lights_fragment_begin.replace(dirLoop, OWN_LOOP);
|
|
98
|
-
chunks.shadowmap_pars_fragment +=
|
|
99
|
-
|
|
100
|
+
chunks.shadowmap_pars_fragment += '\n#define HAS_SUN_SHADOW 1\n' + SUN_SHADOW;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Fit a coarse, texel-aligned directional far shadow volume over sampled terrain ahead of the camera.
|
|
105
|
+
*
|
|
106
|
+
* @param {object} options
|
|
107
|
+
* @param {THREE.Scene} options.scene Scene receiving the far shadow directional light and its target.
|
|
108
|
+
* @param {THREE.Camera} options.camera Viewer camera used to place the shadow frustum ahead of the eye.
|
|
109
|
+
* @param {THREE.Vector3} options.direction Unit vector toward the light source.
|
|
110
|
+
* @param {(x: number, z: number) => number} options.ground Terrain height sampler in metres.
|
|
111
|
+
* @param {object} options.config Cascade bounds (`lift`, `back`, `span`, `lead`, `bias`, `normalBias`, `step`, `turn`, `turnAt`, `minDot`).
|
|
112
|
+
* @param {number} options.mapSize Shadow map resolution per side, in texels.
|
|
113
|
+
* @param {() => boolean} [options.active] Predicate returning whether the far shadow pass should update.
|
|
114
|
+
* @param {number} [options.reliefSteps=FAR_SHADOW_DEFAULTS.reliefSteps] Terrain grid samples per axis for vertical fit.
|
|
115
|
+
* @param {number} [options.spanDivisions=FAR_SHADOW_DEFAULTS.spanDivisions] Sub-divisions of the shadow span when sampling relief.
|
|
116
|
+
* @param {number} [options.minElevationSin=FAR_SHADOW_DEFAULTS.minElevationSin] Minimum light elevation sine before clamping depth.
|
|
117
|
+
* @param {number} [options.lowMargin=FAR_SHADOW_DEFAULTS.lowMargin] Extra margin below sampled terrain floor, in metres.
|
|
118
|
+
*/
|
|
119
|
+
export function createFarShadow({
|
|
120
|
+
scene,
|
|
121
|
+
camera,
|
|
122
|
+
direction,
|
|
123
|
+
ground,
|
|
124
|
+
config: FAR,
|
|
125
|
+
mapSize,
|
|
126
|
+
active = () => true,
|
|
127
|
+
reliefSteps = FAR_SHADOW_DEFAULTS.reliefSteps,
|
|
128
|
+
spanDivisions = FAR_SHADOW_DEFAULTS.spanDivisions,
|
|
129
|
+
minElevationSin = FAR_SHADOW_DEFAULTS.minElevationSin,
|
|
130
|
+
lowMargin = FAR_SHADOW_DEFAULTS.lowMargin,
|
|
131
|
+
}) {
|
|
104
132
|
const FAR_DEPTH = FAR.lift + FAR.back - 1;
|
|
105
133
|
const farSun = new THREE.DirectionalLight(0x000000, 0);
|
|
106
134
|
farSun.castShadow = true;
|
|
@@ -126,28 +154,27 @@ export function createFarShadow({scene, camera, direction, ground, config: FAR,
|
|
|
126
154
|
}
|
|
127
155
|
drawn.x = NaN;
|
|
128
156
|
}
|
|
129
|
-
const
|
|
130
|
-
SPAN_STEP = FAR.range / 4;
|
|
157
|
+
const spanStep = FAR.range / spanDivisions;
|
|
131
158
|
const snapToTexels = createShadowSnap();
|
|
132
159
|
function fitFar(x, z) {
|
|
133
160
|
const L = direction,
|
|
134
|
-
sinE = Math.max(
|
|
161
|
+
sinE = Math.max(minElevationSin, L.y),
|
|
135
162
|
cosE = Math.sqrt(1 - sinE * sinE),
|
|
136
163
|
R = FAR.range,
|
|
137
164
|
baseHeight = ground(x, z),
|
|
138
165
|
y0 = Number.isFinite(baseHeight) ? baseHeight : 0;
|
|
139
166
|
let low = y0,
|
|
140
167
|
high = y0;
|
|
141
|
-
for (let i = 0; i <=
|
|
142
|
-
for (let j = 0; j <=
|
|
143
|
-
const h = ground(x + R * ((2 * i) /
|
|
168
|
+
for (let i = 0; i <= reliefSteps; i++)
|
|
169
|
+
for (let j = 0; j <= reliefSteps; j++) {
|
|
170
|
+
const h = ground(x + R * ((2 * i) / reliefSteps - 1), z + R * ((2 * j) / reliefSteps - 1));
|
|
144
171
|
if (!Number.isFinite(h)) continue;
|
|
145
172
|
if (h < low) low = h;
|
|
146
173
|
else if (h > high) high = h;
|
|
147
174
|
}
|
|
148
|
-
const bottom = Math.max(-R, -R * sinE + (low - y0) * cosE -
|
|
175
|
+
const bottom = Math.max(-R, -R * sinE + (low - y0) * cosE - lowMargin),
|
|
149
176
|
top = Math.min(R, R * sinE + (high + FAR.above - y0) * cosE),
|
|
150
|
-
span = Math.min(2 * R, Math.ceil((top - bottom) /
|
|
177
|
+
span = Math.min(2 * R, Math.ceil((top - bottom) / spanStep) * spanStep),
|
|
151
178
|
size = farSun.shadow.mapSize.x,
|
|
152
179
|
across = (2 * R) / size,
|
|
153
180
|
upward = span / size;
|
|
@@ -182,5 +209,5 @@ export function createFarShadow({scene, camera, direction, ground, config: FAR,
|
|
|
182
209
|
farSun.target.removeFromParent();
|
|
183
210
|
farSun.shadow.dispose();
|
|
184
211
|
}
|
|
185
|
-
return {light: farSun, setSize: setFarShadow, update: updateFarShadow, dispose};
|
|
212
|
+
return { light: farSun, setSize: setFarShadow, update: updateFarShadow, dispose };
|
|
186
213
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { glslFloat } from './glsl-literal.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default row and strip spacings (in metres) for procedural agricultural field surfaces:
|
|
5
|
+
* `plough` (furrow pitch), `shoots` (young crop rows), `grain` (standing grain rows),
|
|
6
|
+
* `headland` (border turn width), `strip` (mown pasture strips), and `swathe` (cut swathe pitch).
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_FIELD_PITCHES = {
|
|
9
|
+
plough: 1.78,
|
|
10
|
+
shoots: 2.1,
|
|
11
|
+
grain: 1.45,
|
|
12
|
+
headland: 3.2,
|
|
13
|
+
strip: 7.4,
|
|
14
|
+
swathe: 2.3,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Default GLSL `vec3(...)` linear RGB colour expressions for procedural field uses:
|
|
19
|
+
* `[dark, light]` pairs for `fallow`, `yard`, `grazedTint`, `mownTint`, and `parcelTint`,
|
|
20
|
+
* plus a single `shoots` colour.
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_FIELD_PALETTE = {
|
|
23
|
+
fallow: ['vec3(0.25, 0.22, 0.16)', 'vec3(0.42, 0.38, 0.28)'],
|
|
24
|
+
yard: ['vec3(0.24, 0.20, 0.16)', 'vec3(0.38, 0.33, 0.26)'],
|
|
25
|
+
shoots: 'vec3(0.14, 0.24, 0.08)',
|
|
26
|
+
grazedTint: ['vec3(1.08, 1.06, 0.90)', 'vec3(0.84, 0.94, 0.84)'],
|
|
27
|
+
mownTint: ['vec3(1.20, 1.16, 0.96)', 'vec3(0.92, 1.00, 0.88)'],
|
|
28
|
+
parcelTint: ['vec3(1.04, 1.0, 0.94)', 'vec3(0.96, 1.0, 1.05)'],
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Build a GLSL ES 3 fragment chunk for furrows, standing grain, mown pasture,
|
|
33
|
+
* fallow land, orchards and farmyards. The caller supplies its palette, row
|
|
34
|
+
* pitches, kind branches and parcel sampler.
|
|
35
|
+
* Insert the chunk inside a terrain material block. It blends into vec4 diffuseColor and
|
|
36
|
+
* float gTH (surface relief). Supply vec4 farm (normalized row angle, kind × kindStep/255,
|
|
37
|
+
* unused, coverage), vec2 groundX and groundY (plan-space pixel derivatives), detail
|
|
38
|
+
* samples d2 and d3 with a green channel, floats fleck and grit, world position vWP,
|
|
39
|
+
* a detail sampler2D map and the horizontal wind displacement uWindDrift.
|
|
40
|
+
* Coordinates and distances are in metres.
|
|
41
|
+
*
|
|
42
|
+
* @param {{read: string, dirt: string[], straw: string[], pasture: string[],
|
|
43
|
+
* standing: string[], baked: string, fallow?: string[], yard?: string[],
|
|
44
|
+
* shoots?: string, grazedTint?: string[], mownTint?: string[], parcelTint?: string[],
|
|
45
|
+
* pitches?: Partial<typeof DEFAULT_FIELD_PITCHES>, kindStep?: number,
|
|
46
|
+
* kinds?: string, kindBranches?: string}} look GLSL expressions and layout options.
|
|
47
|
+
* Each palette pair gives the dark and light RGB ends. The read snippet declares
|
|
48
|
+
* vec2 plan and vec4 lot (tint, row-end distance / 12.75, signed work depth
|
|
49
|
+
* encoded as (metres × 20 + 127.5) / 255, edge distance / 12.75).
|
|
50
|
+
* baked is the base RGB tint to divide out. Optional else-if branches in kinds
|
|
51
|
+
* can set crop, rough and arable for additional land uses, or kindBranches can
|
|
52
|
+
* replace the entire if/else chain.
|
|
53
|
+
* @returns {string} Fragment statements for use within their own scope.
|
|
54
|
+
*/
|
|
55
|
+
export function fieldSurfaceGLSL(look) {
|
|
56
|
+
const pitches = { ...DEFAULT_FIELD_PITCHES, ...look.pitches };
|
|
57
|
+
const fallow = look.fallow ?? DEFAULT_FIELD_PALETTE.fallow;
|
|
58
|
+
const yard = look.yard ?? DEFAULT_FIELD_PALETTE.yard;
|
|
59
|
+
const shoots = look.shoots ?? DEFAULT_FIELD_PALETTE.shoots;
|
|
60
|
+
const grazedTint = look.grazedTint ?? DEFAULT_FIELD_PALETTE.grazedTint;
|
|
61
|
+
const mownTint = look.mownTint ?? DEFAULT_FIELD_PALETTE.mownTint;
|
|
62
|
+
const parcelTint = look.parcelTint ?? DEFAULT_FIELD_PALETTE.parcelTint;
|
|
63
|
+
const kindStep = glslFloat(look.kindStep ?? 42);
|
|
64
|
+
const ploughPitch = glslFloat(pitches.plough);
|
|
65
|
+
const shootsPitch = glslFloat(pitches.shoots);
|
|
66
|
+
const grainPitch = glslFloat(pitches.grain);
|
|
67
|
+
const headland = glslFloat(pitches.headland);
|
|
68
|
+
const stripWidth = glslFloat(pitches.strip);
|
|
69
|
+
const swatheWidth = glslFloat(pitches.swathe);
|
|
70
|
+
const pitchExpr = `(kind < 0.5 ? ${ploughPitch} : kind > 5.5 ? ${shootsPitch} : ${grainPitch})`;
|
|
71
|
+
const branches =
|
|
72
|
+
look.kindBranches ??
|
|
73
|
+
`if (kind < 0.5) { // under the plough: fresh furrows behind the team, last year's weedy stubble ahead of it
|
|
74
|
+
float furrow = mix(0.33, 1.0 - smoothstep(0.03, 0.51, rows), resolved);
|
|
75
|
+
vec3 turned = dirt * (1.04 + 0.38 * (lined - 0.5) - 0.46 * (furrow - 0.33));
|
|
76
|
+
vec3 old = mix(dirt * 1.7, straw * 0.75, smoothstep(0.3, 0.7, tone * 0.75 + lined * 0.25));
|
|
77
|
+
old = mix(old, pasture * 0.85, smoothstep(0.55, 0.8, patchy) * 0.5);
|
|
78
|
+
crop = mix(old, turned, worked);
|
|
79
|
+
rough += 0.58 * rows * resolved * worked;
|
|
80
|
+
} else if (kind < 1.5) { // grain: standing gold ahead of the reapers, pale stubble in rows behind them
|
|
81
|
+
float gust = smoothstep(0.8, 0.92, textureLod(map, (vWP.xz - uWindDrift * 0.8) * 0.013, max(0.0, log2((spanAlong + spanAcross) * 3.3))).r); // the one wind running over the standing corn, a little slower than the air
|
|
82
|
+
vec3 standing = mix(${look.standing[0]}, ${look.standing[1]}, tone) * (0.88 + 0.26 * gust) * (0.94 + 0.12 * lined);
|
|
83
|
+
vec3 cut = mix(dirt * 1.9, straw * 1.05, 0.35 + 0.5 * lined);
|
|
84
|
+
crop = mix(standing, cut, worked);
|
|
85
|
+
rough += mix(0.5 * speck, 0.13 * rows * resolved, worked);
|
|
86
|
+
} else if (kind < 2.5) { // grass: pasture grazed unevenly, or a meadow mown with its hay lying in swathes
|
|
87
|
+
float graze = smoothstep(0.25, 0.75, wide * 0.7 + patchy * 0.3);
|
|
88
|
+
vec3 grazed = pasture * mix(${grazedTint[0]}, ${grazedTint[1]}, graze);
|
|
89
|
+
float sw = across / ${swatheWidth} + (wide - 0.5) * 0.3;
|
|
90
|
+
float swathe = mix(0.4, smoothstep(0.1, 0.6, sin(sw * 6.2831853) * 0.5 + 0.5), 1.0 - smoothstep(0.09, 0.3, spanAcross / ${swatheWidth}));
|
|
91
|
+
vec3 mown = mix(pasture * ${mownTint[0]}, straw * ${mownTint[1]}, swathe * 0.75);
|
|
92
|
+
crop = mix(grazed, mown, worked);
|
|
93
|
+
arable = worked;
|
|
94
|
+
} else if (kind < 3.5) { // fallow: bare in places, weeds taking it back in others
|
|
95
|
+
crop = mix(${fallow[0]}, ${fallow[1]}, tone);
|
|
96
|
+
crop = mix(crop, pasture, smoothstep(0.3, 0.8, wide * 0.8 + patchy * 0.2) * 0.65);
|
|
97
|
+
arable = 0.35;
|
|
98
|
+
} else if (kind < 4.5) { // orchard: grass under the trees
|
|
99
|
+
crop = pasture * (0.9 + 0.2 * wide);
|
|
100
|
+
arable = 0.0;
|
|
101
|
+
} else if (kind < 5.5) { // the farmyard's beaten earth
|
|
102
|
+
crop = mix(${yard[0]}, ${yard[1]}, tone);
|
|
103
|
+
arable = 0.0;
|
|
104
|
+
}${look.kinds ?? ''} else { // sown and sprouting: green lines on harrowed soil
|
|
105
|
+
float sprout = mix(0.42, smoothstep(0.42, 0.9, rows), resolved) * (0.55 + 0.45 * patchy);
|
|
106
|
+
crop = mix(dirt * 1.5, ${shoots} * (0.8 + 0.5 * tone), sprout * 0.9);
|
|
107
|
+
rough += 0.2 * rows * resolved;
|
|
108
|
+
}`;
|
|
109
|
+
return `/* glsl */
|
|
110
|
+
${look.read}
|
|
111
|
+
float kind = floor(farm.g * (255.0 / ${kindStep}) + 0.5), angle = farm.r * 3.14159265, tint = lot.r;
|
|
112
|
+
// the grain texture's samples run from about 0.73 to 1: these spread them over nought to one
|
|
113
|
+
float speck = fleck * 0.57 + grit * 0.43, tone = smoothstep(0.76, 0.96, speck), patchy = smoothstep(0.74, 0.96, d2.g), wide = smoothstep(0.76, 0.94, d3.r);
|
|
114
|
+
float worked = smoothstep(-0.25, 0.25, (lot.b * 255.0 - 127.5) / 20.0 + (d2.b - 0.83) * 2.0); // metres inside the part the season's work has reached
|
|
115
|
+
vec2 axis = vec2(cos(angle), sin(angle));
|
|
116
|
+
float along = dot(plan, axis), across = dot(plan, vec2(-axis.y, axis.x));
|
|
117
|
+
float head = step(lot.g * 12.75 + (patchy - 0.5) * 1.3, ${headland}); // the headland, where the team turns: worked last, across the rows
|
|
118
|
+
float row = (mix(across, along, head) + (wide - 0.5) * 0.42 + sin((along + across) * 0.123) * 0.16) * ${pitchExpr};
|
|
119
|
+
float rows = sin(row * 6.2831853) * 0.5 + 0.5;
|
|
120
|
+
// how far a pixel reaches along and across the rows, from groundX and groundY (taken outside every branch, so the GPU can skip all this off the fields)
|
|
121
|
+
float spanAlong = abs(dot(groundX, axis)) + abs(dot(groundY, axis)), spanAcross = abs(axis.x * groundX.y - axis.y * groundX.x) + abs(axis.x * groundY.y - axis.y * groundY.x);
|
|
122
|
+
float resolved = 1.0 - smoothstep(0.09, 0.3, mix(spanAcross, spanAlong, head) * ${pitchExpr}); // rows finer than a few pixels are left out: they would shimmer
|
|
123
|
+
float lined = mix(0.5, rows, resolved); // the rows while they can be told apart, their mean beyond
|
|
124
|
+
float land = across / ${stripWidth} + tint * 13.0, landW = spanAcross / ${stripWidth}; // strips a day's ploughing wide, each worked a little differently
|
|
125
|
+
float strip = fract(sin(floor(land) * 12.9898 + tint * 78.233) * 43758.5453) - 0.5;
|
|
126
|
+
float open = (1.0 - smoothstep(0.022, 0.022 + landW * 1.5, min(fract(land), 1.0 - fract(land)))) * min(1.0, 0.07 / max(landW, 0.0001)); // the open furrow between two strips
|
|
127
|
+
float broad = 0.72 + 0.16 * patchy + 0.4 * wide;
|
|
128
|
+
// the colours below are the ground's own: the baked colour the mesh carries is divided out where they are laid on
|
|
129
|
+
vec3 dirt = mix(${look.dirt[0]}, ${look.dirt[1]}, tone);
|
|
130
|
+
vec3 straw = mix(${look.straw[0]}, ${look.straw[1]}, tone);
|
|
131
|
+
vec3 pasture = mix(${look.pasture[0]}, ${look.pasture[1]}, patchy * 0.8 + tone * 0.2);
|
|
132
|
+
vec3 crop; float rough = 0.72 * speck, arable = 1.0;
|
|
133
|
+
${branches}
|
|
134
|
+
crop *= mix(0.86, 1.14, tint) * mix(${parcelTint[0]}, ${parcelTint[1]}, fract(tint * 7.31)); // every parcel a shade of its own
|
|
135
|
+
crop *= (1.0 + strip * 0.16 * arable * (1.0 - head)) * (1.0 - 0.17 * open * arable * (1.0 - head)) * (1.0 - 0.07 * head * arable);
|
|
136
|
+
diffuseColor.rgb = mix(diffuseColor.rgb, crop * broad / max(${look.baked}, vec3(0.02)), farm.a * 0.96);
|
|
137
|
+
gTH = mix(gTH, rough, farm.a);`;
|
|
138
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A round shield strapped on a figure's left hand (createShields): a board dished outward, faced with painted hide, an iron
|
|
3
|
+
* rim and a domed iron boss over the fist that holds its grip. It hangs at the side, face out, and comes up before the body as
|
|
4
|
+
* its bearer fights (whoever poses the arm turns it; shieldHeld turns the board in the hand).
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import * as THREE from 'three';
|
|
8
|
+
import { lerp } from '../math/scalar.js';
|
|
9
|
+
import { C } from '../geometry/primitives.js';
|
|
10
|
+
import { GB } from '../geometry/builder.js';
|
|
11
|
+
|
|
12
|
+
const DISH = 0.05, // how far its middle stands out before its edge
|
|
13
|
+
BOARD = 0.016, // the board's thickness
|
|
14
|
+
RIM = 0.012, // the iron rim's thickness
|
|
15
|
+
BOSS = 0.075, // the boss's radius
|
|
16
|
+
SIDES = 28, // round the shield: smooth from a scene's close shot
|
|
17
|
+
IRON = 0x4c4a46,
|
|
18
|
+
BACK = 0x5a4632; // the bare wood of its back
|
|
19
|
+
// A ring of the dish: [radius, height] on the front, from the middle out, of a shield of that radius.
|
|
20
|
+
function dishAt(radius, r) {
|
|
21
|
+
const u = r / radius;
|
|
22
|
+
return DISH * (1 - u * u);
|
|
23
|
+
}
|
|
24
|
+
// The shield's geometry, its face towards +y, its middle at the origin. `made`: one geometry for each paint, shared by every bearer.
|
|
25
|
+
function shieldGeometry(made, radius, paint) {
|
|
26
|
+
if (made.has(paint)) return made.get(paint);
|
|
27
|
+
const gb = new GB(),
|
|
28
|
+
face = [],
|
|
29
|
+
back = [];
|
|
30
|
+
// a lathe's faces look to the left of its profile's way: the face is drawn from the edge in, the back from the middle out
|
|
31
|
+
for (let i = 0; i <= 4; i++) {
|
|
32
|
+
const r = BOSS * 0.9 + (radius - BOSS * 0.9) * (i / 4);
|
|
33
|
+
face.unshift(new THREE.Vector2(r, dishAt(radius, r)));
|
|
34
|
+
back.push(new THREE.Vector2(r, dishAt(radius, r) - BOARD));
|
|
35
|
+
}
|
|
36
|
+
const lathe = pts => new THREE.LatheGeometry(pts, SIDES),
|
|
37
|
+
I = new THREE.Matrix4();
|
|
38
|
+
gb.add(lathe(face), C(paint), I);
|
|
39
|
+
gb.add(lathe(back), C(BACK), I);
|
|
40
|
+
// the rim: an iron band clasped over the edge, front and back
|
|
41
|
+
gb.add(
|
|
42
|
+
lathe([
|
|
43
|
+
new THREE.Vector2(radius - 0.02, dishAt(radius, radius - 0.02) - BOARD - RIM * 0.5),
|
|
44
|
+
new THREE.Vector2(radius + RIM * 0.6, -BOARD - RIM * 0.4),
|
|
45
|
+
new THREE.Vector2(radius + RIM * 0.6, RIM * 0.4),
|
|
46
|
+
new THREE.Vector2(radius - 0.02, dishAt(radius, radius - 0.02) + RIM * 0.5),
|
|
47
|
+
]),
|
|
48
|
+
C(IRON),
|
|
49
|
+
I,
|
|
50
|
+
);
|
|
51
|
+
// the boss: a dome on a flange, over the hole the fist fills
|
|
52
|
+
const boss = [new THREE.Vector2(BOSS * 1.02, DISH - 0.004), new THREE.Vector2(BOSS, DISH + 0.004)];
|
|
53
|
+
for (let i = 0; i <= 4; i++) {
|
|
54
|
+
const a = (i / 4) * (Math.PI / 2);
|
|
55
|
+
boss.push(new THREE.Vector2(BOSS * 0.72 * Math.cos(a), DISH + 0.012 + BOSS * 0.7 * Math.sin(a)));
|
|
56
|
+
}
|
|
57
|
+
gb.add(lathe(boss), C(IRON), I);
|
|
58
|
+
const geo = gb.build();
|
|
59
|
+
gb.release();
|
|
60
|
+
made.set(paint, geo);
|
|
61
|
+
return geo;
|
|
62
|
+
}
|
|
63
|
+
// How the shield sits in the hand: hanging at the side, its face turned out (the hand's -x); and in the fight, its face out along
|
|
64
|
+
// the forearm (the hand's -y), the fist in the boss. Positions in metres from the wrist.
|
|
65
|
+
const AT_REST = new THREE.Quaternion().setFromEuler(new THREE.Euler(0, 0, Math.PI / 2)),
|
|
66
|
+
IN_GUARD = new THREE.Quaternion().setFromEuler(new THREE.Euler(Math.PI, 0, 0)),
|
|
67
|
+
REST_AT = [-0.05, -0.06, 0],
|
|
68
|
+
GUARD_AT = [0, -0.08, 0];
|
|
69
|
+
/**
|
|
70
|
+
* Turns an actor's shield between the side and the guard.
|
|
71
|
+
* @param {{shield: THREE.Object3D}} a - The actor (createShields, strapShield).
|
|
72
|
+
* @param {number} k - 0 at rest, 1 fighting.
|
|
73
|
+
*/
|
|
74
|
+
function shieldHeld(a, k) {
|
|
75
|
+
const m = a.shield;
|
|
76
|
+
m.quaternion.slerpQuaternions(AT_REST, IN_GUARD, k);
|
|
77
|
+
m.position.set(lerp(REST_AT[0], GUARD_AT[0], k), lerp(REST_AT[1], GUARD_AT[1], k), 0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Round shields of one size, drawn in one material.
|
|
82
|
+
* @param {object} options
|
|
83
|
+
* @param {THREE.Material|function(): THREE.Material} options.material - What the shields are drawn in (vertex colours), or
|
|
84
|
+
* what gives it when the first is strapped on (for a page whose materials are made after its modules load).
|
|
85
|
+
* @param {number} [options.radius=0.36] - Metres: about as wide as the shoulders.
|
|
86
|
+
* @returns {{strapShield: function(object): void, shieldHeld: Function}} strapShield(actor): straps a shield on the left hand
|
|
87
|
+
* (`handL`) of an actor whose look carries one (`def.look.shield`: the colour its face is painted), once its figure is
|
|
88
|
+
* built, and keeps it as `actor.shield`.
|
|
89
|
+
*/
|
|
90
|
+
function createShields({ material, radius = 0.36 }) {
|
|
91
|
+
const made = new Map();
|
|
92
|
+
return {
|
|
93
|
+
strapShield(a) {
|
|
94
|
+
const paint = a.def.look.shield;
|
|
95
|
+
if (!paint || !a.handL) return;
|
|
96
|
+
const m = new THREE.Mesh(shieldGeometry(made, radius, paint), typeof material === 'function' ? material() : material);
|
|
97
|
+
m.castShadow = m.receiveShadow = true;
|
|
98
|
+
a.handL.add(m);
|
|
99
|
+
a.shield = m;
|
|
100
|
+
},
|
|
101
|
+
shieldHeld,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { createShields, shieldHeld };
|