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,110 @@
|
|
|
1
|
+
// A settlement's far version: its buildings as instanced unit shapes sharing its materials (walls, more walls for houses built
|
|
2
|
+
// otherwise, and roofs; gable ends in plaster of their walls' colour under roofs drawn as `eaves`), each part able to be hidden
|
|
3
|
+
// on its own while a detailed block stands over it (`createQuarterStream`), and a whole-town mesh for the distance.
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { GB, geometryView, meshOf } from '../geometry/builder.js';
|
|
6
|
+
import { TRS } from '../geometry/primitives.js';
|
|
7
|
+
import { createInstanceVisibility } from '../geometry/instance-visibility.js';
|
|
8
|
+
|
|
9
|
+
/** The kinds of a town's parts, each one of the unit shapes. */
|
|
10
|
+
export const TOWN_PARTS = ['box', 'cyl', 'prism', 'eaves', 'gable', 'pyr', 'cone', 'dome'];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The far versions of a world's settlements.
|
|
14
|
+
* @param {object} o
|
|
15
|
+
* @param {Object<string, import('three').BufferGeometry>} o.shapes - The world's unit shapes (`createUnitShapes`), one to each
|
|
16
|
+
* of {@link TOWN_PARTS}: every town draws them, each part through a view of its own.
|
|
17
|
+
* @param {() => import('three').Material} o.farMaterial - The material of a whole-town mesh for the distance (read when built).
|
|
18
|
+
* @param {() => import('three').Material} o.gableMaterial - The material of the gable ends (read when built).
|
|
19
|
+
* @param {object[]} [o.towns] - The list every town is kept in (for a map of their footprints); made here if not given.
|
|
20
|
+
* @returns {{ Town: Function, towns: object[] }} `Town(wallMaterial, roofMaterial, ...moreWalls)`: its `items` by part kind, as
|
|
21
|
+
* data a worker can build (`add`, `gableRoof`); `build(parent)` makes its instanced meshes; `buildFar(parent, roofs)` its mesh for
|
|
22
|
+
* the distance (the arrays `roofs`, or a box over every third wall); `hide(ids, on)` hides the parts `ids` (`[kind, index]`) or
|
|
23
|
+
* shows them again; `setFar(far)` shows the mesh for the distance in place of its parts. `Town.all` is `towns`.
|
|
24
|
+
*/
|
|
25
|
+
export function createTowns({ shapes, farMaterial, gableMaterial, towns = [] }) {
|
|
26
|
+
const _cc = new THREE.Color();
|
|
27
|
+
class Town {
|
|
28
|
+
static all = towns;
|
|
29
|
+
constructor(wallMat, roofMat, ...moreWalls) {
|
|
30
|
+
this.wallMats = [wallMat, ...moreWalls];
|
|
31
|
+
this.roofMat = roofMat;
|
|
32
|
+
this.items = Object.fromEntries(TOWN_PARTS.map(kind => [kind, []]));
|
|
33
|
+
this.meshes = [];
|
|
34
|
+
this.slots = {}; // each part's instanced mesh and its index there, by type: [mesh, index] per part
|
|
35
|
+
this.isFar = false;
|
|
36
|
+
towns.push(this);
|
|
37
|
+
}
|
|
38
|
+
// A part; `wall` puts a wall (box or cylinder) in another of the town's wall materials: true or 1 the second, 2 the third...
|
|
39
|
+
add(type, x, y, z, sx, sy, sz, ry, col, rx = 0, rz = 0, wall = 0) {
|
|
40
|
+
const item = { x, y, z, sx, sy, sz, ry, rx, rz, col };
|
|
41
|
+
if (wall) item.wall = +wall;
|
|
42
|
+
this.items[type].push(item);
|
|
43
|
+
return [type, this.items[type].length - 1];
|
|
44
|
+
}
|
|
45
|
+
// A gable roof over walls `span` across and `len` long: its slopes in the roof's colour, overhanging by `over`, and its two
|
|
46
|
+
// gable ends in the walls' own colour (as a house's are built near); the two parts' ids.
|
|
47
|
+
gableRoof(x, y, z, span, rise, len, ry, roofCol, wallCol, over, rz = 0) {
|
|
48
|
+
return [
|
|
49
|
+
this.add('eaves', x, y, z, span + over, rise, len + over, ry, roofCol, 0, rz),
|
|
50
|
+
this.add('gable', x, y, z, span, rise - 0.05, len, ry, wallCol, 0, rz),
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
build(parent) {
|
|
54
|
+
for (const type in this.items) {
|
|
55
|
+
const list = this.items[type],
|
|
56
|
+
wall = type === 'box' || type === 'cyl',
|
|
57
|
+
slots = (this.slots[type] = new Array(list.length));
|
|
58
|
+
for (let k = 0; k < (wall ? this.wallMats.length : 1); k++) {
|
|
59
|
+
const material = wall ? this.wallMats[k] : type === 'gable' ? gableMaterial() : this.roofMat;
|
|
60
|
+
let count = 0;
|
|
61
|
+
for (let i = 0; i < list.length; i++) if (!wall || (list[i].wall || 0) === k) count++;
|
|
62
|
+
if (!count) continue;
|
|
63
|
+
// every town draws the same unit shapes, each part through a view of its own (geometryView)
|
|
64
|
+
const im = new THREE.InstancedMesh(geometryView(shapes[type]), material, count);
|
|
65
|
+
let n = 0;
|
|
66
|
+
for (let i = 0; i < list.length; i++) {
|
|
67
|
+
const b = list[i];
|
|
68
|
+
if (wall && (b.wall || 0) !== k) continue;
|
|
69
|
+
im.setMatrixAt(n, TRS(b.x, b.y, b.z, b.sx, b.sy, b.sz, b.ry, b.rx, b.rz));
|
|
70
|
+
im.setColorAt(n, _cc.setRGB(b.col[0], b.col[1], b.col[2]));
|
|
71
|
+
slots[i] = { show: null, id: n++ };
|
|
72
|
+
}
|
|
73
|
+
im.castShadow = im.receiveShadow = true;
|
|
74
|
+
im.matrixAutoUpdate = false;
|
|
75
|
+
const show = createInstanceVisibility(im);
|
|
76
|
+
for (let i = 0; i < list.length; i++) if (!wall || (list[i].wall || 0) === k) slots[i].show = show;
|
|
77
|
+
parent.add(im);
|
|
78
|
+
this.meshes.push(im);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Only settlements with a whole-town distance switch need this mesh.
|
|
83
|
+
buildFar(parent, distantRoofs) {
|
|
84
|
+
if (distantRoofs) this.far = meshOf(distantRoofs, farMaterial(), parent, false);
|
|
85
|
+
else {
|
|
86
|
+
const gb = new GB(),
|
|
87
|
+
boxes = this.items.box;
|
|
88
|
+
for (let i = 0; i < boxes.length; i += 3) {
|
|
89
|
+
const b = boxes[i];
|
|
90
|
+
gb.add(shapes.box, b.col, TRS(b.x, b.y, b.z, b.sx * 1.75, b.sy * 1.15, b.sz * 1.75, b.ry));
|
|
91
|
+
}
|
|
92
|
+
this.far = gb.mesh(farMaterial(), parent, false);
|
|
93
|
+
}
|
|
94
|
+
this.far.visible = false;
|
|
95
|
+
}
|
|
96
|
+
hide(ids, on) {
|
|
97
|
+
for (const [type, i] of ids) {
|
|
98
|
+
const slot = this.slots[type][i];
|
|
99
|
+
slot.show(slot.id, !on);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
setFar(f) {
|
|
103
|
+
if (f === this.isFar) return;
|
|
104
|
+
this.isFar = f;
|
|
105
|
+
for (const m of this.meshes) m.visible = !f;
|
|
106
|
+
this.far.visible = f;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { Town, towns };
|
|
110
|
+
}
|
|
@@ -21,6 +21,7 @@ function meshKind(object) {
|
|
|
21
21
|
if (attributes.uv2) key += ':uv2';
|
|
22
22
|
if (attributes.uv3) key += ':uv3';
|
|
23
23
|
if (attributes.tangent) key += ':tangent';
|
|
24
|
+
if (!attributes.normal) key += ':flat';
|
|
24
25
|
if (attributes.color?.itemSize === 4) key += ':rgba';
|
|
25
26
|
return key;
|
|
26
27
|
}
|
|
@@ -29,7 +30,10 @@ function representatives(root) {
|
|
|
29
30
|
const picked = new Map();
|
|
30
31
|
root.traverse(object => {
|
|
31
32
|
if (!(object.isMesh || object.isPoints || object.isLine || object.isSprite) || !object.material) return;
|
|
32
|
-
|
|
33
|
+
// Empty placeholder geometries (e.g. an unpopulated PieceBatch or pending worker mesh) cannot be drawn and lack
|
|
34
|
+
// vertex normals, which causes Three.js to compile an unwanted FLAT_SHADED program variant.
|
|
35
|
+
if (!object.geometry?.attributes?.position) return;
|
|
36
|
+
const materials = Array.isArray(object.material) ? object.material.map(material => material.uuid).join(',') : object.material.uuid;
|
|
33
37
|
const key = materials + ':' + meshKind(object);
|
|
34
38
|
if (!picked.has(key)) picked.set(key, object);
|
|
35
39
|
});
|
|
@@ -40,7 +44,7 @@ const shadowSide = [THREE.BackSide, THREE.FrontSide, THREE.DoubleSide];
|
|
|
40
44
|
|
|
41
45
|
// Compile a group in its lighting environment, including material overrides and offscreen passes.
|
|
42
46
|
// All scratch resources and readiness polling belong to this renderer instance.
|
|
43
|
-
export function createShaderWarmup({renderer, scene, camera, postMaterials = () => [], pollIntervalMs = 10}) {
|
|
47
|
+
export function createShaderWarmup({ renderer, scene, camera, postMaterials = () => [], pollIntervalMs = 10 }) {
|
|
44
48
|
const target = new THREE.WebGLRenderTarget(1, 1);
|
|
45
49
|
const quad = new THREE.Mesh(new THREE.PlaneGeometry(2, 2), []);
|
|
46
50
|
const twins = new Map();
|
|
@@ -60,26 +64,53 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
60
64
|
}
|
|
61
65
|
if (entry.programs.size) continue;
|
|
62
66
|
pending.delete(entry);
|
|
63
|
-
entry.
|
|
67
|
+
entry.finish();
|
|
64
68
|
}
|
|
65
69
|
timer = pending.size ? setTimeout(poll, pollIntervalMs) : undefined;
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
function begin(traverse, root, view, lit, yieldIfReady = false) {
|
|
69
|
-
const materials = renderer.compile(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
function begin(traverse, root, view, lit, yieldIfReady = false, signal) {
|
|
73
|
+
const materials = renderer.compile(
|
|
74
|
+
{
|
|
75
|
+
traverse,
|
|
76
|
+
traverseVisible: visit => {
|
|
77
|
+
if (lit !== root) root.traverseVisible(visit);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
view,
|
|
81
|
+
lit,
|
|
82
|
+
);
|
|
73
83
|
const programs = new Set();
|
|
74
|
-
for (const
|
|
75
|
-
const variants = renderer.properties.get(
|
|
76
|
-
if (variants)
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
for (const material of materials) {
|
|
85
|
+
const variants = renderer.properties.get(material).programs;
|
|
86
|
+
if (variants)
|
|
87
|
+
for (const program of variants.values()) {
|
|
88
|
+
if (!ready.has(program)) programs.add(program);
|
|
89
|
+
}
|
|
79
90
|
}
|
|
80
91
|
if (!programs.size && !yieldIfReady) return Promise.resolve();
|
|
81
|
-
return new Promise(resolve => {
|
|
82
|
-
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const entry = {
|
|
94
|
+
programs,
|
|
95
|
+
finish() {
|
|
96
|
+
signal?.removeEventListener('abort', abort);
|
|
97
|
+
resolve();
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
function abort() {
|
|
101
|
+
pending.delete(entry);
|
|
102
|
+
if (!pending.size) {
|
|
103
|
+
clearTimeout(timer);
|
|
104
|
+
timer = undefined;
|
|
105
|
+
}
|
|
106
|
+
reject(signal.reason);
|
|
107
|
+
}
|
|
108
|
+
if (signal?.aborted) {
|
|
109
|
+
abort();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
113
|
+
pending.add(entry);
|
|
83
114
|
if (timer === undefined) timer = setTimeout(poll, 0);
|
|
84
115
|
});
|
|
85
116
|
}
|
|
@@ -89,8 +120,11 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
89
120
|
const face = renderer.getActiveCubeFace();
|
|
90
121
|
const level = renderer.getActiveMipmapLevel();
|
|
91
122
|
renderer.setRenderTarget(into);
|
|
92
|
-
try {
|
|
93
|
-
|
|
123
|
+
try {
|
|
124
|
+
return work();
|
|
125
|
+
} finally {
|
|
126
|
+
renderer.setRenderTarget(previous, face, level);
|
|
127
|
+
}
|
|
94
128
|
}
|
|
95
129
|
|
|
96
130
|
function compiled(root, view = camera, lit = root) {
|
|
@@ -98,9 +132,11 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
98
132
|
return begin(visit => objects.forEach(visit), root, view, lit);
|
|
99
133
|
}
|
|
100
134
|
|
|
101
|
-
async function compiledInTurn(root, view = camera, lit = scene, into = null) {
|
|
135
|
+
async function compiledInTurn(root, view = camera, lit = scene, into = null, signal) {
|
|
136
|
+
signal?.throwIfAborted();
|
|
102
137
|
for (const object of representatives(root)) {
|
|
103
|
-
|
|
138
|
+
signal?.throwIfAborted();
|
|
139
|
+
await withTarget(into, () => begin(visit => visit(object), root, view, lit, true, signal));
|
|
104
140
|
}
|
|
105
141
|
}
|
|
106
142
|
|
|
@@ -108,10 +144,18 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
108
144
|
const picked = new Map();
|
|
109
145
|
root.traverse(object => {
|
|
110
146
|
if (!(object.isMesh || object.isPoints || object.isLine) || !object.material) return;
|
|
147
|
+
if (!object.geometry?.attributes?.position) return;
|
|
111
148
|
if (!includeMaterialArrays && Array.isArray(object.material)) return;
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
114
|
-
const key = [
|
|
149
|
+
const standInMaterial = standIn(object);
|
|
150
|
+
if (!standInMaterial) return;
|
|
151
|
+
const key = [
|
|
152
|
+
standInMaterial.uuid,
|
|
153
|
+
standInMaterial.side,
|
|
154
|
+
!!standInMaterial.map,
|
|
155
|
+
!!standInMaterial.alphaMap,
|
|
156
|
+
standInMaterial.alphaTest > 0,
|
|
157
|
+
meshKind(object),
|
|
158
|
+
].join(':');
|
|
115
159
|
if (!picked.has(key)) picked.set(key, object);
|
|
116
160
|
});
|
|
117
161
|
return withTarget(into, () => {
|
|
@@ -120,16 +164,25 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
120
164
|
try {
|
|
121
165
|
// Three gathers the target scene's lights once per compile. Submit the entire override pass
|
|
122
166
|
// together, applying mutable stand-ins only while Three prepares their representative.
|
|
123
|
-
return begin(
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
167
|
+
return begin(
|
|
168
|
+
visit => {
|
|
169
|
+
for (const object of picked.values()) {
|
|
170
|
+
const material = object.material;
|
|
171
|
+
try {
|
|
172
|
+
object.material = standIn(object);
|
|
173
|
+
visit(object);
|
|
174
|
+
} finally {
|
|
175
|
+
object.material = material;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
scene,
|
|
180
|
+
view,
|
|
181
|
+
scene,
|
|
182
|
+
);
|
|
183
|
+
} finally {
|
|
184
|
+
scene.fog = previousFog;
|
|
185
|
+
}
|
|
133
186
|
});
|
|
134
187
|
}
|
|
135
188
|
|
|
@@ -141,9 +194,7 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
141
194
|
if (!twin) {
|
|
142
195
|
twin = twins.get(key);
|
|
143
196
|
if (!twin) {
|
|
144
|
-
twin = point ? new THREE.MeshDistanceMaterial() : new THREE.MeshDepthMaterial(
|
|
145
|
-
Number(THREE.REVISION) <= 170 ? {depthPacking: THREE.RGBADepthPacking} : {}
|
|
146
|
-
);
|
|
197
|
+
twin = point ? new THREE.MeshDistanceMaterial() : new THREE.MeshDepthMaterial();
|
|
147
198
|
twins.set(key, twin);
|
|
148
199
|
}
|
|
149
200
|
}
|
|
@@ -158,12 +209,14 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
158
209
|
return twin;
|
|
159
210
|
}
|
|
160
211
|
|
|
161
|
-
function warmShadowPass(root, {waitForPoint = true} = {}) {
|
|
212
|
+
function warmShadowPass(root, { waitForPoint = true } = {}) {
|
|
162
213
|
if (!renderer.shadowMap.enabled) return Promise.resolve();
|
|
163
|
-
const depth = warmStandIns(root,
|
|
214
|
+
const depth = warmStandIns(root, object => object.castShadow && shadowMaterial(object, false), camera, target, null);
|
|
164
215
|
let point;
|
|
165
|
-
scene.traverseVisible(
|
|
166
|
-
|
|
216
|
+
scene.traverseVisible(object => {
|
|
217
|
+
if (object.isPointLight && object.castShadow) point = true;
|
|
218
|
+
});
|
|
219
|
+
const distance = point && warmStandIns(root, object => object.castShadow && shadowMaterial(object, true), camera, target, null);
|
|
167
220
|
for (const twin of twins.values()) {
|
|
168
221
|
twin.map = twin.alphaMap = twin.displacementMap = twin.clippingPlanes = null;
|
|
169
222
|
}
|
|
@@ -171,7 +224,8 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
171
224
|
}
|
|
172
225
|
|
|
173
226
|
function warmPostPasses() {
|
|
174
|
-
const screen = [],
|
|
227
|
+
const screen = [],
|
|
228
|
+
offscreen = [];
|
|
175
229
|
for (const [material, into] of postMaterials()) (into === null ? screen : offscreen).push(material);
|
|
176
230
|
// Three prepares each material in a material array against the same render target.
|
|
177
231
|
const compilePass = (materials, into) => {
|
|
@@ -179,19 +233,22 @@ export function createShaderWarmup({renderer, scene, camera, postMaterials = ()
|
|
|
179
233
|
quad.material = materials;
|
|
180
234
|
return withTarget(into, () => compiled(quad, camera));
|
|
181
235
|
};
|
|
182
|
-
try {
|
|
183
|
-
|
|
236
|
+
try {
|
|
237
|
+
return Promise.all([compilePass(offscreen, target), compilePass(screen, null)]);
|
|
238
|
+
} finally {
|
|
239
|
+
quad.material = [];
|
|
240
|
+
}
|
|
184
241
|
}
|
|
185
242
|
|
|
186
243
|
function dispose() {
|
|
187
244
|
clearTimeout(timer);
|
|
188
245
|
timer = undefined;
|
|
189
|
-
for (const entry of pending) entry.
|
|
246
|
+
for (const entry of pending) entry.finish();
|
|
190
247
|
pending.clear();
|
|
191
248
|
quad.geometry.dispose();
|
|
192
249
|
target.dispose();
|
|
193
250
|
for (const twin of twins.values()) twin.dispose();
|
|
194
251
|
twins.clear();
|
|
195
252
|
}
|
|
196
|
-
return {compiled, compiledInTurn, compilingNow: () => pending.size > 0, warmStandIns, warmShadowPass, warmPostPasses, dispose};
|
|
253
|
+
return { compiled, compiledInTurn, compilingNow: () => pending.size > 0, warmStandIns, warmShadowPass, warmPostPasses, dispose };
|
|
197
254
|
}
|
|
@@ -10,10 +10,10 @@ export function createShadowSnap() {
|
|
|
10
10
|
if (right.lengthSq() < 1e-8) right.set(1, 0, 0);
|
|
11
11
|
right.normalize();
|
|
12
12
|
up.crossVectors(direction, right);
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
return out.set(0, 0, 0).addScaledVector(right,
|
|
13
|
+
const snappedRight = Math.round((x * right.x + y * right.y + z * right.z) / texelWidth) * texelWidth;
|
|
14
|
+
const snappedUp = Math.round((x * up.x + y * up.y + z * up.z) / texelHeight) * texelHeight;
|
|
15
|
+
const depth = x * direction.x + y * direction.y + z * direction.z;
|
|
16
|
+
return out.set(0, 0, 0).addScaledVector(right, snappedRight).addScaledVector(up, snappedUp).addScaledVector(direction, depth);
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import { placeOf, stillCastersFor } from './still-casters.js';
|
|
3
3
|
|
|
4
4
|
const handlers = new WeakMap();
|
|
5
5
|
let installed = 0;
|
|
@@ -15,32 +15,56 @@ function after(renderer, object, camera, shadowCamera, geometry, material, group
|
|
|
15
15
|
previousAfter.call(this, renderer, object, camera, shadowCamera, geometry, material, group);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function kindOf(
|
|
19
|
-
const morph =
|
|
18
|
+
function kindOf(object) {
|
|
19
|
+
const morph = object.geometry.morphAttributes;
|
|
20
20
|
if (morph.position || morph.normal || morph.color) return null;
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
21
|
+
if (object.isSkinnedMesh) return 'skinned';
|
|
22
|
+
if (object.isInstancedMesh) return object.instanceColor ? 'tinted' : 'instanced';
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Install per-renderer shadow depth hooks so instanced and skinned meshes share compact shadow
|
|
28
|
+
* materials and skip out-of-range shadow updates. Meshes with custom shadow hooks keep their own.
|
|
29
|
+
*
|
|
30
|
+
* @param {THREE.WebGLRenderer} renderer Target renderer to opt in.
|
|
31
|
+
* @param {object} [options]
|
|
32
|
+
* @param {object} [options.stillCasters] Optional still-caster registry from `stillCastersFor(renderer)` or `createStillCasters`.
|
|
33
|
+
* @returns {{ dispose: () => void }} Cleanup handle that uninstalls this renderer's hooks and frees shared materials.
|
|
34
|
+
*/
|
|
35
|
+
export function installShadowDepth(renderer, { stillCasters } = {}) {
|
|
28
36
|
if (handlers.has(renderer)) throw new Error('Shadow depth hooks already installed for this renderer');
|
|
29
|
-
const
|
|
30
|
-
const
|
|
37
|
+
const casters = stillCasters ?? stillCastersFor(renderer);
|
|
38
|
+
const { isStill, keptAway, still, layer: stillLayer } = casters;
|
|
39
|
+
const materials = { customDepthMaterial: {}, customDistanceMaterial: {} },
|
|
40
|
+
entries = new WeakMap();
|
|
41
|
+
const world = new THREE.Matrix4(),
|
|
42
|
+
instance = new THREE.Matrix4(),
|
|
43
|
+
sphere = new THREE.Sphere();
|
|
31
44
|
function noneNear(object, at, reach, entry) {
|
|
32
45
|
const matrix = object.instanceMatrix;
|
|
33
46
|
const geometry = object.geometry;
|
|
34
47
|
if (!geometry.boundingSphere) geometry.computeBoundingSphere();
|
|
35
48
|
const bounds = geometry.boundingSphere;
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
if (
|
|
50
|
+
entry.matrix === matrix &&
|
|
51
|
+
entry.version === matrix.version &&
|
|
52
|
+
entry.count === object.count &&
|
|
53
|
+
entry.reach === reach &&
|
|
54
|
+
entry.x === at.x &&
|
|
55
|
+
entry.y === at.y &&
|
|
56
|
+
entry.z === at.z &&
|
|
57
|
+
entry.bounds.equals(bounds) &&
|
|
58
|
+
entry.world.equals(object.matrixWorld)
|
|
59
|
+
)
|
|
60
|
+
return entry.away;
|
|
39
61
|
entry.matrix = matrix;
|
|
40
62
|
entry.version = matrix.version;
|
|
41
63
|
entry.count = object.count;
|
|
42
64
|
entry.reach = reach;
|
|
43
|
-
entry.x = at.x;
|
|
65
|
+
entry.x = at.x;
|
|
66
|
+
entry.y = at.y;
|
|
67
|
+
entry.z = at.z;
|
|
44
68
|
(entry.world ??= new THREE.Matrix4()).copy(object.matrixWorld);
|
|
45
69
|
(entry.bounds ??= new THREE.Sphere()).copy(bounds);
|
|
46
70
|
entry.away = true;
|
|
@@ -60,16 +84,16 @@ export function installShadowDepth(renderer) {
|
|
|
60
84
|
let entry = entries.get(object);
|
|
61
85
|
if (point && isStill(object)) {
|
|
62
86
|
const at = placeOf(object.matrixWorld.elements);
|
|
63
|
-
if (still.kept && object.keptIn === still.round && object.keptAs !== at) object.layers.disable(
|
|
87
|
+
if (still.kept && object.keptIn === still.round && object.keptAs !== at) object.layers.disable(stillLayer);
|
|
64
88
|
if (keptAway(object, at)) {
|
|
65
|
-
if (!entry) entries.set(object, entry = {});
|
|
89
|
+
if (!entry) entries.set(object, (entry = {}));
|
|
66
90
|
entry.range = geometry.drawRange.count;
|
|
67
91
|
geometry.drawRange.count = -1;
|
|
68
92
|
}
|
|
69
93
|
return;
|
|
70
94
|
}
|
|
71
95
|
if (!(object.isInstancedMesh || object.isSkinnedMesh)) return;
|
|
72
|
-
if (!entry) entries.set(object, entry = {});
|
|
96
|
+
if (!entry) entries.set(object, (entry = {}));
|
|
73
97
|
if (object.isInstancedMesh && point && noneNear(object, shadowCamera.position, shadowCamera.far, entry)) {
|
|
74
98
|
entry.countAside = object.count;
|
|
75
99
|
object.count = 0;
|
|
@@ -84,9 +108,7 @@ export function installShadowDepth(renderer) {
|
|
|
84
108
|
}
|
|
85
109
|
let shared = materials[field][kind];
|
|
86
110
|
if (!shared) {
|
|
87
|
-
shared = point ? new THREE.MeshDistanceMaterial() : new THREE.MeshDepthMaterial(
|
|
88
|
-
Number(THREE.REVISION) <= 170 ? {depthPacking: THREE.RGBADepthPacking} : {}
|
|
89
|
-
);
|
|
111
|
+
shared = point ? new THREE.MeshDistanceMaterial() : new THREE.MeshDepthMaterial();
|
|
90
112
|
materials[field][kind] = shared;
|
|
91
113
|
}
|
|
92
114
|
object[field] = entry[field] = shared;
|
|
@@ -109,14 +131,14 @@ export function installShadowDepth(renderer) {
|
|
|
109
131
|
THREE.Object3D.prototype.onBeforeShadow = before;
|
|
110
132
|
THREE.Object3D.prototype.onAfterShadow = after;
|
|
111
133
|
}
|
|
112
|
-
handlers.set(renderer, {begin, end});
|
|
134
|
+
handlers.set(renderer, { begin, end });
|
|
113
135
|
function dispose(root) {
|
|
114
136
|
if (!handlers.delete(renderer)) return;
|
|
115
|
-
root?.traverse(
|
|
116
|
-
const entry = entries.get(
|
|
137
|
+
root?.traverse(object => {
|
|
138
|
+
const entry = entries.get(object);
|
|
117
139
|
if (!entry) return;
|
|
118
|
-
for (const field of ['customDepthMaterial','customDistanceMaterial']) {
|
|
119
|
-
if (entry[field] &&
|
|
140
|
+
for (const field of ['customDepthMaterial', 'customDistanceMaterial']) {
|
|
141
|
+
if (entry[field] && object[field] === entry[field]) object[field] = undefined;
|
|
120
142
|
}
|
|
121
143
|
});
|
|
122
144
|
for (const group of Object.values(materials)) for (const material of Object.values(group)) material.dispose();
|
|
@@ -125,5 +147,5 @@ export function installShadowDepth(renderer) {
|
|
|
125
147
|
if (THREE.Object3D.prototype.onAfterShadow === after) THREE.Object3D.prototype.onAfterShadow = previousAfter;
|
|
126
148
|
}
|
|
127
149
|
}
|
|
128
|
-
return {dispose};
|
|
150
|
+
return { dispose };
|
|
129
151
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A ship of the kit as meshes on the page: her timber, rigging and canvas set or furled, a lateen yard built apart in both its
|
|
3
|
+
* poses, her riding light, and oars instanced to pull in time.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import * as THREE from 'three';
|
|
7
|
+
import { dim } from '../math/color.js';
|
|
8
|
+
import { sstep } from '../math/scalar.js';
|
|
9
|
+
import { GB, meshOf } from '../geometry/builder.js';
|
|
10
|
+
import { C } from '../geometry/primitives.js';
|
|
11
|
+
import { shipLines } from '../geometry/ship-lines.js';
|
|
12
|
+
import { gripOf, oarMatrix, oarPorts, oarPose } from '../geometry/ship-oars.js';
|
|
13
|
+
import { YARD_APART } from '../geometry/ship-rig.js';
|
|
14
|
+
import { twinMaterial } from './material-lod.js';
|
|
15
|
+
|
|
16
|
+
const _stretch = new THREE.Matrix4(),
|
|
17
|
+
_m = new THREE.Matrix4();
|
|
18
|
+
|
|
19
|
+
// The materials used where the caller gives none.
|
|
20
|
+
const plainMaterials = () => {
|
|
21
|
+
const plain = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.85 });
|
|
22
|
+
return { wood: plain, cloth: plain, glass: new THREE.MeshStandardMaterial({ vertexColors: true, emissive: 0x332211 }) };
|
|
23
|
+
};
|
|
24
|
+
// Runs the work on the page, when no worker pool is given.
|
|
25
|
+
const runHere = (job, inputOf, here) => Promise.resolve().then(here);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Makes the meshes of a ship kit's ships.
|
|
29
|
+
*
|
|
30
|
+
* @param {object} options
|
|
31
|
+
* @param {ReturnType<typeof import('../geometry/ship-kit.js').createShipKit>} options.kit - The kit (createShipKit).
|
|
32
|
+
* @param {{ wood: THREE.Material, cloth: THREE.Material, glass: THREE.Material }} [options.materials] - Her timber, her rope and
|
|
33
|
+
* canvas, and her lanterns' panes. Each is read when a ship is meshed, so a getter may hand over a material made later.
|
|
34
|
+
* @param {(job: string, inputOf: () => object, here: () => object) => Promise<object>} [options.runOrHere] - Runs a job on a
|
|
35
|
+
* worker pool, or `here()` on the page where there is none (as `createPool().runOrHere`). The page by default.
|
|
36
|
+
* @param {string} [options.job] - The pool's job that answers `{ spec, options }` with `kit.shipParts(spec, options)`.
|
|
37
|
+
* @returns {{ buildShip: Function, orderShip: Function, shipOf: Function, raiseOars: Function }} buildShip(spec, options) a
|
|
38
|
+
* ship now; orderShip(spec, options) the promise of her, built by the pool; shipOf(spec, options, parts) one from her arrays;
|
|
39
|
+
* raiseOars(parent, spec, lines) her oars to pull. A ship is `{ group, set, setOther, furl, yard, stow, half, lines,
|
|
40
|
+
* ridingLight, deckAt? }`: her canvas set either way or furled (meshes, null where none), a lateen yard's two poses (groups),
|
|
41
|
+
* half(z) half her breadth, deckAt(x, z) a decked ship's deck height. Options: `far` (the light hull, which casts no shadow),
|
|
42
|
+
* `moving` (oars left out, to be rowed), `tacks` (lateen sails set on both sides), `yardApart` (the lateen yard built apart,
|
|
43
|
+
* hoisted or stowed), `riding` (the riding light, a group to take in when she puts out).
|
|
44
|
+
*/
|
|
45
|
+
export function createShipMeshes({ kit, materials = plainMaterials(), runOrHere = runHere, job = 'ship' }) {
|
|
46
|
+
// The spec a boat with a lateen yard is built from when the yard is to stand apart from her hull (`yardApart`: a boat that
|
|
47
|
+
// both sails and lies): the yard, the sail furled on it and its hoisted ropes are left out of her own builders, and shipOf
|
|
48
|
+
// builds them of their own in both poses.
|
|
49
|
+
const yardApartSpec = (spec, { yardApart }) => (yardApart ? { ...spec, lateenYard: YARD_APART } : spec);
|
|
50
|
+
const buildShip = (spec, options = {}) => shipOf(spec, options, kit.shipParts(yardApartSpec(spec, options), options));
|
|
51
|
+
const orderShip = (spec, options = {}) =>
|
|
52
|
+
runOrHere(
|
|
53
|
+
job,
|
|
54
|
+
() => ({ spec: yardApartSpec(spec, options), options }),
|
|
55
|
+
() => kit.shipParts(yardApartSpec(spec, options), options),
|
|
56
|
+
).then(parts => shipOf(spec, options, parts));
|
|
57
|
+
|
|
58
|
+
function shipOf(spec, { far = false, yardApart = false }, parts) {
|
|
59
|
+
const group = new THREE.Group(),
|
|
60
|
+
lines = shipLines(spec),
|
|
61
|
+
mesh = (p, mat, shadow = !far, parent = group) => (p ? meshOf(p, mat, parent, shadow) : null);
|
|
62
|
+
mesh(parts.wood, materials.wood);
|
|
63
|
+
mesh(parts.rope, materials.cloth, false); // rope and iron cast none: a line a few centimetres thick is finer than the shadow map, and its shadow falls as dark smears
|
|
64
|
+
mesh(parts.glass, materials.glass, false);
|
|
65
|
+
const setMesh = mesh(parts.set, materials.cloth),
|
|
66
|
+
otherMesh = mesh(parts.setOther, materials.cloth),
|
|
67
|
+
furlMesh = mesh(parts.furl, materials.cloth);
|
|
68
|
+
if (furlMesh && setMesh) furlMesh.visible = false;
|
|
69
|
+
if (otherMesh) otherMesh.visible = false;
|
|
70
|
+
const ship = {
|
|
71
|
+
group,
|
|
72
|
+
set: setMesh,
|
|
73
|
+
setOther: otherMesh,
|
|
74
|
+
furl: furlMesh,
|
|
75
|
+
yard: null,
|
|
76
|
+
stow: null,
|
|
77
|
+
half: lines.half,
|
|
78
|
+
lines,
|
|
79
|
+
ridingLight: null,
|
|
80
|
+
};
|
|
81
|
+
// a lateen yard built apart, of the timber and rope her other spars are: shown as she sails, or as she lies, never both
|
|
82
|
+
if (yardApart) {
|
|
83
|
+
const yard = kit.lateenYardParts(spec, far);
|
|
84
|
+
ship.yard = poseOf(yard.hoisted, group, mesh, far);
|
|
85
|
+
ship.stow = poseOf(yard.stowed, group, mesh, far);
|
|
86
|
+
if (ship.stow) ship.stow.visible = !setMesh;
|
|
87
|
+
}
|
|
88
|
+
if (parts.ride) {
|
|
89
|
+
ship.ridingLight = new THREE.Group();
|
|
90
|
+
group.add(ship.ridingLight);
|
|
91
|
+
meshOf(parts.ride.glass, materials.glass, ship.ridingLight, false);
|
|
92
|
+
meshOf(parts.ride.iron, materials.cloth, ship.ridingLight, !far);
|
|
93
|
+
}
|
|
94
|
+
if (!spec.open) {
|
|
95
|
+
const ladder = 1.5, // metres of deck over which a ladder climbs
|
|
96
|
+
{ fore = [-Infinity, 0], aft = [Infinity, 0], waist } = spec;
|
|
97
|
+
ship.deckAt = (x, z) =>
|
|
98
|
+
waist + (fore[1] && fore[1] * sstep(fore[0] + ladder, fore[0], z)) + (aft[1] && aft[1] * sstep(aft[0] - ladder, aft[0], z));
|
|
99
|
+
}
|
|
100
|
+
return ship;
|
|
101
|
+
}
|
|
102
|
+
// One pose of a yard built apart as a group of its meshes under the ship's group: her timber as her spars, her ropes and
|
|
103
|
+
// furled sail as her canvas. `mesh` is the ship's own, (parts, material, shadow, parent). Null where the pose has nothing.
|
|
104
|
+
function poseOf({ spar, rig, sail }, group, mesh, far) {
|
|
105
|
+
const pose = new THREE.Group();
|
|
106
|
+
mesh(spar, materials.wood, !far, pose);
|
|
107
|
+
mesh(rig, materials.cloth, false, pose);
|
|
108
|
+
mesh(sail, materials.cloth, !far, pose);
|
|
109
|
+
if (!pose.children.length) return null;
|
|
110
|
+
group.add(pose);
|
|
111
|
+
return pose;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Her oars as instanced meshes in `parent` (in the ship's frame), two to a bank: the shafts, all of one length, and the
|
|
115
|
+
// looms, one length stretched to each port's (her sides close in toward her ends). pull(phase) sets every oar to a
|
|
116
|
+
// stroke's phase, or to rest with null. Returns { ports, pull }.
|
|
117
|
+
function raiseOars(parent, spec, lines) {
|
|
118
|
+
const ports = oarPorts(spec, lines),
|
|
119
|
+
colour = dim(C(spec.deckTone), 0.85),
|
|
120
|
+
instanced = (gb, count) => {
|
|
121
|
+
const mesh = new THREE.InstancedMesh(gb.build(), twinMaterial(materials.wood, 'instanced'), count);
|
|
122
|
+
mesh.castShadow = mesh.receiveShadow = true;
|
|
123
|
+
mesh.frustumCulled = false; // its instances spread wider than its geometry's bounds
|
|
124
|
+
parent.add(mesh);
|
|
125
|
+
return mesh;
|
|
126
|
+
},
|
|
127
|
+
banks = spec.oars.banks.map((y, bank) => {
|
|
128
|
+
const mine = ports.filter(p => p.bank === bank),
|
|
129
|
+
shaft = new GB(),
|
|
130
|
+
loom = new GB();
|
|
131
|
+
kit.shaftInto(shaft, _m.identity(), mine[0].outboard, colour);
|
|
132
|
+
const typical = mine[mine.length >> 1].inboard;
|
|
133
|
+
kit.loomInto(loom, _m.identity(), 1, mine[0].outboard, colour, gripOf(typical) / typical); // a metre long, stretched to each port's
|
|
134
|
+
return { mine, shafts: instanced(shaft, mine.length), looms: instanced(loom, mine.length) };
|
|
135
|
+
});
|
|
136
|
+
const pull = phase => {
|
|
137
|
+
for (const { mine, shafts, looms } of banks) {
|
|
138
|
+
mine.forEach((port, k) => {
|
|
139
|
+
shafts.setMatrixAt(k, oarMatrix(port, oarPose(port, phase), _m));
|
|
140
|
+
looms.setMatrixAt(k, _m.multiply(_stretch.makeScale(port.inboard, 1, 1)));
|
|
141
|
+
});
|
|
142
|
+
shafts.instanceMatrix.needsUpdate = looms.instanceMatrix.needsUpdate = true;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
pull(null);
|
|
146
|
+
return { ports, pull };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return { buildShip, orderShip, shipOf, raiseOars };
|
|
150
|
+
}
|