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,275 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import {
|
|
3
|
+
createHouseKit,
|
|
4
|
+
createHouseKitMeshes,
|
|
5
|
+
createNoise,
|
|
6
|
+
createRenderContext,
|
|
7
|
+
createUnitShapes,
|
|
8
|
+
GeometryBuilder,
|
|
9
|
+
mulberry32,
|
|
10
|
+
} from 'roamwright';
|
|
11
|
+
import { createHash } from 'roamwright/math/random.js';
|
|
12
|
+
import { sstep } from 'roamwright/math/scalar.js';
|
|
13
|
+
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
14
|
+
import { partsGeometry } from 'roamwright/geometry/foliage.js';
|
|
15
|
+
import { createProps } from 'roamwright/geometry/props.js';
|
|
16
|
+
import { createPlantTints } from 'roamwright/geometry/plant-tints.js';
|
|
17
|
+
import { createShrubs } from 'roamwright/geometry/plant-shrub.js';
|
|
18
|
+
import { createBroadleaf } from 'roamwright/geometry/plant-broadleaf.js';
|
|
19
|
+
import { createTrees } from 'roamwright/geometry/plant-trees.js';
|
|
20
|
+
import { PLAIN_GRASS, tussockGeometry } from 'roamwright/geometry/plant-tussock.js';
|
|
21
|
+
import { createReeds } from 'roamwright/rendering/plant-reeds.js';
|
|
22
|
+
import { createOrbitRig, makeRollingGround, makeSky, makeWaterMesh, readSeed, setupSun } from './stage.js';
|
|
23
|
+
|
|
24
|
+
const canvas = document.querySelector('canvas');
|
|
25
|
+
const { renderer, camera, scene, worldGroup } = createRenderContext(canvas, { fov: 40 });
|
|
26
|
+
const seed = readSeed(42);
|
|
27
|
+
const random = mulberry32(seed);
|
|
28
|
+
const noise = createNoise(seed);
|
|
29
|
+
const { fbm, vnoise } = noise;
|
|
30
|
+
const hash = createHash(seed);
|
|
31
|
+
const shapes = createUnitShapes(fbm);
|
|
32
|
+
const houseKit = createHouseKit({ shapes });
|
|
33
|
+
|
|
34
|
+
// Gently rolling meadow with a natural pond basin on the eastern side and low hills behind.
|
|
35
|
+
const POND = { x: 21, z: 4, r: 9.5 };
|
|
36
|
+
const WATER_Y = -0.35;
|
|
37
|
+
function ground(x, z) {
|
|
38
|
+
const pondDist = Math.hypot((x - POND.x) * 0.9, (z - POND.z) * 1.15);
|
|
39
|
+
const basin = (1 - sstep(POND.r * 0.45, POND.r * 1.45, pondDist)) * -1.45;
|
|
40
|
+
const dist = Math.hypot(x * 0.8, z * 1.1);
|
|
41
|
+
const hills = sstep(26, 105, dist) * (12 * fbm(x * 0.012, z * 0.012, 4, 17) + 4 * noise.ridged(x * 0.008, z * 0.008, 3, 7));
|
|
42
|
+
const swell = 0.35 * Math.sin(x * 0.045) * Math.cos(z * 0.04) * sstep(14, 34, dist);
|
|
43
|
+
return basin + hills + swell;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const grassCol = new THREE.Color(0x6d7d4a),
|
|
47
|
+
meadowCol = new THREE.Color(0x88925b),
|
|
48
|
+
pathCol = new THREE.Color(0xb1a07a),
|
|
49
|
+
mudCol = new THREE.Color(0x6c654d);
|
|
50
|
+
const terrain = makeRollingGround({
|
|
51
|
+
size: 420,
|
|
52
|
+
segs: 160,
|
|
53
|
+
heightAt: ground,
|
|
54
|
+
colorAt: (x, y, z, up, out) => {
|
|
55
|
+
const g = fbm(x * 0.045, z * 0.045, 3, 11);
|
|
56
|
+
const inCamp = 1 - sstep(11, 20, Math.hypot(x + 8, z - 3));
|
|
57
|
+
const nearPond = 1 - sstep(POND.r * 0.75, POND.r * 1.3, Math.hypot((x - POND.x) * 0.9, (z - POND.z) * 1.15));
|
|
58
|
+
out.copy(grassCol).lerp(meadowCol, g);
|
|
59
|
+
out.lerp(pathCol, inCamp * 0.65);
|
|
60
|
+
out.lerp(mudCol, nearPond * 0.75);
|
|
61
|
+
out.multiplyScalar(0.86 + 0.24 * vnoise(x * 0.14, z * 0.14, 29));
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
worldGroup.add(terrain);
|
|
65
|
+
|
|
66
|
+
// Shimmering pond filling the eastern basin.
|
|
67
|
+
const { mesh: pondMesh, timeUniform: waterTime } = makeWaterMesh({
|
|
68
|
+
width: 28,
|
|
69
|
+
depth: 24,
|
|
70
|
+
segs: 40,
|
|
71
|
+
level: WATER_Y,
|
|
72
|
+
depthAt: (x, z) => Math.max(0, WATER_Y - ground(x + POND.x, z + POND.z)),
|
|
73
|
+
shallowColor: 0x6fa194,
|
|
74
|
+
deepColor: 0x2c5c63,
|
|
75
|
+
opacity: 0.9,
|
|
76
|
+
});
|
|
77
|
+
pondMesh.position.set(POND.x, WATER_Y, POND.z);
|
|
78
|
+
worldGroup.add(pondMesh);
|
|
79
|
+
|
|
80
|
+
// Rocks along the pond bank and hillsides.
|
|
81
|
+
const rocks = new GeometryBuilder();
|
|
82
|
+
for (let i = 0; i < 36; i++) {
|
|
83
|
+
const a = (i / 36) * Math.PI * 2 + random() * 0.3;
|
|
84
|
+
const r = POND.r * (0.85 + random() * 0.45);
|
|
85
|
+
const rx = POND.x + Math.cos(a) * r,
|
|
86
|
+
rz = POND.z + Math.sin(a) * r * 0.85;
|
|
87
|
+
const s = 0.35 + random() * 0.75;
|
|
88
|
+
rocks.add(shapes.rock, C(0x888479, 0.16, random), TRS(rx, ground(rx, rz) - 0.05, rz, s * 1.3, s * 0.8, s, random() * Math.PI));
|
|
89
|
+
}
|
|
90
|
+
const rockMesh = rocks.mesh(new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.94, flatShading: true }), worldGroup);
|
|
91
|
+
rockMesh.castShadow = rockMesh.receiveShadow = true;
|
|
92
|
+
|
|
93
|
+
// Foreground camp and trade clearing props, grouped naturally instead of a bare line.
|
|
94
|
+
const horse = (B, x, y, z, yaw, colour) => B.wood.box(x, y + 1, z, 0.5, 1.3, 1.9, colour, yaw);
|
|
95
|
+
const props = createProps({ houseKit, shapes, vnoise, hash, horse });
|
|
96
|
+
const kit = houseKit.kitNew();
|
|
97
|
+
const placements = [
|
|
98
|
+
[-15, -3, 0.35, (B, R) => props.propPavilion(B, R, 9)],
|
|
99
|
+
[-21, 5, 0.7, (B, R) => props.propTent(B, R, C(0xb8ab8c, 0.1, R))],
|
|
100
|
+
[-6.5, -2.5, 0.12, props.propStall],
|
|
101
|
+
[-1.5, -0.5, -0.35, props.propCrates],
|
|
102
|
+
[2.5, 4.5, 0.45, props.propCart],
|
|
103
|
+
[-9.5, 6.5, -0.25, props.propWagon],
|
|
104
|
+
[4.5, -2, 0.1, props.propWell],
|
|
105
|
+
[-12, 2, 0.4, (B, R) => props.propWoodpile(B, R)],
|
|
106
|
+
[-3.5, 3.5, 0.2, (B, R) => props.propBrazier(B, R)],
|
|
107
|
+
[11.5, -8.5, -0.4, (B, R) => props.houseTomb(B, R, 0, 0, 0, 1, 0)],
|
|
108
|
+
];
|
|
109
|
+
for (const [x, z, yaw, build] of placements) {
|
|
110
|
+
houseKit.kitAt(kit, x, ground(x, z), z, yaw, false, build, random);
|
|
111
|
+
}
|
|
112
|
+
const solid = { vertexColors: true, roughness: 0.9 };
|
|
113
|
+
const materials = Object.fromEntries(houseKit.KIT_KEYS.map(k => [k, new THREE.MeshStandardMaterial({ ...solid, side: THREE.DoubleSide })]));
|
|
114
|
+
materials.stain = new THREE.MeshStandardMaterial({ vertexColors: true, transparent: true, opacity: 0.25, depthWrite: false });
|
|
115
|
+
const handOver = { paced: steps => Promise.resolve(steps), drain: steps => steps, heldBytes: () => 0 };
|
|
116
|
+
const { kitMeshes } = createHouseKitMeshes({ materials, PieceBatch: null, handOver });
|
|
117
|
+
const propsGroup = new THREE.Group();
|
|
118
|
+
kitMeshes(
|
|
119
|
+
houseKit.KIT_KEYS.map(k => kit[k].parts(true)),
|
|
120
|
+
propsGroup,
|
|
121
|
+
);
|
|
122
|
+
propsGroup.traverse(o => {
|
|
123
|
+
if (o.isMesh) {
|
|
124
|
+
o.castShadow = true;
|
|
125
|
+
o.receiveShadow = true;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
worldGroup.add(propsGroup);
|
|
129
|
+
|
|
130
|
+
// Harvest sheaves and a haycock beside the wagon.
|
|
131
|
+
const straw = new THREE.MeshStandardMaterial(solid);
|
|
132
|
+
const stook = (draw, x, z) => {
|
|
133
|
+
const builder = new GeometryBuilder();
|
|
134
|
+
draw(builder);
|
|
135
|
+
const mesh = builder.mesh(straw, worldGroup);
|
|
136
|
+
mesh.position.set(x, ground(x, z), z);
|
|
137
|
+
mesh.castShadow = mesh.receiveShadow = true;
|
|
138
|
+
mesh.updateMatrix();
|
|
139
|
+
};
|
|
140
|
+
for (let i = 0; i < 6; i++) {
|
|
141
|
+
const sx = -16.5 + (i % 3) * 1.45,
|
|
142
|
+
sz = 9.5 + Math.floor(i / 3) * 1.45;
|
|
143
|
+
stook(
|
|
144
|
+
builder => props.sheaf(builder, random, C(0xcdb97c, 0.12, random), C(0xc29a45, 0.13, random), random() * 6.28, random(), false),
|
|
145
|
+
sx,
|
|
146
|
+
sz,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
stook(builder => props.haycock(builder, false), -20.5, 11);
|
|
150
|
+
|
|
151
|
+
// The plant kit's trees arcing behind the clearing and beside the pond.
|
|
152
|
+
const tints = createPlantTints({ fbm, vnoise, hash });
|
|
153
|
+
const trees = createTrees({ hash, ...tints, seed });
|
|
154
|
+
const { broadleaf } = createBroadleaf(tints);
|
|
155
|
+
const { shrubParts } = createShrubs({ hash, ...tints });
|
|
156
|
+
const leafy = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.86, side: THREE.DoubleSide });
|
|
157
|
+
const plant = (parts, x, z, scale = 1) => {
|
|
158
|
+
const mesh = new THREE.Mesh(parts.isBufferGeometry ? parts : partsGeometry(parts.near ?? parts), leafy);
|
|
159
|
+
mesh.position.set(x, ground(x, z) - 0.08, z);
|
|
160
|
+
mesh.scale.setScalar(scale);
|
|
161
|
+
mesh.rotation.y = random() * Math.PI * 2;
|
|
162
|
+
mesh.castShadow = mesh.receiveShadow = true;
|
|
163
|
+
worldGroup.add(mesh);
|
|
164
|
+
};
|
|
165
|
+
const grove = [
|
|
166
|
+
[trees.conifer(), -24, -14, 1.1],
|
|
167
|
+
[broadleaf(), -11, -15, 1.05],
|
|
168
|
+
[trees.cedar(0), 2, -16, 0.88],
|
|
169
|
+
[trees.acacia(), 16, -13, 1.0],
|
|
170
|
+
[trees.thornTree(), 27, -6, 1.0],
|
|
171
|
+
[trees.burntTree(), 29, 12, 1.05],
|
|
172
|
+
[broadleaf(), 13, 16, 0.92],
|
|
173
|
+
[trees.conifer(), -4, -22, 1.2],
|
|
174
|
+
[trees.cedar(0), -20, -21, 0.95],
|
|
175
|
+
];
|
|
176
|
+
for (const [parts, x, z, scale] of grove) plant(parts, x, z, scale);
|
|
177
|
+
|
|
178
|
+
// Shrubs and grass tussocks across the meadow and pond banks.
|
|
179
|
+
const shrub = {
|
|
180
|
+
stems: 6,
|
|
181
|
+
lengths: [0.42, 0.72],
|
|
182
|
+
leans: [0.6, 1.15],
|
|
183
|
+
root: 0.04,
|
|
184
|
+
wood: 3,
|
|
185
|
+
leaf: 0.13,
|
|
186
|
+
leaves: 5,
|
|
187
|
+
splay: 0.95,
|
|
188
|
+
cluster: 2,
|
|
189
|
+
crown: 9,
|
|
190
|
+
heart: 2,
|
|
191
|
+
bark: 0x7b6d59,
|
|
192
|
+
greens: [0x6e7a4a, 0x5f6a42, 0x7a8256],
|
|
193
|
+
dead: 0,
|
|
194
|
+
stalks: 0,
|
|
195
|
+
far: 5,
|
|
196
|
+
};
|
|
197
|
+
for (let i = 0; i < 20; i++) {
|
|
198
|
+
const sx = (random() - 0.5) * 66,
|
|
199
|
+
sz = -20 + random() * 38;
|
|
200
|
+
if (Math.hypot(sx + 6, sz - 2) < 9 || Math.hypot(sx - POND.x, sz - POND.z) < POND.r * 0.8) continue;
|
|
201
|
+
plant(shrubParts(shrub, mulberry32(seed + i)), sx, sz, 1.2 + random() * 0.9);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const tuftGeo = tussockGeometry(mulberry32(seed * 7), false, PLAIN_GRASS);
|
|
205
|
+
const tufts = new THREE.InstancedMesh(tuftGeo, leafy, 110);
|
|
206
|
+
const dummy = new THREE.Object3D();
|
|
207
|
+
let tc = 0;
|
|
208
|
+
for (let i = 0; i < 160 && tc < 110; i++) {
|
|
209
|
+
const tx = (random() - 0.5) * 76,
|
|
210
|
+
tz = -22 + random() * 44;
|
|
211
|
+
if (Math.hypot(tx - POND.x, tz - POND.z) < POND.r * 0.85) continue;
|
|
212
|
+
dummy.position.set(tx, ground(tx, tz), tz);
|
|
213
|
+
dummy.rotation.set(0, random() * Math.PI * 2, 0);
|
|
214
|
+
dummy.scale.setScalar(0.85 + random() * 0.6);
|
|
215
|
+
dummy.updateMatrix();
|
|
216
|
+
tufts.setMatrixAt(tc++, dummy.matrix);
|
|
217
|
+
}
|
|
218
|
+
tufts.count = tc;
|
|
219
|
+
tufts.instanceMatrix.needsUpdate = true;
|
|
220
|
+
worldGroup.add(tufts);
|
|
221
|
+
|
|
222
|
+
// Animated wind-swaying reed beds ringing the shallow pond margin.
|
|
223
|
+
const uTime = new THREE.Uniform(0);
|
|
224
|
+
const uWind = new THREE.Uniform(new THREE.Vector3(1.1, 0, 0.5));
|
|
225
|
+
const { reedModels, meshReedBeds } = createReeds({ uTime, uWind });
|
|
226
|
+
const bed = [];
|
|
227
|
+
for (let i = 0; i < 65; i++) {
|
|
228
|
+
const a = (i / 65) * Math.PI * 2 + random() * 0.25;
|
|
229
|
+
const r = POND.r * (0.72 + random() * 0.28);
|
|
230
|
+
const rx = POND.x + Math.cos(a) * r,
|
|
231
|
+
rz = POND.z + Math.sin(a) * r * 0.86;
|
|
232
|
+
bed.push([rx, Math.max(WATER_Y - 0.25, ground(rx, rz)), rz, 0.85 + random() * 0.55, random() * 6.28, 0.8 + random() * 0.2]);
|
|
233
|
+
}
|
|
234
|
+
meshReedBeds(worldGroup, [bed], reedModels(mulberry32(seed)));
|
|
235
|
+
|
|
236
|
+
scene.background = makeSky(noise, { sunDir: [-0.72, 0.34, 0.6] });
|
|
237
|
+
scene.fog = new THREE.FogExp2(0xd3ddd7, 0.0024);
|
|
238
|
+
setupSun(scene, renderer, {
|
|
239
|
+
sunPosition: [-52, 34, 44],
|
|
240
|
+
shadowRadius: 48,
|
|
241
|
+
shadowFar: 170,
|
|
242
|
+
staticShadows: true,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const views = {
|
|
246
|
+
clearing: { eye: [-2, 13, 37], target: [-1, 2.5, -2.5] },
|
|
247
|
+
camp: { eye: [-18, 6.2, 16], target: [-8, 2.0, -1] },
|
|
248
|
+
grove: { eye: [10, 7.5, 21], target: [18, 2.4, -1] },
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const rig = createOrbitRig({
|
|
252
|
+
camera,
|
|
253
|
+
canvas,
|
|
254
|
+
renderer,
|
|
255
|
+
scene,
|
|
256
|
+
views,
|
|
257
|
+
initialView: 'clearing',
|
|
258
|
+
groundAt: ground,
|
|
259
|
+
minClearance: 1.2,
|
|
260
|
+
minDistance: 5,
|
|
261
|
+
maxDistance: 130,
|
|
262
|
+
onDraw: () => {},
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const clock = new THREE.Timer();
|
|
266
|
+
function animate() {
|
|
267
|
+
clock.update();
|
|
268
|
+
const t = clock.getElapsed();
|
|
269
|
+
uTime.value = t;
|
|
270
|
+
waterTime.value = t;
|
|
271
|
+
rig.clampCamera();
|
|
272
|
+
renderer.render(scene, camera);
|
|
273
|
+
requestAnimationFrame(animate);
|
|
274
|
+
}
|
|
275
|
+
animate();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="theme-color" content="#152c2c" />
|
|
7
|
+
<title>Rooms · Roamwright</title>
|
|
8
|
+
<link rel="stylesheet" href="./showcase.css" />
|
|
9
|
+
<script type="importmap">
|
|
10
|
+
{
|
|
11
|
+
"imports": {
|
|
12
|
+
"three": "../node_modules/three/build/three.module.js",
|
|
13
|
+
"three/addons/": "../node_modules/three/examples/jsm/",
|
|
14
|
+
"roamwright": "../index.js",
|
|
15
|
+
"roamwright/": "../"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<canvas tabindex="0" aria-label="A furnished beamed room and a domed arcaded hall with baked window, lamp and hearth light"></canvas>
|
|
22
|
+
<header>
|
|
23
|
+
<a class="back" href="../index.html"><span aria-hidden="true">←</span> Roamwright</a>
|
|
24
|
+
<div class="meta">
|
|
25
|
+
<a class="source" href="https://github.com/enestaylan/roamwright/blob/main/examples/rooms.js">Source</a>
|
|
26
|
+
<form method="get">
|
|
27
|
+
<label for="seed">Seed</label>
|
|
28
|
+
<input id="seed" name="seed" type="number" step="1" min="-2147483648" max="2147483647" value="42" required />
|
|
29
|
+
<button type="submit" title="Retone interiors with this seed" aria-label="Retone interiors with this seed">→</button>
|
|
30
|
+
</form>
|
|
31
|
+
</div>
|
|
32
|
+
</header>
|
|
33
|
+
<footer>
|
|
34
|
+
<div class="caption">
|
|
35
|
+
<h1>Rooms</h1>
|
|
36
|
+
<p>Procedural interiors from the room kit — beamed room and domed arcaded hall lit from windows, hearth and hanging lamps.</p>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="tools">
|
|
39
|
+
<div class="views" role="group" aria-label="Interior space">
|
|
40
|
+
<button type="button" data-room="small" aria-pressed="true">Small room</button>
|
|
41
|
+
<button type="button" data-room="hall" aria-pressed="false">Domed hall</button>
|
|
42
|
+
</div>
|
|
43
|
+
<button type="button" class="action" id="hour" aria-pressed="false">Night</button>
|
|
44
|
+
</div>
|
|
45
|
+
</footer>
|
|
46
|
+
<script type="module" src="./rooms.js"></script>
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
+
import { createRoomKit, createRoomMaterials, finishRoom } from 'roamwright';
|
|
4
|
+
import { createParticleEmitters } from '../rendering/particle-emitters.js';
|
|
5
|
+
import { createParticleSystem } from '../rendering/particles.js';
|
|
6
|
+
import { updateRoomLight } from '../rendering/room-light.js';
|
|
7
|
+
import { perspectivePointScale } from '../rendering/viewport.js';
|
|
8
|
+
import { createSiteSchedule } from '../runtime/effect-sites.js';
|
|
9
|
+
import { bindKeyboardOrbit, initExample } from './stage.js';
|
|
10
|
+
import { makeParticleNoiseTexture } from './stage-kits.js';
|
|
11
|
+
|
|
12
|
+
const { canvas, renderer, camera, scene, worldGroup, seed, noise, hash, shapes } = initExample({
|
|
13
|
+
fallbackSeed: 42,
|
|
14
|
+
fov: 50,
|
|
15
|
+
});
|
|
16
|
+
const fireSites = [];
|
|
17
|
+
const kit = createRoomKit({ shapes, hash, addSite: site => fireSites.push(site) });
|
|
18
|
+
|
|
19
|
+
// Soft daylight sky colour for the glazed window panes so crown glass reads as sky light rather than pure white.
|
|
20
|
+
const DAY_PANE_SKY = new THREE.Color(0.32, 0.48, 0.68);
|
|
21
|
+
const windowSky = { uSky: { value: DAY_PANE_SKY.clone() }, uNight: { value: 0 } };
|
|
22
|
+
const materials = createRoomMaterials({ sky: windowSky });
|
|
23
|
+
|
|
24
|
+
// The sky the rooms are lit by: warm afternoon sun, or a moonlit night.
|
|
25
|
+
const sky = {
|
|
26
|
+
day: 1,
|
|
27
|
+
dusk: 0.12,
|
|
28
|
+
wet: 0,
|
|
29
|
+
dust: 0,
|
|
30
|
+
nightSky: 0.7,
|
|
31
|
+
horizon: new THREE.Color(0.78, 0.84, 0.9),
|
|
32
|
+
zenith: new THREE.Color(0.38, 0.56, 0.86),
|
|
33
|
+
sunColor: new THREE.Color(1, 0.93, 0.82),
|
|
34
|
+
sunDir: new THREE.Vector3(0.55, 0.56, 0.42).normalize(),
|
|
35
|
+
time: 0,
|
|
36
|
+
};
|
|
37
|
+
const outdoors = new THREE.HemisphereLight(0xeef4fa, 0x7c6a52, 0.86);
|
|
38
|
+
scene.add(outdoors);
|
|
39
|
+
const roomFill = new THREE.PointLight(0xffe8cb, 2.2, 12, 1.4);
|
|
40
|
+
roomFill.position.set(1.2, 2.1, 0.2);
|
|
41
|
+
scene.add(roomFill);
|
|
42
|
+
const hearthLight = new THREE.PointLight(0xff9c44, 5.2, 11, 1.5);
|
|
43
|
+
scene.add(hearthLight);
|
|
44
|
+
|
|
45
|
+
const hourBtn = document.getElementById('hour');
|
|
46
|
+
function setHour(night) {
|
|
47
|
+
sky.day = night ? 0 : 1;
|
|
48
|
+
sky.sunDir.set(0.55, night ? -0.3 : 0.56, 0.42).normalize();
|
|
49
|
+
outdoors.intensity = night ? 0.14 : 0.86;
|
|
50
|
+
roomFill.intensity = night ? 0.35 : 2.2;
|
|
51
|
+
windowSky.uNight.value = night ? 1 : 0;
|
|
52
|
+
hourBtn.setAttribute('aria-pressed', String(night));
|
|
53
|
+
hourBtn.textContent = night ? 'Day' : 'Night';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function smallRoom() {
|
|
57
|
+
const R = kit.startRoom('small', { x: 0, z: 0 }),
|
|
58
|
+
hx = 3.2,
|
|
59
|
+
hz = 2.6,
|
|
60
|
+
h = 2.9,
|
|
61
|
+
walls = { tone: 0xd4c3a6, low: 0xa69378, dado: 0.9, rail: true };
|
|
62
|
+
kit.boards(R, -hx, hx, -hz, hz);
|
|
63
|
+
kit.beamedCeiling(R, -hx, hx, -hz, hz, h);
|
|
64
|
+
const north = kit.wallRun(R, [-hx, -hz], [hx, -hz], h, [], walls);
|
|
65
|
+
kit.wallRun(R, [hx, -hz], [hx, hz], h, [{ at: 1.8, w: 1.35, h: 1.35, sill: 0.88, fill: kit.glazed({ shutters: true }) }], walls);
|
|
66
|
+
kit.wallRun(R, [hx, hz], [-hx, hz], h, [{ at: 4.6, w: 1.1, h: 2.1, sill: 0, fill: kit.doorLeaf({ open: 1.1 }) }], walls);
|
|
67
|
+
const westHoles = [{ at: 2.6, w: 0.9, h: 1.1, sill: 1.0, fill: kit.glazed({ panes: [3, 4] }) }],
|
|
68
|
+
west = kit.wallRun(R, [-hx, hz], [-hx, -hz], h, westHoles, walls);
|
|
69
|
+
kit.wainscot(R, west, 0, 2 * hz, 0.9, westHoles);
|
|
70
|
+
const mantel = kit.hearth(R, north, hx - 0.35, h, { wide: 1.85, open: 1.05, high: 0.98, fire: 0.46, light: 1.25 });
|
|
71
|
+
for (const dx of [-0.95, 0.25]) kit.candle(R, dx, mantel.y, -hz + 0.36, { stick: true });
|
|
72
|
+
// Place the laid table beside the sunlit east window so the hearth, bookshelves and window open cleanly toward the viewer.
|
|
73
|
+
kit.table(R, 1.95, 0.8, 1.35, 0.78, 0.76, -0.18);
|
|
74
|
+
kit.chair(R, 1.85, 0.15, -0.18);
|
|
75
|
+
kit.chair(R, 2.08, 1.45, Math.PI - 0.18, { arms: true });
|
|
76
|
+
kit.bench(R, -2.4, -0.5, 1.3, Math.PI / 2);
|
|
77
|
+
kit.candle(R, 1.65, 0.76, 0.76);
|
|
78
|
+
kit.jug(R, 2.05, 0.76, 0.7);
|
|
79
|
+
kit.tankard(R, 2.3, 0.76, 0.92, 1);
|
|
80
|
+
kit.shelves(R, 1.85, -hz + 0.22, 0, 1.55, 0.36, [0.5, 1.0, 1.5], (row, x, y, z) => kit.books(R, x, y, z, 0, 1.35, row + seed));
|
|
81
|
+
kit.barrel(R, -2.55, 0, 1.85);
|
|
82
|
+
kit.rug(R, -0.35, -0.65, 2.4, 1.7, 0x6a2a22, 0x2a2a3a);
|
|
83
|
+
kit.hangingLamp(R, 0.35, 2.25, -0.55, h - 0.24);
|
|
84
|
+
return finish(R, { name: 'A small room', spawn: { x: -2.45, z: 2.05, yaw: 0 }, bx: hx, bz: hz, ceiling: () => h });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function hall() {
|
|
88
|
+
const R = kit.startRoom('hall', { x: 60, z: 0 }),
|
|
89
|
+
hx = 9,
|
|
90
|
+
hz = 8,
|
|
91
|
+
h = 7,
|
|
92
|
+
nave = 5.5,
|
|
93
|
+
gallery = 4.2,
|
|
94
|
+
dome = { r: 3.4, drum: 1.4 },
|
|
95
|
+
walls = { tone: 0xd8ccb4, low: 0x7e6a54, dado: 1.2, rail: true, cornice: true },
|
|
96
|
+
tall = at => ({ at, w: 1.2, h: 2.4, sill: 1.3, fill: kit.glazed({ panes: [4, 7], bars: true }) });
|
|
97
|
+
kit.tiles(R, R.B.polished, -hx, hx, -hz, hz, 0, 0.6, (i, j) =>
|
|
98
|
+
i === 0 || j === 0 || i === 29 || j === 26 ? 0x8a7050 : (i + j) % 2 ? 0xd6cdb8 : 0x6e7a70,
|
|
99
|
+
);
|
|
100
|
+
kit.wallRun(
|
|
101
|
+
R,
|
|
102
|
+
[hx, hz],
|
|
103
|
+
[-hx, hz],
|
|
104
|
+
h,
|
|
105
|
+
[tall(4), { at: hx, w: 2.2, h: 3.6, sill: 0, fill: kit.doorLeaf({ open: 2.4 }) }, tall(2 * hx - 4)],
|
|
106
|
+
walls,
|
|
107
|
+
);
|
|
108
|
+
kit.wallRun(R, [-hx, hz], [-hx, -hz], h, [tall(4), tall(8), tall(12)], walls);
|
|
109
|
+
kit.wallRun(R, [-hx, -hz], [hx, -hz], h, [], walls);
|
|
110
|
+
kit.wallRun(R, [hx, -hz], [hx, hz], h, [tall(4), tall(8), tall(12)], walls);
|
|
111
|
+
kit.ceilingRound(R, -nave, nave, -hz, hz, h, 0, 0, dome.r + 0.15);
|
|
112
|
+
const top = kit.dome(R, 0, 0, dome.r, h, dome.drum, { windows: 3, segs: 24 });
|
|
113
|
+
for (const side of [-1, 1]) {
|
|
114
|
+
const middle = side * (nave + (hx - nave) / 2);
|
|
115
|
+
kit.plainCeiling(R, side > 0 ? nave : -hx, side > 0 ? hx : -nave, -hz, hz, h);
|
|
116
|
+
kit.put(R.B.wood, R, middle, gallery, 0, hx - nave, 0.2, 2 * hz, [0.2, 0.13, 0.08]);
|
|
117
|
+
kit.occludeRoom(R, middle, gallery, 0, hx - nave, 0.2, 2 * hz);
|
|
118
|
+
kit.arcade(R, { x: side * nave, from: -hz + 1.5, bay: 2.6, bays: 5, ends: [-hz, hz], spring: 2.8, gallery, ceiling: h });
|
|
119
|
+
}
|
|
120
|
+
const flight = { foot: 3.6, top: -nave, rise: gallery + 0.2 };
|
|
121
|
+
kit.stairFlight(R, { ...flight, from: -hz, to: -hz + 1.2, steps: 24 });
|
|
122
|
+
kit.stairBalustrade(R, { ...flight, side: -hz + 1.2, inward: -1 });
|
|
123
|
+
for (const z of [-4, 0, 4]) kit.hangingLantern(R, 0, 3.4, z, z === 0 ? top - 1 : h);
|
|
124
|
+
for (const side of [-1, 1]) for (const z of [-4, 2]) kit.hangingLantern(R, side * (nave + 1.7), 2.6, z, gallery);
|
|
125
|
+
kit.rug(R, 0, 4.5, 2.4, 5, 0x6a2a22, 0x22303a);
|
|
126
|
+
kit.bench(R, -2.4, 0, 2.4, Math.PI / 2);
|
|
127
|
+
kit.bench(R, 2.4, 0, 2.4, Math.PI / 2);
|
|
128
|
+
return finish(R, {
|
|
129
|
+
name: 'A hall',
|
|
130
|
+
spawn: { x: 0, z: hz - 1.5, yaw: 0 },
|
|
131
|
+
bx: hx,
|
|
132
|
+
bz: hz,
|
|
133
|
+
ceiling: (x, z) => (Math.hypot(x, z) < dome.r ? top - 1.2 : Math.abs(x) > nave ? gallery : h),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const spaces = [];
|
|
138
|
+
const finish = (R, def) =>
|
|
139
|
+
finishRoom(R, def, {
|
|
140
|
+
materials,
|
|
141
|
+
register: space => (worldGroup.add(space.group), spaces.push(space), space),
|
|
142
|
+
warm: async group => renderer.compile(group, camera),
|
|
143
|
+
updateLight: (runtime, dt) => updateRoomLight(runtime, dt, sky),
|
|
144
|
+
});
|
|
145
|
+
const rooms = { small: await smallRoom(), hall: await hall() };
|
|
146
|
+
|
|
147
|
+
// Real engine fire inside the small room's hearth, using the fire site emitted by kit.hearth().
|
|
148
|
+
const noiseTexture = makeParticleNoiseTexture(noise, 128);
|
|
149
|
+
const pointScale = { value: 520 };
|
|
150
|
+
let fireClock = 0;
|
|
151
|
+
const particles = createParticleSystem({
|
|
152
|
+
scene: worldGroup,
|
|
153
|
+
pointScale,
|
|
154
|
+
elapsed: () => fireClock,
|
|
155
|
+
noiseTexture: () => noiseTexture,
|
|
156
|
+
sceneDepth: { uDepth: { value: null }, uDepthPx: { value: new THREE.Vector2(1, 1) }, uSoft: { value: 0 } },
|
|
157
|
+
});
|
|
158
|
+
const pools = { alpha: particles.makeParticles(400, false), additive: particles.makeParticles(900, true) };
|
|
159
|
+
const emit = createParticleEmitters({ spawn: particles.spawn, put: particles.pSpawn });
|
|
160
|
+
const schedule = createSiteSchedule();
|
|
161
|
+
const hearthSite = fireSites[0];
|
|
162
|
+
if (hearthSite) {
|
|
163
|
+
hearthSite.y = 0.18;
|
|
164
|
+
hearthLight.position.set(hearthSite.x, hearthSite.y + 0.36, hearthSite.z + 0.32);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const emitHearth = s => emit.fire(s, pools.additive, pools.alpha);
|
|
168
|
+
function stepFire(dt) {
|
|
169
|
+
fireClock += dt;
|
|
170
|
+
const U = particles.fxU;
|
|
171
|
+
U.uTime.value = fireClock;
|
|
172
|
+
U.uFogD.value = 0;
|
|
173
|
+
U.uLight.value = 0.6;
|
|
174
|
+
U.uWind.value.set(0.04, 0.02);
|
|
175
|
+
if (hearthSite) {
|
|
176
|
+
schedule.run(fireSites, activeRoom, camera.position.x, camera.position.z, dt, 1, 1, emitHearth);
|
|
177
|
+
hearthLight.intensity = 5.0 + 0.65 * Math.sin(fireClock * 8.3) + 0.35 * Math.sin(fireClock * 15.7);
|
|
178
|
+
}
|
|
179
|
+
particles.pFlush(pools.additive);
|
|
180
|
+
particles.pFlush(pools.alpha);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
scene.background = new THREE.Color(0x1c1a17);
|
|
184
|
+
const controls = new OrbitControls(camera, canvas);
|
|
185
|
+
controls.enablePan = false;
|
|
186
|
+
bindKeyboardOrbit({ canvas, camera, controls, minDistance: 0.6, maxDistance: 6.5 });
|
|
187
|
+
|
|
188
|
+
let activeRoom = 'small';
|
|
189
|
+
function enter(name) {
|
|
190
|
+
activeRoom = name;
|
|
191
|
+
const space = rooms[name],
|
|
192
|
+
s = space.spawn,
|
|
193
|
+
inside = name === 'hall' ? 6.5 : 3.2;
|
|
194
|
+
if (name === 'small') {
|
|
195
|
+
const narrow = canvas.clientWidth < canvas.clientHeight;
|
|
196
|
+
camera.position.set(-2.35, 1.48, 2.02);
|
|
197
|
+
controls.target.set(narrow ? 0.15 : 0.75, 1.08, -1.65);
|
|
198
|
+
roomFill.position.set(1.2, 2.1, 0.2);
|
|
199
|
+
} else {
|
|
200
|
+
camera.position.set(s.x, 2.2, s.z);
|
|
201
|
+
controls.target.set(space.cx, 2.6, space.cz);
|
|
202
|
+
roomFill.position.set(space.cx, 5.2, space.cz);
|
|
203
|
+
}
|
|
204
|
+
controls.maxDistance = inside;
|
|
205
|
+
controls.minDistance = 0.6;
|
|
206
|
+
controls.update();
|
|
207
|
+
for (const button of document.querySelectorAll('[data-room]')) button.setAttribute('aria-pressed', String(button.dataset.room === name));
|
|
208
|
+
space.arrive();
|
|
209
|
+
}
|
|
210
|
+
for (const button of document.querySelectorAll('[data-room]')) button.addEventListener('click', () => enter(button.dataset.room));
|
|
211
|
+
let night = new URL(location.href).searchParams.has('night');
|
|
212
|
+
hourBtn.addEventListener('click', () => setHour((night = !night)));
|
|
213
|
+
setHour(night);
|
|
214
|
+
enter('small');
|
|
215
|
+
|
|
216
|
+
function resize() {
|
|
217
|
+
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
|
|
218
|
+
renderer.setSize(canvas.clientWidth, canvas.clientHeight, false);
|
|
219
|
+
camera.aspect = canvas.clientWidth / Math.max(1, canvas.clientHeight);
|
|
220
|
+
const baseFov = activeRoom === 'hall' ? 50 : 54;
|
|
221
|
+
camera.fov = THREE.MathUtils.clamp(baseFov / Math.min(camera.aspect, 1), baseFov, 74);
|
|
222
|
+
camera.updateProjectionMatrix();
|
|
223
|
+
pointScale.value = perspectivePointScale(canvas.clientHeight * Math.min(devicePixelRatio, 2), camera.fov);
|
|
224
|
+
}
|
|
225
|
+
window.addEventListener('resize', resize);
|
|
226
|
+
resize();
|
|
227
|
+
|
|
228
|
+
// Pre-warm the hearth flames and embers so the fireplace is alive on frame 1.
|
|
229
|
+
for (let i = 0; i < 45; i++) stepFire(1 / 30);
|
|
230
|
+
|
|
231
|
+
const clock = new THREE.Timer();
|
|
232
|
+
function frame() {
|
|
233
|
+
clock.update();
|
|
234
|
+
const dt = Math.min(clock.getDelta(), 0.1);
|
|
235
|
+
sky.time += dt;
|
|
236
|
+
for (const space of spaces) space.tick(dt);
|
|
237
|
+
stepFire(dt);
|
|
238
|
+
controls.update();
|
|
239
|
+
renderer.render(scene, camera);
|
|
240
|
+
requestAnimationFrame(frame);
|
|
241
|
+
}
|
|
242
|
+
frame();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="theme-color" content="#152c2c" />
|
|
7
|
+
<title>Harbour of ships · Roamwright</title>
|
|
8
|
+
<link rel="stylesheet" href="./showcase.css" />
|
|
9
|
+
<script type="importmap">
|
|
10
|
+
{
|
|
11
|
+
"imports": {
|
|
12
|
+
"three": "../node_modules/three/build/three.module.js",
|
|
13
|
+
"three/addons/": "../node_modules/three/examples/jsm/",
|
|
14
|
+
"roamwright": "../index.js",
|
|
15
|
+
"roamwright/": "../"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<canvas
|
|
22
|
+
tabindex="0"
|
|
23
|
+
aria-label="A sunlit stone harbour with four ship presets moored to a quay and two boats sailing offshore"
|
|
24
|
+
></canvas>
|
|
25
|
+
<header>
|
|
26
|
+
<a class="back" href="../index.html"><span aria-hidden="true">←</span> Roamwright</a>
|
|
27
|
+
<div class="meta">
|
|
28
|
+
<a class="source" href="https://github.com/enestaylan/roamwright/blob/main/examples/ships.js">Source</a>
|
|
29
|
+
<form method="get">
|
|
30
|
+
<label for="seed">Seed</label>
|
|
31
|
+
<input id="seed" name="seed" type="number" step="1" min="-2147483648" max="2147483647" value="42" required />
|
|
32
|
+
<button type="submit" title="Rebuild harbour with this seed" aria-label="Rebuild harbour with this seed">→</button>
|
|
33
|
+
</form>
|
|
34
|
+
</div>
|
|
35
|
+
</header>
|
|
36
|
+
<footer>
|
|
37
|
+
<div class="caption">
|
|
38
|
+
<h1>Harbour of ships</h1>
|
|
39
|
+
<p>Every preset of the ship kit moored stern-on to a stone quay while a cog and rowing boat tack offshore.</p>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="tools">
|
|
42
|
+
<div class="views" role="group" aria-label="Camera viewpoint">
|
|
43
|
+
<button type="button" data-view="harbour" aria-pressed="true">Harbour</button>
|
|
44
|
+
<button type="button" data-view="quayside" aria-pressed="false">Quayside</button>
|
|
45
|
+
<button type="button" data-view="sailing" aria-pressed="false">Open bay</button>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</footer>
|
|
49
|
+
<script type="module" src="./ships.js"></script>
|
|
50
|
+
</body>
|
|
51
|
+
</html>
|