@wildshard/sdk 0.0.1 → 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 +13 -5
- 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 +365 -3
- 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,477 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-ktx2.mjs — every GPU texture as KTX2 / Basis Universal, so it stays compressed ON the GPU (E157): ASTC 4×4 on
|
|
3
|
+
// the iPhone, BC7 / ASTC / ETC2 on desktop, instead of the RGBA8 an image decodes to (4 bytes a texel + mips).
|
|
4
|
+
//
|
|
5
|
+
// What it encodes (the images the game samples in 3D; UI art — title decks, HUD icons, the journal — is not a GPU
|
|
6
|
+
// texture and is left alone):
|
|
7
|
+
// - standalone images: the Poly Haven sets (/assets/tex), the tree set's cards + impostors, the Driftwood lightmaps,
|
|
8
|
+
// the baked textures (/assets/baked), Nalati's painted tiles, grass-card atlas and sky panorama, the painted horizons;
|
|
9
|
+
// - the glTF props' external textures (/assets/models/<id>/textures) and their .gltf, rewritten to point at them;
|
|
10
|
+
// - every GLB with embedded images (KHR_texture_basisu; geometry bytes untouched).
|
|
11
|
+
//
|
|
12
|
+
// Per tier, per file the tier SERVES (the phone's `.phone.webp` / `.phone.glb` copy when there is one, src/client/engine/boot/bytes.ts
|
|
13
|
+
// tierUrl): the phone's KTX2 has the phone copy's size, the desktop's the full-res file's own size (E173; the desktop
|
|
14
|
+
// loaders cap at 4096 and read every file here whole). Encoded from the best source there is (the original map, not a
|
|
15
|
+
// lossy copy of it). Both tiers are baked (E173: desktop Pine Hollow held ~950 MB of RGBA8 textures, ~1.7 GB with two
|
|
16
|
+
// shards resident); an encode that is the same for both tiers (same source, size, class, flip) is one file.
|
|
17
|
+
// Texture-array layers are baked at the tier's array size (src/client/engine/core/tier.ts layerSize: the desktop's 1024 is the phone's
|
|
18
|
+
// file size, so the desktop reuses the phone's layer twins of the 2048² ground sets instead of a 2048² twin it would
|
|
19
|
+
// only sample from mip 1).
|
|
20
|
+
//
|
|
21
|
+
// Encoder (basisu v2.50, Homebrew `basis_universal`), per texture class:
|
|
22
|
+
// color UASTC LDR 4×4, level 2, sRGB, no RDO (λ 4 cost 6 dB), zstd 20 diffuse / albedo / emissive, atlases, horizons
|
|
23
|
+
// normal UASTC LDR 4×4, level 2, -normal_map (linear metrics, linear mips) tangent-space normal maps
|
|
24
|
+
// linear UASTC LDR 4×4, level 2, linear lightmaps, the cloud field (smooth: no ETC1S banding)
|
|
25
|
+
// data ETC1S q255, linear ARM / ORM / AO / roughness / metalness planes
|
|
26
|
+
// all: full mip chain (-mipmap, box filter = what the GPU's generateMipmap made before); standalone images are Y-flipped
|
|
27
|
+
// at encode (-y_flip: the loaders drew them flipY = true / ImageBitmap 'flipY'); glTF textures are not (glTF's own
|
|
28
|
+
// convention), nor the Driftwood lightmaps (loaded flipY = false).
|
|
29
|
+
//
|
|
30
|
+
// Output: public/assets/gpu/<the source's path>/<served name>-<sha256[:8] of the bytes>.{ktx2,glb,gltf} — content-addressed,
|
|
31
|
+
// so a file never changes under its name (the `immutable` cache rule; the SW keeps it forever) and a rebake that
|
|
32
|
+
// changes nothing changes no name. src/client/engine/boot/ktx2.generated.ts maps, per tier, each served URL → its KTX2 stand-in
|
|
33
|
+
// (read by src/client/engine/boot/gpuFiles.ts). scripts/bake-ktx2.cache.json remembers the source hash + settings of every output,
|
|
34
|
+
// so a rerun encodes only what changed (a no-change rerun: ~2 s).
|
|
35
|
+
//
|
|
36
|
+
// Only files the game was SEEN to load are baked: scripts/bake-ktx2.list.json, per tier, the URLs a boot of each shard
|
|
37
|
+
// fetched (recorded by `node scripts/gpu-texmem.mjs --record --chunk=<slug> --tier=<tier>`). The repo
|
|
38
|
+
// holds ~250 GLBs and ~180 images, most of them sources, alternates and other shards' art; a file that is not on the
|
|
39
|
+
// list simply keeps loading as an image (the texmem report lists what is still RGBA8). The texture-array layers (the
|
|
40
|
+
// terrain splat, the bark) are baked a second time unflipped (`<url>#layer`): loadPBRArray keeps the file's orientation.
|
|
41
|
+
//
|
|
42
|
+
// node --import ./scripts/bake-loader.mjs scripts/bake-ktx2.mjs [--dry] [--force] [--only=<substr>] [--jobs=4] [--tiers=phone,desktop] [--desktop-max=16384]
|
|
43
|
+
import { COMMON, CLASS, FAR, glbKtx2Key } from './ktx2-settings.mjs';
|
|
44
|
+
import { writeKtx2Tables } from '@wildshard/engine/scripts/ktx2-tables.mjs';
|
|
45
|
+
import { createHash } from 'node:crypto';
|
|
46
|
+
import { execFileSync, spawn } from 'node:child_process';
|
|
47
|
+
import { once } from 'node:events';
|
|
48
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
49
|
+
import { tmpdir } from 'node:os';
|
|
50
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
51
|
+
|
|
52
|
+
/** a child process as a promise (the encodes run JOBS at a time); rejects with its stderr's tail */
|
|
53
|
+
async function execFile(cmd, args) {
|
|
54
|
+
const child = spawn(cmd, args, { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
55
|
+
let err = '';
|
|
56
|
+
child.stderr.on('data', (d) => { err += String(d); });
|
|
57
|
+
const [code] = await once(child, 'close');
|
|
58
|
+
if (code !== 0) throw new Error(`${cmd} exited ${code}: ${err.slice(-400)}`);
|
|
59
|
+
}
|
|
60
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
61
|
+
const PUB = resolve(ROOT, 'public');
|
|
62
|
+
const ASSETS = resolve(PUB, 'assets');
|
|
63
|
+
const OUT = resolve(ASSETS, 'gpu');
|
|
64
|
+
const CACHE_FILE = resolve(ROOT, 'scripts/bake-ktx2.cache.json');
|
|
65
|
+
const LIST_FILE = resolve(ROOT, 'scripts/bake-ktx2.list.json');
|
|
66
|
+
const argv = process.argv.slice(2);
|
|
67
|
+
const flag = (n, d) => { const a = argv.find((x) => x.startsWith(`--${n}=`)); return a ? a.slice(n.length + 3) : d; };
|
|
68
|
+
const CHECK = argv.includes('--check');
|
|
69
|
+
const DRY = argv.includes('--dry') ? true : CHECK, FORCE = argv.includes('--force') && !CHECK;
|
|
70
|
+
const missing = new Set();
|
|
71
|
+
const staleSource = (served) => { missing.add(served); console.log(`bake-ktx2: STALE ${served} (source/settings cache entry or output missing)`); };
|
|
72
|
+
const ONLY = flag('only', '');
|
|
73
|
+
const JOBS = Number(flag('jobs', '4'));
|
|
74
|
+
/** the desktop's largest KTX2 edge: the file's own size (the horizons are 6144 wide and load whole) */
|
|
75
|
+
const DESKTOP_MAX = Number(flag('desktop-max', String(1 << 14)));
|
|
76
|
+
/** the texture-array size per tier (src/client/engine/core/tier.ts TIER_CONFIG.layerSize): a desktop layer twin is baked at it */
|
|
77
|
+
const DESKTOP_LAYER = 1024;
|
|
78
|
+
/** the tiers baked (E173: both; `--tiers=phone` bakes the phone's alone, and then drops the desktop's files) */
|
|
79
|
+
const TIERS = new Set(flag('tiers', 'phone,desktop').split(','));
|
|
80
|
+
|
|
81
|
+
/** the URLs each tier was seen to load (see the header) */
|
|
82
|
+
// A bounded source catalogue can emit charged library assets without native shard/engine imports.
|
|
83
|
+
const libraryInput = flag('library', '');
|
|
84
|
+
if (libraryInput !== '') {
|
|
85
|
+
const { bakeTextureLibrary } = await import('../src/shards/far-reach/generators/bake-sky-world.mjs');
|
|
86
|
+
const { bakeColourTexture } = await import('../src/sharddev/bake/texture.ts');
|
|
87
|
+
await bakeTextureLibrary(ROOT, libraryInput, { encoder: bakeColourTexture, encode: argv.includes('--encode'), check: CHECK });
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
|
90
|
+
const LIST = JSON.parse(readFileSync(LIST_FILE, 'utf8'));
|
|
91
|
+
const listed = { phone: new Set(TIERS.has('phone') ? LIST.phone : []), desktop: new Set(TIERS.has('desktop') ? LIST.desktop : []) };
|
|
92
|
+
// the texture-array layers' sets (src/client/engine/core/assets.ts loadPBRArray): every shard's ground layers + the bark set
|
|
93
|
+
// the modules read the tier from the page's URL at import time: stand in for a phone page (as scripts/bake-packs.mjs does)
|
|
94
|
+
const { initializeTier } = await import('@wildshard/engine/core/tier');
|
|
95
|
+
initializeTier('phone');
|
|
96
|
+
const { pathToFileURL } = await import('node:url');
|
|
97
|
+
const imp = (p) => import(pathToFileURL(resolve(ROOT, p)).href);
|
|
98
|
+
const { SHARDS } = await imp('src/shards.generated.ts');
|
|
99
|
+
const { playable } = await imp('src/client/game/shard/registry.ts');
|
|
100
|
+
const PLAYABLE_SHARDS = SHARDS.filter(playable);
|
|
101
|
+
const { BARK_LAYERS } = await imp('src/client/engine/world/forest/treeSet.ts');
|
|
102
|
+
const LAYER_SETS = new Set(BARK_LAYERS);
|
|
103
|
+
for (const c of PLAYABLE_SHARDS) for (const id of [...(c.assets?.groundLayers ?? []), ...(c.assets?.boreal?.v1?.groundLayers ?? [])]) LAYER_SETS.add(id);
|
|
104
|
+
const layerSetOf = (file) => /\/assets\/tex\/([^/]+)\/(diffuse|nor_gl|arm)(_1k)?\.jpg$/.exec(file)?.[1] ?? null;
|
|
105
|
+
const isLayerFile = (file) => { const id = layerSetOf(file); return id !== null && LAYER_SETS.has(id); };
|
|
106
|
+
/**
|
|
107
|
+
* Layer sets no plain loader reads (loadPBR / loadTexture): only their unflipped `#layer` twin is ever loaded, so their
|
|
108
|
+
* Y-flipped KTX2 would be a file no KTX2 set names (E173: 31.8 MB on the desktop, 10.4 MB of the phone's). The sets a
|
|
109
|
+
* plain loader also reads keep both: pine_bark (the cabins), rock_ground (the terrain slab, the crags).
|
|
110
|
+
* test/ktx2-auto.test.ts holds this list to the truth both ways: every file under /assets/gpu is in some tier's KTX2 set
|
|
111
|
+
* (a set missing here leaves an unread file), and no KTX2 boot declares an image of a set named here (one wrongly here
|
|
112
|
+
* would load as an image).
|
|
113
|
+
*/
|
|
114
|
+
const ARRAY_ONLY = new Set(['bark_willow_02', 'birch_bark', 'fir_bark', 'metasequoia_bark', 'forrest_ground_03', 'leafy_grass', 'stony_dirt_path']);
|
|
115
|
+
const arrayOnly = (file) => { const id = layerSetOf(file); return id !== null && ARRAY_ONLY.has(id) && LAYER_SETS.has(id); };
|
|
116
|
+
|
|
117
|
+
const ENCODER = /v[\d.]+/.exec(execFileSync('basisu', ['-version']).toString())?.[0] ?? '?';
|
|
118
|
+
/** texture class from a file / image name */
|
|
119
|
+
function classOf(name) {
|
|
120
|
+
const n = basename(name).toLowerCase();
|
|
121
|
+
if (/(^|[_\-.])(lm|clouds)[_\-.]/.test(n)) return 'linear'; // lightmaps; the baked cloud field (sampled as data, NoColorSpace)
|
|
122
|
+
if (/(^|[_\-.])(nor|nor_gl|normal|nrm)([_\-.]|$)/.test(n)) return 'normal';
|
|
123
|
+
if (/(^|[_\-.])(arm|orm|ao|rough|roughness|metal|metalness|metallic)([_\-.]|$)/.test(n)) return 'data';
|
|
124
|
+
return 'color';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const sha = (buf) => createHash('sha256').update(buf).digest('hex');
|
|
128
|
+
const pub = (abs) => `/${relative(PUB, abs).split('\\').join('/')}`;
|
|
129
|
+
const abs = (p) => join(PUB, p);
|
|
130
|
+
const walk = (dir, out = []) => { if (!existsSync(dir)) return out; for (const n of readdirSync(dir)) { const p = join(dir, n); if (statSync(p).isDirectory()) { if (p !== OUT && !p.endsWith('/packs')) walk(p, out); } else out.push(p); } return out; };
|
|
131
|
+
const dimsCache = new Map();
|
|
132
|
+
function dims(file) {
|
|
133
|
+
let d = dimsCache.get(file);
|
|
134
|
+
if (!d) { const [w, h] = execFileSync('magick', ['identify', '-format', '%w %h\n', `${file}[0]`]).toString().trim().split(/\s+/).map(Number); d = { w, h }; dimsCache.set(file, d); }
|
|
135
|
+
return d;
|
|
136
|
+
}
|
|
137
|
+
const hasAlpha = (file) => execFileSync('magick', ['identify', '-format', '%[opaque]', `${file}[0]`]).toString().trim().toLowerCase() === 'false';
|
|
138
|
+
/** fit (w, h) inside max, keeping the aspect; multiples of 4 (the block size) */
|
|
139
|
+
function fit(w, h, max) {
|
|
140
|
+
const k = Math.min(1, max / Math.max(w, h));
|
|
141
|
+
const r4 = (x) => Math.max(4, Math.round((x * k) / 4) * 4);
|
|
142
|
+
return { w: r4(w), h: r4(h) };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ── the cache: key (source hash + settings) → output path ──
|
|
146
|
+
const cache = existsSync(CACHE_FILE) ? JSON.parse(readFileSync(CACHE_FILE, 'utf8')) : {};
|
|
147
|
+
const usedKeys = new Set();
|
|
148
|
+
|
|
149
|
+
// ── encoding ──
|
|
150
|
+
const TMP = join(tmpdir(), `bake-ktx2-${process.pid}`);
|
|
151
|
+
mkdirSync(TMP, { recursive: true });
|
|
152
|
+
let tmpN = 0;
|
|
153
|
+
/**
|
|
154
|
+
* Encode `srcFile` (any image magick reads) to KTX2 at w×h with the class's flags; returns the bytes. Resized per
|
|
155
|
+
* channel when it has alpha (the default alpha-weighted resize blackens the RGB under transparent texels, which
|
|
156
|
+
* filtering and the mips still read — scripts/tex-tiers.mjs does the same).
|
|
157
|
+
*/
|
|
158
|
+
async function encode(srcFile, w, h, cls, flip) {
|
|
159
|
+
const id = ++tmpN;
|
|
160
|
+
const png = join(TMP, `${id}.png`), out = join(TMP, `${id}.ktx2`);
|
|
161
|
+
const d = dims(srcFile);
|
|
162
|
+
const resize = d.w === w && d.h === h ? [] : hasAlpha(srcFile) ? ['-separate', '-resize', `${w}x${h}!`, '-combine'] : ['-resize', `${w}x${h}!`];
|
|
163
|
+
await execFile('magick', [`${srcFile}[0]`, ...resize, '-strip', `PNG32:${png}`]);
|
|
164
|
+
await execFile('basisu', [...COMMON, ...(cls === 'far' ? FAR : CLASS[cls]), ...(flip ? ['-y_flip'] : []), png, '-output_file', out]);
|
|
165
|
+
const bytes = readFileSync(out);
|
|
166
|
+
rmSync(png); rmSync(out);
|
|
167
|
+
return bytes;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** a content-addressed output next to its source's mirror under /assets/gpu: `<stem>-<hash8>.<ext>` */
|
|
171
|
+
function outPath(servedPub, bytes, ext) {
|
|
172
|
+
const rel = servedPub.replace(/^\/assets\//, '').replace(/#layer$/, '');
|
|
173
|
+
const stem = basename(rel).replace(/\.(png|jpe?g|webp|glb|gltf)$/i, '');
|
|
174
|
+
return join(OUT, dirname(rel), `${stem}-${sha(bytes).slice(0, 8)}.${ext}`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
async function runPool(tasks) {
|
|
179
|
+
let i = 0;
|
|
180
|
+
const worker = async () => { while (i < tasks.length) { const t = tasks[i++]; await t(); } };
|
|
181
|
+
await Promise.all(Array.from({ length: Math.max(1, JOBS) }, worker));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ── the jobs ──
|
|
185
|
+
/** [tier, served URL, best source (abs), target w, h, class, flip] */
|
|
186
|
+
const imageJobs = [];
|
|
187
|
+
const skipped = [];
|
|
188
|
+
const phoneCopyOf = (file) => {
|
|
189
|
+
const stem = file.replace(/\.(png|jpe?g|webp)$/i, '');
|
|
190
|
+
for (const c of [`${stem}.phone.webp`, `${stem}-phone.webp`]) if (existsSync(c)) return c;
|
|
191
|
+
return null;
|
|
192
|
+
};
|
|
193
|
+
const isPhoneCopy = (f) => /\.phone\.webp$|-phone\.webp$/.test(f);
|
|
194
|
+
function addImage(file, flip, clsOverride) {
|
|
195
|
+
const cls = clsOverride ?? classOf(file);
|
|
196
|
+
const orig = file.endsWith('_1k.jpg') && existsSync(file.replace(/_1k\.jpg$/, '.jpg')) ? file.replace(/_1k\.jpg$/, '.jpg') : file; // the best source
|
|
197
|
+
const phone = phoneCopyOf(file);
|
|
198
|
+
// desktop: the file itself (never a Poly Haven set's phone-only `_1k` copy of a larger map: texUrl() asks those only on the phone)
|
|
199
|
+
if (orig === file && listed.desktop.has(pub(file))) {
|
|
200
|
+
const d = dims(file);
|
|
201
|
+
if (Math.max(d.w, d.h) > DESKTOP_MAX) skipped.push(`${pub(file)} (desktop, ${d.w}×${d.h} > ${DESKTOP_MAX})`);
|
|
202
|
+
else { const t = fit(d.w, d.h, DESKTOP_MAX); push('desktop', pub(file), orig, t.w, t.h, cls, flip, isLayerFile(file) ? fit(d.w, d.h, DESKTOP_LAYER) : null, arrayOnly(file)); }
|
|
203
|
+
}
|
|
204
|
+
// phone: the phone copy when there is one (≤ 1024 px, scripts/tex-tiers.mjs), else the file, at its own size — the
|
|
205
|
+
// loaders that cap the phone at 1024 (core/assets loadTexture) drop the KTX2's top mips instead; `X.jpg` with an
|
|
206
|
+
// `X_1k.jpg` sibling is never asked for on the phone
|
|
207
|
+
if (file.endsWith('.jpg') && !file.endsWith('_1k.jpg') && existsSync(file.replace(/\.jpg$/, '_1k.jpg'))) return;
|
|
208
|
+
const served = phone ?? file;
|
|
209
|
+
const d = dims(served);
|
|
210
|
+
const t = fit(d.w, d.h, 1 << 14);
|
|
211
|
+
push('phone', pub(served), orig, t.w, t.h, cls, flip, isLayerFile(file) ? t : null, arrayOnly(file));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* A job for a file the tier was seen to load; a texture-array layer also gets its unflipped twin under `<url>#layer`, at
|
|
215
|
+
* `layer`'s size (the phone: the file's own — ktx2Layers starts at the mip that fits; the desktop: its array size), and
|
|
216
|
+
* only that twin when its set is ARRAY_ONLY.
|
|
217
|
+
*/
|
|
218
|
+
function push(tier, served, orig, w, h, cls, flip, layer, onlyLayer = false) {
|
|
219
|
+
if (!listed[tier].has(served)) return;
|
|
220
|
+
if (!(layer && onlyLayer)) imageJobs.push([tier, served, orig, w, h, cls, flip]);
|
|
221
|
+
if (layer) imageJobs.push([tier, `${served}#layer`, orig, layer.w, layer.h, cls, false]);
|
|
222
|
+
}
|
|
223
|
+
const images = (dir, re = /\.(png|jpe?g|webp)$/i) => walk(join(ASSETS, dir)).filter((f) => re.test(f) && !isPhoneCopy(f));
|
|
224
|
+
|
|
225
|
+
// Poly Haven sets + twig atlases (loadTexture / loadPBR / loadPBRArray: flipped)
|
|
226
|
+
for (const f of images('tex')) addImage(f, true);
|
|
227
|
+
// the tree set's cards + impostors (TreeFactory loadTexture), Driftwood's lightmaps (BlenderIsland: flipY false)
|
|
228
|
+
for (const f of images('models/pine-hollow-trees')) addImage(f, true);
|
|
229
|
+
for (const f of images('models/driftwood-blender')) addImage(f, false);
|
|
230
|
+
// baked textures + baked branch cards (bakedTexture / BakedCards: flipped); fur maps have only phone copies and are unread
|
|
231
|
+
for (const f of images('baked')) addImage(f, true);
|
|
232
|
+
// Nalati: painted tiles, the grass-card atlas, the sky panorama (fetchImage / loadTexture: flipped)
|
|
233
|
+
for (const f of images('nalati/tex')) addImage(f, true);
|
|
234
|
+
for (const n of ['cards', 'panorama']) addImage(join(ASSETS, `nalati/${n}.webp`), true);
|
|
235
|
+
// painted horizons (HorizonMatte, TextureLoader flipY = true): the phone copy of pine-hollow is `-phone.webp`
|
|
236
|
+
for (const f of images('horizon')) addImage(f, true);
|
|
237
|
+
// Nine Dragon's painted leaf and LED scroll, plus the viewmodel's data and object-normal maps.
|
|
238
|
+
// The paint layers are assembled into a DataArrayTexture on the CPU, so they stay images.
|
|
239
|
+
for (const f of images('nine-dragon/lab/organic')) addImage(f, true);
|
|
240
|
+
for (const f of images('nine-dragon/viewmodel')) addImage(f, false, f.includes('-maps.') ? 'data' : undefined);
|
|
241
|
+
// glTF props' external textures: glTF orientation (no flip); their .gltf is rewritten below
|
|
242
|
+
for (const f of walk(join(ASSETS, 'models')).filter((x) => /\/textures\/[^/]+\.(png|jpe?g)$/i.test(x))) addImage(f, false);
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* GLBs whose textures the game reads back on the CPU, so they must stay images: a compressed texture has no pixels to
|
|
246
|
+
* draw on a canvas. Nalati's creature hulls' atlases are still read (the Sky-Marked Saddle repaints the saddled hull's
|
|
247
|
+
* felt, weapons/nalatiSkins.ts; a coat with no bake is painted from it), though its coats come baked (scripts/bake-coats.mjs,
|
|
248
|
+
* merged below), and the camp's people are packed into one atlas (src/shards/nalati-grasslands/campPeopleModels.ts). Pine
|
|
249
|
+
* Hollow's hulls are baked (G187 cut 2): their coats come pre-painted from scripts/bake-coats.mjs (merged below), and the trophy wall
|
|
250
|
+
* reads a KTX2 coat back through the GPU (src/shards/pine-hollow/world/trophyWall.ts).
|
|
251
|
+
*/
|
|
252
|
+
const CPU_READ = [/^\/assets\/nalati\/models\/[^/]+\.rigged\.glb$/, /^\/assets\/nalati\/models\/people\//];
|
|
253
|
+
/**
|
|
254
|
+
* G187: textures baked by their own scripts (table name → KTX2, per tier): cut 2, Pine Hollow's coats, painted and encoded
|
|
255
|
+
* by scripts/bake-coats.mjs (G226: Nalati's too); cut 3, the weapon viewmodel sets, drawn and encoded by scripts/bake-viewmodel-sets.mjs
|
|
256
|
+
*/
|
|
257
|
+
const BAKED = ['src/shards/pine-hollow/generators/bake-pine-coats.json', 'src/shards/nalati-grasslands/generators/bake-nalati-coats.json', 'scripts/bake-viewmodel-sets.json'].map((f) => resolve(ROOT, f)).filter((f) => existsSync(f)).map((f) => JSON.parse(readFileSync(f, 'utf8')));
|
|
258
|
+
/** GLBs with embedded images, per tier: [tier, served URL, file] */
|
|
259
|
+
const glbJobs = [];
|
|
260
|
+
for (const f of walk(ASSETS).filter((x) => x.endsWith('.glb') && !CPU_READ.some((re) => re.test(pub(x))))) {
|
|
261
|
+
const phoneName = f.includes('.phone.');
|
|
262
|
+
if (!phoneName && listed.desktop.has(pub(f))) glbJobs.push(['desktop', pub(f), f]);
|
|
263
|
+
if (listed.phone.has(pub(f))) glbJobs.push(['phone', pub(f), f]);
|
|
264
|
+
}
|
|
265
|
+
/** .gltf props with external textures */
|
|
266
|
+
const gltfJobs = [];
|
|
267
|
+
for (const f of walk(join(ASSETS, 'models')).filter((x) => x.endsWith('.gltf'))) for (const tier of ['desktop', 'phone']) if (listed[tier].has(pub(f))) gltfJobs.push([tier, pub(f), f]);
|
|
268
|
+
|
|
269
|
+
const only = (served) => ONLY === '' || served.includes(ONLY);
|
|
270
|
+
const map = { phone: {}, desktop: {} };
|
|
271
|
+
let encoded = 0, reused = 0, bytesIn = 0, bytesOut = 0;
|
|
272
|
+
|
|
273
|
+
/** encode-or-reuse one standalone image; returns its output path */
|
|
274
|
+
async function imageOut(src, w, h, cls, flip, served) {
|
|
275
|
+
const key = sha(`${sha(readFileSync(src))}|${w}x${h}|${cls}|${flip ? 'flip' : ''}|${ENCODER}|${[...COMMON, ...CLASS[cls]].join(' ')}`);
|
|
276
|
+
usedKeys.add(key);
|
|
277
|
+
const hit = cache[key];
|
|
278
|
+
if (!FORCE && hit && existsSync(abs(hit))) { reused++; return hit; }
|
|
279
|
+
if (DRY) { if (CHECK) staleSource(served); return `(new) ${served}`; }
|
|
280
|
+
const bytes = await encode(src, w, h, cls, flip);
|
|
281
|
+
const out = outPath(served, bytes, 'ktx2');
|
|
282
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
283
|
+
writeFileSync(out, bytes);
|
|
284
|
+
cache[key] = pub(out);
|
|
285
|
+
encoded++;
|
|
286
|
+
return pub(out);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
console.log(`bake-ktx2: ${ENCODER} · ${imageJobs.length} image jobs · ${glbJobs.length} GLB jobs · ${gltfJobs.length} glTF jobs${DRY ? ' (dry)' : ''}`);
|
|
290
|
+
// images: dedupe identical encodes (the same source at the same size for both tiers)
|
|
291
|
+
const pending = new Map();
|
|
292
|
+
const imageTask = (job) => async () => {
|
|
293
|
+
const [tier, served, src, w, h, cls, flip] = job;
|
|
294
|
+
if (!only(served)) return;
|
|
295
|
+
const k = `${src}|${w}x${h}|${cls}|${flip}`; // the same encode for both tiers / both keys: one file
|
|
296
|
+
let p = pending.get(k);
|
|
297
|
+
if (!p) { p = imageOut(src, w, h, cls, flip, served); pending.set(k, p); }
|
|
298
|
+
map[tier][served] = await p;
|
|
299
|
+
if (!served.endsWith('#layer')) bytesIn += statSync(abs(served)).size;
|
|
300
|
+
};
|
|
301
|
+
await runPool(imageJobs.map(imageTask));
|
|
302
|
+
|
|
303
|
+
/** GLB: its embedded images → KTX2 (KHR_texture_basisu), classed by the material slot that samples them */
|
|
304
|
+
/**
|
|
305
|
+
* A GLB's JSON and its BIN chunk (buffer 0). Only buffer 0 holds bytes: a meshopt GLB's bufferViews point into a
|
|
306
|
+
* data-less fallback buffer and carry their real range in EXT_meshopt_compression — both kinds of range are kept.
|
|
307
|
+
*/
|
|
308
|
+
function readGlb(path) {
|
|
309
|
+
const b = readFileSync(path);
|
|
310
|
+
if (b.readUInt32LE(0) !== 0x46546c67) throw new Error(`${path}: not a GLB`);
|
|
311
|
+
const jsonLen = b.readUInt32LE(12);
|
|
312
|
+
const json = JSON.parse(b.subarray(20, 20 + jsonLen).toString('utf8'));
|
|
313
|
+
const binStart = 20 + jsonLen + 8;
|
|
314
|
+
const bin = b.subarray(binStart, binStart + b.readUInt32LE(20 + jsonLen));
|
|
315
|
+
return { json, bin };
|
|
316
|
+
}
|
|
317
|
+
/** the bytes of an image's bufferView (images are never meshopt-compressed) */
|
|
318
|
+
const imageBytes = (json, bin, view) => { const v = json.bufferViews[view]; return bin.subarray(v.byteOffset ?? 0, (v.byteOffset ?? 0) + v.byteLength); };
|
|
319
|
+
/**
|
|
320
|
+
* The GLB with some bufferViews' bytes replaced (`swap`: view index → new bytes): buffer 0 is rebuilt from every range
|
|
321
|
+
* that points into it — each bufferView on buffer 0 and each EXT_meshopt_compression range on buffer 0 — in their
|
|
322
|
+
* original order, 4-byte aligned, and every offset is remapped. Nothing else changes (geometry bytes are copied as they were).
|
|
323
|
+
*/
|
|
324
|
+
function glbBytes(json, bin, swap) {
|
|
325
|
+
const ranges = [];
|
|
326
|
+
for (const [i, v] of json.bufferViews.entries()) {
|
|
327
|
+
if ((v.buffer ?? 0) === 0) ranges.push({ holder: v, off: v.byteOffset ?? 0, len: v.byteLength, data: swap.get(i) });
|
|
328
|
+
const m = v.extensions?.EXT_meshopt_compression;
|
|
329
|
+
if (m && (m.buffer ?? 0) === 0) ranges.push({ holder: m, off: m.byteOffset ?? 0, len: m.byteLength, data: undefined });
|
|
330
|
+
}
|
|
331
|
+
ranges.sort((a, b) => a.off - b.off);
|
|
332
|
+
const parts = []; const placed = new Map(); let at = 0;
|
|
333
|
+
for (const r of ranges) {
|
|
334
|
+
const key = `${r.off}:${r.len}`;
|
|
335
|
+
let where = placed.get(key);
|
|
336
|
+
if (where === undefined || r.data !== undefined) {
|
|
337
|
+
const bytes = r.data ?? bin.subarray(r.off, r.off + r.len);
|
|
338
|
+
const pad = (4 - (at % 4)) % 4; if (pad > 0) { parts.push(Buffer.alloc(pad)); at += pad; }
|
|
339
|
+
where = at; parts.push(bytes); at += bytes.length;
|
|
340
|
+
if (r.data === undefined) placed.set(key, where);
|
|
341
|
+
}
|
|
342
|
+
r.holder.byteOffset = where;
|
|
343
|
+
r.holder.byteLength = r.data?.length ?? r.len;
|
|
344
|
+
}
|
|
345
|
+
const pad = (4 - (at % 4)) % 4; if (pad > 0) { parts.push(Buffer.alloc(pad)); at += pad; }
|
|
346
|
+
json.buffers[0].byteLength = at;
|
|
347
|
+
const out = Buffer.concat(parts);
|
|
348
|
+
let jb = Buffer.from(JSON.stringify(json), 'utf8');
|
|
349
|
+
jb = Buffer.concat([jb, Buffer.alloc((4 - (jb.length % 4)) % 4, 0x20)]);
|
|
350
|
+
const header = Buffer.alloc(12); header.writeUInt32LE(0x46546c67, 0); header.writeUInt32LE(2, 4);
|
|
351
|
+
const jh = Buffer.alloc(8); jh.writeUInt32LE(jb.length, 0); jh.writeUInt32LE(0x4e4f534a, 4);
|
|
352
|
+
const bh = Buffer.alloc(8); bh.writeUInt32LE(out.length, 0); bh.writeUInt32LE(0x004e4942, 4);
|
|
353
|
+
header.writeUInt32LE(12 + 8 + jb.length + 8 + out.length, 8);
|
|
354
|
+
return Buffer.concat([header, jh, jb, bh, out]);
|
|
355
|
+
}
|
|
356
|
+
/** per image index: the strictest class of the slots that sample it (color > normal > linear > data) */
|
|
357
|
+
function imageClasses(json) {
|
|
358
|
+
const texSource = (t) => { const x = json.textures?.[t]; return x?.source ?? x?.extensions?.EXT_texture_webp?.source ?? x?.extensions?.KHR_texture_basisu?.source; };
|
|
359
|
+
const rank = { data: 0, linear: 1, normal: 2, color: 3 };
|
|
360
|
+
const out = new Map();
|
|
361
|
+
const note = (info, cls) => { if (!info) return; const s = texSource(info.index); if (s === undefined) return; const cur = out.get(s); if (!cur || rank[cls] > rank[cur]) out.set(s, cls); };
|
|
362
|
+
for (const m of json.materials ?? []) {
|
|
363
|
+
const p = m.pbrMetallicRoughness ?? {};
|
|
364
|
+
note(p.baseColorTexture, 'color'); note(m.emissiveTexture, 'color');
|
|
365
|
+
note(m.normalTexture, 'normal');
|
|
366
|
+
note(p.metallicRoughnessTexture, 'data'); note(m.occlusionTexture, 'data');
|
|
367
|
+
for (const ext of Object.values(m.extensions ?? {})) for (const [k, v] of Object.entries(ext ?? {})) if (v && typeof v === 'object' && 'index' in v) note(v, /normal/i.test(k) ? 'normal' : /color|sheen|specularColor/i.test(k) ? 'color' : 'data');
|
|
368
|
+
}
|
|
369
|
+
return out;
|
|
370
|
+
}
|
|
371
|
+
const glbDone = new Map();
|
|
372
|
+
/** G738 / I4: GLBs drawn only far away, whose colour images take the FAR encode (the phone's ambient bird flock: its
|
|
373
|
+
* atlas 782 → 175 KB, board art/pine-hollow/round-37-phone-birds-etc1s) */
|
|
374
|
+
const FAR_GLBS = new Set(['/assets/pine-hollow/life/birds.phone.glb']);
|
|
375
|
+
async function glbOut(file, served) {
|
|
376
|
+
const src = readFileSync(file), far = FAR_GLBS.has(served);
|
|
377
|
+
const key = glbKtx2Key(src, ENCODER, far);
|
|
378
|
+
usedKeys.add(key);
|
|
379
|
+
const hit = cache[key];
|
|
380
|
+
if (!FORCE && hit && (hit === 'none' || existsSync(abs(hit)))) { reused++; return hit === 'none' ? null : hit; }
|
|
381
|
+
const { json, bin } = readGlb(file);
|
|
382
|
+
const swap = new Map();
|
|
383
|
+
if (!(json.images?.length > 0)) { if (CHECK) staleSource(served); else cache[key] = 'none'; return null; }
|
|
384
|
+
if (DRY) { if (CHECK) staleSource(served); return `(new) ${served}`; }
|
|
385
|
+
const classes = imageClasses(json);
|
|
386
|
+
for (const [i, img] of json.images.entries()) {
|
|
387
|
+
if (img.bufferView === undefined) throw new Error(`${file}: image ${i} is not embedded`);
|
|
388
|
+
const tmp = join(TMP, `glb-${++tmpN}.${(img.mimeType ?? 'image/png').split('/')[1]}`);
|
|
389
|
+
writeFileSync(tmp, imageBytes(json, bin, img.bufferView));
|
|
390
|
+
const d = dims(tmp);
|
|
391
|
+
const t = fit(d.w, d.h, 1 << 14);
|
|
392
|
+
const cls = classes.get(i) ?? 'color';
|
|
393
|
+
swap.set(img.bufferView, await encode(tmp, t.w, t.h, far && cls === 'color' ? 'far' : cls, false));
|
|
394
|
+
rmSync(tmp);
|
|
395
|
+
img.mimeType = 'image/ktx2';
|
|
396
|
+
}
|
|
397
|
+
for (const t of json.textures ?? []) {
|
|
398
|
+
const s = t.source ?? t.extensions?.EXT_texture_webp?.source;
|
|
399
|
+
if (s === undefined) continue;
|
|
400
|
+
const ext = { ...t.extensions }; delete ext.EXT_texture_webp;
|
|
401
|
+
t.extensions = { ...ext, KHR_texture_basisu: { source: s } };
|
|
402
|
+
delete t.source;
|
|
403
|
+
}
|
|
404
|
+
for (const k of ['extensionsUsed', 'extensionsRequired']) json[k] = [...new Set([...(json[k] ?? []).filter((e) => e !== 'EXT_texture_webp'), 'KHR_texture_basisu'])];
|
|
405
|
+
const bytes = glbBytes(json, bin, swap);
|
|
406
|
+
const out = outPath(served, bytes, 'glb');
|
|
407
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
408
|
+
writeFileSync(out, bytes);
|
|
409
|
+
cache[key] = pub(out);
|
|
410
|
+
encoded++;
|
|
411
|
+
return pub(out);
|
|
412
|
+
}
|
|
413
|
+
await runPool(glbJobs.map(([tier, served, file]) => async () => {
|
|
414
|
+
if (!only(served)) return;
|
|
415
|
+
let p = glbDone.get(file);
|
|
416
|
+
if (!p) { p = glbOut(file, served); glbDone.set(file, p); }
|
|
417
|
+
const out = await p;
|
|
418
|
+
if (out) { map[tier][served] = out; bytesIn += statSync(file).size; }
|
|
419
|
+
}));
|
|
420
|
+
|
|
421
|
+
// .gltf: the same JSON with each image pointing at the tier's KTX2 of the file the tier would have loaded (relative to
|
|
422
|
+
// the ORIGINAL .gltf's folder: GLTFLoader resolves resources against the URL it was asked for, before the URL modifier)
|
|
423
|
+
for (const [tier, served, file] of gltfJobs) {
|
|
424
|
+
if (!only(served)) continue;
|
|
425
|
+
const json = JSON.parse(readFileSync(file, 'utf8'));
|
|
426
|
+
if (!(json.images?.length > 0)) continue;
|
|
427
|
+
const dir = dirname(file);
|
|
428
|
+
let ok = true;
|
|
429
|
+
for (const img of json.images) {
|
|
430
|
+
if (!img.uri) { ok = false; break; }
|
|
431
|
+
const f = join(dir, decodeURI(img.uri));
|
|
432
|
+
const tierFile = tier === 'phone' ? (phoneCopyOf(f) ?? f) : f;
|
|
433
|
+
const k = map[tier][pub(tierFile)];
|
|
434
|
+
if (!k) { ok = false; break; }
|
|
435
|
+
img.uri = relative(dir, abs(k)).split('\\').join('/');
|
|
436
|
+
img.mimeType = 'image/ktx2';
|
|
437
|
+
}
|
|
438
|
+
if (!ok) { skipped.push(`${served} (${tier}: a texture has no KTX2)`); continue; }
|
|
439
|
+
for (const t of json.textures ?? []) { if (t.source === undefined) continue; t.extensions = { ...t.extensions, KHR_texture_basisu: { source: t.source } }; delete t.source; }
|
|
440
|
+
for (const k of ['extensionsUsed', 'extensionsRequired']) json[k] = [...new Set([...(json[k] ?? []), 'KHR_texture_basisu'])];
|
|
441
|
+
const bytes = Buffer.from(JSON.stringify(json));
|
|
442
|
+
if (DRY) {
|
|
443
|
+
const out = outPath(served.replace(/\.gltf$/, `.${tier}.gltf`), bytes, 'gltf');
|
|
444
|
+
if (CHECK && !existsSync(out)) staleSource(served);
|
|
445
|
+
map[tier][served] = existsSync(out) ? pub(out) : `(new) ${served}`; continue;
|
|
446
|
+
}
|
|
447
|
+
const out = outPath(served.replace(/\.gltf$/, `.${tier}.gltf`), bytes, 'gltf');
|
|
448
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
449
|
+
if (!existsSync(out)) writeFileSync(out, bytes);
|
|
450
|
+
map[tier][served] = pub(out);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// G187 cuts 2 + 3: the coats and the viewmodel sets (their own scripts own their encode; this table and the pruning below keep them)
|
|
454
|
+
for (const baked of BAKED) for (const tier of ['phone', 'desktop']) if (TIERS.has(tier)) for (const [served, out] of Object.entries(baked[tier] ?? {})) {
|
|
455
|
+
if (!existsSync(abs(out))) { if (CHECK) staleSource(served); continue; }
|
|
456
|
+
map[tier][served] = out;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ── outputs ──
|
|
460
|
+
let stale = 0;
|
|
461
|
+
if (!DRY && ONLY === '') {
|
|
462
|
+
// drop the cache entries nothing asked for, and every file under /assets/gpu no mapping names
|
|
463
|
+
for (const k of Object.keys(cache)) if (!usedKeys.has(k)) delete cache[k];
|
|
464
|
+
const live = new Set([...Object.values(map.phone), ...Object.values(map.desktop)]);
|
|
465
|
+
for (const f of walk(OUT)) if (!live.has(pub(f))) { rmSync(f); stale++; }
|
|
466
|
+
}
|
|
467
|
+
if (!DRY) {
|
|
468
|
+
writeFileSync(CACHE_FILE, `${JSON.stringify(cache, null, 1)}\n`);
|
|
469
|
+
if (ONLY === '') {
|
|
470
|
+
writeKtx2Tables(ROOT, map, SHARDS);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
for (const f of new Set(Object.values(map.phone).concat(Object.values(map.desktop)))) if (!f.startsWith('(new)') && existsSync(abs(f))) bytesOut += statSync(abs(f)).size;
|
|
474
|
+
rmSync(TMP, { recursive: true, force: true });
|
|
475
|
+
console.log(`bake-ktx2: ${encoded} encoded, ${reused} reused, ${stale} stale removed · phone ${Object.keys(map.phone).length} + desktop ${Object.keys(map.desktop).length} mapped · ${(bytesOut / 1048576).toFixed(1)} MB of KTX2 (the files they stand in for: ${(bytesIn / 1048576).toFixed(1)} MB, counted per tier)`);
|
|
476
|
+
if (skipped.length > 0) console.log(` not baked (${skipped.length}):\n ${skipped.slice(0, 40).join('\n ')}${skipped.length > 40 ? '\n …' : ''}`);
|
|
477
|
+
if (CHECK && missing.size > 0) { console.log(`bake-ktx2: tools node ${process.version}; basisu ${ENCODER}; ${execFileSync('magick', ['-version']).toString().split('\n')[0]}`); process.exitCode = 1; }
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// G320 / SF87 (a): bake an authored-GLB shard's map from its own world GLB in Node, with no game page and no browser. A
|
|
3
|
+
// shard whose look/map.json names `"from": "<its world GLB>"` (the Blender Template: assets/world.glb, SF55a's input) is
|
|
4
|
+
// baked here instead of scripts/bake-maps.mjs's served-build capture. The GLB's triangles are rasterized straight down in
|
|
5
|
+
// the minimap's frame (north +Z up the image, east −X right, 0.25 m a pixel over the 500 m cell): the colour pass is each
|
|
6
|
+
// material's base colour times its vertex colours (sRGB, a fixed top light so walls read darker than floors), the height
|
|
7
|
+
// pass the highest surface in each pixel, encoded as bake-maps.mjs encodes it ((y + 100) / 400 over 16 bits in R, G; B = 1
|
|
8
|
+
// where anything is). scripts/map-stylize.py then applies the shard's own colour table, and the stamp is written as
|
|
9
|
+
// bake-maps.mjs writes it. Deterministic: the same GLB and map.json give the same bytes.
|
|
10
|
+
// node scripts/bake-map-glb.mjs [--shards=a,b] [--all] [--keep=<dir>]
|
|
11
|
+
// (the stylizer runs under `uv run` with numpy, scipy and pillow, as bake-maps.mjs runs it)
|
|
12
|
+
import { execFileSync } from 'node:child_process';
|
|
13
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { tmpdir } from 'node:os';
|
|
15
|
+
import { join, resolve } from 'node:path';
|
|
16
|
+
import { NodeIO } from '@gltf-transform/core';
|
|
17
|
+
import { MAP_METRES, mapPixelHash, mapSettings, mapSettingsPath, mapStampPath, mapShards, mapTilesHash, writeMapStamp } from '@wildshard/engine/scripts/map-hash.mjs';
|
|
18
|
+
|
|
19
|
+
const SIDE = 2000, OUT = 1000, PPM = SIDE / MAP_METRES, BG = [0.16, 0.18, 0.2];
|
|
20
|
+
const option = (name) => process.argv.find((part) => part.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
21
|
+
|
|
22
|
+
/** Linear [0, 1] to an sRGB byte. @param {number} v */
|
|
23
|
+
const srgb = (v) => Math.round(255 * Math.min(1, Math.max(0, v <= 0.0031308 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055)));
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Rasterize a GLB's every triangle top-down into a colour pass and a height pass (binary PPM bytes, SIDE × SIDE).
|
|
27
|
+
* @param {string} glbPath @param {{clipBelow: number | null, clipAbove: number | null}} clip
|
|
28
|
+
* @returns {Promise<{colour: Buffer, height: Buffer, triangles: number}>}
|
|
29
|
+
*/
|
|
30
|
+
export async function rasterizeGlb(glbPath, clip) {
|
|
31
|
+
const doc = await new NodeIO().read(glbPath);
|
|
32
|
+
const top = new Float64Array(SIDE * SIDE).fill(-Infinity), rgb = new Float32Array(SIDE * SIDE * 3);
|
|
33
|
+
const lo = clip.clipBelow ?? -Infinity, hi = clip.clipAbove ?? Infinity;
|
|
34
|
+
let triangles = 0;
|
|
35
|
+
const p = [0, 0, 0], c = [1, 1, 1, 1];
|
|
36
|
+
for (const node of doc.getRoot().listNodes()) {
|
|
37
|
+
const mesh = node.getMesh();
|
|
38
|
+
if (mesh === null) continue;
|
|
39
|
+
const m = node.getWorldMatrix();
|
|
40
|
+
for (const prim of mesh.listPrimitives()) {
|
|
41
|
+
if (prim.getMode() !== 4) continue; // triangles only
|
|
42
|
+
const position = prim.getAttribute('POSITION'), colour = prim.getAttribute('COLOR_0'), indices = prim.getIndices();
|
|
43
|
+
if (position === null) continue;
|
|
44
|
+
const base = prim.getMaterial()?.getBaseColorFactor() ?? [1, 1, 1, 1];
|
|
45
|
+
const count = position.getCount(), world = new Float64Array(count * 3), albedo = new Float32Array(count * 3);
|
|
46
|
+
for (let i = 0; i < count; i++) {
|
|
47
|
+
position.getElement(i, p);
|
|
48
|
+
world[i * 3] = m[0] * p[0] + m[4] * p[1] + m[8] * p[2] + m[12];
|
|
49
|
+
world[i * 3 + 1] = m[1] * p[0] + m[5] * p[1] + m[9] * p[2] + m[13];
|
|
50
|
+
world[i * 3 + 2] = m[2] * p[0] + m[6] * p[1] + m[10] * p[2] + m[14];
|
|
51
|
+
if (colour !== null) colour.getElement(i, c); else c[0] = c[1] = c[2] = 1;
|
|
52
|
+
for (let k = 0; k < 3; k++) albedo[i * 3 + k] = base[k] * c[k];
|
|
53
|
+
}
|
|
54
|
+
const n = indices === null ? count : indices.getCount();
|
|
55
|
+
for (let t = 0; t + 2 < n; t += 3) {
|
|
56
|
+
const v = [0, 1, 2].map((k) => (indices === null ? t + k : indices.getScalar(t + k)));
|
|
57
|
+
const [a, b, d] = v.map((i) => [world[i * 3], world[i * 3 + 1], world[i * 3 + 2]]);
|
|
58
|
+
triangles++;
|
|
59
|
+
// the face's light: straight-down floors full, walls darker (a fixed top light, no shard look involved)
|
|
60
|
+
const ux = b[0] - a[0], uy = b[1] - a[1], uz = b[2] - a[2], wx = d[0] - a[0], wy = d[1] - a[1], wz = d[2] - a[2];
|
|
61
|
+
const nx = uy * wz - uz * wy, ny = uz * wx - ux * wz, nz = ux * wy - uy * wx, len = Math.hypot(nx, ny, nz);
|
|
62
|
+
if (len === 0) continue;
|
|
63
|
+
const light = 0.55 + 0.45 * Math.abs(ny / len);
|
|
64
|
+
// pixel space: column from +X (left) toward −X, row from +Z (top) toward −Z
|
|
65
|
+
const px = [a, b, d].map((q) => (MAP_METRES / 2 - q[0]) * PPM), py = [a, b, d].map((q) => (MAP_METRES / 2 - q[2]) * PPM);
|
|
66
|
+
const area = (px[1] - px[0]) * (py[2] - py[0]) - (px[2] - px[0]) * (py[1] - py[0]);
|
|
67
|
+
if (area === 0) continue;
|
|
68
|
+
const x0 = Math.max(0, Math.floor(Math.min(...px))), x1 = Math.min(SIDE - 1, Math.ceil(Math.max(...px)));
|
|
69
|
+
const y0 = Math.max(0, Math.floor(Math.min(...py))), y1 = Math.min(SIDE - 1, Math.ceil(Math.max(...py)));
|
|
70
|
+
for (let y = y0; y <= y1; y++) for (let x = x0; x <= x1; x++) {
|
|
71
|
+
const sx = x + 0.5, sy = y + 0.5;
|
|
72
|
+
const w0 = ((px[1] - sx) * (py[2] - sy) - (px[2] - sx) * (py[1] - sy)) / area;
|
|
73
|
+
const w1 = ((px[2] - sx) * (py[0] - sy) - (px[0] - sx) * (py[2] - sy)) / area;
|
|
74
|
+
const w2 = 1 - w0 - w1;
|
|
75
|
+
if (w0 < 0 || w1 < 0 || w2 < 0) continue;
|
|
76
|
+
const h = w0 * a[1] + w1 * b[1] + w2 * d[1];
|
|
77
|
+
const at = y * SIDE + x;
|
|
78
|
+
if (h < lo || h > hi || h <= top[at]) continue;
|
|
79
|
+
top[at] = h;
|
|
80
|
+
for (let k = 0; k < 3; k++) rgb[at * 3 + k] = light * (w0 * albedo[v[0] * 3 + k] + w1 * albedo[v[1] * 3 + k] + w2 * albedo[v[2] * 3 + k]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const header = Buffer.from(`P6\n${SIDE} ${SIDE}\n255\n`, 'ascii');
|
|
86
|
+
const colour = Buffer.alloc(SIDE * SIDE * 3), height = Buffer.alloc(SIDE * SIDE * 3);
|
|
87
|
+
for (let at = 0; at < SIDE * SIDE; at++) {
|
|
88
|
+
if (top[at] === -Infinity) { for (let k = 0; k < 3; k++) colour[at * 3 + k] = srgb(BG[k]); continue; }
|
|
89
|
+
for (let k = 0; k < 3; k++) colour[at * 3 + k] = srgb(rgb[at * 3 + k]);
|
|
90
|
+
const e = Math.floor(Math.min(1, Math.max(0, (top[at] + 100) / 400)) * 65535);
|
|
91
|
+
height[at * 3] = Math.floor(e / 256); height[at * 3 + 1] = e % 256; height[at * 3 + 2] = 255;
|
|
92
|
+
}
|
|
93
|
+
return { colour: Buffer.concat([header, colour]), height: Buffer.concat([header, height]), triangles };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
97
|
+
const root = resolve(import.meta.dirname, '..');
|
|
98
|
+
const only = option('shards')?.split(','), keep = option('keep');
|
|
99
|
+
const stampPath = mapStampPath;
|
|
100
|
+
const todo = mapShards(root).filter(({ slug, dir }) => {
|
|
101
|
+
if (JSON.parse(readFileSync(mapSettingsPath(dir), 'utf8')).painter !== undefined) return false;
|
|
102
|
+
if (mapSettings(dir).from === null) return false;
|
|
103
|
+
if (only) return only.includes(slug);
|
|
104
|
+
if (process.argv.includes('--all') || !existsSync(stampPath(dir))) return true;
|
|
105
|
+
const stamp = JSON.parse(readFileSync(stampPath(dir), 'utf8'));
|
|
106
|
+
return stamp.tilesHash !== mapTilesHash(dir) || typeof stamp.pixelHash !== 'string';
|
|
107
|
+
});
|
|
108
|
+
if (todo.length === 0) { console.log('bake-map-glb: every GLB-baked map is current'); process.exit(0); }
|
|
109
|
+
const work = keep ?? mkdtempSync(join(tmpdir(), 'bake-map-glb-'));
|
|
110
|
+
mkdirSync(work, { recursive: true });
|
|
111
|
+
try {
|
|
112
|
+
for (const { slug, dir } of todo) {
|
|
113
|
+
const settings = mapSettings(dir);
|
|
114
|
+
if (settings.style === null || settings.from === null) throw new Error(`${slug}: look/map.json needs "style" and "from"`);
|
|
115
|
+
const out = await rasterizeGlb(join(dir, settings.from), settings);
|
|
116
|
+
const colourPath = join(work, `colour-${slug}.ppm`), heightPath = join(work, `height-${slug}.ppm`), stylePath = join(work, `style-${slug}.json`);
|
|
117
|
+
writeFileSync(colourPath, out.colour); writeFileSync(heightPath, out.height); writeFileSync(stylePath, JSON.stringify(settings.style));
|
|
118
|
+
const imageDir = join(root, 'public/assets', slug, 'map'), webp = join(imageDir, 'top.webp');
|
|
119
|
+
mkdirSync(imageDir, { recursive: true });
|
|
120
|
+
execFileSync('uv', ['run', '--quiet', '--with', 'numpy', '--with', 'scipy', '--with', 'pillow', 'python', join(root, 'scripts/map-stylize.py'), colourPath, heightPath, stylePath, webp, String(OUT)], { stdio: 'inherit' });
|
|
121
|
+
const bytes = statSync(webp).size;
|
|
122
|
+
const stamp = { version: 1, tilesHash: mapTilesHash(dir), pixelHash: await mapPixelHash(webp), image: `/assets/${slug}/map/top.webp`, size: OUT, metres: MAP_METRES, north: '+z', east: '-x', style: `stylized:${settings.style.kind}`, bytes };
|
|
123
|
+
await writeMapStamp(dir, webp, stamp);
|
|
124
|
+
console.log(`bake-map-glb: ${slug} from ${settings.from}, ${out.triangles} triangles, ${OUT}px ${(bytes / 1024).toFixed(0)} KB`);
|
|
125
|
+
}
|
|
126
|
+
} finally { if (keep === undefined) rmSync(work, { recursive: true, force: true }); }
|
|
127
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClientChannelProgram } from '@wildshard/format/clientChannels';
|
|
2
|
+
import type { MoverPose } from '@wildshard/engine/physics/mover';
|
|
3
|
+
|
|
4
|
+
export function mapRest(scene: { nodes: readonly { id: string; instances?: number }[] }, programs: readonly ClientChannelProgram[], poses: readonly (MoverPose & { id: string })[]): {
|
|
5
|
+
version: number;
|
|
6
|
+
nodes: Record<string, { position: number[]; quaternion: number[]; scale: number[]; visible: boolean; matrices?: number[] }>;
|
|
7
|
+
};
|