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,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polyline landward curtain wall with square pyramid-roofed corner towers, partially dismantled stretches, twin-tower
|
|
3
|
+
* gatehouses with corbelled fighting chambers, raised portcullises and folded timber leaves, plus arched grated
|
|
4
|
+
* culverts where streams pass under the wall. Builds on `wall-runs.js` (`wallRun`) and `fort-parts.js` (`wallGateFrames`).
|
|
5
|
+
* Worker-safe.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { dim } from '../math/color.js';
|
|
10
|
+
import { C as defaultColor, TRS as defaultTransform } from './primitives.js';
|
|
11
|
+
import { wallGateFrames } from './fort-parts.js';
|
|
12
|
+
|
|
13
|
+
const DEFAULT_GATE_HALF = 6.5; // half-length of a twin-tower gatehouse along the curtain in metres
|
|
14
|
+
const DEFAULT_DARK = [0.02, 0.018, 0.016];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Adds arched, iron-grated drainage culverts where stream endpoints meet a polyline curtain wall.
|
|
18
|
+
* @param {object} options - Wall polyline, streams, ground sampler and builders.
|
|
19
|
+
* @param {Array<[number, number]>} options.wall - Ordered curtain vertices `[x, z]` in metres.
|
|
20
|
+
* @param {Array<{ kind?: string, pts: Array<[number, number]> }>} options.streams - Waterways; those with `kind === 'stream'` are checked.
|
|
21
|
+
* @param {(x: number, z: number) => number} options.ground - Ground height function in metres.
|
|
22
|
+
* @param {object} options.stone - Masonry geometry builder (`GeometryBuilder`).
|
|
23
|
+
* @param {() => number[]} options.wallColor - Returns a linear RGB stone colour `[r, g, b]`.
|
|
24
|
+
* @param {object} options.shapes - Unit shapes (`{ cyl6, box }`).
|
|
25
|
+
* @param {Function} [options.transform] - Transform matrix helper (`TRS`).
|
|
26
|
+
* @param {number[]} [options.dark] - Linear RGB colour of dark recessed openings.
|
|
27
|
+
* @returns {void}
|
|
28
|
+
*/
|
|
29
|
+
export function buildWallCulverts({ wall, streams, ground, stone, wallColor, shapes, transform = defaultTransform, dark = DEFAULT_DARK }) {
|
|
30
|
+
for (const stream of streams) {
|
|
31
|
+
if (stream.kind !== 'stream') continue;
|
|
32
|
+
const [ex, ez] = stream.pts[stream.pts.length - 1];
|
|
33
|
+
for (let i = 0; i < wall.length - 1; i++) {
|
|
34
|
+
const [ax, az] = wall[i];
|
|
35
|
+
const [bx, bz] = wall[i + 1];
|
|
36
|
+
const L = Math.hypot(bx - ax, bz - az);
|
|
37
|
+
const ux = (bx - ax) / L;
|
|
38
|
+
const uz = (bz - az) / L;
|
|
39
|
+
const t = Math.max(0, Math.min(L, (ex - ax) * ux + (ez - az) * uz));
|
|
40
|
+
const px = ax + ux * t;
|
|
41
|
+
const pz = az + uz * t;
|
|
42
|
+
if (Math.hypot(ex - px, ez - pz) > 12) continue;
|
|
43
|
+
const nx = uz;
|
|
44
|
+
const nz = -ux;
|
|
45
|
+
const rot = Math.atan2(-uz, ux);
|
|
46
|
+
const fx = px + nx * 1.15;
|
|
47
|
+
const fz = pz + nz * 1.15;
|
|
48
|
+
const y = Math.min(ground(fx + nx * 2, fz + nz * 2), ground(px, pz)) - 0.4;
|
|
49
|
+
const W2 = 2.1;
|
|
50
|
+
const H = 2.6;
|
|
51
|
+
stone.tv = y;
|
|
52
|
+
stone.box(fx, y, fz, W2 * 2, H, 0.12, dark, rot);
|
|
53
|
+
for (let k = -4; k <= 4; k++)
|
|
54
|
+
stone.add(
|
|
55
|
+
shapes.cyl6,
|
|
56
|
+
[0.05, 0.045, 0.04],
|
|
57
|
+
transform(fx + nx * 0.12 + ux * k * 0.48, y, fz + nz * 0.12 + uz * k * 0.48, 0.09, H, 0.09),
|
|
58
|
+
);
|
|
59
|
+
stone.box(fx + nx * 0.12, y + H * 0.55, fz + nz * 0.12, W2 * 2, 0.1, 0.1, [0.05, 0.045, 0.04], rot);
|
|
60
|
+
for (let k = 0; k <= 8; k++) {
|
|
61
|
+
const a = (k / 8) * Math.PI;
|
|
62
|
+
const ox = Math.cos(a) * (W2 + 0.35);
|
|
63
|
+
const oy = Math.sin(a) * 1.1;
|
|
64
|
+
stone.add(
|
|
65
|
+
shapes.box,
|
|
66
|
+
dim(wallColor(), 1.12),
|
|
67
|
+
transform(fx + nx * 0.2 + ux * ox, y + H - 0.6 + oy, fz + nz * 0.2 + uz * ox, 0.7, 0.55, 0.4, rot, 0, a - Math.PI / 2),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
for (const s of [-1, 1])
|
|
71
|
+
stone.box(
|
|
72
|
+
fx + nx * 0.25 + ux * s * (W2 + 0.35),
|
|
73
|
+
y - 0.5,
|
|
74
|
+
fz + nz * 0.25 + uz * s * (W2 + 0.35),
|
|
75
|
+
0.7,
|
|
76
|
+
H,
|
|
77
|
+
0.5,
|
|
78
|
+
dim(wallColor(), 1.05),
|
|
79
|
+
rot,
|
|
80
|
+
);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Builds a polyline landward curtain wall with corner towers, optional dismantled/lowered stretches, twin-tower
|
|
88
|
+
* gatehouses with corbelled fighting chambers, raised portcullises and timber doors, and arched stream culverts.
|
|
89
|
+
* @param {object} options - Wall layout, ground, builders, shapes, and world hooks.
|
|
90
|
+
* @param {Array<[number, number]>} options.wall - Ordered curtain vertices `[x, z]` in metres.
|
|
91
|
+
* @param {Array<object>} [options.gates] - Pre-projected gate frames (`wallGateFrames`), or raw gates if `rawGates` is passed.
|
|
92
|
+
* @param {Array<object>} [options.streams=[]] - Streams for culvert placement (`buildWallCulverts`).
|
|
93
|
+
* @param {(x: number, z: number) => number} options.ground - Ground height function in metres.
|
|
94
|
+
* @param {() => number} options.rng - Seeded random generator.
|
|
95
|
+
* @param {object} options.stone - Masonry geometry builder (`GeometryBuilder`).
|
|
96
|
+
* @param {object} options.wood - Timber/iron gate geometry builder (`GeometryBuilder`).
|
|
97
|
+
* @param {object} [options.space] - Space object passed to colliders and marks.
|
|
98
|
+
* @param {(x: number, z: number) => void} [options.lamp] - Lamp placement callback flanking gate towers.
|
|
99
|
+
* @param {number} [options.roofHex=0x808d9a] - Hex roof colour for pyramid tower caps.
|
|
100
|
+
* @param {number} [options.stoneHex=0x8f8776] - Base hex stone colour for wall and towers.
|
|
101
|
+
* @param {Function} options.wallRun - Straight wall-run builder (`createWallRuns().wallRun`).
|
|
102
|
+
* @param {Function} [options.addBox] - Box collider hook.
|
|
103
|
+
* @param {Function} [options.markWall] - Wall footprint map-mark hook.
|
|
104
|
+
* @param {object} options.shapes - Unit shapes (`{ pyr, cyl6, box }`).
|
|
105
|
+
* @param {(hex: number, jitter?: number, rng?: () => number) => number[]} [options.color] - Linear RGB colour helper.
|
|
106
|
+
* @param {Function} [options.transform] - Transform matrix helper (`TRS`).
|
|
107
|
+
* @param {number} [options.gateHalf=6.5] - Half-length of each twin-tower gatehouse along the curtain in metres.
|
|
108
|
+
* @returns {{ gates: Array<object> }} Resolved gate frames.
|
|
109
|
+
*/
|
|
110
|
+
export function buildPolylineWall({
|
|
111
|
+
wall,
|
|
112
|
+
gates: givenGates,
|
|
113
|
+
rawGates = [],
|
|
114
|
+
streams = [],
|
|
115
|
+
ground,
|
|
116
|
+
rng,
|
|
117
|
+
stone,
|
|
118
|
+
wood,
|
|
119
|
+
space = null,
|
|
120
|
+
lamp = () => {},
|
|
121
|
+
roofHex = 0x808d9a,
|
|
122
|
+
stoneHex = 0x8f8776,
|
|
123
|
+
wallRun,
|
|
124
|
+
addBox = () => {},
|
|
125
|
+
markWall = () => {},
|
|
126
|
+
shapes,
|
|
127
|
+
color = defaultColor,
|
|
128
|
+
transform = defaultTransform,
|
|
129
|
+
gateHalf = DEFAULT_GATE_HALF,
|
|
130
|
+
}) {
|
|
131
|
+
const gates = givenGates ?? wallGateFrames(wall, rawGates);
|
|
132
|
+
const wallColor = () => color(stoneHex, 0.08, rng);
|
|
133
|
+
const dark = DEFAULT_DARK;
|
|
134
|
+
|
|
135
|
+
const tower = (px, pz, w, h, ry) => {
|
|
136
|
+
const ty = ground(px, pz);
|
|
137
|
+
const wc = wallColor();
|
|
138
|
+
stone.tv = ty;
|
|
139
|
+
stone.box(px, ty - 1.5, pz, w, h, w, wc, ry);
|
|
140
|
+
stone.add(shapes.pyr, color(roofHex), transform(px, ty + h - 1.5, pz, w + 1, 3.4, w + 1, ry));
|
|
141
|
+
if (space) {
|
|
142
|
+
addBox(space, px, pz, w / 2, w / 2, ry);
|
|
143
|
+
markWall(space, px, pz, w / 2, w / 2, ry);
|
|
144
|
+
}
|
|
145
|
+
stone.box(px, ty - 1.5, pz, w + 0.7, 2.2, w + 0.7, dim(wc, 0.85), ry);
|
|
146
|
+
stone.box(px, ty + h - 2.6, pz, w + 0.6, 0.5, w + 0.6, dim(wc, 0.9), ry);
|
|
147
|
+
for (let k = 0; k < 4; k++) {
|
|
148
|
+
const a = (k * Math.PI) / 2 + ry;
|
|
149
|
+
const cx = Math.cos(a);
|
|
150
|
+
const sz = -Math.sin(a);
|
|
151
|
+
for (const hh of [3.5, h * 0.58])
|
|
152
|
+
stone.box(
|
|
153
|
+
px + cx * (w / 2 + 0.02),
|
|
154
|
+
ty + hh,
|
|
155
|
+
pz + sz * (w / 2 + 0.02),
|
|
156
|
+
Math.abs(cx) > 0.5 ? 0.06 : 0.22,
|
|
157
|
+
1.2,
|
|
158
|
+
Math.abs(sz) > 0.5 ? 0.06 : 0.22,
|
|
159
|
+
dark,
|
|
160
|
+
ry,
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
for (let i = 0; i < wall.length - 1; i++) {
|
|
166
|
+
const [ax, az] = wall[i];
|
|
167
|
+
const [bx, bz] = wall[i + 1];
|
|
168
|
+
const L = Math.hypot(bx - ax, bz - az);
|
|
169
|
+
const ux = (bx - ax) / L;
|
|
170
|
+
const uz = (bz - az) / L;
|
|
171
|
+
const ry = Math.atan2(-uz, ux);
|
|
172
|
+
const cuts = gates
|
|
173
|
+
.filter(g => g.leg === i)
|
|
174
|
+
.map(g => g.t)
|
|
175
|
+
.sort((p, q) => p - q);
|
|
176
|
+
const spans = [];
|
|
177
|
+
let s0 = 3.2;
|
|
178
|
+
for (const t of cuts) {
|
|
179
|
+
if (t - gateHalf > s0) spans.push([s0, t - gateHalf]);
|
|
180
|
+
s0 = t + gateHalf;
|
|
181
|
+
}
|
|
182
|
+
if (L - 3.2 > s0) spans.push([s0, L - 3.2]);
|
|
183
|
+
for (const [p0, p1] of spans) {
|
|
184
|
+
const n = Math.max(1, Math.round((p1 - p0) / 11));
|
|
185
|
+
for (let k = 0; k < n; k++) {
|
|
186
|
+
const t0 = p0 + ((p1 - p0) * k) / n;
|
|
187
|
+
const t1 = p0 + ((p1 - p0) * (k + 1)) / n;
|
|
188
|
+
const r = rng();
|
|
189
|
+
const end = k === 0 || k === n - 1;
|
|
190
|
+
if (r < 0.13 && !end) continue; // dismantled gap
|
|
191
|
+
wallRun(
|
|
192
|
+
stone,
|
|
193
|
+
space,
|
|
194
|
+
ax + ux * t0,
|
|
195
|
+
az + uz * t0,
|
|
196
|
+
ax + ux * t1,
|
|
197
|
+
az + uz * t1,
|
|
198
|
+
r < 0.3 && !end ? 2.5 + rng() * 2 : 6 + rng() * 1.6,
|
|
199
|
+
2.2,
|
|
200
|
+
wallColor(),
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (!gates.some(g => Math.hypot(g.x - ax, g.z - az) < 14)) tower(ax, az, 6, 12.5, ry);
|
|
205
|
+
if (i === wall.length - 2 && !gates.some(g => Math.hypot(g.x - bx, g.z - bz) < 14)) tower(bx, bz, 6, 12.5, ry);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
for (const g of gates) {
|
|
209
|
+
const x1 = g.x - g.ux * gateHalf;
|
|
210
|
+
const z1 = g.z - g.uz * gateHalf;
|
|
211
|
+
const x2 = g.x + g.ux * gateHalf;
|
|
212
|
+
const z2 = g.z + g.uz * gateHalf;
|
|
213
|
+
for (const [px, pz] of [
|
|
214
|
+
[x1, z1],
|
|
215
|
+
[x2, z2],
|
|
216
|
+
]) {
|
|
217
|
+
tower(px, pz, 5, 12.5, Math.atan2(-g.uz, g.ux));
|
|
218
|
+
lamp(px - g.nx * 3.5, pz - g.nz * 3.5);
|
|
219
|
+
}
|
|
220
|
+
const gx = g.x;
|
|
221
|
+
const gz = g.z;
|
|
222
|
+
const gy = ground(gx, gz);
|
|
223
|
+
const L = gateHalf * 2;
|
|
224
|
+
const ux = g.ux;
|
|
225
|
+
const uz = g.uz;
|
|
226
|
+
const rot = Math.atan2(-uz, ux);
|
|
227
|
+
const nx = -uz;
|
|
228
|
+
const nz = ux;
|
|
229
|
+
const wc = wallColor();
|
|
230
|
+
const span = L - 5;
|
|
231
|
+
stone.tv = gy;
|
|
232
|
+
stone.box(gx, gy + 5.4, gz, span + 0.6, 4.4, 4.6, wc, rot);
|
|
233
|
+
stone.box(gx, gy + 5.15, gz, span + 0.6, 0.3, 4.9, dim(wc, 0.85), rot);
|
|
234
|
+
for (const sg of [-1, 1]) {
|
|
235
|
+
const merlonCount = Math.round(span / 1.3);
|
|
236
|
+
for (let k = 0; k < merlonCount; k++) {
|
|
237
|
+
const t = ((k + 0.5) * span) / merlonCount - span / 2;
|
|
238
|
+
stone.box(gx + ux * t + nx * sg * 2.45, gy + 9.8, gz + uz * t + nz * sg * 2.45, 0.7, 0.85, 0.42, wc, rot);
|
|
239
|
+
stone.box(gx + ux * t + nx * sg * 2.42, gy + 8.85, gz + uz * t + nz * sg * 2.42, 0.36, 0.5, 0.5, dim(wc, 0.8), rot);
|
|
240
|
+
}
|
|
241
|
+
stone.box(gx + nx * sg * 2.33, gy + 6.6, gz + nz * sg * 2.33, 0.6, 1.3, 0.05, dark, rot);
|
|
242
|
+
}
|
|
243
|
+
for (let k = -6; k <= 6; k++)
|
|
244
|
+
wood.box(gx + ux * k * 0.6 + nx * 1.1, gy + 4.25, gz + uz * k * 0.6 + nz * 1.1, 0.09, 1.0, 0.09, [0.03, 0.028, 0.026], rot);
|
|
245
|
+
wood.box(gx + nx * 1.1, gy + 4.4, gz + nz * 1.1, span, 0.1, 0.1, [0.03, 0.028, 0.026], rot);
|
|
246
|
+
for (const sg of [-1, 1])
|
|
247
|
+
wood.box(
|
|
248
|
+
gx + ux * sg * (span / 2 - 0.15) - nx * 0.6,
|
|
249
|
+
gy - 0.1,
|
|
250
|
+
gz + uz * sg * (span / 2 - 0.15) - nz * 0.6,
|
|
251
|
+
0.18,
|
|
252
|
+
4.6,
|
|
253
|
+
span / 2 - 0.2,
|
|
254
|
+
color(0x3a2c20, 0.15, rng),
|
|
255
|
+
rot,
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
buildWallCulverts({ wall, streams, ground, stone, wallColor, shapes, transform, dark });
|
|
260
|
+
return { gates };
|
|
261
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monumental recessed pointed-arch portal gateway (for walled inns, compounds, and palace fronts) and its lighting
|
|
3
|
+
* descriptors: projecting piers, deep pointed arch with stepped shaded vault tiers, moulded frame, glazed tile frieze,
|
|
4
|
+
* crenellated crown, and open or shut timber doors. Worker-safe.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { dim } from '../math/color.js';
|
|
9
|
+
import { facePut } from './house-kit-frame.js';
|
|
10
|
+
import { addMerlonRow } from './fort-parts.js';
|
|
11
|
+
|
|
12
|
+
const STOREY = 5.2; // single storey height in metres
|
|
13
|
+
const HEIGHT = 10.4; // flanking range roof height in metres
|
|
14
|
+
const MERLON = 1.5;
|
|
15
|
+
const PASSAGE = 5; // clear doorway width in metres
|
|
16
|
+
const GATE_W = 15; // portal block width in metres
|
|
17
|
+
const GATE_OUT = 2.4; // projection proud of front wall in metres
|
|
18
|
+
const GATE_RISE = 2.6; // portal crown rise above flanking roof in metres
|
|
19
|
+
const ARCH = 4.2; // half-width of recessed portal opening in metres
|
|
20
|
+
const SPRING = 4.8; // arch springing height in metres
|
|
21
|
+
const PIER_LAMP = 3.2; // bracket lantern height on portal piers in metres
|
|
22
|
+
const HUNG_LAMP = 3.4; // chain-hung lantern height inside recess in metres
|
|
23
|
+
|
|
24
|
+
const FRONT_FACE = facePut(0, 0, 0);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Builds a monumental recessed pointed-arch portal gateway standing proud of a front wall at `z = half`.
|
|
28
|
+
* @param {object} kit - House-kit geometry builders (`{ stone, wall, wood }`).
|
|
29
|
+
* @param {number} half - Z coordinate of the front wall face in metres (`0` when placed standalone).
|
|
30
|
+
* @param {number[]} color - Linear RGB brick/stone colour `[r, g, b]`.
|
|
31
|
+
* @param {number[]} plaster - Linear RGB plaster colour `[r, g, b]`.
|
|
32
|
+
* @param {number[]} tile - Linear RGB glazed tile frieze colour `[r, g, b]`.
|
|
33
|
+
* @param {number[]} timber - Linear RGB door timber colour `[r, g, b]`.
|
|
34
|
+
* @param {object} options - Portal state and arch primitive bindings.
|
|
35
|
+
* @param {Function} options.archRing - House-kit `archRing` builder.
|
|
36
|
+
* @param {object} options.box - Unit box geometry (`shapes.box`).
|
|
37
|
+
* @param {boolean} [options.shut=false] - Whether the timber door leaves are closed across the passage.
|
|
38
|
+
* @param {number} [options.deep=1] - Foundation depth below `y = 0` in metres.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
export function buildPortalGateway(kit, half, color, plaster, tile, timber, { archRing, box, shut = false, deep = 1 }) {
|
|
42
|
+
const h = HEIGHT + GATE_RISE;
|
|
43
|
+
const pierW = GATE_W / 2 - ARCH;
|
|
44
|
+
const zMid = half + (GATE_OUT - 0.5) / 2;
|
|
45
|
+
const face = half + GATE_OUT;
|
|
46
|
+
const crown = SPRING + ARCH * 1.35;
|
|
47
|
+
for (const s of [-1, 1]) {
|
|
48
|
+
kit.stone.box(s * (ARCH + pierW / 2), -deep, zMid, pierW, h + deep, GATE_OUT + 0.5, color);
|
|
49
|
+
kit.stone.box(s * (ARCH + 0.7), 0.6, face + 0.05, 0.5, crown + 0.8, 0.2, dim(color, 1.12)); // frame jambs
|
|
50
|
+
if (shut) kit.wood.box(s * (PASSAGE / 4), 0, half + 0.1, PASSAGE / 2 - 0.04, 4.6, 0.2, timber);
|
|
51
|
+
else kit.wood.box(s * (PASSAGE / 2 - 0.1), 0, half - 1.3, 0.16, 4.4, 2.4, timber); // open leaf
|
|
52
|
+
}
|
|
53
|
+
kit.stone.box(0, crown + 0.6, zMid, GATE_W, h - crown - 0.6, GATE_OUT + 0.5, color); // spandrel block above arch
|
|
54
|
+
archRing(kit.stone, FRONT_FACE, dim(color, 1.06), 0, SPRING, ARCH, face - 0.35, 0.5, 0.7, 0.35, box);
|
|
55
|
+
for (let k = 0; k < 4; k++) {
|
|
56
|
+
const t = k / 4;
|
|
57
|
+
const depth = GATE_OUT * (1 - k * 0.2);
|
|
58
|
+
kit.stone.box(
|
|
59
|
+
0,
|
|
60
|
+
SPRING + ARCH * 1.35 * t,
|
|
61
|
+
half + depth / 2,
|
|
62
|
+
2 * ARCH * (1 - t * 0.7),
|
|
63
|
+
ARCH * 0.34 + 0.1,
|
|
64
|
+
depth,
|
|
65
|
+
dim(color, 0.55 - k * 0.06),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
kit.wall.box(0, 4.6, half + 0.05, PASSAGE + 0.2, STOREY + 1.2 - 4.6, 0.2, plaster); // tympanum over passage
|
|
69
|
+
kit.stone.box(0, 4.9, half + 0.18, PASSAGE - 1, 0.9, 0.1, tile);
|
|
70
|
+
kit.stone.box(0, crown + 0.9, face + 0.05, 2 * ARCH + 1.9, 0.5, 0.2, dim(color, 1.12)); // frame lintel
|
|
71
|
+
kit.stone.box(0, h - 2.3, face + 0.08, GATE_W - 1.6, 1.1, 0.2, tile); // glazed frieze band
|
|
72
|
+
for (let x = -GATE_W / 2 + 1.6; x < GATE_W / 2 - 1.4; x += 0.9) kit.stone.box(x, h - 2.05, face + 0.12, 0.45, 0.55, 0.1, dim(tile, 1.35));
|
|
73
|
+
addMerlonRow(kit.stone, GATE_W, h, face - 0.3, color, { width: MERLON, height: 0.9, depth: 0.6, step: MERLON * 2 });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns lantern and brazier descriptors for a recessed portal gateway placed at `(u, v, y)` in a town frame with its
|
|
78
|
+
* wall face at local `z = half`.
|
|
79
|
+
* @param {number} u - Portal centre U in metres.
|
|
80
|
+
* @param {number} v - Portal centre V in metres.
|
|
81
|
+
* @param {number} y - Floor elevation in metres.
|
|
82
|
+
* @param {number} half - Distance from origin to wall face in metres.
|
|
83
|
+
* @returns {{ lamps: Array<[number, number, number, number, number]>, fires: Array<[number, number]> }}
|
|
84
|
+
*/
|
|
85
|
+
export function portalGatewayLights(u, v, y, half) {
|
|
86
|
+
const pier = (ARCH + GATE_W / 2) / 2;
|
|
87
|
+
const face = half + GATE_OUT;
|
|
88
|
+
return {
|
|
89
|
+
lamps: [
|
|
90
|
+
[u - pier, v - face, y + PIER_LAMP, 0, 0],
|
|
91
|
+
[u + pier, v - face, y + PIER_LAMP, 0, 0],
|
|
92
|
+
[u, v - half - GATE_OUT / 2, y + HUNG_LAMP, SPRING - HUNG_LAMP, 0],
|
|
93
|
+
],
|
|
94
|
+
fires: [],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circular curtain fortification (intact or siege-breached): segmented ring curtain wall with crenellated parapet or
|
|
3
|
+
* stepped rubble breaks, battered footing, intact (crenellated and optionally roofed) or ruined round towers with
|
|
4
|
+
* protruding timbers, and a portcullis gatehouse. Worker-safe.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { dim } from '../math/color.js';
|
|
9
|
+
import { lerp, TAU } from '../math/scalar.js';
|
|
10
|
+
import { C as defaultColor, stick as defaultStick, TRS as defaultTransform } from './primitives.js';
|
|
11
|
+
import { addRadialMerlons } from './fort-parts.js';
|
|
12
|
+
|
|
13
|
+
const DEG = Math.PI / 180;
|
|
14
|
+
const DEFAULT_SEGMENTS = 96;
|
|
15
|
+
const DEFAULT_HEIGHT = 9.5;
|
|
16
|
+
const DEFAULT_THICK = 3.1;
|
|
17
|
+
const DEFAULT_TOWER_HEIGHT = 14.5;
|
|
18
|
+
const DEFAULT_TOWER_RADIUS = 3.8;
|
|
19
|
+
|
|
20
|
+
const angleDiff = (a, b) => ((((a - b) % TAU) + TAU + Math.PI) % TAU) - Math.PI;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Builds a circular curtain wall in segmented runs around `(city.x, city.z)` at `wallRadius`, optionally damaged by
|
|
24
|
+
* `wallDamage(angle, wide)` and slumped by `noise`, leaving a gate opening at `gateDeg`.
|
|
25
|
+
* @param {object} site - Cell-routed build site (`{ city, rng, ground, space, wallRadius, use, between, wallDamage, stoneCol, cell }`).
|
|
26
|
+
* @param {object} options - Dimensions, unit shapes and hooks.
|
|
27
|
+
* @param {object} options.rubbleStone - Angular rubble stone geometry placed on broken wall crowns.
|
|
28
|
+
* @param {(x: number, y: number, seed: number) => number} [options.noise] - Value noise for occasional natural slump.
|
|
29
|
+
* @param {(space: object, x: number, z: number, hx: number, hz: number, rot: number) => void} [options.addBox] - Box collider hook.
|
|
30
|
+
* @param {(site: object, x: number, z: number, radius: number, height: number) => void} [options.onHeap] - Rubble heap callback.
|
|
31
|
+
* @param {Function} [options.transform] - Transform matrix helper (`TRS`).
|
|
32
|
+
* @param {number} [options.segments=96] - Number of major segments around the circle.
|
|
33
|
+
* @param {number} [options.height=9.5] - Intact curtain height in metres.
|
|
34
|
+
* @param {number} [options.thick=3.1] - Curtain thickness in metres.
|
|
35
|
+
* @param {number} [options.gateDeg=270] - Bearing of the gate opening in degrees.
|
|
36
|
+
* @param {number} [options.gateHalfDeg=3] - Half-angle of the gate gap in degrees.
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
39
|
+
export function buildRingCurtain(
|
|
40
|
+
site,
|
|
41
|
+
{
|
|
42
|
+
rubbleStone,
|
|
43
|
+
noise = () => 0,
|
|
44
|
+
addBox = () => {},
|
|
45
|
+
onHeap = () => {},
|
|
46
|
+
transform = defaultTransform,
|
|
47
|
+
segments = DEFAULT_SEGMENTS,
|
|
48
|
+
height = DEFAULT_HEIGHT,
|
|
49
|
+
thick = DEFAULT_THICK,
|
|
50
|
+
gateDeg = 270,
|
|
51
|
+
gateHalfDeg = 3,
|
|
52
|
+
},
|
|
53
|
+
) {
|
|
54
|
+
const { city, rng, ground, space, wallRadius, use, between, wallDamage, stoneCol } = site;
|
|
55
|
+
for (let i = 0; i < segments; i++) {
|
|
56
|
+
const a0 = (i / segments) * TAU;
|
|
57
|
+
const a1 = ((i + 1) / segments) * TAU;
|
|
58
|
+
const am = (a0 + a1) / 2;
|
|
59
|
+
if (Math.abs(angleDiff(am, gateDeg * DEG)) < gateHalfDeg * DEG) continue;
|
|
60
|
+
use(city.x + Math.cos(am) * wallRadius, city.z + Math.sin(am) * wallRadius);
|
|
61
|
+
let top = 0;
|
|
62
|
+
const ox = Math.cos(am);
|
|
63
|
+
const oz = Math.sin(am);
|
|
64
|
+
const rot = Math.atan2(-Math.cos(am), -Math.sin(am));
|
|
65
|
+
const soot = wallDamage(am, 2.6);
|
|
66
|
+
for (let q = 0; q < 3; q++) {
|
|
67
|
+
const b0 = lerp(a0, a1, q / 3);
|
|
68
|
+
const b1 = lerp(a0, a1, (q + 1) / 3);
|
|
69
|
+
const bm = (b0 + b1) / 2;
|
|
70
|
+
const d = wallDamage(bm);
|
|
71
|
+
const slump = d === 0 && noise(bm * 14, 2.2, 77) > 0.86 ? 0.3 : 0;
|
|
72
|
+
const h = height * (1 - Math.max(d, slump)) * (d > 0 ? between(0.82, 1.12) : 1) - (d > 0 || slump ? between(0, 0.6) : 0);
|
|
73
|
+
if (h < 1.1) continue;
|
|
74
|
+
const mx = city.x + Math.cos(bm) * wallRadius;
|
|
75
|
+
const mz = city.z + Math.sin(bm) * wallRadius;
|
|
76
|
+
const y = ground(mx, mz) - 1.5;
|
|
77
|
+
const l = wallRadius * (b1 - b0) + 0.06;
|
|
78
|
+
const col = stoneCol(soot, 0.07);
|
|
79
|
+
site.cell.stone.box(mx, y, mz, l, h + 1.5, thick, col, rot);
|
|
80
|
+
top = Math.max(top, h);
|
|
81
|
+
if (q === 1) site.cell.stone.box(mx, y, mz, l * 3, 3.2, thick + 0.7, dim(col, 0.86), rot);
|
|
82
|
+
if (d === 0 && !slump) {
|
|
83
|
+
const px = mx + ox * (thick / 2 - 0.25);
|
|
84
|
+
const pz = mz + oz * (thick / 2 - 0.25);
|
|
85
|
+
site.cell.stone.box(px, y + h + 1.5, pz, l, 0.95, 0.5, col, rot);
|
|
86
|
+
site.cell.stone.box(px + oz * l * 0.2, y + h + 2.45, pz - ox * l * 0.2, l * 0.55, 0.85, 0.5, col, rot);
|
|
87
|
+
site.cell.stone.box(mx + ox * (thick / 2 + 0.12), y + h + 0.9, mz + oz * (thick / 2 + 0.12), l, 0.3, 0.3, dim(col, 0.85), rot);
|
|
88
|
+
} else if (rng() < 0.7)
|
|
89
|
+
site.cell.stone.add(
|
|
90
|
+
rubbleStone,
|
|
91
|
+
dim(col, 0.9),
|
|
92
|
+
transform(
|
|
93
|
+
mx + between(-0.4, 0.4),
|
|
94
|
+
y + h + 1.0,
|
|
95
|
+
mz + between(-0.4, 0.4),
|
|
96
|
+
l * 1.05,
|
|
97
|
+
1.5,
|
|
98
|
+
thick * 1.0,
|
|
99
|
+
rot + between(-0.3, 0.3),
|
|
100
|
+
between(-0.2, 0.2),
|
|
101
|
+
between(-0.2, 0.2),
|
|
102
|
+
),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const mx = city.x + ox * wallRadius;
|
|
106
|
+
const mz = city.z + oz * wallRadius;
|
|
107
|
+
if (top > 1.6) addBox(space, mx, mz, (wallRadius * (a1 - a0)) / 2 + 0.2, thick / 2 + 0.2, rot);
|
|
108
|
+
const d = wallDamage(am);
|
|
109
|
+
if (d > 0.05 && d < 0.98 && rng() < 0.8) {
|
|
110
|
+
const sgn = rng() < 0.6 ? 1 : -1;
|
|
111
|
+
onHeap(site, mx + ox * sgn * between(2.5, 4.5), mz + oz * sgn * between(2.5, 4.5), between(2.4, 4.2), between(0.7, 1.9) * d + 0.3);
|
|
112
|
+
} else if (d === 0 && rng() < 0.1) onHeap(site, mx - ox * 3, mz - oz * 3, between(1.6, 2.6), between(0.4, 0.8));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Builds a round tower on a circular curtain wall at bearing `deg`: intact (crenellated and optionally capped with a
|
|
118
|
+
* conical roof) when `frac === 1`, or broken open with jagged masonry, charred rafters, and fallen rubble when `frac < 1`.
|
|
119
|
+
* @param {object} site - Cell-routed build site.
|
|
120
|
+
* @param {number} deg - Bearing around the curtain ring in degrees.
|
|
121
|
+
* @param {number} frac - Standing fraction of full tower height (`1` for intact).
|
|
122
|
+
* @param {boolean} roof - Whether an intact tower carries a conical roof.
|
|
123
|
+
* @param {object} options - Unit shapes, dimensions and hooks.
|
|
124
|
+
* @param {object} options.shapes - Unit shapes (`{ cyl16, cone16, box }`).
|
|
125
|
+
* @param {(space: object, x: number, z: number, radius: number) => void} [options.addCircle] - Circle collider hook.
|
|
126
|
+
* @param {(site: object, x: number, z: number, radius: number, height: number) => void} [options.onHeap] - Rubble heap callback.
|
|
127
|
+
* @param {(builder: object, x: number, y: number, z: number, yaw: number, scale: number) => void} [options.onPerched] - Optional perched bird callback on intact merlons.
|
|
128
|
+
* @param {(hex: number, jitter?: number, rng?: () => number) => number[]} [options.color] - Linear RGB colour helper.
|
|
129
|
+
* @param {Function} [options.transform] - Transform matrix helper (`TRS`).
|
|
130
|
+
* @param {Function} [options.stick] - Beam placement helper (`stick`).
|
|
131
|
+
* @param {number} [options.towerHeight=14.5] - Full tower height in metres.
|
|
132
|
+
* @param {number} [options.towerRadius=3.8] - Tower shaft radius in metres.
|
|
133
|
+
* @returns {void}
|
|
134
|
+
*/
|
|
135
|
+
export function buildRingTower(
|
|
136
|
+
site,
|
|
137
|
+
deg,
|
|
138
|
+
frac,
|
|
139
|
+
roof,
|
|
140
|
+
{
|
|
141
|
+
shapes,
|
|
142
|
+
addCircle = () => {},
|
|
143
|
+
onHeap = () => {},
|
|
144
|
+
onPerched = null,
|
|
145
|
+
color = defaultColor,
|
|
146
|
+
transform = defaultTransform,
|
|
147
|
+
stick = defaultStick,
|
|
148
|
+
towerHeight = DEFAULT_TOWER_HEIGHT,
|
|
149
|
+
towerRadius = DEFAULT_TOWER_RADIUS,
|
|
150
|
+
},
|
|
151
|
+
) {
|
|
152
|
+
const { city, rng, ground, space, wallRadius, use, between, charcoal, wallDamage, stoneCol } = site;
|
|
153
|
+
const a = deg * DEG;
|
|
154
|
+
const rad = towerRadius;
|
|
155
|
+
const x = city.x + Math.cos(a) * (wallRadius + 0.9);
|
|
156
|
+
const z = city.z + Math.sin(a) * (wallRadius + 0.9);
|
|
157
|
+
use(x, z);
|
|
158
|
+
const y = ground(x, z);
|
|
159
|
+
const h = towerHeight * frac;
|
|
160
|
+
const col = stoneCol(wallDamage(a, 2.6), 0.06);
|
|
161
|
+
const dk = dim(col, 0.85);
|
|
162
|
+
site.cell.stone.add(shapes.cyl16, dk, transform(x, y - 1.5, z, rad * 2 + 1.4, 4.4, rad * 2 + 1.4));
|
|
163
|
+
site.cell.stone.add(shapes.cyl16, col, transform(x, y, z, rad * 2, h, rad * 2));
|
|
164
|
+
for (let q = 0; q < 6; q++) {
|
|
165
|
+
const sa = a + ((q % 3) - 1) * 0.85;
|
|
166
|
+
const hh = 3.4 + (q > 2 ? 4.6 : 0) + (q % 3 === 1 ? 1.2 : 0);
|
|
167
|
+
if (hh < h - 1.6)
|
|
168
|
+
site.cell.cloth.box(
|
|
169
|
+
x + Math.cos(sa) * (rad - 0.07),
|
|
170
|
+
y + hh,
|
|
171
|
+
z + Math.sin(sa) * (rad - 0.07),
|
|
172
|
+
0.2,
|
|
173
|
+
1.35,
|
|
174
|
+
0.2,
|
|
175
|
+
[0.01, 0.01, 0.01],
|
|
176
|
+
Math.PI / 2 - sa,
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (frac === 1) {
|
|
180
|
+
site.cell.stone.add(shapes.cyl16, dk, transform(x, y + h - 0.5, z, rad * 2 + 1.0, 1.35, rad * 2 + 1.0));
|
|
181
|
+
site.cell.cloth.add(shapes.cyl16, [0.03, 0.028, 0.026], transform(x, y + h + 0.86, z, rad * 2 - 0.2, 0.05, rad * 2 - 0.2));
|
|
182
|
+
addRadialMerlons(site.cell.stone, x, y + h + 0.85, z, rad + 0.22, 10, 1.3, 1.0, 0.55, col, { scaleFirst: true });
|
|
183
|
+
if (roof) {
|
|
184
|
+
site.cell.wood.add(shapes.cyl16, color(0x2a211b), transform(x, y + h + 1.85, z, rad * 2 + 1.5, 0.16, rad * 2 + 1.5));
|
|
185
|
+
site.cell.roof.add(shapes.cone16, color(0x4a342c, 0.12, rng), transform(x, y + h + 2.0, z, rad * 2 + 1.5, 4.8, rad * 2 + 1.5));
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
const hi = rng() * TAU;
|
|
189
|
+
site.cell.cloth.add(shapes.cyl16, [0.012, 0.011, 0.01], transform(x, y + h - 0.05, z, rad * 2 - 1.5, 0.08, rad * 2 - 1.5));
|
|
190
|
+
for (let q = 0; q < 9; q++) {
|
|
191
|
+
const qa = (q * TAU) / 9;
|
|
192
|
+
const hh = 0.3 + 3.6 * Math.max(0, Math.cos(qa - hi)) ** 2 * between(0.6, 1.2) + between(0, 0.6);
|
|
193
|
+
site.cell.stone.box(
|
|
194
|
+
x + Math.cos(qa) * (rad - 0.42),
|
|
195
|
+
y + h - 0.2,
|
|
196
|
+
z + Math.sin(qa) * (rad - 0.42),
|
|
197
|
+
2.72,
|
|
198
|
+
hh + 0.2,
|
|
199
|
+
0.84,
|
|
200
|
+
dim(col, between(0.85, 1.1)),
|
|
201
|
+
Math.PI / 2 - qa,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
for (let q = 0; q < 3; q++)
|
|
205
|
+
stick(
|
|
206
|
+
site.cell.wood,
|
|
207
|
+
[x + between(-1.5, 1.5), y + h - between(0.5, 2.5), z + between(-1.5, 1.5)],
|
|
208
|
+
[x + between(-3.4, 3.4), y + h + between(0.2, 1.4), z + between(-3.4, 3.4)],
|
|
209
|
+
0.2,
|
|
210
|
+
charcoal(),
|
|
211
|
+
shapes.box,
|
|
212
|
+
);
|
|
213
|
+
onHeap(site, x + Math.cos(hi + Math.PI) * (rad + 2.2), z + Math.sin(hi + Math.PI) * (rad + 2.2), between(3.2, 4.4), between(1.2, 2.2));
|
|
214
|
+
use(x, z);
|
|
215
|
+
}
|
|
216
|
+
if (frac >= 1 && rng() < 0.7 && onPerched) {
|
|
217
|
+
const qa = (((rng() * 10) | 0) * TAU) / 10;
|
|
218
|
+
onPerched(site.cell.cloth, x + Math.cos(qa) * (rad + 0.22), y + h + 1.85, z + Math.sin(qa) * (rad + 0.22), rng() * 6, between(1.5, 2));
|
|
219
|
+
}
|
|
220
|
+
addCircle(space, x, z, rad + 0.25);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Builds the gatehouse bridge spanning the north opening of a circular curtain wall, with battlements, a jammed
|
|
225
|
+
* portcullis, an ajar timber leaf, and a fallen door beam.
|
|
226
|
+
* @param {object} site - Cell-routed build site.
|
|
227
|
+
* @param {object} options - Unit shapes, thickness and helpers.
|
|
228
|
+
* @param {object} options.shapes - Unit shapes (`{ box }`).
|
|
229
|
+
* @param {number} [options.thick=3.1] - Curtain thickness in metres.
|
|
230
|
+
* @param {(hex: number, jitter?: number, rng?: () => number) => number[]} [options.color] - Linear RGB colour helper.
|
|
231
|
+
* @param {Function} [options.stick] - Beam placement helper (`stick`).
|
|
232
|
+
* @returns {void}
|
|
233
|
+
*/
|
|
234
|
+
export function buildRingGate(site, { shapes, thick = DEFAULT_THICK, color = defaultColor, stick = defaultStick }) {
|
|
235
|
+
const { city, ground, wallRadius, use, stoneCol } = site;
|
|
236
|
+
const x = city.x;
|
|
237
|
+
const z = city.z - wallRadius;
|
|
238
|
+
const y = ground(x, z);
|
|
239
|
+
const col = stoneCol(0, 0.05);
|
|
240
|
+
const dk = [0.012, 0.011, 0.01];
|
|
241
|
+
use(x, z);
|
|
242
|
+
site.cell.stone.box(x, y + 4.7, z, 6.2, 6.0, thick + 0.6, col);
|
|
243
|
+
site.cell.stone.box(x, y + 10.7, z - thick / 2 - 0.05, 6.2, 0.95, 0.5, col);
|
|
244
|
+
for (const sg of [-1, 0, 1]) site.cell.stone.box(x + sg * 2.1, y + 11.65, z - thick / 2 - 0.05, 1.15, 0.85, 0.5, col);
|
|
245
|
+
site.cell.stone.box(x, y + 4.2, z, 6.0, 0.5, thick + 0.9, dim(col, 0.8));
|
|
246
|
+
site.cell.cloth.box(x, y + 4.15, z, 5.6, 0.06, thick + 0.4, dk);
|
|
247
|
+
for (let q = -4; q <= 4; q++) site.cell.cloth.box(x + q * 0.56, y + 2.3, z - 0.9, 0.09, 1.9, 0.09, [0.03, 0.03, 0.032]);
|
|
248
|
+
for (const hh of [2.5, 3.4]) site.cell.cloth.box(x, y + hh, z - 0.9, 5.2, 0.09, 0.07, [0.03, 0.03, 0.032]);
|
|
249
|
+
site.cell.wood.box(x + 2.3, y - 0.1, z + 2.6, 0.16, 3.9, 2.3, color(0x35271c), 0.5, 0, 0.04);
|
|
250
|
+
stick(site.cell.wood, [x - 2.6, y, z + 2.2], [x - 0.4, y + 0.25, z + 4.2], 0.2, color(0x35271c), shapes.box);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Builds a complete circular fortification: curtain wall, tower ring, gatehouse, and optional breach rubble fans.
|
|
255
|
+
* @param {object} site - Cell-routed build site.
|
|
256
|
+
* @param {object} options - Tower list, breach list, unit shapes, and hooks.
|
|
257
|
+
* @param {Array<[number, number, boolean]>} options.towers - `[deg, standingFraction, roofed]` tuples.
|
|
258
|
+
* @param {Array<Array<any>>} [options.breaches=[]] - `[deg, half, depth, rubble, way]` breach tuples.
|
|
259
|
+
* @param {(site: object, deg: number, half: number, rubble: number, way: number) => void} [options.onBreachFan] - Breach rubble fan builder.
|
|
260
|
+
* @returns {void}
|
|
261
|
+
*/
|
|
262
|
+
export function buildRingFortification(site, { towers, breaches = [], onBreachFan = () => {}, ...rest }) {
|
|
263
|
+
buildRingCurtain(site, rest);
|
|
264
|
+
for (const [deg, frac, roofed] of towers) buildRingTower(site, deg, frac, roofed, rest);
|
|
265
|
+
buildRingGate(site, rest);
|
|
266
|
+
for (const [deg, half, , rubble, way] of breaches) if (rubble) onBreachFan(site, deg, half, rubble, way);
|
|
267
|
+
}
|