roamwright 0.4.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +21 -14
- package/README.md +38 -42
- package/examples/animals.html +49 -0
- package/examples/animals.js +209 -0
- package/examples/crowds.html +50 -0
- package/examples/crowds.js +268 -0
- package/examples/effects.html +53 -0
- package/examples/effects.js +343 -0
- package/examples/figure-motion.html +55 -0
- package/examples/figure-motion.js +265 -0
- package/examples/figure.html +49 -0
- package/examples/figure.js +238 -0
- package/examples/fliers.html +53 -0
- package/examples/fliers.js +292 -0
- package/examples/fortification.html +54 -0
- package/examples/fortification.js +288 -0
- package/examples/house-kit.html +48 -0
- package/examples/house-kit.js +175 -0
- package/examples/index.html +26 -16
- package/examples/island.html +48 -0
- package/examples/island.js +134 -52
- package/examples/land.html +54 -0
- package/examples/land.js +392 -0
- package/examples/props-and-plants.html +53 -0
- package/examples/props-and-plants.js +275 -0
- package/examples/rooms.html +48 -0
- package/examples/rooms.js +242 -0
- package/examples/ships.html +51 -0
- package/examples/ships.js +235 -0
- package/examples/showcase.css +320 -0
- package/examples/small-world-land.js +151 -0
- package/examples/small-world-life.js +160 -0
- package/examples/small-world-town.js +127 -0
- package/examples/small-world.html +57 -0
- package/examples/small-world.js +226 -0
- package/examples/soundscape.html +138 -0
- package/examples/soundscape.js +467 -0
- package/examples/stage-kits.js +300 -0
- package/examples/stage.js +374 -0
- package/examples/towns.html +50 -0
- package/examples/towns.js +325 -0
- package/examples/viaduct-camera.js +8 -4
- package/examples/viaduct-landscape.js +28 -17
- package/examples/viaduct.html +45 -43
- package/examples/viaduct.js +68 -92
- package/geometry/animal-camel-body.js +410 -0
- package/geometry/animal-camel-head.js +118 -0
- package/geometry/animal-canine-body.js +361 -0
- package/geometry/animal-canine-breeds.js +316 -0
- package/geometry/animal-canine-head.js +337 -0
- package/geometry/animal-cattle-body.js +391 -0
- package/geometry/animal-cattle-coat.js +42 -0
- package/geometry/animal-cattle-head.js +152 -0
- package/geometry/animal-hen.js +248 -0
- package/geometry/animal-horse-body.js +446 -0
- package/geometry/animal-horse-bridle.js +171 -0
- package/geometry/animal-horse-coat.js +68 -0
- package/geometry/animal-horse-face.js +162 -0
- package/geometry/animal-horse-hair.js +304 -0
- package/geometry/animal-horse-head.js +133 -0
- package/geometry/animal-horse-tack.js +157 -0
- package/geometry/animal-options.js +59 -0
- package/geometry/animal-shapes.js +21 -0
- package/geometry/animal-skin.js +390 -0
- package/geometry/bedding.js +141 -0
- package/geometry/builder-cells.js +50 -0
- package/geometry/builder-frame.js +48 -0
- package/geometry/builder.js +200 -177
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cell-mask.js +25 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +40 -35
- package/geometry/crowd-dress.js +315 -0
- package/geometry/crowd-far.js +174 -0
- package/geometry/crowd-look.js +42 -0
- package/geometry/crowd-weld.js +218 -0
- package/geometry/ear.js +44 -39
- package/geometry/erosion.js +71 -45
- package/geometry/face-grid.js +85 -65
- package/geometry/field-map.js +59 -0
- package/geometry/figure-arms.js +339 -0
- package/geometry/figure-beard.js +250 -0
- package/geometry/figure-body.js +297 -0
- package/geometry/figure-bow.js +105 -0
- package/geometry/figure-cloak.js +189 -0
- package/geometry/figure-clothes.js +337 -0
- package/geometry/figure-face-grids.js +75 -0
- package/geometry/figure-gear.js +446 -0
- package/geometry/figure-hair-far.js +151 -0
- package/geometry/figure-hair-hangs.js +108 -0
- package/geometry/figure-hair-patch.js +66 -0
- package/geometry/figure-hair.js +320 -0
- package/geometry/figure-hands.js +321 -0
- package/geometry/figure-head-features.js +280 -0
- package/geometry/figure-head.js +375 -0
- package/geometry/figure-headwear.js +223 -0
- package/geometry/figure-legs.js +231 -0
- package/geometry/figure-limbs.js +39 -0
- package/geometry/figure-sculpt.js +82 -0
- package/geometry/figure-skin.js +97 -0
- package/geometry/figure-skirts.js +303 -0
- package/geometry/figure-trunk.js +411 -0
- package/geometry/flier-corvid-body.js +322 -0
- package/geometry/flier-corvid-wings.js +154 -0
- package/geometry/flier-long-body.js +195 -0
- package/geometry/flier-shapes.js +219 -0
- package/geometry/flier-soaring-bird.js +84 -0
- package/geometry/foliage.js +187 -14
- package/geometry/fort-city-walls.js +479 -0
- package/geometry/fort-gate-approach.js +233 -0
- package/geometry/fort-great-walls.js +280 -0
- package/geometry/fort-keep.js +297 -0
- package/geometry/fort-parts.js +261 -0
- package/geometry/fort-polyline.js +261 -0
- package/geometry/fort-portal.js +96 -0
- package/geometry/fort-ring-wall.js +267 -0
- package/geometry/fort-seawall.js +104 -0
- package/geometry/fort-terrace-gates.js +323 -0
- package/geometry/fort-terrace-plan.js +250 -0
- package/geometry/fort-terrace-wall.js +345 -0
- package/geometry/garment-tags.js +11 -3
- package/geometry/grid-gather.js +69 -0
- package/geometry/grid-sample.js +185 -0
- package/geometry/hair-gathers.js +57 -42
- package/geometry/hair-locks.js +42 -42
- package/geometry/hair-patch.js +24 -20
- package/geometry/hair-shell.js +43 -31
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +26 -15
- package/geometry/head-shape.js +123 -95
- package/geometry/heightfield.js +50 -24
- package/geometry/horizon-angles.js +166 -0
- package/geometry/house-kit-body.js +195 -0
- package/geometry/house-kit-courtyard-parts.js +340 -0
- package/geometry/house-kit-courtyard-roof.js +223 -0
- package/geometry/house-kit-courtyard.js +409 -0
- package/geometry/house-kit-cut.js +29 -0
- package/geometry/house-kit-extras.js +192 -0
- package/geometry/house-kit-forms.js +298 -0
- package/geometry/house-kit-frame.js +74 -0
- package/geometry/house-kit-marks.js +93 -0
- package/geometry/house-kit-openings.js +193 -0
- package/geometry/house-kit-palette.js +54 -0
- package/geometry/house-kit-pool.js +71 -0
- package/geometry/house-kit-roofs.js +151 -0
- package/geometry/house-kit.js +202 -0
- package/geometry/index-parts.js +2 -2
- package/geometry/instance-visibility.js +12 -12
- package/geometry/instances.js +17 -17
- package/geometry/lamp-wash.js +65 -0
- package/geometry/land-clearings.js +83 -0
- package/geometry/land-ditches.js +290 -0
- package/geometry/land-dry-basin.js +327 -0
- package/geometry/land-dunes.js +150 -0
- package/geometry/land-earthworks.js +432 -0
- package/geometry/land-edge.js +292 -0
- package/geometry/land-mound-faces.js +349 -0
- package/geometry/land-near-relief.js +102 -0
- package/geometry/land-sheet.js +220 -0
- package/geometry/land-town-ground.js +256 -0
- package/geometry/land-waters.js +228 -0
- package/geometry/land-wildness.js +123 -0
- package/geometry/lathed-vessel.js +293 -0
- package/geometry/outline-grid.js +11 -10
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +38 -3
- package/geometry/path-field.js +98 -34
- package/geometry/placement.js +52 -52
- package/geometry/planked-floor.js +149 -0
- package/geometry/plant-broadleaf.js +268 -0
- package/geometry/plant-shrub.js +198 -0
- package/geometry/plant-tints.js +80 -0
- package/geometry/plant-trees.js +453 -0
- package/geometry/plant-tussock.js +107 -0
- package/geometry/point-buckets.js +50 -0
- package/geometry/primitives.js +117 -59
- package/geometry/prop-battlefield.js +69 -0
- package/geometry/prop-camp.js +175 -0
- package/geometry/prop-door.js +26 -0
- package/geometry/prop-harbour.js +105 -0
- package/geometry/prop-haycock.js +60 -0
- package/geometry/prop-sacks.js +74 -0
- package/geometry/prop-sheaf.js +68 -0
- package/geometry/prop-street.js +69 -0
- package/geometry/prop-tents.js +396 -0
- package/geometry/prop-tombs.js +80 -0
- package/geometry/prop-trade.js +393 -0
- package/geometry/prop-vehicles.js +218 -0
- package/geometry/props.js +58 -0
- package/geometry/room-arcade.js +134 -0
- package/geometry/room-dome.js +188 -0
- package/geometry/room-flames.js +138 -0
- package/geometry/room-frame.js +106 -0
- package/geometry/room-furniture.js +260 -0
- package/geometry/room-hearth.js +98 -0
- package/geometry/room-kit.js +59 -0
- package/geometry/room-openings.js +142 -0
- package/geometry/room-stairs.js +180 -0
- package/geometry/room-surfaces.js +272 -0
- package/geometry/sagging-tube.js +27 -27
- package/geometry/sampled-surface.js +123 -77
- package/geometry/scatter-grid.js +49 -6
- package/geometry/sculpt.js +97 -93
- package/geometry/ship-fittings.js +350 -0
- package/geometry/ship-hull.js +460 -0
- package/geometry/ship-kit.js +208 -0
- package/geometry/ship-lines.js +69 -0
- package/geometry/ship-oars.js +150 -0
- package/geometry/ship-presets.js +131 -0
- package/geometry/ship-rig.js +374 -0
- package/geometry/ship-sails.js +148 -0
- package/geometry/shore-grid.js +81 -34
- package/geometry/strata-field.js +131 -98
- package/geometry/strata-tiles.js +108 -94
- package/geometry/stream.js +96 -59
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +216 -123
- package/geometry/terrain-extension.js +29 -13
- package/geometry/town-courtyard-inn.js +272 -0
- package/geometry/town-ground.js +76 -0
- package/geometry/town-houses.js +343 -0
- package/geometry/town-lights.js +254 -0
- package/geometry/town-lots.js +172 -0
- package/geometry/town-plan.js +370 -0
- package/geometry/town-works.js +465 -0
- package/geometry/village-layout.js +181 -0
- package/geometry/village-yards.js +167 -0
- package/geometry/wall-runs.js +64 -0
- package/index.js +138 -2
- package/math/cell-edge.js +16 -16
- package/math/cell-key.js +6 -0
- package/math/circle-clearances.js +19 -0
- package/math/cloth-textures.js +6 -6
- package/math/cloud-textures.js +22 -26
- package/math/color.js +14 -14
- package/math/curve.js +26 -22
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +379 -205
- package/math/noise.js +101 -49
- package/math/particle-noise.js +28 -28
- package/math/periodic.js +11 -5
- package/math/random.js +24 -15
- package/math/rectangles.js +58 -0
- package/math/rock-texture.js +22 -17
- package/math/scalar.js +5 -5
- package/math/surface-textures.js +74 -59
- package/math/wandering-path.js +40 -0
- package/math/ways.js +120 -0
- package/motion/action-dynamics.js +398 -0
- package/motion/animal-bearing.js +247 -0
- package/motion/animal-canine-bearing.js +178 -0
- package/motion/animal-canine-cast.js +131 -0
- package/motion/animal-cattle-cast.js +64 -0
- package/motion/animal-herd-cast.js +154 -0
- package/motion/animal-horse-still.js +161 -0
- package/motion/animal-troop-cast.js +43 -0
- package/motion/arm-reach.js +27 -26
- package/motion/ballistic-arc.js +191 -0
- package/motion/biped-cycle.js +46 -0
- package/motion/biped-leg.js +40 -0
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +226 -140
- package/motion/boat-sailing.js +214 -0
- package/motion/contact-transition.js +32 -0
- package/motion/crowd-alarms.js +72 -42
- package/motion/crowd-attention.js +108 -0
- package/motion/crowd-beasts.js +203 -0
- package/motion/crowd-camp.js +295 -0
- package/motion/crowd-figure.js +100 -0
- package/motion/crowd-herd.js +86 -0
- package/motion/crowd-hold.js +130 -0
- package/motion/crowd-pose.js +296 -0
- package/motion/crowd-poses.js +481 -0
- package/motion/crowd-routine.js +126 -67
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/daily-clock.js +9 -9
- package/motion/deck-surface.js +40 -0
- package/motion/figure-acts.js +411 -0
- package/motion/figure-arms.js +437 -0
- package/motion/figure-blade-slide.js +149 -0
- package/motion/figure-body-place.js +180 -0
- package/motion/figure-bones.js +118 -0
- package/motion/figure-bow-draw.js +70 -0
- package/motion/figure-fingers.js +215 -0
- package/motion/figure-gaze.js +205 -0
- package/motion/figure-gestures.js +452 -0
- package/motion/figure-grip.js +134 -0
- package/motion/figure-head.js +287 -0
- package/motion/figure-legs.js +264 -0
- package/motion/figure-links.js +293 -0
- package/motion/figure-locomotion.js +391 -0
- package/motion/figure-mount-up.js +180 -0
- package/motion/figure-mount.js +201 -0
- package/motion/figure-pose-frame.js +375 -0
- package/motion/figure-pose-table.js +156 -0
- package/motion/figure-pose.js +343 -0
- package/motion/figure-seat.js +267 -0
- package/motion/figure-sway.js +125 -0
- package/motion/flier-corvid-pose.js +74 -0
- package/motion/flier-flight-air.js +122 -0
- package/motion/flier-flight-echelon.js +164 -0
- package/motion/flier-flight-roost.js +131 -0
- package/motion/flier-swarm-flight.js +252 -0
- package/motion/formation.js +193 -0
- package/motion/ground-lookahead.js +5 -5
- package/motion/instance-sight.js +15 -8
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +41 -32
- package/motion/quadruped.js +244 -168
- package/motion/spaces.js +90 -38
- package/motion/speech-cadence.js +304 -0
- package/motion/vessel-motion.js +57 -0
- package/motion/walk-grid.js +235 -0
- package/motion/weather.js +133 -26
- package/motion/wind.js +58 -13
- package/package.json +33 -6
- package/rendering/alpha-mips.js +340 -0
- package/rendering/animal-camel-figure.js +29 -0
- package/rendering/animal-canine-figure.js +59 -0
- package/rendering/animal-cattle-figure.js +36 -0
- package/rendering/animal-horse-figure.js +49 -0
- package/rendering/atmosphere.js +86 -0
- package/rendering/camera-track.js +156 -0
- package/rendering/cart-track.js +92 -0
- package/rendering/caster-motion.js +6 -5
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +754 -113
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +30 -30
- package/rendering/cloud-field.js +2 -2
- package/rendering/compilation-schedule.js +79 -14
- package/rendering/contact-shadows.js +7 -4
- package/rendering/context.js +57 -6
- package/rendering/crowd-batches.js +420 -0
- package/rendering/crowd-herd.js +198 -0
- package/rendering/crowd-rig.js +132 -0
- package/rendering/crowd-skinning.js +62 -19
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/crust.js +18 -12
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +4 -6
- package/rendering/detail-range.js +29 -0
- package/rendering/dispose-meshes.js +18 -0
- package/rendering/dof.js +20 -13
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/eye-adapt.js +14 -14
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +89 -62
- package/rendering/field-surface.js +138 -0
- package/rendering/figure-shield.js +105 -0
- package/rendering/figure-skeleton.js +329 -0
- package/rendering/fire-light-watch.js +197 -0
- package/rendering/fire-pools.js +148 -0
- package/rendering/flame-sources.js +86 -0
- package/rendering/flier-bird-looks.js +97 -0
- package/rendering/flier-corvid-figure.js +67 -0
- package/rendering/flier-long-body-company.js +169 -0
- package/rendering/flier-swarm.js +186 -0
- package/rendering/flocks.js +82 -78
- package/rendering/garment-material.js +147 -51
- package/rendering/glow-lines.js +13 -13
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +45 -31
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +164 -22
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +56 -0
- package/rendering/label-range.js +41 -0
- package/rendering/lamp-light-map.js +159 -0
- package/rendering/lamp-maps.js +62 -0
- package/rendering/lamp-wash.js +51 -0
- package/rendering/light-budget.js +71 -55
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +39 -8
- package/rendering/material-lod.js +49 -50
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +135 -99
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +212 -101
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +298 -11
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +806 -103
- package/rendering/plant-cells.js +122 -0
- package/rendering/plant-reeds.js +113 -0
- package/rendering/plant-shade-trees.js +239 -0
- package/rendering/plant-tuft-patch.js +122 -0
- package/rendering/post-shaders.js +98 -31
- package/rendering/post.js +107 -87
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/rain-streaks.js +67 -0
- package/rendering/room-light.js +250 -0
- package/rendering/room-materials.js +78 -0
- package/rendering/room-space.js +111 -0
- package/rendering/scene-lights.js +106 -0
- package/rendering/sea-shaders.js +94 -37
- package/rendering/settlement-approach.js +226 -0
- package/rendering/settlement-dissolve.js +89 -0
- package/rendering/settlement-quarter-warm.js +55 -0
- package/rendering/settlement-quarter.js +477 -0
- package/rendering/settlement-switch.js +42 -0
- package/rendering/settlement-town.js +110 -0
- package/rendering/shader-warmup.js +101 -44
- package/rendering/shadow-alignment.js +4 -4
- package/rendering/shadow-depth.js +47 -25
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +56 -29
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +126 -54
- package/rendering/smoke-shadows.js +201 -0
- package/rendering/stage-framing.js +182 -0
- package/rendering/stage-lights.js +46 -39
- package/rendering/stain-material.js +74 -0
- package/rendering/static-point-shadow.js +65 -26
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +12 -12
- package/rendering/stream-flow.js +10 -10
- package/rendering/street-lamps.js +166 -0
- package/rendering/sunbeam-motes.js +670 -0
- package/rendering/surface-light.js +65 -6
- package/rendering/surface-material.js +306 -0
- package/rendering/surface-projection.js +32 -0
- package/rendering/surface-snippets.js +314 -0
- package/rendering/taa.js +75 -44
- package/rendering/talus.js +15 -15
- package/rendering/terrain-rock.js +7 -7
- package/rendering/texture-fills.js +8 -8
- package/rendering/textures.js +28 -28
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/wakes.js +24 -24
- package/rendering/water-material.js +304 -103
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +38 -40
- package/ruff.toml +20 -0
- package/runtime/cue-cursor.js +21 -0
- package/runtime/device-quality.js +13 -2
- package/runtime/device.js +73 -0
- package/runtime/diagnostic-log.js +12 -4
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +36 -28
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +47 -0
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +15 -11
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +44 -5
- package/runtime/hand-over.js +47 -24
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +73 -17
- package/runtime/quality-fit.js +60 -28
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +26 -22
- package/runtime/settlement-reach.js +42 -0
- package/runtime/sound-calls.js +113 -0
- package/runtime/sound-impacts.js +297 -0
- package/runtime/sound-voices.js +194 -0
- package/runtime/soundscape.js +282 -0
- package/runtime/spatial-audio.js +79 -30
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +46 -0
- package/runtime/worker.js +7 -0
- package/scripts/app-parts.mjs +118 -0
- package/scripts/bake-revisions.mjs +81 -0
- package/scripts/browser-scripts.mjs +64 -0
- package/scripts/bundle.mjs +192 -0
- package/scripts/check-app.sh +26 -0
- package/scripts/eslint-config.mjs +119 -0
- package/scripts/format.sh +92 -0
- package/scripts/keep-builds.mjs +158 -0
- package/scripts/layers.mjs +112 -0
- package/scripts/lint.sh +49 -0
- package/scripts/module-graph.mjs +123 -0
- package/scripts/pre-commit.sh +38 -0
- package/scripts/serve.py +5 -3
- package/scripts/site.mjs +358 -0
- package/scripts/test-runner.sh +42 -0
- package/scripts/vendor.mjs +221 -0
- package/scripts/verify-publish.mjs +175 -0
- package/scripts/world.mk +59 -0
- package/tools/README.md +73 -0
- package/tools/contact-sheet.cjs +137 -0
- package/tools/cpu-profile.cjs +275 -0
- package/tools/cpu-profile.test.cjs +98 -0
- package/tools/first-draws.cjs +395 -0
- package/tools/flight-guard.cjs +482 -0
- package/tools/flight-guard.test.cjs +153 -0
- package/tools/flight-profile.cjs +145 -0
- package/tools/frame-bench.cjs +336 -0
- package/tools/frame-parts.cjs +365 -0
- package/tools/ios-sim.sh +145 -0
- package/tools/load-audit.cjs +201 -0
- package/tools/look-compare.cjs +304 -0
- package/tools/look-guard.cjs +407 -0
- package/tools/look-guard.test.cjs +93 -0
- package/tools/look-stats.cjs +185 -0
- package/tools/look-stats.test.cjs +71 -0
- package/tools/memory-audit.cjs +323 -0
- package/tools/page-driver.cjs +320 -0
- package/tools/page-driver.test.cjs +219 -0
- package/tools/program-census-report.cjs +191 -0
- package/tools/program-census.cjs +465 -0
- package/tools/program-census.test.cjs +332 -0
- package/tools/remote-runner.sh +265 -0
- package/tools/runners.test.cjs +59 -0
- package/tools/scene-audit-beat.cjs +344 -0
- package/tools/scene-audit-sheet.cjs +282 -0
- package/tools/scene-audit.cjs +471 -0
- package/tools/scene-audit.test.cjs +201 -0
- package/tools/scene-batch.cjs +219 -0
- package/tools/scene-bench.cjs +149 -0
- package/tools/scene-bench.test.cjs +33 -0
- package/tools/scene-run.cjs +443 -0
- package/tools/scene-run.test.cjs +94 -0
- package/tools/servers.sh +59 -0
- package/tools/shader-arrival.cjs +316 -0
- package/tools/shader-renewal.cjs +53 -0
- package/tools/shader-renewal.test.cjs +115 -0
- package/tools/speed-guard.cjs +258 -0
- package/tools/stills.cjs +492 -0
- package/tools/stills.test.cjs +49 -0
- package/tools/turns.sh +7 -0
- package/tools/yaml.cjs +158 -0
- package/examples/viaduct.css +0 -75
- package/rendering/light-shafts.js +0 -131
- package/rendering/road-surface.js +0 -63
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// The forms of a house kit's buildings: the gabled house, the hipped and corniced bodies, the flat-roofed house, the round
|
|
2
|
+
// and square towers, the domed building and the ruin. Worker-safe.
|
|
3
|
+
import { dim } from '../math/color.js';
|
|
4
|
+
import { pickR } from '../math/random.js';
|
|
5
|
+
import { clamp, TAU } from '../math/scalar.js';
|
|
6
|
+
import { C, TRS } from './primitives.js';
|
|
7
|
+
import { facePut } from './house-kit-frame.js';
|
|
8
|
+
import { kitSoot } from './house-kit-marks.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The house kit's built-in forms, bound to its parts. Each is called as form(kit, house, spec, bodyOptions), where `house`
|
|
12
|
+
* holds the house's values (its random stream `R`, its style `st`, its colours) and `spec` is the house's spec.
|
|
13
|
+
* @param {object} o
|
|
14
|
+
* @param {object} o.U - The unit shapes.
|
|
15
|
+
* @param {Function} o.kitPush - The kit frame's push.
|
|
16
|
+
* @param {Function} o.kitPop - The kit frame's pop.
|
|
17
|
+
* @param {object} o.palette - The house palette.
|
|
18
|
+
* @param {object} o.openings - The kit's openings (`createHouseKitOpenings`).
|
|
19
|
+
* @param {object} o.roofs - The kit's roofs (`createHouseKitRoofs`).
|
|
20
|
+
* @param {Function} o.kitBody - The kit's body (`createHouseKitBody`).
|
|
21
|
+
* @returns {object} The forms by name: `gable` (the default: a body under a pitched roof, its ridge across the front unless
|
|
22
|
+
* `turn`; a style's `yardClutter` stacks logs and a barrel by it), `hip` (a pyramid roof and two chimneys), `body` (a corniced
|
|
23
|
+
* body, its roof left to the caller), `flat` (a parapet, and a roof room with washing unless the style's roof is `bareRoof`),
|
|
24
|
+
* `round` (a round stone tower), `tower` (a square tower with a corbelled parapet), `dome` (a domed building) and `ruin`
|
|
25
|
+
* (broken walls, fallen beams and rubble: genHouse builds it for any spec whose `ruin` is under 1).
|
|
26
|
+
*/
|
|
27
|
+
export function createHouseKitForms({ U, kitPush, kitPop, palette, openings, roofs, kitBody }) {
|
|
28
|
+
const { windowLight: WARM, black: BLACK, cloths: CLOTHS } = palette,
|
|
29
|
+
{ kitBarrel, kitDoor, kitWindow } = openings,
|
|
30
|
+
{ kitChimney, kitFinial, kitGable } = roofs;
|
|
31
|
+
// A round tower of stone: storeys marked by bands, windows staggered round it, a door at the foot and a conical roof.
|
|
32
|
+
function kitRound(kit, house, s) {
|
|
33
|
+
const { R: rand } = house,
|
|
34
|
+
r = s.w * 0.36,
|
|
35
|
+
h = s.h + 5,
|
|
36
|
+
n = Math.max(2, Math.round(h / 3.3)),
|
|
37
|
+
sh = h / n,
|
|
38
|
+
ap = r * Math.cos(Math.PI / 16),
|
|
39
|
+
sc = dim(s.col, 0.86);
|
|
40
|
+
kit.stone.add(U.cyl16, house.plinth, TRS(0, -2.4, 0, r * 2 + 0.3, 3.1, r * 2 + 0.3));
|
|
41
|
+
kit.stone.add(U.cyl16, sc, TRS(0, 0, 0, r * 2, h, r * 2));
|
|
42
|
+
for (let i = 1; i < n; i++) kit.stone.add(U.cyl16, house.trim, TRS(0, i * sh - 0.1, 0, r * 2 + 0.16, 0.2, r * 2 + 0.16));
|
|
43
|
+
kit.stone.add(U.cyl16, house.trim, TRS(0, h - 0.5, 0, r * 2 + 0.5, 0.5, r * 2 + 0.5));
|
|
44
|
+
const f0 = (rand() * 16) | 0;
|
|
45
|
+
for (let i = 0; i < n; i++)
|
|
46
|
+
for (let q = 0; q < 4; q++) {
|
|
47
|
+
kitPush(0, 0, 0, ((((f0 + q * 4 + (i % 2) * 2) % 16) + 0.5) * TAU) / 16);
|
|
48
|
+
const put = facePut(0, 0, ap);
|
|
49
|
+
if (i === 0 && q === 0) kitDoor(kit, house, put, 0, { w: 0.85 });
|
|
50
|
+
else if (i > 0 || rand() < 0.5)
|
|
51
|
+
kitWindow(kit, put, 0, i * sh + 1.0, Math.min(0.62, r * 0.3), Math.min(1.3, sh - 1.6), {
|
|
52
|
+
frame: house.frame,
|
|
53
|
+
lit: rand() < house.litP ? WARM[(rand() * 3) | 0] : null,
|
|
54
|
+
sill: house.trim,
|
|
55
|
+
lintel: house.trim,
|
|
56
|
+
});
|
|
57
|
+
kitPop();
|
|
58
|
+
}
|
|
59
|
+
kit.wood.add(U.cyl16, house.tim, TRS(0, h, 0, r * 2 + 1.1, 0.12, r * 2 + 1.1));
|
|
60
|
+
kit.roof.add(U.cone16, s.rc, TRS(0, h + 0.12, 0, r * 2 + 1.1, s.rise, r * 2 + 1.1));
|
|
61
|
+
kitFinial(kit, h + s.rise);
|
|
62
|
+
}
|
|
63
|
+
// A ruin: a plinth, four broken walls whose tops step down course by course, fallen beams and rubble round it.
|
|
64
|
+
function kitRuin(kit, house, s) {
|
|
65
|
+
const { R: rand } = house,
|
|
66
|
+
w = s.w,
|
|
67
|
+
d = s.d,
|
|
68
|
+
h = s.h,
|
|
69
|
+
th = 0.55,
|
|
70
|
+
sc = s.col;
|
|
71
|
+
kit.stone.box(0, -1.7, 0, w + 0.2, 1.85, d + 0.2, house.plinth);
|
|
72
|
+
for (let f = 0; f < 4; f++) {
|
|
73
|
+
const fw = f < 2 ? w : d - th * 2,
|
|
74
|
+
ns = Math.max(2, Math.round(fw / 2.2)),
|
|
75
|
+
sw = fw / ns,
|
|
76
|
+
put = facePut(f, w / 2 - th, d / 2 - th);
|
|
77
|
+
for (let k = 0; k < ns; k++) {
|
|
78
|
+
// a broken wall gives way course by course: sound to some height, then stepping back toward one end, so its top rakes down in steps
|
|
79
|
+
const hh = h * (0.35 + 0.65 * rand()) * (rand() < 0.15 ? 0.25 : 1),
|
|
80
|
+
u = (k + 0.5 - ns / 2) * sw,
|
|
81
|
+
c = dim(sc, 0.82 + rand() * 0.36),
|
|
82
|
+
W0 = sw + 0.02;
|
|
83
|
+
const hb = hh * (0.5 + 0.2 * rand()),
|
|
84
|
+
side = (k + f) % 2 ? 1 : -1,
|
|
85
|
+
cut = 0.45 + 0.45 * rand(),
|
|
86
|
+
nC = Math.max(1, Math.round((hh - hb) / 0.38)),
|
|
87
|
+
ch = (hh - hb) / nC;
|
|
88
|
+
put(kit.stone, U.box, c, u, 0, th / 2, W0, hb, th);
|
|
89
|
+
for (let j = 0; j < nC; j++) {
|
|
90
|
+
const ww = clamp(W0 * (1 - (cut * (j + 1)) / nC) + (rand() - 0.5) * 0.35, 0.3, W0);
|
|
91
|
+
put(
|
|
92
|
+
kit.stone,
|
|
93
|
+
U.box,
|
|
94
|
+
dim(c, 0.92 + rand() * 0.14),
|
|
95
|
+
u - (side * (W0 - ww)) / 2,
|
|
96
|
+
hb + j * ch,
|
|
97
|
+
th / 2 + (rand() - 0.5) * 0.05,
|
|
98
|
+
ww,
|
|
99
|
+
ch + 0.01,
|
|
100
|
+
th,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (hb > 2.9 && rand() < 0.65) {
|
|
104
|
+
const wh = Math.min(1.3, hb - 1.75);
|
|
105
|
+
put(kit.cloth, U.quad, BLACK, u, 1.0, th + 0.02, 0.8, wh, 1);
|
|
106
|
+
put(kit.stone, U.boxF, dim(c, 1.2), u, 0.86, th + 0.06, 1.1, 0.12, 0.14);
|
|
107
|
+
kitSoot(kit, put, u, 1.0 + wh, 1.3, Math.min(1.8, hb - 1.0 - wh + 0.4), u * 0.37 + f * 0.21 + hh * 0.13, th);
|
|
108
|
+
}
|
|
109
|
+
if (rand() < 0.35) put(kit.stone, U.rock, c, u + side * W0 * 0.28, hb - 0.25, th / 2, 0.8, 0.55, th * 1.4);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const nb = 2 + ((rand() * 3) | 0);
|
|
113
|
+
for (let q = 0; q < nb; q++)
|
|
114
|
+
kit.wood.add(
|
|
115
|
+
U.box,
|
|
116
|
+
C(0x1c1714, 0.25, rand),
|
|
117
|
+
TRS(
|
|
118
|
+
(rand() - 0.5) * w * 0.6,
|
|
119
|
+
0.15,
|
|
120
|
+
(rand() - 0.5) * d * 0.6,
|
|
121
|
+
0.22,
|
|
122
|
+
2.4 + rand() * Math.min(w, d) * 0.6,
|
|
123
|
+
0.22,
|
|
124
|
+
rand() * 6,
|
|
125
|
+
0.5 + rand() * 0.9,
|
|
126
|
+
(rand() - 0.5) * 0.8,
|
|
127
|
+
),
|
|
128
|
+
);
|
|
129
|
+
for (let q = 0; q < 6; q++)
|
|
130
|
+
kit.stone.add(
|
|
131
|
+
U.rock,
|
|
132
|
+
dim(sc, 0.8 + rand() * 0.4),
|
|
133
|
+
TRS(
|
|
134
|
+
(rand() - 0.5) * (w + 2.5),
|
|
135
|
+
-0.2,
|
|
136
|
+
(rand() - 0.5) * (d + 2.5),
|
|
137
|
+
0.6 + rand() * 1.3,
|
|
138
|
+
0.4 + rand() * 0.8,
|
|
139
|
+
0.6 + rand() * 1.3,
|
|
140
|
+
rand() * 6,
|
|
141
|
+
rand(),
|
|
142
|
+
rand(),
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
// A square tower: a plain body, a corbelled parapet, a pyramid roof and its finial.
|
|
147
|
+
function kitTower(kit, house, s) {
|
|
148
|
+
const { w, d, h } = s;
|
|
149
|
+
const tw = w * 0.8,
|
|
150
|
+
td = d * 0.8,
|
|
151
|
+
th = h + 3;
|
|
152
|
+
kitBody(kit, house, tw, td, th, { plain: true, sideSkip: 0.15, n: s.n, party: s.party, found: s.found });
|
|
153
|
+
kit.stone.box(0, th - 0.8, 0, tw + 0.44, 0.8, td + 0.44, house.trim);
|
|
154
|
+
const nk = Math.max(3, Math.round(tw / 0.9));
|
|
155
|
+
for (let k = 0; k <= nk; k++)
|
|
156
|
+
for (const sg of [-1, 1]) {
|
|
157
|
+
kit.stone.box((k / nk - 0.5) * tw, th - 1.15, sg * (td / 2 + 0.1), 0.24, 0.36, 0.3, house.trim);
|
|
158
|
+
kit.stone.box(sg * (tw / 2 + 0.1), th - 1.15, (k / nk - 0.5) * td, 0.3, 0.36, 0.24, house.trim);
|
|
159
|
+
}
|
|
160
|
+
kit.wood.box(0, th, 0, tw + 1.2, 0.12, td + 1.2, house.tim);
|
|
161
|
+
kit.roof.add(U.pyr, s.rc, TRS(0, th + 0.12, 0, tw + 1.2, s.rise, td + 1.2));
|
|
162
|
+
kitFinial(kit, th + s.rise);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// A domed building: a plain body, a drum with windows, the dome and its finial.
|
|
166
|
+
function kitDomed(kit, house, s) {
|
|
167
|
+
const { R: rand } = house;
|
|
168
|
+
const { w, d, h } = s;
|
|
169
|
+
kitBody(kit, house, w, d, h, { plain: true, party: s.party, found: s.found });
|
|
170
|
+
const m = Math.min(w, d) * 0.92;
|
|
171
|
+
kit.stone.box(0, h - 0.05, 0, w + 0.4, 0.3, d + 0.4, house.trim);
|
|
172
|
+
kit.wall.box(0, h + 0.25, 0, w - 0.3, 0.4, d - 0.3, s.col);
|
|
173
|
+
kit.stone.add(U.cyl16, house.trim, TRS(0, h + 0.6, 0, m * 0.98, 1.0, m * 0.98));
|
|
174
|
+
for (let q = 0; q < 8; q++) {
|
|
175
|
+
kitPush(0, 0, 0, ((q * 2 + 0.5) * TAU) / 16);
|
|
176
|
+
facePut(0, 0, m * 0.49 * Math.cos(Math.PI / 16))(
|
|
177
|
+
kit.glass,
|
|
178
|
+
U.quad,
|
|
179
|
+
rand() < house.litP ? WARM[0] : BLACK,
|
|
180
|
+
0,
|
|
181
|
+
h + 0.8,
|
|
182
|
+
0.03,
|
|
183
|
+
m * 0.1,
|
|
184
|
+
0.6,
|
|
185
|
+
1,
|
|
186
|
+
);
|
|
187
|
+
kitPop();
|
|
188
|
+
}
|
|
189
|
+
kit.stone.add(U.cyl16, house.trim, TRS(0, h + 1.6, 0, m * 1.04, 0.14, m * 1.04));
|
|
190
|
+
kit.cloth.add(U.dome16, s.rc, TRS(0, h + 1.74, 0, m, m, m));
|
|
191
|
+
kitFinial(kit, h + 1.7 + m / 2, 1.2);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// A body with a cornice, and for form hip (`roofed`) a pyramid roof with two chimneys.
|
|
195
|
+
function kitHipped(kit, house, s, opts, roofed) {
|
|
196
|
+
const { w, d, h } = s;
|
|
197
|
+
const b = kitBody(kit, house, w, d, h, opts);
|
|
198
|
+
kit.stone.box(0, h - 0.1, 0, b.hw * 2 + 0.5, 0.34, b.hd * 2 + 0.5, house.trim);
|
|
199
|
+
if (roofed) {
|
|
200
|
+
kit.roof.add(U.pyr, s.rc, TRS(0, h + 0.24, 0, b.hw * 2 + 1.1, s.rise, b.hd * 2 + 1.1));
|
|
201
|
+
for (const sg of [-1, 1]) kitChimney(kit, house, sg * w * 0.28, 0, h + s.rise * 0.3, h + s.rise * 0.72 + 1.0);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// A flat-roofed house: a parapet round the roof and, unless its style's roof is bare (a ruin's), a room on the roof, washing on a line and pots.
|
|
206
|
+
function kitFlatRoofed(kit, house, s, opts) {
|
|
207
|
+
const { R: rand, st } = house;
|
|
208
|
+
const { w, d, h } = s;
|
|
209
|
+
const b = kitBody(kit, house, w, d, h, opts),
|
|
210
|
+
hw = b.hw,
|
|
211
|
+
hd = b.hd;
|
|
212
|
+
for (const sg of [1, -1]) {
|
|
213
|
+
kit.wall.box(0, h, sg * (hd - 0.15), hw * 2, 0.8, 0.3, s.col);
|
|
214
|
+
kit.wall.box(sg * (hw - 0.15), h, 0, 0.3, 0.8, hd * 2 - 0.6, s.col);
|
|
215
|
+
kit.stone.box(0, h + 0.8, sg * (hd - 0.15), hw * 2 + 0.1, 0.1, 0.42, house.trim);
|
|
216
|
+
kit.stone.box(sg * (hw - 0.15), h + 0.8, 0, 0.42, 0.1, hd * 2 + 0.1, house.trim);
|
|
217
|
+
}
|
|
218
|
+
if (!st.bareRoof) {
|
|
219
|
+
const hx = (rand() < 0.5 ? -1 : 1) * hw * 0.42,
|
|
220
|
+
hz = (rand() < 0.5 ? -1 : 1) * hd * 0.36,
|
|
221
|
+
uw = hw * 0.84,
|
|
222
|
+
ud = hd * 0.8;
|
|
223
|
+
kit.wall.box(hx, h, hz, uw, 2.1, ud, s.col2 || s.col);
|
|
224
|
+
kit.roof.add(U.box, s.rc, TRS(hx, h + 2.1, hz, uw + 0.5, 0.12, ud + 0.5, 0, 0.1));
|
|
225
|
+
kitPush(hx, h, hz, hx > 0 ? -Math.PI / 2 : Math.PI / 2);
|
|
226
|
+
facePut(0, 0, uw / 2)(kit.wood, U.boxF, C(st.door, 0.2, rand), 0, 0, 0.03, 0.8, 1.8, 0.06);
|
|
227
|
+
kitPop();
|
|
228
|
+
const lx = -hx,
|
|
229
|
+
nl = 3 + ((rand() * 3) | 0);
|
|
230
|
+
for (const sg of [-1, 1]) kit.wood.add(U.cyl6, house.tim, TRS(lx, h, sg * hd * 0.62, 0.07, 1.95, 0.07));
|
|
231
|
+
kit.cloth.box(lx, h + 1.84, 0, 0.025, 0.025, hd * 1.24, [0.03, 0.03, 0.03]);
|
|
232
|
+
for (let q = 0; q < nl; q++) {
|
|
233
|
+
const ch = 0.5 + rand() * 0.5;
|
|
234
|
+
kit.cloth.box(
|
|
235
|
+
lx,
|
|
236
|
+
h + 1.84 - ch,
|
|
237
|
+
(((q + 0.5 - nl / 2) * hd * 1.0) / nl) * 1.1,
|
|
238
|
+
0.03,
|
|
239
|
+
ch,
|
|
240
|
+
0.42 + rand() * 0.2,
|
|
241
|
+
C(pickR(rand, CLOTHS), 0.12, rand),
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
for (let q = 0; q < 3; q++) {
|
|
245
|
+
const px = (rand() - 0.5) * hw * 1.4,
|
|
246
|
+
pz = -hz + (rand() - 0.5) * 1.5;
|
|
247
|
+
kit.cloth.add(U.taper, [0.3, 0.13, 0.07], TRS(px, h, pz, 0.36, 0.34, 0.36, 0, Math.PI));
|
|
248
|
+
kit.cloth.add(U.sph, [0.07, 0.17, 0.05], TRS(px, h + 0.42, pz, 0.5, 0.5, 0.5));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// A gabled house; one of a style with a cluttered yard (`yardClutter`) with logs stacked by its side, a barrel at the door and a stovepipe.
|
|
254
|
+
function kitGabled(kit, house, s, opts) {
|
|
255
|
+
const { R: rand, st } = house;
|
|
256
|
+
const { w, d, h } = s;
|
|
257
|
+
const b = kitBody(kit, house, w, d, h, opts),
|
|
258
|
+
turn = s.turn;
|
|
259
|
+
kitGable(kit, house, 0, h, 0, turn ? b.hw * 2 : b.hd * 2, turn ? b.hd * 2 : b.hw * 2, s.rise, turn ? 0 : Math.PI / 2, s.rc, s.col, {
|
|
260
|
+
full: true,
|
|
261
|
+
chimney: s.chim,
|
|
262
|
+
chimAt: s.chimAt ? (turn ? s.chimAt : [-s.chimAt[1], s.chimAt[0]]) : null,
|
|
263
|
+
timber: b.timber,
|
|
264
|
+
gmat: house.rubble && !b.timber ? kit.rubble : st.material === 'wood' ? kit.wood : kit.wall,
|
|
265
|
+
});
|
|
266
|
+
if (st.yardClutter) {
|
|
267
|
+
const put = facePut(2, w / 2, d / 2);
|
|
268
|
+
if (rand() < 0.6)
|
|
269
|
+
for (let q = 0; q < 9; q++)
|
|
270
|
+
put(
|
|
271
|
+
kit.wood,
|
|
272
|
+
U.cyl6,
|
|
273
|
+
C(0x6a5540, 0.2, rand),
|
|
274
|
+
-d * 0.2 + (q % 3) * 0.3,
|
|
275
|
+
0.02 + ((q / 3) | 0) * 0.26,
|
|
276
|
+
0.5,
|
|
277
|
+
0.28,
|
|
278
|
+
0.9,
|
|
279
|
+
0.28,
|
|
280
|
+
0,
|
|
281
|
+
Math.PI / 2,
|
|
282
|
+
);
|
|
283
|
+
if (rand() < 0.6) kitBarrel(kit, facePut(0, w / 2, d / 2), w * 0.3, 0.5, 0.9, rand);
|
|
284
|
+
if (!s.chim) kit.cloth.add(U.cyl6, [0.03, 0.03, 0.03], TRS(w * 0.2, h, d * 0.15, 0.16, s.rise + 0.7, 0.16));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
gable: kitGabled,
|
|
290
|
+
hip: (kit, house, s, opts) => kitHipped(kit, house, s, opts, true),
|
|
291
|
+
body: (kit, house, s, opts) => kitHipped(kit, house, s, opts, false),
|
|
292
|
+
flat: kitFlatRoofed,
|
|
293
|
+
round: kitRound,
|
|
294
|
+
tower: kitTower,
|
|
295
|
+
dome: kitDomed,
|
|
296
|
+
ruin: kitRuin,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// The house kit's builders, one per material, and the frame its parts are placed in: kitPush and kitPop move it, facePut
|
|
2
|
+
// places on a wall. Worker-safe: no DOM, no WebGL.
|
|
3
|
+
import { boxFacePlacer, createBuilderFrame } from './builder-frame.js';
|
|
4
|
+
import { GB } from './builder.js';
|
|
5
|
+
import { TRS } from './primitives.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The kinds of a house kit, one geometry builder and one material each, in the order every kit's arrays are given.
|
|
9
|
+
* `trim` is woodwork too small to cast a shadow worth drawing (window frames, shutters, door leaves); `stain` holds the
|
|
10
|
+
* see-through weathering decals; `rubble`, the unsquared stone of the meanest houses.
|
|
11
|
+
* @type {ReadonlyArray<string>}
|
|
12
|
+
*/
|
|
13
|
+
export const KIT_KEYS = Object.freeze(['wall', 'stone', 'wood', 'roof', 'glass', 'cloth', 'trim', 'stain', 'rubble']);
|
|
14
|
+
/** A bit for each kind of {@link KIT_KEYS}, in its order: every kind wanted. */
|
|
15
|
+
export const EVERY_KIND = (1 << KIT_KEYS.length) - 1;
|
|
16
|
+
/**
|
|
17
|
+
* The vertex counts of each kind of a kit, in {@link KIT_KEYS}'s order: where whatever is added next will start.
|
|
18
|
+
* @param {object} kit - A kit made by a house kit's `kitNew`.
|
|
19
|
+
* @returns {number[]}
|
|
20
|
+
*/
|
|
21
|
+
export const kitCounts = kit => KIT_KEYS.map(kind => kit[kind].count);
|
|
22
|
+
/**
|
|
23
|
+
* A placer on one face of a box (the engine's `boxFacePlacer`): `put(builder, shape, colour, along, height, outward, sx, sy, sz, roll, pitch)`.
|
|
24
|
+
* Faces are numbered +Z, -Z, +X, -X.
|
|
25
|
+
*/
|
|
26
|
+
export const facePut = boxFacePlacer;
|
|
27
|
+
|
|
28
|
+
// A builder for a kind of the kit that is not wanted (a block built without its small parts): the houses are built as ever,
|
|
29
|
+
// drawing the same numbers from their seeds, so the other kinds come out the same, but nothing put in it is kept.
|
|
30
|
+
class Unkept extends GB {
|
|
31
|
+
add() {
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
raw() {}
|
|
35
|
+
take() {}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The frame a house kit places its parts in, and its fresh kits. Each house kit has one: the frame is shared by every kit it
|
|
40
|
+
* makes, so parts placed by one builder land where the builder before it moved the frame.
|
|
41
|
+
* @returns {{
|
|
42
|
+
* kitFrame: import('three').Matrix4,
|
|
43
|
+
* kitPush: (x: number, y: number, z: number, ry?: number, rz?: number) => void,
|
|
44
|
+
* kitPop: () => void,
|
|
45
|
+
* kitNew: (lean?: boolean, kinds?: number) => object,
|
|
46
|
+
* kitAt: (kit: object, x: number, y: number, z: number, ry: number, streetLit: boolean, fn: Function, random?: () => number) => void,
|
|
47
|
+
* }} `kitFrame`, the frame's matrix (stable, read by every builder); `kitPush`, moves it by a translation in metres and turns
|
|
48
|
+
* about y then z in radians, remembering the old one; `kitPop`, puts the old one back; `kitNew(lean, kinds)`, a fresh kit of
|
|
49
|
+
* builders, one per kind (`lean`: built for the middle distance, where a house that knows how gives its rounded and finer
|
|
50
|
+
* parts fewer faces; `kinds`: a bit each, {@link EVERY_KIND}'s, the others keep nothing); `kitAt(kit, x, y, z, ry, streetLit, fn, random)`,
|
|
51
|
+
* calls fn(kit, random) with the frame at (x, y, z) turned by ry, its glass lit by street light at height y when `streetLit`.
|
|
52
|
+
*/
|
|
53
|
+
export function createKitFrame() {
|
|
54
|
+
const { matrix: kitFrame, push, pop: kitPop } = createBuilderFrame();
|
|
55
|
+
function kitNew(lean = false, kinds = EVERY_KIND) {
|
|
56
|
+
const kit = { lean };
|
|
57
|
+
for (const [i, k] of KIT_KEYS.entries()) {
|
|
58
|
+
const g = (kit[k] = (kinds >> i) & 1 ? new GB() : new Unkept());
|
|
59
|
+
g.M = kitFrame;
|
|
60
|
+
if (k === 'wall' || k === 'stone' || k === 'wood' || k === 'trim' || k === 'rubble') g.tg = [];
|
|
61
|
+
}
|
|
62
|
+
return kit;
|
|
63
|
+
}
|
|
64
|
+
function kitPush(x, y, z, ry = 0, rz = 0) {
|
|
65
|
+
push(TRS(x, y, z, 1, 1, 1, ry, 0, rz));
|
|
66
|
+
}
|
|
67
|
+
function kitAt(B, x, y, z, ry, streetLit, fn, R) {
|
|
68
|
+
for (const k of KIT_KEYS) B[k].tv = streetLit ? y : y - 1000;
|
|
69
|
+
kitPush(x, y, z, ry);
|
|
70
|
+
fn(B, R);
|
|
71
|
+
kitPop();
|
|
72
|
+
}
|
|
73
|
+
return { kitFrame, kitPush, kitPop, kitNew, kitAt };
|
|
74
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Weathering on a house kit's walls: stains run down from sills and eaves, soot above openings, wear and tilled earth on the
|
|
2
|
+
// ground, all as see-through decals in the kit's `stain` builder. Each decal's vertex colour is not a colour: it carries
|
|
3
|
+
// (across, down, pattern) for the material that draws the kit's stains. Worker-safe and stateless.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A decal: a see-through quad lying just off a surface, written into a builder as two triangles.
|
|
7
|
+
* @param {object} g - The builder (a kit's `stain`).
|
|
8
|
+
* @param {number[]} a - Lower-left corner [x, y, z], in the builder's frame.
|
|
9
|
+
* @param {number[]} b - Lower-right corner.
|
|
10
|
+
* @param {number[]} c - Upper-right corner.
|
|
11
|
+
* @param {number[]} d - Upper-left corner.
|
|
12
|
+
* @param {number[]} n - The surface's normal.
|
|
13
|
+
* @param {number} k - The pattern code the stain material reads (a byte as 0..1).
|
|
14
|
+
*/
|
|
15
|
+
export function kitDecal(g, a, b, c, d, n, k) {
|
|
16
|
+
// corners: lower left, lower right, upper right, upper left
|
|
17
|
+
g.raw(a[0], a[1], a[2], n[0], n[1], n[2], 0, 1, k);
|
|
18
|
+
g.raw(b[0], b[1], b[2], n[0], n[1], n[2], 1, 1, k);
|
|
19
|
+
g.raw(c[0], c[1], c[2], n[0], n[1], n[2], 1, 0, k);
|
|
20
|
+
g.raw(a[0], a[1], a[2], n[0], n[1], n[2], 0, 1, k);
|
|
21
|
+
g.raw(c[0], c[1], c[2], n[0], n[1], n[2], 1, 0, k);
|
|
22
|
+
g.raw(d[0], d[1], d[2], n[0], n[1], n[2], 0, 0, k);
|
|
23
|
+
}
|
|
24
|
+
function wallMark(kit, put, u, w, startY, endY, out, pattern) {
|
|
25
|
+
kitDecal(
|
|
26
|
+
kit.stain,
|
|
27
|
+
put.point(u - w / 2, endY, out),
|
|
28
|
+
put.point(u + w / 2, endY, out),
|
|
29
|
+
put.point(u + w / 2, startY, out),
|
|
30
|
+
put.point(u - w / 2, startY, out),
|
|
31
|
+
put.normal,
|
|
32
|
+
pattern,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const streakSeed = seed => (((seed % 1) + 1) % 1) * 0.48;
|
|
36
|
+
/**
|
|
37
|
+
* A stain run down a wall from a ledge (a sill, an eave): runoff hangs from yTop and fades h metres below it.
|
|
38
|
+
* @param {object} kit - A house kit's kit.
|
|
39
|
+
* @param {Function} put - The wall's face placer (`facePut`).
|
|
40
|
+
* @param {number} u - Metres along the face from its middle.
|
|
41
|
+
* @param {number} yTop - Height of the ledge, in metres.
|
|
42
|
+
* @param {number} w - Width of the stain, in metres.
|
|
43
|
+
* @param {number} h - Its length down the wall, in metres.
|
|
44
|
+
* @param {number} seed - Any number: its fraction picks the streaks' pattern.
|
|
45
|
+
*/
|
|
46
|
+
export function kitStain(kit, put, u, yTop, w, h, seed) {
|
|
47
|
+
wallMark(kit, put, u, w, yTop, yTop - h, 0.014, streakSeed(seed));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Soot risen up a wall from an opening: from yBot it climbs h metres.
|
|
51
|
+
* @param {object} kit - A house kit's kit.
|
|
52
|
+
* @param {Function} put - The wall's face placer.
|
|
53
|
+
* @param {number} u - Metres along the face from its middle.
|
|
54
|
+
* @param {number} yBot - Height of the opening's head, in metres.
|
|
55
|
+
* @param {number} w - Width, in metres.
|
|
56
|
+
* @param {number} h - Height it climbs, in metres.
|
|
57
|
+
* @param {number} seed - Any number: its fraction picks the pattern.
|
|
58
|
+
* @param {number} [out=0] - Extra metres off the wall (for a wall thicker than its face).
|
|
59
|
+
*/
|
|
60
|
+
export function kitSoot(kit, put, u, yBot, w, h, seed, out = 0) {
|
|
61
|
+
wallMark(kit, put, u, w, yBot, yBot + h, out + 0.016, 0.5 + streakSeed(seed));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const WEAR = 1; // the pattern the stain material draws as a blotch
|
|
65
|
+
/**
|
|
66
|
+
* Wear lying on the ground about the frame's origin, turned with it: a soft dark blotch where boots and wheels pass.
|
|
67
|
+
* @param {object} kit - A house kit's kit.
|
|
68
|
+
* @param {number} w - Metres across (x).
|
|
69
|
+
* @param {number} d - Metres deep (z).
|
|
70
|
+
* @param {number} [y=0.03] - Height over the ground, in metres.
|
|
71
|
+
*/
|
|
72
|
+
export function kitWear(kit, w, d, y = 0.03) {
|
|
73
|
+
const x = w / 2,
|
|
74
|
+
z = d / 2;
|
|
75
|
+
kitDecal(kit.stain, [-x, y, z], [x, y, z], [x, y, -z], [-x, y, -z], [0, 1, 0], WEAR);
|
|
76
|
+
}
|
|
77
|
+
const TILLED = 252 / 255; // the pattern the stain material draws as tilled earth (a colour byte, between soot's codes and wear's)
|
|
78
|
+
/**
|
|
79
|
+
* Tilled earth over a bed: furrows down its length and clods.
|
|
80
|
+
* @param {object} kit - A house kit's kit.
|
|
81
|
+
* @param {number} x - Middle of the bed in the frame, metres.
|
|
82
|
+
* @param {number} y - Its height, metres.
|
|
83
|
+
* @param {number} z - Its middle, metres.
|
|
84
|
+
* @param {number} len - Its length down x, metres.
|
|
85
|
+
* @param {number} w - Its width across z, metres.
|
|
86
|
+
*/
|
|
87
|
+
export function kitTilled(kit, x, y, z, len, w) {
|
|
88
|
+
const x0 = x - len / 2,
|
|
89
|
+
x1 = x + len / 2,
|
|
90
|
+
z0 = z - w / 2,
|
|
91
|
+
z1 = z + w / 2;
|
|
92
|
+
kitDecal(kit.stain, [x0, y, z0], [x0, y, z1], [x1, y, z1], [x1, y, z0], [0, 1, 0], TILLED);
|
|
93
|
+
}
|
|
@@ -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
|
+
}
|