@developerz.ai/ts23d 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/bug-hunter.md +21 -0
- package/.claude/agents/docs-author.md +13 -0
- package/.claude/agents/dx-auditor.md +14 -0
- package/.claude/agents/primitive-author.md +22 -0
- package/.claude/agents/recipe-author.md +36 -0
- package/.claude/agents/visual-reviewer.md +23 -0
- package/.claude/commands/feature.md +28 -0
- package/.claude/commands/new-recipe.md +19 -0
- package/.claude/commands/release.md +14 -0
- package/.claude/commands/verify.md +9 -0
- package/.claude/skills/author-recipe/SKILL.md +93 -0
- package/CHANGELOG.md +90 -0
- package/CLAUDE.md +85 -0
- package/LICENSE +21 -0
- package/README.md +385 -2
- package/dist/chunk-6b05mnmx.js +19 -0
- package/dist/chunk-6b05mnmx.js.map +11 -0
- package/dist/chunk-7rtfjh9f.js +45 -0
- package/dist/chunk-7rtfjh9f.js.map +10 -0
- package/dist/chunk-8j4c28jt.js +4085 -0
- package/dist/chunk-8j4c28jt.js.map +46 -0
- package/dist/chunk-d1fv6hrm.js +2532 -0
- package/dist/chunk-d1fv6hrm.js.map +43 -0
- package/dist/chunk-dbq4qf52.js +902 -0
- package/dist/chunk-dbq4qf52.js.map +25 -0
- package/dist/chunk-drna2rny.js +836 -0
- package/dist/chunk-drna2rny.js.map +17 -0
- package/dist/chunk-dxvypr7y.js +89 -0
- package/dist/chunk-dxvypr7y.js.map +11 -0
- package/dist/chunk-f6yme003.js +1589 -0
- package/dist/chunk-f6yme003.js.map +30 -0
- package/dist/chunk-hg7pf34j.js +465 -0
- package/dist/chunk-hg7pf34j.js.map +19 -0
- package/dist/chunk-jq4e17tj.js +1031 -0
- package/dist/chunk-jq4e17tj.js.map +21 -0
- package/dist/chunk-y63c6zcv.js +2668 -0
- package/dist/chunk-y63c6zcv.js.map +53 -0
- package/dist/cli/args.d.ts +30 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +348 -0
- package/dist/cli/bin.js.map +15 -0
- package/dist/cli/load.d.ts +2 -0
- package/dist/cli/manifest.d.ts +53 -0
- package/dist/cli/render-cmds.d.ts +12 -0
- package/dist/cli/run.d.ts +1 -0
- package/dist/cli/texture-cache.d.ts +4 -0
- package/dist/core/asset.d.ts +10 -0
- package/dist/core/definition.d.ts +155 -0
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/family.d.ts +23 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +69 -0
- package/dist/core/index.js.map +9 -0
- package/dist/core/mesh.d.ts +35 -0
- package/dist/core/part.d.ts +114 -0
- package/dist/core/png.d.ts +1 -0
- package/dist/core/rng.d.ts +12 -0
- package/dist/core/transform.d.ts +20 -0
- package/dist/core/vec.d.ts +11 -0
- package/dist/core/world.d.ts +16 -0
- package/dist/export/bin-writer.d.ts +16 -0
- package/dist/export/container.d.ts +3 -0
- package/dist/export/credits.d.ts +4 -0
- package/dist/export/glb-options.d.ts +48 -0
- package/dist/export/glb.d.ts +8 -0
- package/dist/export/hierarchy.d.ts +23 -0
- package/dist/export/index.d.ts +5 -0
- package/dist/export/index.js +40 -0
- package/dist/export/index.js.map +9 -0
- package/dist/export/lights.d.ts +8 -0
- package/dist/export/lod-coverage.d.ts +12 -0
- package/dist/export/materials.d.ts +23 -0
- package/dist/export/merge-pivots.d.ts +6 -0
- package/dist/export/metadata.d.ts +21 -0
- package/dist/export/motion.d.ts +9 -0
- package/dist/export/optimize-parts.d.ts +26 -0
- package/dist/export/primitive.d.ts +3 -0
- package/dist/export/tangents.d.ts +2 -0
- package/dist/export/textures.d.ts +22 -0
- package/dist/export/version.d.ts +2 -0
- package/dist/grammar/index.d.ts +2 -0
- package/dist/grammar/index.js +16 -0
- package/dist/grammar/index.js.map +9 -0
- package/dist/grammar/split.d.ts +21 -0
- package/dist/grammar/whyte.d.ts +5 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +457 -0
- package/dist/index.js.map +9 -0
- package/dist/kinds/building.d.ts +44 -0
- package/dist/kinds/faces.d.ts +27 -0
- package/dist/kinds/head-armour.d.ts +5 -0
- package/dist/kinds/head-beard.d.ts +6 -0
- package/dist/kinds/head-bust.d.ts +5 -0
- package/dist/kinds/head-extras.d.ts +15 -0
- package/dist/kinds/head-face.d.ts +8 -0
- package/dist/kinds/head-garb.d.ts +4 -0
- package/dist/kinds/head-geom.d.ts +7 -0
- package/dist/kinds/head-hair.d.ts +4 -0
- package/dist/kinds/head-layout.d.ts +29 -0
- package/dist/kinds/head-mesh.d.ts +31 -0
- package/dist/kinds/head-mouth.d.ts +4 -0
- package/dist/kinds/head-params.d.ts +116 -0
- package/dist/kinds/head-presets.d.ts +19 -0
- package/dist/kinds/head-rim.d.ts +10 -0
- package/dist/kinds/head-tone.d.ts +10 -0
- package/dist/kinds/head-torso.d.ts +35 -0
- package/dist/kinds/head.d.ts +39 -0
- package/dist/kinds/hull-lines.d.ts +65 -0
- package/dist/kinds/hull-skin.d.ts +6 -0
- package/dist/kinds/hull.d.ts +14 -0
- package/dist/kinds/index.d.ts +16 -0
- package/dist/kinds/index.js +78 -0
- package/dist/kinds/index.js.map +9 -0
- package/dist/kinds/mass.d.ts +15 -0
- package/dist/kinds/openings.d.ts +30 -0
- package/dist/kinds/planned.d.ts +6 -0
- package/dist/kinds/roof-chimney.d.ts +16 -0
- package/dist/kinds/roof-shape.d.ts +64 -0
- package/dist/kinds/roof.d.ts +31 -0
- package/dist/kinds/vegetation-fronds.d.ts +15 -0
- package/dist/kinds/vegetation-impostor.d.ts +9 -0
- package/dist/kinds/vegetation-leaves.d.ts +15 -0
- package/dist/kinds/vegetation-mesh.d.ts +21 -0
- package/dist/kinds/vegetation-params.d.ts +90 -0
- package/dist/kinds/vegetation-presets.d.ts +20 -0
- package/dist/kinds/vegetation-skeleton.d.ts +20 -0
- package/dist/kinds/vegetation.d.ts +42 -0
- package/dist/kinds/vehicle.d.ts +42 -0
- package/dist/material/cc0.d.ts +4 -0
- package/dist/material/define.d.ts +34 -0
- package/dist/material/generator.d.ts +4 -0
- package/dist/material/index.d.ts +9 -0
- package/dist/material/index.js +70 -0
- package/dist/material/index.js.map +9 -0
- package/dist/material/library.d.ts +7 -0
- package/dist/material/material-def.d.ts +30 -0
- package/dist/material/paint/bond.d.ts +3 -0
- package/dist/material/paint/canvas.d.ts +39 -0
- package/dist/material/paint/cell.d.ts +4 -0
- package/dist/material/paint/cells-round.d.ts +5 -0
- package/dist/material/paint/cells.d.ts +7 -0
- package/dist/material/paint/compose.d.ts +5 -0
- package/dist/material/paint/concrete.d.ts +3 -0
- package/dist/material/paint/courses.d.ts +31 -0
- package/dist/material/paint/decode-png.d.ts +6 -0
- package/dist/material/paint/default-sheet.d.ts +4 -0
- package/dist/material/paint/fabric.d.ts +4 -0
- package/dist/material/paint/foliage-broad.d.ts +5 -0
- package/dist/material/paint/foliage-common.d.ts +35 -0
- package/dist/material/paint/foliage-compound.d.ts +4 -0
- package/dist/material/paint/foliage-conifer.d.ts +5 -0
- package/dist/material/paint/foliage-raster.d.ts +26 -0
- package/dist/material/paint/foliage.d.ts +3 -0
- package/dist/material/paint/image-strip.d.ts +4 -0
- package/dist/material/paint/kit.d.ts +5 -0
- package/dist/material/paint/masks.d.ts +3 -0
- package/dist/material/paint/metal.d.ts +3 -0
- package/dist/material/paint/noise.d.ts +9 -0
- package/dist/material/paint/normal.d.ts +8 -0
- package/dist/material/paint/orm.d.ts +8 -0
- package/dist/material/paint/planks.d.ts +3 -0
- package/dist/material/paint/plates.d.ts +3 -0
- package/dist/material/paint/shapes.d.ts +8 -0
- package/dist/material/paint/slate.d.ts +3 -0
- package/dist/material/paint/stamp.d.ts +3 -0
- package/dist/material/paint/strip.d.ts +3 -0
- package/dist/material/paint/surface.d.ts +5 -0
- package/dist/material/paint/types.d.ts +65 -0
- package/dist/material/paint/validate.d.ts +3 -0
- package/dist/material/palette.d.ts +14 -0
- package/dist/material/shader-godot.d.ts +2 -0
- package/dist/material/shader-three.d.ts +2 -0
- package/dist/material/shader.d.ts +46 -0
- package/dist/material/slots.d.ts +5 -0
- package/dist/material/texture-source.d.ts +34 -0
- package/dist/material/trim-sheet.d.ts +38 -0
- package/dist/neural/generator.d.ts +25 -0
- package/dist/neural/images.d.ts +17 -0
- package/dist/neural/index.d.ts +2 -0
- package/dist/neural/index.js +14 -0
- package/dist/neural/index.js.map +9 -0
- package/dist/passes/bake-ao.d.ts +17 -0
- package/dist/passes/grime.d.ts +15 -0
- package/dist/passes/index.d.ts +6 -0
- package/dist/passes/index.js +22 -0
- package/dist/passes/index.js.map +9 -0
- package/dist/passes/livery.d.ts +19 -0
- package/dist/passes/optimize-cache.d.ts +15 -0
- package/dist/passes/optimize-weld.d.ts +15 -0
- package/dist/passes/optimize.d.ts +28 -0
- package/dist/passes/ray-grid.d.ts +23 -0
- package/dist/passes/weighted-normals.d.ts +8 -0
- package/dist/primitives/beam.d.ts +17 -0
- package/dist/primitives/bevel-box.d.ts +13 -0
- package/dist/primitives/box.d.ts +16 -0
- package/dist/primitives/cell.d.ts +20 -0
- package/dist/primitives/check.d.ts +12 -0
- package/dist/primitives/closed.d.ts +11 -0
- package/dist/primitives/erosion.d.ts +22 -0
- package/dist/primitives/font-5x7.d.ts +3 -0
- package/dist/primitives/heightfield.d.ts +16 -0
- package/dist/primitives/index.d.ts +23 -0
- package/dist/primitives/index.js +81 -0
- package/dist/primitives/index.js.map +9 -0
- package/dist/primitives/lathe-facets.d.ts +8 -0
- package/dist/primitives/lathe.d.ts +26 -0
- package/dist/primitives/lattice.d.ts +30 -0
- package/dist/primitives/loft.d.ts +15 -0
- package/dist/primitives/mc-table.d.ts +2 -0
- package/dist/primitives/member.d.ts +19 -0
- package/dist/primitives/noise.d.ts +34 -0
- package/dist/primitives/planar.d.ts +10 -0
- package/dist/primitives/prism.d.ts +13 -0
- package/dist/primitives/sculpt-edit.d.ts +56 -0
- package/dist/primitives/sculpt-tree.d.ts +23 -0
- package/dist/primitives/sculpt.d.ts +27 -0
- package/dist/primitives/sdf-grid.d.ts +17 -0
- package/dist/primitives/sdf-ops.d.ts +37 -0
- package/dist/primitives/sdf.d.ts +21 -0
- package/dist/primitives/strip-uv.d.ts +11 -0
- package/dist/primitives/surface-nets.d.ts +7 -0
- package/dist/primitives/sweep.d.ts +19 -0
- package/dist/primitives/terrain-color.d.ts +30 -0
- package/dist/primitives/terrain-grid.d.ts +36 -0
- package/dist/primitives/text-layout.d.ts +22 -0
- package/dist/primitives/text.d.ts +27 -0
- package/dist/primitives/tiled.d.ts +22 -0
- package/dist/primitives/transport.d.ts +17 -0
- package/dist/primitives/triangulate.d.ts +2 -0
- package/dist/primitives/value-noise.d.ts +10 -0
- package/dist/qa/checks.d.ts +11 -0
- package/dist/qa/clash.d.ts +2 -0
- package/dist/qa/floating.d.ts +5 -0
- package/dist/qa/gates.d.ts +12 -0
- package/dist/qa/geometry.d.ts +21 -0
- package/dist/qa/index.d.ts +12 -0
- package/dist/qa/index.js +78 -0
- package/dist/qa/index.js.map +9 -0
- package/dist/qa/inside.d.ts +12 -0
- package/dist/qa/inspect.d.ts +18 -0
- package/dist/qa/lods.d.ts +12 -0
- package/dist/qa/measures.d.ts +4 -0
- package/dist/qa/occlusion.d.ts +3 -0
- package/dist/qa/sanity.d.ts +7 -0
- package/dist/qa/types.d.ts +12 -0
- package/dist/render/beauty.d.ts +40 -0
- package/dist/render/camera.d.ts +33 -0
- package/dist/render/depth-map.d.ts +38 -0
- package/dist/render/font.d.ts +1 -0
- package/dist/render/ground.d.ts +13 -0
- package/dist/render/index.d.ts +10 -0
- package/dist/render/index.js +47 -0
- package/dist/render/index.js.map +9 -0
- package/dist/render/lighting.d.ts +27 -0
- package/dist/render/lod-strip.d.ts +5 -0
- package/dist/render/metrics.d.ts +37 -0
- package/dist/render/options.d.ts +28 -0
- package/dist/render/photo-match.d.ts +19 -0
- package/dist/render/raster.d.ts +25 -0
- package/dist/render/resolve.d.ts +11 -0
- package/dist/render/review-prompt.d.ts +2 -0
- package/dist/render/review-warnings.d.ts +34 -0
- package/dist/render/review.d.ts +24 -0
- package/dist/render/scene.d.ts +18 -0
- package/dist/render/shade.d.ts +22 -0
- package/dist/render/sheet.d.ts +15 -0
- package/dist/render/texture.d.ts +15 -0
- package/dist/render/thumbnail.d.ts +8 -0
- package/dist/render/vis-buffer.d.ts +18 -0
- package/dist/testing/assert.d.ts +21 -0
- package/dist/testing/compiled.d.ts +15 -0
- package/dist/testing/hash.d.ts +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.js +134 -0
- package/dist/testing/index.js.map +13 -0
- package/dist/testing/snapshot.d.ts +13 -0
- package/docs/README.md +56 -0
- package/docs/architecture/README.md +68 -0
- package/docs/architecture/adding-a-kind.md +44 -0
- package/docs/architecture/adding-a-primitive.md +49 -0
- package/docs/architecture/errors.md +47 -0
- package/docs/architecture/glb-production.md +214 -0
- package/docs/architecture/gltf-capabilities.md +117 -0
- package/docs/architecture/materials.md +151 -0
- package/docs/decisions/001-recipe-compiler-over-ai-meshes.md +27 -0
- package/docs/decisions/002-typescript-not-json.md +22 -0
- package/docs/decisions/003-shared-trim-sheet.md +21 -0
- package/docs/decisions/004-z-up-metres.md +21 -0
- package/docs/decisions/005-zero-runtime-deps.md +21 -0
- package/docs/decisions/006-single-package-subpath-exports.md +20 -0
- package/docs/decisions/007-cpu-contact-sheets.md +21 -0
- package/docs/decisions/008-surface-materials.md +21 -0
- package/docs/decisions/009-gltf-front-axis.md +21 -0
- package/docs/decisions/README.md +15 -0
- package/docs/idea/01-vision.md +117 -0
- package/docs/idea/02-dsl.md +343 -0
- package/docs/idea/03-ir.md +97 -0
- package/docs/idea/04-materials.md +114 -0
- package/docs/idea/05-agent-loop.md +141 -0
- package/docs/idea/06-qa.md +101 -0
- package/docs/idea/07-what-fits.md +45 -0
- package/docs/idea/08-neural-adapters.md +78 -0
- package/docs/idea/09-kinds.md +105 -0
- package/docs/idea/10-sculpting.md +166 -0
- package/docs/idea/11-materials-authoring.md +132 -0
- package/docs/idea/12-blender-bridge.md +136 -0
- package/docs/idea/13-asset-pipeline-research.md +89 -0
- package/docs/landscape.md +49 -0
- package/docs/plans/roadmap.md +139 -0
- package/examples/build-with-bun.ts +41 -0
- package/llms.txt +47 -0
- package/package.json +100 -4
- package/recipes/README.md +38 -0
- package/recipes/asteroid/README.md +46 -0
- package/recipes/asteroid/asteroid.ts +336 -0
- package/recipes/boulders/README.md +28 -0
- package/recipes/boulders/boulders.ts +117 -0
- package/recipes/boxcar/README.md +53 -0
- package/recipes/boxcar/boxcar.ts +1000 -0
- package/recipes/cargo_container_scifi/README.md +52 -0
- package/recipes/cargo_container_scifi/cargo_container_scifi.ts +461 -0
- package/recipes/dropship/README.md +84 -0
- package/recipes/dropship/dropship.ts +1144 -0
- package/recipes/eiffel_tower/README.md +110 -0
- package/recipes/eiffel_tower/eiffel_tower.ts +781 -0
- package/recipes/goblin_head/README.md +75 -0
- package/recipes/goblin_head/goblin_head.ts +38 -0
- package/recipes/human_head/README.md +68 -0
- package/recipes/human_head/human_head.ts +38 -0
- package/recipes/loco_440/README.md +32 -0
- package/recipes/loco_440/loco_440.ts +1404 -0
- package/recipes/material_swatches/README.md +21 -0
- package/recipes/material_swatches/material_swatches.ts +189 -0
- package/recipes/mountain_range/README.md +45 -0
- package/recipes/mountain_range/mountain_range.ts +128 -0
- package/recipes/oak/README.md +30 -0
- package/recipes/oak/oak.ts +19 -0
- package/recipes/orc_head/README.md +78 -0
- package/recipes/orc_head/orc_head.ts +41 -0
- package/recipes/palm/README.md +30 -0
- package/recipes/palm/palm.ts +19 -0
- package/recipes/pine/README.md +29 -0
- package/recipes/pine/pine.ts +19 -0
- package/recipes/signal_gantry/README.md +36 -0
- package/recipes/signal_gantry/signal_gantry.ts +522 -0
- package/recipes/station_halt/README.md +39 -0
- package/recipes/station_halt/station_halt.ts +722 -0
- package/recipes/t34/README.md +44 -0
- package/recipes/t34/t34.ts +1068 -0
- package/recipes/tiger_1/README.md +75 -0
- package/recipes/tiger_1/tiger_1.ts +1370 -0
- package/recipes/water_tower/README.md +40 -0
- package/recipes/water_tower/water_tower.ts +542 -0
- package/src/cli/args.ts +125 -0
- package/src/cli/bin.ts +7 -0
- package/src/cli/load.ts +17 -0
- package/src/cli/manifest.ts +95 -0
- package/src/cli/render-cmds.ts +66 -0
- package/src/cli/run.ts +192 -0
- package/src/cli/texture-cache.ts +24 -0
- package/src/core/asset.ts +129 -0
- package/src/core/definition.ts +156 -0
- package/src/core/errors.ts +50 -0
- package/src/core/family.ts +50 -0
- package/src/core/index.ts +66 -0
- package/src/core/mesh.ts +114 -0
- package/src/core/part.ts +130 -0
- package/src/core/png.ts +49 -0
- package/src/core/rng.ts +49 -0
- package/src/core/transform.ts +90 -0
- package/src/core/vec.ts +26 -0
- package/src/core/world.ts +80 -0
- package/src/export/bin-writer.ts +79 -0
- package/src/export/container.ts +35 -0
- package/src/export/credits.ts +25 -0
- package/src/export/glb-options.ts +53 -0
- package/src/export/glb.ts +187 -0
- package/src/export/hierarchy.ts +122 -0
- package/src/export/index.ts +34 -0
- package/src/export/lights.ts +49 -0
- package/src/export/lod-coverage.ts +71 -0
- package/src/export/materials.ts +126 -0
- package/src/export/merge-pivots.ts +146 -0
- package/src/export/metadata.ts +62 -0
- package/src/export/motion.ts +70 -0
- package/src/export/optimize-parts.ts +80 -0
- package/src/export/primitive.ts +35 -0
- package/src/export/tangents.ts +75 -0
- package/src/export/textures.ts +88 -0
- package/src/export/version.ts +6 -0
- package/src/grammar/index.ts +4 -0
- package/src/grammar/split.ts +87 -0
- package/src/grammar/whyte.ts +20 -0
- package/src/index.ts +14 -0
- package/src/kinds/building.ts +153 -0
- package/src/kinds/faces.ts +138 -0
- package/src/kinds/head-armour.ts +181 -0
- package/src/kinds/head-beard.ts +133 -0
- package/src/kinds/head-bust.ts +184 -0
- package/src/kinds/head-extras.ts +150 -0
- package/src/kinds/head-face.ts +242 -0
- package/src/kinds/head-garb.ts +181 -0
- package/src/kinds/head-geom.ts +31 -0
- package/src/kinds/head-hair.ts +193 -0
- package/src/kinds/head-layout.ts +63 -0
- package/src/kinds/head-mesh.ts +195 -0
- package/src/kinds/head-mouth.ts +111 -0
- package/src/kinds/head-params.ts +162 -0
- package/src/kinds/head-presets.ts +155 -0
- package/src/kinds/head-rim.ts +128 -0
- package/src/kinds/head-tone.ts +52 -0
- package/src/kinds/head-torso.ts +230 -0
- package/src/kinds/head.ts +176 -0
- package/src/kinds/hull-lines.ts +160 -0
- package/src/kinds/hull-skin.ts +83 -0
- package/src/kinds/hull.ts +209 -0
- package/src/kinds/index.ts +63 -0
- package/src/kinds/mass.ts +110 -0
- package/src/kinds/openings.ts +141 -0
- package/src/kinds/planned.ts +12 -0
- package/src/kinds/roof-chimney.ts +100 -0
- package/src/kinds/roof-shape.ts +230 -0
- package/src/kinds/roof.ts +250 -0
- package/src/kinds/vegetation-fronds.ts +126 -0
- package/src/kinds/vegetation-impostor.ts +118 -0
- package/src/kinds/vegetation-leaves.ts +168 -0
- package/src/kinds/vegetation-mesh.ts +174 -0
- package/src/kinds/vegetation-params.ts +147 -0
- package/src/kinds/vegetation-presets.ts +184 -0
- package/src/kinds/vegetation-skeleton.ts +168 -0
- package/src/kinds/vegetation.ts +199 -0
- package/src/kinds/vehicle.ts +144 -0
- package/src/material/cc0.ts +41 -0
- package/src/material/define.ts +130 -0
- package/src/material/generator.ts +63 -0
- package/src/material/index.ts +60 -0
- package/src/material/library.ts +196 -0
- package/src/material/material-def.ts +84 -0
- package/src/material/paint/bond.ts +60 -0
- package/src/material/paint/canvas.ts +101 -0
- package/src/material/paint/cell.ts +39 -0
- package/src/material/paint/cells-round.ts +119 -0
- package/src/material/paint/cells.ts +111 -0
- package/src/material/paint/compose.ts +53 -0
- package/src/material/paint/concrete.ts +62 -0
- package/src/material/paint/courses.ts +85 -0
- package/src/material/paint/decode-png.ts +106 -0
- package/src/material/paint/default-sheet.ts +73 -0
- package/src/material/paint/fabric.ts +63 -0
- package/src/material/paint/foliage-broad.ts +126 -0
- package/src/material/paint/foliage-common.ts +93 -0
- package/src/material/paint/foliage-compound.ts +135 -0
- package/src/material/paint/foliage-conifer.ts +143 -0
- package/src/material/paint/foliage-raster.ts +196 -0
- package/src/material/paint/foliage.ts +23 -0
- package/src/material/paint/image-strip.ts +88 -0
- package/src/material/paint/kit.ts +37 -0
- package/src/material/paint/masks.ts +46 -0
- package/src/material/paint/metal.ts +109 -0
- package/src/material/paint/noise.ts +52 -0
- package/src/material/paint/normal.ts +52 -0
- package/src/material/paint/orm.ts +108 -0
- package/src/material/paint/planks.ts +101 -0
- package/src/material/paint/plates.ts +72 -0
- package/src/material/paint/shapes.ts +28 -0
- package/src/material/paint/slate.ts +52 -0
- package/src/material/paint/stamp.ts +40 -0
- package/src/material/paint/strip.ts +48 -0
- package/src/material/paint/surface.ts +60 -0
- package/src/material/paint/types.ts +94 -0
- package/src/material/paint/validate.ts +74 -0
- package/src/material/palette.ts +46 -0
- package/src/material/shader-godot.ts +77 -0
- package/src/material/shader-three.ts +103 -0
- package/src/material/shader.ts +100 -0
- package/src/material/slots.ts +18 -0
- package/src/material/texture-source.ts +86 -0
- package/src/material/trim-sheet.ts +166 -0
- package/src/neural/generator.ts +37 -0
- package/src/neural/images.ts +27 -0
- package/src/neural/index.ts +10 -0
- package/src/passes/bake-ao.ts +183 -0
- package/src/passes/grime.ts +37 -0
- package/src/passes/index.ts +8 -0
- package/src/passes/livery.ts +66 -0
- package/src/passes/optimize-cache.ts +175 -0
- package/src/passes/optimize-weld.ts +147 -0
- package/src/passes/optimize.ts +85 -0
- package/src/passes/ray-grid.ts +237 -0
- package/src/passes/weighted-normals.ts +125 -0
- package/src/primitives/beam.ts +60 -0
- package/src/primitives/bevel-box.ts +140 -0
- package/src/primitives/box.ts +90 -0
- package/src/primitives/cell.ts +115 -0
- package/src/primitives/check.ts +49 -0
- package/src/primitives/closed.ts +74 -0
- package/src/primitives/erosion.ts +183 -0
- package/src/primitives/font-5x7.ts +117 -0
- package/src/primitives/heightfield.ts +101 -0
- package/src/primitives/index.ts +56 -0
- package/src/primitives/lathe-facets.ts +45 -0
- package/src/primitives/lathe.ts +174 -0
- package/src/primitives/lattice.ts +131 -0
- package/src/primitives/loft.ts +174 -0
- package/src/primitives/mc-table.ts +41 -0
- package/src/primitives/member.ts +130 -0
- package/src/primitives/noise.ts +157 -0
- package/src/primitives/planar.ts +55 -0
- package/src/primitives/prism.ts +85 -0
- package/src/primitives/sculpt-edit.ts +212 -0
- package/src/primitives/sculpt-tree.ts +226 -0
- package/src/primitives/sculpt.ts +80 -0
- package/src/primitives/sdf-grid.ts +131 -0
- package/src/primitives/sdf-ops.ts +145 -0
- package/src/primitives/sdf.ts +83 -0
- package/src/primitives/strip-uv.ts +26 -0
- package/src/primitives/surface-nets.ts +161 -0
- package/src/primitives/sweep.ts +162 -0
- package/src/primitives/terrain-color.ts +85 -0
- package/src/primitives/terrain-grid.ts +137 -0
- package/src/primitives/text-layout.ts +85 -0
- package/src/primitives/text.ts +197 -0
- package/src/primitives/tiled.ts +93 -0
- package/src/primitives/transport.ts +85 -0
- package/src/primitives/triangulate.ts +42 -0
- package/src/primitives/value-noise.ts +62 -0
- package/src/qa/checks.ts +110 -0
- package/src/qa/clash.ts +177 -0
- package/src/qa/floating.ts +63 -0
- package/src/qa/gates.ts +126 -0
- package/src/qa/geometry.ts +187 -0
- package/src/qa/index.ts +28 -0
- package/src/qa/inside.ts +114 -0
- package/src/qa/inspect.ts +107 -0
- package/src/qa/lods.ts +97 -0
- package/src/qa/measures.ts +67 -0
- package/src/qa/occlusion.ts +166 -0
- package/src/qa/sanity.ts +137 -0
- package/src/qa/types.ts +17 -0
- package/src/render/beauty.ts +115 -0
- package/src/render/camera.ts +142 -0
- package/src/render/depth-map.ts +191 -0
- package/src/render/font.ts +76 -0
- package/src/render/ground.ts +87 -0
- package/src/render/index.ts +34 -0
- package/src/render/lighting.ts +121 -0
- package/src/render/lod-strip.ts +34 -0
- package/src/render/metrics.ts +147 -0
- package/src/render/options.ts +81 -0
- package/src/render/photo-match.ts +28 -0
- package/src/render/raster.ts +143 -0
- package/src/render/resolve.ts +109 -0
- package/src/render/review-prompt.ts +59 -0
- package/src/render/review-warnings.ts +92 -0
- package/src/render/review.ts +103 -0
- package/src/render/scene.ts +119 -0
- package/src/render/shade.ts +204 -0
- package/src/render/sheet.ts +88 -0
- package/src/render/texture.ts +97 -0
- package/src/render/thumbnail.ts +75 -0
- package/src/render/vis-buffer.ts +119 -0
- package/src/testing/assert.ts +115 -0
- package/src/testing/compiled.ts +31 -0
- package/src/testing/hash.ts +14 -0
- package/src/testing/index.ts +14 -0
- package/src/testing/snapshot.ts +37 -0
- package/src/types/gltf-validator.d.ts +13 -0
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
// T-34/76 family. `t34` = Model 1943 (hexagonal "nut" turret, commander's cupola, side fuel drums,
|
|
2
|
+
// «LIDICE» as photographed on the 1st Czechoslovak brigade tank); `t34_1941` = cast turret with the
|
|
3
|
+
// big front hatch. Real: 6.68 m with gun (hull 5.92 m) × 3.00 m × 2.45 m (1941: 2.40 m); 830 mm
|
|
4
|
+
// Christie wheels, 550 mm track; 60° glacis, 40° side plates; 76.2 mm F-34 L/41.5.
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
applyAffine,
|
|
8
|
+
beam,
|
|
9
|
+
box,
|
|
10
|
+
type Check,
|
|
11
|
+
clear,
|
|
12
|
+
cross,
|
|
13
|
+
cylinder,
|
|
14
|
+
defineFamily,
|
|
15
|
+
frame,
|
|
16
|
+
grime,
|
|
17
|
+
hex,
|
|
18
|
+
type Lod,
|
|
19
|
+
lathe,
|
|
20
|
+
type Mesh,
|
|
21
|
+
merge,
|
|
22
|
+
noOverlap,
|
|
23
|
+
normalize,
|
|
24
|
+
place,
|
|
25
|
+
planar,
|
|
26
|
+
prism,
|
|
27
|
+
scale,
|
|
28
|
+
sub,
|
|
29
|
+
symmetric,
|
|
30
|
+
touches,
|
|
31
|
+
translate,
|
|
32
|
+
type Vec2,
|
|
33
|
+
type Vec3,
|
|
34
|
+
} from '@developerz.ai/ts23d';
|
|
35
|
+
|
|
36
|
+
const green = hex('#4e5a2c');
|
|
37
|
+
const greenDark = hex('#3a4422');
|
|
38
|
+
const rubber = hex('#252523');
|
|
39
|
+
const steel = hex('#45443f');
|
|
40
|
+
const trackSteel = hex('#4a4139');
|
|
41
|
+
const black = hex('#191919');
|
|
42
|
+
const white = hex('#e6e4da');
|
|
43
|
+
const rust = hex('#4a3426');
|
|
44
|
+
|
|
45
|
+
const TRACK_Y = 1.225;
|
|
46
|
+
const TRACK_W = 0.55;
|
|
47
|
+
const LINK_T = 0.06;
|
|
48
|
+
const WHEEL_R = 0.415;
|
|
49
|
+
const WHEEL_Z = 0.475;
|
|
50
|
+
const WHEELS_X = [1.82, 0.97, -0.08, -0.93, -1.78];
|
|
51
|
+
const IDLER = { x: 2.55, z: 0.6, r: 0.3 };
|
|
52
|
+
const SPROCKET = { x: -2.5, z: 0.58, r: 0.32 };
|
|
53
|
+
const BELLY = 0.4;
|
|
54
|
+
const PANNIER_Z = 1.0;
|
|
55
|
+
const DECK = 1.45;
|
|
56
|
+
const HULL_HALF = 2.96;
|
|
57
|
+
const NOSE: Vec2 = [HULL_HALF, 0.78];
|
|
58
|
+
const TAN60 = Math.tan(Math.PI / 3);
|
|
59
|
+
/** x of the glacis at height z (60° from vertical). */
|
|
60
|
+
const glacisX = (z: number): number => NOSE[0] - (z - NOSE[1]) * TAN60;
|
|
61
|
+
const REAR_PITCH = Math.atan2(-0.66, 0.75);
|
|
62
|
+
const TURRET_AT: Vec3 = [0.45, 0, DECK];
|
|
63
|
+
|
|
64
|
+
type Circle = { readonly x: number; readonly z: number; readonly r: number };
|
|
65
|
+
type Station = { readonly p: Vec2; readonly pitch: number; readonly len: number };
|
|
66
|
+
|
|
67
|
+
// ---------------------------------------------------------------- track belt
|
|
68
|
+
|
|
69
|
+
/** Clockwise (x right, z up) convex hull of points: walking it, outward is on the left. */
|
|
70
|
+
function hullCw(pts: Vec2[]): Vec2[] {
|
|
71
|
+
const s = [...pts].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
72
|
+
const cr = (o: Vec2, a: Vec2, b: Vec2): number =>
|
|
73
|
+
(a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
|
74
|
+
const half = (list: Vec2[]): Vec2[] => {
|
|
75
|
+
const h: Vec2[] = [];
|
|
76
|
+
for (const p of list) {
|
|
77
|
+
while (h.length >= 2 && cr(h[h.length - 2] as Vec2, h[h.length - 1] as Vec2, p) <= 0) h.pop();
|
|
78
|
+
h.push(p);
|
|
79
|
+
}
|
|
80
|
+
h.pop();
|
|
81
|
+
return h;
|
|
82
|
+
};
|
|
83
|
+
return [...half(s), ...half([...s].reverse())].reverse();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Evenly re-sample a closed polyline into n stations with their pitch (for place()). */
|
|
87
|
+
function resample(poly: readonly Vec2[], n: number): Station[] {
|
|
88
|
+
const seg = poly.map((a, i) => {
|
|
89
|
+
const b = poly[(i + 1) % poly.length] as Vec2;
|
|
90
|
+
return Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
91
|
+
});
|
|
92
|
+
const total = seg.reduce((s, l) => s + l, 0);
|
|
93
|
+
const out: Station[] = [];
|
|
94
|
+
let i = 0;
|
|
95
|
+
let acc = 0;
|
|
96
|
+
for (let k = 0; k < n; k++) {
|
|
97
|
+
const d = (k / n) * total;
|
|
98
|
+
while (acc + (seg[i] ?? 0) < d && i < poly.length - 1) acc += seg[i++] ?? 0;
|
|
99
|
+
const a = poly[i] as Vec2;
|
|
100
|
+
const b = poly[(i + 1) % poly.length] as Vec2;
|
|
101
|
+
const t = (d - acc) / (seg[i] || 1);
|
|
102
|
+
out.push({
|
|
103
|
+
p: [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t],
|
|
104
|
+
pitch: Math.atan2(-(b[1] - a[1]), b[0] - a[0]),
|
|
105
|
+
len: total / n,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The track's centre line: a belt around sprocket, idler and road wheels, sagging on top. */
|
|
112
|
+
function beltLine(wheels: readonly Circle[], ends: readonly Circle[], sag: number): Vec2[] {
|
|
113
|
+
const off = LINK_T / 2;
|
|
114
|
+
const pts: Vec2[] = [];
|
|
115
|
+
for (const c of [...wheels, ...ends])
|
|
116
|
+
for (let i = 0; i < 72; i++) {
|
|
117
|
+
const t = (i / 72) * Math.PI * 2;
|
|
118
|
+
pts.push([c.x + (c.r + off) * Math.cos(t), c.z + (c.r + off) * Math.sin(t)]);
|
|
119
|
+
}
|
|
120
|
+
const dense = resample(hullCw(pts), 600);
|
|
121
|
+
const x0 = Math.min(...ends.map((c) => c.x));
|
|
122
|
+
const x1 = Math.max(...ends.map((c) => c.x));
|
|
123
|
+
const env = (x: number): number =>
|
|
124
|
+
Math.max(
|
|
125
|
+
0,
|
|
126
|
+
...wheels.map((w) =>
|
|
127
|
+
Math.abs(x - w.x) < w.r + off ? w.z + Math.sqrt((w.r + off) ** 2 - (x - w.x) ** 2) : 0,
|
|
128
|
+
),
|
|
129
|
+
);
|
|
130
|
+
return dense.map(({ p, pitch }) => {
|
|
131
|
+
const topRun = Math.cos(pitch) > 0.8 && p[1] > WHEEL_Z;
|
|
132
|
+
if (!topRun || p[0] <= x0 || p[0] >= x1) return p;
|
|
133
|
+
const drop = sag * Math.sin((Math.PI * (p[0] - x0)) / (x1 - x0));
|
|
134
|
+
return [p[0], Math.max(env(p[0]), p[1] - drop)];
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Waffle-pattern cast link (X along the run, Z outward); every other one has a guide horn. */
|
|
139
|
+
function trackLink(pitch: number, horn: boolean): Mesh {
|
|
140
|
+
const parts = [
|
|
141
|
+
box({
|
|
142
|
+
size: [pitch * 0.88, TRACK_W, LINK_T * 0.6],
|
|
143
|
+
at: [0, 0, -LINK_T * 0.3],
|
|
144
|
+
color: trackSteel,
|
|
145
|
+
}),
|
|
146
|
+
box({
|
|
147
|
+
size: [0.03, TRACK_W * 0.96, LINK_T * 0.4],
|
|
148
|
+
at: [-pitch * 0.2, 0, 0],
|
|
149
|
+
color: trackSteel,
|
|
150
|
+
}),
|
|
151
|
+
box({ size: [0.03, TRACK_W * 0.96, LINK_T * 0.4], at: [pitch * 0.2, 0, 0], color: trackSteel }),
|
|
152
|
+
];
|
|
153
|
+
if (horn)
|
|
154
|
+
parts.push(
|
|
155
|
+
box({ size: [pitch * 0.5, 0.06, 0.13], at: [0, 0, -LINK_T * 0.3 - 0.13], color: steel }),
|
|
156
|
+
);
|
|
157
|
+
return merge(parts);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function trackMesh(lod: Lod, line: readonly Vec2[], y: number): Mesh {
|
|
161
|
+
if (lod === 2) {
|
|
162
|
+
const ring = resample(line, 22).map(
|
|
163
|
+
(s): Vec2 => [
|
|
164
|
+
s.p[0] + (Math.sin(s.pitch) * LINK_T) / 2,
|
|
165
|
+
s.p[1] + (Math.cos(s.pitch) * LINK_T) / 2,
|
|
166
|
+
],
|
|
167
|
+
);
|
|
168
|
+
return translate(prism({ profile: ring, depth: TRACK_W, plane: 'xz', color: trackSteel }), [
|
|
169
|
+
0,
|
|
170
|
+
y,
|
|
171
|
+
0,
|
|
172
|
+
]);
|
|
173
|
+
}
|
|
174
|
+
const perimeter = resample(line, 1)[0]?.len ?? 1;
|
|
175
|
+
const stations = resample(line, Math.round(perimeter / (lod === 0 ? 0.172 : 0.25)));
|
|
176
|
+
const len = stations[0]?.len ?? 0.172;
|
|
177
|
+
const band = box({
|
|
178
|
+
size: [len * 1.04, TRACK_W, LINK_T],
|
|
179
|
+
at: [0, 0, -LINK_T / 2],
|
|
180
|
+
color: trackSteel,
|
|
181
|
+
});
|
|
182
|
+
const links = [trackLink(len, true), trackLink(len, false)];
|
|
183
|
+
return merge(
|
|
184
|
+
stations.map((s, i) =>
|
|
185
|
+
place(lod === 0 ? (links[i % 2] as Mesh) : band, {
|
|
186
|
+
at: [s.p[0], y, s.p[1]],
|
|
187
|
+
pitch: s.pitch,
|
|
188
|
+
}),
|
|
189
|
+
),
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ---------------------------------------------------------------- wheels
|
|
194
|
+
|
|
195
|
+
/** One half of a Christie double wheel: rubber tyre + stamped dished disc. Axis Y, face +Y. */
|
|
196
|
+
function wheelHalf(lod: Lod, r: number, w: number, ribs: number, paint: Vec3): Mesh {
|
|
197
|
+
const segs = [24, 12, 8][lod] ?? 8;
|
|
198
|
+
const h = w / 2;
|
|
199
|
+
const tyre = lathe({
|
|
200
|
+
profile: [
|
|
201
|
+
[r - 0.07, -h],
|
|
202
|
+
[r - 0.01, -h],
|
|
203
|
+
[r, -h + 0.015],
|
|
204
|
+
[r, h - 0.015],
|
|
205
|
+
[r - 0.01, h],
|
|
206
|
+
[r - 0.07, h],
|
|
207
|
+
],
|
|
208
|
+
segments: segs,
|
|
209
|
+
axis: 'y',
|
|
210
|
+
color: rubber,
|
|
211
|
+
});
|
|
212
|
+
const face: Vec2[] =
|
|
213
|
+
lod === 0
|
|
214
|
+
? [
|
|
215
|
+
[r - 0.07, h - 0.005],
|
|
216
|
+
[r * 0.72, h - 0.04],
|
|
217
|
+
[r * 0.36, h - 0.05],
|
|
218
|
+
[r * 0.3, h - 0.01],
|
|
219
|
+
[r * 0.2, h + 0.03],
|
|
220
|
+
[r * 0.1, h + 0.045],
|
|
221
|
+
[0, h + 0.05],
|
|
222
|
+
]
|
|
223
|
+
: [
|
|
224
|
+
[r - 0.07, h - 0.005],
|
|
225
|
+
[r * 0.35, h - 0.04],
|
|
226
|
+
[r * 0.2, h + 0.03],
|
|
227
|
+
[0, h + 0.04],
|
|
228
|
+
];
|
|
229
|
+
const back = face.map(([fr, fz]) => [fr, -fz] as Vec2).reverse();
|
|
230
|
+
const parts = [
|
|
231
|
+
tyre,
|
|
232
|
+
lathe({ profile: [...back, ...face], segments: segs, axis: 'y', color: paint }),
|
|
233
|
+
];
|
|
234
|
+
if (lod === 0) {
|
|
235
|
+
// Stamped radial ribs and hub bolts.
|
|
236
|
+
const rib = box({ size: [0.035, 0.025, r * 0.36], at: [0, 0, r * 0.33], color: paint });
|
|
237
|
+
const bolt = box({ size: [0.03, 0.03, 0.03], at: [0, 0, -0.015], color: greenDark });
|
|
238
|
+
for (let i = 0; i < ribs; i++) {
|
|
239
|
+
const a = (i / ribs) * Math.PI * 2;
|
|
240
|
+
parts.push(place(rib, { at: [0, h - 0.035, 0], pitch: a }));
|
|
241
|
+
const b = a + Math.PI / ribs;
|
|
242
|
+
parts.push(place(bolt, { at: [Math.sin(b) * r * 0.16, h + 0.045, Math.cos(b) * r * 0.16] }));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return merge(parts);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Double road wheel: two halves straddling the guide horns. */
|
|
249
|
+
function christie(lod: Lod, r: number, ribs: number, paint: Vec3): Mesh {
|
|
250
|
+
const half = wheelHalf(lod, r, 0.17, ribs, paint);
|
|
251
|
+
return merge([
|
|
252
|
+
translate(half, [0, 0.135, 0]),
|
|
253
|
+
translate(place(half, { yaw: Math.PI }), [0, -0.135, 0]),
|
|
254
|
+
]);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Rear drive sprocket: two discs joined by six rollers that engage the guide horns. */
|
|
258
|
+
function sprocket(lod: Lod, r: number, paint: Vec3): Mesh {
|
|
259
|
+
const segs = [24, 12, 8][lod] ?? 8;
|
|
260
|
+
const disc = (y: number): Mesh =>
|
|
261
|
+
lathe({
|
|
262
|
+
profile: [
|
|
263
|
+
[0.1, y - 0.03],
|
|
264
|
+
[r, y - 0.03],
|
|
265
|
+
[r, y + 0.03],
|
|
266
|
+
[0.1, y + 0.03],
|
|
267
|
+
],
|
|
268
|
+
segments: segs,
|
|
269
|
+
axis: 'y',
|
|
270
|
+
color: paint,
|
|
271
|
+
});
|
|
272
|
+
const parts = [
|
|
273
|
+
disc(0.1),
|
|
274
|
+
disc(-0.1),
|
|
275
|
+
lathe({
|
|
276
|
+
profile: [
|
|
277
|
+
[0.16, -0.25],
|
|
278
|
+
[0.16, 0.2],
|
|
279
|
+
[0.1, 0.27],
|
|
280
|
+
[0, 0.27],
|
|
281
|
+
],
|
|
282
|
+
segments: segs,
|
|
283
|
+
axis: 'y',
|
|
284
|
+
color: greenDark,
|
|
285
|
+
}),
|
|
286
|
+
];
|
|
287
|
+
if (lod === 0)
|
|
288
|
+
for (let i = 0; i < 6; i++) {
|
|
289
|
+
const a = (i / 6) * Math.PI * 2;
|
|
290
|
+
parts.push(
|
|
291
|
+
cylinder({
|
|
292
|
+
radius: 0.05,
|
|
293
|
+
length: 0.2,
|
|
294
|
+
segments: 8,
|
|
295
|
+
axis: 'y',
|
|
296
|
+
at: [Math.cos(a) * (r - 0.06), 0, Math.sin(a) * (r - 0.06)],
|
|
297
|
+
color: steel,
|
|
298
|
+
}),
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
return merge(parts);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// ---------------------------------------------------------------- solids and details
|
|
305
|
+
|
|
306
|
+
/** Solid between two parallel polygons with matching vertices (CCW from above): sloped armour. */
|
|
307
|
+
function taper(bottom: readonly Vec3[], top: readonly Vec3[], color: Vec3): Mesh {
|
|
308
|
+
const faces = [planar({ points: [...bottom].reverse(), color, strip: 'iron' })];
|
|
309
|
+
faces.push(planar({ points: top, color, strip: 'iron' }));
|
|
310
|
+
bottom.forEach((b, i) => {
|
|
311
|
+
const j = (i + 1) % bottom.length;
|
|
312
|
+
faces.push(
|
|
313
|
+
planar({
|
|
314
|
+
points: [b, bottom[j] as Vec3, top[j] as Vec3, top[i] as Vec3],
|
|
315
|
+
color,
|
|
316
|
+
strip: 'iron',
|
|
317
|
+
}),
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
return merge(faces);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function cable(points: readonly Vec3[], d: number, color: Vec3): Mesh {
|
|
324
|
+
return merge(
|
|
325
|
+
points
|
|
326
|
+
.slice(1)
|
|
327
|
+
.map((to, i) => beam({ from: points[i] as Vec3, to, width: d, segments: 5, color })),
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Grime in world space for a part authored around its own pivot. */
|
|
332
|
+
const muddy = (m: Mesh, at: Vec3 = [0, 0, 0]): Mesh =>
|
|
333
|
+
translate(grime(translate(m, at), { ground: 1.0, groundStrength: 0.5 }), [
|
|
334
|
+
-at[0],
|
|
335
|
+
-at[1],
|
|
336
|
+
-at[2],
|
|
337
|
+
]);
|
|
338
|
+
|
|
339
|
+
/** Place a detail flat on the glacis at height z (local Z → plate normal, local X → downslope). */
|
|
340
|
+
const onGlacis = (m: Mesh, y: number, z: number): Mesh =>
|
|
341
|
+
place(m, { at: [glacisX(z), y, z], pitch: Math.PI / 6 });
|
|
342
|
+
|
|
343
|
+
/** Run a check only at LODs where `part` exists (running gear is dropped at LOD2). */
|
|
344
|
+
const whenBuilt =
|
|
345
|
+
(part: string, check: Check): Check =>
|
|
346
|
+
(asset) =>
|
|
347
|
+
asset.parts.some((p) => p.name === part && p.mesh) ? check(asset) : [];
|
|
348
|
+
|
|
349
|
+
// ---------------------------------------------------------------- lettering
|
|
350
|
+
|
|
351
|
+
/** Block capitals on a 4 × 6 grid as stroke segments; enough for slogans and numbers. */
|
|
352
|
+
const GLYPHS: Record<string, readonly (readonly [number, number, number, number])[]> = {
|
|
353
|
+
L: [
|
|
354
|
+
[0, 0, 0, 6],
|
|
355
|
+
[0, 0, 4, 0],
|
|
356
|
+
],
|
|
357
|
+
I: [
|
|
358
|
+
[2, 0, 2, 6],
|
|
359
|
+
[1, 0, 3, 0],
|
|
360
|
+
[1, 6, 3, 6],
|
|
361
|
+
],
|
|
362
|
+
D: [
|
|
363
|
+
[0, 0, 0, 6],
|
|
364
|
+
[0, 6, 3, 6],
|
|
365
|
+
[3, 6, 4, 5],
|
|
366
|
+
[4, 5, 4, 1],
|
|
367
|
+
[4, 1, 3, 0],
|
|
368
|
+
[3, 0, 0, 0],
|
|
369
|
+
],
|
|
370
|
+
C: [
|
|
371
|
+
[4, 6, 0, 6],
|
|
372
|
+
[0, 6, 0, 0],
|
|
373
|
+
[0, 0, 4, 0],
|
|
374
|
+
],
|
|
375
|
+
E: [
|
|
376
|
+
[0, 0, 0, 6],
|
|
377
|
+
[0, 6, 4, 6],
|
|
378
|
+
[0, 3, 3, 3],
|
|
379
|
+
[0, 0, 4, 0],
|
|
380
|
+
],
|
|
381
|
+
'"': [
|
|
382
|
+
[1, 6, 1, 4.5],
|
|
383
|
+
[2.5, 6, 2.5, 4.5],
|
|
384
|
+
],
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/** Text as stroke quads (u right, v up), letter height `h`, CCW in (u, v). */
|
|
388
|
+
function lettering(text: string, h: number): Vec2[][] {
|
|
389
|
+
const k = h / 6;
|
|
390
|
+
const t = 0.9 * k;
|
|
391
|
+
const out: Vec2[][] = [];
|
|
392
|
+
[...text].forEach((ch, i) => {
|
|
393
|
+
for (const [x0, y0, x1, y1] of GLYPHS[ch] ?? []) {
|
|
394
|
+
const a: Vec2 = [(x0 + i * 5.5) * k, y0 * k];
|
|
395
|
+
const b: Vec2 = [(x1 + i * 5.5) * k, y1 * k];
|
|
396
|
+
const l = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1;
|
|
397
|
+
const d: Vec2 = [((b[0] - a[0]) / l) * (t / 2), ((b[1] - a[1]) / l) * (t / 2)];
|
|
398
|
+
const n: Vec2 = [-d[1], d[0]];
|
|
399
|
+
out.push([
|
|
400
|
+
[a[0] - n[0] - d[0], a[1] - n[1] - d[1]],
|
|
401
|
+
[b[0] - n[0] + d[0], b[1] - n[1] + d[1]],
|
|
402
|
+
[b[0] + n[0] + d[0], b[1] + n[1] + d[1]],
|
|
403
|
+
[a[0] + n[0] - d[0], a[1] + n[1] - d[1]],
|
|
404
|
+
]);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
return out;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Paint flat quads onto a (possibly sloped) plate. `a` → `b` is the plate's bottom edge in the
|
|
412
|
+
* reading direction, `up` a point higher on the plate; the decal stands 8 mm proud.
|
|
413
|
+
*/
|
|
414
|
+
function plateDecal(quads: readonly Vec2[][], a: Vec3, b: Vec3, up: Vec3, at: Vec2, c: Vec3) {
|
|
415
|
+
const u = normalize(sub(b, a));
|
|
416
|
+
const raw = sub(up, a);
|
|
417
|
+
const v = normalize(sub(raw, scale(u, raw[0] * u[0] + raw[1] * u[1] + raw[2] * u[2])));
|
|
418
|
+
const n = cross(u, v);
|
|
419
|
+
const o: Vec3 = [
|
|
420
|
+
a[0] + u[0] * at[0] + v[0] * at[1] + n[0] * 0.008,
|
|
421
|
+
a[1] + u[1] * at[0] + v[1] * at[1] + n[1] * 0.008,
|
|
422
|
+
a[2] + u[2] * at[0] + v[2] * at[1] + n[2] * 0.008,
|
|
423
|
+
];
|
|
424
|
+
return merge(
|
|
425
|
+
quads.map((q) =>
|
|
426
|
+
applyAffine(
|
|
427
|
+
planar({ points: q.map(([x, y]): Vec3 => [x, y, 0]), color: c }),
|
|
428
|
+
frame(u, v, n, o),
|
|
429
|
+
),
|
|
430
|
+
),
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// ---------------------------------------------------------------- turrets
|
|
435
|
+
|
|
436
|
+
interface Params {
|
|
437
|
+
/** 1941: cast turret with one big front hatch; 1943: hexagonal "nut" with twin roof hatches. */
|
|
438
|
+
readonly turret: 'cast1941' | 'hex1943';
|
|
439
|
+
readonly cupola: boolean;
|
|
440
|
+
readonly fuelDrums: boolean;
|
|
441
|
+
/** White turret-side slogan, as photographed (null = unmarked). */
|
|
442
|
+
readonly slogan: string | null;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
type Shell = { bottom: Vec3[]; top: Vec3[] };
|
|
446
|
+
|
|
447
|
+
function turretShell(kind: Params['turret']): Shell {
|
|
448
|
+
if (kind === 'hex1943')
|
|
449
|
+
return {
|
|
450
|
+
bottom: [
|
|
451
|
+
[1.0, -0.62, 0],
|
|
452
|
+
[1.0, 0.62, 0],
|
|
453
|
+
[0.15, 1.0, 0],
|
|
454
|
+
[-1.1, 0.72, 0],
|
|
455
|
+
[-1.1, -0.72, 0],
|
|
456
|
+
[0.15, -1.0, 0],
|
|
457
|
+
],
|
|
458
|
+
top: [
|
|
459
|
+
[0.78, -0.46, 0.72],
|
|
460
|
+
[0.78, 0.46, 0.72],
|
|
461
|
+
[0.1, 0.76, 0.72],
|
|
462
|
+
[-0.92, 0.56, 0.72],
|
|
463
|
+
[-0.92, -0.56, 0.72],
|
|
464
|
+
[0.1, -0.76, 0.72],
|
|
465
|
+
],
|
|
466
|
+
};
|
|
467
|
+
// Cast 1941 turret: narrow nose, rounded sides, long rear overhang.
|
|
468
|
+
const ring = (rx: number, ry: number, z: number, front: number, rear: number): Vec3[] =>
|
|
469
|
+
[
|
|
470
|
+
[front, -ry * 0.62, z],
|
|
471
|
+
[front, ry * 0.62, z],
|
|
472
|
+
[front - 0.35, ry * 0.92, z],
|
|
473
|
+
[0.0, ry, z],
|
|
474
|
+
[-0.55, ry * 0.95, z],
|
|
475
|
+
[rear + 0.25, ry * 0.7, z],
|
|
476
|
+
[rear, ry * 0.3, z],
|
|
477
|
+
[rear, -ry * 0.3, z],
|
|
478
|
+
[rear + 0.25, -ry * 0.7, z],
|
|
479
|
+
[-0.55, -ry * 0.95, z],
|
|
480
|
+
[0.0, -ry, z],
|
|
481
|
+
[front - 0.35, -ry * 0.92, z],
|
|
482
|
+
].map(([x, y, zz]): Vec3 => [(x ?? 0) * rx, y ?? 0, zz ?? 0]);
|
|
483
|
+
return { bottom: ring(1, 0.92, 0, 0.98, -1.2), top: ring(0.92, 0.7, 0.66, 0.85, -1.08) };
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ---------------------------------------------------------------- the family
|
|
487
|
+
|
|
488
|
+
const t34Family = defineFamily<Params>({
|
|
489
|
+
kind: 'vehicle',
|
|
490
|
+
tags: ['military', 'tracked', 'ww2'],
|
|
491
|
+
sources: [
|
|
492
|
+
'https://en.wikipedia.org/wiki/T-34 (T-34/76 specifications: 6.68 × 3.00 × 2.45 m, hull 5.92 m)',
|
|
493
|
+
'https://en.wikipedia.org/wiki/76_mm_tank_gun_M1940_F-34 (L/41.5 → 3.162 m barrel)',
|
|
494
|
+
'Zaloga & Grandsen, T-34 in Action (Squadron/Signal 1981): 830 mm road wheels, 550 mm track, plate angles',
|
|
495
|
+
'https://commons.wikimedia.org/wiki/File:Tank_Lidice,_čs._armáda_v_SSSR.png («LIDICE» slogan, Model 1943 with cupola and side drums)',
|
|
496
|
+
],
|
|
497
|
+
real: {
|
|
498
|
+
length: 6.68,
|
|
499
|
+
width: 3.0,
|
|
500
|
+
height: 2.45,
|
|
501
|
+
measures: [
|
|
502
|
+
{ label: 'road wheel diameter', axis: 'z', value: 0.83, parts: ['wheel_l_0'] },
|
|
503
|
+
{ label: 'track width', axis: 'y', value: 0.55, parts: ['track_l'] },
|
|
504
|
+
{
|
|
505
|
+
label: 'track centres',
|
|
506
|
+
axis: 'y',
|
|
507
|
+
value: 2.45,
|
|
508
|
+
between: ['track_l', 'track_r'],
|
|
509
|
+
source: '3.00 m overall − 0.55 m track',
|
|
510
|
+
},
|
|
511
|
+
{ label: 'hull length', axis: 'x', value: 5.92, parts: ['hull'] },
|
|
512
|
+
{
|
|
513
|
+
label: 'F-34 barrel length (L/41.5)',
|
|
514
|
+
axis: 'x',
|
|
515
|
+
value: 3.162,
|
|
516
|
+
parts: ['gun_barrel'],
|
|
517
|
+
source: 'https://en.wikipedia.org/wiki/76_mm_tank_gun_M1940_F-34',
|
|
518
|
+
},
|
|
519
|
+
],
|
|
520
|
+
},
|
|
521
|
+
budget: { triangles: [60000, 14000, 800] },
|
|
522
|
+
checks: [
|
|
523
|
+
clear('track_*', 'hull'),
|
|
524
|
+
clear('wheel_*', 'hull'),
|
|
525
|
+
noOverlap('wheel_l_*'),
|
|
526
|
+
noOverlap('wheel_r_*'),
|
|
527
|
+
touches('turret_body', 'hull'),
|
|
528
|
+
whenBuilt('sprocket_l', touches('sprocket_l', 'hull')),
|
|
529
|
+
whenBuilt('idler_l', touches('idler_l', 'hull')),
|
|
530
|
+
symmetric('_l', '_r', 'y'),
|
|
531
|
+
],
|
|
532
|
+
defaults: { turret: 'hex1943', cupola: true, fuelDrums: true, slogan: '"LIDICE"' },
|
|
533
|
+
build(ctx, p) {
|
|
534
|
+
const lod = ctx.lod;
|
|
535
|
+
const segs = ctx.pick([20, 14, 8]);
|
|
536
|
+
// Factory paint varies a little from tank to tank.
|
|
537
|
+
const paint = ctx.rng.fork('paint').jitter(green, 0.04);
|
|
538
|
+
const wheels: Circle[] = WHEELS_X.map((x) => ({ x, z: WHEEL_Z, r: WHEEL_R }));
|
|
539
|
+
const line = beltLine(wheels, [IDLER, SPROCKET], 0.06);
|
|
540
|
+
|
|
541
|
+
// ---- Running gear ----
|
|
542
|
+
const stubs: Mesh[] = [];
|
|
543
|
+
for (const side of ['l', 'r'] as const) {
|
|
544
|
+
const s = side === 'l' ? 1 : -1;
|
|
545
|
+
const y = s * TRACK_Y;
|
|
546
|
+
const track = `track_${side}`;
|
|
547
|
+
ctx.part(track, muddy(trackMesh(lod, line, y)));
|
|
548
|
+
// Idler crank and final-drive housing: what holds idler and sprocket to the hull side.
|
|
549
|
+
stubs.push(
|
|
550
|
+
cylinder({
|
|
551
|
+
radius: 0.1,
|
|
552
|
+
length: 0.05,
|
|
553
|
+
segments: segs,
|
|
554
|
+
axis: 'y',
|
|
555
|
+
at: [IDLER.x, s * 0.93, IDLER.z],
|
|
556
|
+
color: paint,
|
|
557
|
+
}),
|
|
558
|
+
cylinder({
|
|
559
|
+
radius: 0.16,
|
|
560
|
+
length: 0.07,
|
|
561
|
+
segments: segs,
|
|
562
|
+
axis: 'y',
|
|
563
|
+
at: [SPROCKET.x, s * 0.94, SPROCKET.z],
|
|
564
|
+
color: paint,
|
|
565
|
+
}),
|
|
566
|
+
);
|
|
567
|
+
if (lod === 2) continue;
|
|
568
|
+
const flip = (m: Mesh): Mesh => (s > 0 ? m : place(m, { yaw: Math.PI }));
|
|
569
|
+
const wheel = christie(lod, WHEEL_R, 8, paint);
|
|
570
|
+
WHEELS_X.forEach((x, i) => {
|
|
571
|
+
ctx.part(`wheel_${side}_${i}`, muddy(flip(wheel), [x, y, WHEEL_Z]), {
|
|
572
|
+
at: [x, y, WHEEL_Z],
|
|
573
|
+
motion: { kind: 'spin', axis: [0, 1, 0], rps: 0.75 },
|
|
574
|
+
clearOf: [track],
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
ctx.part(
|
|
578
|
+
`idler_${side}`,
|
|
579
|
+
muddy(flip(christie(lod, IDLER.r, 6, paint)), [IDLER.x, y, IDLER.z]),
|
|
580
|
+
{
|
|
581
|
+
at: [IDLER.x, y, IDLER.z],
|
|
582
|
+
motion: { kind: 'spin', axis: [0, 1, 0], rps: 1.0 },
|
|
583
|
+
clearOf: [track],
|
|
584
|
+
},
|
|
585
|
+
);
|
|
586
|
+
ctx.part(
|
|
587
|
+
`sprocket_${side}`,
|
|
588
|
+
muddy(flip(sprocket(lod, SPROCKET.r, paint)), [SPROCKET.x, y, SPROCKET.z]),
|
|
589
|
+
{
|
|
590
|
+
at: [SPROCKET.x, y, SPROCKET.z],
|
|
591
|
+
motion: { kind: 'spin', axis: [0, 1, 0], rps: 1.0 },
|
|
592
|
+
clearOf: [track],
|
|
593
|
+
},
|
|
594
|
+
);
|
|
595
|
+
ctx.emitter(`track_dust_${side}`, {
|
|
596
|
+
kind: 'dust',
|
|
597
|
+
at: [SPROCKET.x - 0.4, y, 0.15],
|
|
598
|
+
dir: [-1, 0, 0.4],
|
|
599
|
+
rate: 30,
|
|
600
|
+
life: 1.6,
|
|
601
|
+
size: [0.3, 1.6],
|
|
602
|
+
color: hex('#9a8a6a'),
|
|
603
|
+
speed: 1.2,
|
|
604
|
+
spreadDeg: 35,
|
|
605
|
+
when: 'moving',
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// ---- Hull structure: tub between the tracks + sloped upper hull (60° glacis, 40° sides) ----
|
|
610
|
+
const tub: Vec2[] = [
|
|
611
|
+
[-2.72, BELLY],
|
|
612
|
+
[2.42, BELLY],
|
|
613
|
+
NOSE,
|
|
614
|
+
[glacisX(PANNIER_Z), PANNIER_Z],
|
|
615
|
+
[-HULL_HALF, PANNIER_Z],
|
|
616
|
+
[-HULL_HALF, 0.72],
|
|
617
|
+
];
|
|
618
|
+
const lowX = glacisX(PANNIER_Z);
|
|
619
|
+
const topX = glacisX(DECK);
|
|
620
|
+
ctx.part(
|
|
621
|
+
'hull',
|
|
622
|
+
muddy(
|
|
623
|
+
merge([
|
|
624
|
+
prism({ profile: tub, depth: 1.84, plane: 'xz', color: paint, strip: 'iron' }),
|
|
625
|
+
taper(
|
|
626
|
+
[
|
|
627
|
+
[lowX, -1.5, PANNIER_Z],
|
|
628
|
+
[lowX, 1.5, PANNIER_Z],
|
|
629
|
+
[-HULL_HALF, 1.5, PANNIER_Z],
|
|
630
|
+
[-HULL_HALF, -1.5, PANNIER_Z],
|
|
631
|
+
],
|
|
632
|
+
[
|
|
633
|
+
[topX, -1.12, DECK],
|
|
634
|
+
[topX, 1.12, DECK],
|
|
635
|
+
[-2.45, 1.12, DECK],
|
|
636
|
+
[-2.45, -1.12, DECK],
|
|
637
|
+
],
|
|
638
|
+
paint,
|
|
639
|
+
),
|
|
640
|
+
...stubs,
|
|
641
|
+
]),
|
|
642
|
+
),
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
// ---- Hull dressing ----
|
|
646
|
+
const detail: Mesh[] = [];
|
|
647
|
+
for (const s of [1, -1])
|
|
648
|
+
detail.push(
|
|
649
|
+
planar({
|
|
650
|
+
points: [
|
|
651
|
+
[lowX, s * 0.95, PANNIER_Z],
|
|
652
|
+
[lowX, s * 1.5, PANNIER_Z],
|
|
653
|
+
[3.0, s * 1.5, 0.93],
|
|
654
|
+
[3.0, s * 0.95, 0.93],
|
|
655
|
+
],
|
|
656
|
+
color: paint,
|
|
657
|
+
doubleSided: true,
|
|
658
|
+
}),
|
|
659
|
+
);
|
|
660
|
+
if (lod < 2) {
|
|
661
|
+
// Driver's hatch (left) with twin periscopes; hull MG ball (right); headlight.
|
|
662
|
+
detail.push(
|
|
663
|
+
onGlacis(box({ size: [0.5, 0.55, 0.07], color: greenDark }), 0.42, 1.2),
|
|
664
|
+
onGlacis(
|
|
665
|
+
box({ size: [0.08, 0.12, 0.09], at: [-0.12, 0.13, 0.07], color: black }),
|
|
666
|
+
0.42,
|
|
667
|
+
1.2,
|
|
668
|
+
),
|
|
669
|
+
onGlacis(
|
|
670
|
+
box({ size: [0.08, 0.12, 0.09], at: [-0.12, -0.13, 0.07], color: black }),
|
|
671
|
+
0.42,
|
|
672
|
+
1.2,
|
|
673
|
+
),
|
|
674
|
+
onGlacis(
|
|
675
|
+
lathe({
|
|
676
|
+
profile: [
|
|
677
|
+
[0.17, 0],
|
|
678
|
+
[0.16, 0.06],
|
|
679
|
+
[0.1, 0.11],
|
|
680
|
+
[0, 0.12],
|
|
681
|
+
],
|
|
682
|
+
segments: segs,
|
|
683
|
+
color: paint,
|
|
684
|
+
}),
|
|
685
|
+
-0.5,
|
|
686
|
+
1.12,
|
|
687
|
+
),
|
|
688
|
+
beam({
|
|
689
|
+
from: [glacisX(1.12) + 0.08, -0.5, 1.17],
|
|
690
|
+
to: [glacisX(1.12) + 0.45, -0.5, 1.12],
|
|
691
|
+
width: 0.035,
|
|
692
|
+
segments: 6,
|
|
693
|
+
color: black,
|
|
694
|
+
}),
|
|
695
|
+
lathe({
|
|
696
|
+
profile: [
|
|
697
|
+
[0.05, 0],
|
|
698
|
+
[0.09, 0.05],
|
|
699
|
+
[0.09, 0.14],
|
|
700
|
+
[0, 0.15],
|
|
701
|
+
],
|
|
702
|
+
segments: 10,
|
|
703
|
+
axis: 'x',
|
|
704
|
+
at: [lowX - 0.05, 1.1, PANNIER_Z + 0.12],
|
|
705
|
+
color: greenDark,
|
|
706
|
+
}),
|
|
707
|
+
// Engine deck: access hatch, rear-plate transmission hatch.
|
|
708
|
+
box({ size: [1.0, 0.95, 0.05], at: [-1.6, 0, DECK], color: greenDark }),
|
|
709
|
+
place(
|
|
710
|
+
lathe({
|
|
711
|
+
profile: [
|
|
712
|
+
[0.3, 0],
|
|
713
|
+
[0.3, 0.04],
|
|
714
|
+
[0.26, 0.07],
|
|
715
|
+
[0, 0.08],
|
|
716
|
+
],
|
|
717
|
+
segments: segs,
|
|
718
|
+
color: greenDark,
|
|
719
|
+
}),
|
|
720
|
+
{ at: [-2.705, 0, 1.225], pitch: REAR_PITCH },
|
|
721
|
+
),
|
|
722
|
+
);
|
|
723
|
+
for (const s of [1, -1]) {
|
|
724
|
+
detail.push(
|
|
725
|
+
beam({
|
|
726
|
+
from: [-2.78, s * 0.55, 1.14],
|
|
727
|
+
to: [-3.06, s * 0.55, 1.04],
|
|
728
|
+
width: 0.13,
|
|
729
|
+
segments: 8,
|
|
730
|
+
color: rust,
|
|
731
|
+
}),
|
|
732
|
+
box({ size: [0.22, 0.24, 0.05], at: [-2.83, s * 0.55, 1.2], color: paint }),
|
|
733
|
+
);
|
|
734
|
+
if (lod === 0)
|
|
735
|
+
for (let k = 0; k < 7; k++)
|
|
736
|
+
detail.push(
|
|
737
|
+
box({
|
|
738
|
+
size: [0.95, 0.05, 0.03],
|
|
739
|
+
at: [-1.55, s * (0.62 + k * 0.065), DECK],
|
|
740
|
+
color: greenDark,
|
|
741
|
+
}),
|
|
742
|
+
);
|
|
743
|
+
else
|
|
744
|
+
detail.push(
|
|
745
|
+
box({ size: [0.95, 0.42, 0.03], at: [-1.55, s * 0.8, DECK], color: greenDark }),
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (lod === 0) {
|
|
750
|
+
// Tow hooks, spare links on the glacis, rear-plate bolts, side tow cables, rider rails.
|
|
751
|
+
for (const s of [1, -1]) {
|
|
752
|
+
detail.push(
|
|
753
|
+
beam({
|
|
754
|
+
from: [2.85, s * 0.7, 0.72],
|
|
755
|
+
to: [3.05, s * 0.7, 0.7],
|
|
756
|
+
width: 0.06,
|
|
757
|
+
color: steel,
|
|
758
|
+
}),
|
|
759
|
+
beam({
|
|
760
|
+
from: [-2.9, s * 0.7, 0.75],
|
|
761
|
+
to: [-3.08, s * 0.7, 0.75],
|
|
762
|
+
width: 0.06,
|
|
763
|
+
color: steel,
|
|
764
|
+
}),
|
|
765
|
+
cable(
|
|
766
|
+
[
|
|
767
|
+
[1.6, s * 1.42, 1.1],
|
|
768
|
+
[-2.4, s * 1.42, 1.1],
|
|
769
|
+
[-2.55, s * 1.4, 1.18],
|
|
770
|
+
[-2.4, s * 1.36, 1.25],
|
|
771
|
+
[1.5, s * 1.36, 1.25],
|
|
772
|
+
[1.65, s * 1.4, 1.18],
|
|
773
|
+
],
|
|
774
|
+
0.035,
|
|
775
|
+
steel,
|
|
776
|
+
),
|
|
777
|
+
);
|
|
778
|
+
const railY = s * 1.2;
|
|
779
|
+
detail.push(
|
|
780
|
+
beam({
|
|
781
|
+
from: [1.2, railY, 1.38],
|
|
782
|
+
to: [-2.2, railY, 1.38],
|
|
783
|
+
width: 0.025,
|
|
784
|
+
segments: 5,
|
|
785
|
+
color: steel,
|
|
786
|
+
}),
|
|
787
|
+
);
|
|
788
|
+
for (const x of [1.2, 0.0, -1.1, -2.2])
|
|
789
|
+
detail.push(
|
|
790
|
+
beam({ from: [x, railY, 1.33], to: [x, railY, 1.38], width: 0.025, color: steel }),
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
const spare = place(trackLink(0.172, true), { yaw: Math.PI / 2 });
|
|
794
|
+
for (const y of [-0.55, -0.35, 0.0, 0.2])
|
|
795
|
+
detail.push(onGlacis(translate(spare, [0, 0, LINK_T * 0.6]), y, 0.92));
|
|
796
|
+
const bolt = box({ size: [0.035, 0.035, 0.03], color: greenDark });
|
|
797
|
+
for (let k = 0; k < 16; k++) {
|
|
798
|
+
const y = -1.0 + (2.0 * k) / 15;
|
|
799
|
+
for (const t of [0.06, 0.94])
|
|
800
|
+
detail.push(
|
|
801
|
+
place(bolt, {
|
|
802
|
+
at: [-HULL_HALF + 0.51 * t, y, PANNIER_Z + 0.45 * t],
|
|
803
|
+
pitch: REAR_PITCH,
|
|
804
|
+
}),
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (p.fuelDrums && lod < 2) {
|
|
809
|
+
// External fuel drums strapped high on the rear side plates (40° slope: normal y·0.77, z·0.64).
|
|
810
|
+
for (const s of [1, -1])
|
|
811
|
+
for (const x of [-1.25, -2.05]) {
|
|
812
|
+
const c: Vec3 = [x, s * (1.247 + 0.18 * 0.766), 1.3 + 0.18 * 0.643];
|
|
813
|
+
detail.push(
|
|
814
|
+
cylinder({
|
|
815
|
+
radius: 0.18,
|
|
816
|
+
length: 0.72,
|
|
817
|
+
segments: segs,
|
|
818
|
+
axis: 'x',
|
|
819
|
+
at: c,
|
|
820
|
+
color: paint,
|
|
821
|
+
}),
|
|
822
|
+
);
|
|
823
|
+
if (lod === 0)
|
|
824
|
+
for (const dx of [-0.22, 0.22])
|
|
825
|
+
detail.push(
|
|
826
|
+
cylinder({
|
|
827
|
+
radius: 0.19,
|
|
828
|
+
length: 0.04,
|
|
829
|
+
segments: segs,
|
|
830
|
+
axis: 'x',
|
|
831
|
+
at: [x + dx, c[1], c[2]],
|
|
832
|
+
color: greenDark,
|
|
833
|
+
}),
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
ctx.part(
|
|
838
|
+
'fittings',
|
|
839
|
+
grime(merge(detail), {
|
|
840
|
+
ground: 1.0,
|
|
841
|
+
groundStrength: 0.5,
|
|
842
|
+
zones: [
|
|
843
|
+
{ at: [-3.0, 0.55, 1.05], radius: 0.5, strength: 0.7 },
|
|
844
|
+
{ at: [-3.0, -0.55, 1.05], radius: 0.5, strength: 0.7 },
|
|
845
|
+
],
|
|
846
|
+
}),
|
|
847
|
+
);
|
|
848
|
+
for (const [side, s] of [
|
|
849
|
+
['l', 1],
|
|
850
|
+
['r', -1],
|
|
851
|
+
] as const)
|
|
852
|
+
ctx.emitter(`exhaust_smoke_${side}`, {
|
|
853
|
+
kind: 'smoke',
|
|
854
|
+
at: [-3.08, s * 0.55, 1.03],
|
|
855
|
+
dir: [-1, 0, 0.3],
|
|
856
|
+
rate: 14,
|
|
857
|
+
life: 2.5,
|
|
858
|
+
size: [0.2, 1.3],
|
|
859
|
+
color: hex('#38362f'),
|
|
860
|
+
speed: 1.5,
|
|
861
|
+
spreadDeg: 15,
|
|
862
|
+
when: 'always',
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
// ---- Turret ----
|
|
866
|
+
ctx.group('turret', {
|
|
867
|
+
at: TURRET_AT,
|
|
868
|
+
motion: { kind: 'sway', axis: [0, 0, 1], degrees: 20, hz: 0.1 },
|
|
869
|
+
});
|
|
870
|
+
const shell = turretShell(p.turret);
|
|
871
|
+
const roofZ = shell.top[0]?.[2] ?? 0.7;
|
|
872
|
+
const turret: Mesh[] = [taper(shell.bottom, shell.top, paint)];
|
|
873
|
+
if (p.cupola)
|
|
874
|
+
turret.push(
|
|
875
|
+
lathe({
|
|
876
|
+
profile: [
|
|
877
|
+
[0.34, roofZ - 0.02],
|
|
878
|
+
[0.34, roofZ + 0.18],
|
|
879
|
+
[0.3, roofZ + 0.23],
|
|
880
|
+
[0.24, roofZ + 0.28],
|
|
881
|
+
[0, roofZ + 0.28],
|
|
882
|
+
],
|
|
883
|
+
segments: segs,
|
|
884
|
+
at: [-0.4, 0.38, 0],
|
|
885
|
+
color: paint,
|
|
886
|
+
caps: true,
|
|
887
|
+
}),
|
|
888
|
+
);
|
|
889
|
+
if (lod < 2) {
|
|
890
|
+
if (p.turret === 'hex1943')
|
|
891
|
+
turret.push(
|
|
892
|
+
lathe({
|
|
893
|
+
profile: [
|
|
894
|
+
[0.27, roofZ - 0.02],
|
|
895
|
+
[0.27, roofZ + 0.04],
|
|
896
|
+
[0.2, roofZ + 0.08],
|
|
897
|
+
[0, roofZ + 0.09],
|
|
898
|
+
],
|
|
899
|
+
segments: segs,
|
|
900
|
+
at: [-0.35, -0.38, 0],
|
|
901
|
+
color: greenDark,
|
|
902
|
+
}),
|
|
903
|
+
box({ size: [0.12, 0.1, 0.12], at: [0.35, -0.38, roofZ - 0.01], color: greenDark }),
|
|
904
|
+
);
|
|
905
|
+
else
|
|
906
|
+
turret.push(
|
|
907
|
+
// The 1941 turret's single big hatch, hinged at the front, and two periscopes.
|
|
908
|
+
box({ size: [0.95, 0.85, 0.06], at: [-0.35, 0, roofZ - 0.01], color: greenDark }),
|
|
909
|
+
box({ size: [0.14, 0.12, 0.2], at: [0.45, -0.3, roofZ - 0.01], color: greenDark }),
|
|
910
|
+
box({ size: [0.12, 0.1, 0.12], at: [0.45, 0.3, roofZ - 0.01], color: greenDark }),
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
if (lod === 0) {
|
|
914
|
+
if (p.cupola)
|
|
915
|
+
for (let i = 0; i < 5; i++) {
|
|
916
|
+
const a = (i / 5) * Math.PI * 2 + 0.6;
|
|
917
|
+
turret.push(
|
|
918
|
+
box({
|
|
919
|
+
size: [0.09, 0.09, 0.07],
|
|
920
|
+
at: [-0.4 + Math.cos(a) * 0.33, 0.38 + Math.sin(a) * 0.33, roofZ + 0.12],
|
|
921
|
+
color: black,
|
|
922
|
+
}),
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
// Grab handles on the sloped sides, pistol ports, lifting hooks.
|
|
926
|
+
for (const s of [1, -1])
|
|
927
|
+
turret.push(
|
|
928
|
+
cable(
|
|
929
|
+
[
|
|
930
|
+
[0.3, s * 0.97, 0.18],
|
|
931
|
+
[0.3, s * 1.0, 0.24],
|
|
932
|
+
[-0.6, s * 0.85, 0.24],
|
|
933
|
+
[-0.6, s * 0.82, 0.18],
|
|
934
|
+
],
|
|
935
|
+
0.025,
|
|
936
|
+
steel,
|
|
937
|
+
),
|
|
938
|
+
box({ size: [0.12, 0.05, 0.06], at: [0.45, s * 0.6, roofZ - 0.01], color: greenDark }),
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
if (p.slogan && lod < 2) {
|
|
942
|
+
// White slogan on both rear side faces, read from outside, front to back.
|
|
943
|
+
const b = shell.bottom;
|
|
944
|
+
const t = shell.top;
|
|
945
|
+
const text = lettering(p.slogan, 0.14);
|
|
946
|
+
const width = Math.max(...text.flat().map((q) => q[0]));
|
|
947
|
+
for (const [i0, i1] of [
|
|
948
|
+
[2, 3],
|
|
949
|
+
[4, 5],
|
|
950
|
+
] as const) {
|
|
951
|
+
const a = b[i0] as Vec3;
|
|
952
|
+
const c = b[i1] as Vec3;
|
|
953
|
+
const up = t[i0] as Vec3;
|
|
954
|
+
const len = Math.hypot(c[0] - a[0], c[1] - a[1]);
|
|
955
|
+
turret.push(plateDecal(text, a, c, up, [(len - width) / 2, 0.24], white));
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
ctx.part('turret_body', muddy(merge(turret), TURRET_AT), { parent: 'turret' });
|
|
959
|
+
|
|
960
|
+
// ---- Gun: cast mantlet + cradle + F-34 barrel; elevation sways ----
|
|
961
|
+
const gunZ = 0.32;
|
|
962
|
+
const front =
|
|
963
|
+
(shell.bottom[0]?.[0] ?? 1) -
|
|
964
|
+
((shell.bottom[0]?.[0] ?? 1) - (shell.top[0]?.[0] ?? 0.8)) * (gunZ / roofZ);
|
|
965
|
+
// The elevation sweep is checked as a full turn about the trunnion, so it passes through the
|
|
966
|
+
// turret and front deck; the real arc (−5°…+25°) clears both.
|
|
967
|
+
ctx.group('gun', {
|
|
968
|
+
at: [front, 0, gunZ],
|
|
969
|
+
parent: 'turret',
|
|
970
|
+
motion: { kind: 'sway', axis: [0, 1, 0], degrees: 5, hz: 0.25 },
|
|
971
|
+
clearOf: ['turret_body', 'hull', 'fittings'],
|
|
972
|
+
});
|
|
973
|
+
ctx.emitter('muzzle', {
|
|
974
|
+
kind: 'muzzle',
|
|
975
|
+
parent: 'gun',
|
|
976
|
+
at: [2.4, 0, 0],
|
|
977
|
+
dir: [1, 0, 0],
|
|
978
|
+
rate: 60,
|
|
979
|
+
life: 0.2,
|
|
980
|
+
size: [0.3, 1.5],
|
|
981
|
+
speed: 12,
|
|
982
|
+
spreadDeg: 25,
|
|
983
|
+
when: 'event',
|
|
984
|
+
});
|
|
985
|
+
const mantlet: Vec2[] = [
|
|
986
|
+
[0, -0.27],
|
|
987
|
+
[0.16, -0.27],
|
|
988
|
+
[0.25, -0.16],
|
|
989
|
+
[0.28, 0],
|
|
990
|
+
[0.25, 0.16],
|
|
991
|
+
[0.16, 0.27],
|
|
992
|
+
[0, 0.27],
|
|
993
|
+
];
|
|
994
|
+
const mParts = [prism({ profile: mantlet, depth: 0.78, plane: 'xz', color: paint })];
|
|
995
|
+
if (lod === 0)
|
|
996
|
+
mParts.push(
|
|
997
|
+
box({ size: [0.04, 0.07, 0.07], at: [0.26, 0.2, -0.03], color: black }),
|
|
998
|
+
box({ size: [0.04, 0.06, 0.06], at: [0.25, -0.17, 0.1], color: black }),
|
|
999
|
+
);
|
|
1000
|
+
ctx.part('gun_mantlet', merge(mParts), { parent: 'gun' });
|
|
1001
|
+
const tip = 2.37;
|
|
1002
|
+
const breech = tip - 3.162;
|
|
1003
|
+
ctx.part(
|
|
1004
|
+
'gun_barrel',
|
|
1005
|
+
lathe({
|
|
1006
|
+
profile:
|
|
1007
|
+
lod === 0
|
|
1008
|
+
? [
|
|
1009
|
+
[0.1, breech],
|
|
1010
|
+
[0.14, 0.2],
|
|
1011
|
+
[0.2, 0.26],
|
|
1012
|
+
[0.2, 0.29],
|
|
1013
|
+
[0.14, 0.3],
|
|
1014
|
+
[0.14, 0.62],
|
|
1015
|
+
[0.11, 0.66],
|
|
1016
|
+
[0.075, 0.7],
|
|
1017
|
+
[0.068, 1.3],
|
|
1018
|
+
[0.058, 2.28],
|
|
1019
|
+
[0.064, 2.3],
|
|
1020
|
+
[0.064, tip],
|
|
1021
|
+
[0.04, tip],
|
|
1022
|
+
[0.04, 2.3],
|
|
1023
|
+
]
|
|
1024
|
+
: [
|
|
1025
|
+
[0.1, breech],
|
|
1026
|
+
[0.14, 0.2],
|
|
1027
|
+
[0.2, 0.26],
|
|
1028
|
+
[0.2, 0.29],
|
|
1029
|
+
[0.14, 0.3],
|
|
1030
|
+
[0.14, 0.62],
|
|
1031
|
+
[0.075, 0.7],
|
|
1032
|
+
[0.06, tip],
|
|
1033
|
+
],
|
|
1034
|
+
segments: ctx.pick([14, 10, 6]),
|
|
1035
|
+
axis: 'x',
|
|
1036
|
+
color: paint,
|
|
1037
|
+
caps: true,
|
|
1038
|
+
}),
|
|
1039
|
+
{ parent: 'gun' },
|
|
1040
|
+
);
|
|
1041
|
+
},
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
/** T-34/76 Model 1943: hex turret with cupola, side fuel drums, «LIDICE» (1st Czechoslovak bde). */
|
|
1045
|
+
export const t34 = t34Family.variant({
|
|
1046
|
+
name: 't34',
|
|
1047
|
+
description:
|
|
1048
|
+
'T-34/76 Model 1943 — hexagonal turret with cupola, Christie double wheels, waffle track link by link, «LIDICE»',
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
/** T-34/76 Model 1941: cast turret with the single big hatch, no cupola, no drums, unmarked. */
|
|
1052
|
+
export const t34_1941 = t34Family.variant({
|
|
1053
|
+
name: 't34_1941',
|
|
1054
|
+
description: 'T-34/76 Model 1941 — cast turret with the big front hatch, F-34 gun',
|
|
1055
|
+
params: { turret: 'cast1941', cupola: false, fuelDrums: false, slogan: null },
|
|
1056
|
+
real: {
|
|
1057
|
+
length: 6.68,
|
|
1058
|
+
width: 3.0,
|
|
1059
|
+
height: 2.4,
|
|
1060
|
+
measures: [
|
|
1061
|
+
{ label: 'road wheel diameter', axis: 'z', value: 0.83, parts: ['wheel_l_0'] },
|
|
1062
|
+
{ label: 'track width', axis: 'y', value: 0.55, parts: ['track_l'] },
|
|
1063
|
+
{ label: 'track centres', axis: 'y', value: 2.45, between: ['track_l', 'track_r'] },
|
|
1064
|
+
{ label: 'hull length', axis: 'x', value: 5.92, parts: ['hull'] },
|
|
1065
|
+
{ label: 'F-34 barrel length (L/41.5)', axis: 'x', value: 3.162, parts: ['gun_barrel'] },
|
|
1066
|
+
],
|
|
1067
|
+
},
|
|
1068
|
+
});
|