roamwright 0.20.1 → 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 +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 +134 -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/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 +27 -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/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/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,69 @@
|
|
|
1
|
+
// The dead of a battlefield: a horse on its side and a soldier on the ground, as lofted bodies rather than blocks. Worker-safe.
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { dim } from '../math/color.js';
|
|
4
|
+
import { C, TRS, stick } from './primitives.js';
|
|
5
|
+
import { createSculptor } from './sculpt.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The battlefield props, bound to a world's shapes, sculptor and horse.
|
|
9
|
+
* @param {object} o
|
|
10
|
+
* @param {object} o.shapes - The unit shapes (`createUnitShapes`).
|
|
11
|
+
* @param {Function} [o.loft] - The sculptor's loft (`createSculptor`); a plain sculptor's if not given.
|
|
12
|
+
* @param {Function} [o.horse] - A still horse cast into a builder, (builder, x, y, z, yaw, colour, R, graze, lying);
|
|
13
|
+
* `propHorse` needs it.
|
|
14
|
+
* @returns {object} `propHorse(builder, x, y, z, yaw, colour, R)`, a dead horse on its side, and `propFallen(builder, x, y, z,
|
|
15
|
+
* yaw, colour, R)`, a fallen soldier, face up or down.
|
|
16
|
+
*/
|
|
17
|
+
export function createBattlefieldProps({ shapes: U, loft = createSculptor().loft, horse: stillHorse }) {
|
|
18
|
+
const _mA = new THREE.Matrix4();
|
|
19
|
+
function propHorse(into, x, y, z, yaw, col, R) {
|
|
20
|
+
stillHorse(into, x, y, z, yaw, col, R, false, true);
|
|
21
|
+
}
|
|
22
|
+
function propFallen(gb, x, y, z, yaw, col, R) {
|
|
23
|
+
const M0 = gb.M,
|
|
24
|
+
face = R() < 0.5,
|
|
25
|
+
M = new THREE.Matrix4()
|
|
26
|
+
.makeTranslation(x, y + 0.13, z)
|
|
27
|
+
.multiply(_mA.makeRotationY(yaw))
|
|
28
|
+
.multiply(_mA.makeRotationX(face ? Math.PI / 2 : -Math.PI / 2))
|
|
29
|
+
.multiply(_mA.makeTranslation(0, -0.95, 0));
|
|
30
|
+
const skin = C(0xb98e6e, 0.2, R),
|
|
31
|
+
steel = C(0x8a8d92),
|
|
32
|
+
dk = dim(col, 0.5),
|
|
33
|
+
boot = C(0x2a221c);
|
|
34
|
+
gb.M = M;
|
|
35
|
+
loft(
|
|
36
|
+
gb,
|
|
37
|
+
0,
|
|
38
|
+
0,
|
|
39
|
+
0,
|
|
40
|
+
[
|
|
41
|
+
[0.86, 0.13, 0.09, 0, 0, dk, 0],
|
|
42
|
+
[0.98, 0.17, 0.11, 0, 0, col, 0],
|
|
43
|
+
[1.2, 0.165, 0.1, 0, 0, col, 0],
|
|
44
|
+
[1.4, 0.2, 0.105, 0, 0, col, 0],
|
|
45
|
+
[1.5, 0.11, 0.08, 0, 0, col, 0],
|
|
46
|
+
[1.56, 0.055, 0.055, 0, 0, skin, 0],
|
|
47
|
+
],
|
|
48
|
+
8,
|
|
49
|
+
);
|
|
50
|
+
gb.add(U.sph, skin, TRS(0, 1.66, 0.01, 0.17, 0.22, 0.19));
|
|
51
|
+
gb.add(U.dome, steel, TRS(0, 1.66, 0, 0.2, 0.26, 0.22));
|
|
52
|
+
for (const s of [-1, 1]) {
|
|
53
|
+
const a = (R() - 0.3) * 1.6,
|
|
54
|
+
el = [s * (0.24 + Math.abs(Math.sin(a)) * 0.26), 1.42 - Math.cos(a) * 0.3, 0.02],
|
|
55
|
+
ha = [el[0] + s * R() * 0.2, el[1] - Math.cos(a * 0.6) * 0.28, 0.05];
|
|
56
|
+
stick(gb, [s * 0.2, 1.42, 0], el, 0.1, col);
|
|
57
|
+
stick(gb, el, ha, 0.085, col);
|
|
58
|
+
gb.add(U.sph, skin, TRS(ha[0], ha[1], ha[2], 0.09, 0.1, 0.07));
|
|
59
|
+
const b = (R() - 0.5) * 0.5,
|
|
60
|
+
kn = [s * 0.1 + b * 0.3, 0.5, 0.03],
|
|
61
|
+
ft = [kn[0] + b * 0.4, 0.06, 0];
|
|
62
|
+
stick(gb, [s * 0.09, 0.92, 0], kn, 0.15, dk);
|
|
63
|
+
stick(gb, kn, ft, 0.12, boot);
|
|
64
|
+
gb.add(U.sph, boot, TRS(ft[0], ft[1], ft[2] + 0.07, 0.11, 0.1, 0.24));
|
|
65
|
+
}
|
|
66
|
+
gb.M = M0;
|
|
67
|
+
}
|
|
68
|
+
return { propFallen, propHorse };
|
|
69
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// The furniture of an army's camp or a siege line besides its tents: fodder stacks, a weapon rack, a cookfire, a well and a
|
|
2
|
+
// trough, a woodpile, a watch brazier, a picketed horse and a raven. Each is built into a house kit's builders round the kit
|
|
3
|
+
// frame's origin, its front to +z. Worker-safe.
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { dim } from '../math/color.js';
|
|
6
|
+
import { TAU } from '../math/scalar.js';
|
|
7
|
+
import { pickR } from '../math/random.js';
|
|
8
|
+
import { C, TRS, stick } from './primitives.js';
|
|
9
|
+
import { HOUSE_PALETTE } from './house-kit-palette.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The camp props, bound to a world's shapes, palette, haycock and horse.
|
|
13
|
+
* @param {object} o
|
|
14
|
+
* @param {object} o.shapes - The unit shapes (`createUnitShapes`).
|
|
15
|
+
* @param {object} [o.palette] - The house palette (`hemp` for rope, `cloths` and `awnings`, sRGB hex choices); a house kit's
|
|
16
|
+
* `palette`, or the kit's default (`HOUSE_PALETTE`).
|
|
17
|
+
* @param {Function} o.haycock - The haycock (`createHaycock`), the fodder stacks' hay.
|
|
18
|
+
* @param {Function} [o.horse] - A still horse cast into a builder, (builder, x, y, z, yaw, colour, R, graze); `propHorseUp`
|
|
19
|
+
* needs it.
|
|
20
|
+
* @returns {object} Builders, each (B, R, ...) into a kit's builders: `fodderStack(B, R, far)`, `propRack`, `propCookfire`,
|
|
21
|
+
* `propDesertWell`, `propPlankTrough`, `propWoodpile(B, R, n)`, `propBrazier`; and, into one builder at a point and bearing,
|
|
22
|
+
* `propHorseUp(builder, x, y, z, yaw, colour, R, graze)` and `propRaven(builder, x, y, z, yaw, scale)`.
|
|
23
|
+
*/
|
|
24
|
+
export function createCampProps({ shapes: U, palette = HOUSE_PALETTE, haycock, horse: stillHorse }) {
|
|
25
|
+
const { hemp: HEMP } = palette;
|
|
26
|
+
const _mA = new THREE.Matrix4();
|
|
27
|
+
|
|
28
|
+
// The main rick and the loose forkful pulled from its foot share the same hay as the mown fields.
|
|
29
|
+
function fodderStack(B, R, far = false) {
|
|
30
|
+
const straw = C(0xb49e65, 0.07, R),
|
|
31
|
+
gb = B.cloth,
|
|
32
|
+
frame = gb.M;
|
|
33
|
+
gb.M = _mA.multiplyMatrices(frame, TRS(0, -0.02, 0, 1.56, 1 + R() * 0.24, 1.37, R() * TAU));
|
|
34
|
+
haycock(gb, far, straw);
|
|
35
|
+
gb.M = _mA.multiplyMatrices(frame, TRS(1.28, -0.025, 0.76, 0.95, 0.31, 0.76, R() * TAU));
|
|
36
|
+
haycock(gb, far, dim(straw, 0.89));
|
|
37
|
+
gb.M = frame;
|
|
38
|
+
}
|
|
39
|
+
function propRack(B, R) {
|
|
40
|
+
// spears stacked on a rack, shields leaning at its foot
|
|
41
|
+
const w = C(0x4a3a2a),
|
|
42
|
+
st = [0.5, 0.52, 0.56];
|
|
43
|
+
for (const sx of [-1, 1]) {
|
|
44
|
+
stick(B.wood, [sx * 0.9, 0, -0.35], [sx * 0.9, 1.5, 0], 0.035, w);
|
|
45
|
+
stick(B.wood, [sx * 0.9, 0, 0.35], [sx * 0.9, 1.5, 0], 0.035, w);
|
|
46
|
+
}
|
|
47
|
+
B.wood.box(0, 1.45, 0, 2.0, 0.06, 0.06, w);
|
|
48
|
+
for (let q = 0; q < 6; q++) {
|
|
49
|
+
const x = -0.75 + q * 0.3;
|
|
50
|
+
stick(B.wood, [x, 0, 0.5], [x, 2.3, -0.12], 0.02, C(0x6a5540, 0.15, R));
|
|
51
|
+
B.cloth.add(U.cone6, st, TRS(x, 2.3, -0.12, 0.06, 0.24, 0.06, 0, -0.26));
|
|
52
|
+
}
|
|
53
|
+
for (let q = 0; q < 2; q++)
|
|
54
|
+
B.cloth.add(U.cyl16, C(q ? 0x6a2a26 : 0x4a4640), TRS(-0.4 + q * 0.9, 0.42, -0.5, 0.8, 0.06, 0.8, 0, Math.PI / 2 - 0.35));
|
|
55
|
+
}
|
|
56
|
+
function propCookfire(B, R) {
|
|
57
|
+
// an iron pot hung from a tripod, logs to sit on
|
|
58
|
+
const w = C(0x3a2e22);
|
|
59
|
+
for (let k = 0; k < 3; k++) stick(B.wood, [Math.cos(k * 2.094) * 0.95, 0, Math.sin(k * 2.094) * 0.95], [0, 1.9, 0], 0.03, w);
|
|
60
|
+
stick(B.cloth, [0, 1.85, 0], [0, 0.95, 0], 0.012, [0.02, 0.02, 0.02]);
|
|
61
|
+
B.cloth.add(U.sph, [0.025, 0.024, 0.023], TRS(0, 0.75, 0, 0.5, 0.42, 0.5));
|
|
62
|
+
for (let k = 0; k < 3; k++) {
|
|
63
|
+
const a = k * 2.1 + 0.6;
|
|
64
|
+
B.wood.add(U.cyl, C(0x5a4632, 0.15, R), TRS(Math.cos(a) * 1.9, 0.2, Math.sin(a) * 1.9, 0.38, 1.3, 0.38, -a, 0, Math.PI / 2));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function propDesertWell(B, R) {
|
|
69
|
+
// a camp's well: a curb of rough fieldstones laid dry in two courses round a dark shaft, two forked posts carrying a beam with a
|
|
70
|
+
// wooden pulley, the rope down it, a leather bucket left on the curb, and the trodden, splashed ground round it
|
|
71
|
+
const st = C(0x9a8a70, 0.06, R),
|
|
72
|
+
tim = C(0x4a3826, 0.1, R);
|
|
73
|
+
for (let course = 0; course < 2; course++)
|
|
74
|
+
for (let k = 0; k < 13; k++) {
|
|
75
|
+
const a = ((k + course * 0.5) / 13) * Math.PI * 2 + (R() - 0.5) * 0.08,
|
|
76
|
+
r = 1.05 + (R() - 0.5) * 0.06;
|
|
77
|
+
B.stone.add(
|
|
78
|
+
U.box,
|
|
79
|
+
dim(st, 0.85 + R() * 0.3),
|
|
80
|
+
TRS(Math.cos(a) * r, course * 0.34, Math.sin(a) * r, 0.5 + R() * 0.12, 0.36, 0.42, -a, (R() - 0.5) * 0.1),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
B.cloth.add(U.cyl16, [0.008, 0.009, 0.01], TRS(0, 0.3, 0, 1.7, 0.06, 1.7)); // the shaft, dark
|
|
84
|
+
B.stone.add(U.cyl16, [0.11, 0.1, 0.085], TRS(0, -0.02, 0, 4.6, 0.04, 4.2)); // the wet, trodden ground round the curb
|
|
85
|
+
for (const sx of [-1, 1]) {
|
|
86
|
+
stick(B.wood, [sx * 1.45, -0.3, 0], [sx * 1.4, 2.25, 0], 0.075, tim); // a forked post
|
|
87
|
+
stick(B.wood, [sx * 1.4, 2.0, 0], [sx * 1.6, 2.4, 0.04], 0.035, tim);
|
|
88
|
+
}
|
|
89
|
+
stick(B.wood, [-1.6, 2.28, 0], [1.6, 2.28, 0], 0.06, tim); // the beam
|
|
90
|
+
B.wood.add(U.cyl, dim(tim, 0.8), TRS(0.2, 2.18, -0.09, 0.32, 0.06, 0.32, 0, Math.PI / 2)); // the pulley wheel
|
|
91
|
+
stick(B.cloth, [0.2, 2.06, 0], [0.2, 0.3, 0], 0.012, HEMP); // the rope into the shaft
|
|
92
|
+
stick(B.cloth, [0.2, 2.06, 0], [1.5, 0.4, 0.7], 0.012, HEMP); // and its end to the bucket
|
|
93
|
+
B.cloth.add(U.taper, C(0x5a3a24, 0.1, R), TRS(1.5, 0.38, 0.7, 0.42, 0.38, 0.42, 0, Math.PI)); // the bucket, wide mouth up
|
|
94
|
+
B.cloth.add(U.cyl16, [0.03, 0.035, 0.04], TRS(1.5, 0.34, 0.7, 0.36, 0.01, 0.36));
|
|
95
|
+
}
|
|
96
|
+
function propPlankTrough(B, R) {
|
|
97
|
+
// a plank trough on two stones, its water dark in it, and the wet ground before it where the beasts stand; front is +z
|
|
98
|
+
const wood = C(0x6a5034, 0.1, R);
|
|
99
|
+
B.wood.box(0, 0.12, 0, 2.4, 0.06, 0.56, dim(wood, 0.85));
|
|
100
|
+
for (const sz of [-1, 1]) B.wood.box(0, 0.12, sz * 0.26, 2.4, 0.34, 0.05, wood, 0, sz * 0.08);
|
|
101
|
+
for (const sx of [-1, 1]) B.wood.box(sx * 1.18, 0.12, 0, 0.05, 0.34, 0.5, dim(wood, 0.9));
|
|
102
|
+
B.cloth.box(0, 0.38, 0, 2.3, 0.02, 0.44, [0.04, 0.05, 0.055]); // the water, nearly to the brim
|
|
103
|
+
for (const sx of [-1, 1]) B.stone.add(U.rock, C(0x8a7a62, 0.1, R), TRS(sx * 0.95, -0.08, 0, 0.45, 0.28, 0.6, R() * 3));
|
|
104
|
+
B.stone.add(U.cyl16, [0.1, 0.09, 0.075], TRS(0, -0.02, 0.7, 3.2, 0.03, 1.2));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function propWoodpile(B, R, n = 9) {
|
|
108
|
+
// split cordwood stacked between stakes, a chopping block and its axe
|
|
109
|
+
const wd = [0x6a5540, 0x5a4632, 0x77614a];
|
|
110
|
+
for (let j = 0; j < 5; j++)
|
|
111
|
+
for (let i = 0; i < n - (j > 2 ? j - 2 : 0); i++) {
|
|
112
|
+
const c = C(pickR(R, wd), 0.18, R);
|
|
113
|
+
B.wood.add(
|
|
114
|
+
U.cyl6,
|
|
115
|
+
c,
|
|
116
|
+
TRS(
|
|
117
|
+
(i - n / 2 + 0.5 + (j % 2) * 0.5) * 0.3,
|
|
118
|
+
0.14 + j * 0.25,
|
|
119
|
+
-0.55 + (R() - 0.5) * 0.08,
|
|
120
|
+
0.27 + R() * 0.05,
|
|
121
|
+
1.1,
|
|
122
|
+
0.26,
|
|
123
|
+
0,
|
|
124
|
+
Math.PI / 2,
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
for (const sx of [-1, 1]) B.wood.box(sx * (n * 0.15 + 0.12), -0.2, 0, 0.08, 1.6, 0.08, C(0x4a3a2a));
|
|
129
|
+
B.wood.add(U.cyl, C(0x5a4632), TRS(n * 0.15 + 1.2, -0.1, 0.5, 0.6, 0.6, 0.6));
|
|
130
|
+
stick(B.wood, [n * 0.15 + 1.2, 0.5, 0.5], [n * 0.15 + 1.75, 0.95, 0.42], 0.035, C(0x6a5540), U.box);
|
|
131
|
+
B.cloth.box(n * 0.15 + 1.2, 0.5, 0.5, 0.06, 0.2, 0.26, [0.3, 0.31, 0.33], 0.2);
|
|
132
|
+
for (let q = 0; q < 5; q++)
|
|
133
|
+
B.wood.add(
|
|
134
|
+
U.cyl6,
|
|
135
|
+
C(pickR(R, wd), 0.2, R),
|
|
136
|
+
TRS(n * 0.15 + 0.6 + R() * 1.4, 0.02, 0.9 + R() * 0.8, 0.22, 0.5, 0.2, R() * 6, Math.PI / 2),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
function propBrazier(B, R) {
|
|
140
|
+
// a watch brazier: an iron basket on three legs, dung coals banked in it
|
|
141
|
+
const iron = [0.03, 0.03, 0.032];
|
|
142
|
+
for (let k = 0; k < 3; k++)
|
|
143
|
+
stick(
|
|
144
|
+
B.cloth,
|
|
145
|
+
[Math.cos(k * 2.094) * 0.42, 0, Math.sin(k * 2.094) * 0.42],
|
|
146
|
+
[Math.cos(k * 2.094) * 0.22, 0.8, Math.sin(k * 2.094) * 0.22],
|
|
147
|
+
0.035,
|
|
148
|
+
iron,
|
|
149
|
+
U.box,
|
|
150
|
+
);
|
|
151
|
+
B.cloth.add(U.cyl6, iron, TRS(0, 0.74, 0, 0.62, 0.3, 0.62));
|
|
152
|
+
B.cloth.add(U.cyl6, iron, TRS(0, 0.62, 0, 0.4, 0.14, 0.4));
|
|
153
|
+
B.cloth.add(U.sph, [0.2, 0.05, 0.02], TRS(0, 0.96, 0, 0.5, 0.22, 0.5));
|
|
154
|
+
B.cloth.add(U.sph, [0.05, 0.04, 0.035], TRS(0.08, 1.0, 0.05, 0.3, 0.16, 0.34));
|
|
155
|
+
}
|
|
156
|
+
// A horse standing at a picket line, head up or down at its fodder: the horse a rider sits, cast where it stands.
|
|
157
|
+
function propHorseUp(into, x, y, z, yaw, col, R, graze) {
|
|
158
|
+
stillHorse(into, x, y, z, yaw, col, R, graze);
|
|
159
|
+
}
|
|
160
|
+
function propRaven(gb, x, y, z, yaw, s) {
|
|
161
|
+
// a raven on the ground or a perch
|
|
162
|
+
const k = [0.016, 0.016, 0.02],
|
|
163
|
+
sn = Math.sin(yaw),
|
|
164
|
+
cs = Math.cos(yaw);
|
|
165
|
+
gb.add(U.sph, k, TRS(x, y + 0.08 * s, z, 0.3 * s, 0.32 * s, 0.6 * s, yaw, -0.5));
|
|
166
|
+
gb.add(U.sph, k, TRS(x + sn * 0.25 * s, y + 0.4 * s, z + cs * 0.25 * s, 0.2 * s, 0.2 * s, 0.22 * s));
|
|
167
|
+
gb.add(
|
|
168
|
+
U.cone6,
|
|
169
|
+
[0.05, 0.05, 0.05],
|
|
170
|
+
TRS(x + sn * 0.33 * s, y + 0.49 * s, z + cs * 0.33 * s, 0.07 * s, 0.24 * s, 0.07 * s, yaw, Math.PI / 2 + 0.25),
|
|
171
|
+
);
|
|
172
|
+
gb.box(x - sn * 0.36 * s, y + 0.02 * s, z - cs * 0.36 * s, 0.17 * s, 0.03 * s, 0.4 * s, k, yaw, 0.5);
|
|
173
|
+
}
|
|
174
|
+
return { fodderStack, propBrazier, propCookfire, propDesertWell, propHorseUp, propPlankTrough, propRack, propRaven, propWoodpile };
|
|
175
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// A door's leaf of planks bound with black iron, hung in a doorway a world builds. Worker-safe.
|
|
2
|
+
import { dim } from '../math/color.js';
|
|
3
|
+
import { C, TRS } from './primitives.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The door props, bound to a world's shapes and hash.
|
|
7
|
+
* @param {object} o
|
|
8
|
+
* @param {object} o.shapes - The unit shapes (`createUnitShapes`).
|
|
9
|
+
* @param {Function} o.hash - The world's hash (`createHash`), which shades each plank.
|
|
10
|
+
* @returns {{strappedDoor: Function}} `strappedDoor(builder, R, x, z, width, height)`: the leaf into one builder, its hinge at
|
|
11
|
+
* (x, z) of the builder's frame (the west jamb), metres.
|
|
12
|
+
*/
|
|
13
|
+
export function createDoorProps({ shapes: U, hash: hash2 }) {
|
|
14
|
+
// The door's leaf into builder b, its hinge at (x, z) of b's frame (the west jamb): planks bound with black iron.
|
|
15
|
+
function strappedDoor(b, rng, x, z, w, h) {
|
|
16
|
+
const oak = C(0x2e241c, 0.06, rng),
|
|
17
|
+
iron = [0.03, 0.03, 0.034];
|
|
18
|
+
for (let p = 0; p < 5; p++) b.box(x + (p + 0.5) * (w / 5), 0, z, w / 5 - 0.012, h, 0.12, dim(oak, 0.8 + 0.3 * hash2(p, 5, 974)));
|
|
19
|
+
for (const y of [0.35, h / 2, h - 0.35]) b.box(x + w / 2, y, z + 0.07, w - 0.06, 0.12, 0.03, iron);
|
|
20
|
+
const latchX = x + w - 0.22,
|
|
21
|
+
wornIron = [0.16, 0.15, 0.13];
|
|
22
|
+
b.add(U.cyl6, iron, TRS(latchX, 1.15, z + 0.1, 0.16, 0.05, 0.16, 0, Math.PI / 2));
|
|
23
|
+
b.box(latchX - 0.07, 1.15, z + 0.15, 0.21, 0.035, 0.055, wornIron);
|
|
24
|
+
}
|
|
25
|
+
return { strappedDoor };
|
|
26
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// The furniture of a quay: sheer-legs with their windlass, and nets hung to dry on a rack. Each is built into a house kit's
|
|
2
|
+
// builders round the kit frame's origin, the water to +z. Worker-safe.
|
|
3
|
+
import { dim } from '../math/color.js';
|
|
4
|
+
import { pickR } from '../math/random.js';
|
|
5
|
+
import { C, TRS, stick } from './primitives.js';
|
|
6
|
+
import { HOUSE_PALETTE } from './house-kit-palette.js';
|
|
7
|
+
import { sackLying } from './prop-sacks.js';
|
|
8
|
+
import { sampleSurface as surf } from './sampled-surface.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The harbour props, bound to a world's shapes and palette.
|
|
12
|
+
* @param {object} o
|
|
13
|
+
* @param {object} o.shapes - The unit shapes (`createUnitShapes`).
|
|
14
|
+
* @param {object} [o.palette] - The house palette (`hemp` for rope, `cloths` and `awnings`, sRGB hex choices); a house kit's
|
|
15
|
+
* `palette`, or the kit's default (`HOUSE_PALETTE`).
|
|
16
|
+
* @returns {object} `propCrane(B, R, quarry)` (a quarry's lifts stone, not sacks) and `propNetRack(B, R)`.
|
|
17
|
+
*/
|
|
18
|
+
export function createHarbourProps({ shapes: U, palette = HOUSE_PALETTE }) {
|
|
19
|
+
const { hemp: HEMP } = palette;
|
|
20
|
+
// Sheer-legs on the quay, +z the water: two tapering poles of weathered timber standing in stone shoes, leaning out over the
|
|
21
|
+
// edge and lashed where they cross; two guys back to rings in the paving; a block hung from the lashing, its fall down to the
|
|
22
|
+
// hook and a sling of sacks, and the hauling part back to a windlass on its trestles, worked by handspikes.
|
|
23
|
+
const CRANE = { head: [0, 6.9, 2.5], feet: 1.5, guyBack: 6.2, guySpread: 2.4, load: 2.1 }; // metres
|
|
24
|
+
function propCrane(B, R, quarry = false) {
|
|
25
|
+
const tim = C(0x7a6a56, 0.1, R),
|
|
26
|
+
iron = [0.05, 0.05, 0.055],
|
|
27
|
+
[hx, hy, hz] = CRANE.head;
|
|
28
|
+
for (const sx of [-1, 1]) {
|
|
29
|
+
stick(B.wood, [sx * CRANE.feet, 0.1, 0], [sx * 0.12, hy + 0.35, hz + 0.05], 0.32, dim(tim, 0.95 + sx * 0.05), U.taper);
|
|
30
|
+
B.stone.box(sx * CRANE.feet, -0.1, 0, 0.7, 0.34, 0.7, C(0x6a645a, 0.05, R)); // its shoe
|
|
31
|
+
B.trim.add(U.cyl6, iron, TRS(sx * CRANE.feet, 0.18, 0, 0.36, 0.08, 0.36)); // the iron band at its foot
|
|
32
|
+
const ring = [sx * CRANE.guySpread, 0.02, -CRANE.guyBack];
|
|
33
|
+
stick(B.trim, [hx, hy + 0.15, hz - 0.1], ring, 0.03, HEMP, U.box); // a guy
|
|
34
|
+
B.trim.add(U.cyl6, iron, TRS(ring[0], -0.02, ring[2], 0.24, 0.06, 0.24));
|
|
35
|
+
}
|
|
36
|
+
for (let k = 0; k < 5; k++) B.trim.add(U.cyl6, HEMP, TRS(hx, hy - 0.05 + k * 0.07, hz, 0.42, 0.06, 0.42, 0, 0.35, 0)); // the lashing
|
|
37
|
+
// the block: its wooden shell in an iron strop, the sheave showing at its sides
|
|
38
|
+
B.trim.box(hx, hy - 0.55, hz, 0.05, 0.5, 0.05, iron);
|
|
39
|
+
B.wood.box(hx, hy - 1.05, hz, 0.2, 0.5, 0.32, dim(tim, 0.8));
|
|
40
|
+
B.trim.add(U.cyl16, dim(tim, 0.6), TRS(hx - 0.11, hy - 0.8, hz, 0.26, 0.02, 0.26, 0, 0, Math.PI / 2));
|
|
41
|
+
// the fall to the hook, the sling and its two sacks
|
|
42
|
+
const hook = [hx, CRANE.load + 1.0, hz];
|
|
43
|
+
stick(B.trim, [hx, hy - 1.05, hz + 0.08], hook, 0.03, HEMP, U.box);
|
|
44
|
+
B.trim.add(U.cone6, iron, TRS(hook[0], hook[1] - 0.22, hook[2], 0.12, 0.22, 0.12, 0, Math.PI, 0));
|
|
45
|
+
B.trim.add(U.cyl6, iron, TRS(hook[0], hook[1] - 0.3, hook[2], 0.14, 0.04, 0.14, 0, Math.PI / 2, 0));
|
|
46
|
+
for (const sx of [-0.32, 0.32]) {
|
|
47
|
+
stick(B.trim, [hook[0], hook[1] - 0.28, hook[2]], [sx, CRANE.load + (quarry ? 0.5 : 0.3), hz + 0.05], 0.025, HEMP, U.box);
|
|
48
|
+
stick(B.trim, [sx, CRANE.load + (quarry ? 0.5 : 0.3), hz + 0.05], [sx, CRANE.load - 0.02, hz + 0.05], 0.025, HEMP, U.box);
|
|
49
|
+
}
|
|
50
|
+
if (quarry) B.stone.box(hx, CRANE.load - 0.02, hz, 0.76, 0.52, 0.68, C(0xa49a84, 0.07, R));
|
|
51
|
+
else
|
|
52
|
+
for (let k = 0; k < 2; k++)
|
|
53
|
+
sackLying(
|
|
54
|
+
B.cloth,
|
|
55
|
+
C(0x8a7a5a, 0.12, R),
|
|
56
|
+
0,
|
|
57
|
+
CRANE.load + k * 0.3,
|
|
58
|
+
hz + (k - 0.5) * 0.08,
|
|
59
|
+
Math.PI / 2 + (k - 0.5) * 0.2,
|
|
60
|
+
0.85,
|
|
61
|
+
0.48,
|
|
62
|
+
0.32,
|
|
63
|
+
);
|
|
64
|
+
// the hauling part from the block back to the windlass: a drum on two trestles, the rope wound on it, handspikes in its head
|
|
65
|
+
const wz = -1.6,
|
|
66
|
+
wy = 1.0;
|
|
67
|
+
stick(B.trim, [hx, hy - 0.85, hz - 0.1], [-0.2, wy + 0.18, wz], 0.03, HEMP, U.box);
|
|
68
|
+
for (const sx of [-0.75, 0.75]) {
|
|
69
|
+
stick(B.wood, [sx, 0, wz - 0.45], [sx, wy + 0.05, wz], 0.12, tim, U.box);
|
|
70
|
+
stick(B.wood, [sx, 0, wz + 0.45], [sx, wy + 0.05, wz], 0.12, tim, U.box);
|
|
71
|
+
B.wood.box(sx, 0, wz, 0.12, 0.1, 1.0, dim(tim, 0.85));
|
|
72
|
+
}
|
|
73
|
+
B.wood.add(U.cyl, dim(tim, 1.1), TRS(-0.85, wy, wz, 0.32, 1.7, 0.32, 0, 0, -Math.PI / 2));
|
|
74
|
+
const coil = dim(HEMP, 0.72); // rope wound on, darkened by handling and tar
|
|
75
|
+
B.cloth.add(U.cyl16, coil, TRS(-0.45, wy, wz, 0.4, 0.75, 0.4, 0, 0, -Math.PI / 2));
|
|
76
|
+
for (let k = 0; k < 6; k++)
|
|
77
|
+
B.cloth.add(U.cyl16, dim(coil, 0.85 + (k % 2) * 0.2), TRS(-0.42 + k * 0.13, wy, wz, 0.43, 0.06, 0.43, 0, 0, -Math.PI / 2)); // its turns
|
|
78
|
+
for (const x of [-0.51, 0.3]) B.wood.add(U.cyl16, dim(tim, 0.9), TRS(x, wy, wz, 0.56, 0.06, 0.56, 0, 0, -Math.PI / 2)); // the drum's flanges
|
|
79
|
+
for (let k = 0; k < 4; k++) {
|
|
80
|
+
const a = k * (Math.PI / 2) + 0.3;
|
|
81
|
+
stick(B.wood, [0.82, wy, wz], [0.82, wy + Math.sin(a) * 0.75, wz + Math.cos(a) * 0.75], 0.05, dim(tim, 1.15));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function propNetRack(B, R) {
|
|
85
|
+
// nets hung to dry over a pole between two posts, cork floats along their head-ropes
|
|
86
|
+
const tim = C(0x4a3a2a, 0.15, R),
|
|
87
|
+
net = C(pickR(R, [0x4a4436, 0x3e3a30, 0x55503e]), 0.1, R);
|
|
88
|
+
for (const sx of [-1.6, 1.6]) B.wood.box(sx, -0.2, 0, 0.14, 2.2, 0.14, tim);
|
|
89
|
+
B.wood.add(U.cyl6, tim, TRS(-1.75, 1.95, 0, 0.1, 3.5, 0.1, 0, 0, -Math.PI / 2));
|
|
90
|
+
for (const sg of [-1, 1])
|
|
91
|
+
surf(
|
|
92
|
+
B.cloth,
|
|
93
|
+
6,
|
|
94
|
+
3,
|
|
95
|
+
(u, v) => [(u - 0.5) * 3.1, 1.95 - v * (1.6 + 0.2 * Math.sin(u * 9)), sg * (0.04 + v * 0.35) + Math.sin(u * 7 + v * 3) * 0.06],
|
|
96
|
+
net,
|
|
97
|
+
{ flip: sg > 0, back: dim(net, 0.7) },
|
|
98
|
+
);
|
|
99
|
+
for (let k = 0; k < 7; k++) B.cloth.add(U.sph, C(0xb09a6a, 0.1, R), TRS(-1.35 + k * 0.45, 1.92, 0.08, 0.12, 0.09, 0.12));
|
|
100
|
+
B.cloth.add(U.cyl16, net, TRS(1.2, 0, 1.0, 1.4, 0.35, 1.2, R() * 3));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// A boat of the harbours and shores from the ship kit, `len` metres long, of the kind a harbour has at that length (boatSpec);
|
|
104
|
+
return { propCrane, propNetRack };
|
|
105
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// A raked heap of hay. Its cut grass hangs in overlapping forkfuls around a settling core, with sun-bleached tips on the skirt
|
|
2
|
+
// and darker stems under each overhang. Worker-safe.
|
|
3
|
+
import { TAU } from '../math/scalar.js';
|
|
4
|
+
import { dim } from '../math/color.js';
|
|
5
|
+
import { mulberry32 } from '../math/random.js';
|
|
6
|
+
import { C } from './primitives.js';
|
|
7
|
+
import { createSculptor } from './sculpt.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A haycock builder bound to a world's sculptor.
|
|
11
|
+
* @param {object} [o]
|
|
12
|
+
* @param {Function} [o.loft] - The sculptor's loft (`createSculptor`); a plain sculptor's if not given.
|
|
13
|
+
* @returns {{haycock: Function}} `haycock(builder, far, hay)`: a heap about 1.24 m high and 1.7 m across at the builder's origin,
|
|
14
|
+
* `far` its coarse form, `hay` its colour, linear [r, g, b]. It draws from its own seeded random, so every heap is the same.
|
|
15
|
+
*/
|
|
16
|
+
export function createHaycock({ loft = createSculptor().loft } = {}) {
|
|
17
|
+
const radiusAt = v => 0.87 * (1 - v ** 1.7) ** 0.76;
|
|
18
|
+
const edge = (a, v) => 1 + 0.065 * Math.sin(3 * a + 2 * v) + 0.052 * Math.cos(5 * a - v) + 0.035 * Math.sin(9 * a + 3 * v);
|
|
19
|
+
const point = (v, a, out) => {
|
|
20
|
+
const r = radiusAt(v) * edge(a, v) + out;
|
|
21
|
+
return [0.15 * v + r * Math.cos(a), 1.24 * v, r * Math.sin(a)];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function haycock(b, far, hay = C(0xaf985e)) {
|
|
25
|
+
const R = mulberry32(3591);
|
|
26
|
+
const rings = [-0.045, 0.05, 0.22, 0.45, 0.68, 0.86, 0.97, 1].map(v => {
|
|
27
|
+
const r = radiusAt(Math.max(0, v));
|
|
28
|
+
return [1.24 * v, r, r, 0.15 * v, 0, dim(hay, 0.66 + 0.42 * v)];
|
|
29
|
+
});
|
|
30
|
+
loft(b, 0, 0, 0, rings, far ? 10 : 28, {
|
|
31
|
+
fold: (v, a) => edge(a, v),
|
|
32
|
+
tint: (p, a) => 0.81 + 0.16 * Math.sin(a * 7 + p[1] * 2),
|
|
33
|
+
});
|
|
34
|
+
// Tapered strips follow the slope. Neighbouring stems fan apart at their loose ends.
|
|
35
|
+
const rows = far ? 3 : 8,
|
|
36
|
+
clumps = far ? 12 : 38,
|
|
37
|
+
stems = far ? 1 : 5;
|
|
38
|
+
for (let row = 0; row < rows; row++)
|
|
39
|
+
for (let j = 0; j < clumps; j++) {
|
|
40
|
+
const a = (TAU * (j + R() * 0.55 + (row % 2) * 0.5)) / clumps,
|
|
41
|
+
top = Math.min(0.99, (row + 0.75 + R() * 0.3) / rows),
|
|
42
|
+
tone = C(R() < 0.35 ? 0xcab87c : 0xbba164, 0.21, R),
|
|
43
|
+
length = (0.15 + 0.14 * R()) * (far ? 1.5 : 1),
|
|
44
|
+
sweep = (R() - 0.5) * 0.35;
|
|
45
|
+
for (let k = 0; k < stems; k++) {
|
|
46
|
+
const az = a + (R() - 0.5) * 0.13,
|
|
47
|
+
v = Math.max(0.002, top - length * (0.7 + 0.45 * R())),
|
|
48
|
+
side = (far ? 0.052 : 0.019) / (radiusAt(top) + 0.15),
|
|
49
|
+
root = point(top, az, 0.006),
|
|
50
|
+
mid = (top + v) * 0.5,
|
|
51
|
+
l = point(mid, az + sweep * 0.5 - side, 0.045),
|
|
52
|
+
r = point(mid, az + sweep * 0.5 + side, 0.045),
|
|
53
|
+
tip = point(v, az + sweep + (R() - 0.5) * 0.11, v < 0.02 ? 0.05 + R() * 0.23 : 0.08);
|
|
54
|
+
const normal = [Math.cos(az) * 0.8, 0.6, Math.sin(az) * 0.8];
|
|
55
|
+
for (const vertex of [root, r, l, r, tip, l]) b.raw(...vertex, ...normal, ...tone);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { haycock };
|
|
60
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// A sack of grain: the one shape every sack and bale is drawn from. Standing, it is a metre tall (its tuft included) on a flat
|
|
2
|
+
// bottom, a metre across and 0.72 deep (sized where it is put): a boxy body that bellies out low where the grain settles,
|
|
3
|
+
// shoulders drawn in by the folds of the cloth to a neck tied off with a cord, and the gathered mouth flaring above the tie.
|
|
4
|
+
// Lying, it is the same turned on its side and pressed flatter by what lies on it. Worker-safe.
|
|
5
|
+
import * as THREE from 'three';
|
|
6
|
+
import { TRS } from './primitives.js';
|
|
7
|
+
|
|
8
|
+
const AROUND = 10, // points round each ring
|
|
9
|
+
DEPTH = 0.72, // its depth as a share of its width
|
|
10
|
+
// the profile up its height: [height, half width, squareness of the cross-section (2 round, more boxier), folds]
|
|
11
|
+
PROFILE = [
|
|
12
|
+
[0, 0.36, 3, 0],
|
|
13
|
+
[0.05, 0.47, 3, 0],
|
|
14
|
+
[0.3, 0.5, 3, 0],
|
|
15
|
+
[0.6, 0.47, 2.8, 0.01],
|
|
16
|
+
[0.76, 0.38, 2.4, 0.05],
|
|
17
|
+
[0.86, 0.17, 2, 0.09],
|
|
18
|
+
[0.9, 0.065, 2, 0.02],
|
|
19
|
+
[0.94, 0.06, 2, 0],
|
|
20
|
+
[1, 0.12, 2, 0.12],
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
function sackGeometry() {
|
|
24
|
+
const pos = [],
|
|
25
|
+
idx = [],
|
|
26
|
+
rings = PROFILE.length;
|
|
27
|
+
for (const [y, r, sq, folds] of PROFILE)
|
|
28
|
+
for (let i = 0; i < AROUND; i++) {
|
|
29
|
+
const a = (i / AROUND) * Math.PI * 2,
|
|
30
|
+
c = Math.cos(a),
|
|
31
|
+
s = Math.sin(a),
|
|
32
|
+
f = 1 + folds * Math.sin(a * 5 + y * 9), // the cloth gathered in folds toward the neck
|
|
33
|
+
k = 2 / sq;
|
|
34
|
+
pos.push(r * f * Math.sign(c) * Math.abs(c) ** k, y, r * f * DEPTH * Math.sign(s) * Math.abs(s) ** k);
|
|
35
|
+
}
|
|
36
|
+
for (let j = 0; j < rings - 1; j++)
|
|
37
|
+
for (let i = 0; i < AROUND; i++) {
|
|
38
|
+
const a = j * AROUND + i,
|
|
39
|
+
b = j * AROUND + ((i + 1) % AROUND),
|
|
40
|
+
c = a + AROUND,
|
|
41
|
+
d = b + AROUND;
|
|
42
|
+
idx.push(a, c, b, b, c, d);
|
|
43
|
+
}
|
|
44
|
+
const bottom = pos.length / 3,
|
|
45
|
+
top = bottom + 1;
|
|
46
|
+
pos.push(0, 0, 0, 0, PROFILE[rings - 1][0] - 0.03, 0); // the middles of the flat bottom and of the mouth
|
|
47
|
+
for (let i = 0; i < AROUND; i++) {
|
|
48
|
+
idx.push(bottom, i, (i + 1) % AROUND);
|
|
49
|
+
idx.push(top, (rings - 1) * AROUND + ((i + 1) % AROUND), (rings - 1) * AROUND + i);
|
|
50
|
+
}
|
|
51
|
+
const geo = new THREE.BufferGeometry();
|
|
52
|
+
geo.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));
|
|
53
|
+
geo.setIndex(idx);
|
|
54
|
+
geo.computeVertexNormals();
|
|
55
|
+
return geo;
|
|
56
|
+
}
|
|
57
|
+
const LYING_HIGH = 0.78, // the lying shape's height, pressed down from its metre of width
|
|
58
|
+
BREADTH = DEPTH, // the lying shape's breadth across, the standing one's depth
|
|
59
|
+
SACK = sackGeometry(), // standing on its bottom
|
|
60
|
+
SACK_LYING = SACK.clone()
|
|
61
|
+
.rotateZ(-Math.PI / 2)
|
|
62
|
+
.scale(1, LYING_HIGH, 1)
|
|
63
|
+
.translate(-0.5, LYING_HIGH / 2, 0); // on its side, its middle at x 0, the mouth to +x
|
|
64
|
+
|
|
65
|
+
// A sack standing at (x, y, z) in builder gb, turned by ry: `tall` metres high and `wide` across.
|
|
66
|
+
function sackStanding(gb, col, x, y, z, ry, tall, wide) {
|
|
67
|
+
gb.add(SACK, col, TRS(x, y, z, wide, tall, wide, ry));
|
|
68
|
+
}
|
|
69
|
+
// A sack lying at (x, y, z), turned by ry: `long` metres from its bottom to its mouth (along x), `wide` across and `high`.
|
|
70
|
+
function sackLying(gb, col, x, y, z, ry, long, wide, high) {
|
|
71
|
+
gb.add(SACK_LYING, col, TRS(x, y, z, long, high / LYING_HIGH, wide / BREADTH, ry));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { sackLying, sackStanding };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// A gathered sheaf of cut grain, lofted from its cut ends to its seed heads and pinched under its binding, its straws drawn
|
|
2
|
+
// one by one near the viewer. Worker-safe.
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { TAU } from '../math/scalar.js';
|
|
5
|
+
import { dim } from '../math/color.js';
|
|
6
|
+
import { C, stick } from './primitives.js';
|
|
7
|
+
import { createSculptor } from './sculpt.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A sheaf builder bound to a world's noise and sculptor.
|
|
11
|
+
* @param {object} o
|
|
12
|
+
* @param {Function} o.vnoise - Seeded value noise (`createNoise`), which ruffles the straws.
|
|
13
|
+
* @param {Function} [o.loft] - The sculptor's loft (`createSculptor`); a plain sculptor's if not given.
|
|
14
|
+
* @returns {{sheaf: Function}} `sheaf(builder, random, stalk, ears, twist, grain, far)`: a sheaf at the builder's origin, its
|
|
15
|
+
* stalk and ear colours linear [r, g, b], `twist` its turn in radians, `grain` how full its heads are (0..1), `far` the
|
|
16
|
+
* coarse form with no loose straws.
|
|
17
|
+
*/
|
|
18
|
+
export function createSheaf({ vnoise, loft = createSculptor().loft }) {
|
|
19
|
+
const STRAW = new THREE.CylinderGeometry(0.5, 0.5, 1, 3, 1, true).translate(0, 0.5, 0); // a single stalk: three sides, no ends
|
|
20
|
+
const ring = (y, rx, rz, cz, col) => [y, rx, rz, 0, cz, col];
|
|
21
|
+
|
|
22
|
+
// A gathered sheaf, from the cut ends at y=0 to the seed heads, pinched under its binding.
|
|
23
|
+
function sheaf(b, rng, stalk, ears, twist, grain, far) {
|
|
24
|
+
const around = far ? 4 : 24,
|
|
25
|
+
twine = dim(stalk, 0.26);
|
|
26
|
+
loft(
|
|
27
|
+
b,
|
|
28
|
+
0,
|
|
29
|
+
0,
|
|
30
|
+
0,
|
|
31
|
+
[
|
|
32
|
+
ring(0.008, 0.005, 0.005, 0, dim(stalk, 0.66)),
|
|
33
|
+
ring(0, 0.17, 0.17, 0, dim(stalk, 0.75)),
|
|
34
|
+
ring(0.22, 0.135, 0.135, 0, stalk),
|
|
35
|
+
ring(0.52, 0.085, 0.085, 0, stalk),
|
|
36
|
+
ring(0.535, 0.097, 0.097, 0, twine), // the binding stands proud of the compressed stalks
|
|
37
|
+
ring(0.57, 0.097, 0.097, 0, twine),
|
|
38
|
+
ring(0.6, 0.085, 0.085, 0, stalk),
|
|
39
|
+
ring(0.84, 0.14, 0.14, 0, ears),
|
|
40
|
+
ring(1.0, 0.19, 0.19, 0, ears),
|
|
41
|
+
ring(1.08, 0.13, 0.13, 0, dim(ears, 0.9)),
|
|
42
|
+
ring(1.04, 0.01, 0.01, 0, dim(ears, 0.75)),
|
|
43
|
+
],
|
|
44
|
+
around,
|
|
45
|
+
{
|
|
46
|
+
fold: (v, a) => 0.92 + 0.08 * Math.sin(a * 5 + twist) + 0.14 * vnoise(a * 2.1 + grain, v * 5, 373),
|
|
47
|
+
tint: (point, a) => 0.68 + 0.28 * Math.cos(a * 11 + twist + point[1] * 0.6),
|
|
48
|
+
lay: (point, a) => {
|
|
49
|
+
if (point[1] < 0.01 || point[1] >= 1) point[1] += 0.034 * Math.sin(a * 3 + twist);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
if (far) return;
|
|
54
|
+
const at = (a, out, y) => [Math.cos(a) * out, y, Math.sin(a) * out];
|
|
55
|
+
for (let k = 0; k < 8; k++) {
|
|
56
|
+
// loose straws down the butt, and the ears standing out of the head
|
|
57
|
+
const a = twist + (k / 8) * TAU + rng() * 0.3;
|
|
58
|
+
stick(b, at(a, 0.152 + rng() * 0.021, 0), at(a + 0.25, 0.075, 0.5), 0.009, C(k % 2 ? 0xd9c688 : 0xa8935a, 0.1, rng), STRAW);
|
|
59
|
+
}
|
|
60
|
+
for (let k = 0; k < 14; k++) {
|
|
61
|
+
const a = rng() * TAU,
|
|
62
|
+
out = 0.06 + rng() * 0.13,
|
|
63
|
+
tip = at(a + (rng() - 0.5) * 0.4, out + 0.05 + rng() * 0.08, 1.14 + rng() * 0.12);
|
|
64
|
+
stick(b, at(a, out, 0.96), tip, 0.01, dim(ears, 0.95 + rng() * 0.3), STRAW);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { sheaf };
|
|
68
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Street furniture a city's builders set out: gas valves where the mains rise, benches and wells. Each is built into a house
|
|
2
|
+
// kit's builders round the kit frame's origin, its front to +z. Worker-safe.
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { dim } from '../math/color.js';
|
|
5
|
+
import { pickR } from '../math/random.js';
|
|
6
|
+
import { C, TRS } from './primitives.js';
|
|
7
|
+
import { HOUSE_PALETTE } from './house-kit-palette.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The street props, bound to a world's shapes, its house kit's gable and palette.
|
|
11
|
+
* @param {object} o
|
|
12
|
+
* @param {object} o.shapes - The unit shapes (`createUnitShapes`).
|
|
13
|
+
* @param {Function} o.kitGable - The house kit's gable (`createHouseKit`), the well's roof.
|
|
14
|
+
* @param {object} [o.palette] - The house palette (`hemp` for rope, `cloths` and `awnings`, sRGB hex choices); a house kit's
|
|
15
|
+
* `palette`, or the kit's default (`HOUSE_PALETTE`).
|
|
16
|
+
* @param {number} [o.crank] - The height of a well's windlass, metres (1.45); a world whose figures turn it shares the figure.
|
|
17
|
+
* @returns {object} `propValve(B, R)`, `propBench(B, R)`, `propWell(B, R)`, and `WHEEL`, the valve's hand-wheel geometry.
|
|
18
|
+
*/
|
|
19
|
+
export function createStreetProps({ shapes: U, kitGable, palette = HOUSE_PALETTE, crank: WELL_CRANK = 1.45 }) {
|
|
20
|
+
const { hemp: HEMP } = palette;
|
|
21
|
+
const WHEEL = new THREE.TorusGeometry(0.56, 0.05, 5, 18);
|
|
22
|
+
|
|
23
|
+
function propValve(B, R) {
|
|
24
|
+
// a gas valve where the copper mains rise: a stone kerb, the iron valve body and its great hand-wheel; front is +z
|
|
25
|
+
const cu = () => C(pickR(R, [0x6f8a6c, 0x5e7a62, 0x7a6a4a]), 0.12, R),
|
|
26
|
+
iron = C(0x2a2826, 0.1, R);
|
|
27
|
+
B.stone.box(0, -0.3, 0, 2.2, 0.5, 1.5, C(0x8a8274, 0.1, R));
|
|
28
|
+
B.stone.box(0, 0.2, 0, 2.3, 0.08, 1.6, C(0x9a9284, 0.1, R));
|
|
29
|
+
B.cloth.add(U.cyl16, cu(), TRS(-0.5, 0.25, 0, 0.42, 1.3, 0.42));
|
|
30
|
+
B.cloth.add(U.cyl16, cu(), TRS(0.55, 0.25, 0, 0.34, 0.9, 0.34));
|
|
31
|
+
for (const [x, y] of [
|
|
32
|
+
[-0.5, 0.6],
|
|
33
|
+
[-0.5, 1.3],
|
|
34
|
+
[0.55, 0.75],
|
|
35
|
+
])
|
|
36
|
+
B.cloth.add(U.cyl16, dim(cu(), 0.8), TRS(x, y, 0, 0.56, 0.09, 0.56));
|
|
37
|
+
B.cloth.add(U.cyl16, cu(), TRS(-0.5, 1.15, -0.05, 0.3, 1.25, 0.3, 0, -Math.PI / 2));
|
|
38
|
+
B.cloth.add(U.cyl16, cu(), TRS(0.55, 0.85, -0.05, 0.26, 1.25, 0.26, 0, -Math.PI / 2)); // the mains into the wall behind
|
|
39
|
+
B.cloth.add(U.cyl16, iron, TRS(-0.5, 1.55, 0, 0.62, 0.42, 0.62));
|
|
40
|
+
B.cloth.add(U.cyl6, iron, TRS(-0.5, 1.95, 0, 0.09, 0.55, 0.09));
|
|
41
|
+
B.cloth.add(WHEEL, iron, TRS(-0.5, 2.5, 0, 1, 1, 1, 0, Math.PI / 2));
|
|
42
|
+
for (let k = 0; k < 3; k++) B.cloth.box(-0.5, 2.48, 0, 1.08, 0.05, 0.05, iron, (k * Math.PI) / 3);
|
|
43
|
+
B.cloth.add(WHEEL, iron, TRS(0.55, 1.55, 0.26, 0.55, 0.55, 0.55));
|
|
44
|
+
B.cloth.box(0.55, 1.2, 0.18, 0.05, 0.35, 0.05, iron);
|
|
45
|
+
B.cloth.box(0.95, -0.02, 0.4, 0.7, 0.04, 0.5, [0.04, 0.04, 0.04]); // the iron plate over the pit
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function propBench(B, R) {
|
|
49
|
+
const w = C(0x5a4632, 0.15, R);
|
|
50
|
+
B.wood.box(0, 0.42, 0, 1.8, 0.07, 0.42, w);
|
|
51
|
+
B.wood.box(0, 0.5, -0.2, 1.8, 0.5, 0.06, w);
|
|
52
|
+
for (const sx of [-1, 1]) B.stone.box(sx * 0.75, -0.2, 0, 0.16, 0.64, 0.42, C(0x8d8676, 0.1, R));
|
|
53
|
+
}
|
|
54
|
+
function propWell(B, R) {
|
|
55
|
+
const st = C(0x8d8676, 0.08, R),
|
|
56
|
+
tim = C(0x3f2e20);
|
|
57
|
+
B.stone.add(U.cyl16, dim(st, 0.8), TRS(0, -0.4, 0, 3.2, 0.52, 3.2));
|
|
58
|
+
B.stone.add(U.cyl16, st, TRS(0, 0, 0, 2.0, 0.95, 2.0));
|
|
59
|
+
B.cloth.add(U.cyl16, [0.01, 0.012, 0.014], TRS(0, 0.9, 0, 1.5, 0.07, 1.5));
|
|
60
|
+
for (const sx of [-1, 1]) B.wood.box(sx * 1.05, 0, 0, 0.16, 2.6, 0.16, tim);
|
|
61
|
+
// the windlass at a working height between the posts, in iron-bound bearings, with the rope coiled on it; its crank, rope and bucket
|
|
62
|
+
// move, and a world builds them apart
|
|
63
|
+
B.wood.add(U.cyl6, tim, TRS(-1.15, WELL_CRANK, 0, 0.14, 2.3, 0.14, 0, 0, -Math.PI / 2));
|
|
64
|
+
B.wood.add(U.cyl16, HEMP, TRS(-0.15, WELL_CRANK, 0, 0.22, 0.5, 0.22, 0, 0, -Math.PI / 2));
|
|
65
|
+
for (const sx of [-1, 1]) B.wood.box(sx * 1.05, WELL_CRANK - 0.13, 0, 0.24, 0.26, 0.24, C(0x2b2927));
|
|
66
|
+
kitGable(B, { R, tim }, 0, 2.6, 0, 2.5, 1.5, 0.7, 0, C(0x6b4034, 0.1, R), null, { eave: 0.2, over: 0.15 });
|
|
67
|
+
}
|
|
68
|
+
return { WHEEL, propBench, propValve, propWell };
|
|
69
|
+
}
|