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
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A land's inland waters, cut into its ground: rivers in valleys of their own, and lakes in basins.
|
|
3
|
+
*
|
|
4
|
+
* A river's channel is cut along a smoothed line whose level falls steeply where it leaves the hills and slackly across
|
|
5
|
+
* the plain. Where the land lies lower than its bank the river runs on a levee of its own silt; at its ford the channel
|
|
6
|
+
* shallows; a river into the sea is cut on past its mouth into the sea's floor, so no beach stands across it, and keeps
|
|
7
|
+
* its floor over the sea until near its mouth, so the sea does not stand in it in pools. A lake lies in a shallow basin
|
|
8
|
+
* with a ragged shore; a lake in a quarried pit has a short beach round it and never raises the ground beside it.
|
|
9
|
+
*
|
|
10
|
+
* A land calls {@link LandWaters.carve} for each point of its bake, after its hills and before its towns; what the waters
|
|
11
|
+
* made of the place (how wet, whose water, silt, mud) is written into the site record the land passes in. Plain
|
|
12
|
+
* arithmetic over seeded noise, the same on a page and in a worker.
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { spacedCurve } from '../math/curve.js';
|
|
17
|
+
import { lerp, sstep } from '../math/scalar.js';
|
|
18
|
+
import { nearestPathPoint, pathBox } from './path-field.js';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {object} River
|
|
22
|
+
* @property {[number, number][]} pts - Its line from source to mouth, as X/Z points.
|
|
23
|
+
* @property {[number, number]} level - The water's level at its source and at its mouth.
|
|
24
|
+
* @property {number} width - Metres across at its full width.
|
|
25
|
+
* @property {number} depth - Metres its channel is cut under the water.
|
|
26
|
+
* @property {string} [into] - The id of the lake it runs into; the sea when omitted.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {object} Lake
|
|
31
|
+
* @property {string} id - Its name in the land's data.
|
|
32
|
+
* @property {number} x - World X of its middle.
|
|
33
|
+
* @property {number} z - World Z of its middle.
|
|
34
|
+
* @property {number} rx - Radius along X in metres.
|
|
35
|
+
* @property {number} rz - Radius along Z in metres.
|
|
36
|
+
* @property {number} level - The level of its water.
|
|
37
|
+
* @property {number} depth - Metres deep at its middle.
|
|
38
|
+
* @property {number} [ragged] - How far its shore wanders in and out, as a share of its radii, with finer bays on the broad ones.
|
|
39
|
+
* @property {boolean} [bare] - Nothing grows on its shore.
|
|
40
|
+
* @property {boolean} [pit] - It lies in a quarried pit: a beach on the floor, and the wall standing at the water.
|
|
41
|
+
* @property {{ x: number, z: number, r: number, y: number }[]} [shelves] - Ledges a pit lake's water leaves dry.
|
|
42
|
+
* @property {boolean} [reeds] - A pit lake with reed beds: the land's `mudAt` says where their mud lies.
|
|
43
|
+
* @property {boolean} [silt] - A pit lake whose beach is silted.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/** The shape of a land's waters, in metres unless said. */
|
|
47
|
+
export const LAND_WATERS_SHAPE = {
|
|
48
|
+
/** How far from a river its valley is shaped. */
|
|
49
|
+
reach: 190,
|
|
50
|
+
/** From a river's bank, how far the rise it runs on stays level where the land lies lower than the bank. */
|
|
51
|
+
levee: 30,
|
|
52
|
+
/** A river into the sea keeps the floor of its channel this far over the sea's level, */
|
|
53
|
+
overSea: 0.4,
|
|
54
|
+
/** until within this far of its mouth (opening from the second, wholly open by the first). */
|
|
55
|
+
mouth: [180, 420],
|
|
56
|
+
/** A river's channel is cut on this far past its mouth into the sea. */
|
|
57
|
+
pastMouth: 320,
|
|
58
|
+
/** A lake in a pit: metres its beach rises over the water, to where it meets the floor (in its radii), */
|
|
59
|
+
pitBeach: [2.2, 1.3],
|
|
60
|
+
/** and past that, metres it rises a metre out, */
|
|
61
|
+
pitWall: 2,
|
|
62
|
+
/** and over how many metres of the ground's rise past the beach's top the wall is left standing at the water. */
|
|
63
|
+
pitCliff: 2,
|
|
64
|
+
/** How far up its beach a lake's silt is washed. */
|
|
65
|
+
siltUp: 1.3,
|
|
66
|
+
/** Over which a lake's shelf falls to its bed. */
|
|
67
|
+
shelfEdge: 3,
|
|
68
|
+
/** How far a lake's shore wanders in and out, as a share of its radii, unless the lake says. */
|
|
69
|
+
lakeRagged: 0.2,
|
|
70
|
+
/** Of a lake's own raggedness, how far its finer bays reach. */
|
|
71
|
+
fineRagged: 0.6,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @typedef {object} LandWaters
|
|
76
|
+
* @property {(land: { rivers: River[], lakes: Lake[], sea: number, fordOf: (river: River) => { x: number, z: number } }) => void} layOut -
|
|
77
|
+
* Takes a land's rivers and lakes, the sea's level, and where each river is forded.
|
|
78
|
+
* @property {(x: number, z: number, h: number) => number} carve - The ground at a place with the land's lakes and rivers cut
|
|
79
|
+
* into it, `h` the ground without them. Writes into the site record: `wet` (how near water the place is, 0 to 1), `silt`
|
|
80
|
+
* and `mud` (a pit lake's, 0 to 1) and `water` (the level of the water that lies there: the sea's unless a lake's or a river's).
|
|
81
|
+
* @property {{ lake: number }} found - Of the place last carved: the level of the lake it lies in, or -Infinity.
|
|
82
|
+
* @property {(x: number, z: number, reach: number) => number} bankDistance - Metres from a place to the nearest river's bank within `reach` of its middle; Infinity beyond.
|
|
83
|
+
* @property {(x: number, z: number) => number} watersideAt - How near water a place is, 0 to 1: the banks of the rivers and the shores of the lakes (not of a bare one).
|
|
84
|
+
* @property {object[]} channels - The rivers laid out, each with its smoothed `line`, its `level(t)` along it (0 source, 1 mouth), and its `mouth`.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Make a land's waters.
|
|
89
|
+
* @param {object} options
|
|
90
|
+
* @param {(x: number, z: number, channel: number) => number} options.vnoise - Seeded value noise, 0 to 1.
|
|
91
|
+
* @param {{ wet: number, silt: number, mud: number, water: number }} options.site - The record of the place the land is working out, which the waters write into.
|
|
92
|
+
* @param {(lake: Lake, x: number, z: number, h: number) => number} [options.mudAt] - How far a place by a lake with `reeds` is their mud, 0 to 1.
|
|
93
|
+
* @param {Partial<typeof LAND_WATERS_SHAPE>} [options.shape] - Changes to {@link LAND_WATERS_SHAPE}.
|
|
94
|
+
* @returns {LandWaters}
|
|
95
|
+
*/
|
|
96
|
+
export function createLandWaters({ vnoise, site, mudAt = () => 0, shape = {} }) {
|
|
97
|
+
const {
|
|
98
|
+
reach: REACH,
|
|
99
|
+
levee: LEVEE,
|
|
100
|
+
overSea: OVER_SEA,
|
|
101
|
+
mouth: MOUTH,
|
|
102
|
+
pastMouth: PAST_MOUTH,
|
|
103
|
+
pitBeach: PIT_BEACH,
|
|
104
|
+
pitWall: PIT_WALL,
|
|
105
|
+
pitCliff: PIT_CLIFF,
|
|
106
|
+
siltUp: SILT_UP,
|
|
107
|
+
shelfEdge: SHELF_EDGE,
|
|
108
|
+
lakeRagged: LAKE_RAGGED,
|
|
109
|
+
fineRagged: FINE_RAGGED,
|
|
110
|
+
} = { ...LAND_WATERS_SHAPE, ...shape };
|
|
111
|
+
const near = { d: 0, t: 0, side: 1 }, // the nearest point of the path last asked about
|
|
112
|
+
channels = [], // the rivers laid out
|
|
113
|
+
found = { lake: -Infinity };
|
|
114
|
+
let lakes = [], // the land's inland waters
|
|
115
|
+
SEA = 0,
|
|
116
|
+
fordOf = null;
|
|
117
|
+
|
|
118
|
+
// A river as the ground reads it: the channel is cut along a smoothed line.
|
|
119
|
+
function channel(r) {
|
|
120
|
+
const line = spacedCurve(r.pts, 40),
|
|
121
|
+
mouth = line[line.length - 1];
|
|
122
|
+
// a river into the sea is cut on past its mouth, down into the sea's floor, so no beach stands across it
|
|
123
|
+
if (!r.into) {
|
|
124
|
+
const [ax, az] = line[line.length - 2],
|
|
125
|
+
step = Math.hypot(mouth[0] - ax, mouth[1] - az);
|
|
126
|
+
for (let k = 1; k * step <= PAST_MOUTH; k++) line.push([mouth[0] + (mouth[0] - ax) * k, mouth[1] + (mouth[1] - az) * k]);
|
|
127
|
+
}
|
|
128
|
+
const n = line.length,
|
|
129
|
+
level = t => lerp(r.level[0], r.level[1], 1 - (1 - t) ** 2), // steep where it leaves the hills, slack across the plain
|
|
130
|
+
ford = fordOf(r);
|
|
131
|
+
return { ...r, line, n, box: pathBox(line), level, fordX: ford.x, fordZ: ford.z, mouth };
|
|
132
|
+
}
|
|
133
|
+
// How far a river into the sea has opened to it at (x, z): 0 upstream, 1 within MOUTH[0] metres of its mouth and past it.
|
|
134
|
+
function openToSea(c, x, z) {
|
|
135
|
+
return c.into ? 0 : sstep(MOUTH[1], MOUTH[0], Math.hypot(x - c.mouth[0], z - c.mouth[1]));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function layOut(land) {
|
|
139
|
+
SEA = land.sea;
|
|
140
|
+
fordOf = land.fordOf;
|
|
141
|
+
lakes = land.lakes;
|
|
142
|
+
channels.length = 0;
|
|
143
|
+
channels.push(...land.rivers.map(channel));
|
|
144
|
+
}
|
|
145
|
+
function carve(x, z, h) {
|
|
146
|
+
let lakeLevel = -Infinity; // the level of the lake the place lies in, if it lies in one
|
|
147
|
+
site.wet = site.silt = site.mud = 0;
|
|
148
|
+
site.water = SEA;
|
|
149
|
+
for (let i = 0; i < lakes.length; i++) {
|
|
150
|
+
// a lake lies in a shallow basin
|
|
151
|
+
const K = lakes[i],
|
|
152
|
+
kFar = Math.hypot((x - K.x) / K.rx, (z - K.z) / K.rz),
|
|
153
|
+
ragged = K.ragged ?? LAKE_RAGGED,
|
|
154
|
+
// its ragged shore, worked out only near it: broad bays and points, and for a lake that names its own (`ragged`) finer ones on them
|
|
155
|
+
kr =
|
|
156
|
+
kFar < 2.2
|
|
157
|
+
? kFar *
|
|
158
|
+
(1 -
|
|
159
|
+
ragged / 2 +
|
|
160
|
+
ragged * vnoise(x * 0.008, z * 0.008, 306) +
|
|
161
|
+
(K.ragged ?? 0) * FINE_RAGGED * (vnoise(x * 0.03, z * 0.03, 307) - 0.5))
|
|
162
|
+
: kFar;
|
|
163
|
+
if (K.pit) {
|
|
164
|
+
// a lake in a quarried pit: a basin sunk into the floor with a short beach of silt round it, where it meets the wall lapping
|
|
165
|
+
// at its foot as a cliff, and never raising the ground round it
|
|
166
|
+
if (kr < PIT_BEACH[1] + 1) {
|
|
167
|
+
let basin =
|
|
168
|
+
K.level -
|
|
169
|
+
K.depth * sstep(1, 0.45, kr) +
|
|
170
|
+
PIT_BEACH[0] * sstep(1, PIT_BEACH[1], kr) +
|
|
171
|
+
Math.max(0, kr - PIT_BEACH[1]) * K.rz * PIT_WALL;
|
|
172
|
+
for (const s of K.shelves ?? [])
|
|
173
|
+
basin = lerp(basin, Math.max(basin, s.y), sstep(s.r + SHELF_EDGE, s.r, Math.hypot(x - s.x, z - s.z)));
|
|
174
|
+
const lapped = Math.min(h, basin);
|
|
175
|
+
h = kr < 1 ? lapped : lerp(lapped, h, sstep(K.level + PIT_BEACH[0], K.level + PIT_BEACH[0] + PIT_CLIFF, h)); // a beach only on the floor
|
|
176
|
+
}
|
|
177
|
+
if (K.reeds && kr < PIT_BEACH[1] + 0.1) site.mud = mudAt(K, x, z, h);
|
|
178
|
+
if (K.silt)
|
|
179
|
+
site.silt = Math.max(site.silt, sstep(K.level + SILT_UP, K.level - 0.3, h) * sstep(PIT_BEACH[1] + 0.3, PIT_BEACH[1], kr));
|
|
180
|
+
if (kr < 1.25) site.water = K.level;
|
|
181
|
+
} else if (kr < 1.9) {
|
|
182
|
+
h = lerp(K.level - K.depth * sstep(1, 0.45, kr), Math.max(h, K.level + 1.2), sstep(0.96, 1.9, kr));
|
|
183
|
+
if (!K.bare) site.wet = Math.max(site.wet, sstep(1.7, 1.05, kr));
|
|
184
|
+
if (kr < 1.25) site.water = K.level;
|
|
185
|
+
}
|
|
186
|
+
if (kr < 1) lakeLevel = K.level;
|
|
187
|
+
}
|
|
188
|
+
for (const c of channels) {
|
|
189
|
+
if (!nearestPathPoint(c, x, z, REACH, near)) continue;
|
|
190
|
+
const L = c.level(near.t),
|
|
191
|
+
hw = c.width * 0.5 * (0.35 + 0.65 * sstep(0, 0.4, near.t)),
|
|
192
|
+
ford = sstep(120, 30, Math.hypot(x - c.fordX, z - c.fordZ)),
|
|
193
|
+
open = openToSea(c, x, z),
|
|
194
|
+
bed = Math.max(L - lerp(c.depth, 0.45, ford), c.into ? -Infinity : c.level(1) + OVER_SEA - (OVER_SEA + c.depth) * open),
|
|
195
|
+
bank = L + 0.9;
|
|
196
|
+
// where the land lies lower than a river's bank (below the hills it comes out of), the river runs on a rise of its own
|
|
197
|
+
// silt, which falls away to the land on either side
|
|
198
|
+
const cut = lerp(bed, bank, sstep(hw * 0.7, hw + 7, near.d)),
|
|
199
|
+
beside = h < bank ? lerp(bank, h, sstep(hw + LEVEE, REACH - 20, near.d) * sstep(SEA + 0.5, SEA + 2.5, h)) : h, // not where the land is the sea's floor: there its bank is the shore
|
|
200
|
+
carved = lerp(cut, beside, sstep(hw + 7, REACH - 20, near.d));
|
|
201
|
+
// in the lake or the sea its channel runs on into the floor, under the water, so no sill of the shore stands across its mouth
|
|
202
|
+
if (L <= lakeLevel + 0.5 || open > 0.5) {
|
|
203
|
+
h = Math.min(h, carved);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
h = carved;
|
|
207
|
+
site.wet = Math.max(site.wet, sstep(hw + 120, hw + 12, near.d));
|
|
208
|
+
if (near.d < hw + 10) site.water = L;
|
|
209
|
+
}
|
|
210
|
+
found.lake = lakeLevel;
|
|
211
|
+
return h;
|
|
212
|
+
}
|
|
213
|
+
// Metres from (x, z) to the nearest river's bank, of those within `reach` of their middles.
|
|
214
|
+
function bankDistance(x, z, reach) {
|
|
215
|
+
let d = Infinity;
|
|
216
|
+
for (const c of channels) if (nearestPathPoint(c, x, z, reach, near)) d = Math.min(d, near.d - c.width * 0.5);
|
|
217
|
+
return d;
|
|
218
|
+
}
|
|
219
|
+
// How near water a place is, 0..1: the banks of the rivers and the shores of the lakes (not of a bare one, where nothing grows).
|
|
220
|
+
function watersideAt(x, z) {
|
|
221
|
+
let wet = 0;
|
|
222
|
+
for (const K of lakes) if (!K.bare) wet = Math.max(wet, sstep(1.7, 1.05, Math.hypot((x - K.x) / K.rx, (z - K.z) / K.rz)));
|
|
223
|
+
for (const c of channels)
|
|
224
|
+
if (nearestPathPoint(c, x, z, REACH, near)) wet = Math.max(wet, sstep(c.width * 0.5 + 120, c.width * 0.5 + 12, near.d));
|
|
225
|
+
return wet;
|
|
226
|
+
}
|
|
227
|
+
return { layOut, carve, found, bankDistance, watersideAt, channels };
|
|
228
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How wild each point of a land's grid is: how far it lies from what people built and laid out (towns and landmarks, the
|
|
3
|
+
* grounds its scenes are played on, roads, the channels of streams, farmland, water, the land's own edge). What wears or
|
|
4
|
+
* roughens the ground reads it: erosion (`erosion.js`) and the relief near the eye (`land-near-relief.js`) each touch
|
|
5
|
+
* only what it leaves wild, each with its own reach.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { sstep } from '../math/scalar.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The distances over which the ground turns wild, each as [not wild at all, wholly wild], in metres.
|
|
13
|
+
* @typedef {object} WildReach
|
|
14
|
+
* @property {[number, number]} above - Over the water's level.
|
|
15
|
+
* @property {[number, number]} road - From a road.
|
|
16
|
+
* @property {[number, number]} river - From a stream's middle.
|
|
17
|
+
* @property {[number, number]} place - From a town or landmark.
|
|
18
|
+
* @property {[number, number]} site - From a scene's ground.
|
|
19
|
+
* @property {[number, number]} edge - From the land's edge.
|
|
20
|
+
* @property {number} [clear] - How far round the `clear` rectangle none is wild.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Work out a land's wildness.
|
|
25
|
+
* @param {object} land
|
|
26
|
+
* @param {import('./grid-sample.js').GridFrame} land.grid - The grid's frame (square: `stride` points each way, an odd number).
|
|
27
|
+
* @param {ArrayLike<number>} land.heights - One height to a grid point.
|
|
28
|
+
* @param {number} land.waterLevel - The level of the land's water.
|
|
29
|
+
* @param {ArrayLike<number>} land.roadDistance - Metres from each point to the nearest road.
|
|
30
|
+
* @param {ArrayLike<number>} land.riverDistance - Metres from each point to the nearest stream's middle.
|
|
31
|
+
* @param {(x: number, z: number) => number} [land.open] - How open a place is to the wild for reasons that change only
|
|
32
|
+
* over tens of metres (clear of a city, back from a lake), 0 to 1. Asked on a coarser grid and read between its points.
|
|
33
|
+
* @param {{ x: number, z: number }[]} [land.places] - Towns and landmarks.
|
|
34
|
+
* @param {[number, number][]} [land.sites] - The grounds scenes are played on, as [x, z].
|
|
35
|
+
* @param {{ x: number, z: number, w: number, d: number }} [land.clear] - A rectangle (its corner and size) none of which is wild: farmland.
|
|
36
|
+
* @param {WildReach} land.reach - The distances over which the ground turns wild.
|
|
37
|
+
* @param {number} [land.coarse=2] - Grid points to a point of the coarser grid the slow terms are worked out on.
|
|
38
|
+
* @returns {Float32Array} One number to a grid point, 0 (tame) to 1 (wild).
|
|
39
|
+
*/
|
|
40
|
+
export function wildness({
|
|
41
|
+
grid,
|
|
42
|
+
heights,
|
|
43
|
+
waterLevel,
|
|
44
|
+
roadDistance,
|
|
45
|
+
riverDistance,
|
|
46
|
+
open = () => 1,
|
|
47
|
+
places = [],
|
|
48
|
+
sites = [],
|
|
49
|
+
clear,
|
|
50
|
+
reach,
|
|
51
|
+
coarse = 2,
|
|
52
|
+
}) {
|
|
53
|
+
const { x0, z0, spacing, stride } = grid,
|
|
54
|
+
last = stride - 1,
|
|
55
|
+
x1 = x0 + last * spacing,
|
|
56
|
+
z1 = z0 + last * spacing,
|
|
57
|
+
coarseStride = last / coarse + 1,
|
|
58
|
+
mask = new Float32Array(stride * stride),
|
|
59
|
+
far = farTerms(grid, coarse, coarseStride, open, places, sites, reach);
|
|
60
|
+
for (let j = 0; j <= last; j++)
|
|
61
|
+
for (let i = 0; i <= last; i++) {
|
|
62
|
+
const k = j * stride + i,
|
|
63
|
+
x = x0 + i * spacing,
|
|
64
|
+
z = z0 + j * spacing;
|
|
65
|
+
const m =
|
|
66
|
+
sstep(reach.above[0], reach.above[1], heights[k] - waterLevel) *
|
|
67
|
+
sstep(reach.road[0], reach.road[1], roadDistance[k]) *
|
|
68
|
+
sstep(reach.river[0], reach.river[1], riverDistance[k]) *
|
|
69
|
+
sstep(reach.edge[0], reach.edge[1], Math.min(x - x0, x1 - x, z - z0, z1 - z));
|
|
70
|
+
if (m <= 0) continue;
|
|
71
|
+
if (
|
|
72
|
+
clear &&
|
|
73
|
+
x > clear.x - reach.clear &&
|
|
74
|
+
x < clear.x + clear.w + reach.clear &&
|
|
75
|
+
z > clear.z - reach.clear &&
|
|
76
|
+
z < clear.z + clear.d + reach.clear
|
|
77
|
+
)
|
|
78
|
+
continue;
|
|
79
|
+
const ci = Math.min((i / coarse) | 0, coarseStride - 2),
|
|
80
|
+
cj = Math.min((j / coarse) | 0, coarseStride - 2),
|
|
81
|
+
u = i / coarse - ci,
|
|
82
|
+
v = j / coarse - cj,
|
|
83
|
+
c = cj * coarseStride + ci;
|
|
84
|
+
mask[k] =
|
|
85
|
+
m *
|
|
86
|
+
(far[c] * (1 - u) * (1 - v) + far[c + 1] * u * (1 - v) + far[c + coarseStride] * (1 - u) * v + far[c + coarseStride + 1] * u * v);
|
|
87
|
+
}
|
|
88
|
+
return mask;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// The slow terms on the coarse grid: open to the wild, and clear of the places and of the scenes' grounds.
|
|
92
|
+
function farTerms(grid, coarse, coarseStride, open, places, sites, reach) {
|
|
93
|
+
const far = new Float32Array(coarseStride * coarseStride),
|
|
94
|
+
placeFar = reach.place[1] ** 2, // squared distances past which a place or a scene's ground no longer tames the ground
|
|
95
|
+
siteFar = reach.site[1] ** 2;
|
|
96
|
+
for (let cj = 0; cj < coarseStride; cj++)
|
|
97
|
+
for (let ci = 0; ci < coarseStride; ci++) {
|
|
98
|
+
const x = grid.x0 + ci * coarse * grid.spacing,
|
|
99
|
+
z = grid.z0 + cj * coarse * grid.spacing;
|
|
100
|
+
let m = open(x, z);
|
|
101
|
+
for (let p = 0; p < places.length && m > 0; p++) {
|
|
102
|
+
const d2 = (x - places[p].x) ** 2 + (z - places[p].z) ** 2;
|
|
103
|
+
if (d2 < placeFar) m *= sstep(reach.place[0], reach.place[1], Math.sqrt(d2));
|
|
104
|
+
}
|
|
105
|
+
for (let s = 0; s < sites.length && m > 0; s++) {
|
|
106
|
+
const d2 = (x - sites[s][0]) ** 2 + (z - sites[s][1]) ** 2;
|
|
107
|
+
if (d2 < siteFar) m *= sstep(reach.site[0], reach.site[1], Math.sqrt(d2));
|
|
108
|
+
}
|
|
109
|
+
far[cj * coarseStride + ci] = m;
|
|
110
|
+
}
|
|
111
|
+
return far;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A wildness as the bytes a land keeps with its heights.
|
|
116
|
+
* @param {Float32Array} wild - {@link wildness}'s result.
|
|
117
|
+
* @returns {Uint8Array} Each number as 0 to 255.
|
|
118
|
+
*/
|
|
119
|
+
export function wildnessBytes(wild) {
|
|
120
|
+
const mask = new Uint8Array(wild.length);
|
|
121
|
+
for (let k = 0; k < wild.length; k++) mask[k] = Math.round(wild[k] * 255);
|
|
122
|
+
return mask;
|
|
123
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build revolved vessels, hooped stave tankards, curved handles, and carved tabletop pieces for a geometry builder.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const TAU = Math.PI * 2;
|
|
7
|
+
|
|
8
|
+
function deterministicHash(indexA, indexB, seed) {
|
|
9
|
+
const value = Math.sin(indexA * 127.1 + indexB * 311.7 + seed * 74.7) * 43758.5453123;
|
|
10
|
+
return value - Math.floor(value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function rotateYaw(x, y, z, cosYaw, sinYaw, origin, out) {
|
|
14
|
+
out[0] = origin[0] + x * cosYaw + z * sinYaw;
|
|
15
|
+
out[1] = origin[1] + y;
|
|
16
|
+
out[2] = origin[2] - x * sinYaw + z * cosYaw;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Revolve a 2D `[radius, y]` profile around a vertical axis into triangles with smooth or faceted stave normals.
|
|
21
|
+
* When `wallThickness` is positive, an open rim lip and darkened interior cavity are generated automatically.
|
|
22
|
+
*
|
|
23
|
+
* @param {Pick<import('./builder.js').GB, 'raw'>} builder - Destination geometry builder.
|
|
24
|
+
* @param {ReadonlyArray<ReadonlyArray<number>>} profile - Ordered `[radius, height]` rings from base to rim (metres).
|
|
25
|
+
* @param {{
|
|
26
|
+
* origin?: ReadonlyArray<number>,
|
|
27
|
+
* yaw?: number,
|
|
28
|
+
* segments?: number,
|
|
29
|
+
* wallThickness?: number,
|
|
30
|
+
* staves?: boolean,
|
|
31
|
+
* seed?: number,
|
|
32
|
+
* interiorShade?: number,
|
|
33
|
+
* hoops?: ReadonlyArray<ReadonlyArray<number>>,
|
|
34
|
+
* color: ArrayLike<number> | ((ringRatio: number, angleRatio: number) => ArrayLike<number>)
|
|
35
|
+
* }} options - Placement, tessellation, optional hollow wall thickness, stave faceting, and linear RGB colour.
|
|
36
|
+
* @example
|
|
37
|
+
* ```js
|
|
38
|
+
* import { GeometryBuilder } from 'roamwright';
|
|
39
|
+
* import { revolveProfile } from 'roamwright/geometry/lathed-vessel.js';
|
|
40
|
+
*
|
|
41
|
+
* const pottery = new GeometryBuilder();
|
|
42
|
+
* revolveProfile(pottery, [[0, 0], [0.08, 0], [0.12, 0.14], [0.07, 0.26], [0.09, 0.3]], {
|
|
43
|
+
* wallThickness: 0.012,
|
|
44
|
+
* color: [0.52, 0.34, 0.22],
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function revolveProfile(builder, profile, options) {
|
|
49
|
+
if (!profile || profile.length < 2) return;
|
|
50
|
+
const origin = options.origin ?? [0, 0, 0],
|
|
51
|
+
yaw = options.yaw ?? 0,
|
|
52
|
+
cosYaw = Math.cos(yaw),
|
|
53
|
+
sinYaw = Math.sin(yaw),
|
|
54
|
+
segments = Math.max(5, Math.round(options.segments ?? 16)),
|
|
55
|
+
wallThickness = Math.max(0, options.wallThickness ?? 0),
|
|
56
|
+
staves = !!options.staves,
|
|
57
|
+
seed = options.seed ?? 1,
|
|
58
|
+
interiorShade = options.interiorShade ?? 0.42,
|
|
59
|
+
colorOption = options.color,
|
|
60
|
+
hasSampler = typeof colorOption === 'function';
|
|
61
|
+
|
|
62
|
+
// Assemble full ring list: outer profile from base to rim, plus optional rim lip and inner cavity.
|
|
63
|
+
const rings = [];
|
|
64
|
+
for (let i = 0; i < profile.length; i++) {
|
|
65
|
+
rings.push([Math.max(0, profile[i][0]), profile[i][1], 1]);
|
|
66
|
+
}
|
|
67
|
+
if (wallThickness > 0) {
|
|
68
|
+
const rim = profile[profile.length - 1],
|
|
69
|
+
innerRimRadius = Math.max(0.002, rim[0] - wallThickness);
|
|
70
|
+
rings.push([innerRimRadius, rim[1], 0.86]);
|
|
71
|
+
for (let i = profile.length - 2; i >= 1; i--) {
|
|
72
|
+
const ringRadius = Math.max(0.002, profile[i][0] - wallThickness),
|
|
73
|
+
ringY = Math.max(profile[0][1] + wallThickness, profile[i][1]);
|
|
74
|
+
rings.push([ringRadius, ringY, interiorShade]);
|
|
75
|
+
}
|
|
76
|
+
rings.push([0, profile[0][1] + wallThickness, interiorShade * 0.85]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const ringCount = rings.length,
|
|
80
|
+
pointA = [0, 0, 0],
|
|
81
|
+
pointB = [0, 0, 0],
|
|
82
|
+
pointC = [0, 0, 0],
|
|
83
|
+
pointD = [0, 0, 0],
|
|
84
|
+
normalA = [0, 1, 0],
|
|
85
|
+
normalB = [0, 1, 0],
|
|
86
|
+
normalC = [0, 1, 0],
|
|
87
|
+
normalD = [0, 1, 0];
|
|
88
|
+
|
|
89
|
+
// Precompute per-ring slope normals along the profile curve.
|
|
90
|
+
const radialSlope = new Float64Array(ringCount),
|
|
91
|
+
verticalSlope = new Float64Array(ringCount);
|
|
92
|
+
for (let i = 0; i < ringCount; i++) {
|
|
93
|
+
const prev = rings[Math.max(0, i - 1)],
|
|
94
|
+
next = rings[Math.min(ringCount - 1, i + 1)],
|
|
95
|
+
dr = next[0] - prev[0],
|
|
96
|
+
dy = next[1] - prev[1],
|
|
97
|
+
len = Math.hypot(dr, dy) || 1;
|
|
98
|
+
// Outward normal in meridian plane for contour (r(s), y(s)): (dy, -dr) / len.
|
|
99
|
+
radialSlope[i] = dy / len;
|
|
100
|
+
verticalSlope[i] = -dr / len;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (let i = 0; i < ringCount - 1; i++) {
|
|
104
|
+
const [r0, y0, shade0] = rings[i],
|
|
105
|
+
[r1, y1, shade1] = rings[i + 1];
|
|
106
|
+
if (r0 < 1e-6 && r1 < 1e-6) continue;
|
|
107
|
+
const ringRatio = i / Math.max(1, profile.length - 1);
|
|
108
|
+
for (let seg = 0; seg < segments; seg++) {
|
|
109
|
+
const a0 = (seg / segments) * TAU,
|
|
110
|
+
a1 = ((seg + 1) / segments) * TAU,
|
|
111
|
+
midA = ((seg + 0.5) / segments) * TAU,
|
|
112
|
+
s0 = Math.sin(a0),
|
|
113
|
+
c0 = Math.cos(a0),
|
|
114
|
+
s1 = Math.sin(a1),
|
|
115
|
+
c1 = Math.cos(a1);
|
|
116
|
+
|
|
117
|
+
const staveShade = staves ? 0.88 + 0.22 * deterministicHash(seg, 3, seed) : 1,
|
|
118
|
+
baseColor = hasSampler ? colorOption(Math.min(1, ringRatio), (seg + 0.5) / segments) : colorOption,
|
|
119
|
+
tone0 = [baseColor[0] * shade0 * staveShade, baseColor[1] * shade0 * staveShade, baseColor[2] * shade0 * staveShade],
|
|
120
|
+
tone1 = [baseColor[0] * shade1 * staveShade, baseColor[1] * shade1 * staveShade, baseColor[2] * shade1 * staveShade];
|
|
121
|
+
|
|
122
|
+
rotateYaw(s0 * r0, y0, c0 * r0, cosYaw, sinYaw, origin, pointA);
|
|
123
|
+
rotateYaw(s1 * r0, y0, c1 * r0, cosYaw, sinYaw, origin, pointB);
|
|
124
|
+
rotateYaw(s1 * r1, y1, c1 * r1, cosYaw, sinYaw, origin, pointC);
|
|
125
|
+
rotateYaw(s0 * r1, y1, c0 * r1, cosYaw, sinYaw, origin, pointD);
|
|
126
|
+
|
|
127
|
+
if (staves) {
|
|
128
|
+
const sm = Math.sin(midA),
|
|
129
|
+
cm = Math.cos(midA),
|
|
130
|
+
dr = r1 - r0,
|
|
131
|
+
dy = y1 - y0,
|
|
132
|
+
len = Math.hypot(dr, dy) || 1,
|
|
133
|
+
nr = dy / len,
|
|
134
|
+
ny = -dr / len,
|
|
135
|
+
wx = sm * nr * cosYaw + cm * nr * sinYaw,
|
|
136
|
+
wz = -sm * nr * sinYaw + cm * nr * cosYaw;
|
|
137
|
+
normalA[0] = normalB[0] = normalC[0] = normalD[0] = wx;
|
|
138
|
+
normalA[1] = normalB[1] = normalC[1] = normalD[1] = ny;
|
|
139
|
+
normalA[2] = normalB[2] = normalC[2] = normalD[2] = wz;
|
|
140
|
+
} else {
|
|
141
|
+
const nr0 = radialSlope[i],
|
|
142
|
+
ny0 = verticalSlope[i],
|
|
143
|
+
nr1 = radialSlope[i + 1],
|
|
144
|
+
ny1 = verticalSlope[i + 1];
|
|
145
|
+
normalA[0] = s0 * nr0 * cosYaw + c0 * nr0 * sinYaw;
|
|
146
|
+
normalA[1] = ny0;
|
|
147
|
+
normalA[2] = -s0 * nr0 * sinYaw + c0 * nr0 * cosYaw;
|
|
148
|
+
|
|
149
|
+
normalB[0] = s1 * nr0 * cosYaw + c1 * nr0 * sinYaw;
|
|
150
|
+
normalB[1] = ny0;
|
|
151
|
+
normalB[2] = -s1 * nr0 * sinYaw + c1 * nr0 * cosYaw;
|
|
152
|
+
|
|
153
|
+
normalC[0] = s1 * nr1 * cosYaw + c1 * nr1 * sinYaw;
|
|
154
|
+
normalC[1] = ny1;
|
|
155
|
+
normalC[2] = -s1 * nr1 * sinYaw + c1 * nr1 * cosYaw;
|
|
156
|
+
|
|
157
|
+
normalD[0] = s0 * nr1 * cosYaw + c0 * nr1 * sinYaw;
|
|
158
|
+
normalD[1] = ny1;
|
|
159
|
+
normalD[2] = -s0 * nr1 * sinYaw + c0 * nr1 * cosYaw;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (r0 > 1e-6) {
|
|
163
|
+
builder.raw(pointA[0], pointA[1], pointA[2], normalA[0], normalA[1], normalA[2], tone0[0], tone0[1], tone0[2]);
|
|
164
|
+
builder.raw(pointB[0], pointB[1], pointB[2], normalB[0], normalB[1], normalB[2], tone0[0], tone0[1], tone0[2]);
|
|
165
|
+
builder.raw(pointC[0], pointC[1], pointC[2], normalC[0], normalC[1], normalC[2], tone1[0], tone1[1], tone1[2]);
|
|
166
|
+
}
|
|
167
|
+
if (r1 > 1e-6) {
|
|
168
|
+
builder.raw(pointA[0], pointA[1], pointA[2], normalA[0], normalA[1], normalA[2], tone0[0], tone0[1], tone0[2]);
|
|
169
|
+
builder.raw(pointC[0], pointC[1], pointC[2], normalC[0], normalC[1], normalC[2], tone1[0], tone1[1], tone1[2]);
|
|
170
|
+
builder.raw(pointD[0], pointD[1], pointD[2], normalD[0], normalD[1], normalD[2], tone1[0], tone1[1], tone1[2]);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (options.hoops) {
|
|
176
|
+
const baseY = profile[0][1],
|
|
177
|
+
topY = profile[profile.length - 1][1],
|
|
178
|
+
spanY = Math.max(1e-4, topY - baseY);
|
|
179
|
+
for (let h = 0; h < options.hoops.length; h++) {
|
|
180
|
+
const [yRatio, bandHeight, proud, rColor, gColor, bColor] = options.hoops[h],
|
|
181
|
+
hoopY = baseY + yRatio * spanY,
|
|
182
|
+
radius = sampleProfileRadius(profile, hoopY) + proud;
|
|
183
|
+
revolveProfile(
|
|
184
|
+
builder,
|
|
185
|
+
[
|
|
186
|
+
[radius - proud * 0.6, hoopY - bandHeight * 0.5],
|
|
187
|
+
[radius, hoopY - bandHeight * 0.35],
|
|
188
|
+
[radius, hoopY + bandHeight * 0.35],
|
|
189
|
+
[radius - proud * 0.6, hoopY + bandHeight * 0.5],
|
|
190
|
+
],
|
|
191
|
+
{
|
|
192
|
+
origin,
|
|
193
|
+
yaw,
|
|
194
|
+
segments,
|
|
195
|
+
staves,
|
|
196
|
+
seed: seed + 19 + h,
|
|
197
|
+
color: [rColor, gColor, bColor],
|
|
198
|
+
},
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function sampleProfileRadius(profile, targetY) {
|
|
205
|
+
for (let i = 0; i < profile.length - 1; i++) {
|
|
206
|
+
const y0 = profile[i][1],
|
|
207
|
+
y1 = profile[i + 1][1];
|
|
208
|
+
if ((targetY >= y0 && targetY <= y1) || (targetY <= y0 && targetY >= y1)) {
|
|
209
|
+
const t = Math.abs(y1 - y0) > 1e-6 ? (targetY - y0) / (y1 - y0) : 0;
|
|
210
|
+
return profile[i][0] + (profile[i + 1][0] - profile[i][0]) * t;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return profile[profile.length - 1][0];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Sweep a curved strap or loop handle along `[radiusOffset, y]` points in the vessel's `+Z` half-plane.
|
|
218
|
+
*
|
|
219
|
+
* @param {Pick<import('./builder.js').GB, 'raw'>} builder - Destination geometry builder.
|
|
220
|
+
* @param {ReadonlyArray<number>} origin - Vessel base `[x, y, z]` in builder space.
|
|
221
|
+
* @param {number} yaw - Rotation around `+Y` in radians.
|
|
222
|
+
* @param {ReadonlyArray<ReadonlyArray<number>>} spine - Ordered `[radialZ, heightY]` handle spine points.
|
|
223
|
+
* @param {number} tubeRadius - Handle cross-section radius in metres.
|
|
224
|
+
* @param {ArrayLike<number>} color - Linear RGB colour `[r, g, b]`.
|
|
225
|
+
* @param {number} [sides=6] - Radial sides around the handle tube.
|
|
226
|
+
*/
|
|
227
|
+
export function vesselHandle(builder, origin, yaw, spine, tubeRadius, color, sides = 6) {
|
|
228
|
+
if (!spine || spine.length < 2) return;
|
|
229
|
+
const cosYaw = Math.cos(yaw),
|
|
230
|
+
sinYaw = Math.sin(yaw),
|
|
231
|
+
rings = [],
|
|
232
|
+
ringNormals = [];
|
|
233
|
+
for (let i = 0; i < spine.length; i++) {
|
|
234
|
+
const prev = spine[Math.max(0, i - 1)],
|
|
235
|
+
next = spine[Math.min(spine.length - 1, i + 1)],
|
|
236
|
+
tz = next[0] - prev[0],
|
|
237
|
+
ty = next[1] - prev[1],
|
|
238
|
+
tLen = Math.hypot(tz, ty) || 1,
|
|
239
|
+
// Normal in the (Y, Z) handle plane perpendicular to tangent:
|
|
240
|
+
ny = -tz / tLen,
|
|
241
|
+
nz = ty / tLen,
|
|
242
|
+
taper = 1 - 0.18 * Math.sin((i / (spine.length - 1)) * Math.PI),
|
|
243
|
+
ring = [],
|
|
244
|
+
norms = [];
|
|
245
|
+
for (let k = 0; k < sides; k++) {
|
|
246
|
+
const a = (k / sides) * TAU,
|
|
247
|
+
ca = Math.cos(a),
|
|
248
|
+
sa = Math.sin(a),
|
|
249
|
+
// Cross-section basis: +X (width) and (0, ny, nz) (in-plane normal), flattened slightly like a strap handle.
|
|
250
|
+
lx = sa * tubeRadius * 1.15 * taper,
|
|
251
|
+
ly = spine[i][1] + ca * ny * tubeRadius * 0.85 * taper,
|
|
252
|
+
lz = spine[i][0] + ca * nz * tubeRadius * 0.85 * taper,
|
|
253
|
+
wp = [0, 0, 0],
|
|
254
|
+
wn = [0, 0, 0];
|
|
255
|
+
rotateYaw(lx, ly, lz, cosYaw, sinYaw, origin, wp);
|
|
256
|
+
wn[0] = sa * cosYaw + ca * nz * sinYaw;
|
|
257
|
+
wn[1] = ca * ny;
|
|
258
|
+
wn[2] = -sa * sinYaw + ca * nz * cosYaw;
|
|
259
|
+
const nLen = Math.hypot(wn[0], wn[1], wn[2]) || 1;
|
|
260
|
+
wn[0] /= nLen;
|
|
261
|
+
wn[1] /= nLen;
|
|
262
|
+
wn[2] /= nLen;
|
|
263
|
+
ring.push(wp);
|
|
264
|
+
norms.push(wn);
|
|
265
|
+
}
|
|
266
|
+
rings.push(ring);
|
|
267
|
+
ringNormals.push(norms);
|
|
268
|
+
}
|
|
269
|
+
for (let i = 0; i < rings.length - 1; i++) {
|
|
270
|
+
const r0 = rings[i],
|
|
271
|
+
r1 = rings[i + 1],
|
|
272
|
+
n0 = ringNormals[i],
|
|
273
|
+
n1 = ringNormals[i + 1];
|
|
274
|
+
for (let k = 0; k < sides; k++) {
|
|
275
|
+
const k1 = (k + 1) % sides,
|
|
276
|
+
a = r0[k],
|
|
277
|
+
b = r0[k1],
|
|
278
|
+
c = r1[k1],
|
|
279
|
+
d = r1[k],
|
|
280
|
+
na = n0[k],
|
|
281
|
+
nb = n0[k1],
|
|
282
|
+
nc = n1[k1],
|
|
283
|
+
nd = n1[k];
|
|
284
|
+
builder.raw(a[0], a[1], a[2], na[0], na[1], na[2], color[0], color[1], color[2]);
|
|
285
|
+
builder.raw(b[0], b[1], b[2], nb[0], nb[1], nb[2], color[0], color[1], color[2]);
|
|
286
|
+
builder.raw(c[0], c[1], c[2], nc[0], nc[1], nc[2], color[0], color[1], color[2]);
|
|
287
|
+
|
|
288
|
+
builder.raw(a[0], a[1], a[2], na[0], na[1], na[2], color[0], color[1], color[2]);
|
|
289
|
+
builder.raw(c[0], c[1], c[2], nc[0], nc[1], nc[2], color[0], color[1], color[2]);
|
|
290
|
+
builder.raw(d[0], d[1], d[2], nd[0], nd[1], nd[2], color[0], color[1], color[2]);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
package/geometry/outline-grid.js
CHANGED
|
@@ -3,7 +3,8 @@ import { outlineDistance, outlineEdges } from './shore-grid.js';
|
|
|
3
3
|
// A closed outline's signed distance (metres, negative inside) baked on a grid over its box, `pad` metres wider than the outline:
|
|
4
4
|
// plain numbers and an array, which can be handed to a worker of the pool.
|
|
5
5
|
function polyGrid(poly, cell, pad) {
|
|
6
|
-
if (!poly.length || !Number.isFinite(cell) || cell <= 0 || !Number.isFinite(pad) || pad < 0)
|
|
6
|
+
if (!poly.length || !Number.isFinite(cell) || cell <= 0 || !Number.isFinite(pad) || pad < 0)
|
|
7
|
+
throw new RangeError('Provide an outline, positive cell size and nonnegative padding');
|
|
7
8
|
let x0 = Infinity,
|
|
8
9
|
z0 = Infinity,
|
|
9
10
|
x1 = -Infinity,
|
|
@@ -22,8 +23,7 @@ function polyGrid(poly, cell, pad) {
|
|
|
22
23
|
nz = Math.max(2, Math.ceil((z1 - z0) / cell) + 1),
|
|
23
24
|
g = new Float32Array(nx * nz),
|
|
24
25
|
edges = outlineEdges(poly);
|
|
25
|
-
for (let j = 0; j < nz; j++)
|
|
26
|
-
for (let i = 0; i < nx; i++) g[j * nx + i] = -outlineDistance(edges, x0 + i * cell, z0 + j * cell);
|
|
26
|
+
for (let j = 0; j < nz; j++) for (let i = 0; i < nx; i++) g[j * nx + i] = -outlineDistance(edges, x0 + i * cell, z0 + j * cell);
|
|
27
27
|
return { x0, z0, x1, z1, nx, nz, cell, pad, g };
|
|
28
28
|
}
|
|
29
29
|
// The signed distance anywhere, read from a grid of polyGrid's; beyond the box, the distance to the box.
|
|
@@ -31,7 +31,8 @@ function gridField({ x0, z0, x1, z1, nx, nz, cell, pad, g }) {
|
|
|
31
31
|
return (x, z) => {
|
|
32
32
|
const gridX = (x - x0) / cell,
|
|
33
33
|
gridZ = (z - z0) / cell;
|
|
34
|
-
if (gridX < 0 || gridZ < 0 || gridX > nx - 1 || gridZ > nz - 1)
|
|
34
|
+
if (gridX < 0 || gridZ < 0 || gridX > nx - 1 || gridZ > nz - 1)
|
|
35
|
+
return pad + Math.hypot(Math.max(x0 - x, 0, x - x1), Math.max(z0 - z, 0, z - z1));
|
|
35
36
|
const i = Math.min(nx - 2, gridX | 0),
|
|
36
37
|
j = Math.min(nz - 2, gridZ | 0),
|
|
37
38
|
u = gridX - i,
|