roamwright 0.20.1 → 0.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +19 -14
- package/README.md +35 -16
- package/examples/animals.html +49 -0
- package/examples/animals.js +209 -0
- package/examples/crowds.html +50 -0
- package/examples/crowds.js +268 -0
- package/examples/effects.html +53 -0
- package/examples/effects.js +343 -0
- package/examples/figure-motion.html +55 -0
- package/examples/figure-motion.js +265 -0
- package/examples/figure.html +49 -0
- package/examples/figure.js +238 -0
- package/examples/fliers.html +53 -0
- package/examples/fliers.js +292 -0
- package/examples/fortification.html +54 -0
- package/examples/fortification.js +288 -0
- package/examples/house-kit.html +48 -0
- package/examples/house-kit.js +175 -0
- package/examples/index.html +26 -16
- package/examples/island.html +48 -0
- package/examples/island.js +134 -52
- package/examples/land.html +54 -0
- package/examples/land.js +392 -0
- package/examples/props-and-plants.html +53 -0
- package/examples/props-and-plants.js +275 -0
- package/examples/rooms.html +48 -0
- package/examples/rooms.js +242 -0
- package/examples/ships.html +51 -0
- package/examples/ships.js +235 -0
- package/examples/showcase.css +320 -0
- package/examples/small-world-land.js +151 -0
- package/examples/small-world-life.js +160 -0
- package/examples/small-world-town.js +127 -0
- package/examples/small-world.html +57 -0
- package/examples/small-world.js +226 -0
- package/examples/soundscape.html +138 -0
- package/examples/soundscape.js +467 -0
- package/examples/stage-kits.js +300 -0
- package/examples/stage.js +374 -0
- package/examples/towns.html +50 -0
- package/examples/towns.js +325 -0
- package/examples/viaduct-camera.js +8 -4
- package/examples/viaduct-landscape.js +28 -17
- package/examples/viaduct.html +45 -43
- package/examples/viaduct.js +68 -92
- package/geometry/animal-camel-body.js +410 -0
- package/geometry/animal-camel-head.js +118 -0
- package/geometry/animal-canine-body.js +361 -0
- package/geometry/animal-canine-breeds.js +316 -0
- package/geometry/animal-canine-head.js +337 -0
- package/geometry/animal-cattle-body.js +391 -0
- package/geometry/animal-cattle-coat.js +42 -0
- package/geometry/animal-cattle-head.js +152 -0
- package/geometry/animal-hen.js +248 -0
- package/geometry/animal-horse-body.js +446 -0
- package/geometry/animal-horse-bridle.js +171 -0
- package/geometry/animal-horse-coat.js +68 -0
- package/geometry/animal-horse-face.js +162 -0
- package/geometry/animal-horse-hair.js +304 -0
- package/geometry/animal-horse-head.js +133 -0
- package/geometry/animal-horse-tack.js +157 -0
- package/geometry/animal-options.js +59 -0
- package/geometry/animal-shapes.js +21 -0
- package/geometry/animal-skin.js +390 -0
- package/geometry/builder-cells.js +10 -2
- package/geometry/builder-frame.js +2 -1
- package/geometry/builder.js +15 -4
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +7 -2
- package/geometry/crowd-dress.js +315 -0
- package/geometry/crowd-far.js +174 -0
- package/geometry/crowd-look.js +42 -0
- package/geometry/crowd-weld.js +218 -0
- package/geometry/ear.js +9 -4
- package/geometry/erosion.js +7 -4
- package/geometry/face-grid.js +26 -6
- package/geometry/field-map.js +59 -0
- package/geometry/figure-arms.js +339 -0
- package/geometry/figure-beard.js +250 -0
- package/geometry/figure-body.js +297 -0
- package/geometry/figure-bow.js +105 -0
- package/geometry/figure-cloak.js +189 -0
- package/geometry/figure-clothes.js +337 -0
- package/geometry/figure-face-grids.js +75 -0
- package/geometry/figure-gear.js +446 -0
- package/geometry/figure-hair-far.js +151 -0
- package/geometry/figure-hair-hangs.js +108 -0
- package/geometry/figure-hair-patch.js +66 -0
- package/geometry/figure-hair.js +320 -0
- package/geometry/figure-hands.js +321 -0
- package/geometry/figure-head-features.js +280 -0
- package/geometry/figure-head.js +375 -0
- package/geometry/figure-headwear.js +223 -0
- package/geometry/figure-legs.js +231 -0
- package/geometry/figure-limbs.js +39 -0
- package/geometry/figure-sculpt.js +82 -0
- package/geometry/figure-skin.js +97 -0
- package/geometry/figure-skirts.js +303 -0
- package/geometry/figure-trunk.js +411 -0
- package/geometry/flier-corvid-body.js +322 -0
- package/geometry/flier-corvid-wings.js +154 -0
- package/geometry/flier-long-body.js +195 -0
- package/geometry/flier-shapes.js +219 -0
- package/geometry/flier-soaring-bird.js +84 -0
- package/geometry/foliage.js +177 -4
- package/geometry/fort-city-walls.js +479 -0
- package/geometry/fort-gate-approach.js +233 -0
- package/geometry/fort-great-walls.js +280 -0
- package/geometry/fort-keep.js +297 -0
- package/geometry/fort-parts.js +261 -0
- package/geometry/fort-polyline.js +261 -0
- package/geometry/fort-portal.js +96 -0
- package/geometry/fort-ring-wall.js +267 -0
- package/geometry/fort-seawall.js +104 -0
- package/geometry/fort-terrace-gates.js +323 -0
- package/geometry/fort-terrace-plan.js +250 -0
- package/geometry/fort-terrace-wall.js +345 -0
- package/geometry/garment-tags.js +11 -3
- package/geometry/grid-gather.js +69 -0
- package/geometry/grid-sample.js +185 -0
- package/geometry/hair-gathers.js +19 -4
- package/geometry/hair-locks.js +1 -1
- package/geometry/hair-patch.js +6 -2
- package/geometry/hair-shell.js +14 -2
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +13 -2
- package/geometry/head-shape.js +51 -23
- package/geometry/heightfield.js +26 -9
- package/geometry/horizon-angles.js +166 -0
- package/geometry/house-kit-body.js +195 -0
- package/geometry/house-kit-courtyard-parts.js +340 -0
- package/geometry/house-kit-courtyard-roof.js +223 -0
- package/geometry/house-kit-courtyard.js +409 -0
- package/geometry/house-kit-cut.js +29 -0
- package/geometry/house-kit-extras.js +192 -0
- package/geometry/house-kit-forms.js +298 -0
- package/geometry/house-kit-frame.js +74 -0
- package/geometry/house-kit-marks.js +93 -0
- package/geometry/house-kit-openings.js +193 -0
- package/geometry/house-kit-palette.js +54 -0
- package/geometry/house-kit-pool.js +71 -0
- package/geometry/house-kit-roofs.js +151 -0
- package/geometry/house-kit.js +202 -0
- package/geometry/instances.js +4 -4
- package/geometry/lamp-wash.js +65 -0
- package/geometry/land-clearings.js +83 -0
- package/geometry/land-ditches.js +290 -0
- package/geometry/land-dry-basin.js +327 -0
- package/geometry/land-dunes.js +150 -0
- package/geometry/land-earthworks.js +432 -0
- package/geometry/land-edge.js +292 -0
- package/geometry/land-mound-faces.js +349 -0
- package/geometry/land-near-relief.js +102 -0
- package/geometry/land-sheet.js +220 -0
- package/geometry/land-town-ground.js +256 -0
- package/geometry/land-waters.js +228 -0
- package/geometry/land-wildness.js +123 -0
- package/geometry/lathed-vessel.js +293 -0
- package/geometry/outline-grid.js +5 -4
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +35 -0
- package/geometry/path-field.js +35 -1
- package/geometry/planked-floor.js +149 -0
- package/geometry/plant-broadleaf.js +268 -0
- package/geometry/plant-shrub.js +198 -0
- package/geometry/plant-tints.js +80 -0
- package/geometry/plant-trees.js +453 -0
- package/geometry/plant-tussock.js +107 -0
- package/geometry/primitives.js +65 -23
- package/geometry/prop-battlefield.js +69 -0
- package/geometry/prop-camp.js +175 -0
- package/geometry/prop-door.js +26 -0
- package/geometry/prop-harbour.js +105 -0
- package/geometry/prop-haycock.js +60 -0
- package/geometry/prop-sacks.js +74 -0
- package/geometry/prop-sheaf.js +68 -0
- package/geometry/prop-street.js +69 -0
- package/geometry/prop-tents.js +396 -0
- package/geometry/prop-tombs.js +80 -0
- package/geometry/prop-trade.js +393 -0
- package/geometry/prop-vehicles.js +218 -0
- package/geometry/props.js +58 -0
- package/geometry/room-arcade.js +134 -0
- package/geometry/room-dome.js +188 -0
- package/geometry/room-flames.js +138 -0
- package/geometry/room-frame.js +106 -0
- package/geometry/room-furniture.js +260 -0
- package/geometry/room-hearth.js +98 -0
- package/geometry/room-kit.js +59 -0
- package/geometry/room-openings.js +142 -0
- package/geometry/room-stairs.js +180 -0
- package/geometry/room-surfaces.js +272 -0
- package/geometry/sampled-surface.js +24 -10
- package/geometry/scatter-grid.js +6 -3
- package/geometry/sculpt.js +5 -1
- package/geometry/ship-fittings.js +350 -0
- package/geometry/ship-hull.js +460 -0
- package/geometry/ship-kit.js +208 -0
- package/geometry/ship-lines.js +69 -0
- package/geometry/ship-oars.js +150 -0
- package/geometry/ship-presets.js +131 -0
- package/geometry/ship-rig.js +374 -0
- package/geometry/ship-sails.js +148 -0
- package/geometry/shore-grid.js +5 -1
- package/geometry/strata-field.js +44 -11
- package/geometry/strata-tiles.js +20 -6
- package/geometry/stream.js +32 -17
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +139 -51
- package/geometry/terrain-extension.js +24 -8
- package/geometry/town-courtyard-inn.js +272 -0
- package/geometry/town-ground.js +76 -0
- package/geometry/town-houses.js +343 -0
- package/geometry/town-lights.js +254 -0
- package/geometry/town-lots.js +172 -0
- package/geometry/town-plan.js +370 -0
- package/geometry/town-works.js +465 -0
- package/geometry/village-layout.js +181 -0
- package/geometry/village-yards.js +167 -0
- package/geometry/wall-runs.js +64 -0
- package/index.js +139 -3
- package/math/cloud-textures.js +3 -7
- package/math/curve.js +5 -1
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +177 -54
- package/math/periodic.js +6 -0
- package/math/rectangles.js +8 -2
- package/math/rock-texture.js +17 -12
- package/math/surface-textures.js +24 -9
- package/math/wandering-path.js +40 -0
- package/math/ways.js +120 -0
- package/motion/action-dynamics.js +398 -0
- package/motion/animal-bearing.js +247 -0
- package/motion/animal-canine-bearing.js +178 -0
- package/motion/animal-canine-cast.js +131 -0
- package/motion/animal-cattle-cast.js +64 -0
- package/motion/animal-herd-cast.js +154 -0
- package/motion/animal-horse-still.js +161 -0
- package/motion/animal-troop-cast.js +43 -0
- package/motion/arm-reach.js +3 -2
- package/motion/ballistic-arc.js +182 -2
- package/motion/biped-cycle.js +4 -2
- package/motion/biped-leg.js +4 -1
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +142 -32
- package/motion/boat-sailing.js +214 -0
- package/motion/cast-actors.js +379 -0
- package/motion/cast-manager.js +321 -0
- package/motion/contact-transition.js +5 -6
- package/motion/crowd-alarms.js +36 -6
- package/motion/crowd-attention.js +108 -0
- package/motion/crowd-beasts.js +203 -0
- package/motion/crowd-camp.js +295 -0
- package/motion/crowd-figure.js +100 -0
- package/motion/crowd-herd.js +86 -0
- package/motion/crowd-hold.js +130 -0
- package/motion/crowd-pose.js +296 -0
- package/motion/crowd-poses.js +481 -0
- package/motion/crowd-routine.js +44 -14
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/deck-surface.js +4 -2
- package/motion/figure-acts.js +411 -0
- package/motion/figure-arms.js +437 -0
- package/motion/figure-blade-slide.js +149 -0
- package/motion/figure-body-place.js +180 -0
- package/motion/figure-bones.js +118 -0
- package/motion/figure-bow-draw.js +70 -0
- package/motion/figure-fingers.js +215 -0
- package/motion/figure-gaze.js +205 -0
- package/motion/figure-gestures.js +452 -0
- package/motion/figure-grip.js +134 -0
- package/motion/figure-head.js +287 -0
- package/motion/figure-legs.js +264 -0
- package/motion/figure-links.js +293 -0
- package/motion/figure-locomotion.js +391 -0
- package/motion/figure-mount-up.js +180 -0
- package/motion/figure-mount.js +201 -0
- package/motion/figure-pose-frame.js +375 -0
- package/motion/figure-pose-table.js +156 -0
- package/motion/figure-pose.js +343 -0
- package/motion/figure-seat.js +267 -0
- package/motion/figure-sway.js +125 -0
- package/motion/flier-corvid-pose.js +74 -0
- package/motion/flier-flight-air.js +122 -0
- package/motion/flier-flight-echelon.js +164 -0
- package/motion/flier-flight-roost.js +131 -0
- package/motion/flier-swarm-flight.js +252 -0
- package/motion/formation.js +193 -0
- package/motion/instance-sight.js +8 -1
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +7 -6
- package/motion/quadruped.js +109 -33
- package/motion/spaces.js +58 -6
- package/motion/speech-cadence.js +304 -0
- package/motion/vessel-motion.js +57 -0
- package/motion/walk-grid.js +235 -0
- package/motion/weather.js +70 -12
- package/motion/wind.js +27 -1
- package/package.json +46 -4
- package/rendering/alpha-mips.js +340 -0
- package/rendering/animal-camel-figure.js +29 -0
- package/rendering/animal-canine-figure.js +59 -0
- package/rendering/animal-cattle-figure.js +36 -0
- package/rendering/animal-horse-figure.js +49 -0
- package/rendering/atmosphere.js +86 -0
- package/rendering/camera-track.js +156 -0
- package/rendering/{road-surface.js → cart-track.js} +40 -11
- package/rendering/cast-stage.js +299 -0
- package/rendering/caster-motion.js +2 -1
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +665 -80
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +2 -2
- package/rendering/compilation-schedule.js +18 -10
- package/rendering/contact-shadows.js +5 -2
- package/rendering/context.js +47 -8
- package/rendering/crowd-batches.js +420 -0
- package/rendering/crowd-herd.js +198 -0
- package/rendering/crowd-rig.js +132 -0
- package/rendering/crowd-skinning.js +52 -9
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +1 -3
- package/rendering/detail-range.js +6 -5
- package/rendering/dof.js +11 -4
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +81 -54
- package/rendering/field-surface.js +138 -0
- package/rendering/figure-shield.js +105 -0
- package/rendering/figure-skeleton.js +329 -0
- package/rendering/fire-light-watch.js +197 -0
- package/rendering/fire-pools.js +148 -0
- package/rendering/flame-sources.js +86 -0
- package/rendering/flier-bird-looks.js +97 -0
- package/rendering/flier-corvid-figure.js +67 -0
- package/rendering/flier-long-body-company.js +169 -0
- package/rendering/flier-swarm.js +186 -0
- package/rendering/flocks.js +6 -2
- package/rendering/garment-material.js +145 -49
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +38 -24
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +15 -3
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +13 -3
- package/rendering/label-range.js +5 -2
- package/rendering/lamp-light-map.js +159 -0
- package/rendering/lamp-maps.js +62 -0
- package/rendering/lamp-wash.js +51 -0
- package/rendering/light-budget.js +19 -3
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +27 -7
- package/rendering/material-lod.js +5 -6
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/nameplate-groups.js +84 -0
- package/rendering/nameplates.js +386 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +61 -25
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +134 -34
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +282 -6
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +780 -77
- package/rendering/plant-cells.js +122 -0
- package/rendering/plant-reeds.js +113 -0
- package/rendering/plant-shade-trees.js +239 -0
- package/rendering/plant-tuft-patch.js +122 -0
- package/rendering/post-shaders.js +84 -21
- package/rendering/post.js +39 -19
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/room-light.js +250 -0
- package/rendering/room-materials.js +78 -0
- package/rendering/room-space.js +111 -0
- package/rendering/scene-lights.js +106 -0
- package/rendering/sea-shaders.js +83 -26
- package/rendering/settlement-approach.js +226 -0
- package/rendering/settlement-dissolve.js +89 -0
- package/rendering/settlement-quarter-warm.js +55 -0
- package/rendering/settlement-quarter.js +477 -0
- package/rendering/settlement-switch.js +42 -0
- package/rendering/settlement-town.js +110 -0
- package/rendering/shader-warmup.js +80 -36
- package/rendering/shadow-depth.js +40 -18
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +42 -15
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +112 -50
- package/rendering/smoke-shadows.js +201 -0
- package/rendering/stage-framing.js +182 -0
- package/rendering/stage-lights.js +46 -39
- package/rendering/stain-material.js +74 -0
- package/rendering/static-point-shadow.js +62 -23
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +2 -2
- package/rendering/street-lamps.js +166 -0
- package/rendering/sunbeam-motes.js +670 -0
- package/rendering/surface-light.js +65 -6
- package/rendering/surface-material.js +306 -0
- package/rendering/surface-projection.js +32 -0
- package/rendering/surface-snippets.js +314 -0
- package/rendering/taa.js +49 -18
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/water-material.js +270 -82
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +0 -2
- package/ruff.toml +20 -0
- package/runtime/cue-cursor.js +21 -0
- package/runtime/device-quality.js +13 -2
- package/runtime/device.js +73 -0
- package/runtime/diagnostic-log.js +11 -3
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +8 -5
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +18 -4
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +8 -4
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +5 -5
- package/runtime/hand-over.js +7 -2
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +17 -3
- package/runtime/quality-fit.js +59 -27
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +6 -2
- package/runtime/settlement-reach.js +42 -0
- package/runtime/sound-calls.js +113 -0
- package/runtime/sound-impacts.js +297 -0
- package/runtime/sound-voices.js +194 -0
- package/runtime/soundscape.js +282 -0
- package/runtime/spatial-audio.js +69 -20
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +19 -8
- package/scripts/app-parts.mjs +118 -0
- package/scripts/bake-revisions.mjs +81 -0
- package/scripts/browser-scripts.mjs +64 -0
- package/scripts/bundle.mjs +192 -0
- package/scripts/check-app.sh +26 -0
- package/scripts/eslint-config.mjs +119 -0
- package/scripts/format.sh +92 -0
- package/scripts/keep-builds.mjs +158 -0
- package/scripts/layers.mjs +112 -0
- package/scripts/lint.sh +49 -0
- package/scripts/module-graph.mjs +123 -0
- package/scripts/pre-commit.sh +38 -0
- package/scripts/serve.py +5 -3
- package/scripts/site.mjs +358 -0
- package/scripts/test-runner.sh +42 -0
- package/scripts/vendor.mjs +221 -0
- package/scripts/verify-publish.mjs +175 -0
- package/scripts/world.mk +59 -0
- package/tools/README.md +73 -0
- package/tools/contact-sheet.cjs +137 -0
- package/tools/cpu-profile.cjs +275 -0
- package/tools/cpu-profile.test.cjs +98 -0
- package/tools/first-draws.cjs +395 -0
- package/tools/flight-guard.cjs +482 -0
- package/tools/flight-guard.test.cjs +153 -0
- package/tools/flight-profile.cjs +145 -0
- package/tools/frame-bench.cjs +336 -0
- package/tools/frame-parts.cjs +365 -0
- package/tools/ios-sim.sh +145 -0
- package/tools/load-audit.cjs +201 -0
- package/tools/look-compare.cjs +304 -0
- package/tools/look-guard.cjs +407 -0
- package/tools/look-guard.test.cjs +93 -0
- package/tools/look-stats.cjs +185 -0
- package/tools/look-stats.test.cjs +71 -0
- package/tools/memory-audit.cjs +323 -0
- package/tools/page-driver.cjs +320 -0
- package/tools/page-driver.test.cjs +219 -0
- package/tools/program-census-report.cjs +191 -0
- package/tools/program-census.cjs +465 -0
- package/tools/program-census.test.cjs +332 -0
- package/tools/remote-runner.sh +265 -0
- package/tools/runners.test.cjs +59 -0
- package/tools/scene-audit-beat.cjs +344 -0
- package/tools/scene-audit-sheet.cjs +282 -0
- package/tools/scene-audit.cjs +471 -0
- package/tools/scene-audit.test.cjs +201 -0
- package/tools/scene-batch.cjs +219 -0
- package/tools/scene-bench.cjs +149 -0
- package/tools/scene-bench.test.cjs +33 -0
- package/tools/scene-run.cjs +443 -0
- package/tools/scene-run.test.cjs +94 -0
- package/tools/servers.sh +59 -0
- package/tools/shader-arrival.cjs +316 -0
- package/tools/shader-renewal.cjs +53 -0
- package/tools/shader-renewal.test.cjs +115 -0
- package/tools/speed-guard.cjs +258 -0
- package/tools/stills.cjs +492 -0
- package/tools/stills.test.cjs +49 -0
- package/tools/turns.sh +7 -0
- package/tools/yaml.cjs +158 -0
- package/examples/viaduct.css +0 -75
- package/rendering/light-shafts.js +0 -131
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planned-town street furniture and civic works: pointed-arch street arcades, planter-lined boulevards, rectangular and
|
|
3
|
+
* circular market squares with fountains, wells, benches and worn paving stones, covered market lanes with sagging
|
|
4
|
+
* striped awnings and stalls/chests, house-courtyard palms and pools, level and sloped walkable decks, and instanced
|
|
5
|
+
* grove placement matrices. Worker-safe.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { dim } from '../math/color.js';
|
|
10
|
+
import { pickR as defaultPick } from '../math/random.js';
|
|
11
|
+
import { TAU } from '../math/scalar.js';
|
|
12
|
+
import { C as defaultColor, createUnitShapes, TRS as defaultTransform } from './primitives.js';
|
|
13
|
+
import { addRampDeck } from './fort-parts.js';
|
|
14
|
+
import { createHouseKit } from './house-kit.js';
|
|
15
|
+
import { HOUSE, STREET } from './town-plan.js';
|
|
16
|
+
|
|
17
|
+
/** Standard arcade bay width, pier-to-pier, in metres. */
|
|
18
|
+
export const ARCADE_BAY = 3.4;
|
|
19
|
+
/** Standard arcade covered walkway depth in metres. */
|
|
20
|
+
export const ARCADE_WALK = 2.8;
|
|
21
|
+
|
|
22
|
+
const PIER = 0.6;
|
|
23
|
+
const PIER_H = 2.35; // arch springing height above walkway, metres
|
|
24
|
+
const POINT = 0.3; // pointed-arch crown lift ratio
|
|
25
|
+
const PALM_STEP = 13; // tree spacing down planted avenues, metres
|
|
26
|
+
const SOUK_STEP = 4.4; // stall spacing along covered market lanes, metres
|
|
27
|
+
const AWNING_STEP = 6.2; // overhead awning spacing along covered market lanes, metres
|
|
28
|
+
|
|
29
|
+
const DEFAULT_PALETTE = {
|
|
30
|
+
fired: [0x9a6a4a, 0x8e5f42, 0xa5765a],
|
|
31
|
+
timber: [0x5a4632, 0x4a3828, 0x6a5238],
|
|
32
|
+
awning: [0xb04a32, 0x2f6a7a, 0xc9a24a, 0xd8cfb8],
|
|
33
|
+
clay: [0xa0603c, 0xb07048, 0x8f5636],
|
|
34
|
+
dressed: [0xd9cfb4, 0xcfc4a8, 0xe2d9c2],
|
|
35
|
+
water: 0x2a6f78,
|
|
36
|
+
};
|
|
37
|
+
const DEFAULT_ARCADE_RENDER = [0xebe3d0, 0xe4d9c0, 0xf0e9da];
|
|
38
|
+
|
|
39
|
+
const noop = () => {};
|
|
40
|
+
/** Default no-op street and courtyard prop builders. */
|
|
41
|
+
export const DEFAULT_TOWN_PROPS = { bench: noop, crates: noop, goods: noop, stall: noop, trough: noop, well: noop };
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Places a kit prop at `(u, v)` in a town's local frame, rotated by `ry` relative to the town's yaw.
|
|
45
|
+
* @param {Function} kitAt - House-kit `kitAt` placer.
|
|
46
|
+
* @param {object} K - Town fortification/layout kit (`{ kit, f, Y }`).
|
|
47
|
+
* @param {() => number} rng - Seeded random generator.
|
|
48
|
+
* @param {number} u - Town-frame U coordinate in metres.
|
|
49
|
+
* @param {number} v - Town-frame V coordinate in metres.
|
|
50
|
+
* @param {number} ry - Local yaw rotation in radians.
|
|
51
|
+
* @param {Function} prop - Prop builder callback `(kit, rng) => void`.
|
|
52
|
+
* @param {number} [y] - Elevation in metres (defaults to `K.Y(u, v)`).
|
|
53
|
+
* @returns {void}
|
|
54
|
+
*/
|
|
55
|
+
export function placeInTown(kitAt, K, rng, u, v, ry, prop, y = K.Y(u, v)) {
|
|
56
|
+
const [x, z] = K.f.world(u, v);
|
|
57
|
+
kitAt(K.kit, x, y, z, K.f.yaw + ry, false, prop, rng);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns a prop's yaw rotation in a town frame so its local front (`+z`) faces direction `(mu, mv)`.
|
|
62
|
+
* @param {number} mu - Town-frame U direction component.
|
|
63
|
+
* @param {number} mv - Town-frame V direction component.
|
|
64
|
+
* @returns {number} Yaw angle in radians.
|
|
65
|
+
*/
|
|
66
|
+
export function townFacing(mu, mv) {
|
|
67
|
+
return Math.atan2(mu, -mv);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Creates a planned-town civic works and street furniture builder bound to unit shapes, house-kit primitives, prop
|
|
72
|
+
* builders, and palettes.
|
|
73
|
+
* @param {object} [options] - Geometry, prop and palette bindings.
|
|
74
|
+
* @param {object} [options.shapes] - Unit shapes (`{ cyl16, cyl6, taper, sph, box }`).
|
|
75
|
+
* @param {(hex: number, jitter?: number, rng?: () => number) => number[]} [options.color] - Linear RGB colour helper.
|
|
76
|
+
* @param {Function} [options.transform] - Transform matrix helper (`TRS`).
|
|
77
|
+
* @param {(rng: () => number, list: Array<any>) => any} [options.pick] - Seeded array picker.
|
|
78
|
+
* @param {Function} [options.archOpening] - House-kit `archOpening` builder.
|
|
79
|
+
* @param {Function} [options.facePut] - House-kit `facePut` helper.
|
|
80
|
+
* @param {Function} [options.waterJar] - House-kit `waterJar` builder.
|
|
81
|
+
* @param {Function} [options.kitAt] - House-kit `kitAt` placer `(kit, x, y, z, yaw, flip, prop, rng)`.
|
|
82
|
+
* @param {object} [options.props] - Street prop builders `{ bench, crates, goods, stall, trough, well }`.
|
|
83
|
+
* @param {object} [options.palette] - Shared palettes `{ fired, timber, awning, clay, dressed, water }`.
|
|
84
|
+
* @param {number[]} [options.arcadeRender] - sRGB hex plaster palette for street arcades.
|
|
85
|
+
* @param {string} [options.groveOrderKey='palms'] - Order key pushed into `K.orders` by `palmGrove`.
|
|
86
|
+
* @returns {{
|
|
87
|
+
* BAY: number,
|
|
88
|
+
* WALK: number,
|
|
89
|
+
* facing: typeof townFacing,
|
|
90
|
+
* arcadeBay: Function,
|
|
91
|
+
* arcades: Function,
|
|
92
|
+
* streetPalms: Function,
|
|
93
|
+
* fountain: Function,
|
|
94
|
+
* squares: Function,
|
|
95
|
+
* roundSquare: Function,
|
|
96
|
+
* carvedChest: Function,
|
|
97
|
+
* soukAwning: Function,
|
|
98
|
+
* souk: Function,
|
|
99
|
+
* courtyards: Function,
|
|
100
|
+
* levelFloor: Function,
|
|
101
|
+
* rampFloor: Function,
|
|
102
|
+
* palmGrove: Function,
|
|
103
|
+
* townWorks: Function,
|
|
104
|
+
* }}
|
|
105
|
+
*/
|
|
106
|
+
export function createTownWorks(options = {}) {
|
|
107
|
+
const shapes = options.shapes ?? createUnitShapes();
|
|
108
|
+
const color = options.color ?? defaultColor;
|
|
109
|
+
const transform = options.transform ?? defaultTransform;
|
|
110
|
+
const pick = options.pick ?? defaultPick;
|
|
111
|
+
let fallback = null;
|
|
112
|
+
const kitFallback = () => (fallback ??= createHouseKit({ shapes }));
|
|
113
|
+
const archOpening = options.archOpening ?? kitFallback().archOpening;
|
|
114
|
+
const facePut = options.facePut ?? kitFallback().facePut;
|
|
115
|
+
const waterJar = options.waterJar ?? kitFallback().waterJar;
|
|
116
|
+
const kitAt = options.kitAt ?? kitFallback().kitAt;
|
|
117
|
+
const props = { ...DEFAULT_TOWN_PROPS, ...options.props };
|
|
118
|
+
const palette = { ...DEFAULT_PALETTE, ...options.palette };
|
|
119
|
+
const arcadeRender = options.arcadeRender ?? DEFAULT_ARCADE_RENDER;
|
|
120
|
+
const groveOrderKey = options.groveOrderKey ?? 'palms';
|
|
121
|
+
|
|
122
|
+
const front = facePut(0, 0, 0);
|
|
123
|
+
const setDown = (K, rng, u, v, ry, prop, y) => placeInTown(kitAt, K, rng, u, v, ry, prop, y);
|
|
124
|
+
|
|
125
|
+
function streetLegs(plan, filter) {
|
|
126
|
+
const legs = [];
|
|
127
|
+
for (const s of plan.town.streets) {
|
|
128
|
+
if (!filter(s)) continue;
|
|
129
|
+
for (let i = 0; i + 1 < s.pts.length; i++) {
|
|
130
|
+
const [u0, v0] = s.pts[i];
|
|
131
|
+
const [u1, v1] = s.pts[i + 1];
|
|
132
|
+
const len = Math.hypot(u1 - u0, v1 - v0);
|
|
133
|
+
legs.push({ s, u0, v0, len, du: (u1 - u0) / len, dv: (v1 - v0) / len });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return legs;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function arcadeBay(kit, rng, col, timber, closing) {
|
|
140
|
+
const r = ARCADE_BAY / 2 - PIER / 2;
|
|
141
|
+
const spring = PIER_H + 0.18;
|
|
142
|
+
const roof = spring + r * (1 + POINT) + 0.65;
|
|
143
|
+
const z = ARCADE_WALK - PIER / 2;
|
|
144
|
+
kit.stone.box(0, -0.4, ARCADE_WALK / 2, ARCADE_BAY + 0.02, 0.58, ARCADE_WALK + 0.1, dim(col, 0.86));
|
|
145
|
+
for (const x of closing ? [-ARCADE_BAY / 2, ARCADE_BAY / 2] : [-ARCADE_BAY / 2]) {
|
|
146
|
+
kit.stone.box(x, 0, z, PIER + 0.16, 0.34, PIER + 0.16, dim(col, 0.9));
|
|
147
|
+
kit.wall.box(x, 0.34, z, PIER, PIER_H - 0.34, PIER, col);
|
|
148
|
+
kit.stone.box(x, PIER_H, z, PIER + 0.2, 0.18, PIER + 0.2, dim(col, 1.06));
|
|
149
|
+
}
|
|
150
|
+
archOpening(kit.wall, kit.stone, front, col, dim(col, 1.04), 0, spring, r, z, PIER, POINT, ARCADE_BAY / 2, roof);
|
|
151
|
+
kit.stone.box(0, roof, ARCADE_WALK / 2, ARCADE_BAY + 0.02, 0.2, ARCADE_WALK + 0.4, dim(col, 0.95));
|
|
152
|
+
kit.wall.box(0, roof + 0.2, ARCADE_WALK + 0.05, ARCADE_BAY + 0.02, 0.5, 0.3, col);
|
|
153
|
+
for (const x of [-ARCADE_BAY / 4, ARCADE_BAY / 4])
|
|
154
|
+
kit.wood.box(x, roof - 0.16, ARCADE_WALK / 2, 0.16, 0.16, ARCADE_WALK, dim(timber, 0.9 + rng() * 0.2));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function arcades(K, rng, plan) {
|
|
158
|
+
for (const g of streetLegs(plan, s => s.porch)) {
|
|
159
|
+
for (const sd of [-1, 1]) {
|
|
160
|
+
const nu = -g.dv * sd;
|
|
161
|
+
const nv = g.du * sd;
|
|
162
|
+
const edge = g.s.w / 2;
|
|
163
|
+
const col = color(pick(rng, arcadeRender), 0.03, rng);
|
|
164
|
+
const timber = color(pick(rng, palette.timber), 0.05, rng);
|
|
165
|
+
const count = Math.floor((g.len - 4) / ARCADE_BAY);
|
|
166
|
+
const spot = k => {
|
|
167
|
+
const t = 2 + (k + 0.5) * ARCADE_BAY;
|
|
168
|
+
return [g.u0 + g.du * t + nu * edge, g.v0 + g.dv * t + nv * edge];
|
|
169
|
+
};
|
|
170
|
+
const backed = k => {
|
|
171
|
+
if (k < 0 || k >= count) return false;
|
|
172
|
+
const [u, v] = spot(k);
|
|
173
|
+
return [-0.4, 0, 0.4].every(f => plan.at(u + g.du * f * ARCADE_BAY + nu * 1.5, v + g.dv * f * ARCADE_BAY + nv * 1.5) === HOUSE);
|
|
174
|
+
};
|
|
175
|
+
for (let k = 0; k < count; k++) {
|
|
176
|
+
if (!backed(k)) continue;
|
|
177
|
+
const [u, v] = spot(k);
|
|
178
|
+
const ry = townFacing(-nu, -nv);
|
|
179
|
+
const closing = !backed(k + 1);
|
|
180
|
+
setDown(K, rng, u, v, ry, kit => arcadeBay(kit, rng, col, timber, closing));
|
|
181
|
+
for (const x of closing ? [-1, 1] : [-1]) {
|
|
182
|
+
const along = (x * sd * ARCADE_BAY) / 2;
|
|
183
|
+
const out = ARCADE_WALK - PIER / 2;
|
|
184
|
+
K.solid(u + g.du * along - nu * out, v + g.dv * along - nv * out, PIER / 2, PIER / 2, ry);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function streetPalms(K, rng, plan, palms) {
|
|
192
|
+
for (const g of streetLegs(plan, s => s.trees)) {
|
|
193
|
+
for (let t = PALM_STEP / 2; t < g.len; t += PALM_STEP) {
|
|
194
|
+
const u = g.u0 + g.du * t;
|
|
195
|
+
const v = g.v0 + g.dv * t;
|
|
196
|
+
if (plan.at(u, v) !== STREET) continue;
|
|
197
|
+
palms.push([u, v, 0.95 + rng() * 0.35]);
|
|
198
|
+
setDown(K, rng, u, v, 0, kit => {
|
|
199
|
+
const col = color(pick(rng, palette.fired), 0.05, rng);
|
|
200
|
+
kit.stone.add(shapes.cyl16, col, transform(0, -0.3, 0, 2.2, 0.8, 2.2));
|
|
201
|
+
kit.stone.add(shapes.cyl16, dim(col, 1.1), transform(0, 0.5, 0, 2.3, 0.1, 2.3));
|
|
202
|
+
kit.cloth.add(shapes.cyl16, [0.3, 0.24, 0.17], transform(0, 0.42, 0, 1.9, 0.06, 1.9));
|
|
203
|
+
});
|
|
204
|
+
K.solid(u, v, 1.1, 1.1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function fountain(K, rng, u, v) {
|
|
210
|
+
const stone = color(pick(rng, palette.dressed), 0.03, rng);
|
|
211
|
+
const [x, z] = K.f.world(u, v);
|
|
212
|
+
const y = K.Y(u, v);
|
|
213
|
+
setDown(K, rng, u, v, 0, kit => {
|
|
214
|
+
kit.stone.add(shapes.cyl16, dim(stone, 0.85), transform(0, -0.4, 0, 11.4, 0.62, 11.4));
|
|
215
|
+
kit.stone.add(shapes.cyl6, dim(stone, 0.95), transform(0, -0.2, 0, 9.6, 0.95, 9.6, Math.PI / 6));
|
|
216
|
+
kit.stone.add(shapes.cyl6, dim(stone, 1.08), transform(0, 0.72, 0, 9.9, 0.14, 9.9, Math.PI / 6));
|
|
217
|
+
kit.stone.add(shapes.cyl16, stone, transform(0, 0.4, 0, 0.9, 2.1, 0.9));
|
|
218
|
+
kit.stone.add(shapes.taper, dim(stone, 1.05), transform(0, 2.5, 0, 3.2, 0.42, 3.2, 0, Math.PI));
|
|
219
|
+
kit.stone.add(shapes.cyl16, stone, transform(0, 2.5, 0, 0.5, 1.2, 0.5));
|
|
220
|
+
kit.stone.add(shapes.taper, dim(stone, 1.05), transform(0, 3.7, 0, 1.6, 0.26, 1.6, 0, Math.PI));
|
|
221
|
+
kit.stone.add(shapes.sph, dim(stone, 1.1), transform(0, 3.85, 0, 0.42, 0.42, 0.42));
|
|
222
|
+
});
|
|
223
|
+
K.glow('circle', [4.2, 24], palette.water, 0.5, [x, y + 0.6, z]);
|
|
224
|
+
K.solid(u, v, 5, 5);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function roundSquare(K, rng, s, palms) {
|
|
228
|
+
const STALLS = 24;
|
|
229
|
+
const MIDDLE = 12;
|
|
230
|
+
const INNER = 8;
|
|
231
|
+
for (const [n, r, out] of [
|
|
232
|
+
[STALLS, s.r - 3.2, -1],
|
|
233
|
+
[MIDDLE, s.r * 0.72, 1],
|
|
234
|
+
]) {
|
|
235
|
+
for (let k = 0; k < n; k++) {
|
|
236
|
+
const a = ((k + rng() * 0.4) / n) * TAU;
|
|
237
|
+
setDown(
|
|
238
|
+
K,
|
|
239
|
+
rng,
|
|
240
|
+
s.u + Math.cos(a) * r,
|
|
241
|
+
s.v + Math.sin(a) * r,
|
|
242
|
+
townFacing(out * Math.cos(a), out * Math.sin(a)),
|
|
243
|
+
rng() < 0.65 ? props.stall : props.goods,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
for (let k = 0; k < INNER; k++) {
|
|
248
|
+
const a = ((k + 0.5) / INNER) * TAU;
|
|
249
|
+
const r = s.r * 0.55;
|
|
250
|
+
if (k % 2) palms.push([s.u + Math.cos(a) * r, s.v + Math.sin(a) * r, 0.9 + rng() * 0.35]);
|
|
251
|
+
else setDown(K, rng, s.u + Math.cos(a) * r, s.v + Math.sin(a) * r, townFacing(Math.cos(a), Math.sin(a)), props.bench);
|
|
252
|
+
}
|
|
253
|
+
if (!s.stone) return;
|
|
254
|
+
const kerb = color(pick(rng, palette.dressed), 0.04, rng);
|
|
255
|
+
setDown(K, rng, s.u, s.v, rng() * TAU, kit => {
|
|
256
|
+
kit.stone.add(shapes.cyl16, dim(kerb, 0.9), transform(0, -0.25, 0, 4.4, 0.36, 4.4));
|
|
257
|
+
kit.stone.add(shapes.cyl16, dim(kerb, 0.8), transform(0, -0.2, 0, 3.7, 0.34, 3.7));
|
|
258
|
+
kit.stone.box(0, -0.16, 0, 1.9, 0.3, 1.1, color(0x8a8070, 0.04, rng));
|
|
259
|
+
for (let k = 0; k < 4; k++) kit.stone.box(-0.6 + k * 0.4, 0.13, (rng() - 0.5) * 0.3, 0.22, 0.012, 0.5, color(0x6a6255, 0.05, rng));
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function squares(K, rng, plan, palms) {
|
|
264
|
+
for (const s of plan.town.squares) {
|
|
265
|
+
if (s.r) {
|
|
266
|
+
roundSquare(K, rng, s, palms);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (s.fountain) fountain(K, rng, s.u, s.v);
|
|
270
|
+
if (s.well) {
|
|
271
|
+
setDown(K, rng, s.u, s.v, rng() * TAU, props.well);
|
|
272
|
+
setDown(K, rng, s.u + 3.2, s.v - 1.5, Math.PI / 2, props.trough);
|
|
273
|
+
K.solid(s.u, s.v, 1.7, 1.7);
|
|
274
|
+
}
|
|
275
|
+
for (const [a, b] of [
|
|
276
|
+
[-1, -1],
|
|
277
|
+
[1, -1],
|
|
278
|
+
[-1, 1],
|
|
279
|
+
[1, 1],
|
|
280
|
+
]) {
|
|
281
|
+
palms.push([s.u + a * (s.w / 2 - 3), s.v + b * (s.d / 2 - 3), 0.9 + rng() * 0.4]);
|
|
282
|
+
setDown(K, rng, s.u + a * (s.w / 2 - 6.5), s.v + b * (s.d / 2 - 3), townFacing(-a, 0), props.bench);
|
|
283
|
+
}
|
|
284
|
+
for (let i = 0; i < 2; i++) {
|
|
285
|
+
const a = i ? 1 : -1;
|
|
286
|
+
setDown(K, rng, s.u + a * (s.w / 2 - 2.5), s.v + (rng() - 0.5) * 6, townFacing(-a, 0), rng() < 0.6 ? props.stall : props.goods);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Carved stone chest / sarcophagus on a plinth with panelled sides and ridged corner-knobbed lid.
|
|
292
|
+
function carvedChest(kit, rng, x, z, ry, stone) {
|
|
293
|
+
const L = 2.1 + rng() * 0.3;
|
|
294
|
+
const W = 0.8 + rng() * 0.12;
|
|
295
|
+
const H = 0.78 + rng() * 0.12;
|
|
296
|
+
const c = Math.cos(ry);
|
|
297
|
+
const s = Math.sin(ry);
|
|
298
|
+
const at = (lx, lz) => [x + lx * c + lz * s, z - lx * s + lz * c];
|
|
299
|
+
const open = rng() < 0.3;
|
|
300
|
+
kit.stone.box(x, 0, z, L + 0.14, 0.14, W + 0.14, dim(stone, 0.88), ry);
|
|
301
|
+
kit.stone.box(x, 0.14, z, L, H, W, stone, ry);
|
|
302
|
+
for (const sd of [-1, 1]) {
|
|
303
|
+
for (let k = 0; k < 3; k++) {
|
|
304
|
+
const [px, pz] = at(-L / 3 + (k * L) / 3, sd * (W / 2 + 0.006));
|
|
305
|
+
kit.stone.box(px, 0.3, pz, L / 3 - 0.16, H - 0.34, 0.02, dim(stone, 0.9), ry);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (open) {
|
|
309
|
+
const [lx, lz] = at(0, W / 2 + 0.45);
|
|
310
|
+
kit.stone.box(lx, 0.02, lz, L, 0.2, W + 0.1, dim(stone, 1.04), ry, 1.15);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
kit.stone.box(x, 0.14 + H, z, L + 0.08, 0.12, W + 0.08, dim(stone, 1.04), ry);
|
|
314
|
+
for (const sd of [-1, 1]) {
|
|
315
|
+
const [px, pz] = at(0, (sd * W) / 4);
|
|
316
|
+
kit.stone.box(px, 0.22 + H, pz, L, 0.05, W / 2 + 0.04, dim(stone, 1.06), ry, sd * 0.32);
|
|
317
|
+
for (const e of [-1, 1]) {
|
|
318
|
+
const [qx, qz] = at((e * L) / 2, (sd * W) / 2);
|
|
319
|
+
kit.stone.box(qx, 0.26 + H, qz, 0.14, 0.14, 0.14, dim(stone, 1.02), ry);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function soukAwning(kit, rng, w, cloth, timber) {
|
|
325
|
+
const n = Math.ceil(w / 0.6);
|
|
326
|
+
const sag = 0.35 + rng() * 0.2;
|
|
327
|
+
const top = 4.4 + rng() * 0.5;
|
|
328
|
+
for (const x of [-w / 2, w / 2]) kit.wood.box(x, top - 0.1, 0, 0.18, 0.18, AWNING_STEP - 1.4, timber);
|
|
329
|
+
for (let q = 0; q < n; q++) {
|
|
330
|
+
const t = (q + 0.5) / n - 0.5;
|
|
331
|
+
const x = t * w;
|
|
332
|
+
const y = top - sag * (1 - (2 * t) ** 2);
|
|
333
|
+
kit.cloth.add(
|
|
334
|
+
shapes.box,
|
|
335
|
+
q % 2 ? cloth[0] : cloth[1],
|
|
336
|
+
transform(x, y, 0, w / n + 0.02, 0.03, AWNING_STEP - 1.6, 0, 0, Math.atan(8 * sag * t * (1 / w))),
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function souk(K, rng, plan) {
|
|
342
|
+
for (const g of streetLegs(plan, s => s.souk)) {
|
|
343
|
+
const nu = -g.dv;
|
|
344
|
+
const nv = g.du;
|
|
345
|
+
const edge = g.s.w / 2;
|
|
346
|
+
for (let t = 2.5; t < g.len - 2; t += SOUK_STEP) {
|
|
347
|
+
for (const sd of [-1, 1]) {
|
|
348
|
+
const u = g.u0 + g.du * t + nu * sd * (edge - 1.3);
|
|
349
|
+
const v = g.v0 + g.dv * t + nv * sd * (edge - 1.3);
|
|
350
|
+
if (plan.at(u + nu * sd * 2, v + nv * sd * 2) !== HOUSE) continue;
|
|
351
|
+
const choice = rng();
|
|
352
|
+
const ry = townFacing(-nu * sd, -nv * sd);
|
|
353
|
+
if (g.s.coffins && choice < 0.5) {
|
|
354
|
+
setDown(K, rng, u, v, ry, kit => {
|
|
355
|
+
const stone = color(pick(rng, palette.dressed), 0.05, rng);
|
|
356
|
+
carvedChest(kit, rng, 0, 0.2, 0, stone);
|
|
357
|
+
if (rng() < 0.5) carvedChest(kit, rng, 0.2, -1.15, 0, dim(stone, 0.96));
|
|
358
|
+
});
|
|
359
|
+
} else if (choice < 0.62) setDown(K, rng, u, v, ry, props.stall);
|
|
360
|
+
else if (choice < 0.82) setDown(K, rng, u, v, ry, props.goods);
|
|
361
|
+
else {
|
|
362
|
+
setDown(K, rng, u, v, ry, kit => {
|
|
363
|
+
for (let k = 0; k < 3; k++)
|
|
364
|
+
waterJar(kit.stone, front, (k - 1) * 0.8, 0.3 * (k % 2), 0.8 + rng() * 0.4, color(pick(rng, palette.clay), 0.06, rng), rng);
|
|
365
|
+
props.crates(kit, rng, 2);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
for (let t = AWNING_STEP / 2; t < g.len; t += AWNING_STEP) {
|
|
371
|
+
const u = g.u0 + g.du * t;
|
|
372
|
+
const v = g.v0 + g.dv * t;
|
|
373
|
+
if (rng() < 0.15) continue;
|
|
374
|
+
const cloth = [color(pick(rng, palette.awning), 0.06, rng), color(0xd8cfb8, 0.05, rng)];
|
|
375
|
+
const timber = color(pick(rng, palette.timber), 0.05, rng);
|
|
376
|
+
setDown(K, rng, u, v, townFacing(g.du, g.dv), kit => soukAwning(kit, rng, g.s.w + 0.6, cloth, timber));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function courtyards(K, rng, courts, palms) {
|
|
382
|
+
for (const ct of courts) {
|
|
383
|
+
const ry = ct.rot - K.f.yaw;
|
|
384
|
+
if (ct.rich) {
|
|
385
|
+
palms.push([ct.u, ct.v + 0.8, 0.8 + rng() * 0.3, ct.y]);
|
|
386
|
+
const [x, z] = K.f.world(ct.u, ct.v - 1.4);
|
|
387
|
+
K.glow('plane', [2.6, 1.4], palette.water, 0.45, [x, ct.y + 0.12, z], ct.rot);
|
|
388
|
+
setDown(
|
|
389
|
+
K,
|
|
390
|
+
rng,
|
|
391
|
+
ct.u,
|
|
392
|
+
ct.v - 1.4,
|
|
393
|
+
ry,
|
|
394
|
+
kit => kit.stone.box(0, -0.2, 0, 3.2, 0.3, 2, color(pick(rng, palette.dressed), 0.04, rng)),
|
|
395
|
+
ct.y,
|
|
396
|
+
);
|
|
397
|
+
} else if (rng() < 0.55) palms.push([ct.u, ct.v, 0.65 + rng() * 0.35, ct.y]);
|
|
398
|
+
else {
|
|
399
|
+
setDown(
|
|
400
|
+
K,
|
|
401
|
+
rng,
|
|
402
|
+
ct.u,
|
|
403
|
+
ct.v,
|
|
404
|
+
ry,
|
|
405
|
+
kit => {
|
|
406
|
+
props.well(kit, rng);
|
|
407
|
+
waterJar(kit.stone, front, 2.1, 0.4, 0.9, color(pick(rng, palette.clay), 0.06, rng), rng);
|
|
408
|
+
},
|
|
409
|
+
ct.y,
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function levelFloor(K, u, v, w, d) {
|
|
416
|
+
const heights = [-1, 1].flatMap(a => [-1, 1].map(b => K.Y(u + (a * w) / 2, v + (b * d) / 2)));
|
|
417
|
+
const y = Math.max(...heights);
|
|
418
|
+
const [x, z] = K.f.world(u, v);
|
|
419
|
+
K.sp.decks.push({ x, z, hx: w / 2, hz: d / 2, c: Math.cos(K.f.yaw), s: Math.sin(K.f.yaw), y });
|
|
420
|
+
return { y, drop: y - Math.min(...heights) };
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function rampFloor(K, u0, v0, u1, v1, y0, y1, width) {
|
|
424
|
+
addRampDeck(K.sp.decks, K.f.world, u0, v0, u1, v1, y0, y1, width);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function palmGrove(K, rng, spots) {
|
|
428
|
+
const matrices = new Float32Array(spots.length * 16);
|
|
429
|
+
spots.forEach(([u, v, s = 1, y], i) => {
|
|
430
|
+
const [x, z] = K.f.world(u, v);
|
|
431
|
+
transform(x, y ?? K.Y(u, v), z, s, s * (0.8 + rng() * 0.5), s, rng() * TAU).toArray(matrices, i * 16);
|
|
432
|
+
});
|
|
433
|
+
K.orders.push({ [groveOrderKey]: matrices });
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function townWorks(K, rng, plan, courts) {
|
|
437
|
+
const palms = [];
|
|
438
|
+
arcades(K, rng, plan);
|
|
439
|
+
streetPalms(K, rng, plan, palms);
|
|
440
|
+
squares(K, rng, plan, palms);
|
|
441
|
+
souk(K, rng, plan);
|
|
442
|
+
courtyards(K, rng, courts, palms);
|
|
443
|
+
return palms;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return {
|
|
447
|
+
BAY: ARCADE_BAY,
|
|
448
|
+
WALK: ARCADE_WALK,
|
|
449
|
+
facing: townFacing,
|
|
450
|
+
arcadeBay,
|
|
451
|
+
arcades,
|
|
452
|
+
streetPalms,
|
|
453
|
+
fountain,
|
|
454
|
+
squares,
|
|
455
|
+
roundSquare,
|
|
456
|
+
carvedChest,
|
|
457
|
+
soukAwning,
|
|
458
|
+
souk,
|
|
459
|
+
courtyards,
|
|
460
|
+
levelFloor,
|
|
461
|
+
rampFloor,
|
|
462
|
+
palmGrove,
|
|
463
|
+
townWorks,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// A village strung along its roads: house plots both sides of each road, nearest the village's middle first, each house facing
|
|
2
|
+
// its road with a fenced yard behind (`layVillageYards`), carts, goods and a bench at the crossroads, and shade trees beside some
|
|
3
|
+
// yards and on the green. What a world's village has of its own (a landmark inn, boats drawn up on a shore) it lays through hooks.
|
|
4
|
+
// Worker-safe: it fills a house kit's builders, a town's far parts and a quarter's specs, and makes no meshes.
|
|
5
|
+
import { TAU } from '../math/scalar.js';
|
|
6
|
+
import { layVillageYards } from './village-yards.js';
|
|
7
|
+
|
|
8
|
+
/** The share of a village's houses with a shade tree beside the yard. */
|
|
9
|
+
export const SHADE_BY_YARD = 0.4;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lays out one village. Every random draw is taken from the streams given, in a fixed order, so a village is the same each time.
|
|
13
|
+
* @param {object} o
|
|
14
|
+
* @param {{ x: number, z: number, r: number, houses: number }} o.centre - The village's middle, its radius in metres and how
|
|
15
|
+
* many houses it has at most; handed to the hooks as it is (a hook may note things on it).
|
|
16
|
+
* @param {{ fine: number[][], w: number }[]} o.roads - The village's roads: each its fine line of `[x, z]` points and its width
|
|
17
|
+
* in metres.
|
|
18
|
+
* @param {() => number} o.random - The village's own stream: plots, sizes and turns of its houses.
|
|
19
|
+
* @param {() => number} o.crossRandom - The stream of the crossroads' goods and the landmarks' hooks.
|
|
20
|
+
* @param {() => number} o.yardRandom - The stream of the yards.
|
|
21
|
+
* @param {(x: number, z: number) => number} o.ground - The ground's height in metres.
|
|
22
|
+
* @param {(x: number, z: number) => number} o.roadDistance - Metres from the nearest road.
|
|
23
|
+
* @param {(x: number, z: number) => number} o.riverDistance - Metres from the nearest river.
|
|
24
|
+
* @param {(x: number, z: number) => number} [o.clear] - How clear a point is of what a village keeps off (a walled city: 1 on its
|
|
25
|
+
* wall, rising beyond): houses stand where it is at least `clearAtLeast`, shade trees where it is more.
|
|
26
|
+
* @param {number} [o.clearAtLeast] - The least `clear` a house stands at (1.08).
|
|
27
|
+
* @param {number} o.waterLevel - The water's height in metres: houses stand 1.4 m above it, trees 1.5 m.
|
|
28
|
+
* @param {object} o.town - The village's far parts (`createTowns`' `Town`: `add`, `gableRoof`).
|
|
29
|
+
* @param {{ add: (spec: object, ids: Array) => void }} o.quarter - Where each house's spec goes, with the ids of its far parts.
|
|
30
|
+
* @param {object} o.space - The space colliders are laid in.
|
|
31
|
+
* @param {(space: object, x: number, z: number, halfX: number, halfZ: number, rotation: number) => void} o.addBox - Lays a box collider.
|
|
32
|
+
* @param {object} o.kit - The house kit (`createHouseKit`): `kitAt`, `kitPush`, `kitPop`, `kitBarrel`, `facePut`, `propWashing`, `lump`.
|
|
33
|
+
* @param {object} o.builder - A filled-as-it-goes kit of builders (`kitNew()`) the near detail is laid into.
|
|
34
|
+
* @param {object} o.shapes - The world's unit shapes (`box`).
|
|
35
|
+
* @param {Function} o.transform - Places a unit shape (`TRS`).
|
|
36
|
+
* @param {Function} o.color - A colour from a hex with jitter (`C`).
|
|
37
|
+
* @param {(x: number, y: number, seed: number) => number} o.noise - Value noise, 0 to 1 (the trodden mud and its puddles).
|
|
38
|
+
* @param {(i: number, random: () => number) => { style: string, col: number[], rc: number[], rise: number, rubble?: boolean, wall?:
|
|
39
|
+
* number|boolean }} o.dress - The `i`-th house's style, wall and roof colours, its roof's rise (metres) and whether it is of rubble,
|
|
40
|
+
* drawing from the village's stream after its size and turn; `wall`, the town's wall material its far walls take.
|
|
41
|
+
* @param {Array<[number, number, Function]>} [o.crossroads] - Things laid about the crossroads: metres from the middle and a
|
|
42
|
+
* prop's builder `(kit, random)`, each where it is clear of road and houses.
|
|
43
|
+
* @param {(kit: object, random: () => number, logs: number) => void} o.woodpile - Builds a yard's woodpile of `logs` logs.
|
|
44
|
+
* @param {(village: object) => void} [o.landmarks] - Lays the village's own landmarks before its houses (keeping them clear
|
|
45
|
+
* through `village.keepOut`).
|
|
46
|
+
* @param {(village: object) => void} [o.shore] - Lays what the village has on its shore after the crossroads (`village.free`).
|
|
47
|
+
* @param {{ random: () => number, plant: (x: number, z: number, size: number) => void }|null} [o.shade] - Shade trees: their
|
|
48
|
+
* stream and how one is planted; none where not given.
|
|
49
|
+
* @param {object} [o.palette] - The yards' colours (`YARD_PALETTE` of `village-yards.js`).
|
|
50
|
+
* @param {number} [o.salt] - Mixed into each house's seed (the village's x).
|
|
51
|
+
* @returns {{ homes: object[], keepOut: number[][], hens: number[][] }} The houses laid (`{ x, y, z, w, d, rot, side, off, r }`),
|
|
52
|
+
* the circles kept clear (`[x, z, r]`) and, for each yard with a coop, `[x, z, hens, metres they stray]`.
|
|
53
|
+
*/
|
|
54
|
+
export function layVillage(o) {
|
|
55
|
+
const { centre: c, roads, random: rng, ground: Y, roadDistance, riverDistance, clear = () => Infinity, clearAtLeast = 1.08 } = o;
|
|
56
|
+
const { waterLevel, town, quarter: Q, space: sp, addBox, salt = c.x } = o;
|
|
57
|
+
const homes = [],
|
|
58
|
+
keepOut = [],
|
|
59
|
+
hens = [];
|
|
60
|
+
const free = (x, z, r) =>
|
|
61
|
+
!homes.some(h => Math.hypot(h.x - x, h.z - z) < r + h.r) && !keepOut.some(k => Math.hypot(k[0] - x, k[1] - z) < r + k[2]);
|
|
62
|
+
const village = { ...o, homes, keepOut, hens, free };
|
|
63
|
+
o.landmarks?.(village);
|
|
64
|
+
// the house plots: both sides of each of the village's roads, nearest the village's middle first
|
|
65
|
+
const plots = [];
|
|
66
|
+
for (const road of roads) {
|
|
67
|
+
const f = road.fine,
|
|
68
|
+
hw = road.w / 2;
|
|
69
|
+
for (let i = 2, next = 0, run = 0; i < f.length - 2; i++) {
|
|
70
|
+
run += Math.hypot(f[i][0] - f[i - 1][0], f[i][1] - f[i - 1][1]);
|
|
71
|
+
if (run < next) continue;
|
|
72
|
+
next = run + 6.5 + rng() * 3;
|
|
73
|
+
const [px, pz] = f[i];
|
|
74
|
+
if (Math.hypot(px - c.x, pz - c.z) > c.r + 14) continue;
|
|
75
|
+
const tx = f[i + 2][0] - f[i - 2][0],
|
|
76
|
+
tz = f[i + 2][1] - f[i - 2][1],
|
|
77
|
+
tl = Math.hypot(tx, tz),
|
|
78
|
+
ux = tx / tl,
|
|
79
|
+
uz = tz / tl;
|
|
80
|
+
for (const side of [-1, 1]) plots.push({ px, pz, ux, uz, side, hw, d: Math.hypot(px - c.x, pz - c.z) + rng() * 10 });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
plots.sort((a, b) => a.d - b.d);
|
|
84
|
+
for (const q of plots) {
|
|
85
|
+
if (homes.length >= c.houses) break;
|
|
86
|
+
const w = 4.8 + rng() * 2.6,
|
|
87
|
+
d = 4.4 + rng() * 2,
|
|
88
|
+
off = q.hw + 2.6 + d / 2 + rng() * 2.5,
|
|
89
|
+
x = q.px - q.uz * q.side * off,
|
|
90
|
+
z = q.pz + q.ux * q.side * off;
|
|
91
|
+
if (
|
|
92
|
+
roadDistance(x, z) < q.hw + d / 2 + 1.2 ||
|
|
93
|
+
riverDistance(x, z) < 10 ||
|
|
94
|
+
clear(x, z) < clearAtLeast ||
|
|
95
|
+
Y(x, z) < waterLevel + 1.4 ||
|
|
96
|
+
!free(x, z, Math.hypot(w, d) / 2 + 0.8)
|
|
97
|
+
)
|
|
98
|
+
continue;
|
|
99
|
+
const s = -q.side,
|
|
100
|
+
i = homes.length; // s: the side of the house its yard is on, away from the road
|
|
101
|
+
const y = Y(x, z),
|
|
102
|
+
h = 2.8 + rng() * 1.8,
|
|
103
|
+
rot = Math.atan2(-q.uz, q.ux) + (rng() - 0.5) * 0.24,
|
|
104
|
+
lean = (rng() - 0.5) * 0.14;
|
|
105
|
+
const { style, col, rc, rise, rubble = false, wall = 0 } = o.dress(i, rng);
|
|
106
|
+
Q.add(
|
|
107
|
+
{
|
|
108
|
+
x,
|
|
109
|
+
y,
|
|
110
|
+
z,
|
|
111
|
+
w,
|
|
112
|
+
d,
|
|
113
|
+
h,
|
|
114
|
+
rot,
|
|
115
|
+
lean,
|
|
116
|
+
style,
|
|
117
|
+
form: 'gable',
|
|
118
|
+
turn: false,
|
|
119
|
+
rise,
|
|
120
|
+
chim: i % 3 === 0,
|
|
121
|
+
col,
|
|
122
|
+
rc,
|
|
123
|
+
seed: i * 977 + 3 + salt,
|
|
124
|
+
streetLit: 0,
|
|
125
|
+
ruin: 1,
|
|
126
|
+
rubble,
|
|
127
|
+
},
|
|
128
|
+
[
|
|
129
|
+
town.add('box', x, y - 0.8, z, w, h + 0.8, d, rot, col, 0, lean, wall),
|
|
130
|
+
...town.gableRoof(x, y + h - 0.1, z, w, rise, d, rot, rc, col, 0.9, lean * 1.6),
|
|
131
|
+
],
|
|
132
|
+
);
|
|
133
|
+
addBox(sp, x, z, w / 2, d / 2, rot);
|
|
134
|
+
homes.push({ x, y, z, w, d, rot, side: -s, off, r: Math.hypot(w, d) / 2 + 3 });
|
|
135
|
+
}
|
|
136
|
+
if (o.shade) plantShade(village);
|
|
137
|
+
// carts, goods and a bench at the crossroads
|
|
138
|
+
for (const [dx, dz, fn] of o.crossroads ?? []) {
|
|
139
|
+
const x = c.x + dx,
|
|
140
|
+
z = c.z + dz;
|
|
141
|
+
if (roadDistance(x, z) < 3.5 || !free(x, z, 1.5)) continue;
|
|
142
|
+
o.kit.kitAt(o.builder, x, Y(x, z), z, o.crossRandom() * 6, 0, fn, o.crossRandom);
|
|
143
|
+
}
|
|
144
|
+
o.shore?.(village);
|
|
145
|
+
layVillageYards(village);
|
|
146
|
+
return { homes, keepOut, hens };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// A village's shade trees: one beside some yards, out of the way of its fence, and a few on the green round the crossroads; never
|
|
150
|
+
// on a road, in a river or the water, or against a house or a yard. Drawn from their own stream.
|
|
151
|
+
function plantShade(village) {
|
|
152
|
+
const { centre: c, homes, keepOut, ground: Y, roadDistance, riverDistance, clear = () => Infinity, clearAtLeast = 1.08 } = village;
|
|
153
|
+
const R = village.shade.random,
|
|
154
|
+
trees = [],
|
|
155
|
+
isClear = (x, z) =>
|
|
156
|
+
roadDistance(x, z) > 5 &&
|
|
157
|
+
riverDistance(x, z) > 7 &&
|
|
158
|
+
clear(x, z) > clearAtLeast &&
|
|
159
|
+
Y(x, z) > village.waterLevel + 1.5 &&
|
|
160
|
+
!homes.some(h => Math.hypot(h.x - x, h.z - z) < Math.max(h.w, h.d) / 2 + 3.2) &&
|
|
161
|
+
!keepOut.some(k => Math.hypot(k[0] - x, k[1] - z) < k[2] + 2) &&
|
|
162
|
+
!trees.some(([tx, tz]) => Math.hypot(tx - x, tz - z) < 6),
|
|
163
|
+
plant = (x, z, size) => {
|
|
164
|
+
if (!isClear(x, z)) return;
|
|
165
|
+
trees.push([x, z]);
|
|
166
|
+
village.shade.plant(x, z, size);
|
|
167
|
+
};
|
|
168
|
+
for (const h of homes) {
|
|
169
|
+
if (R() > SHADE_BY_YARD) continue;
|
|
170
|
+
const cs = Math.cos(h.rot),
|
|
171
|
+
sn = Math.sin(h.rot),
|
|
172
|
+
lx = (R() < 0.5 ? -1 : 1) * (h.w / 2 + 2.6 + R() * 1.5),
|
|
173
|
+
lz = -h.side * (h.d / 2 + 1 + R() * 4); // beside the yard, which lies on the house's side away from the road
|
|
174
|
+
plant(h.x + lx * cs + lz * sn, h.z - lx * sn + lz * cs, 0.6 + R() * 0.35);
|
|
175
|
+
}
|
|
176
|
+
for (let n = 0; n < 12 && trees.length < homes.length * SHADE_BY_YARD + 3; n++) {
|
|
177
|
+
const a = R() * TAU,
|
|
178
|
+
r = 7 + R() * 9;
|
|
179
|
+
plant(c.x + Math.cos(a) * r, c.z + Math.sin(a) * r, 0.7 + R() * 0.35);
|
|
180
|
+
}
|
|
181
|
+
}
|