@wildshard/sdk 0.0.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GUIDE.md +790 -0
- package/README.md +13 -5
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +365 -3
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +46 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +247 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +18 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +234 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Emit a declared scene's initial presentation using the browser's own CPU
|
|
2
|
+
// channel projection. No renderer, physics, runtime installation or clock.
|
|
3
|
+
import { readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, resolve } from 'node:path';
|
|
5
|
+
import { BufferGeometry, Group, InstancedMesh, MeshBasicMaterial } from 'three';
|
|
6
|
+
import { createClientChannelView, moverChannelValues } from '@wildshard/engine/game/plugin/clientChannelView';
|
|
7
|
+
|
|
8
|
+
export function mapRest(scene, programs, poses) {
|
|
9
|
+
const targets = new Map(), coverage = new Map(), nodes = {}, movers = new Map(poses.map(pose => [pose.id, pose]));
|
|
10
|
+
const geometry = new BufferGeometry(), material = new MeshBasicMaterial();
|
|
11
|
+
for (const row of scene.nodes) {
|
|
12
|
+
const target = row.instances === undefined ? new Group() : new InstancedMesh(geometry, material, row.instances);
|
|
13
|
+
if (row.position !== undefined) target.position.fromArray(row.position);
|
|
14
|
+
if (row.rotation !== undefined) target.rotation.set(...row.rotation, row.order ?? 'XYZ');
|
|
15
|
+
if (row.quaternion !== undefined) target.quaternion.fromArray(row.quaternion);
|
|
16
|
+
if (row.scale !== undefined) target.scale.fromArray(row.scale);
|
|
17
|
+
if (row.visible !== undefined) target.visible = row.visible;
|
|
18
|
+
if (row.matrices !== undefined && target instanceof InstancedMesh) target.instanceMatrix.array.set(row.matrices);
|
|
19
|
+
if (row.instances !== undefined) coverage.set(row.id, new Uint8Array(row.instances).fill(row.matrices === undefined ? 0 : 1));
|
|
20
|
+
targets.set(row.id, target);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
for (const program of programs) {
|
|
24
|
+
if (program.mover === undefined) throw new Error(`Map rest needs a declared mover: ${program.id}`);
|
|
25
|
+
const pose = movers.get(program.mover); if (pose === undefined) throw new Error(`Missing map rest pose ${program.mover}`);
|
|
26
|
+
const view = createClientChannelView(program, targets);
|
|
27
|
+
view.evaluate({ time: 0, delta: 0, values: moverChannelValues(view.reads, pose, {}) });
|
|
28
|
+
for (const connector of program.connectors ?? []) {
|
|
29
|
+
const slots = coverage.get(connector.target), span = connector.instances;
|
|
30
|
+
if (slots !== undefined && span !== undefined) slots.fill(1, span.start, span.start + span.capacity);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const [id, slots] of coverage) if (slots.some(value => value === 0)) throw new Error(`Incomplete map rest instance slots ${id}`);
|
|
34
|
+
for (const [id, target] of targets) {
|
|
35
|
+
nodes[id] = { position: target.position.toArray(), quaternion: target.quaternion.toArray(), scale: target.scale.toArray(), visible: target.visible,
|
|
36
|
+
...(target instanceof InstancedMesh ? { matrices: Array.from(target.instanceMatrix.array) } : {}) };
|
|
37
|
+
}
|
|
38
|
+
return { version: 1, nodes };
|
|
39
|
+
} finally { geometry.dispose(); material.dispose(); }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (process.argv[1] === import.meta.filename) {
|
|
43
|
+
const arg = process.argv.find(value => value.startsWith('--config='));
|
|
44
|
+
if (arg === undefined) throw new Error('Map rest requires --config=declared.json');
|
|
45
|
+
const configPath = resolve(arg.slice(9)), base = dirname(configPath), config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
46
|
+
const read = file => JSON.parse(readFileSync(resolve(base, file), 'utf8'));
|
|
47
|
+
const scene = read(config.scene), motion = read(config.motion), output = resolve(base, config.output);
|
|
48
|
+
mkdirSync(dirname(output), { recursive: true });
|
|
49
|
+
writeFileSync(output, `${JSON.stringify(mapRest(scene.scene ?? scene, motion.channels, motion.rest))}\n`);
|
|
50
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { KEYCHAIN_ARGS } from './chromium-keychain.mjs';
|
|
3
|
+
// Bake each shard's map from its world (SF66, G246 / G247; the look is G252's B, stylized): boot the shard in a served
|
|
4
|
+
// build, render it straight down (orthographic, the full 500 m cell centred on the origin) in 2 × 2 tiles, twice: a colour
|
|
5
|
+
// pass and a height pass (every mesh drawn with its world height). scripts/map-stylize.py turns the two into flat colours
|
|
6
|
+
// by ground type from the shard's own colour table (look/map.json "style"), with a hillshade and inked edges, and writes
|
|
7
|
+
// public/assets/<slug>/map/top.webp (1000 px, 0.5 m per pixel). The stamp (the map inputs' hash, look/map.json included, so
|
|
8
|
+
// a palette change rebakes) goes in src/shards/<slug>/look/map.baked.json. Only shards whose map inputs changed are baked
|
|
9
|
+
// unless --all or --shards is given. A shard with no "style" fails its bake: every shard owns its colour table.
|
|
10
|
+
// node scripts/bake-maps.mjs --url=<scripts/serve-build.sh --head> [--shards=a,b] [--all] [--keep=<dir>]
|
|
11
|
+
// (through scripts/browser-lane.sh; the stylizer runs under `uv run` with numpy, scipy and pillow)
|
|
12
|
+
// Bake rules (art/maps/round-1-baked-map-style/README.md): the engine renders with autoClear off, so colour and depth are
|
|
13
|
+
// cleared before every tile; the pixels are read straight after each draw; movers are drawn at rest (each mover runtime's
|
|
14
|
+
// `showRest`, in the same task as the draws).
|
|
15
|
+
import { chromium } from 'playwright';
|
|
16
|
+
import { execFileSync } from 'node:child_process';
|
|
17
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { join, resolve } from 'node:path';
|
|
19
|
+
import { saveFixture } from '@wildshard/engine/scripts/debug-settings.mjs';
|
|
20
|
+
import { installInit } from '@wildshard/engine/scripts/parity/init.mjs';
|
|
21
|
+
import { MAP_METRES, mapPixelHash, mapSettings, mapSettingsPath, mapStampPath, mapShards, mapTilesHash, writeMapStamp } from '@wildshard/engine/scripts/map-hash.mjs';
|
|
22
|
+
import { saveMapFrames } from './map-bake-frames.mjs';
|
|
23
|
+
|
|
24
|
+
const option = (name) => process.argv.find((part) => part.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
25
|
+
const root = resolve(import.meta.dirname, '..');
|
|
26
|
+
const url = option('url');
|
|
27
|
+
if (url === undefined) throw new Error('bake-maps: --url=<served build> (scripts/serve-build.sh --head)');
|
|
28
|
+
const base = url.replace(/\/?$/, '/');
|
|
29
|
+
const only = option('shards')?.split(',');
|
|
30
|
+
const keep = option('keep');
|
|
31
|
+
const TILE = 1000, HEIGHT = 900, OUT = 1000;
|
|
32
|
+
|
|
33
|
+
const stampPath = mapStampPath;
|
|
34
|
+
const todo = mapShards(root).filter(({ slug, dir }) => {
|
|
35
|
+
if (JSON.parse(readFileSync(mapSettingsPath(dir), 'utf8')).painter !== undefined) return false;
|
|
36
|
+
// G320: a map with "from" (its world GLB) is baked by scripts/bake-map-glb.mjs in Node, never from the game page
|
|
37
|
+
if (mapSettings(dir).from !== null) return false;
|
|
38
|
+
if (only) return only.includes(slug);
|
|
39
|
+
if (process.argv.includes('--all') || !existsSync(stampPath(dir))) return true;
|
|
40
|
+
const stamp = JSON.parse(readFileSync(stampPath(dir), 'utf8'));
|
|
41
|
+
return stamp.tilesHash !== mapTilesHash(dir) || typeof stamp.pixelHash !== 'string';
|
|
42
|
+
});
|
|
43
|
+
if (todo.length === 0) { console.log('bake-maps: every map is current'); process.exit(0); }
|
|
44
|
+
|
|
45
|
+
// Browser side: hide what is not the world, pose the movers at rest, render 2 × 2 orthographic tiles of the colour pass and
|
|
46
|
+
// the height pass, each tile cleared before its draw and read straight after it; retains both native canvases.
|
|
47
|
+
function bake(arg) {
|
|
48
|
+
const g = window.__wildshard.world.game, r = g.renderer, scene = g.rootScene ?? g.scene, gl = r.getContext();
|
|
49
|
+
const exposed = g.app.debug.snapshot();
|
|
50
|
+
const rest = () => { for (const [name, value] of Object.entries(exposed)) if (name.startsWith('movers.') && typeof value?.showRest === 'function') value.showRest(); };
|
|
51
|
+
const hidden = [], hide = (o) => { if (o.visible) { o.visible = false; hidden.push(o); } };
|
|
52
|
+
for (const c of g.camera.children) hide(c); // held items
|
|
53
|
+
const clouds = g.sky?.clouds; if (clouds) hide(clouds);
|
|
54
|
+
const match = (list, o) => list.some((p) => (p.endsWith('*') ? o.name.startsWith(p.slice(0, -1)) : o.name === p));
|
|
55
|
+
const kept = (o) => { for (let p = o; p; p = p.parent) if (arg.keep.includes(p.name)) return true; return false; };
|
|
56
|
+
const named = (o) => match(arg.hide, o) && !kept(o);
|
|
57
|
+
const standing = []; // the hidden meshes whose riders hide too ("hideStanding")
|
|
58
|
+
scene.traverse((o) => {
|
|
59
|
+
// the engine sky and backdrops by name (never an island or a sky isle), the shard's own hides, particles and sprites
|
|
60
|
+
const sky = o.name === 'look-dome' || (/cloud|sky|dome|backdrop/iu.test(o.name) && !/isle|island/iu.test(o.name));
|
|
61
|
+
if (named(o) && match(arg.hideStanding, o)) standing.push(o);
|
|
62
|
+
if (named(o) || sky || o.isPoints === true || o.isSprite === true) hide(o);
|
|
63
|
+
});
|
|
64
|
+
// what stands on a "hideStanding" mesh hides with it: every instance of a visible instanced mesh rooted on the top of one of
|
|
65
|
+
// that mesh's instances, within 80 % of its half width of its origin and from 4 m under to 6 m over the origin's height (a
|
|
66
|
+
// fir on the turf; never a bridge plank or an updraft streak passing under, over or beside it). Sky Reach's sky-isle firs
|
|
67
|
+
// share the archipelago's one forest.
|
|
68
|
+
const M = g.camera.matrixWorld.clone(), V = g.camera.position.clone(), zero = M.clone().makeScale(0, 0, 0);
|
|
69
|
+
const boxes = []; // per hidden instance: its origin (ox, oy, oz) and its top's reach r
|
|
70
|
+
for (const o of standing) o.traverse((m) => {
|
|
71
|
+
if (!m.isMesh || !m.geometry) return;
|
|
72
|
+
if (!m.geometry.boundingBox) m.geometry.computeBoundingBox();
|
|
73
|
+
const b = m.geometry.boundingBox, n = m.isInstancedMesh ? m.count : 1;
|
|
74
|
+
for (let k = 0; k < n; k++) {
|
|
75
|
+
if (m.isInstancedMesh) { m.getMatrixAt(k, M); M.premultiply(m.matrixWorld); } else M.copy(m.matrixWorld);
|
|
76
|
+
const box = { x0: Infinity, x1: -Infinity, y0: Infinity, y1: -Infinity, z0: Infinity, z1: -Infinity };
|
|
77
|
+
for (let c = 0; c < 8; c++) {
|
|
78
|
+
V.set(c & 1 ? b.max.x : b.min.x, c & 2 ? b.max.y : b.min.y, c & 4 ? b.max.z : b.min.z).applyMatrix4(M);
|
|
79
|
+
box.x0 = Math.min(box.x0, V.x); box.x1 = Math.max(box.x1, V.x); box.y0 = Math.min(box.y0, V.y); box.y1 = Math.max(box.y1, V.y); box.z0 = Math.min(box.z0, V.z); box.z1 = Math.max(box.z1, V.z);
|
|
80
|
+
}
|
|
81
|
+
boxes.push({ ox: M.elements[12], oy: M.elements[13], oz: M.elements[14], r: 0.4 * Math.min(box.x1 - box.x0, box.z1 - box.z0) });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const collapsed = []; // [mesh, index, original matrix]
|
|
85
|
+
if (boxes.length > 0) scene.traverse((m) => {
|
|
86
|
+
if (!m.isInstancedMesh || standing.includes(m)) return;
|
|
87
|
+
for (let p = m; p; p = p.parent) if (!p.visible) return;
|
|
88
|
+
let changed = false;
|
|
89
|
+
for (let k = 0; k < m.count; k++) {
|
|
90
|
+
m.getMatrixAt(k, M); const local = M.clone(); M.premultiply(m.matrixWorld);
|
|
91
|
+
const x = M.elements[12], y = M.elements[13], z = M.elements[14];
|
|
92
|
+
if (boxes.some((b) => Math.hypot(x - b.ox, z - b.oz) <= b.r && y >= b.oy - 4 && y <= b.oy + 6)) { collapsed.push([m, k, local]); m.setMatrixAt(k, zero); changed = true; }
|
|
93
|
+
}
|
|
94
|
+
if (changed) m.instanceMatrix.needsUpdate = true;
|
|
95
|
+
});
|
|
96
|
+
const fog = scene.fog, bg = scene.background; scene.fog = null;
|
|
97
|
+
const cam0 = g.camera, side = Math.min(arg.tile, gl.drawingBufferWidth, gl.drawingBufferHeight), ratio = r.getPixelRatio(), half = arg.metres / 2;
|
|
98
|
+
const near = arg.clipAbove === null ? 1 : arg.height - arg.clipAbove, far = arg.clipBelow === null ? arg.height + 400 : arg.height - arg.clipBelow;
|
|
99
|
+
const pass = () => {
|
|
100
|
+
const out = document.createElement('canvas'); out.width = side * 2; out.height = side * 2; const ctx = out.getContext('2d');
|
|
101
|
+
r.setRenderTarget(null); r.setScissorTest(false); r.setViewport(0, 0, side / ratio, side / ratio);
|
|
102
|
+
for (let j = 0; j < 2; j++) for (let i = 0; i < 2; i++) {
|
|
103
|
+
// straight down in the minimap's frame (Minimap.ts): north (+Z) up the image, east (−X) right; tile i from the left (+X), j from the top (+Z)
|
|
104
|
+
const cam = cam0.clone(false); cam.isPerspectiveCamera = false; cam.isOrthographicCamera = true;
|
|
105
|
+
cam.position.set(0, arg.height, 0); cam.up.set(0, 0, 1); cam.lookAt(0, 0, 0); cam.updateMatrixWorld(true);
|
|
106
|
+
const l = -half + i * half, t = half - j * half;
|
|
107
|
+
// camera space: x runs toward −X world (east), y toward +Z (north); the tile spans world X [−l−half, −l], Z [t−half, t]
|
|
108
|
+
cam.projectionMatrix.makeOrthographic(l, l + half, t, t - half, near, far);
|
|
109
|
+
cam.projectionMatrixInverse.copy(cam.projectionMatrix).invert();
|
|
110
|
+
r.clear(true, true, true); r.render(scene, cam);
|
|
111
|
+
const buf = new Uint8Array(side * side * 4); gl.readPixels(0, 0, side, side, gl.RGBA, gl.UNSIGNED_BYTE, buf);
|
|
112
|
+
const img = ctx.createImageData(side, side), row = side * 4;
|
|
113
|
+
for (let y = 0; y < side; y++) img.data.set(buf.subarray((side - 1 - y) * row, (side - y) * row), y * row); // GL rows are bottom-up
|
|
114
|
+
for (let k = 3; k < img.data.length; k += 4) img.data[k] = 255;
|
|
115
|
+
ctx.putImageData(img, i * side, j * side);
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
};
|
|
119
|
+
const Color = scene.getObjectByProperty('isMesh', true)?.material?.color?.constructor;
|
|
120
|
+
if (Color !== undefined) scene.background = new Color(arg.bg[0], arg.bg[1], arg.bg[2]);
|
|
121
|
+
let colour, height = null;
|
|
122
|
+
try {
|
|
123
|
+
// every material's clock held (as scripts/proof-*-look-parity.mjs hold it): swaying grass and drifting paint drew
|
|
124
|
+
// wherever the wall clock had them when the bake ran
|
|
125
|
+
scene.traverse((o) => {
|
|
126
|
+
for (const m of Array.isArray(o.material) ? o.material : o.material ? [o.material] : []) {
|
|
127
|
+
for (const key of ['uTime', 'time', 'uCloudTime']) if (typeof m.uniforms?.[key]?.value === 'number') m.uniforms[key].value = 10;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
rest(); colour = pass();
|
|
131
|
+
// height pass: every mesh in its world height (16 bit over R, G; B = 1 where anything is), cleared to black; the sky / sea
|
|
132
|
+
// backdrops (> 800 m across), ghosts (invisible, colour-off or depth-off transparent) and the shard's "heightHide" left out
|
|
133
|
+
const mat = g.captureHeightMaterial();
|
|
134
|
+
{
|
|
135
|
+
const hid2 = [], back = (o) => arg.heightHide.some((p) => (p.endsWith('*') ? o.name.startsWith(p.slice(0, -1)) : o.name === p));
|
|
136
|
+
scene.traverse((o) => {
|
|
137
|
+
if (!o.visible || !(o.isMesh || o.isLine)) return;
|
|
138
|
+
if (o.geometry && !o.geometry.boundingSphere) o.geometry.computeBoundingSphere?.();
|
|
139
|
+
const radius = o.geometry?.boundingSphere?.radius ?? 0, ms = Array.isArray(o.material) ? o.material : [o.material];
|
|
140
|
+
const ghost = ms.every((m) => !m || m.visible === false || m.colorWrite === false || (m.transparent && m.depthWrite === false));
|
|
141
|
+
if (radius > 800 || ghost || back(o)) { o.visible = false; hid2.push(o); }
|
|
142
|
+
});
|
|
143
|
+
const cc = r.getClearColor(cam0.position.clone()), ca = r.getClearAlpha(), tm = r.toneMapping;
|
|
144
|
+
scene.background = null; r.setClearColor(0x000000, 1); r.toneMapping = 0; scene.overrideMaterial = mat;
|
|
145
|
+
try { rest(); height = pass(); } finally { scene.overrideMaterial = null; r.setClearColor(cc, ca); r.toneMapping = tm; for (const o of hid2) o.visible = true; mat.dispose(); }
|
|
146
|
+
}
|
|
147
|
+
} finally {
|
|
148
|
+
for (const o of hidden) o.visible = true;
|
|
149
|
+
for (const [m, k, local] of collapsed) { m.setMatrixAt(k, local); m.instanceMatrix.needsUpdate = true; }
|
|
150
|
+
scene.fog = fog; scene.background = bg;
|
|
151
|
+
r.setViewport(0, 0, r.domElement.width / ratio, r.domElement.height / ratio);
|
|
152
|
+
}
|
|
153
|
+
return { side, colour, height, collapsed: collapsed.length, from: [...new Set(collapsed.map(([m]) => (m.name !== '' ? m.name : m.parent?.name ?? '?')))].join(' ') };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const browser = await chromium.launch({ args: [...KEYCHAIN_ARGS, '--use-angle=metal', '--ignore-gpu-blocklist', '--mute-audio'] });
|
|
157
|
+
mkdirSync(join(root, 'tmp'), { recursive: true });
|
|
158
|
+
const work = keep ?? mkdtempSync(join(root, 'tmp', 'bake-maps-'));
|
|
159
|
+
mkdirSync(work, { recursive: true });
|
|
160
|
+
let failed = 0;
|
|
161
|
+
try {
|
|
162
|
+
for (const { slug, dir } of todo) {
|
|
163
|
+
const settings = mapSettings(dir);
|
|
164
|
+
const context = await browser.newContext({ viewport: { width: TILE + 100, height: TILE + 100 }, deviceScaleFactor: 1, serviceWorkers: 'block' });
|
|
165
|
+
await saveFixture(context, { scope: 'device', key: 'devMode', data: true }); // Developer-only shards boot too
|
|
166
|
+
// the parity harness's page (scripts/parity/init.mjs), so two bakes of one build are the same bytes: the session's seed
|
|
167
|
+
// and Math.random pinned (a live page salts its seed from crypto: Sky Reach's cosmetic stream drew different island
|
|
168
|
+
// meshes, op-sky81), the capture clock (every frame 1/30 s of game time), the animals held where they spawn, and the
|
|
169
|
+
// world's frames held at ws:ready until the bake advances them (a wall-clock wait moved creatures, rotors and drifting
|
|
170
|
+
// things by however many frames the machine drew, op-sky82)
|
|
171
|
+
await installInit(context, { lane: 'bake-maps', sha: '', browser: 'chromium', capture: 30 });
|
|
172
|
+
const page = await context.newPage();
|
|
173
|
+
try {
|
|
174
|
+
await page.goto(`${base}?chunk=${encodeURIComponent(slug)}&mute=1&skipintro=1&nolock=1&sw=0`, { waitUntil: 'domcontentloaded' });
|
|
175
|
+
await page.waitForFunction(() => Boolean(window.__wildshard?.world?.game && !document.querySelector('.ws-load')), null, { timeout: 180_000, polling: 250 });
|
|
176
|
+
// late streamed pieces and models load with the world held; then exactly 6 s of game time (180 capture frames) run,
|
|
177
|
+
// and anything those frames streamed in loads, held again, before the bake
|
|
178
|
+
await page.waitForTimeout(6000);
|
|
179
|
+
await page.evaluate(() => window.__parity.advance(180));
|
|
180
|
+
await page.waitForTimeout(3000);
|
|
181
|
+
const colourPng = join(work, `colour-${slug}.png`), heightPng = join(work, `height-${slug}.png`), stylePath = join(work, `style-${slug}.json`);
|
|
182
|
+
const out = await saveMapFrames(page, await page.evaluateHandle(bake, { tile: TILE, height: HEIGHT, metres: MAP_METRES, bg: [0.16, 0.18, 0.2], hide: settings.hide, heightHide: settings.heightHide, keep: settings.keep, hideStanding: settings.hideStanding, clipBelow: settings.clipBelow, clipAbove: settings.clipAbove }), colourPng, heightPng);
|
|
183
|
+
const imageDir = join(root, 'public/assets', slug, 'map'), webp = join(imageDir, 'top.webp');
|
|
184
|
+
mkdirSync(imageDir, { recursive: true });
|
|
185
|
+
if (settings.style === null || !out.hasHeight) throw new Error(`${slug}: no look/map.json "style" (the colour table) or no height pass`);
|
|
186
|
+
writeFileSync(stylePath, JSON.stringify(settings.style));
|
|
187
|
+
execFileSync('uv', ['run', '--quiet', '--with', 'numpy', '--with', 'scipy', '--with', 'pillow', 'python', join(root, 'scripts/map-stylize.py'), colourPng, heightPng, stylePath, webp, String(OUT)], { stdio: 'inherit' });
|
|
188
|
+
const bytes = statSync(webp).size;
|
|
189
|
+
const stamp = { version: 1, tilesHash: mapTilesHash(dir), pixelHash: await mapPixelHash(webp), image: `/assets/${slug}/map/top.webp`, size: OUT, metres: MAP_METRES, north: '+z', east: '-x', style: `stylized:${settings.style.kind}`, bytes };
|
|
190
|
+
await writeMapStamp(dir, webp, stamp);
|
|
191
|
+
console.log(`bake-maps: ${slug} ${OUT}px ${(bytes / 1024).toFixed(0)} KB${out.collapsed > 0 ? `, ${String(out.collapsed)} instances hidden with what they stand on (${out.from})` : ''}`);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
failed++; console.error(`bake-maps: ${slug} FAILED — ${error instanceof Error ? error.message : String(error)}`);
|
|
194
|
+
} finally { await context.close(); }
|
|
195
|
+
}
|
|
196
|
+
} finally {
|
|
197
|
+
await browser.close();
|
|
198
|
+
if (keep === undefined) rmSync(work, { recursive: true, force: true });
|
|
199
|
+
}
|
|
200
|
+
if (failed > 0) process.exit(1);
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-navmesh.mjs — every shard's navmesh, baked offline (project/archive/2026-09-23-physics.md P6b).
|
|
3
|
+
//
|
|
4
|
+
// Runs each manifest's normalized world hook with the engine level context, using a render-free host. It reads
|
|
5
|
+
// static ColliderDescs from the same WorldRegistry the game fills, and the terrain grid the world cuts through
|
|
6
|
+
// the physics service. Declared water bodies remove submerged ground; moving/disabled pieces are excluded.
|
|
7
|
+
// Structure-first shards bake their registered floors without inventing a terrain plane.
|
|
8
|
+
//
|
|
9
|
+
// Output: public/assets/baked/<slug>/navmesh.bin (format below; src/shared/engine/physics/navmesh.ts reads it) + navmesh.json (the
|
|
10
|
+
// output hash and stats). Every run bakes in memory and writes only differing bytes. Offline: run it after a builder / terrain change and commit the output.
|
|
11
|
+
//
|
|
12
|
+
// node --experimental-transform-types --import ./scripts/bake-loader.mjs scripts/bake-navmesh.mjs [--check] [slug…]
|
|
13
|
+
//
|
|
14
|
+
// Format (little-endian): 'WSNM' u32 version=1 · u32 layers · then per layer:
|
|
15
|
+
// f32 radius · f32 height · f32 climb · f32 cellSize · f32 cellHeight · f32 origin[3] · f32 tileSize · u32 tiles · per tile:
|
|
16
|
+
// i32 tileX · i32 tileY · f32 bounds[6] · u32 nVerts · u32 nPolys · u32 nDetailVerts · u32 nDetailTris ·
|
|
17
|
+
// u16[nVerts·3] vertices (1 cm steps above bounds.min) · per poly: u8 nv · u8 area · u16 flags · u16[nv] vertex · u16[nv] neis ·
|
|
18
|
+
// per poly: u32 detail verticesBase · u16 verticesCount · u32 trianglesBase · u16 trianglesCount ·
|
|
19
|
+
// u16[nDetailVerts·3] detail vertices (1 cm, same frame) · u8[nDetailTris·4] detail triangles (3 local indices + edge flags)
|
|
20
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
21
|
+
import { byteWriter, outputHash, jsonBytes } from '@wildshard/engine/scripts/bake-output.mjs';
|
|
22
|
+
import { resolve } from 'node:path';
|
|
23
|
+
import { pathToFileURL } from 'node:url';
|
|
24
|
+
import { brotliCompressSync, gzipSync } from 'node:zlib';
|
|
25
|
+
import { visitAuthoredWorld } from './bake/worldHost.mjs';
|
|
26
|
+
import { prepareNativeScalarBlocks } from './bake/nativeWorld.mjs';
|
|
27
|
+
import { installBakeEnvironment } from './bake/environment.mjs';
|
|
28
|
+
import { bakeNavigation } from '@wildshard/sdk/bake/navigation';
|
|
29
|
+
import { navmeshGroundExclusion } from './bake/navmeshGround.ts';
|
|
30
|
+
|
|
31
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
32
|
+
const check = process.argv.includes('--check');
|
|
33
|
+
const only = process.argv.slice(2).filter((a) => !a.startsWith('--'));
|
|
34
|
+
const VERSION = 1;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The agent classes per shard: a creature paths on the smallest layer whose radius covers its own (src/shared/engine/physics/navmesh.ts;
|
|
38
|
+
* the largest when none does). Motor capsule radii (src/shared/engine/physics/creatures.ts: min(bodyRadius, bodyHalfLen) × scale): crab
|
|
39
|
+
* 0.22, monkey 0.16, sailor 0.26, captain 0.3, deer / boar 0.33, bear 0.36, elk 0.52. The erosion is whole voxels
|
|
40
|
+
* (cellSize 0.25): round(radius / cellSize) — 0.3 erodes 0.25 m, 0.5 erodes 0.5 m; the motor absorbs the rest. Climb and slope are the motor's (step 0.3 m, the plan's 40°); height is
|
|
41
|
+
* the clearance a creature needs under a deck or a hold's beams. Pine Hollow's herds are all big: one layer — a second
|
|
42
|
+
* would double its ~110 KB (the plan's budget: ≤ 150 KB per shard on the wire); its 1 770 trunks are most of its polys.
|
|
43
|
+
*/
|
|
44
|
+
const SHARD_LAYERS = {
|
|
45
|
+
'driftwood-isle': [
|
|
46
|
+
{ name: 'small', radius: 0.3, height: 1.8, climb: 0.3, slope: 40 }, // crabs, monkeys, sailors, the captain
|
|
47
|
+
{ name: 'large', radius: 0.5, height: 1.8, climb: 0.3, slope: 40 }, // boar, deer, bear
|
|
48
|
+
],
|
|
49
|
+
// Nalati (NALATI-MERGE P3): one layer — wolves 0.16–0.22, sheep, the dog, the leopards 0.17–0.26, the mares 0.29–0.31;
|
|
50
|
+
// the stallion (0.32) and Kokbori (0.49) path on it too (a second 0.5 m layer is +88 KB brotli: 216 KB, past the
|
|
51
|
+
// budget). Climb 0.4: recast calls a cell a ledge when its neighbours' floors span more than the climb, and across two
|
|
52
|
+
// 0.25 m cells that caps the slope at atan(climb / 0.5) — 31° at 0.3, where Nalati's roads and knolls run 32–39°
|
|
53
|
+
// (the bridge's own north approach is 34°); 0.4 walks to ~38.7°, 5 cm over the motors' step
|
|
54
|
+
'nalati-grasslands': [{ name: 'small', radius: 0.3, height: 1.8, climb: 0.4, slope: 40 }],
|
|
55
|
+
default: [{ name: 'large', radius: 0.5, height: 1.8, climb: 0.3, slope: 40 }],
|
|
56
|
+
};
|
|
57
|
+
const layersFor = (slug) => JSON.parse(process.env.NAVMESH_LAYERS ?? 'null') ?? SHARD_LAYERS[slug] ?? SHARD_LAYERS.default;
|
|
58
|
+
/** recast's knobs (navcat README's table); simplification and detail error are loose — the ground's height comes from
|
|
59
|
+
* heightAt / the motor, the navmesh only has to say where a creature can go */
|
|
60
|
+
const GEN = { cellSize: 0.25, cellHeight: 0.1, tileSizeVoxels: 128, minRegionArea: 24, mergeRegionArea: 64, maxSimplificationError: 2.0, maxEdgeLength: 24, maxVerticesPerPoly: 6, detailSampleDistance: 3, detailSampleMaxError: 0.8, ...JSON.parse(process.env.NAVMESH_GEN ?? '{}') };
|
|
61
|
+
|
|
62
|
+
// ── the game's modules in Node: a DOM that draws nothing, /assets read from public/ ──────────────────────────────────
|
|
63
|
+
const noop = () => undefined;
|
|
64
|
+
const environment = installBakeEnvironment(ROOT), el = environment.element;
|
|
65
|
+
const src = (p) => import(pathToFileURL(resolve(ROOT, 'src', p)).href);
|
|
66
|
+
|
|
67
|
+
const THREE = await import('three');
|
|
68
|
+
const { ConvexHull } = await import('three/examples/jsm/math/ConvexHull.js');
|
|
69
|
+
const registry = await src('game/client/shard/registry.ts');
|
|
70
|
+
const { SHARDS } = await src('shards.generated.ts');
|
|
71
|
+
const HF = await src('engine/shared/world/Heightfield.ts');
|
|
72
|
+
const BT = await src('engine/shared/world/BakedTerrain.ts');
|
|
73
|
+
const { bakedTerrainSource } = await src('engine/shared/world/bakedTerrainField.ts');
|
|
74
|
+
const { TERRAIN_RES, CHUNK_SIZE } = await src('engine/shared/core/config.ts');
|
|
75
|
+
const { treadBoxes } = await src('engine/shared/physics/pieces.ts');
|
|
76
|
+
|
|
77
|
+
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) },
|
|
78
|
+
{ 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 });
|
|
79
|
+
|
|
80
|
+
// The shared owned world seam is also used by authored-world extraction.
|
|
81
|
+
const shardColliders = (def) => visitAuthoredWorld(def, { root: ROOT, sky, element: el });
|
|
82
|
+
|
|
83
|
+
// ── triangles ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
84
|
+
class Soup {
|
|
85
|
+
positions = []; indices = [];
|
|
86
|
+
vert(x, y, z) { this.positions.push(x, y, z); return this.positions.length / 3 - 1; }
|
|
87
|
+
/** a triangle facing up (+Y normal) — recast's walkable test is the normal's y */
|
|
88
|
+
tri(a, b, c) { this.indices.push(a, b, c); }
|
|
89
|
+
/** a face of a convex solid, wound to face away from `centre` */
|
|
90
|
+
solidTri(a, b, c, centre) {
|
|
91
|
+
const P = this.positions, ax = P[a * 3], ay = P[a * 3 + 1], az = P[a * 3 + 2];
|
|
92
|
+
const ux = P[b * 3] - ax, uy = P[b * 3 + 1] - ay, uz = P[b * 3 + 2] - az, vx = P[c * 3] - ax, vy = P[c * 3 + 1] - ay, vz = P[c * 3 + 2] - az;
|
|
93
|
+
const nx = uy * vz - uz * vy, ny = uz * vx - ux * vz, nz = ux * vy - uy * vx;
|
|
94
|
+
const mx = (ax + P[b * 3] + P[c * 3]) / 3 - centre.x, my = (ay + P[b * 3 + 1] + P[c * 3 + 1]) / 3 - centre.y, mz = (az + P[b * 3 + 2] + P[c * 3 + 2]) / 3 - centre.z;
|
|
95
|
+
if (nx * mx + ny * my + nz * mz >= 0) this.indices.push(a, b, c); else this.indices.push(a, c, b);
|
|
96
|
+
}
|
|
97
|
+
/** a convex solid from its points (world space): the hull's faces */
|
|
98
|
+
convex(points) {
|
|
99
|
+
if (points.length < 4) return;
|
|
100
|
+
const hull = new ConvexHull().setFromPoints(points);
|
|
101
|
+
const centre = new THREE.Vector3();
|
|
102
|
+
for (const p of points) centre.add(p);
|
|
103
|
+
centre.divideScalar(points.length);
|
|
104
|
+
for (const f of hull.faces) {
|
|
105
|
+
const vs = []; let e = f.edge;
|
|
106
|
+
do { vs.push(e.head().point); e = e.next; } while (e !== f.edge);
|
|
107
|
+
const ids = vs.map((p) => this.vert(p.x, p.y, p.z));
|
|
108
|
+
for (let i = 1; i + 1 < ids.length; i++) this.solidTri(ids[0], ids[i], ids[i + 1], centre);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const _q = new THREE.Quaternion();
|
|
114
|
+
function orient(d) {
|
|
115
|
+
if (d.rot) return _q.set(d.rot.x, d.rot.y, d.rot.z, d.rot.w);
|
|
116
|
+
return _q.setFromAxisAngle(new THREE.Vector3(0, 1, 0), d.yaw ?? 0);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** One ColliderDesc into the soup, as a closed solid. */
|
|
120
|
+
function addDesc(soup, d) {
|
|
121
|
+
if (d.kind === 'treads') { for (const b of treadBoxes(d)) addDesc(soup, b); return; }
|
|
122
|
+
const q = orient(d).clone(), c = new THREE.Vector3(d.x, d.y, d.z);
|
|
123
|
+
const at = (x, y, z) => new THREE.Vector3(x, y, z).applyQuaternion(q).add(c);
|
|
124
|
+
switch (d.kind) {
|
|
125
|
+
case 'box': {
|
|
126
|
+
const pts = [];
|
|
127
|
+
for (const sx of [-1, 1]) for (const sy of [-1, 1]) for (const sz of [-1, 1]) pts.push(at(sx * d.hx, sy * d.hy, sz * d.hz));
|
|
128
|
+
soup.convex(pts);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
case 'capsule': case 'ball': {
|
|
132
|
+
// an octagonal prism round the axis, capped a radius past each end (a ball: the same, zero length)
|
|
133
|
+
const hh = d.kind === 'capsule' ? d.halfHeight : 0, r = d.radius, pts = [];
|
|
134
|
+
for (let i = 0; i < 8; i++) {
|
|
135
|
+
const a = (i / 8) * Math.PI * 2, x = Math.cos(a) * r, z = Math.sin(a) * r;
|
|
136
|
+
pts.push(at(x, hh, z), at(x, -hh, z));
|
|
137
|
+
}
|
|
138
|
+
pts.push(at(0, hh + r, 0), at(0, -hh - r, 0));
|
|
139
|
+
soup.convex(pts);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
case 'hull': {
|
|
143
|
+
const pts = [];
|
|
144
|
+
for (let i = 0; i < d.points.length; i += 3) pts.push(at(d.points[i], d.points[i + 1], d.points[i + 2]));
|
|
145
|
+
soup.convex(pts);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
case 'trimesh': {
|
|
149
|
+
// a floor you walk inside or over: every triangle faces up
|
|
150
|
+
const base = soup.positions.length / 3;
|
|
151
|
+
for (let i = 0; i < d.vertices.length; i += 3) { const p = at(d.vertices[i], d.vertices[i + 1], d.vertices[i + 2]); soup.vert(p.x, p.y, p.z); }
|
|
152
|
+
for (let i = 0; i < d.indices.length; i += 3) {
|
|
153
|
+
const a = base + d.indices[i], b = base + d.indices[i + 1], cc = base + d.indices[i + 2];
|
|
154
|
+
const P = soup.positions;
|
|
155
|
+
const ny = (P[cc * 3] - P[a * 3]) * (P[b * 3 + 2] - P[a * 3 + 2]) - (P[b * 3] - P[a * 3]) * (P[cc * 3 + 2] - P[a * 3 + 2]);
|
|
156
|
+
if (ny >= 0) soup.tri(a, b, cc); else soup.tri(a, cc, b);
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
default: throw new Error(`bake-navmesh: unknown collider kind ${d.kind}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Where the ground is under water: the sea (an ocean shard) or the pond — inside the square src/client/engine/world/pondGrid.ts draws
|
|
166
|
+
* (2r + 30 m across) and below its surface; 0.25 m of margin, as AnimalManager's `isDry`. (A pond shard's valleys lower
|
|
167
|
+
* than the pond elsewhere are dry land: no water is drawn there, though `isDry` still calls them wet.)
|
|
168
|
+
*/
|
|
169
|
+
function wetTest(def, exclusion) {
|
|
170
|
+
if (exclusion !== undefined) return exclusion;
|
|
171
|
+
const wl = HF.waterLevel() + 0.25;
|
|
172
|
+
if (def.ocean) return (_x, _z, y) => y <= wl;
|
|
173
|
+
if (!HF.hasPond()) return () => false;
|
|
174
|
+
const P = HF.POND, half = P.r + 15;
|
|
175
|
+
return (x, z, y) => y <= wl && Math.abs(x - P.x) <= half && Math.abs(z - P.z) <= half;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The physics ground's triangles (src/shared/engine/physics/terrain.ts: the mesh's vertices, the (x0,z1)–(x1,z0) diagonal), dry ones only. */
|
|
179
|
+
function addTerrain(soup, grid, wet) {
|
|
180
|
+
const res = TERRAIN_RES, size = CHUNK_SIZE, d = size / (res - 1), half = size / 2;
|
|
181
|
+
if (grid === null) return 0;
|
|
182
|
+
const base = soup.positions.length / 3;
|
|
183
|
+
for (let iz = 0; iz < res; iz++) for (let ix = 0; ix < res; ix++) soup.vert(ix * d - half, grid[iz * res + ix], iz * d - half);
|
|
184
|
+
let dropped = 0;
|
|
185
|
+
const tri = (a, b, c) => {
|
|
186
|
+
const P = soup.positions, m = (k) => (P[(base + a) * 3 + k] + P[(base + b) * 3 + k] + P[(base + c) * 3 + k]) / 3;
|
|
187
|
+
if (wet(m(0), m(2), m(1))) { dropped++; return; }
|
|
188
|
+
soup.tri(base + a, base + b, base + c);
|
|
189
|
+
};
|
|
190
|
+
for (let iz = 0; iz < res - 1; iz++) for (let ix = 0; ix < res - 1; ix++) {
|
|
191
|
+
const i00 = iz * res + ix, i10 = i00 + 1, i01 = i00 + res, i11 = i01 + 1;
|
|
192
|
+
tri(i00, i01, i10); // up-facing: (x0,z0) → (x0,z1) → (x1,z0)
|
|
193
|
+
tri(i10, i01, i11);
|
|
194
|
+
}
|
|
195
|
+
return dropped;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ── main ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
199
|
+
const output = byteWriter(check, 'bake-navmesh');
|
|
200
|
+
for (const def of SHARDS.filter(registry.playable)) {
|
|
201
|
+
if (only.length > 0 && !only.includes(def.slug)) continue;
|
|
202
|
+
prepareNativeScalarBlocks(def, ROOT);
|
|
203
|
+
const exclusion = navmeshGroundExclusion(def.navmesh,def.ground.terrain,def.scalarBlocks);
|
|
204
|
+
const bakedFile = resolve(ROOT, 'public/assets/baked', def.slug, 'terrain.bin');
|
|
205
|
+
const required = def.ground.terrain === undefined ? null : bakedTerrainSource(def.ground.terrain);
|
|
206
|
+
if (!existsSync(bakedFile) && required === null && def.ground.structures === undefined) throw new Error(`bake-navmesh: ${def.slug}/terrain.bin missing — run scripts/bake-chunk.mjs`);
|
|
207
|
+
const t0 = performance.now();
|
|
208
|
+
registry.setActiveChunk(def.slug);
|
|
209
|
+
if (existsSync(bakedFile)) {
|
|
210
|
+
const buf = readFileSync(bakedFile);
|
|
211
|
+
const grid = BT.parseBakedTerrain(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
|
|
212
|
+
if (!grid) throw new Error(`bake-navmesh: ${def.slug}/terrain.bin does not parse`);
|
|
213
|
+
BT.installBakedGrid(grid); // Admit required manifest ground as well as the selected Heightfield.
|
|
214
|
+
} else if (required !== null) {
|
|
215
|
+
const file = resolve(ROOT, 'src/shards', def.slug, 'data/nativeGround.generated.json');
|
|
216
|
+
const row = JSON.parse(readFileSync(file,'utf8'));
|
|
217
|
+
if (row.version !== 1 || row.res !== 256 || row.size !== 500 || row.seed !== required.seed
|
|
218
|
+
|| !Array.isArray(row.heights) || row.heights.length !== 256 ** 2
|
|
219
|
+
|| row.heights.some(value => !Number.isFinite(value) || Math.abs(value) > 250 || Math.fround(value) !== value)) {
|
|
220
|
+
throw new Error(`Required navigation ground ${def.slug} has invalid recipe samples`);
|
|
221
|
+
}
|
|
222
|
+
const splat = new Uint8Array(256 ** 2 * 4);
|
|
223
|
+
for (let i = 0; i < 256 ** 2; i++) splat[i * 4] = 255;
|
|
224
|
+
BT.installBakedGrid({res:256,size:500,seed:row.seed,landscapeHash:0,heights:Float32Array.from(row.heights),splat,undergrowth:null});
|
|
225
|
+
}
|
|
226
|
+
const { colliders, ground, counts } = await shardColliders(def);
|
|
227
|
+
if (process.env.NAVMESH_DUMP) { // debugging: NAVMESH_DUMP=x,z,r prints the colliders centred within r m of (x, z)
|
|
228
|
+
const [dx, dz, dr] = process.env.NAVMESH_DUMP.split(',').map(Number);
|
|
229
|
+
for (const d of colliders) { const c = d.kind === 'treads' ? d.from : d; if (Math.hypot(c.x - dx, c.z - dz) < dr) console.log(JSON.stringify(d, (k, v) => (v instanceof Float32Array ? `[${v.length / 3} points]` : typeof v === 'number' ? Math.round(v * 100) / 100 : v))); }
|
|
230
|
+
}
|
|
231
|
+
const soup = new Soup();
|
|
232
|
+
const dropped = addTerrain(soup, ground, wetTest(def, exclusion));
|
|
233
|
+
for (const d of colliders) addDesc(soup, d);
|
|
234
|
+
// the navmesh is baked in the authored frame (src/shared/engine/physics/navmesh.ts queries `y − datum`): a level shifted at
|
|
235
|
+
// runtime (its terrain field's `datum`, Driftwood's G164 drop) builds shifted, so its soup is raised back by the datum
|
|
236
|
+
const datum = def.ground.terrain?.datum ?? 0;
|
|
237
|
+
if (datum !== 0) for (let i = 1; i < soup.positions.length; i += 3) soup.positions[i] -= datum;
|
|
238
|
+
const LAYERS = layersFor(def.slug);
|
|
239
|
+
const dir = resolve(ROOT, 'public/assets/baked', def.slug), jsonFile = resolve(dir, 'navmesh.json'), binFile = resolve(dir, 'navmesh.bin');
|
|
240
|
+
const tIn = performance.now() - t0;
|
|
241
|
+
console.log(`[navmesh] ${def.slug}: ${colliders.length} colliders (${Object.entries(counts).map(([k, n]) => `${n} ${k}`).join(', ')}), ${soup.indices.length / 3} triangles (${dropped} wet terrain triangles left out) in ${tIn.toFixed(0)} ms`);
|
|
242
|
+
const t1 = performance.now();
|
|
243
|
+
const { bytes, layers } = bakeNavigation(soup, LAYERS, GEN);
|
|
244
|
+
for (const layer of layers) console.log(`[navmesh] ${def.slug} ${layer.name} r=${layer.radius}: ${layer.tiles} tiles, ${layer.polys} polys, ${layer.detailTris} detail tris`);
|
|
245
|
+
console.log(`[navmesh] ${def.slug}: all layers in ${((performance.now() - t1) / 1000).toFixed(1)} s`);
|
|
246
|
+
const gz = gzipSync(bytes, { level: 9 }).byteLength, br = brotliCompressSync(bytes).byteLength;
|
|
247
|
+
output.put(binFile, bytes);
|
|
248
|
+
output.put(jsonFile, jsonBytes({ version: VERSION, hash: outputHash(bytes), bytes: bytes.byteLength, layers }, 1));
|
|
249
|
+
console.log(`[navmesh] ${def.slug}: baked navmesh.bin ${(bytes.byteLength / 1024).toFixed(1)} KB (${(gz / 1024).toFixed(1)} KB gzip, ${(br / 1024).toFixed(1)} KB brotli)`);
|
|
250
|
+
}
|
|
251
|
+
output.finish();
|
|
252
|
+
|
|
253
|
+
// Runtime imports install page-lifetime services (for example the reload heartbeat). A CLI has no page.
|
|
254
|
+
const { app: bakeApp } = await src('engine/client/app/runtime.ts');
|
|
255
|
+
bakeApp.engineScope.dispose();
|
|
256
|
+
const { pageScope } = await src('engine/shared/app/resources.ts');
|
|
257
|
+
pageScope.dispose();
|
|
258
|
+
|
|
259
|
+
environment.dispose();
|