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,58 @@
|
|
|
1
|
+
// A world's props in one call: the furniture of camps, markets, streets, quays, farms, roads, graveyards and battlefields,
|
|
2
|
+
// bound to the world's unit shapes, noise, hash, sculptor and horse, and to the frame and palette of its house kit, so that
|
|
3
|
+
// every prop is built into the kit's builders like a house. Worker-safe: a worker's builders reach the same props.
|
|
4
|
+
import { createSculptor } from './sculpt.js';
|
|
5
|
+
import { createBattlefieldProps } from './prop-battlefield.js';
|
|
6
|
+
import { createCampProps } from './prop-camp.js';
|
|
7
|
+
import { createDoorProps } from './prop-door.js';
|
|
8
|
+
import { createHarbourProps } from './prop-harbour.js';
|
|
9
|
+
import { createHaycock } from './prop-haycock.js';
|
|
10
|
+
import { sackLying, sackStanding } from './prop-sacks.js';
|
|
11
|
+
import { createSheaf } from './prop-sheaf.js';
|
|
12
|
+
import { createStreetProps } from './prop-street.js';
|
|
13
|
+
import { createTentProps } from './prop-tents.js';
|
|
14
|
+
import { createTombProps } from './prop-tombs.js';
|
|
15
|
+
import { createTradeProps } from './prop-trade.js';
|
|
16
|
+
import { CART_WHEELS, WAGON_WHEELS, createVehicleProps } from './prop-vehicles.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Every prop builder, bound to one world.
|
|
20
|
+
* @param {object} o
|
|
21
|
+
* @param {object} o.houseKit - The world's house kit (`createHouseKit`): its frame (`kitPush`, `kitPop`), gable and palette.
|
|
22
|
+
* @param {object} o.shapes - The unit shapes (`createUnitShapes`).
|
|
23
|
+
* @param {Function} o.vnoise - Seeded value noise (`createNoise`).
|
|
24
|
+
* @param {Function} o.hash - The world's hash (`createHash`).
|
|
25
|
+
* @param {Function} [o.loft] - The sculptor's loft (`createSculptor`); a plain sculptor's if not given.
|
|
26
|
+
* @param {Function} [o.horse] - A still horse cast into a builder, (builder, x, y, z, yaw, colour, R, graze, lying); the
|
|
27
|
+
* picketed and the dead horse need it.
|
|
28
|
+
* @param {number} [o.crank] - The height of a well's windlass, metres.
|
|
29
|
+
* @param {Function} [o.onStall] - Called as each market stall is begun (`createTradeProps`).
|
|
30
|
+
* @returns {object} The builders of `createTradeProps`, `createTentProps`, `createCampProps`, `createVehicleProps`,
|
|
31
|
+
* `createStreetProps`, `createHarbourProps`, `createDoorProps`, `createTombProps` and `createBattlefieldProps`, with `sheaf`,
|
|
32
|
+
* `haycock`, `sackLying`, `sackStanding`, `CART_WHEELS` and `WAGON_WHEELS`.
|
|
33
|
+
*/
|
|
34
|
+
export function createProps({ houseKit, shapes, vnoise, hash, loft = createSculptor().loft, horse, crank, onStall }) {
|
|
35
|
+
const { kitPush, kitPop, kitGable, palette } = houseKit,
|
|
36
|
+
common = { shapes, kitPush, kitPop, palette },
|
|
37
|
+
{ sheaf } = createSheaf({ vnoise, loft }),
|
|
38
|
+
{ haycock } = createHaycock({ loft }),
|
|
39
|
+
trade = createTradeProps({ ...common, onStall }),
|
|
40
|
+
{ propCrates, stavedBarrel } = trade;
|
|
41
|
+
return {
|
|
42
|
+
sackLying,
|
|
43
|
+
sackStanding,
|
|
44
|
+
sheaf,
|
|
45
|
+
haycock,
|
|
46
|
+
CART_WHEELS,
|
|
47
|
+
WAGON_WHEELS,
|
|
48
|
+
...trade,
|
|
49
|
+
...createTentProps({ ...common, propCrates, stavedBarrel }),
|
|
50
|
+
...createCampProps({ shapes, palette, haycock, horse }),
|
|
51
|
+
...createVehicleProps({ ...common, propCrates, stavedBarrel, sheaf }),
|
|
52
|
+
...createStreetProps({ shapes, kitGable, palette, crank }),
|
|
53
|
+
...createHarbourProps({ shapes, palette }),
|
|
54
|
+
...createDoorProps({ shapes, hash }),
|
|
55
|
+
...createTombProps({ shapes }),
|
|
56
|
+
...createBattlefieldProps({ shapes, loft, horse }),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An arcade down a hall: columns of stone (a base, a polished shaft, a carved capital) carrying pointed arches of voussoirs,
|
|
3
|
+
* piers over the capitals up to the floor of a gallery behind, and over each arch the gallery's wall with an opening screened
|
|
4
|
+
* by a lattice of turned wood. Built into a room started with `startRoom`, along a line of constant x in its frame (lay a room
|
|
5
|
+
* out turned to have one along x).
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { dim } from '../math/color.js';
|
|
10
|
+
import { C, createUnitShapes } from './primitives.js';
|
|
11
|
+
import { barRound, put, shape } from './room-frame.js';
|
|
12
|
+
|
|
13
|
+
const STONE = 0xd0bea0,
|
|
14
|
+
SHAFT = 0xc8b8a0,
|
|
15
|
+
PLASTER = 0xd8c8a8,
|
|
16
|
+
LATTICE = 0x5a3a20,
|
|
17
|
+
LATTICE_STEP = 0.14, // metres between a lattice's rails and stiles
|
|
18
|
+
ARCH_STONES = 8, // voussoirs up each side of an arch
|
|
19
|
+
GALLERY_FLOOR = 0.2; // metres: the gallery's floor over the aisle, which the spandrels fill up to
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Makes a room's arcade builders.
|
|
23
|
+
* @param {object} [options]
|
|
24
|
+
* @param {object} [options.shapes] - The unit shapes (`createUnitShapes`): columns are lathed cylinders and cones.
|
|
25
|
+
* @returns {{ arcade: Function, pointedArch: Function, lattice: Function }}
|
|
26
|
+
*/
|
|
27
|
+
export function createRoomArcade({ shapes: U = createUnitShapes() } = {}) {
|
|
28
|
+
/**
|
|
29
|
+
* A lattice screen of wood in an opening: rails and stiles crossing on a small square, w wide (along z) and h high, its foot at
|
|
30
|
+
* y and its middle at (x, z), on a sill.
|
|
31
|
+
* @param {{ tone?: number, step?: number }} [o] - The wood's sRGB hex, and the square's side in metres (0.14).
|
|
32
|
+
*/
|
|
33
|
+
function lattice(R, x, y, z, w, h, o = {}) {
|
|
34
|
+
const wood = C(o.tone ?? LATTICE),
|
|
35
|
+
step = o.step ?? LATTICE_STEP;
|
|
36
|
+
put(R.B.wood, R, x, y - 0.06, z, 0.12, 0.06, w, dim(wood, 0.9));
|
|
37
|
+
for (let s = -w / 2 + step / 2; s < w / 2; s += step) put(R.B.wood, R, x, y, z + s, 0.06, h, 0.025, wood);
|
|
38
|
+
for (let t = step / 2; t < h; t += step) put(R.B.wood, R, x, y + t, z, 0.06, 0.025, w, dim(wood, 1.1));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A pointed arch over the bay from z0 to z1 at x, springing at y: two arcs of voussoirs (pale and dark by turns) meeting at the
|
|
43
|
+
* crown, each the arc of a circle centred on the other's foot, and the spandrels over them filled with plaster up to `top`.
|
|
44
|
+
* @param {number[]} stone - The voussoirs' linear colour. `plaster` the spandrels' sRGB hex.
|
|
45
|
+
*/
|
|
46
|
+
function pointedArch(R, x, z0, z1, y, top, stone, plaster = PLASTER) {
|
|
47
|
+
const span = z1 - z0 - 0.34,
|
|
48
|
+
rise = span * 0.62,
|
|
49
|
+
a = z0 + 0.17;
|
|
50
|
+
const point = t => {
|
|
51
|
+
// t from 0 (the left foot) to 1 (the right foot)
|
|
52
|
+
const half = t < 0.5,
|
|
53
|
+
u = half ? t * 2 : (1 - t) * 2, // 0 at a foot, 1 at the crown
|
|
54
|
+
th = u * Math.acos(0.5), // up the arc from the foot
|
|
55
|
+
dz = span - span * Math.cos(th),
|
|
56
|
+
dy = span * Math.sin(th) * (rise / (span * Math.sin(Math.acos(0.5))));
|
|
57
|
+
return [half ? a + dz : a + span - dz, y + dy];
|
|
58
|
+
};
|
|
59
|
+
for (let k = 0; k < 2 * ARCH_STONES; k++) {
|
|
60
|
+
const [za, ya] = point(k / (2 * ARCH_STONES)),
|
|
61
|
+
[zb, yb] = point((k + 1) / (2 * ARCH_STONES)),
|
|
62
|
+
len = Math.hypot(zb - za, yb - ya),
|
|
63
|
+
tilt = Math.atan2(zb - za, yb - ya);
|
|
64
|
+
put(R.B.stone, R, x, ya, za, 0.42, len + 0.02, 0.2, dim(stone, k % 2 ? 1.0 : 0.88), 0, tilt); // a voussoir
|
|
65
|
+
put(
|
|
66
|
+
R.B.plaster,
|
|
67
|
+
R,
|
|
68
|
+
x,
|
|
69
|
+
Math.max(ya, yb) + 0.08,
|
|
70
|
+
(za + zb) / 2,
|
|
71
|
+
0.36,
|
|
72
|
+
top - Math.max(ya, yb) - 0.08,
|
|
73
|
+
Math.abs(zb - za) + 0.02,
|
|
74
|
+
C(plaster),
|
|
75
|
+
); // the spandrel over it
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An arcade along x = `x`: `bays` bays `bay` metres long from the first column at `from` (along z, increasing), arches
|
|
81
|
+
* springing at `spring`, a gallery's floor at `gallery` behind them, and the wall over them up to `ceiling`, screened with a
|
|
82
|
+
* lattice in each bay. The end bays are walled from the last arch's spring to the ceiling as far as `ends` ([z, z]: the room's
|
|
83
|
+
* end walls), so the aisle behind does not show through. Each column bars the way.
|
|
84
|
+
* @param {object} R - The room.
|
|
85
|
+
* @param {object} o - `x`, `from`, `bay`, `bays`, `ends`, `spring`, `gallery`, `ceiling` (metres); `stone`, `shaft`, `plaster`
|
|
86
|
+
* and `lattice` (sRGB hex).
|
|
87
|
+
*/
|
|
88
|
+
function arcade(
|
|
89
|
+
R,
|
|
90
|
+
{
|
|
91
|
+
x,
|
|
92
|
+
from,
|
|
93
|
+
bay,
|
|
94
|
+
bays,
|
|
95
|
+
ends,
|
|
96
|
+
spring,
|
|
97
|
+
gallery,
|
|
98
|
+
ceiling,
|
|
99
|
+
stone: stoneHex = STONE,
|
|
100
|
+
shaft = SHAFT,
|
|
101
|
+
plaster = PLASTER,
|
|
102
|
+
lattice: latticeHex = LATTICE,
|
|
103
|
+
},
|
|
104
|
+
) {
|
|
105
|
+
const stone = C(stoneHex),
|
|
106
|
+
top = gallery + GALLERY_FLOOR;
|
|
107
|
+
for (let b = 0; b <= bays; b++) {
|
|
108
|
+
const z = from + b * bay;
|
|
109
|
+
// the column: a base, a shaft, a capital of carved stone
|
|
110
|
+
shape(R.B.stone, R, U.cyl16, dim(stone, 0.9), x, 0, z, 0.52, 0.3, 0.52);
|
|
111
|
+
shape(R.B.polished, R, U.cyl16, C(shaft), x, 0.3, z, 0.34, spring - 0.6, 0.34);
|
|
112
|
+
shape(R.B.stone, R, U.cone16, dim(stone, 1.05), x, spring - 0.05, z, 0.62, -0.3, 0.62);
|
|
113
|
+
put(R.B.stone, R, x, spring - 0.05, z, 0.62, 0.1, 0.62, dim(stone, 0.95));
|
|
114
|
+
barRound(R, x, z, 0.28);
|
|
115
|
+
// the pier over the capital, up to the gallery's floor, that the arches on either side lean on
|
|
116
|
+
put(R.B.plaster, R, x, spring + 0.05, z, 0.4, top - spring - 0.05, 0.56, C(plaster));
|
|
117
|
+
if (ends && (b === 0 || b === bays)) {
|
|
118
|
+
// the wall over the end bay, from the last arch's spring to the ceiling: the aisle behind showed black through it
|
|
119
|
+
const end = b === 0 ? ends[0] : ends[1],
|
|
120
|
+
wallFrom = z + (b === 0 ? -0.28 : 0.28);
|
|
121
|
+
put(R.B.plaster, R, x, spring - 0.05, (end + wallFrom) / 2, 0.4, ceiling - spring + 0.05, Math.abs(end - wallFrom), C(plaster));
|
|
122
|
+
}
|
|
123
|
+
if (b === bays) break;
|
|
124
|
+
pointedArch(R, x, z, z + bay, spring, top, stone, plaster);
|
|
125
|
+
// over the arch, the gallery's wall with its screened opening
|
|
126
|
+
put(R.B.plaster, R, x, top, z + 0.05, 0.4, ceiling - gallery - GALLERY_FLOOR, 0.3, C(plaster));
|
|
127
|
+
put(R.B.plaster, R, x, top, z + bay / 2, 0.4, 0.5, bay - 0.4, C(plaster));
|
|
128
|
+
put(R.B.plaster, R, x, ceiling - 0.7, z + bay / 2, 0.4, 0.7, bay - 0.4, C(plaster));
|
|
129
|
+
lattice(R, x, gallery + 0.7, z + bay / 2, bay - 0.4, ceiling - gallery - 1.4, { tone: latticeHex });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return { arcade, pointedArch, lattice };
|
|
134
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A dome seen from under it, and the flat ceiling round its drum: coffered panels between ribs that stand proud of them, round-
|
|
3
|
+
* headed windows of glass in the drum, and an open eye at the crown under a glazed lantern. Its windows and its eye are
|
|
4
|
+
* openings of the room's baked light.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { dim } from '../math/color.js';
|
|
9
|
+
import { createHash } from '../math/random.js';
|
|
10
|
+
import { C, createUnitShapes } from './primitives.js';
|
|
11
|
+
import { panel, put, shape } from './room-frame.js';
|
|
12
|
+
|
|
13
|
+
const DOME_PLASTER = 0xd4c8ae,
|
|
14
|
+
DOME_RIB = 0xc0b090,
|
|
15
|
+
CEILING_PLASTER = 0xd8ccb4,
|
|
16
|
+
EYE = 0.42, // radians from the crown down that are left open: the dome's eye
|
|
17
|
+
DRUM_GLASS = [0.9, 0.9, 0.86],
|
|
18
|
+
LANTERN_GLASS = [0.95, 0.95, 0.9];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Makes a room's dome builders.
|
|
22
|
+
* @param {object} [options]
|
|
23
|
+
* @param {object} [options.shapes] - The unit shapes (`createUnitShapes`).
|
|
24
|
+
* @param {(i: number, j: number, salt: number) => number} [options.hash] - A hash in [0, 1), which gives each coffer its tone.
|
|
25
|
+
* @param {Function} options.tiles - The tiling of the room's surfaces (`createRoomSurfaces`), which lays the ceiling round the drum.
|
|
26
|
+
* @returns {{ dome: Function, ceilingRound: Function }}
|
|
27
|
+
*/
|
|
28
|
+
export function createRoomDome({ shapes: U = createUnitShapes(), hash = createHash(), tiles }) {
|
|
29
|
+
/**
|
|
30
|
+
* A dome round (x, z) with radius r, springing at height y + drum from a drum `drum` metres high.
|
|
31
|
+
* @param {object} [o] - `tone` and `rib` (sRGB hex), `rings` of coffers (6), `segs` round it (24), `windows` (every n'th bay
|
|
32
|
+
* of the drum has one; none if not given), `gb` (the builder: plaster unless given).
|
|
33
|
+
* @returns {number} The height of the lantern's top over the room's floor, metres.
|
|
34
|
+
*/
|
|
35
|
+
function dome(R, x, z, r, y, drum, o = {}) {
|
|
36
|
+
const gb = o.gb ?? R.B.plaster,
|
|
37
|
+
tone = C(o.tone ?? DOME_PLASTER),
|
|
38
|
+
rib = C(o.rib ?? DOME_RIB),
|
|
39
|
+
rings = o.rings ?? 6,
|
|
40
|
+
segs = o.segs ?? 24,
|
|
41
|
+
dTh = (2 * Math.PI) / segs,
|
|
42
|
+
dPh = (Math.PI / 2 - EYE) / rings,
|
|
43
|
+
spring = y + drum;
|
|
44
|
+
for (let j = 0; j < segs; j++) {
|
|
45
|
+
const th = (j + 0.5) * dTh,
|
|
46
|
+
c = Math.cos(th),
|
|
47
|
+
s = Math.sin(th),
|
|
48
|
+
chord = 2 * r * Math.sin(dTh / 2);
|
|
49
|
+
// the drum: a bay of wall between pilasters, every n'th with a round-headed window
|
|
50
|
+
const win = o.windows && j % o.windows === 0;
|
|
51
|
+
panel(gb, R, x + c * (r + 0.15), y, z + s * (r + 0.15), chord, win ? 0.6 : drum, 0.3, dim(tone, 0.95), th, 0);
|
|
52
|
+
if (win) {
|
|
53
|
+
const winH = drum - 0.95;
|
|
54
|
+
panel(gb, R, x + c * (r + 0.15), y + drum - 0.35, z + s * (r + 0.15), chord, 0.35, 0.3, dim(tone, 0.95), th, 0);
|
|
55
|
+
for (const side of [-1, 1])
|
|
56
|
+
panel(
|
|
57
|
+
gb,
|
|
58
|
+
R,
|
|
59
|
+
x + c * (r + 0.15) - s * side * chord * 0.38,
|
|
60
|
+
y + 0.6,
|
|
61
|
+
z + s * (r + 0.15) + c * side * chord * 0.38,
|
|
62
|
+
chord * 0.24,
|
|
63
|
+
winH,
|
|
64
|
+
0.3,
|
|
65
|
+
dim(tone, 0.95),
|
|
66
|
+
th,
|
|
67
|
+
0,
|
|
68
|
+
);
|
|
69
|
+
panel(R.B.glass, R, x + c * (r + 0.25), y + 0.6, z + s * (r + 0.25), chord * 0.54, winH, 0.04, DRUM_GLASS, th, 0);
|
|
70
|
+
if (winH > 0.15) {
|
|
71
|
+
R.windows.push({
|
|
72
|
+
x: R.O.x + x + c * r,
|
|
73
|
+
y: y + 0.6 + winH * 0.5,
|
|
74
|
+
z: R.O.z + z + s * r,
|
|
75
|
+
w: chord * 0.54,
|
|
76
|
+
h: winH,
|
|
77
|
+
nx: -c,
|
|
78
|
+
ny: 0,
|
|
79
|
+
nz: -s,
|
|
80
|
+
weight: 0.85,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// a pilaster
|
|
85
|
+
panel(
|
|
86
|
+
gb,
|
|
87
|
+
R,
|
|
88
|
+
x + Math.cos(th - dTh / 2) * (r - 0.05),
|
|
89
|
+
y,
|
|
90
|
+
z + Math.sin(th - dTh / 2) * (r - 0.05),
|
|
91
|
+
0.22,
|
|
92
|
+
drum,
|
|
93
|
+
0.16,
|
|
94
|
+
rib,
|
|
95
|
+
th - dTh / 2,
|
|
96
|
+
0,
|
|
97
|
+
);
|
|
98
|
+
// the coffers, ring by ring up to the eye, and the rib between this bay and the next
|
|
99
|
+
for (let i = 0; i < rings; i++) {
|
|
100
|
+
const ph = i * dPh,
|
|
101
|
+
rr = r * Math.cos(ph),
|
|
102
|
+
yy = spring + r * Math.sin(ph),
|
|
103
|
+
wide = 2 * r * Math.cos(ph + dPh / 2) * Math.sin(dTh / 2),
|
|
104
|
+
k = hash(i, j, 6701);
|
|
105
|
+
panel(
|
|
106
|
+
gb,
|
|
107
|
+
R,
|
|
108
|
+
x + c * (rr + 0.12),
|
|
109
|
+
yy,
|
|
110
|
+
z + s * (rr + 0.12),
|
|
111
|
+
wide + 0.02,
|
|
112
|
+
r * dPh + 0.02,
|
|
113
|
+
0.12,
|
|
114
|
+
dim(tone, 0.9 + 0.08 * k - 0.04 * i),
|
|
115
|
+
th,
|
|
116
|
+
ph,
|
|
117
|
+
);
|
|
118
|
+
panel(gb, R, x + c * rr, yy, z + s * rr, wide * 0.98, 0.14, 0.22, rib, th, ph); // the ring rib at the coffer's foot
|
|
119
|
+
const re = rr - 0.06;
|
|
120
|
+
panel(gb, R, x + Math.cos(th - dTh / 2) * re, yy, z + Math.sin(th - dTh / 2) * re, 0.14, r * dPh, 0.22, rib, th - dTh / 2, ph);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// the eye's ring, and the lantern's glass over it, lit by the sky
|
|
124
|
+
const top = spring + r * Math.sin(Math.PI / 2 - EYE),
|
|
125
|
+
eyeR = r * Math.cos(Math.PI / 2 - EYE);
|
|
126
|
+
shape(gb, R, U.cyl16, rib, x, top - 0.1, z, 2 * eyeR + 0.3, 0.25, 2 * eyeR + 0.3);
|
|
127
|
+
shape(R.B.glass, R, U.cyl16, LANTERN_GLASS, x, top + 0.9, z, 2 * eyeR + 0.2, 0.05, 2 * eyeR + 0.2);
|
|
128
|
+
for (let j = 0; j < 8; j++) {
|
|
129
|
+
const th = (j / 8) * Math.PI * 2;
|
|
130
|
+
put(gb, R, x + Math.cos(th) * eyeR, top + 0.1, z + Math.sin(th) * eyeR, 0.12, 0.8, 0.12, rib);
|
|
131
|
+
}
|
|
132
|
+
R.windows.push({
|
|
133
|
+
x: R.O.x + x,
|
|
134
|
+
y: top,
|
|
135
|
+
z: R.O.z + z,
|
|
136
|
+
w: eyeR * 1.75,
|
|
137
|
+
h: eyeR * 1.75,
|
|
138
|
+
nx: 0,
|
|
139
|
+
ny: -1,
|
|
140
|
+
nz: 0,
|
|
141
|
+
weight: 1,
|
|
142
|
+
});
|
|
143
|
+
if (top + 0.9 > R.maxTopY) R.maxTopY = top + 0.9;
|
|
144
|
+
return top + 0.9;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A flat plaster ceiling at height h over a rectangle, with a round opening of radius r about (x, z) for a dome's drum and a
|
|
149
|
+
* moulded ring round its edge; `tone` its sRGB hex.
|
|
150
|
+
*/
|
|
151
|
+
function ceilingRound(R, x0, x1, z0, z1, h, x, z, r, tone = CEILING_PLASTER) {
|
|
152
|
+
if (h > R.maxTopY) R.maxTopY = h;
|
|
153
|
+
tiles(
|
|
154
|
+
R,
|
|
155
|
+
R.B.plaster,
|
|
156
|
+
x0,
|
|
157
|
+
x1,
|
|
158
|
+
z0,
|
|
159
|
+
z1,
|
|
160
|
+
h + 0.05,
|
|
161
|
+
0.5,
|
|
162
|
+
(i, j) => {
|
|
163
|
+
const px = x0 + (i + 0.5) * 0.5 - x,
|
|
164
|
+
pz = z0 + (j + 0.5) * 0.5 - z;
|
|
165
|
+
return Math.hypot(px, pz) < r + 0.1 ? null : tone;
|
|
166
|
+
},
|
|
167
|
+
{ joint: 0 },
|
|
168
|
+
);
|
|
169
|
+
for (let j = 0; j < 32; j++) {
|
|
170
|
+
const th = ((j + 0.5) / 32) * Math.PI * 2;
|
|
171
|
+
panel(
|
|
172
|
+
R.B.plaster,
|
|
173
|
+
R,
|
|
174
|
+
x + Math.cos(th) * (r + 0.1),
|
|
175
|
+
h - 0.3,
|
|
176
|
+
z + Math.sin(th) * (r + 0.1),
|
|
177
|
+
2 * (r + 0.1) * Math.sin(Math.PI / 32) + 0.02,
|
|
178
|
+
0.35,
|
|
179
|
+
0.3,
|
|
180
|
+
dim(C(tone), 0.94),
|
|
181
|
+
th,
|
|
182
|
+
0,
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return { dome, ceilingRound };
|
|
188
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The small lights of a room: a flame (or a glowing globe) that lights it, a candle on its dish or stick, an oil lamp and a
|
|
3
|
+
* pierced lantern hung on chains, and the chain itself. Each flame is drawn as a small glow in the room's `flame` builder, is an
|
|
4
|
+
* emitter of the room's baked light (`R.lamps`), and is handed to the world as a light site (`addSite`, in the shape
|
|
5
|
+
* `createFlameSources` reads), so the world can give the nearest of them a real light.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { C, createUnitShapes } from './primitives.js';
|
|
10
|
+
import { put, shape } from './room-frame.js';
|
|
11
|
+
|
|
12
|
+
/** A flame's linear colour. */
|
|
13
|
+
export const ROOM_FLAME = [1, 0.62, 0.24];
|
|
14
|
+
/** A candle's and a hanging lamp's light, in units of a small fire (a light site's `light`). */
|
|
15
|
+
export const ROOM_FLAME_LIGHT = Object.freeze({ candle: 0.22, lamp: 0.5 });
|
|
16
|
+
const IRON = [0.05, 0.045, 0.04],
|
|
17
|
+
BRASS = [0.42, 0.3, 0.12],
|
|
18
|
+
LAMP_BOWL = [0.08, 0.07, 0.06],
|
|
19
|
+
LAMP_RIM = [0.1, 0.09, 0.07],
|
|
20
|
+
TALLOW = [0.78, 0.72, 0.58],
|
|
21
|
+
STICK = 0x9a7a3a, // a brass candlestick
|
|
22
|
+
DISH = 0x6e6a62, // a pewter dish
|
|
23
|
+
LANTERN_GLASS = [0.32, 0.2, 0.09], // a lantern's horn or glass, lit from within
|
|
24
|
+
LANTERN_FLAME = [1.0, 0.72, 0.42];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Makes the builders of a room's small lights.
|
|
28
|
+
* @param {object} [options]
|
|
29
|
+
* @param {object} [options.shapes] - The unit shapes (`createUnitShapes`).
|
|
30
|
+
* @param {(site: object) => void} [options.addSite] - Takes each light site a flame makes: `{ space, type: 'light', x, y, z,
|
|
31
|
+
* light, lift, tint }` in world coordinates (the room's id its space). Nothing is done with them if not given.
|
|
32
|
+
* @returns {{ flame: Function, candle: Function, chain: Function, hangingLamp: Function, hangingLantern: Function }}
|
|
33
|
+
*/
|
|
34
|
+
export function createRoomFlames({ shapes: U = createUnitShapes(), addSite = () => {} } = {}) {
|
|
35
|
+
/**
|
|
36
|
+
* A flame that lights the room: drawn as a small glow, an emitter of the baked light whose reach grows with its power, and a
|
|
37
|
+
* light site.
|
|
38
|
+
* @param {object} R - The room.
|
|
39
|
+
* @param {number} x - Where it burns, in the room's frame (y its height, metres).
|
|
40
|
+
* @param {number} size - Its glow's height, metres.
|
|
41
|
+
* @param {number} power - Its light, in units of a small fire.
|
|
42
|
+
* @param {{ round?: boolean, tint?: number[] }} [o] - A round globe rather than a tall flame; its linear colour.
|
|
43
|
+
*/
|
|
44
|
+
function flame(R, x, y, z, size, power, o = {}) {
|
|
45
|
+
const wide = o.round ? size : size * 0.42; // a flame is tall and narrow, a glowing globe round
|
|
46
|
+
const tint = o.tint ?? ROOM_FLAME;
|
|
47
|
+
shape(R.B.flame, R, U.sph, tint, x, y - size * 0.3, z, wide, size, wide);
|
|
48
|
+
R.lamps.push({
|
|
49
|
+
x: R.O.x + x,
|
|
50
|
+
y,
|
|
51
|
+
z: R.O.z + z,
|
|
52
|
+
r: tint[0],
|
|
53
|
+
g: tint[1],
|
|
54
|
+
b: tint[2],
|
|
55
|
+
power: power * 1.35,
|
|
56
|
+
range: 3.6 + 5.2 * Math.sqrt(Math.max(0.05, power)),
|
|
57
|
+
});
|
|
58
|
+
addSite({ space: R.id, type: 'light', x: R.O.x + x, y, z: R.O.z + z, light: power, lift: 0.04, tint: o.tint });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A tallow candle on its dish (or in a brass stick, `stick`), its flame lit: y its foot.
|
|
63
|
+
* @param {{ tall?: number, stick?: boolean, lit?: boolean, light?: number }} [o] - The candle's height (0.12 m), a stick, false
|
|
64
|
+
* for an unlit one, its light ({@link ROOM_FLAME_LIGHT}.candle).
|
|
65
|
+
*/
|
|
66
|
+
function candle(R, x, y, z, o = {}) {
|
|
67
|
+
const tall = o.tall ?? 0.12,
|
|
68
|
+
holder = C(o.stick ? STICK : DISH);
|
|
69
|
+
if (o.stick) {
|
|
70
|
+
shape(R.B.metal, R, U.cyl, holder, x, y, z, 0.1, 0.02, 0.1);
|
|
71
|
+
shape(R.B.metal, R, U.cyl, holder, x, y, z, 0.025, 0.2, 0.025);
|
|
72
|
+
shape(R.B.metal, R, U.cyl, holder, x, y + 0.2, z, 0.06, 0.015, 0.06);
|
|
73
|
+
y += 0.215;
|
|
74
|
+
} else shape(R.B.metal, R, U.cyl, holder, x, y, z, 0.11, 0.012, 0.11);
|
|
75
|
+
shape(R.B.cloth, R, U.cyl, TALLOW, x, y + 0.01, z, 0.035, tall, 0.035);
|
|
76
|
+
if (o.lit !== false) flame(R, x, y + tall + 0.045, z, 0.04, o.light ?? ROOM_FLAME_LIGHT.candle);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A chain hung from a ceiling: links turned by a quarter each, from height `from` up to `top`.
|
|
81
|
+
* @param {{ link?: number, size?: number[], tint?: number[] }} [o] - A link's pitch (0.06 m), its size ([0.012, 0.05, 0.03] m),
|
|
82
|
+
* its linear colour (iron).
|
|
83
|
+
*/
|
|
84
|
+
function chain(R, x, from, z, top, o = {}) {
|
|
85
|
+
const link = o.link ?? 0.06,
|
|
86
|
+
[sx, sy, sz] = o.size ?? [0.012, 0.05, 0.03],
|
|
87
|
+
tint = o.tint ?? IRON;
|
|
88
|
+
for (let k = 0; from + k * link < top; k++)
|
|
89
|
+
shape(R.B.metal, R, U.box, tint, x, from + k * link, z, sx, sy, sz, k % 2 ? Math.PI / 2 : 0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** An oil lamp hung on a chain from the ceiling at height top: a pierced iron bowl with its wick burning, y the flame's height. */
|
|
93
|
+
function hangingLamp(R, x, y, z, top) {
|
|
94
|
+
chain(R, x, y + 0.12, z, top);
|
|
95
|
+
shape(R.B.metal, R, U.dome, LAMP_BOWL, x, y - 0.02, z, 0.24, -0.12, 0.24);
|
|
96
|
+
shape(R.B.metal, R, U.cyl, LAMP_RIM, x, y - 0.02, z, 0.25, 0.025, 0.25);
|
|
97
|
+
for (let i = 0; i < 3; i++) {
|
|
98
|
+
const a = (i / 3) * Math.PI * 2;
|
|
99
|
+
shape(
|
|
100
|
+
R.B.metal,
|
|
101
|
+
R,
|
|
102
|
+
U.cyl6,
|
|
103
|
+
IRON,
|
|
104
|
+
x + Math.cos(a) * 0.09,
|
|
105
|
+
y,
|
|
106
|
+
z + Math.sin(a) * 0.09,
|
|
107
|
+
0.01,
|
|
108
|
+
0.13,
|
|
109
|
+
0.01,
|
|
110
|
+
0,
|
|
111
|
+
Math.sin(a) * 0.55,
|
|
112
|
+
-Math.cos(a) * 0.55,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
flame(R, x, y + 0.06, z, 0.06, ROOM_FLAME_LIGHT.lamp);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A lantern hung on a chain from height top: six-sided, pierced sides of metal round its lit glass, a cap and a foot; y its
|
|
120
|
+
* body's foot.
|
|
121
|
+
* @param {{ metal?: number[], glass?: number[], tint?: number[], light?: number }} [o] - The metal's and the lit glass's linear
|
|
122
|
+
* colours (brass, warm amber), the flame's colour and its light (0.45 of a small fire).
|
|
123
|
+
*/
|
|
124
|
+
function hangingLantern(R, x, y, z, top, o = {}) {
|
|
125
|
+
const metal = o.metal ?? BRASS;
|
|
126
|
+
chain(R, x, y + 0.62, z, top, { tint: metal });
|
|
127
|
+
shape(R.B.metal, R, U.cone6, metal, x, y + 0.42, z, 0.36, 0.2, 0.36);
|
|
128
|
+
shape(R.B.metal, R, U.cone6, metal, x, y + 0.02, z, 0.36, -0.18, 0.36);
|
|
129
|
+
for (let k = 0; k < 6; k++) {
|
|
130
|
+
const a = (k / 6) * Math.PI * 2 + Math.PI / 6;
|
|
131
|
+
put(R.B.metal, R, x + Math.cos(a) * 0.16, y + 0.02, z + Math.sin(a) * 0.16, 0.025, 0.4, 0.025, metal);
|
|
132
|
+
}
|
|
133
|
+
shape(R.B.flame, R, U.cyl6, o.glass ?? LANTERN_GLASS, x, y + 0.04, z, 0.28, 0.36, 0.28); // its glass, lit by the flame
|
|
134
|
+
flame(R, x, y + 0.2, z, 0.06, o.light ?? 0.45, { tint: o.tint ?? LANTERN_FLAME });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return { flame, candle, chain, hangingLamp, hangingLantern };
|
|
138
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A room in the making, and the placing helpers every room builder shares: a room is laid out in its own frame (metres east
|
|
3
|
+
* along x and south along z of its origin, y up from its floor) into one geometry builder per surface, and gathers as it is
|
|
4
|
+
* laid out what bars a walker's way and what its baked light is worked out from (windows, lamps and the boxes that block
|
|
5
|
+
* light). The surfaces, the openings, the lights and the furniture of `createRoomKit` all build into such a room.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { GB } from './builder.js';
|
|
10
|
+
import { TRS } from './primitives.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The surfaces a room is built of, one geometry builder each, by the material it is drawn with: `stone`, `wood`, `plaster`,
|
|
14
|
+
* `cloth`, `metal`, `polished` (polished stone), `glass` (a window's panes, lit by the sky beyond) and `flame` (a flame's or
|
|
15
|
+
* a globe's glow, drawn unlit).
|
|
16
|
+
*/
|
|
17
|
+
export const ROOM_SURFACES = Object.freeze(['stone', 'wood', 'plaster', 'cloth', 'metal', 'polished', 'glass', 'flame']);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Starts a room: its builders by surface, and the lists its builders fill as it is laid out.
|
|
21
|
+
*
|
|
22
|
+
* The room's lists: `solid` (what a walker cannot pass: `{ x, z, hx, hz, rot }` boxes and `{ x, z, r }` circles), `windows`
|
|
23
|
+
* (`{ x, y, z, w, h, nx, ny, nz, weight }`: the middle of an opening the sky's light comes in by, its size and the direction it
|
|
24
|
+
* faces into the room), `lamps` (`{ x, y, z, r, g, b, power, range }`: a flame or a hearth), `occluders` (`{ x, y, z, hx, hy,
|
|
25
|
+
* hz, ry }`: a box that blocks light, y its middle), `fireboxes` (where a hearth's smoke is held under its mantel), `wallSpans`
|
|
26
|
+
* (where each wall runs, the room's extent) and `maxTopY` (the highest point a wall or ceiling reaches, metres). Every point
|
|
27
|
+
* noted is in world coordinates (the origin added).
|
|
28
|
+
*
|
|
29
|
+
* @param {string} id - The room's id, which its sites and its dust are keyed by.
|
|
30
|
+
* @param {{ x: number, z: number }} origin - Where the room's frame stands in the world, metres.
|
|
31
|
+
* @param {object} [options]
|
|
32
|
+
* @param {object} [options.group] - The group the room's meshes go into, where the caller adds meshes of its own before the room
|
|
33
|
+
* is finished; the room's finishing makes one if none is given.
|
|
34
|
+
* @param {readonly string[]} [options.surfaces] - The surfaces it has a builder for ({@link ROOM_SURFACES}).
|
|
35
|
+
* @returns {object} The room: `{ id, O, g, solid, fireboxes, windows, lamps, occluders, wallSpans, maxTopY, B }`, `B` its
|
|
36
|
+
* builders by surface.
|
|
37
|
+
*/
|
|
38
|
+
export function startRoom(id, origin, { group = null, surfaces = ROOM_SURFACES } = {}) {
|
|
39
|
+
const builders = {};
|
|
40
|
+
for (const surface of surfaces) builders[surface] = new GB();
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
O: origin,
|
|
44
|
+
g: group,
|
|
45
|
+
solid: [],
|
|
46
|
+
fireboxes: [],
|
|
47
|
+
windows: [],
|
|
48
|
+
lamps: [],
|
|
49
|
+
occluders: [],
|
|
50
|
+
wallSpans: [],
|
|
51
|
+
maxTopY: 3,
|
|
52
|
+
B: builders,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A box in the room's frame: (x, z) its middle, y its foot; sizes in metres, turned by ry, rx, rz radians; col a linear colour. */
|
|
57
|
+
export const put = (gb, R, x, y, z, sx, sy, sz, col, ry = 0, rx = 0, rz = 0) =>
|
|
58
|
+
gb.box(R.O.x + x, y, R.O.z + z, sx, sy, sz, col, ry, rx, rz);
|
|
59
|
+
|
|
60
|
+
/** A unit shape (`geo`, as `createUnitShapes` makes them) in the room's frame, scaled by sx, sy, sz and turned by ry, rx, rz. */
|
|
61
|
+
export const shape = (gb, R, geo, col, x, y, z, sx, sy, sz, ry = 0, rx = 0, rz = 0) =>
|
|
62
|
+
gb.add(geo, col, TRS(R.O.x + x, y, R.O.z + z, sx, sy, sz, ry, rx, rz));
|
|
63
|
+
|
|
64
|
+
/** Notes a box that blocks the room's baked light, in the room's frame: (x, z) its middle, y its foot, sy its height, ry its turn. */
|
|
65
|
+
export const occludeRoom = (R, x, y, z, sx, sy, sz, ry = 0) =>
|
|
66
|
+
R.occluders.push({ x: R.O.x + x, y: y + sy * 0.5, z: R.O.z + z, hx: sx * 0.5, hy: sy * 0.5, hz: sz * 0.5, ry });
|
|
67
|
+
|
|
68
|
+
/** Notes a box a walker cannot pass, in the room's frame: hx, hz its half sizes, turned by rot radians. */
|
|
69
|
+
export const bar = (R, x, z, hx, hz, rot = 0) => R.solid.push({ x: R.O.x + x, z: R.O.z + z, hx, hz, rot });
|
|
70
|
+
|
|
71
|
+
/** Notes a circle a walker cannot pass, in the room's frame, r its radius in metres. */
|
|
72
|
+
export const barRound = (R, x, z, r) => R.solid.push({ x: R.O.x + x, z: R.O.z + z, r });
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A wall's frame: the wall runs from a to b (`[x, z]` in the room's frame, along its inner face) with the room on its right.
|
|
76
|
+
* A point on it is s metres along it from a and d metres out from its face into the room (`onWall`).
|
|
77
|
+
* @param {number[]} a - Where the wall starts.
|
|
78
|
+
* @param {number[]} b - Where it ends.
|
|
79
|
+
* @param {number} [base] - The height of its foot, metres.
|
|
80
|
+
* @returns {{ a: number[], len: number, ux: number, uz: number, nx: number, nz: number, ry: number, y: number }} Its length,
|
|
81
|
+
* the unit vector along it, the one into the room, its turn about the vertical and its foot's height.
|
|
82
|
+
*/
|
|
83
|
+
export function wallFrame(a, b, base = 0) {
|
|
84
|
+
const len = Math.hypot(b[0] - a[0], b[1] - a[1]),
|
|
85
|
+
ux = (b[0] - a[0]) / len,
|
|
86
|
+
uz = (b[1] - a[1]) / len;
|
|
87
|
+
return { a, len, ux, uz, nx: -uz, nz: ux, ry: -Math.atan2(uz, ux), y: base };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The point s metres along a wall (`wallFrame`) and d metres out from its face, as `[x, z]` in the room's frame. */
|
|
91
|
+
export const onWall = (W, s, d) => [W.a[0] + W.ux * s + W.nx * d, W.a[1] + W.uz * s + W.nz * d];
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A box set against a wall: s along it, d out from its face (to the box's middle), y its foot over the wall's; `long` along the
|
|
95
|
+
* wall, h high, `deep` out from it, tilted by `tilt` radians about the wall's line.
|
|
96
|
+
*/
|
|
97
|
+
export function wallBox(gb, R, W, s, d, y, long, h, deep, col, tilt = 0) {
|
|
98
|
+
const [x, z] = onWall(W, s, d);
|
|
99
|
+
put(gb, R, x, W.y + y, z, long, h, deep, col, W.ry, tilt);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A panel of a curved surface (a dome's coffer, a ring of steps): its foot's middle at (x, y, z), facing out along the bearing
|
|
104
|
+
* `th` (about the vertical, from +x towards +z) and tilted up by `ph`; sx across, sy up the curve, `deep` through it.
|
|
105
|
+
*/
|
|
106
|
+
export const panel = (gb, R, x, y, z, sx, sy, deep, col, th, ph) => put(gb, R, x, y, z, sx, sy, deep, col, Math.PI / 2 - th, -ph);
|