@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,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-voxel-ao.mjs — the voxel AO of the code-built worlds (Nalati's, Driftwood's), at build time (SF67 fix 3, E461).
|
|
3
|
+
//
|
|
4
|
+
// Both worlds marched voxel AO for every painted model on the main thread at load (the audit's voxelAO.ts:62 owner, in
|
|
5
|
+
// Driftwood's lowpolyKit models and Nalati's camps, outcrops, dressing and Kurgan). The AO is a pure function of each
|
|
6
|
+
// geometry's inputs, so this builds the shard's real world in Node (scripts/bake/worldHost.mjs, the navmesh baker's host;
|
|
7
|
+
// once per tier, a child process each, the tier set before the modules load) while src/client/engine/world/voxelAO.ts records
|
|
8
|
+
// every result under a hash of its inputs, and writes one table (both tiers' entries) to the shard's own asset folder. At load the shard adds
|
|
9
|
+
// the table before it builds (`addVoxelAOBake`); a geometry whose inputs hash differently (a miss) marches as before.
|
|
10
|
+
// Every run bakes in memory and writes only differing bytes; --check (bake-check.mjs) fails when a source changed
|
|
11
|
+
// without a rebake.
|
|
12
|
+
//
|
|
13
|
+
// node --experimental-transform-types --import ./scripts/bake-loader.mjs scripts/bake-voxel-ao.mjs [--check | --verify] [slug…]
|
|
14
|
+
// (--verify: build as the page does, with the committed table, and fail unless every AO call is answered by it)
|
|
15
|
+
import { spawnSync } from 'node:child_process';
|
|
16
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
17
|
+
import { tmpdir } from 'node:os';
|
|
18
|
+
import { join, resolve } from 'node:path';
|
|
19
|
+
import { pathToFileURL } from 'node:url';
|
|
20
|
+
import { brotliCompressSync } from 'node:zlib';
|
|
21
|
+
import { byteWriter } from '@wildshard/engine/scripts/bake-output.mjs';
|
|
22
|
+
|
|
23
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
24
|
+
const TIERS = ['phone', 'desktop'];
|
|
25
|
+
/** where each shard keeps its table, one for every tier (the keys are the inputs): a folder the shard owns (its manifest's
|
|
26
|
+
* assetGlobs; the shard sandbox) */
|
|
27
|
+
const OUTPUT = {
|
|
28
|
+
'nalati-grasslands': 'public/assets/nalati/baked/voxel-ao.bin',
|
|
29
|
+
// beside the Blender island's other build outputs; the page's G164 boot hits every kit (the key drops the trig last bits
|
|
30
|
+
// that differ between Node and the browsers, SF67 part 3)
|
|
31
|
+
'driftwood-isle': 'public/assets/models/driftwood-blender/voxel-ao.bin',
|
|
32
|
+
};
|
|
33
|
+
const arg = (name) => process.argv.find((a) => a.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
34
|
+
const tierArg = arg('tier'), slugArg = arg('slug'), recordTo = arg('record-to');
|
|
35
|
+
|
|
36
|
+
if (tierArg === undefined) {
|
|
37
|
+
// the parent: one child per shard and tier (TIER is read once, as each module loads); the children record, the parent
|
|
38
|
+
// merges the tiers' entries into the shard's one table
|
|
39
|
+
const only = process.argv.slice(2).filter((a) => !a.startsWith('--'));
|
|
40
|
+
const verify = process.argv.includes('--verify'), check = process.argv.includes('--check');
|
|
41
|
+
const ao = await import(pathToFileURL(resolve(ROOT, 'src/client/engine/world/voxelAO.ts')).href);
|
|
42
|
+
const output = byteWriter(check, 'bake-voxel-ao');
|
|
43
|
+
const scratch = mkdtempSync(join(tmpdir(), 'bake-voxel-ao-'));
|
|
44
|
+
let failed = false;
|
|
45
|
+
try {
|
|
46
|
+
for (const [slug, out] of Object.entries(OUTPUT)) {
|
|
47
|
+
if (only.length > 0 && !only.includes(slug)) continue;
|
|
48
|
+
const merged = new Map();
|
|
49
|
+
for (const tier of TIERS) {
|
|
50
|
+
const file = join(scratch, `${slug}.${tier}.bin`);
|
|
51
|
+
const r = spawnSync(process.execPath, [...process.execArgv, import.meta.filename, `--tier=${tier}`, `--slug=${slug}`, ...(verify ? ['--verify'] : [`--record-to=${file}`])], { cwd: ROOT, stdio: 'inherit' });
|
|
52
|
+
if (r.status !== 0) { failed = true; continue; }
|
|
53
|
+
if (verify) continue;
|
|
54
|
+
const b = readFileSync(file);
|
|
55
|
+
const table = ao.decodeVoxelAOBake(b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength));
|
|
56
|
+
if (table === null) throw new Error(`bake-voxel-ao: ${slug} ${tier} recorded no table`);
|
|
57
|
+
for (const [key, k] of table) merged.set(key, k);
|
|
58
|
+
}
|
|
59
|
+
if (verify || failed) continue;
|
|
60
|
+
const bytes = ao.encodeVoxelAOBake(merged);
|
|
61
|
+
output.put(resolve(ROOT, out), bytes);
|
|
62
|
+
console.log(`[voxel-ao] ${slug}: ${merged.size} geometries (both tiers), ${(bytes.length / 1024).toFixed(1)} KB (${(brotliCompressSync(bytes).length / 1024).toFixed(1)} KB brotli)`);
|
|
63
|
+
}
|
|
64
|
+
} finally {
|
|
65
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
66
|
+
}
|
|
67
|
+
if (!verify) output.finish();
|
|
68
|
+
if (failed) process.exitCode = 1;
|
|
69
|
+
} else {
|
|
70
|
+
if (!TIERS.includes(tierArg)) throw new Error(`bake-voxel-ao: unknown tier ${tierArg}`);
|
|
71
|
+
if (slugArg === undefined || !(slugArg in OUTPUT)) throw new Error(`bake-voxel-ao: unknown shard ${slugArg}`);
|
|
72
|
+
const { installBakeEnvironment } = await import('./bake/environment.mjs');
|
|
73
|
+
const environment = installBakeEnvironment(ROOT);
|
|
74
|
+
try {
|
|
75
|
+
const src = (p) => import(pathToFileURL(resolve(ROOT, 'src', p)).href);
|
|
76
|
+
if (tierArg !== 'desktop') (await src('engine/client/core/tier.ts')).initializeTier(tierArg); // desktop is Node's own tier (navigator 'node')
|
|
77
|
+
const THREE = await import('three');
|
|
78
|
+
const { visitAuthoredWorld } = await import('./bake/worldHost.mjs');
|
|
79
|
+
const registry = await src('game/client/shard/registry.ts');
|
|
80
|
+
const { SHARDS } = await src('shards.generated.ts');
|
|
81
|
+
const HF = await src('engine/shared/world/Heightfield.ts');
|
|
82
|
+
const BT = await src('engine/shared/world/BakedTerrain.ts');
|
|
83
|
+
const ao = await src('engine/client/world/voxelAO.ts');
|
|
84
|
+
const def = SHARDS.find((s) => s.slug === slugArg);
|
|
85
|
+
if (def === undefined) throw new Error(`bake-voxel-ao: no shard ${slugArg}`);
|
|
86
|
+
registry.setActiveChunk(def.slug);
|
|
87
|
+
const terrain = resolve(ROOT, 'public/assets/baked', def.slug, 'terrain.bin');
|
|
88
|
+
if (existsSync(terrain)) {
|
|
89
|
+
const buf = readFileSync(terrain);
|
|
90
|
+
const grid = BT.parseBakedTerrain(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
|
|
91
|
+
if (!grid) throw new Error(`bake-voxel-ao: ${def.slug}/terrain.bin does not parse`);
|
|
92
|
+
HF._installBakedTerrain(BT.bakedSamplers(grid));
|
|
93
|
+
}
|
|
94
|
+
const noop = () => undefined;
|
|
95
|
+
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) },
|
|
96
|
+
{ 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 });
|
|
97
|
+
const t0 = performance.now();
|
|
98
|
+
if (process.argv.includes('--verify')) {
|
|
99
|
+
// the page's path: the shard adds its committed table and builds; every AO call must be answered by it
|
|
100
|
+
await visitAuthoredWorld(def, { root: ROOT, sky, element: environment.element });
|
|
101
|
+
const s = ao.voxelAOBakeStats();
|
|
102
|
+
console.log(`[voxel-ao] ${def.slug} ${tierArg} verify: ${s.hits} answered by the bake, ${s.misses} marched, in ${((performance.now() - t0) / 1000).toFixed(1)} s`);
|
|
103
|
+
if (s.hits === 0 || s.misses > 0) process.exitCode = 1;
|
|
104
|
+
process.exit(process.exitCode ?? 0);
|
|
105
|
+
}
|
|
106
|
+
const rec = ao.recordVoxelAO();
|
|
107
|
+
try { await visitAuthoredWorld(def, { root: ROOT, sky, element: environment.element }); } finally { rec.stop(); }
|
|
108
|
+
let vertices = 0;
|
|
109
|
+
for (const k of rec.entries.values()) vertices += k.length;
|
|
110
|
+
if (recordTo === undefined) throw new Error('bake-voxel-ao: a tier child records to --record-to=<file>');
|
|
111
|
+
const bytes = ao.encodeVoxelAOBake(rec.entries);
|
|
112
|
+
writeFileSync(recordTo, bytes);
|
|
113
|
+
console.log(`[voxel-ao] ${def.slug} ${tierArg}: ${rec.entries.size} geometries, ${vertices} vertices in ${((performance.now() - t0) / 1000).toFixed(1)} s`);
|
|
114
|
+
} finally {
|
|
115
|
+
environment.dispose();
|
|
116
|
+
}
|
|
117
|
+
// the built level leaves timers behind (its systems, the physics host); the bake is done, so the child ends here
|
|
118
|
+
process.exit(process.exitCode ?? 0);
|
|
119
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bake-water-ripples.mjs — the pond's tiling ripple normal + foam map at build time (SHARD-PLATFORM frame floor).
|
|
3
|
+
//
|
|
4
|
+
// src/client/engine/world/water/ripples.ts marched a 256² nine-octave value-noise fbm on the main thread the first time a
|
|
5
|
+
// pond or a forest page's water asked for it (~25 ms of Pine's forest-page world step at 4× CPU). The pixels are a pure
|
|
6
|
+
// function of src/client/engine/world/water/ripplePixels.ts, so this runs the page's own function in Node (V8, as Chromium) and
|
|
7
|
+
// writes the raw RGBA bytes to public/assets/baked/common/water-ripples.bin. A page that fetched it
|
|
8
|
+
// (ripples.ts preloadWaterRipples, boot/bakedTextures.ts bakedBytes) builds the byte-identical texture without the
|
|
9
|
+
// march. Raw bytes, not an image: no phone / KTX2 copy can make it lossy. Writes only differing bytes; --check
|
|
10
|
+
// (bake-check.mjs) fails when stale.
|
|
11
|
+
//
|
|
12
|
+
// node --experimental-transform-types --import ./scripts/bake-loader.mjs scripts/bake-water-ripples.mjs [--check]
|
|
13
|
+
import { resolve } from 'node:path';
|
|
14
|
+
import { pathToFileURL } from 'node:url';
|
|
15
|
+
import { byteWriter } from '@wildshard/engine/scripts/bake-output.mjs';
|
|
16
|
+
|
|
17
|
+
const ROOT = resolve(import.meta.dirname, '..');
|
|
18
|
+
const check = process.argv.includes('--check');
|
|
19
|
+
const ripples = await import(pathToFileURL(resolve(ROOT, 'src/client/engine/world/water/ripplePixels.ts')).href);
|
|
20
|
+
const { WATER_RIPPLES_URL } = await import(pathToFileURL(resolve(ROOT, 'src/client/engine/boot/bakedApi.ts')).href);
|
|
21
|
+
const bytes = ripples.waterRipplePixels();
|
|
22
|
+
if (bytes.length !== ripples.WATER_RIPPLES_N * ripples.WATER_RIPPLES_N * 4) throw new Error('bake-water-ripples: wrong map size');
|
|
23
|
+
const output = byteWriter(check, 'bake-water-ripples');
|
|
24
|
+
output.put(resolve(ROOT, `public${WATER_RIPPLES_URL}`), bytes);
|
|
25
|
+
output.finish();
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Blender models: the scripts are the source (M10, E315)
|
|
2
|
+
|
|
3
|
+
**Every Blender-made model is a headless `bpy` script. The GLB it exports is committed, and a `.blend` never is.** The
|
|
4
|
+
reasoning is in [docs/design/blender-practice.md](../../docs/design/blender-practice.md).
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
scripts/blender/
|
|
8
|
+
build.sh the one runner: build.sh <target>… | --check | --all | --list | --save-blend | --no-copy
|
|
9
|
+
targets.json target → script, args, pre / post steps, sources, outputs, lock; Blender 5.2.1 pinned
|
|
10
|
+
lib/ shared: export-scene.mjs (the game's data → the cache), glb.py (a minimal glTF writer),
|
|
11
|
+
glb-digest.mjs (--check's comparison), save_blend.py (--save-blend)
|
|
12
|
+
driftwood-isle/ the spawn cove: build_island.py, assets.py, export.mjs (its half of the export), post.sh
|
|
13
|
+
pine-hollow/ trees/, crags/ (kit + cave), weapons/ (rifle, knife), export.mjs (its half of the export)
|
|
14
|
+
nine-dragon-stack/ viewmodel/ (the first-person arms: fp-rig.glb's sources, README), lab/fei_zhua.py (lab only)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- **Build:** `bash scripts/blender/build.sh <target>`. `--list` shows the targets. `pnpm blender:island` is
|
|
18
|
+
`build.sh driftwood-isle/island`. Script flags pass through: `build.sh pine-hollow/trees --quick --only=trees`.
|
|
19
|
+
- **What a run does:**
|
|
20
|
+
- the target's `pre` steps (the game's heights and layout → `~/.cache/wildshard-blender/<target>/`, downloads);
|
|
21
|
+
- `blender -b --factory-startup -noaudio --python-exit-code 1 -P <script> -- <args>`: a Python exception fails the
|
|
22
|
+
build;
|
|
23
|
+
- the model lock (`lockf -k ~/projects/localai/.model.lock`) for every Cycles target, which is all of them today;
|
|
24
|
+
- then meshopt and copy into `public/`, then the target's `post` step.
|
|
25
|
+
- **Inspect:** `--save-blend` also saves the final scene as `~/.cache/wildshard-blender/<target>/<name>.blend`. Open it,
|
|
26
|
+
never commit it: `.gitignore` and `.githooks/pre-commit` refuse `*.blend`.
|
|
27
|
+
- **Check:** `build.sh --check <target>` (or `--check --all`) rebuilds into the cache, meshopts each GLB and compares it
|
|
28
|
+
with the committed one (`lib/glb-digest.mjs`): the structure, the vertex and triangle counts, the materials, the
|
|
29
|
+
bounds, and an order-free position hash. Bytes are not compared, because Cycles bakes and the exporter aren't
|
|
30
|
+
byte-stable. Run it after a Blender upgrade and after moving a builder.
|
|
31
|
+
- **Add a model:** a script under `scripts/blender/<shard>/`, a `targets.json` row (`script`, `sources`, `outputs`, …)
|
|
32
|
+
and a build. `node scripts/check-model-sources.mjs` (in `pnpm test`) refuses:
|
|
33
|
+
- a Blender output GLB with no target;
|
|
34
|
+
- an unreferenced file under `scripts/blender/`;
|
|
35
|
+
- a tracked `.blend`.
|
|
36
|
+
|
|
37
|
+
| Target | Builds | Minutes | `--check` on 2026-09-29 |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| `driftwood-isle/island` | `public/assets/models/driftwood-blender/` (island.glb, placements.bin, lightmaps) | ~0.5 | IDENTICAL, placements.bin same bytes |
|
|
40
|
+
| `pine-hollow/trees` | `public/assets/models/pine-hollow-trees/` + 4 bark sets | ~1.5 | IDENTICAL, trees.json same bytes |
|
|
41
|
+
| `pine-hollow/crags` | `pine-hollow-crags/crags.glb` | < 0.1 | IDENTICAL (crags.json AO means differ: Cycles noise) |
|
|
42
|
+
| `pine-hollow/cave` | `pine-hollow-crags/cave.glb` | < 0.1 | IDENTICAL, cave.json same bytes |
|
|
43
|
+
| `pine-hollow/lever-rifle` | `pine-hollow/weapons/lever-rifle{,.phone}.glb` | ~3 | IDENTICAL (both tiers) |
|
|
44
|
+
| `pine-hollow/skinning-knife` | `pine-hollow/weapons/skinning-knife{,.phone}.glb` + `.json` | ~1 | IDENTICAL (both tiers) |
|
|
45
|
+
| `pine-hollow/area-export` | the cache only (the Blender build is PH-U17, wave 2) | < 0.1 | export only |
|
|
46
|
+
| `nine-dragon-stack/fei-zhua` | `nine-dragon/lab/grapple/fei-zhua.glb` (the dev lab page only) | < 0.1 | IDENTICAL |
|
|
47
|
+
| `nine-dragon-stack/fp-rig` | `nine-dragon/viewmodel/fp-rig.glb` + maps | manual | the 16 clips within 0.031° ([viewmodel/README](nine-dragon-stack/viewmodel/README.md)) |
|
|
48
|
+
|
|
49
|
+
Image-to-3D models (TRELLIS.2, Hunyuan3D-2, CC0) and their Blender clean-up are `scripts/img2mesh/`, not here. Their
|
|
50
|
+
recipes are the prop lists in `scripts/img2mesh/props/`; Nalati's is `nalati.json`.
|
|
51
|
+
|
|
52
|
+
## The Driftwood island (DRIFTWOOD-REMASTER X2, E52)
|
|
53
|
+
|
|
54
|
+
`pnpm blender:island [--quick]` rebuilds Driftwood's spawn cove in Blender, headless, and writes
|
|
55
|
+
`public/assets/models/driftwood-blender/`. The game always loads it in place of the procedural cove (the user's pick, E7;
|
|
56
|
+
the `?island` switch is gone since E136). The runtime still constructs procedural content before
|
|
57
|
+
replacing or clipping its drawing inside the Blender area; this is remaining loading
|
|
58
|
+
work, not a supported load-failure fallback. A required island asset failure refuses
|
|
59
|
+
boot. SF67 baking work must remove redundant construction while preserving colliders
|
|
60
|
+
and authored content; it has not landed yet.
|
|
61
|
+
|
|
62
|
+
**Per shard (PINE-HOLLOW-REMASTER PH-0.3).** Three things name a shard:
|
|
63
|
+
- its area: `src/world/blenderArea.ts`, `blenderAreaFor(slug)`. Driftwood's is also the `area` export that
|
|
64
|
+
BlenderIsland.ts clips at.
|
|
65
|
+
- its half of the export: `scripts/blender/<slug>/export.mjs`. `groundColor(ctx)` gives the area grid's colour;
|
|
66
|
+
`layout(ctx)` gives scene.json's shard keys, plus bake occluders through `ctx.addObject`.
|
|
67
|
+
- its Blender builder: a `targets.json` target (`driftwood-isle/island` → `driftwood-isle/build_island.py`). A shard
|
|
68
|
+
without one has an export-only target.
|
|
69
|
+
|
|
70
|
+
Pine Hollow has an area (provisional: the Hollow, until board B1) and an exporter:
|
|
71
|
+
- `area.bin` holds the splat-weighted PBR ground albedo;
|
|
72
|
+
- `splat.bin` holds the real layer weights;
|
|
73
|
+
- `scene.json` holds every tree, the cabin sites, the pond and the trails.
|
|
74
|
+
|
|
75
|
+
Its builder is wave 2 (PH-U17), so `build.sh pine-hollow/area-export` exports to
|
|
76
|
+
`~/.cache/wildshard-blender/pine-hollow/area-export/` and writes nothing to `public/`. Every export reads the shard's
|
|
77
|
+
baked grid, `public/assets/baked/<slug>/terrain.bin`.
|
|
78
|
+
|
|
79
|
+
| Step | File | What |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| 1 | `lib/export-scene.mjs` + `driftwood-isle/export.mjs` | Runs the game's own code in Node: the area's heights from the baked grid (the surface `heightAt` walks), the game's ground colour (`lowPolyGroundColor`), slope, trail distance; the whole chunk's coarse heights; the palms / boulders / bushes / trailside specs; the pier, hut and trailside meshes as triangle soup. → the target's cache |
|
|
82
|
+
| 2 | `driftwood-isle/build_island.py` + `assets.py` | Blender 5.2, Cycles on the Metal GPU. Terrain on a grid twice the game's (edges on the game's grid lines, interior jittered for natural facets), ~60 prototypes from code (palms, crag slabs, boulders, ferns, hibiscus, bushes, flowers, grass, beach grass, shells, starfish, pebbles, driftwood), ~13 k placements by height / slope / path rules. Bakes, exports `island.glb` (no materials, no normals), `placements.bin`, `island.json`. |
|
|
83
|
+
| 3 | `build.sh` + `driftwood-isle/post.sh` | meshopt (`gltf-transform meshopt`), lightmaps to WebP (desktop 2048 / 1024, phone half), copy into `public/`. |
|
|
84
|
+
|
|
85
|
+
The area is `src/world/blenderArea.ts` (x −110.8…110.8, z −214.7…−20.6: the pier landing, the crescent beach, the plank
|
|
86
|
+
stair, the hut plateau). Terrain, crag slabs, plants and beach scatter are modelled from code (`assets.py`); the palms,
|
|
87
|
+
shore boulders, driftwood and coconuts are the asset-agent's kit (`public/assets/models/driftwood-hero/`, image-to-3D, and
|
|
88
|
+
`driftwood-cc0/`, CC0 1.0 — licences in `scripts/img2mesh/CC0.md`), imported by `build_island.py`. The kit palms are
|
|
89
|
+
used as authored near the camera (collapse-decimating tore their trunks apart); their far cut is the code palm at the same
|
|
90
|
+
height / lean in their own colours. The game draws the props as 4×4 / 3×3 caster tiles (near + far copy) and 8×8 / 4×4
|
|
91
|
+
cover tiles (drawn within 32 m on phone, 150 m desktop), phone / desktop.
|
|
92
|
+
|
|
93
|
+
### Lighting: what is baked and what stays live (the decision)
|
|
94
|
+
|
|
95
|
+
The island runs a 20 + 4 min day/night clock (`src/world/DayNight.ts`), so the sun cannot be baked. Baked, once:
|
|
96
|
+
|
|
97
|
+
- **AO lightmap** (terrain, 2048², 5 m sky visibility). Every object occludes: palms, crag slabs, scatter, pier, hut. In
|
|
98
|
+
game it multiplies the indirect term (the hemisphere fill that the clock tints, the toon shade lift), never the sun.
|
|
99
|
+
- **Bounce lightmap** (terrain, 1024²): Cycles indirect diffuse with the sun alone at the midday reference (62° up,
|
|
100
|
+
due south), irradiance 1, sky black. In game it is added to the indirect term × the live sun (colour × intensity ×
|
|
101
|
+
its elevation relative to the reference), so it fades with the sun and is gone at night.
|
|
102
|
+
- **Prototype AO** in the vertex colour's alpha (self-occlusion + ground contact). Multiplies the fill, and 35 % of
|
|
103
|
+
the direct light (the inside of a palm crown).
|
|
104
|
+
|
|
105
|
+
Live: the sun's direct light, its CSM shadows and the toon ramp (`stylize.ts`), the hemisphere fill, fog, sky, sea.
|
|
106
|
+
Rejected: baking the four DayNight presets and blending (4× the textures and the bake time for a term that the live
|
|
107
|
+
sun already gets right); baking the full combined light (static, wrong 23 minutes out of 24).
|
|
108
|
+
|
|
109
|
+
Measured (first bake): AO mean 0.83; the bounce is small on open ground (mean 0.003 of the sun's irradiance, up to
|
|
110
|
+
0.08–0.11 at the foot of the crag and under the pier): honest for a low-poly beach, most of its GI is sky occlusion.
|
|
111
|
+
|
|
112
|
+
## The tree species set (PINE-HOLLOW-REMASTER PH-B4)
|
|
113
|
+
|
|
114
|
+
`bash scripts/blender/build.sh pine-hollow/trees [--quick] [--only=bark,cards,trees,lineup] [--no-copy]` builds Pine
|
|
115
|
+
Hollow's photoreal species set:
|
|
116
|
+
- Scots pine ×4, fir ×2, old-growth giant ×2 (4–6× a pine's girth), silver birch ×2, dead snag ×2, sapling ×2;
|
|
117
|
+
- under the machine-wide model lock (it waits for a running model job), in ~90 s of Blender once it has the lock.
|
|
118
|
+
|
|
119
|
+
| File | What |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `pine-hollow/trees/treegen.py` | The species as numpy geometry, per variant five LOD parts (trunk / trunkLo bark, hi / lo / twigs cards) + the vertex data the game reads (bark layer, bark tint, crown occlusion, crown-bent card normals). `SPECS` = the game's `TREE_SPECS_V2` (`src/world/treeSpecies.ts`, checked by `test/tree-species.test.ts`). |
|
|
122
|
+
| `pine-hollow/trees/barkgen.py` | The silver birch's bark, generated seamless (Poly Haven has none). |
|
|
123
|
+
| `pine-hollow/trees/build_trees.py` | Blender 5.2: the bark sets, the branch-card atlas (branches modelled from CC0 photoscan sprigs, rendered top-down in Cycles: albedo × AO, camera-space normal, ARM), `trees.glb`, the impostor atlas (each variant's hi LOD from the side), a lit lineup preview. |
|
|
124
|
+
| `lib/glb.py` | A minimal glTF writer (meshes `<variant>__<part>`). |
|
|
125
|
+
| `pine-hollow/trees/post.sh` | After build.sh's meshopt of `trees.glb`: pngquant / JPEG / half-size `.phone.webp` → `public/assets/models/pine-hollow-trees/` + `public/assets/tex/{fir_bark,metasequoia_bark,birch_bark,bark_willow_02}/`. |
|
|
126
|
+
|
|
127
|
+
Sources are Poly Haven CC0 (fir_tree_01's sprays + bark, tree_small_02's leaves, pine_tree_01's twig, metasequoia_bark,
|
|
128
|
+
bark_willow_02), cached in `~/.cache/wildshard-blender/trees-src/`. The game side is `src/world/treeSet.ts` (the GLB →
|
|
129
|
+
plain float geometry, the bark array lookups) and `TreeFactory.buildSet`; a build without the set's files plants the runtime pines.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# build.sh — the one runner for every model a Blender script builds (M10, E315; docs/design/blender-practice.md §4).
|
|
3
|
+
# The scripts are the source, the GLB they export is committed, a .blend never is.
|
|
4
|
+
#
|
|
5
|
+
# bash scripts/blender/build.sh <target>... [flags] [-- <script args>]
|
|
6
|
+
# bash scripts/blender/build.sh --list the targets in scripts/blender/targets.json
|
|
7
|
+
# bash scripts/blender/build.sh --check <target>... rebuild into the cache and compare with the committed GLBs
|
|
8
|
+
# bash scripts/blender/build.sh --check --all every target (one Blender run at a time, under the model lock)
|
|
9
|
+
#
|
|
10
|
+
# Flags: --check · --all · --save-blend (also save the scene as ~/.cache/wildshard-blender/<target>/<name>.blend, to open
|
|
11
|
+
# and inspect) · --no-copy (build into the cache, write nothing into the repo) · --no-lock. Any other --flag, and
|
|
12
|
+
# everything after `--`, is passed to the target's Blender script (e.g. --quick, --only=trees, --lod=hi).
|
|
13
|
+
#
|
|
14
|
+
# Per target (targets.json): the `pre` commands (the game's data → the cache, downloads) → Blender, headless:
|
|
15
|
+
# blender -b --factory-startup -noaudio --python-exit-code 1 -P <script> -- <args>
|
|
16
|
+
# (an exception fails the run) under `lockf -k ~/projects/localai/.model.lock` when `lock` is true (Cycles work,
|
|
17
|
+
# AGENTS.md ▸ Local models) → every `build` file must exist → `meshopt` pairs (gltf-transform meshopt --level medium into
|
|
18
|
+
# the repo) → `copy` pairs → the `post` script. --check stops before the repo: it meshopts each rebuilt GLB into the check
|
|
19
|
+
# folder and compares it with the committed one (lib/glb-digest.mjs: structure, counts, materials, bounds; bytes may
|
|
20
|
+
# differ). A `manual` target is not built here; --check runs its `check` command instead.
|
|
21
|
+
#
|
|
22
|
+
# Environment for pre / post / args: REPO, CACHE (~/.cache/wildshard-blender/<target>), BUILD (CACHE/build, or
|
|
23
|
+
# CACHE/check under --check), SHARED (~/.cache/wildshard-blender: downloads shared between targets), BLENDER.
|
|
24
|
+
set -euo pipefail
|
|
25
|
+
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
|
26
|
+
REPO=$PWD
|
|
27
|
+
MANIFEST=scripts/blender/targets.json
|
|
28
|
+
BLENDER="${BLENDER:-$(jq -r '.blender.path' "$MANIFEST")}"
|
|
29
|
+
command -v "$BLENDER" >/dev/null || BLENDER=$(command -v blender || true)
|
|
30
|
+
LOCK="${HOME}/$(jq -r '.lock' "$MANIFEST" | sed 's#^~/##')"
|
|
31
|
+
SHARED="${BLENDER_CACHE:-$HOME/$(jq -r '.cache' "$MANIFEST" | sed 's#^~/##')}"
|
|
32
|
+
GT="$REPO/node_modules/.bin/gltf-transform"
|
|
33
|
+
|
|
34
|
+
CHECK=0 ALL=0 SAVE=0 COPY=1 USELOCK=1 LIST=0
|
|
35
|
+
TARGETS=() PASS=()
|
|
36
|
+
while [ $# -gt 0 ]; do
|
|
37
|
+
case "$1" in
|
|
38
|
+
--check) CHECK=1 ;;
|
|
39
|
+
--all) ALL=1 ;;
|
|
40
|
+
--save-blend) SAVE=1 ;;
|
|
41
|
+
--no-copy) COPY=0 ;;
|
|
42
|
+
--no-lock) USELOCK=0 ;;
|
|
43
|
+
--list) LIST=1 ;;
|
|
44
|
+
--) shift; PASS+=("$@"); break ;;
|
|
45
|
+
--*) PASS+=("$1") ;;
|
|
46
|
+
*) TARGETS+=("$1") ;;
|
|
47
|
+
esac
|
|
48
|
+
shift
|
|
49
|
+
done
|
|
50
|
+
|
|
51
|
+
if [ "$LIST" = 1 ]; then
|
|
52
|
+
jq -r '.targets | to_entries[] | "\(.key)\t\(if .value.manual then "manual" elif .value.script then .value.script else "export only" end)\t\(.value.about)"' "$MANIFEST" \
|
|
53
|
+
| awk -F'\t' '{ printf "%-32s %-58s %s\n", $1, $2, substr($3, 1, 90) }'
|
|
54
|
+
exit 0
|
|
55
|
+
fi
|
|
56
|
+
if [ "$ALL" = 1 ]; then TARGETS=(); while IFS= read -r t; do TARGETS+=("$t"); done < <(jq -r '.targets | keys[]' "$MANIFEST"); fi
|
|
57
|
+
[ ${#TARGETS[@]} -gt 0 ] || { sed -n '2,24p' "$0" | sed 's/^# \{0,1\}//'; exit 2; }
|
|
58
|
+
|
|
59
|
+
want="$(jq -r '.blender.version' "$MANIFEST")"
|
|
60
|
+
have="$("$BLENDER" --version 2>/dev/null | head -1 | awk '{print $2}')"
|
|
61
|
+
[ "$have" = "$want" ] || echo "build.sh: WARNING Blender $have, targets.json pins $want. Adopt a new version with a --check of every target." >&2
|
|
62
|
+
|
|
63
|
+
# $REPO / $CACHE / $BUILD / $SHARED / $BLENDER in a manifest string
|
|
64
|
+
expand() {
|
|
65
|
+
local s=$1
|
|
66
|
+
s=${s//\$REPO/$REPO}; s=${s//\$CACHE/$CACHE}; s=${s//\$BUILD/$BUILD}; s=${s//\$SHARED/$SHARED}; s=${s//\$BLENDER/$BLENDER}
|
|
67
|
+
printf '%s' "$s"
|
|
68
|
+
}
|
|
69
|
+
field() { jq -r --arg t "$T" ".targets[\$t]$1" "$MANIFEST"; }
|
|
70
|
+
fields() { jq -r --arg t "$T" ".targets[\$t]$1 // [] | .[]" "$MANIFEST"; }
|
|
71
|
+
pairs() { jq -r --arg t "$T" ".targets[\$t].$1 // [] | .[] | \"\(.[0])\t\(.[1])\"" "$MANIFEST"; }
|
|
72
|
+
|
|
73
|
+
FAILED=()
|
|
74
|
+
for T in "${TARGETS[@]}"; do
|
|
75
|
+
[ "$(jq --arg t "$T" '.targets | has($t)' "$MANIFEST")" = true ] || { echo "build.sh: no target \"$T\" (bash $0 --list)" >&2; exit 2; }
|
|
76
|
+
CACHE="$SHARED/$T"
|
|
77
|
+
BUILD="$CACHE/$([ "$CHECK" = 1 ] && echo check || echo build)"
|
|
78
|
+
export REPO CACHE BUILD SHARED BLENDER
|
|
79
|
+
echo "── $T $([ "$CHECK" = 1 ] && echo '(check)')"
|
|
80
|
+
|
|
81
|
+
manual=$(field '.manual // empty')
|
|
82
|
+
if [ -n "$manual" ]; then
|
|
83
|
+
chk=$(field '.check // empty')
|
|
84
|
+
if [ "$CHECK" = 1 ] && [ -n "$chk" ]; then
|
|
85
|
+
bash -c "$(expand "$chk")" || FAILED+=("$T")
|
|
86
|
+
else
|
|
87
|
+
echo "build.sh: $T is built by hand: $manual"
|
|
88
|
+
[ "$CHECK" = 1 ] || FAILED+=("$T")
|
|
89
|
+
fi
|
|
90
|
+
continue
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
# a fresh check folder every time (only ever under the cache)
|
|
94
|
+
if [ "$CHECK" = 1 ]; then case "$BUILD" in "$SHARED"/*/check) rm -rf -- "$BUILD" ;; esac; fi
|
|
95
|
+
mkdir -p "$CACHE" "$BUILD"
|
|
96
|
+
prefail=0
|
|
97
|
+
while IFS= read -r c; do
|
|
98
|
+
[ -n "$c" ] || continue
|
|
99
|
+
bash -c "$(expand "$c")" || { echo "build.sh: $T: pre step failed: $c" >&2; prefail=1; break; }
|
|
100
|
+
done < <(fields '.pre')
|
|
101
|
+
[ "$prefail" = 0 ] || { FAILED+=("$T"); continue; }
|
|
102
|
+
|
|
103
|
+
script=$(field '.script // empty')
|
|
104
|
+
if [ -z "$script" ]; then echo "build.sh: $T has no Blender step (export only): $CACHE"; continue; fi
|
|
105
|
+
args=()
|
|
106
|
+
while IFS= read -r a; do args+=("$(expand "$a")"); done < <(fields '.args')
|
|
107
|
+
cmd=("$BLENDER" -b --factory-startup -noaudio --python-exit-code 1 -P "$script")
|
|
108
|
+
if [ "$SAVE" = 1 ]; then
|
|
109
|
+
cmd+=(-P scripts/blender/lib/save_blend.py)
|
|
110
|
+
export WILDSHARD_SAVE_BLEND="$CACHE/$(basename "$T").blend"
|
|
111
|
+
fi
|
|
112
|
+
cmd+=(-- ${args[@]+"${args[@]}"} ${PASS[@]+"${PASS[@]}"})
|
|
113
|
+
LOG="$CACHE/$(basename "$BUILD").log"
|
|
114
|
+
locked=$(jq -r --arg t "$T" '.targets[$t] | if has("lock") then .lock else true end' "$MANIFEST")
|
|
115
|
+
if [ "$locked" = true ] && [ "$USELOCK" = 1 ]; then cmd=(lockf -k -t 300 "$LOCK" "${cmd[@]}"); fi
|
|
116
|
+
t0=$(date +%s)
|
|
117
|
+
rc=0
|
|
118
|
+
PYTHONDONTWRITEBYTECODE=1 "${cmd[@]}" >"$LOG" 2>&1 || rc=$?
|
|
119
|
+
if [ "$rc" = 75 ]; then echo "build.sh: model lock timed out after 300s: $LOCK" >&2; lsof "$LOCK" >&2 || true; fi
|
|
120
|
+
grep -E '^\[|Error|Traceback| File "|Exception' "$LOG" | tail -25 || true
|
|
121
|
+
echo "build.sh: $T: Blender exit $rc after $(( $(date +%s) - t0 )) s (log: $LOG)"
|
|
122
|
+
[ "$rc" = 0 ] || { FAILED+=("$T"); continue; }
|
|
123
|
+
missing=0
|
|
124
|
+
while IFS= read -r f; do
|
|
125
|
+
[ -s "$BUILD/$f" ] || { echo "build.sh: $T produced no $f" >&2; missing=1; }
|
|
126
|
+
done < <(fields '.build')
|
|
127
|
+
[ "$missing" = 0 ] || { FAILED+=("$T"); continue; }
|
|
128
|
+
|
|
129
|
+
if [ "$CHECK" = 1 ]; then
|
|
130
|
+
mkdir -p "$BUILD/meshopt"
|
|
131
|
+
ok=1
|
|
132
|
+
while IFS=$'\t' read -r from to; do
|
|
133
|
+
[ -n "$from" ] || continue
|
|
134
|
+
out="$BUILD/meshopt/$(basename "$to")"
|
|
135
|
+
"$GT" meshopt "$BUILD/$from" "$out" --level medium >/dev/null
|
|
136
|
+
echo " $to"
|
|
137
|
+
node scripts/blender/lib/glb-digest.mjs "$out" "$to" --json "$out.check.json" | sed 's/^/ /' || ok=0
|
|
138
|
+
done < <(pairs meshopt)
|
|
139
|
+
while IFS=$'\t' read -r from to; do
|
|
140
|
+
[ -n "$from" ] || continue
|
|
141
|
+
if cmp -s "$BUILD/$from" "$to"; then echo " $to: same bytes"; else echo " $to: differs (a sidecar: info only)"; fi
|
|
142
|
+
done < <(pairs copy)
|
|
143
|
+
[ "$ok" = 1 ] || FAILED+=("$T")
|
|
144
|
+
continue
|
|
145
|
+
fi
|
|
146
|
+
[ "$COPY" = 1 ] || { echo "build.sh: --no-copy: $T built into $BUILD"; continue; }
|
|
147
|
+
while IFS=$'\t' read -r from to; do
|
|
148
|
+
[ -n "$from" ] || continue
|
|
149
|
+
mkdir -p "$(dirname "$to")"
|
|
150
|
+
"$GT" meshopt "$BUILD/$from" "$to" --level medium >/dev/null
|
|
151
|
+
done < <(pairs meshopt)
|
|
152
|
+
while IFS=$'\t' read -r from to; do
|
|
153
|
+
[ -n "$from" ] || continue
|
|
154
|
+
mkdir -p "$(dirname "$to")"
|
|
155
|
+
cp "$BUILD/$from" "$to"
|
|
156
|
+
done < <(pairs copy)
|
|
157
|
+
post=$(field '.post // empty')
|
|
158
|
+
[ -z "$post" ] || bash "$post"
|
|
159
|
+
while IFS= read -r f; do ls -la "$f"; done < <(fields '.outputs')
|
|
160
|
+
done
|
|
161
|
+
|
|
162
|
+
if [ ${#FAILED[@]} -gt 0 ]; then
|
|
163
|
+
echo "build.sh: FAILED: ${FAILED[*]}" >&2
|
|
164
|
+
exit 1
|
|
165
|
+
fi
|
|
166
|
+
echo "build.sh: $([ "$CHECK" = 1 ] && echo 'checked' || echo 'built') ${TARGETS[*]}"
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// export-scene.mjs — step 1 of the Blender island pipeline (DRIFTWOOD-REMASTER X2, E52; any shard since PH-0.3).
|
|
3
|
+
//
|
|
4
|
+
// Runs the game's own terrain + layout code in Node (as scripts/bake-chunk.mjs does) and writes what Blender needs
|
|
5
|
+
// to author a shard's area on the SAME ground the player walks:
|
|
6
|
+
//
|
|
7
|
+
// <cache>/scene.json the area, the sea level (null on a dry shard), the chunk, then the shard's own layout specs
|
|
8
|
+
// (scripts/blender/<slug>/export.mjs: Driftwood's palms / boulders / bushes / trailside / pier,
|
|
9
|
+
// Pine Hollow's trees / cabins / pond / trails)
|
|
10
|
+
// <cache>/area.bin f32 grid over the area at STEP m: height · r · g · b (the shard's ground colour, linear) · slope ·
|
|
11
|
+
// trail distance (6 floats per vertex, row-major iz·nx + ix, x = x0 + ix·STEP, z = z0 + iz·STEP)
|
|
12
|
+
// <cache>/context.bin f32 grid over the whole chunk at the game's own 256² resolution (height only): the GI bake's
|
|
13
|
+
// surroundings (the plateau beyond the area occludes the sky, the far beach bounces light)
|
|
14
|
+
// <cache>/structures.bin the procedural structures the shard keeps in blender mode (Driftwood: pier, hut, trailside
|
|
15
|
+
// stair / fences) as triangle soup: u32 tris · f32[tris·9] positions · f32[tris·9] colours —
|
|
16
|
+
// bake occluders only (0 tris when the shard lists none)
|
|
17
|
+
// + whatever extra grids the shard module writes (Pine Hollow: splat.bin, u8×4 ground-layer weights per area vertex)
|
|
18
|
+
//
|
|
19
|
+
// Heights come from the BAKED grid (public/assets/baked/<slug>/terrain.bin → Heightfield's bilinear lookups), i.e.
|
|
20
|
+
// exactly the surface Player.groundAt() walks, so the Blender terrain never floats or sinks against collision. The area
|
|
21
|
+
// is the shard manifest's `blender.area` (blenderAreaFor in src/client/engine/world/blenderArea.ts).
|
|
22
|
+
//
|
|
23
|
+
// node --import ./scripts/bake-loader.mjs scripts/blender/lib/export-scene.mjs [--chunk <slug>] [cacheDir]
|
|
24
|
+
// (--chunk defaults to driftwood-isle; cacheDir to ~/.cache/wildshard-blender/<slug>)
|
|
25
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
26
|
+
import { resolve } from 'node:path';
|
|
27
|
+
import { prepareNativeScalarBlocks } from '../../bake/nativeWorld.mjs';
|
|
28
|
+
import { homedir } from 'node:os';
|
|
29
|
+
import { pathToFileURL } from 'node:url';
|
|
30
|
+
|
|
31
|
+
const ROOT = resolve(import.meta.dirname, '../../..');
|
|
32
|
+
const args = process.argv.slice(2);
|
|
33
|
+
const ci = args.indexOf('--chunk');
|
|
34
|
+
const SLUG = ci !== -1 ? args[ci + 1] : 'driftwood-isle';
|
|
35
|
+
if (!SLUG || SLUG.startsWith('-')) throw new Error('export-scene: --chunk needs a shard slug');
|
|
36
|
+
const cacheArg = args.find((a, i) => !a.startsWith('--') && !(ci !== -1 && i === ci + 1));
|
|
37
|
+
const CACHE = resolve(cacheArg ??`${homedir()}/.cache/wildshard-blender/${SLUG}`);
|
|
38
|
+
mkdirSync(CACHE, { recursive: true });
|
|
39
|
+
if (!('location' in globalThis)) Object.assign(globalThis, { location: new URL('http://localhost/?tier=desktop') });
|
|
40
|
+
|
|
41
|
+
const imp = (p) => import(pathToFileURL(resolve(ROOT, p)).href);
|
|
42
|
+
const shardModule = resolve(ROOT, `src/shards/${SLUG}/blender/export.mjs`);
|
|
43
|
+
if (!existsSync(shardModule)) throw new Error(`export-scene: no src/shards/${SLUG}/blender/export.mjs (the shard's ground colour + layout)`);
|
|
44
|
+
const { CHUNK_SIZE, CHUNK_HALF, TERRAIN_RES, ROAD_LENGTH } = await imp('src/shared/engine/core/config.ts');
|
|
45
|
+
const registry = await imp('src/client/game/shard/registry.ts');
|
|
46
|
+
if (!registry.findChunk(SLUG)) throw new Error(`export-scene: unknown shard "${SLUG}"`);
|
|
47
|
+
registry.setActiveChunk(SLUG);
|
|
48
|
+
const hf = await imp('src/shared/engine/world/Heightfield.ts');
|
|
49
|
+
const baked = await imp('src/shared/engine/world/BakedTerrain.ts');
|
|
50
|
+
const def = registry.getActiveChunk();
|
|
51
|
+
prepareNativeScalarBlocks(def, ROOT);
|
|
52
|
+
const grid = baked.parseBakedTerrain(readFileSync(resolve(ROOT, `public/assets/baked/${SLUG}/terrain.bin`)).buffer.slice(0));
|
|
53
|
+
if (!grid) throw new Error('no baked terrain');
|
|
54
|
+
// the scene is exported in the raw bake's authored frame: a level shifted at runtime (its field's `datum`, Driftwood's G164
|
|
55
|
+
// drop) would install the bake shifted, so it binds the raw bake and the authored waterline instead; the game shifts the
|
|
56
|
+
// exported island by the same datum as it loads (BlenderIsland.ts)
|
|
57
|
+
const field = def.ground.terrain, datum = field?.datum ?? 0, samplers = baked.bakedSamplers(grid);
|
|
58
|
+
if (datum === 0) hf._installBakedTerrain(samplers);
|
|
59
|
+
else hf.overrideTerrain({ heightAt: samplers.heightAt, normalAt: samplers.normalAt, splatAt: samplers.splatAt, waterLevel: () => field.waterLevel() - datum });
|
|
60
|
+
const THREE = await import('three');
|
|
61
|
+
const shard = await import(pathToFileURL(shardModule).href);
|
|
62
|
+
const { blenderAreaFor, STEP } = await imp('src/client/engine/world/blenderArea.ts');
|
|
63
|
+
const AREA = blenderAreaFor(def);
|
|
64
|
+
if (!AREA) throw new Error(`export-scene: the manifest has no Blender area for "${SLUG}"`);
|
|
65
|
+
const ctx = { ROOT, CACHE, SLUG, THREE, imp, hf, def, CHUNK_SIZE, CHUNK_HALF, ROAD_LENGTH };
|
|
66
|
+
|
|
67
|
+
// ── the area grid ──
|
|
68
|
+
const x0 = AREA.x0, z0 = AREA.z0;
|
|
69
|
+
const nx = Math.round((AREA.x1 - AREA.x0) / STEP) + 1, nz = Math.round((AREA.z1 - AREA.z0) / STEP) + 1;
|
|
70
|
+
const areaInfo = { x0, z0, x1: AREA.x1, z1: AREA.z1, step: STEP, nx, nz };
|
|
71
|
+
const groundColor = await shard.groundColor({ ...ctx, area: areaInfo }); // (c, x, z, y, ny, td) → c = the shard's ground colour there
|
|
72
|
+
const g = new Float32Array(nx * nz * 6);
|
|
73
|
+
const c = new THREE.Color();
|
|
74
|
+
for (let iz = 0; iz < nz; iz++) for (let ix = 0; ix < nx; ix++) {
|
|
75
|
+
const x = x0 + ix * STEP, z = z0 + iz * STEP, y = hf.heightAt(x, z);
|
|
76
|
+
const [, ny] = hf.normalAt(x, z, 0.98);
|
|
77
|
+
const td = hf.trailDistance(x, z);
|
|
78
|
+
groundColor(c, x, z, y, ny, td);
|
|
79
|
+
g.set([y, c.r, c.g, c.b, 1 - ny, td], (iz * nx + ix) * 6);
|
|
80
|
+
}
|
|
81
|
+
writeFileSync(`${CACHE}/area.bin`, Buffer.from(g.buffer));
|
|
82
|
+
|
|
83
|
+
// ── the whole chunk, coarse (the bake's surroundings) ──
|
|
84
|
+
const res = TERRAIN_RES, d = CHUNK_SIZE / (res - 1);
|
|
85
|
+
const ctxGrid = new Float32Array(res * res);
|
|
86
|
+
for (let iz = 0; iz < res; iz++) for (let ix = 0; ix < res; ix++) ctxGrid[iz * res + ix] = hf.heightAt(-CHUNK_HALF + ix * d, -CHUNK_HALF + iz * d);
|
|
87
|
+
writeFileSync(`${CACHE}/context.bin`, Buffer.from(ctxGrid.buffer));
|
|
88
|
+
|
|
89
|
+
// ── structures kept in blender mode, as bake occluders ──
|
|
90
|
+
const soupPos = [], soupCol = [];
|
|
91
|
+
const addObject = (obj) => {
|
|
92
|
+
obj.updateMatrixWorld(true);
|
|
93
|
+
obj.traverse((m) => {
|
|
94
|
+
if (!m.isMesh || !m.geometry) return;
|
|
95
|
+
const geo = m.geometry.index ? m.geometry.toNonIndexed() : m.geometry;
|
|
96
|
+
const p = geo.getAttribute('position'), col = geo.getAttribute('color');
|
|
97
|
+
if (!p) return;
|
|
98
|
+
const v = new THREE.Vector3();
|
|
99
|
+
const count = m.isInstancedMesh ? m.count : 1;
|
|
100
|
+
const im = new THREE.Matrix4();
|
|
101
|
+
for (let k = 0; k < count; k++) {
|
|
102
|
+
const mw = m.matrixWorld.clone();
|
|
103
|
+
if (m.isInstancedMesh) { m.getMatrixAt(k, im); mw.multiply(im); }
|
|
104
|
+
for (let i = 0; i < p.count; i++) {
|
|
105
|
+
v.fromBufferAttribute(p, i).applyMatrix4(mw);
|
|
106
|
+
soupPos.push(v.x, v.y, v.z);
|
|
107
|
+
soupCol.push(col ? col.getX(i) : 0.6, col ? col.getY(i) : 0.5, col ? col.getZ(i) : 0.4);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const tryBuild = (name, f) => { try { addObject(f()); } catch (e) { console.warn(`[export] ${name} skipped: ${e.message}`); } };
|
|
113
|
+
|
|
114
|
+
// ── the shard's layout specs (desktop tier, as the bake's reference) + its structures (via addObject) ──
|
|
115
|
+
const layout = await shard.layout({ ...ctx, area: areaInfo, addObject, tryBuild });
|
|
116
|
+
|
|
117
|
+
const tris = soupPos.length / 9;
|
|
118
|
+
const soup = new Float32Array(1 + soupPos.length * 2);
|
|
119
|
+
new Uint32Array(soup.buffer, 0, 1)[0] = tris;
|
|
120
|
+
soup.set(soupPos, 1); soup.set(soupCol, 1 + soupPos.length);
|
|
121
|
+
writeFileSync(`${CACHE}/structures.bin`, Buffer.from(soup.buffer));
|
|
122
|
+
|
|
123
|
+
const scene = {
|
|
124
|
+
area: areaInfo, sea: def.ocean ? def.ocean.level - datum : null,
|
|
125
|
+
chunk: { size: CHUNK_SIZE, res },
|
|
126
|
+
...layout.scene,
|
|
127
|
+
};
|
|
128
|
+
writeFileSync(`${CACHE}/scene.json`, JSON.stringify(scene));
|
|
129
|
+
console.log(`[export] ${SLUG} → ${CACHE}: area ${nx}×${nz} @ ${STEP} m, ${layout.summary}, structure tris ${tris}`);
|