@wildshard/sdk 0.0.1 → 0.2.4
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 +895 -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 +47 -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 +39 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +204 -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 +291 -0
- package/src/cli/report.ts +20 -0
- package/src/cli/shardfile/command.ts +49 -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/agentFiles.ts +127 -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 +118 -0
- package/src/sharddev/checkProject.ts +127 -0
- package/src/sharddev/cli.ts +200 -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 +226 -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 +29 -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 +304 -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,115 @@
|
|
|
1
|
+
import { Object3D, Vector3 } from 'three';
|
|
2
|
+
import { ZiplineModeSchema, UpdraftModeSchema, type ZiplineMode, type UpdraftMode, RideModeSchema, type RideMode, GrappleModeSchema, type GrappleMode, LadderModeSchema, type LadderMode } from '@wildshard/format/modes';
|
|
3
|
+
import * as v from 'valibot';
|
|
4
|
+
import { updateAuthoringMatrix } from './sceneTransform';
|
|
5
|
+
|
|
6
|
+
/** A complete set of admitted platform traversal declarations. */
|
|
7
|
+
export interface ModeRows { grapple?: GrappleMode[]; ride?: RideMode[]; traverse: (ZiplineMode | UpdraftMode | LadderMode)[] }
|
|
8
|
+
|
|
9
|
+
/** Data-only cable parameters; its endpoints come from ordinary authoring vectors. */
|
|
10
|
+
export type ZiplineOptions = Partial<Pick<ZiplineMode, 'sag' | 'hang' | 'gravity' | 'drag' | 'maxSpeed'>>;
|
|
11
|
+
/** An authored cable traversal in a normal three.js hierarchy; nothing installs a runtime service. */
|
|
12
|
+
export class Zipline extends Object3D {
|
|
13
|
+
/** Floor positions in this object's local frame. */
|
|
14
|
+
readonly top: Vector3 = new Vector3();
|
|
15
|
+
/** The floor at the landing, in this object's local frame. */
|
|
16
|
+
readonly bottom: Vector3 = new Vector3();
|
|
17
|
+
/** Bounded physical parameters emitted at synth time. */
|
|
18
|
+
options: ZiplineOptions;
|
|
19
|
+
constructor(top: Vector3 = new Vector3(), bottom: Vector3 = new Vector3(), options: ZiplineOptions = {}) {
|
|
20
|
+
super(); this.name = 'zipline'; this.top.copy(top); this.bottom.copy(bottom); this.options = { ...options };
|
|
21
|
+
}
|
|
22
|
+
/** Clone independent endpoint vectors and parameter data together with the normal graph state. */
|
|
23
|
+
override copy(source: this, recursive = true): this { super.copy(source, recursive); this.top.copy(source.top); this.bottom.copy(source.bottom); this.options = { ...source.options }; return this; }
|
|
24
|
+
/** Emit validated world-space floors; the platform derives cable height and sag using one law. */
|
|
25
|
+
toModeData(): ZiplineMode {
|
|
26
|
+
updateAuthoringMatrix(this);
|
|
27
|
+
const top = this.top.clone().applyMatrix4(this.matrixWorld), bottom = this.bottom.clone().applyMatrix4(this.matrixWorld);
|
|
28
|
+
return v.parse(ZiplineModeSchema, { ...this.options, kind: 'zipline', id: this.name,
|
|
29
|
+
top: { x: top.x, y: top.y, z: top.z }, bottom: { x: bottom.x, y: bottom.y, z: bottom.z } });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The width and force of a directional board wind column. */
|
|
34
|
+
export interface UpdraftOptions { width: number; lift: number; margin?: number }
|
|
35
|
+
const DEFAULT_UPDRAFT = { width: 1, lift: 0 };
|
|
36
|
+
/** An authored directional wind column; from/to are local points and the ceiling is to.y + margin. */
|
|
37
|
+
export class Updraft extends Object3D {
|
|
38
|
+
/** Beginning of the column's horizontal run. */
|
|
39
|
+
readonly from: Vector3 = new Vector3();
|
|
40
|
+
/** End of the run, including its upper ceiling. */
|
|
41
|
+
readonly to: Vector3 = new Vector3();
|
|
42
|
+
/** Data-only world-metre width and force. */
|
|
43
|
+
options: UpdraftOptions;
|
|
44
|
+
constructor(from: Vector3 = new Vector3(), to: Vector3 = new Vector3(), options: UpdraftOptions = DEFAULT_UPDRAFT) {
|
|
45
|
+
super(); this.name = 'updraft'; this.from.copy(from); this.to.copy(to); this.options = { ...options };
|
|
46
|
+
}
|
|
47
|
+
/** Clone independent endpoints and bounded tuning with the normal transform. */
|
|
48
|
+
override copy(source: this, recursive = true): this { super.copy(source, recursive); this.from.copy(source.from); this.to.copy(source.to); this.options = { ...source.options }; return this; }
|
|
49
|
+
/** Emit the admitted world-space column; width and margin remain explicit world metres. */
|
|
50
|
+
toModeData(): UpdraftMode {
|
|
51
|
+
updateAuthoringMatrix(this);
|
|
52
|
+
const from = this.from.clone().applyMatrix4(this.matrixWorld), to = this.to.clone().applyMatrix4(this.matrixWorld);
|
|
53
|
+
return v.parse(UpdraftModeSchema, { ...this.options, kind: 'updraft', id: this.name,
|
|
54
|
+
from: { x: from.x, y: from.y, z: from.z }, to: { x: to.x, y: to.y, z: to.z } });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A mounted control profile with normal three.js graph semantics; it neither spawns nor grants a mount. */
|
|
59
|
+
export class Mount extends Object3D {
|
|
60
|
+
/** Explicit bounded gait speeds in metres per second. */
|
|
61
|
+
gaits: RideMode['gaits'];
|
|
62
|
+
constructor(gaits: RideMode['gaits']) { super(); this.name = 'ride'; this.gaits = { ...gaits }; }
|
|
63
|
+
/** Copy independent control parameters with the ordinary graph state. */
|
|
64
|
+
override copy(source: this, recursive = true): this { super.copy(source, recursive); this.gaits = { ...source.gaits }; return this; }
|
|
65
|
+
/** Emit validated control data; native mount/taming ownership stays with the host. */
|
|
66
|
+
toModeData(): RideMode { return v.parse(RideModeSchema, { id: this.name, gaits: this.gaits }); }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A native grapple control profile; the real world and its owner still provide anchors, floors and guards. */
|
|
70
|
+
export class Grapple extends Object3D {
|
|
71
|
+
/** Bounded selection and timing parameters; omitted fields retain native defaults. */
|
|
72
|
+
options: Partial<Omit<GrappleMode, 'id'>>;
|
|
73
|
+
constructor(options: Partial<Omit<GrappleMode, 'id'>> = {}) { super(); this.name = 'grapple'; this.options = { ...options }; }
|
|
74
|
+
/** Copy independent parameters together with normal three.js graph semantics. */
|
|
75
|
+
override copy(source: this, recursive = true): this { super.copy(source, recursive); this.options = { ...source.options }; return this; }
|
|
76
|
+
/** Emit data only; no synthetic anchors, targets, floors or gameplay grants. */
|
|
77
|
+
toModeData(): GrappleMode { return v.parse(GrappleModeSchema, { id: this.name, ...this.options }); }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Explicit world-metre climb controls; the outward normal is a local horizontal direction. */
|
|
81
|
+
export interface LadderOptions { reach?: number; speed?: number }
|
|
82
|
+
/** Vertical climbing declaration with ordinary scene transforms; its visible rungs, rails and colliders remain authored. */
|
|
83
|
+
export class Ladder extends Object3D {
|
|
84
|
+
/** Local lower floor; the capsule starts climbing here without teleporting. */
|
|
85
|
+
readonly bottom: Vector3 = new Vector3();
|
|
86
|
+
/** Local top of the vertical route. */
|
|
87
|
+
readonly top: Vector3 = new Vector3(0, 3, 0);
|
|
88
|
+
/** Local upper landing floor beyond the top; the motor sweeps the exit. */
|
|
89
|
+
readonly exit: Vector3 = new Vector3(0, 3, -1);
|
|
90
|
+
/** Local outward horizontal direction; its opposite climbs and its direction descends. */
|
|
91
|
+
readonly normal: Vector3 = new Vector3(0, 0, 1);
|
|
92
|
+
/** Bounded speed/reach, explicitly in world metres. */
|
|
93
|
+
options: LadderOptions;
|
|
94
|
+
constructor(bottom: Vector3 = new Vector3(), top: Vector3 = new Vector3(0, 3, 0), exit: Vector3 = new Vector3(0, 3, -1), options: LadderOptions = {}) {
|
|
95
|
+
super(); this.name = 'ladder'; this.bottom.copy(bottom); this.top.copy(top); this.exit.copy(exit); this.options = { ...options };
|
|
96
|
+
}
|
|
97
|
+
/** Copy independent route vectors and parameters with the normal scene graph. */
|
|
98
|
+
override copy(source: this, recursive = true): this {
|
|
99
|
+
super.copy(source, recursive); this.bottom.copy(source.bottom); this.top.copy(source.top); this.exit.copy(source.exit);
|
|
100
|
+
this.normal.copy(source.normal); this.options = { ...source.options }; return this;
|
|
101
|
+
}
|
|
102
|
+
/** Emit a validated world route; tilted/nonvertical routes refuse rather than silently changing their law. */
|
|
103
|
+
toModeData(): LadderMode {
|
|
104
|
+
updateAuthoringMatrix(this);
|
|
105
|
+
const bottom = this.bottom.clone().applyMatrix4(this.matrixWorld), top = this.top.clone().applyMatrix4(this.matrixWorld);
|
|
106
|
+
const exit = this.exit.clone().applyMatrix4(this.matrixWorld), normal = this.normal.clone().transformDirection(this.matrixWorld);
|
|
107
|
+
if (Math.abs(normal.y) > 1e-10) throw new Error('Ladder normal must remain horizontal');
|
|
108
|
+
// Y-only rotation can leave identical endpoints a few ulps apart; no authored tilt is accepted.
|
|
109
|
+
if (Math.hypot(top.x - bottom.x, top.z - bottom.z) > 1e-10) throw new Error('Ladder route must remain vertical');
|
|
110
|
+
top.x = bottom.x; top.z = bottom.z;
|
|
111
|
+
return v.parse(LadderModeSchema, { ...this.options, kind: 'ladder', id: this.name,
|
|
112
|
+
bottom: { x: bottom.x, y: bottom.y, z: bottom.z }, top: { x: top.x, y: top.y, z: top.z },
|
|
113
|
+
exit: { x: exit.x, y: exit.y, z: exit.z }, normal: { x: normal.x, z: normal.z } });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// Readable ABI-v0 fixed motion kernels. Rows supply every stop, speed, wave and permission.
|
|
2
|
+
// Keep arithmetic and field order stable: the complete guest continuation is part of saved gameplay.
|
|
3
|
+
const ride = String.raw`// SF49-g (G183) / SF8c socketLift: the Rising Islet (and its road gate: the same script with the gate flag). The islet
|
|
4
|
+
// rests level with the road; an action carries it up its chains to the gate isle (a tenth of the ride easing in, a tenth out);
|
|
5
|
+
// it rests there, and with nobody calling it comes back down after the dwell (the automatic idle return).
|
|
6
|
+
// Parameters: rest x y z, dock x y z, the travel one way (seconds), the row's part (0 the islet, which always collides;
|
|
7
|
+
// 1 its stationary road gate, which collides while the islet is away from the road), the dwell at the top (seconds).
|
|
8
|
+
// Actions: 1 ride (from either end, to the other; on the way, turn back), 2 call down, 3 call up (either also turns a ride
|
|
9
|
+
// heading the other way).
|
|
10
|
+
// The state lives in the entity's own fields, so a snapshot of them is the whole lift: 5 raised = progress 0..1 along the
|
|
11
|
+
// chains; 6 raising = 1 rising, 0.5 lowering, 0 resting at the road, 0.2..0.4 resting at the top (the dwell's clock).
|
|
12
|
+
export function abi_version(): i32 { return 0; }
|
|
13
|
+
export function init(lo: i32, hi: i32): void {}
|
|
14
|
+
export function in_ptr(): i32 { return 16384; }
|
|
15
|
+
export function in_cap(): i32 { return 4096; }
|
|
16
|
+
export function out_ptr(): i32 { return 24576; }
|
|
17
|
+
export function out_cap(): i32 { return 4; }
|
|
18
|
+
let count: i32 = 0;
|
|
19
|
+
export function out_count(): i32 { return count; }
|
|
20
|
+
@external("env", "query") declare function query(kind: i32, request: i32, response: i32): i32;
|
|
21
|
+
@inline function input(i: i32): f64 { return load<f64>(16384 + i * 8); }
|
|
22
|
+
@inline function param(i: i32): f64 { return load<f64>(8192 + i * 8); }
|
|
23
|
+
@inline function field(id: f64, value: f64): void {
|
|
24
|
+
const o = 24576 + count * 40; store<f64>(o, 1); store<f64>(o + 8, id); store<f64>(o + 16, value); store<f64>(o + 24, 0); store<f64>(o + 32, 0); count++;
|
|
25
|
+
}
|
|
26
|
+
const UP: f64 = 1;
|
|
27
|
+
const DOWN: f64 = 0.5;
|
|
28
|
+
const DWELL0: f64 = 0.2;
|
|
29
|
+
const DWELL1: f64 = 0.4;
|
|
30
|
+
const RAMP: f64 = 0.1;
|
|
31
|
+
const SETTLE: f64 = 0.004;
|
|
32
|
+
// the fraction of the climb reached at progress s: accelerate, cruise, decelerate (peak speed 1 / (1 - RAMP) of the mean)
|
|
33
|
+
@inline function eased(s: f64): f64 {
|
|
34
|
+
const top: f64 = 1 / (1 - RAMP);
|
|
35
|
+
if (s < RAMP) return top * s * s / (2 * RAMP);
|
|
36
|
+
if (s > 1 - RAMP) return 1 - top * (1 - s) * (1 - s) / (2 * RAMP);
|
|
37
|
+
return top * (s - RAMP / 2);
|
|
38
|
+
}
|
|
39
|
+
export function on_tick(): void {
|
|
40
|
+
count = 0;
|
|
41
|
+
if (query(410, 4096, 8192) !== 9) unreachable();
|
|
42
|
+
const action = input(2), dt = input(1), travel = param(6), dwell = param(8);
|
|
43
|
+
let s = input(10), raising = input(11);
|
|
44
|
+
const atTop = raising >= DWELL0 && raising <= DWELL1;
|
|
45
|
+
if (raising === 0) {
|
|
46
|
+
if (action === 1 || action === 3) raising = UP;
|
|
47
|
+
} else if (raising === UP) {
|
|
48
|
+
if (action === 1 || action === 2) raising = DOWN;
|
|
49
|
+
} else if (raising === DOWN) {
|
|
50
|
+
if (action === 1 || action === 3) raising = UP;
|
|
51
|
+
} else if (atTop) {
|
|
52
|
+
if (action === 1 || action === 2) raising = DOWN;
|
|
53
|
+
else {
|
|
54
|
+
raising += (DWELL1 - DWELL0) * dt / dwell;
|
|
55
|
+
if (raising >= DWELL1 - 1e-9) raising = DOWN;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// the last few millimetres settle in one step, so a deck within a millimetre of a stop is resting there (its gate open)
|
|
59
|
+
if (raising === UP) { s += dt / travel; if (s >= 1 - SETTLE) { s = 1; raising = DWELL0; } }
|
|
60
|
+
else if (raising === DOWN) { s -= dt / travel; if (s <= SETTLE) { s = 0; raising = 0; } }
|
|
61
|
+
const e = eased(s);
|
|
62
|
+
store<f64>(24576, 4); store<f64>(24584, param(0) + (param(3) - param(0)) * e); store<f64>(24592, param(1) + (param(4) - param(1)) * e);
|
|
63
|
+
store<f64>(24600, param(2) + (param(5) - param(2)) * e); store<f64>(24608, 0); count = 1;
|
|
64
|
+
// the islet always collides; the gate closes the road whenever the islet is not resting at the road
|
|
65
|
+
field(4, param(7) === 0 ? 1 : (s > 0 || raising !== 0 ? 1 : 0));
|
|
66
|
+
field(5, s); field(6, raising);
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
const waves = String.raw`// ABI-v0: tick, dt, action, self, permissions, parameter count; then data and six pose/state fields.
|
|
70
|
+
export function abi_version(): i32 { return 0; }
|
|
71
|
+
export function init(lo: i32, hi: i32): void {}
|
|
72
|
+
export function in_ptr(): i32 { return 16384; }
|
|
73
|
+
export function in_cap(): i32 { return 4096; }
|
|
74
|
+
export function out_ptr(): i32 { return 24576; }
|
|
75
|
+
export function out_cap(): i32 { return 5; }
|
|
76
|
+
let count: i32 = 0;
|
|
77
|
+
export function out_count(): i32 { return count; }
|
|
78
|
+
@external("env", "query") declare function query(kind: i32, request: i32, response: i32): i32;
|
|
79
|
+
const PI: f64 = 3.141592653589793, TAU: f64 = 6.283185307179586;
|
|
80
|
+
@inline function input(i: i32): f64 { return load<f64>(16384 + i * 8); }
|
|
81
|
+
@inline function param(i: i32): f64 { return load<f64>(8192 + i * 8); }
|
|
82
|
+
// Range-reduced 13th-order sine. The recorded-pose witness checks its resulting metric error.
|
|
83
|
+
@inline function sine(value: f64): f64 {
|
|
84
|
+
const x = value - Math.floor(value / TAU + 0.5) * TAU;
|
|
85
|
+
const z = x * x;
|
|
86
|
+
return x * (1 + z * (-1.0/6 + z * (1.0/120 + z * (-1.0/5040 + z * (1.0/362880 + z * (-1.0/39916800 + z / 6227020800))))));
|
|
87
|
+
}
|
|
88
|
+
let dx: f64 = 0, dy: f64 = 0, dz: f64 = 0;
|
|
89
|
+
@inline function wave(i: i32, x: f64, z: f64, t: f64): void {
|
|
90
|
+
const o = 5 + i * 6, wx = param(o), wz = param(o+1), amp = param(o+2), k = TAU / param(o+3), speed = param(o+4), q = param(o+5);
|
|
91
|
+
const phase = k * (wx*x + wz*z - speed*t), qa = q / (k * 4), c = sine(phase + PI/2);
|
|
92
|
+
dx += wx*qa*c; dz += wz*qa*c; dy += amp*sine(phase);
|
|
93
|
+
}
|
|
94
|
+
@inline function displace(x: f64, z: f64, t: f64): void {
|
|
95
|
+
dx = 0; dy = 0; dz = 0;
|
|
96
|
+
wave(0,x,z,t); wave(1,x,z,t); wave(2,x,z,t); wave(3,x,z,t);
|
|
97
|
+
const damp = param(4); dx *= damp; dy *= damp; dz *= damp;
|
|
98
|
+
}
|
|
99
|
+
@inline function height(x: f64, z: f64, t: f64): f64 {
|
|
100
|
+
displace(x,z,t); let px = x-dx, pz = z-dz;
|
|
101
|
+
displace(px,pz,t); px = x-dx; pz = z-dz;
|
|
102
|
+
displace(px,pz,t); return dy;
|
|
103
|
+
}
|
|
104
|
+
@inline function field(id: f64, value: f64): void {
|
|
105
|
+
const o = 24576 + count * 40; store<f64>(o,1); store<f64>(o+8,id); store<f64>(o+16,value); store<f64>(o+24,0); store<f64>(o+32,0); count++;
|
|
106
|
+
}
|
|
107
|
+
// The gentle swell's height difference / 4 stays below 0.1; the pose witness bounds the metric error.
|
|
108
|
+
@inline function tilt(value: f64): f64 { const z = value * value; return value * (1 + z * (-1.0/3 + z * (1.0/5 + z * (-1.0/7 + z / 9)))); }
|
|
109
|
+
export function on_tick(): void {
|
|
110
|
+
count = 0;
|
|
111
|
+
if (query(410, 4096, 8192) !== 29) unreachable();
|
|
112
|
+
const t = input(0) / 60, x = param(0), y = param(1), z = param(2), heading = param(3);
|
|
113
|
+
const fx = -sine(heading), fz = -sine(heading+PI/2), sx = -fz, sz = fx;
|
|
114
|
+
const fore = height(x+fx*2,z+fz*2,t), aft = height(x-fx*2,z-fz*2,t);
|
|
115
|
+
const star = height(x+sx*2,z+sz*2,t), port = height(x-sx*2,z-sz*2,t), heave = height(x,z,t);
|
|
116
|
+
store<f64>(24576,4); store<f64>(24584,x); store<f64>(24592,y+heave); store<f64>(24600,z); store<f64>(24608,0); count = 1;
|
|
117
|
+
field(1,tilt((fore-aft)/4)); field(2,heading); field(3,tilt((star-port)/4)); field(4,1);
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
const abi = String.raw`// Shared ABI-v0 setup: fixed request, parameter and four-effect buffers.
|
|
121
|
+
export function abi_version(): i32 { return 0; }
|
|
122
|
+
export function init(lo: i32, hi: i32): void {}
|
|
123
|
+
export function in_ptr(): i32 { return 16384; }
|
|
124
|
+
export function in_cap(): i32 { return 4096; }
|
|
125
|
+
export function out_ptr(): i32 { return 24576; }
|
|
126
|
+
export function out_cap(): i32 { return 4; }
|
|
127
|
+
let count: i32 = 0;
|
|
128
|
+
export function out_count(): i32 { return count; }
|
|
129
|
+
export function reset(): void { count = 0; }
|
|
130
|
+
@inline export function input(i: i32): f64 { return load<f64>(16384+i*8); }
|
|
131
|
+
@inline export function state(i: i32): f64 { return input(6+i); }
|
|
132
|
+
@inline export function param(i: i32): f64 { return load<f64>(8192+i*8); }
|
|
133
|
+
@inline export function field(id: f64, value: f64): void { const o = 24576+count*40; store<f64>(o,1); store<f64>(o+8,id); store<f64>(o+16,value); store<f64>(o+24,0); store<f64>(o+32,0); count++; }
|
|
134
|
+
`;
|
|
135
|
+
const hinge = String.raw`// Mode0 keeps a declared deck enabled; mode1 raises a winched deck after both locks.
|
|
136
|
+
import { reset, input, state, param, field } from './abi';
|
|
137
|
+
@external("env", "query") declare function query(kind: i32, request: i32, response: i32): i32;
|
|
138
|
+
export function on_tick(): void {
|
|
139
|
+
reset();
|
|
140
|
+
if (query(410, 4096, 8192) < 1) unreachable();
|
|
141
|
+
if (param(0) === 0) { field(4,1); return; }
|
|
142
|
+
let angle = state(0), raised = state(4), raising = state(5);
|
|
143
|
+
const action = input(2), unlocked = input(4) === 3;
|
|
144
|
+
if (action === 3) { angle = 0; raised = 1; raising = 0; }
|
|
145
|
+
else if ((action === 1 && unlocked) || action === 2) { if (raised === 0) raising = 1; }
|
|
146
|
+
if (raising === 1 && raised === 0) { angle = min(0, angle+input(1)*param(1)); if (angle >= 0) { raised = 1; raising = 0; } }
|
|
147
|
+
field(1,angle); field(4,raised); field(5,raised); field(6,raising);
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
|
|
151
|
+
const clip = String.raw`// Fixed general transform driver. All keys, activation and periods are admitted numeric rows.
|
|
152
|
+
export function abi_version(): i32 { return 0; }
|
|
153
|
+
export function init(lo: i32, hi: i32): void {}
|
|
154
|
+
export function in_ptr(): i32 { return 16384; }
|
|
155
|
+
export function in_cap(): i32 { return 4096; }
|
|
156
|
+
export function out_ptr(): i32 { return 24576; }
|
|
157
|
+
export function out_cap(): i32 { return 6; }
|
|
158
|
+
let count: i32 = 0;
|
|
159
|
+
export function out_count(): i32 { return count; }
|
|
160
|
+
@external("env", "query") declare function query(kind: i32, request: i32, response: i32): i32;
|
|
161
|
+
@inline function input(i: i32): f64 { return load<f64>(16384 + i * 8); }
|
|
162
|
+
@inline function param(i: i32): f64 { return load<f64>(8192 + i * 8); }
|
|
163
|
+
@inline function field(id: f64, value: f64): void {
|
|
164
|
+
const o = 24576 + count * 40; store<f64>(o, 1); store<f64>(o+8, id); store<f64>(o+16, value); store<f64>(o+24, 0); store<f64>(o+32, 0); count++;
|
|
165
|
+
}
|
|
166
|
+
@inline function lerp(a: f64, b: f64, t: f64): f64 { return a + (b-a)*t; }
|
|
167
|
+
let qx: f64 = 0, qy: f64 = 0, qz: f64 = 0, qw: f64 = 1;
|
|
168
|
+
function rotation(a: i32, b: i32, t: f64): void {
|
|
169
|
+
const ax=param(a+4), ay=param(a+5), az=param(a+6), aw=param(a+7);
|
|
170
|
+
let bx=param(b+4), by=param(b+5), bz=param(b+6), bw=param(b+7);
|
|
171
|
+
let dot=ax*bx+ay*by+az*bz+aw*bw;
|
|
172
|
+
if(dot<0){dot=-dot;bx=-bx;by=-by;bz=-bz;bw=-bw;}
|
|
173
|
+
if(ax===bx && ay===by && az===bz && aw===bw){qx=ax;qy=ay;qz=az;qw=aw;return;}
|
|
174
|
+
let u: f64=1-t, v: f64=t;
|
|
175
|
+
if(dot<0.9995){const angle=Math.acos(dot),sin=Math.sin(angle);u=Math.sin((1-t)*angle)/sin;v=Math.sin(t*angle)/sin;}
|
|
176
|
+
qx=ax*u+bx*v;qy=ay*u+by*v;qz=az*u+bz*v;qw=aw*u+bw*v;
|
|
177
|
+
if(dot>=0.9995){const n=1/Math.sqrt(qx*qx+qy*qy+qz*qz+qw*qw);qx*=n;qy*=n;qz*=n;qw*=n;}
|
|
178
|
+
|
|
179
|
+
}
|
|
180
|
+
export function on_tick(): void {
|
|
181
|
+
count=0;
|
|
182
|
+
const length=query(410,4096,8192), keys=<i32>param(15);
|
|
183
|
+
if(length!==16+keys*8 || keys<0 || keys>10) unreachable();
|
|
184
|
+
const trigger=<i32>param(4), action=input(2), gate=input(4)!==0, dt=input(1);
|
|
185
|
+
let active=input(11), phase=input(10);
|
|
186
|
+
if(trigger===0) active=1;
|
|
187
|
+
else if(trigger===1){if(gate){if(action===1)active=1-active;else if(action===2)active=0;else if(action===3){phase=0;active=1;}}}
|
|
188
|
+
else if(trigger===2) active=gate ? (param(5)===0 ? 1 : min(1,active+dt/param(5))) : 0;
|
|
189
|
+
else active=gate ? 1 : 0;
|
|
190
|
+
if(active===1){const cycle=param(0)===1 ? param(8) : param(1)/param(2)*(param(3)===2 ? 2 : 1);phase+=dt/cycle;phase=param(0)===1 || param(3)!==0 ? phase-Math.floor(phase) : min(1,phase);}
|
|
191
|
+
let x=param(9),y=param(10),z=param(11),pitch=param(12),yaw=param(13),roll=param(14);
|
|
192
|
+
if(param(0)===1){const angle=param(7)*Math.sin(phase*6.283185307179586);if(param(6)===0)pitch+=angle;else if(param(6)===1)yaw+=angle;else roll+=angle;}
|
|
193
|
+
else {
|
|
194
|
+
if(keys<2) unreachable();
|
|
195
|
+
const sample=param(3)===2 ? (phase<0.5 ? phase*2 : (1-phase)*2) : phase, time=sample*param(1);
|
|
196
|
+
let i:i32=0;while(i<keys-2 && time>param(16+(i+1)*8))i++;
|
|
197
|
+
const a=16+i*8,b=a+8,t=min(1,max(0,(time-param(a))/(param(b)-param(a))));
|
|
198
|
+
x=lerp(param(a+1),param(b+1),t);y=lerp(param(a+2),param(b+2),t);z=lerp(param(a+3),param(b+3),t);rotation(a,b,t);
|
|
199
|
+
const m23=2*(qy*qz-qx*qw);pitch=Math.asin(-min<f64>(1,max<f64>(-1,m23)));
|
|
200
|
+
if(Math.abs(m23)<0.9999999){yaw=Math.atan2(2*(qx*qz+qy*qw),1-2*(qx*qx+qy*qy));roll=Math.atan2(2*(qx*qy+qz*qw),1-2*(qx*qx+qz*qz));}
|
|
201
|
+
else {yaw=Math.atan2(-2*(qx*qz-qy*qw),1-2*(qy*qy+qz*qz));roll=0;}
|
|
202
|
+
}
|
|
203
|
+
store<f64>(24576,4);store<f64>(24584,x);store<f64>(24592,y);store<f64>(24600,z);store<f64>(24608,0);count=1;
|
|
204
|
+
field(1,pitch);field(2,yaw);field(3,roll);field(5,phase);field(6,active);
|
|
205
|
+
}
|
|
206
|
+
`;
|
|
207
|
+
|
|
208
|
+
/** Readable fixed guest sources; compiler inputs are independent of any shard or browser. */
|
|
209
|
+
export function moverProgram(kind: 'ride' | 'hinge' | 'waves' | 'clip'): { source: string; sources: Readonly<Record<string, string>> } {
|
|
210
|
+
if (kind === 'clip') return { source: clip, sources: {} };
|
|
211
|
+
if (kind === 'hinge') return { source: "export {abi_version,init,in_ptr,in_cap,out_ptr,out_cap,out_count} from './commons/abi';\nexport {on_tick} from './commons/bridge';\n", sources: { 'commons/abi.ts': abi, 'commons/bridge.ts': hinge } };
|
|
212
|
+
return { source: kind === 'ride' ? ride : waves, sources: {} };
|
|
213
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { parseMovers } from '@wildshard/format/movers';
|
|
2
|
+
import { type AnimationClip, InterpolateLinear, LinearInterpolant, QuaternionLinearInterpolant, Object3D, PropertyBinding } from 'three';
|
|
3
|
+
import { lowerMoverMotion, MoverMotionSchema, type MoverMotion, type MoverTrack } from '@wildshard/format/moverMotion';
|
|
4
|
+
import { WAVES } from '@wildshard/format/waterWaves';
|
|
5
|
+
import * as v from 'valibot';
|
|
6
|
+
|
|
7
|
+
/** Typed numeric mover declarations: local collider primitives and admitted fixed-step scripts. */
|
|
8
|
+
export type MoverData = ReturnType<typeof parseMovers>;
|
|
9
|
+
|
|
10
|
+
/** Admit detached numeric mover headers through the defining platform grammar, without installing an owner. */
|
|
11
|
+
export function parseMoverRows(input: unknown): MoverData { return parseMovers(input); }
|
|
12
|
+
|
|
13
|
+
/** Lower an admitted stop/trigger/driver recipe to the native fixed-step ABI.
|
|
14
|
+
* Rest coordinates remain caller-owned; all numeric limits and cross-field refusals are defining format checks. */
|
|
15
|
+
export function compileMoverMotion(input: unknown, rest: Parameters<typeof lowerMoverMotion>[1]): ReturnType<typeof lowerMoverMotion> {
|
|
16
|
+
return lowerMoverMotion(input, rest);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A `waves` driver for a body floating in `depth` metres of water: the format's four swell rows, damped over the shore as
|
|
20
|
+
* the drawn sea is. test/mover-swell-parity.test.ts fences the damping against the engine's `seaDamp`. */
|
|
21
|
+
export function swellDriver(depth: number): Extract<MoverMotion['driver'], { kind: 'waves' }> {
|
|
22
|
+
const [a, b, c, d] = WAVES;
|
|
23
|
+
if (WAVES.length !== 4 || a === undefined || b === undefined || c === undefined || d === undefined) throw new Error('Four authored wave components required');
|
|
24
|
+
const x = Math.min(1, Math.max(0, depth / 1.5));
|
|
25
|
+
return { kind: 'waves', damping: 0.35 + 0.65 * x * x * (3 - 2 * x), waves: [[...a], [...b], [...c], [...d]] };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Motion options on a real three.js object, with explicit gameplay activation. */
|
|
29
|
+
export interface MoverOptions {
|
|
30
|
+
clip?: AnimationClip;
|
|
31
|
+
trigger: MoverMotion['trigger'];
|
|
32
|
+
driver: MoverMotion['driver'];
|
|
33
|
+
speed?: number;
|
|
34
|
+
loop?: MoverTrack['loop'];
|
|
35
|
+
}
|
|
36
|
+
/** An ordinary scene object with a stop clip and a fixed data-only mover policy. */
|
|
37
|
+
export class Mover extends Object3D {
|
|
38
|
+
/** Actual authored body; its stable name binds the clip. */
|
|
39
|
+
readonly body: Object3D;
|
|
40
|
+
/** Options retained for build-time compilation. */
|
|
41
|
+
readonly options: MoverOptions;
|
|
42
|
+
constructor(body: Object3D, options: MoverOptions) {
|
|
43
|
+
super(); this.body = body; this.options = options; this.name = body.name; this.add(body);
|
|
44
|
+
}
|
|
45
|
+
/** Read real clip keys; unrelated objects, unsupported interpolation or incomplete stops refuse. */
|
|
46
|
+
toMotionData(): MoverMotion {
|
|
47
|
+
const clip = this.options.clip;
|
|
48
|
+
let track: MoverTrack | undefined;
|
|
49
|
+
if (clip !== undefined) {
|
|
50
|
+
if (clip.tracks.length === 0 || clip.tracks.length > 2) throw new Error('Mover clip requires position and/or quaternion');
|
|
51
|
+
const times = [...new Set(clip.tracks.flatMap(channel => [...channel.times]))].sort((a, b) => a - b);
|
|
52
|
+
const common = { clip: clip.name, duration: clip.duration, loop: this.options.loop ?? 'once', speed: this.options.speed ?? 1, times };
|
|
53
|
+
let position: MoverTrack['position'], quaternion: MoverTrack['quaternion'];
|
|
54
|
+
for (const channel of clip.tracks) {
|
|
55
|
+
const binding = PropertyBinding.parseTrackName(channel.name);
|
|
56
|
+
if (channel.getInterpolation() !== InterpolateLinear || Boolean(binding.objectName) || Boolean(binding.propertyIndex) || !['', '.', this.body.name, this.body.uuid].includes(binding.nodeName)) throw new Error('Mover clip must linearly bind its own body');
|
|
57
|
+
// Interpolants are the actual three.js clip law, including shortest-arc quaternion interpolation.
|
|
58
|
+
const sample = binding.propertyName === 'quaternion' ? new QuaternionLinearInterpolant(channel.times, channel.values, 4, new Float64Array(4)) : new LinearInterpolant(channel.times, channel.values, channel.getValueSize(), new Float64Array(channel.getValueSize()));
|
|
59
|
+
if (binding.propertyName === 'position' && channel.getValueSize() === 3 && position === undefined) {
|
|
60
|
+
position = times.map(t => { const [x, y, z] = sample.evaluate(t); if (x === undefined || y === undefined || z === undefined) throw new Error('Missing position key'); return [x, y, z]; });
|
|
61
|
+
} else if (binding.propertyName === 'quaternion' && channel.getValueSize() === 4 && quaternion === undefined) {
|
|
62
|
+
quaternion = times.map(t => { const [x, y, z, w] = sample.evaluate(t); if (x === undefined || y === undefined || z === undefined || w === undefined) throw new Error('Missing quaternion key'); return [x, y, z, w]; });
|
|
63
|
+
} else throw new Error('Mover clips animate each position or quaternion channel once');
|
|
64
|
+
}
|
|
65
|
+
track = { ...common, ...(position === undefined ? {} : { position }), ...(quaternion === undefined ? {} : { quaternion }) };
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
return v.parse(MoverMotionSchema, { ...(track === undefined ? {} : { track }), trigger: this.options.trigger, driver: this.options.driver });
|
|
69
|
+
}
|
|
70
|
+
/** Bind authored motion to a numeric collider/rest row while retaining the fixed guest continuation ABI. */
|
|
71
|
+
toMoverData(rest: Omit<MoverData[number], 'module' | 'input' | 'track' | 'trigger' | 'driver'>): MoverData[number] {
|
|
72
|
+
const motion = this.toMotionData(), compiled = compileMoverMotion(motion, rest), row = { ...rest, ...compiled, ...motion };
|
|
73
|
+
parseMovers([row]); return row;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { NativeGroupRowsSchema, PageGroupRowsSchema, PopulationKnockdownSchema } from '@wildshard/format/creatures';
|
|
3
|
+
import { WildlifePopulationSchema } from '@wildshard/format/wildlifePopulation';
|
|
4
|
+
import { ForagerPopulationSchema, ForagerContinuation } from '@wildshard/format/ambientLife';
|
|
5
|
+
import { PopulationFieldSchema } from '@wildshard/format/populationEnvironment';
|
|
6
|
+
import { parseNativePopulationRows } from '@wildshard/format/populationRoster';
|
|
7
|
+
import { nameBlob, type NamedBlob } from './blobs';
|
|
8
|
+
import { encodeCanonicalJson } from './immutable';
|
|
9
|
+
import { namedJsonSchema, registeredJsonSchema } from '@wildshard/engine/host/formatJsonSchema';
|
|
10
|
+
|
|
11
|
+
/** Admit complete native fauna/encounter/pose roster data with its original identity and resource checks. */
|
|
12
|
+
export function parseNativePopulationRoster(input: unknown): ReturnType<typeof parseNativePopulationRows> { return parseNativePopulationRows(input); }
|
|
13
|
+
|
|
14
|
+
/** Admit data-only native group ownership, ordered steps and guest bindings without a live world. */
|
|
15
|
+
export function parseNativeGroupRows(input: unknown): v.InferOutput<typeof NativeGroupRowsSchema> { return v.parse(NativeGroupRowsSchema, input); }
|
|
16
|
+
/** Admit native habitat fields through the same bounded runtime schema. */
|
|
17
|
+
export function parsePopulationField(input: unknown): v.InferOutput<typeof PopulationFieldSchema> { return v.parse(PopulationFieldSchema, input); }
|
|
18
|
+
/** Admit page-owned group metadata, contacts and effects. */
|
|
19
|
+
export function parsePageGroupRows(input: unknown): v.InferOutput<typeof PageGroupRowsSchema> { return v.parse(PageGroupRowsSchema, input); }
|
|
20
|
+
/** Admit the complete native wildlife population declaration. */
|
|
21
|
+
export function parseWildlifePopulation(input: unknown): v.InferOutput<typeof WildlifePopulationSchema> { return v.parse(WildlifePopulationSchema, input); }
|
|
22
|
+
/** Preserve the required population/frame/knockdown envelope when reading authored motion metadata. */
|
|
23
|
+
export function parsePopulationKnockdownSource(input: unknown): v.InferOutput<typeof PopulationKnockdownSchema> {
|
|
24
|
+
return v.parse(v.object({ population: v.object({ frame: v.object({ knockdown: PopulationKnockdownSchema }) }) }), input).population.frame.knockdown;
|
|
25
|
+
}
|
|
26
|
+
/** Preserve the required population/forager/row envelope without installing its native host. */
|
|
27
|
+
export function parsePopulationForagerSource(input: unknown): v.InferOutput<typeof ForagerPopulationSchema> {
|
|
28
|
+
return v.parse(v.object({ population: v.object({ forager: v.object({ row: ForagerPopulationSchema }) }) }), input).population.forager.row;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Name an authored canopy/ledge/forager habitat with its exact row counts and
|
|
32
|
+
* native continuation grammar. Limits belong to the supplied source inventory,
|
|
33
|
+
* and both author admission and the emitted reader retain the same schema. */
|
|
34
|
+
export function namePopulationHabitat(name: string, input: unknown, treeCount: number, maxLedges: number): NamedBlob {
|
|
35
|
+
if (!Number.isSafeInteger(treeCount) || treeCount < 0 || !Number.isSafeInteger(maxLedges) || maxLedges < 0)
|
|
36
|
+
throw new Error('Invalid population habitat limits');
|
|
37
|
+
const number = v.pipe(v.number(), v.finite());
|
|
38
|
+
const schema = v.strictObject({
|
|
39
|
+
trees: v.pipe(v.array(v.tuple([number, number, v.pipe(number, v.minValue(0))])), v.length(treeCount)),
|
|
40
|
+
tops: v.pipe(v.array(number), v.length(treeCount)),
|
|
41
|
+
ledges: v.pipe(v.array(v.strictObject({ x: number, y: number, z: number, r: v.pipe(number, v.minValue(0)) })), v.maxLength(maxLedges)),
|
|
42
|
+
marmots: ForagerContinuation,
|
|
43
|
+
});
|
|
44
|
+
const rows = v.parse(schema, input), defining = registeredJsonSchema(name);
|
|
45
|
+
return nameBlob(name, 'json', new TextEncoder().encode(encodeCanonicalJson(rows)), { jsonSchema: defining ?? namedJsonSchema(schema) });
|
|
46
|
+
}
|