roamwright 0.20.1 → 0.55.1
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 +139 -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/cast-actors.js +379 -0
- package/motion/cast-manager.js +321 -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 +46 -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/cast-stage.js +299 -0
- 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/nameplate-groups.js +84 -0
- package/rendering/nameplates.js +386 -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,446 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { dim } from '../math/color.js';
|
|
3
|
+
import { HANGS, KIND, garmentTag } from './garment-tags.js';
|
|
4
|
+
import { C, TRS, plainUnitShapes } from './primitives.js';
|
|
5
|
+
import { loft } from './figure-sculpt.js';
|
|
6
|
+
import { GRIP_U, GRIP_V } from '../motion/figure-fingers.js';
|
|
7
|
+
import { BELT, HAND_L, HAND_R, ITEM_L, ITEM_R, SHOULDERS, STOWED } from '../motion/figure-bones.js';
|
|
8
|
+
import { bowGear } from './figure-bow.js';
|
|
9
|
+
|
|
10
|
+
const U = plainUnitShapes();
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* What a person carries: things worn on the body (a fiddle, a sack, a bow on the back), a weapon in the hand or put away at the
|
|
14
|
+
* hip, on the belt or across the back, a staff, a spear, a cane, a crossbow, a pipe, a tankard, a tray or a book. Each is built
|
|
15
|
+
* in a frame of its own on the bone that carries it: the origin is the middle of the grip and z runs along the blade or shaft.
|
|
16
|
+
* A world adds its own things through the figure builder's kit (createFigureBuilder: holds, blades, worn).
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* How each kind of thing is carried, by a look's `item`. r: the radius the fingers close round; stow: where it is worn until a
|
|
22
|
+
* fighting pose draws it ('hip', 'belt' or 'back'); up: kept upright by the wrist; rest: [upper arm, elbow, shoulder turn] of
|
|
23
|
+
* the carrying arm when the pose leaves it hanging; plant: its foot rests on the ground; both: one in each hand; left: held in
|
|
24
|
+
* the left hand; flat: laid on the open palm; bow: an archer's.
|
|
25
|
+
* @type {Object<string, object>}
|
|
26
|
+
*/
|
|
27
|
+
const HOLD = {
|
|
28
|
+
sword: { r: 0.015, stow: 'hip' },
|
|
29
|
+
rapier: { r: 0.013, stow: 'hip' },
|
|
30
|
+
daggers: { r: 0.012, stow: 'belt', both: 1 },
|
|
31
|
+
scimitars: { r: 0.015, stow: 'belt', both: 1 }, // one in each hand
|
|
32
|
+
axe: { r: 0.016, stow: 'back' },
|
|
33
|
+
bow: { r: 0.014, stow: 'back', left: 1, bow: 1 }, // in the left hand while its owner shoots, across the back otherwise (figure-bow.js)
|
|
34
|
+
crossbow: { r: 0.019, rest: [0, -0.5, 0] },
|
|
35
|
+
pipe: { r: 0.007, rest: [-0.25, -2.2, 0] },
|
|
36
|
+
staff: { r: 0.019, up: 1, plant: 1, rest: [-0.2, -1.05, 0] },
|
|
37
|
+
spear: { r: 0.017, up: 1, plant: 1, rest: [-0.2, -1.05, 0] },
|
|
38
|
+
cane: { r: 0.013, up: 1, plant: 1, rest: [-0.1, -0.55, 0] },
|
|
39
|
+
mug: { r: 0.011, up: 1, rest: [0.02, -1.45, 0] },
|
|
40
|
+
tray: { flat: 1, left: 1, level: 1, rest: [-0.08, -1.5, 0] },
|
|
41
|
+
book: { flat: 1, left: 1, rest: [0.12, -1.62, 0.85] },
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The blades, by a look's `item`: [blade length, blade width, colour ('steel' or a hex), guard width, the length of the grip
|
|
45
|
+
* behind the hand (a one-handed sword's if not said), the blade's shape: shape(length, width, colour, lod) => the rings of a
|
|
46
|
+
* rod along it from the hilt to the point ([z, half thickness, half width, colour], drawn with four sides; a smith's blade of
|
|
47
|
+
* diamond section if not said)].
|
|
48
|
+
* @type {Object<string, Array>}
|
|
49
|
+
*/
|
|
50
|
+
const BLADES = {
|
|
51
|
+
sword: [0.9, 0.05, 'steel', 0.15],
|
|
52
|
+
rapier: [0.95, 0.02, 'steel', 0.1],
|
|
53
|
+
daggers: [0.3, 0.034, 'steel', 0.07],
|
|
54
|
+
scimitars: [0.74, 0.056, 'steel', 0.09],
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Where a thing stowed on the back lies, by a look's `item`, where it is not slung as a sword is (SLUNG): [x, y, out, dx, dy,
|
|
58
|
+
* dz cloaked, dz bare], its grip's middle (out: behind the back's surface), and the way its blade or haft runs over a cloak
|
|
59
|
+
* and over bare cloth.
|
|
60
|
+
* @type {Object<string, number[]>}
|
|
61
|
+
*/
|
|
62
|
+
const SLINGS = {
|
|
63
|
+
axe: [-0.07, 1.02, -0.02, 0.22, 0.97, 0.1, 0.0], // thrust through the belt at the back, head up
|
|
64
|
+
};
|
|
65
|
+
const ONE_HAND_GRIP = 0.098, // how far a one-handed sword's grip and pommel reach behind the hand
|
|
66
|
+
SCABBARD_MOUTH = 0.06; // and how far before the middle of the grip a scabbard's mouth is, a blade being in it
|
|
67
|
+
const BELT_AT = 1.03, // the height a scabbard hangs from,
|
|
68
|
+
BACK_AT = [1.32, 0.07], // and where a weapon slung across the back lies on it: the height, and how far from the spine
|
|
69
|
+
SLUNG = [0.15, 1.5, 0, -0.25, -0.95, -0.14, -0.02]; // slung across the back, hilt over the right shoulder (SLINGS)
|
|
70
|
+
/** Turns a loft's rings along y into rings along z. */
|
|
71
|
+
const HORIZ = new THREE.Matrix4().makeRotationX(Math.PI / 2); // turns a loft's rings along y into rings along z
|
|
72
|
+
// Things worn on the body, built before the arms.
|
|
73
|
+
function wornItems(fig) {
|
|
74
|
+
const { body, L, lod } = fig,
|
|
75
|
+
hip = fig.trunk.hipX + 0.026; // just off the hip
|
|
76
|
+
fig.kit.worn?.(fig); // what the world's own looks wear (createFigureBuilder, worn)
|
|
77
|
+
if (L.item === 'fiddle') {
|
|
78
|
+
body.box(0.04, 0.98, -0.2, 0.2, 0.36, 0.07, fig.wood, 0, 0, 0.4);
|
|
79
|
+
body.box(-0.1, 1.32, -0.2, 0.04, 0.28, 0.04, C(0x3a2818), 0, 0, 0.4);
|
|
80
|
+
}
|
|
81
|
+
if (L.item === 'sack') {
|
|
82
|
+
if (!lod) body.tv = garmentTag(HANGS, KIND.linen);
|
|
83
|
+
body.add(U.sph, C(0x8a7a5a), TRS(-hip, 1.0, -0.24, 0.5, 0.66, 0.42));
|
|
84
|
+
body.tv = 0;
|
|
85
|
+
}
|
|
86
|
+
if (L.item === 'satchel') satchel(body, hip, lod);
|
|
87
|
+
if (L.item === 'rope') body.add(U.cyl6, C(0x8a7a5a), TRS(hip - 0.01, 0.8, 0.04, 0.18, 0.08, 0.18));
|
|
88
|
+
}
|
|
89
|
+
// A leather satchel hung at the hip from the belt: soft-sided, fuller below than at its mouth, its flap over the outer face
|
|
90
|
+
// held by a brass buckle, on two straps up to the belt. Rings [height, half its thickness out from the hip, half its width].
|
|
91
|
+
const SATCHEL = {
|
|
92
|
+
rings: [
|
|
93
|
+
[0.695, 0.012, 0.085],
|
|
94
|
+
[0.708, 0.04, 0.122],
|
|
95
|
+
[0.74, 0.055, 0.134],
|
|
96
|
+
[0.83, 0.056, 0.136],
|
|
97
|
+
[0.91, 0.046, 0.13],
|
|
98
|
+
[0.938, 0.03, 0.124],
|
|
99
|
+
[0.944, 0.004, 0.11],
|
|
100
|
+
],
|
|
101
|
+
out: 0.05, // its middle stands this far out from the hip
|
|
102
|
+
flap: 0.855, // the flap covers the outer face from this height up
|
|
103
|
+
square: 0.45, // how square its corners are (1 a lozenge, towards 0 a box)
|
|
104
|
+
},
|
|
105
|
+
LEATHER = 0x5a4a34,
|
|
106
|
+
BRASS = 0x9a8250;
|
|
107
|
+
function satchel(body, hip, lod) {
|
|
108
|
+
const leather = C(LEATHER),
|
|
109
|
+
buckle = C(BRASS),
|
|
110
|
+
x = hip + SATCHEL.out,
|
|
111
|
+
rings = SATCHEL.rings.map(([y, rx, rz]) => [y, rx, rz, x, 0, leather, BELT]), // it hangs from the belt, and swings on its bone
|
|
112
|
+
top = rings[rings.length - 1][0],
|
|
113
|
+
rounded = v => Math.sign(v) * Math.abs(v) ** SATCHEL.square;
|
|
114
|
+
if (!lod) {
|
|
115
|
+
body.tags.set(leather, garmentTag(0.3, KIND.leather));
|
|
116
|
+
body.tags.set(buckle, garmentTag(0, KIND.plate));
|
|
117
|
+
}
|
|
118
|
+
loft(body, 0, 0, 0, rings, 16, {
|
|
119
|
+
joined: true,
|
|
120
|
+
lay: (p, a, r) => {
|
|
121
|
+
p[0] = r[3] + rounded(Math.cos(a)) * r[1];
|
|
122
|
+
p[2] = r[4] + rounded(Math.sin(a)) * r[2];
|
|
123
|
+
},
|
|
124
|
+
tint: (p, a) => (Math.cos(a) > 0.3 && p[1] > SATCHEL.flap ? 0.72 : 1), // the flap, a darker hide than the bag's
|
|
125
|
+
});
|
|
126
|
+
body.bone = BELT;
|
|
127
|
+
body.box(x + 0.057, SATCHEL.flap + 0.012, 0, 0.01, 0.03, 0.026, buckle);
|
|
128
|
+
for (const z of [-0.085, 0.085]) body.box(x + 0.035, (top + BELT_AT) / 2, z, 0.01, BELT_AT - top + 0.03, 0.022, leather); // over the flap's top, up to the belt
|
|
129
|
+
body.bone = 0;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A part on a bone, in the frame M: add puts a shape in it, rod a tube of rings along z ([z, half thickness, half width,
|
|
133
|
+
* colour]), col a tube of rings along y starting at z.
|
|
134
|
+
* @param {object} body - The figure's GB builder.
|
|
135
|
+
* @param {number} bone - The bone it is skinned to.
|
|
136
|
+
* @param {THREE.Matrix4} M - Its frame in the body.
|
|
137
|
+
* @returns {{add: Function, rod: Function, col: Function}} The part, each method returning it again.
|
|
138
|
+
*/
|
|
139
|
+
function part(body, bone, M) {
|
|
140
|
+
const along = M.clone().multiply(HORIZ),
|
|
141
|
+
p = {
|
|
142
|
+
add(geo, col, m) {
|
|
143
|
+
body.bone = bone;
|
|
144
|
+
body.M = M;
|
|
145
|
+
body.add(geo, col, m);
|
|
146
|
+
body.bone = 0;
|
|
147
|
+
body.M = null;
|
|
148
|
+
return p;
|
|
149
|
+
},
|
|
150
|
+
rod(rings, seg = 6) {
|
|
151
|
+
body.M = along;
|
|
152
|
+
loft(
|
|
153
|
+
body,
|
|
154
|
+
0,
|
|
155
|
+
0,
|
|
156
|
+
0,
|
|
157
|
+
rings.map(r => [r[0], r[1], r[2], 0, 0, r[3], bone]),
|
|
158
|
+
seg,
|
|
159
|
+
);
|
|
160
|
+
body.M = null;
|
|
161
|
+
return p;
|
|
162
|
+
},
|
|
163
|
+
col(z, rings, seg = 4) {
|
|
164
|
+
body.M = M;
|
|
165
|
+
loft(
|
|
166
|
+
body,
|
|
167
|
+
0,
|
|
168
|
+
0,
|
|
169
|
+
z,
|
|
170
|
+
rings.map(r => [r[0], r[1], r[2], 0, 0, r[3], bone]),
|
|
171
|
+
seg,
|
|
172
|
+
);
|
|
173
|
+
body.M = null;
|
|
174
|
+
return p;
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
return p;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A frame at a point (px, py, pz) whose z runs along (dx, dy, dz), its y square to that and to (fx, fy, fz).
|
|
181
|
+
* @returns {THREE.Matrix4} The frame.
|
|
182
|
+
*/
|
|
183
|
+
function aimedFrame(px, py, pz, dx, dy, dz, fx, fy, fz) {
|
|
184
|
+
const z = new THREE.Vector3(dx, dy, dz).normalize(),
|
|
185
|
+
y = new THREE.Vector3().crossVectors(z, new THREE.Vector3(fx, fy, fz)).normalize(),
|
|
186
|
+
x = new THREE.Vector3().crossVectors(y, z);
|
|
187
|
+
return new THREE.Matrix4().makeBasis(x, y, z).setPosition(px, py, pz);
|
|
188
|
+
}
|
|
189
|
+
function bladeParts(blades, p, item, R, hiltOnly, lod, dark, steel, leather) {
|
|
190
|
+
// a hilt with pommel and guard, and a blade of diamond section with its edges in the plane of the knuckles
|
|
191
|
+
const [len, wid, tint, guard, grip = ONE_HAND_GRIP, shape] = blades[item],
|
|
192
|
+
col = tint === 'steel' ? steel : C(tint),
|
|
193
|
+
back = grip - ONE_HAND_GRIP; // how much further the grip and pommel reach behind the hand than a one-handed sword's
|
|
194
|
+
if (lod && hiltOnly) return;
|
|
195
|
+
p.rod(
|
|
196
|
+
lod
|
|
197
|
+
? [
|
|
198
|
+
[-0.08 - back, 0.012, 0.012, dark],
|
|
199
|
+
[0.05, 0.012, 0.014, dark],
|
|
200
|
+
]
|
|
201
|
+
: [
|
|
202
|
+
[-0.082 - back, 0.002, 0.002, dark],
|
|
203
|
+
[-0.076 - back, 0.017, 0.017, dark],
|
|
204
|
+
[-0.058 - back, 0.017, 0.017, dark],
|
|
205
|
+
[-0.052 - back, R, R, leather],
|
|
206
|
+
[0.046, R, R, leather],
|
|
207
|
+
[0.05, 0.012, 0.014, dark],
|
|
208
|
+
],
|
|
209
|
+
);
|
|
210
|
+
if (guard && !lod) p.add(U.box, dark, TRS(0, -guard / 2, 0.056, 0.022, guard, 0.016));
|
|
211
|
+
if (item === 'rapier' && !lod) p.add(U.sph, dark, TRS(0, 0, 0.05, 0.075, 0.075, 0.03));
|
|
212
|
+
if (hiltOnly) return;
|
|
213
|
+
if (shape) {
|
|
214
|
+
p.rod(shape(len, wid, col, lod), 4);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
p.rod(
|
|
218
|
+
[
|
|
219
|
+
[0.064, 0.0065, wid / 2, col],
|
|
220
|
+
[0.064 + len * 0.72, 0.0055, wid * 0.46, col],
|
|
221
|
+
[0.064 + len * 0.93, 0.004, wid * 0.3, col],
|
|
222
|
+
[0.064 + len, 0.0005, 0.002, col],
|
|
223
|
+
],
|
|
224
|
+
4,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A blade on its own, not in a hand: the same hilt and blade a figure carries, lying with the width of its blade and guard
|
|
229
|
+
* across the ground it rests on.
|
|
230
|
+
* @param {object} body - The GB builder it is built into, on bone 0.
|
|
231
|
+
* @param {string} item - The blade's name in `blades`.
|
|
232
|
+
* @param {number} radius - The grip's radius.
|
|
233
|
+
* @param {number} fittings - The pommel's and guard's colour (hex).
|
|
234
|
+
* @param {Object<string, Array>} [blades=FIGURE_BLADES] - The blades it is one of (createFigureBuilder's, with the world's own).
|
|
235
|
+
*/
|
|
236
|
+
function looseBlade(body, item, radius, fittings, blades = BLADES) {
|
|
237
|
+
const frame = new THREE.Matrix4().makeRotationZ(Math.PI / 2);
|
|
238
|
+
bladeParts(blades, part(body, 0, frame), item, radius, false, false, C(fittings), C(0xc3cbc8), C(0x69493d));
|
|
239
|
+
}
|
|
240
|
+
// The things a person holds, and what they wear that a fighting pose draws.
|
|
241
|
+
function heldGear(fig) {
|
|
242
|
+
const { body, L, lod, sx, trunk, hold } = fig,
|
|
243
|
+
dark = C(0x2a2622),
|
|
244
|
+
{ wood, steel, leather, metal } = fig;
|
|
245
|
+
const gripAt = (side, R) => [side * sx - side * (GRIP_U + R), SHOULDERS + GRIP_V + 0.95 * R, 0.004],
|
|
246
|
+
inHand = (side, R, bone) => part(body, bone, new THREE.Matrix4().makeTranslation(...gripAt(side, R)));
|
|
247
|
+
const blade = fig.kit.blades[L.item];
|
|
248
|
+
const weapon = (p, R, hiltOnly) => {
|
|
249
|
+
if (blade) {
|
|
250
|
+
bladeParts(fig.kit.blades, p, L.item, R, hiltOnly, lod, dark, steel, leather);
|
|
251
|
+
} else if (L.item === 'axe') {
|
|
252
|
+
p.rod([
|
|
253
|
+
[-0.15, 0.004, 0.004, wood],
|
|
254
|
+
[-0.14, 0.016, 0.018, wood],
|
|
255
|
+
[0.3, 0.015, 0.017, wood],
|
|
256
|
+
[0.6, 0.016, 0.02, wood],
|
|
257
|
+
[0.62, 0.003, 0.003, wood],
|
|
258
|
+
]);
|
|
259
|
+
p.col(0.52, [
|
|
260
|
+
[0.04, 0.004, 0.03, steel],
|
|
261
|
+
[0.03, 0.019, 0.045, steel],
|
|
262
|
+
[-0.03, 0.017, 0.05, steel],
|
|
263
|
+
[-0.13, 0.007, 0.085, steel],
|
|
264
|
+
[-0.185, 0.0008, 0.105, steel],
|
|
265
|
+
]);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
if (hold && hold.bow) bowGear(fig, hold.r, -(trunk.reach(BACK_AT[0], -1, 1, BACK_AT[1]) + (L.cloak ? 0.07 : 0.025)));
|
|
269
|
+
else if (hold && hold.stow) {
|
|
270
|
+
// where each hand's weapon lies put away, for drawing it out along its length (the world's own drawing of it): the frame of the
|
|
271
|
+
// one put away (its grip's middle, z along the blade), and the middle of the hand's grip, in the body as built
|
|
272
|
+
const stowed = (M, side) => ({ frame: M.toArray(), grip: gripAt(side, R) }),
|
|
273
|
+
R = hold.r,
|
|
274
|
+
hipX = trunk.at(BELT_AT).rx + 0.034, // off the hip at the belt,
|
|
275
|
+
backZ = -(trunk.reach(BACK_AT[0], -1, 1, BACK_AT[1]) + (L.cloak ? 0.07 : 0.025)); // and behind the shoulder blades, over a cloak if one is worn
|
|
276
|
+
weapon(inHand(1, R, ITEM_R), R, false);
|
|
277
|
+
if (hold.both) weapon(inHand(-1, R, ITEM_L), R, false);
|
|
278
|
+
if (hold.stow === 'hip') {
|
|
279
|
+
// a scabbard at the left hip; the hilt shows in it until the sword is drawn
|
|
280
|
+
const M = aimedFrame(-hipX, 1.045, 0.03, -0.1, -0.9, -0.42, 1, 0, 0),
|
|
281
|
+
len = blade[0],
|
|
282
|
+
wid = blade[1];
|
|
283
|
+
part(body, BELT, M).rod(
|
|
284
|
+
lod
|
|
285
|
+
? [
|
|
286
|
+
[0.06, 0.011, wid / 2 + 0.007, leather],
|
|
287
|
+
[0.064 + len + 0.01, 0.005, 0.007, leather],
|
|
288
|
+
]
|
|
289
|
+
: [
|
|
290
|
+
[0.06, 0.011, wid / 2 + 0.007, leather],
|
|
291
|
+
[0.064 + len * 0.9, 0.009, wid * 0.4 + 0.006, leather],
|
|
292
|
+
[0.064 + len + 0.004, 0.006, 0.008, metal],
|
|
293
|
+
[0.064 + len + 0.016, 0.001, 0.001, metal],
|
|
294
|
+
],
|
|
295
|
+
);
|
|
296
|
+
if (!lod) part(body, BELT, M).add(U.box, leather, TRS(0.01, -0.012, 0.1, 0.03, 0.024, 0.05));
|
|
297
|
+
weapon(part(body, STOWED, M), R, true);
|
|
298
|
+
fig.sheaths = { kind: 'hip', mouth: SCABBARD_MOUTH, tip: SCABBARD_MOUTH + len, hands: [stowed(M, 1), null] };
|
|
299
|
+
} else if (hold.stow === 'belt') {
|
|
300
|
+
fig.sheaths = { kind: 'belt', mouth: SCABBARD_MOUTH, tip: SCABBARD_MOUTH + blade[0], hands: [null, null] };
|
|
301
|
+
for (const sd of [-1, 1]) {
|
|
302
|
+
// a sheath at each hip, each drawn from by the hand on its side
|
|
303
|
+
const M = aimedFrame(sd * hipX, 1.03, 0.0, sd * 0.12, -0.95, -0.28, 1, 0, 0),
|
|
304
|
+
len = blade[0],
|
|
305
|
+
wid = blade[1];
|
|
306
|
+
part(body, BELT, M).rod([
|
|
307
|
+
[0.058, 0.01, wid / 2 + 0.006, leather],
|
|
308
|
+
[0.064 + len * 0.85, 0.008, wid * 0.4 + 0.005, leather],
|
|
309
|
+
[0.064 + len + 0.012, 0.001, 0.001, leather],
|
|
310
|
+
]);
|
|
311
|
+
weapon(part(body, STOWED, M), R, true);
|
|
312
|
+
fig.sheaths.hands[sd > 0 ? 0 : 1] = stowed(M, sd);
|
|
313
|
+
}
|
|
314
|
+
} else {
|
|
315
|
+
const [x, y, out, dx, dy, cloaked, bare] = fig.kit.slings[L.item] || SLUNG,
|
|
316
|
+
M = aimedFrame(x, y, out ? backZ + out : backZ, dx, dy, L.cloak ? cloaked : bare, 0, 0, 1);
|
|
317
|
+
weapon(part(body, STOWED, M), R, false);
|
|
318
|
+
fig.sheaths = { kind: 'back', mouth: 0, tip: 0, hands: [stowed(M, 1), null] };
|
|
319
|
+
}
|
|
320
|
+
} else if (hold && hold.r)
|
|
321
|
+
heldInHand(inHand(1, hold.r, L.item === 'spear' ? ITEM_R : HAND_R), L.item, hold.r, wood, steel, dark); // a spear's shaft turns in the fist
|
|
322
|
+
else if (hold && hold.flat)
|
|
323
|
+
flatInHand(part(body, HAND_L, new THREE.Matrix4().makeTranslation(-sx + 0.017, SHOULDERS - 0.705, 0.004)), L.item);
|
|
324
|
+
}
|
|
325
|
+
// What the right hand holds by its grip, of radius R.
|
|
326
|
+
function heldInHand(p, it, R, wood, steel, dark) {
|
|
327
|
+
if (it === 'staff')
|
|
328
|
+
p.rod(
|
|
329
|
+
[
|
|
330
|
+
[-0.98, 0.006, 0.006, wood],
|
|
331
|
+
[-0.96, 0.014, 0.014, wood],
|
|
332
|
+
[-0.4, 0.019, 0.018, wood],
|
|
333
|
+
[0, R, R, wood],
|
|
334
|
+
[0.45, 0.02, 0.019, wood],
|
|
335
|
+
[0.76, 0.021, 0.022, wood],
|
|
336
|
+
[0.82, 0.032, 0.03, wood],
|
|
337
|
+
[0.87, 0.027, 0.028, wood],
|
|
338
|
+
[0.89, 0.004, 0.004, wood],
|
|
339
|
+
],
|
|
340
|
+
7,
|
|
341
|
+
);
|
|
342
|
+
else if (it === 'spear') {
|
|
343
|
+
p.rod([
|
|
344
|
+
[-0.98, 0.005, 0.005, wood],
|
|
345
|
+
[-0.96, 0.014, 0.014, wood],
|
|
346
|
+
[0, R, R, wood],
|
|
347
|
+
[1.1, 0.014, 0.014, wood],
|
|
348
|
+
[1.12, 0.017, 0.017, dark],
|
|
349
|
+
[1.17, 0.012, 0.012, dark],
|
|
350
|
+
]);
|
|
351
|
+
p.rod(
|
|
352
|
+
[
|
|
353
|
+
[1.16, 0.004, 0.012, steel],
|
|
354
|
+
[1.22, 0.007, 0.038, steel],
|
|
355
|
+
[1.36, 0.004, 0.02, steel],
|
|
356
|
+
[1.45, 0.0005, 0.001, steel],
|
|
357
|
+
],
|
|
358
|
+
4,
|
|
359
|
+
);
|
|
360
|
+
} else if (it === 'cane') {
|
|
361
|
+
const ebony = C(0x15151a),
|
|
362
|
+
silver = C(0xb9bcc4);
|
|
363
|
+
p.rod(
|
|
364
|
+
[
|
|
365
|
+
[-0.8, 0.004, 0.004, silver],
|
|
366
|
+
[-0.785, 0.011, 0.011, silver],
|
|
367
|
+
[-0.76, 0.011, 0.011, ebony],
|
|
368
|
+
[0, R, R, ebony],
|
|
369
|
+
[0.06, R, R, ebony],
|
|
370
|
+
[0.066, 0.022, 0.022, silver],
|
|
371
|
+
[0.09, 0.024, 0.024, silver],
|
|
372
|
+
[0.108, 0.014, 0.014, silver],
|
|
373
|
+
[0.112, 0.002, 0.002, silver],
|
|
374
|
+
],
|
|
375
|
+
7,
|
|
376
|
+
);
|
|
377
|
+
} else if (it === 'crossbow') {
|
|
378
|
+
p.rod([
|
|
379
|
+
[-0.13, 0.004, 0.006, wood],
|
|
380
|
+
[-0.12, 0.018, 0.03, wood],
|
|
381
|
+
[-0.03, R, 0.024, wood],
|
|
382
|
+
[0.04, R, 0.022, wood],
|
|
383
|
+
[0.3, 0.017, 0.02, wood],
|
|
384
|
+
[0.5, 0.015, 0.017, wood],
|
|
385
|
+
[0.52, 0.003, 0.003, wood],
|
|
386
|
+
]);
|
|
387
|
+
for (const sd of [-1, 1]) {
|
|
388
|
+
p.add(U.box, dark, TRS(sd * 0.14, 0.006, 0.44, 0.3, 0.02, 0.032, sd * 0.28));
|
|
389
|
+
p.add(U.box, C(0xb8ac90), TRS(sd * 0.135, 0.012, 0.335, 0.31, 0.005, 0.005, -sd * 0.52));
|
|
390
|
+
}
|
|
391
|
+
p.add(U.box, steel, TRS(0, 0.018, 0.2, 0.012, 0.008, 0.26));
|
|
392
|
+
} else if (it === 'pipe') {
|
|
393
|
+
p.rod([
|
|
394
|
+
[-0.045, 0.006, 0.006, wood],
|
|
395
|
+
[-0.03, 0.007, 0.007, wood],
|
|
396
|
+
[0.07, 0.0045, 0.0045, dark],
|
|
397
|
+
[0.105, 0.004, 0.003, dark],
|
|
398
|
+
[0.11, 0.001, 0.001, dark],
|
|
399
|
+
]);
|
|
400
|
+
p.add(U.cyl6, wood, TRS(0, 0.004, -0.045, 0.032, 0.05, 0.032, 0, Math.PI));
|
|
401
|
+
p.add(U.cyl6, C(0x8a2a12), TRS(0, -0.047, -0.045, 0.022, 0.002, 0.022, 0, Math.PI));
|
|
402
|
+
} else if (it === 'mug') {
|
|
403
|
+
// a tankard: the hand goes through the handle, the bowl stands in front of the knuckles
|
|
404
|
+
const pewter = C(0x7a6a52),
|
|
405
|
+
bx = -(R + 0.024 + 0.05);
|
|
406
|
+
p.rod([
|
|
407
|
+
[-0.064, 0.004, 0.004, pewter],
|
|
408
|
+
[-0.058, R, R, pewter],
|
|
409
|
+
[0.058, R, R, pewter],
|
|
410
|
+
[0.064, 0.004, 0.004, pewter],
|
|
411
|
+
]);
|
|
412
|
+
for (const z of [-0.052, 0.052]) p.add(U.box, pewter, TRS(bx / 2, -0.008, z, -bx, 0.016, 0.014));
|
|
413
|
+
p.add(U.cyl, pewter, TRS(bx, 0, -0.068, 0.1, 0.14, 0.1, 0, Math.PI / 2));
|
|
414
|
+
p.add(U.cyl, dim(pewter, 1.25), TRS(bx, 0, 0.066, 0.106, 0.008, 0.106, 0, Math.PI / 2));
|
|
415
|
+
p.add(U.cyl, C(0x2a1808), TRS(bx, 0, 0.0745, 0.086, 0.001, 0.086, 0, Math.PI / 2));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
// Things that lie against the open left palm: a tray with its cups, or a closed book.
|
|
419
|
+
function flatInHand(p, it) {
|
|
420
|
+
const q = Math.PI / 2;
|
|
421
|
+
if (it === 'tray') {
|
|
422
|
+
const tin = C(0x8a8478),
|
|
423
|
+
pewter = C(0x7a6a52);
|
|
424
|
+
p.add(U.cyl16, tin, TRS(0, 0, 0, 0.4, 0.012, 0.4, 0, 0, -q));
|
|
425
|
+
p.add(U.cyl16, dim(tin, 0.8), TRS(0.012, 0, 0, 0.36, 0.002, 0.36, 0, 0, -q));
|
|
426
|
+
for (const [y, z, d, hgt] of [
|
|
427
|
+
[0.09, 0.07, 0.085, 0.11],
|
|
428
|
+
[-0.07, 0.09, 0.085, 0.11],
|
|
429
|
+
[-0.04, -0.09, 0.085, 0.11],
|
|
430
|
+
[0.08, -0.07, 0.1, 0.17],
|
|
431
|
+
]) {
|
|
432
|
+
p.add(U.cyl, hgt > 0.12 ? C(0x6a4a30) : pewter, TRS(0.013, y, z, d, hgt, d, 0, 0, -q));
|
|
433
|
+
p.add(U.cyl, C(0x2a1808), TRS(0.013 + hgt, y, z, d * 0.82, 0.001, d * 0.82, 0, 0, -q));
|
|
434
|
+
}
|
|
435
|
+
} else {
|
|
436
|
+
// a closed book: boards, spine and the block of pages between them
|
|
437
|
+
const boards = C(0x6a2a24),
|
|
438
|
+
pages = C(0xcfc4a4);
|
|
439
|
+
p.add(U.box, boards, TRS(0.004, -0.09, 0, 0.006, 0.18, 0.24));
|
|
440
|
+
p.add(U.box, boards, TRS(0.046, -0.09, 0, 0.006, 0.18, 0.24));
|
|
441
|
+
p.add(U.box, boards, TRS(0.025, -0.09, -0.117, 0.048, 0.18, 0.007));
|
|
442
|
+
p.add(U.box, pages, TRS(0.025, -0.084, 0.0, 0.037, 0.168, 0.226));
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export { BLADES as FIGURE_BLADES, HOLD as FIGURE_HOLDS, SLINGS as FIGURE_SLINGS, HORIZ, aimedFrame, heldGear, looseBlade, part, wornItems };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hair of a far body (and of the light one a crowd draws furthest off): one close layer over the scalp, as full as a near
|
|
3
|
+
* head's hair with its locks, ending in the hairline; the fall of long hair as one sheet; and what a tied cut gathers behind
|
|
4
|
+
* the head, each a plain rope or knot. A near body's hair is figure-hair.js's.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { sstep, TAU } from '../math/scalar.js';
|
|
8
|
+
import { TRS, plainUnitShapes } from './primitives.js';
|
|
9
|
+
import { SKULL } from './head-presets.js';
|
|
10
|
+
import { capFn, loft, sculptMesh } from './figure-sculpt.js';
|
|
11
|
+
|
|
12
|
+
const U = plainUnitShapes();
|
|
13
|
+
|
|
14
|
+
const OVER = [1.045, 1.02, 1.035]; // a layer of hair that lies close on the skull: across, up, and fore and aft
|
|
15
|
+
|
|
16
|
+
// The fall of long hair down the back: rings of [height above the ground, half-width, half-depth, middle fore and aft] from
|
|
17
|
+
// above the ears down, and the height it ends at.
|
|
18
|
+
function fallShape(fig, cut) {
|
|
19
|
+
const { HY } = fig,
|
|
20
|
+
k = cut.thick || 1,
|
|
21
|
+
end = cut.falls + (fig.hairPick - 0.5) * 0.2,
|
|
22
|
+
rings = [
|
|
23
|
+
[HY + 0.04, 0.082 * k, 0.098, -0.006],
|
|
24
|
+
[HY - 0.07, 0.088 * k, 0.096, -0.014],
|
|
25
|
+
...(end < 1.44
|
|
26
|
+
? [
|
|
27
|
+
[1.47, 0.108 * k, 0.083, -0.03],
|
|
28
|
+
[(1.47 + end) / 2, 0.122 * k, 0.073, -0.05],
|
|
29
|
+
[end, 0.108 * k, 0.058, -0.062],
|
|
30
|
+
]
|
|
31
|
+
: [[end, 0.098 * k, 0.094, -0.02]]), // a fall that ends above the shoulders
|
|
32
|
+
];
|
|
33
|
+
return { rings, end };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The fall as one sheet.
|
|
37
|
+
function fall(fig, cut) {
|
|
38
|
+
const { body, hair } = fig,
|
|
39
|
+
{ rings } = fallShape(fig, cut),
|
|
40
|
+
A0 = Math.PI + 0.1,
|
|
41
|
+
A1 = TAU - 0.1;
|
|
42
|
+
loft(
|
|
43
|
+
body,
|
|
44
|
+
0,
|
|
45
|
+
0,
|
|
46
|
+
0,
|
|
47
|
+
rings.map(r => [r[0], r[1], r[2], 0, r[3], hair, 1, 0, sstep(1.4, 1.5, r[0])]),
|
|
48
|
+
12,
|
|
49
|
+
{ a0: A0, a1: A0 + (A1 - A0), fold: (v, a) => 1 + 0.05 * Math.cos(a * 17) + v * 0.05 * Math.cos(a * 9) },
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The leather that binds a tail or a knot on the crown. It is not hair: it is drawn untagged, with the shading of leather.
|
|
54
|
+
function bind(fig, head, style) {
|
|
55
|
+
const { body, leather, HY } = fig,
|
|
56
|
+
tag = body.tv,
|
|
57
|
+
at =
|
|
58
|
+
style === 'swept' || style === 'tail'
|
|
59
|
+
? TRS(0, HY - 0.062, -0.106, 0.036, 0.013, 0.036, 0, 0.5)
|
|
60
|
+
: style === 'topknot'
|
|
61
|
+
? TRS(0, HY + 0.108, -0.03, 0.03, 0.012, 0.03)
|
|
62
|
+
: null;
|
|
63
|
+
if (!at) return;
|
|
64
|
+
body.tv = 0;
|
|
65
|
+
head.hd.add(U.cyl6, leather, at);
|
|
66
|
+
body.tv = tag;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// What a tied cut gathers behind the head: a queue, a tail, a bun, a plait, a knot on the crown, or braids.
|
|
70
|
+
function tie(fig, head, style) {
|
|
71
|
+
const { body, hair, HY } = fig,
|
|
72
|
+
{ hd } = head,
|
|
73
|
+
strand = (y, rx, rz, cz, bone, weight) => [y, rx, rz, 0, cz, hair, bone, 0, weight],
|
|
74
|
+
rope = (rings, fold, x = 0, z = -0.1) => loft(body, x, 0, z, rings, 6, { fold });
|
|
75
|
+
if (style !== 'topknot') bind(fig, head, style);
|
|
76
|
+
if (style === 'swept')
|
|
77
|
+
rope(
|
|
78
|
+
[
|
|
79
|
+
strand(HY - 0.045, 0.019, 0.019, -0.004, 1, 1),
|
|
80
|
+
strand(HY - 0.085, 0.024, 0.021, -0.014, 1, 1),
|
|
81
|
+
strand(HY - 0.135, 0.017, 0.015, -0.018, 1, 1),
|
|
82
|
+
strand(HY - 0.17, 0.004, 0.004, -0.016, 1, 1),
|
|
83
|
+
],
|
|
84
|
+
(v, a) => 1 + 0.08 * Math.cos(a * 5),
|
|
85
|
+
);
|
|
86
|
+
if (style === 'tail')
|
|
87
|
+
rope(
|
|
88
|
+
[
|
|
89
|
+
strand(HY - 0.045, 0.021, 0.021, -0.004, 1, 1),
|
|
90
|
+
strand(HY - 0.09, 0.029, 0.025, -0.018, 1, 1),
|
|
91
|
+
strand(1.47, 0.026, 0.022, -0.03, 1, 0.5),
|
|
92
|
+
strand(1.38, 0.018, 0.016, -0.036, 0, 1),
|
|
93
|
+
strand(1.3, 0.004, 0.004, -0.034, 0, 1),
|
|
94
|
+
],
|
|
95
|
+
(v, a) => 1 + 0.1 * Math.cos(a * 5 + v * 3),
|
|
96
|
+
);
|
|
97
|
+
if (style === 'bun')
|
|
98
|
+
hd.sc(sculptMesh('bun', 5, capFn(0.043, 0.038, 0.043, 0.06, 0, 0, null, { grain: 2 })), hair, hair, null, HY + 0.07, 1, -0.094);
|
|
99
|
+
if (style === 'topknot') {
|
|
100
|
+
hd.sc(sculptMesh('knot', 4, capFn(0.027, 0.032, 0.027, 0.06, 0, 0, null, { grain: 2 })), hair, hair, null, HY + 0.135, 1, -0.03);
|
|
101
|
+
bind(fig, head, style);
|
|
102
|
+
}
|
|
103
|
+
if (style === 'plait')
|
|
104
|
+
rope(
|
|
105
|
+
[
|
|
106
|
+
strand(HY - 0.03, 0.027, 0.025, 0, 1, 1),
|
|
107
|
+
strand(1.5, 0.027, 0.023, -0.02, 1, 0.5),
|
|
108
|
+
strand(1.32, 0.023, 0.02, -0.036, 0, 1),
|
|
109
|
+
strand(1.14, 0.017, 0.015, -0.036, 0, 1),
|
|
110
|
+
strand(1.06, 0.005, 0.005, -0.034, 0, 1),
|
|
111
|
+
],
|
|
112
|
+
v => 1 + 0.22 * Math.cos(v * 48),
|
|
113
|
+
);
|
|
114
|
+
if (style === 'braids')
|
|
115
|
+
for (const s of [-1, 0, 1])
|
|
116
|
+
rope(
|
|
117
|
+
[
|
|
118
|
+
strand(HY + 0.0, 0.017, 0.017, 0, 1, 1),
|
|
119
|
+
strand(1.5, 0.016, 0.016, -0.02, 1, 0.5),
|
|
120
|
+
strand(1.3, 0.015, 0.015, -0.03, 0, 1),
|
|
121
|
+
strand(1.12, 0.008, 0.008, -0.03, 0, 1),
|
|
122
|
+
],
|
|
123
|
+
v => 1 + 0.25 * Math.cos(v * 40),
|
|
124
|
+
s * 0.05,
|
|
125
|
+
-0.085 + Math.abs(s) * 0.02,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Grows a far head's hair in its cut (head.cut, from hairCut).
|
|
130
|
+
function farHair(fig, head) {
|
|
131
|
+
const { hair, HY } = fig,
|
|
132
|
+
{ style, key, cut, inHair } = head.cut;
|
|
133
|
+
head.hd.sc(
|
|
134
|
+
sculptMesh(
|
|
135
|
+
'hair:' + key,
|
|
136
|
+
9,
|
|
137
|
+
capFn(OVER[0] * cut.far, OVER[1] * cut.far, OVER[2] * cut.far, cut.n, 0, cut.drop || 0, inHair, {
|
|
138
|
+
grain: cut.grain,
|
|
139
|
+
skull: SKULL.skull,
|
|
140
|
+
}),
|
|
141
|
+
),
|
|
142
|
+
hair,
|
|
143
|
+
hair,
|
|
144
|
+
(x, y, z) => inHair(x, y, z) < -0.22,
|
|
145
|
+
HY + 0.002,
|
|
146
|
+
);
|
|
147
|
+
if (cut.falls) fall(fig, cut);
|
|
148
|
+
tie(fig, head, style);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export { OVER, bind, fallShape, farHair };
|