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,193 @@
|
|
|
1
|
+
// The openings of a house kit's walls: windows (and which lit ones throw light on the street), doors, shop fronts; a barrel
|
|
2
|
+
// by a wall. Worker-safe.
|
|
3
|
+
import { dim } from '../math/color.js';
|
|
4
|
+
import { pickR } from '../math/random.js';
|
|
5
|
+
import { C } from './primitives.js';
|
|
6
|
+
import { kitStain } from './house-kit-marks.js';
|
|
7
|
+
|
|
8
|
+
const GLOW_SILL = 2.6; // a lit window standing no higher than this above the street throws its light on the paving
|
|
9
|
+
// A lit window's lamplight: its warm colour with the green set to one of LIT_STEPS steps (0 <= pick < 1). The glass reads the step
|
|
10
|
+
// back from green over red, which the dimmer pane below the sill keeps, and lights the window when the clock's share of lit
|
|
11
|
+
// windows passes it, so the windows of a street come on one by one at dusk and some go dark late at night.
|
|
12
|
+
// A lamp seen through an open doorway (`door`) takes the steps below a window's, which the glass reads as a doorway: by day it is
|
|
13
|
+
// dark and dull as any doorway, where a window's pane is glass with the sky in it.
|
|
14
|
+
const LIT_STEPS = 11,
|
|
15
|
+
LIT_G = [0.55, 0.025]; // the first step's green over red, and the step between two
|
|
16
|
+
/**
|
|
17
|
+
* A lit window's lamplight: `warm` with its green set to one of eleven steps, which the window glass's material reads back
|
|
18
|
+
* (green over red) to light the window once the hour's share of lit windows passes it. A doorway's lamp takes the steps
|
|
19
|
+
* below a window's.
|
|
20
|
+
* @param {number[]} warm - The lamplight, linear [r, g, b].
|
|
21
|
+
* @param {number} pick - 0 <= pick < 1: which step.
|
|
22
|
+
* @param {boolean} [door=false] - Whether it is seen through an open doorway.
|
|
23
|
+
* @returns {number[]} The colour to give the glass.
|
|
24
|
+
*/
|
|
25
|
+
export function litAt(warm, pick, door = false) {
|
|
26
|
+
const k = Math.floor(pick * LIT_STEPS) - (door ? LIT_STEPS : 0);
|
|
27
|
+
return [warm[0], warm[0] * (LIT_G[0] + LIT_G[1] * k), warm[2]];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The openings of a house kit, bound to its shapes, frame and palette; each house kit makes its own, with its own list of
|
|
32
|
+
* lit windows near the street.
|
|
33
|
+
* @param {object} o
|
|
34
|
+
* @param {object} o.U - The unit shapes (`createUnitShapes`).
|
|
35
|
+
* @param {import('three').Matrix4} o.kitFrame - The kit's frame (`createKitFrame`).
|
|
36
|
+
* @param {object} o.palette - The house palette (`HOUSE_PALETTE`'s keys).
|
|
37
|
+
* @param {object} o.lump - A rounded lump geometry (`KIT_LUMP`).
|
|
38
|
+
* @returns {object} `kitWindow(kit, put, u, y, w, h, o)`, a window in a wall (its glass, curtains or a shutter behind it, frame,
|
|
39
|
+
* sill, stain, lintel, shutters, a flower box); `kitDoor(kit, house, put, u, o)`, a door with panels, frame, steps and now and
|
|
40
|
+
* then a canopy; `kitBarrel(kit, put, u, out, scale, random)`; `kitShop(kit, house, put, u, w)`, a shop front with its awning;
|
|
41
|
+
* `takeLitWindows(from)`, the lit windows low enough to light the street noted since the last call (each [x, z, facing x,
|
|
42
|
+
* facing z, width]); `litWindowCount()`; `addLitWindows(windows, at)`, notes windows built elsewhere (a worker).
|
|
43
|
+
*/
|
|
44
|
+
export function createHouseKitOpenings({ U, kitFrame, palette, lump }) {
|
|
45
|
+
const { windowLight: WARM, black: BLACK, drapes: DRAPES, indoors: INDOORS, folds: FOLDS, awnings: AWN } = palette,
|
|
46
|
+
KBLOB = lump;
|
|
47
|
+
const litWindows = []; // such windows built since they were last taken: [x, z, the way it faces (x, z), width]
|
|
48
|
+
function noteLitWindow(kit, put, u, y, ww) {
|
|
49
|
+
const f = put.face,
|
|
50
|
+
e = kitFrame.elements;
|
|
51
|
+
if (f === undefined) return;
|
|
52
|
+
const lx = f === 0 ? u : f === 1 ? -u : f === 2 ? put.halfWidth : -put.halfWidth,
|
|
53
|
+
lz = f === 0 ? put.halfDepth : f === 1 ? -put.halfDepth : f === 2 ? -u : u,
|
|
54
|
+
ox = f === 2 ? 1 : f === 3 ? -1 : 0,
|
|
55
|
+
oz = f === 0 ? 1 : f === 1 ? -1 : 0;
|
|
56
|
+
if (e[1] * lx + e[5] * y + e[9] * lz + e[13] - kit.glass.tv > GLOW_SILL) return;
|
|
57
|
+
litWindows.push([
|
|
58
|
+
e[0] * lx + e[4] * y + e[8] * lz + e[12],
|
|
59
|
+
e[2] * lx + e[6] * y + e[10] * lz + e[14],
|
|
60
|
+
e[0] * ox + e[8] * oz,
|
|
61
|
+
e[2] * ox + e[10] * oz,
|
|
62
|
+
ww,
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
function takeLitWindows(from = 0) {
|
|
66
|
+
return litWindows.splice(from);
|
|
67
|
+
}
|
|
68
|
+
const litWindowCount = () => litWindows.length;
|
|
69
|
+
function addLitWindows(windows, at = litWindows.length) {
|
|
70
|
+
litWindows.splice(Math.min(at, litWindows.length), 0, ...windows);
|
|
71
|
+
}
|
|
72
|
+
function kitWindow(kit, put, u, y, ww, wh, o) {
|
|
73
|
+
const f = 0.09,
|
|
74
|
+
fc = o.frame;
|
|
75
|
+
const s = u * 0.731 + y * 0.317 + (put.halfWidth || 0) * 0.113 + (put.face || 0) * 0.21,
|
|
76
|
+
h = k => {
|
|
77
|
+
const v = Math.sin(s * 12.9898 + k * 78.233) * 43758.5453;
|
|
78
|
+
return v - Math.floor(v);
|
|
79
|
+
},
|
|
80
|
+
lit = o.lit && litAt(o.lit, h(9));
|
|
81
|
+
if (lit) noteLitWindow(kit, put, u, y, ww);
|
|
82
|
+
put(kit.glass, U.quad, lit || BLACK, u, y, 0.035, ww, wh, 1);
|
|
83
|
+
if (!o.lite && ww > 0.5) {
|
|
84
|
+
// behind the glass each window its own: curtains drawn to the sides, an inner shutter half closed, a lit room darker below the sill line
|
|
85
|
+
if (h(1) < 0.6) {
|
|
86
|
+
const cw = ww * (0.16 + 0.22 * h(2)),
|
|
87
|
+
col = DRAPES[(h(3) * DRAPES.length) | 0];
|
|
88
|
+
// each drawn curtain hangs in folds, a strip to each, lit as a room's shade lights it (in front of the glass, far enough out
|
|
89
|
+
// that the glass's depth offset cannot hide them at a slant)
|
|
90
|
+
for (const sg of [-1, 1]) {
|
|
91
|
+
const shade = INDOORS * (0.85 + 0.3 * h(4 + sg)),
|
|
92
|
+
fw = cw / FOLDS.length;
|
|
93
|
+
for (let k = 0; k < FOLDS.length; k++)
|
|
94
|
+
put(kit.cloth, U.quad, dim(col, shade * FOLDS[k]), u + sg * (ww / 2 - cw + (k + 0.5) * fw), y, 0.052, fw, wh, 1);
|
|
95
|
+
}
|
|
96
|
+
put(kit.cloth, U.quad, dim(col, 0.8 * INDOORS), u, y + wh * 0.86, 0.054, ww, wh * 0.14, 1);
|
|
97
|
+
} else if (h(4) < 0.3) put(kit.trim, U.quad, dim(o.frame, 0.7), u + ((h(5) < 0.5 ? -1 : 1) * ww) / 4, y, 0.052, ww / 2, wh, 1);
|
|
98
|
+
if (lit)
|
|
99
|
+
put(
|
|
100
|
+
kit.glass,
|
|
101
|
+
U.quad,
|
|
102
|
+
lit.map(c => c * 0.3),
|
|
103
|
+
u,
|
|
104
|
+
y,
|
|
105
|
+
0.039,
|
|
106
|
+
ww,
|
|
107
|
+
wh * 0.3,
|
|
108
|
+
1,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (o.lite) {
|
|
112
|
+
// backs and sides: the same window with a flat frame
|
|
113
|
+
for (const sg of [-1, 1]) put(kit.trim, U.quad, fc, u + sg * (ww / 2 + f / 2), y - f, 0.05, f, wh + f * 2, 1);
|
|
114
|
+
put(kit.trim, U.quad, fc, u, y + wh, 0.05, ww, f, 1);
|
|
115
|
+
put(kit.trim, U.quad, fc, u, y, 0.07, 0.05, wh, 1);
|
|
116
|
+
} else {
|
|
117
|
+
put(kit.trim, U.boxF, fc, u - ww / 2 - f / 2, y - f, 0.06, f, wh + f * 2, 0.12);
|
|
118
|
+
put(kit.trim, U.boxF, fc, u + ww / 2 + f / 2, y - f, 0.06, f, wh + f * 2, 0.12);
|
|
119
|
+
put(kit.trim, U.boxF, fc, u, y + wh, 0.06, ww, f, 0.12);
|
|
120
|
+
put(kit.trim, U.boxF, fc, u, y, 0.05, 0.045, wh, 0.07); // mullion
|
|
121
|
+
if (wh > 1.2) put(kit.trim, U.boxF, fc, u, y + wh * 0.62, 0.05, ww, 0.045, 0.07); // transom
|
|
122
|
+
}
|
|
123
|
+
put(kit.stone, U.boxF, o.sill, u, y - f - 0.1, 0.11, ww + 0.36, 0.11, 0.22);
|
|
124
|
+
if (put.face !== undefined && !o.dry)
|
|
125
|
+
kitStain(
|
|
126
|
+
kit,
|
|
127
|
+
put,
|
|
128
|
+
u,
|
|
129
|
+
y - f - 0.1,
|
|
130
|
+
ww + 0.34,
|
|
131
|
+
Math.min(0.5 + wh * 0.45, o.drop ?? 0.62),
|
|
132
|
+
u * 0.731 + y * 0.317 + put.halfWidth * 0.113 + put.face * 0.21,
|
|
133
|
+
);
|
|
134
|
+
if (o.lintel) put(kit.stone, U.boxF, o.lintel, u, y + wh + f, 0.05, ww + 0.44, 0.2, 0.1);
|
|
135
|
+
if (o.shut) {
|
|
136
|
+
const sw = ww / 2 + 0.02;
|
|
137
|
+
for (const sg of [-1, 1]) put(kit.trim, U.boxF, o.shut, u + sg * (ww / 2 + f + sw / 2), y, 0.03, sw, wh, 0.06);
|
|
138
|
+
}
|
|
139
|
+
if (o.box) {
|
|
140
|
+
put(kit.trim, U.boxF, dim(fc, 0.8), u, y - 0.4, 0.2, ww + 0.1, 0.2, 0.26);
|
|
141
|
+
for (let k = 0; k < 4; k++)
|
|
142
|
+
put(kit.cloth, KBLOB, k % 2 ? [0.1, 0.22, 0.06] : o.box, u + ((k - 1.5) * ww) / 4, y - 0.12, 0.2, 0.3, 0.28, 0.3, k * 1.3);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// A door in a wall: panels, a handle, and its frame of stone or timber.
|
|
146
|
+
function kitDoor(kit, house, put, u, o = {}) {
|
|
147
|
+
const { R: rand, st } = house,
|
|
148
|
+
dw = o.w ?? 0.95 + rand() * 0.2,
|
|
149
|
+
dh = o.h ?? 2.1,
|
|
150
|
+
sf = st.material === 'stone',
|
|
151
|
+
SG = sf ? kit.stone : kit.trim,
|
|
152
|
+
fc = sf ? house.trim : house.tim,
|
|
153
|
+
dc = C(st.door, 0.2, rand);
|
|
154
|
+
put(kit.trim, U.boxF, dc, u, 0.1, 0.035, dw, dh, 0.07);
|
|
155
|
+
for (const yy of [0.45, 1.7]) put(kit.trim, U.boxF, dim(dc, 0.7), u, yy, 0.085, dw - 0.08, 0.1, 0.03);
|
|
156
|
+
put(kit.cloth, U.boxF, [0.3, 0.24, 0.08], u + dw * 0.33, 1.12, 0.09, 0.06, 0.14, 0.05);
|
|
157
|
+
for (const sg of [-1, 1]) put(SG, U.boxF, fc, u + sg * (dw / 2 + 0.1), 0, 0.09, 0.2, dh + 0.3, 0.18);
|
|
158
|
+
put(SG, U.boxF, fc, u, dh + 0.1, 0.1, dw + 0.56, 0.24, 0.2);
|
|
159
|
+
put(kit.stone, U.box, house.plinth, u, -0.9, 0.42, dw + 0.8, 1.02, 0.84);
|
|
160
|
+
put(kit.stone, U.box, house.plinth, u, -1.0, 0.95, dw + 1.2, 0.94, 0.5);
|
|
161
|
+
if (o.canopy || rand() < 0.3) {
|
|
162
|
+
put(kit.wood, U.box, house.tim, u, dh + 0.66, 0.5, dw + 0.9, 0.07, 1.05, 0, 0.32);
|
|
163
|
+
for (const sg of [-1, 1]) put(kit.wood, U.box, house.tim, u + sg * (dw / 2 + 0.3), dh - 0.1, 0.06, 0.08, 0.8, 0.08, 0, 0.9);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// A barrel standing by a wall.
|
|
167
|
+
function kitBarrel(kit, put, u, out, s, rand) {
|
|
168
|
+
put(kit.wood, U.cyl, C(0x5a4330, 0.15, rand), u, 0, out, 0.58 * s, 0.86 * s, 0.58 * s);
|
|
169
|
+
put(kit.wood, U.cyl, C(0x4f3b2a, 0.1, rand), u, 0.2 * s, out, 0.64 * s, 0.46 * s, 0.64 * s);
|
|
170
|
+
for (const yy of [0.15, 0.68]) put(kit.cloth, U.cyl, [0.02, 0.018, 0.016], u, yy * s, out, 0.65 * s, 0.05 * s, 0.65 * s);
|
|
171
|
+
}
|
|
172
|
+
function kitShop(kit, house, put, u, sw) {
|
|
173
|
+
const { R: rand } = house,
|
|
174
|
+
ac = C(pickR(rand, AWN), 0.1, rand),
|
|
175
|
+
wc = C(0xd8cfb8, 0.06, rand);
|
|
176
|
+
kitWindow(kit, put, u, 0.85, sw, 1.55, { frame: house.frame, lit: WARM[(rand() * 3) | 0], sill: house.trim });
|
|
177
|
+
for (const q of [-0.25, 0.25]) put(kit.wood, U.boxF, house.frame, u + q * sw, 0.85, 0.05, 0.045, 1.55, 0.07);
|
|
178
|
+
const aw = sw + 0.5,
|
|
179
|
+
ns = 6;
|
|
180
|
+
for (let q = 0; q < ns; q++)
|
|
181
|
+
put(kit.cloth, U.box, q % 2 ? ac : wc, u + ((q + 0.5 - ns / 2) * aw) / ns, 2.62, 0.78, aw / ns, 0.035, 1.56, 0, 0.3);
|
|
182
|
+
for (const sg of [-1, 1]) put(kit.wood, U.cyl6, house.tim, u + sg * (aw / 2 - 0.04), -0.3, 1.5, 0.07, 2.5, 0.07);
|
|
183
|
+
put(kit.wood, U.box, C(0x7a6245, 0.18, rand), u - sw * 0.28, -0.1, 0.55, 0.62, 0.6, 0.62, 0, 0, 0);
|
|
184
|
+
if (rand() < 0.6) put(kit.wood, U.box, C(0x6d583f, 0.18, rand), u - sw * 0.28 + 0.08, 0.5, 0.55, 0.46, 0.4, 0.46);
|
|
185
|
+
kitBarrel(kit, put, u + sw * 0.3, 0.6, 1, rand);
|
|
186
|
+
if (rand() < 0.7) {
|
|
187
|
+
put(kit.wood, U.box, house.tim, u + aw / 2 + 0.3, 3.05, 0.5, 0.06, 0.06, 1.0);
|
|
188
|
+
put(kit.wood, U.box, C(pickR(rand, AWN), 0.15, rand), u + aw / 2 + 0.3, 2.42, 0.62, 0.05, 0.56, 0.72);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return { kitWindow, kitDoor, kitBarrel, kitShop, takeLitWindows, litWindowCount, addLitWindows };
|
|
193
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The colours a house kit dresses its houses in, as a world gives them (each has a default): window light, curtains, timber,
|
|
2
|
+
// shutters, awnings and washing; and the courtyard house's colours. Colours are linear [r, g, b] or sRGB hex numbers, as noted.
|
|
3
|
+
import { IcosahedronGeometry } from 'three';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The house kit's default palette. A world passes its own to `createHouseKit({ palette })`; keys it leaves out take these.
|
|
7
|
+
* - `windowLight`: three warm lamplights of lit windows, linear [r, g, b].
|
|
8
|
+
* - `black`: an unlit opening.
|
|
9
|
+
* - `drapes`: the curtains behind windows, linear; `indoors`: the light a curtain takes in a room's shade, as a share of the
|
|
10
|
+
* street's; `folds`: a drawn curtain's folds across it, the light on each.
|
|
11
|
+
* - `timbers`: a house's timber frame (sRGB hex), picked by where the house stands; `hemp`: rope and lines, linear.
|
|
12
|
+
* - `shutters`, `awnings`, `cloths`: sRGB hex choices for shutters, shop awnings, and washing on a line.
|
|
13
|
+
*/
|
|
14
|
+
export const HOUSE_PALETTE = Object.freeze({
|
|
15
|
+
windowLight: [
|
|
16
|
+
[1.0, 0.62, 0.28],
|
|
17
|
+
[1.0, 0.74, 0.42],
|
|
18
|
+
[0.92, 0.5, 0.2],
|
|
19
|
+
],
|
|
20
|
+
black: [0, 0, 0],
|
|
21
|
+
// three muted dyes, linen the commonest: faded madder, ochre, undyed linen twice
|
|
22
|
+
drapes: [
|
|
23
|
+
[0.4, 0.16, 0.12],
|
|
24
|
+
[0.46, 0.36, 0.19],
|
|
25
|
+
[0.6, 0.56, 0.48],
|
|
26
|
+
[0.6, 0.56, 0.48],
|
|
27
|
+
],
|
|
28
|
+
indoors: 0.3,
|
|
29
|
+
folds: [0.95, 0.6, 1, 0.7],
|
|
30
|
+
// weathered oak, mostly brown, some silvered grey, some tarred dark
|
|
31
|
+
timbers: [0x5a4434, 0x6a5644, 0x6a5644, 0x7c7468, 0x3e3128],
|
|
32
|
+
hemp: [0.3, 0.25, 0.15],
|
|
33
|
+
shutters: [0x2f4a44, 0x4a2a24, 0x2a3a52, 0x3d3324, 0x55452c, 0x304030],
|
|
34
|
+
awnings: [0x8a3a30, 0x2f5a52, 0x9a7a35, 0x3a4a6a, 0x6a3a55],
|
|
35
|
+
cloths: [0xb9ad92, 0x8a3a30, 0x3f5a6a, 0xc9b98a, 0x6a7a4a, 0x9a8a9a, 0xd8d2c4],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The courtyard house's default colours (sRGB hex choices): `fired`, fired brick of plinths and sills; `timber`, lintels and
|
|
40
|
+
* screens; `clay`, water jars; `awning`, `rugs`, `washing`, the cloth of awnings, hung rugs and washing; `brass`, finials.
|
|
41
|
+
* A world passes its own to `createHouseKit({ courtyard })`.
|
|
42
|
+
*/
|
|
43
|
+
export const COURTYARD_PALETTE = Object.freeze({
|
|
44
|
+
fired: [0x9a6a4a, 0x8e5f42, 0xa5765a],
|
|
45
|
+
timber: [0x5a4632, 0x4a3828, 0x6a5238, 0x3f3022],
|
|
46
|
+
clay: [0xa0603c, 0xb07048, 0x8f5636],
|
|
47
|
+
awning: [0xb04a32, 0x2f6a7a, 0xc9a24a, 0x7a3a5a, 0xd8cfb8, 0x4a6a3a, 0x9a5a2a],
|
|
48
|
+
rugs: [0x8a2a24, 0x2a3a6a, 0x6a2a3a, 0x9a6a2a, 0x3a5a4a],
|
|
49
|
+
washing: [0xe0d8c4, 0xb9ad92, 0x8a3a30, 0x3f5a6a, 0xc9b98a, 0x2a4a6a, 0xd8c070],
|
|
50
|
+
brass: 0xb8923a,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/** A cheap rounded lump, half a metre across (an icosahedron): flower heads, loaves, cabbages. */
|
|
54
|
+
export const KIT_LUMP = new IcosahedronGeometry(0.5, 0);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Houses of a house kit built by a pool of workers, for a builder that fills a kit and makes it meshes whole. The builder
|
|
2
|
+
// fills the pooled kit as it would any (genHouse included): a plain house is noted with where it goes instead and built on
|
|
3
|
+
// another core meanwhile; `mesh` then makes the kit's meshes with every house in its place, and its lit windows in theirs,
|
|
4
|
+
// as the page alone would have built them.
|
|
5
|
+
import { Matrix4 } from 'three';
|
|
6
|
+
import { insertPartGroups } from './part-ranges.js';
|
|
7
|
+
import { KIT_KEYS, kitCounts } from './house-kit-frame.js';
|
|
8
|
+
|
|
9
|
+
const UNMOVED = new Matrix4();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Whether a house's spec is plain numbers and names, which a worker can build: not if a builder has given it a function of
|
|
13
|
+
* its own to call (only the page can call that).
|
|
14
|
+
* @param {object} spec - A house's spec.
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
*/
|
|
17
|
+
export const isPlain = spec => !Object.values(spec).some(value => typeof value === 'function');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Binds the pooled kit to a house kit and a pool of workers. The workers' job (`job`, 'houses' if not given) is given
|
|
21
|
+
* { specs, frames } and answers what the kit's `housesFromSpecs(specs, frames)` returns.
|
|
22
|
+
* @param {object} o
|
|
23
|
+
* @param {object} o.houseKit - The house kit (`createHouseKit`).
|
|
24
|
+
* @param {object} o.pool - The worker pool: `pooled()` (whether there are workers), `ready(job)` (start them on a job),
|
|
25
|
+
* `runOrHere(job, args, here)` (run it on a worker, or call `here` on the page where none can).
|
|
26
|
+
* @param {(parts: object[], parent: object) => object[]} o.kitMeshes - Makes a kit's arrays meshes (`createHouseKitMeshes`).
|
|
27
|
+
* @param {string} [o.job='houses'] - The workers' job name.
|
|
28
|
+
* @returns {Function} The PooledKit class: `new PooledKit()` holds a fresh `kit`; `mesh(parent)` promises its meshes under
|
|
29
|
+
* parent; `parts()` promises each kind's arrays with the pool's houses in their places (the kit is let go).
|
|
30
|
+
*/
|
|
31
|
+
export function createPooledKit({ houseKit, pool, kitMeshes, job = 'houses' }) {
|
|
32
|
+
const { kitFrame, kitNew, tagKit, housesFromSpecs, addLitWindows, litWindowCount } = houseKit,
|
|
33
|
+
{ pooled, ready, runOrHere } = pool;
|
|
34
|
+
return class PooledKit {
|
|
35
|
+
constructor() {
|
|
36
|
+
if (pooled()) ready(job);
|
|
37
|
+
this.kit = kitNew();
|
|
38
|
+
this.kit.toPool = spec => this.take(spec);
|
|
39
|
+
this.sent = []; // the houses for the pool, each with where it goes: the kit's counts and the lit windows noted when it was
|
|
40
|
+
// handed over, and the kit's frame it was placed in where the builder had moved it
|
|
41
|
+
}
|
|
42
|
+
// Whether genHouse leaves a house to the pool: not if it carries a function, or goes into a kit cut into cells by its
|
|
43
|
+
// parts (kitCells), whose part marks a worker does not send back.
|
|
44
|
+
take(spec) {
|
|
45
|
+
if (!pooled() || !isPlain(spec) || this.kit.wall.pb) return false;
|
|
46
|
+
this.sent.push({ spec, at: kitCounts(this.kit), lit: litWindowCount(), frame: kitFrame.equals(UNMOVED) ? null : kitFrame.toArray() });
|
|
47
|
+
tagKit(this.kit, spec); // as genHouse leaves it, for what the builder adds round the house
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// The kit's meshes, one to a kind, under parent (as kitStatic makes them); the promise is kept once they stand.
|
|
51
|
+
async mesh(parent) {
|
|
52
|
+
return kitMeshes(await this.parts(), parent);
|
|
53
|
+
}
|
|
54
|
+
// Each kind's arrays (GB.parts), in KIT_KEYS's order, with the pool's houses in their places; the kit is let go.
|
|
55
|
+
async parts() {
|
|
56
|
+
const own = KIT_KEYS.map(k => this.kit[k].parts(true));
|
|
57
|
+
for (const k of KIT_KEYS) this.kit[k].release();
|
|
58
|
+
if (!this.sent.length) return own;
|
|
59
|
+
const specs = this.sent.map(s => s.spec),
|
|
60
|
+
frames = this.sent.map(s => s.frame),
|
|
61
|
+
at = this.sent.map(s => s.at);
|
|
62
|
+
const built = await runOrHere(
|
|
63
|
+
job,
|
|
64
|
+
() => ({ specs, frames }),
|
|
65
|
+
() => housesFromSpecs(specs, frames),
|
|
66
|
+
);
|
|
67
|
+
for (let i = this.sent.length - 1; i >= 0; i--) addLitWindows(built.lit[i], this.sent[i].lit); // the last first, so the places noted before it hold
|
|
68
|
+
return insertPartGroups(own, built.kits, at, built.ends);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// A house kit's roofs: pitched roofs with eaves, barge boards and ridges, dormers, chimneys and their soot, finials.
|
|
2
|
+
// Worker-safe.
|
|
3
|
+
import { dim } from '../math/color.js';
|
|
4
|
+
import { TRS } from './primitives.js';
|
|
5
|
+
import { facePut } from './house-kit-frame.js';
|
|
6
|
+
import { kitDecal } from './house-kit-marks.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A house kit's roofs, bound to its shapes, frame, palette and windows.
|
|
10
|
+
* @param {object} o
|
|
11
|
+
* @param {object} o.U - The unit shapes.
|
|
12
|
+
* @param {Function} o.kitPush - The kit frame's push (`createKitFrame`).
|
|
13
|
+
* @param {Function} o.kitPop - The kit frame's pop.
|
|
14
|
+
* @param {object} o.palette - The house palette.
|
|
15
|
+
* @param {Function} o.kitWindow - The kit's windows (`createHouseKitOpenings`).
|
|
16
|
+
* @returns {object} `kitGable(kit, house, x, y, z, len, span, rise, ry, roofColour, wallColour, o)`, a pitched roof with real
|
|
17
|
+
* thickness whose ridge runs along local x (len, span and rise in metres; o: `eave`, `over`, `bare`, `full` for its gable
|
|
18
|
+
* ends, dormers and `chimney`/`chimAt`, `timber`, `gmat`); `kitChimney(kit, house, x, z, y0, top)`, a stack with its soot and
|
|
19
|
+
* pots; `kitFinial(kit, y, scale)`, a spike and ball on a roof's top. `house` is the house's values (`R`, its random stream;
|
|
20
|
+
* `tim`, `frame`, `trim`, `chim` colours; `litP`).
|
|
21
|
+
*/
|
|
22
|
+
export function createHouseKitRoofs({ U, kitPush, kitPop, palette, kitWindow }) {
|
|
23
|
+
const WARM = palette.windowLight;
|
|
24
|
+
function kitChimney(kit, house, x, z, y0, top) {
|
|
25
|
+
const c = house.chim;
|
|
26
|
+
kit.stone.box(x, y0, z, 0.74, top - y0, 0.74, c);
|
|
27
|
+
kit.stone.box(x, top, z, 0.94, 0.13, 0.94, dim(c, 0.45));
|
|
28
|
+
kit.stone.box(x, top - 0.55, z, 0.765, 0.55, 0.765, dim(c, 0.6)); // soot round the mouth of the flue
|
|
29
|
+
for (const [ax, az] of [
|
|
30
|
+
[1, 0],
|
|
31
|
+
[-1, 0],
|
|
32
|
+
[0, 1],
|
|
33
|
+
[0, -1],
|
|
34
|
+
]) {
|
|
35
|
+
// and smoke-black run down the stack below it, longest on the lee side
|
|
36
|
+
const o = 0.386,
|
|
37
|
+
yt = top - 0.55,
|
|
38
|
+
hh = Math.min(yt - y0 - 0.1, 0.35 + house.R() * (ax > 0 ? 1.4 : 0.8)),
|
|
39
|
+
px = x + ax * o,
|
|
40
|
+
pz = z + az * o,
|
|
41
|
+
tx = -az * 0.36,
|
|
42
|
+
tz = ax * 0.36;
|
|
43
|
+
if (hh > 0.2)
|
|
44
|
+
kitDecal(
|
|
45
|
+
kit.stain,
|
|
46
|
+
[px - tx, yt - hh, pz - tz],
|
|
47
|
+
[px + tx, yt - hh, pz + tz],
|
|
48
|
+
[px + tx, yt, pz + tz],
|
|
49
|
+
[px - tx, yt, pz - tz],
|
|
50
|
+
[ax, 0, az],
|
|
51
|
+
house.R() * 0.48,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const two = house.R() < 0.5;
|
|
55
|
+
kit.cloth.add(U.taper, [0.3, 0.12, 0.06], TRS(x - (two ? 0.17 : 0), top + 0.13, z, 0.3, 0.46, 0.3));
|
|
56
|
+
if (two) kit.cloth.add(U.taper, [0.26, 0.1, 0.05], TRS(x + 0.17, top + 0.13, z, 0.28, 0.38, 0.28));
|
|
57
|
+
}
|
|
58
|
+
function kitDormer(kit, house, u, span, rise, sg, rc, wc) {
|
|
59
|
+
// inside the roof frame (ridge along x), on the +z or -z slope
|
|
60
|
+
const zf = span / 2 - 0.4,
|
|
61
|
+
yb = rise * (1 - zf / (span / 2)),
|
|
62
|
+
dh = 1.15,
|
|
63
|
+
yt = yb + dh;
|
|
64
|
+
if (yt > rise - 0.3) return;
|
|
65
|
+
const zb = ((1 - yt / rise) * span) / 2,
|
|
66
|
+
dp = zf - zb + 0.3,
|
|
67
|
+
dw = 1.25;
|
|
68
|
+
kitPush(u, 0, 0, sg > 0 ? 0 : Math.PI);
|
|
69
|
+
kit.wall.box(0, yb - 0.2, zf - dp / 2, dw, dh + 0.2, dp, wc);
|
|
70
|
+
kitGable(kit, house, 0, yt, zf - dp / 2 + 0.06, dp + 0.14, dw, 0.52, Math.PI / 2, rc, wc, { eave: 0.16, over: 0.12, bare: true });
|
|
71
|
+
kitWindow(kit, facePut(0, dw / 2, zf), 0, yb + 0.24, 0.66, 0.74, {
|
|
72
|
+
frame: house.frame,
|
|
73
|
+
lit: house.R() < house.litP ? WARM[1] : null,
|
|
74
|
+
sill: house.trim,
|
|
75
|
+
dry: true,
|
|
76
|
+
});
|
|
77
|
+
kitPop();
|
|
78
|
+
}
|
|
79
|
+
// A pitched roof with real thickness, eaves, barge boards and a ridge; the ridge runs along local x.
|
|
80
|
+
function kitGable(kit, house, x, y, z, len, span, rise, ry, rc, wc, o = {}) {
|
|
81
|
+
kitPush(x, y, z, ry);
|
|
82
|
+
const rand = house.R,
|
|
83
|
+
ev = o.eave ?? 0.42,
|
|
84
|
+
ov = o.over ?? 0.32,
|
|
85
|
+
a = Math.atan2(rise, span / 2),
|
|
86
|
+
sl = Math.hypot(span / 2, rise) + ev,
|
|
87
|
+
sa = Math.sin(a),
|
|
88
|
+
ca = Math.cos(a);
|
|
89
|
+
if (wc) (o.gmat || kit.wall).add(U.prism, wc, TRS(0, 0, 0, span, rise - 0.04, len, Math.PI / 2));
|
|
90
|
+
for (const sg of [1, -1]) {
|
|
91
|
+
kit.roof.add(U.box, rc, TRS(0, rise - (sa * sl) / 2, (sg * ca * sl) / 2, len + ov * 2, 0.15, sl, 0, sg * a));
|
|
92
|
+
if (!o.bare)
|
|
93
|
+
for (const e of [1, -1])
|
|
94
|
+
kit.wood.add(
|
|
95
|
+
U.box,
|
|
96
|
+
house.tim,
|
|
97
|
+
TRS(e * (len / 2 + ov), rise - (sa * sl) / 2 - 0.12, (sg * ca * sl) / 2, 0.07, 0.26, sl + 0.02, 0, sg * a),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
kit.roof.add(U.box, dim(rc, 0.72), TRS(0, rise + 0.05, 0, len + ov * 2 + 0.05, 0.13, 0.36));
|
|
101
|
+
if (o.full) {
|
|
102
|
+
if (rise > 1.9)
|
|
103
|
+
for (const e of [2, 3]) {
|
|
104
|
+
const put = facePut(e, len / 2, 0);
|
|
105
|
+
if (o.timber) {
|
|
106
|
+
put(kit.wood, U.boxF, house.tim, 0, 0, 0.03, 0.17, rise - 0.3, 0.06);
|
|
107
|
+
put(kit.wood, U.boxF, house.tim, 0, rise * 0.42, 0.03, span * 0.5, 0.14, 0.06);
|
|
108
|
+
put(kit.wood, U.boxF, house.tim, 0, 0, 0.03, span - 0.2, 0.16, 0.06);
|
|
109
|
+
} else
|
|
110
|
+
kitWindow(kit, put, 0, rise * 0.2, 0.6, Math.min(0.8, rise * 0.38), {
|
|
111
|
+
frame: house.frame,
|
|
112
|
+
lit: rand() < house.litP ? WARM[0] : null,
|
|
113
|
+
sill: house.trim,
|
|
114
|
+
drop: Math.max(0.1, rise * 0.2 - 0.25),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (rise > 2.3 && len > 5 && rand() < 0.5) {
|
|
118
|
+
const nd = len > 8 ? 2 : 1,
|
|
119
|
+
sg = rand() < 0.5 ? 1 : -1;
|
|
120
|
+
for (let q = 0; q < nd; q++) kitDormer(kit, house, (q + 0.5 - nd / 2) * len * 0.5, span, rise, sg, rc, wc);
|
|
121
|
+
}
|
|
122
|
+
if (o.chimney) {
|
|
123
|
+
const cu = o.chimAt ? o.chimAt[0] : (rand() - 0.5) * len * 0.6,
|
|
124
|
+
cz = o.chimAt ? o.chimAt[1] : (rand() < 0.5 ? 1 : -1) * span * (0.12 + rand() * 0.2);
|
|
125
|
+
kitChimney(kit, house, cu, cz, rise * (1 - Math.abs(cz) / (span / 2)) - 0.4, rise + 0.5 + rand() * 0.8);
|
|
126
|
+
const sg = cz < 0 ? -1 : 1,
|
|
127
|
+
z0 = Math.abs(cz) + 0.3,
|
|
128
|
+
z1 = Math.min(z0 + 1.6 + rand() * 1.4, span / 2 + ev * ca - 0.05),
|
|
129
|
+
yy = z => rise * (1 - z / (span / 2)) + 0.19 / ca,
|
|
130
|
+
hw = 0.6;
|
|
131
|
+
if (z1 > z0 + 0.5)
|
|
132
|
+
kitDecal(
|
|
133
|
+
kit.stain,
|
|
134
|
+
[cu - hw * sg, yy(z1), sg * z1],
|
|
135
|
+
[cu + hw * sg, yy(z1), sg * z1],
|
|
136
|
+
[cu + hw * sg, yy(z0), sg * z0],
|
|
137
|
+
[cu - hw * sg, yy(z0), sg * z0],
|
|
138
|
+
[0, ca, sg * sa],
|
|
139
|
+
0.5 + rand() * 0.48,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
kitPop();
|
|
144
|
+
}
|
|
145
|
+
function kitFinial(kit, y, s = 1) {
|
|
146
|
+
kit.cloth.add(U.cone6, [0.32, 0.26, 0.1], TRS(0, y - 0.1, 0, 0.14 * s, 1.3 * s, 0.14 * s));
|
|
147
|
+
kit.cloth.add(U.sph, [0.36, 0.29, 0.1], TRS(0, y + 0.35 * s, 0, 0.3 * s, 0.3 * s, 0.3 * s));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return { kitChimney, kitFinial, kitGable };
|
|
151
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// The house kit: buildings assembled from real parts (window frames and glass, sills, shutters, doors and steps, jettied
|
|
2
|
+
// storeys, timber framing, eaved roofs, dormers, chimneys; and the flat-roofed courtyard house of a hot land) from plain
|
|
3
|
+
// specs, into one geometry builder per material. A world makes one with its unit shapes, its styles and palette, and the
|
|
4
|
+
// forms, builds and extras of its own it adds. Worker-safe: a worker that builds houses makes the same kit as the page.
|
|
5
|
+
import { mulberry32, pickR } from '../math/random.js';
|
|
6
|
+
import { C } from './primitives.js';
|
|
7
|
+
import { facePut, KIT_KEYS, kitCounts, createKitFrame } from './house-kit-frame.js';
|
|
8
|
+
import { COURTYARD_PALETTE, HOUSE_PALETTE, KIT_LUMP } from './house-kit-palette.js';
|
|
9
|
+
import { createHouseKitOpenings, litAt } from './house-kit-openings.js';
|
|
10
|
+
import { createHouseKitRoofs } from './house-kit-roofs.js';
|
|
11
|
+
import { createHouseKitBody } from './house-kit-body.js';
|
|
12
|
+
import { createHouseKitForms } from './house-kit-forms.js';
|
|
13
|
+
import { createHouseKitExtras } from './house-kit-extras.js';
|
|
14
|
+
import { createCourtyardParts } from './house-kit-courtyard-parts.js';
|
|
15
|
+
import { createCourtyardRoof } from './house-kit-courtyard-roof.js';
|
|
16
|
+
import { createCourtyardHouse } from './house-kit-courtyard.js';
|
|
17
|
+
|
|
18
|
+
const plainHash = (x, z, salt) => {
|
|
19
|
+
const s = Math.sin(x * 127.1 + z * 311.7 + salt * 74.7) * 43758.5453;
|
|
20
|
+
return s - Math.floor(s);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** A house kit's default style: what a spec whose `style` the kit does not know is built as. */
|
|
24
|
+
export const PLAIN_HOUSE_STYLE = Object.freeze({
|
|
25
|
+
material: 'wall',
|
|
26
|
+
storey: 3.0,
|
|
27
|
+
timber: 0.55,
|
|
28
|
+
jetty: 0.6,
|
|
29
|
+
shutters: 0.65,
|
|
30
|
+
shops: 0.45,
|
|
31
|
+
balconies: 0.1,
|
|
32
|
+
windowW: 0.9,
|
|
33
|
+
windowH: 1.35,
|
|
34
|
+
frame: 0x45311f,
|
|
35
|
+
door: 0x2f2016,
|
|
36
|
+
trim: 0xa89c86,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Makes a house kit.
|
|
41
|
+
*
|
|
42
|
+
* A house's spec: `{ x, y, z, w, d, h, rot, style, form, col, rc, seed, rise, turn, chim, streetLit, ruin, lean, n, ... }` (metres,
|
|
43
|
+
* radians, linear colours `col` for its walls and `rc` its roof, `seed` its random stream). `form` names a form: `gable`
|
|
44
|
+
* (the default), `hip`, `body`, `flat`, `round`, `tower`, `dome`, `courtyard`, or one of `forms`; a spec whose `ruin` is
|
|
45
|
+
* under 1 is built as a ruin. `build` names one of `builds` (built in place of a house: street clutter), and `extra` one of
|
|
46
|
+
* `extras` (built after it), or either is a function of the caller's own (which only the page can call, not a worker).
|
|
47
|
+
*
|
|
48
|
+
* A style (`styles[spec.style]`, {@link PLAIN_HOUSE_STYLE} where none): `material` ('stone', 'wood', or 'wall' for render
|
|
49
|
+
* over brick), `storey` (metres), `timber` (the share of houses framed), `jetty` (the share jettied), `shutters`, `shops` and
|
|
50
|
+
* `balconies` (the shares with them), `windowW` and `windowH` (metres), `frame`, `door`, `trim` (sRGB hex); and optionally `timberColour`, `plinthColour`, `chimneyColour`
|
|
51
|
+
* (sRGB hex, in place of the palette's), `litShare` (the share of its windows lit at night, 0.32 if not given), `bareRoof`
|
|
52
|
+
* (a flat roof with nothing on it), `yardClutter` (logs and a barrel by a gabled house) and `rich` (a courtyard house's
|
|
53
|
+
* richer door).
|
|
54
|
+
*
|
|
55
|
+
* @param {object} o
|
|
56
|
+
* @param {object} o.shapes - The unit shapes (`createUnitShapes`).
|
|
57
|
+
* @param {(x: number, z: number, salt: number) => number} [o.hash] - A hash in [0, 1) of whole numbers: picks a house's
|
|
58
|
+
* timber by where it stands.
|
|
59
|
+
* @param {Object<string, object>} [o.styles] - The styles by name.
|
|
60
|
+
* @param {object} [o.palette] - The house palette's keys to change (`HOUSE_PALETTE`).
|
|
61
|
+
* @param {object} [o.courtyard] - The courtyard palette's keys to change (`COURTYARD_PALETTE`).
|
|
62
|
+
* @param {Object<string, Function|string>} [o.forms] - Forms of the world's own, by name, each (kit, house, spec,
|
|
63
|
+
* bodyOptions); a string names another form (an alias).
|
|
64
|
+
* @param {Object<string, Function>} [o.builds] - Builds of the world's own, by name, each (kit, random, spec).
|
|
65
|
+
* @param {Object<string, Function>} [o.extras] - Extras of the world's own, by name, each (kit, house, spec).
|
|
66
|
+
* @returns {object} The kit's frame (`kitFrame`, `kitPush`, `kitPop`, `kitNew`, `kitAt`, `facePut`, `KIT_KEYS`, `kitCounts`);
|
|
67
|
+
* `genHouse(kit, spec)`, builds one house into a kit; `housesFromSpecs(specs, frames, build)`, builds many into a fresh kit as
|
|
68
|
+
* a worker would; `tagKit(kit, spec)`; its lit windows (`takeLitWindows`, `litWindowCount`, `addLitWindows`, `litAt`); and
|
|
69
|
+
* every part, to build with outside a house (`kitWindow`, `kitDoor`, `kitBarrel`, `kitShop`, `kitGable`, `kitChimney`,
|
|
70
|
+
* `kitFinial`, `kitBody`, `propWashing`, the courtyard parts, `forms`, `builds`, `extras`, `palette`, `courtyard`).
|
|
71
|
+
*/
|
|
72
|
+
export function createHouseKit({
|
|
73
|
+
shapes: U,
|
|
74
|
+
hash = plainHash,
|
|
75
|
+
styles = {},
|
|
76
|
+
palette: ownPalette,
|
|
77
|
+
courtyard: ownCourtyard,
|
|
78
|
+
forms: ownForms,
|
|
79
|
+
builds: ownBuilds,
|
|
80
|
+
extras: ownExtras,
|
|
81
|
+
} = {}) {
|
|
82
|
+
if (!U) throw new Error('createHouseKit: shapes (createUnitShapes) are required');
|
|
83
|
+
const palette = Object.freeze({ ...HOUSE_PALETTE, ...ownPalette }),
|
|
84
|
+
courtyard = Object.freeze({ ...COURTYARD_PALETTE, ...ownCourtyard }),
|
|
85
|
+
lump = KIT_LUMP,
|
|
86
|
+
TIMBERS = palette.timbers,
|
|
87
|
+
SHUT = palette.shutters;
|
|
88
|
+
const frame = createKitFrame(),
|
|
89
|
+
{ kitFrame, kitPush, kitPop, kitNew } = frame;
|
|
90
|
+
const openings = createHouseKitOpenings({ U, kitFrame, palette, lump }),
|
|
91
|
+
roofs = createHouseKitRoofs({ U, kitPush, kitPop, palette, kitWindow: openings.kitWindow }),
|
|
92
|
+
{ kitBody } = createHouseKitBody({ U, palette, openings }),
|
|
93
|
+
builtIn = createHouseKitForms({ U, kitPush, kitPop, palette, openings, roofs, kitBody }),
|
|
94
|
+
more = createHouseKitExtras({ U, kitPush, kitPop, palette, lump, kitBarrel: openings.kitBarrel }),
|
|
95
|
+
parts = createCourtyardParts({ U, palette }),
|
|
96
|
+
roof = createCourtyardRoof({ U, kitPush, kitPop, palette, parts }),
|
|
97
|
+
{ kitCourtyardHouse } = createCourtyardHouse({ U, kitPush, kitPop, palette, courtyard, parts, roof });
|
|
98
|
+
const forms = Object.assign(Object.create(null), builtIn, { courtyard: kitCourtyardHouse }, ownForms),
|
|
99
|
+
builds = Object.assign(Object.create(null), more.builds, ownBuilds),
|
|
100
|
+
extras = Object.assign(Object.create(null), more.extras, ownExtras);
|
|
101
|
+
const formOf = name => {
|
|
102
|
+
let f = forms[name];
|
|
103
|
+
for (let hops = 0; typeof f === 'string' && hops < 8; hops++) f = forms[f];
|
|
104
|
+
return typeof f === 'function' ? f : forms.gable;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// Tags what the kit's builders take from here on with the house's height (the shaders' lit windows and street light): left
|
|
108
|
+
// so after the house, for what its builder adds round it.
|
|
109
|
+
function tagKit(kit, s) {
|
|
110
|
+
const tag = s.streetLit ? s.y : s.y - 1000;
|
|
111
|
+
for (const k of KIT_KEYS) kit[k].tv = tag;
|
|
112
|
+
}
|
|
113
|
+
// One building from its spec. A kit that hands houses to workers (`kit.toPool`) may take the house to be built there instead.
|
|
114
|
+
function genHouse(kit, s) {
|
|
115
|
+
if (kit.toPool?.(s)) return;
|
|
116
|
+
const rand = mulberry32(s.seed),
|
|
117
|
+
st = styles[s.style] ?? PLAIN_HOUSE_STYLE;
|
|
118
|
+
tagKit(kit, s);
|
|
119
|
+
if (s.build) {
|
|
120
|
+
kitPush(s.x, s.y, s.z, s.rot || 0);
|
|
121
|
+
(builds[s.build] ?? s.build)(kit, rand, s);
|
|
122
|
+
kitPop();
|
|
123
|
+
return;
|
|
124
|
+
} // street furniture and roof clutter that is only worth building near the viewer
|
|
125
|
+
kitPush(s.x, s.y, s.z, s.rot, s.lean || 0);
|
|
126
|
+
const house = {
|
|
127
|
+
R: rand, // the house's own random stream; other builders pass their own as R
|
|
128
|
+
st,
|
|
129
|
+
col: s.col,
|
|
130
|
+
rc: s.rc,
|
|
131
|
+
tim: C(st.timberColour ?? TIMBERS[Math.floor(hash(Math.round(s.x), Math.round(s.z), 17) * TIMBERS.length)], 0.2, rand),
|
|
132
|
+
frame: C(st.frame, 0.14, rand),
|
|
133
|
+
trim: C(st.trim, 0.08, rand),
|
|
134
|
+
plinth: C(st.plinthColour ?? 0x6f6a60, 0.1, rand),
|
|
135
|
+
chim: C(st.chimneyColour ?? 0x7a6f62, 0.12, rand),
|
|
136
|
+
shut: C(pickR(rand, SHUT), 0.12, rand),
|
|
137
|
+
hasShut: rand() < st.shutters,
|
|
138
|
+
litP: s.litP ?? st.litShare ?? 0.32,
|
|
139
|
+
rubble: !!s.rubble, // its walls of rubble stone, unplastered
|
|
140
|
+
};
|
|
141
|
+
const bodyOpts = {
|
|
142
|
+
n: s.n,
|
|
143
|
+
center: s.center,
|
|
144
|
+
noBal: s.noBal,
|
|
145
|
+
party: s.party,
|
|
146
|
+
shop: s.shop,
|
|
147
|
+
arch: s.arch,
|
|
148
|
+
found: s.found,
|
|
149
|
+
lite: s.lite,
|
|
150
|
+
doorCol: s.doorCol,
|
|
151
|
+
timber: s.timber,
|
|
152
|
+
};
|
|
153
|
+
(s.ruin < 1 ? forms.ruin : formOf(s.form))(kit, house, s, bodyOpts);
|
|
154
|
+
if (s.extra) (extras[s.extra] ?? s.extra)(kit, house, s);
|
|
155
|
+
kitPop();
|
|
156
|
+
}
|
|
157
|
+
// Houses from plain specs, as a worker builds them, or the page when there is none: each kit's arrays, where each house
|
|
158
|
+
// ends in them, and the lit windows each puts on the street. `frames`: for each house, the kit's frame it was placed in
|
|
159
|
+
// (kitFrame's numbers), where its builder had moved it; none, where it had not. `build`: lean, built for the middle
|
|
160
|
+
// distance, and kinds, the kinds of the kit wanted (kitNew: the others come back empty); padded, four bytes to a normal
|
|
161
|
+
// and a colour (GB.parts).
|
|
162
|
+
function housesFromSpecs(specs, frames = [], build = {}) {
|
|
163
|
+
const B = kitNew(build.lean, build.kinds),
|
|
164
|
+
ends = [],
|
|
165
|
+
lit = [],
|
|
166
|
+
before = kitFrame.clone();
|
|
167
|
+
specs.forEach((spec, i) => {
|
|
168
|
+
const from = openings.litWindowCount();
|
|
169
|
+
if (frames[i]) kitFrame.fromArray(frames[i]);
|
|
170
|
+
else kitFrame.copy(before);
|
|
171
|
+
genHouse(B, spec);
|
|
172
|
+
ends.push(kitCounts(B));
|
|
173
|
+
lit.push(openings.takeLitWindows(from));
|
|
174
|
+
});
|
|
175
|
+
kitFrame.copy(before);
|
|
176
|
+
return { kits: KIT_KEYS.map(k => B[k].parts(true, build.padded)), ends, lit };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
...frame,
|
|
181
|
+
...openings,
|
|
182
|
+
...roofs,
|
|
183
|
+
...parts,
|
|
184
|
+
...roof,
|
|
185
|
+
KIT_KEYS,
|
|
186
|
+
kitCounts,
|
|
187
|
+
facePut,
|
|
188
|
+
litAt,
|
|
189
|
+
kitBody,
|
|
190
|
+
kitCourtyardHouse,
|
|
191
|
+
propWashing: more.propWashing,
|
|
192
|
+
genHouse,
|
|
193
|
+
housesFromSpecs,
|
|
194
|
+
tagKit,
|
|
195
|
+
forms,
|
|
196
|
+
builds,
|
|
197
|
+
extras,
|
|
198
|
+
palette,
|
|
199
|
+
courtyard,
|
|
200
|
+
lump,
|
|
201
|
+
};
|
|
202
|
+
}
|