@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,279 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-astc6.mjs — Pine Hollow's phone textures as ASTC 6×6 (G180 B2, Jake E450: "ASTC 6×6 instead of 4×4"), the
|
|
3
|
+
// Pine memory trim's texture cut. 6×6 is 16/36 of 4×4's GPU bytes (3.56 bits a texel instead of 8).
|
|
4
|
+
//
|
|
5
|
+
// What: every UASTC (4×4) KTX2 a phone boot of Pine Hollow fetches (scripts/bake-astc6.list.json: the /assets/gpu URLs
|
|
6
|
+
// one boot fetched, recorded with --record), re-encoded from the same source bake-ktx2.mjs used, at the 4×4 file's own
|
|
7
|
+
// size, as standard ASTC LDR 6×6 (basisu -ldr_6x6, Zstandard-supercompressed). The ETC1S data planes (ARM / ORM: ETC2 on
|
|
8
|
+
// the phone, ½ byte a texel, already below 6×6's 0.89) stay as they are. GLBs keep their geometry bytes: their colour /
|
|
9
|
+
// normal images become 6×6, their data images ETC1S as before. A .gltf prop is rewritten to point at its 6×6 textures.
|
|
10
|
+
//
|
|
11
|
+
// The files are raw ASTC, not Basis: they are sampled only where the GPU has ASTC (the phone tier: every iPhone; three's
|
|
12
|
+
// KTX2Loader uploads them as RGBA_ASTC_6x6 without a transcode). The desktop keeps bake-ktx2's set.
|
|
13
|
+
//
|
|
14
|
+
// Output: public/assets/pine-hollow/astc6/<the 4×4 file's path under /assets/gpu>-<sha256[:8]>.{ktx2,glb,gltf} (Pine's own
|
|
15
|
+
// folder, outside /assets/gpu, which bake-ktx2.mjs owns and prunes) and src/shards/pine-hollow/data/astc6.generated.json:
|
|
16
|
+
// served URL → 6×6 stand-in, the overlay src/shards/pine-hollow/runtime/boot/gpuTable.ts lays over the phone table when the trim
|
|
17
|
+
// is on. Content-addressed and cached (scripts/bake-astc6.cache.json): a rerun encodes only what changed.
|
|
18
|
+
//
|
|
19
|
+
// node --import ./scripts/bake-loader.mjs scripts/bake-astc6.mjs [--shard=<slug>] [--jobs=6] [--force]
|
|
20
|
+
//
|
|
21
|
+
// S4 on (SHARD-SIZE-PLAN): another shard's phone set the same way. --shard names a row of SHARDS: its overlay goes to
|
|
22
|
+
// public/assets/<folder>/astc6/, which its programs read as the table, its list is every UASTC file of its own
|
|
23
|
+
// phone table, and its cache is its own. With no --shard this is Pine's bake, unchanged.
|
|
24
|
+
import { createHash } from 'node:crypto';
|
|
25
|
+
import { execFileSync, spawn } from 'node:child_process';
|
|
26
|
+
import { once } from 'node:events';
|
|
27
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
28
|
+
import { tmpdir } from 'node:os';
|
|
29
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
30
|
+
import { glbBytes, imageBytes, readGlb } from './astc6-phone-cap.mjs';
|
|
31
|
+
|
|
32
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
33
|
+
const PUB = resolve(ROOT, 'public');
|
|
34
|
+
const argv = process.argv.slice(2);
|
|
35
|
+
const flag = (n, d) => { const a = argv.find((x) => x.startsWith(`--${n}=`)); return a ? a.slice(n.length + 3) : d; };
|
|
36
|
+
/** The shards with a phone overlay. `noFlip`: paths written in glTF orientation (a coat is a hull's own map). */
|
|
37
|
+
const SHARDS = {
|
|
38
|
+
'pine-hollow': { folder: 'pine-hollow', list: true, cap: true, noFlip: [] },
|
|
39
|
+
'nalati-grasslands': { folder: 'nalati', list: false, cap: false, atlases: true, noFlip: ['/models/coats/'] },
|
|
40
|
+
// Sky's rigs stay: each row names a product file (generators/rigAssetSources.ts).
|
|
41
|
+
'far-reach': { folder: 'far-reach', list: false, cap: false, glbs: true, skip: /\/rigs\//, noFlip: [] },
|
|
42
|
+
};
|
|
43
|
+
const SLUG = flag('shard', 'pine-hollow'), SHARD = SHARDS[SLUG];
|
|
44
|
+
if (SHARD === undefined) throw new Error(`bake-astc6: no overlay row for ${SLUG}`);
|
|
45
|
+
const OUT = resolve(PUB, `assets/${SHARD.folder}/astc6`);
|
|
46
|
+
const LIST_FILE = resolve(ROOT, 'scripts/bake-astc6.list.json');
|
|
47
|
+
const CACHE_FILE = resolve(ROOT, SLUG === 'pine-hollow' ? 'scripts/bake-astc6.cache.json' : `scripts/bake-astc6.${SLUG}.cache.json`);
|
|
48
|
+
const TABLE_FILE = resolve(ROOT, `src/shards/${SLUG}/data/astc6.generated.json`);
|
|
49
|
+
const JOBS = Number(flag('jobs', '6'));
|
|
50
|
+
const FORCE = argv.includes('--force');
|
|
51
|
+
|
|
52
|
+
async function execFile(cmd, args) {
|
|
53
|
+
const child = spawn(cmd, args, { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
54
|
+
let err = '';
|
|
55
|
+
child.stderr.on('data', (d) => { err += String(d); });
|
|
56
|
+
const [code] = await once(child, 'close');
|
|
57
|
+
if (code !== 0) throw new Error(`${cmd} exited ${code}: ${err.slice(-400)}`);
|
|
58
|
+
}
|
|
59
|
+
const sha = (buf) => createHash('sha256').update(buf).digest('hex');
|
|
60
|
+
const pub = (p) => `/${relative(PUB, p).split('\\').join('/')}`;
|
|
61
|
+
const abs = (p) => join(PUB, p);
|
|
62
|
+
const ENCODER = /v[\d.]+/.exec(execFileSync('basisu', ['-version']).toString())?.[0] ?? '?';
|
|
63
|
+
const COMMON = ['-ktx2', '-mipmap', '-mip_filter', 'box', '-max_threads', '2'];
|
|
64
|
+
/** bake-ktx2.mjs's classes, with 6×6 for the three UASTC ones (effort 4 of 10: one notch above basisu's default) */
|
|
65
|
+
const CLASS = {
|
|
66
|
+
color: ['-ldr_6x6', '-effort', '4', '-srgb'],
|
|
67
|
+
normal: ['-ldr_6x6', '-effort', '4', '-normal_map'],
|
|
68
|
+
linear: ['-ldr_6x6', '-effort', '4', '-linear'],
|
|
69
|
+
data: ['-etc1s', '-q', '255', '-linear'],
|
|
70
|
+
};
|
|
71
|
+
/** bake-ktx2.mjs classOf */
|
|
72
|
+
function classOf(name) {
|
|
73
|
+
const n = basename(name).toLowerCase();
|
|
74
|
+
if (/(^|[_\-.])(lm|clouds)[_\-.]/.test(n)) return 'linear';
|
|
75
|
+
if (/(^|[_\-.])(nor|nor_gl|normal|nrm)([_\-.]|$)/.test(n)) return 'normal';
|
|
76
|
+
if (/(^|[_\-.])(arm|orm|ao|rough|roughness|metal|metalness|metallic)([_\-.]|$)/.test(n)) return 'data';
|
|
77
|
+
return 'color';
|
|
78
|
+
}
|
|
79
|
+
/** a KTX2's header: size and supercompression (1 = BasisLZ, i.e. ETC1S) */
|
|
80
|
+
function ktx2Header(file) {
|
|
81
|
+
const b = readFileSync(file);
|
|
82
|
+
return { w: b.readUInt32LE(20), h: b.readUInt32LE(24), scheme: b.readUInt32LE(44), vk: b.readUInt32LE(12) };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ── the phone tables: served URL → 4×4 stand-in (the engine's and every shard's generated table) ──
|
|
86
|
+
function tableEntries(file) {
|
|
87
|
+
const src = readFileSync(resolve(ROOT, file), 'utf8');
|
|
88
|
+
const phone = src.slice(src.indexOf('"phone"'), src.indexOf('"desktop"'));
|
|
89
|
+
return [...phone.matchAll(/"([^"]+)":\s*"([^"]+)"/g)].map((m) => [m[1], m[2]]);
|
|
90
|
+
}
|
|
91
|
+
const tables = ['src/client/engine/boot/ktx2.generated.ts', ...readdirSync(resolve(ROOT, 'src/shards')).map((s) => `src/shards/${s}/ktx2.generated.ts`)].filter((f) => existsSync(resolve(ROOT, f)));
|
|
92
|
+
/** 4×4 stand-in → the served URLs it stands in for */
|
|
93
|
+
const servedOf = new Map();
|
|
94
|
+
for (const t of tables) for (const [served, gpu] of tableEntries(t)) { const l = servedOf.get(gpu) ?? []; l.push(served); servedOf.set(gpu, l); }
|
|
95
|
+
|
|
96
|
+
const fetched = SHARD.list ? JSON.parse(readFileSync(LIST_FILE, 'utf8')).phone
|
|
97
|
+
: [...new Set(tableEntries(`src/shards/${SLUG}/ktx2.generated.ts`).map(([, gpu]) => gpu).filter((url) => (SHARD.glbs === true ? /\.(?:ktx2|glb)$/u : /\.ktx2$/u).test(url) && SHARD.skip?.test(url) !== true))];
|
|
98
|
+
const cache = existsSync(CACHE_FILE) ? JSON.parse(readFileSync(CACHE_FILE, 'utf8')) : {};
|
|
99
|
+
const usedKeys = new Set();
|
|
100
|
+
const TMP = join(tmpdir(), `bake-astc6-${process.pid}`);
|
|
101
|
+
mkdirSync(TMP, { recursive: true });
|
|
102
|
+
let tmpN = 0, encoded = 0, reused = 0;
|
|
103
|
+
|
|
104
|
+
async function encode(srcFile, w, h, cls, flip) {
|
|
105
|
+
const id = ++tmpN;
|
|
106
|
+
const png = join(TMP, `${id}.png`), out = join(TMP, `${id}.ktx2`);
|
|
107
|
+
const [sw, sh] = execFileSync('magick', ['identify', '-format', '%w %h\n', `${srcFile}[0]`]).toString().trim().split(/\s+/).map(Number);
|
|
108
|
+
const alpha = execFileSync('magick', ['identify', '-format', '%[opaque]', `${srcFile}[0]`]).toString().trim().toLowerCase() === 'false';
|
|
109
|
+
const resize = sw === w && sh === h ? [] : alpha ? ['-separate', '-resize', `${w}x${h}!`, '-combine'] : ['-resize', `${w}x${h}!`];
|
|
110
|
+
await execFile('magick', [`${srcFile}[0]`, ...resize, '-strip', `PNG32:${png}`]);
|
|
111
|
+
await execFile('basisu', [...COMMON, ...CLASS[cls], ...(flip ? ['-y_flip'] : []), png, '-output_file', out]);
|
|
112
|
+
const bytes = readFileSync(out);
|
|
113
|
+
rmSync(png); rmSync(out);
|
|
114
|
+
return bytes;
|
|
115
|
+
}
|
|
116
|
+
function writeOut(gpuUrl, bytes, ext) {
|
|
117
|
+
const rel = gpuUrl.replace(/^\/assets\/gpu\//, '');
|
|
118
|
+
const stem = basename(rel).replace(/-[0-9a-f]{8}\.(ktx2|glb|gltf)$/, '');
|
|
119
|
+
const out = join(OUT, dirname(rel), `${stem}-${sha(bytes).slice(0, 8)}.${ext}`);
|
|
120
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
121
|
+
writeFileSync(out, bytes);
|
|
122
|
+
return pub(out);
|
|
123
|
+
}
|
|
124
|
+
/** bake-ktx2.mjs addImage's best source for a served image: the full-res original of a `_1k` / phone copy */
|
|
125
|
+
function sourceOf(served) {
|
|
126
|
+
const file = abs(served.replace(/#layer$/, ''));
|
|
127
|
+
if (file.endsWith('_1k.jpg') && existsSync(file.replace(/_1k\.jpg$/, '.jpg'))) return file.replace(/_1k\.jpg$/, '.jpg');
|
|
128
|
+
const m = /^(.*)(\.phone|-phone)\.webp$/.exec(file);
|
|
129
|
+
if (m) for (const ext of ['.png', '.jpg', '.jpeg', '.webp']) if (existsSync(`${m[1]}${ext}`)) return `${m[1]}${ext}`;
|
|
130
|
+
return file;
|
|
131
|
+
}
|
|
132
|
+
/** standalone images are Y-flipped at encode; glTF textures, layer twins and Driftwood's lightmaps are not (bake-ktx2.mjs) */
|
|
133
|
+
const NO_FLIP = ['/textures/', '/driftwood-blender/', ...SHARD.noFlip];
|
|
134
|
+
const flipOf = (served) => !served.endsWith('#layer') && !NO_FLIP.some((part) => served.includes(part));
|
|
135
|
+
|
|
136
|
+
const map = {};
|
|
137
|
+
async function cached(key, make) {
|
|
138
|
+
usedKeys.add(key);
|
|
139
|
+
const hit = cache[key];
|
|
140
|
+
if (!FORCE && hit && (hit === 'none' || existsSync(abs(hit)))) { reused++; return hit === 'none' ? null : hit; }
|
|
141
|
+
const out = await make();
|
|
142
|
+
cache[key] = out ?? 'none';
|
|
143
|
+
if (out) encoded++;
|
|
144
|
+
return out;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ── GLB helpers (bake-ktx2.mjs imageClasses, unchanged; readGlb / glbBytes live in astc6-phone-cap.mjs) ──
|
|
148
|
+
function imageClasses(json) {
|
|
149
|
+
const texSource = (t) => { const x = json.textures?.[t]; return x?.source ?? x?.extensions?.EXT_texture_webp?.source ?? x?.extensions?.KHR_texture_basisu?.source; };
|
|
150
|
+
const rank = { data: 0, linear: 1, normal: 2, color: 3 };
|
|
151
|
+
const out = new Map();
|
|
152
|
+
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); };
|
|
153
|
+
for (const m of json.materials ?? []) {
|
|
154
|
+
const p = m.pbrMetallicRoughness ?? {};
|
|
155
|
+
note(p.baseColorTexture, 'color'); note(m.emissiveTexture, 'color');
|
|
156
|
+
note(m.normalTexture, 'normal');
|
|
157
|
+
note(p.metallicRoughnessTexture, 'data'); note(m.occlusionTexture, 'data');
|
|
158
|
+
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');
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
/** the GLB's embedded images re-encoded (colour / normal / linear → 6×6, data → ETC1S), at each 4×4 image's own size */
|
|
163
|
+
async function glbOut(src, gpuUrl) {
|
|
164
|
+
const { json, bin } = readGlb(src);
|
|
165
|
+
if (!(json.images?.length > 0)) return null;
|
|
166
|
+
const four = readGlb(abs(gpuUrl));
|
|
167
|
+
const classes = imageClasses(json);
|
|
168
|
+
const swap = new Map();
|
|
169
|
+
for (const [i, img] of json.images.entries()) {
|
|
170
|
+
const tmp = join(TMP, `glb-${++tmpN}.${(img.mimeType ?? 'image/png').split('/')[1]}`);
|
|
171
|
+
writeFileSync(tmp, imageBytes(json, bin, img.bufferView));
|
|
172
|
+
const fourImg = four.json.images[i];
|
|
173
|
+
const k4 = join(TMP, `glb4-${tmpN}.ktx2`);
|
|
174
|
+
writeFileSync(k4, imageBytes(four.json, four.bin, fourImg.bufferView));
|
|
175
|
+
const { w, h } = ktx2Header(k4);
|
|
176
|
+
rmSync(k4);
|
|
177
|
+
swap.set(img.bufferView, await encode(tmp, w, h, classes.get(i) ?? 'color', false));
|
|
178
|
+
rmSync(tmp);
|
|
179
|
+
img.mimeType = 'image/ktx2';
|
|
180
|
+
}
|
|
181
|
+
for (const t of json.textures ?? []) {
|
|
182
|
+
const s = t.source ?? t.extensions?.EXT_texture_webp?.source;
|
|
183
|
+
if (s === undefined) continue;
|
|
184
|
+
const ext = { ...t.extensions }; delete ext.EXT_texture_webp;
|
|
185
|
+
t.extensions = { ...ext, KHR_texture_basisu: { source: s } };
|
|
186
|
+
delete t.source;
|
|
187
|
+
}
|
|
188
|
+
for (const k of ['extensionsUsed', 'extensionsRequired']) json[k] = [...new Set([...(json[k] ?? []).filter((e) => e !== 'EXT_texture_webp'), 'KHR_texture_basisu'])];
|
|
189
|
+
return writeOut(gpuUrl, glbBytes(json, bin, swap), 'glb');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ── the jobs ──
|
|
193
|
+
const imageTasks = [], glbTasks = [], gltfJobs = [];
|
|
194
|
+
for (const gpuUrl of fetched) {
|
|
195
|
+
const served = servedOf.get(gpuUrl);
|
|
196
|
+
if (!served || !existsSync(abs(gpuUrl))) { console.log(`bake-astc6: skip ${gpuUrl} (no table entry / file)`); continue; }
|
|
197
|
+
if (gpuUrl.endsWith('.ktx2')) {
|
|
198
|
+
const { w, h, scheme } = ktx2Header(abs(gpuUrl));
|
|
199
|
+
if (scheme === 1) continue; // ETC1S: stays
|
|
200
|
+
const s = served[0], cls = classOf(s.replace(/#layer$/, '')), flip = flipOf(s), src = sourceOf(s);
|
|
201
|
+
imageTasks.push(async () => {
|
|
202
|
+
const key = sha(`${sha(readFileSync(src))}|${w}x${h}|${cls}|${flip ? 'flip' : ''}|${ENCODER}|${[...COMMON, ...CLASS[cls]].join(' ')}`);
|
|
203
|
+
const out = await cached(key, async () => writeOut(gpuUrl, await encode(src, w, h, cls, flip), 'ktx2'));
|
|
204
|
+
if (out) for (const x of served) map[x] = out;
|
|
205
|
+
});
|
|
206
|
+
} else if (gpuUrl.endsWith('.glb')) {
|
|
207
|
+
const s = served[0], src = abs(s);
|
|
208
|
+
glbTasks.push(async () => {
|
|
209
|
+
const key = sha(`${sha(readFileSync(src))}|${sha(readFileSync(abs(gpuUrl)))}|glb6|${ENCODER}|${JSON.stringify(CLASS)}|${COMMON.join(' ')}`);
|
|
210
|
+
const out = await cached(key, () => glbOut(src, gpuUrl));
|
|
211
|
+
if (out) for (const x of served) map[x] = out;
|
|
212
|
+
});
|
|
213
|
+
} else if (gpuUrl.endsWith('.gltf')) gltfJobs.push([served, gpuUrl]);
|
|
214
|
+
}
|
|
215
|
+
async function runPool(tasks) {
|
|
216
|
+
let i = 0;
|
|
217
|
+
const worker = async () => { while (i < tasks.length) { const t = tasks[i++]; await t(); } };
|
|
218
|
+
await Promise.all(Array.from({ length: Math.max(1, JOBS) }, worker));
|
|
219
|
+
}
|
|
220
|
+
console.log(`bake-astc6: ${ENCODER} · ${imageTasks.length} images · ${glbTasks.length} GLBs · ${gltfJobs.length} glTFs`);
|
|
221
|
+
await runPool([...glbTasks, ...imageTasks]);
|
|
222
|
+
|
|
223
|
+
// .gltf: the 4×4 .gltf with each image that has a 6×6 twin pointed at it (relative to the ORIGINAL .gltf's folder, as
|
|
224
|
+
// bake-ktx2.mjs writes them: GLTFLoader resolves against the URL it was asked for)
|
|
225
|
+
for (const [served, gpuUrl] of gltfJobs) {
|
|
226
|
+
const json = JSON.parse(readFileSync(abs(gpuUrl), 'utf8'));
|
|
227
|
+
const dir = dirname(abs(served[0]));
|
|
228
|
+
let changed = false;
|
|
229
|
+
for (const img of json.images ?? []) {
|
|
230
|
+
const k4 = pub(resolve(dir, decodeURI(img.uri)));
|
|
231
|
+
const servedImg = servedOf.get(k4)?.[0];
|
|
232
|
+
const six = servedImg === undefined ? undefined : map[servedImg];
|
|
233
|
+
if (six === undefined) continue;
|
|
234
|
+
img.uri = relative(dir, abs(six)).split('\\').join('/');
|
|
235
|
+
changed = true;
|
|
236
|
+
}
|
|
237
|
+
if (!changed) continue;
|
|
238
|
+
const out = writeOut(gpuUrl, Buffer.from(JSON.stringify(json)), 'gltf');
|
|
239
|
+
for (const x of served) map[x] = out;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ── Nalati's painted atlases: the phone's 512² RGBA stays a phone file, as UASTC with its mip chain. Not raw 6×6: an atlas
|
|
243
|
+
// is a product blob with no image route, so a phone-tier GPU with no ASTC must still transcode it. ──
|
|
244
|
+
const atlasFiles = [];
|
|
245
|
+
if (SHARD.atlases) {
|
|
246
|
+
const atlasOut = join(OUT, 'atlas'), models = join(PUB, 'assets/nalati/models');
|
|
247
|
+
mkdirSync(atlasOut, { recursive: true });
|
|
248
|
+
await runPool(readdirSync(models).filter((name) => name.endsWith('.phone.glb')).sort().map((name) => async () => {
|
|
249
|
+
const { json, bin } = readGlb(readFileSync(join(models, name)));
|
|
250
|
+
if (!(json.images?.length === 1)) return;
|
|
251
|
+
const stem = name.replace(/\.glb$/, ''), image = imageBytes(json, bin, json.images[0].bufferView), to = join(atlasOut, `${stem}.ktx2`);
|
|
252
|
+
atlasFiles.push(to);
|
|
253
|
+
const flags = ['-uastc', '-uastc_level', '2', '-srgb', '-ktx2_zstandard_level', '20'];
|
|
254
|
+
await cached(sha(`${sha(image)}|atlas|${ENCODER}|${[...COMMON, ...flags].join(' ')}`), async () => {
|
|
255
|
+
const webp = join(TMP, `${stem}.webp`), png = join(TMP, `${stem}.png`);
|
|
256
|
+
writeFileSync(webp, image);
|
|
257
|
+
await execFile('magick', [webp, '-strip', `PNG32:${png}`]);
|
|
258
|
+
await execFile('basisu', [...COMMON, ...flags, png, '-output_file', to]);
|
|
259
|
+
rmSync(webp); rmSync(png);
|
|
260
|
+
return pub(to);
|
|
261
|
+
});
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ── outputs: prune what nothing names, the cache and the overlay table ──
|
|
266
|
+
for (const k of Object.keys(cache)) if (!usedKeys.has(k)) delete cache[k];
|
|
267
|
+
const live = new Set([...Object.values(map), ...atlasFiles.map(pub)]);
|
|
268
|
+
const walk = (d, out = []) => { if (!existsSync(d)) return out; for (const n of readdirSync(d)) { const p = join(d, n); if (statSync(p).isDirectory()) walk(p, out); else out.push(p); } return out; };
|
|
269
|
+
let stale = 0;
|
|
270
|
+
for (const f of walk(OUT)) if (!live.has(pub(f))) { rmSync(f); stale++; }
|
|
271
|
+
writeFileSync(CACHE_FILE, `${JSON.stringify(cache, null, 1)}\n`);
|
|
272
|
+
const sorted = Object.fromEntries(Object.entries(map).sort(([a], [b]) => a.localeCompare(b)));
|
|
273
|
+
// Only Pine keeps a table in the source: another shard's programs read the overlay off these files (phoneOverlayRows).
|
|
274
|
+
if (SHARD.list) writeFileSync(TABLE_FILE, `${JSON.stringify(sorted, null, 2)}\n`);
|
|
275
|
+
rmSync(TMP, { recursive: true, force: true });
|
|
276
|
+
let six = 0; for (const f of live) six += statSync(abs(f)).size;
|
|
277
|
+
console.log(`bake-astc6: ${encoded} encoded, ${reused} reused, ${stale} stale removed · ${Object.keys(map).length} served URLs → ${live.size} files, ${(six / 1048576).toFixed(1)} MB`);
|
|
278
|
+
// S4: the phone's 512 sets are these files less their top mip; a later bake would otherwise bring the 1024s back.
|
|
279
|
+
if (SHARD.cap) execFileSync(process.execPath, [resolve(ROOT, 'scripts/astc6-phone-cap.mjs')], { stdio: 'inherit' });
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"aa05b5d03983b376b0d27f5ea807b044b7bb15c47dcbbeba7ccae9daa9d67ea2": "/assets/nalati/astc6/nalati/models/coats/horse-wild.horse.black.coat.phone-480f2ce6.ktx2",
|
|
3
|
+
"2d6f8313be20ceb28ba3fdecb8401d5bd4d9adb5aee567e64bd2c02db3b9df9e": "/assets/nalati/astc6/nalati/models/coats/horse-saddled.horse.camp-black.coat.phone-1de266e2.ktx2",
|
|
4
|
+
"712619e91ac12de3288d51f39f1728214f6588dd7a1843752fb0c0b178a92f9d": "/assets/nalati/astc6/nalati/models/coats/horse-wild.horse.bay.coat.phone-925dd340.ktx2",
|
|
5
|
+
"b20825f1fa29af2e7eb08053eaaec3e0fc30a22d2706bfe27e4ec87605859d1c": "/assets/nalati/astc6/nalati/models/coats/horse-wild.horse.chestnut.coat.phone-71169bd3.ktx2",
|
|
6
|
+
"039acd185f9212f2eee58cf2b2125e60e1fabaa2915fe9f4cec450c8c5d227e5": "/assets/nalati/astc6/nalati/models/coats/horse-wild.horse.foal-bay.coat.phone-47c36f1a.ktx2",
|
|
7
|
+
"15a188ec06d64789e917b4d5c94ff87a5581446a122e37f20fdac5c457e06326": "/assets/nalati/astc6/nalati/models/coats/horse-wild.horse.foal-chestnut.coat.phone-a7cd187d.ktx2",
|
|
8
|
+
"6227c434bc92bd8fe594d08a41070302c44c804e80502bef0d05cceca5389f68": "/assets/nalati/astc6/nalati/cards.phone-b3a5391d.ktx2",
|
|
9
|
+
"b14c1db0251ce0aee60e9157838d66fe52d738d6da33650211ee0d1ad4638d1c": "/assets/nalati/astc6/nalati/models/coats/horse-wild.horse.grey.coat.phone-419d6e30.ktx2",
|
|
10
|
+
"1ec9d1edf58b09d7f76dd2ef87a6d7d381e5fd0bf7f69fef117bafbe04cc4269": "/assets/nalati/astc6/nalati/models/coats/wolf.kokbori.kokbori.coat.phone-b83a8879.ktx2",
|
|
11
|
+
"06b0e1df86d7d977dd96a8e4e8d33ff430535041d214aeaf0d5fcf9c0137f94c": "/assets/nalati/astc6/nalati/models/coats/wolf.wolf.alpha.coat.phone-9269659a.ktx2",
|
|
12
|
+
"035d51a95821d4373553f09b0b51f07725a33eccfb3a84d364d798240d9328db": "/assets/nalati/astc6/nalati/models/coats/wolf.wolf.dark.coat.phone-50592dec.ktx2",
|
|
13
|
+
"202eea816b8b8a968b76b5309cd55f66e9a7aa5a74a83a6f2ec68e048237f1ae": "/assets/nalati/astc6/nalati/models/coats/wolf.wolf.scout.coat.phone-b85cd533.ktx2",
|
|
14
|
+
"64d355510c68c902397eb242552d1ce428ae7ed76b4c9e5725cf1acc0c058b12": "/assets/nalati/astc6/nalati/models/coats/wolf.wolf.tawny.coat.phone-9e6ddee6.ktx2",
|
|
15
|
+
"b3314a65f18b25341d92f52d1e9bd6d37b60f2473bb64650e19e613b5370dae2": "/assets/nalati/astc6/nalati/tex/felt.phone-ccce7627.ktx2",
|
|
16
|
+
"4882997aa781a65fbaac3ab6dccbe10a14d5d8dcabafb237495dfc5706a380e1": "/assets/nalati/astc6/nalati/tex/gravel.phone-baaa051d.ktx2",
|
|
17
|
+
"ae5ef69fc74f9f27202249e62ab1ad238bfb197749dfc6458f1940054ff0e110": "/assets/nalati/astc6/nalati/tex/meadow.phone-0e2bfeb5.ktx2",
|
|
18
|
+
"4c3cebb411f00da4c484aeae60f0e33da5181d7bd0cc02a6b452b46bad869cb1": "/assets/nalati/astc6/nalati/tex/path.phone-ccf054a0.ktx2",
|
|
19
|
+
"8122aaf99884e721a3ba28745db9a97062bedcb79485fe75072390b1e07b4bd2": "/assets/nalati/astc6/nalati/tex/rock.phone-4c17dbb2.ktx2",
|
|
20
|
+
"3b375ed20f0f35d58a6e48f2e8880483a083889350e7fc51d338eb01846a23a5": "/assets/nalati/astc6/nalati/tex/snow.phone-c93b3bcf.ktx2",
|
|
21
|
+
"f217dd50b97c76781f96f063852601d2b2165004f873641cb5a0a9abab3eea8e": "/assets/nalati/astc6/nalati/panorama.phone-c0d379fd.ktx2",
|
|
22
|
+
"48206827be33f4a5d8a56bbb9527f09658d2c7bacdd2949c4e12cedbcfac58dd": "/assets/nalati/astc6/atlas/boulder-1.phone.ktx2",
|
|
23
|
+
"691795f0705e3a59aa11d0c0582b200fc0632adf5ca47fea1bffd3f32837f982": "/assets/nalati/astc6/atlas/balbal.phone.ktx2",
|
|
24
|
+
"072d5a263b2e7109f0ce56cb7f4d1f5d09282f4bc3359833cd14d155cff6485d": "/assets/nalati/astc6/atlas/boulder-2.phone.ktx2",
|
|
25
|
+
"0eafbff613f4b4578861567f6919bf42e9fbd54e8db73adaecb14b134006c50e": "/assets/nalati/astc6/atlas/boulder-3.phone.ktx2",
|
|
26
|
+
"9e0623dea6db545357176257c4d9da7918daaeb192731fcf4dc4cb5da65bdd1d": "/assets/nalati/astc6/atlas/cauldron.phone.ktx2",
|
|
27
|
+
"a3654f78211bab4eaf2076f3dffe3e41b91894da04c7588e570b992ab35083ad": "/assets/nalati/astc6/atlas/chest.phone.ktx2",
|
|
28
|
+
"a40adebef9f1595b8d7b3f4045ae247813075db90b318225ffb185e2d9970ed1": "/assets/nalati/astc6/atlas/eagle.phone.ktx2",
|
|
29
|
+
"6407a969e48660e96d809b952484f370fa813daa5ec7c7dcccfd2f5bf1174386": "/assets/nalati/astc6/atlas/firewood.phone.ktx2",
|
|
30
|
+
"811dd94e47384cbbbec10d565fa2f29bfed00d9547abbeae200ca557af64ac27": "/assets/nalati/astc6/atlas/golden-king.phone.ktx2",
|
|
31
|
+
"e1e5923f7bd77934151d9c6c9f21d4758216cc81c89b696a574c950c3d1240e1": "/assets/nalati/astc6/atlas/horse-saddled.phone.ktx2",
|
|
32
|
+
"4650f34d8f6a6df8725eab55fd2f361b55be7797b736e060cc3f09baa3b8149e": "/assets/nalati/astc6/atlas/horse-wild.phone.ktx2",
|
|
33
|
+
"10c8ee494aef84691dcb630dc84488f1b98147f9ab5926bc191c0897cc09c762": "/assets/nalati/astc6/atlas/kokpar-rider.phone.ktx2",
|
|
34
|
+
"8ec568ff078ce662d908b992295ee9dcd80011cc264c532d910c8a7e1dd8c816": "/assets/nalati/astc6/atlas/kumis-churn.phone.ktx2",
|
|
35
|
+
"0e12b7751a26652de1d45061e1fa3f27d4aa1509284810c72b3b7567d6cda1a1": "/assets/nalati/astc6/atlas/saddle.phone.ktx2",
|
|
36
|
+
"4b5397d8a3ef50c8898b5d4de7c2b0a53bbc7ca76c0ab10fab4795212234f362": "/assets/nalati/astc6/atlas/snow-leopard.phone.ktx2",
|
|
37
|
+
"390245c6e3b1948a0fd71228997abfea66e59452c5554e625c08b846e70d7e95": "/assets/nalati/astc6/atlas/sheep.phone.ktx2",
|
|
38
|
+
"240e27cda99dd442517494fd4b30694dfb60dccfddfbfec40fcfb86ee9b68b2f": "/assets/nalati/astc6/atlas/snow-lotus.phone.ktx2",
|
|
39
|
+
"7366591917dd9113780ad61eda9f115ca5ff23ee6d725cd9d5307f6f9b69e4dd": "/assets/nalati/astc6/atlas/spruce.phone.ktx2",
|
|
40
|
+
"da7f63fd3a789ecf3b809abaa554f0071c6b6cfe46b65b2d478a0de5a5341fda": "/assets/nalati/astc6/atlas/watchtower.phone.ktx2",
|
|
41
|
+
"368d715fcb99fe420465f01b1d27a0bd46e6acc2effddc60fab24130745fe4ce": "/assets/nalati/astc6/atlas/wolf.phone.ktx2"
|
|
42
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// C3 (D7): put a shard on an already built client, with no rebuild: what a flip does at the next deploy until E7.
|
|
3
|
+
// node --import ./scripts/bake-loader.mjs scripts/bake-catalogue.mjs <dist> <shard.tar> <instance> <cellX> <cellY> [<packs folder> <packs origin>]
|
|
4
|
+
// With a packs folder the cook goes there for the store, and pages read it from that origin (J138); only the header stays.
|
|
5
|
+
// The tarball is cooked into <dist> and every table a page reads names it, title, spawn and server, in files the bundle doesn't hash. A deploy that
|
|
6
|
+
// takes its grid from api-server names that file with WILDSHARD_CATALOGUE at build time instead.
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { join, resolve } from 'node:path';
|
|
11
|
+
import { brotliCompressSync, constants } from 'node:zlib';
|
|
12
|
+
|
|
13
|
+
const { addCookedShards, productVerdict, writeCatalogueDocument } = await import('@wildshard/engine/scripts/app-build/catalogue.ts');
|
|
14
|
+
const { cookShard, openShardfile, servedAsIs } = await import('@wildshard/engine/game/shardCook');
|
|
15
|
+
const { writeServiceWorker } = await import('@wildshard/engine/scripts/app-build/serviceWorker.ts');
|
|
16
|
+
|
|
17
|
+
const [dist, tar, instance, x, y, packs, origin] = process.argv.slice(2);
|
|
18
|
+
if (dist === undefined || tar === undefined || instance === undefined || x === undefined || y === undefined) throw new Error('usage: bake-catalogue <dist> <shard.tar> <instance> <cellX> <cellY>');
|
|
19
|
+
const out = resolve(dist), tarball = readFileSync(tar), shard = openShardfile(tarball), slug = shard.slug;
|
|
20
|
+
const cooked = mkdtempSync(join(tmpdir(), 'bake-catalogue-'));
|
|
21
|
+
try {
|
|
22
|
+
const report = await cookShard(tarball, cooked, { now: () => performance.now(), wireBytes: (url, bytes) => servedAsIs(url, bytes) ? bytes.length : brotliCompressSync(bytes, { params: { [constants.BROTLI_PARAM_QUALITY]: 5 } }).length });
|
|
23
|
+
// `dereference`: a preview's dist symlinks its folders.
|
|
24
|
+
cpSync(cooked, packs === undefined ? out : resolve(packs), { recursive: true, dereference: true, force: true });
|
|
25
|
+
const proved = await productVerdict(tarball, out);
|
|
26
|
+
const header = join(out, 'shardfiles', slug);
|
|
27
|
+
mkdirSync(header, { recursive: true }); writeFileSync(join(header, 'shard.json'), shard.header);
|
|
28
|
+
// A shard's manifests name its document at the page's URL, loose as its header is: no part carries it.
|
|
29
|
+
const document = join(cooked, 'shardfiles', slug, 'discovery.json');
|
|
30
|
+
if (existsSync(document)) cpSync(document, join(header, 'discovery.json'));
|
|
31
|
+
if (packs !== undefined) { mkdirSync(join(packs, 'shardfiles', slug), { recursive: true }); writeFileSync(join(packs, 'shardfiles', slug, 'shard.json'), shard.header); }
|
|
32
|
+
const catalogue = JSON.parse(readFileSync(join(out, 'catalogue.json'), 'utf8'));
|
|
33
|
+
const hash = createHash('sha256').update(tarball).digest('hex');
|
|
34
|
+
catalogue.placements = [...catalogue.placements.filter(row => row.slug !== slug), { instance, slug, cell: [Number(x), Number(y)], size: [500, 500, 500], order: catalogue.placements.length + 1 }];
|
|
35
|
+
catalogue.shards = [...catalogue.shards.filter(row => row.slug !== slug), { slug, name: shard.index.identity.name, revision: 1, hash }];
|
|
36
|
+
writeCatalogueDocument(out, catalogue);
|
|
37
|
+
// The server worker reads its pack beside the page, wherever the page's packs live (J134: nothing in it is secret).
|
|
38
|
+
const { server: packed } = report;
|
|
39
|
+
if (packed !== undefined) cpSync(join(cooked, 'assets/spawn/server'), join(out, 'assets/spawn/server'), { recursive: true, force: true });
|
|
40
|
+
const server = packed === undefined ? {} : { server: JSON.parse(readFileSync(join(cooked, packed.index.slice(1)), 'utf8')) };
|
|
41
|
+
addCookedShards(out, [{ slug, hash, header: '', manifests: report.manifests, ...proved, ...server }], cooked, packs === undefined || origin === undefined ? undefined : { base: origin, shards: [slug] });
|
|
42
|
+
if (existsSync(join(out, 'sw.js'))) await writeServiceWorker(out, process.cwd());
|
|
43
|
+
console.log(JSON.stringify({ slug, hash, seconds: report.seconds, parts: report.parts }));
|
|
44
|
+
} finally { rmSync(cooked, { recursive: true, force: true }); }
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// E357 F1: check committed outputs by baking them, including local GPU/encoder outputs where supported.
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { join, resolve as pathResolve } from 'node:path';
|
|
6
|
+
import { toolVersion } from '@wildshard/engine/scripts/bake-output.mjs';
|
|
7
|
+
|
|
8
|
+
const ROOT = pathResolve(import.meta.dirname, '..');
|
|
9
|
+
const nodeOnly = process.argv.includes('--node-only'); // builders queue the GPU/derived batch to the lead
|
|
10
|
+
const skipGpu = nodeOnly ? true : process.argv.includes('--skip-gpu');
|
|
11
|
+
const state = { failed: false };
|
|
12
|
+
const run = (args, command = process.execPath) => {
|
|
13
|
+
const result = spawnSync(command, args, { cwd: ROOT, stdio: 'inherit' });
|
|
14
|
+
if (result.error) console.error(result.error.message);
|
|
15
|
+
if (result.status !== 0) state.failed = true;
|
|
16
|
+
return result.status === 0;
|
|
17
|
+
};
|
|
18
|
+
// SF74 W24 (speed audit #10): the push gate caches each node baker on its own inputs (`--list-node`, then
|
|
19
|
+
// `--node-only --only=<baker>` per cached step), so one touched src file re-runs only the bakers that read it.
|
|
20
|
+
const NODE_BAKERS = ['directors', 'chunk', 'sky', 'navmesh', 'island-cover', 'voxel-ao', 'geometry', 'cloud-field', 'water-ripples', 'nalati-bodies', 'nalati-places', 'pine-thrall-extras', 'pine-rain'];
|
|
21
|
+
if (process.argv.includes('--list-node')) { console.log(NODE_BAKERS.join('\n')); process.exit(0); }
|
|
22
|
+
const only = process.argv.find((arg) => arg.startsWith('--only='))?.slice('--only='.length);
|
|
23
|
+
if (only !== undefined && !NODE_BAKERS.includes(only)) { console.error(`bake-check: no node baker ${only} (${NODE_BAKERS.join(', ')})`); process.exit(64); }
|
|
24
|
+
if (only !== undefined && !nodeOnly) { console.error('bake-check: --only needs --node-only'); process.exit(64); }
|
|
25
|
+
for (const baker of NODE_BAKERS) if (only === undefined || only === baker) {
|
|
26
|
+
if (baker === 'directors') {
|
|
27
|
+
run(['--experimental-transform-types', '--import', './scripts/bake-loader.mjs', '--input-type=module', '-e', `import { runCli } from './src/sharddev/cli.ts'; await runCli(['build', 'src/shards/nalati-grasslands', '--behaviour-only', '--check']);`]);
|
|
28
|
+
} else {
|
|
29
|
+
const entry = baker.startsWith('pine-') ? `src/shards/pine-hollow/generators/bake-${baker}.mjs` : baker.startsWith('nalati-') ? `src/shards/nalati-grasslands/generators/bake-${baker === 'nalati-places' ? 'nalati-painted' : baker}.mjs` : `scripts/bake-${baker}.mjs`;
|
|
30
|
+
run(['--experimental-transform-types', '--import', './scripts/bake-loader.mjs', entry, '--check']);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const metal = only === undefined && process.platform === 'darwin' && spawnSync('system_profiler', ['SPDisplaysDataType'], { encoding: 'utf8' }).stdout.includes('Metal');
|
|
35
|
+
if (only !== undefined) { /* one node baker: no GPU bakers */ }
|
|
36
|
+
else if (!metal) console.log('bake-check: GPU bakers skipped (no Metal): bake-textures');
|
|
37
|
+
else if (skipGpu) console.log('bake-check: GPU bakers queued: bake-textures');
|
|
38
|
+
else if (!state.failed) {
|
|
39
|
+
// SF87 (G320): the sky textures render on their own bake page (no game build, no preview, no ?chunk= boot)
|
|
40
|
+
run(['scripts/browser-lane.sh', '--max', '4', process.execPath, 'scripts/bake-textures.mjs', '--check', '--all'], 'bash');
|
|
41
|
+
}
|
|
42
|
+
if (only !== undefined) { /* one node baker for the gate's per-baker cache */ }
|
|
43
|
+
else if (nodeOnly) console.log('bake-check: derived copies queued (--node-only): tex-tiers, bake-ktx2');
|
|
44
|
+
else {
|
|
45
|
+
if (toolVersion('magick', ['-version']) && toolVersion('cwebp', ['-version'])) run(['scripts/tex-tiers.mjs', '--check']);
|
|
46
|
+
else console.log('bake-check: phone copies skipped (no magick/cwebp): tex-tiers');
|
|
47
|
+
if (toolVersion('magick', ['-version']) && toolVersion('basisu', ['-version'])) run(['--import', './scripts/bake-loader.mjs', 'scripts/bake-ktx2.mjs', '--check']);
|
|
48
|
+
else console.log('bake-check: KTX2 copies skipped (no magick/basisu): bake-ktx2');
|
|
49
|
+
}
|
|
50
|
+
if (state.failed) {
|
|
51
|
+
const playwright = JSON.parse(readFileSync(join(ROOT, 'node_modules/playwright/package.json'), 'utf8'));
|
|
52
|
+
console.log(`bake-check: tools node ${process.version}; playwright ${playwright.version}; ${['magick', 'cwebp', 'basisu'].map((command) => `${command} ${toolVersion(command, ['-version']) ?? 'unavailable'}`).join('; ')}`);
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-chunk.mjs — pre-bake every registered shard's terrain at build time (project/archive/2026-09-22-load-perf.md §P2.1).
|
|
3
|
+
//
|
|
4
|
+
// Runs the chunk's pure terrain functions (src/chunks/<slug>.ts → buildTerrain: seeded Noise2D / Rng)
|
|
5
|
+
// in Node and writes public/assets/baked/<slug>/terrain.bin — the height and splat weights at every
|
|
6
|
+
// vertex of the terrain mesh grid (TERRAIN_RES² over CHUNK_SIZE, the exact PlaneGeometry order), so
|
|
7
|
+
// the phone builds the mesh, plants the forest and walks the ground from a lookup instead of ~200 k
|
|
8
|
+
// noise evaluations at launch. src/shared/engine/world/BakedTerrain.ts reads it and swaps Heightfield's bindings.
|
|
9
|
+
//
|
|
10
|
+
// Every run bakes in memory and writes only differing output bytes. Source-only edits write nothing.
|
|
11
|
+
//
|
|
12
|
+
// node --import ./scripts/bake-loader.mjs scripts/bake-chunk.mjs [--check]
|
|
13
|
+
//
|
|
14
|
+
// Format (little-endian): 'WSTR' u32 version=1 · u32 res · f32 size · u32 seed · u32 landscapeHash (0 = unhashed legacy) ·
|
|
15
|
+
// f32[res²] height · u8[res²·4] splat weights (each row sums to ≈ 255) — vertex i = iz·res + ix at
|
|
16
|
+
// (x, z) = (−half + ix·d, −half + iz·d), d = size / (res − 1).
|
|
17
|
+
// Then, for a shard that grows undergrowth, the placement decision log (src/shared/engine/world/forest/placement.ts — the forest
|
|
18
|
+
// planted on this grid, then every undergrowth candidate's kept / skipped bit, ~17 KB): 'WSPL' u32 version=1 ·
|
|
19
|
+
// u32 decisions · u32 kinds · u32[kinds] counts · f64 checksum sum · u8[⌈decisions/8⌉] bits.
|
|
20
|
+
import { byteWriter, outputHash, jsonBytes } from '@wildshard/engine/scripts/bake-output.mjs';
|
|
21
|
+
import { resolve } from 'node:path';
|
|
22
|
+
import { pathToFileURL } from 'node:url';
|
|
23
|
+
|
|
24
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
25
|
+
const OUT = resolve(ROOT, 'public/assets/baked');
|
|
26
|
+
const check = process.argv.includes('--check');
|
|
27
|
+
const VERSION = 1;
|
|
28
|
+
// before any game module loads: the settings (and the defs that read them) take the page's query at import
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const { CHUNK_SIZE, CHUNK_HALF, TERRAIN_RES } = await import(pathToFileURL(resolve(ROOT, 'src/shared/engine/core/config.ts')).href);
|
|
32
|
+
const { landscapeHash } = await import(pathToFileURL(resolve(ROOT, 'src/shared/engine/world/terrainField.ts')).href);
|
|
33
|
+
|
|
34
|
+
// every chunk module that exports a ShardManifest (has slug + terrain); the registry itself needs `location`
|
|
35
|
+
const { SHARDS } = await import(pathToFileURL(resolve(ROOT, 'src/shards.generated.ts')).href);
|
|
36
|
+
|
|
37
|
+
const registry = await import(pathToFileURL(resolve(ROOT, 'src/client/game/shard/registry.ts')).href);
|
|
38
|
+
const heightfield = await import(pathToFileURL(resolve(ROOT, 'src/shared/engine/world/Heightfield.ts')).href);
|
|
39
|
+
const bakedTerrain = await import(pathToFileURL(resolve(ROOT, 'src/shared/engine/world/BakedTerrain.ts')).href);
|
|
40
|
+
const placement = await import(pathToFileURL(resolve(ROOT, 'src/shared/engine/world/forest/placement.ts')).href);
|
|
41
|
+
const { bakesTerrain } = await import(pathToFileURL(resolve(ROOT, 'src/shared/game/shard/terrainBake.ts')).href);
|
|
42
|
+
|
|
43
|
+
// G384: a shard whose retained WSTR alias is its shardfile's admitted query terrain (shard.config `terrain.form: 'query'`)
|
|
44
|
+
// ships the bare lattice. The content gate admits no placement tail, and no runtime of these shards replays one.
|
|
45
|
+
const QUERY_TERRAIN = new Set(['nalati-grasslands']);
|
|
46
|
+
|
|
47
|
+
/** The undergrowth decision log for `def` planted on the grid in `gridBuf` — null for a shard that grows none (main.ts: no forest carpet at sea). */
|
|
48
|
+
function placementSection(def, gridBuf) {
|
|
49
|
+
if (def.ocean || QUERY_TERRAIN.has(def.slug) || !registry.findChunk(def.slug)) return null;
|
|
50
|
+
registry.setActiveChunk(def.slug);
|
|
51
|
+
heightfield._installBakedTerrain(bakedTerrain.bakedSamplers(bakedTerrain.parseBakedTerrain(gridBuf))); // as loadBakedTerrain does at launch
|
|
52
|
+
const variants = placement.plantSpecs(def.trees); // the species set when the shard has one (PH-B4), else the runtime pines
|
|
53
|
+
const { trees, grid } = placement.placeForest(variants);
|
|
54
|
+
if (trees.length === 0) return null;
|
|
55
|
+
const log = placement.DecisionLog.record();
|
|
56
|
+
const run = placement.placeUndergrowth(trees, grid, log);
|
|
57
|
+
let r = run.next(); while (!r.done) r = run.next();
|
|
58
|
+
const { counts, sum } = placement.placementChecksum(r.value);
|
|
59
|
+
const bits = log.bits();
|
|
60
|
+
const out = new ArrayBuffer(16 + counts.length * 4 + 8 + bits.length);
|
|
61
|
+
const dv = new DataView(out);
|
|
62
|
+
dv.setUint8(0, 0x57); dv.setUint8(1, 0x53); dv.setUint8(2, 0x50); dv.setUint8(3, 0x4c); // 'WSPL'
|
|
63
|
+
dv.setUint32(4, 1, true); dv.setUint32(8, log.count, true); dv.setUint32(12, counts.length, true);
|
|
64
|
+
counts.forEach((c, k) => dv.setUint32(16 + k * 4, c, true));
|
|
65
|
+
dv.setFloat64(16 + counts.length * 4, sum, true);
|
|
66
|
+
new Uint8Array(out, 16 + counts.length * 4 + 8).set(bits);
|
|
67
|
+
return { bytes: new Uint8Array(out), decisions: log.count, counts, trees: trees.length };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const output = byteWriter(check, 'bake-chunk');
|
|
71
|
+
for (const def of SHARDS) {
|
|
72
|
+
// one rule with the grid's edge reader (src/shared/game/shard/terrainBake.ts): a structures world ships no bake, and the reader
|
|
73
|
+
// never fetches one for it (C4-R1-C13)
|
|
74
|
+
if (!bakesTerrain(def.ground)) continue;
|
|
75
|
+
// A required manifest ground is its shardfile's own terrain collider (compiled by its tiles job, loaded through the
|
|
76
|
+
// session's required-ground loader): it ships no WSTR bake, so never sample an unready field here.
|
|
77
|
+
const { bakedTerrainSource } = await import(pathToFileURL(resolve(ROOT, 'src/shared/engine/world/bakedTerrainField.ts')).href);
|
|
78
|
+
if (bakedTerrainSource(def.ground.terrain) !== null) continue;
|
|
79
|
+
// the bake holds the authored (unshifted) heights: a field shifted at runtime (its `datum`, Driftwood's G164 drop)
|
|
80
|
+
// installs this bake shifted by it (src/shared/engine/world/Heightfield.ts)
|
|
81
|
+
const terrain = def.ground.terrain, datum = terrain.datum ?? 0, authored = { heightAt: (x, z) => terrain.heightAt(x, z) - datum };
|
|
82
|
+
const res = TERRAIN_RES;
|
|
83
|
+
const dir = resolve(OUT, def.slug);
|
|
84
|
+
const meta = resolve(dir, 'terrain.json');
|
|
85
|
+
const bin = resolve(dir, 'terrain.bin');
|
|
86
|
+
const tag = def.slug;
|
|
87
|
+
const t0 = performance.now();
|
|
88
|
+
const n = res * res;
|
|
89
|
+
const header = 24;
|
|
90
|
+
const buf = new ArrayBuffer(header + n * 4 + n * 4);
|
|
91
|
+
const dv = new DataView(buf);
|
|
92
|
+
dv.setUint8(0, 0x57); dv.setUint8(1, 0x53); dv.setUint8(2, 0x54); dv.setUint8(3, 0x52); // 'WSTR'
|
|
93
|
+
const lhash = landscapeHash(authored, CHUNK_SIZE); // retained header field; staleness is checked by comparing the full bake
|
|
94
|
+
dv.setUint32(4, VERSION, true); dv.setUint32(8, res, true); dv.setFloat32(12, CHUNK_SIZE, true); dv.setUint32(16, def.seed >>> 0, true); dv.setUint32(20, lhash, true);
|
|
95
|
+
const heights = new Float32Array(buf, header, n);
|
|
96
|
+
const splat = new Uint8Array(buf, header + n * 4, n * 4);
|
|
97
|
+
const d = CHUNK_SIZE / (res - 1);
|
|
98
|
+
let min = Infinity, max = -Infinity;
|
|
99
|
+
for (let iz = 0; iz < res; iz++) {
|
|
100
|
+
const z = -CHUNK_HALF + iz * d;
|
|
101
|
+
for (let ix = 0; ix < res; ix++) {
|
|
102
|
+
const x = -CHUNK_HALF + ix * d;
|
|
103
|
+
const i = iz * res + ix;
|
|
104
|
+
const h = authored.heightAt(x, z);
|
|
105
|
+
heights[i] = h; if (h < min) min = h; if (h > max) max = h;
|
|
106
|
+
const s = def.ground.terrain.splatAt(x, z);
|
|
107
|
+
// quantise so the four bytes sum to exactly 255 (largest weight absorbs the rounding)
|
|
108
|
+
const q = s.map((w) => Math.round(w * 255));
|
|
109
|
+
const sum = q[0] + q[1] + q[2] + q[3];
|
|
110
|
+
let k = 0; for (let j = 1; j < 4; j++) if (q[j] > q[k]) k = j;
|
|
111
|
+
q[k] += 255 - sum;
|
|
112
|
+
splat[i * 4] = q[0]; splat[i * 4 + 1] = q[1]; splat[i * 4 + 2] = q[2]; splat[i * 4 + 3] = q[3];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const tp = performance.now();
|
|
116
|
+
const section = placementSection(def, buf);
|
|
117
|
+
const bytes = section ? Buffer.concat([Buffer.from(buf), section.bytes]) : Buffer.from(buf);
|
|
118
|
+
if (section) console.log(`bake: ${tag} placement: ${section.trees} trees, ${section.decisions} undergrowth candidates → ${section.counts.join(' / ')} kept, ${section.bytes.length} B in ${Math.round(performance.now() - tp)} ms`);
|
|
119
|
+
const digest = outputHash(bytes);
|
|
120
|
+
output.put(bin, bytes);
|
|
121
|
+
output.put(meta, jsonBytes({ hash: digest, version: VERSION, res, size: CHUNK_SIZE, seed: def.seed, landscapeHash: lhash, bytes: bytes.byteLength, placement: section ? { decisions: section.decisions, counts: section.counts } : null, heightRange: [min, max] }));
|
|
122
|
+
console.log(`bake: ${tag} terrain ${res}² → ${(buf.byteLength / 1024).toFixed(0)} KB in ${Math.round(performance.now() - t0)} ms (h ${min.toFixed(1)}…${max.toFixed(1)} m, ${digest})`);
|
|
123
|
+
}
|
|
124
|
+
output.finish();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-cloud-field.mjs — the engine's tileable cloud fbm at build time (SF67, E461).
|
|
3
|
+
//
|
|
4
|
+
// src/client/engine/world/cloudField.ts marched 512² six-octave simplex noise on the main thread at load (the audit's ~400 ms
|
|
5
|
+
// skyBackdrop.ts task at 4× CPU, Nalati's longest). The field is a pure function of that file and core/noise.ts, so this
|
|
6
|
+
// runs the page's own function in Node (V8, as Chromium) and writes the raw grey bytes to public/assets/baked/common/
|
|
7
|
+
// cloud-field.bin. A level that declares the file in its boot reads it back (boot/bakedTextures.ts bakedBytes); the
|
|
8
|
+
// texture the page builds from it is byte-identical to the marched one. Raw bytes, not an image: no phone / KTX2 copy
|
|
9
|
+
// (tex-tiers, bake-ktx2) can make it lossy. Writes only differing bytes; --check (bake-check.mjs) fails when stale.
|
|
10
|
+
//
|
|
11
|
+
// node --experimental-transform-types --import ./scripts/bake-loader.mjs scripts/bake-cloud-field.mjs [--check]
|
|
12
|
+
import { resolve } from 'node:path';
|
|
13
|
+
import { pathToFileURL } from 'node:url';
|
|
14
|
+
import { byteWriter } from '@wildshard/engine/scripts/bake-output.mjs';
|
|
15
|
+
|
|
16
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
17
|
+
const check = process.argv.includes('--check');
|
|
18
|
+
const field = await import(pathToFileURL(resolve(ROOT, 'src/client/engine/world/cloudField.ts')).href);
|
|
19
|
+
const { CLOUD_FIELD_URL } = await import(pathToFileURL(resolve(ROOT, 'src/client/engine/boot/bakedApi.ts')).href);
|
|
20
|
+
const bytes = field.cloudFieldPixels();
|
|
21
|
+
if (bytes.length !== field.CLOUD_FIELD_N * field.CLOUD_FIELD_N) throw new Error('bake-cloud-field: wrong field size');
|
|
22
|
+
const output = byteWriter(check, 'bake-cloud-field');
|
|
23
|
+
output.put(resolve(ROOT, `public${CLOUD_FIELD_URL}`), bytes);
|
|
24
|
+
output.finish();
|