@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,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-coats.mjs — a shard's creature coats, painted offline (G187 cut 2 for Pine Hollow; SHARD-PLATFORM G226 for Nalati,
|
|
3
|
+
// E435). The coats are painted on the CPU from each rigged hull's atlas by the shard's own coat painter, which costs the
|
|
4
|
+
// entry hundreds of milliseconds to seconds (and which a KTX2 hull cannot do at all: its atlas has no pixels). So the game
|
|
5
|
+
// paints them here, offline, and the runtime loads the result.
|
|
6
|
+
//
|
|
7
|
+
// Pine Hollow: generators/coatProducer.ts (through src/shards/pine-hollow/bake/pineCoats.mjs) reads authored recipes and the committed
|
|
8
|
+
// rigged hulls through SDK Node readers. It installs no runtime registry and opens no page. The Pine program paints the
|
|
9
|
+
// same lossless pages as product files (generators/coatPages.ts).
|
|
10
|
+
// Nalati: generators/coats.ts (through scripts/bake/nalatiCoats.mjs) reads the committed rigged hulls and the
|
|
11
|
+
// species palettes in plain Node, painting with the page's former canvas painter and its canvas rounding, exactly.
|
|
12
|
+
// Either way every hull variant whose coat repaints the atlas is handed back as a lossless PNG keyed by its table name. Each is encoded with bake-ktx2.mjs's colour class
|
|
13
|
+
// (UASTC LDR 4×4 level 2, sRGB, full box-filtered mips, zstd 20), unflipped (glTF orientation, as the hull's own map),
|
|
14
|
+
// content-addressed under the shard's `ktx2` folder. The shard's table (`table`) maps, per tier, each coat's table name to
|
|
15
|
+
// its KTX2; bake-ktx2.mjs merges it into the shard's KTX2 table and keeps the files.
|
|
16
|
+
// pine-hollow the table name is a name, not a file (species/rigs.ts pineCoatUrl): only the KTX2 path reads coats;
|
|
17
|
+
// nalati-grasslands the table name is a real file (species/rigs.ts nalatiCoatUrl): the coat stored LOSSLESS (WebP,
|
|
18
|
+
// the canvas's exact pixels, unflipped) for the images path, its KTX2 stand-in for the KTX2 path.
|
|
19
|
+
// Rerun whenever a coat, a palette or a hull changes, then rerun bake-ktx2.mjs.
|
|
20
|
+
//
|
|
21
|
+
// node scripts/bake-coats.mjs --shard=<pine-hollow|nalati-grasslands> [--tiers=phone,desktop]
|
|
22
|
+
// node --import ./scripts/bake-loader.mjs scripts/bake-ktx2.mjs
|
|
23
|
+
import { createHash } from 'node:crypto';
|
|
24
|
+
import { execFileSync } from 'node:child_process';
|
|
25
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
26
|
+
import { dirname, join, relative, resolve } from 'node:path';
|
|
27
|
+
import { readCoatFiles } from './bake/coatFiles.mjs';
|
|
28
|
+
|
|
29
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
30
|
+
const PUB = resolve(ROOT, 'public');
|
|
31
|
+
/** per shard: the KTX2 folder, the table, and (Nalati) the folder of the lossless images the table names */
|
|
32
|
+
const SHARDS = {
|
|
33
|
+
'pine-hollow': { ktx2: 'assets/gpu/pine-hollow/creatures/coats', table: 'src/shards/pine-hollow/generators/bake-pine-coats.json', images: null, doc: 'G187 cut 2' },
|
|
34
|
+
'nalati-grasslands': { ktx2: 'assets/gpu/nalati/models/coats', table: 'src/shards/nalati-grasslands/generators/bake-nalati-coats.json', images: 'assets/nalati/models/coats', doc: 'SHARD-PLATFORM G226' },
|
|
35
|
+
};
|
|
36
|
+
const argv = process.argv.slice(2);
|
|
37
|
+
const slug = argv.find((a) => a.startsWith('--shard='))?.slice(8) ?? '';
|
|
38
|
+
const tiers = (argv.find((a) => a.startsWith('--tiers='))?.slice(8) ?? 'phone,desktop').split(',');
|
|
39
|
+
const shard = Object.hasOwn(SHARDS, slug) ? SHARDS[/** @type {keyof typeof SHARDS} */ (slug)] : undefined;
|
|
40
|
+
if (!shard || tiers.some((t) => !['phone', 'desktop'].includes(t))) throw new Error(`Usage: bake-coats.mjs --shard=<${Object.keys(SHARDS).join('|')}> [--tiers=phone,desktop]`);
|
|
41
|
+
const OUT = resolve(PUB, shard.ktx2);
|
|
42
|
+
const IMAGES = shard.images === null ? null : resolve(PUB, shard.images);
|
|
43
|
+
const TABLE = resolve(ROOT, shard.table);
|
|
44
|
+
const ENCODER = /v[\d.]+/.exec(execFileSync('basisu', ['-version']).toString())?.[0] ?? '?';
|
|
45
|
+
/** bake-ktx2.mjs COMMON + CLASS.color */
|
|
46
|
+
const FLAGS = ['-ktx2', '-mipmap', '-mip_filter', 'box', '-max_threads', '4', '-uastc', '-uastc_level', '2', '-srgb', '-ktx2_zstandard_level', '20'];
|
|
47
|
+
const sha = (buf) => createHash('sha256').update(buf).digest('hex');
|
|
48
|
+
const pub = (abs) => `/${relative(PUB, abs).split('\\').join('/')}`;
|
|
49
|
+
|
|
50
|
+
const prior = existsSync(TABLE) ? JSON.parse(readFileSync(TABLE, 'utf8')) : {};
|
|
51
|
+
const cache = prior.cache ?? {};
|
|
52
|
+
const table = { phone: prior.phone ?? {}, desktop: prior.desktop ?? {} };
|
|
53
|
+
const used = new Set();
|
|
54
|
+
mkdirSync(resolve(ROOT, 'tmp'), { recursive: true });
|
|
55
|
+
const TMP = mkdtempSync(resolve(ROOT, 'tmp/bake-coats-'));
|
|
56
|
+
try {
|
|
57
|
+
mkdirSync(OUT, { recursive: true });
|
|
58
|
+
if (IMAGES !== null) mkdirSync(IMAGES, { recursive: true });
|
|
59
|
+
let encoded = 0, reused = 0;
|
|
60
|
+
|
|
61
|
+
for (const tier of tiers) {
|
|
62
|
+
const tex = 'img';
|
|
63
|
+
const list = join(TMP, `${tier}.json`);
|
|
64
|
+
execFileSync(process.execPath, ['--import', './scripts/bake-loader.mjs', slug === 'pine-hollow' ? 'src/shards/pine-hollow/bake/pineCoats.mjs' : 'scripts/bake/nalatiCoats.mjs', tier, list], { cwd: ROOT, stdio: 'inherit' });
|
|
65
|
+
const sources = readCoatFiles(list);
|
|
66
|
+
if (sources.length === 0) throw new Error(`${tier}: no coats (texture mode ${tex})`);
|
|
67
|
+
const next = {};
|
|
68
|
+
for (const s of sources) {
|
|
69
|
+
const png = s.png;
|
|
70
|
+
if (IMAGES !== null) {
|
|
71
|
+
// the images path's file: the canvas's exact pixels (lossless, -exact keeps every RGB)
|
|
72
|
+
const file = join(PUB, s.url);
|
|
73
|
+
if (!file.startsWith(`${IMAGES}/`)) throw new Error(`${s.url}: not under /${shard.images}`);
|
|
74
|
+
const src = join(TMP, 'lossless.png');
|
|
75
|
+
writeFileSync(src, png);
|
|
76
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
77
|
+
execFileSync('cwebp', ['-quiet', '-lossless', '-exact', '-z', '9', '-metadata', 'none', src, '-o', file]);
|
|
78
|
+
}
|
|
79
|
+
const key = sha(`${sha(png)}|${ENCODER}|${FLAGS.join(' ')}`);
|
|
80
|
+
used.add(key);
|
|
81
|
+
let out = cache[key];
|
|
82
|
+
if (out && existsSync(join(PUB, out))) reused++;
|
|
83
|
+
else {
|
|
84
|
+
const src = join(TMP, `${encoded}.png`), dst = join(TMP, `${encoded}.ktx2`);
|
|
85
|
+
writeFileSync(src, png);
|
|
86
|
+
execFileSync('basisu', [...FLAGS, src, '-output_file', dst], { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
87
|
+
const bytes = readFileSync(dst);
|
|
88
|
+
const stem = s.url.slice(s.url.lastIndexOf('/') + 1).replace(/\.(png|webp)$/u, '');
|
|
89
|
+
const file = join(OUT, `${stem}-${sha(bytes).slice(0, 8)}.ktx2`);
|
|
90
|
+
writeFileSync(file, bytes);
|
|
91
|
+
out = pub(file); cache[key] = out; encoded++;
|
|
92
|
+
}
|
|
93
|
+
next[s.url] = out;
|
|
94
|
+
}
|
|
95
|
+
table[tier] = Object.fromEntries(Object.entries(next).sort(([a], [b]) => a.localeCompare(b)));
|
|
96
|
+
console.log(`bake-coats: ${slug} ${tier} ${sources.length} coats (texture mode ${tex})`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (const k of Object.keys(cache)) if (!used.has(k) && !Object.values(table).some((t) => Object.values(t).includes(cache[k]))) delete cache[k];
|
|
100
|
+
const live = new Set([...Object.values(table.phone), ...Object.values(table.desktop)]);
|
|
101
|
+
for (const f of readdirSync(OUT)) if (!live.has(pub(join(OUT, f)))) rmSync(join(OUT, f));
|
|
102
|
+
if (IMAGES !== null) {
|
|
103
|
+
const named = new Set([...Object.keys(table.phone), ...Object.keys(table.desktop)]);
|
|
104
|
+
for (const f of readdirSync(IMAGES)) if (!named.has(pub(join(IMAGES, f)))) rmSync(join(IMAGES, f));
|
|
105
|
+
}
|
|
106
|
+
writeFileSync(TABLE, `${JSON.stringify({ $doc: `${shard.doc}: written by scripts/bake-coats.mjs --shard=${slug} (per tier: coat table name -> KTX2; cache: PNG+settings hash -> KTX2); merged into the shard's KTX2 table by scripts/bake-ktx2.mjs`, phone: table.phone, desktop: table.desktop, cache }, null, 1)}\n`);
|
|
107
|
+
console.log(`bake-coats: ${encoded} encoded, ${reused} reused · ${live.size} files`);
|
|
108
|
+
} finally {
|
|
109
|
+
rmSync(TMP, { recursive: true, force: true });
|
|
110
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MapBakeStamp } from '@wildshard/engine/scripts/map-hash.mjs';
|
|
2
|
+
import type { MapRaster } from '../src/sharddev/bake/mapRaster';
|
|
3
|
+
|
|
4
|
+
/** Existing map geometry and palette declarations, without filesystem roots. */
|
|
5
|
+
export interface DataMapSettings {
|
|
6
|
+
readonly painter?: { readonly version: number; readonly terrain?: readonly string[]; readonly props?: readonly string[];
|
|
7
|
+
readonly glbs?: readonly string[]; readonly scenes?: unknown };
|
|
8
|
+
readonly style?: { readonly kind: string } & Readonly<Record<string, unknown>>;
|
|
9
|
+
readonly clipBelow?: number; readonly clipAbove?: number;
|
|
10
|
+
readonly outputs?: Readonly<Record<string, { readonly exclude?: string | readonly string[];
|
|
11
|
+
readonly style?: { readonly kind: string } & Readonly<Record<string, unknown>> }>>;
|
|
12
|
+
}
|
|
13
|
+
/** Call-scoped input authority; no reader is inferred from a shard name or path. */
|
|
14
|
+
export interface DataMapReader {
|
|
15
|
+
input: (file: string) => string | Uint8Array;
|
|
16
|
+
json: (file: string) => unknown;
|
|
17
|
+
bytes: (file: string) => Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
/** The single existing raster algorithm, returning owned pixels without image/stamp publication. */
|
|
20
|
+
export function rasterDataMap(settings: DataMapSettings, data: DataMapReader,
|
|
21
|
+
options?: { output?: string; glbs?: readonly string[]; label?: string }): Promise<{ raster: MapRaster; pixels: Uint8Array }>;
|
|
22
|
+
|
|
23
|
+
/** SF88g: `output` paints one declared output. `sources` supplies owned terrain/props/scene rows and geometry/GLB bytes by logical input name; omitted inputs retain the declared file path checks. */
|
|
24
|
+
export function paintDataMap(root: string, slug: string, options?: { output?: string; glbs?: readonly string[]; sources?: ReadonlyMap<string, Uint8Array> }): Promise<{ raster: MapRaster; stamp: MapBakeStamp }>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// G508: normal generation job; reads only declared JSON, terrain and GLB data.
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { dirname, resolve, sep } from 'node:path';
|
|
6
|
+
import { pathToFileURL } from 'node:url';
|
|
7
|
+
import { MapRaster } from '../src/sharddev/bake/mapRaster.ts';
|
|
8
|
+
import { readMapGeometry, stylizeMap } from '@wildshard/engine/scripts/map-painter.mjs';
|
|
9
|
+
import { MAP_METRES, mapPixelHash, mapSettingsPath, mapStampPath, mapShards, mapTilesHash } from '@wildshard/engine/scripts/map-hash.mjs';
|
|
10
|
+
|
|
11
|
+
const sharp = createRequire(new URL('../src/sharddev/package.json', import.meta.url))('sharp');
|
|
12
|
+
const json = file => JSON.parse(readFileSync(file, 'utf8'));
|
|
13
|
+
|
|
14
|
+
/** Rasterize declared map geometry into owned RGBA without publishing an image or stamp.
|
|
15
|
+
* Readers retain input authority; both source-owned and validated file inputs use this same algorithm. */
|
|
16
|
+
export async function rasterDataMap(settings, data, { output, glbs, label = 'map' } = {}) {
|
|
17
|
+
const painter = settings.painter;
|
|
18
|
+
if (painter?.version !== 1 || settings.style === undefined) throw new Error(`${label}: missing data map painter declaration`);
|
|
19
|
+
const raster = new MapRaster(1000, settings, readMapGeometry);
|
|
20
|
+
const { paintMapGeometry } = await import('../src/sharddev/bake/mapScenes.ts');
|
|
21
|
+
const source = data.input;
|
|
22
|
+
await paintMapGeometry(raster, settings, { input: source, model: url => source(`../../../public${url}`), json: data.json, bytes: data.bytes }, { output, glbs, label });
|
|
23
|
+
const own = output === undefined ? undefined : settings.outputs?.[output];
|
|
24
|
+
const style = own?.style ?? settings.style;
|
|
25
|
+
const pixels = stylizeMap(raster, style);
|
|
26
|
+
return { raster, pixels };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Paint the exact render lattice and placed prop triangles. Each address is
|
|
30
|
+
* already world-space in the authored products; no second placement law exists.
|
|
31
|
+
* SF88g: `output` paints one declared output of the folder (scripts/shard-outputs.mjs) from its own `glbs`, into
|
|
32
|
+
* public/assets/<output>/map/top.webp with its stamp at look/map.<output>.baked.json. An output's own row in the map
|
|
33
|
+
* settings' `outputs` (G633: a tiled open plot) gives its `style` (else the folder's) and `exclude`, node-name prefixes
|
|
34
|
+
* its glbs leave out (its collision boxes stand over its roofs; its additive light pools are no ground). */
|
|
35
|
+
/** Every repository file by its path, as a shard's pure map producer reads its inputs. @param {string} root */
|
|
36
|
+
export const repoSource = root => path => new Uint8Array(readFileSync(resolve(root, path)));
|
|
37
|
+
export async function paintDataMap(root, slug, { output, glbs, sources } = {}) {
|
|
38
|
+
const dir = resolve(root, 'src/shards', slug), settings = json(mapSettingsPath(dir));
|
|
39
|
+
const tilesHash = mapTilesHash(dir);
|
|
40
|
+
const declared = settings.inputs.map(file => resolve(dir, file));
|
|
41
|
+
const input = file => {
|
|
42
|
+
const path = resolve(dir, file);
|
|
43
|
+
if (!declared.some(source => path === source || path.startsWith(source + sep))) throw new Error(`${slug}: undeclared map input ${file}`);
|
|
44
|
+
return path;
|
|
45
|
+
};
|
|
46
|
+
const source = file => sources?.get(file) ?? input(file);
|
|
47
|
+
const readBytes = file => { const value = source(file); return value instanceof Uint8Array ? value : readFileSync(value); };
|
|
48
|
+
const rows = file => JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(readBytes(file)));
|
|
49
|
+
const { raster, pixels } = await rasterDataMap(settings, { input: source, json: rows, bytes: readBytes }, { output, glbs, label: slug });
|
|
50
|
+
const own = output === undefined ? undefined : settings.outputs?.[output], style = own?.style ?? settings.style, painter = settings.painter;
|
|
51
|
+
const product = output ?? slug, image = resolve(root, 'public/assets', product, 'map/top.webp');
|
|
52
|
+
mkdirSync(dirname(image), { recursive: true });
|
|
53
|
+
// Lossless VP8L stores precisely the integer raster; no lossy SIMD rounding.
|
|
54
|
+
const bytes = await sharp(pixels, { raw: { width: 1000, height: 1000, channels: 4 } }).webp({ lossless: true, effort: 6 }).toBuffer();
|
|
55
|
+
if (mapTilesHash(dir) !== tilesHash) throw new Error(`${slug}: map inputs changed while painting`);
|
|
56
|
+
writeFileSync(image, bytes);
|
|
57
|
+
const stamp = { version: 1, tilesHash, pixelHash: await mapPixelHash(image), image: `/assets/${product}/map/top.webp`, size: 1000, metres: MAP_METRES, north: '+z', east: '-x', style: `data:${style.kind}`, bytes: bytes.length };
|
|
58
|
+
const stampPath = output === undefined ? mapStampPath(dir) : resolve(dir, `look/map.${output}.baked.json`); mkdirSync(dirname(stampPath), { recursive: true });
|
|
59
|
+
writeFileSync(stampPath, `${JSON.stringify(stamp, null, 2)}\n`);
|
|
60
|
+
if (output !== undefined) { console.info(`data-map: ${output}, ${raster.triangles} source triangles, ${bytes.length} bytes`); return { raster, stamp }; }
|
|
61
|
+
const companion = resolve(dir, 'data/productMap.json');
|
|
62
|
+
if (companion !== stampPath && (painter.authored === true || existsSync(companion))) writeFileSync(companion, `${JSON.stringify(stamp, null, 2)}\n`);
|
|
63
|
+
if (painter.authored === true) { mkdirSync(resolve(dir, 'assets'), { recursive: true }); writeFileSync(resolve(dir, 'assets/map.webp'), bytes); }
|
|
64
|
+
console.info(`data-map: ${slug}, ${raster.triangles} source triangles, ${bytes.length} bytes`);
|
|
65
|
+
return { raster, stamp };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const entry = process.argv.at(1);
|
|
69
|
+
if (entry !== undefined && import.meta.url === pathToFileURL(resolve(entry)).href) {
|
|
70
|
+
const root = resolve(import.meta.dirname, '..'), only = process.argv.find(arg => arg.startsWith('--shards='))?.slice(9).split(',');
|
|
71
|
+
for (const { slug, dir } of mapShards(root)) if ((only === undefined || only.includes(slug)) && json(mapSettingsPath(dir)).painter !== undefined) await paintDataMap(root, slug);
|
|
72
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// DL10: record the GLSL programs a shard links from ENTER WORLD to control, in Playwright WebKit as the phone (iPhone 16
|
|
3
|
+
// Pro, phone tier, 2x), and write them as public/programs/<slug>.json. With Debug 'Early shader compile' on,
|
|
4
|
+
// the session links this list from the renderer step on, so WebKit's GPU process has compiled each source before the
|
|
5
|
+
// Shaders step asks for it. A stale list costs only wasted links: re-bake after a shader or material change.
|
|
6
|
+
// node scripts/bake-entry-programs.mjs --base <served build URL> [--check] <slug>...
|
|
7
|
+
// --check: write nothing; print how many of the build's entry programs the committed list already holds.
|
|
8
|
+
// Run through scripts/browser-lane.sh.
|
|
9
|
+
import {webkit,devices} from 'playwright';
|
|
10
|
+
import {existsSync,readFileSync,writeFileSync} from 'node:fs';
|
|
11
|
+
import {createHash} from 'node:crypto';
|
|
12
|
+
import {hideDeveloperOverlays} from '@wildshard/engine/scripts/debug-settings.mjs';
|
|
13
|
+
import {loadingCardIndex} from '@wildshard/engine/scripts/loading-benchmark/catalogue.mjs';
|
|
14
|
+
import {preparationSaveSeed} from './preparation-seed.mjs';
|
|
15
|
+
|
|
16
|
+
const args=process.argv.slice(2), flag=name=>{const at=args.indexOf(name);if(at===-1)return null;const [value]=args.splice(at,2).slice(1);return value;};
|
|
17
|
+
const base=flag('--base'), output=flag('--out'), wantedHeader=flag('--header'), title=flag('--title'), check=args.includes('--check'), slugs=args.filter(arg=>!arg.startsWith('--'));
|
|
18
|
+
if(base===null||slugs.length===0)throw new Error('usage: bake-entry-programs.mjs --base <url> [--check] <slug>...');
|
|
19
|
+
|
|
20
|
+
/** Every program linked between the tap and control, in link order (the page's own WebGL2 calls, read in place). */
|
|
21
|
+
async function record(browser,slug){
|
|
22
|
+
const before=await(await fetch(new URL('/version.json',base))).json(),epoch=before.saveEpoch??0;
|
|
23
|
+
if(!Number.isSafeInteger(epoch)||epoch<0)throw new Error('Preview has an invalid save epoch');
|
|
24
|
+
if(wantedHeader!==null){
|
|
25
|
+
const flags=await(await fetch(new URL('/build-flags.json',base))).json();
|
|
26
|
+
if(flags.devserver!==false)throw new Error('Preparation needs a production-renderer preview, with DEVSERVER off');
|
|
27
|
+
}
|
|
28
|
+
const context=await browser.newContext({...devices['iPhone 16 Pro']});
|
|
29
|
+
try{
|
|
30
|
+
// The served epoch owns this fresh diagnostic context. The installed SDK
|
|
31
|
+
// may predate that epoch; never write fixtures through its old namespace.
|
|
32
|
+
// A device that has played and answered the Name prompt (engine MP2.4), or PLAY never reaches SHARD SELECT.
|
|
33
|
+
await context.addInitScript(({seed})=>{for(const [key,value] of Object.entries(seed))localStorage.setItem(key,value);},{seed:preparationSaveSeed(epoch)});
|
|
34
|
+
await context.addInitScript(hideDeveloperOverlays);
|
|
35
|
+
// in the page: each document's own shaderSource / attachShader / linkProgram calls, the sources of every linked pair
|
|
36
|
+
await context.addInitScript(`(() => {
|
|
37
|
+
const P = WebGL2RenderingContext.prototype, source = new WeakMap(), attached = new WeakMap();
|
|
38
|
+
window.__entryPrograms = [];
|
|
39
|
+
const shaderSource = P.shaderSource, attach = P.attachShader, link = P.linkProgram;
|
|
40
|
+
P.shaderSource = function (shader, text) { source.set(shader, text); shaderSource.call(this, shader, text); };
|
|
41
|
+
P.attachShader = function (program, shader) {
|
|
42
|
+
const list = attached.get(program) ?? []; list.push(shader); attached.set(program, list); attach.call(this, program, shader);
|
|
43
|
+
};
|
|
44
|
+
P.linkProgram = function (program) {
|
|
45
|
+
const shaders = attached.get(program) ?? [];
|
|
46
|
+
const of = type => source.get(shaders.find(shader => this.getShaderParameter(shader, this.SHADER_TYPE) === type));
|
|
47
|
+
const vs = of(this.VERTEX_SHADER), fs = of(this.FRAGMENT_SHADER);
|
|
48
|
+
if (typeof vs === 'string' && typeof fs === 'string') window.__entryPrograms.push([vs, fs]);
|
|
49
|
+
link.call(this, program);
|
|
50
|
+
};
|
|
51
|
+
})();`);
|
|
52
|
+
const page=await context.newPage();page.setDefaultTimeout(30000);
|
|
53
|
+
const reads=new Set(),headers=[],metadata=[],hashes=new Set();
|
|
54
|
+
page.on('response',response=>{
|
|
55
|
+
const url=new URL(response.url());reads.add(url.pathname);
|
|
56
|
+
if(wantedHeader!==null&&url.pathname.endsWith('/shard.json'))headers.push(response.body().then(bytes=>createHash('sha256').update(bytes).digest('hex')));
|
|
57
|
+
if(wantedHeader!==null&&/\/assets\/spawn\/[^/]+\.json$/u.test(url.pathname))metadata.push(response.json().then(manifest=>{
|
|
58
|
+
for(const file of manifest.files??[])if(typeof file.hash==='string')hashes.add(file.hash);
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
await page.goto(base,{waitUntil:'load'});
|
|
62
|
+
await page.locator('.ws-main-select').click();
|
|
63
|
+
const names=await page.locator('.ws-menu-card b').allTextContents();
|
|
64
|
+
const matches=title===null?[]:names.flatMap((name,index)=>name.toLowerCase().includes(title.toLowerCase())?[index]:[]);
|
|
65
|
+
if(matches.length>1)throw new Error(`Candidate card ambiguous: ${title}`);
|
|
66
|
+
if(title!==null&&matches.length===0){
|
|
67
|
+
// Grid-only products have no standalone picker card. Exercise the
|
|
68
|
+
// existing one-shot arrival contract, as the full-catalogue boot proof.
|
|
69
|
+
await context.addInitScript(({epoch,slug,title})=>{
|
|
70
|
+
if(new URL(location.href).searchParams.get('chunk')!==slug)return;
|
|
71
|
+
const prefix=epoch===0?'wildshard.save.v2.':`wildshard.save.v2@${epoch}.`;
|
|
72
|
+
const data=JSON.stringify({slug,name:title,mode:'enter',at:Date.now()});
|
|
73
|
+
sessionStorage.setItem(`${prefix}session`,JSON.stringify({keys:{titleArrival:{v:1,data},'travel.handoff':{v:1,data:{v:1,from:null,to:slug,mode:'enter',arrive:null,carry:[],at:Date.now()}}}}));
|
|
74
|
+
},{epoch,slug,title});
|
|
75
|
+
const arrival=new URL(base);arrival.searchParams.set('chunk',slug);
|
|
76
|
+
await page.goto(arrival.href,{waitUntil:'load'});
|
|
77
|
+
}else{
|
|
78
|
+
await page.locator(`.ws-menu-dots i[data-i="${title===null?loadingCardIndex(names,slug):matches[0]}"]`).click();
|
|
79
|
+
// ENTER WORLD opens a fresh document and a fresh measured link list.
|
|
80
|
+
await page.locator('.ws-menu-play').click();
|
|
81
|
+
}
|
|
82
|
+
await page.waitForFunction(()=>window.__wildshard?.world?.hud?.entered===true&&!document.querySelector('.ws-load'),undefined,{timeout:240000});
|
|
83
|
+
const version=await(await page.request.get(new URL('/version.json',base).href)).json();
|
|
84
|
+
const documentBuild=await page.evaluate(()=>globalThis.__WS_BUILD_ID__);
|
|
85
|
+
const renderer=await page.evaluate(()=>globalThis.__WS_RENDERER_REVISION__);
|
|
86
|
+
if(wantedHeader!==null&&(documentBuild!==String(version.build??'')||documentBuild!==String(before.build??'')||version.saveEpoch!==before.saveEpoch))throw new Error('Preview changed renderer documents during preparation');
|
|
87
|
+
if(wantedHeader!==null&&(typeof renderer!=='string'||!/^[a-f0-9]{64}$/u.test(renderer)||renderer!==before.rendererRevision||renderer!==version.rendererRevision))throw new Error('Preview does not expose one matching engine renderer revision; build a D5 preparation preview');
|
|
88
|
+
const admitted=await page.evaluate(()=>globalThis.__WS_SHARDFILE_VERDICTS__??[]);
|
|
89
|
+
const direct=(await Promise.all(headers)).includes(wantedHeader),receipt=admitted.some(row=>row.indexHash===wantedHeader);
|
|
90
|
+
if(wantedHeader!==null&&!direct&&!receipt)throw new Error('Preparation boot has no exact candidate header or built admission receipt');
|
|
91
|
+
await Promise.all(metadata);
|
|
92
|
+
return {build:String(documentBuild??version.build??''),renderer,pairs:await page.evaluate(()=>window.__entryPrograms),reads:[...reads],hashes:[...hashes]};
|
|
93
|
+
}finally{await context.close();}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const browser=await webkit.launch({headless:true});
|
|
97
|
+
try{
|
|
98
|
+
for(const slug of slugs){
|
|
99
|
+
const {build,renderer,pairs,reads,hashes}=await record(browser,slug),file=output??`public/programs/${slug}.json`;
|
|
100
|
+
if(check){
|
|
101
|
+
const held=existsSync(file)?JSON.parse(readFileSync(file,'utf8')):null;
|
|
102
|
+
const text=at=>held.shaders[at].map(line=>held.lines[line]).join('\n');
|
|
103
|
+
const known=new Set((held?.programs??[]).map(([v,f])=>`${text(v)}\0${text(f)}`));
|
|
104
|
+
const hits=pairs.filter(([v,f])=>known.has(`${v}\0${f}`)).length;
|
|
105
|
+
console.log(`${slug}: ${hits} / ${pairs.length} entry programs on ${build} are in ${file}${held?` (baked on ${held.build})`:' (none)'}`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
// three's shaders share most lines (its chunks): one line table, each shader a list of line indices
|
|
109
|
+
const lines=[],lineAt=new Map(),line=text=>{if(!lineAt.has(text)){lineAt.set(text,lines.length);lines.push(text);}return lineAt.get(text);};
|
|
110
|
+
const shaders=[],at=new Map(),index=text=>{if(!at.has(text)){at.set(text,shaders.length);shaders.push(text.split('\n').map(line));}return at.get(text);};
|
|
111
|
+
const seen=new Set(),programs=[];
|
|
112
|
+
for(const [vs,fs] of pairs){const pair=[index(vs),index(fs)],key=pair.join(',');if(!seen.has(key)){seen.add(key);programs.push(pair);}}
|
|
113
|
+
const list={version:2,build,lines,shaders,programs};
|
|
114
|
+
writeFileSync(file,`${JSON.stringify(wantedHeader===null?list:{headerHash:wantedHeader,renderer,reads,hashes,programs:list})}\n`);
|
|
115
|
+
console.log(`${slug}: ${programs.length} programs, ${shaders.length} shaders, ${lines.length} lines, ${(readFileSync(file).length/1048576).toFixed(2)} MB -> ${file} (${build})`);
|
|
116
|
+
}
|
|
117
|
+
}finally{await browser.close();}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-geometry.mjs — finished Driftwood scene draws and Nalati's recorded geometry.
|
|
3
|
+
// Driftwood delegates to its registered rock-scene producer; no runtime table remains.
|
|
4
|
+
// Nalati retains the existing two-tier recorder and verification path.
|
|
5
|
+
//
|
|
6
|
+
// node --experimental-transform-types --import ./scripts/bake-loader.mjs scripts/bake-geometry.mjs [--check | --verify] [slug…]
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { join, resolve } from 'node:path';
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
12
|
+
import { brotliCompressSync } from 'node:zlib';
|
|
13
|
+
import { byteWriter } from '@wildshard/engine/scripts/bake-output.mjs';
|
|
14
|
+
|
|
15
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
16
|
+
const TIERS = ['phone', 'desktop'];
|
|
17
|
+
/** where each shard keeps its table (one for every tier: the keys are the inputs), a folder the shard owns (the shard
|
|
18
|
+
* sandbox), beside its voxel AO table; the runtime fetches the same literal path */
|
|
19
|
+
const OUTPUT = {
|
|
20
|
+
'nalati-grasslands': 'public/assets/nalati/baked/geometry.bin',
|
|
21
|
+
};
|
|
22
|
+
const arg = (name) => process.argv.find((a) => a.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
23
|
+
const tierArg = arg('tier'), slugArg = arg('slug'), recordTo = arg('record-to');
|
|
24
|
+
|
|
25
|
+
if (tierArg === undefined) {
|
|
26
|
+
const only = process.argv.slice(2).filter((a) => !a.startsWith('--'));
|
|
27
|
+
const verify = process.argv.includes('--verify'), check = process.argv.includes('--check');
|
|
28
|
+
const gb = await import(pathToFileURL(resolve(ROOT, 'src/client/engine/world/geometryBake.ts')).href);
|
|
29
|
+
const output = byteWriter(check, 'bake-geometry');
|
|
30
|
+
const scratch = mkdtempSync(join(tmpdir(), 'bake-geometry-'));
|
|
31
|
+
let failed = false;
|
|
32
|
+
try {
|
|
33
|
+
// Driftwood's rocks are built in its product (generators/rockBank.ts, GR7), not baked here.
|
|
34
|
+
for (const [slug, out] of Object.entries(OUTPUT)) {
|
|
35
|
+
if (only.length > 0 && !only.includes(slug)) continue;
|
|
36
|
+
const merged = new Map();
|
|
37
|
+
for (const tier of TIERS) {
|
|
38
|
+
const file = join(scratch, `${slug}.${tier}.bin`);
|
|
39
|
+
const r = spawnSync(process.execPath, [...process.execArgv, import.meta.filename, `--tier=${tier}`, `--slug=${slug}`, ...(verify ? ['--verify'] : [`--record-to=${file}`])], { cwd: ROOT, stdio: 'inherit' });
|
|
40
|
+
if (r.status !== 0) { failed = true; continue; }
|
|
41
|
+
if (verify) continue;
|
|
42
|
+
const b = readFileSync(file);
|
|
43
|
+
const table = gb.decodeGeometryBake(b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength));
|
|
44
|
+
if (table === null) throw new Error(`bake-geometry: ${slug} ${tier} recorded no table`);
|
|
45
|
+
for (const [key, g] of table) merged.set(key, g);
|
|
46
|
+
}
|
|
47
|
+
if (verify || failed) continue;
|
|
48
|
+
const bytes = gb.encodeGeometryBake(merged);
|
|
49
|
+
output.put(resolve(ROOT, out), bytes);
|
|
50
|
+
console.log(`[geometry] ${slug}: ${merged.size} geometries (both tiers), ${(bytes.length / 1024).toFixed(1)} KB (${(brotliCompressSync(bytes).length / 1024).toFixed(1)} KB brotli)`);
|
|
51
|
+
}
|
|
52
|
+
} finally {
|
|
53
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
54
|
+
}
|
|
55
|
+
if (!verify) output.finish();
|
|
56
|
+
if (failed) process.exitCode = 1;
|
|
57
|
+
} else {
|
|
58
|
+
if (!TIERS.includes(tierArg)) throw new Error(`bake-geometry: unknown tier ${tierArg}`);
|
|
59
|
+
if (slugArg === undefined || !(slugArg in OUTPUT)) throw new Error(`bake-geometry: unknown shard ${slugArg}`);
|
|
60
|
+
const { installBakeEnvironment } = await import('./bake/environment.mjs');
|
|
61
|
+
const environment = installBakeEnvironment(ROOT);
|
|
62
|
+
try {
|
|
63
|
+
const src = (p) => import(pathToFileURL(resolve(ROOT, 'src', p)).href);
|
|
64
|
+
if (tierArg !== 'desktop') (await src('engine/client/core/tier.ts')).initializeTier(tierArg); // desktop is Node's own tier (navigator 'node')
|
|
65
|
+
const THREE = await import('three');
|
|
66
|
+
const { visitAuthoredWorld } = await import('./bake/worldHost.mjs');
|
|
67
|
+
const registry = await src('game/client/shard/registry.ts');
|
|
68
|
+
const { SHARDS } = await src('shards.generated.ts');
|
|
69
|
+
const HF = await src('engine/shared/world/Heightfield.ts');
|
|
70
|
+
const BT = await src('engine/shared/world/BakedTerrain.ts');
|
|
71
|
+
const gb = await src('engine/client/world/geometryBake.ts');
|
|
72
|
+
const def = SHARDS.find((s) => s.slug === slugArg);
|
|
73
|
+
if (def === undefined) throw new Error(`bake-geometry: no shard ${slugArg}`);
|
|
74
|
+
registry.setActiveChunk(def.slug);
|
|
75
|
+
const terrain = resolve(ROOT, 'public/assets/baked', def.slug, 'terrain.bin');
|
|
76
|
+
if (existsSync(terrain)) {
|
|
77
|
+
const buf = readFileSync(terrain);
|
|
78
|
+
const grid = BT.parseBakedTerrain(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
|
|
79
|
+
if (!grid) throw new Error(`bake-geometry: ${def.slug}/terrain.bin does not parse`);
|
|
80
|
+
HF._installBakedTerrain(BT.bakedSamplers(grid));
|
|
81
|
+
}
|
|
82
|
+
const noop = () => undefined;
|
|
83
|
+
const sky = new Proxy({ setupMaterial: noop, csm: { lights: [new THREE.DirectionalLight()], update: noop }, hemi: new THREE.HemisphereLight(), sunDisc: new THREE.Mesh(new THREE.SphereGeometry(), new THREE.MeshBasicMaterial()), planet: new THREE.Group(), clouds: null, dayNight: null, viewCamera: new THREE.PerspectiveCamera(), sunDir: new THREE.Vector3(0, 1, 0) },
|
|
84
|
+
{ get: (t, k) => k in t ? t[k] : typeof k === 'string' && k.endsWith('Color') ? new THREE.Color(1, 1, 1) : typeof k === 'string' && k.endsWith('Dir') ? new THREE.Vector3(0, 1, 0) : undefined });
|
|
85
|
+
const t0 = performance.now();
|
|
86
|
+
if (process.argv.includes('--verify')) {
|
|
87
|
+
// the page's path: the shard adds its committed table and builds; every wrapped call must be answered by it
|
|
88
|
+
await visitAuthoredWorld(def, { root: ROOT, sky, element: environment.element });
|
|
89
|
+
const s = gb.geometryBakeStats();
|
|
90
|
+
console.log(`[geometry] ${def.slug} ${tierArg} verify: ${s.hits} answered by the bake, ${s.misses} built, in ${((performance.now() - t0) / 1000).toFixed(1)} s`);
|
|
91
|
+
if (s.hits === 0 || s.misses > 0) process.exitCode = 1;
|
|
92
|
+
process.exit(process.exitCode ?? 0);
|
|
93
|
+
}
|
|
94
|
+
const rec = gb.recordGeometryBake();
|
|
95
|
+
try { await visitAuthoredWorld(def, { root: ROOT, sky, element: environment.element }); } finally { rec.stop(); }
|
|
96
|
+
let vertices = 0;
|
|
97
|
+
for (const g of rec.entries.values()) vertices += (g.attributes[0]?.array.length ?? 0) / (g.attributes[0]?.itemSize ?? 1);
|
|
98
|
+
if (recordTo === undefined) throw new Error('bake-geometry: a tier child records to --record-to=<file>');
|
|
99
|
+
writeFileSync(recordTo, gb.encodeGeometryBake(rec.entries));
|
|
100
|
+
console.log(`[geometry] ${def.slug} ${tierArg}: ${rec.entries.size} geometries, ${vertices} vertices in ${((performance.now() - t0) / 1000).toFixed(1)} s`);
|
|
101
|
+
} finally {
|
|
102
|
+
environment.dispose();
|
|
103
|
+
}
|
|
104
|
+
// the built level leaves timers behind (its systems, the physics host); the bake is done, so the child ends here
|
|
105
|
+
process.exit(process.exitCode ?? 0);
|
|
106
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SHARD-PLATFORM M3 (G227): compile a hybrid shard's code-built heightfield into its shardfile's 62.5 m terrain tiles.
|
|
3
|
+
// Trusted first-party bake: the generator (src/shards/<slug>/generators/tiles.ts) runs here only; its immutable wire files go
|
|
4
|
+
// to src/shards/<slug>/assets/<sha256> and the numeric rows to src/shards/<slug>/data/tiles.json, which shard.config.ts
|
|
5
|
+
// declares. test/shards/<slug>/tiles-bake.test.ts is the byte-exact stale gate (it re-runs the generator).
|
|
6
|
+
// Usage: node --import ./scripts/sim-node-loader.mjs scripts/bake-hybrid-tiles.mjs sunscar-dunes
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { resolve } from 'node:path';
|
|
9
|
+
import { pathToFileURL } from 'node:url';
|
|
10
|
+
|
|
11
|
+
const GENERATORS = { 'sunscar-dunes': 'signalDunesTiles' };
|
|
12
|
+
const slug = process.argv[2] ?? '', name = GENERATORS[slug];
|
|
13
|
+
if (name === undefined) throw new Error(`bake-hybrid-tiles: no tile generator for "${slug}" (known: ${Object.keys(GENERATORS).join(', ')})`);
|
|
14
|
+
const root = resolve(import.meta.dirname, '..'), project = resolve(root, 'src/shards', slug);
|
|
15
|
+
const generator = await import(pathToFileURL(resolve(project, 'generators/tiles.ts')).href);
|
|
16
|
+
const baked = generator[name]();
|
|
17
|
+
const assets = resolve(project, 'assets');
|
|
18
|
+
mkdirSync(assets, { recursive: true });
|
|
19
|
+
// remove the hashes the previous bake declared and this one drops, so a rebake leaves no orphans; the folder also holds
|
|
20
|
+
// other bakes' library files (Signal's sand maps, data/sandMaps.json), which are not this bake's to remove
|
|
21
|
+
const keep = new Set(baked.assets.keys()), declared = resolve(project, 'data/tiles.json');
|
|
22
|
+
const previous = existsSync(declared) ? JSON.parse(readFileSync(declared, 'utf8')).files.map((file) => file.hash) : [];
|
|
23
|
+
for (const hash of previous) if (!keep.has(hash) && existsSync(resolve(assets, hash))) rmSync(resolve(assets, hash));
|
|
24
|
+
for (const [hash, bytes] of baked.assets) writeFileSync(resolve(assets, hash), bytes);
|
|
25
|
+
const { assets: _assets, ...metadata } = baked;
|
|
26
|
+
writeFileSync(resolve(project, 'data/tiles.json'), `${JSON.stringify(metadata)}\n`);
|
|
27
|
+
const bytes = [...baked.assets.values()].reduce((sum, b) => sum + b.length, 0);
|
|
28
|
+
console.info(`${slug} tiles: ${baked.tiles.length} tiles, ${baked.assets.size} files, ${bytes} bytes`);
|