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,460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A vessel's hull, from her spec and lines (ship-lines.js): a shell of strakes lofted through her stations with wales, weed
|
|
3
|
+
* below the waterline and wear above it, keel, stem and sternpost, a rudder hung on its post, decks of planks, bulwarks with
|
|
4
|
+
* timberheads and a cap rail, and the inside of an open boat (ribs, floor, thwarts). Builders: parts.hull and parts.deck take
|
|
5
|
+
* timber, parts.iron small ironwork. Bow to -z, the waterline at y 0.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import * as THREE from 'three';
|
|
9
|
+
import { dim } from '../math/color.js';
|
|
10
|
+
import { createHash } from '../math/random.js';
|
|
11
|
+
import { lerp, sstep } from '../math/scalar.js';
|
|
12
|
+
import { C, TRS, createUnitShapes, stick } from './primitives.js';
|
|
13
|
+
import { sampleSurface as surf } from './sampled-surface.js';
|
|
14
|
+
import { shipStations as stations } from './ship-lines.js';
|
|
15
|
+
|
|
16
|
+
const TAR = [0.05, 0.045, 0.04],
|
|
17
|
+
WEED = [0.06, 0.075, 0.035], // the growth on her bottom
|
|
18
|
+
SLIME = [0.15, 0.18, 0.08], // the green band the water line leaves
|
|
19
|
+
BLEACH = [0.4, 0.37, 0.32], // timber greyed by sun and salt, where hands and ropes wear it pale
|
|
20
|
+
WET = 0.12, // metres over the water her planking is dark from wash and spray
|
|
21
|
+
IRON = [0.07, 0.065, 0.06],
|
|
22
|
+
PLANK = 0.24, // a deck plank's width
|
|
23
|
+
STATIONS = 26, // the frames her shell is drawn through, bow to stern
|
|
24
|
+
RIB_GAP = 0.42, // metres between an open boat's ribs
|
|
25
|
+
BOARDS_OVER_BILGE = 0.03; // metres an open boat's bottom boards lie over her bottom
|
|
26
|
+
const mix = (a, b, t) => [lerp(a[0], b[0], t), lerp(a[1], b[1], t), lerp(a[2], b[2], t)];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Makes the hull builder, with the seeded hash that shades each plank and the unit shapes its timbers are cut from.
|
|
30
|
+
*
|
|
31
|
+
* @param {object} [options]
|
|
32
|
+
* @param {(x: number, y: number, salt: number) => number} [options.hash] - A seeded hash of whole numbers to [0, 1), as
|
|
33
|
+
* `createHash(seed)` makes (seed 0 if none is given).
|
|
34
|
+
* @param {ReturnType<typeof createUnitShapes>} [options.shapes] - Unit shapes (`box`, `cyl6`, ...), as `createUnitShapes` makes.
|
|
35
|
+
* @returns {{ buildHull: (parts: object, spec: object, lines: object) => void }} buildHull fills `parts.hull`, `parts.deck` and
|
|
36
|
+
* `parts.iron` (geometry builders) with the whole hull of a spec; `spec.far` builds the light hull seen from afar.
|
|
37
|
+
*/
|
|
38
|
+
export function createShipHull({ hash = createHash(), shapes = createUnitShapes() } = {}) {
|
|
39
|
+
// What a strake of her side looks like at a height: tarred and grown with weed below the water, a green band at the
|
|
40
|
+
// waterline and a dark wet band over it, greyed by the weather the higher it stands, each plank its own shade, scraped
|
|
41
|
+
// pale where fenders rub; `lap` is the tarred seam between strakes.
|
|
42
|
+
function plankColour(spec, tone, k, butt, y, lap) {
|
|
43
|
+
const wear = 0.93 + 0.12 * hash(k, butt, 211),
|
|
44
|
+
[p0, p1, paint] = spec.paint ?? [-1, -1, 0],
|
|
45
|
+
painted = spec.strakes - 1 - k >= p0 && spec.strakes - 1 - k <= p1,
|
|
46
|
+
weathered = mix(tone, BLEACH, 0.18 + 0.22 * sstep(0, spec.strakes, k));
|
|
47
|
+
let c;
|
|
48
|
+
if (y < -0.06) c = mix(mix(tone, TAR, 0.55), WEED, 0.35 + 0.4 * sstep(-0.1, -1.2, y));
|
|
49
|
+
else if (y < 0.1) c = mix(SLIME, tone, sstep(-0.06, 0.1, y) * 0.6);
|
|
50
|
+
else c = dim(painted ? mix(C(paint), BLEACH, 0.12) : weathered, 0.72 + 0.28 * sstep(0.1, WET + 0.3, y));
|
|
51
|
+
c = lap ? mix(c, TAR, 0.45) : dim(c, wear);
|
|
52
|
+
return y > 0.1 && y < 0.6 && hash(butt, k, 219) < 0.25 ? mix(c, BLEACH, 0.3) : c; // scrapes where she has lain against quays
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Her shell: both sides lofted through the stations, two rows to a strake (the plank's face and its lapped or caulked edge).
|
|
56
|
+
function shell(gb, spec, lines) {
|
|
57
|
+
const zs = stations(lines, spec.far ? 8 : STATIONS),
|
|
58
|
+
S = spec.far ? 3 : spec.strakes,
|
|
59
|
+
clinker = spec.build === 'clinker' && !spec.far,
|
|
60
|
+
edge = clinker ? 0.78 : 0.94, // where a strake's lapped or caulked edge begins
|
|
61
|
+
thick = clinker ? 0.012 * spec.beam : 0, // how far a lapped strake stands out from the one under it
|
|
62
|
+
rows = spec.far ? S : S * 2,
|
|
63
|
+
vOf = j => (spec.far ? j / S : (Math.floor(j / 2) + (j % 2) * edge) / S),
|
|
64
|
+
tone = C(spec.hull);
|
|
65
|
+
for (const side of [1, -1]) {
|
|
66
|
+
const at = (cu, cv) => {
|
|
67
|
+
const i = Math.round(cu * (zs.length - 1)),
|
|
68
|
+
j = Math.round(cv * rows),
|
|
69
|
+
[x, y, z] = lines.frame(zs[i], vOf(j)),
|
|
70
|
+
out = clinker && j % 2 === 0 && j > 0 && j < rows ? thick : 0;
|
|
71
|
+
return [side * (x + out), y, z];
|
|
72
|
+
};
|
|
73
|
+
const colour = (cu, cv) => {
|
|
74
|
+
const i = Math.floor(cu * (zs.length - 1)),
|
|
75
|
+
j = Math.floor(cv * rows),
|
|
76
|
+
k = spec.far ? j * Math.round(spec.strakes / S) : j >> 1,
|
|
77
|
+
z = (zs[i] + zs[Math.min(zs.length - 1, i + 1)]) / 2,
|
|
78
|
+
y = lines.frame(z, (vOf(j) + vOf(j + 1)) / 2)[1];
|
|
79
|
+
return plankColour(spec, tone, k, Math.floor((i + k * 2) / 4), y, !spec.far && j % 2 === 1);
|
|
80
|
+
};
|
|
81
|
+
surf(gb, zs.length - 1, rows, at, colour, { flip: side < 0 });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The transom: boards across her stern between the last stations, with the master's windows where she has a cabin aft.
|
|
86
|
+
function transom(gb, spec, lines) {
|
|
87
|
+
const { L } = lines,
|
|
88
|
+
tone = C(spec.hull),
|
|
89
|
+
n = spec.far ? 3 : spec.strakes;
|
|
90
|
+
for (let k = 0; k < n; k++) {
|
|
91
|
+
const a = lines.frame(L, k / n),
|
|
92
|
+
d = lines.frame(L, (k + 1) / n),
|
|
93
|
+
c = dim(a[1] < 0 ? mix(tone, TAR, 0.6) : mix(tone, BLEACH, 0.15), 0.8 + 0.25 * hash(k, 9, 213));
|
|
94
|
+
quad(gb, [a[0], a[1], a[2]], [d[0], d[1], d[2]], [-d[0], d[1], d[2]], [-a[0], a[1], a[2]], c);
|
|
95
|
+
}
|
|
96
|
+
if (!spec.windows || spec.far) return;
|
|
97
|
+
const sill = lines.deck(L) - 1.5,
|
|
98
|
+
z = lines.frame(L, lines.uAt(L, sill))[2] + 0.03,
|
|
99
|
+
frameTone = dim(tone, 0.75);
|
|
100
|
+
for (let k = -2; k <= 2; k++) {
|
|
101
|
+
gb.box(k * 0.82, sill, z, 0.6, 0.85, 0.05, [0.03, 0.035, 0.04]);
|
|
102
|
+
gb.box(k * 0.82, sill - 0.08, z + 0.03, 0.72, 0.08, 0.09, frameTone);
|
|
103
|
+
gb.box(k * 0.82, sill + 0.85, z + 0.03, 0.72, 0.08, 0.09, frameTone);
|
|
104
|
+
gb.box(k * 0.82, sill + 0.4, z + 0.03, 0.6, 0.03, 0.03, frameTone);
|
|
105
|
+
gb.box(k * 0.82, sill, z + 0.03, 0.03, 0.85, 0.03, frameTone);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// A quad between four points, facing the way its corners turn.
|
|
110
|
+
function quad(gb, a, b, c, d, col) {
|
|
111
|
+
const ux = b[0] - a[0],
|
|
112
|
+
uy = b[1] - a[1],
|
|
113
|
+
uz = b[2] - a[2],
|
|
114
|
+
vx = d[0] - a[0],
|
|
115
|
+
vy = d[1] - a[1],
|
|
116
|
+
vz = d[2] - a[2],
|
|
117
|
+
nx = uy * vz - uz * vy,
|
|
118
|
+
ny = uz * vx - ux * vz,
|
|
119
|
+
nz = ux * vy - uy * vx,
|
|
120
|
+
l = Math.hypot(nx, ny, nz) || 1;
|
|
121
|
+
for (const p of [a, b, c, a, c, d]) gb.raw(p[0], p[1], p[2], nx / l, ny / l, nz / l, col[0], col[1], col[2]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// A run of timber along her side at height y over the water (a wale), or along the rail (u given), standing `out` proud.
|
|
125
|
+
function alongSide(gb, lines, from, to, place, size, col, out = 0.04) {
|
|
126
|
+
const zs = stations(lines, STATIONS).filter(z => z >= from && z <= to);
|
|
127
|
+
for (const side of [1, -1])
|
|
128
|
+
for (let i = 0; i < zs.length - 1; i++) {
|
|
129
|
+
const p = place(zs[i]),
|
|
130
|
+
q = place(zs[i + 1]);
|
|
131
|
+
if (Math.abs(p[1] - q[1]) > 0.3) continue; // where a rail steps, the timber stops
|
|
132
|
+
stick(gb, [side * (p[0] + out), p[1], p[2]], [side * (q[0] + out), q[1], q[2]], size, col, shapes.box);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const RUDDER_POINTS = 6; // points up the sternpost that the blade's leading edge follows
|
|
137
|
+
// A rudder blade in one piece, as a shipwright cuts it from planks edge-joined and trimmed: its leading edge straight down the
|
|
138
|
+
// sternpost (between heights k0 and k1 on it, set a hand's breadth aft of it), its trailing edge narrowing from `span` metres at
|
|
139
|
+
// the foot to under half that at the head, its foot rounded off, and its edges eased. `thick` is its thickness in metres.
|
|
140
|
+
// Built on its side in the frame's (z, y) plane and stood up across x.
|
|
141
|
+
function rudderBlade(lines, L, k0, k1, span, thick) {
|
|
142
|
+
const lead = [];
|
|
143
|
+
for (let i = 0; i <= RUDDER_POINTS; i++) {
|
|
144
|
+
const [, y, z] = lines.frame(L, lerp(k0, k1, i / RUDDER_POINTS));
|
|
145
|
+
lead.push([z + 0.08, y]);
|
|
146
|
+
}
|
|
147
|
+
const width = t => span * (1 - 0.55 * t),
|
|
148
|
+
foot = Math.min(0.35 * span, 0.3 * (lead[RUDDER_POINTS][1] - lead[0][1])), // how far up the trailing edge the foot's curve reaches
|
|
149
|
+
shape = new THREE.Shape();
|
|
150
|
+
shape.moveTo(lead[0][0], lead[0][1]);
|
|
151
|
+
for (let i = 1; i <= RUDDER_POINTS; i++) shape.lineTo(lead[i][0], lead[i][1]);
|
|
152
|
+
const [headZ, headY] = lead[RUDDER_POINTS],
|
|
153
|
+
[footZ, footY] = lead[0];
|
|
154
|
+
shape.lineTo(headZ + width(1), headY);
|
|
155
|
+
shape.lineTo(footZ + width(0), footY + foot);
|
|
156
|
+
shape.quadraticCurveTo(footZ + width(0), footY, footZ + width(0) - foot, footY);
|
|
157
|
+
shape.closePath();
|
|
158
|
+
const bevel = thick * 0.3;
|
|
159
|
+
return new THREE.ExtrudeGeometry(shape, {
|
|
160
|
+
depth: thick - 2 * bevel,
|
|
161
|
+
bevelEnabled: true,
|
|
162
|
+
bevelThickness: bevel,
|
|
163
|
+
bevelSize: Math.min(bevel, 0.03),
|
|
164
|
+
bevelSegments: 1,
|
|
165
|
+
curveSegments: 5,
|
|
166
|
+
})
|
|
167
|
+
.translate(0, 0, -(thick - 2 * bevel) / 2)
|
|
168
|
+
.rotateY(-Math.PI / 2);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Keel, stem and sternpost, the wales, and the rudder hung on the sternpost with its pintles.
|
|
172
|
+
function backbone(parts, spec, lines) {
|
|
173
|
+
const { hull, iron } = parts,
|
|
174
|
+
{ L } = lines,
|
|
175
|
+
heft = spec.beam / 4, // a boat's timbers are as much lighter as she is narrower
|
|
176
|
+
post = dim(C(spec.hull), 0.78);
|
|
177
|
+
const profile = (zFrom, zTo, n) => {
|
|
178
|
+
const pts = [];
|
|
179
|
+
for (let i = 0; i <= n; i++) {
|
|
180
|
+
const z = lerp(zFrom, zTo, i / n);
|
|
181
|
+
pts.push(lines.frame(z, 0));
|
|
182
|
+
}
|
|
183
|
+
return pts;
|
|
184
|
+
};
|
|
185
|
+
// the keel and the forefoot sweeping up into the stem, which stands proud of the rail as a stem-head
|
|
186
|
+
const bow = [...profile(L * 0.2, -L, 8)];
|
|
187
|
+
for (let i = 1; i <= 6; i++) bow.push(lines.frame(-L, i / 6, lines.top(-L) + 0.35 * heft * (i === 6 ? 1 : 0)));
|
|
188
|
+
for (let i = 0; i < bow.length - 1; i++) stick(hull, bow[i], bow[i + 1], 0.2 * heft + 0.03, post, shapes.box);
|
|
189
|
+
const stern = [...profile(L * 0.2, L, 6)];
|
|
190
|
+
for (let i = 1; i <= 6; i++) stern.push(lines.frame(L, i / 6, lines.top(L) + (lines.pointed ? 0.25 * heft : -0.05)));
|
|
191
|
+
for (let i = 0; i < stern.length - 1; i++) stick(hull, stern[i], stern[i + 1], 0.2 * heft + 0.03, post, shapes.box);
|
|
192
|
+
if (spec.far) return;
|
|
193
|
+
for (const y of spec.wales ?? [])
|
|
194
|
+
alongSide(hull, lines, -L, L, z => lines.frame(z, lines.uAt(z, y)), 0.17, mix(C(spec.hull), TAR, 0.5), 0.06); // wales are tarred
|
|
195
|
+
if ((spec.gear ?? []).includes('steering')) return; // she steers by oars on her quarters (ship-fittings.js)
|
|
196
|
+
// the rudder: a blade hung behind the sternpost from the keel to over the water, wider at its foot
|
|
197
|
+
const k0 = lines.uAt(L, lines.keel(L) + 0.05),
|
|
198
|
+
k1 = lines.uAt(L, Math.min(lines.top(L) - 0.2, 0.55 + spec.rail * 0.4));
|
|
199
|
+
hull.add(rudderBlade(lines, L, k0, k1, Math.max(0.45, spec.beam * 0.32), 0.1 * heft + 0.05), dim(C(spec.hull), 0.85), TRS(0, 0, 0));
|
|
200
|
+
for (const t of [0.15, 0.5, 0.85]) {
|
|
201
|
+
const [, y, z] = lines.frame(L, lerp(k0, k1, t));
|
|
202
|
+
iron.add(shapes.box, IRON, TRS(0, y, z + 0.12, 0.14 * heft + 0.06, 0.06, 0.5));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// A deck plank's run from z0 to z1 at x, in the pieces left where an open hatch is cut through it.
|
|
207
|
+
function cutByHatch(spec, x, z0, z1) {
|
|
208
|
+
const [hz, hw, hl, open] = spec.hatch ?? [];
|
|
209
|
+
if (!open || Math.abs(x) > hw + 0.1 || z1 < hz - hl || z0 > hz + hl) return [[z0, z1]];
|
|
210
|
+
return [
|
|
211
|
+
[z0, hz - hl],
|
|
212
|
+
[hz + hl, z1],
|
|
213
|
+
].filter(([a, b]) => b - a > 0.05);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// The decks, plank by plank fore and aft, each cut to her side; under an open hatch the beams that carry them.
|
|
217
|
+
function decks(gb, spec, lines) {
|
|
218
|
+
const { L } = lines,
|
|
219
|
+
tone = C(spec.deckTone),
|
|
220
|
+
fore = Math.max(-L + 0.3, lines.fore[0]),
|
|
221
|
+
aft = Math.min(L - 0.05, lines.aft[0]);
|
|
222
|
+
for (const [z0, z1] of [
|
|
223
|
+
[-L + 0.3, fore],
|
|
224
|
+
[fore, aft],
|
|
225
|
+
[aft, L - 0.05],
|
|
226
|
+
]) {
|
|
227
|
+
if (z1 - z0 < 0.3) continue;
|
|
228
|
+
const y = lines.deck((z0 + z1) / 2),
|
|
229
|
+
beam = lines.inner(0, y);
|
|
230
|
+
for (let x = -beam + PLANK / 2; x < beam; x += PLANK) {
|
|
231
|
+
let from = null,
|
|
232
|
+
to = null;
|
|
233
|
+
for (let z = z0; z <= z1 + 1e-6; z += 0.05)
|
|
234
|
+
if (lines.inner(z, y) - 0.1 > Math.abs(x)) {
|
|
235
|
+
from ??= z;
|
|
236
|
+
to = z;
|
|
237
|
+
}
|
|
238
|
+
if (from === null || to - from < 0.3) continue;
|
|
239
|
+
const k = 0.82 + 0.3 * hash(Math.round(x * 31), Math.round(z0), 214);
|
|
240
|
+
for (const [a, b] of cutByHatch(spec, x, from, to)) gb.box(x, y - 0.09, (a + b) / 2, PLANK, 0.09, b - a, dim(tone, k)); // laid close: the seams show in the planks' shades
|
|
241
|
+
}
|
|
242
|
+
if (z0 < -L + 0.5) foredeck(gb, lines, y, dim(tone, 0.8));
|
|
243
|
+
// the margin plank along her side, which the deck planks' ends are let into
|
|
244
|
+
alongSide(gb, lines, z0, z1, z => [lines.inner(z, y) - 0.12, y - 0.11, z], 0.22, dim(tone, 0.8), 0);
|
|
245
|
+
}
|
|
246
|
+
for (const [brk, openings] of [
|
|
247
|
+
[fore, spec.fore?.[2]],
|
|
248
|
+
[aft, spec.aft?.[2]],
|
|
249
|
+
])
|
|
250
|
+
if (Math.abs(brk) < L - 0.5) bulkhead(gb, spec, lines, brk, openings);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Where a deck steps up to a forecastle or quarterdeck, the boarded front between the two, with its openings (a door into
|
|
254
|
+
// the space under the upper deck, or a gangway with steps up to it) and a breast rail along the upper deck's edge.
|
|
255
|
+
// Without it the open hold shows the water through her shell.
|
|
256
|
+
function bulkhead(gb, spec, lines, z, openings = [[0, 0.45, 1.8]]) {
|
|
257
|
+
const low = Math.min(lines.deck(z - 0.01), lines.deck(z + 0.01)),
|
|
258
|
+
high = Math.max(lines.deck(z - 0.01), lines.deck(z + 0.01));
|
|
259
|
+
if (high - low < 0.2) return;
|
|
260
|
+
const tone = mix(C(spec.hull), BLEACH, 0.2),
|
|
261
|
+
toWaist = z < 0 ? 1 : -1,
|
|
262
|
+
face = z + toWaist * 0.04,
|
|
263
|
+
reach = y => lines.inner(face, y) - 0.04,
|
|
264
|
+
half = Math.max(reach(low), reach(high)),
|
|
265
|
+
within = x => openings.find(([at, w]) => Math.abs(x - at) < w);
|
|
266
|
+
for (let x = -half + PLANK / 2; x < half; x += PLANK) {
|
|
267
|
+
let top = high;
|
|
268
|
+
while (top > low && reach(top) < Math.abs(x) + PLANK / 2) top -= 0.05; // her sides draw in as they rise
|
|
269
|
+
const gap = within(x),
|
|
270
|
+
shade = 0.8 + 0.25 * hash(Math.round(x * 17), Math.round(z), 226);
|
|
271
|
+
if (top - low < 0.1 || (gap && !gap[2])) continue; // a gangway stands open
|
|
272
|
+
if (gap) {
|
|
273
|
+
const head = low + Math.min(gap[2], high - low - 0.12);
|
|
274
|
+
if (!gap[3]) gb.box(x, low - 0.12, face, PLANK - 0.012, head - low + 0.12, 0.07, dim(tone, 0.62)); // the door's boards, unless it stands open
|
|
275
|
+
gb.box(x, head, face, PLANK - 0.012, top - head, 0.07, dim(tone, shade));
|
|
276
|
+
} else gb.box(x, low - 0.12, face, PLANK - 0.012, top - low + 0.12, 0.07, dim(tone, shade));
|
|
277
|
+
}
|
|
278
|
+
const rail = high + 0.95;
|
|
279
|
+
for (const [at, w, door] of openings) {
|
|
280
|
+
if (door) {
|
|
281
|
+
const head = low + Math.min(door, high - low - 0.12);
|
|
282
|
+
gb.box(at, head, face + toWaist * 0.03, w * 2 + 0.16, 0.1, 0.08, dim(tone, 0.6)); // the door's head
|
|
283
|
+
for (const s of [-1, 1]) gb.box(at + s * (w + 0.04), low, face + toWaist * 0.03, 0.1, head - low, 0.1, dim(tone, 0.7)); // its posts
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
// a flight of steps up from the waist, the highest against the bulkhead
|
|
287
|
+
const n = Math.max(2, Math.round((high - low) / 0.28)),
|
|
288
|
+
tread = 0.27;
|
|
289
|
+
for (let k = 0; k < n; k++)
|
|
290
|
+
gb.box(
|
|
291
|
+
at,
|
|
292
|
+
low,
|
|
293
|
+
face + toWaist * (n - k - 0.5) * tread,
|
|
294
|
+
w * 2 - 0.1,
|
|
295
|
+
((k + 1) / n) * (high - low),
|
|
296
|
+
tread,
|
|
297
|
+
dim(tone, 0.85 + 0.15 * (k % 2)),
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
const ends = [-half, ...openings.filter(o => !o[2]).flatMap(([at, w]) => [at - w, at + w]), half].sort((p, q) => p - q);
|
|
301
|
+
for (let i = 0; i < ends.length - 1; i += 2) {
|
|
302
|
+
const x0 = ends[i],
|
|
303
|
+
x1 = ends[i + 1];
|
|
304
|
+
if (x1 - x0 < 0.2) continue;
|
|
305
|
+
gb.box((x0 + x1) / 2, rail, z, x1 - x0, 0.08, 0.12, mix(tone, BLEACH, 0.3)); // the breast rail, broken where a gangway comes up
|
|
306
|
+
const posts = Math.max(1, Math.round((x1 - x0) / 0.8));
|
|
307
|
+
for (let k = 0; k <= posts; k++) gb.box(lerp(x0 + 0.05, x1 - 0.05, k / posts), high, z, 0.08, rail - high, 0.08, dim(tone, 0.85)); // its stanchions
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// The deck right forward, where her sides lean out to the stem: one sheet out to the planking, so no water shows at the bow.
|
|
312
|
+
function foredeck(gb, lines, y, tone) {
|
|
313
|
+
const { L } = lines,
|
|
314
|
+
n = 6;
|
|
315
|
+
surf(
|
|
316
|
+
gb,
|
|
317
|
+
n,
|
|
318
|
+
1,
|
|
319
|
+
(cu, cv) => {
|
|
320
|
+
const z = lerp(-L, -L * 0.55, cu),
|
|
321
|
+
[x, , zz] = lines.frame(z, lines.uAt(z, y));
|
|
322
|
+
return [lerp(x, -x, cv) * 0.97, y - 0.004, zz];
|
|
323
|
+
},
|
|
324
|
+
tone,
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Bulwarks: their inner face from deck to rail, timberheads standing up inside them, the cap rail, scuppers at the deck.
|
|
329
|
+
function bulwarks(parts, spec, lines) {
|
|
330
|
+
const { hull } = parts,
|
|
331
|
+
{ L } = lines,
|
|
332
|
+
tone = C(spec.hull),
|
|
333
|
+
zs = stations(lines, STATIONS);
|
|
334
|
+
for (let i = 0; i < zs.length - 1; i++) {
|
|
335
|
+
const z0 = zs[i],
|
|
336
|
+
z1 = zs[i + 1];
|
|
337
|
+
if (z1 - z0 < 0.01) continue;
|
|
338
|
+
const zm = (z0 + z1) / 2,
|
|
339
|
+
d0 = lines.deck(zm),
|
|
340
|
+
inner = dim(mix(tone, BLEACH, 0.15), 0.85 + 0.2 * hash(i, 3, 212));
|
|
341
|
+
for (const s of [-1, 1]) {
|
|
342
|
+
// the inner face follows her side as it leans out at the ends: from just under the deck to the rail
|
|
343
|
+
const within = (z, u, dy) => {
|
|
344
|
+
const [x, y, zz] = lines.frame(z, u);
|
|
345
|
+
return [s * Math.max(0, x - 0.07), y + dy, zz];
|
|
346
|
+
},
|
|
347
|
+
p0 = within(z0, lines.uAt(z0, d0 - 0.12), 0),
|
|
348
|
+
p1 = within(z1, lines.uAt(z1, d0 - 0.12), 0),
|
|
349
|
+
q0 = within(z0, 1, -0.02),
|
|
350
|
+
q1 = within(z1, 1, -0.02);
|
|
351
|
+
if (s > 0) quad(hull, p0, p1, q1, q0, inner);
|
|
352
|
+
else quad(hull, p0, q0, q1, p1, inner);
|
|
353
|
+
if (i % 2 === 0 && Math.abs(zm) < L - 0.6)
|
|
354
|
+
hull.box(p0[0] - s * 0.07, d0, zm, 0.13, lines.top(zm) - d0 + 0.06, 0.13, dim(tone, 0.85)); // a timberhead
|
|
355
|
+
if (i % 3 === 1 && Math.abs(zm) < L * 0.7) {
|
|
356
|
+
const [x] = lines.frame(zm, lines.uAt(zm, d0 + 0.04));
|
|
357
|
+
hull.box(s * (x + 0.005), d0 - 0.02, zm, 0.03, 0.08, 0.2, dim(tone, 0.3)); // a scupper
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
alongSide(hull, lines, -L, L, z => lines.frame(z, 1), 0.13 * Math.min(1, spec.rail), mix(tone, BLEACH, 0.35), -0.03); // the cap rail, worn pale by hands
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// The bottom of an open boat at height y, from stem to stern and out to her planking: her shell is drawn from outside only,
|
|
365
|
+
// so without it the water's surface shows inside her, in her ends and between her bottom boards.
|
|
366
|
+
function bilge(gb, lines, zs, y, tone) {
|
|
367
|
+
surf(
|
|
368
|
+
gb,
|
|
369
|
+
zs.length - 1,
|
|
370
|
+
1,
|
|
371
|
+
(cu, cv) => {
|
|
372
|
+
const z = zs[Math.round(cu * (zs.length - 1))],
|
|
373
|
+
[x, , zz] = lines.frame(z, lines.uAt(z, y));
|
|
374
|
+
return [lerp(x, -x, cv) * 0.97, y, zz];
|
|
375
|
+
},
|
|
376
|
+
tone,
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// An open boat's inside: her planking seen from within, ribs across it, bottom boards, thwarts, and the gunwale over all.
|
|
381
|
+
function openBoat(parts, spec, lines) {
|
|
382
|
+
const { hull } = parts,
|
|
383
|
+
{ L } = lines,
|
|
384
|
+
zs = stations(lines, STATIONS),
|
|
385
|
+
light = dim(C(spec.hull), 1.12),
|
|
386
|
+
rows = spec.strakes;
|
|
387
|
+
for (const side of [1, -1])
|
|
388
|
+
surf(
|
|
389
|
+
hull,
|
|
390
|
+
zs.length - 1,
|
|
391
|
+
rows,
|
|
392
|
+
(cu, cv) => {
|
|
393
|
+
const [x, y, z] = lines.frame(zs[Math.round(cu * (zs.length - 1))], cv);
|
|
394
|
+
return [side * Math.max(0, x - 0.025), y + 0.015, z];
|
|
395
|
+
},
|
|
396
|
+
(cu, cv) => dim(light, 0.82 + 0.24 * hash(Math.floor(cv * rows), Math.floor(cu * 6), 220)),
|
|
397
|
+
{ flip: side > 0 },
|
|
398
|
+
);
|
|
399
|
+
const rib = dim(light, 0.7);
|
|
400
|
+
for (let z = -L * 0.82; z <= L * 0.84; z += RIB_GAP) {
|
|
401
|
+
let last = null;
|
|
402
|
+
for (let u = 0.05; u <= 1.0001; u += 0.19) {
|
|
403
|
+
const [x, y, zz] = lines.frame(z, u),
|
|
404
|
+
p = [Math.max(0, x - 0.05), y + 0.02, zz];
|
|
405
|
+
if (last) for (const s of [1, -1]) stick(hull, [s * last[0], last[1], last[2]], [s * p[0], p[1], p[2]], 0.045, rib, shapes.box);
|
|
406
|
+
last = p;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const floor = spec.waist + 0.04;
|
|
410
|
+
bilge(hull, lines, zs, floor - BOARDS_OVER_BILGE, dim(C(spec.deckTone), 0.5));
|
|
411
|
+
for (let x = -0.5; x <= 0.5; x += 0.25) {
|
|
412
|
+
const reach = lines.inner(0, floor);
|
|
413
|
+
if (Math.abs(x) * spec.beam > reach) continue;
|
|
414
|
+
hull.box(x * spec.beam * 0.9, floor, 0, 0.2, 0.03, L * 1.15, dim(C(spec.deckTone), 0.85 + 0.2 * hash(Math.round(x * 8), 2, 221)));
|
|
415
|
+
}
|
|
416
|
+
const seat = spec.waist + spec.rail * 0.55;
|
|
417
|
+
for (const t of spec.thwarts ?? []) {
|
|
418
|
+
const z = t * L,
|
|
419
|
+
w = lines.inner(z, seat) * 2 + 0.06;
|
|
420
|
+
hull.box(0, seat, z, w, 0.04, 0.24, dim(light, 0.9));
|
|
421
|
+
for (const s of [-1, 1]) hull.box(s * (w / 2 - 0.05), seat - 0.18, z, 0.06, 0.18, 0.06, rib); // the thwart's knees
|
|
422
|
+
}
|
|
423
|
+
alongSide(hull, lines, -L * 0.96, L * 0.96, z => lines.frame(z, 1), 0.06, mix(C(spec.hull), BLEACH, 0.35), -0.01);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// The whole hull of a spec into the kit's parts.
|
|
427
|
+
function buildHull(parts, spec, lines) {
|
|
428
|
+
shell(parts.hull, spec, lines);
|
|
429
|
+
if (!lines.pointed) transom(parts.hull, spec, lines);
|
|
430
|
+
backbone(parts, spec, lines);
|
|
431
|
+
if (spec.far) {
|
|
432
|
+
// a far hull's deck is one sheet at the deck's height, stepping with it
|
|
433
|
+
const zs = stations(lines, 8),
|
|
434
|
+
tone = C(spec.deckTone);
|
|
435
|
+
surf(
|
|
436
|
+
parts.deck,
|
|
437
|
+
zs.length - 1,
|
|
438
|
+
1,
|
|
439
|
+
(cu, cv) => {
|
|
440
|
+
// out to the shell itself, which is drawn from outside only: a margin left inside it shows the water
|
|
441
|
+
const z = zs[Math.round(cu * (zs.length - 1))],
|
|
442
|
+
y = lines.deck(z) + (spec.open ? 0.05 : 0),
|
|
443
|
+
[x, , zz] = lines.frame(z, lines.uAt(z, y));
|
|
444
|
+
return [lerp(x, -x, cv) * 0.97, y, zz];
|
|
445
|
+
},
|
|
446
|
+
tone,
|
|
447
|
+
);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (spec.open) openBoat(parts, spec, lines);
|
|
451
|
+
else {
|
|
452
|
+
decks(parts.deck, spec, lines);
|
|
453
|
+
bulwarks(parts, spec, lines);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return { buildHull };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export { IRON, TAR };
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ship kit: every vessel of a world built from a spec by the same hull, rig and fittings, near plank by plank or far as a
|
|
3
|
+
* light hull of the same lines and colours. Plain geometry builders, so Web Workers and the page build the same arrays.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import * as THREE from 'three';
|
|
7
|
+
import { indexParts } from './index-parts.js';
|
|
8
|
+
import { GB } from './builder.js';
|
|
9
|
+
import { createHash } from '../math/random.js';
|
|
10
|
+
import { TRS, createUnitShapes } from './primitives.js';
|
|
11
|
+
import { createShipFittings } from './ship-fittings.js';
|
|
12
|
+
import { createShipHull } from './ship-hull.js';
|
|
13
|
+
import { shipLines } from './ship-lines.js';
|
|
14
|
+
import { createShipOars } from './ship-oars.js';
|
|
15
|
+
import { createShipRig, YARD_STOWED } from './ship-rig.js';
|
|
16
|
+
|
|
17
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
18
|
+
// A ship fills named builders: hull, deck and spar (timber), rig and iron (rope and ironwork), set and furl (her canvas spread
|
|
19
|
+
// and stowed), glass (her lanterns' panes, lit at night; left out where none). Her frame: middle at the origin on the
|
|
20
|
+
// waterline, bow to -z, starboard +x, metres.
|
|
21
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
22
|
+
const _c = new THREE.Color(),
|
|
23
|
+
_scale = new THREE.Matrix4();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A builder that takes nothing: what a ship would draw into it is left out (her canvas the other way, say).
|
|
27
|
+
* @type {{ add: () => object, box: () => object, raw: () => void }}
|
|
28
|
+
*/
|
|
29
|
+
const NOWHERE = {
|
|
30
|
+
add() {
|
|
31
|
+
return NOWHERE;
|
|
32
|
+
},
|
|
33
|
+
box() {
|
|
34
|
+
return NOWHERE;
|
|
35
|
+
},
|
|
36
|
+
raw() {},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// A hex colour a little lighter or darker, by the seeded random R.
|
|
40
|
+
function shade(hex, R, by = 0.08) {
|
|
41
|
+
_c.setHex(hex).multiplyScalar(1 + (R() - 0.5) * 2 * by);
|
|
42
|
+
return _c.getHex();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The spec as one vessel of her kind: her hull, deck and sail each a shade of their own (three draws of R, in that order).
|
|
47
|
+
*
|
|
48
|
+
* @param {object} spec - The vessel's spec.
|
|
49
|
+
* @param {() => number} R - A seeded random in [0, 1).
|
|
50
|
+
* @returns {object} A copy of the spec with `hull`, `deckTone` and `sail` shaded.
|
|
51
|
+
*/
|
|
52
|
+
const oneOf = (spec, R) => ({
|
|
53
|
+
...spec,
|
|
54
|
+
hull: shade(spec.hull, R),
|
|
55
|
+
deckTone: shade(spec.deckTone, R),
|
|
56
|
+
sail: spec.sail && shade(spec.sail, R, 0.05),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// What a builder holds, as the arrays its geometry is made of (as GB.build makes it), or null if nothing was put in it.
|
|
60
|
+
const partsOf = gb => (gb?.count ? gb.parts(!gb.wide) : null);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Makes a ship kit. A spec holds a vessel's lines (see `shipLines`), and:
|
|
64
|
+
* `len` her length (metres, for scaling), `hull`, `deckTone` and `sail` (hex colours; `sail` null for none), `masts`
|
|
65
|
+
* (`{ z, height, rig: 'square' | 'lateen', yards?, nest?, yard?: [length, sling share, angle] }`), `gear` (any of 'capstan',
|
|
66
|
+
* 'windlass', 'tiller', 'binnacle', 'steering', 'anchors', 'fenders', 'oars', 'sweeps', 'nets', 'colours', 'lanterns',
|
|
67
|
+
* 'bowsprit', 'casks', 'coils'), `oars` (see `oarPorts`), `hatch`, `cabin`, `open` (an open boat), `rags` (sails rotted on
|
|
68
|
+
* their yards), `lateenYard` ('hoisted', 'stowed' or 'apart').
|
|
69
|
+
*
|
|
70
|
+
* @param {object} [options]
|
|
71
|
+
* @param {(x: number, y: number, salt: number) => number} [options.hash] - A seeded hash to [0, 1), as `createHash(seed)` makes:
|
|
72
|
+
* it shades every plank, cloth and coil.
|
|
73
|
+
* @param {ReturnType<typeof createUnitShapes>} [options.shapes] - Unit shapes, as `createUnitShapes` makes.
|
|
74
|
+
* @param {number[]} [options.flagColour] - Linear [r, g, b] of the flag a ship with `colours` flies.
|
|
75
|
+
* @param {number[]} [options.lanternColour] - Linear [r, g, b] of her lanterns' panes.
|
|
76
|
+
* @returns {{ fillShip: Function, shipParts: Function, fleetShipParts: Function, shipInBuilders: Function,
|
|
77
|
+
* lateenYardParts: Function, loomInto: Function, shaftInto: Function }} The kit's builders (each documented below).
|
|
78
|
+
*/
|
|
79
|
+
export function createShipKit({ hash = createHash(), shapes = createUnitShapes(), flagColour, lanternColour } = {}) {
|
|
80
|
+
const { buildHull } = createShipHull({ hash, shapes }),
|
|
81
|
+
{ buildRig, lateenYardParts } = createShipRig({ hash, shapes }),
|
|
82
|
+
{ buildFittings, lanterns } = createShipFittings({ hash, shapes, flagColour, lanternColour }),
|
|
83
|
+
{ loomInto, shaftInto } = createShipOars({ shapes });
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Fills the parts with a ship of the spec.
|
|
87
|
+
*
|
|
88
|
+
* @param {object} parts - Geometry builders: hull, deck, spar, rig, iron, set, furl, and optionally setOther (her lateen sails
|
|
89
|
+
* set for a wind on her starboard side), glass and ridingLight (`{ glass, iron, rig? }`).
|
|
90
|
+
* @param {object} spec - The vessel.
|
|
91
|
+
* @param {object} [options]
|
|
92
|
+
* @param {boolean} [options.far] - The light hull seen from afar.
|
|
93
|
+
* @param {number} [options.berth] - The side she lies against a quay (+1 starboard, -1 port, 2 either), where fenders hang.
|
|
94
|
+
* @param {boolean} [options.moving] - Her oars are left out, to be drawn apart and pull.
|
|
95
|
+
* @param {boolean} [options.riding] - She lies moored, her riding light hung.
|
|
96
|
+
* @returns {object} Her lines (shipLines).
|
|
97
|
+
*/
|
|
98
|
+
function fillShip(parts, spec, { far = false, berth = 0, moving = false, riding = false } = {}) {
|
|
99
|
+
const lines = shipLines(spec),
|
|
100
|
+
s = far ? { ...spec, far: true } : spec;
|
|
101
|
+
buildHull(parts, s, lines);
|
|
102
|
+
buildRig(parts, s, lines, far);
|
|
103
|
+
if (!far) buildFittings(parts, s, lines, berth, moving);
|
|
104
|
+
lanterns(parts, s, lines, riding, far);
|
|
105
|
+
return lines;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A ship of her own as arrays (`GB.parts`), for rendering/ship-meshes.js to mesh.
|
|
110
|
+
*
|
|
111
|
+
* @param {object} spec - The vessel.
|
|
112
|
+
* @param {object} [options]
|
|
113
|
+
* @param {boolean} [options.far] - The light hull.
|
|
114
|
+
* @param {boolean} [options.tacks] - Also her lateen sails set on the other side of the mast (`setOther`).
|
|
115
|
+
* @param {boolean} [options.moving] - Her oars left out, to pull.
|
|
116
|
+
* @param {boolean} [options.riding] - Her riding light hung, apart (`ride`).
|
|
117
|
+
* @returns {{ wood, rope, set, setOther, furl, glass, ride }} Each null where she has none; `ride` is `{ glass, iron }`.
|
|
118
|
+
*/
|
|
119
|
+
function shipParts(spec, { far = false, tacks = false, moving = false, riding = false } = {}) {
|
|
120
|
+
const wood = new GB(),
|
|
121
|
+
rope = new GB(),
|
|
122
|
+
set = new GB(),
|
|
123
|
+
setOther = tacks ? new GB() : null,
|
|
124
|
+
furl = new GB(),
|
|
125
|
+
glass = new GB(),
|
|
126
|
+
ride = riding ? { glass: new GB(), iron: new GB() } : null; // the riding light: its pane, and its iron with its lanyard
|
|
127
|
+
fillShip({ hull: wood, deck: wood, spar: wood, rig: rope, iron: rope, set, setOther, furl, glass, ridingLight: ride }, spec, {
|
|
128
|
+
far,
|
|
129
|
+
moving,
|
|
130
|
+
riding,
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
wood: partsOf(wood),
|
|
134
|
+
rope: partsOf(rope),
|
|
135
|
+
set: partsOf(set),
|
|
136
|
+
setOther: partsOf(setOther),
|
|
137
|
+
furl: partsOf(furl),
|
|
138
|
+
glass: partsOf(glass),
|
|
139
|
+
ride: ride?.glass.count ? { glass: partsOf(ride.glass), iron: ride.iron.parts(!ride.iron.wide) } : null,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A vessel of a moored fleet, at a quay with fenders either side, her riding light hung and her sails furled, as indexed
|
|
145
|
+
* arrays (`indexParts`) for instancing. She is at rest, so a lateen yard is lowered along her.
|
|
146
|
+
*
|
|
147
|
+
* @param {object} spec - The vessel.
|
|
148
|
+
* @param {boolean} far - The light hull.
|
|
149
|
+
* @returns {{ wood, rope, furl, glass }} Each null where she has none.
|
|
150
|
+
*/
|
|
151
|
+
function fleetShipParts(spec, far) {
|
|
152
|
+
const wood = new GB(),
|
|
153
|
+
rope = new GB(),
|
|
154
|
+
furl = new GB(),
|
|
155
|
+
glass = new GB();
|
|
156
|
+
fillShip(
|
|
157
|
+
{ hull: wood, deck: wood, spar: wood, rig: rope, iron: rope, set: new GB(), furl, glass },
|
|
158
|
+
{ ...spec, lateenYard: YARD_STOWED },
|
|
159
|
+
{
|
|
160
|
+
far,
|
|
161
|
+
berth: 2,
|
|
162
|
+
riding: true,
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
const indexed = gb => (gb.count ? indexParts(gb.parts(!gb.wide)) : null);
|
|
166
|
+
return { wood: indexed(wood), rope: indexed(rope), furl: indexed(furl), glass: indexed(glass) };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A ship into a building kit's builders, placed by their shared frame matrix (as `createBuilderFrame` makes), scaled to `len`
|
|
171
|
+
* metres, her bow to +z as a prop's front is. A kit's boat is at rest: furled, a lateen yard is lowered along her and her
|
|
172
|
+
* riding light hung.
|
|
173
|
+
*
|
|
174
|
+
* @param {{ wood: object, trim: object, cloth: object, glass?: object }} builders - Timber, rope and iron, canvas, lit glass.
|
|
175
|
+
* @param {THREE.Matrix4} frame - The matrix the builders place their parts by; restored before returning.
|
|
176
|
+
* @param {() => number} R - A seeded random (three draws: oneOf).
|
|
177
|
+
* @param {object} spec - The vessel.
|
|
178
|
+
* @param {number} [len] - Her length, metres.
|
|
179
|
+
* @param {object} [options]
|
|
180
|
+
* @param {'set' | 'furled'} [options.sails] - Her canvas set or furled.
|
|
181
|
+
* @param {number} [options.berth] - The side she lies against a quay (fillShip).
|
|
182
|
+
*/
|
|
183
|
+
function shipInBuilders(builders, frame, R, spec, len = spec.len, { sails = 'furled', berth = 0 } = {}) {
|
|
184
|
+
const saved = frame.clone(); // a ship is placed once as a block is built, not each frame
|
|
185
|
+
frame.multiply(TRS(0, 0, 0, 1, 1, 1, Math.PI, 0, 0));
|
|
186
|
+
const k = len / spec.len;
|
|
187
|
+
frame.multiply(_scale.makeScale(k, k, k));
|
|
188
|
+
fillShip(
|
|
189
|
+
{
|
|
190
|
+
hull: builders.wood,
|
|
191
|
+
deck: builders.wood,
|
|
192
|
+
spar: builders.wood,
|
|
193
|
+
rig: builders.trim,
|
|
194
|
+
iron: builders.trim,
|
|
195
|
+
set: sails === 'set' ? builders.cloth : NOWHERE,
|
|
196
|
+
furl: sails === 'set' ? NOWHERE : builders.cloth,
|
|
197
|
+
glass: builders.glass,
|
|
198
|
+
},
|
|
199
|
+
oneOf(sails === 'set' ? spec : { ...spec, lateenYard: YARD_STOWED }, R),
|
|
200
|
+
{ berth, riding: sails !== 'set' },
|
|
201
|
+
);
|
|
202
|
+
frame.copy(saved);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return { fillShip, shipParts, fleetShipParts, shipInBuilders, lateenYardParts, loomInto, shaftInto };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export { NOWHERE, oneOf };
|