roamwright 0.4.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +21 -14
- package/README.md +38 -42
- package/examples/animals.html +49 -0
- package/examples/animals.js +209 -0
- package/examples/crowds.html +50 -0
- package/examples/crowds.js +268 -0
- package/examples/effects.html +53 -0
- package/examples/effects.js +343 -0
- package/examples/figure-motion.html +55 -0
- package/examples/figure-motion.js +265 -0
- package/examples/figure.html +49 -0
- package/examples/figure.js +238 -0
- package/examples/fliers.html +53 -0
- package/examples/fliers.js +292 -0
- package/examples/fortification.html +54 -0
- package/examples/fortification.js +288 -0
- package/examples/house-kit.html +48 -0
- package/examples/house-kit.js +175 -0
- package/examples/index.html +26 -16
- package/examples/island.html +48 -0
- package/examples/island.js +134 -52
- package/examples/land.html +54 -0
- package/examples/land.js +392 -0
- package/examples/props-and-plants.html +53 -0
- package/examples/props-and-plants.js +275 -0
- package/examples/rooms.html +48 -0
- package/examples/rooms.js +242 -0
- package/examples/ships.html +51 -0
- package/examples/ships.js +235 -0
- package/examples/showcase.css +320 -0
- package/examples/small-world-land.js +151 -0
- package/examples/small-world-life.js +160 -0
- package/examples/small-world-town.js +127 -0
- package/examples/small-world.html +57 -0
- package/examples/small-world.js +226 -0
- package/examples/soundscape.html +138 -0
- package/examples/soundscape.js +467 -0
- package/examples/stage-kits.js +300 -0
- package/examples/stage.js +374 -0
- package/examples/towns.html +50 -0
- package/examples/towns.js +325 -0
- package/examples/viaduct-camera.js +8 -4
- package/examples/viaduct-landscape.js +28 -17
- package/examples/viaduct.html +45 -43
- package/examples/viaduct.js +68 -92
- package/geometry/animal-camel-body.js +410 -0
- package/geometry/animal-camel-head.js +118 -0
- package/geometry/animal-canine-body.js +361 -0
- package/geometry/animal-canine-breeds.js +316 -0
- package/geometry/animal-canine-head.js +337 -0
- package/geometry/animal-cattle-body.js +391 -0
- package/geometry/animal-cattle-coat.js +42 -0
- package/geometry/animal-cattle-head.js +152 -0
- package/geometry/animal-hen.js +248 -0
- package/geometry/animal-horse-body.js +446 -0
- package/geometry/animal-horse-bridle.js +171 -0
- package/geometry/animal-horse-coat.js +68 -0
- package/geometry/animal-horse-face.js +162 -0
- package/geometry/animal-horse-hair.js +304 -0
- package/geometry/animal-horse-head.js +133 -0
- package/geometry/animal-horse-tack.js +157 -0
- package/geometry/animal-options.js +59 -0
- package/geometry/animal-shapes.js +21 -0
- package/geometry/animal-skin.js +390 -0
- package/geometry/bedding.js +141 -0
- package/geometry/builder-cells.js +50 -0
- package/geometry/builder-frame.js +48 -0
- package/geometry/builder.js +200 -177
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cell-mask.js +25 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +40 -35
- package/geometry/crowd-dress.js +315 -0
- package/geometry/crowd-far.js +174 -0
- package/geometry/crowd-look.js +42 -0
- package/geometry/crowd-weld.js +218 -0
- package/geometry/ear.js +44 -39
- package/geometry/erosion.js +71 -45
- package/geometry/face-grid.js +85 -65
- package/geometry/field-map.js +59 -0
- package/geometry/figure-arms.js +339 -0
- package/geometry/figure-beard.js +250 -0
- package/geometry/figure-body.js +297 -0
- package/geometry/figure-bow.js +105 -0
- package/geometry/figure-cloak.js +189 -0
- package/geometry/figure-clothes.js +337 -0
- package/geometry/figure-face-grids.js +75 -0
- package/geometry/figure-gear.js +446 -0
- package/geometry/figure-hair-far.js +151 -0
- package/geometry/figure-hair-hangs.js +108 -0
- package/geometry/figure-hair-patch.js +66 -0
- package/geometry/figure-hair.js +320 -0
- package/geometry/figure-hands.js +321 -0
- package/geometry/figure-head-features.js +280 -0
- package/geometry/figure-head.js +375 -0
- package/geometry/figure-headwear.js +223 -0
- package/geometry/figure-legs.js +231 -0
- package/geometry/figure-limbs.js +39 -0
- package/geometry/figure-sculpt.js +82 -0
- package/geometry/figure-skin.js +97 -0
- package/geometry/figure-skirts.js +303 -0
- package/geometry/figure-trunk.js +411 -0
- package/geometry/flier-corvid-body.js +322 -0
- package/geometry/flier-corvid-wings.js +154 -0
- package/geometry/flier-long-body.js +195 -0
- package/geometry/flier-shapes.js +219 -0
- package/geometry/flier-soaring-bird.js +84 -0
- package/geometry/foliage.js +187 -14
- package/geometry/fort-city-walls.js +479 -0
- package/geometry/fort-gate-approach.js +233 -0
- package/geometry/fort-great-walls.js +280 -0
- package/geometry/fort-keep.js +297 -0
- package/geometry/fort-parts.js +261 -0
- package/geometry/fort-polyline.js +261 -0
- package/geometry/fort-portal.js +96 -0
- package/geometry/fort-ring-wall.js +267 -0
- package/geometry/fort-seawall.js +104 -0
- package/geometry/fort-terrace-gates.js +323 -0
- package/geometry/fort-terrace-plan.js +250 -0
- package/geometry/fort-terrace-wall.js +345 -0
- package/geometry/garment-tags.js +11 -3
- package/geometry/grid-gather.js +69 -0
- package/geometry/grid-sample.js +185 -0
- package/geometry/hair-gathers.js +57 -42
- package/geometry/hair-locks.js +42 -42
- package/geometry/hair-patch.js +24 -20
- package/geometry/hair-shell.js +43 -31
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +26 -15
- package/geometry/head-shape.js +123 -95
- package/geometry/heightfield.js +50 -24
- package/geometry/horizon-angles.js +166 -0
- package/geometry/house-kit-body.js +195 -0
- package/geometry/house-kit-courtyard-parts.js +340 -0
- package/geometry/house-kit-courtyard-roof.js +223 -0
- package/geometry/house-kit-courtyard.js +409 -0
- package/geometry/house-kit-cut.js +29 -0
- package/geometry/house-kit-extras.js +192 -0
- package/geometry/house-kit-forms.js +298 -0
- package/geometry/house-kit-frame.js +74 -0
- package/geometry/house-kit-marks.js +93 -0
- package/geometry/house-kit-openings.js +193 -0
- package/geometry/house-kit-palette.js +54 -0
- package/geometry/house-kit-pool.js +71 -0
- package/geometry/house-kit-roofs.js +151 -0
- package/geometry/house-kit.js +202 -0
- package/geometry/index-parts.js +2 -2
- package/geometry/instance-visibility.js +12 -12
- package/geometry/instances.js +17 -17
- package/geometry/lamp-wash.js +65 -0
- package/geometry/land-clearings.js +83 -0
- package/geometry/land-ditches.js +290 -0
- package/geometry/land-dry-basin.js +327 -0
- package/geometry/land-dunes.js +150 -0
- package/geometry/land-earthworks.js +432 -0
- package/geometry/land-edge.js +292 -0
- package/geometry/land-mound-faces.js +349 -0
- package/geometry/land-near-relief.js +102 -0
- package/geometry/land-sheet.js +220 -0
- package/geometry/land-town-ground.js +256 -0
- package/geometry/land-waters.js +228 -0
- package/geometry/land-wildness.js +123 -0
- package/geometry/lathed-vessel.js +293 -0
- package/geometry/outline-grid.js +11 -10
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +38 -3
- package/geometry/path-field.js +98 -34
- package/geometry/placement.js +52 -52
- package/geometry/planked-floor.js +149 -0
- package/geometry/plant-broadleaf.js +268 -0
- package/geometry/plant-shrub.js +198 -0
- package/geometry/plant-tints.js +80 -0
- package/geometry/plant-trees.js +453 -0
- package/geometry/plant-tussock.js +107 -0
- package/geometry/point-buckets.js +50 -0
- package/geometry/primitives.js +117 -59
- package/geometry/prop-battlefield.js +69 -0
- package/geometry/prop-camp.js +175 -0
- package/geometry/prop-door.js +26 -0
- package/geometry/prop-harbour.js +105 -0
- package/geometry/prop-haycock.js +60 -0
- package/geometry/prop-sacks.js +74 -0
- package/geometry/prop-sheaf.js +68 -0
- package/geometry/prop-street.js +69 -0
- package/geometry/prop-tents.js +396 -0
- package/geometry/prop-tombs.js +80 -0
- package/geometry/prop-trade.js +393 -0
- package/geometry/prop-vehicles.js +218 -0
- package/geometry/props.js +58 -0
- package/geometry/room-arcade.js +134 -0
- package/geometry/room-dome.js +188 -0
- package/geometry/room-flames.js +138 -0
- package/geometry/room-frame.js +106 -0
- package/geometry/room-furniture.js +260 -0
- package/geometry/room-hearth.js +98 -0
- package/geometry/room-kit.js +59 -0
- package/geometry/room-openings.js +142 -0
- package/geometry/room-stairs.js +180 -0
- package/geometry/room-surfaces.js +272 -0
- package/geometry/sagging-tube.js +27 -27
- package/geometry/sampled-surface.js +123 -77
- package/geometry/scatter-grid.js +49 -6
- package/geometry/sculpt.js +97 -93
- package/geometry/ship-fittings.js +350 -0
- package/geometry/ship-hull.js +460 -0
- package/geometry/ship-kit.js +208 -0
- package/geometry/ship-lines.js +69 -0
- package/geometry/ship-oars.js +150 -0
- package/geometry/ship-presets.js +131 -0
- package/geometry/ship-rig.js +374 -0
- package/geometry/ship-sails.js +148 -0
- package/geometry/shore-grid.js +81 -34
- package/geometry/strata-field.js +131 -98
- package/geometry/strata-tiles.js +108 -94
- package/geometry/stream.js +96 -59
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +216 -123
- package/geometry/terrain-extension.js +29 -13
- package/geometry/town-courtyard-inn.js +272 -0
- package/geometry/town-ground.js +76 -0
- package/geometry/town-houses.js +343 -0
- package/geometry/town-lights.js +254 -0
- package/geometry/town-lots.js +172 -0
- package/geometry/town-plan.js +370 -0
- package/geometry/town-works.js +465 -0
- package/geometry/village-layout.js +181 -0
- package/geometry/village-yards.js +167 -0
- package/geometry/wall-runs.js +64 -0
- package/index.js +138 -2
- package/math/cell-edge.js +16 -16
- package/math/cell-key.js +6 -0
- package/math/circle-clearances.js +19 -0
- package/math/cloth-textures.js +6 -6
- package/math/cloud-textures.js +22 -26
- package/math/color.js +14 -14
- package/math/curve.js +26 -22
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +379 -205
- package/math/noise.js +101 -49
- package/math/particle-noise.js +28 -28
- package/math/periodic.js +11 -5
- package/math/random.js +24 -15
- package/math/rectangles.js +58 -0
- package/math/rock-texture.js +22 -17
- package/math/scalar.js +5 -5
- package/math/surface-textures.js +74 -59
- package/math/wandering-path.js +40 -0
- package/math/ways.js +120 -0
- package/motion/action-dynamics.js +398 -0
- package/motion/animal-bearing.js +247 -0
- package/motion/animal-canine-bearing.js +178 -0
- package/motion/animal-canine-cast.js +131 -0
- package/motion/animal-cattle-cast.js +64 -0
- package/motion/animal-herd-cast.js +154 -0
- package/motion/animal-horse-still.js +161 -0
- package/motion/animal-troop-cast.js +43 -0
- package/motion/arm-reach.js +27 -26
- package/motion/ballistic-arc.js +191 -0
- package/motion/biped-cycle.js +46 -0
- package/motion/biped-leg.js +40 -0
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +226 -140
- package/motion/boat-sailing.js +214 -0
- package/motion/contact-transition.js +32 -0
- package/motion/crowd-alarms.js +72 -42
- package/motion/crowd-attention.js +108 -0
- package/motion/crowd-beasts.js +203 -0
- package/motion/crowd-camp.js +295 -0
- package/motion/crowd-figure.js +100 -0
- package/motion/crowd-herd.js +86 -0
- package/motion/crowd-hold.js +130 -0
- package/motion/crowd-pose.js +296 -0
- package/motion/crowd-poses.js +481 -0
- package/motion/crowd-routine.js +126 -67
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/daily-clock.js +9 -9
- package/motion/deck-surface.js +40 -0
- package/motion/figure-acts.js +411 -0
- package/motion/figure-arms.js +437 -0
- package/motion/figure-blade-slide.js +149 -0
- package/motion/figure-body-place.js +180 -0
- package/motion/figure-bones.js +118 -0
- package/motion/figure-bow-draw.js +70 -0
- package/motion/figure-fingers.js +215 -0
- package/motion/figure-gaze.js +205 -0
- package/motion/figure-gestures.js +452 -0
- package/motion/figure-grip.js +134 -0
- package/motion/figure-head.js +287 -0
- package/motion/figure-legs.js +264 -0
- package/motion/figure-links.js +293 -0
- package/motion/figure-locomotion.js +391 -0
- package/motion/figure-mount-up.js +180 -0
- package/motion/figure-mount.js +201 -0
- package/motion/figure-pose-frame.js +375 -0
- package/motion/figure-pose-table.js +156 -0
- package/motion/figure-pose.js +343 -0
- package/motion/figure-seat.js +267 -0
- package/motion/figure-sway.js +125 -0
- package/motion/flier-corvid-pose.js +74 -0
- package/motion/flier-flight-air.js +122 -0
- package/motion/flier-flight-echelon.js +164 -0
- package/motion/flier-flight-roost.js +131 -0
- package/motion/flier-swarm-flight.js +252 -0
- package/motion/formation.js +193 -0
- package/motion/ground-lookahead.js +5 -5
- package/motion/instance-sight.js +15 -8
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +41 -32
- package/motion/quadruped.js +244 -168
- package/motion/spaces.js +90 -38
- package/motion/speech-cadence.js +304 -0
- package/motion/vessel-motion.js +57 -0
- package/motion/walk-grid.js +235 -0
- package/motion/weather.js +133 -26
- package/motion/wind.js +58 -13
- package/package.json +33 -6
- package/rendering/alpha-mips.js +340 -0
- package/rendering/animal-camel-figure.js +29 -0
- package/rendering/animal-canine-figure.js +59 -0
- package/rendering/animal-cattle-figure.js +36 -0
- package/rendering/animal-horse-figure.js +49 -0
- package/rendering/atmosphere.js +86 -0
- package/rendering/camera-track.js +156 -0
- package/rendering/cart-track.js +92 -0
- package/rendering/caster-motion.js +6 -5
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +754 -113
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +30 -30
- package/rendering/cloud-field.js +2 -2
- package/rendering/compilation-schedule.js +79 -14
- package/rendering/contact-shadows.js +7 -4
- package/rendering/context.js +57 -6
- package/rendering/crowd-batches.js +420 -0
- package/rendering/crowd-herd.js +198 -0
- package/rendering/crowd-rig.js +132 -0
- package/rendering/crowd-skinning.js +62 -19
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/crust.js +18 -12
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +4 -6
- package/rendering/detail-range.js +29 -0
- package/rendering/dispose-meshes.js +18 -0
- package/rendering/dof.js +20 -13
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/eye-adapt.js +14 -14
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +89 -62
- package/rendering/field-surface.js +138 -0
- package/rendering/figure-shield.js +105 -0
- package/rendering/figure-skeleton.js +329 -0
- package/rendering/fire-light-watch.js +197 -0
- package/rendering/fire-pools.js +148 -0
- package/rendering/flame-sources.js +86 -0
- package/rendering/flier-bird-looks.js +97 -0
- package/rendering/flier-corvid-figure.js +67 -0
- package/rendering/flier-long-body-company.js +169 -0
- package/rendering/flier-swarm.js +186 -0
- package/rendering/flocks.js +82 -78
- package/rendering/garment-material.js +147 -51
- package/rendering/glow-lines.js +13 -13
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +45 -31
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +164 -22
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +56 -0
- package/rendering/label-range.js +41 -0
- package/rendering/lamp-light-map.js +159 -0
- package/rendering/lamp-maps.js +62 -0
- package/rendering/lamp-wash.js +51 -0
- package/rendering/light-budget.js +71 -55
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +39 -8
- package/rendering/material-lod.js +49 -50
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +135 -99
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +212 -101
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +298 -11
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +806 -103
- package/rendering/plant-cells.js +122 -0
- package/rendering/plant-reeds.js +113 -0
- package/rendering/plant-shade-trees.js +239 -0
- package/rendering/plant-tuft-patch.js +122 -0
- package/rendering/post-shaders.js +98 -31
- package/rendering/post.js +107 -87
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/rain-streaks.js +67 -0
- package/rendering/room-light.js +250 -0
- package/rendering/room-materials.js +78 -0
- package/rendering/room-space.js +111 -0
- package/rendering/scene-lights.js +106 -0
- package/rendering/sea-shaders.js +94 -37
- package/rendering/settlement-approach.js +226 -0
- package/rendering/settlement-dissolve.js +89 -0
- package/rendering/settlement-quarter-warm.js +55 -0
- package/rendering/settlement-quarter.js +477 -0
- package/rendering/settlement-switch.js +42 -0
- package/rendering/settlement-town.js +110 -0
- package/rendering/shader-warmup.js +101 -44
- package/rendering/shadow-alignment.js +4 -4
- package/rendering/shadow-depth.js +47 -25
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +56 -29
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +126 -54
- package/rendering/smoke-shadows.js +201 -0
- package/rendering/stage-framing.js +182 -0
- package/rendering/stage-lights.js +46 -39
- package/rendering/stain-material.js +74 -0
- package/rendering/static-point-shadow.js +65 -26
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +12 -12
- package/rendering/stream-flow.js +10 -10
- package/rendering/street-lamps.js +166 -0
- package/rendering/sunbeam-motes.js +670 -0
- package/rendering/surface-light.js +65 -6
- package/rendering/surface-material.js +306 -0
- package/rendering/surface-projection.js +32 -0
- package/rendering/surface-snippets.js +314 -0
- package/rendering/taa.js +75 -44
- package/rendering/talus.js +15 -15
- package/rendering/terrain-rock.js +7 -7
- package/rendering/texture-fills.js +8 -8
- package/rendering/textures.js +28 -28
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/wakes.js +24 -24
- package/rendering/water-material.js +304 -103
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +38 -40
- package/ruff.toml +20 -0
- package/runtime/cue-cursor.js +21 -0
- package/runtime/device-quality.js +13 -2
- package/runtime/device.js +73 -0
- package/runtime/diagnostic-log.js +12 -4
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +36 -28
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +47 -0
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +15 -11
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +44 -5
- package/runtime/hand-over.js +47 -24
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +73 -17
- package/runtime/quality-fit.js +60 -28
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +26 -22
- package/runtime/settlement-reach.js +42 -0
- package/runtime/sound-calls.js +113 -0
- package/runtime/sound-impacts.js +297 -0
- package/runtime/sound-voices.js +194 -0
- package/runtime/soundscape.js +282 -0
- package/runtime/spatial-audio.js +79 -30
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +46 -0
- package/runtime/worker.js +7 -0
- package/scripts/app-parts.mjs +118 -0
- package/scripts/bake-revisions.mjs +81 -0
- package/scripts/browser-scripts.mjs +64 -0
- package/scripts/bundle.mjs +192 -0
- package/scripts/check-app.sh +26 -0
- package/scripts/eslint-config.mjs +119 -0
- package/scripts/format.sh +92 -0
- package/scripts/keep-builds.mjs +158 -0
- package/scripts/layers.mjs +112 -0
- package/scripts/lint.sh +49 -0
- package/scripts/module-graph.mjs +123 -0
- package/scripts/pre-commit.sh +38 -0
- package/scripts/serve.py +5 -3
- package/scripts/site.mjs +358 -0
- package/scripts/test-runner.sh +42 -0
- package/scripts/vendor.mjs +221 -0
- package/scripts/verify-publish.mjs +175 -0
- package/scripts/world.mk +59 -0
- package/tools/README.md +73 -0
- package/tools/contact-sheet.cjs +137 -0
- package/tools/cpu-profile.cjs +275 -0
- package/tools/cpu-profile.test.cjs +98 -0
- package/tools/first-draws.cjs +395 -0
- package/tools/flight-guard.cjs +482 -0
- package/tools/flight-guard.test.cjs +153 -0
- package/tools/flight-profile.cjs +145 -0
- package/tools/frame-bench.cjs +336 -0
- package/tools/frame-parts.cjs +365 -0
- package/tools/ios-sim.sh +145 -0
- package/tools/load-audit.cjs +201 -0
- package/tools/look-compare.cjs +304 -0
- package/tools/look-guard.cjs +407 -0
- package/tools/look-guard.test.cjs +93 -0
- package/tools/look-stats.cjs +185 -0
- package/tools/look-stats.test.cjs +71 -0
- package/tools/memory-audit.cjs +323 -0
- package/tools/page-driver.cjs +320 -0
- package/tools/page-driver.test.cjs +219 -0
- package/tools/program-census-report.cjs +191 -0
- package/tools/program-census.cjs +465 -0
- package/tools/program-census.test.cjs +332 -0
- package/tools/remote-runner.sh +265 -0
- package/tools/runners.test.cjs +59 -0
- package/tools/scene-audit-beat.cjs +344 -0
- package/tools/scene-audit-sheet.cjs +282 -0
- package/tools/scene-audit.cjs +471 -0
- package/tools/scene-audit.test.cjs +201 -0
- package/tools/scene-batch.cjs +219 -0
- package/tools/scene-bench.cjs +149 -0
- package/tools/scene-bench.test.cjs +33 -0
- package/tools/scene-run.cjs +443 -0
- package/tools/scene-run.test.cjs +94 -0
- package/tools/servers.sh +59 -0
- package/tools/shader-arrival.cjs +316 -0
- package/tools/shader-renewal.cjs +53 -0
- package/tools/shader-renewal.test.cjs +115 -0
- package/tools/speed-guard.cjs +258 -0
- package/tools/stills.cjs +492 -0
- package/tools/stills.test.cjs +49 -0
- package/tools/turns.sh +7 -0
- package/tools/yaml.cjs +158 -0
- package/examples/viaduct.css +0 -75
- package/rendering/light-shafts.js +0 -131
- package/rendering/road-surface.js +0 -63
package/math/mountain-ranges.js
CHANGED
|
@@ -1,61 +1,187 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Add seeded hills, ridges and escarpments to a terrain height function.
|
|
3
|
+
* {@link createMountainRanges} samples relief and loose rock for the same location.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
2
6
|
import { clamp, lerp, sstep } from './scalar.js';
|
|
3
7
|
import { createNoise } from './noise.js';
|
|
4
8
|
import { createHash } from './random.js';
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The shape of every range, escarpment and field of hills: the defaults of {@link createMountainRanges}'s `shape` option,
|
|
12
|
+
* any of which a caller may replace. Shares and widths are as each line says; lengths are metres.
|
|
13
|
+
*/
|
|
14
|
+
export const RANGE_SHAPE = Object.freeze({
|
|
15
|
+
// how broken an upland must be to begin to be a range, and to be one wholly
|
|
16
|
+
rangeFrom: [0.3, 0.75],
|
|
17
|
+
// where a flank's rock slope meets its apron, in flank widths from the crest
|
|
18
|
+
foot: 1.15,
|
|
19
|
+
// the share of a crest's height its apron stands for: the scree and wash banked against its foot
|
|
20
|
+
apron: 0.13,
|
|
21
|
+
// flank widths from the crest at which nothing of a range is left
|
|
22
|
+
reach: 2.1,
|
|
23
|
+
// and the same past a crest's end, in the lengths its end falls away over
|
|
24
|
+
tailReach: 1.9,
|
|
25
|
+
// the share of its width a range keeps where its crest has fallen away
|
|
26
|
+
narrow: 0.4,
|
|
27
|
+
// metres a crest is rounded over, so its line does not saw across the ground's cells
|
|
28
|
+
crestRound: 7,
|
|
29
|
+
// peaks along a crest, in half-widths of the range ...
|
|
30
|
+
peakSpacing: 0.6,
|
|
31
|
+
// ... but no nearer and no farther apart than this, in metres
|
|
32
|
+
peakSpan: [60, 200],
|
|
33
|
+
// how pointed a peak is and how level a saddle (1: a straight line from one to the other)
|
|
34
|
+
peakPoint: 1.4,
|
|
35
|
+
// the most a lesser peak stands under the highest, as a share of it,
|
|
36
|
+
peakDrop: 0.26,
|
|
37
|
+
// and a saddle under the lower of its two peaks;
|
|
38
|
+
saddleDrop: [0.05, 0.24],
|
|
39
|
+
// the share of the saddles that are passes, and how much lower a pass lies
|
|
40
|
+
pass: [0.12, 0.2],
|
|
41
|
+
// the share of its length beyond its width that an ellipse's crest holds its height over, where it is a range
|
|
42
|
+
held: 0.6,
|
|
43
|
+
// how much narrower than its half-width a range's steeper flank may be, and the other wider
|
|
44
|
+
lop: 0.3,
|
|
45
|
+
// how far a flank's slope may be bowed out or hollowed
|
|
46
|
+
bow: 0.3,
|
|
47
|
+
// how far a crest strays from its straight line, in half-widths
|
|
48
|
+
wander: 0.28,
|
|
49
|
+
// how far a range's whole shape is pulled about, in half-widths, and over what length, in peak spacings
|
|
50
|
+
warp: [0.5, 3.2],
|
|
51
|
+
// the share of a crest's saddles that send a short spur of their own down one side
|
|
52
|
+
shoulder: 0.85,
|
|
53
|
+
// how much nearer the crest a valley's floor meets the apron than a spur's toe does
|
|
54
|
+
embayed: 0.32,
|
|
55
|
+
// the share of a flank's height the valleys between its spurs are cut down by
|
|
56
|
+
cut: 0.6,
|
|
57
|
+
// and the gullies in a spur's side
|
|
58
|
+
ribCut: 0.42,
|
|
59
|
+
// how far a spur's own crest is notched between its knobs, as a share of the valleys' depth
|
|
60
|
+
knob: 0.3,
|
|
61
|
+
// metres from one such gully to the next: six cells of the ground at the least
|
|
62
|
+
ribSpan: [36, 80],
|
|
63
|
+
// how far broken rock roughens a flank
|
|
64
|
+
crag: 0.42,
|
|
65
|
+
// and notches a crest between its peaks, as a share of its height
|
|
66
|
+
notch: 0.1,
|
|
67
|
+
// the rock's hard beds: metres from one to the next, how far they step a flank into cliffs and benches at the most, how they dip
|
|
68
|
+
// (metres to a metre along +X and +Z) and how far (metres) they are warped
|
|
69
|
+
beds: { thick: 21, hold: 0.34, dip: [0.05, 0.03], warp: 9 },
|
|
70
|
+
// the share of its height a crest must keep for a spur to leave it
|
|
71
|
+
spurLeast: 0.1,
|
|
72
|
+
// an escarpment: its face's and its dip slope's widths as shares of the half-width, how far its rim stands off the middle
|
|
73
|
+
// toward its face, how far down the face its cliff reaches (in flank widths) and the share of the height it drops, how much of
|
|
74
|
+
// a range's peaks and saddles its rim keeps, and how much farther than a range's crest it strays, in bays and headlands
|
|
75
|
+
scarp: { face: 0.5, back: 1.3, rim: 0.55, cliff: [0.28, 0.48], level: 0.35, wander: 2.4 },
|
|
76
|
+
// a field of hills: the swell they stand on as a share of its height; each hill's half-length as a share of the field's lesser
|
|
77
|
+
// radius, its half-width as a share of its length, its height as a share of the field's, and how far (radians) its crest may
|
|
78
|
+
// turn off the field's strike
|
|
79
|
+
hill: { base: 0.3, long: [0.2, 0.5], wide: [0.35, 0.6], high: [0.4, 1], turn: 1.1 },
|
|
80
|
+
// how far out a swell's foot runs, as its radius squared,
|
|
81
|
+
swellReach: 3.2,
|
|
82
|
+
// and how far that radius is pulled about
|
|
83
|
+
swellWarp: 0.22,
|
|
84
|
+
});
|
|
85
|
+
const SEG = 9; // numbers to a spur: its ends (u, v), the metres along it at each, its flanks' width at each, its ribs' phase
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {object} EllipticalUpland
|
|
89
|
+
* @property {number} x - Centre X in metres.
|
|
90
|
+
* @property {number} z - Centre Z in metres.
|
|
91
|
+
* @property {number} rx - X radius in metres, or half-length along the supplied axis.
|
|
92
|
+
* @property {number} rz - Z radius in metres, or half-width across the supplied axis.
|
|
93
|
+
* @property {number} h - Height scale in metres.
|
|
94
|
+
* @property {number} rough - Relief roughness from 0 for a smooth swell to 1 for a broken ridge.
|
|
95
|
+
* @property {number} [axis] - Long-axis bearing in radians from +X toward +Z.
|
|
96
|
+
* @property {number} [face] - Bearing toward the steep side of an escarpment, in radians.
|
|
97
|
+
* @property {number} [hills] - Number of hills to scatter inside the ellipse.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @typedef {object} Ridge
|
|
102
|
+
* @property {[number, number, number][]} crest - At least two distinct consecutive points, each [x, z, height multiplier].
|
|
103
|
+
* @property {number} wide - Flank half-width in metres.
|
|
104
|
+
* @property {number} h - Height in metres before applying each crest point’s multiplier.
|
|
105
|
+
* @property {number} rough - Relief roughness from 0 to 1.
|
|
106
|
+
* @property {number} [face] - Bearing toward the steep side of an escarpment, in radians from +X toward +Z.
|
|
107
|
+
*/
|
|
45
108
|
|
|
46
109
|
// The long axis of an upland given as an ellipse ({ x, z, rx, rz }), as [bearing, half-length, half-width]: the longer of its
|
|
47
110
|
// radii, or along `axis` (a bearing: 0 east, clockwise seen from above), with rx then its half-length and rz its half-width.
|
|
48
|
-
const ellipseAxis =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
111
|
+
const ellipseAxis = landform =>
|
|
112
|
+
landform.axis !== undefined
|
|
113
|
+
? [landform.axis, landform.rx, landform.rz]
|
|
114
|
+
: landform.rx >= landform.rz
|
|
115
|
+
? [0, landform.rx, landform.rz]
|
|
116
|
+
: [Math.PI / 2, landform.rz, landform.rx];
|
|
117
|
+
/**
|
|
118
|
+
* Get the crest line and flank half-width for drawing a map. An explicit ridge
|
|
119
|
+
* keeps its original point array, including the third height component. An
|
|
120
|
+
* ellipse yields two X/Z endpoints along its long axis.
|
|
121
|
+
* @param {EllipticalUpland | Ridge} landform - Landform supplied to the range layout.
|
|
122
|
+
*/
|
|
123
|
+
export function crestOf(landform) {
|
|
124
|
+
if (landform.crest) return { line: landform.crest, wide: landform.wide };
|
|
125
|
+
const [bearing, halfLength, halfWidth] = ellipseAxis(landform),
|
|
126
|
+
reach = 0.8 * halfLength;
|
|
127
|
+
return { line: [-reach, reach].map(u => [landform.x + u * Math.cos(bearing), landform.z + u * Math.sin(bearing)]), wide: halfWidth };
|
|
55
128
|
}
|
|
56
129
|
|
|
57
|
-
|
|
58
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Build a reusable field of mountain relief. Call `layout` with ellipses or ridgelines,
|
|
132
|
+
* then add `heightAt(x, z)` to the base terrain elevation in metres. Each call also
|
|
133
|
+
* overwrites `surface.scree`, the loose-rock amount for that sample.
|
|
134
|
+
* Calling `layout` again replaces the previous landforms. Keep their order stable
|
|
135
|
+
* when reproducing a landscape because each landform’s seed depends on its index.
|
|
136
|
+
* @param {number} [seed] - World seed for the ridges, spurs and surface detail.
|
|
137
|
+
* @param {object} [options]
|
|
138
|
+
* @param {Partial<typeof RANGE_SHAPE>} [options.shape] - Replaces any of {@link RANGE_SHAPE}'s figures (a nested one whole).
|
|
139
|
+
* @example
|
|
140
|
+
* ```js
|
|
141
|
+
* import { createMountainRanges } from 'roamwright/math/mountain-ranges.js';
|
|
142
|
+
*
|
|
143
|
+
* const mountains = createMountainRanges(42);
|
|
144
|
+
* mountains.layout([{ crest: [[0, 0, 0.6], [120, 40, 1]], wide: 50, h: 90, rough: 0.8 }]);
|
|
145
|
+
* const elevation = 12 + mountains.heightAt(80, 25);
|
|
146
|
+
* const looseRock = mountains.surface.scree;
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export function createMountainRanges(seed = 0, { shape = {} } = {}) {
|
|
150
|
+
// This instance's shape, under the names the arithmetic below reads.
|
|
151
|
+
const {
|
|
152
|
+
rangeFrom: RANGE_FROM,
|
|
153
|
+
foot: FOOT,
|
|
154
|
+
apron: APRON,
|
|
155
|
+
reach: REACH,
|
|
156
|
+
tailReach: TAIL_REACH,
|
|
157
|
+
narrow: NARROW,
|
|
158
|
+
crestRound: CREST_ROUND,
|
|
159
|
+
peakSpacing: PEAK_SPACING,
|
|
160
|
+
peakSpan: PEAK_SPAN,
|
|
161
|
+
peakPoint: PEAK_POINT,
|
|
162
|
+
peakDrop: PEAK_DROP,
|
|
163
|
+
saddleDrop: SADDLE_DROP,
|
|
164
|
+
pass: PASS,
|
|
165
|
+
held: HELD,
|
|
166
|
+
lop: LOP,
|
|
167
|
+
bow: BOW,
|
|
168
|
+
wander: WANDER,
|
|
169
|
+
warp: WARP,
|
|
170
|
+
shoulder: SHOULDER,
|
|
171
|
+
embayed: EMBAYED,
|
|
172
|
+
cut: CUT,
|
|
173
|
+
ribCut: RIB_CUT,
|
|
174
|
+
knob: KNOB,
|
|
175
|
+
ribSpan: RIB_SPAN,
|
|
176
|
+
crag: CRAG,
|
|
177
|
+
notch: NOTCH,
|
|
178
|
+
beds: BEDS,
|
|
179
|
+
spurLeast: SPUR_LEAST,
|
|
180
|
+
scarp: SCARP,
|
|
181
|
+
hill: HILL,
|
|
182
|
+
swellReach: SWELL_REACH,
|
|
183
|
+
swellWarp: SWELL_WARP,
|
|
184
|
+
} = { ...RANGE_SHAPE, ...shape };
|
|
59
185
|
const { fbm, ridged, vnoise } = createNoise(seed);
|
|
60
186
|
const hash2 = createHash(seed);
|
|
61
187
|
// What rangesAt found out about the place it worked out last, for the colours: how far it is scree and wash, the apron at a
|
|
@@ -67,8 +193,8 @@ export function createMountainRanges(seed = 0) {
|
|
|
67
193
|
|
|
68
194
|
// The swell of an ellipse ({ x, z, rx, rz, h, rough }) at (x, z), in metres: a rise that falls away smoothly all round, broken
|
|
69
195
|
// by noise the more it is rough.
|
|
70
|
-
function swellAt(
|
|
71
|
-
const r0 = ((x -
|
|
196
|
+
function swellAt(landform, x, z) {
|
|
197
|
+
const r0 = ((x - landform.x) / landform.rx) ** 2 + ((z - landform.z) / landform.rz) ** 2;
|
|
72
198
|
if (r0 >= SWELL_REACH + SWELL_WARP / 2) return 0;
|
|
73
199
|
if (crag < 0) {
|
|
74
200
|
// the noise is worked out only where a swell is near
|
|
@@ -76,72 +202,81 @@ export function createMountainRanges(seed = 0) {
|
|
|
76
202
|
pull = SWELL_WARP * (fbm(x * 0.0021, z * 0.0021, 2, 337) - 0.5);
|
|
77
203
|
}
|
|
78
204
|
const r = r0 + pull;
|
|
79
|
-
return r < SWELL_REACH ?
|
|
205
|
+
return r < SWELL_REACH ? landform.h * Math.exp(-1.5 * Math.max(r, 0)) * lerp(1, 0.35 + 1.25 * crag, landform.rough) : 0;
|
|
80
206
|
}
|
|
81
207
|
|
|
82
208
|
// The height of a limb's crest at u, as a share of its own: 1 along its length, falling away past each end.
|
|
83
|
-
function crestShare(
|
|
84
|
-
const over = u < 0 ? -u /
|
|
85
|
-
return (over > 0 ? Math.exp(-1.5 * over **
|
|
209
|
+
function crestShare(limbData, u) {
|
|
210
|
+
const over = u < 0 ? -u / limbData.tail0 : u > limbData.len ? (u - limbData.len) / limbData.tail1 : 0;
|
|
211
|
+
return (over > 0 ? Math.exp(-1.5 * over ** limbData.fall) : 1) * lerp(limbData.k0, limbData.k1, clamp(u / (limbData.len || 1), 0, 1));
|
|
86
212
|
}
|
|
87
213
|
// How far a limb's crest stands off its straight line at u: it wanders, and an escarpment's rim stands toward its face.
|
|
88
|
-
function crestOffset(
|
|
89
|
-
const stray = 2 * (vnoise(u /
|
|
90
|
-
return
|
|
214
|
+
function crestOffset(limbData, u) {
|
|
215
|
+
const stray = 2 * (vnoise(u / limbData.wave + 7.3, 0, limbData.seed) - limbData.strayAt);
|
|
216
|
+
return (
|
|
217
|
+
limbData.rim +
|
|
218
|
+
limbData.wander * stray * (limbData.line ? sstep(0, limbData.step, u) * sstep(limbData.len, limbData.len - limbData.step, u) : 1)
|
|
219
|
+
); // the stretches of a line meet end to end
|
|
91
220
|
}
|
|
92
221
|
// How far a range leans to one side at u, -1..1: no range's two flanks are alike, and which is the steeper changes along it.
|
|
93
|
-
const leanAt = (
|
|
94
|
-
// The width of a limb's flank on `side` of its crest at u, where the crest stands at
|
|
222
|
+
const leanAt = (limbData, u, seed) => 2 * vnoise(u / (4 * limbData.step) + 3.1, 0, limbData.seed + seed) - 1;
|
|
223
|
+
// The width of a limb's flank on `side` of its crest at u, where the crest stands at fraction crestFraction of its height: a range narrows as
|
|
95
224
|
// its crest falls, so its flanks keep their slope, and the flank it leans toward is the narrower and steeper.
|
|
96
|
-
const flankWidth = (
|
|
97
|
-
|
|
225
|
+
const flankWidth = (limbData, crestFraction, side, u) =>
|
|
226
|
+
limbData.b *
|
|
227
|
+
(NARROW + (1 - NARROW) * crestFraction) *
|
|
228
|
+
(limbData.face ? (limbData.face === side ? SCARP.face : SCARP.back) : 1 - side * LOP * limbData.rough * leanAt(limbData, u, 9));
|
|
98
229
|
// How far a range's shape is pulled off its place at (x, z), along x (`turn` 0) or z (1), as a share of the most: at two scales.
|
|
99
|
-
const warpAt = (
|
|
230
|
+
const warpAt = (limbData, x, z, turn) =>
|
|
231
|
+
2 * fbm(x * limbData.warpOver + 31.7 * turn, z * limbData.warpOver + 11.3 * turn, 2, limbData.seed + 3 + turn) - 1;
|
|
100
232
|
// How far a crest is notched at u, as a share of the most.
|
|
101
|
-
const notchAt = (
|
|
233
|
+
const notchAt = (limbData, u) => 2 * fbm(u / (0.7 * limbData.step), 0, 3, limbData.seed + 6) - 1;
|
|
102
234
|
|
|
103
235
|
// The peaks and saddles of a limb's crest, as [u, share of the height] in turn from a peak to a peak: a peak stands where the
|
|
104
236
|
// data puts the upland (the middle of an ellipse, the points of a line), the rest a spacing apart.
|
|
105
|
-
function crestKnots(
|
|
106
|
-
const first =
|
|
107
|
-
step =
|
|
108
|
-
last =
|
|
109
|
-
from = -Math.ceil((first + 1.3 *
|
|
110
|
-
to = Math.ceil((
|
|
111
|
-
level =
|
|
237
|
+
function crestKnots(limbData, spacing) {
|
|
238
|
+
const first = limbData.line ? 0 : limbData.len / 2,
|
|
239
|
+
step = limbData.line ? limbData.len / Math.max(1, Math.round(limbData.len / spacing)) : spacing,
|
|
240
|
+
last = limbData.line ? Math.round(limbData.len / step) : 0, // the peak at a line's far point
|
|
241
|
+
from = -Math.ceil((first + 1.3 * limbData.tail0) / step),
|
|
242
|
+
to = Math.ceil((limbData.len + 1.3 * limbData.tail1 - first) / step),
|
|
243
|
+
level = limbData.rough * (limbData.face ? SCARP.level : 1),
|
|
112
244
|
knots = [];
|
|
113
245
|
let before = 0;
|
|
114
246
|
for (let k = from; k <= to; k++) {
|
|
115
|
-
const given = k === 0 || (
|
|
116
|
-
u = first + (k + (given ? 0 : 0.6 * (hash2(k, 1,
|
|
117
|
-
peak = given ? 1 : 1 - level * PEAK_DROP * Math.sqrt(hash2(k, 2,
|
|
247
|
+
const given = k === 0 || (limbData.line && k === last),
|
|
248
|
+
u = first + (k + (given ? 0 : 0.6 * (hash2(k, 1, limbData.seed) - 0.5))) * step,
|
|
249
|
+
peak = given ? 1 : 1 - level * PEAK_DROP * Math.sqrt(hash2(k, 2, limbData.seed)); // a few stand near the highest, most well under it
|
|
118
250
|
if (k > from) {
|
|
119
|
-
const drop =
|
|
120
|
-
|
|
251
|
+
const drop =
|
|
252
|
+
lerp(SADDLE_DROP[0], SADDLE_DROP[1], hash2(k, 4, limbData.seed)) + (hash2(k, 5, limbData.seed) < PASS[0] ? PASS[1] : 0);
|
|
253
|
+
knots.push(lerp(knots[knots.length - 2], u, 0.35 + 0.3 * hash2(k, 3, limbData.seed)), Math.min(before, peak) - level * drop);
|
|
121
254
|
}
|
|
122
255
|
knots.push(u, peak);
|
|
123
256
|
before = peak;
|
|
124
257
|
}
|
|
125
|
-
|
|
258
|
+
limbData.step = step;
|
|
126
259
|
return Float64Array.from(knots);
|
|
127
260
|
}
|
|
128
261
|
// How high a limb's crest stands at u between its peaks and saddles, as a share: pointed at a peak, level across a saddle.
|
|
129
|
-
function knotShare(
|
|
130
|
-
const
|
|
131
|
-
n =
|
|
132
|
-
if (u <=
|
|
133
|
-
if (u >=
|
|
134
|
-
let i = clamp(Math.floor(((u -
|
|
135
|
-
while (
|
|
136
|
-
while (
|
|
137
|
-
const t = (u -
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return
|
|
262
|
+
function knotShare(limbData, u) {
|
|
263
|
+
const knots = limbData.knots,
|
|
264
|
+
n = knots.length / 2;
|
|
265
|
+
if (u <= knots[0]) return knots[1];
|
|
266
|
+
if (u >= knots[2 * n - 2]) return knots[2 * n - 1];
|
|
267
|
+
let i = clamp(Math.floor(((u - knots[0]) / limbData.step) * 2), 0, n - 2);
|
|
268
|
+
while (knots[2 * i] > u) i--;
|
|
269
|
+
while (knots[2 * i + 2] < u) i++;
|
|
270
|
+
const t = (u - knots[2 * i]) / (knots[2 * i + 2] - knots[2 * i]),
|
|
271
|
+
startHeight = knots[2 * i + 1],
|
|
272
|
+
endHeight = knots[2 * i + 3];
|
|
273
|
+
return startHeight >= endHeight
|
|
274
|
+
? endHeight + (startHeight - endHeight) * (1 - t) ** PEAK_POINT
|
|
275
|
+
: startHeight + (endHeight - startHeight) * t ** PEAK_POINT;
|
|
141
276
|
}
|
|
142
277
|
// The spurs that run down one side of a limb: one from each peak, with a branch or two that leave it lower down, and a short
|
|
143
278
|
// one from the shoulder of most saddles. A spur is a straight line: the range's warp bends it.
|
|
144
|
-
function limbSpurs(
|
|
279
|
+
function limbSpurs(limbData, side) {
|
|
145
280
|
const out = [],
|
|
146
281
|
spur = (u0, v0, angle, long, tau, wide0, wide1, seed) =>
|
|
147
282
|
out.push(
|
|
@@ -153,26 +288,26 @@ export function createMountainRanges(seed = 0) {
|
|
|
153
288
|
tau + long,
|
|
154
289
|
wide0,
|
|
155
290
|
wide1,
|
|
156
|
-
hash2(seed, 9,
|
|
291
|
+
hash2(seed, 9, limbData.seed),
|
|
157
292
|
);
|
|
158
|
-
for (let k = 0; k <
|
|
159
|
-
const u =
|
|
160
|
-
|
|
293
|
+
for (let k = 0; k < limbData.knots.length; k += 2) {
|
|
294
|
+
const u = limbData.knots[k],
|
|
295
|
+
crestFraction = crestShare(limbData, u),
|
|
161
296
|
id = k + (side > 0 ? 1 : 0),
|
|
162
|
-
r = n => hash2(id, n,
|
|
297
|
+
r = n => hash2(id, n, limbData.seed + 1),
|
|
163
298
|
peak = k % 4 === 0;
|
|
164
|
-
if (
|
|
165
|
-
const buttress =
|
|
166
|
-
long = flankWidth(
|
|
167
|
-
splay = u < 0 ? -sstep(0, 1, -u /
|
|
299
|
+
if (crestFraction < SPUR_LEAST || (!peak && r(0) > SHOULDER)) continue;
|
|
300
|
+
const buttress = limbData.face === side, // an escarpment's face is buttressed, not spurred
|
|
301
|
+
long = flankWidth(limbData, crestFraction, side, u) * FOOT * (buttress ? 0.75 : peak ? 0.45 + 0.7 * r(1) : 0.3 + 0.35 * r(1)),
|
|
302
|
+
splay = u < 0 ? -sstep(0, 1, -u / limbData.tail0) : u > limbData.len ? sstep(0, 1, (u - limbData.len) / limbData.tail1) : 0, // round a crest's end they fan out
|
|
168
303
|
lean = (r(2) - 0.5) * 1.1 + 0.9 * splay,
|
|
169
|
-
v = crestOffset(
|
|
170
|
-
girth =
|
|
304
|
+
v = crestOffset(limbData, u),
|
|
305
|
+
girth = limbData.step * (0.8 + 0.4 * r(7));
|
|
171
306
|
spur(u, v, lean, long, 0, 0.42 * girth, 0.64 * girth, id);
|
|
172
307
|
if (buttress || !peak) continue;
|
|
173
|
-
for (let
|
|
174
|
-
const at = (
|
|
175
|
-
turn = lean + (
|
|
308
|
+
for (let branchIndex = 0; branchIndex < 2; branchIndex++) {
|
|
309
|
+
const at = (branchIndex ? 0.6 : 0.38) + 0.14 * r(3 + branchIndex),
|
|
310
|
+
turn = lean + (branchIndex ? -1 : 1) * (r(5) < 0.5 ? -1 : 1) * (0.6 + 0.4 * r(6 + branchIndex));
|
|
176
311
|
spur(
|
|
177
312
|
u + at * long * Math.sin(lean),
|
|
178
313
|
v + side * at * long * Math.cos(lean),
|
|
@@ -181,32 +316,33 @@ export function createMountainRanges(seed = 0) {
|
|
|
181
316
|
at * long,
|
|
182
317
|
0.3 * girth,
|
|
183
318
|
0.42 * girth,
|
|
184
|
-
id + 1000 * (
|
|
319
|
+
id + 1000 * (branchIndex + 1),
|
|
185
320
|
);
|
|
186
321
|
}
|
|
187
322
|
}
|
|
188
323
|
// where a crest ends, a long spur runs out and away on either side of its fall, so that the end of a range is no cone
|
|
189
324
|
for (const [u, away, free] of [
|
|
190
|
-
[0, -1,
|
|
191
|
-
[
|
|
325
|
+
[0, -1, limbData.free0],
|
|
326
|
+
[limbData.len, 1, limbData.free1],
|
|
192
327
|
]) {
|
|
193
328
|
if (!free) continue;
|
|
194
329
|
const id = 5000 + (away > 0 ? 2 : 0) + (side > 0 ? 1 : 0),
|
|
195
|
-
long = flankWidth(
|
|
196
|
-
girth =
|
|
197
|
-
spur(u, crestOffset(
|
|
330
|
+
long = flankWidth(limbData, crestShare(limbData, u), side, u) * FOOT * (0.7 + 0.6 * hash2(id, 1, limbData.seed + 1)),
|
|
331
|
+
girth = limbData.step * (1 + 0.4 * hash2(id, 2, limbData.seed + 1));
|
|
332
|
+
spur(u, crestOffset(limbData, u), away * (0.6 + 0.7 * hash2(id, 3, limbData.seed + 1)), long, 0, 0.42 * girth, 0.64 * girth, id);
|
|
198
333
|
}
|
|
199
|
-
return binned(
|
|
334
|
+
return binned(limbData, out);
|
|
200
335
|
}
|
|
201
336
|
// The spurs of `list` sorted into bins along a limb's crest, a peak spacing long each: every bin holds the spurs that reach into
|
|
202
337
|
// its stretch, so a place asks only the few that could lie near it.
|
|
203
|
-
function binned(
|
|
204
|
-
const bins = Array.from({ length: Math.ceil((
|
|
338
|
+
function binned(limbData, list) {
|
|
339
|
+
const bins = Array.from({ length: Math.ceil((limbData.to - limbData.from) / limbData.step) }, () => []);
|
|
205
340
|
for (let i = 0; i < list.length; i += SEG) {
|
|
206
341
|
const reach = Math.max(list[i + 6], list[i + 7]),
|
|
207
|
-
first = Math.floor((Math.min(list[i], list[i + 2]) - reach -
|
|
208
|
-
last = Math.floor((Math.max(list[i], list[i + 2]) + reach -
|
|
209
|
-
for (let
|
|
342
|
+
first = Math.floor((Math.min(list[i], list[i + 2]) - reach - limbData.from) / limbData.step),
|
|
343
|
+
last = Math.floor((Math.max(list[i], list[i + 2]) + reach - limbData.from) / limbData.step);
|
|
344
|
+
for (let binIndex = Math.max(first, 0); binIndex <= Math.min(last, bins.length - 1); binIndex++)
|
|
345
|
+
bins[binIndex].push(...list.slice(i, i + SEG));
|
|
210
346
|
}
|
|
211
347
|
return bins.map(bin => Float64Array.from(bin));
|
|
212
348
|
}
|
|
@@ -217,7 +353,7 @@ export function createMountainRanges(seed = 0) {
|
|
|
217
353
|
// swell it is where it is not broken enough to be one (none: a swell about its own crest).
|
|
218
354
|
function limb(spec, seed) {
|
|
219
355
|
const sharp = sstep(RANGE_FROM[0], RANGE_FROM[1], spec.rough),
|
|
220
|
-
|
|
356
|
+
limbData = {
|
|
221
357
|
...spec,
|
|
222
358
|
seed,
|
|
223
359
|
sharp,
|
|
@@ -226,23 +362,27 @@ export function createMountainRanges(seed = 0) {
|
|
|
226
362
|
wander: WANDER * spec.b * spec.rough * (spec.face ? SCARP.wander : 1),
|
|
227
363
|
strayAt: 0.5,
|
|
228
364
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
365
|
+
limbData.knots = crestKnots(limbData, clamp(PEAK_SPACING * limbData.b, PEAK_SPAN[0], PEAK_SPAN[1]));
|
|
366
|
+
limbData.wave = 3 * limbData.step;
|
|
367
|
+
limbData.warp = WARP[0] * limbData.b * limbData.rough * sharp;
|
|
368
|
+
limbData.warpOver = 1 / (WARP[1] * limbData.step);
|
|
369
|
+
limbData.rib = clamp(0.3 * limbData.step, RIB_SPAN[0], RIB_SPAN[1]);
|
|
234
370
|
// the stretch of its frame outside which the range raises nothing, however it is pulled about (by twice its warp at the most)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
371
|
+
limbData.from = -TAIL_REACH * limbData.tail0 - 2 * limbData.warp;
|
|
372
|
+
limbData.to = limbData.len + TAIL_REACH * limbData.tail1 + 2 * limbData.warp;
|
|
373
|
+
limbData.far = REACH * limbData.b * Math.max(1 + LOP, SCARP.back) + Math.abs(limbData.rim) + 2 * limbData.wander + 2 * limbData.warp;
|
|
238
374
|
// a summit stands where the data puts it, the middle of an ellipse or the points of a line: there the crest has not strayed
|
|
239
375
|
// (crestOffset), nor been pulled about or notched, which `pin` holds for each end of the limb [warp along x, along z, notch]
|
|
240
|
-
const mid =
|
|
241
|
-
pinAt = u => [
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
376
|
+
const mid = limbData.len / 2,
|
|
377
|
+
pinAt = u => [
|
|
378
|
+
warpAt(limbData, limbData.x + u * limbData.ax, limbData.z + u * limbData.az, 0),
|
|
379
|
+
warpAt(limbData, limbData.x + u * limbData.ax, limbData.z + u * limbData.az, 1),
|
|
380
|
+
notchAt(limbData, u),
|
|
381
|
+
];
|
|
382
|
+
limbData.pin = limbData.line ? [pinAt(0), pinAt(limbData.len)] : [pinAt(mid), pinAt(mid)];
|
|
383
|
+
if (!limbData.line) limbData.strayAt = vnoise(mid / limbData.wave + 7.3, 0, seed);
|
|
384
|
+
limbData.spurs = { 1: limbSpurs(limbData, 1), [-1]: limbSpurs(limbData, -1) };
|
|
385
|
+
return limbData;
|
|
246
386
|
}
|
|
247
387
|
|
|
248
388
|
const spurAt = { best: 0, next: 0, tau: 0, phase: 0, side: 0 }; // what spurNear found: the nearest spur's share and the next one's, how far along the nearest, its phase and which side of it
|
|
@@ -292,71 +432,82 @@ export function createMountainRanges(seed = 0) {
|
|
|
292
432
|
}
|
|
293
433
|
// Metres a limb's range raises the ground at (x, z), and the swell about its crest where it has no ellipse's (`smooth`: how
|
|
294
434
|
// far it is that swell).
|
|
295
|
-
function rangeHeight(
|
|
296
|
-
const px = x -
|
|
297
|
-
pz = z -
|
|
298
|
-
along = px *
|
|
299
|
-
if (along <
|
|
300
|
-
// a range's shape is pulled about, so that no crest, spur or foot is a ruled line; not at its summits (
|
|
301
|
-
const [from, to] =
|
|
302
|
-
held = clamp(along / (
|
|
303
|
-
dx = px +
|
|
304
|
-
dz = pz +
|
|
305
|
-
u = dx *
|
|
306
|
-
if (u < -TAIL_REACH *
|
|
307
|
-
const off = dz *
|
|
435
|
+
function rangeHeight(limbData, x, z, smooth) {
|
|
436
|
+
const px = x - limbData.x,
|
|
437
|
+
pz = z - limbData.z,
|
|
438
|
+
along = px * limbData.ax + pz * limbData.az;
|
|
439
|
+
if (along < limbData.from || along > limbData.to || Math.abs(pz * limbData.ax - px * limbData.az) > limbData.far) return 0; // before any noise is worked out
|
|
440
|
+
// a range's shape is pulled about, so that no crest, spur or foot is a ruled line; not at its summits (limbData.pin)
|
|
441
|
+
const [from, to] = limbData.pin,
|
|
442
|
+
held = clamp(along / (limbData.len || 1), 0, 1),
|
|
443
|
+
dx = px + limbData.warp * (warpAt(limbData, x, z, 0) - lerp(from[0], to[0], held)),
|
|
444
|
+
dz = pz + limbData.warp * (warpAt(limbData, x, z, 1) - lerp(from[1], to[1], held)),
|
|
445
|
+
u = dx * limbData.ax + dz * limbData.az;
|
|
446
|
+
if (u < -TAIL_REACH * limbData.tail0 || u > limbData.len + TAIL_REACH * limbData.tail1) return 0;
|
|
447
|
+
const off = dz * limbData.ax - dx * limbData.az - crestOffset(limbData, u),
|
|
308
448
|
side = off < 0 ? -1 : 1,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
crest =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
449
|
+
flankDistance = side * off,
|
|
450
|
+
crestFraction = crestShare(limbData, u),
|
|
451
|
+
crest =
|
|
452
|
+
limbData.h *
|
|
453
|
+
crestFraction *
|
|
454
|
+
knotShare(limbData, u) *
|
|
455
|
+
(1 + limbData.sharp * limbData.rough * NOTCH * (notchAt(limbData, u) - lerp(from[2], to[2], held))),
|
|
456
|
+
swell = smooth > 0 ? crest * Math.exp(-1.5 * (flankDistance / limbData.b) ** 2) : 0,
|
|
457
|
+
wide = flankWidth(limbData, crestFraction, side, u),
|
|
458
|
+
s = flankDistance / wide;
|
|
315
459
|
if (smooth >= 1 || s >= REACH) return swell * smooth;
|
|
316
|
-
spurNear(
|
|
317
|
-
const
|
|
318
|
-
scarp =
|
|
319
|
-
own = sstep(0, 0.25,
|
|
320
|
-
knobs = 1 - KNOB * own * vnoise(spurAt.tau /
|
|
321
|
-
floor = 1 - ((
|
|
460
|
+
spurNear(limbData.spurs[side][clamp(Math.floor((u - limbData.from) / limbData.step), 0, limbData.spurs[side].length - 1)], u, off);
|
|
461
|
+
const spurStrength = spurAt.best,
|
|
462
|
+
scarp = limbData.face ? (limbData.face === side ? 1 : -1) : 0,
|
|
463
|
+
own = sstep(0, 0.25, spurStrength - spurAt.next), // how far the place is one spur's alone: what is its own (its knobs, its gullies) fades out toward the next spur
|
|
464
|
+
knobs = 1 - KNOB * own * vnoise(spurAt.tau / limbData.step + 40 * spurAt.phase, 0, limbData.seed + 8),
|
|
465
|
+
floor = 1 - ((spurStrength * spurStrength) / (spurStrength + 0.15)) * 1.15 * knobs, // how far the place is a valley's floor: a spur's crest is a sharp line, the floor rounded
|
|
322
466
|
round = CREST_ROUND / wide,
|
|
323
|
-
bow = 1 + side * BOW *
|
|
467
|
+
bow = 1 + side * BOW * limbData.rough * leanAt(limbData, u, 10),
|
|
324
468
|
body = flankBody((Math.sqrt(s * s + round * round) - round) / (1 - EMBAYED * floor * sstep(0.1, 0.5, s)), scarp, bow),
|
|
325
|
-
deep =
|
|
326
|
-
sides =
|
|
327
|
-
gully = spurAt.tau /
|
|
469
|
+
deep = limbData.rough * CUT * sstep(0.02, 0.3, s) * (scarp < 0 ? 0.5 : 1),
|
|
470
|
+
sides = limbData.rough * RIB_CUT * own * (1 - spurStrength) * sstep(0.1, 0.35, s),
|
|
471
|
+
gully = spurAt.tau / limbData.rib + spurAt.phase + spurAt.side,
|
|
328
472
|
cut = (1 - deep * floor) * (1 - sides * Math.abs(2 * (gully - Math.floor(gully)) - 1)), // what the valleys and gullies leave of the flank
|
|
329
|
-
broken = body > 0 ? 1 +
|
|
330
|
-
stone = bedded(crest * (1 - APRON) * body * cut * broken, x, z, BEDS.hold *
|
|
473
|
+
broken = body > 0 ? 1 + limbData.rough * CRAG * sstep(0, 0.12, s) * (ridged(x * 0.009, z * 0.009, 4, 331) - 0.45) : 1,
|
|
474
|
+
stone = bedded(crest * (1 - APRON) * body * cut * broken, x, z, BEDS.hold * limbData.rough),
|
|
331
475
|
// the apron is banked highest where a valley comes out onto it, in a fan
|
|
332
|
-
apron = crest * APRON * Math.exp(-1.2 * s * s) * (1 + 0.5 *
|
|
476
|
+
apron = crest * APRON * Math.exp(-1.2 * s * s) * (1 + 0.5 * limbData.rough * (floor - 0.5) * sstep(0.6, 1, s)),
|
|
333
477
|
lies = sstep(2, 1.3, s) * Math.max(sstep(0.75, 1.05, s), 0.7 * floor * floor * sstep(0.3, 0.8, s)),
|
|
334
|
-
loose =
|
|
478
|
+
loose = limbData.sharp * sstep(8, 30, limbData.h * crestFraction) * lies;
|
|
335
479
|
if (loose > range.scree) range.scree = loose;
|
|
336
480
|
return lerp(stone + apron, swell, smooth);
|
|
337
481
|
}
|
|
338
482
|
// Metres a limb raises the ground at (x, z): its range, and where it is not broken enough to be one wholly, its swell.
|
|
339
|
-
function limbHeight(
|
|
340
|
-
if (!
|
|
341
|
-
return (
|
|
483
|
+
function limbHeight(limbData, x, z) {
|
|
484
|
+
if (!limbData.swell) return rangeHeight(limbData, x, z, 1 - limbData.sharp);
|
|
485
|
+
return (
|
|
486
|
+
(limbData.sharp < 1 ? (1 - limbData.sharp) * swellAt(limbData.swell, x, z) : 0) +
|
|
487
|
+
(limbData.sharp > 0 ? limbData.sharp * rangeHeight(limbData, x, z, 0) : 0)
|
|
488
|
+
);
|
|
342
489
|
}
|
|
343
490
|
// The higher of two limbs of one upland, rounded where they meet.
|
|
344
|
-
function joined(
|
|
345
|
-
const most = Math.max(
|
|
491
|
+
function joined(firstHeight, secondHeight) {
|
|
492
|
+
const most = Math.max(firstHeight, secondHeight),
|
|
346
493
|
k = 0.25 * most,
|
|
347
|
-
near = k > 0 ? Math.max(k - Math.abs(
|
|
494
|
+
near = k > 0 ? Math.max(k - Math.abs(firstHeight - secondHeight), 0) / k : 0;
|
|
348
495
|
return most + (near * near * k) / 4;
|
|
349
496
|
}
|
|
350
|
-
|
|
497
|
+
/**
|
|
498
|
+
* @param {number} x - World X in metres.
|
|
499
|
+
* @param {number} z - World Z in metres.
|
|
500
|
+
* @returns {number} Added elevation in metres. An empty layout contributes zero.
|
|
501
|
+
*/
|
|
351
502
|
function rangesAt(x, z) {
|
|
352
503
|
let h = 0;
|
|
353
504
|
range.scree = 0;
|
|
354
505
|
crag = -1;
|
|
355
506
|
for (let i = 0; i < uplands.length; i++) {
|
|
356
|
-
const
|
|
357
|
-
if (x <
|
|
507
|
+
const upland = uplands[i];
|
|
508
|
+
if (x < upland.x0 || x > upland.x1 || z < upland.z0 || z > upland.z1) continue;
|
|
358
509
|
let top = 0;
|
|
359
|
-
for (let j = 0; j <
|
|
510
|
+
for (let j = 0; j < upland.limbs.length; j++) top = joined(top, limbHeight(upland.limbs[j], x, z));
|
|
360
511
|
h += top;
|
|
361
512
|
}
|
|
362
513
|
return h;
|
|
@@ -371,12 +522,14 @@ export function createMountainRanges(seed = 0) {
|
|
|
371
522
|
box.z0 = Math.min(box.z0, z);
|
|
372
523
|
box.z1 = Math.max(box.z1, z);
|
|
373
524
|
};
|
|
374
|
-
for (const
|
|
375
|
-
for (const u of [
|
|
376
|
-
|
|
525
|
+
for (const limbData of limbs) {
|
|
526
|
+
for (const u of [limbData.from, limbData.to])
|
|
527
|
+
for (const v of [-limbData.far, limbData.far])
|
|
528
|
+
hold(limbData.x + u * limbData.ax - v * limbData.az, limbData.z + u * limbData.az + v * limbData.ax);
|
|
529
|
+
if (limbData.swell) {
|
|
377
530
|
const reach = Math.sqrt(SWELL_REACH + SWELL_WARP / 2);
|
|
378
|
-
hold(
|
|
379
|
-
hold(
|
|
531
|
+
hold(limbData.swell.x - reach * limbData.swell.rx, limbData.swell.z - reach * limbData.swell.rz);
|
|
532
|
+
hold(limbData.swell.x + reach * limbData.swell.rx, limbData.swell.z + reach * limbData.swell.rz);
|
|
380
533
|
}
|
|
381
534
|
}
|
|
382
535
|
return box;
|
|
@@ -385,15 +538,15 @@ export function createMountainRanges(seed = 0) {
|
|
|
385
538
|
const faceSide = (face, ax, az) => (face === undefined ? 0 : Math.cos(face) * -az + Math.sin(face) * ax < 0 ? -1 : 1);
|
|
386
539
|
// An upland given as an ellipse ({ x, z, rx, rz, h, rough }): one limb along its long axis. The more broken it is, the longer
|
|
387
540
|
// its crest holds its height before it falls away.
|
|
388
|
-
function ellipseLimb(
|
|
389
|
-
const [bearing,
|
|
390
|
-
held = HELD * sstep(RANGE_FROM[0], RANGE_FROM[1],
|
|
391
|
-
tail =
|
|
541
|
+
function ellipseLimb(landform, seed) {
|
|
542
|
+
const [bearing, halfLength, halfWidth] = ellipseAxis(landform),
|
|
543
|
+
held = HELD * sstep(RANGE_FROM[0], RANGE_FROM[1], landform.rough) * Math.max(halfLength - 0.5 * halfWidth, 0.2 * halfLength), // the half-length its crest holds its height over: little of a round one's
|
|
544
|
+
tail = halfLength - 0.95 * held,
|
|
392
545
|
ax = Math.cos(bearing),
|
|
393
546
|
az = Math.sin(bearing),
|
|
394
547
|
crest = {
|
|
395
|
-
x:
|
|
396
|
-
z:
|
|
548
|
+
x: landform.x - held * ax,
|
|
549
|
+
z: landform.z - held * az,
|
|
397
550
|
ax,
|
|
398
551
|
az,
|
|
399
552
|
len: 2 * held,
|
|
@@ -405,58 +558,79 @@ export function createMountainRanges(seed = 0) {
|
|
|
405
558
|
free1: true,
|
|
406
559
|
};
|
|
407
560
|
return limb(
|
|
408
|
-
{
|
|
561
|
+
{
|
|
562
|
+
...crest,
|
|
563
|
+
b: halfWidth,
|
|
564
|
+
h: landform.h,
|
|
565
|
+
rough: landform.rough,
|
|
566
|
+
face: faceSide(landform.face, ax, az),
|
|
567
|
+
line: false,
|
|
568
|
+
swell: landform.axis === undefined ? landform : null,
|
|
569
|
+
},
|
|
409
570
|
seed,
|
|
410
571
|
);
|
|
411
572
|
}
|
|
412
573
|
// An upland given as a line ({ crest: [[x, z, share of h], ...], wide, h, rough }): a limb to each stretch, each running on a
|
|
413
574
|
// little past the point where the next begins.
|
|
414
|
-
function lineLimbs(
|
|
575
|
+
function lineLimbs(landform, seed) {
|
|
415
576
|
const limbs = [],
|
|
416
|
-
tail = end =>
|
|
417
|
-
for (let i = 0; i + 1 <
|
|
418
|
-
const [x, z, k0] =
|
|
419
|
-
[x1, z1, k1] =
|
|
577
|
+
tail = end => landform.wide * (end ? 0.65 : 0.7);
|
|
578
|
+
for (let i = 0; i + 1 < landform.crest.length; i++) {
|
|
579
|
+
const [x, z, k0] = landform.crest[i],
|
|
580
|
+
[x1, z1, k1] = landform.crest[i + 1],
|
|
420
581
|
len = Math.hypot(x1 - x, z1 - z),
|
|
421
582
|
ax = (x1 - x) / len,
|
|
422
583
|
az = (z1 - z) / len,
|
|
423
584
|
first = i === 0,
|
|
424
|
-
last = i + 2 ===
|
|
585
|
+
last = i + 2 === landform.crest.length,
|
|
425
586
|
crest = { x, z, ax, az, len, tail0: tail(first), tail1: tail(last), k0, k1, free0: first, free1: last };
|
|
426
587
|
limbs.push(
|
|
427
|
-
limb(
|
|
588
|
+
limb(
|
|
589
|
+
{
|
|
590
|
+
...crest,
|
|
591
|
+
b: landform.wide,
|
|
592
|
+
h: landform.h,
|
|
593
|
+
rough: landform.rough,
|
|
594
|
+
face: faceSide(landform.face, ax, az),
|
|
595
|
+
line: true,
|
|
596
|
+
swell: null,
|
|
597
|
+
},
|
|
598
|
+
seed + i * 3,
|
|
599
|
+
),
|
|
428
600
|
);
|
|
429
601
|
}
|
|
430
602
|
return limbs;
|
|
431
603
|
}
|
|
432
604
|
// A field of hills ({ x, z, rx, rz, h, rough, hills: how many }): small ranges scattered over its ellipse, their crests near one
|
|
433
605
|
// strike (`axis`, or the ellipse's long axis), on a low swell.
|
|
434
|
-
function hillField(
|
|
435
|
-
const [strike, , lesser] = ellipseAxis(
|
|
606
|
+
function hillField(landform, seed) {
|
|
607
|
+
const [strike, , lesser] = ellipseAxis(landform),
|
|
436
608
|
r = (i, n) => hash2(i, n, seed + 2),
|
|
437
|
-
out = [boxed([ellipseLimb({ ...
|
|
438
|
-
for (let i = 0; i <
|
|
439
|
-
const far = 0.85 * Math.sqrt((i + 0.5) /
|
|
609
|
+
out = [boxed([ellipseLimb({ ...landform, h: landform.h * HILL.base, rough: 0, axis: undefined }, seed)])];
|
|
610
|
+
for (let i = 0; i < landform.hills; i++) {
|
|
611
|
+
const far = 0.85 * Math.sqrt((i + 0.5) / landform.hills),
|
|
440
612
|
round = i * 2.39996 + r(i, 1), // the golden angle from one to the next, so they fill the ellipse evenly
|
|
441
613
|
long = lesser * lerp(HILL.long[0], HILL.long[1], r(i, 2)),
|
|
442
614
|
hill = {
|
|
443
|
-
x:
|
|
444
|
-
z:
|
|
615
|
+
x: landform.x + landform.rx * far * Math.cos(round),
|
|
616
|
+
z: landform.z + landform.rz * far * Math.sin(round),
|
|
445
617
|
rx: long,
|
|
446
618
|
rz: long * lerp(HILL.wide[0], HILL.wide[1], r(i, 3)),
|
|
447
|
-
h:
|
|
448
|
-
rough:
|
|
619
|
+
h: landform.h * lerp(HILL.high[0], HILL.high[1], r(i, 4)) * (1 - 0.4 * far * far),
|
|
620
|
+
rough: landform.rough,
|
|
449
621
|
axis: strike + (r(i, 5) - 0.5) * HILL.turn,
|
|
450
622
|
};
|
|
451
623
|
out.push(boxed([ellipseLimb(hill, seed + 10 + i * 3)]));
|
|
452
624
|
}
|
|
453
625
|
return out;
|
|
454
626
|
}
|
|
455
|
-
|
|
627
|
+
/** @param {(EllipticalUpland | Ridge)[]} list - Landforms in stable seed order. */
|
|
456
628
|
function layOutRanges(list) {
|
|
457
|
-
uplands = list.flatMap((
|
|
629
|
+
uplands = list.flatMap((landform, i) => {
|
|
458
630
|
const seed = 400 + i * 41;
|
|
459
|
-
return
|
|
631
|
+
return landform.hills
|
|
632
|
+
? hillField(landform, seed)
|
|
633
|
+
: [boxed(landform.crest ? lineLimbs(landform, seed) : [ellipseLimb(landform, seed)])];
|
|
460
634
|
});
|
|
461
635
|
}
|
|
462
636
|
return { layout: layOutRanges, heightAt: rangesAt, surface: range };
|