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,178 @@
|
|
|
1
|
+
import { clamp, sstep, TAU } from '../math/scalar.js';
|
|
2
|
+
import { BONE, LEGS, stepRig } from './quadruped.js';
|
|
3
|
+
|
|
4
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
5
|
+
// A canine's bearing: what its body does on top of its gait (motion/quadruped.js moves the legs). It crouches before a
|
|
6
|
+
// spring and stretches through it, sits, lies down, lies dead; its head goes to what holds its attention; its jaw
|
|
7
|
+
// pants, snarls and bites; its ears, hackles and tail say the rest.
|
|
8
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
9
|
+
const CROUCH = 0, // the channels of a canine's bearing, each eased towards its target
|
|
10
|
+
SIT = 1,
|
|
11
|
+
LIE = 2,
|
|
12
|
+
LIMP = 3,
|
|
13
|
+
REACH = 4,
|
|
14
|
+
SNARL = 5,
|
|
15
|
+
NECK_X = 6,
|
|
16
|
+
NECK_Y = 7,
|
|
17
|
+
JAW = 8,
|
|
18
|
+
TAIL = 9,
|
|
19
|
+
EARS = 10,
|
|
20
|
+
CHANNELS = 11,
|
|
21
|
+
SIT_BACK = 0.78, // how far the back tips up when a dog sits, radians
|
|
22
|
+
_want = new Float32Array(CHANNELS),
|
|
23
|
+
_manner = { dy: 0, dz: 0, pitch: 0, hips: 0, chest: 0, legs: [0, 1, 2, 3].map(() => ({ y: 0, z: 0, a3: 0, a4: 0, w: 0 })) },
|
|
24
|
+
_frame = { x: 0, y: 0, z: 0, yaw: 0, s: 1, ground: null };
|
|
25
|
+
|
|
26
|
+
// Takes a foot off the ground towards a place of its own, by weight w; several such claims on one foot are averaged.
|
|
27
|
+
function hold(leg, w, y, z, a3, a4) {
|
|
28
|
+
if (w <= 0) return;
|
|
29
|
+
const k = w / (leg.w + w);
|
|
30
|
+
leg.y += (y - leg.y) * k;
|
|
31
|
+
leg.z += (z - leg.z) * k;
|
|
32
|
+
leg.a3 += (a3 - leg.a3) * k;
|
|
33
|
+
leg.a4 += (a4 - leg.a4) * k;
|
|
34
|
+
leg.w = Math.min(1, leg.w + w);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Where the head should turn to, as a turn of the neck to the side: towards the place it watches ({ x, z }), if it is in sight.
|
|
38
|
+
function gazeYaw(a, F) {
|
|
39
|
+
if (!F) return null;
|
|
40
|
+
const dx = F.x - a.x,
|
|
41
|
+
dz = F.z - a.z;
|
|
42
|
+
if (dx * dx + dz * dz < 2) return null;
|
|
43
|
+
let dy = Math.atan2(dx, dz) - a.yaw;
|
|
44
|
+
dy -= Math.round(dy / TAU) * TAU;
|
|
45
|
+
return Math.abs(dy) < 1.9 ? clamp(dy, -1, 1) : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Poses a canine for this frame, on top of its gait: crouching, springing, sitting, lying, lying dead, its head to what it
|
|
50
|
+
* watches, its jaw, lips, ears, hackles and tail.
|
|
51
|
+
* @param {object} a The animal: its rig (`canineRig`, with `u` its speed against its legs), group, place (x, y, z), yaw, seed,
|
|
52
|
+
* pose ('prowl', 'guard', 'strike', 'cower', 'sit', 'kneel' or 'dead') and fixY (null while its feet follow the ground).
|
|
53
|
+
* @param {number} dt Seconds since the last frame.
|
|
54
|
+
* @param {number} t Seconds of the clock.
|
|
55
|
+
* @param {{ w: number, cr: number, reach: number, jaw: number, worry: number } | null} blow A blow being struck, by weight w: cr a
|
|
56
|
+
* crouch, reach a spring's stretch, jaw a bite, worry the shaking of what it has caught.
|
|
57
|
+
* @param {((x: number, z: number) => number) | null} [ground] The ground's height, for feet that follow it; null to stand on y.
|
|
58
|
+
* @param {{ x: number, z: number } | null} [watch] What it looks at. Defaults to `a.lookAt`.
|
|
59
|
+
* @returns {number} How far its group should rise: nothing, since the body rises on its own legs.
|
|
60
|
+
*/
|
|
61
|
+
function caninePose(a, dt, t, blow, ground = null, watch = a.lookAt) {
|
|
62
|
+
const Q = a.rig,
|
|
63
|
+
B = Q.bones,
|
|
64
|
+
joints = Q.joints,
|
|
65
|
+
h = Q.leg,
|
|
66
|
+
S = a.hs || (a.hs = new Float32Array(CHANNELS)),
|
|
67
|
+
W = _want,
|
|
68
|
+
M = _manner,
|
|
69
|
+
pose = a.pose,
|
|
70
|
+
dead = pose === 'dead',
|
|
71
|
+
wary = pose === 'prowl' || pose === 'guard' || pose === 'strike',
|
|
72
|
+
fx = blow ? blow.w : 0,
|
|
73
|
+
worry = blow ? blow.worry * fx : 0,
|
|
74
|
+
run = sstep(0.9, 1.7, Q.u || 0),
|
|
75
|
+
brisk = sstep(0.05, 0.6, Q.u || 0);
|
|
76
|
+
W[CROUCH] = Math.max(pose === 'prowl' ? 0.35 : pose === 'cower' ? 0.6 : 0, blow ? blow.cr * fx : 0);
|
|
77
|
+
W[SIT] = pose === 'sit' ? 1 : 0;
|
|
78
|
+
W[LIE] = pose === 'kneel' ? 1 : 0;
|
|
79
|
+
W[LIMP] = dead ? 1 : 0;
|
|
80
|
+
W[REACH] = blow ? blow.reach * fx : 0;
|
|
81
|
+
W[SNARL] = dead ? 0.3 : Math.max(Q.breed.leer, wary ? 0.8 : 0, blow ? Math.max(blow.cr, blow.jaw) * fx : 0);
|
|
82
|
+
// the head: low and forward on the hunt and at a run, turned to what it watches when it stands
|
|
83
|
+
const look = dead || brisk > 0.5 ? null : gazeYaw(a, watch),
|
|
84
|
+
idle = Math.sin(t * 0.37 + a.seed * 30) * 0.3 * (1 - brisk);
|
|
85
|
+
W[NECK_Y] = look === null ? idle : idle * 0.25 + look * 0.75;
|
|
86
|
+
W[NECK_X] = dead
|
|
87
|
+
? 0.5
|
|
88
|
+
: 0.3 * run + (pose === 'prowl' ? 0.45 : 0) + 0.35 * W[CROUCH] - 0.2 * W[REACH] + 0.5 * worry + (pose === 'cower' ? 0.3 : 0);
|
|
89
|
+
const pant = run > 0.3 ? 0.2 + 0.05 * Math.sin(t * 15 + a.seed * 9) : 0;
|
|
90
|
+
W[JAW] = dead ? 0.3 : Math.max(pant, W[SNARL] * 0.14, blow ? blow.jaw * fx * 0.85 : 0) * (1 - 0.7 * worry);
|
|
91
|
+
W[TAIL] = dead ? 0 : pose === 'cower' ? -0.6 : 0.85 * run + 0.25 * brisk + (wary ? 0.45 : 0) + 0.5 * W[REACH];
|
|
92
|
+
W[EARS] = dead ? 0.4 : Math.max(W[SNARL], run * 0.8, pose === 'cower' ? 1 : 0);
|
|
93
|
+
const quick = Math.min(1, dt * (blow ? 20 : 5));
|
|
94
|
+
for (let i = 0; i < CHANNELS; i++) S[i] += (W[i] - S[i]) * quick;
|
|
95
|
+
|
|
96
|
+
// the body's manner, and the feet it takes off the ground
|
|
97
|
+
const sit = S[SIT],
|
|
98
|
+
lie = S[LIE],
|
|
99
|
+
limp = S[LIMP],
|
|
100
|
+
reach = S[REACH],
|
|
101
|
+
tip = -SIT_BACK * sit,
|
|
102
|
+
sy = joints[LEGS[0]][1] - joints[0][1], // the shoulders from the root: a sitting dog turns about them
|
|
103
|
+
sz = joints[LEGS[0]][2] - joints[0][2],
|
|
104
|
+
floor = joints[LEGS[0] + 1][1] - 0.06 * h; // how far the chest is from the ground
|
|
105
|
+
M.pitch = tip + 0.1 * S[CROUCH] * (1 - limp) - 0.3 * reach;
|
|
106
|
+
M.dy = -0.26 * h * S[CROUCH] - floor * lie - (sy * Math.cos(tip) - sz * Math.sin(tip) - sy) - (a.cur ? a.cur[6] : 0);
|
|
107
|
+
M.dz = -(sy * Math.sin(tip) + sz * Math.cos(tip) - sz) + 0.12 * h * reach;
|
|
108
|
+
M.chest = -0.22 * reach + 0.1 * Math.sin(t * 29) * worry;
|
|
109
|
+
M.hips = 0.2 * reach;
|
|
110
|
+
const rootY = joints[0][1] + M.dy,
|
|
111
|
+
rootZ = joints[0][2] + M.dz;
|
|
112
|
+
for (let k = 0; k < 4; k++) {
|
|
113
|
+
const leg = M.legs[k],
|
|
114
|
+
hind = k > 1,
|
|
115
|
+
L = Q.legs[k],
|
|
116
|
+
// the leg's pivot as the body will carry it
|
|
117
|
+
oy = joints[L.bone][1] - joints[0][1],
|
|
118
|
+
oz = joints[L.bone][2] - joints[0][2],
|
|
119
|
+
py = rootY + oy * Math.cos(M.pitch) - oz * Math.sin(M.pitch),
|
|
120
|
+
pz = rootZ + oy * Math.sin(M.pitch) + oz * Math.cos(M.pitch),
|
|
121
|
+
len = L.len[0] + L.len[1] + L.len[2],
|
|
122
|
+
odd = k % 2 ? 1 : -1;
|
|
123
|
+
leg.w = 0;
|
|
124
|
+
// sitting and lying, the hocks are on the ground with the paws ahead of them; lying, so are the forearms
|
|
125
|
+
if (hind) hold(leg, Math.max(sit, lie), 0, pz + 0.3 * h + odd * 0.02 * h, -1.25, 0);
|
|
126
|
+
else hold(leg, lie, 0, pz + 0.52 * h + odd * 0.03 * h, -1.3, 0);
|
|
127
|
+
// a spring: the forelegs thrown forward, the hind legs trailing
|
|
128
|
+
if (hind) hold(leg, reach, py - 0.5 * len, pz - 0.82 * len, 0.5, 0.9);
|
|
129
|
+
else hold(leg, reach, py - 0.42 * len, pz + 0.78 * len + odd * 0.05 * len, -0.25, 0.3);
|
|
130
|
+
// dead on its side: the legs lie loose
|
|
131
|
+
if (hind) hold(leg, limp, py - 0.82 * len, pz - (0.25 + odd * 0.12) * len, 0.3, 0.6);
|
|
132
|
+
else hold(leg, limp, py - 0.8 * len, pz + (0.3 + odd * 0.14) * len, 0.25, 0.7);
|
|
133
|
+
}
|
|
134
|
+
const F = _frame,
|
|
135
|
+
free = a.fixY === null || a.fixY === undefined;
|
|
136
|
+
F.x = a.x;
|
|
137
|
+
F.y = a.y;
|
|
138
|
+
F.z = a.z;
|
|
139
|
+
F.yaw = a.yaw;
|
|
140
|
+
F.s = a.group.scale.y;
|
|
141
|
+
F.ground = free && !dead ? ground : null;
|
|
142
|
+
stepRig(Q, F, dt, M);
|
|
143
|
+
|
|
144
|
+
// neck and head, kept level over whatever the body does
|
|
145
|
+
const level = -(Q.pitch + B[BONE.chest].rotation.x) * 0.8,
|
|
146
|
+
nx = S[NECK_X],
|
|
147
|
+
ny = S[NECK_Y],
|
|
148
|
+
nod = 0.04 * brisk * (1 - run) * Math.sin(Q.ph * TAU * 2),
|
|
149
|
+
shake = worry ? Math.sin(t * 29) * 0.4 * worry : 0;
|
|
150
|
+
B[BONE.neck].rotation.set(level * 0.6 + nx * 0.6 + nod, ny * 0.35 + shake * 0.3, 0);
|
|
151
|
+
B[BONE.neck2].rotation.set(level * 0.4 + nx * 0.4, ny * 0.35 + shake * 0.3, 0);
|
|
152
|
+
B[BONE.head].rotation.set(-nx * 0.45 - nod * 0.5 + 0.25 * limp, ny * 0.4 + shake * 0.5, shake * 0.3 + ny * 0.12 + Q.breed.tilt);
|
|
153
|
+
B[BONE.jaw].rotation.x = S[JAW];
|
|
154
|
+
// lips lifted off the teeth, ears laid back, hackles up
|
|
155
|
+
const snarl = S[SNARL],
|
|
156
|
+
lip = joints[BONE.lip],
|
|
157
|
+
head = joints[BONE.head],
|
|
158
|
+
crest = joints[BONE.crest],
|
|
159
|
+
chest = joints[BONE.chest];
|
|
160
|
+
B[BONE.lip].position.set(lip[0] - head[0], lip[1] - head[1] + snarl * 0.02 * Q.breed.head * h, lip[2] - head[2]);
|
|
161
|
+
B[BONE.crest].position.set(0, crest[1] - chest[1] + snarl * 0.045 * h, crest[2] - chest[2] + snarl * 0.02 * h);
|
|
162
|
+
const twitch = sstep(0.96, 1, Math.sin(t * 0.9 + a.seed * 40)) * Math.sin(t * 30) * 0.2;
|
|
163
|
+
B[BONE.earL].rotation.set(-0.9 * S[EARS] + twitch, 0, 0.25 * S[EARS]);
|
|
164
|
+
B[BONE.earR].rotation.set(-0.9 * S[EARS], 0, -0.25 * S[EARS]);
|
|
165
|
+
// the tail: streaming behind at a run, up when it threatens, tucked when it cowers; it sways, each joint after the last
|
|
166
|
+
const lift = S[TAIL],
|
|
167
|
+
sway = (0.16 * (1 - run) + 0.08) * (1 - limp),
|
|
168
|
+
beat = t * (1.7 + 2.5 * brisk) + a.seed * 20;
|
|
169
|
+
for (let i = 0; i < 3; i++)
|
|
170
|
+
B[BONE.tail + i].rotation.set(
|
|
171
|
+
lift * (i ? 0.25 : 0.7) + 0.06 * run * Math.sin(Q.ph * TAU - i),
|
|
172
|
+
sway * Math.sin(beat - i * 0.9) * (1 + i * 0.4),
|
|
173
|
+
0,
|
|
174
|
+
);
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { caninePose };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { geometryOf } from '../geometry/builder.js';
|
|
3
|
+
import { NO_ANIMAL_OPTIONS } from '../geometry/animal-options.js';
|
|
4
|
+
import { canineBodies, canineRig } from '../geometry/animal-canine-body.js';
|
|
5
|
+
import { caninePose } from './animal-canine-bearing.js';
|
|
6
|
+
import { castBeast } from './animal-bearing.js';
|
|
7
|
+
import { BONE, bindRig } from './quadruped.js';
|
|
8
|
+
|
|
9
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
10
|
+
// A herd's canine (a street dog, a cat: a breed on the four-legged skeleton, geometry/animal-canine-body.js) cast as still poses for
|
|
11
|
+
// the crowds (animal-herd-cast.js), as the rats of a swarm are: its walk at the herd's pace caught at even moments, and its rests at a halt, each a
|
|
12
|
+
// series from standing to the full of it: nosing at the ground, sitting, lying down. Arithmetic only, so a pool's workers can cast it.
|
|
13
|
+
// Cast at the skeleton's own size (a canine's withers WITHERS model units high); the crowd draws it at its own.
|
|
14
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
15
|
+
const STEP = 1 / 240, // seconds a step of the cast
|
|
16
|
+
SETTLE = 720, // steps to settle into a gait or a stand
|
|
17
|
+
STEPS = 4, // poses after standing in each rest's series
|
|
18
|
+
SIT_FULL = 0.97, // the share of its sit (or lie) at which a canine counts as down: its bearing eases there and never quite arrives
|
|
19
|
+
BEARING = { sit: 'sit', lie: 'kneel' }, // the bearing (animal-canine-bearing.js) each rest is cast from
|
|
20
|
+
MIDDLE = 1, // the detail of a herd canine's near skin (canineBodies): finer rings than its far skin, without a figure's locks and teeth
|
|
21
|
+
// nosing at the ground: how far the neck's two joints and the head bow at the full of it, radians
|
|
22
|
+
SNIFF = { neck: 0.95, neck2: 0.55, head: 0.35 };
|
|
23
|
+
|
|
24
|
+
// The canine's skins [far, middle] on its skeleton, standing at the origin on level ground, with what moves it.
|
|
25
|
+
function rigged(look, options) {
|
|
26
|
+
const bodies = canineBodies(look, MIDDLE, true, options).map(arrays => geometryOf(arrays)), // ears on both faces: a herd's material shows one
|
|
27
|
+
{ rig } = canineRig(look, options),
|
|
28
|
+
mesh = new THREE.SkinnedMesh(bodies[1]),
|
|
29
|
+
group = new THREE.Group();
|
|
30
|
+
bindRig(mesh, rig);
|
|
31
|
+
group.add(mesh);
|
|
32
|
+
return {
|
|
33
|
+
H: { mesh, near: bodies[1], far: bodies[0] },
|
|
34
|
+
a: { rig, pose: 'idle', seed: 0.41, x: 0, y: 0, z: 0, yaw: 0, group, fixY: 0, cur: null, hs: null },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// One step of the cast: the canine moved on `ahead` metres and posed.
|
|
39
|
+
function step(c, ahead, t) {
|
|
40
|
+
c.a.z += ahead;
|
|
41
|
+
c.a.group.position.z = c.a.z;
|
|
42
|
+
caninePose(c.a, STEP, t, null);
|
|
43
|
+
c.a.group.updateMatrixWorld(true);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Its walk at `speed` (metres a second at the skeleton's size) caught at n even moments of its stride, and the metres one stride covers.
|
|
47
|
+
function walkOf(c, speed, n, cast) {
|
|
48
|
+
const Q = c.a.rig,
|
|
49
|
+
frames = [];
|
|
50
|
+
let t = 0,
|
|
51
|
+
turned = 0;
|
|
52
|
+
const advance = () => {
|
|
53
|
+
const ph = Q.ph;
|
|
54
|
+
step(c, speed * STEP, (t += STEP));
|
|
55
|
+
turned += (Q.ph - ph + 1) % 1;
|
|
56
|
+
};
|
|
57
|
+
for (let i = 0; i < SETTLE; i++) advance();
|
|
58
|
+
turned = 0;
|
|
59
|
+
for (let i = 0; i < SETTLE; i++) advance();
|
|
60
|
+
const stride = (speed * SETTLE * STEP) / turned;
|
|
61
|
+
for (let k = 0; k < n; k++) {
|
|
62
|
+
// on to the moment the stride's phase reaches k / n (the phase wraps at 1)
|
|
63
|
+
const ahead = () => (Q.ph - k / n + 1.5) % 1 >= 0.5;
|
|
64
|
+
for (let guard = 0; guard < 2400 && ahead(); guard++) advance();
|
|
65
|
+
for (let guard = 0; guard < 2400 && !ahead(); guard++) advance();
|
|
66
|
+
frames.push(cast());
|
|
67
|
+
}
|
|
68
|
+
return { frames, stride };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// It stands still: settled on its feet with its bearing at rest.
|
|
72
|
+
function stand(c) {
|
|
73
|
+
c.a.pose = 'idle';
|
|
74
|
+
c.a.hs = null;
|
|
75
|
+
for (let i = 0; i < SETTLE; i++) step(c, 0, i * STEP);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// A rest's series: standing, then STEPS poses on to the full of it.
|
|
79
|
+
function restOf(c, rest, cast) {
|
|
80
|
+
stand(c);
|
|
81
|
+
const series = [cast()],
|
|
82
|
+
B = c.a.rig.bones;
|
|
83
|
+
if (rest === 'sniff') {
|
|
84
|
+
const base = [B[BONE.neck].rotation.x, B[BONE.neck2].rotation.x, B[BONE.head].rotation.x];
|
|
85
|
+
for (let k = 1; k <= STEPS; k++) {
|
|
86
|
+
const f = k / STEPS;
|
|
87
|
+
B[BONE.neck].rotation.x = base[0] + SNIFF.neck * f;
|
|
88
|
+
B[BONE.neck2].rotation.x = base[1] + SNIFF.neck2 * f;
|
|
89
|
+
B[BONE.head].rotation.x = base[2] + SNIFF.head * f;
|
|
90
|
+
c.a.group.updateMatrixWorld(true);
|
|
91
|
+
series.push(cast());
|
|
92
|
+
}
|
|
93
|
+
return series;
|
|
94
|
+
}
|
|
95
|
+
// sitting or lying down: its bearing eases into it, caught as it passes each step of the way
|
|
96
|
+
const channel = rest === 'sit' ? 1 : 2;
|
|
97
|
+
c.a.pose = BEARING[rest];
|
|
98
|
+
let t = 0;
|
|
99
|
+
for (let k = 1; k <= STEPS; k++)
|
|
100
|
+
for (let guard = 0; guard < 2400; guard++) {
|
|
101
|
+
step(c, 0, (t += STEP));
|
|
102
|
+
if (c.a.hs[channel] >= (SIT_FULL * k) / STEPS) {
|
|
103
|
+
series.push(cast());
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return series;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A canine of `look` for a herd (motion/animal-herd-cast.js): its skins [middle, far], a skin cast as it stands now, and its rests
|
|
112
|
+
* and walk cast as `cast` says.
|
|
113
|
+
* @param {{ look: object, size: number, speed: number, moments: number, rests: string[] }} input look: its look (`canineBodies`);
|
|
114
|
+
* size: the crowd's size of it (its withers against WITHERS model units); speed: the herd's pace, metres a second at that size;
|
|
115
|
+
* moments: how many moments of its walk are cast; rests: what it does at a halt ('sniff', 'sit' or 'lie').
|
|
116
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options]
|
|
117
|
+
*/
|
|
118
|
+
function canineHerd({ look, size, speed, moments, rests }, options = NO_ANIMAL_OPTIONS) {
|
|
119
|
+
const c = rigged(look, options);
|
|
120
|
+
return {
|
|
121
|
+
skins: [c.H.near, c.H.far],
|
|
122
|
+
skin: k => castBeast(c.H, k ? c.H.far : c.H.near),
|
|
123
|
+
// the pace at the skeleton's size that is the same gait as `speed` at the crowd's (a gait goes by speed over the root of size)
|
|
124
|
+
frames: cast => {
|
|
125
|
+
const walk = walkOf(c, speed / Math.sqrt(size), moments, cast);
|
|
126
|
+
return { rests: rests.map(rest => restOf(c, rest, cast)), walk };
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { canineHerd };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { NO_ANIMAL_OPTIONS, cachePerOptions } from '../geometry/animal-options.js';
|
|
3
|
+
import { buildCattle } from '../rendering/animal-cattle-figure.js';
|
|
4
|
+
import { castBeast, horsePose } from './animal-bearing.js';
|
|
5
|
+
import { BONE, LEGS } from './quadruped.js';
|
|
6
|
+
|
|
7
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
8
|
+
// Cattle and sheep as plain geometry, cast from a beast on its skeleton (rendering/animal-cattle-figure.js) after a few moments of standing or
|
|
9
|
+
// grazing, so that it stands as cattle stand: weight off a hind leg, ears and tail at rest. One model of each build is made
|
|
10
|
+
// where it is first wanted (the page, or a worker casting a land's herds), for each world's options: its near skin for the beasts close
|
|
11
|
+
// by, its far one for the rest. Nothing here touches the page, so a worker can do all of it.
|
|
12
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
13
|
+
const modelsOf = cachePerOptions(),
|
|
14
|
+
// A dead beast is laid on its left side by whoever places it (rolled about its length, its right side up): its legs then go
|
|
15
|
+
// out level over the ground, so the ones underneath lie a little bent towards it and the ones on top sag down onto them, and
|
|
16
|
+
// its head is turned on its neck, so the horn beneath lies along the ground instead of through it. Radians about its length.
|
|
17
|
+
DEAD = { under: -0.12, over: -0.5, head: -1.05 },
|
|
18
|
+
LENGTH = new THREE.Vector3(0, 0, 1), // the body's length, nose-wards
|
|
19
|
+
_turn = new THREE.Quaternion();
|
|
20
|
+
const cattleModel = (build, options) => (modelsOf(options)[build] ??= buildCattle(build, [2, 0], options));
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A beast of the build as one plain geometry, facing +z on y = 0, its head down at the grass or up.
|
|
24
|
+
* @param {boolean} grazing Its head down at the grass.
|
|
25
|
+
* @param {boolean} far The lighter copy.
|
|
26
|
+
* @param {string} build Its build's name (`buildCattle`).
|
|
27
|
+
* @param {boolean} [fallen] Dead, its legs loose, to be laid on its left side by whoever places it (rolled about its length).
|
|
28
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options]
|
|
29
|
+
* @returns {THREE.BufferGeometry}
|
|
30
|
+
*/
|
|
31
|
+
function castCattle(grazing, far, build, fallen = false, options = NO_ANIMAL_OPTIONS) {
|
|
32
|
+
const H = cattleModel(build, options);
|
|
33
|
+
H.graze = grazing ? 1 : 0;
|
|
34
|
+
H.down = fallen ? 1 : 0;
|
|
35
|
+
H.rig.px = null;
|
|
36
|
+
H.rig.seed = grazing ? 3.1 : 7.3; // which leg it rests and where its ears are: the same on every visit
|
|
37
|
+
H.mesh.updateMatrixWorld(true);
|
|
38
|
+
for (let i = 0, t = grazing ? 17 : 41; i < 40; i++) horsePose(H, 0.1, (t += 0.1), 0);
|
|
39
|
+
if (fallen) layOnSide(H.rig.bones);
|
|
40
|
+
const geo = castBeast(H, far ? H.far : H.near);
|
|
41
|
+
H.down = 0;
|
|
42
|
+
return geo;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function layOnSide(bones) {
|
|
46
|
+
// each leg swung about the body's length at its top joint; the left legs (even) are the ones underneath
|
|
47
|
+
LEGS.forEach((bone, k) => bones[bone].quaternion.premultiply(_turn.setFromAxisAngle(LENGTH, k % 2 ? DEAD.over : DEAD.under)));
|
|
48
|
+
bones[BONE.head].quaternion.premultiply(_turn.setFromAxisAngle(LENGTH, DEAD.head));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// The engine's static builder layout, by attribute name. The page binds the compact arrays
|
|
52
|
+
// without loading the skeleton or retaining an extra copy of their positions after upload.
|
|
53
|
+
const arraysOf = geo => Object.fromEntries(Object.entries(geo.attributes).map(([name, attribute]) => [name, attribute.array]));
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A worker's job: the casts of one build, each [grazing, far], as arrays by attribute name in the same order. Casts of one skin
|
|
57
|
+
* share its colours.
|
|
58
|
+
* @param {{ build: string, casts: boolean[][] }} spec
|
|
59
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options]
|
|
60
|
+
*/
|
|
61
|
+
const castArrays = ({ build, casts }, options = NO_ANIMAL_OPTIONS) =>
|
|
62
|
+
casts.map(([grazing, far]) => arraysOf(castCattle(grazing, far, build, false, options)));
|
|
63
|
+
|
|
64
|
+
export { castArrays, castCattle };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { NO_ANIMAL_OPTIONS } from '../geometry/animal-options.js';
|
|
2
|
+
import { buildCamel } from '../rendering/animal-camel-figure.js';
|
|
3
|
+
import { buildCattle } from '../rendering/animal-cattle-figure.js';
|
|
4
|
+
import { canineHerd } from './animal-canine-cast.js';
|
|
5
|
+
import { gatherPlan, gatherWith } from '../geometry/grid-gather.js';
|
|
6
|
+
import { henHerd } from '../geometry/animal-hen.js';
|
|
7
|
+
import { castBeast, herdFrames } from './animal-bearing.js';
|
|
8
|
+
import { rigHorse } from '../rendering/animal-horse-figure.js';
|
|
9
|
+
|
|
10
|
+
// A herd uses the middle skin even from the air: the visitor can walk among these same instances. A herd may be drawn in lighter
|
|
11
|
+
// levels further off, its far skin as it is or gathered on a grid (geometry/grid-gather.js).
|
|
12
|
+
const DETAIL = 1;
|
|
13
|
+
|
|
14
|
+
// A herd's beast of the four-legged kinds the horse's bearing poses (animal-bearing.js): a camel for the build 'camel' (and with a
|
|
15
|
+
// caravan's load, 'pack camel'), cattle of `build` when coat is null, else an unsaddled horse of that coat. Its skins: the middle
|
|
16
|
+
// one, and the far one only if a level is drawn from it.
|
|
17
|
+
function hoofedHerd({ build, coat, speed, moments, levels }, options) {
|
|
18
|
+
const detail = [DETAIL, levels.some(l => l.skin) ? 0 : DETAIL],
|
|
19
|
+
H =
|
|
20
|
+
build === 'camel' || build === 'pack camel'
|
|
21
|
+
? buildCamel(detail, build === 'pack camel', options)
|
|
22
|
+
: coat === null
|
|
23
|
+
? buildCattle(build, detail, options)
|
|
24
|
+
: rigHorse(null, coat, 0x6a2a26, false, build, false, detail, null, options);
|
|
25
|
+
return {
|
|
26
|
+
skins: [H.near, H.far],
|
|
27
|
+
skin: k => castBeast(H, k ? H.far : H.near),
|
|
28
|
+
frames: cast => {
|
|
29
|
+
const { heads, walk } = herdFrames(H, speed, moments, 4, cast);
|
|
30
|
+
return { rests: [heads], walk };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// The beast a herd's input names: a hen, a canine of a look (a street dog, a cat), or one of the hoofed kinds.
|
|
36
|
+
const sourceOf = (input, options) =>
|
|
37
|
+
input.build === 'hen' ? henHerd(input) : input.look ? canineHerd(input, options) : hoofedHerd(input, options);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A herd's beast cast as arrays, on a pool's workers or on the page where there are none: its levels, each with what every pose
|
|
41
|
+
* of it shares (colours and tags), its rests (each a series of poses from standing to the full of what it does at a halt:
|
|
42
|
+
* grazing, nosing at the ground, sitting, lying, pecking, settling), the moments of its walk at `speed` (metres a second), and
|
|
43
|
+
* its distance. Only positions, normals and bounds change with a pose.
|
|
44
|
+
* @param {object} input The beast: `build` ('hen', 'camel', 'pack camel', a cattle build with `coat` null, or a horse build with
|
|
45
|
+
* its coat), or a canine's `look` with its `size` and `rests`; its `speed` and walk's `moments`; and its `levels`, each
|
|
46
|
+
* { skin: 0 near or 1 far, cell: metres of the grid it is gathered on or none, from: metres off beyond which it is drawn,
|
|
47
|
+
* most: how many of a herd it draws at once, the rest going on to the next level (optional) }.
|
|
48
|
+
* @param {import('../geometry/animal-options.js').AnimalKitOptions} [options]
|
|
49
|
+
*/
|
|
50
|
+
function herdArrays(input, options = NO_ANIMAL_OPTIONS) {
|
|
51
|
+
const source = sourceOf(input, options),
|
|
52
|
+
levels = input.levels,
|
|
53
|
+
plans = levels.map(l => (l.cell ? gatherPlan(source.skins[l.skin], l.cell) : null)),
|
|
54
|
+
welds = levels.map((l, i) => (plans[i] ? null : weldOf(source.skins[l.skin]))),
|
|
55
|
+
// every level of the pose the source is in now, each skin cast once
|
|
56
|
+
cast = () => {
|
|
57
|
+
const skins = [];
|
|
58
|
+
return levels.map((l, i) => {
|
|
59
|
+
const geo = (skins[l.skin] ??= source.skin(l.skin));
|
|
60
|
+
return plans[i] ? gatherWith(plans[i], geo) : geo;
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
{ rests, walk } = source.frames(cast);
|
|
64
|
+
// a skin not on bones (a hen's) is built anew for each pose: its weld stands only if it holds in every one
|
|
65
|
+
levels.forEach((l, k) => {
|
|
66
|
+
if (
|
|
67
|
+
welds[k] &&
|
|
68
|
+
!welds[k].boned &&
|
|
69
|
+
!rests
|
|
70
|
+
.flat()
|
|
71
|
+
.concat(walk.frames)
|
|
72
|
+
.every(pose => holds(welds[k], pose[k]))
|
|
73
|
+
)
|
|
74
|
+
welds[k] = null;
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
levels: levels.map((l, k) => ({
|
|
78
|
+
...skinArrays(null, rests[0][0][k], welds[k]),
|
|
79
|
+
rests: rests.map(series => series.map(pose => packPose(pose[k], welds[k]))),
|
|
80
|
+
walk: { frames: walk.frames.map(pose => packPose(pose[k], welds[k])), stride: walk.stride },
|
|
81
|
+
from: l.from,
|
|
82
|
+
most: l.most ?? Infinity,
|
|
83
|
+
})),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The points of a skin that are one point: the same place, normal, colour, tag and bones (a beast's tubes repeat each point of
|
|
88
|
+
// their grid for every triangle that meets there), and so, on bones, the same in every pose. Gives the first of each (first),
|
|
89
|
+
// each point's number among those (index), and whether the skin is on bones (boned: else see holds).
|
|
90
|
+
function weldOf(geo) {
|
|
91
|
+
const A = geo.attributes,
|
|
92
|
+
arrays = ['position', 'normal', 'color', 'aTag', 'skinIndex', 'skinWeight'].filter(name => A[name]).map(name => A[name]),
|
|
93
|
+
n = A.position.count,
|
|
94
|
+
ids = new Map(),
|
|
95
|
+
first = [],
|
|
96
|
+
at = new Uint32Array(n);
|
|
97
|
+
for (let i = 0; i < n; i++) {
|
|
98
|
+
let key = '';
|
|
99
|
+
for (const a of arrays) for (let c = 0; c < a.itemSize; c++) key += a.array[i * a.itemSize + c] + ',';
|
|
100
|
+
let id = ids.get(key);
|
|
101
|
+
if (id === undefined) {
|
|
102
|
+
id = first.length;
|
|
103
|
+
ids.set(key, id);
|
|
104
|
+
first.push(i);
|
|
105
|
+
}
|
|
106
|
+
at[i] = id;
|
|
107
|
+
}
|
|
108
|
+
return { first: Uint32Array.from(first), index: first.length < 65535 ? Uint16Array.from(at) : at, at, boned: !!A.skinIndex };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Whether a pose keeps a weld: every point where the first of its kind is, and turned the same way.
|
|
112
|
+
function holds(weld, geo) {
|
|
113
|
+
const { position, normal } = geo.attributes,
|
|
114
|
+
{ first, at } = weld;
|
|
115
|
+
for (let i = 0; i < at.length; i++) {
|
|
116
|
+
const f = first[at[i]];
|
|
117
|
+
for (let c = 0; c < 3; c++)
|
|
118
|
+
if (position.array[i * 3 + c] !== position.array[f * 3 + c] || normal.array[i * 3 + c] !== normal.array[f * 3 + c]) return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// An attribute's array at the welded points only (all of it, without a weld).
|
|
124
|
+
function welded(attribute, weld) {
|
|
125
|
+
if (!weld) return attribute.array;
|
|
126
|
+
const s = attribute.itemSize,
|
|
127
|
+
src = attribute.array,
|
|
128
|
+
out = new src.constructor(weld.first.length * s);
|
|
129
|
+
weld.first.forEach((i, k) => {
|
|
130
|
+
for (let c = 0; c < s; c++) out[k * s + c] = src[i * s + c];
|
|
131
|
+
});
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// One cast pose as the arrays that change with a pose: positions, normals and its bounds; at the welded points, with a weld.
|
|
136
|
+
function packPose(geo, weld = null) {
|
|
137
|
+
geo.computeBoundingSphere();
|
|
138
|
+
const { center, radius } = geo.boundingSphere;
|
|
139
|
+
return {
|
|
140
|
+
position: welded(geo.attributes.position, weld),
|
|
141
|
+
normal: welded(geo.attributes.normal, weld),
|
|
142
|
+
sphere: [center.x, center.y, center.z, radius],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// What every pose of a beast's skin shares: its colours and tags (of its far skin, or of the geometry given); with a weld, at its
|
|
146
|
+
// points, and the triangles' index into them.
|
|
147
|
+
function skinArrays(beast, geo = beast.far, weld = null) {
|
|
148
|
+
const { color, aTag } = geo.attributes,
|
|
149
|
+
shared = { color: welded(color, weld), aTag: welded(aTag, weld) };
|
|
150
|
+
if (weld) shared.index = weld.index;
|
|
151
|
+
return shared;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { herdArrays, packPose, skinArrays, weldOf };
|