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,223 @@
|
|
|
1
|
+
// What stands on a courtyard house's roof: a wind tower, a ribbed dome on its drum, a room set back from the front, an open
|
|
2
|
+
// sleeping gallery, and the terrace's awning, washing, jars and pigeon cote. Worker-safe.
|
|
3
|
+
import { dim } from '../math/color.js';
|
|
4
|
+
import { pickR } from '../math/random.js';
|
|
5
|
+
import { TAU } from '../math/scalar.js';
|
|
6
|
+
import { C, TRS } from './primitives.js';
|
|
7
|
+
import { blockFaces } from './house-kit-courtyard-parts.js';
|
|
8
|
+
import { facePut } from './house-kit-frame.js';
|
|
9
|
+
|
|
10
|
+
const RIBS = 12,
|
|
11
|
+
RIB_STEPS = 6, // the pieces of a rib from the dome's foot to its crown; in a lean kit (the kit frame's kitNew) fewer
|
|
12
|
+
LEAN_RIB_STEPS = 3,
|
|
13
|
+
DRUM = 0.75; // a dome's drum on a house; a palace's hall raises its dome higher
|
|
14
|
+
/** A wind tower's side, in metres. */
|
|
15
|
+
export const WIND_TOWER = 1.9;
|
|
16
|
+
const TOWER = WIND_TOWER;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An open sleeping gallery's solid parts: a back wall of piers, two front piers and its finished roof, each handed to `box`.
|
|
20
|
+
* The same parts serve a house built near and a town's far boxes, so the gallery's silhouette is the same at both.
|
|
21
|
+
* @param {{x: number, z: number, w: number, h: number, d: number, cap: number[]}} g - The gallery: its middle, width, height
|
|
22
|
+
* and depth on the roof (metres), and its roof's colour.
|
|
23
|
+
* @param {number[]} render - The piers' colour.
|
|
24
|
+
* @param {(x: number, y: number, z: number, w: number, h: number, d: number, colour: number[]) => void} box - Adds a box
|
|
25
|
+
* standing on its foot.
|
|
26
|
+
*/
|
|
27
|
+
export function galleryParts(g, render, box) {
|
|
28
|
+
const { x, z, w, h, d } = g,
|
|
29
|
+
pier = 0.42,
|
|
30
|
+
back = z - d / 2 + 0.32,
|
|
31
|
+
front = z + d / 2 - 0.32;
|
|
32
|
+
box(x, 0, back, w - 0.28, h + 0.12, pier, render);
|
|
33
|
+
for (const side of [-1, 1]) box(x + side * ((w - pier) / 2 - 0.14), 0, front, pier, h + 0.12, pier, render);
|
|
34
|
+
box(x, h + 0.12, z, w, 0.24, d, g.cap);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What stands on a courtyard house's roof, bound to the kit's shapes, frame, palette and parts.
|
|
39
|
+
* @param {object} o
|
|
40
|
+
* @param {object} o.U - The unit shapes.
|
|
41
|
+
* @param {Function} o.kitPush - The kit frame's push.
|
|
42
|
+
* @param {Function} o.kitPop - The kit frame's pop.
|
|
43
|
+
* @param {object} o.palette - The house palette.
|
|
44
|
+
* @param {object} o.parts - The courtyard parts (`createCourtyardParts`).
|
|
45
|
+
* @returns {object} `windTower(kit, look, x, z, base, h)`; `ribbedDome(kit, look, x, z, y, r, colour, drum)`; `terrace(kit,
|
|
46
|
+
* look, spec, avoid)`, the terrace's furniture kept clear of `avoid` ([x, z, half-width, half-depth] each); `roofRoom(kit, look,
|
|
47
|
+
* up, h)`, a room [x, z, w, d, height] on the roof at h; `roofGallery(kit, g, h, render, timber)`. `look` is the house's look
|
|
48
|
+
* (house-kit-courtyard.js).
|
|
49
|
+
*/
|
|
50
|
+
export function createCourtyardRoof({ U, kitPush, kitPop, palette, parts }) {
|
|
51
|
+
const WARM = palette.windowLight,
|
|
52
|
+
{ courtyardDoor, courtyardWindow, parapet, waterJar } = parts;
|
|
53
|
+
// A wind tower: a square shaft standing over the roof, slotted at its head on all four sides to catch the breeze, capped.
|
|
54
|
+
function windTower(kit, look, x, z, base, h) {
|
|
55
|
+
const s = TOWER;
|
|
56
|
+
kit.wall.box(x, base, z, s, h, s, look.render);
|
|
57
|
+
const faces = blockFaces(x, z, s, s),
|
|
58
|
+
top = base + h;
|
|
59
|
+
for (const put of faces) {
|
|
60
|
+
for (let k = 0; k < 3; k++) put(kit.glass, U.quad, [0, 0, 0], (k - 1) * 0.55, top - 1.5, 0.02, 0.32, 1.15, 1);
|
|
61
|
+
for (let k = 0; k < 4; k++) put(kit.wall, U.boxF, dim(look.render, 1.03), (k - 1.5) * 0.55, top - 1.55, 0.06, 0.14, 1.25, 0.12); // fins between the slots
|
|
62
|
+
put(kit.wood, U.boxF, look.timber, 0, top - 1.7, 0.08, s + 0.1, 0.12, 0.14);
|
|
63
|
+
}
|
|
64
|
+
kit.wall.box(x, top, z, s + 0.36, 0.18, s + 0.36, dim(look.render, 1.05));
|
|
65
|
+
for (const [dx, dz] of [
|
|
66
|
+
[-1, -1],
|
|
67
|
+
[1, -1],
|
|
68
|
+
[-1, 1],
|
|
69
|
+
[1, 1],
|
|
70
|
+
])
|
|
71
|
+
kit.wall.box(x + (dx * s) / 2.4, top + 0.18, z + (dz * s) / 2.4, 0.36, 0.42, 0.36, look.render);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// A dome of radius r on a drum, over a room whose roof is at y: glazed tile or plaster, ribs running from its foot to its
|
|
75
|
+
// crown, small lights round its drum, and a finial of brass.
|
|
76
|
+
function ribbedDome(kit, look, x, z, y, r, col, drum = DRUM) {
|
|
77
|
+
const lights = Math.max(8, Math.round(r * 2.4)),
|
|
78
|
+
size = drum / DRUM;
|
|
79
|
+
kit.wall.add(U.cyl16, dim(look.render, 1.02), TRS(x, y, z, r * 2.1, drum, r * 2.1));
|
|
80
|
+
for (let q = 0; q < lights; q++) {
|
|
81
|
+
const a = ((q + 0.5) * TAU) / lights;
|
|
82
|
+
kitPush(x, 0, z, a);
|
|
83
|
+
facePut(0, 0, r * 1.03)(
|
|
84
|
+
kit.glass,
|
|
85
|
+
U.quad,
|
|
86
|
+
look.R() < look.litP ? WARM[1] : [0, 0, 0],
|
|
87
|
+
0,
|
|
88
|
+
y + 0.15 * size,
|
|
89
|
+
0.02,
|
|
90
|
+
0.22 * size,
|
|
91
|
+
0.42 * size,
|
|
92
|
+
1,
|
|
93
|
+
);
|
|
94
|
+
kitPop();
|
|
95
|
+
}
|
|
96
|
+
kit.wall.add(U.cyl16, dim(look.render, 1.07), TRS(x, y + drum, z, r * 2.2, 0.12, r * 2.2));
|
|
97
|
+
const k = 1.0, // the dome's rise over its radius
|
|
98
|
+
base = y + drum + 0.12;
|
|
99
|
+
kit.roof.add(U.dome16, col, TRS(x, base, z, r * 2, r * 2 * k, r * 2));
|
|
100
|
+
const ribCol = dim(col, col[2] > col[0] ? 1.35 : 1.08),
|
|
101
|
+
steps = kit.lean ? LEAN_RIB_STEPS : RIB_STEPS;
|
|
102
|
+
for (let q = 0; q < RIBS; q++) {
|
|
103
|
+
const az = (q * TAU) / RIBS;
|
|
104
|
+
for (let i = 0; i < steps; i++) {
|
|
105
|
+
const t = ((i + 0.5) / steps) * (Math.PI / 2),
|
|
106
|
+
rr = (r + 0.08) * Math.cos(t),
|
|
107
|
+
yy = base + (r + 0.08) * k * Math.sin(t);
|
|
108
|
+
kit.wall.add(
|
|
109
|
+
U.box,
|
|
110
|
+
ribCol,
|
|
111
|
+
TRS(x + Math.sin(az) * rr, yy, z + Math.cos(az) * rr, 0.12, 0.1, ((Math.PI / 2) * r) / steps + 0.06, az, -(t + Math.PI / 2)), // along the meridian, its depth into the dome
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const top = base + r * k;
|
|
116
|
+
kit.cloth.add(U.cyl6, look.brass, TRS(x, top - 0.05, z, 0.14, 0.5, 0.14));
|
|
117
|
+
kit.cloth.add(U.sph, look.brass, TRS(x, top + 0.42, z, 0.3, 0.3, 0.3));
|
|
118
|
+
kit.cloth.add(U.sph, look.brass, TRS(x, top + 0.7, z, 0.2, 0.2, 0.2));
|
|
119
|
+
kit.cloth.add(U.cone6, look.brass, TRS(x, top + 0.8, z, 0.08, 0.7, 0.08));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// What lives on a roof terrace: an awning of cloth on poles, washing on a line, jars and a mat, here and there a pigeon cote.
|
|
123
|
+
function terrace(kit, look, s, avoid) {
|
|
124
|
+
const { w, d, h, shade } = s,
|
|
125
|
+
shelter = s.gallery ?? shade,
|
|
126
|
+
R = look.R,
|
|
127
|
+
free = (x, z, r) => !avoid.some(a => Math.abs(x - a[0]) < a[2] + r && Math.abs(z - a[1]) < a[3] + r);
|
|
128
|
+
if (shade || R() < look.awningP) {
|
|
129
|
+
const aw = shade ? shade.w : Math.min(w - 1.4, 3 + R() * 2),
|
|
130
|
+
ad = shade ? shade.d : Math.min(d - 1.4, 2.4 + R() * 1.6),
|
|
131
|
+
ax = shade ? (shade.x ?? 0) : (R() - 0.5) * (w - aw - 1),
|
|
132
|
+
az = shade ? shade.z : (R() - 0.5) * (d - ad - 1);
|
|
133
|
+
if (shade || free(ax, az, Math.max(aw, ad) / 2)) {
|
|
134
|
+
const cloth = shade?.col ?? C(pickR(R, look.awnings), 0.1, R);
|
|
135
|
+
for (const [px, pz] of [
|
|
136
|
+
[-1, -1],
|
|
137
|
+
[1, -1],
|
|
138
|
+
[-1, 1],
|
|
139
|
+
[1, 1],
|
|
140
|
+
])
|
|
141
|
+
kit.wood.add(
|
|
142
|
+
U.cyl6,
|
|
143
|
+
look.timber,
|
|
144
|
+
TRS(ax + (px * aw) / 2, h, az + (pz * ad) / 2, 0.08, shade ? 2.42 + aw * 0.02 : 2.3 + (pz > 0 ? 0 : 0.3), 0.08),
|
|
145
|
+
);
|
|
146
|
+
for (const sg of [-1, 1])
|
|
147
|
+
kit.cloth.add(
|
|
148
|
+
U.box,
|
|
149
|
+
dim(cloth, sg > 0 ? 1 : 0.92),
|
|
150
|
+
TRS(ax + (sg * aw) / 4, h + 2.42, az, aw / 2 + 0.05, 0.03, ad + 0.2, 0, 0, sg * 0.08),
|
|
151
|
+
);
|
|
152
|
+
kit.cloth.add(U.box, dim(cloth, 0.6), TRS(ax, h + 0.02, az, aw * 0.8, 0.03, ad * 0.7)); // a mat in its shade
|
|
153
|
+
avoid.push([ax, az, aw / 2, ad / 2]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (R() < 0.55) {
|
|
157
|
+
const lz = (R() - 0.5) * (d - 2),
|
|
158
|
+
lx0 = -w / 2 + 0.8,
|
|
159
|
+
lx1 = w / 2 - 0.8;
|
|
160
|
+
if (free(0, lz, 0.3) && (!shelter || Math.abs(lz - shelter.z) > shelter.d / 2 + 0.3)) {
|
|
161
|
+
for (const x of [lx0, lx1]) kit.wood.add(U.cyl6, look.timber, TRS(x, h, lz, 0.06, 1.9, 0.06));
|
|
162
|
+
kit.cloth.add(U.box, [0.03, 0.03, 0.03], TRS(0, h + 1.85, lz, lx1 - lx0, 0.02, 0.02));
|
|
163
|
+
const nl = 3 + ((R() * 4) | 0);
|
|
164
|
+
for (let q = 0; q < nl; q++) {
|
|
165
|
+
const cw = 0.4 + R() * 0.5,
|
|
166
|
+
ch = 0.5 + R() * 0.6;
|
|
167
|
+
kit.cloth.add(
|
|
168
|
+
U.box,
|
|
169
|
+
C(pickR(R, look.washing), 0.1, R),
|
|
170
|
+
TRS(lx0 + ((q + 0.5) * (lx1 - lx0)) / nl, h + 1.85 - ch, lz, cw, ch, 0.03),
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const nj = (R() * 4) | 0;
|
|
176
|
+
for (let q = 0; q < nj; q++) {
|
|
177
|
+
const x = (R() - 0.5) * (w - 1.6),
|
|
178
|
+
z = (R() - 0.5) * (d - 1.6);
|
|
179
|
+
if (free(x, z, 0.4))
|
|
180
|
+
waterJar(
|
|
181
|
+
kit.cloth,
|
|
182
|
+
(gb, geo, col, u, y, out, sx, sy, sz, rz, rx) => gb.add(geo, col, TRS(x + u, h + y, z + out, sx, sy, sz, 0, rx || 0, rz || 0)),
|
|
183
|
+
0,
|
|
184
|
+
0,
|
|
185
|
+
0.7 + R() * 0.4,
|
|
186
|
+
look.clay,
|
|
187
|
+
R,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// A room on the roof, set back from the front: its walls, a door onto the terrace and a window, and a low parapet of its own.
|
|
193
|
+
function roofRoom(kit, look, up, h) {
|
|
194
|
+
const [x, z, w, d, rh] = up;
|
|
195
|
+
kit.wall.box(x, h, z, w, rh, d, dim(look.render, 1.02));
|
|
196
|
+
const faces = blockFaces(x, z, w, d);
|
|
197
|
+
kitPush(0, h, 0);
|
|
198
|
+
courtyardDoor(kit, faces[0], -w * 0.2, { ...look, w: 0.95, h: 2.0, benches: false, lamp: null });
|
|
199
|
+
courtyardWindow(kit, faces[0], w * 0.25, 1.05, 0.55, 0.7, {
|
|
200
|
+
...look,
|
|
201
|
+
lit: look.R() < look.litP ? WARM[2] : null,
|
|
202
|
+
screen: look.R() < 0.4,
|
|
203
|
+
dry: true,
|
|
204
|
+
});
|
|
205
|
+
for (const f of [2, 3]) if (look.R() < 0.5) courtyardWindow(kit, faces[f], 0, 1.1, 0.45, 0.6, { ...look, lit: null, dry: true });
|
|
206
|
+
kitPop();
|
|
207
|
+
kitPush(x, 0, z);
|
|
208
|
+
parapet(kit, look.house, w, d, h + rh, { render: look.render, ph: 0.45, spoutFaces: [], faces, timber: look.timber });
|
|
209
|
+
kitPop();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// The open sleeping gallery on a roof, its edge beam and the ends of its joists.
|
|
213
|
+
function roofGallery(kit, g, h, render, timber) {
|
|
214
|
+
galleryParts(g, render, (x, y, z, w, rh, d, col) => kit.wall.box(x, h + y, z, w, rh, d, col));
|
|
215
|
+
// The edge beam and the exposed ends of the joists sit below the rolled roof.
|
|
216
|
+
kit.wood.box(g.x, h + g.h - 0.18, g.z + g.d / 2 - 0.28, g.w - 0.28, 0.22, 0.3, timber);
|
|
217
|
+
const joists = Math.ceil(g.w / 0.85);
|
|
218
|
+
for (let i = 0; i < joists; i++)
|
|
219
|
+
kit.wood.box(g.x + ((i + 0.5) / joists - 0.5) * (g.w - 0.35), h + g.h, g.z + g.d / 2 - 0.16, 0.18, 0.14, 0.38, timber);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return { ribbedDome, roofGallery, roofRoom, terrace, windTower };
|
|
223
|
+
}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
// A courtyard house (form `courtyard` of the house kit): a flat-roofed block of mud brick under render, a tower of six faces,
|
|
2
|
+
// or four wings round an open court; storeys marked by the ends of their floor beams; small windows low down and screened
|
|
3
|
+
// ones above; a carved door; the parapet with its spouts; and on the roof a terrace with a room, a wind tower, a ribbed dome,
|
|
4
|
+
// an awning, washing and jars, reached by a stair up the outside. What a far version shows (the blocks, the room, the tower
|
|
5
|
+
// and the dome) is in the spec, so near and far are the same house. Worker-safe.
|
|
6
|
+
//
|
|
7
|
+
// Its spec, beside the kit's (x, z, w, d, h, ry): `n` storeys; `col` the render's colour and `brick` the brick's; `fired`, the
|
|
8
|
+
// plinth's and sills' colours if not the palette's; `bare` (0..1), how much render has fallen away (over a half: bare brick);
|
|
9
|
+
// `party` [back, +x, -x], how high neighbours cover those faces; `found`, metres of foundation; `doorK`, the front's bay with
|
|
10
|
+
// the door (`doorAlong`); `shop`, `loadingBay`, `screens` (the share of upper windows screened), `awning` (the terrace's
|
|
11
|
+
// share), `buttress`, `stair` (the face, 2 or 3, of a stair up the outside), `crenel`; `hex` for a six-faced tower; `court`
|
|
12
|
+
// [w, d] for wings round a court; and on the roof `gallery` ({x, z, w, h, d, cap}), `up` [x, z, w, d, height] (a room), `wind` [x,
|
|
13
|
+
// z, base] and `windH` (a wind tower), `dome` [x, z, r, base, drum] and `rc` (its colour), `watchTower` (a roof kept clear).
|
|
14
|
+
import { dim } from '../math/color.js';
|
|
15
|
+
import { pickR } from '../math/random.js';
|
|
16
|
+
import { TAU } from '../math/scalar.js';
|
|
17
|
+
import { C, TRS } from './primitives.js';
|
|
18
|
+
import { blockFaces, MERLON, PARAPET } from './house-kit-courtyard-parts.js';
|
|
19
|
+
import { WIND_TOWER as TOWER } from './house-kit-courtyard-roof.js';
|
|
20
|
+
import { facePut } from './house-kit-frame.js';
|
|
21
|
+
import { kitStain } from './house-kit-marks.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* How many bays a courtyard house's face `len` metres long has: a door, a shop or a window to each.
|
|
25
|
+
* @param {number} len - The face's length, metres.
|
|
26
|
+
* @returns {number}
|
|
27
|
+
*/
|
|
28
|
+
export const baysOf = len => Math.max(1, Math.floor((len - 0.6) / 2.6));
|
|
29
|
+
/**
|
|
30
|
+
* Where along a courtyard house's front, w metres wide, the door of its spec stands.
|
|
31
|
+
* @param {number} w - The front's width, metres.
|
|
32
|
+
* @param {number} doorK - The spec's `doorK`: the bay of the door.
|
|
33
|
+
* @returns {number} Metres from the front's middle, toward +x.
|
|
34
|
+
*/
|
|
35
|
+
export function doorAlong(w, doorK) {
|
|
36
|
+
const nc = baysOf(w);
|
|
37
|
+
return ((doorK % nc) + 0.5 - nc / 2) * (w / nc);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The `doorK` that sets a courtyard house's door in the middle bay of its front, w metres wide (the nearer the middle of two).
|
|
41
|
+
* @param {number} w - The front's width, metres.
|
|
42
|
+
* @returns {number}
|
|
43
|
+
*/
|
|
44
|
+
export const middleDoor = w => baysOf(w) >> 1;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The courtyard house, bound to the kit's shapes, frame, palette and courtyard palette.
|
|
48
|
+
* @param {object} o
|
|
49
|
+
* @param {object} o.U - The unit shapes.
|
|
50
|
+
* @param {Function} o.kitPush - The kit frame's push.
|
|
51
|
+
* @param {Function} o.kitPop - The kit frame's pop.
|
|
52
|
+
* @param {object} o.palette - The house palette.
|
|
53
|
+
* @param {object} o.courtyard - The courtyard palette (`COURTYARD_PALETTE`'s keys).
|
|
54
|
+
* @param {object} o.parts - The courtyard parts (`createCourtyardParts`).
|
|
55
|
+
* @param {object} o.roof - What stands on its roof (`createCourtyardRoof`).
|
|
56
|
+
* @returns {{kitCourtyardHouse: Function}} `kitCourtyardHouse(kit, house, spec)`: the house a form `courtyard` spec asks for;
|
|
57
|
+
* its style's `rich` gives it a richer door.
|
|
58
|
+
*/
|
|
59
|
+
export function createCourtyardHouse({ U, kitPush, kitPop, palette, courtyard, parts, roof }) {
|
|
60
|
+
const WARM = palette.windowLight,
|
|
61
|
+
{ beamEnds, courtyardDoor, courtyardWindow, lantern, parapet, shopFront, waterJar } = parts,
|
|
62
|
+
{ ribbedDome, roofGallery, roofRoom, terrace, windTower } = roof;
|
|
63
|
+
|
|
64
|
+
// The colours and choices one house carries through its parts.
|
|
65
|
+
function houseLook(house, s) {
|
|
66
|
+
const R = house.R,
|
|
67
|
+
common = courtyard;
|
|
68
|
+
return {
|
|
69
|
+
R,
|
|
70
|
+
render: s.col,
|
|
71
|
+
brick: s.brick,
|
|
72
|
+
sill: C(pickR(R, s.fired ?? common.fired), 0.08, R), // plinth and sills: fired brick, or a stone city's own footing stone
|
|
73
|
+
timber: C(pickR(R, common.timber), 0.1, R),
|
|
74
|
+
screenWood: C(pickR(R, common.timber), 0.12, R),
|
|
75
|
+
door: C(house.st.door, 0.2, R),
|
|
76
|
+
trim: house.trim,
|
|
77
|
+
shut: house.hasShut ? house.shut : null,
|
|
78
|
+
clay: C(pickR(R, common.clay), 0.08, R),
|
|
79
|
+
awnings: common.awning,
|
|
80
|
+
rugs: common.rugs,
|
|
81
|
+
washing: common.washing,
|
|
82
|
+
brass: C(common.brass, 0.05, R),
|
|
83
|
+
litP: house.litP,
|
|
84
|
+
rich: !!house.st.rich,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Patches where the render has fallen away and the brick shows, on one face; `bare` is the share of the house's walls so worn.
|
|
89
|
+
function renderLoss(kit, put, len, h, look, bare) {
|
|
90
|
+
const n = Math.round(bare * 4 + look.R() * 2 * bare);
|
|
91
|
+
for (let k = 0; k < n; k++) {
|
|
92
|
+
const pw = 0.6 + look.R() * 2.2,
|
|
93
|
+
ph = 0.4 + look.R() * 1.4,
|
|
94
|
+
u = (look.R() - 0.5) * (len - pw),
|
|
95
|
+
y = look.R() < 0.6 ? 0.3 + look.R() * 0.8 : look.R() * (h - ph);
|
|
96
|
+
put(kit.stone, U.quad, dim(look.brick, 0.95 + look.R() * 0.1), u, y, 0.012, pw, ph, 1);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// The openings of one face of a block: a door (front face, ground floor), a shop, windows that grow toward the top, beam ends.
|
|
100
|
+
function faceOpenings(kit, put, len, h, n, look, o) {
|
|
101
|
+
const R = look.R,
|
|
102
|
+
sh = h / n,
|
|
103
|
+
nc = baysOf(len),
|
|
104
|
+
pitch = len / nc;
|
|
105
|
+
for (let i = 0; i < n; i++) {
|
|
106
|
+
const y0 = i * sh;
|
|
107
|
+
if (o.hidden > y0 + sh - 0.4) continue;
|
|
108
|
+
if (i > 0 && o.beams) beamEnds(kit, put, len, y0 - 0.32, look.timber, R);
|
|
109
|
+
for (let k = 0; k < nc; k++) {
|
|
110
|
+
const u = (k + 0.5 - nc / 2) * pitch;
|
|
111
|
+
if (i === 0 && k === o.doorK) {
|
|
112
|
+
courtyardDoor(kit, put, u, {
|
|
113
|
+
...look,
|
|
114
|
+
w: o.loadingBay ? Math.min(2.5, pitch - 0.65) : undefined,
|
|
115
|
+
benches: !o.loadingBay && R() < 0.55,
|
|
116
|
+
lamp: R() < 0.35 ? WARM[0] : null,
|
|
117
|
+
});
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (o.loadingBay && i === n - 1 && k === o.doorK) {
|
|
121
|
+
// Shuttered loft opening and a short hoist over the door: clear ground for unloading.
|
|
122
|
+
const width = Math.min(2.1, pitch - 0.7);
|
|
123
|
+
put(kit.glass, U.quad, dim(look.timber, 0.35), u, y0 + 0.18, 0.035, width, 1.85, 1);
|
|
124
|
+
for (const side of [-1, 1]) {
|
|
125
|
+
put(
|
|
126
|
+
kit.wood,
|
|
127
|
+
U.boxF,
|
|
128
|
+
dim(look.timber, side < 0 ? 0.92 : 1.04),
|
|
129
|
+
u + side * width * 0.25,
|
|
130
|
+
y0 + 0.22,
|
|
131
|
+
0.09,
|
|
132
|
+
width * 0.48,
|
|
133
|
+
1.75,
|
|
134
|
+
0.12,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
put(kit.stone, U.boxF, look.sill, u, y0 + 0.05, 0.16, width + 0.3, 0.16, 0.34);
|
|
138
|
+
put(kit.wood, U.box, look.timber, u, y0 + 2.12, 0.47, 0.22, 0.27, 1.38);
|
|
139
|
+
put(kit.wood, U.cyl6, look.timber, u, y0 + 1.97, 1.02, 0.23, 0.12, 0.23, 0, 0, Math.PI / 2);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (i === 0 && o.shopK === k) {
|
|
143
|
+
shopFront(kit, put, u, Math.min(pitch - 0.6, 2.8), { ...look, lit: R() < 0.5 });
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (o.hidden > y0 + 1.2) continue;
|
|
147
|
+
const ground = i === 0,
|
|
148
|
+
skip = ground ? 0.45 : o.side ? 0.45 : 0.15;
|
|
149
|
+
if (R() < skip) continue;
|
|
150
|
+
const ww = ground ? 0.45 + R() * 0.2 : 0.6 + R() * 0.35,
|
|
151
|
+
wh = ground ? 0.55 + R() * 0.2 : Math.min(sh - 1.2, 0.9 + R() * 0.5),
|
|
152
|
+
yy = y0 + (ground ? sh - 1.05 - wh * 0.4 : 0.95);
|
|
153
|
+
courtyardWindow(kit, put, u, yy, ww, wh, {
|
|
154
|
+
...look,
|
|
155
|
+
lit: R() < look.litP ? WARM[(R() * 3) | 0] : null,
|
|
156
|
+
screen: !ground && R() < o.screens,
|
|
157
|
+
bars: ground && R() < 0.6,
|
|
158
|
+
shut: !ground && look.shut && R() < 0.5 ? look.shut : null,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// A rectangular block of the house: its walls, plinth, openings on its open faces and render loss. `cover`: how high a
|
|
165
|
+
// neighbour covers each face (front, back, +x, -x); `door`: the face and bay of its door, if it has one.
|
|
166
|
+
function block(kit, look, x, z, w, d, h, n, o) {
|
|
167
|
+
const fd = o.found || 0;
|
|
168
|
+
kit.stone.box(x, -2.4 - fd, z, w + 0.24, 2.4 + fd + 0.45, d + 0.24, dim(look.sill, 0.9)); // a plinth of fired brick against the damp
|
|
169
|
+
(o.bare ? kit.stone : kit.wall).box(x, 0, z, w, h, d, o.bare ? look.brick : look.render);
|
|
170
|
+
kit.wall.box(x, h, z, w - 0.5, 0.06, d - 0.5, dim(o.bare ? look.brick : look.render, 0.9)); // the roof's skin of mud plaster, rolled smooth
|
|
171
|
+
const faces = blockFaces(x, z, w, d);
|
|
172
|
+
for (let f = 0; f < 4; f++) {
|
|
173
|
+
const hidden = o.cover[f];
|
|
174
|
+
if (hidden > h - 0.4) continue;
|
|
175
|
+
const len = f < 2 ? w : d;
|
|
176
|
+
faceOpenings(kit, faces[f], len, h, n, o.bare ? { ...look, render: look.brick } : look, {
|
|
177
|
+
hidden,
|
|
178
|
+
side: f > 1,
|
|
179
|
+
beams: f < 2 === w >= d, // the floor beams span the shorter way: their ends show on the long faces
|
|
180
|
+
loadingBay: o.loadingBay && f === o.doorFace,
|
|
181
|
+
doorK: f === o.doorFace ? o.doorK % baysOf(len) : -1,
|
|
182
|
+
shopK: f === o.doorFace && o.shop ? (o.doorK + 1) % baysOf(len) : -1,
|
|
183
|
+
screens: o.screens,
|
|
184
|
+
});
|
|
185
|
+
if (!o.bare) renderLoss(kit, faces[f], len, h, look, o.worn);
|
|
186
|
+
}
|
|
187
|
+
return faces;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// A block of six faces about the house's middle (a spec's `hex`), `w` across from face to face, the front (face 0, +z) first and
|
|
191
|
+
// the rest round it toward +x: each face's walls, plinth, openings and stains are laid as a block's are, in a frame turned to that
|
|
192
|
+
// face; the roof's skin is one hexagonal slab. A sixth of a turn, in radians, from one face to the next.
|
|
193
|
+
const HEX_TURN = TAU / 6,
|
|
194
|
+
HEX_WALL = 0.9, // metres: the walls' thickness, which the faces' slabs overlap by inside the corners
|
|
195
|
+
HEX_PLINTH_OUT = 0.12, // how far the plinth stands out from the wall
|
|
196
|
+
HEX_STAINS = 3; // runs of the smoke's grime down each face from under the parapet
|
|
197
|
+
function hexBlock(kit, look, w, h, n, o) {
|
|
198
|
+
const ap = w / 2,
|
|
199
|
+
side = w / Math.sqrt(3), // the length of a face, which is also the radius to a corner
|
|
200
|
+
fd = o.found || 0,
|
|
201
|
+
col = o.bare ? look.brick : look.render,
|
|
202
|
+
body = o.bare ? kit.stone : kit.wall,
|
|
203
|
+
plinth = (ap + HEX_PLINTH_OUT) / ap;
|
|
204
|
+
kit.wall.add(U.cyl6, dim(col, 0.9), TRS(0, h, 0, side * 2 - 0.5, 0.06, side * 2 - 0.5, Math.PI / 6)); // the roof's skin, its flats on the faces
|
|
205
|
+
for (let f = 0; f < 6; f++) {
|
|
206
|
+
kitPush(0, 0, 0, f * HEX_TURN);
|
|
207
|
+
const put = facePut(0, side / 2, ap);
|
|
208
|
+
put(kit.stone, U.box, dim(look.sill, 0.9), 0, -2.4 - fd, HEX_PLINTH_OUT - HEX_WALL / 2, side * plinth, 2.4 + fd + 0.45, HEX_WALL);
|
|
209
|
+
put(body, U.box, col, 0, 0, -HEX_WALL / 2, side, h, HEX_WALL);
|
|
210
|
+
faceOpenings(kit, put, side, h, n, o.bare ? { ...look, render: look.brick } : look, {
|
|
211
|
+
hidden: 0,
|
|
212
|
+
side: f > 0,
|
|
213
|
+
beams: false, // a tower of stone carries its floors inside its walls
|
|
214
|
+
doorK: f === 0 ? o.doorK % baysOf(side) : -1,
|
|
215
|
+
shopK: -1,
|
|
216
|
+
screens: o.screens,
|
|
217
|
+
});
|
|
218
|
+
if (!o.bare) renderLoss(kit, put, side, h, look, o.worn);
|
|
219
|
+
for (let k = 0; k < HEX_STAINS; k++) {
|
|
220
|
+
const u = (look.R() - 0.5) * (side - 1.2);
|
|
221
|
+
kitStain(kit, put, u, h - 0.05, 0.6 + look.R() * 0.8, h * (0.3 + 0.5 * look.R()), u * 0.37 + f * 0.19 + h * 0.07);
|
|
222
|
+
}
|
|
223
|
+
kitPop();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// The parapet round a hexagonal block's roof (hexBlock): a face's run of wall and coping, and its merlons where it is crenellated.
|
|
227
|
+
function hexParapet(kit, w, h, col, crenel) {
|
|
228
|
+
const ap = w / 2,
|
|
229
|
+
side = w / Math.sqrt(3),
|
|
230
|
+
t = PARAPET.t;
|
|
231
|
+
for (let f = 0; f < 6; f++) {
|
|
232
|
+
kitPush(0, 0, 0, f * HEX_TURN);
|
|
233
|
+
const put = facePut(0, side / 2, ap);
|
|
234
|
+
put(kit.wall, U.boxFootless, col, 0, h, -t / 2, side, PARAPET.h, t);
|
|
235
|
+
put(kit.wall, kit.lean ? U.boxFootless : U.box, dim(col, 1.06), 0, h + PARAPET.h, -t / 2, side + 0.06, 0.07, t + 0.06);
|
|
236
|
+
if (crenel) {
|
|
237
|
+
const top = h + PARAPET.h,
|
|
238
|
+
m = Math.max(1, Math.floor(side / MERLON.step));
|
|
239
|
+
for (let k = 0; k < m; k++) {
|
|
240
|
+
const u = (k + 0.5 - m / 2) * (side / m);
|
|
241
|
+
put(kit.wall, U.boxFootless, col, u, top + MERLON.at, -t / 2, MERLON.w, MERLON.h, t);
|
|
242
|
+
put(kit.wall, U.boxFootless, col, u, top + MERLON.capAt, -t / 2, MERLON.cap, MERLON.capH, t * 0.7);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
kitPop();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// A buttress of mud brick leaning on a face, wide at its foot.
|
|
250
|
+
function buttress(kit, put, u, h, col) {
|
|
251
|
+
put(kit.wall, U.box, dim(col, 0.96), u, -0.4, 0.42, 0.85, h * 0.7 + 0.4, 0.9, 0, -0.09);
|
|
252
|
+
put(kit.wall, U.box, dim(col, 1.02), u, -0.4, 0.62, 1.05, 1.1, 1.3);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// A stair of mud brick climbing a side face to the roof, each step solid to the ground, with a low wall along its outer edge.
|
|
256
|
+
function outsideStair(kit, put, len, h, col) {
|
|
257
|
+
const rise = 0.27,
|
|
258
|
+
run = 0.31,
|
|
259
|
+
n = Math.round(h / rise),
|
|
260
|
+
u0 = -len / 2 + 0.5;
|
|
261
|
+
if (n * run > len - 0.8) return false;
|
|
262
|
+
for (let i = 0; i < n; i++)
|
|
263
|
+
put(kit.wall, U.box, dim(col, 0.97 + (i % 3) * 0.015), u0 + (i + 0.5) * run, -0.3, 0.5, run + 0.01, (i + 1) * rise + 0.3, 1.0);
|
|
264
|
+
const L = n * run,
|
|
265
|
+
a = Math.atan2(n * rise, L);
|
|
266
|
+
put(kit.wall, U.box, dim(col, 1.03), u0 + L / 2, (n * rise) / 2 + 0.15, 1.0, Math.hypot(L, n * rise), 0.5, 0.18, a);
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// A courtyard house from its spec: the body, then what stands on its roof.
|
|
271
|
+
function kitCourtyardHouse(kit, house, s) {
|
|
272
|
+
const look = houseLook(house, s),
|
|
273
|
+
{ w, d, h } = s,
|
|
274
|
+
n = s.n,
|
|
275
|
+
cover = [0, ...s.party];
|
|
276
|
+
look.awningP = s.awning ?? 0.4;
|
|
277
|
+
look.house = house;
|
|
278
|
+
const o = {
|
|
279
|
+
found: s.found,
|
|
280
|
+
bare: s.bare > 0.5,
|
|
281
|
+
worn: s.bare,
|
|
282
|
+
screens: s.screens ?? 0.4,
|
|
283
|
+
cover,
|
|
284
|
+
doorFace: 0,
|
|
285
|
+
loadingBay: s.loadingBay,
|
|
286
|
+
doorK: s.doorK ?? 0,
|
|
287
|
+
shop: s.shop,
|
|
288
|
+
};
|
|
289
|
+
if (s.hex) {
|
|
290
|
+
// a tower of six faces: its block and the parapet round its roof, and nothing on the roof but what its builder puts there
|
|
291
|
+
hexBlock(kit, look, w, h, n, o);
|
|
292
|
+
hexParapet(kit, w, h, s.bare > 0.5 ? s.brick : look.render, s.crenel);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const faces = blockFaces(0, 0, w, d); // the outline's faces, for what stands against the house as a whole
|
|
296
|
+
if (s.court) {
|
|
297
|
+
// four wings round a court open to the sky; the front wing has the door, the court a well or a tree (placed by the plan)
|
|
298
|
+
const [cw, cd] = s.court,
|
|
299
|
+
fw = (d - cd) / 2,
|
|
300
|
+
sw = (w - cw) / 2;
|
|
301
|
+
block(kit, look, 0, d / 2 - fw / 2, w, fw, h, n, { ...o, cover: [0, h, cover[2], cover[3]] });
|
|
302
|
+
block(kit, look, 0, -d / 2 + fw / 2, w, fw, h, n, { ...o, cover: [h, cover[1], cover[2], cover[3]], doorFace: -1 });
|
|
303
|
+
for (const sg of [-1, 1])
|
|
304
|
+
block(kit, look, (sg * (w - sw)) / 2, 0, sw, cd, h, n, {
|
|
305
|
+
...o,
|
|
306
|
+
cover: [h, h, sg > 0 ? cover[2] : h, sg > 0 ? h : cover[3]],
|
|
307
|
+
doorFace: -1,
|
|
308
|
+
});
|
|
309
|
+
courtInside(kit, look, cw, cd, h, n);
|
|
310
|
+
} else block(kit, look, 0, 0, w, d, h, n, o);
|
|
311
|
+
// the front's sides: buttresses where a face stands open, and a stair up one of them
|
|
312
|
+
for (const f of [2, 3])
|
|
313
|
+
if (!cover[f]) {
|
|
314
|
+
if (s.stair === f && outsideStair(kit, faces[f], d, h, look.render)) continue;
|
|
315
|
+
if (look.R() < (s.buttress ?? 0)) buttress(kit, faces[f], (look.R() - 0.5) * d * 0.5, h, look.render);
|
|
316
|
+
}
|
|
317
|
+
const spoutFaces = [0, 1, 2, 3].filter(f => !cover[f]);
|
|
318
|
+
parapet(kit, house, w, d, h, {
|
|
319
|
+
render: s.bare > 0.5 ? s.brick : look.render,
|
|
320
|
+
crenel: s.crenel,
|
|
321
|
+
spoutFaces,
|
|
322
|
+
faces,
|
|
323
|
+
timber: look.timber,
|
|
324
|
+
});
|
|
325
|
+
const avoid = [];
|
|
326
|
+
if (s.court) avoid.push([0, 0, s.court[0] / 2 + 0.3, s.court[1] / 2 + 0.3]);
|
|
327
|
+
if (s.gallery) {
|
|
328
|
+
const g = s.gallery;
|
|
329
|
+
roofGallery(kit, g, h, look.render, look.timber);
|
|
330
|
+
avoid.push([g.x, g.z, g.w / 2, g.d / 2]);
|
|
331
|
+
}
|
|
332
|
+
if (s.up) {
|
|
333
|
+
roofRoom(kit, look, s.up, h);
|
|
334
|
+
avoid.push([s.up[0], s.up[1], s.up[2] / 2 + 0.5, s.up[3] / 2 + 0.5]);
|
|
335
|
+
}
|
|
336
|
+
if (s.wind) {
|
|
337
|
+
const [x, z, base] = s.wind;
|
|
338
|
+
windTower(kit, look, x, z, h + base, s.windH);
|
|
339
|
+
avoid.push([x, z, TOWER, TOWER]);
|
|
340
|
+
}
|
|
341
|
+
if (s.dome) {
|
|
342
|
+
const [x, z, r, base, drum] = s.dome;
|
|
343
|
+
ribbedDome(kit, look, x, z, h + base, r, s.rc, drum);
|
|
344
|
+
avoid.push([x, z, r + 0.4, r + 0.4]);
|
|
345
|
+
}
|
|
346
|
+
if (s.stair >= 2) avoid.push([s.stair === 2 ? w / 2 - 0.6 : -w / 2 + 0.6, 0, 0.8, d / 2]);
|
|
347
|
+
if (s.watchTower) return; // The roof walk and its access must stay clear for the watch.
|
|
348
|
+
terrace(kit, look, s, avoid);
|
|
349
|
+
if (!s.court && !s.shop && look.R() < 0.5) {
|
|
350
|
+
const put = faces[0];
|
|
351
|
+
waterJar(kit.cloth, put, (look.R() < 0.5 ? -1 : 1) * (w / 2 - 0.7), 0.5, 0.9, look.clay, look.R);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Inside a court: an arcade along its far side (piers carrying arches over a shaded walk), windows and doors onto it, and
|
|
356
|
+
// a paved floor with a drain.
|
|
357
|
+
function courtInside(kit, look, cw, cd, h, n) {
|
|
358
|
+
// the inner walls, each facing into the court: its far side, its near side, its +x side and its -x side
|
|
359
|
+
const faces = [facePut(0, cw / 2, -cd / 2), facePut(1, cw / 2, -cd / 2), facePut(3, -cw / 2, cd / 2), facePut(2, -cw / 2, cd / 2)],
|
|
360
|
+
sh = h / n,
|
|
361
|
+
R = look.R;
|
|
362
|
+
kit.stone.box(0, -0.05, 0, cw, 0.1, cd, dim(look.sill, 0.85)); // its floor of fired brick
|
|
363
|
+
for (let f = 0; f < 4; f++) {
|
|
364
|
+
const put = faces[f],
|
|
365
|
+
len = f < 2 ? cw : cd,
|
|
366
|
+
nc = Math.max(1, Math.floor(len / 2.6));
|
|
367
|
+
for (let i = 0; i < n; i++)
|
|
368
|
+
for (let k = 0; k < nc; k++) {
|
|
369
|
+
const u = (k + 0.5 - nc / 2) * (len / nc);
|
|
370
|
+
if (i === 0 && k === 0 && f === 1) courtyardDoor(kit, put, u, { ...look, w: 1.1, h: 2.2, benches: false, lamp: null });
|
|
371
|
+
else if (R() < 0.7)
|
|
372
|
+
courtyardWindow(kit, put, u, i * sh + 1.0, 0.6, Math.min(1.1, sh - 1.3), {
|
|
373
|
+
...look,
|
|
374
|
+
lit: R() < look.litP ? WARM[1] : null,
|
|
375
|
+
screen: i > 0 && R() < 0.5,
|
|
376
|
+
dry: true,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const put = faces[0],
|
|
381
|
+
nb = Math.max(2, Math.round(cw / 2.4)),
|
|
382
|
+
bay = cw / nb;
|
|
383
|
+
for (let k = 0; k <= nb; k++) put(kit.wall, U.box, look.render, (k - nb / 2) * bay, 0, 1.4, 0.45, sh - 0.3, 0.45);
|
|
384
|
+
for (let k = 0; k < nb; k++) {
|
|
385
|
+
const u = (k + 0.5 - nb / 2) * bay;
|
|
386
|
+
for (let q = 0; q < 7; q++) {
|
|
387
|
+
const a = (Math.PI * (q + 0.5)) / 7,
|
|
388
|
+
r = bay / 2 - 0.2;
|
|
389
|
+
put(
|
|
390
|
+
kit.wall,
|
|
391
|
+
U.box,
|
|
392
|
+
dim(look.render, 1.04),
|
|
393
|
+
u + r * Math.cos(a),
|
|
394
|
+
sh - 0.3 - r * 0.7 + r * Math.sin(a) * 0.7,
|
|
395
|
+
1.4,
|
|
396
|
+
(r * Math.PI) / 7 + 0.05,
|
|
397
|
+
0.22,
|
|
398
|
+
0.42,
|
|
399
|
+
a - Math.PI / 2,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
put(kit.wall, U.box, look.render, 0, sh - 0.3, 1.4, cw, 0.4, 0.5);
|
|
404
|
+
put(kit.wood, U.box, look.timber, 0, sh + 0.08, 0.8, cw, 0.08, 1.7); // the walk's roof
|
|
405
|
+
if (R() < 0.5) lantern(kit, put, -cw * 0.25, sh - 1.4, WARM[0]);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return { kitCourtyardHouse };
|
|
409
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// A filled house kit cut into cells of the ground, so a renderer can cull and batch each cell: a cell's arrays per kind, its
|
|
2
|
+
// bounding sphere, and whether it holds only small parts. Worker-safe.
|
|
3
|
+
import { sphereOf } from './builder.js';
|
|
4
|
+
import { cutBuilderCells } from './builder-cells.js';
|
|
5
|
+
import { KIT_KEYS } from './house-kit-frame.js';
|
|
6
|
+
|
|
7
|
+
const SMALL = 0.75; // metres, measured on the part's longest axis
|
|
8
|
+
/**
|
|
9
|
+
* A kit's parts cut into square cells of the ground, each kind on its own; parts under 0.75 m on their longest axis are set
|
|
10
|
+
* apart as small (but never glass or stains, which always follow their main batch).
|
|
11
|
+
* @param {object} B - A filled kit whose builders were made with part marks (`pb = []` on each kind before filling).
|
|
12
|
+
* @param {number} cs - The cells' side, in metres.
|
|
13
|
+
* @param {boolean} [smallApart=true] - Whether small parts go in cells of their own.
|
|
14
|
+
* @returns {Array<Array<{small: boolean, parts: object, sphere: object}>>} A list of cells to each of {@link KIT_KEYS}.
|
|
15
|
+
*/
|
|
16
|
+
export const cutKit = (B, cs, smallApart = true) =>
|
|
17
|
+
KIT_KEYS.map(k => cutBuilderCells(B[k], cs, smallApart && k !== 'glass' && k !== 'stain' ? SMALL : 0));
|
|
18
|
+
/**
|
|
19
|
+
* Kits already gathered by cells (one kit's arrays to a cell, each in {@link KIT_KEYS}'s order) in {@link cutKit}'s shape, nothing set apart as small.
|
|
20
|
+
* @param {Array<object[]>} kits - Each cell's arrays, a kind to each.
|
|
21
|
+
* @returns {Array<Array<{small: boolean, parts: object, sphere: object}>>}
|
|
22
|
+
*/
|
|
23
|
+
export const kitsByCell = kits =>
|
|
24
|
+
KIT_KEYS.map((k, kind) =>
|
|
25
|
+
kits
|
|
26
|
+
.map(kit => kit[kind])
|
|
27
|
+
.filter(parts => parts.position.length)
|
|
28
|
+
.map(parts => ({ small: false, parts, sphere: sphereOf(parts.position) })),
|
|
29
|
+
);
|