@wildshard/sdk 0.0.0 → 0.2.3
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/GUIDE.md +790 -0
- package/README.md +14 -4
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +371 -4
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +46 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +247 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +18 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +234 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { Noise2D } from '../noise';
|
|
3
|
+
import type { RngState } from '../random';
|
|
4
|
+
import { Rng as NativeRng } from '@wildshard/engine/core/rng';
|
|
5
|
+
import { setLowPoly as setNativeLowPoly, registerToonPaint as registerNativePaint } from '@wildshard/engine/entities/species/loft';
|
|
6
|
+
import { BEAR } from '@wildshard/engine/game/systems/species/bear';
|
|
7
|
+
import { BOAR } from '@wildshard/engine/game/systems/species/boar';
|
|
8
|
+
import { BEAR_LOOK } from '@wildshard/engine/game/systems/species/view/bear';
|
|
9
|
+
import { BOAR_LOOK } from '@wildshard/engine/game/systems/species/view/boar';
|
|
10
|
+
import type { SpeciesRow } from '@wildshard/engine/ai/species';
|
|
11
|
+
import type { SpeciesDef } from '@wildshard/engine/entities/species/registry';
|
|
12
|
+
import { readSpecies, SpeciesSchema, type SpeciesData } from '@wildshard/format/speciesPrograms';
|
|
13
|
+
|
|
14
|
+
/** Complete authored gameplay, fur, variant and rig policy before an owned body builder is attached. */
|
|
15
|
+
export type AuthorSpeciesRows = Omit<SpeciesDef, 'build'>;
|
|
16
|
+
|
|
17
|
+
/** Build-only extraction of gameplay fields from a resolved species. Visual variants stay with their look;
|
|
18
|
+
* a species with native think/act callbacks refuses instead of silently discarding its behaviour. */
|
|
19
|
+
export function bakeSpecies(row: Omit<SpeciesRow, 'id'>, speciesId: string): SpeciesData {
|
|
20
|
+
if (row.think !== undefined || row.act !== undefined) throw new Error('Species programmes require callback-free gameplay rows');
|
|
21
|
+
const fields: Record<string, unknown> = { id: speciesId };
|
|
22
|
+
for (const key of Object.keys(SpeciesSchema.entries)) {
|
|
23
|
+
if (key === 'id' || key === 'variants' || key === 'spawnOnly' || !Object.hasOwn(row, key)) continue;
|
|
24
|
+
const value: unknown = Reflect.get(row, key); fields[key] = value;
|
|
25
|
+
}
|
|
26
|
+
const variant = ({ id, label, weight, rarity, scale, hp, mods }: SpeciesRow['variants'][number]): SpeciesRow['variants'][number] =>
|
|
27
|
+
({ id, label, weight, rarity, scale, ...(hp === undefined ? {} : { hp }), ...(mods === undefined ? {} : { mods }) });
|
|
28
|
+
fields['variants'] = row.variants.map(variant);
|
|
29
|
+
if (row.spawnOnly !== undefined) fields['spawnOnly'] = row.spawnOnly.map(variant);
|
|
30
|
+
return readSpecies(fields);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Admit fresh shared boar/bear gameplay metadata; no live species or parent identity escapes. */
|
|
34
|
+
export function commonSpeciesRows(kind: 'boar' | 'bear', speciesId: string): SpeciesData {
|
|
35
|
+
return bakeSpecies(kind === 'boar' ? BOAR : BEAR, speciesId);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Derive callback-free author data, preserving inherited fields and the original tuning merge. */
|
|
39
|
+
export function deriveSpeciesRows(parent: SpeciesData, patch: Partial<SpeciesData> & { id: string }): SpeciesData {
|
|
40
|
+
const row = { ...parent, ...patch };
|
|
41
|
+
if (parent.tuning !== undefined && patch.tuning !== undefined) row.tuning = { ...parent.tuning, ...patch.tuning };
|
|
42
|
+
return readSpecies(row);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A geometry recipe's palette and shape knobs, without simulation or runtime owners. */
|
|
46
|
+
export interface VariantDef {
|
|
47
|
+
id: string; label: string; weight: number;
|
|
48
|
+
rarity: 'common' | 'uncommon' | 'rare' | 'legendary';
|
|
49
|
+
scale: [number, number];
|
|
50
|
+
tint?: Record<string, [number, number, number]>;
|
|
51
|
+
traits?: Record<string, number | boolean | string>;
|
|
52
|
+
}
|
|
53
|
+
/** One authored joint in model space. */
|
|
54
|
+
export interface BoneDef { name: string; parent: string | null; pos: [number, number, number] }
|
|
55
|
+
/** Data-only dimensions accompanying the baked skin. */
|
|
56
|
+
export interface AnimalDims {
|
|
57
|
+
/** height of the body bone (spine centre) above ground in the bind pose */
|
|
58
|
+
bodyY: number;
|
|
59
|
+
/** half-length of the body capsule along Z (for hit tests) */
|
|
60
|
+
bodyHalfLen: number;
|
|
61
|
+
/** radius of the body capsule */
|
|
62
|
+
bodyRadius: number;
|
|
63
|
+
/** head hit-sphere radius */
|
|
64
|
+
headRadius: number;
|
|
65
|
+
/** rest length of the front leg (shoulder → hoof) — drives stride frequency */
|
|
66
|
+
legLen: number;
|
|
67
|
+
/** foot rest positions (x, z) per leg FL, FR, BL, BR */
|
|
68
|
+
feet: [number, number][];
|
|
69
|
+
/** width of the body (for the corpse's resting height when rolled on its side) */
|
|
70
|
+
halfWidth: number;
|
|
71
|
+
/** body hit-capsule axis: 'z' (default, along the spine of a quadruped) or 'y' (upright: the Drowned Sailor) */
|
|
72
|
+
capsuleAxis?: 'z' | 'y';
|
|
73
|
+
/** the head ball's centre, head-bone local (model units); default the joint itself. A hull whose skull sits off its head
|
|
74
|
+
* joint (the Antler King, E350 F-X2) moves the ball onto it */
|
|
75
|
+
headAt?: readonly [number, number, number];
|
|
76
|
+
/** the body capsule's centre, body-bone local (model units; default the joint), and its axis tilted `bodyPitch` rad from
|
|
77
|
+
* the bone's z toward its y (+ = the front up) — a 'z' capsule only */
|
|
78
|
+
bodyAt?: readonly [number, number, number];
|
|
79
|
+
bodyPitch?: number;
|
|
80
|
+
/** a second body capsule across `bone`'s x axis (the Antler King's shoulders and chest, E350 F-X2): centre (bone local,
|
|
81
|
+
* model units), half-length along x and radius. Its hits are body hits */
|
|
82
|
+
fore?: { readonly bone: string; readonly at: readonly [number, number, number]; readonly halfLen: number; readonly radius: number };
|
|
83
|
+
}
|
|
84
|
+
/** Owned, unmerged body parts produced offline. */
|
|
85
|
+
export interface AnimalSpecies {
|
|
86
|
+
bones: BoneDef[];
|
|
87
|
+
/** geometries drawn with the fur material + fur shells (loft() output: has color / skin / furLen attributes) */
|
|
88
|
+
furParts: THREE.BufferGeometry[];
|
|
89
|
+
/** hard parts: hooves, antlers, tusks, snout (no fur shells, vertex colours only) */
|
|
90
|
+
hardParts: THREE.BufferGeometry[];
|
|
91
|
+
/** eye spheres (glossy clearcoat material) */
|
|
92
|
+
eyeParts: THREE.BufferGeometry[];
|
|
93
|
+
dims: AnimalDims;
|
|
94
|
+
/** low-poly style: a base-colour texture on the rig's material (a generated model's own paint, e.g. the Drowned
|
|
95
|
+
* Captain); the vertex colours multiply it, so textured parts carry white */
|
|
96
|
+
map?: THREE.Texture;
|
|
97
|
+
/** low-poly style: the per-facet lightness jitter (lowpoly.ts facetGeometry, default 0.12) — 0 for a textured model */
|
|
98
|
+
facetJitter?: number;
|
|
99
|
+
/** low-poly style, with `map`: the texture fed back as emissive at this intensity, so a painted model keeps its colours
|
|
100
|
+
* in shade (the flat toon fill alone left the captain's navy coat near-black) */
|
|
101
|
+
selfLight?: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Offline loft math preserves the runtime station order and floating-point arithmetic. */
|
|
105
|
+
export interface Station {
|
|
106
|
+
x: number; y: number; z: number;
|
|
107
|
+
rx: number; ry: number;
|
|
108
|
+
top: number; bot: number; // asymmetric vertical scale (withers hump / deep belly)
|
|
109
|
+
b0: number; b1: number; w1: number; // skin: bone b0 with weight 1-w1, bone b1 with w1
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** vertex colour callback: (out, x, y, z, nx, ny, nz, part, t = 0..1 along the part, a = ring angle) */
|
|
113
|
+
export type Paint = (out: THREE.Color, x: number, y: number, z: number, nx: number, ny: number, nz: number, part: string, t: number, a: number) => void;
|
|
114
|
+
|
|
115
|
+
export const TEX_M = 0.32; // metres per detail-texture repeat
|
|
116
|
+
|
|
117
|
+
/** sRGB colour triple, 0..1 (palette entries and VariantDef.tint values) */
|
|
118
|
+
export type RGB = [number, number, number];
|
|
119
|
+
|
|
120
|
+
const _t = new THREE.Vector3(), _side = new THREE.Vector3(), _up = new THREE.Vector3(), _n = new THREE.Vector3(), _c = new THREE.Color();
|
|
121
|
+
|
|
122
|
+
/** shared low-frequency noise for coat mottling / patches (fbm ≈ -1..1) */
|
|
123
|
+
export const paintNoise: Noise2D = new Noise2D(4242);
|
|
124
|
+
|
|
125
|
+
export const srgb = (r: number, g: number, b: number): THREE.Color => new THREE.Color().setRGB(r, g, b, THREE.SRGBColorSpace);
|
|
126
|
+
export const mix = (out: THREE.Color, a: THREE.Color, b: THREE.Color, t: number): THREE.Color => { out.copy(a).lerp(b, THREE.MathUtils.clamp(t, 0, 1)); return out; };
|
|
127
|
+
// the one smoothstep (E357 X5)
|
|
128
|
+
|
|
129
|
+
/** the species palette as THREE.Colors, each entry overridden by the variant's tint of the same name (VariantDef.tint) */
|
|
130
|
+
export function paletteColors<K extends string>(base: Record<K, RGB>, tint: Record<string, RGB> | undefined): Record<K, THREE.Color> {
|
|
131
|
+
const out: Partial<Record<K, THREE.Color>> = {};
|
|
132
|
+
for (const k of Object.keys(base) as K[]) { const c = tint?.[k] ?? base[k]; out[k] = srgb(c[0], c[1], c[2]); }
|
|
133
|
+
return out as Record<K, THREE.Color>; // every key of `base` was just filled in
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** station helper */
|
|
137
|
+
export const S: (x: number, y: number, z: number, rx: number, ry: number, b0: number, b1?: number, w1?: number, top?: number, bot?: number) => Station = (x: number, y: number, z: number, rx: number, ry: number, b0: number, b1: number = b0, w1 = 0, top = 1, bot = 1): Station => ({ x, y, z, rx, ry, top, bot, b0, b1, w1 });
|
|
138
|
+
|
|
139
|
+
/** name → index lookup for a BoneDef list (throws on a typo) */
|
|
140
|
+
export function boneIndex(bones: { name: string }[]): (name: string) => number {
|
|
141
|
+
const m = new Map<string, number>();
|
|
142
|
+
bones.forEach((b, i) => { m.set(b.name, i); });
|
|
143
|
+
return (name: string) => { const i = m.get(name); if (i === undefined) throw new Error(`no bone ${name}`); return i; };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Relative fur length per vertex (1 = the species' base shell length). Long on the body, neck mane and
|
|
148
|
+
* boar crest; short on the face, ears and lower legs; none on hard parts.
|
|
149
|
+
*/
|
|
150
|
+
function furLength(part: string, y: number, ny: number, t: number): number {
|
|
151
|
+
switch (part) {
|
|
152
|
+
case 'body': return ny < -0.5 ? 0.7 : 1.0;
|
|
153
|
+
case 'neck': return 1.15;
|
|
154
|
+
case 'head': return t < 0.5 ? 0.45 : 0.2;
|
|
155
|
+
case 'ear': return 0.25;
|
|
156
|
+
case 'leg': return y > 0.5 ? 0.55 : y > 0.25 ? 0.3 : 0.15;
|
|
157
|
+
case 'tail': return 0.9;
|
|
158
|
+
case 'crest': return 1.9;
|
|
159
|
+
default: return 0;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
/** metres of noise displacement along the ring normal (set per species before lofting; reset to 0 after build) */
|
|
165
|
+
let shagAmp = 0;
|
|
166
|
+
export function setShag(amp: number): void { shagAmp = amp; }
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* An optional surface-shape function for the lofts that follow: (x, y, z, part) → metres to push the vertex out along
|
|
170
|
+
* its normal (the sheep's wool lumps, a wolf's fur clumps). The Paint callback sees the displaced position, so it can
|
|
171
|
+
* shade the troughs. Set per species in build(), reset to null after (Pine Hollow / Driftwood never set it).
|
|
172
|
+
*/
|
|
173
|
+
let shapeFn: ((x: number, y: number, z: number, part: string) => number) | null = null;
|
|
174
|
+
export function setShapeFn(fn: ((x: number, y: number, z: number, part: string) => number) | null): void { shapeFn = fn; }
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Low-poly mode (Driftwood Isle, `ShardManifest.style === 'toon'`; set by AnimalFactory around `build()`):
|
|
178
|
+
* every loft gets `lowPolySides()` sides instead of what it asks for and no shag noise; the factory then
|
|
179
|
+
* de-indexes the merged model for flat facets (see `src/client/engine/entities/lowpoly.ts`). Species files may branch on
|
|
180
|
+
* `isLowPoly()` for a different palette or part (the boar's crest becomes a row of spikes).
|
|
181
|
+
*/
|
|
182
|
+
let lowPoly = false;
|
|
183
|
+
const authorPaints = new Map<string, (variant?: VariantDef) => Paint>();
|
|
184
|
+
/** Current explicit offline geometry style; independent of any runtime species owner. */
|
|
185
|
+
export function isLowPoly(): boolean { return lowPoly; }
|
|
186
|
+
/** Palette supplied to the author geometry context; no runtime registry is lent out. */
|
|
187
|
+
export function toonPaint(kind: string): ((variant?: VariantDef) => Paint) | null { return authorPaints.get(kind) ?? null; }
|
|
188
|
+
|
|
189
|
+
/** Pure geometry kernels a recipe consumes; native before-controls may supply an independent compiler. */
|
|
190
|
+
export interface SpeciesGeometryCompiler {
|
|
191
|
+
readonly loft: typeof loft;
|
|
192
|
+
readonly tube: typeof tube;
|
|
193
|
+
readonly skinPlain: typeof skinPlain;
|
|
194
|
+
readonly S: typeof S;
|
|
195
|
+
readonly boneIndex: typeof boneIndex;
|
|
196
|
+
readonly srgb: typeof srgb;
|
|
197
|
+
readonly mix: typeof mix;
|
|
198
|
+
readonly paintNoise: Pick<Noise2D, 'fbm'>;
|
|
199
|
+
readonly setShag: typeof setShag;
|
|
200
|
+
readonly isLowPoly: typeof isLowPoly;
|
|
201
|
+
readonly toonPaint: typeof toonPaint;
|
|
202
|
+
readonly paletteColors: typeof paletteColors;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** ring sides for a loft that asks for `seg` in PBR: big parts 6, legs 5, ears / hooves / tusks 4 */
|
|
206
|
+
export function lowPolySides(seg: number): number { return seg >= 16 ? 6 : seg >= 11 ? 5 : 4; }
|
|
207
|
+
|
|
208
|
+
/** Loft a closed tube through `st` stations with `seg` sides; returns an indexed geometry with position/normal/uv/color/skinIndex/skinWeight. */
|
|
209
|
+
export function loft(st: Station[], sides: number, part: string, paint: Paint, capStart = true, capEnd = true, frame: 'x' | 'z' = 'x'): THREE.BufferGeometry {
|
|
210
|
+
const seg = lowPoly ? lowPolySides(sides) : sides;
|
|
211
|
+
const n = st.length;
|
|
212
|
+
const at = (i: number): Station => { const s = st[i]; if (s === undefined) throw new Error(`loft: no station ${i}`); return s; };
|
|
213
|
+
const pos: number[] = [], nor: number[] = [], uv: number[] = [], col: number[] = [], si: number[] = [], sw: number[] = [], fl: number[] = [];
|
|
214
|
+
const idx: number[] = [];
|
|
215
|
+
// arc length along the spine for v
|
|
216
|
+
const along: number[] = [0];
|
|
217
|
+
for (let i = 1; i < n; i++) { const a = at(i), b = at(i - 1); along.push((along[i - 1] ?? 0) + Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z)); }
|
|
218
|
+
const total = (along[n - 1] ?? 0) || 1;
|
|
219
|
+
let circ = 0;
|
|
220
|
+
for (const s of st) circ += Math.PI * (s.rx + s.ry);
|
|
221
|
+
const uRep = Math.max(1, Math.round(circ / n / TEX_M));
|
|
222
|
+
const ringVerts = seg + 1;
|
|
223
|
+
for (let i = 0; i < n; i++) {
|
|
224
|
+
const s = at(i), al = along[i] ?? 0;
|
|
225
|
+
const p0 = at(Math.max(0, i - 1)), p1 = at(Math.min(n - 1, i + 1));
|
|
226
|
+
_t.set(p1.x - p0.x, p1.y - p0.y, p1.z - p0.z).normalize();
|
|
227
|
+
// ring frame: 'x' keeps the ring's side axis on +X (no twist along bilateral parts; order stations
|
|
228
|
+
// so the tangent runs +Z or down), 'z' keeps the ring's thin axis facing +Z (ears)
|
|
229
|
+
if (frame === 'x') _side.set(1, 0, 0).addScaledVector(_t, -_t.x).normalize();
|
|
230
|
+
else _side.set(0, 0, 1).cross(_t).normalize();
|
|
231
|
+
_up.crossVectors(_t, _side).normalize();
|
|
232
|
+
// radius change per metre → tilts normals along the taper
|
|
233
|
+
const dr = ((p1.rx + p1.ry) - (p0.rx + p0.ry)) * 0.5 / Math.max(1e-3, (along[Math.min(n - 1, i + 1)] ?? 0) - (along[Math.max(0, i - 1)] ?? 0));
|
|
234
|
+
const t = al / total;
|
|
235
|
+
for (let j = 0; j <= seg; j++) {
|
|
236
|
+
const a = (j / seg) * Math.PI * 2;
|
|
237
|
+
const ca = Math.cos(a), sa = Math.sin(a);
|
|
238
|
+
const vs = sa > 0 ? s.top : s.bot;
|
|
239
|
+
const rx = Math.max(1e-4, s.rx), ry = Math.max(1e-4, s.ry * vs);
|
|
240
|
+
let px = s.x + _side.x * rx * ca + _up.x * ry * sa;
|
|
241
|
+
let py = s.y + _side.y * rx * ca + _up.y * ry * sa;
|
|
242
|
+
let pz = s.z + _side.z * rx * ca + _up.z * ry * sa;
|
|
243
|
+
// ellipse normal: (cos/rx, sin/ry) in the ring frame, then tilt by the taper
|
|
244
|
+
_n.set(_side.x * ca / rx + _up.x * sa / ry, _side.y * ca / rx + _up.y * sa / ry, _side.z * ca / rx + _up.z * sa / ry).normalize();
|
|
245
|
+
_n.addScaledVector(_t, -dr).normalize();
|
|
246
|
+
// shaggy coat: push the surface in/out with noise so the silhouette isn't a smooth tube (big parts only)
|
|
247
|
+
if (shagAmp > 0 && !lowPoly && (part === 'body' || part === 'neck' || part === 'head' || part === 'crest')) {
|
|
248
|
+
const amp = shagAmp * Math.min(1, (rx + ry) / 0.25) * (part === 'crest' ? 2.5 : 1);
|
|
249
|
+
const d = paintNoise.fbm(px * 9 + py * 3, pz * 9 - py * 4, 3) * amp;
|
|
250
|
+
px += _n.x * d; py += _n.y * d; pz += _n.z * d;
|
|
251
|
+
}
|
|
252
|
+
if (shapeFn !== null && !lowPoly) {
|
|
253
|
+
const d = shapeFn(px, py, pz, part);
|
|
254
|
+
px += _n.x * d; py += _n.y * d; pz += _n.z * d;
|
|
255
|
+
}
|
|
256
|
+
pos.push(px, py, pz); nor.push(_n.x, _n.y, _n.z);
|
|
257
|
+
uv.push((j / seg) * uRep, al / TEX_M);
|
|
258
|
+
paint(_c, px, py, pz, _n.x, _n.y, _n.z, part, t, a);
|
|
259
|
+
col.push(_c.r, _c.g, _c.b);
|
|
260
|
+
si.push(s.b0, s.b1, 0, 0); sw.push(1 - s.w1, s.w1, 0, 0);
|
|
261
|
+
fl.push(furLength(part, py, _n.y, t));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
for (let i = 0; i < n - 1; i++) for (let j = 0; j < seg; j++) {
|
|
265
|
+
const a = i * ringVerts + j, b = a + 1, c = a + ringVerts, d = c + 1;
|
|
266
|
+
idx.push(a, b, c, b, d, c);
|
|
267
|
+
}
|
|
268
|
+
const cap = (i: number, flip: boolean) => {
|
|
269
|
+
const s = at(i), al = along[i] ?? 0;
|
|
270
|
+
const p0 = at(Math.max(0, i - 1)), p1 = at(Math.min(n - 1, i + 1));
|
|
271
|
+
_t.set(p1.x - p0.x, p1.y - p0.y, p1.z - p0.z).normalize();
|
|
272
|
+
if (flip) _t.negate();
|
|
273
|
+
const ci = pos.length / 3;
|
|
274
|
+
pos.push(s.x, s.y, s.z); nor.push(_t.x, _t.y, _t.z); uv.push(0.5 * uRep, al / TEX_M);
|
|
275
|
+
paint(_c, s.x, s.y, s.z, _t.x, _t.y, _t.z, part, al / total, 0);
|
|
276
|
+
col.push(_c.r, _c.g, _c.b); si.push(s.b0, s.b1, 0, 0); sw.push(1 - s.w1, s.w1, 0, 0); fl.push(furLength(part, s.y, _t.y, al / total));
|
|
277
|
+
for (let j = 0; j < seg; j++) {
|
|
278
|
+
const a = i * ringVerts + j, b = a + 1;
|
|
279
|
+
if (flip) idx.push(ci, b, a); else idx.push(ci, a, b);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
if (capStart) cap(0, true);
|
|
283
|
+
if (capEnd) cap(n - 1, false);
|
|
284
|
+
const g = new THREE.BufferGeometry();
|
|
285
|
+
g.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));
|
|
286
|
+
g.setAttribute('normal', new THREE.Float32BufferAttribute(nor, 3));
|
|
287
|
+
g.setAttribute('uv', new THREE.Float32BufferAttribute(uv, 2));
|
|
288
|
+
g.setAttribute('color', new THREE.Float32BufferAttribute(col, 3));
|
|
289
|
+
g.setAttribute('skinIndex', new THREE.Uint16BufferAttribute(si, 4));
|
|
290
|
+
g.setAttribute('skinWeight', new THREE.Float32BufferAttribute(sw, 4));
|
|
291
|
+
g.setAttribute('furLen', new THREE.Float32BufferAttribute(fl, 1));
|
|
292
|
+
g.setIndex(idx);
|
|
293
|
+
// smooth face-averaged normals (more robust than the analytic ring normal on coarse lofts); the
|
|
294
|
+
// duplicated uv-seam vertices get the average of both sides so the seam is invisible
|
|
295
|
+
g.computeVertexNormals();
|
|
296
|
+
const na = g.getAttribute('normal') as THREE.BufferAttribute;
|
|
297
|
+
for (let i = 0; i < n; i++) {
|
|
298
|
+
const a = i * ringVerts, b = a + seg;
|
|
299
|
+
_n.set(na.getX(a) + na.getX(b), na.getY(a) + na.getY(b), na.getZ(a) + na.getZ(b)).normalize();
|
|
300
|
+
na.setXYZ(a, _n.x, _n.y, _n.z); na.setXYZ(b, _n.x, _n.y, _n.z);
|
|
301
|
+
}
|
|
302
|
+
return g;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Give a plain geometry (sphere) colour + skin attributes for one bone. */
|
|
306
|
+
export function skinPlain(g: THREE.BufferGeometry, bone: number, part: string, paint: Paint): THREE.BufferGeometry {
|
|
307
|
+
const p = g.getAttribute('position') as THREE.BufferAttribute, nrm = g.getAttribute('normal') as THREE.BufferAttribute;
|
|
308
|
+
const cnt = p.count;
|
|
309
|
+
const col = new Float32Array(cnt * 3), si = new Uint16Array(cnt * 4), sw = new Float32Array(cnt * 4);
|
|
310
|
+
for (let i = 0; i < cnt; i++) {
|
|
311
|
+
paint(_c, p.getX(i), p.getY(i), p.getZ(i), nrm.getX(i), nrm.getY(i), nrm.getZ(i), part, 0.5, 0);
|
|
312
|
+
col[i * 3] = _c.r; col[i * 3 + 1] = _c.g; col[i * 3 + 2] = _c.b;
|
|
313
|
+
si[i * 4] = bone; sw[i * 4] = 1;
|
|
314
|
+
}
|
|
315
|
+
g.setAttribute('color', new THREE.BufferAttribute(col, 3));
|
|
316
|
+
g.setAttribute('skinIndex', new THREE.BufferAttribute(si, 4));
|
|
317
|
+
g.setAttribute('skinWeight', new THREE.BufferAttribute(sw, 4));
|
|
318
|
+
g.setAttribute('furLen', new THREE.BufferAttribute(new Float32Array(cnt), 1)); // eyes: no fur
|
|
319
|
+
return g;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Sweep a tapered tube along a polyline (antler beams, tusks). */
|
|
323
|
+
export function tube(points: [number, number, number][], r0: number, r1: number, bone: number, part: string, paint: Paint, seg = 7): THREE.BufferGeometry {
|
|
324
|
+
// subdivide for smoothness (catmull-rom)
|
|
325
|
+
const curve = new THREE.CatmullRomCurve3(points.map((p) => new THREE.Vector3(...p)), false, 'catmullrom', 0.3);
|
|
326
|
+
const N = lowPoly ? Math.max(3, points.length + 1) : Math.max(4, points.length * 4); // faceted tusks / antlers: one bend per point
|
|
327
|
+
const st: Station[] = [];
|
|
328
|
+
for (let i = 0; i <= N; i++) {
|
|
329
|
+
const t = i / N;
|
|
330
|
+
const p = curve.getPoint(t);
|
|
331
|
+
const r = THREE.MathUtils.lerp(r0, r1, t ** 0.8);
|
|
332
|
+
st.push({ x: p.x, y: p.y, z: p.z, rx: r, ry: r, top: 1, bot: 1, b0: bone, b1: bone, w1: 0 });
|
|
333
|
+
}
|
|
334
|
+
// rounded tip
|
|
335
|
+
const last = st[st.length - 1], prev = st[st.length - 2];
|
|
336
|
+
if (last === undefined || prev === undefined) throw new Error('tube: fewer than two stations'); // N >= 3 above
|
|
337
|
+
st.push({ ...last, x: last.x + (last.x - prev.x) * 0.6, y: last.y + (last.y - prev.y) * 0.6, z: last.z + (last.z - prev.z) * 0.6, rx: r1 * 0.35, ry: r1 * 0.35 });
|
|
338
|
+
return loft(st, seg, part, paint);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Build a bounded author recipe in the same low-poly paint context as shared bodies.
|
|
342
|
+
* The callback returns owned geometry; no runtime species/installer is lent out. */
|
|
343
|
+
export function withSpeciesGeometry<T>(paints: Readonly<Record<string, (variant?: VariantDef) => Paint>>, run: () => T): T {
|
|
344
|
+
lowPoly = true;
|
|
345
|
+
setNativeLowPoly(true);
|
|
346
|
+
for (const [kind, paint] of Object.entries(paints)) { authorPaints.set(kind, paint); registerNativePaint(kind, paint); }
|
|
347
|
+
try { return run(); }
|
|
348
|
+
finally { lowPoly = false; setNativeLowPoly(false); }
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Common authored body kinds, not runtime species handles. */
|
|
352
|
+
export type CommonBodyKind = 'boar' | 'bear';
|
|
353
|
+
/** Enumerate each common body's authored variant knobs in their original row order. */
|
|
354
|
+
export function commonBodyVariants(kind: CommonBodyKind): VariantDef[] {
|
|
355
|
+
const row = kind === 'boar' ? BOAR : BEAR, look = kind === 'boar' ? BOAR_LOOK : BEAR_LOOK;
|
|
356
|
+
return row.variants.map(({ id }): VariantDef => {
|
|
357
|
+
const variant: VariantDef = { id, label: id, weight: 1, rarity: 'common', scale: [1, 1] };
|
|
358
|
+
return Object.assign(variant, look.variants?.[id]);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/** Run a common body's native geometry recipe with an explicit RNG continuation.
|
|
362
|
+
* The author owns both the returned parts and the next continuation. */
|
|
363
|
+
export function bakeCommonBody(kind: CommonBodyKind, variant: VariantDef, state: RngState): { body: AnimalSpecies; random: RngState } {
|
|
364
|
+
const rng = new NativeRng(0);
|
|
365
|
+
rng.restore(state);
|
|
366
|
+
const body = (kind === 'boar' ? BOAR_LOOK : BEAR_LOOK).build(variant, rng);
|
|
367
|
+
return { body, random: rng.snapshot() };
|
|
368
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { parse, object, array, string, unknown } from 'valibot';
|
|
2
|
+
import { PickupCatalogueSchema, SpecimenBookSchema, type PickupCatalogueRows, type SpecimenBookRows, type SpecimenModelMetadataRows } from '@wildshard/format/specimenCatalogue';
|
|
3
|
+
import pickupRows from '@wildshard/engine/game/data/pickupCatalogue' with { type: 'json' };
|
|
4
|
+
import { namedJsonSchema } from '@wildshard/engine/host/formatJsonSchema';
|
|
5
|
+
import { encodeCanonicalJson } from '../immutable';
|
|
6
|
+
import { nameBlob, type NamedBlob, type BlobOptions } from '../blobs';
|
|
7
|
+
|
|
8
|
+
/** Admit fresh shared pickup metadata for an offline recipe, without installing runtime models or loading geometry. */
|
|
9
|
+
export function sharedPickupCatalogue(): PickupCatalogueRows {
|
|
10
|
+
return parse(PickupCatalogueSchema, pickupRows);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** A build-time catalogue: admitted rows and metadata, without runtime registration or model construction. */
|
|
14
|
+
export interface AuthoredSpecimenCatalogue {
|
|
15
|
+
readonly book: SpecimenBookRows;
|
|
16
|
+
readonly model: (key: string) => SpecimenModelMetadataRows;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Admit a complete specimen book once; model lookups retain its ordered authored metadata. */
|
|
20
|
+
export function defineSpecimenCatalogue(input: unknown): AuthoredSpecimenCatalogue {
|
|
21
|
+
const book = parse(SpecimenBookSchema, input), models = new Map<string, SpecimenModelMetadataRows>();
|
|
22
|
+
for (const row of book.rows) {
|
|
23
|
+
if (models.has(row.key)) throw new Error(`Duplicate authored specimen ${row.key}`);
|
|
24
|
+
models.set(row.key, row.model);
|
|
25
|
+
}
|
|
26
|
+
return { book, model(key) {
|
|
27
|
+
const model = models.get(key);
|
|
28
|
+
if (model === undefined) throw new Error(`Missing authored specimen ${key}`);
|
|
29
|
+
return model;
|
|
30
|
+
} };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Emit admitted book data with its defining schema and caller-owned tier/dependencies. */
|
|
34
|
+
export function nameSpecimenBook(name: string, input: unknown, options: Pick<BlobOptions, 'tier' | 'dependencies'> = {}): NamedBlob {
|
|
35
|
+
const book = defineSpecimenCatalogue(input).book;
|
|
36
|
+
return nameBlob(name, 'json', new TextEncoder().encode(encodeCanonicalJson(book)), {
|
|
37
|
+
...options, jsonSchema: namedJsonSchema(SpecimenBookSchema, {provenance:true}),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Admit the named shape envelope from an offline painter. Geometry remains
|
|
42
|
+
* opaque here and must pass the consumer's complete geometry grammar; no model
|
|
43
|
+
* is constructed and unrelated source metadata is stripped as before. */
|
|
44
|
+
export function specimenShapeSources(input: unknown): { key: string; name: string; geometry: unknown }[] {
|
|
45
|
+
const shapeSources = object({ rows: array(object({ key: string(), name: string(), geometry: unknown() })) });
|
|
46
|
+
return parse(shapeSources, input).rows;
|
|
47
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { floatPositionError } from './geometryError';
|
|
2
|
+
/**
|
|
3
|
+
* Tile streaming (G652) on G227 splat terrain: a shard's native ground (its committed WSTR256 bake, as the live chunk draws
|
|
4
|
+
* it with `terrainChunkGeometry`) cut into 64 L0 + 16 L1 render tiles for a `props.splat` row. Each tile is one GLB primitive
|
|
5
|
+
* in the row's material, carrying positions, normals and the `_SPLAT` weights, plus a `_CANOPY` density channel; the drawn
|
|
6
|
+
* openings (a page's terrain cuts) leave the indices as the runtime punch removes them. Physics stays on the native ground.
|
|
7
|
+
*
|
|
8
|
+
* const source = splatGroundSource(terrainBin, nativeSplatGround('pine-hollow', terrainBin).canopy, hole); // hole: the page's openings
|
|
9
|
+
* const tiles = await bakeSplatGround(source, { material: 'pine.ground', lod1: { targetRatio: 0.25, maxErrorMetres: 1 } });
|
|
10
|
+
* const files = splatLayerFiles(['forrest_ground_03', ...], PINE_GPU_FILES); // each tier's layer KTX2s, as the runtime picks them
|
|
11
|
+
*
|
|
12
|
+
* Build time only: geometry and bytes, no textures, renderer, physics or scene.
|
|
13
|
+
*/
|
|
14
|
+
import { BufferAttribute, BufferGeometry, Float32BufferAttribute, MeshStandardMaterial } from 'three';
|
|
15
|
+
import { parseBakedTerrain, bakedSamplers } from '@wildshard/engine/world/BakedTerrain';
|
|
16
|
+
import { canopyChannel, terrainChunkGeometry } from '@wildshard/engine/world/Terrain';
|
|
17
|
+
import { _installBakedTerrain } from '@wildshard/engine/world/Heightfield';
|
|
18
|
+
import { filePolicy } from '@wildshard/engine/boot/filePolicy';
|
|
19
|
+
import type { Ktx2Table } from '@wildshard/engine/boot/gpuFiles';
|
|
20
|
+
import { sliceNativeLattice, type NativeLatticeAttribute, type NativeLatticeSource, type NativeLatticeTile } from './nativeLattice';
|
|
21
|
+
import { staticGlb } from './glb';
|
|
22
|
+
import { simplifyNativeLatticeTile } from './worldLod';
|
|
23
|
+
import { parseGlb, type AssetCost } from '../assets';
|
|
24
|
+
|
|
25
|
+
const CHANNELS = { normal: 3, splat: 4, canopy: 1 } as const;
|
|
26
|
+
const CUSTOM = { _SPLAT: 'splat', _CANOPY: 'canopy' } as const;
|
|
27
|
+
export interface SplatGroundTile { tile: NativeLatticeTile; bytes: Uint8Array; cost: AssetCost; geometricError: number }
|
|
28
|
+
/** A drawn opening's triangle test (world corners a, b, c), as `punchPageTerrain` applies it. */
|
|
29
|
+
export type SplatGroundHole = (ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number) => boolean;
|
|
30
|
+
/** The tiles' material name (the `props.splat` row binds it) and the L1 simplification (`simplifyNativeLatticeTile`). */
|
|
31
|
+
/** Splat weights (layer i = channel i). */
|
|
32
|
+
export type SplatWeights = readonly [number, number, number, number];
|
|
33
|
+
/**
|
|
34
|
+
* The tiles' material name (the `props.splat` row binds it), the L1 simplification (`simplifyNativeLatticeTile`) and, for a
|
|
35
|
+
* coarse tier the rings can draw without the splat layers (a coarse tile may not depend on the library the layers live
|
|
36
|
+
* in), `coarse`: L1 tiles then carry vertex colours (`colourAt` over each vertex's height, slope, splat weights and canopy)
|
|
37
|
+
* in their own material name, which the props family draws, beside the same `_SPLAT` / `_CANOPY` channels, so a client that
|
|
38
|
+
* draws the splat ground can draw them with it in one mesh (no layer dependency: their material is not the splat one).
|
|
39
|
+
*/
|
|
40
|
+
export interface SplatGroundOptions {
|
|
41
|
+
readonly material: string; readonly lod1: { readonly targetRatio: number; readonly maxErrorMetres: number };
|
|
42
|
+
readonly coarse?: { readonly material: string; readonly colourAt: (h: number, slope: number, splat: SplatWeights, canopy: number) => readonly [number, number, number] };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The live chunk's ground over the committed bake, `canopy` (a 256² density, `canopyMapOf`) as a channel, the openings cut. */
|
|
46
|
+
export function splatGroundSource(bytes: Uint8Array, canopy: ArrayLike<number>, hole?: SplatGroundHole): NativeLatticeSource {
|
|
47
|
+
const grid = parseBakedTerrain(Uint8Array.from(bytes).buffer);
|
|
48
|
+
if (grid?.res !== 256 || grid.size !== 500) throw new Error('Splat ground requires a native WSTR256');
|
|
49
|
+
if (canopy.length !== 256 * 256) throw new Error('Splat ground canopy must be 256²');
|
|
50
|
+
const geometry = terrainChunkGeometry(bakedSamplers(grid));
|
|
51
|
+
try {
|
|
52
|
+
const position = geometry.getAttribute('position'), index = geometry.getIndex();
|
|
53
|
+
if (position.itemSize !== 3 || position.count !== 256 ** 2 || index === null) throw new Error('Chunk geometry changed its native lattice');
|
|
54
|
+
geometry.setAttribute('canopy', new BufferAttribute(canopyChannel(position, canopy, 256), 1));
|
|
55
|
+
const positions = Float32Array.from({ length: position.count * 3 }, (_, i) => position.getComponent(Math.floor(i / 3), i % 3));
|
|
56
|
+
const attributes: Record<string, NativeLatticeAttribute> = {};
|
|
57
|
+
for (const [name, width] of Object.entries(CHANNELS)) {
|
|
58
|
+
const channel = geometry.getAttribute(name);
|
|
59
|
+
if (channel.itemSize !== width || channel.count !== position.count) throw new Error(`Chunk geometry lost channel ${name}`);
|
|
60
|
+
attributes[name] = { itemSize: width, values: Float32Array.from({ length: channel.count * width }, (_, i) => channel.getComponent(Math.floor(i / width), i % width)) };
|
|
61
|
+
}
|
|
62
|
+
const kept: number[] = [];
|
|
63
|
+
for (let t = 0; t < index.count; t += 3) {
|
|
64
|
+
const a = index.getX(t), b = index.getX(t + 1), c = index.getX(t + 2);
|
|
65
|
+
if (hole?.(position.getX(a), position.getY(a), position.getZ(a), position.getX(b), position.getY(b), position.getZ(b), position.getX(c), position.getY(c), position.getZ(c)) === true) continue;
|
|
66
|
+
kept.push(a, b, c);
|
|
67
|
+
}
|
|
68
|
+
return { resolution: 256, positions, indices: Uint32Array.from(kept), attributes };
|
|
69
|
+
} finally { geometry.dispose(); }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The 64 L0 tiles at native detail, then the 16 L1 tiles simplified; each one primitive that receives shadow, never casts. */
|
|
73
|
+
export async function bakeSplatGround(source: NativeLatticeSource, options: SplatGroundOptions): Promise<SplatGroundTile[]> {
|
|
74
|
+
const lod1: { tile: NativeLatticeTile; errorMetres: number }[] = [];
|
|
75
|
+
for (const tile of sliceNativeLattice(source, 1)) lod1.push(await simplifyNativeLatticeTile(tile, options.lod1.targetRatio, options.lod1.maxErrorMetres));
|
|
76
|
+
const material = new MeshStandardMaterial({ color: 0xffffff, metalness: 0, roughness: 1 });
|
|
77
|
+
material.name = options.material;
|
|
78
|
+
const coarse = options.coarse === undefined ? null : new MeshStandardMaterial({ color: 0xffffff, metalness: 0, roughness: 1, vertexColors: true });
|
|
79
|
+
if (coarse !== null && options.coarse !== undefined) coarse.name = options.coarse.material;
|
|
80
|
+
try {
|
|
81
|
+
return [...sliceNativeLattice(source, 0).map(tile => ({ tile, errorMetres: 0 })), ...lod1].map(({ tile, errorMetres }) => {
|
|
82
|
+
const geometry = new BufferGeometry();
|
|
83
|
+
let bytes: Uint8Array;
|
|
84
|
+
try {
|
|
85
|
+
geometry.setAttribute('position', new Float32BufferAttribute(tile.positions, 3));
|
|
86
|
+
geometry.setIndex(new BufferAttribute(tile.indices, 1));
|
|
87
|
+
if (tile.lod === 1 && coarse !== null && options.coarse !== undefined) {
|
|
88
|
+
geometry.setAttribute('normal', new Float32BufferAttribute(channelOf(tile, 'normal', 3), 3));
|
|
89
|
+
geometry.setAttribute('color', new Float32BufferAttribute(coarseColours(tile, options.coarse.colourAt), 3));
|
|
90
|
+
for (const name of ['splat', 'canopy'] as const) { const width = CHANNELS[name]; geometry.setAttribute(name, new Float32BufferAttribute(channelOf(tile, name, width), width)); }
|
|
91
|
+
bytes = staticGlb([{ geometry, material: coarse, castShadow: false, customAttributes: CUSTOM }], `${options.coarse.material}.l1.${String(tile.x)}.${String(tile.z)}`);
|
|
92
|
+
} else {
|
|
93
|
+
for (const [name, channel] of Object.entries(tile.attributes)) geometry.setAttribute(name, new Float32BufferAttribute(channel.values, channel.itemSize));
|
|
94
|
+
bytes = staticGlb([{ geometry, material, castShadow: false, customAttributes: CUSTOM }], `${options.material}.l${String(tile.lod)}.${String(tile.x)}.${String(tile.z)}`);
|
|
95
|
+
}
|
|
96
|
+
} finally { geometry.dispose(); }
|
|
97
|
+
return { tile, bytes, cost: parseGlb(bytes), geometricError: errorMetres + floatPositionError(tile.positions) };
|
|
98
|
+
});
|
|
99
|
+
} finally { material.dispose(); coarse?.dispose(); }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function channelOf(tile: NativeLatticeTile, name: string, width: number): Float64Array {
|
|
103
|
+
const channel = tile.attributes[name];
|
|
104
|
+
if (channel?.itemSize !== width) throw new Error(`Splat ground tile lost channel ${name}`);
|
|
105
|
+
return channel.values;
|
|
106
|
+
}
|
|
107
|
+
/** A coarse tile's vertex colours: `colourAt` over each vertex's height, slope (1 - normal y), splat weights and canopy. */
|
|
108
|
+
function coarseColours(tile: NativeLatticeTile, colourAt: NonNullable<SplatGroundOptions['coarse']>['colourAt']): Float32Array {
|
|
109
|
+
const normal = channelOf(tile, 'normal', 3), splat = channelOf(tile, 'splat', 4), canopy = channelOf(tile, 'canopy', 1), n = tile.positions.length / 3;
|
|
110
|
+
const out = new Float32Array(n * 3);
|
|
111
|
+
for (let i = 0; i < n; i++) {
|
|
112
|
+
const rgb = colourAt(tile.positions[i * 3 + 1] ?? 0, 1 - (normal[i * 3 + 1] ?? 1), [splat[i * 4] ?? 0, splat[i * 4 + 1] ?? 0, splat[i * 4 + 2] ?? 0, splat[i * 4 + 3] ?? 0], canopy[i] ?? 0);
|
|
113
|
+
out.set(rgb, i * 3);
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** One tier's four splat layers by role, as public asset paths. */
|
|
119
|
+
export interface SplatLayerPaths { colour: string[]; normal: string[]; arm: string[] }
|
|
120
|
+
/**
|
|
121
|
+
* The KTX2 files four native ground layers (`groundLayers` ids, in splat channel order) draw from on each tier, exactly as the
|
|
122
|
+
* runtime's texture arrays resolve them (`filePolicy(tier, 'ktx2', table).layer`: the engine table under the shard's own,
|
|
123
|
+
* the phone's `.phone` variants, found in `inventory`: the public files, keyed by URL); throws when a layer has no `#layer` KTX2.
|
|
124
|
+
*/
|
|
125
|
+
export function splatLayerFiles(ids: readonly string[], table: Ktx2Table, inventory: Readonly<Record<string, number | true>>): { desktop: SplatLayerPaths; phone: SplatLayerPaths } {
|
|
126
|
+
if (ids.length !== 4) throw new Error('A splat ground has four layers');
|
|
127
|
+
const tier = (name: 'phone' | 'desktop'): SplatLayerPaths => {
|
|
128
|
+
const policy = filePolicy(name, 'ktx2', table, inventory), roles: SplatLayerPaths = { colour: [], normal: [], arm: [] };
|
|
129
|
+
for (const id of ids) {
|
|
130
|
+
const [colour, normal, arm] = policy.pbr(id).map(url => {
|
|
131
|
+
const file = policy.layer(url);
|
|
132
|
+
if (!file.endsWith('.ktx2')) throw new Error(`Splat layer ${url} has no ${name} #layer KTX2`);
|
|
133
|
+
return file;
|
|
134
|
+
});
|
|
135
|
+
if (colour === undefined || normal === undefined || arm === undefined) throw new Error(`Splat layer ${id} lost a role`);
|
|
136
|
+
roles.colour.push(colour); roles.normal.push(normal); roles.arm.push(arm);
|
|
137
|
+
}
|
|
138
|
+
return roles;
|
|
139
|
+
};
|
|
140
|
+
return { desktop: tier('desktop'), phone: tier('phone') };
|
|
141
|
+
}
|