@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,139 @@
|
|
|
1
|
+
import { AmbientLight, Bone, BufferAttribute, BufferGeometry, Color, DirectionalLight, Fog, FogExp2, Group, HemisphereLight, InstancedMesh, LOD, Matrix4, Mesh, MeshBasicMaterial, MeshStandardMaterial, MeshToonMaterial, Object3D, PointLight, Scene, Skeleton, SkinnedMesh, SpotLight, type Light, type TypedArray } from 'three';
|
|
2
|
+
import type { SceneDescription, SceneGeometry, SceneMaterial, SceneNode } from './scene';
|
|
3
|
+
import { restoreSceneAnimations } from './sceneAnimation';
|
|
4
|
+
import { restoreSceneDeclaration } from './sceneDeclarations';
|
|
5
|
+
import { catalogueMaterial } from './materials';
|
|
6
|
+
|
|
7
|
+
function isSkin(object: Object3D | undefined): object is SkinnedMesh { return object instanceof SkinnedMesh; }
|
|
8
|
+
function isBone(object: Object3D | undefined): object is Bone { return object instanceof Bone; }
|
|
9
|
+
|
|
10
|
+
function storage(name: string, values: number[]): TypedArray {
|
|
11
|
+
switch (name) {
|
|
12
|
+
case 'Float32Array': return new Float32Array(values);
|
|
13
|
+
case 'Float64Array': return new Float64Array(values);
|
|
14
|
+
case 'Int8Array': return new Int8Array(values);
|
|
15
|
+
case 'Uint8Array': return new Uint8Array(values);
|
|
16
|
+
case 'Uint8ClampedArray': return new Uint8ClampedArray(values);
|
|
17
|
+
case 'Int16Array': return new Int16Array(values);
|
|
18
|
+
case 'Uint16Array': return new Uint16Array(values);
|
|
19
|
+
case 'Int32Array': return new Int32Array(values);
|
|
20
|
+
case 'Uint32Array': return new Uint32Array(values);
|
|
21
|
+
default: throw new Error(`Unknown scene channel storage ${name}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function geometryOf(row: SceneGeometry): BufferGeometry {
|
|
26
|
+
const geometry = new BufferGeometry();
|
|
27
|
+
for (const [name, attribute] of Object.entries(row.attributes)) {
|
|
28
|
+
if (!Number.isSafeInteger(attribute.itemSize) || attribute.itemSize < 1 || attribute.itemSize > 16 || attribute.array.length % attribute.itemSize !== 0 || !attribute.array.every(Number.isFinite)) throw new Error('Malformed scene geometry channel');
|
|
29
|
+
const array = storage(attribute.storage, attribute.array);
|
|
30
|
+
if (!array.every((value, index) => value === attribute.array[index])) throw new Error('Scene channel cannot be represented in its declared storage');
|
|
31
|
+
geometry.setAttribute(name, new BufferAttribute(array, attribute.itemSize, attribute.normalized));
|
|
32
|
+
}
|
|
33
|
+
if (row.index !== null) geometry.setIndex(row.index);
|
|
34
|
+
for (const group of row.groups) geometry.addGroup(group.start, group.count, group.materialIndex);
|
|
35
|
+
geometry.setDrawRange(row.drawRange.start, row.drawRange.count ?? Infinity);
|
|
36
|
+
return geometry;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function materialOf(row: SceneMaterial): MeshStandardMaterial | MeshToonMaterial | MeshBasicMaterial {
|
|
40
|
+
const material = row.entry !== undefined ? catalogueMaterial(row.entry) : row.type === 'MeshStandardMaterial' ? new MeshStandardMaterial() : row.type === 'MeshToonMaterial' ? new MeshToonMaterial() : row.type === 'MeshBasicMaterial' ? new MeshBasicMaterial() : null;
|
|
41
|
+
if (material === null) throw new Error(`Unknown scene material ${row.type}`);
|
|
42
|
+
material.name = row.name; material.color.fromArray(row.color); material.opacity = row.opacity; material.transparent = row.transparent; material.side = row.side; material.vertexColors = row.vertexColors;
|
|
43
|
+
const { emissive, emissiveIntensity, alphaTest, flatShading, roughness, metalness } = row.parameters;
|
|
44
|
+
if (!(material instanceof MeshBasicMaterial) && Array.isArray(emissive)) material.emissive.fromArray(emissive);
|
|
45
|
+
if (!(material instanceof MeshBasicMaterial) && typeof emissiveIntensity === 'number') material.emissiveIntensity = emissiveIntensity;
|
|
46
|
+
if (typeof alphaTest === 'number') material.alphaTest = alphaTest;
|
|
47
|
+
if (material instanceof MeshStandardMaterial) {
|
|
48
|
+
if (typeof flatShading === 'boolean') material.flatShading = flatShading;
|
|
49
|
+
if (typeof roughness === 'number') material.roughness = roughness;
|
|
50
|
+
if (typeof metalness === 'number') material.metalness = metalness;
|
|
51
|
+
}
|
|
52
|
+
return material;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function lightOf(row: SceneNode): Light {
|
|
56
|
+
const data = row.light;
|
|
57
|
+
if (data === undefined) throw new Error('Missing scene light');
|
|
58
|
+
const color = new Color().fromArray(data.color), p = data.parameters;
|
|
59
|
+
const number = (name: string, fallback: number): number => typeof p[name] === 'number' ? p[name] : fallback;
|
|
60
|
+
if (row.type === 'AmbientLight') return new AmbientLight(color, data.intensity);
|
|
61
|
+
if (row.type === 'HemisphereLight') return new HemisphereLight(color, new Color().fromArray(Array.isArray(p['groundColor']) ? p['groundColor'] : [1, 1, 1]), data.intensity);
|
|
62
|
+
const light = row.type === 'DirectionalLight' ? new DirectionalLight(color, data.intensity)
|
|
63
|
+
: row.type === 'PointLight' ? new PointLight(color, data.intensity, number('distance', 0), number('decay', 2))
|
|
64
|
+
: row.type === 'SpotLight' ? new SpotLight(color, data.intensity, number('distance', 0), number('angle', Math.PI / 3), number('penumbra', 0), number('decay', 2)) : null;
|
|
65
|
+
if (light === null) throw new Error(`Unknown scene light ${row.type}`);
|
|
66
|
+
if (light instanceof DirectionalLight || light instanceof SpotLight) {
|
|
67
|
+
const at = p['target'];
|
|
68
|
+
if (!Array.isArray(at)) throw new Error('Missing scene light target');
|
|
69
|
+
light.target.position.fromArray(at); light.target.updateMatrixWorld(true);
|
|
70
|
+
}
|
|
71
|
+
return light;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Rebuild the draw/animation graph and defining SDK declarations from persisted scene JSON in Node.
|
|
75
|
+
* Declaration classes emit compiler rows again; restoration never installs runtime hosts.
|
|
76
|
+
* It retains sharing, skeleton joint order, inverse binds and authored TRS without resampling clips. */
|
|
77
|
+
export function restoreSceneGraph(data: SceneDescription): Object3D {
|
|
78
|
+
if (data.nodes.length === 0) throw new Error('Empty scene description');
|
|
79
|
+
const geometries = data.geometries.map(geometryOf), materials = data.materials.map(materialOf), nodes = new Map<string, Object3D>();
|
|
80
|
+
const rows = new Map(data.nodes.map(row => [row.id, row])), constructing = new Set<string>();
|
|
81
|
+
if (rows.size !== data.nodes.length) throw new Error('Duplicate scene node identity');
|
|
82
|
+
let root: Object3D | undefined;
|
|
83
|
+
const linked = new Set<string>();
|
|
84
|
+
function create(row: SceneNode): Object3D {
|
|
85
|
+
const cached = nodes.get(row.id); if (cached !== undefined) return cached;
|
|
86
|
+
if (constructing.has(row.id)) throw new Error('Cyclic scene declaration dependency');
|
|
87
|
+
constructing.add(row.id);
|
|
88
|
+
if (row.matrix.length !== 16 || !row.matrix.every(Number.isFinite)) throw new Error('Malformed scene node identity or matrix');
|
|
89
|
+
let object: Object3D;
|
|
90
|
+
if (row.declaration !== undefined && (row.geometry !== undefined || row.light !== undefined)) throw new Error('SDK declaration cannot replace a draw resource');
|
|
91
|
+
if (row.declaration !== undefined) object = restoreSceneDeclaration(row.declaration, id => {
|
|
92
|
+
const child = rows.get(id); if (child === undefined || child.parent !== row.id) throw new Error('Mover body must be its graph child'); return create(child);
|
|
93
|
+
});
|
|
94
|
+
else if (row.geometry !== undefined) {
|
|
95
|
+
const geometry = geometries[row.geometry], selected = row.materials?.map(index => materials[index]);
|
|
96
|
+
if (geometry === undefined || selected === undefined || selected.length === 0 || selected.some(material => material === undefined)) throw new Error('Missing scene mesh resource');
|
|
97
|
+
const valid = selected.filter((material): material is MeshStandardMaterial | MeshToonMaterial | MeshBasicMaterial => material !== undefined);
|
|
98
|
+
const material = valid.length === 1 ? valid[0] : valid;
|
|
99
|
+
if (material === undefined) throw new Error('Missing scene mesh material');
|
|
100
|
+
object = row.skin !== undefined ? new SkinnedMesh(geometry, material) : row.instances !== undefined ? new InstancedMesh(geometry, material, row.instances.length) : new Mesh(geometry, material);
|
|
101
|
+
if (object instanceof InstancedMesh && row.instances !== undefined) {
|
|
102
|
+
const instances = object;
|
|
103
|
+
row.instances.forEach((matrix, index) => { instances.setMatrixAt(index, new Matrix4().fromArray(matrix)); });
|
|
104
|
+
row.instanceColors?.forEach((color, index) => { instances.setColorAt(index, new Color().fromArray(color)); });
|
|
105
|
+
}
|
|
106
|
+
} else object = row.light !== undefined ? lightOf(row) : row.type === 'Bone' ? new Bone() : row.type === 'LOD' ? new LOD() : row.type === 'Scene' ? new Scene() : row.type === 'Group' ? new Group() : new Object3D();
|
|
107
|
+
object.name = row.name; object.visible = row.visible; object.castShadow = row.castShadow; object.receiveShadow = row.receiveShadow; object.matrix.fromArray(row.matrix);
|
|
108
|
+
if (row.transform === undefined) object.matrixAutoUpdate = false;
|
|
109
|
+
else { object.position.fromArray(row.transform.position); object.quaternion.fromArray(row.transform.quaternion); object.scale.fromArray(row.transform.scale); }
|
|
110
|
+
object.animations = restoreSceneAnimations(row.animations ?? []);
|
|
111
|
+
nodes.set(row.id, object);
|
|
112
|
+
constructing.delete(row.id);
|
|
113
|
+
return object;
|
|
114
|
+
}
|
|
115
|
+
for (const row of data.nodes) {
|
|
116
|
+
const object = create(row);
|
|
117
|
+
if (row.parent === null) { if (root !== undefined) throw new Error('Multiple scene roots'); root = object; }
|
|
118
|
+
else { const parent = nodes.get(row.parent); if (parent === undefined || !linked.has(row.parent)) throw new Error('Scene parent must precede its child'); parent.add(object); }
|
|
119
|
+
linked.add(row.id);
|
|
120
|
+
}
|
|
121
|
+
if (root === undefined) throw new Error('Missing scene root');
|
|
122
|
+
root.updateMatrixWorld(true);
|
|
123
|
+
for (const row of data.nodes) {
|
|
124
|
+
const object = nodes.get(row.id);
|
|
125
|
+
if (row.skin !== undefined) {
|
|
126
|
+
if (!isSkin(object)) throw new Error('Skin requires a mesh');
|
|
127
|
+
const bones = row.skin.bones.map(id => { const bone = nodes.get(id); if (!isBone(bone)) throw new Error('Unknown scene skin joint'); return bone; });
|
|
128
|
+
if (bones.length === 0 || bones.length !== row.skin.inverses.length || new Set(bones).size !== bones.length) throw new Error('Malformed scene skeleton');
|
|
129
|
+
object.skeleton = new Skeleton(bones, row.skin.inverses.map(values => new Matrix4().fromArray(values)));
|
|
130
|
+
object.bindMode = row.skin.bindMode; object.bindMatrix.fromArray(row.skin.bindMatrix); object.bindMatrixInverse.fromArray(row.skin.bindMatrixInverse);
|
|
131
|
+
}
|
|
132
|
+
if (row.levels !== undefined) {
|
|
133
|
+
if (!(object instanceof LOD)) throw new Error('LOD levels require an LOD object');
|
|
134
|
+
for (const level of row.levels) { const child = nodes.get(level.object); if (child === undefined) throw new Error('Unknown LOD child'); object.addLevel(child, level.distance, level.hysteresis); }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (root instanceof Scene && data.fog !== null) root.fog = data.fog.kind === 'linear' ? new Fog(new Color().fromArray(data.fog.color), data.fog.near, data.fog.far) : new FogExp2(new Color().fromArray(data.fog.color), data.fog.density);
|
|
138
|
+
return root;
|
|
139
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Object3D } from 'three';
|
|
2
|
+
/** Recompute authored matrices, including manually supplied local matrices, without visiting unrelated branches. */
|
|
3
|
+
export function updateAuthoringMatrix(object: Object3D): void {
|
|
4
|
+
const ancestors: Object3D[] = [];
|
|
5
|
+
let cursor: Object3D | null = object;
|
|
6
|
+
while (cursor !== null) {
|
|
7
|
+
ancestors.push(cursor);
|
|
8
|
+
cursor = cursor.parent;
|
|
9
|
+
}
|
|
10
|
+
for (const ancestor of ancestors.reverse())
|
|
11
|
+
ancestor.updateWorldMatrix(false, false, true);
|
|
12
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type Ajv from 'ajv';
|
|
2
|
+
import { isJsonData, parseNamedJson } from '@wildshard/format/json';
|
|
3
|
+
import { encodeCanonicalJson } from './immutable';
|
|
4
|
+
|
|
5
|
+
const DRAFT = 'http://json-schema.org/draft-07/schema#';
|
|
6
|
+
|
|
7
|
+
/** Validate named JSON with the caller's schema compiler under the existing byte bounds. */
|
|
8
|
+
export function validateNamedJson(schemaBytes: Uint8Array, bytes: Uint8Array, Validator: SchemaValidator): unknown {
|
|
9
|
+
return validateDefinedSchema(schemaBytes, parseNamedJson(bytes), Validator);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** CI6: each compiled schema by its exact canonical text, per validator (a product names hundreds of JSON blobs under a
|
|
13
|
+
* few schemas, and every call built a new validator and compiled again). A compiled schema is a pure function of its text;
|
|
14
|
+
* only a schema text that passed the checks below is kept. Bounded: the oldest goes first.
|
|
15
|
+
* The table is the process's: a product build loads this module twice, in the shard config's bundle and in the author's,
|
|
16
|
+
* each with its own copy of the same Ajv, and both validate the same named JSON, so the author's admission compiled every
|
|
17
|
+
* schema the config had just compiled (Driftwood: 31 schemas, ~0.3 s). A validator is known by its class's source,
|
|
18
|
+
* so only the same Ajv shares an entry. */
|
|
19
|
+
type AjvInstance = InstanceType<typeof Ajv>;
|
|
20
|
+
/** What validation constructs: an Ajv (or a subclass of one). */
|
|
21
|
+
export type SchemaValidator = new (options?: ConstructorParameters<typeof Ajv>[0]) => AjvInstance;
|
|
22
|
+
interface Compiled { readonly validator: AjvInstance; readonly validate: ReturnType<AjvInstance['compile']> }
|
|
23
|
+
type CompiledTable = Map<string, Map<string, Compiled>>;
|
|
24
|
+
const SHARED = Symbol.for('wildshard.sdk.compiledSchemas/1');
|
|
25
|
+
const isTable = (value: unknown): value is CompiledTable => value instanceof Map;
|
|
26
|
+
const compiled = ((): CompiledTable => {
|
|
27
|
+
const existing: unknown = Reflect.get(globalThis, SHARED);
|
|
28
|
+
if (isTable(existing)) return existing;
|
|
29
|
+
const table: CompiledTable = new Map();
|
|
30
|
+
Reflect.set(globalThis, SHARED, table); return table;
|
|
31
|
+
})();
|
|
32
|
+
const validators = new WeakMap<SchemaValidator, string>();
|
|
33
|
+
const COMPILED_LIMIT = 256;
|
|
34
|
+
/** The validator's identity across bundles: its class's source. */
|
|
35
|
+
function validatorKey(Validator: SchemaValidator): string {
|
|
36
|
+
let key = validators.get(Validator);
|
|
37
|
+
if (key === undefined) { key = String(Validator); validators.set(Validator, key); }
|
|
38
|
+
return key;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Shared canonical draft-07 validation policy; the dependency is supplied only by schema consumers. */
|
|
42
|
+
export function validateDefinedSchema(schemaBytes: Uint8Array, value: unknown, Validator: SchemaValidator): unknown {
|
|
43
|
+
if (schemaBytes.length > 1_000_000) throw new Error('Custom section schema exceeds its byte limit');
|
|
44
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(schemaBytes);
|
|
45
|
+
const kind = validatorKey(Validator), own = compiled.get(kind), known = own?.get(text);
|
|
46
|
+
if (known !== undefined) {
|
|
47
|
+
if (known.validate(value) !== true) throw new Error(`Custom section value refuses its schema: ${known.validator.errorsText(known.validate.errors)}`);
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
const schema: unknown = JSON.parse(text);
|
|
51
|
+
if (!isJsonData(schema) || typeof schema !== 'object' || schema === null || !('$schema' in schema) || schema.$schema !== DRAFT || encodeCanonicalJson(schema) !== text) throw new Error('Custom section schema must be canonical draft-07 JSON');
|
|
52
|
+
const validator = new Validator({ allErrors: false, strictKeywords: true, unknownFormats: true, jsonPointers: true });
|
|
53
|
+
const validate = validator.compile(schema);
|
|
54
|
+
if (validate.$async === true) throw new Error('Custom section schemas cannot be asynchronous');
|
|
55
|
+
const table = own ?? new Map<string, Compiled>();
|
|
56
|
+
if (own === undefined) compiled.set(kind, table);
|
|
57
|
+
if (table.size >= COMPILED_LIMIT) { const oldest = table.keys().next().value; if (oldest !== undefined) table.delete(oldest); }
|
|
58
|
+
table.set(text, { validator, validate });
|
|
59
|
+
if (validate(value) !== true) throw new Error(`Custom section value refuses its schema: ${validator.errorsText(validate.errors)}`);
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import Ajv from 'ajv';
|
|
3
|
+
import { registeredJsonContract, validateRegisteredJson } from '@wildshard/format/registeredJson';
|
|
4
|
+
import { encodeCanonicalJson } from './immutable';
|
|
5
|
+
import { registeredJsonSchema } from '@wildshard/engine/host/formatJsonSchema';
|
|
6
|
+
import { validateNamedJson } from './schemaValidation';
|
|
7
|
+
|
|
8
|
+
/** A platform section entry with its defining schema identity. */
|
|
9
|
+
export interface DefinedSectionEntry {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly schema: string;
|
|
13
|
+
readonly hash: string;
|
|
14
|
+
readonly bytes: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Relative product paths and their canonical bytes, ready for the product writer. */
|
|
18
|
+
export interface EmittedSections {
|
|
19
|
+
readonly sections: readonly DefinedSectionEntry[];
|
|
20
|
+
readonly files: ReadonlyMap<string, Uint8Array>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Validate serialized named JSON under its existing producer/reader byte bound.
|
|
24
|
+
* The defining schema is independently bounded; no custom-section node cap is
|
|
25
|
+
* imposed on a payload that was already emitted as a named file. Registered
|
|
26
|
+
* names also retain their original defining semantic parser before publication. */
|
|
27
|
+
export function validateDefinedJson(schemaBytes: Uint8Array, bytes: Uint8Array, name?: string): unknown {
|
|
28
|
+
const value = validateNamedJson(schemaBytes, bytes, Ajv);
|
|
29
|
+
if (name !== undefined && registeredJsonContract(name) !== undefined) {
|
|
30
|
+
if (new TextDecoder('utf-8', { fatal: true }).decode(schemaBytes) !== encodeCanonicalJson(registeredJsonSchema(name)))
|
|
31
|
+
throw new Error('Registered JSON requires its exact defining format contract');
|
|
32
|
+
validateRegisteredJson(name, value);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Parse authored section values with their defining native grammar. Use when
|
|
38
|
+
* the wire schema is owned separately: defaults, transforms and custom checks
|
|
39
|
+
* still run, without converting that grammar into a different JSON schema. */
|
|
40
|
+
export function parseSectionValue<S extends v.GenericSchema>(schema: S, value: unknown): v.InferOutput<S> {
|
|
41
|
+
return v.parse(schema, value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Admit both device-tier records with the same defining grammar and native transform/default order. */
|
|
45
|
+
export function parseDeviceTierSections<S extends v.GenericSchema>(schema: S, value: unknown): v.InferOutput<v.ObjectSchema<{ readonly phone: S; readonly desktop: S }, undefined>> {
|
|
46
|
+
return v.parse(v.object({ phone: schema, desktop: schema }), value);
|
|
47
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The CLI finds a shard source on disk from the path it was given.
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Resolve the shard source beneath the given repo path.
|
|
4
|
+
import { basename, dirname, resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
/** The build entry that marks a folder as a shard source. */
|
|
7
|
+
export const SHARD_CONFIG = 'shard.config.ts';
|
|
8
|
+
/** A hand-written shard source (`new --template blender`, J314) is a shard file folder held by hand: its index. */
|
|
9
|
+
export const SHARD_INDEX = 'shard.json';
|
|
10
|
+
|
|
11
|
+
/** A hand-written shard source: a shard file folder (`shard.json`) a person edits, with no `shard.config.ts` to build. */
|
|
12
|
+
export function isHandwrittenSource(source: string): boolean {
|
|
13
|
+
return existsSync(resolve(source, SHARD_INDEX)) && !existsSync(resolve(source, SHARD_CONFIG));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* SA16 (J317): the shard source a path names. A folder with `shard.config.ts` is one; a single-shard repo keeps its
|
|
18
|
+
* source at `src/` (or a hand-written shard file folder there, `--template blender`); a multi-shard repo keeps `src/shards/<slug>/`, so its repo root names one only when it holds exactly
|
|
19
|
+
* one. Any other path comes back unchanged, so the verb refuses it as it always has.
|
|
20
|
+
*/
|
|
21
|
+
export function findShardSource(path: string): string {
|
|
22
|
+
const given = resolve(path);
|
|
23
|
+
if (existsSync(resolve(given, SHARD_CONFIG))) return given;
|
|
24
|
+
if (existsSync(resolve(given, 'src', SHARD_CONFIG)) || isHandwrittenSource(resolve(given, 'src'))) return resolve(given, 'src');
|
|
25
|
+
const shards = resolve(given, 'src/shards');
|
|
26
|
+
if (!existsSync(shards)) return given;
|
|
27
|
+
const found = readdirSync(shards, { withFileTypes: true }).filter(entry => entry.isDirectory() && existsSync(resolve(shards, entry.name, SHARD_CONFIG)));
|
|
28
|
+
return found.length === 1 && found[0] !== undefined ? resolve(shards, found[0].name) : given;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A shard source at a single-shard repo's `src/` (J317), rather than its own folder or `src/shards/<slug>/`. */
|
|
32
|
+
export function isRepoSource(source: string): boolean {
|
|
33
|
+
return basename(source) === 'src' && (existsSync(resolve(source, SHARD_CONFIG)) || isHandwrittenSource(source));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Where build output lands for a shard source: the repo root for `src/`, the source folder itself otherwise. */
|
|
37
|
+
export function shardOutputRoot(source: string): string {
|
|
38
|
+
return isRepoSource(source) ? dirname(source) : source;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The folder name build checks a manifest's slug against (`project-folder-slug`). A `src/` source names no slug by its
|
|
43
|
+
* folder, so its `manifest.json` slug is the folder; any other source is named by its folder, as before.
|
|
44
|
+
*/
|
|
45
|
+
export function shardFolderName(source: string): string {
|
|
46
|
+
if (!isRepoSource(source)) return basename(source);
|
|
47
|
+
const index = resolve(source, SHARD_INDEX);
|
|
48
|
+
if (isHandwrittenSource(source)) {
|
|
49
|
+
const parsed: unknown = JSON.parse(readFileSync(index, 'utf8'));
|
|
50
|
+
if (typeof parsed === 'object' && parsed !== null && 'identity' in parsed && typeof parsed.identity === 'object' && parsed.identity !== null
|
|
51
|
+
&& 'slug' in parsed.identity && typeof parsed.identity.slug === 'string') return parsed.identity.slug;
|
|
52
|
+
}
|
|
53
|
+
const manifest = resolve(source, 'manifest.json');
|
|
54
|
+
if (existsSync(manifest)) {
|
|
55
|
+
const parsed: unknown = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
56
|
+
if (typeof parsed === 'object' && parsed !== null && 'slug' in parsed && typeof parsed.slug === 'string') return parsed.slug;
|
|
57
|
+
}
|
|
58
|
+
return basename(dirname(source));
|
|
59
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- The CLI reads author files through a bounded open descriptor.
|
|
2
|
+
import { openSync, closeSync, fstatSync, readSync } from 'node:fs';
|
|
3
|
+
import { SHARDFILE_ADMISSION_LIMITS as limits } from '@wildshard/format/admissionLimits';
|
|
4
|
+
|
|
5
|
+
/** Read a file within its declared wire bound, detecting growth without an unbounded readFile allocation.
|
|
6
|
+
* The requested cap is validated before opening the file.
|
|
7
|
+
* The initial size check runs before allocating the payload buffer.
|
|
8
|
+
* The descriptor is closed even when a bound or growth check rejects it.
|
|
9
|
+
* A short read returns only the bytes actually read from the open descriptor. */
|
|
10
|
+
export function readBoundedFile(path: string, maximum: number): Uint8Array {
|
|
11
|
+
if (!Number.isSafeInteger(maximum) || maximum < 0 || maximum > limits.wireBytes) throw new Error('Invalid file admission bound');
|
|
12
|
+
const descriptor = openSync(path, 'r');
|
|
13
|
+
try {
|
|
14
|
+
const size = fstatSync(descriptor).size;
|
|
15
|
+
if (!Number.isSafeInteger(size) || size > maximum) throw new Error(`File exceeds admission byte cap: ${path} (${size} > ${maximum})`);
|
|
16
|
+
const bytes = new Uint8Array(size); let at = 0;
|
|
17
|
+
while (at < size) { const count = readSync(descriptor, bytes, at, size - at, null); if (count === 0) break; at += count; }
|
|
18
|
+
if (readSync(descriptor, new Uint8Array(1), 0, 1, null) !== 0) throw new Error('File grew beyond admission byte cap');
|
|
19
|
+
return bytes.subarray(0, at);
|
|
20
|
+
} finally { closeSync(descriptor); }
|
|
21
|
+
}
|
|
22
|
+
/** Parse only source bytes within the shared network/cache limit, rejecting malformed UTF-8.
|
|
23
|
+
* JSON parsing starts after the bounded read and fatal UTF-8 decoding. */
|
|
24
|
+
export function readShardfileSource(path: string): unknown {
|
|
25
|
+
return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(readBoundedFile(path, limits.sourceBytes)));
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Matrix4, Object3D, Quaternion, Vector3 } from 'three';
|
|
2
|
+
import { updateAuthoringMatrix } from './sceneTransform';
|
|
3
|
+
import type { SpawnTables } from '@wildshard/format/spawnTables';
|
|
4
|
+
|
|
5
|
+
/** Complete authored spawn populations and fixed placement tables, without a live spawn owner. */
|
|
6
|
+
export type AuthorSpawnTables = SpawnTables;
|
|
7
|
+
/** One player start in the ordinary scene graph; position is feet and rotation faces local -Z. */
|
|
8
|
+
export class PlayerStart extends Object3D {
|
|
9
|
+
constructor() { super(); this.name = 'player'; }
|
|
10
|
+
}
|
|
11
|
+
/** One authored creature or actor placement. The kind names an independently declared species or actor row. */
|
|
12
|
+
export class Spawn extends Object3D {
|
|
13
|
+
/** The independently declared species or actor identity. */
|
|
14
|
+
kind: string;
|
|
15
|
+
constructor(kind = '') { super(); this.kind = kind; }
|
|
16
|
+
/** Clone the kind together with its standard three.js transform. */
|
|
17
|
+
override copy(source: this, recursive = true): this { super.copy(source, recursive); this.kind = source.kind; return this; }
|
|
18
|
+
}
|
|
19
|
+
/** The existing player/actor placement convention, read from a world transform. */
|
|
20
|
+
export interface SpawnPlacement {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
z: number;
|
|
24
|
+
yaw: number;
|
|
25
|
+
}
|
|
26
|
+
/** Spawn admission refuses a tilted or scaled frame; bodies own their declared dimensions. */
|
|
27
|
+
export function spawnPlacement(object: PlayerStart | Spawn): SpawnPlacement {
|
|
28
|
+
updateAuthoringMatrix(object);
|
|
29
|
+
const position = new Vector3(), rotation = new Quaternion(), scale = new Vector3();
|
|
30
|
+
object.matrixWorld.decompose(position, rotation, scale);
|
|
31
|
+
const composed = new Matrix4().compose(position, rotation, scale);
|
|
32
|
+
if (object.matrixWorld.elements.some((value, index) => !Number.isFinite(value) || Math.abs(value - (composed.elements[index] ?? Infinity)) > 1e-8))
|
|
33
|
+
throw new Error('Spawn requires an unsheared affine transform');
|
|
34
|
+
if (![...position, ...rotation, ...scale].every(Number.isFinite) || Math.abs(rotation.x) > 1e-8 || Math.abs(rotation.z) > 1e-8 || scale.distanceTo(new Vector3(1, 1, 1)) > 1e-8)
|
|
35
|
+
throw new Error('Spawn requires finite upright unscaled placement');
|
|
36
|
+
const forward = new Vector3(0, 0, 1).applyQuaternion(rotation);
|
|
37
|
+
return { x: position.x, y: position.y, z: position.z, yaw: object.matrixAutoUpdate && (object.parent === null || object.parent.matrixWorld.equals(new Matrix4())) && object.rotation.x === 0 && object.rotation.z === 0 ? object.rotation.y : Math.atan2(forward.x, forward.z) };
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { clipAnimate as platformClipAnimate, playClips as platformPlayClips, type ClipCase as PlatformClipCase, type ClipChannel as PlatformClipChannel, type ClipClock as PlatformClipClock, type ClipCtx as PlatformClipCtx, type ClipFactor as PlatformClipFactor, type ClipRow as PlatformClipRow, type ClipTerm as PlatformClipTerm, type ClipWhen as PlatformClipWhen, type SpeciesClips as PlatformSpeciesClips } from '@wildshard/engine/game/plugin/animation';
|
|
2
|
+
|
|
3
|
+
/** The clocks a clip factor reads: the animal's time or its gait phase. */
|
|
4
|
+
export type ClipClock = PlatformClipClock;
|
|
5
|
+
/** When a clip case or term applies. */
|
|
6
|
+
export type ClipWhen = PlatformClipWhen;
|
|
7
|
+
/** One factor of a clip term (a bare number is a constant). */
|
|
8
|
+
export type ClipFactor = PlatformClipFactor;
|
|
9
|
+
/** One term of a clip sum: a constant or a product of factors. */
|
|
10
|
+
export type ClipTerm = PlatformClipTerm;
|
|
11
|
+
/** One case of a clip row. */
|
|
12
|
+
export type ClipCase = PlatformClipCase;
|
|
13
|
+
/** The bone channels a clip row drives. */
|
|
14
|
+
export type ClipChannel = PlatformClipChannel;
|
|
15
|
+
/** One clip row: a bone's channel and its cases. */
|
|
16
|
+
export type ClipRow = PlatformClipRow;
|
|
17
|
+
/** A species' declarative clips (SHARD-PLATFORM M3). */
|
|
18
|
+
export type SpeciesClips = PlatformSpeciesClips;
|
|
19
|
+
/** What a clip reads from the frame. */
|
|
20
|
+
export type ClipCtx = PlatformClipCtx;
|
|
21
|
+
/** Plays one frame of a species' clips on its bones. */
|
|
22
|
+
export const playClips: typeof platformPlayClips = platformPlayClips;
|
|
23
|
+
/** A species' `animate` from its clip rows. */
|
|
24
|
+
export const clipAnimate: typeof platformClipAnimate = platformClipAnimate;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { CreatureStrikeSchema } from '@wildshard/format/creatures';
|
|
3
|
+
import { readSpecies, readSpeciesProgram, SpeciesSchema } from '@wildshard/format/speciesPrograms';
|
|
4
|
+
import { SocketRigCreatureSchema } from '@wildshard/format/socketRigCreature';
|
|
5
|
+
|
|
6
|
+
/** The same strict portable strike admission used by native and page population rows. */
|
|
7
|
+
export const StrikeSchema: typeof CreatureStrikeSchema = CreatureStrikeSchema;
|
|
8
|
+
/** Serializable native strike accepted by the SDK, without an authored callback. */
|
|
9
|
+
export type StrikeData = v.InferOutput<typeof StrikeSchema>;
|
|
10
|
+
/** Validate a serializable native strike before its trusted engine adapter is constructed. */
|
|
11
|
+
export function strike(data: unknown): StrikeData { return v.parse(StrikeSchema, data); }
|
|
12
|
+
/** Gameplay-only species fields; the defining declaration lives in the format layer. */
|
|
13
|
+
export type SpeciesData = ReturnType<typeof readSpecies>;
|
|
14
|
+
/** Refuse malformed species data before registration, actor construction or view creation. */
|
|
15
|
+
export function species(data: unknown): SpeciesData { return readSpecies(data); }
|
|
16
|
+
|
|
17
|
+
/** Admit complete native species, strike and module declarations before compiling actors. */
|
|
18
|
+
export function speciesProgramRows(input: unknown): ReturnType<typeof readSpeciesProgram> { return readSpeciesProgram(input); }
|
|
19
|
+
|
|
20
|
+
/** Prepare a strict reader for selected defining species fields. Only native
|
|
21
|
+
* field names are accepted; original validators, defaults and issue order remain. */
|
|
22
|
+
export function speciesFieldReader<const Keys extends v.ObjectKeys<typeof SpeciesSchema>>(keys: Keys):
|
|
23
|
+
(input: unknown) => v.InferOutput<ReturnType<typeof v.pick<typeof SpeciesSchema, Keys>>> {
|
|
24
|
+
const schema = v.pick(SpeciesSchema, keys);
|
|
25
|
+
return input => v.parse(schema, input);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Admit a socket-dressed creature card, coat and model metadata without constructing a live body. */
|
|
29
|
+
export function socketRigCreatureRows(input: unknown): v.InferOutput<typeof SocketRigCreatureSchema> { return v.parse(SocketRigCreatureSchema, input); }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { admitSpeciesProgram, type BrainedSpecies as PlatformBrainedSpecies, type SpeciesBrain as PlatformSpeciesBrain, type SpeciesBrains as PlatformSpeciesBrains } from "@wildshard/engine/game/plugin/brain";
|
|
2
|
+
|
|
3
|
+
import type { StrikeData } from './species';
|
|
4
|
+
|
|
5
|
+
/** A species row's declared brain (SHARD-PLATFORM SF27): `{ archetype, data }`, one platform archetype and its data. */
|
|
6
|
+
export type SpeciesBrain = PlatformSpeciesBrain;
|
|
7
|
+
/** Species gameplay data with an optional `brain`; a row without one keeps its runtime's own policy. */
|
|
8
|
+
export type BrainedSpecies = PlatformBrainedSpecies;
|
|
9
|
+
/** A catalogue's admitted brains: browser callbacks (`bind`), the live witness and the headless home policies. */
|
|
10
|
+
export type SpeciesBrains = PlatformSpeciesBrains;
|
|
11
|
+
/**
|
|
12
|
+
* Admit a shard's species catalogue and its strike rows (SF27): each strike passes the SDK's strict strike schema, each
|
|
13
|
+
* declared brain its archetype's schema, and every strike a brain names resolves, before any row or policy is built; a
|
|
14
|
+
* `script` brain's module comes in `modules` (a plain row: its SHA-256 → the base64 its bake wrote) and is admitted on its own
|
|
15
|
+
* ScriptHost.
|
|
16
|
+
*/
|
|
17
|
+
export function speciesBrains(species: readonly BrainedSpecies[], strikes: readonly StrikeData[], modules: Readonly<Record<string, string>> = {}): SpeciesBrains {
|
|
18
|
+
return admitSpeciesProgram({ species, strikes, modules });
|
|
19
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { assertConfigBoundary } from './configBoundary';
|
|
2
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Author inputs must remain within the project.
|
|
3
|
+
import { realpathSync } from 'node:fs';
|
|
4
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Author inputs must remain within the project.
|
|
5
|
+
import { resolve, sep } from 'node:path';
|
|
6
|
+
import { executeBundle } from './executeBundle';
|
|
7
|
+
import { build } from 'vite';
|
|
8
|
+
// oxlint-disable-next-line import/no-nodejs-modules -- Resolve the defining reader into the same author bundle.
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import type { Object3D } from 'three';
|
|
11
|
+
import { readScene, type SceneDescription } from './scene';
|
|
12
|
+
import { confined, publishScene, type SynthResult } from './bake';
|
|
13
|
+
|
|
14
|
+
/** Inspect an ordinary three.js graph and publish canonical scene.json, with an immutable content-hash copy.
|
|
15
|
+
* Graph generation still executes on each synth; expensive producers use the verified native bake cache separately.
|
|
16
|
+
* No client, rendering, physics service, wire-format admission or generated source file is involved. */
|
|
17
|
+
export function synthScene(scene: Object3D, project: string, slug: string): SynthResult {
|
|
18
|
+
if (!/^[a-z][a-z0-9-]{0,127}$/u.test(slug)) throw new Error('Scene synth requires a bounded shard slug');
|
|
19
|
+
return publishScene(readScene(scene), project, slug);
|
|
20
|
+
}
|
|
21
|
+
/** Execute a local author config in Node and synthesize its named scene and identity exports.
|
|
22
|
+
* This transitional declaration composes real three.js objects; the existing default shardfile declaration is optional.
|
|
23
|
+
* Only the scene reader's supported features enter JSON; missing scenes refuse instead of synthesizing a fake world. */
|
|
24
|
+
export async function synthProject(project: string): Promise<SynthResult> {
|
|
25
|
+
const root = realpathSync(project), entry = confined(root, 'shard.config.ts');
|
|
26
|
+
const three = import.meta.resolve('three'), reader = fileURLToPath(import.meta.resolve('@wildshard/sdk/scene'));
|
|
27
|
+
// Reader and SDK declarations must share one module graph, not just the same three.js constructors.
|
|
28
|
+
const virtual = resolve(root, '.wildshard-synth-entry.ts');
|
|
29
|
+
const wrapper = `import * as input from ${JSON.stringify(entry)};
|
|
30
|
+
import { Object3D } from 'three';
|
|
31
|
+
import { readScene } from ${JSON.stringify(reader)};
|
|
32
|
+
if (!(input.scene instanceof Object3D)) throw new Error('Scene config must export a real three.js scene');
|
|
33
|
+
if (typeof input.identity?.slug !== 'string') throw new Error('Scene config must export identity.slug');
|
|
34
|
+
export default { scene: readScene(input.scene), slug: input.identity.slug };`;
|
|
35
|
+
const result = await build({ configFile: false, publicDir: false, logLevel: 'silent',
|
|
36
|
+
plugins: [{ name: 'author-scene-three-identity', enforce: 'pre', resolveId(id, importer) {
|
|
37
|
+
if (id === virtual) return virtual;
|
|
38
|
+
const author = importer?.startsWith(root + sep) === true && !importer.startsWith(resolve(root, 'node_modules') + sep);
|
|
39
|
+
if (author && (/^@wildshard\/(?:game|engine)\//u.test(id) || /^@wildshard\/(?:sdk|sharddev)\/runtime\//u.test(id))) throw new Error('Scene synth cannot import trusted runtime');
|
|
40
|
+
return id === 'three' ? { id: three, external: true } : null;
|
|
41
|
+
}, load(id) {
|
|
42
|
+
if (id === virtual) return wrapper;
|
|
43
|
+
const file = id.split('?')[0] ?? id;
|
|
44
|
+
if (!file.startsWith(root + sep)) return null;
|
|
45
|
+
const relative = file.slice(root.length + 1).split(sep).join('/');
|
|
46
|
+
if (relative.startsWith('node_modules/')) return null;
|
|
47
|
+
if (relative !== 'shard.config.ts' && !/^(?:generators|data|quests|assets|behaviour|blender)\//u.test(relative)) throw new Error('Scene synth source is outside authoring folders');
|
|
48
|
+
if (realpathSync(file) !== file) throw new Error('Scene synth author source must not be a symlink');
|
|
49
|
+
return null;
|
|
50
|
+
} }],
|
|
51
|
+
build: { write: false, minify: false, target: 'esnext', lib: { entry: virtual, formats: ['es'], fileName: 'scene' },
|
|
52
|
+
rolldownOptions: { platform: 'node', external: [/^node:/u, 'assemblyscript/dist/asc.js'] } },
|
|
53
|
+
});
|
|
54
|
+
const built = Array.isArray(result) ? result[0] : result;
|
|
55
|
+
if (built === undefined || !('output' in built) || Array.isArray(result) && result.length !== 1) throw new Error('Scene config produced unexpected output');
|
|
56
|
+
const chunks = built.output.filter(output => output.type === 'chunk'), chunk = chunks[0];
|
|
57
|
+
if (chunks.length !== 1 || chunk === undefined) throw new Error('Scene config must compile as one module');
|
|
58
|
+
assertConfigBoundary([...chunk.imports, ...chunk.dynamicImports]);
|
|
59
|
+
const loaded: unknown = await executeBundle(chunk.code, root);
|
|
60
|
+
if (typeof loaded !== 'object' || loaded === null || !('default' in loaded)) throw new Error('Scene config produced no reader result');
|
|
61
|
+
const data = loaded.default;
|
|
62
|
+
if (typeof data !== 'object' || data === null || !('slug' in data) || typeof data.slug !== 'string'
|
|
63
|
+
|| !('scene' in data) || typeof data.scene !== 'object' || data.scene === null || !('version' in data.scene) || data.scene.version !== 1) throw new Error('Invalid scene reader result');
|
|
64
|
+
// Only the defining readScene inside this trusted author bundle creates this result. Wire admission is separate.
|
|
65
|
+
return publishScene(data.scene as SceneDescription, root, data.slug);
|
|
66
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Test-only setup for the retained real ABI2 protocol contracts.
|
|
2
|
+
/** H13's unshipped dual-admission artifacts. Both wrappers receive the same
|
|
3
|
+
* authored closure; neither artifact replaces the public v0/v1 product. */
|
|
4
|
+
import { admitScriptContract } from '@wildshard/format/scriptContract';
|
|
5
|
+
import { admitScriptV2,parseScriptArtifactV2,SCRIPT_V2_REVISIONS,type ScriptArtifactV2 } from '@wildshard/format/scriptAdmissionV2';
|
|
6
|
+
import type { V2Lane } from '@wildshard/format/scriptFuelV2';
|
|
7
|
+
import { inspectDecisionSource } from '../decisionSource';
|
|
8
|
+
import { hashImmutableBytes } from '../immutable';
|
|
9
|
+
import { compileScript } from '../bake/compileScript';
|
|
10
|
+
import { compileScriptV2 } from '../bake/compileScriptV2';
|
|
11
|
+
|
|
12
|
+
interface Wrapper { readonly source: string; readonly sources?: Readonly<Record<string,string>> }
|
|
13
|
+
function checkSource(path: string,text: string): void {
|
|
14
|
+
if (path === 'main.ts' || !/^(?:[a-zA-Z0-9_-][a-zA-Z0-9_.-]*\/)*[a-zA-Z0-9_-][a-zA-Z0-9_.-]*\.ts$/u.test(path) || typeof text !== 'string') throw new Error('Invalid dual script virtual source');
|
|
15
|
+
}
|
|
16
|
+
function resolve(from: string,specifier: string): string {
|
|
17
|
+
if (!specifier.startsWith('.')) throw new Error('Dual script imports must be captured and relative');
|
|
18
|
+
const parts = from.split('/');parts.pop();
|
|
19
|
+
for (const part of specifier.split('/')) {
|
|
20
|
+
if (part === '.' || part.length === 0) continue;
|
|
21
|
+
if (part === '..') { if (parts.length === 0) throw new Error('Dual script import escapes its closure');parts.pop(); }
|
|
22
|
+
else parts.push(part);
|
|
23
|
+
}
|
|
24
|
+
return `${parts.join('/').replace(/\.(?:as|ts)$/u,'')}.ts`;
|
|
25
|
+
}
|
|
26
|
+
function capture(authors: ReadonlyMap<string,string>,wrapper: Wrapper): Readonly<Record<string,string>> {
|
|
27
|
+
const sources: Record<string,string> = Object.fromEntries(authors);
|
|
28
|
+
for (const [path,text] of Object.entries(wrapper.sources ?? {})) {
|
|
29
|
+
checkSource(path,text);
|
|
30
|
+
if (authors.has(path)) throw new Error('Dual wrapper overrides an authored source');sources[path] = text;
|
|
31
|
+
}
|
|
32
|
+
if (Object.keys(sources).length > 64) throw new Error('Too many dual script virtual sources');
|
|
33
|
+
return sources;
|
|
34
|
+
}
|
|
35
|
+
async function reachable(source: string,sources: Readonly<Record<string,string>>,authors: ReadonlyMap<string,string>): Promise<void> {
|
|
36
|
+
const pending = ['main.ts'], seen = new Set<string>();
|
|
37
|
+
while (pending.length > 0) {
|
|
38
|
+
const path = pending.pop();if (path === undefined || seen.has(path)) continue;seen.add(path);
|
|
39
|
+
const text = path === 'main.ts' ? source : sources[path];if (text === undefined) throw new Error('Missing dual script source');
|
|
40
|
+
const info = await inspectDecisionSource(text,path);
|
|
41
|
+
for (const name of info.imports) pending.push(resolve(path,name));
|
|
42
|
+
}
|
|
43
|
+
for (const path of authors.keys()) if (!seen.has(path)) throw new Error(`Dual wrapper omits authored source: ${path}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Adapter sources may differ; authored bodies cannot. Full source reachability
|
|
47
|
+
* prevents a fake second wrapper from silently omitting a port's helper files.
|
|
48
|
+
* Callers publish only their explicitly selected candidate, never this v1
|
|
49
|
+
* shadow artifact. The existing public producer remains untouched. */
|
|
50
|
+
export async function compileDualScriptV2(input: {
|
|
51
|
+
readonly authored: ReadonlyMap<string,string>; readonly legacy: Wrapper;
|
|
52
|
+
readonly candidate: Wrapper & { readonly lane: V2Lane; readonly ioBytes: number };
|
|
53
|
+
readonly pages: number;
|
|
54
|
+
}): Promise<{
|
|
55
|
+
readonly legacy: { readonly bytes: Uint8Array; readonly hash: string };
|
|
56
|
+
readonly candidate: { readonly bytes: Uint8Array; readonly artifact: ScriptArtifactV2 };
|
|
57
|
+
readonly authors: readonly { readonly path: string; readonly hash: string }[];
|
|
58
|
+
}> {
|
|
59
|
+
const authored = new Map(input.authored), legacy = input.legacy.source, candidate = input.candidate.source;
|
|
60
|
+
const pages = input.pages, ioBytes = input.candidate.ioBytes, lane = input.candidate.lane;
|
|
61
|
+
if (authored.size === 0 || authored.size > 64 || authored.has('main.ts')) throw new Error('Dual build requires a bounded authored closure outside its wrappers');
|
|
62
|
+
for (const [path,text] of authored) checkSource(path,text);
|
|
63
|
+
const oldSources = capture(authored,input.legacy), newSources = capture(authored,input.candidate);
|
|
64
|
+
await reachable(legacy,oldSources,authored);await reachable(candidate,newSources,authored);
|
|
65
|
+
const oldBytes = await compileScript(legacy,{ abi: 1,maximumPages: pages,sources: oldSources });admitScriptContract(oldBytes,{ abi: 1,pages });
|
|
66
|
+
const newBytes = await compileScriptV2(candidate,{ maximumPages: pages,ioBytes,lane,sources: newSources,compilerRevision: SCRIPT_V2_REVISIONS.compiler });
|
|
67
|
+
admitScriptV2(newBytes,{ ioBytes,lane,compilerRevision: SCRIPT_V2_REVISIONS.compiler,admissionRevision: SCRIPT_V2_REVISIONS.admission });
|
|
68
|
+
return { legacy: { bytes: oldBytes,hash: hashImmutableBytes(oldBytes) },candidate: {
|
|
69
|
+
bytes: newBytes,artifact: parseScriptArtifactV2({ abi: 2,minor: 0,compilerRevision: SCRIPT_V2_REVISIONS.compiler,admissionRevision: SCRIPT_V2_REVISIONS.admission,hash: hashImmutableBytes(newBytes),lane,pages,ioBytes }),
|
|
70
|
+
},authors: [...authored].sort(([a],[b]) => a < b ? -1 : a > b ? 1 : 0).map(([path,text]) => ({ path,hash: hashImmutableBytes(new TextEncoder().encode(text)) })) };
|
|
71
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Test-only setup for the retained real ABI2 protocol contracts.
|
|
2
|
+
/** Generate the module-sized sim loop. A binding program exports onBinding;
|
|
3
|
+
* it uses the same memory SDK and cannot import a JS callback or refill fuel. */
|
|
4
|
+
import { compileScriptV2 } from '../bake/compileScriptV2';
|
|
5
|
+
import { v2CoreSource } from '../as/wsV2';
|
|
6
|
+
|
|
7
|
+
export function compileSimV2(program: string,options: {
|
|
8
|
+
readonly io: number; readonly ioBytes: number; readonly maximumPages?: number;
|
|
9
|
+
readonly sources?: Readonly<Record<string,string>>;
|
|
10
|
+
}): Promise<Uint8Array> {
|
|
11
|
+
if (Object.hasOwn(options.sources ?? {},'program.ts') || Object.hasOwn(options.sources ?? {},'sdk/as/wsV2.ts')) throw new Error('Reserved v2 sim source');
|
|
12
|
+
const source = `import * as ws from './sdk/as/wsV2';import { onBinding } from './program';
|
|
13
|
+
export function ws_abi():i32{return 2;} export function ws_io():i32{return ws.io();}
|
|
14
|
+
export function ws_init(lo:i32,hi:i32,fuel:i32):i32{return 0;}
|
|
15
|
+
export function ws_step(tick:i32,fuel:i32):i32{
|
|
16
|
+
ws.beginState();for(let i=0;i<ws.count(1);i++){if(!ws.beginBinding(i))continue;onBinding();ws.endBinding();}return 0;
|
|
17
|
+
}`;
|
|
18
|
+
return compileScriptV2(source,{ lane: 'sim',ioBytes: options.ioBytes,...(options.maximumPages === undefined ? {} : { maximumPages: options.maximumPages }),
|
|
19
|
+
sources: { ...options.sources,'program.ts': program,'sdk/as/wsV2.ts': v2CoreSource(options.io) },
|
|
20
|
+
});
|
|
21
|
+
}
|