roamwright 0.20.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.yaml +12 -0
- package/CONTRIBUTING.md +19 -14
- package/README.md +35 -16
- package/examples/animals.html +49 -0
- package/examples/animals.js +209 -0
- package/examples/crowds.html +50 -0
- package/examples/crowds.js +268 -0
- package/examples/effects.html +53 -0
- package/examples/effects.js +343 -0
- package/examples/figure-motion.html +55 -0
- package/examples/figure-motion.js +265 -0
- package/examples/figure.html +49 -0
- package/examples/figure.js +238 -0
- package/examples/fliers.html +53 -0
- package/examples/fliers.js +292 -0
- package/examples/fortification.html +54 -0
- package/examples/fortification.js +288 -0
- package/examples/house-kit.html +48 -0
- package/examples/house-kit.js +175 -0
- package/examples/index.html +26 -16
- package/examples/island.html +48 -0
- package/examples/island.js +134 -52
- package/examples/land.html +54 -0
- package/examples/land.js +392 -0
- package/examples/props-and-plants.html +53 -0
- package/examples/props-and-plants.js +275 -0
- package/examples/rooms.html +48 -0
- package/examples/rooms.js +242 -0
- package/examples/ships.html +51 -0
- package/examples/ships.js +235 -0
- package/examples/showcase.css +320 -0
- package/examples/small-world-land.js +151 -0
- package/examples/small-world-life.js +160 -0
- package/examples/small-world-town.js +127 -0
- package/examples/small-world.html +57 -0
- package/examples/small-world.js +226 -0
- package/examples/soundscape.html +138 -0
- package/examples/soundscape.js +467 -0
- package/examples/stage-kits.js +300 -0
- package/examples/stage.js +374 -0
- package/examples/towns.html +50 -0
- package/examples/towns.js +325 -0
- package/examples/viaduct-camera.js +8 -4
- package/examples/viaduct-landscape.js +28 -17
- package/examples/viaduct.html +45 -43
- package/examples/viaduct.js +68 -92
- package/geometry/animal-camel-body.js +410 -0
- package/geometry/animal-camel-head.js +118 -0
- package/geometry/animal-canine-body.js +361 -0
- package/geometry/animal-canine-breeds.js +316 -0
- package/geometry/animal-canine-head.js +337 -0
- package/geometry/animal-cattle-body.js +391 -0
- package/geometry/animal-cattle-coat.js +42 -0
- package/geometry/animal-cattle-head.js +152 -0
- package/geometry/animal-hen.js +248 -0
- package/geometry/animal-horse-body.js +446 -0
- package/geometry/animal-horse-bridle.js +171 -0
- package/geometry/animal-horse-coat.js +68 -0
- package/geometry/animal-horse-face.js +162 -0
- package/geometry/animal-horse-hair.js +304 -0
- package/geometry/animal-horse-head.js +133 -0
- package/geometry/animal-horse-tack.js +157 -0
- package/geometry/animal-options.js +59 -0
- package/geometry/animal-shapes.js +21 -0
- package/geometry/animal-skin.js +390 -0
- package/geometry/builder-cells.js +10 -2
- package/geometry/builder-frame.js +2 -1
- package/geometry/builder.js +15 -4
- package/geometry/card-emblem.js +437 -0
- package/geometry/catenary-canvas.js +396 -0
- package/geometry/cloth-folds.js +143 -0
- package/geometry/crawl-shapes.js +71 -0
- package/geometry/creased-sheet.js +7 -2
- package/geometry/crowd-dress.js +315 -0
- package/geometry/crowd-far.js +174 -0
- package/geometry/crowd-look.js +42 -0
- package/geometry/crowd-weld.js +218 -0
- package/geometry/ear.js +9 -4
- package/geometry/erosion.js +7 -4
- package/geometry/face-grid.js +26 -6
- package/geometry/field-map.js +59 -0
- package/geometry/figure-arms.js +339 -0
- package/geometry/figure-beard.js +250 -0
- package/geometry/figure-body.js +297 -0
- package/geometry/figure-bow.js +105 -0
- package/geometry/figure-cloak.js +189 -0
- package/geometry/figure-clothes.js +337 -0
- package/geometry/figure-face-grids.js +75 -0
- package/geometry/figure-gear.js +446 -0
- package/geometry/figure-hair-far.js +151 -0
- package/geometry/figure-hair-hangs.js +108 -0
- package/geometry/figure-hair-patch.js +66 -0
- package/geometry/figure-hair.js +320 -0
- package/geometry/figure-hands.js +321 -0
- package/geometry/figure-head-features.js +280 -0
- package/geometry/figure-head.js +375 -0
- package/geometry/figure-headwear.js +223 -0
- package/geometry/figure-legs.js +231 -0
- package/geometry/figure-limbs.js +39 -0
- package/geometry/figure-sculpt.js +82 -0
- package/geometry/figure-skin.js +97 -0
- package/geometry/figure-skirts.js +303 -0
- package/geometry/figure-trunk.js +411 -0
- package/geometry/flier-corvid-body.js +322 -0
- package/geometry/flier-corvid-wings.js +154 -0
- package/geometry/flier-long-body.js +195 -0
- package/geometry/flier-shapes.js +219 -0
- package/geometry/flier-soaring-bird.js +84 -0
- package/geometry/foliage.js +177 -4
- package/geometry/fort-city-walls.js +479 -0
- package/geometry/fort-gate-approach.js +233 -0
- package/geometry/fort-great-walls.js +280 -0
- package/geometry/fort-keep.js +297 -0
- package/geometry/fort-parts.js +261 -0
- package/geometry/fort-polyline.js +261 -0
- package/geometry/fort-portal.js +96 -0
- package/geometry/fort-ring-wall.js +267 -0
- package/geometry/fort-seawall.js +104 -0
- package/geometry/fort-terrace-gates.js +323 -0
- package/geometry/fort-terrace-plan.js +250 -0
- package/geometry/fort-terrace-wall.js +345 -0
- package/geometry/garment-tags.js +11 -3
- package/geometry/grid-gather.js +69 -0
- package/geometry/grid-sample.js +185 -0
- package/geometry/hair-gathers.js +19 -4
- package/geometry/hair-locks.js +1 -1
- package/geometry/hair-patch.js +6 -2
- package/geometry/hair-shell.js +14 -2
- package/geometry/head-presets.js +103 -0
- package/geometry/head-profile.js +13 -2
- package/geometry/head-shape.js +51 -23
- package/geometry/heightfield.js +26 -9
- package/geometry/horizon-angles.js +166 -0
- package/geometry/house-kit-body.js +195 -0
- package/geometry/house-kit-courtyard-parts.js +340 -0
- package/geometry/house-kit-courtyard-roof.js +223 -0
- package/geometry/house-kit-courtyard.js +409 -0
- package/geometry/house-kit-cut.js +29 -0
- package/geometry/house-kit-extras.js +192 -0
- package/geometry/house-kit-forms.js +298 -0
- package/geometry/house-kit-frame.js +74 -0
- package/geometry/house-kit-marks.js +93 -0
- package/geometry/house-kit-openings.js +193 -0
- package/geometry/house-kit-palette.js +54 -0
- package/geometry/house-kit-pool.js +71 -0
- package/geometry/house-kit-roofs.js +151 -0
- package/geometry/house-kit.js +202 -0
- package/geometry/instances.js +4 -4
- package/geometry/lamp-wash.js +65 -0
- package/geometry/land-clearings.js +83 -0
- package/geometry/land-ditches.js +290 -0
- package/geometry/land-dry-basin.js +327 -0
- package/geometry/land-dunes.js +150 -0
- package/geometry/land-earthworks.js +432 -0
- package/geometry/land-edge.js +292 -0
- package/geometry/land-mound-faces.js +349 -0
- package/geometry/land-near-relief.js +102 -0
- package/geometry/land-sheet.js +220 -0
- package/geometry/land-town-ground.js +256 -0
- package/geometry/land-waters.js +228 -0
- package/geometry/land-wildness.js +123 -0
- package/geometry/lathed-vessel.js +293 -0
- package/geometry/outline-grid.js +5 -4
- package/geometry/outline-segments.js +74 -0
- package/geometry/part-ranges.js +35 -0
- package/geometry/path-field.js +35 -1
- package/geometry/planked-floor.js +149 -0
- package/geometry/plant-broadleaf.js +268 -0
- package/geometry/plant-shrub.js +198 -0
- package/geometry/plant-tints.js +80 -0
- package/geometry/plant-trees.js +453 -0
- package/geometry/plant-tussock.js +107 -0
- package/geometry/primitives.js +65 -23
- package/geometry/prop-battlefield.js +69 -0
- package/geometry/prop-camp.js +175 -0
- package/geometry/prop-door.js +26 -0
- package/geometry/prop-harbour.js +105 -0
- package/geometry/prop-haycock.js +60 -0
- package/geometry/prop-sacks.js +74 -0
- package/geometry/prop-sheaf.js +68 -0
- package/geometry/prop-street.js +69 -0
- package/geometry/prop-tents.js +396 -0
- package/geometry/prop-tombs.js +80 -0
- package/geometry/prop-trade.js +393 -0
- package/geometry/prop-vehicles.js +218 -0
- package/geometry/props.js +58 -0
- package/geometry/room-arcade.js +134 -0
- package/geometry/room-dome.js +188 -0
- package/geometry/room-flames.js +138 -0
- package/geometry/room-frame.js +106 -0
- package/geometry/room-furniture.js +260 -0
- package/geometry/room-hearth.js +98 -0
- package/geometry/room-kit.js +59 -0
- package/geometry/room-openings.js +142 -0
- package/geometry/room-stairs.js +180 -0
- package/geometry/room-surfaces.js +272 -0
- package/geometry/sampled-surface.js +24 -10
- package/geometry/scatter-grid.js +6 -3
- package/geometry/sculpt.js +5 -1
- package/geometry/ship-fittings.js +350 -0
- package/geometry/ship-hull.js +460 -0
- package/geometry/ship-kit.js +208 -0
- package/geometry/ship-lines.js +69 -0
- package/geometry/ship-oars.js +150 -0
- package/geometry/ship-presets.js +131 -0
- package/geometry/ship-rig.js +374 -0
- package/geometry/ship-sails.js +148 -0
- package/geometry/shore-grid.js +5 -1
- package/geometry/strata-field.js +44 -11
- package/geometry/strata-tiles.js +20 -6
- package/geometry/stream.js +32 -17
- package/geometry/swept-tube.js +124 -0
- package/geometry/terrain-chunks.js +139 -51
- package/geometry/terrain-extension.js +24 -8
- package/geometry/town-courtyard-inn.js +272 -0
- package/geometry/town-ground.js +76 -0
- package/geometry/town-houses.js +343 -0
- package/geometry/town-lights.js +254 -0
- package/geometry/town-lots.js +172 -0
- package/geometry/town-plan.js +370 -0
- package/geometry/town-works.js +465 -0
- package/geometry/village-layout.js +181 -0
- package/geometry/village-yards.js +167 -0
- package/geometry/wall-runs.js +64 -0
- package/index.js +134 -3
- package/math/cloud-textures.js +3 -7
- package/math/curve.js +5 -1
- package/math/lamp-texels.js +43 -0
- package/math/lit-share.js +22 -0
- package/math/mountain-ranges.js +177 -54
- package/math/periodic.js +6 -0
- package/math/rectangles.js +8 -2
- package/math/rock-texture.js +17 -12
- package/math/surface-textures.js +24 -9
- package/math/wandering-path.js +40 -0
- package/math/ways.js +120 -0
- package/motion/action-dynamics.js +398 -0
- package/motion/animal-bearing.js +247 -0
- package/motion/animal-canine-bearing.js +178 -0
- package/motion/animal-canine-cast.js +131 -0
- package/motion/animal-cattle-cast.js +64 -0
- package/motion/animal-herd-cast.js +154 -0
- package/motion/animal-horse-still.js +161 -0
- package/motion/animal-troop-cast.js +43 -0
- package/motion/arm-reach.js +3 -2
- package/motion/ballistic-arc.js +182 -2
- package/motion/biped-cycle.js +4 -2
- package/motion/biped-leg.js +4 -1
- package/motion/biped-posture.js +459 -0
- package/motion/biped-stride.js +142 -32
- package/motion/boat-sailing.js +214 -0
- package/motion/contact-transition.js +5 -6
- package/motion/crowd-alarms.js +36 -6
- package/motion/crowd-attention.js +108 -0
- package/motion/crowd-beasts.js +203 -0
- package/motion/crowd-camp.js +295 -0
- package/motion/crowd-figure.js +100 -0
- package/motion/crowd-herd.js +86 -0
- package/motion/crowd-hold.js +130 -0
- package/motion/crowd-pose.js +296 -0
- package/motion/crowd-poses.js +481 -0
- package/motion/crowd-routine.js +44 -14
- package/motion/crowd-town.js +166 -0
- package/motion/crowd-water.js +143 -0
- package/motion/deck-surface.js +4 -2
- package/motion/figure-acts.js +411 -0
- package/motion/figure-arms.js +437 -0
- package/motion/figure-blade-slide.js +149 -0
- package/motion/figure-body-place.js +180 -0
- package/motion/figure-bones.js +118 -0
- package/motion/figure-bow-draw.js +70 -0
- package/motion/figure-fingers.js +215 -0
- package/motion/figure-gaze.js +205 -0
- package/motion/figure-gestures.js +452 -0
- package/motion/figure-grip.js +134 -0
- package/motion/figure-head.js +287 -0
- package/motion/figure-legs.js +264 -0
- package/motion/figure-links.js +293 -0
- package/motion/figure-locomotion.js +391 -0
- package/motion/figure-mount-up.js +180 -0
- package/motion/figure-mount.js +201 -0
- package/motion/figure-pose-frame.js +375 -0
- package/motion/figure-pose-table.js +156 -0
- package/motion/figure-pose.js +343 -0
- package/motion/figure-seat.js +267 -0
- package/motion/figure-sway.js +125 -0
- package/motion/flier-corvid-pose.js +74 -0
- package/motion/flier-flight-air.js +122 -0
- package/motion/flier-flight-echelon.js +164 -0
- package/motion/flier-flight-roost.js +131 -0
- package/motion/flier-swarm-flight.js +252 -0
- package/motion/formation.js +193 -0
- package/motion/instance-sight.js +8 -1
- package/motion/melee-contact.js +143 -0
- package/motion/moorings.js +48 -0
- package/motion/path-steering.js +358 -0
- package/motion/player.js +7 -6
- package/motion/quadruped.js +109 -33
- package/motion/spaces.js +58 -6
- package/motion/speech-cadence.js +304 -0
- package/motion/vessel-motion.js +57 -0
- package/motion/walk-grid.js +235 -0
- package/motion/weather.js +70 -12
- package/motion/wind.js +27 -1
- package/package.json +27 -4
- package/rendering/alpha-mips.js +340 -0
- package/rendering/animal-camel-figure.js +29 -0
- package/rendering/animal-canine-figure.js +59 -0
- package/rendering/animal-cattle-figure.js +36 -0
- package/rendering/animal-horse-figure.js +49 -0
- package/rendering/atmosphere.js +86 -0
- package/rendering/camera-track.js +156 -0
- package/rendering/{road-surface.js → cart-track.js} +40 -11
- package/rendering/caster-motion.js +2 -1
- package/rendering/cell-lod-options.js +46 -0
- package/rendering/cell-lod.js +665 -80
- package/rendering/cloth-material.js +140 -0
- package/rendering/cloud-dome.js +2 -2
- package/rendering/compilation-schedule.js +18 -10
- package/rendering/contact-shadows.js +5 -2
- package/rendering/context.js +47 -8
- package/rendering/crowd-batches.js +420 -0
- package/rendering/crowd-herd.js +198 -0
- package/rendering/crowd-rig.js +132 -0
- package/rendering/crowd-skinning.js +52 -9
- package/rendering/crowd-update.js +419 -0
- package/rendering/crowd-visibility.js +107 -0
- package/rendering/day-cycle-defaults.js +200 -0
- package/rendering/day-cycle.js +487 -0
- package/rendering/daylight.js +1 -3
- package/rendering/detail-range.js +6 -5
- package/rendering/dof.js +11 -4
- package/rendering/effects-frame.js +149 -0
- package/rendering/effects-water-rises.js +221 -0
- package/rendering/energy-stream.js +128 -0
- package/rendering/facade-glass-material.js +105 -0
- package/rendering/far-shadow.js +81 -54
- package/rendering/field-surface.js +138 -0
- package/rendering/figure-shield.js +105 -0
- package/rendering/figure-skeleton.js +329 -0
- package/rendering/fire-light-watch.js +197 -0
- package/rendering/fire-pools.js +148 -0
- package/rendering/flame-sources.js +86 -0
- package/rendering/flier-bird-looks.js +97 -0
- package/rendering/flier-corvid-figure.js +67 -0
- package/rendering/flier-long-body-company.js +169 -0
- package/rendering/flier-swarm.js +186 -0
- package/rendering/flocks.js +6 -2
- package/rendering/garment-material.js +145 -49
- package/rendering/glsl-literal.js +19 -0
- package/rendering/ground-marks.js +316 -0
- package/rendering/hair-strands.js +38 -24
- package/rendering/height-haze.js +80 -33
- package/rendering/height-probe.js +15 -3
- package/rendering/house-kit-meshes.js +124 -0
- package/rendering/interior-bake.js +807 -0
- package/rendering/label-layout.js +13 -3
- package/rendering/label-range.js +5 -2
- package/rendering/lamp-light-map.js +159 -0
- package/rendering/lamp-maps.js +62 -0
- package/rendering/lamp-wash.js +51 -0
- package/rendering/light-budget.js +19 -3
- package/rendering/light-points.js +21 -5
- package/rendering/local-lights.js +27 -7
- package/rendering/material-lod.js +5 -6
- package/rendering/memory-estimate.js +84 -0
- package/rendering/moored-fleet.js +186 -0
- package/rendering/part-costs.js +104 -0
- package/rendering/particle-bursts.js +386 -0
- package/rendering/particle-emitters.js +61 -25
- package/rendering/particle-light-bursts.js +189 -0
- package/rendering/particles.js +134 -34
- package/rendering/pen-flocks.js +118 -0
- package/rendering/piece-batch.js +282 -6
- package/rendering/planar-reflection-options.js +159 -0
- package/rendering/planar-reflection.js +780 -77
- package/rendering/plant-cells.js +122 -0
- package/rendering/plant-reeds.js +113 -0
- package/rendering/plant-shade-trees.js +239 -0
- package/rendering/plant-tuft-patch.js +122 -0
- package/rendering/post-shaders.js +84 -21
- package/rendering/post.js +39 -19
- package/rendering/pressed-cover.js +135 -0
- package/rendering/prop-dig.js +136 -0
- package/rendering/room-light.js +250 -0
- package/rendering/room-materials.js +78 -0
- package/rendering/room-space.js +111 -0
- package/rendering/scene-lights.js +106 -0
- package/rendering/sea-shaders.js +83 -26
- package/rendering/settlement-approach.js +226 -0
- package/rendering/settlement-dissolve.js +89 -0
- package/rendering/settlement-quarter-warm.js +55 -0
- package/rendering/settlement-quarter.js +477 -0
- package/rendering/settlement-switch.js +42 -0
- package/rendering/settlement-town.js +110 -0
- package/rendering/shader-warmup.js +80 -36
- package/rendering/shadow-depth.js +40 -18
- package/rendering/ship-meshes.js +150 -0
- package/rendering/shot-cuts.js +68 -0
- package/rendering/sky-occlusion.js +42 -15
- package/rendering/sky-pmrem.js +216 -0
- package/rendering/sky.js +112 -50
- package/rendering/smoke-shadows.js +201 -0
- package/rendering/stage-framing.js +182 -0
- package/rendering/stage-lights.js +46 -39
- package/rendering/stain-material.js +74 -0
- package/rendering/static-point-shadow.js +62 -23
- package/rendering/still-casters.js +77 -27
- package/rendering/strata-material.js +2 -2
- package/rendering/street-lamps.js +166 -0
- package/rendering/sunbeam-motes.js +670 -0
- package/rendering/surface-light.js +65 -6
- package/rendering/surface-material.js +306 -0
- package/rendering/surface-projection.js +32 -0
- package/rendering/surface-snippets.js +314 -0
- package/rendering/taa.js +49 -18
- package/rendering/tree-impostor.js +929 -0
- package/rendering/vehicle-train.js +92 -0
- package/rendering/viewport.js +67 -4
- package/rendering/water-material.js +270 -82
- package/rendering/waypoint-beacons.js +191 -0
- package/rendering/world-matrices.js +0 -2
- package/ruff.toml +20 -0
- package/runtime/cue-cursor.js +21 -0
- package/runtime/device-quality.js +13 -2
- package/runtime/device.js +73 -0
- package/runtime/diagnostic-log.js +11 -3
- package/runtime/effect-sites.js +85 -0
- package/runtime/figure-orders.js +59 -0
- package/runtime/first-use.js +8 -5
- package/runtime/foley-script.js +124 -0
- package/runtime/foley-strides.js +333 -0
- package/runtime/frame-pacing.js +18 -4
- package/runtime/frame-yield.js +18 -0
- package/runtime/gpu-timing.js +8 -4
- package/runtime/grid-cache.js +16 -6
- package/runtime/grid-rows.js +5 -5
- package/runtime/hand-over.js +7 -2
- package/runtime/land-bake.js +78 -0
- package/runtime/lazy-sets.js +105 -0
- package/runtime/pool.js +17 -3
- package/runtime/quality-fit.js +59 -27
- package/runtime/region-pass-lay.js +40 -0
- package/runtime/region-pass.js +78 -0
- package/runtime/search.js +6 -2
- package/runtime/settlement-reach.js +42 -0
- package/runtime/sound-calls.js +113 -0
- package/runtime/sound-impacts.js +297 -0
- package/runtime/sound-voices.js +194 -0
- package/runtime/soundscape.js +282 -0
- package/runtime/spatial-audio.js +69 -20
- package/runtime/steady-frames.js +221 -0
- package/runtime/withdrawable-task.js +19 -8
- package/scripts/app-parts.mjs +118 -0
- package/scripts/bake-revisions.mjs +81 -0
- package/scripts/browser-scripts.mjs +64 -0
- package/scripts/bundle.mjs +192 -0
- package/scripts/check-app.sh +26 -0
- package/scripts/eslint-config.mjs +119 -0
- package/scripts/format.sh +92 -0
- package/scripts/keep-builds.mjs +158 -0
- package/scripts/layers.mjs +112 -0
- package/scripts/lint.sh +49 -0
- package/scripts/module-graph.mjs +123 -0
- package/scripts/pre-commit.sh +38 -0
- package/scripts/serve.py +5 -3
- package/scripts/site.mjs +358 -0
- package/scripts/test-runner.sh +42 -0
- package/scripts/vendor.mjs +221 -0
- package/scripts/verify-publish.mjs +175 -0
- package/scripts/world.mk +59 -0
- package/tools/README.md +73 -0
- package/tools/contact-sheet.cjs +137 -0
- package/tools/cpu-profile.cjs +275 -0
- package/tools/cpu-profile.test.cjs +98 -0
- package/tools/first-draws.cjs +395 -0
- package/tools/flight-guard.cjs +482 -0
- package/tools/flight-guard.test.cjs +153 -0
- package/tools/flight-profile.cjs +145 -0
- package/tools/frame-bench.cjs +336 -0
- package/tools/frame-parts.cjs +365 -0
- package/tools/ios-sim.sh +145 -0
- package/tools/load-audit.cjs +201 -0
- package/tools/look-compare.cjs +304 -0
- package/tools/look-guard.cjs +407 -0
- package/tools/look-guard.test.cjs +93 -0
- package/tools/look-stats.cjs +185 -0
- package/tools/look-stats.test.cjs +71 -0
- package/tools/memory-audit.cjs +323 -0
- package/tools/page-driver.cjs +320 -0
- package/tools/page-driver.test.cjs +219 -0
- package/tools/program-census-report.cjs +191 -0
- package/tools/program-census.cjs +465 -0
- package/tools/program-census.test.cjs +332 -0
- package/tools/remote-runner.sh +265 -0
- package/tools/runners.test.cjs +59 -0
- package/tools/scene-audit-beat.cjs +344 -0
- package/tools/scene-audit-sheet.cjs +282 -0
- package/tools/scene-audit.cjs +471 -0
- package/tools/scene-audit.test.cjs +201 -0
- package/tools/scene-batch.cjs +219 -0
- package/tools/scene-bench.cjs +149 -0
- package/tools/scene-bench.test.cjs +33 -0
- package/tools/scene-run.cjs +443 -0
- package/tools/scene-run.test.cjs +94 -0
- package/tools/servers.sh +59 -0
- package/tools/shader-arrival.cjs +316 -0
- package/tools/shader-renewal.cjs +53 -0
- package/tools/shader-renewal.test.cjs +115 -0
- package/tools/speed-guard.cjs +258 -0
- package/tools/stills.cjs +492 -0
- package/tools/stills.test.cjs +49 -0
- package/tools/turns.sh +7 -0
- package/tools/yaml.cjs +158 -0
- package/examples/viaduct.css +0 -75
- package/rendering/light-shafts.js +0 -131
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { lerp } from '../math/scalar.js';
|
|
3
|
+
import { C } from './primitives.js';
|
|
4
|
+
import { eye, scatter, tube } from './animal-skin.js';
|
|
5
|
+
import { triangle } from './figure-sculpt.js';
|
|
6
|
+
|
|
7
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
8
|
+
// A large corvid (a raven, a crow, a rook), built as one is: a body clad in contour feathers, a head that flows into the neck
|
|
9
|
+
// with a heavy wedge of a bill, the bristles over its nostrils and the shaggy hackles of its throat, a graduated wedge of a tail,
|
|
10
|
+
// and scaled legs with three toes forward and one back. Sizes are in metres for a bird about a metre tall (scale it by its
|
|
11
|
+
// height), nose to +z. Everything is drawn into a GeometryBuilder (`GB`) as weighted vertices with no bones, tagged for a figure
|
|
12
|
+
// material: glossy plumage, smooth horn, the eyes. The wings are in `flier-corvid-wings.js`.
|
|
13
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
14
|
+
export const FEATHER_TAG = 1.6; // a figure material's tag of glossy plumage: between skin (1) and an eye (2)
|
|
15
|
+
export const HORN_TAG = 1; // smooth horn: the bill, the legs' scutes and the claws
|
|
16
|
+
export const NO_BONES = [0];
|
|
17
|
+
/** Metres the body is drawn below where its parts are laid out, so that it sits low on its short legs. */
|
|
18
|
+
export const CORVID_SIT = 0.07;
|
|
19
|
+
/** Where the head turns (its pivot), at a height of 1. */
|
|
20
|
+
export const CORVID_NECK = [0, 0.86 - CORVID_SIT, 0.215];
|
|
21
|
+
/** The wings' shoulders (x either side), at a height of 1. */
|
|
22
|
+
export const CORVID_SHOULDER = [0.13, 0.69 - CORVID_SIT, 0.13];
|
|
23
|
+
/** The bird's height at a scale of 1: its crown over its feet, in metres. */
|
|
24
|
+
export const CORVID_TALL = 0.95;
|
|
25
|
+
const FOOT = [0.078, 0, 0.03];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A corvid's look: `feathers` its plumage and `horn` its bill and legs (hex, sRGB), `shade` a share that makes one bird of a roost a
|
|
29
|
+
* little darker or lighter than the next, and `height` its size (1: about a metre tall). The default is a dark grey bird with a
|
|
30
|
+
* slate bill.
|
|
31
|
+
*/
|
|
32
|
+
export const CORVID_LOOK = { feathers: 0x303238, horn: 0x383532, shade: 1, height: 1 };
|
|
33
|
+
|
|
34
|
+
const _at = new THREE.Matrix4();
|
|
35
|
+
/** Puts what the builder draws next at `local` within the frame F the caller draws the bird in (either may be null). */
|
|
36
|
+
export function placeIn(b, F, local = null) {
|
|
37
|
+
b.M = F && local ? _at.multiplyMatrices(F, local) : local || F;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Plumage, from the look's colour: blue and violet in the gloss of what faces up, a little lighter at the feathers' tips.
|
|
41
|
+
function plumage(c) {
|
|
42
|
+
const sheen = [c[0] * 0.92, c[1] * 1.02, c[2] * 1.32];
|
|
43
|
+
return (col, x, y, z, nx, ny) => {
|
|
44
|
+
const up = Math.max(0, ny),
|
|
45
|
+
grain = 0.86 + 0.28 * scatter(x * 91.7 + y * 57.3 + z * 33.1);
|
|
46
|
+
for (let i = 0; i < 3; i++) col[i] = lerp(c[i], sheen[i], up) * grain;
|
|
47
|
+
col[3] = FEATHER_TAG;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The colours a corvid is drawn in, from its look: `coat` (the plumage's colour by the point, a coat function as `tube` reads
|
|
53
|
+
* one), `horn` (linear) and `tip` (the feathers' tips, linear).
|
|
54
|
+
*
|
|
55
|
+
* @param {typeof CORVID_LOOK} [look=CORVID_LOOK]
|
|
56
|
+
*/
|
|
57
|
+
export function corvidPalette(look = CORVID_LOOK) {
|
|
58
|
+
const feathers = C(look.feathers).map(v => v * (look.shade ?? 1));
|
|
59
|
+
return { coat: plumage(feathers), horn: C(look.horn), tip: [feathers[0] * 1.08, feathers[1] * 1.14, feathers[2] * 1.38] };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* One feather: a vane along a curve from a, bowed towards m, to b, its upper face to `out`, `half` wide at its broadest, raised
|
|
64
|
+
* along its shaft, coloured from col at the quill to end at the tip and darker down its trailing edge where the next lies over it.
|
|
65
|
+
*/
|
|
66
|
+
export function feather(gb, a, m, b, out, half, col, end, rows = 4) {
|
|
67
|
+
let prev = null;
|
|
68
|
+
for (let i = 0; i <= rows; i++) {
|
|
69
|
+
const u = i / rows,
|
|
70
|
+
v = 1 - u,
|
|
71
|
+
p = [0, 1, 2].map(k => v * v * a[k] + 2 * u * v * m[k] + u * u * b[k]),
|
|
72
|
+
d = [0, 1, 2].map(k => v * (m[k] - a[k]) + u * (b[k] - m[k])),
|
|
73
|
+
s = [d[1] * out[2] - d[2] * out[1], d[2] * out[0] - d[0] * out[2], d[0] * out[1] - d[1] * out[0]],
|
|
74
|
+
sl = Math.hypot(s[0], s[1], s[2]) || 1,
|
|
75
|
+
wide = half * (u < 0.35 ? 0.55 + (0.45 * u) / 0.35 : 1 - 0.78 * ((u - 0.35) / 0.65) ** 2),
|
|
76
|
+
rib = half * 0.22 * (1 - u),
|
|
77
|
+
c = [0, 1, 2].map(k => lerp(col[k], end[k], u * u)),
|
|
78
|
+
point = (k, lift, shade) => [
|
|
79
|
+
p[0] + (s[0] / sl) * wide * k + out[0] * lift,
|
|
80
|
+
p[1] + (s[1] / sl) * wide * k + out[1] * lift,
|
|
81
|
+
p[2] + (s[2] / sl) * wide * k + out[2] * lift,
|
|
82
|
+
out[0] * 0.85 + (s[0] / sl) * 0.5 * k,
|
|
83
|
+
out[1] * 0.85 + (s[1] / sl) * 0.5 * k,
|
|
84
|
+
out[2] * 0.85 + (s[2] / sl) * 0.5 * k,
|
|
85
|
+
c.map(x => x * shade),
|
|
86
|
+
],
|
|
87
|
+
row = [point(-1, 0, 0.78), point(0, rib, 1), point(1, 0, 1)];
|
|
88
|
+
if (prev) {
|
|
89
|
+
triangle(gb, prev[0], prev[1], row[1], c, 0);
|
|
90
|
+
triangle(gb, prev[0], row[1], row[0], c, 0);
|
|
91
|
+
triangle(gb, prev[1], prev[2], row[2], c, 0);
|
|
92
|
+
triangle(gb, prev[1], row[2], row[1], c, 0);
|
|
93
|
+
}
|
|
94
|
+
prev = row;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export const lerp3 = (a, b, u) => [lerp(a[0], b[0], u), lerp(a[1], b[1], u), lerp(a[2], b[2], u)];
|
|
98
|
+
export const unit = (x, y, z) => {
|
|
99
|
+
const l = Math.hypot(x, y, z);
|
|
100
|
+
return [x / l, y / l, z / l];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The body, in the frame F (null: the builder's own): breast, belly and back from the root of the tail to the neck, under contour
|
|
105
|
+
* feathers that lie back towards the tail and stand out shaggier on the belly and the front of the neck; the feathered thighs; the
|
|
106
|
+
* tail; the legs and toes. Without `fine` the contour feathers are left to the surface's colour (a bird seen from further off).
|
|
107
|
+
*/
|
|
108
|
+
export function corvidBody(b, coat, horn, tip, F, fine) {
|
|
109
|
+
const sit = new THREE.Matrix4().makeTranslation(0, -CORVID_SIT, 0);
|
|
110
|
+
placeIn(b, F, sit);
|
|
111
|
+
tube(
|
|
112
|
+
b,
|
|
113
|
+
[
|
|
114
|
+
[0.36, -0.36, 0, 0, 0, 0],
|
|
115
|
+
[0.38, -0.31, 0.07, 0.05, 0.06, 0],
|
|
116
|
+
[0.42, -0.21, 0.13, 0.11, 0.13, 0],
|
|
117
|
+
[0.47, -0.09, 0.17, 0.15, 0.18, 0],
|
|
118
|
+
[0.54, 0.03, 0.18, 0.16, 0.2, 0],
|
|
119
|
+
[0.63, 0.13, 0.16, 0.13, 0.17, 0],
|
|
120
|
+
[0.73, 0.19, 0.115, 0.09, 0.12, 0],
|
|
121
|
+
[0.83, 0.22, 0.088, 0.078, 0.085, 0],
|
|
122
|
+
[0.92, 0.23, 0.07, 0.066, 0.07, 0],
|
|
123
|
+
[0.97, 0.235, 0, 0, 0, 0],
|
|
124
|
+
],
|
|
125
|
+
{
|
|
126
|
+
chain: NO_BONES,
|
|
127
|
+
around: 18,
|
|
128
|
+
sub: 3,
|
|
129
|
+
coat,
|
|
130
|
+
lay: -1,
|
|
131
|
+
droop: 0.15,
|
|
132
|
+
fur:
|
|
133
|
+
fine &&
|
|
134
|
+
((out, x, y, z, nx, ny, nz, a, v) => {
|
|
135
|
+
const belly = ny < -0.3 && v > 0.2 && v < 0.62 ? 1 : 0,
|
|
136
|
+
throat = v > 0.66 && nz > 0.25 ? 1 : 0;
|
|
137
|
+
out[0] = (ny > 0.3 ? 0.026 : 0.034) + 0.022 * belly + 0.034 * throat;
|
|
138
|
+
out[1] = 0.02 + 0.1 * belly + 0.18 * throat;
|
|
139
|
+
out[2] = out[0] * (throat ? 0.4 : 0.7);
|
|
140
|
+
out[3] = 2;
|
|
141
|
+
out[4] = 1.05;
|
|
142
|
+
}),
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
for (const s of [-1, 1]) {
|
|
146
|
+
// the thighs, feathered to the heel
|
|
147
|
+
placeIn(b, F, sit);
|
|
148
|
+
tube(
|
|
149
|
+
b,
|
|
150
|
+
[
|
|
151
|
+
[0.44, 0.02, 0, 0, 0, 0],
|
|
152
|
+
[0.4, 0.02, 0.058, 0.06, 0.06, 0],
|
|
153
|
+
[0.31, 0.0, 0.05, 0.05, 0.055, 0],
|
|
154
|
+
[0.23, -0.01, 0.034, 0.034, 0.034, 0],
|
|
155
|
+
[0.2, -0.01, 0, 0, 0, 0],
|
|
156
|
+
],
|
|
157
|
+
{
|
|
158
|
+
chain: NO_BONES,
|
|
159
|
+
x: s * 0.085,
|
|
160
|
+
side: s,
|
|
161
|
+
around: 10,
|
|
162
|
+
sub: 2,
|
|
163
|
+
coat,
|
|
164
|
+
lay: 1,
|
|
165
|
+
droop: 0.4,
|
|
166
|
+
fur:
|
|
167
|
+
fine &&
|
|
168
|
+
(out => {
|
|
169
|
+
out[0] = 0.05;
|
|
170
|
+
out[1] = 0.12;
|
|
171
|
+
out[2] = 0.03;
|
|
172
|
+
out[3] = 2;
|
|
173
|
+
out[4] = 1.05;
|
|
174
|
+
}),
|
|
175
|
+
},
|
|
176
|
+
);
|
|
177
|
+
leg(b, s, horn, F);
|
|
178
|
+
}
|
|
179
|
+
placeIn(b, F, sit);
|
|
180
|
+
tail(b, coat, tip);
|
|
181
|
+
placeIn(b, F);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// A leg below the feathers: the tarsus in its scutes, three toes forward and one back, each ending in a hooked claw.
|
|
185
|
+
function leg(b, s, horn, F) {
|
|
186
|
+
placeIn(b, F);
|
|
187
|
+
const scutes = (col, x, y) => {
|
|
188
|
+
const band = 0.82 + 0.3 * Math.abs(Math.sin(y * 170));
|
|
189
|
+
for (let i = 0; i < 3; i++) col[i] = horn[i] * band;
|
|
190
|
+
col[3] = HORN_TAG;
|
|
191
|
+
};
|
|
192
|
+
tube(
|
|
193
|
+
b,
|
|
194
|
+
[
|
|
195
|
+
[0.012, 0.03, 0, 0, 0, 0],
|
|
196
|
+
[0.02, 0.03, 0.019, 0.019, 0.021, 0],
|
|
197
|
+
[0.09, 0.022, 0.017, 0.017, 0.019, 0],
|
|
198
|
+
[0.15, 0.01, 0.019, 0.02, 0.021, 0],
|
|
199
|
+
[0.2, 0.0, 0.026, 0.027, 0.027, 0],
|
|
200
|
+
[0.22, -0.002, 0, 0, 0, 0],
|
|
201
|
+
],
|
|
202
|
+
{ chain: NO_BONES, x: s * FOOT[0], side: s, around: 8, sub: 2, coat: scutes },
|
|
203
|
+
);
|
|
204
|
+
const M = new THREE.Matrix4(),
|
|
205
|
+
claw = horn.map(x => x * 0.55);
|
|
206
|
+
for (const [turn, len] of [
|
|
207
|
+
[-0.38, 0.062],
|
|
208
|
+
[0, 0.078],
|
|
209
|
+
[0.38, 0.062],
|
|
210
|
+
[Math.PI, 0.046],
|
|
211
|
+
]) {
|
|
212
|
+
placeIn(b, F, M.makeRotationY(turn * s).setPosition(s * FOOT[0], FOOT[1], FOOT[2]));
|
|
213
|
+
const toe = (col, x, y, z) => {
|
|
214
|
+
const c = z > len ? claw : horn,
|
|
215
|
+
knuckle = 0.85 + 0.25 * Math.abs(Math.sin(z * 120));
|
|
216
|
+
for (let i = 0; i < 3; i++) col[i] = c[i] * knuckle;
|
|
217
|
+
col[3] = HORN_TAG;
|
|
218
|
+
};
|
|
219
|
+
tube(
|
|
220
|
+
b,
|
|
221
|
+
[
|
|
222
|
+
[0.012, -0.005, 0, 0, 0, 0],
|
|
223
|
+
[0.012, 0, 0.009, 0.008, 0.007, 0],
|
|
224
|
+
[0.011, len * 0.5, 0.008, 0.007, 0.007, 0],
|
|
225
|
+
[0.009, len, 0.006, 0.006, 0.005, 0],
|
|
226
|
+
[0.006, len + 0.018, 0.0035, 0.0035, 0.003, 0],
|
|
227
|
+
[-0.002, len + 0.032, 0.0015, 0.0015, 0.001, 0],
|
|
228
|
+
[-0.006, len + 0.036, 0, 0, 0, 0],
|
|
229
|
+
],
|
|
230
|
+
{ chain: NO_BONES, around: 7, sub: 2, coat: toe },
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
placeIn(b, F);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// The tail: twelve feathers in a graduated wedge, the middle pair longest, angled down behind the perch, with coverts over its root.
|
|
237
|
+
function tail(b, coat, tip) {
|
|
238
|
+
const col = [0, 0, 0, 0],
|
|
239
|
+
dir = unit(0, -0.5, -0.866),
|
|
240
|
+
out = unit(0, 0.866, -0.5);
|
|
241
|
+
for (let i = 0; i < 12; i++) {
|
|
242
|
+
const k = (i - 5.5) / 5.5, // -1 the outer feather on the left, 1 on the right
|
|
243
|
+
len = 0.5 - 0.14 * k * k,
|
|
244
|
+
root = [k * 0.05, 0.37 + 0.004 * (1 - Math.abs(k)), -0.31],
|
|
245
|
+
end = [root[0] + k * 0.1 + dir[0] * len, root[1] + dir[1] * len + 0.006 * (1 - Math.abs(k)), root[2] + dir[2] * len];
|
|
246
|
+
coat(col, root[0], root[1], root[2], 0, 1, 0);
|
|
247
|
+
feather(b, root, lerp3(root, end, 0.5), end, out, 0.036, col, tip);
|
|
248
|
+
}
|
|
249
|
+
for (let i = 0; i < 5; i++) {
|
|
250
|
+
const k = (i - 2) / 2,
|
|
251
|
+
root = [k * 0.05, 0.42, -0.25],
|
|
252
|
+
end = [k * 0.07, 0.34, -0.42];
|
|
253
|
+
coat(col, root[0], root[1], root[2], 0, 1, 0);
|
|
254
|
+
feather(b, root, lerp3(root, end, 0.5), end, out, 0.04, col, tip, 3);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* The head, about its pivot at the top of the neck (`CORVID_NECK`): the skull with its flat crown and deep throat under short
|
|
260
|
+
* feathers and the long lanceolate hackles; the eyes; the bill, deep and pressed from the sides, its ridge curving down to a
|
|
261
|
+
* hooked tip, with the line of the gape; the bristles lying forward over the nostrils.
|
|
262
|
+
*/
|
|
263
|
+
export function corvidHead(b, coat, horn, tip) {
|
|
264
|
+
tube(
|
|
265
|
+
b,
|
|
266
|
+
[
|
|
267
|
+
[0.07, -0.085, 0, 0, 0, 0],
|
|
268
|
+
[0.072, -0.07, 0.045, 0.045, 0.06, 0, 2.3],
|
|
269
|
+
[0.075, -0.04, 0.066, 0.06, 0.085, 0, 2.3],
|
|
270
|
+
[0.078, 0.0, 0.07, 0.062, 0.085, 0, 2.3],
|
|
271
|
+
[0.078, 0.035, 0.062, 0.058, 0.07, 0, 2.2],
|
|
272
|
+
[0.074, 0.065, 0.048, 0.05, 0.055, 0, 2.1],
|
|
273
|
+
[0.07, 0.09, 0.034, 0.04, 0.04, 0, 2],
|
|
274
|
+
[0.068, 0.105, 0, 0, 0, 0],
|
|
275
|
+
],
|
|
276
|
+
{
|
|
277
|
+
chain: NO_BONES,
|
|
278
|
+
around: 16,
|
|
279
|
+
sub: 3,
|
|
280
|
+
coat,
|
|
281
|
+
lay: -1,
|
|
282
|
+
droop: 0.5,
|
|
283
|
+
fur: (out, x, y, z, nx, ny, nz, a, v) => {
|
|
284
|
+
const throat = ny < -0.25 && v < 0.75 ? 1 : 0;
|
|
285
|
+
if (!throat && v > 0.8) return false; // the face before the eyes is smooth
|
|
286
|
+
out[0] = throat ? 0.085 : 0.022;
|
|
287
|
+
out[1] = throat ? 0.3 : 0.05;
|
|
288
|
+
out[2] = throat ? 0.026 : 0.016;
|
|
289
|
+
out[3] = throat ? 3 : 2;
|
|
290
|
+
out[4] = throat ? 1.25 : 1.1;
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
);
|
|
294
|
+
for (const s of [-1, 1]) eye(b, s * 0.056, 0.088, 0.035, 0.012, 0.012, 0.012, [0.035, 0.022, 0.016]);
|
|
295
|
+
const bill = (col, x, y, z, nx, ny, nz, a) => {
|
|
296
|
+
const gape = Math.abs(Math.sin(a) + 0.22) < 0.09 && z < 0.215 ? 0.35 : 1; // the line where the mandibles meet
|
|
297
|
+
for (let i = 0; i < 3; i++) col[i] = horn[i] * gape * (0.9 + 0.2 * Math.max(0, ny));
|
|
298
|
+
col[3] = HORN_TAG;
|
|
299
|
+
};
|
|
300
|
+
tube(
|
|
301
|
+
b,
|
|
302
|
+
[
|
|
303
|
+
[0.066, 0.07, 0.028, 0.034, 0.03, 0, 2.6],
|
|
304
|
+
[0.064, 0.1, 0.025, 0.031, 0.027, 0, 2.6],
|
|
305
|
+
[0.06, 0.14, 0.02, 0.026, 0.021, 0, 2.4],
|
|
306
|
+
[0.054, 0.18, 0.014, 0.02, 0.014, 0, 2.2],
|
|
307
|
+
[0.045, 0.215, 0.008, 0.014, 0.007, 0, 2],
|
|
308
|
+
[0.032, 0.24, 0.0035, 0.007, 0.002, 0, 2],
|
|
309
|
+
[0.022, 0.25, 0, 0, 0, 0],
|
|
310
|
+
],
|
|
311
|
+
{ chain: NO_BONES, around: 12, sub: 3, coat: bill },
|
|
312
|
+
);
|
|
313
|
+
const col = [0, 0, 0, 0];
|
|
314
|
+
for (let i = 0; i < 9; i++) {
|
|
315
|
+
const around = lerp(-1.2, 1.2, i / 8),
|
|
316
|
+
out = [Math.sin(around), Math.cos(around), 0],
|
|
317
|
+
root = [out[0] * 0.032, 0.066 + out[1] * 0.036, 0.085],
|
|
318
|
+
end = [out[0] * 0.024, 0.066 + out[1] * 0.03, 0.14 - Math.abs(around) * 0.012];
|
|
319
|
+
coat(col, root[0], root[1], root[2], out[0], out[1], 0);
|
|
320
|
+
feather(b, root, lerp3(root, end, 0.5), end, out, 0.011, col, tip, 2);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { lerp } from '../math/scalar.js';
|
|
3
|
+
import { tube } from './animal-skin.js';
|
|
4
|
+
import {
|
|
5
|
+
CORVID_LOOK,
|
|
6
|
+
CORVID_NECK,
|
|
7
|
+
CORVID_SIT,
|
|
8
|
+
NO_BONES,
|
|
9
|
+
corvidBody,
|
|
10
|
+
corvidHead,
|
|
11
|
+
corvidPalette,
|
|
12
|
+
feather,
|
|
13
|
+
lerp3,
|
|
14
|
+
placeIn,
|
|
15
|
+
unit,
|
|
16
|
+
} from './flier-corvid-body.js';
|
|
17
|
+
|
|
18
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
19
|
+
// A large corvid's wings (`flier-corvid-body.js` builds the rest): folded along the body over the tail, or spread in flight with
|
|
20
|
+
// the outer primaries narrowed into the fingers it soars on; and a whole bird perched with its wings folded, drawn into a builder
|
|
21
|
+
// with the rest of a scene's still parts.
|
|
22
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A wing folded along the body, in the body's frame (the caller moves it to its shoulder): the coverts over the shoulder, the
|
|
26
|
+
* primaries beneath, crossing over the tail, the secondaries over them and the tertials on top, over the back. Without `fine` the
|
|
27
|
+
* coverts' feathers are left to the surface's colour.
|
|
28
|
+
*
|
|
29
|
+
* @param {object} b The builder (`GB`).
|
|
30
|
+
* @param {1 | -1} s The side: 1 the right wing.
|
|
31
|
+
*/
|
|
32
|
+
export function foldedCorvidWing(b, s, coat, tip, fine = true) {
|
|
33
|
+
const col = [0, 0, 0, 0],
|
|
34
|
+
out = unit(s * 0.95, 0.3, 0),
|
|
35
|
+
X = p => [p[0] * s, p[1], p[2]];
|
|
36
|
+
for (let i = 0; i < 9; i++) {
|
|
37
|
+
const u = i / 8,
|
|
38
|
+
root = X([0.185 - 0.004 * u, lerp(0.62, 0.56, u), lerp(0.1, 0.0, u)]),
|
|
39
|
+
mid = X([0.15 - 0.003 * i, 0.44 - 0.01 * u, -0.22]),
|
|
40
|
+
end = X([lerp(0.07, 0.03, u), lerp(0.27, 0.24, u), lerp(-0.6, -0.64, u)]);
|
|
41
|
+
coat(col, root[0], root[1], root[2], out[0], out[1], out[2]);
|
|
42
|
+
feather(b, root, mid, end, out, 0.032, col, tip, 5);
|
|
43
|
+
}
|
|
44
|
+
for (let i = 0; i < 9; i++) {
|
|
45
|
+
const u = i / 8,
|
|
46
|
+
lift = 0.004 * (8 - i),
|
|
47
|
+
root = X([0.18 + lift, lerp(0.6, 0.5, u), lerp(0.05, -0.12, u)]),
|
|
48
|
+
end = X([lerp(0.175, 0.15, u) + lift, lerp(0.4, 0.36, u), lerp(-0.27, -0.36, u)]);
|
|
49
|
+
coat(col, root[0], root[1], root[2], out[0], out[1], out[2]);
|
|
50
|
+
feather(b, root, lerp3(root, end, 0.5), end, out, 0.04, col, tip);
|
|
51
|
+
}
|
|
52
|
+
const back = unit(s * 0.55, 0.83, 0);
|
|
53
|
+
for (let i = 0; i < 3; i++) {
|
|
54
|
+
const u = i / 2,
|
|
55
|
+
root = X([0.17, lerp(0.62, 0.57, u), lerp(0.02, -0.06, u)]),
|
|
56
|
+
end = X([lerp(0.12, 0.1, u), lerp(0.46, 0.44, u), lerp(-0.27, -0.31, u)]);
|
|
57
|
+
coat(col, root[0], root[1], root[2], back[0], back[1], back[2]);
|
|
58
|
+
feather(b, root, lerp3(root, end, 0.5), end, back, 0.046, col, tip);
|
|
59
|
+
}
|
|
60
|
+
// the coverts: a pad over the shoulder in short feathers that lie back
|
|
61
|
+
tube(
|
|
62
|
+
b,
|
|
63
|
+
[
|
|
64
|
+
[0.71, 0.15, 0, 0, 0, 0],
|
|
65
|
+
[0.69, 0.12, 0.03, 0.05, 0.05, 0],
|
|
66
|
+
[0.63, 0.04, 0.04, 0.075, 0.07, 0],
|
|
67
|
+
[0.55, -0.06, 0.035, 0.07, 0.06, 0],
|
|
68
|
+
[0.48, -0.13, 0.02, 0.05, 0.04, 0],
|
|
69
|
+
[0.45, -0.16, 0, 0, 0, 0],
|
|
70
|
+
],
|
|
71
|
+
{
|
|
72
|
+
chain: NO_BONES,
|
|
73
|
+
x: s * 0.152,
|
|
74
|
+
side: s,
|
|
75
|
+
around: 12,
|
|
76
|
+
sub: 2,
|
|
77
|
+
coat,
|
|
78
|
+
lay: 1,
|
|
79
|
+
droop: 0.1,
|
|
80
|
+
fur:
|
|
81
|
+
fine &&
|
|
82
|
+
((o, x, y, z, nx) => {
|
|
83
|
+
if (nx * s < 0.2) return false;
|
|
84
|
+
o[0] = 0.05;
|
|
85
|
+
o[1] = 0.06;
|
|
86
|
+
o[2] = 0.032;
|
|
87
|
+
o[3] = 2;
|
|
88
|
+
o[4] = 1.2;
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A wing spread in flight, about its shoulder: two rows of coverts along the arm, the secondaries trailing from it, and the
|
|
96
|
+
* primaries fanned from the wrist, the outer five narrowed into fingers.
|
|
97
|
+
*
|
|
98
|
+
* @param {object} b The builder (`GB`).
|
|
99
|
+
* @param {1 | -1} s The side: 1 the right wing.
|
|
100
|
+
*/
|
|
101
|
+
export function spreadCorvidWing(b, s, coat, tip) {
|
|
102
|
+
const col = [0, 0, 0, 0],
|
|
103
|
+
out = [0, 1, 0],
|
|
104
|
+
X = p => [p[0] * s, p[1], p[2]];
|
|
105
|
+
for (let i = 0; i < 11; i++) {
|
|
106
|
+
const u = i / 10,
|
|
107
|
+
root = X([lerp(0.04, 0.52, u), 0.005 * u, -0.01]),
|
|
108
|
+
end = X([lerp(0.07, 0.56, u), 0.01 * u - 0.01, -0.31 + 0.02 * u]);
|
|
109
|
+
coat(col, root[0], root[1], root[2], 0, 1, 0);
|
|
110
|
+
feather(b, root, lerp3(root, end, 0.5), end, out, 0.03, col, tip);
|
|
111
|
+
}
|
|
112
|
+
for (let i = 0; i < 10; i++) {
|
|
113
|
+
const u = i / 9,
|
|
114
|
+
angle = lerp(-1.25, 0.08, u), // from back along the wing's trailing edge round to out past the wrist
|
|
115
|
+
len = lerp(0.42, 0.6, Math.min(1, u * 1.4)) - (u > 0.9 ? 0.05 : 0),
|
|
116
|
+
root = X([lerp(0.52, 0.6, u), 0.01, lerp(-0.01, 0.04, u)]),
|
|
117
|
+
dir = X([Math.cos(angle), 0.04 + 0.06 * u, Math.sin(angle)]),
|
|
118
|
+
end = [root[0] + dir[0] * len, root[1] + dir[1] * len, root[2] + dir[2] * len];
|
|
119
|
+
coat(col, root[0], root[1], root[2], 0, 1, 0);
|
|
120
|
+
feather(b, root, lerp3(root, end, 0.5), end, out, u > 0.5 ? 0.022 : 0.032, col, tip, 5);
|
|
121
|
+
}
|
|
122
|
+
for (const [z, len, n] of [
|
|
123
|
+
[0.06, 0.14, 9],
|
|
124
|
+
[0.02, 0.17, 10],
|
|
125
|
+
])
|
|
126
|
+
for (let i = 0; i < n; i++) {
|
|
127
|
+
const u = i / (n - 1),
|
|
128
|
+
root = X([lerp(0.02, 0.6, u), 0.012 + 0.005 * (1 - u), z]),
|
|
129
|
+
end = X([lerp(0.04, 0.66, u), 0.01, z - len]);
|
|
130
|
+
coat(col, root[0], root[1], root[2], 0, 1, 0);
|
|
131
|
+
feather(b, root, lerp3(root, end, 0.5), end, out, 0.036, col, tip, 2);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* A corvid perched with its wings folded, drawn into the builder b in the frame F (its feet at F's origin, nose to F's +z), of one
|
|
137
|
+
* mesh with the rest of a scene's still parts; its contour feathers are left to the surface's colour (a bird of a roost, seen from
|
|
138
|
+
* further off).
|
|
139
|
+
*
|
|
140
|
+
* @param {object} b The builder (`GB`).
|
|
141
|
+
* @param {THREE.Matrix4} F
|
|
142
|
+
* @param {typeof CORVID_LOOK} [look=CORVID_LOOK] Its `height` is not read: F carries the bird's size.
|
|
143
|
+
*/
|
|
144
|
+
export function drawPerchedCorvid(b, F, look = CORVID_LOOK) {
|
|
145
|
+
const { coat, horn, tip } = corvidPalette(look),
|
|
146
|
+
frame = F.clone(), // F may be a matrix its maker reuses, which the eyes' placing would change under us
|
|
147
|
+
local = new THREE.Matrix4();
|
|
148
|
+
corvidBody(b, coat, horn, tip, frame, false);
|
|
149
|
+
placeIn(b, frame, local.makeTranslation(CORVID_NECK[0], CORVID_NECK[1], CORVID_NECK[2]));
|
|
150
|
+
corvidHead(b, coat, horn, tip);
|
|
151
|
+
placeIn(b, frame, local.makeTranslation(0, -CORVID_SIT, 0));
|
|
152
|
+
for (const s of [-1, 1]) foldedCorvidWing(b, s, coat, tip, false);
|
|
153
|
+
b.M = null;
|
|
154
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { GB } from './builder.js';
|
|
2
|
+
import { C, TRS, createUnitShapes, stick } from './primitives.js';
|
|
3
|
+
import { flierArrays, shapeBuilder, wingFan } from './flier-shapes.js';
|
|
4
|
+
|
|
5
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
6
|
+
// A long-bodied four-winged flier large enough to be ridden, facing +z with the top of its thorax at y 0.3 (metres): an
|
|
7
|
+
// enormous wedge of a head mostly faceted eyes, with working mandibles and two small arms tucked beneath it; a long thorax
|
|
8
|
+
// carrying a high saddle forward and a second, ridged saddle rising at its back like a cowl; four thin legs folded beneath the
|
|
9
|
+
// saddles; and a tail of many segments in bands of colour, some six metres long, held straight out behind. Whoever rides it is
|
|
10
|
+
// the caller's (`rider`). Its four wings, clear as glass, are a shape of their own, drawn apart. Arithmetic only, so a pool's
|
|
11
|
+
// workers can build it: `createLongFlierCompany` makes the geometries on the page.
|
|
12
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
13
|
+
|
|
14
|
+
/** The tail: where it starts and ends along z, and its radius there (metres). A company's shader sways what lies behind `from`. */
|
|
15
|
+
export const LONG_FLIER_TAIL = { from: -0.8, to: -6.9, r: [0.3, 0.085] };
|
|
16
|
+
|
|
17
|
+
/** A wing's length and its fore and hind chords, the wings' height, the fore and hind roots along z, and the hinge's x (metres). */
|
|
18
|
+
const WING = { long: 3.7, fore: 0.62, hind: 0.82, y: 0.3, zFore: 0.42, zHind: -0.2, hinge: 0.38 };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The flier's colours (hex, sRGB): `bands` the tail's hues, one running into the next down its length; `shell` the thorax and head,
|
|
22
|
+
* `plates` the plates down its back and its face, `eyes`, `rings` at the tail's joints, `saddle` and its `ridges`, `legs` and
|
|
23
|
+
* `claws` (with the mandibles); and the wings' linear colours, `clear` and the darker vein near each tip (`stigma`). The default
|
|
24
|
+
* is a dark bronze-green flier with a tail banded in blue and amber.
|
|
25
|
+
*/
|
|
26
|
+
export const LONG_FLIER_PALETTE = {
|
|
27
|
+
bands: [0x2f4a3a, 0x58502c, 0x3c4a5c, 0x5c4630, 0x2e3e58],
|
|
28
|
+
shell: 0x2b3a30,
|
|
29
|
+
plates: 0x18221c,
|
|
30
|
+
eyes: 0x1a2420,
|
|
31
|
+
rings: 0x12161a,
|
|
32
|
+
saddle: 0x2e231a,
|
|
33
|
+
ridges: 0x3c2e22,
|
|
34
|
+
legs: 0x202c26,
|
|
35
|
+
claws: 0x101412,
|
|
36
|
+
clear: [0.8, 0.84, 0.84],
|
|
37
|
+
stigma: [0.24, 0.2, 0.16],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let plainShapes = null; // the unit shapes made with the engine's own noise, when a caller passes none
|
|
41
|
+
const defaultShapes = () => (plainShapes ??= createUnitShapes());
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The flier's body (and its rider), as a builder's arrays.
|
|
45
|
+
*
|
|
46
|
+
* @param {object} [options]
|
|
47
|
+
* @param {boolean} [options.far=false] The lighter version for the far distance: no legs, arms or mandibles, and a tail of fewer
|
|
48
|
+
* segments.
|
|
49
|
+
* @param {typeof LONG_FLIER_PALETTE} [options.palette=LONG_FLIER_PALETTE]
|
|
50
|
+
* @param {(builder: GB, far: boolean) => void} [options.rider] Draws whoever rides it into the builder (in the flier's frame), near
|
|
51
|
+
* or far; none for a flier with an empty saddle.
|
|
52
|
+
* @param {object} [options.shapes] The unit shapes (`createUnitShapes`) the parts are made of.
|
|
53
|
+
* @returns {object} The builder's parts (`GB.parts`).
|
|
54
|
+
*/
|
|
55
|
+
export function longFlierBody({ far = false, palette = LONG_FLIER_PALETTE, rider = null, shapes = defaultShapes() } = {}) {
|
|
56
|
+
const U = shapes,
|
|
57
|
+
b = new GB(),
|
|
58
|
+
shell = C(palette.shell),
|
|
59
|
+
dark = C(palette.plates);
|
|
60
|
+
// the thorax, and the plates down its back
|
|
61
|
+
b.add(U.sph, shell, TRS(0, 0, 0.1, 1.05, 0.82, 2.1));
|
|
62
|
+
if (!far) for (let i = 0; i < 3; i++) b.add(U.sph, dark, TRS(0, 0.27 - i * 0.02, 0.62 - i * 0.55, 0.74, 0.2, 0.5));
|
|
63
|
+
// the head: a wedge, its face drawn down to the mandibles, the eyes covering most of it
|
|
64
|
+
b.add(U.sph, shell, TRS(0, 0.1, 1.42, 0.86, 0.6, 0.92, 0, 0.15));
|
|
65
|
+
b.add(U.sph, dark, TRS(0, -0.06, 1.86, 0.5, 0.36, 0.62, 0, 0.3));
|
|
66
|
+
// the compound eyes, faceted, wrapping the sides and top of the head
|
|
67
|
+
for (const s of [-1, 1]) b.add(U.sph, C(palette.eyes), TRS(s * 0.27, 0.2, 1.38, 0.46, 0.56, 0.66, s * 0.2));
|
|
68
|
+
tail(b, far ? 6 : 13, palette, U);
|
|
69
|
+
saddles(b, far, palette, U);
|
|
70
|
+
if (!far) limbs(b, palette);
|
|
71
|
+
if (rider) rider(b, far);
|
|
72
|
+
const parts = b.parts(!b.wide);
|
|
73
|
+
b.release();
|
|
74
|
+
return parts;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The tail: segments of chitin, each a short tube, with a darker ring at every joint; its hue runs through the bands.
|
|
78
|
+
function tail(b, n, palette, U) {
|
|
79
|
+
const T = LONG_FLIER_TAIL,
|
|
80
|
+
hues = palette.bands,
|
|
81
|
+
len = (T.from - T.to) / n,
|
|
82
|
+
ring = C(palette.rings);
|
|
83
|
+
for (let i = 0; i < n; i++) {
|
|
84
|
+
const u = (i + 0.5) / n,
|
|
85
|
+
r = T.r[0] + (T.r[1] - T.r[0]) * u,
|
|
86
|
+
z = T.from - i * len,
|
|
87
|
+
y = -0.04 + 0.05 * u * u, // a slight rise to the tip
|
|
88
|
+
h = (i / n) * (hues.length - 1),
|
|
89
|
+
a = C(hues[Math.floor(h)]),
|
|
90
|
+
c = C(hues[Math.min(hues.length - 1, Math.floor(h) + 1)]),
|
|
91
|
+
k = h - Math.floor(h),
|
|
92
|
+
shade = i % 2 ? 0.88 : 1;
|
|
93
|
+
b.add(
|
|
94
|
+
U.cyl,
|
|
95
|
+
[(a[0] + (c[0] - a[0]) * k) * shade, (a[1] + (c[1] - a[1]) * k) * shade, (a[2] + (c[2] - a[2]) * k) * shade],
|
|
96
|
+
TRS(0, y, z, 2 * r, len, 1.8 * r, 0, -Math.PI / 2),
|
|
97
|
+
);
|
|
98
|
+
b.add(U.cyl, ring, TRS(0, y, z + 0.03, 2.16 * r, 0.06, 1.96 * r, 0, -Math.PI / 2));
|
|
99
|
+
}
|
|
100
|
+
b.add(U.cone, C(hues[hues.length - 1]), TRS(0, 0.01, T.to, 2 * T.r[1], 0.45, 1.8 * T.r[1], 0, -Math.PI / 2)); // the tip
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// The high saddle forward, with its pommel and cantle, and the second saddle rising at the back of the thorax, ridged.
|
|
104
|
+
function saddles(b, far, palette, U) {
|
|
105
|
+
const s = C(palette.saddle);
|
|
106
|
+
b.add(U.box, s, TRS(0, 0.3, 0.55, 0.62, 0.12, 0.74));
|
|
107
|
+
b.add(U.box, s, TRS(0, 0.36, 0.92, 0.46, 0.32, 0.1, 0, -0.35));
|
|
108
|
+
b.add(U.box, s, TRS(0, 0.36, 0.2, 0.52, 0.3, 0.1, 0, 0.3));
|
|
109
|
+
// the second saddle: a shell rising from the back of the thorax and swept back over it, its ridges running up its back
|
|
110
|
+
b.add(U.dome, s, TRS(0, 0.22, -0.42, 0.74, 0.62, 0.7, 0, -0.55));
|
|
111
|
+
if (!far) for (let i = -1; i <= 1; i++) b.add(U.sph, C(palette.ridges), TRS(i * 0.17, 0.4, -0.56, 0.06, 0.1, 0.5, 0, -0.6));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Four thin legs folded up beneath the saddles, and two small arms tucked under the head; mandibles at the mouth.
|
|
115
|
+
function limbs(b, palette) {
|
|
116
|
+
const leg = C(palette.legs),
|
|
117
|
+
claw = C(palette.claws);
|
|
118
|
+
for (const s of [-1, 1]) {
|
|
119
|
+
for (const z of [0.55, -0.3]) {
|
|
120
|
+
// tucked up forward under the body in flight, as a dragonfly holds its legs
|
|
121
|
+
const hip = [s * 0.28, -0.22, z],
|
|
122
|
+
knee = [s * 0.46, -0.44, z - 0.18],
|
|
123
|
+
foot = [s * 0.2, -0.46, z + 0.38];
|
|
124
|
+
stick(b, hip, knee, 0.1, leg);
|
|
125
|
+
stick(b, knee, foot, 0.07, leg);
|
|
126
|
+
stick(b, foot, [foot[0] * 0.7, foot[1] + 0.03, foot[2] + 0.16], 0.04, claw);
|
|
127
|
+
}
|
|
128
|
+
const shoulder = [s * 0.18, -0.24, 1.15],
|
|
129
|
+
elbow = [s * 0.24, -0.44, 1.48];
|
|
130
|
+
stick(b, shoulder, elbow, 0.07, leg);
|
|
131
|
+
stick(b, elbow, [s * 0.08, -0.32, 1.78], 0.05, leg);
|
|
132
|
+
// a mandible: a curved pincer, closing in towards the other
|
|
133
|
+
const root = [s * 0.17, -0.16, 1.98],
|
|
134
|
+
bend = [s * 0.2, -0.2, 2.16];
|
|
135
|
+
stick(b, root, bend, 0.09, claw);
|
|
136
|
+
stick(b, bend, [s * 0.05, -0.23, 2.27], 0.06, claw);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The four wings: long, narrow and clear, a fore pair and a broader hind pair, each a fan from its root on the thorax's top; their
|
|
142
|
+
* weights (aW) are how far out from the hinge each corner lies, which the company's shader beats about. The vein near each tip
|
|
143
|
+
* (the pterostigma) is darker.
|
|
144
|
+
*
|
|
145
|
+
* @param {typeof LONG_FLIER_PALETTE} [palette=LONG_FLIER_PALETTE] Its `clear` and `stigma` colours.
|
|
146
|
+
* @returns {ReturnType<typeof flierArrays>}
|
|
147
|
+
*/
|
|
148
|
+
export function longFlierWings(palette = LONG_FLIER_PALETTE) {
|
|
149
|
+
const B = shapeBuilder(),
|
|
150
|
+
L = WING.long,
|
|
151
|
+
clear = palette.clear,
|
|
152
|
+
stigma = palette.stigma;
|
|
153
|
+
for (const side of [-1, 1])
|
|
154
|
+
for (const [z, chord] of [
|
|
155
|
+
[WING.zFore, WING.fore],
|
|
156
|
+
[WING.zHind, WING.hind],
|
|
157
|
+
]) {
|
|
158
|
+
const x = WING.hinge;
|
|
159
|
+
wingFan(
|
|
160
|
+
B,
|
|
161
|
+
side,
|
|
162
|
+
[x, z],
|
|
163
|
+
[
|
|
164
|
+
[x, z + chord * 0.3],
|
|
165
|
+
[x + L * 0.3, z + chord * 0.36],
|
|
166
|
+
[x + L * 0.7, z + chord * 0.32],
|
|
167
|
+
[x + L * 0.86, z + chord * 0.26],
|
|
168
|
+
[x + L * 0.97, z + chord * 0.12],
|
|
169
|
+
[x + L, z - chord * 0.08],
|
|
170
|
+
[x + L * 0.94, z - chord * 0.3],
|
|
171
|
+
[x + L * 0.7, z - chord * 0.5],
|
|
172
|
+
[x + L * 0.35, z - chord * 0.62],
|
|
173
|
+
[x + L * 0.12, z - chord * 0.58],
|
|
174
|
+
[x, z - chord * 0.3],
|
|
175
|
+
],
|
|
176
|
+
(px, pz) => (px > x + L * 0.8 && pz > z + chord * 0.05 ? stigma : clear),
|
|
177
|
+
x,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return flierArrays(B.geometry().translate(0, WING.y, 0));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The flier's shapes as arrays, to hand from a worker to the page: the body near and far, and the wings.
|
|
185
|
+
*
|
|
186
|
+
* @param {object} [options] As `longFlierBody` takes them: `palette`, `rider`, `shapes`.
|
|
187
|
+
* @returns {{ near: object, far: object, wings: ReturnType<typeof flierArrays> }}
|
|
188
|
+
*/
|
|
189
|
+
export function longFlierArrays({ palette = LONG_FLIER_PALETTE, rider = null, shapes = defaultShapes() } = {}) {
|
|
190
|
+
return {
|
|
191
|
+
near: longFlierBody({ far: false, palette, rider, shapes }),
|
|
192
|
+
far: longFlierBody({ far: true, palette, rider, shapes }),
|
|
193
|
+
wings: longFlierWings(palette),
|
|
194
|
+
};
|
|
195
|
+
}
|