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,453 @@
|
|
|
1
|
+
// Trees of the plant kit, near and, for most, far: the conifer, the burnt tree, the thorn tree, the park acacia and the cedar.
|
|
2
|
+
// Each is a set of parts for `partsGeometry`, its foot at the origin. Worker-safe.
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { lerp, TAU } from '../math/scalar.js';
|
|
5
|
+
import { mulberry32 } from '../math/random.js';
|
|
6
|
+
import { C, TRS } from './primitives.js';
|
|
7
|
+
import { addShape, shapeParts } from './foliage.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The kit's trees bound to a world's hash, seed and the kit's tints.
|
|
11
|
+
* @param {object} o
|
|
12
|
+
* @param {Function} o.hash - A seeded integer hash (`createHash`), which mottles needles and char.
|
|
13
|
+
* @param {Function} o.barkTint - The kit's bark tint (`createPlantTints`).
|
|
14
|
+
* @param {Function} o.crownBlob - The kit's crown lump (`createPlantTints`).
|
|
15
|
+
* @param {Function} o.crownTint - The kit's foliage tint (`createPlantTints`).
|
|
16
|
+
* @param {number} [o.seed=0] - The world's seed: the burnt, thorn, acacia and cedar trees grow from streams counted from it.
|
|
17
|
+
* @returns {{conifer: Function, farConifer: Function, burntTree: Function, farBurntTree: Function, thornTree: Function,
|
|
18
|
+
* acacia: Function, cedar: Function}} `conifer()`, `farConifer()`, `burntTree()` and `farBurntTree()`: one set of
|
|
19
|
+
* parts each (about 10, 9.5 and 5 m tall); `thornTree()`, `acacia()` and `cedar(variant = 0)`: `{ near, far }`, the cedar
|
|
20
|
+
* about fourteen metres tall and each `variant` a tree of its own.
|
|
21
|
+
*/
|
|
22
|
+
export function createTrees({ hash: hash2, barkTint, crownBlob, crownTint, seed = 0 }) {
|
|
23
|
+
const LIMB_NEAR = new THREE.CylinderGeometry(0.62, 1, 1, 7, 1, true).translate(0, 0.5, 0), // a limb of radius 1 at its foot, a metre long
|
|
24
|
+
LIMB_FAR = new THREE.CylinderGeometry(0.62, 1, 1, 4, 1, true).translate(0, 0.5, 0),
|
|
25
|
+
FAR_PLATE = new THREE.Vector3(1.3, 1, 1.3), // a far cedar's plates, one to a limb, stand for the near tree's three
|
|
26
|
+
_up = new THREE.Vector3(0, 1, 0),
|
|
27
|
+
_dir = new THREE.Vector3();
|
|
28
|
+
// The matrix that sets a limb (its foot at the origin, standing up y, `radius` at its foot) from point a to point b.
|
|
29
|
+
function limbBetween(a, b, radius) {
|
|
30
|
+
const size = _dir.set(b[0] - a[0], b[1] - a[1], b[2] - a[2]).length();
|
|
31
|
+
return new THREE.Matrix4().compose(
|
|
32
|
+
new THREE.Vector3(...a),
|
|
33
|
+
new THREE.Quaternion().setFromUnitVectors(_up, _dir.normalize()),
|
|
34
|
+
new THREE.Vector3(radius, size, radius),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A conifer: a tapering trunk to the top, and whorl after whorl of separate drooping boughs, long at the base and short at the leader.
|
|
39
|
+
function conifer() {
|
|
40
|
+
const near = shapeParts();
|
|
41
|
+
const boughGeo = (() => {
|
|
42
|
+
// one bough along +z: a tapered spray, thicker above than below, its tip hanging
|
|
43
|
+
const R = [
|
|
44
|
+
[0, 0, 0, 0],
|
|
45
|
+
[0.22, 0.25, 0.1, -0.01],
|
|
46
|
+
[0.62, 0.2, 0.075, -0.08],
|
|
47
|
+
[1, 0, 0, -0.22],
|
|
48
|
+
],
|
|
49
|
+
ring = r =>
|
|
50
|
+
r[1] === 0
|
|
51
|
+
? [[0, r[3], r[0]]]
|
|
52
|
+
: [
|
|
53
|
+
[-r[1], r[3], r[0]],
|
|
54
|
+
[0, r[3] + r[2], r[0]],
|
|
55
|
+
[r[1], r[3], r[0]],
|
|
56
|
+
[0, r[3] - r[2] * 0.6, r[0]],
|
|
57
|
+
];
|
|
58
|
+
const pos = [],
|
|
59
|
+
nor = [],
|
|
60
|
+
tri = (a, b, c) => {
|
|
61
|
+
const ux = b[0] - a[0],
|
|
62
|
+
uy = b[1] - a[1],
|
|
63
|
+
uz = b[2] - a[2],
|
|
64
|
+
vx = c[0] - a[0],
|
|
65
|
+
vy = c[1] - a[1],
|
|
66
|
+
vz = c[2] - a[2],
|
|
67
|
+
nx = uy * vz - uz * vy,
|
|
68
|
+
ny = uz * vx - ux * vz,
|
|
69
|
+
mx = (a[0] + b[0] + c[0]) / 3,
|
|
70
|
+
my = (a[1] + b[1] + c[1]) / 3 + 0.05;
|
|
71
|
+
const T = nx * mx + ny * my < 0 ? [a, c, b] : [a, b, c];
|
|
72
|
+
for (const q of T) {
|
|
73
|
+
pos.push(q[0], q[1], q[2]);
|
|
74
|
+
const l = Math.hypot(q[0], (q[1] + 0.05) * 2.2, 0.15) || 1;
|
|
75
|
+
nor.push(q[0] / l, ((q[1] + 0.05) * 2.2) / l, ((q[2] - 0.5) * 0.3) / l);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
for (let k = 0; k < 3; k++) {
|
|
79
|
+
const A = ring(R[k]),
|
|
80
|
+
B = ring(R[k + 1]);
|
|
81
|
+
if (A.length === 1) for (let e = 0; e < 4; e++) tri(A[0], B[e], B[(e + 1) % 4]);
|
|
82
|
+
else if (B.length === 1) for (let e = 0; e < 4; e++) tri(A[e], B[0], A[(e + 1) % 4]);
|
|
83
|
+
else
|
|
84
|
+
for (let e = 0; e < 4; e++) {
|
|
85
|
+
tri(A[e], B[e], B[(e + 1) % 4]);
|
|
86
|
+
tri(A[e], B[(e + 1) % 4], A[(e + 1) % 4]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const g = new THREE.BufferGeometry();
|
|
90
|
+
g.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));
|
|
91
|
+
g.setAttribute('normal', new THREE.Float32BufferAttribute(nor, 3));
|
|
92
|
+
return g;
|
|
93
|
+
})();
|
|
94
|
+
const H = 9.6,
|
|
95
|
+
trunk = new THREE.CylinderGeometry(0.035, 0.3, H, 7, 3, true).translate(0, H / 2, 0),
|
|
96
|
+
ta = trunk.attributes.position.array,
|
|
97
|
+
r3 = mulberry32(977);
|
|
98
|
+
for (let v = 0; v < ta.length; v += 3)
|
|
99
|
+
if (ta[v + 1] < 0.4) {
|
|
100
|
+
ta[v] *= 1.35;
|
|
101
|
+
ta[v + 2] *= 1.35;
|
|
102
|
+
}
|
|
103
|
+
addShape(near, trunk, TRS(0, 0, 0), barkTint(0x4a3a2a), 0);
|
|
104
|
+
const greens = [0x25432c, 0x2a4b30, 0x2f5334, 0x355b39, 0x3b633d, 0x426b42];
|
|
105
|
+
for (let w = 0; w < 10; w++) {
|
|
106
|
+
const t = w / 9,
|
|
107
|
+
y = 1.5 + t * 7.6,
|
|
108
|
+
len = 3.0 * Math.pow(1 - t, 0.8) + 0.42,
|
|
109
|
+
nb = t < 0.5 ? 7 : t < 0.85 ? 6 : 5,
|
|
110
|
+
droop = 0.34 - t * 0.5;
|
|
111
|
+
for (let b = 0; b < nb; b++) {
|
|
112
|
+
const az = ((b + (w % 2) * 0.5 + (r3() - 0.5) * 0.4) / nb) * TAU,
|
|
113
|
+
L = len * (0.8 + r3() * 0.36),
|
|
114
|
+
c = C(greens[Math.min(5, (t * 5.2 + r3() * 1.2) | 0)]);
|
|
115
|
+
addShape(
|
|
116
|
+
near,
|
|
117
|
+
boughGeo,
|
|
118
|
+
TRS(0, y + (r3() - 0.5) * 0.35, 0, L * (1.25 + r3() * 0.3), L * 1.5, L, az, droop + (r3() - 0.5) * 0.16, 0),
|
|
119
|
+
(x, yy, z, o) => {
|
|
120
|
+
const k = (0.6 + 0.5 * z) * (yy > 0 ? 1.08 : 0.8) * (0.9 + 0.2 * hash2(Math.round(x * 40 + b), Math.round(z * 40 + w), 63));
|
|
121
|
+
o[0] = c[0] * k;
|
|
122
|
+
o[1] = c[1] * k;
|
|
123
|
+
o[2] = c[2] * k;
|
|
124
|
+
},
|
|
125
|
+
1,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const c = C(0x3a5f3e);
|
|
130
|
+
addShape(
|
|
131
|
+
near,
|
|
132
|
+
new THREE.ConeGeometry(0.2, 1.1, 6, 1, true),
|
|
133
|
+
TRS(0, H + 0.3, 0),
|
|
134
|
+
(x, y, z, o) => {
|
|
135
|
+
o[0] = c[0];
|
|
136
|
+
o[1] = c[1];
|
|
137
|
+
o[2] = c[2];
|
|
138
|
+
},
|
|
139
|
+
1,
|
|
140
|
+
);
|
|
141
|
+
return near;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// A burnt tree: a fire-killed trunk, bent and blackened, its top snapped off; charred limbs forking into bare twigs, some burnt back to stubs.
|
|
145
|
+
function burntTree() {
|
|
146
|
+
const near = shapeParts();
|
|
147
|
+
const R = mulberry32(seed + 611),
|
|
148
|
+
up = new THREE.Vector3(0, 1, 0),
|
|
149
|
+
d = new THREE.Vector3(),
|
|
150
|
+
q = new THREE.Quaternion(),
|
|
151
|
+
v0 = new THREE.Vector3(),
|
|
152
|
+
sc = new THREE.Vector3();
|
|
153
|
+
const limb = new THREE.CylinderGeometry(0.66, 1, 1, 7, 1, false).translate(0, 0.5, 0); // closed: a snapped end shows its stump
|
|
154
|
+
const char = hex => {
|
|
155
|
+
const c = C(hex);
|
|
156
|
+
return (x, y, z, o) => {
|
|
157
|
+
const h = hash2(Math.round(x * 6 + y * 9), Math.round(z * 6 - y * 4), 612),
|
|
158
|
+
k = (0.72 + 0.5 * h) * (h > 0.88 ? 1.8 : 1);
|
|
159
|
+
o[0] = c[0] * k;
|
|
160
|
+
o[1] = c[1] * k;
|
|
161
|
+
o[2] = c[2] * k * 1.04;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
const seg = (a, b, r, hex = 0x241f1c) => {
|
|
165
|
+
const L = d.set(b[0] - a[0], b[1] - a[1], b[2] - a[2]).length();
|
|
166
|
+
addShape(
|
|
167
|
+
near,
|
|
168
|
+
limb,
|
|
169
|
+
new THREE.Matrix4().compose(v0.set(...a), q.setFromUnitVectors(up, d.normalize()), sc.set(r, L, r)),
|
|
170
|
+
char(hex),
|
|
171
|
+
0,
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
const T = [
|
|
175
|
+
[0, 0, 0, 0.44],
|
|
176
|
+
[0.14, 1.7, 0.06, 0.33],
|
|
177
|
+
[0.06, 3.3, -0.14, 0.25],
|
|
178
|
+
[0.24, 4.7, 0.02, 0.18],
|
|
179
|
+
],
|
|
180
|
+
at = y => {
|
|
181
|
+
for (let i = 0; i < 3; i++)
|
|
182
|
+
if (y <= T[i + 1][1]) {
|
|
183
|
+
const t = (y - T[i][1]) / (T[i + 1][1] - T[i][1]);
|
|
184
|
+
return [0, 1, 2, 3].map(k => lerp(T[i][k], T[i + 1][k], t));
|
|
185
|
+
}
|
|
186
|
+
return T[3];
|
|
187
|
+
};
|
|
188
|
+
for (let i = 0; i < 3; i++) seg(T[i], T[i + 1], (T[i][3] / 0.9) * (i ? 1 : 1.05), i ? 0x241f1c : 0x2b2420);
|
|
189
|
+
seg([0.24, 4.68, 0.02], [0.32, 5.05, 0.1], 0.13, 0x3a332d); // the splintered break at the top, paler where the wood is newly torn
|
|
190
|
+
for (let k = 0; k < 5; k++) {
|
|
191
|
+
const a = k * 1.26 + R() * 0.4;
|
|
192
|
+
seg([Math.cos(a) * 0.62, -0.15, Math.sin(a) * 0.62], [Math.cos(a) * 0.12, 0.95, Math.sin(a) * 0.12], 0.17 + R() * 0.06, 0x2b2420);
|
|
193
|
+
} // root flare
|
|
194
|
+
for (let i = 0; i < 6; i++) {
|
|
195
|
+
const y0 = 1.9 + i * 0.5 + R() * 0.3,
|
|
196
|
+
a = i * 2.39 + R() * 0.5,
|
|
197
|
+
el = 0.5 + R() * 0.5,
|
|
198
|
+
stub = i !== 5 && R() < 0.3,
|
|
199
|
+
len = (stub ? 0.45 + R() * 0.4 : 1.5 + R() * 1.1) * (1 - i * 0.07);
|
|
200
|
+
const p = at(y0),
|
|
201
|
+
dir = [Math.cos(a) * Math.cos(el), Math.sin(el), Math.sin(a) * Math.cos(el)],
|
|
202
|
+
r = 0.15 - i * 0.012;
|
|
203
|
+
const mid = [p[0] + dir[0] * len * 0.55, p[1] + dir[1] * len * 0.55 + 0.1, p[2] + dir[2] * len * 0.55],
|
|
204
|
+
end = [p[0] + dir[0] * len, p[1] + dir[1] * len + (stub ? 0 : 0.25), p[2] + dir[2] * len];
|
|
205
|
+
seg(p, mid, r);
|
|
206
|
+
seg(mid, end, r * 0.62);
|
|
207
|
+
if (stub) continue;
|
|
208
|
+
for (let j = 0; j < 2; j++) {
|
|
209
|
+
const b = a + (j ? 0.7 : -0.6) + (R() - 0.5) * 0.4,
|
|
210
|
+
e2 = el + 0.35 + R() * 0.3,
|
|
211
|
+
l2 = len * (0.35 + R() * 0.3),
|
|
212
|
+
from = j ? end : mid;
|
|
213
|
+
const tip = [from[0] + Math.cos(b) * Math.cos(e2) * l2, from[1] + Math.sin(e2) * l2, from[2] + Math.sin(b) * Math.cos(e2) * l2];
|
|
214
|
+
seg(from, tip, r * 0.42);
|
|
215
|
+
if (R() < 0.6) seg(tip, [tip[0] + (R() - 0.5) * 0.5, tip[1] + 0.35 + R() * 0.3, tip[2] + (R() - 0.5) * 0.5], r * 0.22);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
for (const a of [0.4, 2.9]) {
|
|
219
|
+
const p = T[3],
|
|
220
|
+
tip = [p[0] + Math.cos(a) * 0.7, p[1] + 1.0, p[2] + Math.sin(a) * 0.7];
|
|
221
|
+
seg([p[0], p[1] - 0.25, p[2]], tip, 0.075);
|
|
222
|
+
seg(tip, [tip[0] + Math.cos(a + 0.8) * 0.4, tip[1] + 0.5, tip[2] + Math.sin(a + 0.8) * 0.4], 0.04);
|
|
223
|
+
}
|
|
224
|
+
return near;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// The far conifer: a bare pole and seven tiers of sprays.
|
|
228
|
+
function farConifer() {
|
|
229
|
+
const parts = shapeParts();
|
|
230
|
+
addShape(parts, new THREE.CylinderGeometry(0.05, 0.28, 9.5, 5, 1, true).translate(0, 4.75, 0), TRS(0, 0, 0), barkTint(0x4a3a2a), 0);
|
|
231
|
+
const spray = new THREE.BufferGeometry();
|
|
232
|
+
spray.setAttribute(
|
|
233
|
+
'position',
|
|
234
|
+
new THREE.Float32BufferAttribute(
|
|
235
|
+
[
|
|
236
|
+
0, 0.36, 0, -0.28, -0.15, 0.64, 0, -0.48, 1, 0, 0.36, 0, 0, -0.48, 1, 0.28, -0.19, 0.52, 0, 0.36, 0, 0.28, -0.19, 0.52, -0.28,
|
|
237
|
+
-0.15, 0.64, -0.28, -0.15, 0.64, 0.28, -0.19, 0.52, 0, -0.48, 1,
|
|
238
|
+
],
|
|
239
|
+
3,
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
spray.computeVertexNormals();
|
|
243
|
+
for (let t = 0; t < 7; t++)
|
|
244
|
+
for (let b = 0; b < 5; b++) {
|
|
245
|
+
const h = hash2(b, t, 311),
|
|
246
|
+
size = lerp(3.6, 0.46, t / 6) * (0.75 + 0.4 * h);
|
|
247
|
+
addShape(
|
|
248
|
+
parts,
|
|
249
|
+
spray,
|
|
250
|
+
TRS(0, 2.2 + t * 1.23 + h * 0.42, 0, size * 1.53, size * 0.9, size, (b * TAU) / 5 + t * 2.399 + h * 0.38),
|
|
251
|
+
crownTint(t < 3 ? 0x304b34 : 0x3a5b3c),
|
|
252
|
+
1,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return parts;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// A thorn tree: a short crooked bole, forked stems and uneven, open crowns.
|
|
259
|
+
function thornTree() {
|
|
260
|
+
const near = shapeParts(),
|
|
261
|
+
far = shapeParts();
|
|
262
|
+
const R = mulberry32(seed + 368);
|
|
263
|
+
const limbNear = new THREE.CylinderGeometry(0.21, 0.5, 1, 7, 1, true).translate(0, 0.5, 0);
|
|
264
|
+
const limbFar = new THREE.CylinderGeometry(0.23, 0.5, 1, 4, 1, true).translate(0, 0.5, 0);
|
|
265
|
+
const branch = (a, b, radius, lower = true) => {
|
|
266
|
+
const m = limbBetween(a, b, radius);
|
|
267
|
+
addShape(near, limbNear, m, barkTint(0x62513d), 0);
|
|
268
|
+
if (lower) addShape(far, limbFar, m, barkTint(0x62513d), 0);
|
|
269
|
+
};
|
|
270
|
+
const neck = [-0.18, 1.03, 0.1],
|
|
271
|
+
split = [0.2, 2.36, 0.28];
|
|
272
|
+
branch([0, 0, 0], neck, 0.49);
|
|
273
|
+
branch(neck, split, 0.33);
|
|
274
|
+
for (let i = 0; i < 5; i++) {
|
|
275
|
+
const angle = i * 2.399 + R() * 0.45,
|
|
276
|
+
reach = 1.1 + 0.87 * R();
|
|
277
|
+
const fork = [Math.cos(angle) * reach * 0.63 + 0.25, 2.57 + R() * 0.37, Math.sin(angle) * reach * 0.68];
|
|
278
|
+
const tip = [Math.cos(angle) * reach + 0.47, fork[1] + 0.43 + R() * 0.6, Math.sin(angle) * reach];
|
|
279
|
+
branch(i < 2 ? neck : split, fork, 0.15 + R() * 0.08);
|
|
280
|
+
branch(fork, tip, 0.082);
|
|
281
|
+
const leaves = [0x565c37, 0x687043, 0x4d5937, 0x697747];
|
|
282
|
+
for (let j = 0; j < 4; j++) {
|
|
283
|
+
const k = j / 3,
|
|
284
|
+
x = lerp(fork[0], tip[0], 0.22 + 0.9 * k) + (R() - 0.5) * 0.85;
|
|
285
|
+
const y = lerp(fork[1], tip[1], 0.45 + 0.65 * k) + R() * 0.49,
|
|
286
|
+
z = lerp(fork[2], tip[2], k) + (R() - 0.5) * 0.94;
|
|
287
|
+
const w = 1.05 + R() * 0.91,
|
|
288
|
+
angle = TAU * R(),
|
|
289
|
+
tint = crownTint(leaves[(i + j) % 4]);
|
|
290
|
+
const m = TRS(x, y, z, w, w * (0.43 + 0.23 * R()), w * (0.83 + R() * 0.32), angle, 0.11);
|
|
291
|
+
addShape(near, crownBlob(52 + i * 4 + j), m, tint, 1);
|
|
292
|
+
if (j % 2 === 0) addShape(far, crownBlob(52 + i * 4 + j, 0), m, tint, 1);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return { near, far };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// An old acacia of a city park: a short bole forking low into three or four limbs climbing at a slant, and a broad, flat crown in layers, wider than the tree is tall, with sky showing between its tiers.
|
|
299
|
+
function acacia() {
|
|
300
|
+
const near = shapeParts(),
|
|
301
|
+
far = shapeParts();
|
|
302
|
+
const R = mulberry32(seed + 372);
|
|
303
|
+
const branch = (a, b, r, lower = true) => {
|
|
304
|
+
const m = limbBetween(a, b, r);
|
|
305
|
+
addShape(near, LIMB_NEAR, m, barkTint(0x4a3e32), 0);
|
|
306
|
+
if (lower) addShape(far, LIMB_FAR, m, barkTint(0x4a3e32), 0);
|
|
307
|
+
};
|
|
308
|
+
const fork = [0.15, 2.3, -0.1],
|
|
309
|
+
leaves = [0x4f5e30, 0x5a6a36, 0x46552c, 0x63703c];
|
|
310
|
+
branch([0, -0.2, 0], fork, 0.42);
|
|
311
|
+
for (let i = 0, n = 4; i < n; i++) {
|
|
312
|
+
const a = (i * TAU) / n + R() * 0.6,
|
|
313
|
+
lean = 0.55 + R() * 0.25,
|
|
314
|
+
L = 3.6 + R() * 1.4;
|
|
315
|
+
const mid = [fork[0] + Math.cos(a) * L * lean * 0.55, fork[1] + L * 0.62, fork[2] + Math.sin(a) * L * lean * 0.55],
|
|
316
|
+
end = [fork[0] + Math.cos(a) * L * lean, fork[1] + L * 0.95, fork[2] + Math.sin(a) * L * lean];
|
|
317
|
+
branch(fork, mid, 0.26);
|
|
318
|
+
branch(mid, end, 0.17);
|
|
319
|
+
for (let j = 0; j < 3; j++) {
|
|
320
|
+
// twigs fanning out flat under the crown
|
|
321
|
+
const b = a + (j - 1) * 0.75 + (R() - 0.5) * 0.3,
|
|
322
|
+
l2 = 1.6 + R() * 1.2,
|
|
323
|
+
tip = [end[0] + Math.cos(b) * l2, end[1] + 0.35 + R() * 0.3, end[2] + Math.sin(b) * l2];
|
|
324
|
+
branch(end, tip, 0.07, j === 1);
|
|
325
|
+
const w = 2.5 + R() * 1.3,
|
|
326
|
+
m = TRS(tip[0], tip[1] + 0.2, tip[2], w, w * (0.36 + 0.12 * R()), w * (0.85 + 0.3 * R()), TAU * R(), 0.05);
|
|
327
|
+
addShape(near, crownBlob(140 + i * 3 + j), m, crownTint(leaves[(i + j) % 4]), 1);
|
|
328
|
+
if (j !== 1) addShape(far, crownBlob(140 + i * 3 + j, 0), m, crownTint(leaves[(i + j) % 4]), 1);
|
|
329
|
+
}
|
|
330
|
+
const w = 3.4 + R(),
|
|
331
|
+
m = TRS(end[0] * 0.6, end[1] + 0.7, end[2] * 0.6, w, w * 0.34, w * 0.9, TAU * R(), 0.04); // the upper tier, set in from the lower
|
|
332
|
+
addShape(near, crownBlob(160 + i), m, crownTint(leaves[(i + 2) % 4]), 1);
|
|
333
|
+
addShape(far, crownBlob(160 + i, 0), m, crownTint(leaves[(i + 2) % 4]), 1);
|
|
334
|
+
}
|
|
335
|
+
return { near, far };
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// The foot of an old cedar: buttress roots flaring from the bole into the ground, and below its lowest living tier the dead
|
|
339
|
+
// limbs it has shed its needles from, bare and grey, drooping, some snapped off short.
|
|
340
|
+
const BUTTRESSES = 5,
|
|
341
|
+
DEAD_LIMBS = 7;
|
|
342
|
+
function cedarFoot(near, far, R, bark) {
|
|
343
|
+
const dead = barkTint(0x6e665c);
|
|
344
|
+
for (let i = 0; i < BUTTRESSES; i++) {
|
|
345
|
+
const a = ((i + R() * 0.6) / BUTTRESSES) * TAU,
|
|
346
|
+
out = 1.3 + R() * 0.8,
|
|
347
|
+
root = limbBetween([Math.cos(a) * 0.3, 1.1 + R() * 0.5, Math.sin(a) * 0.3], [Math.cos(a) * out, -0.35, Math.sin(a) * out], 0.34);
|
|
348
|
+
addShape(near, LIMB_NEAR, root, bark, 0);
|
|
349
|
+
if (i % 2 === 0) addShape(far, LIMB_FAR, root, bark, 0);
|
|
350
|
+
}
|
|
351
|
+
for (let i = 0; i < DEAD_LIMBS; i++) {
|
|
352
|
+
const a = R() * TAU,
|
|
353
|
+
y = 1.9 + R() * 1.5,
|
|
354
|
+
long = R() < 0.3 ? 0.25 + R() * 0.3 : 0.9 + R() * 1.4, // a stub snapped off, or a limb whole
|
|
355
|
+
droop = 0.15 + R() * 0.35,
|
|
356
|
+
foot = [Math.cos(a) * 0.45, y, Math.sin(a) * 0.45],
|
|
357
|
+
end = [foot[0] + Math.cos(a) * long, y - long * droop, foot[2] + Math.sin(a) * long];
|
|
358
|
+
addShape(near, LIMB_FAR, limbBetween(foot, end, 0.06 + 0.02 * R()), dead, 0);
|
|
359
|
+
if (long > 1.2) {
|
|
360
|
+
const b = a + (R() - 0.5) * 1.4,
|
|
361
|
+
twig = [end[0] + Math.cos(b) * 0.5, end[1] + 0.05, end[2] + Math.sin(b) * 0.5],
|
|
362
|
+
from = [lerp(foot[0], end[0], 0.6), lerp(foot[1], end[1], 0.6), lerp(foot[2], end[2], 0.6)];
|
|
363
|
+
addShape(near, LIMB_FAR, limbBetween(from, twig, 0.025), dead, 0);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// A cedar of dry uplands: a stout bole that keeps its girth high up, a few great limbs reaching out nearly level, and on them
|
|
369
|
+
// broad, flat plates of dark needles in tiers, widest below, with sky between them; an old tree's top spreads flat instead of
|
|
370
|
+
// running to a point. About fourteen metres tall. Its far version keeps the bole, the limbs and a plate at each limb's end.
|
|
371
|
+
function cedar(variant = 0) {
|
|
372
|
+
const near = shapeParts(),
|
|
373
|
+
far = shapeParts(),
|
|
374
|
+
R = mulberry32(seed + 377 + variant * 1013),
|
|
375
|
+
bark = barkTint(0x4b3e33),
|
|
376
|
+
needles = [0x2c3f2e, 0x324733, 0x283a2b, 0x3a4f36],
|
|
377
|
+
bole = [0.25, 11.2, 0.1];
|
|
378
|
+
for (const [a, b, r] of [
|
|
379
|
+
[[0, -0.4, 0], [0.12, 6, 0.05], 0.62],
|
|
380
|
+
[[0.12, 5.8, 0.05], bole, 0.4],
|
|
381
|
+
]) {
|
|
382
|
+
addShape(near, LIMB_NEAR, limbBetween(a, b, r), bark, 0);
|
|
383
|
+
addShape(far, LIMB_FAR, limbBetween(a, b, r), bark, 0);
|
|
384
|
+
}
|
|
385
|
+
cedarFoot(near, far, R, bark);
|
|
386
|
+
const TIERS = 5;
|
|
387
|
+
for (let k = 0; k < TIERS; k++) {
|
|
388
|
+
const t = k / (TIERS - 1),
|
|
389
|
+
y = 3.4 + k * 1.75 + (R() - 0.5) * 0.5,
|
|
390
|
+
reach = lerp(5.6, 2.6, t) * (0.9 + R() * 0.2),
|
|
391
|
+
limbs = k < 3 ? 4 : 3;
|
|
392
|
+
for (let i = 0; i < limbs; i++) {
|
|
393
|
+
const a = ((i + R() * 0.5) / limbs) * TAU + k * 2.1,
|
|
394
|
+
c = Math.cos(a),
|
|
395
|
+
s = Math.sin(a),
|
|
396
|
+
foot = [lerp(0.12, bole[0], y / bole[1]), y, 0.05],
|
|
397
|
+
end = [foot[0] + c * reach, y + 0.5 + R() * 0.5, foot[2] + s * reach];
|
|
398
|
+
const limb = limbBetween(foot, end, lerp(0.17, 0.09, t));
|
|
399
|
+
addShape(near, LIMB_FAR, limb, bark, 0);
|
|
400
|
+
addShape(far, LIMB_FAR, limb, bark, 0);
|
|
401
|
+
// the plates along the limb, broadest toward its end, flat above and ragged at their edges
|
|
402
|
+
for (const f of [0.42, 0.72, 1]) {
|
|
403
|
+
const w = reach * (0.55 + 0.25 * f) * (0.85 + R() * 0.3),
|
|
404
|
+
m = TRS(
|
|
405
|
+
lerp(foot[0], end[0], f) + (R() - 0.5) * 0.6,
|
|
406
|
+
lerp(foot[1], end[1], f) + 0.15,
|
|
407
|
+
lerp(foot[2], end[2], f) + (R() - 0.5) * 0.6,
|
|
408
|
+
w,
|
|
409
|
+
w * (0.2 + R() * 0.08),
|
|
410
|
+
w * (0.7 + R() * 0.2),
|
|
411
|
+
a + (R() - 0.5) * 0.5,
|
|
412
|
+
(R() - 0.5) * 0.08,
|
|
413
|
+
);
|
|
414
|
+
addShape(near, crownBlob(180 + k * 12 + i * 3 + f * 2, 0), m, crownTint(needles[(k + i) % 4]), 1);
|
|
415
|
+
if (f === 1)
|
|
416
|
+
addShape(far, crownBlob(180 + k * 12 + i * 3 + f * 2, 0), m.clone().scale(FAR_PLATE), crownTint(needles[(k + i) % 4]), 1);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
for (let i = 0; i < 3; i++) {
|
|
421
|
+
const a = (i / 3) * TAU + R(),
|
|
422
|
+
w = 2.8 + R(),
|
|
423
|
+
m = TRS(bole[0] + Math.cos(a) * 1.1, bole[1] + 0.2 + R() * 0.4, bole[2] + Math.sin(a) * 1.1, w, w * 0.3, w * 0.8, a);
|
|
424
|
+
for (const parts of [near, far]) addShape(parts, crownBlob(230 + i, 0), m, crownTint(needles[i % 4]), 1);
|
|
425
|
+
}
|
|
426
|
+
return { near, far };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// The far burnt tree: its bent bole and main charred forks without small side twigs.
|
|
430
|
+
function farBurntTree() {
|
|
431
|
+
const parts = shapeParts(),
|
|
432
|
+
R = mulberry32(seed + 611),
|
|
433
|
+
char = barkTint(0x26211e);
|
|
434
|
+
const T = [
|
|
435
|
+
[0, 0, 0, 0.44],
|
|
436
|
+
[0.14, 1.7, 0.06, 0.33],
|
|
437
|
+
[0.06, 3.3, -0.14, 0.25],
|
|
438
|
+
[0.24, 5.0, 0.08, 0.16],
|
|
439
|
+
];
|
|
440
|
+
for (let i = 0; i < 3; i++) addShape(parts, LIMB_FAR, limbBetween(T[i], T[i + 1], T[i][3] * 1.1), char, 0);
|
|
441
|
+
for (let i = 0; i < 5; i++) {
|
|
442
|
+
const y0 = 2.0 + i * 0.55,
|
|
443
|
+
a = i * 2.39 + R() * 0.5,
|
|
444
|
+
el = 0.5 + R() * 0.45,
|
|
445
|
+
len = (1.35 + R() * 0.9) * (1 - i * 0.07),
|
|
446
|
+
foot = [0.14, y0, 0],
|
|
447
|
+
end = [foot[0] + Math.cos(a) * Math.cos(el) * len, y0 + Math.sin(el) * len, Math.sin(a) * Math.cos(el) * len];
|
|
448
|
+
addShape(parts, LIMB_FAR, limbBetween(foot, end, 0.13 - i * 0.012), char, 0);
|
|
449
|
+
}
|
|
450
|
+
return parts;
|
|
451
|
+
}
|
|
452
|
+
return { conifer, farConifer, burntTree, farBurntTree, thornTree, acacia, cedar };
|
|
453
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// A tussock of bunch-grass as a shape to instance, near and far. Worker-safe.
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { TAU, lerp } from '../math/scalar.js';
|
|
4
|
+
import { partsGeometry } from './foliage.js';
|
|
5
|
+
|
|
6
|
+
// Tall bunch-grass of a dry plain as a shape to instance: a tussock is a mound of last year's thatch with this year's blades
|
|
7
|
+
// arching out of it, pale at their tips. From the air the mounds read as the grain of the tall-grass stands; on foot the blades do.
|
|
8
|
+
// The geometry carries what the foliage material reads: a colour a vertex and a leaf flag (nought here: nothing is cut away).
|
|
9
|
+
// `o` gives another grass its own: tones (the thatch, the blades from root through middle to tip), the blades near, the
|
|
10
|
+
// mound's detail near and its size (a share of the plain grass's), how tall its blades stand and how far they lean out
|
|
11
|
+
// ([least, most], in metres and in shares of their height), and how far its blades' shading faces out from the tuft
|
|
12
|
+
// (`outward`: 0.5, a blade on the tuft's far side from the sun shaded as turned from it; less for blades that let light through).
|
|
13
|
+
/** The plain bunch-grass: the default form of `tussockGeometry`. */
|
|
14
|
+
const PLAIN_GRASS = {
|
|
15
|
+
thatch: [0.36, 0.31, 0.16],
|
|
16
|
+
tones: [
|
|
17
|
+
[0.27, 0.29, 0.12],
|
|
18
|
+
[0.44, 0.41, 0.19],
|
|
19
|
+
[0.63, 0.53, 0.27],
|
|
20
|
+
],
|
|
21
|
+
blades: 34,
|
|
22
|
+
wide: 0.026, // metres across a blade's foot
|
|
23
|
+
mound: 1,
|
|
24
|
+
cushion: 1,
|
|
25
|
+
tall: [0.6, 1.2],
|
|
26
|
+
lean: [0.2, 0.75],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A tussock: a mound of thatch with blades arching out of it, about a metre across and up to 1.2 m tall in the default form.
|
|
31
|
+
* @param {Function} rng - The stream it is grown from (`mulberry32`).
|
|
32
|
+
* @param {boolean} far - The far version: a low four-sided mound and fewer, plainer blades.
|
|
33
|
+
* @param {object} [o=PLAIN_GRASS] - The grass's form (described above).
|
|
34
|
+
* @returns {THREE.BufferGeometry} position, normal, colour (linear) and leaf (nought) attributes for the foliage material.
|
|
35
|
+
*/
|
|
36
|
+
function tussockGeometry(rng, far, o = PLAIN_GRASS) {
|
|
37
|
+
const [GREEN, MID, STRAW] = o.tones;
|
|
38
|
+
const position = [],
|
|
39
|
+
normal = [],
|
|
40
|
+
color = [];
|
|
41
|
+
const vertex = (x, y, z, nx, ny, nz, tone, light) => {
|
|
42
|
+
const l = Math.hypot(nx, ny, nz) || 1;
|
|
43
|
+
position.push(x, y, z);
|
|
44
|
+
normal.push(nx / l, ny / l, nz / l);
|
|
45
|
+
color.push(tone[0] * light, tone[1] * light, tone[2] * light);
|
|
46
|
+
};
|
|
47
|
+
// the mound (from afar a low four-sided cap, which is all that can be made out of it)
|
|
48
|
+
const mound = far
|
|
49
|
+
? new THREE.ConeGeometry(0.5, 0.5, 4).toNonIndexed().attributes.position.array
|
|
50
|
+
: o.mound === null
|
|
51
|
+
? []
|
|
52
|
+
: new THREE.IcosahedronGeometry(0.5, o.mound).attributes.position.array;
|
|
53
|
+
for (let i = 0; i < mound.length; i += 3) {
|
|
54
|
+
const x = mound[i],
|
|
55
|
+
y = mound[i + 1],
|
|
56
|
+
z = mound[i + 2];
|
|
57
|
+
const c = o.cushion ?? 1;
|
|
58
|
+
vertex(x * 0.7 * c, Math.max(-0.05, (y * 0.34 + 0.05) * c), z * 0.7 * c, x, Math.max(y, 0.2), z, o.thatch, 1 + y * 1.3);
|
|
59
|
+
}
|
|
60
|
+
// the blades: tapering strips, each standing for a spray of leaves, arching out and over
|
|
61
|
+
const blades = far ? 6 : o.blades;
|
|
62
|
+
for (let b = 0; b < blades; b++) {
|
|
63
|
+
const a = (b / blades) * TAU + rng() * 0.5,
|
|
64
|
+
out = [Math.cos(a), Math.sin(a)],
|
|
65
|
+
across = [-out[1], out[0]],
|
|
66
|
+
root = rng() * 0.34,
|
|
67
|
+
tall = lerp(o.tall[0], o.tall[1], rng()),
|
|
68
|
+
lean = lerp((o.lean ?? PLAIN_GRASS.lean)[0], (o.lean ?? PLAIN_GRASS.lean)[1], rng()),
|
|
69
|
+
wide = (far ? 0.15 : o.wide) * (0.7 + rng() * 0.6);
|
|
70
|
+
const along = [
|
|
71
|
+
[root, 0.04, wide, GREEN],
|
|
72
|
+
[root + lean * 0.45, tall * 0.7, wide * 0.75, MID],
|
|
73
|
+
[root + lean * 1.05, tall * 0.95, 0, STRAW],
|
|
74
|
+
]; // root, mid and drooping tip: [how far out, how high, half width, colour]
|
|
75
|
+
const at = (step, side) => {
|
|
76
|
+
const [r, y, w, tone] = along[step];
|
|
77
|
+
vertex(
|
|
78
|
+
out[0] * r + across[0] * w * side,
|
|
79
|
+
y,
|
|
80
|
+
out[1] * r + across[1] * w * side,
|
|
81
|
+
out[0] * (o.outward ?? 0.5),
|
|
82
|
+
0.85,
|
|
83
|
+
out[1] * (o.outward ?? 0.5),
|
|
84
|
+
tone,
|
|
85
|
+
0.85 + step * 0.12,
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
if (far) {
|
|
89
|
+
// one long triangle a spray
|
|
90
|
+
at(0, -1);
|
|
91
|
+
at(0, 1);
|
|
92
|
+
at(2, 1);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
for (let step = 0; step < 2; step++) {
|
|
96
|
+
at(step, -1);
|
|
97
|
+
at(step, 1);
|
|
98
|
+
at(step + 1, 1);
|
|
99
|
+
at(step, -1);
|
|
100
|
+
at(step + 1, 1);
|
|
101
|
+
at(step + 1, -1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return partsGeometry({ p: position, n: normal, c: color, l: new Float32Array(position.length / 3) });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { PLAIN_GRASS, tussockGeometry };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { cellKey } from '../math/cell-key.js';
|
|
2
|
+
|
|
3
|
+
// Index points of an append-only list. Filed x, z and radius are immutable.
|
|
4
|
+
export class PointBuckets {
|
|
5
|
+
// `list`: the things, an array that only grows; `cell`: metres to a side of a cell; `radius(item)`: how far the thing reaches
|
|
6
|
+
// beyond its point, if it has a size (the largest is kept, so a test can widen its reach by it).
|
|
7
|
+
constructor(list, cell, radius = () => 0) {
|
|
8
|
+
if (!(Number.isFinite(cell) && cell > 0)) throw new RangeError('Cell size must be positive and finite');
|
|
9
|
+
this.list = list;
|
|
10
|
+
this.cell = cell;
|
|
11
|
+
this.radius = radius;
|
|
12
|
+
this.widest = 0; // the largest radius filed
|
|
13
|
+
this.filed = 0; // how many of the list are filed
|
|
14
|
+
this.cells = new Map();
|
|
15
|
+
}
|
|
16
|
+
// Files what has been pushed onto the list since the last test.
|
|
17
|
+
catchUp() {
|
|
18
|
+
const { list, cell, cells } = this;
|
|
19
|
+
for (; this.filed < list.length; this.filed++) {
|
|
20
|
+
const item = list[this.filed],
|
|
21
|
+
key = cellKey(Math.floor(item.x / cell), Math.floor(item.z / cell));
|
|
22
|
+
this.widest = Math.max(this.widest, this.radius(item));
|
|
23
|
+
const held = cells.get(key);
|
|
24
|
+
if (held) held.push(item);
|
|
25
|
+
else cells.set(key, [item]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Visit candidate cells in column, row and insertion order. The predicate performs
|
|
29
|
+
// the exact distance or footprint test. widen extends reach by the largest filed radius.
|
|
30
|
+
find(x, z, reach, test, widen = false) {
|
|
31
|
+
this.catchUp();
|
|
32
|
+
const { cell, cells } = this,
|
|
33
|
+
searchRadius = reach + (widen ? this.widest : 0),
|
|
34
|
+
i1 = Math.floor((x + searchRadius) / cell),
|
|
35
|
+
j0 = Math.floor((z - searchRadius) / cell),
|
|
36
|
+
j1 = Math.floor((z + searchRadius) / cell),
|
|
37
|
+
i0 = Math.floor((x - searchRadius) / cell);
|
|
38
|
+
if (!Number.isSafeInteger(i0) || !Number.isSafeInteger(i1) || !Number.isSafeInteger(j0) || !Number.isSafeInteger(j1))
|
|
39
|
+
throw new RangeError('Query exceeds the supported grid coordinates');
|
|
40
|
+
for (let column = i0; column <= i1; column++)
|
|
41
|
+
for (let row = j0; row <= j1; row++) {
|
|
42
|
+
const held = cells.get(cellKey(column, row));
|
|
43
|
+
if (held) for (const item of held) if (test(item)) return item;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
some(x, z, reach, test, widen = false) {
|
|
48
|
+
return this.find(x, z, reach, test, widen) !== undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|