@wildshard/engine 0.0.1 → 0.1.15
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/CHANGELOG.md +128 -0
- package/budgets/calibration/m5-2026-10-01T08-07-18-573Z.json +3985 -0
- package/budgets/calibration/m5-2026-10-01T22-02-53-510Z.json +4473 -0
- package/budgets/calibration-reports/README.md +25 -0
- package/budgets/calibration-reports/_template.desktop.json +1994 -0
- package/budgets/calibration-reports/_template.phone.json +2069 -0
- package/budgets/calibration-reports/assessment.json +571 -0
- package/budgets/calibration-reports/driftwood-isle.phone.json +72 -0
- package/budgets/calibration-reports/far-reach.desktop.json +73158 -0
- package/budgets/calibration-reports/far-reach.phone.json +73086 -0
- package/budgets/calibration-reports/nalati-grasslands-x22.desktop.json +19525 -0
- package/budgets/calibration-reports/nalati-grasslands.phone.json +72 -0
- package/budgets/calibration-reports/nine-dragon-stack-g224.desktop.json +146 -0
- package/budgets/calibration-reports/nine-dragon-stack.phone.json +89 -0
- package/budgets/calibration-reports/pine-hollow.desktop.json +54949 -0
- package/budgets/calibration-reports/pine-hollow.phone.json +72 -0
- package/budgets/calibration-reports/sunscar-dunes.desktop.json +7788 -0
- package/budgets/calibration-reports/sunscar-dunes.phone.json +9378 -0
- package/budgets/calibration.json +4473 -0
- package/budgets/ceiling-re-records.json +71 -0
- package/budgets/ceiling-sources.json +5985 -0
- package/budgets/desktop-reference.json +7 -0
- package/budgets/g224-ceiling-re-record.json +15 -0
- package/budgets/grid-strip-room.json +9 -0
- package/budgets/nalati-ceiling-sources.json +44 -0
- package/budgets/shard-size-baseline.json +552 -0
- package/budgets/x22-ceiling-re-record.json +15 -0
- package/budgets/x7-ceiling-sources.json +41 -0
- package/index.html +622 -0
- package/lint/api-undocumented.json +7 -0
- package/lint/authored-html.d.mts +4 -0
- package/lint/authored-html.mjs +313 -0
- package/lint/base64-debt.json +18 -0
- package/lint/class-moves.json +4 -0
- package/lint/client-plan-boundary.d.mts +2 -0
- package/lint/client-plan-boundary.mjs +102 -0
- package/lint/debug-flags.d.mts +5 -0
- package/lint/debug-flags.mjs +190 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/edge-exemptions.json +6 -0
- package/lint/engine-internal.json +26 -0
- package/lint/engine-side-edges.json +5 -0
- package/lint/engine-sides.d.mts +30 -0
- package/lint/engine-sides.json +1794 -0
- package/lint/engine-sides.mjs +269 -0
- package/lint/engine-words.json +7 -0
- package/lint/exec-max-buffer.mjs +88 -0
- package/lint/generated-import-debt.json +117 -0
- package/lint/generated-source-debt.json +1029 -0
- package/lint/host-callback-syntax.d.mts +4 -0
- package/lint/host-callback-syntax.mjs +62 -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/host-reviews.json +14 -0
- package/lint/layer-edges.json +15 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +23 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/listed-view-code.json +13 -0
- package/lint/manifest-closure-budget.json +6 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/no-base64.d.mts +19 -0
- package/lint/no-base64.mjs +112 -0
- package/lint/no-binary-json.json +174 -0
- package/lint/no-generated-import.d.mts +22 -0
- package/lint/no-generated-import.mjs +114 -0
- package/lint/page-events.json +895 -0
- package/lint/platform-pending-users.json +2520 -0
- package/lint/platform-pending-users.md +18 -0
- package/lint/ratchet-files.d.mts +2 -0
- package/lint/ratchet-files.mjs +45 -0
- package/lint/ratchet.json +230 -0
- package/lint/ratchet.mjs +212 -0
- package/lint/recorded-debt.mjs +24 -0
- package/lint/row-functions.json +173 -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.json +14 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/schema-types.d.mts +9 -0
- package/lint/schema-types.mjs +114 -0
- package/lint/shard-coupling.json +333 -0
- package/lint/shard-imports.d.mts +5 -0
- package/lint/shard-imports.mjs +43 -0
- package/lint/shard-layout.json +64 -0
- package/lint/shard-platform.json +24 -0
- package/lint/shard-words.pin.json +421 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/sim-closure.d.mts +3 -0
- package/lint/sim-closure.json +3 -0
- package/lint/sim-closure.mjs +112 -0
- package/lint/sim-players.json +17 -0
- package/lint/sim-schema-leaves.json +1 -0
- package/lint/source-stamps.mjs +12 -0
- package/lint/syntax-values.mjs +299 -0
- package/lint/tile-bake-debt.json +556 -0
- package/lint/url-params.json +48 -0
- package/lint/weapon-subclasses.json +4 -0
- package/lint/wildshard-plugin.d.ts +13 -0
- package/lint/wildshard-plugin.js +1196 -0
- package/package.json +1298 -3
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/agent-time.py +475 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/api-origin.d.mts +3 -0
- package/scripts/api-origin.mjs +38 -0
- package/scripts/app-build/appCook.ts +19 -0
- package/scripts/app-build/assetHashes.ts +57 -0
- package/scripts/app-build/assetLimits.d.mts +15 -0
- package/scripts/app-build/assetLimits.mjs +61 -0
- package/scripts/app-build/assetTables.d.mts +19 -0
- package/scripts/app-build/assetTables.mjs +68 -0
- package/scripts/app-build/audioPacks.ts +41 -0
- package/scripts/app-build/bakedTextures.d.mts +2 -0
- package/scripts/app-build/bakedTextures.mjs +59 -0
- package/scripts/app-build/basis.ts +25 -0
- package/scripts/app-build/bootExtras.ts +127 -0
- package/scripts/app-build/bootModules.ts +271 -0
- package/scripts/app-build/bootProductTiers.ts +48 -0
- package/scripts/app-build/bootProducts.ts +67 -0
- package/scripts/app-build/buildIdentity.d.mts +16 -0
- package/scripts/app-build/buildIdentity.mjs +89 -0
- package/scripts/app-build/catalogue.ts +216 -0
- package/scripts/app-build/chunkReport.d.mts +3 -0
- package/scripts/app-build/chunkReport.mjs +29 -0
- package/scripts/app-build/contentBase.d.mts +2 -0
- package/scripts/app-build/contentBase.mjs +34 -0
- package/scripts/app-build/controlChunks.ts +106 -0
- package/scripts/app-build/crossroadsRig.ts +17 -0
- package/scripts/app-build/doctorOutput.mjs +19 -0
- package/scripts/app-build/finalChunkNames.d.mts +3 -0
- package/scripts/app-build/finalChunkNames.mjs +94 -0
- package/scripts/app-build/gen.ts +100 -0
- package/scripts/app-build/gridSeams.d.mts +16 -0
- package/scripts/app-build/gridSeams.mjs +95 -0
- package/scripts/app-build/homeIcons.d.mts +20 -0
- package/scripts/app-build/homeIcons.mjs +64 -0
- package/scripts/app-build/importMap.d.mts +7 -0
- package/scripts/app-build/importMap.mjs +102 -0
- package/scripts/app-build/noTopLevelAwait.d.mts +4 -0
- package/scripts/app-build/noTopLevelAwait.mjs +36 -0
- package/scripts/app-build/outputProducts.d.mts +10 -0
- package/scripts/app-build/outputProducts.mjs +114 -0
- package/scripts/app-build/previousDeploy.d.mts +24 -0
- package/scripts/app-build/previousDeploy.mjs +245 -0
- package/scripts/app-build/serviceWorker.ts +145 -0
- package/scripts/app-build/splitOutput.d.mts +6 -0
- package/scripts/app-build/splitOutput.mjs +98 -0
- package/scripts/app-build/standaloneOutput.d.mts +4 -0
- package/scripts/app-build/standaloneOutput.mjs +31 -0
- package/scripts/app-build/validationReceipts.d.mts +2 -0
- package/scripts/app-build/validationReceipts.mjs +25 -0
- package/scripts/app-build/versionFiles.ts +20 -0
- package/scripts/app-build/worldMapAtlas.ts +62 -0
- package/scripts/app-build/writtenBundle.ts +51 -0
- package/scripts/app-build-pipeline-proof.mjs +67 -0
- package/scripts/app-build-pipeline.mjs +274 -0
- package/scripts/assert-store-layout.mjs +17 -0
- package/scripts/author-bundle-cache.d.mts +1 -0
- package/scripts/author-bundle-cache.mjs +137 -0
- package/scripts/author-bundle-usage.d.mts +3 -0
- package/scripts/author-bundle-usage.mjs +20 -0
- package/scripts/authored-manifest.d.mts +7 -0
- package/scripts/authored-manifest.mjs +217 -0
- package/scripts/authoring-inputs.d.mts +8 -0
- package/scripts/authoring-inputs.mjs +104 -0
- package/scripts/bake-grid-seams.mjs +110 -0
- package/scripts/bake-input-hashes.d.mts +6 -0
- package/scripts/bake-input-hashes.mjs +59 -0
- package/scripts/bake-loader.mjs +105 -0
- package/scripts/bake-output.d.mts +29 -0
- package/scripts/bake-output.mjs +84 -0
- package/scripts/bench-load.mjs +391 -0
- package/scripts/boot-dist-plan.mjs +47 -0
- package/scripts/boot-dist.py +251 -0
- package/scripts/boot-pack-parts.d.mts +2 -0
- package/scripts/boot-pack-parts.mjs +51 -0
- package/scripts/boot-publication-proof.d.mts +2 -0
- package/scripts/boot-publication-proof.mjs +64 -0
- package/scripts/boot-publication.d.mts +19 -0
- package/scripts/boot-publication.generated.json +3684 -0
- package/scripts/boot-publication.mjs +100 -0
- package/scripts/boot-temp-warn.sh +70 -0
- package/scripts/boot-timing-proof.mjs +264 -0
- package/scripts/browser-lane.sh +288 -0
- package/scripts/browser-slot-lock.py +49 -0
- package/scripts/budget-ceilings.mjs +88 -0
- package/scripts/budget-ratchet.d.mts +1 -0
- package/scripts/budget-ratchet.mjs +8 -0
- package/scripts/build-app.mjs +49 -0
- package/scripts/build-cache-report.d.mts +20 -0
- package/scripts/build-cache-report.mjs +104 -0
- package/scripts/build-mirror.d.mts +24 -0
- package/scripts/build-mirror.mjs +387 -0
- package/scripts/build-server.mjs +47 -0
- package/scripts/build-without-browser.mjs +14 -0
- package/scripts/built-product.d.mts +22 -0
- package/scripts/built-product.mjs +187 -0
- package/scripts/calibrate.mjs +43 -0
- package/scripts/capture-main-menu-hero.mjs +457 -0
- package/scripts/catalogue-all-heads.ts +35 -0
- package/scripts/changelog.d.mts +18 -0
- package/scripts/changelog.mjs +129 -0
- package/scripts/chaos-proxy-core.mjs +978 -0
- package/scripts/chaos-proxy-proof.mjs +1130 -0
- package/scripts/chaos-proxy.mjs +68 -0
- package/scripts/chaos-router.mjs +107 -0
- package/scripts/chaos-rules.mjs +197 -0
- package/scripts/check-chunks.d.mts +8 -0
- package/scripts/check-chunks.mjs +143 -0
- package/scripts/check-closed-components.d.mts +7 -0
- package/scripts/check-closed-components.mjs +87 -0
- package/scripts/check-css.mjs +235 -0
- package/scripts/check-custom-sections-zero.d.mts +2 -0
- package/scripts/check-custom-sections-zero.mjs +43 -0
- package/scripts/check-devserver.d.mts +2 -0
- package/scripts/check-devserver.mjs +29 -0
- package/scripts/check-engine-sides.mjs +85 -0
- package/scripts/check-graph.d.mts +9 -0
- package/scripts/check-graph.mjs +217 -0
- package/scripts/check-listeners.mjs +122 -0
- package/scripts/check-model-sources.mjs +106 -0
- package/scripts/check-models.d.mts +22 -0
- package/scripts/check-models.mjs +367 -0
- package/scripts/check-page-events.mjs +386 -0
- package/scripts/check-paths.allow.json +1282 -0
- package/scripts/check-paths.mjs +97 -0
- package/scripts/check-platform-ratchets.d.mts +7 -0
- package/scripts/check-platform-ratchets.mjs +297 -0
- package/scripts/check-shards.d.mts +5 -0
- package/scripts/check-shards.mjs +101 -0
- package/scripts/check-sim-players.mjs +82 -0
- package/scripts/check-spelled-paths.d.mts +1 -0
- package/scripts/check-spelled-paths.mjs +34 -0
- package/scripts/chromium-keychain-check.mjs +140 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/chromium-memory-browser.d.mts +4 -0
- package/scripts/chromium-memory-browser.mjs +52 -0
- package/scripts/ci-bisect.py +91 -0
- package/scripts/ci-browser.sh +45 -0
- package/scripts/ci-checks.d.mts +2 -0
- package/scripts/ci-checks.mjs +94 -0
- package/scripts/ci-disk-census.py +58 -0
- package/scripts/ci-docs-proof.mjs +84 -0
- package/scripts/ci-exact-reuse.d.mts +3 -0
- package/scripts/ci-exact-reuse.mjs +73 -0
- package/scripts/ci-generated-manifest.sh +18 -0
- package/scripts/ci-native-fixtures.mjs +36 -0
- package/scripts/ci-pack.d.mts +14 -0
- package/scripts/ci-pack.mjs +231 -0
- package/scripts/ci-playwright-install.sh +11 -0
- package/scripts/ci-product-cache.d.mts +2 -0
- package/scripts/ci-product-cache.mjs +57 -0
- package/scripts/ci-products.py +285 -0
- package/scripts/ci-proof-jobs.d.mts +3 -0
- package/scripts/ci-proof-jobs.mjs +34 -0
- package/scripts/ci-selection.mjs +63 -0
- package/scripts/ci-shard-wall-proof.mjs +26 -0
- package/scripts/ci-shard-wall.mjs +35 -0
- package/scripts/ci-static.sh +63 -0
- package/scripts/commit.sh +305 -0
- package/scripts/commit_lane.py +42 -0
- package/scripts/committed-fast-checks.mjs +262 -0
- package/scripts/committed-source-tables.mjs +47 -0
- package/scripts/compare-platform-steps.mjs +15 -0
- package/scripts/compiler-code.d.mts +3 -0
- package/scripts/compiler-code.mjs +69 -0
- package/scripts/complete-at-control-snapshot.mjs +297 -0
- package/scripts/complete-at-control.mjs +580 -0
- package/scripts/content-base-proof.mjs +158 -0
- package/scripts/content-sw-proof.mjs +215 -0
- package/scripts/cook-admission-proof.mjs +42 -0
- package/scripts/cook-audit.ts +57 -0
- package/scripts/cook-job.mjs +32 -0
- package/scripts/cook-parts-report.mjs +34 -0
- package/scripts/cook-revision.ts +60 -0
- package/scripts/cook-to-play.mjs +96 -0
- package/scripts/cook-worker.mjs +78 -0
- package/scripts/cook-worker.service +5 -0
- package/scripts/cook.mjs +19 -0
- package/scripts/core-heap-diagnostic.d.mts +21 -0
- package/scripts/core-heap-diagnostic.mjs +52 -0
- package/scripts/cpu-admission-proof.mjs +55 -0
- package/scripts/cpu-admission.mjs +32 -0
- package/scripts/cpu-admission.py +243 -0
- package/scripts/cpu-broker-proof.mjs +96 -0
- package/scripts/cpu-broker.mjs +56 -0
- package/scripts/cpu-broker.py +119 -0
- package/scripts/cpu-census-proof.py +193 -0
- package/scripts/cpu-census.py +374 -0
- package/scripts/crossroads-proof.mjs +32 -0
- package/scripts/crossroads-rig/core.d.ts +16 -0
- package/scripts/crossroads-rig/core.js +417 -0
- package/scripts/crossroads-rig/desktop-probe.mjs +163 -0
- package/scripts/crossroads-rig/index.html +21 -0
- package/scripts/crossroads-rig/phone.js +74 -0
- package/scripts/crossroads-rig/production-probe.mjs +160 -0
- package/scripts/crossroads-rig/production.html +23 -0
- package/scripts/crossroads-rig/production.md +28 -0
- package/scripts/crossroads-rig/rig.js +36 -0
- package/scripts/crossroads-rig/sim-probe.mjs +217 -0
- package/scripts/crossroads-rig/stage.sh +11 -0
- package/scripts/crossroads-smoke.mjs +83 -0
- package/scripts/debug-settings.d.mts +24 -0
- package/scripts/debug-settings.mjs +80 -0
- package/scripts/decision-legacy-lines.d.mts +4 -0
- package/scripts/decision-legacy-lines.mjs +30 -0
- package/scripts/deck-skip-proof.mjs +63 -0
- package/scripts/deny-browser.mjs +11 -0
- package/scripts/docs-inputs-proof.mjs +31 -0
- package/scripts/doctor-proof.mjs +186 -0
- package/scripts/dome-cameras.d.mts +27 -0
- package/scripts/dome-cameras.mjs +77 -0
- package/scripts/download-bench/link.mjs +101 -0
- package/scripts/e2e-client.mjs +153 -0
- package/scripts/e2e-offline.sh +9 -0
- package/scripts/e2e-paths.mjs +31 -0
- package/scripts/e2e-watcher.mjs +191 -0
- package/scripts/e7-doctor-proof.mjs +61 -0
- package/scripts/e7-doctor-request-proof.mjs +179 -0
- package/scripts/e7-doctor-worker-proof.mjs +221 -0
- package/scripts/e7-live-staging-proof.mjs +72 -0
- package/scripts/e7-playtest-table.mjs +67 -0
- package/scripts/e7-records-proof.mjs +17 -0
- package/scripts/e7-voice-staging-proof.mjs +94 -0
- package/scripts/engine-ci-budget.ts +39 -0
- package/scripts/engine-ci-membership-proof.ts +26 -0
- package/scripts/engine-ci-plan.ts +120 -0
- package/scripts/engine-ci-proof.mjs +41 -0
- package/scripts/engine-ci-sequencer.ts +18 -0
- package/scripts/engine-ci-shard.mjs +28 -0
- package/scripts/engine-ci.config.ts +17 -0
- package/scripts/engine-order-proof.mjs +41 -0
- package/scripts/environment-boundary-proof.mjs +28 -0
- package/scripts/fetch-assets.mjs +76 -0
- package/scripts/format-hook.mjs +20 -0
- package/scripts/format-lock.d.mts +6 -0
- package/scripts/format-lock.mjs +120 -0
- package/scripts/format-package.d.mts +4 -0
- package/scripts/format-package.mjs +12 -0
- package/scripts/frame-cost-report.ts +85 -0
- package/scripts/frame-floor-args.d.mts +14 -0
- package/scripts/frame-floor-args.mjs +156 -0
- package/scripts/frame-floor-buffer-pressure.d.mts +3 -0
- package/scripts/frame-floor-buffer-pressure.mjs +91 -0
- package/scripts/frame-floor-draw-report.d.mts +38 -0
- package/scripts/frame-floor-draw-report.mjs +112 -0
- package/scripts/frame-floor-gl-time.d.mts +4 -0
- package/scripts/frame-floor-gl-time.mjs +104 -0
- package/scripts/frame-floor-gpu-bisect.mjs +120 -0
- package/scripts/frame-floor-grid.d.mts +67 -0
- package/scripts/frame-floor-grid.mjs +552 -0
- package/scripts/frame-floor-inventory.d.mts +2 -0
- package/scripts/frame-floor-inventory.mjs +10 -0
- package/scripts/frame-floor-jsc-gc.d.mts +15 -0
- package/scripts/frame-floor-jsc-gc.mjs +122 -0
- package/scripts/frame-floor-native-pressure.d.mts +4 -0
- package/scripts/frame-floor-native-pressure.mjs +78 -0
- package/scripts/frame-floor-native.mjs +108 -0
- package/scripts/frame-floor-navigation.d.mts +12 -0
- package/scripts/frame-floor-navigation.mjs +41 -0
- package/scripts/frame-floor-pause-ablation.d.mts +15 -0
- package/scripts/frame-floor-pause-ablation.mjs +90 -0
- package/scripts/frame-floor-pending.d.mts +16 -0
- package/scripts/frame-floor-pending.mjs +29 -0
- package/scripts/frame-floor-programs.mjs +39 -0
- package/scripts/frame-floor-report-phase.d.mts +10 -0
- package/scripts/frame-floor-report-phase.mjs +41 -0
- package/scripts/frame-floor-script-profile.d.mts +20 -0
- package/scripts/frame-floor-script-profile.mjs +159 -0
- package/scripts/frame-floor-settings.d.mts +6 -0
- package/scripts/frame-floor-settings.mjs +118 -0
- package/scripts/frame-floor-standing.d.mts +4 -0
- package/scripts/frame-floor-standing.mjs +20 -0
- package/scripts/frame-floor-task-clock.d.mts +4 -0
- package/scripts/frame-floor-task-clock.mjs +284 -0
- package/scripts/frame-floor-timeline-session.ts +76 -0
- package/scripts/frame-floor-wasm-constructors.d.mts +6 -0
- package/scripts/frame-floor-wasm-constructors.mjs +37 -0
- package/scripts/frame-floor-wasm-probe.d.mts +2 -0
- package/scripts/frame-floor-wasm-probe.mjs +51 -0
- package/scripts/frame-floor-webkit-timeline.d.mts +26 -0
- package/scripts/frame-floor-webkit-timeline.mjs +285 -0
- package/scripts/frame-floor.mjs +1290 -0
- package/scripts/full-test-log-proof.py +191 -0
- package/scripts/full-test-report.py +154 -0
- package/scripts/function-source.d.mts +3 -0
- package/scripts/function-source.mjs +48 -0
- package/scripts/g571-hosts.d.mts +3 -0
- package/scripts/g571-hosts.mjs +54 -0
- package/scripts/game-plugins.d.mts +22 -0
- package/scripts/gate-related-tests.d.mts +7 -0
- package/scripts/gate-related-tests.mjs +178 -0
- package/scripts/gen-api.d.mts +10 -0
- package/scripts/gen-api.mjs +134 -0
- package/scripts/gen-boot-cache.d.mts +2 -0
- package/scripts/gen-boot-cache.mjs +146 -0
- package/scripts/gen-budget-derivations.d.mts +1 -0
- package/scripts/gen-budget-derivations.mjs +43 -0
- package/scripts/gen-programs.d.mts +8 -0
- package/scripts/gen-programs.mjs +82 -0
- package/scripts/gen-shard-words.d.mts +4 -0
- package/scripts/gen-shard-words.mjs +188 -0
- package/scripts/gen-source.d.mts +4 -0
- package/scripts/gen-source.mjs +73 -0
- package/scripts/gen-starter-arm-clips.d.mts +4 -0
- package/scripts/gen-starter-arm-clips.mjs +17 -0
- package/scripts/gen-starter-bag.d.mts +4 -0
- package/scripts/gen-starter-bag.mjs +16 -0
- package/scripts/gen-starter-effects.d.mts +4 -0
- package/scripts/gen-starter-effects.mjs +16 -0
- package/scripts/gen-starter-weapons.d.mts +4 -0
- package/scripts/gen-starter-weapons.mjs +16 -0
- package/scripts/gen.mjs +6 -0
- package/scripts/generate-title-launch.mjs +55 -0
- package/scripts/generated-files.d.mts +6 -0
- package/scripts/generated-files.mjs +86 -0
- package/scripts/generated-input-reading.d.mts +3 -0
- package/scripts/generated-input-reading.mjs +89 -0
- package/scripts/generated-policy.d.mts +13 -0
- package/scripts/generated-policy.mjs +113 -0
- package/scripts/generated-source.d.mts +11 -0
- package/scripts/generated-source.mjs +214 -0
- package/scripts/generation-cache-prune.d.mts +10 -0
- package/scripts/generation-cache-prune.mjs +128 -0
- package/scripts/gfx-toggle/compare.mjs +133 -0
- package/scripts/git-common.d.mts +1 -0
- package/scripts/git-common.mjs +13 -0
- package/scripts/git-rule-counts.mjs +16 -0
- package/scripts/git-source-view.mjs +225 -0
- package/scripts/goldens/board.py +176 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +35 -0
- package/scripts/goldens/capture.mjs +214 -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-gate/matrix.d.mts +3 -0
- package/scripts/gpu-gate/matrix.mjs +48 -0
- package/scripts/gpu-gate/probe.mjs +30 -0
- package/scripts/gpu-gate/status.d.mts +4 -0
- package/scripts/gpu-gate/status.mjs +112 -0
- package/scripts/gpu-perf/com.wildshard.gpu-perf.plist +11 -0
- package/scripts/gpu-perf/install.sh +31 -0
- package/scripts/gpu-perf/nightly.mjs +216 -0
- package/scripts/gpu-perf/nightly.sh +7 -0
- package/scripts/gpu-perf/report.d.mts +18 -0
- package/scripts/gpu-perf/report.mjs +109 -0
- package/scripts/gpu-perf/timing.sh +17 -0
- package/scripts/gpu-trace-frames.mjs +113 -0
- package/scripts/grid-crossing-walk-proof.mjs +172 -0
- package/scripts/grid-gate-proof.mjs +126 -0
- package/scripts/grid-ready-latches.d.mts +7 -0
- package/scripts/grid-ready-latches.mjs +44 -0
- package/scripts/grid-ready-memory.d.mts +3 -0
- package/scripts/grid-ready-memory.mjs +86 -0
- package/scripts/grid-runtime-evidence.d.mts +4 -0
- package/scripts/grid-runtime-evidence.mjs +107 -0
- package/scripts/grid-spawn-proof.mjs +317 -0
- package/scripts/guard-counts.d.mts +8 -0
- package/scripts/guard-counts.mjs +136 -0
- package/scripts/guard-index-tree.d.mts +2 -0
- package/scripts/guard-index-tree.mjs +19 -0
- package/scripts/heavy-lane-lease.d.mts +2 -0
- package/scripts/heavy-lane-lease.mjs +33 -0
- package/scripts/heavy-lane.py +652 -0
- package/scripts/herdr-prompt.sh +13 -0
- package/scripts/herdr-question-open.sh +22 -0
- package/scripts/hero-shots.mjs +168 -0
- package/scripts/home-icons.mjs +27 -0
- package/scripts/host-activity.ts +41 -0
- package/scripts/hud-worst/chat.ts +33 -0
- package/scripts/hud-worst.mjs +344 -0
- package/scripts/inbox-pull.mjs +129 -0
- package/scripts/inline-shell-css.mjs +30 -0
- package/scripts/input-hash-memo.d.mts +16 -0
- package/scripts/input-hash-memo.mjs +109 -0
- package/scripts/input-snapshot.d.mts +2 -0
- package/scripts/input-snapshot.mjs +45 -0
- package/scripts/ios-memory-watchdog.py +339 -0
- package/scripts/iphone-mem-reading.sh +40 -0
- package/scripts/js-entry-census.mjs +54 -0
- package/scripts/js-payload-heap.mjs +23 -0
- package/scripts/json-declarations.d.mts +3 -0
- package/scripts/json-declarations.mjs +101 -0
- package/scripts/json-output-guard.d.mts +6 -0
- package/scripts/json-output-guard.mjs +50 -0
- package/scripts/ktx2-engine-map.json +156 -0
- package/scripts/ktx2-tables.d.mts +5 -0
- package/scripts/ktx2-tables.mjs +103 -0
- package/scripts/land.d.mts +17 -0
- package/scripts/land.mjs +888 -0
- package/scripts/lane-watchdog.d.mts +11 -0
- package/scripts/lane-watchdog.mjs +256 -0
- package/scripts/latch-grid-evidence.d.mts +1 -0
- package/scripts/latch-grid-evidence.mjs +68 -0
- package/scripts/lift-pending-batches-proof.mjs +135 -0
- package/scripts/lift-pending-batches.mjs +124 -0
- package/scripts/lift-pending-history-proof.mjs +41 -0
- package/scripts/lift-pending-proof.mjs +27 -0
- package/scripts/lift-pending-schedule.mjs +23 -0
- package/scripts/lift-pending.d.mts +1 -0
- package/scripts/lift-pending.mjs +78 -0
- package/scripts/link-node-modules.d.mts +1 -0
- package/scripts/link-node-modules.mjs +291 -0
- package/scripts/lint-all.mjs +50 -0
- package/scripts/lint-cli.mjs +10 -0
- package/scripts/lint-fast.mjs +30 -0
- package/scripts/lint-game-selection-proof.mjs +27 -0
- package/scripts/lint-game.mjs +26 -0
- package/scripts/lint-tools.d.mts +4 -0
- package/scripts/lint-tools.mjs +28 -0
- package/scripts/listed-view-code.d.mts +7 -0
- package/scripts/listed-view-code.mjs +93 -0
- package/scripts/live-prepush.py +352 -0
- package/scripts/load-mem-probe.mjs +248 -0
- package/scripts/loading-bar-rule.mjs +107 -0
- package/scripts/loading-benchmark/accuracy-data.d.mts +12 -0
- package/scripts/loading-benchmark/accuracy-data.mjs +92 -0
- package/scripts/loading-benchmark/cache-bodies.d.mts +14 -0
- package/scripts/loading-benchmark/cache-bodies.mjs +103 -0
- package/scripts/loading-benchmark/catalogue.d.mts +8 -0
- package/scripts/loading-benchmark/catalogue.mjs +41 -0
- package/scripts/loading-benchmark/sim-shard.d.mts +60 -0
- package/scripts/loading-benchmark/sim-shard.mjs +289 -0
- package/scripts/loading-benchmark/transport.d.mts +9 -0
- package/scripts/loading-benchmark/transport.mjs +109 -0
- package/scripts/loading-card-proof.mjs +298 -0
- package/scripts/loading-fence-proof.mjs +67 -0
- package/scripts/loading-flow/analyse.mjs +280 -0
- package/scripts/loading-flow/benchmax.mjs +179 -0
- package/scripts/loading-flow/board.py +104 -0
- package/scripts/loading-flow/drive.mjs +283 -0
- package/scripts/loading-flow/layer-parity-proof.mjs +69 -0
- package/scripts/loading-flow/link-probe.mjs +99 -0
- package/scripts/loading-flow/profile.mjs +54 -0
- package/scripts/loading-flow/run.sh +51 -0
- package/scripts/loading-flow/source-maps-proof.mjs +86 -0
- package/scripts/loading-flow/source-maps.mjs +73 -0
- package/scripts/loading-flow/stalls.d.mts +39 -0
- package/scripts/loading-flow/stalls.mjs +141 -0
- package/scripts/loading-flow/sweep-input-proof.mjs +127 -0
- package/scripts/loading-flow/sweep-input.mjs +70 -0
- package/scripts/loading-flow/sweep-report.mjs +112 -0
- package/scripts/loading-flow/sweep.sh +101 -0
- package/scripts/loading-flow/target-proof.mjs +56 -0
- package/scripts/loading-flow/target.mjs +39 -0
- package/scripts/loading-time-left-proof.mjs +121 -0
- package/scripts/loading-time-left-rule.mjs +49 -0
- package/scripts/look-loop/cameras.d.mts +18 -0
- package/scripts/look-loop/cameras.mjs +109 -0
- package/scripts/look-loop/fit-lut.py +142 -0
- package/scripts/look-loop/palette-delta.py +183 -0
- package/scripts/look-loop/regions/driftwood-isle.json +25 -0
- package/scripts/look-loop/regions/far-reach.json +225 -0
- package/scripts/look-loop/regions/open-plot-night-market.json +855 -0
- package/scripts/look-loop/regions/pine-hollow.json +22 -0
- package/scripts/look-loop/regions/sunscar-dunes.json +281 -0
- package/scripts/look-loop/targets.py +229 -0
- package/scripts/look-loop/test_look_loop.py +133 -0
- package/scripts/look-loop/views.mjs +176 -0
- package/scripts/main-menu-aerial-plan.mjs +8 -0
- package/scripts/main-menu-aerial-poses.ts +292 -0
- package/scripts/main-pull.mjs +84 -0
- package/scripts/main-watch.d.mts +19 -0
- package/scripts/main-watch.mjs +248 -0
- package/scripts/manifest-art-inputs.json +4 -0
- package/scripts/manifest-budget.mjs +44 -0
- package/scripts/manifest-declaration.d.mts +3 -0
- package/scripts/manifest-declaration.mjs +40 -0
- package/scripts/manifest-spawns.mjs +38 -0
- package/scripts/manifest-static-imports.d.mts +2 -0
- package/scripts/manifest-static-imports.mjs +83 -0
- package/scripts/map-hash.d.mts +20 -0
- package/scripts/map-hash.mjs +155 -0
- package/scripts/map-painter.d.mts +13 -0
- package/scripts/map-painter.mjs +97 -0
- package/scripts/map-stylize.py +241 -0
- package/scripts/memory/cpuOwners.d.mts +4 -0
- package/scripts/memory/cpuOwners.mjs +51 -0
- package/scripts/memory/heapReader.d.mts +3 -0
- package/scripts/memory/heapReader.mjs +59 -0
- package/scripts/memory/js-heap-ratchet.json +17 -0
- package/scripts/memory/jsHeap.d.mts +6 -0
- package/scripts/memory/jsHeap.mjs +52 -0
- package/scripts/memory-report-blocks.d.mts +28 -0
- package/scripts/memory-report-blocks.mjs +60 -0
- package/scripts/memory-report-data.d.mts +25 -0
- package/scripts/memory-report-data.mjs +222 -0
- package/scripts/memory-report-graphic.d.mts +5 -0
- package/scripts/memory-report-graphic.mjs +90 -0
- package/scripts/memory-report-snapshot.d.mts +4 -0
- package/scripts/memory-report-snapshot.mjs +13 -0
- package/scripts/memory-report.d.mts +5 -0
- package/scripts/memory-report.mjs +94 -0
- package/scripts/mmo-bots.mjs +241 -0
- package/scripts/mobile-graphics-proof.mjs +120 -0
- package/scripts/model-spin-recording.d.mts +4 -0
- package/scripts/model-spin-recording.mjs +25 -0
- package/scripts/model-spin.mjs +327 -0
- package/scripts/module-cache-proof.mjs +43 -0
- package/scripts/name-prompt-proof.mjs +136 -0
- package/scripts/native-recorder-cache.d.mts +33 -0
- package/scripts/native-recorder-cache.mjs +287 -0
- package/scripts/native-retention-proof.mjs +79 -0
- package/scripts/night-market-kit-budget.d.mts +12 -0
- package/scripts/night-market-kit-budget.mjs +80 -0
- package/scripts/nightly-heads.ts +176 -0
- package/scripts/nightly-model.ts +127 -0
- package/scripts/nightly-tag.d.mts +1 -0
- package/scripts/nightly-tag.mjs +32 -0
- package/scripts/nightly.proof.ts +105 -0
- package/scripts/nightly.ts +43 -0
- package/scripts/nine-sim-memory.mjs +353 -0
- package/scripts/no-binary-json.d.mts +12 -0
- package/scripts/no-binary-json.mjs +270 -0
- package/scripts/non-engine-admission-proof.mjs +27 -0
- package/scripts/number-path-probe.d.mts +7 -0
- package/scripts/number-path-probe.mjs +57 -0
- package/scripts/offline-proof-rules.d.mts +23 -0
- package/scripts/offline-proof-rules.mjs +123 -0
- package/scripts/offline-proof.mjs +498 -0
- package/scripts/online-phone-proof.mjs +330 -0
- package/scripts/online-proof.mjs +150 -0
- package/scripts/online-ride-proof.mjs +74 -0
- package/scripts/online-rig.mjs +114 -0
- package/scripts/page-parity.mjs +99 -0
- package/scripts/page-release/content.d.mts +30 -0
- package/scripts/page-release/content.mjs +299 -0
- package/scripts/page-release/flow.d.mts +60 -0
- package/scripts/page-release/flow.mjs +365 -0
- package/scripts/page-release/hosts/workers.d.mts +8 -0
- package/scripts/page-release/hosts/workers.mjs +160 -0
- package/scripts/page-release/packs.mjs +108 -0
- package/scripts/page-release/redact.d.mts +1 -0
- package/scripts/page-release/redact.mjs +19 -0
- package/scripts/page-release.mjs +101 -0
- package/scripts/page-size.d.mts +13 -0
- package/scripts/page-size.mjs +198 -0
- package/scripts/parallel-fast-lint.d.mts +1 -0
- package/scripts/parallel-fast-lint.mjs +54 -0
- package/scripts/parity/audio-diagnostics.d.mts +5 -0
- package/scripts/parity/audio-diagnostics.mjs +63 -0
- package/scripts/parity/audio-settle.mjs +111 -0
- package/scripts/parity/black-frame.d.mts +11 -0
- package/scripts/parity/black-frame.mjs +58 -0
- package/scripts/parity/boot-smoke.d.mts +47 -0
- package/scripts/parity/boot-smoke.mjs +585 -0
- package/scripts/parity/boot-timing-delay.mjs +54 -0
- package/scripts/parity/browser-escape.d.mts +2 -0
- package/scripts/parity/browser-escape.mjs +50 -0
- package/scripts/parity/budgetCeilings.d.mts +3 -0
- package/scripts/parity/budgetCeilings.mjs +30 -0
- package/scripts/parity/budgets.d.mts +7 -0
- package/scripts/parity/budgets.mjs +73 -0
- package/scripts/parity/cache.d.mts +1 -0
- package/scripts/parity/cache.mjs +40 -0
- package/scripts/parity/canvas-bytes.d.mts +13 -0
- package/scripts/parity/canvas-bytes.mjs +96 -0
- package/scripts/parity/capture-rpc.d.mts +2 -0
- package/scripts/parity/capture-rpc.mjs +41 -0
- package/scripts/parity/capture-trace.d.mts +6 -0
- package/scripts/parity/capture-trace.mjs +63 -0
- package/scripts/parity/clock.d.mts +1 -0
- package/scripts/parity/clock.mjs +89 -0
- package/scripts/parity/combat.d.mts +14 -0
- package/scripts/parity/combat.mjs +81 -0
- package/scripts/parity/compare.d.mts +10 -0
- package/scripts/parity/compare.mjs +177 -0
- package/scripts/parity/explorer-smoke.d.mts +21 -0
- package/scripts/parity/explorer-smoke.mjs +310 -0
- package/scripts/parity/fast-png.d.mts +18 -0
- package/scripts/parity/fast-png.mjs +68 -0
- package/scripts/parity/fingerprint.mjs +8 -0
- package/scripts/parity/fixed-render.d.mts +11 -0
- package/scripts/parity/fixed-render.mjs +79 -0
- package/scripts/parity/frame-budget.d.mts +3 -0
- package/scripts/parity/frame-budget.mjs +39 -0
- package/scripts/parity/frame-bytes.d.mts +8 -0
- package/scripts/parity/frame-bytes.mjs +45 -0
- package/scripts/parity/frames.mjs +8 -0
- package/scripts/parity/glbytes.d.mts +8 -0
- package/scripts/parity/glbytes.mjs +148 -0
- package/scripts/parity/grid-boot-waits.d.mts +13 -0
- package/scripts/parity/grid-boot-waits.mjs +43 -0
- package/scripts/parity/heat-bytes.d.mts +5 -0
- package/scripts/parity/heat-bytes.mjs +32 -0
- package/scripts/parity/hover-touch.mjs +153 -0
- package/scripts/parity/hud.d.mts +4 -0
- package/scripts/parity/hud.mjs +17 -0
- package/scripts/parity/image-routes.d.mts +5 -0
- package/scripts/parity/image-routes.mjs +29 -0
- package/scripts/parity/init.d.mts +15 -0
- package/scripts/parity/init.mjs +63 -0
- package/scripts/parity/lane-browser.mjs +14 -0
- package/scripts/parity/offline.d.mts +5 -0
- package/scripts/parity/offline.mjs +24 -0
- package/scripts/parity/phone-route-browser.d.mts +20 -0
- package/scripts/parity/phone-route-browser.mjs +241 -0
- package/scripts/parity/phone-route-page.d.mts +10 -0
- package/scripts/parity/phone-route-page.mjs +245 -0
- package/scripts/parity/phone-route-runner.d.mts +2 -0
- package/scripts/parity/phone-route-runner.mjs +39 -0
- package/scripts/parity/phone-route.d.mts +43 -0
- package/scripts/parity/phone-route.mjs +212 -0
- package/scripts/parity/pool.d.mts +4 -0
- package/scripts/parity/pool.mjs +74 -0
- package/scripts/parity/poses.d.mts +6 -0
- package/scripts/parity/poses.mjs +57 -0
- package/scripts/parity/probe.d.mts +2 -0
- package/scripts/parity/probe.mjs +13 -0
- package/scripts/parity/profile.d.mts +2 -0
- package/scripts/parity/profile.mjs +52 -0
- package/scripts/parity/record.d.mts +8 -0
- package/scripts/parity/record.mjs +102 -0
- package/scripts/parity/resources.mjs +58 -0
- package/scripts/parity/saves.d.mts +1 -0
- package/scripts/parity/saves.mjs +14 -0
- package/scripts/parity/serve.d.mts +9 -0
- package/scripts/parity/serve.mjs +125 -0
- package/scripts/parity/shader-code.d.mts +2 -0
- package/scripts/parity/shader-code.mjs +10 -0
- package/scripts/parity/ssim.d.mts +4 -0
- package/scripts/parity/ssim.mjs +44 -0
- package/scripts/parity/telemetry.d.mts +1 -0
- package/scripts/parity/telemetry.mjs +19 -0
- package/scripts/parity/timeout.mjs +7 -0
- package/scripts/parity/title-trace.d.mts +13 -0
- package/scripts/parity/title-trace.mjs +59 -0
- package/scripts/parity/value.d.mts +11 -0
- package/scripts/parity/value.mjs +50 -0
- package/scripts/parity/walk.d.mts +10 -0
- package/scripts/parity/walk.mjs +109 -0
- package/scripts/parity.mjs +310 -0
- package/scripts/perf/README.md +47 -0
- package/scripts/perf/cameras24.json +2963 -0
- package/scripts/perf/draw-census-page.d.mts +10 -0
- package/scripts/perf/draw-census-page.mjs +162 -0
- package/scripts/perf/draw-census-poses.d.mts +14 -0
- package/scripts/perf/draw-census-poses.mjs +44 -0
- package/scripts/perf/draw-census-report.d.mts +24 -0
- package/scripts/perf/draw-census-report.mjs +86 -0
- package/scripts/perf/draw-census.mjs +156 -0
- package/scripts/perf/exact-world-capture.mjs +167 -0
- package/scripts/perf/gpu-census-coverage.d.mts +6 -0
- package/scripts/perf/gpu-census-coverage.mjs +47 -0
- package/scripts/perf/gpu-census-overdraw.mjs +105 -0
- package/scripts/perf/gpu-census-page.d.mts +11 -0
- package/scripts/perf/gpu-census-page.mjs +53 -0
- package/scripts/perf/gpu-census-report.d.mts +3 -0
- package/scripts/perf/gpu-census-report.mjs +15 -0
- package/scripts/perf/gpu-census.d.mts +6 -0
- package/scripts/perf/gpu-census.mjs +95 -0
- package/scripts/perf/material-program-loan.d.mts +18 -0
- package/scripts/perf/material-program-loan.mjs +88 -0
- package/scripts/perf/world-pixel-difference.d.mts +5 -0
- package/scripts/perf/world-pixel-difference.mjs +22 -0
- package/scripts/phone-loading/chromium.ts +113 -0
- package/scripts/phone-loading/cpu-profile.ts +47 -0
- package/scripts/phone-loading/fixtures.ts +18 -0
- package/scripts/phone-loading/instrument.ts +219 -0
- package/scripts/phone-loading/link.ts +115 -0
- package/scripts/phone-loading/main.ts +261 -0
- package/scripts/phone-loading/model.ts +123 -0
- package/scripts/phone-loading/native-body.ts +40 -0
- package/scripts/phone-loading/native-sizes.ts +194 -0
- package/scripts/phone-loading/network.ts +167 -0
- package/scripts/phone-loading/play.ts +132 -0
- package/scripts/phone-loading/post-control.ts +22 -0
- package/scripts/phone-loading/recording.ts +28 -0
- package/scripts/phone-loading/shaped-preview.ts +37 -0
- package/scripts/phone-loading/tsconfig.json +11 -0
- package/scripts/physics-baseline.mjs +433 -0
- package/scripts/physics-grid-entry.d.mts +15 -0
- package/scripts/physics-grid-entry.mjs +62 -0
- package/scripts/physics-grid.d.mts +10 -0
- package/scripts/physics-grid.mjs +102 -0
- package/scripts/physics-native.d.mts +6 -0
- package/scripts/physics-native.mjs +81 -0
- package/scripts/physics-route.json +4400 -0
- package/scripts/physics-walk.d.mts +16 -0
- package/scripts/physics-walk.mjs +79 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/pin-assets.ts +94 -0
- package/scripts/pin-format.ts +43 -0
- package/scripts/pin-packs.ts +17 -0
- package/scripts/pins-exclude.d.mts +3 -0
- package/scripts/pins-exclude.mjs +54 -0
- package/scripts/pins-reuse.d.mts +27 -0
- package/scripts/pins-reuse.mjs +321 -0
- package/scripts/pins.ts +468 -0
- package/scripts/platform-chargebacks.d.mts +9 -0
- package/scripts/platform-chargebacks.mjs +135 -0
- package/scripts/playground-grapple.mjs +154 -0
- package/scripts/playground-harness.mjs +137 -0
- package/scripts/playground-horse.mjs +106 -0
- package/scripts/prebuilt-output.py +322 -0
- package/scripts/precommit-checks.d.mts +3 -0
- package/scripts/precommit-checks.mjs +115 -0
- package/scripts/precommit-inputs.d.mts +5 -0
- package/scripts/precommit-inputs.mjs +73 -0
- package/scripts/precommit-jobs.d.mts +5 -0
- package/scripts/precommit-jobs.mjs +85 -0
- package/scripts/precommit-source.py +493 -0
- package/scripts/preparation-cache-key.d.mts +2 -0
- package/scripts/preparation-cache-key.mjs +70 -0
- package/scripts/prepush-proof.mjs +36 -0
- package/scripts/preview-encoded-cache.d.mts +7 -0
- package/scripts/preview-encoded-cache.mjs +64 -0
- package/scripts/preview-lag.mjs +80 -0
- package/scripts/preview-server.mjs +256 -0
- package/scripts/preview-telemetry.d.mts +4 -0
- package/scripts/preview-telemetry.mjs +56 -0
- package/scripts/product-build-times.d.mts +3 -0
- package/scripts/product-build-times.mjs +42 -0
- package/scripts/program-discovery.d.mts +5 -0
- package/scripts/program-discovery.mjs +42 -0
- package/scripts/progress-recording.d.mts +6 -0
- package/scripts/progress-recording.mjs +26 -0
- package/scripts/progress-video.sh +27 -0
- package/scripts/proof-run.sh +69 -0
- package/scripts/prune-local-caches.mjs +10 -0
- package/scripts/public-grid.d.mts +11 -0
- package/scripts/public-grid.mjs +56 -0
- package/scripts/push-budget.d.mts +3 -0
- package/scripts/push-budget.mjs +5 -0
- package/scripts/push-cache-git-proof.mjs +32 -0
- package/scripts/push-cache-lease-proof.mjs +22 -0
- package/scripts/push-cache-proof.mjs +29 -0
- package/scripts/push-checks.d.mts +2 -0
- package/scripts/push-checks.mjs +116 -0
- package/scripts/push-cohort-proof.mjs +15 -0
- package/scripts/push-dependencies.mjs +97 -0
- package/scripts/push-dependency-proof.mjs +53 -0
- package/scripts/push-duration-sequencer.ts +26 -0
- package/scripts/push-environment.mjs +21 -0
- package/scripts/push-exclusion-proof.mjs +81 -0
- package/scripts/push-gate-copy.mjs +168 -0
- package/scripts/push-inputs.d.mts +4 -0
- package/scripts/push-inputs.mjs +99 -0
- package/scripts/push-lint-config.d.mts +4 -0
- package/scripts/push-lint-config.mjs +26 -0
- package/scripts/push-local-split.d.mts +15 -0
- package/scripts/push-local-split.mjs +116 -0
- package/scripts/push-loop.py +317 -0
- package/scripts/push-proof-cache.mjs +131 -0
- package/scripts/push-ref-tree-proof.mjs +63 -0
- package/scripts/push-related.mjs +29 -0
- package/scripts/push-selection-dev-proof.mjs +57 -0
- package/scripts/push-selection-proof.mjs +45 -0
- package/scripts/push-selection.d.mts +2 -0
- package/scripts/push-selection.mjs +65 -0
- package/scripts/push-vitest.config.ts +20 -0
- package/scripts/push_input_cache.py +306 -0
- package/scripts/quarantine-placement-proof.mjs +28 -0
- package/scripts/quarantine-renewal-proof.mjs +34 -0
- package/scripts/quarantine-window-proof.mjs +26 -0
- package/scripts/quest-complete-proof.mjs +78 -0
- package/scripts/quiet-cli.mjs +13 -0
- package/scripts/quiet_logs.py +79 -0
- package/scripts/ratchet-approval.d.mts +3 -0
- package/scripts/ratchet-approval.mjs +70 -0
- package/scripts/record-fence-reads.mjs +115 -0
- package/scripts/release-check.mjs +22 -0
- package/scripts/release-proof-proof.mjs +71 -0
- package/scripts/reload-title-proof.mjs +100 -0
- package/scripts/remote-air-proof.mjs +137 -0
- package/scripts/remote-bar-proof.mjs +75 -0
- package/scripts/remote-board-proof.mjs +129 -0
- package/scripts/remote-body-proof.mjs +101 -0
- package/scripts/remote-death-proof.mjs +134 -0
- package/scripts/remote-gait-proof.mjs +139 -0
- package/scripts/remote-held-proof.mjs +155 -0
- package/scripts/remote-hurt-proof.mjs +121 -0
- package/scripts/remote-map-proof.mjs +103 -0
- package/scripts/remote-name-proof.mjs +123 -0
- package/scripts/remote-players-proof.mjs +214 -0
- package/scripts/remote-room.mjs +75 -0
- package/scripts/remote-strike-proof.mjs +148 -0
- package/scripts/renderer-revision-replay.mjs +49 -0
- package/scripts/renderer-revision.d.mts +12 -0
- package/scripts/renderer-revision.mjs +101 -0
- package/scripts/renderer-revision.proof.mjs +71 -0
- package/scripts/repo-size.d.mts +43 -0
- package/scripts/repo-size.mjs +540 -0
- package/scripts/ring-cook.mjs +51 -0
- package/scripts/ring-step.ts +112 -0
- package/scripts/ring1.sh +79 -0
- package/scripts/room-deploy.mjs +130 -0
- package/scripts/room-soak.mjs +40 -0
- package/scripts/runtime_input_copies.py +49 -0
- package/scripts/scorecard.mjs +1156 -0
- package/scripts/script-scenario-metrics.d.mts +10 -0
- package/scripts/script-scenario-metrics.mjs +75 -0
- package/scripts/section-types.d.mts +3 -0
- package/scripts/section-types.mjs +35 -0
- package/scripts/sentry-maps.d.mts +9 -0
- package/scripts/sentry-maps.mjs +94 -0
- package/scripts/serialize-asset-tables.mjs +13 -0
- package/scripts/serve-build.sh +392 -0
- package/scripts/serve-port-lease.py +100 -0
- package/scripts/serve-shared-preview.py +295 -0
- package/scripts/server-origin.mjs +10 -0
- package/scripts/server-release/github.mjs +142 -0
- package/scripts/server-release/publish.d.mts +19 -0
- package/scripts/server-release/publish.mjs +143 -0
- package/scripts/server-release/sign.d.mts +10 -0
- package/scripts/server-release/sign.mjs +75 -0
- package/scripts/shard-component-spans.d.mts +15 -0
- package/scripts/shard-component-spans.mjs +18 -0
- package/scripts/shard-components.d.mts +16 -0
- package/scripts/shard-components.mjs +365 -0
- package/scripts/shard-coupling.d.mts +11 -0
- package/scripts/shard-coupling.mjs +238 -0
- package/scripts/shard-folders.mjs +14 -0
- package/scripts/shard-net-lines.d.mts +13 -0
- package/scripts/shard-net-lines.mjs +62 -0
- package/scripts/shard-output-content.d.mts +4 -0
- package/scripts/shard-output-content.mjs +27 -0
- package/scripts/shard-outputs.d.mts +12 -0
- package/scripts/shard-outputs.mjs +64 -0
- package/scripts/shard-phone-memory.d.mts +37 -0
- package/scripts/shard-phone-memory.mjs +556 -0
- package/scripts/shard-platform-format.d.mts +10 -0
- package/scripts/shard-platform-format.mjs +7 -0
- package/scripts/shard-platform-hosts.d.mts +2 -0
- package/scripts/shard-platform-hosts.mjs +93 -0
- package/scripts/shard-platform-output.d.mts +12 -0
- package/scripts/shard-platform-output.mjs +74 -0
- package/scripts/shard-platform-sections.d.mts +2 -0
- package/scripts/shard-platform-sections.mjs +9 -0
- package/scripts/shard-platform.d.mts +76 -0
- package/scripts/shard-platform.mjs +1072 -0
- package/scripts/shard-public.d.mts +3 -0
- package/scripts/shard-public.mjs +36 -0
- package/scripts/shard-runtime-closure.d.mts +3 -0
- package/scripts/shard-runtime-closure.mjs +30 -0
- package/scripts/shard-size-gate.d.mts +13 -0
- package/scripts/shard-size-gate.mjs +135 -0
- package/scripts/shard-size-watch.d.mts +7 -0
- package/scripts/shard-size-watch.mjs +70 -0
- package/scripts/shard-wire-meter.mjs +107 -0
- package/scripts/shardfile-cache.d.mts +17 -0
- package/scripts/shardfile-cache.mjs +268 -0
- package/scripts/shardfile-inputs.d.mts +19 -0
- package/scripts/shardfile-inputs.mjs +452 -0
- package/scripts/shardfile-validation-revision.d.mts +1 -0
- package/scripts/shardfile-validation-revision.mjs +30 -0
- package/scripts/shards.d.mts +7 -0
- package/scripts/shards.mjs +16 -0
- package/scripts/side-parity.d.mts +8 -0
- package/scripts/side-parity.mjs +220 -0
- package/scripts/sim-boost-lap.mjs +198 -0
- package/scripts/sim-grid-entry.mjs +534 -0
- package/scripts/sim-in-runtime.d.mts +6 -0
- package/scripts/sim-in-runtime.mjs +146 -0
- package/scripts/sim-lane.sh +351 -0
- package/scripts/sim-mem-phases.py +195 -0
- package/scripts/sim-memory.mjs +414 -0
- package/scripts/sim-node-loader.mjs +37 -0
- package/scripts/sim-presentation-proof.py +37 -0
- package/scripts/sim-quiet.py +160 -0
- package/scripts/sim-safari-ready.py +896 -0
- package/scripts/sim-transport.c +93 -0
- package/scripts/slice-inputs.ts +31 -0
- package/scripts/smoke-timings.py +34 -0
- package/scripts/snapshot-admission-proof.mjs +55 -0
- package/scripts/soak/boundary.mjs +110 -0
- package/scripts/soak/inspector.d.mts +18 -0
- package/scripts/soak/inspector.mjs +74 -0
- package/scripts/soak/memory-categories.d.mts +12 -0
- package/scripts/soak/memory-categories.mjs +28 -0
- package/scripts/socket-smoke.mjs +20 -0
- package/scripts/sort-sides.d.mts +33 -0
- package/scripts/sort-sides.mjs +919 -0
- package/scripts/source-generation-outputs.json +11 -0
- package/scripts/source-generators.d.mts +11 -0
- package/scripts/source-generators.mjs +59 -0
- package/scripts/source-input-proof.d.mts +12 -0
- package/scripts/source-input-proof.mjs +106 -0
- package/scripts/source-table-cache.d.mts +2 -0
- package/scripts/source-table-cache.mjs +102 -0
- package/scripts/sp-tools.py +150 -0
- package/scripts/sp-tools.sh +6 -0
- package/scripts/split-repair-data-shard.mjs +98 -0
- package/scripts/split-repair-guardian.mjs +26 -0
- package/scripts/split-repair-hare.mjs +54 -0
- package/scripts/split-repair-held-melee.mjs +41 -0
- package/scripts/split-repair-horse-panic.mjs +45 -0
- package/scripts/split-repair-movers.mjs +92 -0
- package/scripts/split-repair-nalati-signals.mjs +94 -0
- package/scripts/split-repair-perks.mjs +73 -0
- package/scripts/split-repair-pine-writes.mjs +76 -0
- package/scripts/split-repair-proof.mjs +24 -0
- package/scripts/split-repair-sky-trails.mjs +110 -0
- package/scripts/split-repair-stun.mjs +37 -0
- package/scripts/split-repair-wake-loss.mjs +35 -0
- package/scripts/split-repair-whip.mjs +44 -0
- package/scripts/staging-proof-lines.d.mts +8 -0
- package/scripts/staging-proof-lines.mjs +85 -0
- package/scripts/standalone-smoke.mjs +116 -0
- package/scripts/storage-policy.json +89 -0
- package/scripts/temp-janitor.d.mts +6 -0
- package/scripts/temp-janitor.mjs +40 -0
- package/scripts/template-format-proof.mjs +44 -0
- package/scripts/test-amber.d.mts +11 -0
- package/scripts/test-amber.mjs +90 -0
- package/scripts/test-build-tools.ts +24 -0
- package/scripts/test-facade-instancing.mjs +53 -0
- package/scripts/test-ios-memory-watchdog.py +107 -0
- package/scripts/test-products.json +389 -0
- package/scripts/test-quarantine.d.mts +6 -0
- package/scripts/test-quarantine.mjs +132 -0
- package/scripts/test-shard-plan.ts +66 -0
- package/scripts/test-timings.d.mts +14 -0
- package/scripts/test-timings.mjs +174 -0
- package/scripts/test_agent_time.py +155 -0
- package/scripts/test_browser_lane.py +239 -0
- package/scripts/test_lease_order.py +142 -0
- package/scripts/test_partition.py +23 -0
- package/scripts/test_prebuilt_output.py +258 -0
- package/scripts/test_products.py +20 -0
- package/scripts/test_serve_ports.py +645 -0
- package/scripts/test_sim_lane.py +1661 -0
- package/scripts/test_sim_quiet.py +140 -0
- package/scripts/texture-inputs.d.mts +4 -0
- package/scripts/texture-inputs.mjs +16 -0
- package/scripts/tile-bake-policy.d.mts +4 -0
- package/scripts/tile-bake-policy.mjs +43 -0
- package/scripts/tile-bake-report.d.mts +17 -0
- package/scripts/tile-bake-report.mjs +161 -0
- package/scripts/tile-bakes.d.mts +13 -0
- package/scripts/tile-bakes.mjs +100 -0
- package/scripts/timelapse.sh +44 -0
- package/scripts/title-assets.d.mts +6 -0
- package/scripts/title-assets.generated.json +9 -0
- package/scripts/title-assets.mjs +46 -0
- package/scripts/title-exit-proof.mjs +132 -0
- package/scripts/tsconfig.json +576 -0
- package/scripts/typecheck-lint.sh +21 -0
- package/scripts/typecheck-root.d.mts +2 -0
- package/scripts/typecheck-root.mjs +18 -0
- package/scripts/types/wildshard-probe.d.ts +29 -0
- package/scripts/types/worker-page.d.ts +55 -0
- package/scripts/uncatalogued-shard-proof.mjs +48 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/vitest-bench.py +800 -0
- package/scripts/vitest-ci-files.ts +90 -0
- package/scripts/vitest-ci.config.ts +15 -0
- package/scripts/vitest-cpu.ts +46 -0
- package/scripts/vitest-environments.ts +41 -0
- package/scripts/vitest-fixture-snapshots.config.ts +8 -0
- package/scripts/vitest-lane.ts +53 -0
- package/scripts/vitest-module-cache.ts +49 -0
- package/scripts/vitest-native-escape.config.ts +9 -0
- package/scripts/vitest-plan.ts +94 -0
- package/scripts/vitest-push-guards.config.ts +13 -0
- package/scripts/vitest-push.config.ts +19 -0
- package/scripts/vitest-shard.ts +109 -0
- package/scripts/vitest-timings.ts +32 -0
- package/scripts/vitest-tmp.ts +83 -0
- package/scripts/vitest.sh +5 -0
- package/scripts/vps/dump.sh +50 -0
- package/scripts/vps/harden-apply.sh +490 -0
- package/scripts/vps/harden-caddy.sh +215 -0
- package/scripts/vps/harden.sh +358 -0
- package/scripts/vps/health-stub.mjs +11 -0
- package/scripts/vps/pull.mjs +156 -0
- package/scripts/vps/rebuild.sh +531 -0
- package/scripts/vps/restore-check.sh +35 -0
- package/scripts/vps/setup-state.mjs +121 -0
- package/scripts/vps/setup.sh +442 -0
- package/scripts/vps/uptime.sh +26 -0
- package/scripts/vps/wildshard-agent.pub +1 -0
- package/scripts/vps/wildshard-apply.mjs +127 -0
- package/scripts/vps/wildshard-config +211 -0
- package/scripts/vps-harden-proof.sh +117 -0
- package/scripts/vps-rebuild-proof.sh +170 -0
- package/scripts/warm-native-chrome.d.mts +6 -0
- package/scripts/warm-native-chrome.mjs +75 -0
- package/scripts/webkit-mem-reading.mjs +157 -0
- package/scripts/webkit-render-smoke.mjs +145 -0
- package/scripts/worker-bootstrap-proof.mjs +79 -0
- package/scripts/worker-client-death-return.mjs +97 -0
- package/scripts/worker-client-death.mjs +67 -0
- package/scripts/worker-client-fights.mjs +1438 -0
- package/scripts/worker-client-grid-entry.mjs +239 -0
- package/scripts/worker-client-hurt.mjs +92 -0
- package/scripts/worker-client-moments.mjs +340 -0
- package/scripts/worker-client-partner.mjs +93 -0
- package/scripts/worker-client-pine-durable.mjs +102 -0
- package/scripts/worker-client-pine-grid.mjs +77 -0
- package/scripts/worker-client-pine-import.mjs +93 -0
- package/scripts/worker-client-pine.mjs +114 -0
- package/scripts/worker-client-play.mjs +572 -0
- package/scripts/worker-client-proof.mjs +201 -0
- package/scripts/worker-client-repairs.mjs +108 -0
- package/scripts/worker-client-returns.mjs +51 -0
- package/scripts/worker-client-saves.mjs +146 -0
- package/scripts/worker-client-windup.mjs +50 -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 +339 -0
- package/src/.oxfmtrc.json +48 -0
- package/src/.oxlintrc.json +190 -0
- package/src/cli/main.ts +112 -0
- package/src/cli/version.ts +13 -0
- package/src/client/app/assetTables.ts +68 -0
- package/src/client/app/bootDownloads.ts +43 -0
- package/src/client/app/bootRoute.ts +27 -0
- package/src/client/app/calibrate.ts +9 -0
- package/src/client/app/dropModal.ts +99 -0
- package/src/client/app/entry.ts +439 -0
- package/src/client/app/failScreens.ts +561 -0
- package/src/client/app/identity.ts +10 -0
- package/src/client/app/main.ts +3 -0
- package/src/client/app/pageServices.ts +20 -0
- package/src/client/app/selectedManifests.ts +31 -0
- package/src/client/app/shardSelection.ts +46 -0
- package/src/client/app/titleSettings.ts +15 -0
- package/src/client/app.tsx +53 -0
- package/src/client/engine/ai/view/eliteController.ts +148 -0
- package/src/client/engine/ai/view/eliteEntry.ts +464 -0
- package/src/client/engine/aliasFixture.webp +0 -0
- package/src/client/engine/anim/channel.ts +58 -0
- package/src/client/engine/anim/machine.ts +77 -0
- package/src/client/engine/anim/rig.ts +150 -0
- package/src/client/engine/anim/rigAtlas.ts +73 -0
- package/src/client/engine/anim/rigParser.ts +59 -0
- package/src/client/engine/app/app.ts +262 -0
- package/src/client/engine/app/assets.ts +122 -0
- package/src/client/engine/app/cachedAssets.ts +116 -0
- package/src/client/engine/app/disposalCache.ts +30 -0
- package/src/client/engine/app/runtime.ts +16 -0
- package/src/client/engine/app/sceneOwnership.ts +317 -0
- package/src/client/engine/app/services.ts +20 -0
- package/src/client/engine/app/systems.ts +71 -0
- package/src/client/engine/app/ui.ts +33 -0
- package/src/client/engine/app/view/frameScheduler.ts +65 -0
- package/src/client/engine/app/view/pageActivity.ts +12 -0
- package/src/client/engine/app/view/presentation.ts +41 -0
- package/src/client/engine/app/view/presentationLoop.ts +56 -0
- package/src/client/engine/app/view/scopeEnvironment.ts +39 -0
- package/src/client/engine/app/workerScope.js +20 -0
- package/src/client/engine/audio/AmbienceBeds.ts +197 -0
- package/src/client/engine/audio/Audio.ts +634 -0
- package/src/client/engine/audio/Cues.ts +153 -0
- package/src/client/engine/audio/Music.ts +958 -0
- package/src/client/engine/audio/SetScore.ts +297 -0
- package/src/client/engine/audio/Stems.ts +277 -0
- package/src/client/engine/audio/Voices.ts +299 -0
- package/src/client/engine/audio/aacNative.ts +46 -0
- package/src/client/engine/audio/aacPull.ts +166 -0
- package/src/client/engine/audio/aacSource.ts +122 -0
- package/src/client/engine/audio/aacTrack.ts +115 -0
- package/src/client/engine/audio/aacWindows.ts +66 -0
- package/src/client/engine/audio/activity.ts +70 -0
- package/src/client/engine/audio/activityTimers.ts +37 -0
- package/src/client/engine/audio/ambience.ts +549 -0
- package/src/client/engine/audio/audioLog.ts +22 -0
- package/src/client/engine/audio/codecs.merge.d.ts +9 -0
- package/src/client/engine/audio/credits.ts +48 -0
- package/src/client/engine/audio/cueRouting.ts +93 -0
- package/src/client/engine/audio/declared.ts +95 -0
- package/src/client/engine/audio/declaredAmbience.ts +113 -0
- package/src/client/engine/audio/declaredBank.ts +104 -0
- package/src/client/engine/audio/declaredGameplay.ts +82 -0
- package/src/client/engine/audio/dsp.ts +164 -0
- package/src/client/engine/audio/gen.ts +538 -0
- package/src/client/engine/audio/interactSfx.ts +95 -0
- package/src/client/engine/audio/levelAudio.ts +131 -0
- package/src/client/engine/audio/loopWindow.ts +24 -0
- package/src/client/engine/audio/ownership.ts +16 -0
- package/src/client/engine/audio/playerVoices.ts +278 -0
- package/src/client/engine/audio/preload.ts +166 -0
- package/src/client/engine/audio/score/score.ts +60 -0
- package/src/client/engine/audio/scoreSelection.ts +19 -0
- package/src/client/engine/audio/surface.ts +71 -0
- package/src/client/engine/audio/synth.ts +301 -0
- package/src/client/engine/audio/unlock.ts +104 -0
- package/src/client/engine/audio/util.ts +95 -0
- package/src/client/engine/blocks.ts +6 -0
- package/src/client/engine/boot/audioFiles.ts +9 -0
- package/src/client/engine/boot/audioInventory.ts +34 -0
- package/src/client/engine/boot/audioPack.ts +54 -0
- package/src/client/engine/boot/bakedApi.ts +46 -0
- package/src/client/engine/boot/bakedTextures.ts +114 -0
- package/src/client/engine/boot/bootCache.ts +16 -0
- package/src/client/engine/boot/bootTrace.ts +362 -0
- package/src/client/engine/boot/browserChunkRecovery.ts +136 -0
- package/src/client/engine/boot/bytes.ts +272 -0
- package/src/client/engine/boot/catalog.ts +35 -0
- package/src/client/engine/boot/chunkRecovery.ts +41 -0
- package/src/client/engine/boot/clearDownloads.ts +128 -0
- package/src/client/engine/boot/contentBase.ts +77 -0
- package/src/client/engine/boot/contentRead.ts +151 -0
- package/src/client/engine/boot/diagnostics.ts +195 -0
- package/src/client/engine/boot/download.ts +112 -0
- package/src/client/engine/boot/dropNotice.ts +260 -0
- package/src/client/engine/boot/earlyPrograms.ts +123 -0
- package/src/client/engine/boot/extras.ts +324 -0
- package/src/client/engine/boot/filePolicy.ts +126 -0
- package/src/client/engine/boot/firstPlayMark.ts +43 -0
- package/src/client/engine/boot/gpuFiles.ts +176 -0
- package/src/client/engine/boot/gpuTrace.ts +42 -0
- package/src/client/engine/boot/idle.ts +52 -0
- package/src/client/engine/boot/imageDecode.ts +95 -0
- package/src/client/engine/boot/imageDecode.worker.ts +69 -0
- package/src/client/engine/boot/ktx2.generated.ts +157 -0
- package/src/client/engine/boot/lastEnd.ts +312 -0
- package/src/client/engine/boot/leaveAfterPaint.ts +16 -0
- package/src/client/engine/boot/liveJsonParser.ts +124 -0
- package/src/client/engine/boot/liveJsonParser.worker.ts +22 -0
- package/src/client/engine/boot/loadingDownloadText.ts +54 -0
- package/src/client/engine/boot/loadingPacks.ts +18 -0
- package/src/client/engine/boot/lowPower.ts +96 -0
- package/src/client/engine/boot/manifest.ts +12 -0
- package/src/client/engine/boot/pack.ts +180 -0
- package/src/client/engine/boot/parsedPages.ts +115 -0
- package/src/client/engine/boot/perflog.ts +15 -0
- package/src/client/engine/boot/plan.ts +256 -0
- package/src/client/engine/boot/prefetch.ts +188 -0
- package/src/client/engine/boot/prefetchQuota.ts +84 -0
- package/src/client/engine/boot/readContentResponse.ts +17 -0
- package/src/client/engine/boot/retry.ts +14 -0
- package/src/client/engine/boot/runtime.ts +21 -0
- package/src/client/engine/boot/shardPrefetch.ts +278 -0
- package/src/client/engine/boot/shell.ts +135 -0
- package/src/client/engine/boot/stuck.ts +106 -0
- package/src/client/engine/boot/stuckStep.ts +99 -0
- package/src/client/engine/boot/sw.ts +385 -0
- package/src/client/engine/boot/swGlobal.d.ts +9 -0
- package/src/client/engine/boot/texturePack.ts +182 -0
- package/src/client/engine/boot/timeLeft.ts +106 -0
- package/src/client/engine/boot/titleArrival.ts +101 -0
- package/src/client/engine/boot/weights.ts +21 -0
- package/src/client/engine/boot.ts +51 -0
- package/src/client/engine/build.d.ts +2 -0
- package/src/client/engine/calibrate/entry.ts +29 -0
- package/src/client/engine/calibrate/js.ts +39 -0
- package/src/client/engine/calibrate/math.ts +23 -0
- package/src/client/engine/calibrate/run.ts +93 -0
- package/src/client/engine/calibrate/wasm.ts +154 -0
- package/src/client/engine/combat/EquipmentService.ts +412 -0
- package/src/client/engine/combat/cues.ts +46 -0
- package/src/client/engine/combat/types.ts +21 -0
- package/src/client/engine/combat/view/Bow.ts +462 -0
- package/src/client/engine/combat/view/DropArc.ts +64 -0
- package/src/client/engine/combat/view/EquipmentHost.ts +15 -0
- package/src/client/engine/combat/view/SweptMelee.ts +691 -0
- package/src/client/engine/combat/view/bowProfile.ts +182 -0
- package/src/client/engine/combat/view/brass.ts +65 -0
- package/src/client/engine/combat/view/firearmFx.ts +25 -0
- package/src/client/engine/combat/view/hitscan.ts +29 -0
- package/src/client/engine/combat/view/melee.ts +67 -0
- package/src/client/engine/combat/view/projectedTrail.ts +42 -0
- package/src/client/engine/combat/view/projectile.ts +315 -0
- package/src/client/engine/combat/view/ranged.ts +460 -0
- package/src/client/engine/combat/view/rangedFeel.ts +39 -0
- package/src/client/engine/combat/view/slashTrail.ts +151 -0
- package/src/client/engine/core/Game.ts +1833 -0
- package/src/client/engine/core/GpuRecovery.ts +200 -0
- package/src/client/engine/core/Grade.ts +109 -0
- package/src/client/engine/core/KeepAlive.ts +32 -0
- package/src/client/engine/core/Tour.ts +46 -0
- package/src/client/engine/core/Volumetrics.ts +260 -0
- package/src/client/engine/core/apiOrigin.ts +12 -0
- package/src/client/engine/core/assets.ts +292 -0
- package/src/client/engine/core/bootstrap.ts +175 -0
- package/src/client/engine/core/crashFlag.ts +32 -0
- package/src/client/engine/core/crossroads.ts +4 -0
- package/src/client/engine/core/deflate.ts +110 -0
- package/src/client/engine/core/devMode.ts +49 -0
- package/src/client/engine/core/devPixels.ts +62 -0
- package/src/client/engine/core/drawBudget.ts +48 -0
- package/src/client/engine/core/errorReport.ts +248 -0
- package/src/client/engine/core/gpuOnly.ts +139 -0
- package/src/client/engine/core/graphicsMode.ts +62 -0
- package/src/client/engine/core/graphicsQuality.ts +117 -0
- package/src/client/engine/core/heldTiming.ts +24 -0
- package/src/client/engine/core/ktx2.ts +511 -0
- package/src/client/engine/core/ktx2Sources.ts +22 -0
- package/src/client/engine/core/ktx2Zstd.ts +151 -0
- package/src/client/engine/core/ktx2Zstd.worker.ts +31 -0
- package/src/client/engine/core/practiceRoom.ts +16 -0
- package/src/client/engine/core/reloadGuard.ts +21 -0
- package/src/client/engine/core/scopedCpu.ts +49 -0
- package/src/client/engine/core/scopedWorkerPool.ts +55 -0
- package/src/client/engine/core/shadowLayer.ts +8 -0
- package/src/client/engine/core/slowGpuPacing.ts +118 -0
- package/src/client/engine/core/sustainedFrames.ts +73 -0
- package/src/client/engine/core/tier.ts +126 -0
- package/src/client/engine/core/viewport.ts +130 -0
- package/src/client/engine/core/webglStartup.ts +50 -0
- package/src/client/engine/core/worldDepth.ts +183 -0
- package/src/client/engine/core/zstdFrame.ts +38 -0
- package/src/client/engine/debug/probe.ts +560 -0
- package/src/client/engine/debug/timerBaseline.ts +14 -0
- package/src/client/engine/entities/AnimalFactory.ts +766 -0
- package/src/client/engine/entities/AnimalHerdView.ts +413 -0
- package/src/client/engine/entities/AnimalView.ts +583 -0
- package/src/client/engine/entities/RowBodies.ts +276 -0
- package/src/client/engine/entities/animalMatrices.ts +179 -0
- package/src/client/engine/entities/animalShadow.ts +58 -0
- package/src/client/engine/entities/animalShells.ts +14 -0
- package/src/client/engine/entities/farHerd.ts +469 -0
- package/src/client/engine/entities/lowpoly.ts +155 -0
- package/src/client/engine/entities/species/loft.ts +253 -0
- package/src/client/engine/entities/species/look.ts +122 -0
- package/src/client/engine/events/maps.ts +58 -0
- package/src/client/engine/explore/Compare.ts +126 -0
- package/src/client/engine/explore/Explore.ts +648 -0
- package/src/client/engine/explore/FreeCam.ts +280 -0
- package/src/client/engine/explore/MiniMap.ts +283 -0
- package/src/client/engine/explore/ModelExplorer.ts +1155 -0
- package/src/client/engine/explore/Select.ts +176 -0
- package/src/client/engine/explore/SetExplorer.ts +553 -0
- package/src/client/engine/explore/TouchFly.ts +236 -0
- package/src/client/engine/explore/catalog.ts +159 -0
- package/src/client/engine/explore/diorama.ts +245 -0
- package/src/client/engine/explore/fatLines.ts +47 -0
- package/src/client/engine/explore/img/mockups/nalati-camp-live.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nalati-camp-target.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nalati-gully-live.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nalati-gully-target.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nalati-rail-live.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nalati-rail-target.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nine-gate-live.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nine-gate-target.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nine-stair-live.jpg +0 -0
- package/src/client/engine/explore/img/mockups/nine-stair-target.jpg +0 -0
- package/src/client/engine/explore/pick.ts +120 -0
- package/src/client/engine/explore/registry.ts +16 -0
- package/src/client/engine/explore/setView.ts +222 -0
- package/src/client/engine/explore/tiers.ts +27 -0
- package/src/client/engine/explore/viewPoint.ts +100 -0
- package/src/client/engine/fx/Impacts.ts +154 -0
- package/src/client/engine/fx/LightPool.ts +188 -0
- package/src/client/engine/fx/ParticlePool.ts +76 -0
- package/src/client/engine/fx/SiteLights.ts +119 -0
- package/src/client/engine/fx/effectField.ts +91 -0
- package/src/client/engine/fx/groundFx.ts +144 -0
- package/src/client/engine/fx/groundTell.ts +101 -0
- package/src/client/engine/fx/lightEmitters.ts +35 -0
- package/src/client/engine/input/ControlsPanel.ts +108 -0
- package/src/client/engine/input/InputService.ts +394 -0
- package/src/client/engine/input/bindingTable.ts +124 -0
- package/src/client/engine/input/bindings.ts +101 -0
- package/src/client/engine/input/dom.ts +62 -0
- package/src/client/engine/input/equipmentInput.ts +4 -0
- package/src/client/engine/input/gameplay.ts +36 -0
- package/src/client/engine/input/keycap.ts +25 -0
- package/src/client/engine/input/menuInput.ts +7 -0
- package/src/client/engine/input/platform.ts +36 -0
- package/src/client/engine/input/weaponActions.ts +8 -0
- package/src/client/engine/level/frame.ts +95 -0
- package/src/client/engine/level/installation.ts +107 -0
- package/src/client/engine/level/load.ts +97 -0
- package/src/client/engine/level/registrations.ts +59 -0
- package/src/client/engine/math/color.ts +6 -0
- package/src/client/engine/models/animalGeometry.ts +29 -0
- package/src/client/engine/models/castawayBody.ts +257 -0
- package/src/client/engine/models/colliders.ts +186 -0
- package/src/client/engine/models/creature.ts +66 -0
- package/src/client/engine/models/cull.ts +953 -0
- package/src/client/engine/models/gear.ts +87 -0
- package/src/client/engine/models/geometryPack.ts +14 -0
- package/src/client/engine/models/hoverboard.ts +29 -0
- package/src/client/engine/models/instancedBatch.ts +324 -0
- package/src/client/engine/models/interact.ts +26 -0
- package/src/client/engine/models/live.ts +174 -0
- package/src/client/engine/models/model.ts +449 -0
- package/src/client/engine/models/modelPose.ts +14 -0
- package/src/client/engine/models/nativeGeometry.ts +114 -0
- package/src/client/engine/models/ownedGeometry.ts +294 -0
- package/src/client/engine/models/place.ts +1476 -0
- package/src/client/engine/models/roster.ts +44 -0
- package/src/client/engine/models/sets.ts +74 -0
- package/src/client/engine/models/slots.ts +69 -0
- package/src/client/engine/models/staticSets.ts +119 -0
- package/src/client/engine/models/swimHands.ts +44 -0
- package/src/client/engine/models/trainingDummy.ts +46 -0
- package/src/client/engine/models/trainingDummyFigure.ts +16 -0
- package/src/client/engine/models/weld.ts +260 -0
- package/src/client/engine/net/attackPrediction.ts +38 -0
- package/src/client/engine/net/client.ts +314 -0
- package/src/client/engine/net/heldOnOthers.ts +167 -0
- package/src/client/engine/net/hurtOther.ts +12 -0
- package/src/client/engine/net/interpolator.ts +179 -0
- package/src/client/engine/net/nameTag.ts +88 -0
- package/src/client/engine/net/netClock.ts +90 -0
- package/src/client/engine/net/netPlayer.ts +265 -0
- package/src/client/engine/net/netRecord.ts +43 -0
- package/src/client/engine/net/onRep.ts +75 -0
- package/src/client/engine/net/otherPlayers.ts +239 -0
- package/src/client/engine/net/othersOnMap.ts +80 -0
- package/src/client/engine/net/predictionWorld.ts +100 -0
- package/src/client/engine/net/predictor.ts +233 -0
- package/src/client/engine/net/redial.ts +179 -0
- package/src/client/engine/net/remoteAir.ts +134 -0
- package/src/client/engine/net/remoteBoard.ts +128 -0
- package/src/client/engine/net/remoteDeath.ts +140 -0
- package/src/client/engine/net/remoteGait.ts +114 -0
- package/src/client/engine/net/remoteHurt.ts +123 -0
- package/src/client/engine/net/remoteStrike.ts +160 -0
- package/src/client/engine/net/voiceNear.ts +55 -0
- package/src/client/engine/net/webSocketTransport.ts +91 -0
- package/src/client/engine/physics/active.ts +15 -0
- package/src/client/engine/physics/boxFrame.ts +15 -0
- package/src/client/engine/physics/calibration.ts +31 -0
- package/src/client/engine/physics/debug.ts +68 -0
- package/src/client/engine/physics/navmeshLoad.ts +86 -0
- package/src/client/engine/physics/ragdoll.ts +513 -0
- package/src/client/engine/physics/ropeDeck.ts +112 -0
- package/src/client/engine/player/AimAssist.ts +183 -0
- package/src/client/engine/player/AimTargets.ts +55 -0
- package/src/client/engine/player/CameraFX.ts +89 -0
- package/src/client/engine/player/Hands.ts +216 -0
- package/src/client/engine/player/LockOnTarget.ts +395 -0
- package/src/client/engine/player/Player.ts +678 -0
- package/src/client/engine/player/Skins.ts +109 -0
- package/src/client/engine/player/TouchControls.ts +564 -0
- package/src/client/engine/player/WaterLine.ts +94 -0
- package/src/client/engine/player/WeaponPickup.ts +465 -0
- package/src/client/engine/player/bladeGlow.ts +120 -0
- package/src/client/engine/player/firstPersonArms.ts +384 -0
- package/src/client/engine/player/heldHandParts.ts +91 -0
- package/src/client/engine/player/viewmodelSources.ts +25 -0
- package/src/client/engine/player/viewmodelTextures.ts +261 -0
- package/src/client/engine/player/viewmodelTextures.worker.ts +28 -0
- package/src/client/engine/practice/DummyClips.ts +100 -0
- package/src/client/engine/practice/DummyMotion.ts +287 -0
- package/src/client/engine/practice/DummyStudio.ts +137 -0
- package/src/client/engine/practice/TrainingArena.ts +463 -0
- package/src/client/engine/practice/TrainingDummy.ts +160 -0
- package/src/client/engine/practice/TrainingDummyAssets.ts +80 -0
- package/src/client/engine/practice/arena.css +20 -0
- package/src/client/engine/practice/dummyMetadata.ts +12 -0
- package/src/client/engine/practice/lineup.ts +17 -0
- package/src/client/engine/practice/playground/Playground.ts +52 -0
- package/src/client/engine/practice/playground/catalog.ts +44 -0
- package/src/client/engine/practice/playground/devGrid.ts +173 -0
- package/src/client/engine/practice/playground/hud.ts +80 -0
- package/src/client/engine/practice/playground/load.ts +24 -0
- package/src/client/engine/practice/practiceLoan.ts +52 -0
- package/src/client/engine/practice/targets.ts +15 -0
- package/src/client/engine/pwa/cacheNames.ts +2 -0
- package/src/client/engine/pwa/sw.js +401 -0
- package/src/client/engine/quest/view/replica.ts +88 -0
- package/src/client/engine/quest/view/ui.ts +221 -0
- package/src/client/engine/quest/view.ts +209 -0
- package/src/client/engine/render/allocationBytes.ts +16 -0
- package/src/client/engine/render/allocationJournal.ts +125 -0
- package/src/client/engine/render/aoTransparency.ts +225 -0
- package/src/client/engine/render/budgetReport.ts +53 -0
- package/src/client/engine/render/budgets.ts +72 -0
- package/src/client/engine/render/calibration.ts +32 -0
- package/src/client/engine/render/calibrationGpu.ts +84 -0
- package/src/client/engine/render/changedTextureUploads.ts +118 -0
- package/src/client/engine/render/compileLights.ts +75 -0
- package/src/client/engine/render/compileShadows.ts +29 -0
- package/src/client/engine/render/composerDepth.ts +26 -0
- package/src/client/engine/render/compressedMipmaps.ts +59 -0
- package/src/client/engine/render/compressedTextureRetirement.ts +71 -0
- package/src/client/engine/render/compressedUpload.ts +107 -0
- package/src/client/engine/render/contextErrors.ts +14 -0
- package/src/client/engine/render/dataLook.ts +691 -0
- package/src/client/engine/render/desktopReference.ts +5 -0
- package/src/client/engine/render/diagnosticJournal.ts +23 -0
- package/src/client/engine/render/displayColour.ts +55 -0
- package/src/client/engine/render/doubleElements.ts +33 -0
- package/src/client/engine/render/drawGuards.ts +47 -0
- package/src/client/engine/render/drawHooks.ts +265 -0
- package/src/client/engine/render/drawNeutral.ts +19 -0
- package/src/client/engine/render/drawnEnvironment.ts +35 -0
- package/src/client/engine/render/entryWarmupBound.ts +19 -0
- package/src/client/engine/render/families/emissive.ts +224 -0
- package/src/client/engine/render/families/ground.ts +291 -0
- package/src/client/engine/render/families/measure.ts +191 -0
- package/src/client/engine/render/families/paintedTerrain.ts +388 -0
- package/src/client/engine/render/families/painterly.ts +288 -0
- package/src/client/engine/render/families/pbr.ts +67 -0
- package/src/client/engine/render/families/registry.ts +140 -0
- package/src/client/engine/render/families/toon.ts +193 -0
- package/src/client/engine/render/fencedUnits.ts +115 -0
- package/src/client/engine/render/firstFrameParts.ts +95 -0
- package/src/client/engine/render/fogPatches.ts +56 -0
- package/src/client/engine/render/frameCounter.ts +47 -0
- package/src/client/engine/render/frameDrawRange.ts +120 -0
- package/src/client/engine/render/gltfMaterialOrder.ts +83 -0
- package/src/client/engine/render/gpuClasses.ts +29 -0
- package/src/client/engine/render/gpuLabels.ts +437 -0
- package/src/client/engine/render/graph/colourFunction.ts +83 -0
- package/src/client/engine/render/graph/glsl.ts +1056 -0
- package/src/client/engine/render/graph/glslCodec.ts +48 -0
- package/src/client/engine/render/graph/glslMaterial.ts +463 -0
- package/src/client/engine/render/graph/glslPost.ts +79 -0
- package/src/client/engine/render/graph/glslProgram.ts +698 -0
- package/src/client/engine/render/graph/presets.ts +812 -0
- package/src/client/engine/render/graph/viewRay.ts +28 -0
- package/src/client/engine/render/graphBackend.ts +176 -0
- package/src/client/engine/render/hoverboardGeometry.ts +54 -0
- package/src/client/engine/render/instancedGeometry.ts +28 -0
- package/src/client/engine/render/instancedTwin.ts +40 -0
- package/src/client/engine/render/ktx2Probe.ts +299 -0
- package/src/client/engine/render/layeredMaps.ts +64 -0
- package/src/client/engine/render/lightUniforms.ts +22 -0
- package/src/client/engine/render/lighterTargets.ts +47 -0
- package/src/client/engine/render/lightmaps.ts +36 -0
- package/src/client/engine/render/look.ts +406 -0
- package/src/client/engine/render/lookLight.ts +107 -0
- package/src/client/engine/render/lut.ts +23 -0
- package/src/client/engine/render/memoryImages.ts +31 -0
- package/src/client/engine/render/memorySaver.ts +262 -0
- package/src/client/engine/render/offscreenBuild.ts +184 -0
- package/src/client/engine/render/offscreenPreparation.ts +41 -0
- package/src/client/engine/render/parkedDraws.ts +920 -0
- package/src/client/engine/render/pmremSize.ts +21 -0
- package/src/client/engine/render/postPreparation.ts +67 -0
- package/src/client/engine/render/precompile.ts +1833 -0
- package/src/client/engine/render/programRetention.ts +125 -0
- package/src/client/engine/render/readbackPreparation.ts +23 -0
- package/src/client/engine/render/regionCinematic.ts +212 -0
- package/src/client/engine/render/regionLook.ts +301 -0
- package/src/client/engine/render/releasedArrays.ts +13 -0
- package/src/client/engine/render/renderer.ts +68 -0
- package/src/client/engine/render/scatterInstances.ts +139 -0
- package/src/client/engine/render/scenePreparation.ts +27 -0
- package/src/client/engine/render/shaderPatches.ts +303 -0
- package/src/client/engine/render/shaderText.ts +95 -0
- package/src/client/engine/render/shadowDepthVariants.ts +35 -0
- package/src/client/engine/render/shadowMaterialOwnership.ts +120 -0
- package/src/client/engine/render/skinnedSpheres.ts +30 -0
- package/src/client/engine/render/skyEnvironment.ts +222 -0
- package/src/client/engine/render/staticMatrices.ts +88 -0
- package/src/client/engine/render/streamedInstances.ts +184 -0
- package/src/client/engine/render/textureBytes.ts +185 -0
- package/src/client/engine/render/textureUploadEvents.ts +60 -0
- package/src/client/engine/render/tierBenchmark.ts +54 -0
- package/src/client/engine/render/tierBoot.ts +50 -0
- package/src/client/engine/render/tierSelect.ts +27 -0
- package/src/client/engine/render/tiers.ts +78 -0
- package/src/client/engine/render/uniformCaches.ts +143 -0
- package/src/client/engine/render/uploadOwnership.ts +335 -0
- package/src/client/engine/render/viewmodel.ts +114 -0
- package/src/client/engine/render/viewmodelFeel.ts +374 -0
- package/src/client/engine/saves/indexed.ts +250 -0
- package/src/client/engine/saves/slots.ts +42 -0
- package/src/client/engine/saves/view/storage.ts +11 -0
- package/src/client/engine/script/client.ts +240 -0
- package/src/client/engine/telemetry/bootInbox.ts +18 -0
- package/src/client/engine/telemetry/browserErrors.ts +173 -0
- package/src/client/engine/telemetry/crossroads.ts +26 -0
- package/src/client/engine/telemetry/health.ts +40 -0
- package/src/client/engine/telemetry/model.ts +36 -0
- package/src/client/engine/telemetry/runtime.ts +62 -0
- package/src/client/engine/types/meshopt-simplifier.d.ts +10 -0
- package/src/client/engine/types/n8ao.d.ts +52 -0
- package/src/client/engine/ui/BootSettings.ts +97 -0
- package/src/client/engine/ui/BossBar.ts +141 -0
- package/src/client/engine/ui/Combat.ts +299 -0
- package/src/client/engine/ui/DeathFade.ts +104 -0
- package/src/client/engine/ui/DebugMenu.ts +199 -0
- package/src/client/engine/ui/EliteBar.ts +219 -0
- package/src/client/engine/ui/ErrorModal.ts +309 -0
- package/src/client/engine/ui/Feedback.ts +346 -0
- package/src/client/engine/ui/FirstHints.ts +279 -0
- package/src/client/engine/ui/HUD.ts +714 -0
- package/src/client/engine/ui/HurtArc.ts +102 -0
- package/src/client/engine/ui/ItemCard.ts +95 -0
- package/src/client/engine/ui/KeyHelp.ts +59 -0
- package/src/client/engine/ui/Loading.ts +851 -0
- package/src/client/engine/ui/LockOn.ts +131 -0
- package/src/client/engine/ui/Map.ts +280 -0
- package/src/client/engine/ui/Menu.ts +438 -0
- package/src/client/engine/ui/Minimap.ts +840 -0
- package/src/client/engine/ui/Perf.ts +356 -0
- package/src/client/engine/ui/ReloadPrompt.ts +42 -0
- package/src/client/engine/ui/RotateGate.ts +40 -0
- package/src/client/engine/ui/SavePanel.ts +62 -0
- package/src/client/engine/ui/Settings.ts +277 -0
- package/src/client/engine/ui/SpeedLines.ts +46 -0
- package/src/client/engine/ui/StartTitle.ts +39 -0
- package/src/client/engine/ui/ToastStack.ts +90 -0
- package/src/client/engine/ui/Update.ts +116 -0
- package/src/client/engine/ui/WeaponStrip.ts +272 -0
- package/src/client/engine/ui/WindupWarn.ts +116 -0
- package/src/client/engine/ui/authoredDebugRows.ts +3 -0
- package/src/client/engine/ui/buildCheck.ts +72 -0
- package/src/client/engine/ui/buildRow.ts +71 -0
- package/src/client/engine/ui/cards.ts +41 -0
- package/src/client/engine/ui/debugOptions.ts +230 -0
- package/src/client/engine/ui/declared.ts +89 -0
- package/src/client/engine/ui/devSwitch.ts +48 -0
- package/src/client/engine/ui/developerBanner.ts +32 -0
- package/src/client/engine/ui/diagnosticsCopy.ts +20 -0
- package/src/client/engine/ui/drawBudgetCounter.ts +10 -0
- package/src/client/engine/ui/errorScreen.ts +109 -0
- package/src/client/engine/ui/frameWindow.ts +50 -0
- package/src/client/engine/ui/graphicsBlock.ts +156 -0
- package/src/client/engine/ui/graphicsControls.ts +47 -0
- package/src/client/engine/ui/haptics.ts +28 -0
- package/src/client/engine/ui/hoverBoost.ts +61 -0
- package/src/client/engine/ui/hudAdapters.ts +61 -0
- package/src/client/engine/ui/hudSlots.ts +130 -0
- package/src/client/engine/ui/icons.ts +62 -0
- package/src/client/engine/ui/layers.ts +134 -0
- package/src/client/engine/ui/leaveGuard.ts +64 -0
- package/src/client/engine/ui/loadProgress.ts +67 -0
- package/src/client/engine/ui/loading.css +125 -0
- package/src/client/engine/ui/lookLightOption.ts +22 -0
- package/src/client/engine/ui/mapLabel.ts +18 -0
- package/src/client/engine/ui/mapPainter.ts +395 -0
- package/src/client/engine/ui/menuSettings.ts +188 -0
- package/src/client/engine/ui/namePrompt.ts +138 -0
- package/src/client/engine/ui/offlineDownload.ts +83 -0
- package/src/client/engine/ui/ownership.ts +14 -0
- package/src/client/engine/ui/panel.ts +166 -0
- package/src/client/engine/ui/perf.css +93 -0
- package/src/client/engine/ui/perfDock.ts +61 -0
- package/src/client/engine/ui/perfHud.ts +332 -0
- package/src/client/engine/ui/perfLap.ts +206 -0
- package/src/client/engine/ui/perfLapSummary.ts +92 -0
- package/src/client/engine/ui/perfProbe.ts +280 -0
- package/src/client/engine/ui/pinKeepOut.ts +59 -0
- package/src/client/engine/ui/playerDeath.ts +16 -0
- package/src/client/engine/ui/playerHurt.ts +70 -0
- package/src/client/engine/ui/playerReload.ts +55 -0
- package/src/client/engine/ui/reloadChip.ts +24 -0
- package/src/client/engine/ui/reloadCover.ts +110 -0
- package/src/client/engine/ui/review.ts +158 -0
- package/src/client/engine/ui/roomMap.ts +109 -0
- package/src/client/engine/ui/saveStrings.ts +9 -0
- package/src/client/engine/ui/settingsTabs.ts +249 -0
- package/src/client/engine/ui/styles/base.css +92 -0
- package/src/client/engine/ui/styles/boss.css +97 -0
- package/src/client/engine/ui/styles/combat.css +100 -0
- package/src/client/engine/ui/styles/debug.css +22 -0
- package/src/client/engine/ui/styles/elite.css +87 -0
- package/src/client/engine/ui/styles/explore.css +435 -0
- package/src/client/engine/ui/styles/feedback.css +63 -0
- package/src/client/engine/ui/styles/game.css +290 -0
- package/src/client/engine/ui/styles/gmenu.css +407 -0
- package/src/client/engine/ui/styles/hints.css +26 -0
- package/src/client/engine/ui/styles/itemcard.css +38 -0
- package/src/client/engine/ui/styles/menu.css +129 -0
- package/src/client/engine/ui/styles/minimap.css +87 -0
- package/src/client/engine/ui/styles/namePrompt.css +27 -0
- package/src/client/engine/ui/styles/playgrounds.css +18 -0
- package/src/client/engine/ui/styles/quest.css +65 -0
- package/src/client/engine/ui/styles/rotate.css +55 -0
- package/src/client/engine/ui/styles/touch.css +303 -0
- package/src/client/engine/ui/styles/update.css +27 -0
- package/src/client/engine/ui/tabs.ts +27 -0
- package/src/client/engine/ui/unstuck.ts +38 -0
- package/src/client/engine/ui/voiceSettings.ts +135 -0
- package/src/client/engine/world/Atmosphere.ts +333 -0
- package/src/client/engine/world/BakedSky.ts +155 -0
- package/src/client/engine/world/Boundary.ts +234 -0
- package/src/client/engine/world/Grass.ts +664 -0
- package/src/client/engine/world/Horizon.ts +237 -0
- package/src/client/engine/world/HorizonMatte.ts +399 -0
- package/src/client/engine/world/Terrain.ts +560 -0
- package/src/client/engine/world/TreeFactory.ts +128 -0
- package/src/client/engine/world/backdropLayer.ts +580 -0
- package/src/client/engine/world/blenderArea.ts +23 -0
- package/src/client/engine/world/bounds.ts +57 -0
- package/src/client/engine/world/cascadeCull.ts +251 -0
- package/src/client/engine/world/cascadeLights.ts +29 -0
- package/src/client/engine/world/cloudField.ts +29 -0
- package/src/client/engine/world/coarseTileMask.ts +100 -0
- package/src/client/engine/world/csmLightBlock.ts +23 -0
- package/src/client/engine/world/declaredProps.ts +226 -0
- package/src/client/engine/world/forest/Forest.ts +378 -0
- package/src/client/engine/world/forest/treeSet.ts +140 -0
- package/src/client/engine/world/forest/treeSpecies.ts +17 -0
- package/src/client/engine/world/frameCamera.ts +58 -0
- package/src/client/engine/world/geometryBake.ts +272 -0
- package/src/client/engine/world/geometryBounds.ts +77 -0
- package/src/client/engine/world/geometryKit.ts +163 -0
- package/src/client/engine/world/hiddenFaces.ts +153 -0
- package/src/client/engine/world/interact/Interactables.ts +690 -0
- package/src/client/engine/world/interact/kit.ts +6 -0
- package/src/client/engine/world/lookFlags.ts +15 -0
- package/src/client/engine/world/lowpolyKit.ts +270 -0
- package/src/client/engine/world/lut.ts +45 -0
- package/src/client/engine/world/painterly.ts +109 -0
- package/src/client/engine/world/pointLightSkip.ts +31 -0
- package/src/client/engine/world/pond.ts +184 -0
- package/src/client/engine/world/pondGrid.ts +5 -0
- package/src/client/engine/world/registry.ts +348 -0
- package/src/client/engine/world/shadowCadence.ts +14 -0
- package/src/client/engine/world/shadowChunks.ts +193 -0
- package/src/client/engine/world/shadowFade.ts +190 -0
- package/src/client/engine/world/shadowFilter.ts +117 -0
- package/src/client/engine/world/shadowVariants.ts +115 -0
- package/src/client/engine/world/skyBackdrop.ts +526 -0
- package/src/client/engine/world/skyRig.ts +577 -0
- package/src/client/engine/world/skyTextures.ts +103 -0
- package/src/client/engine/world/terrainTileView.ts +164 -0
- package/src/client/engine/world/tileStreamer.ts +823 -0
- package/src/client/engine/world/voxelAO.ts +338 -0
- package/src/client/engine/world/water/ripplePixels.ts +51 -0
- package/src/client/engine/world/water/ripples.ts +102 -0
- package/src/client/engine/world/weakShaderMap.ts +58 -0
- package/src/client/engine/world/wind.ts +112 -0
- package/src/client/game/Boss.ts +354 -0
- package/src/client/game/Elite.ts +529 -0
- package/src/client/game/Inventory.ts +123 -0
- package/src/client/game/Progress.ts +166 -0
- package/src/client/game/ambient/ambientFlock.ts +71 -0
- package/src/client/game/ambient/crowdDraw.ts +85 -0
- package/src/client/game/ambient/foragerDraw.ts +56 -0
- package/src/client/game/ambient/pageCrowds.ts +81 -0
- package/src/client/game/ambient/wingField.ts +46 -0
- package/src/client/game/animation/limbCollision.ts +46 -0
- package/src/client/game/animation/limbQueryPose.ts +141 -0
- package/src/client/game/animation/limbQueryView.ts +53 -0
- package/src/client/game/animation/limbView.ts +28 -0
- package/src/client/game/audio/cueDirector.ts +157 -0
- package/src/client/game/audio/forestPage.ts +30 -0
- package/src/client/game/audio/sceneDirector.ts +239 -0
- package/src/client/game/audio/sceneEvents.merge.d.ts +9 -0
- package/src/client/game/audio/theme.ts +229 -0
- package/src/client/game/audio/voicePatches.ts +108 -0
- package/src/client/game/bag/BagButton.ts +85 -0
- package/src/client/game/bag/bag.ts +239 -0
- package/src/client/game/bag/equipment.ts +18 -0
- package/src/client/game/bag/tabs.ts +194 -0
- package/src/client/game/boot/audio.generated.ts +9258 -0
- package/src/client/game/boot/bytes.generated.ts +1643 -0
- package/src/client/game/boot/loadingPaths.ts +121 -0
- package/src/client/game/boot/packs.generated.ts +5 -0
- package/src/client/game/boot/spawnDownload.ts +999 -0
- package/src/client/game/boot/versions.generated.ts +868 -0
- package/src/client/game/boss/arenaFire.ts +135 -0
- package/src/client/game/boss/arenaRoom.ts +715 -0
- package/src/client/game/boss/arenaRoomView.ts +530 -0
- package/src/client/game/boss/barFeed.ts +253 -0
- package/src/client/game/boss/encounterView.ts +463 -0
- package/src/client/game/boss/presentation.ts +18 -0
- package/src/client/game/boss/roamingProjection.ts +255 -0
- package/src/client/game/boss/slotRowsView.ts +95 -0
- package/src/client/game/boss/socketRig.ts +129 -0
- package/src/client/game/boss/timedEncounters.ts +83 -0
- package/src/client/game/combat/roamingSession.ts +107 -0
- package/src/client/game/compendium/Journal.ts +85 -0
- package/src/client/game/compendium/compendium.css +135 -0
- package/src/client/game/compendium/install.ts +181 -0
- package/src/client/game/compendium/journalView.ts +224 -0
- package/src/client/game/compendium/keepsakes.ts +169 -0
- package/src/client/game/compendium/keepsakesView.ts +70 -0
- package/src/client/game/complete/ShardComplete.ts +148 -0
- package/src/client/game/complete/complete.css +71 -0
- package/src/client/game/complete/declared.ts +111 -0
- package/src/client/game/cosmetics/bodyShadow.ts +148 -0
- package/src/client/game/cosmetics/cosmetics.ts +119 -0
- package/src/client/game/cosmetics/locker.ts +88 -0
- package/src/client/game/data/pickupCatalogue.json +1008 -0
- package/src/client/game/debug/browser.d.ts +10 -0
- package/src/client/game/draftTitles.ts +26 -0
- package/src/client/game/eliteView.ts +246 -0
- package/src/client/game/engineStrings.ts +12 -0
- package/src/client/game/equipmentTypes.merge.d.ts +10 -0
- package/src/client/game/firstPlay.css +18 -0
- package/src/client/game/firstPlay.ts +94 -0
- package/src/client/game/generators/pickups.ts +92 -0
- package/src/client/game/grapple/fontPreparation.ts +31 -0
- package/src/client/game/grapple/netClaw.ts +61 -0
- package/src/client/game/grapple/ribbon.ts +159 -0
- package/src/client/game/grapple/tool.ts +478 -0
- package/src/client/game/grid/admissionPriority.ts +41 -0
- package/src/client/game/grid/admissionYield.ts +37 -0
- package/src/client/game/grid/approachProductInputs.ts +72 -0
- package/src/client/game/grid/assetResidency.ts +188 -0
- package/src/client/game/grid/borderShimmer.ts +185 -0
- package/src/client/game/grid/budgetOverlay.css +40 -0
- package/src/client/game/grid/budgetOverlay.ts +238 -0
- package/src/client/game/grid/budgetPoints.ts +184 -0
- package/src/client/game/grid/cellChanges.ts +106 -0
- package/src/client/game/grid/cellClip.ts +611 -0
- package/src/client/game/grid/cellCover.ts +58 -0
- package/src/client/game/grid/cellLoading.ts +89 -0
- package/src/client/game/grid/cellPresence.ts +28 -0
- package/src/client/game/grid/cellScreens.ts +83 -0
- package/src/client/game/grid/copyIdentity.ts +98 -0
- package/src/client/game/grid/copyLayout.ts +153 -0
- package/src/client/game/grid/copyPrompts.ts +31 -0
- package/src/client/game/grid/edgeSources.ts +120 -0
- package/src/client/game/grid/enteredEquipment.ts +65 -0
- package/src/client/game/grid/enteredInteract.ts +43 -0
- package/src/client/game/grid/entryDownloads.ts +45 -0
- package/src/client/game/grid/entryReadPrefetch.ts +64 -0
- package/src/client/game/grid/farImpostorDecodeWorker.ts +32 -0
- package/src/client/game/grid/farImpostorPack.ts +18 -0
- package/src/client/game/grid/farImpostorView.ts +130 -0
- package/src/client/game/grid/farView.ts +235 -0
- package/src/client/game/grid/frame.ts +845 -0
- package/src/client/game/grid/frameLook.ts +215 -0
- package/src/client/game/grid/frameModel.ts +126 -0
- package/src/client/game/grid/gridHud.css +47 -0
- package/src/client/game/grid/gridHud.ts +126 -0
- package/src/client/game/grid/hazeBand.ts +77 -0
- package/src/client/game/grid/homeCheckpoint.ts +11 -0
- package/src/client/game/grid/homeMetadata.ts +40 -0
- package/src/client/game/grid/intent.ts +65 -0
- package/src/client/game/grid/live.ts +787 -0
- package/src/client/game/grid/liveSession.ts +969 -0
- package/src/client/game/grid/loadingRings.ts +49 -0
- package/src/client/game/grid/mapAtlas.build.d.ts +4 -0
- package/src/client/game/grid/mapAtlas.ts +33 -0
- package/src/client/game/grid/mapFrame.ts +81 -0
- package/src/client/game/grid/memoryRows.ts +32 -0
- package/src/client/game/grid/memoryWarning.css +11 -0
- package/src/client/game/grid/memoryWarning.ts +81 -0
- package/src/client/game/grid/menu.ts +49 -0
- package/src/client/game/grid/minimapBlend.ts +185 -0
- package/src/client/game/grid/nearGrain.ts +40 -0
- package/src/client/game/grid/nearPlaceholderPlan.ts +60 -0
- package/src/client/game/grid/nearPlaceholderView.ts +182 -0
- package/src/client/game/grid/neighbourLife.ts +151 -0
- package/src/client/game/grid/neighbourPanels.ts +84 -0
- package/src/client/game/grid/neighbourRows.ts +32 -0
- package/src/client/game/grid/oneWayIn.ts +114 -0
- package/src/client/game/grid/pageEntry.ts +234 -0
- package/src/client/game/grid/pageResidency.ts +216 -0
- package/src/client/game/grid/pageShell.ts +67 -0
- package/src/client/game/grid/prefetch.ts +344 -0
- package/src/client/game/grid/prefetchIndex.ts +28 -0
- package/src/client/game/grid/prefetchIndexCore.ts +41 -0
- package/src/client/game/grid/prelinkViews.ts +31 -0
- package/src/client/game/grid/preparationAdmission.ts +34 -0
- package/src/client/game/grid/productInputs.ts +98 -0
- package/src/client/game/grid/productLeases.ts +76 -0
- package/src/client/game/grid/products.ts +350 -0
- package/src/client/game/grid/refusal.ts +73 -0
- package/src/client/game/grid/regionLight.ts +102 -0
- package/src/client/game/grid/regionShell.ts +58 -0
- package/src/client/game/grid/regionSky.ts +104 -0
- package/src/client/game/grid/regionalBuildCheckpoint.ts +19 -0
- package/src/client/game/grid/regionalInputs.ts +34 -0
- package/src/client/game/grid/regionalRuntime.ts +518 -0
- package/src/client/game/grid/regionalView.ts +205 -0
- package/src/client/game/grid/regionalWorld.ts +609 -0
- package/src/client/game/grid/renderResidency.ts +95 -0
- package/src/client/game/grid/reveal.ts +163 -0
- package/src/client/game/grid/roadCull.ts +473 -0
- package/src/client/game/grid/roadGrain.ts +32 -0
- package/src/client/game/grid/roadGrain.worker.ts +20 -0
- package/src/client/game/grid/roadGrainPreparation.ts +45 -0
- package/src/client/game/grid/roadLook.ts +487 -0
- package/src/client/game/grid/roadLookPlatform.ts +196 -0
- package/src/client/game/grid/roadResources.ts +15 -0
- package/src/client/game/grid/roadSign.worker.ts +30 -0
- package/src/client/game/grid/roadSignPaint.ts +38 -0
- package/src/client/game/grid/roadSignPixels.ts +22 -0
- package/src/client/game/grid/roadSignPreparation.ts +45 -0
- package/src/client/game/grid/roadSky.ts +219 -0
- package/src/client/game/grid/roadSolid.ts +227 -0
- package/src/client/game/grid/roadTileArchive.ts +239 -0
- package/src/client/game/grid/roadTileBacking.ts +327 -0
- package/src/client/game/grid/roadTileCapture.worker.ts +14 -0
- package/src/client/game/grid/roadTileCaptureJob.ts +37 -0
- package/src/client/game/grid/roadTileCaptureWorker.ts +104 -0
- package/src/client/game/grid/roadTileCoarse.ts +28 -0
- package/src/client/game/grid/roadTileGeometry.ts +77 -0
- package/src/client/game/grid/roadTilePool.ts +157 -0
- package/src/client/game/grid/roadTileStream.ts +69 -0
- package/src/client/game/grid/roadTileWrite.worker.ts +24 -0
- package/src/client/game/grid/roadTileWriter.ts +67 -0
- package/src/client/game/grid/runtimeCost.ts +44 -0
- package/src/client/game/grid/seamLook.ts +177 -0
- package/src/client/game/grid/session.ts +1235 -0
- package/src/client/game/grid/shardfileFar.ts +88 -0
- package/src/client/game/grid/skinEnvelope.ts +135 -0
- package/src/client/game/grid/softWallLook.ts +116 -0
- package/src/client/game/grid/tileDecodeWorker.ts +24 -0
- package/src/client/game/grid/tileDecoder.ts +102 -0
- package/src/client/game/grid/titleOrder.ts +8 -0
- package/src/client/game/grid/titlePrefetchChoice.ts +35 -0
- package/src/client/game/grid/viewAdmissions.ts +36 -0
- package/src/client/game/grid/voidLook.ts +181 -0
- package/src/client/game/icons.merge.d.ts +49 -0
- package/src/client/game/icons.ts +240 -0
- package/src/client/game/identity.ts +28 -0
- package/src/client/game/inputContexts.ts +33 -0
- package/src/client/game/keyBindings.ts +37 -0
- package/src/client/game/loadout/actors.ts +15 -0
- package/src/client/game/loadout/claims.ts +728 -0
- package/src/client/game/loadout/cosmeticFinishes.ts +217 -0
- package/src/client/game/loadout/effects.ts +97 -0
- package/src/client/game/loadout/finishes.ts +60 -0
- package/src/client/game/loadout/held.ts +207 -0
- package/src/client/game/loadout/rangedPage.ts +142 -0
- package/src/client/game/looks/coverAppearance.ts +101 -0
- package/src/client/game/looks/daySky.ts +110 -0
- package/src/client/game/looks/forestGround.ts +49 -0
- package/src/client/game/looks/forestGroundInputs.ts +27 -0
- package/src/client/game/looks/forestRoofMask.ts +15 -0
- package/src/client/game/looks/forestWeather.ts +26 -0
- package/src/client/game/looks/graphDaySky.ts +245 -0
- package/src/client/game/looks/grassPresentation.ts +334 -0
- package/src/client/game/looks/keyedSky.ts +500 -0
- package/src/client/game/looks/lettering.ts +14 -0
- package/src/client/game/looks/overcast.ts +61 -0
- package/src/client/game/looks/paintedGroundMerge.ts +12 -0
- package/src/client/game/looks/paintedLook.ts +197 -0
- package/src/client/game/looks/painterlyLook.ts +259 -0
- package/src/client/game/looks/posedBufferPool.ts +67 -0
- package/src/client/game/looks/posedInstances.ts +199 -0
- package/src/client/game/looks/postGraphLook.ts +455 -0
- package/src/client/game/looks/riggedHulls.ts +451 -0
- package/src/client/game/looks/scaledPost.ts +236 -0
- package/src/client/game/looks/speciesBook.ts +224 -0
- package/src/client/game/looks/staticCapture.ts +225 -0
- package/src/client/game/looks/streamedCover.ts +330 -0
- package/src/client/game/looks/toonLighting.ts +28 -0
- package/src/client/game/looks/toonLook.ts +69 -0
- package/src/client/game/looks/toonSky.ts +60 -0
- package/src/client/game/looks/vertexWear.ts +49 -0
- package/src/client/game/loot/CoinBurst.ts +19 -0
- package/src/client/game/loot/CoinMotion.ts +169 -0
- package/src/client/game/loot/coinModel.ts +11 -0
- package/src/client/game/loot/coins.ts +21 -0
- package/src/client/game/loot/feed.ts +23 -0
- package/src/client/game/loot/loot.css +19 -0
- package/src/client/game/loot/runtime.ts +243 -0
- package/src/client/game/loot/tables.ts +30 -0
- package/src/client/game/loot/ui/CoinChip.ts +70 -0
- package/src/client/game/loot/ui/ShopPanel.ts +211 -0
- package/src/client/game/loot/ui/shop.css +42 -0
- package/src/client/game/mainMenu.css +177 -0
- package/src/client/game/mainMenu.ts +268 -0
- package/src/client/game/models/binarySource.ts +78 -0
- package/src/client/game/models/collectionDisplay.ts +133 -0
- package/src/client/game/models/collectionWall.ts +236 -0
- package/src/client/game/models/explorerCatalogue.ts +176 -0
- package/src/client/game/models/figureCatalogue.ts +172 -0
- package/src/client/game/models/fixedDraws.ts +178 -0
- package/src/client/game/models/heldGear.ts +76 -0
- package/src/client/game/models/interact.ts +107 -0
- package/src/client/game/models/islandLibrary.ts +179 -0
- package/src/client/game/models/kitFigureCard.ts +77 -0
- package/src/client/game/models/libraryModel.ts +67 -0
- package/src/client/game/models/mountedSpecimen.ts +45 -0
- package/src/client/game/models/pickupRows.ts +12 -0
- package/src/client/game/models/ropeDeckSite.ts +114 -0
- package/src/client/game/models/scenePartSpecimen.ts +102 -0
- package/src/client/game/models/sceneSpecimens.ts +103 -0
- package/src/client/game/models/socketRigCreature.ts +65 -0
- package/src/client/game/models/specimenCatalogue.ts +540 -0
- package/src/client/game/models/treeSet.ts +149 -0
- package/src/client/game/models/worldSceneCatalogue.ts +310 -0
- package/src/client/game/nativeItems.merge.d.ts +6 -0
- package/src/client/game/pageSaveKeys.ts +13 -0
- package/src/client/game/plugin/audio.ts +277 -0
- package/src/client/game/plugin/bakedGeometry.ts +103 -0
- package/src/client/game/plugin/bladeMoves.ts +117 -0
- package/src/client/game/plugin/bossStorm.ts +40 -0
- package/src/client/game/plugin/clientChannelView.ts +135 -0
- package/src/client/game/plugin/context.ts +198 -0
- package/src/client/game/plugin/followedMovers.ts +184 -0
- package/src/client/game/plugin/geometry.ts +2083 -0
- package/src/client/game/plugin/headless.ts +127 -0
- package/src/client/game/plugin/heldEquipment.ts +208 -0
- package/src/client/game/plugin/heldFirearm.ts +395 -0
- package/src/client/game/plugin/heldRecipe.ts +43 -0
- package/src/client/game/plugin/heldTool.ts +166 -0
- package/src/client/game/plugin/moverEvents.merge.d.ts +6 -0
- package/src/client/game/plugin/moverViews.ts +114 -0
- package/src/client/game/plugin/placeholderGeometry.ts +40 -0
- package/src/client/game/plugin/scene.ts +290 -0
- package/src/client/game/plugin/shaderFamily.ts +225 -0
- package/src/client/game/plugin/ui.ts +1511 -0
- package/src/client/game/plugin/weaponFamily.ts +779 -0
- package/src/client/game/population/netCounts.ts +12 -0
- package/src/client/game/population/pageAir.ts +37 -0
- package/src/client/game/population/pageLife.ts +289 -0
- package/src/client/game/population/pageReturns.ts +17 -0
- package/src/client/game/population/productCreatures.ts +71 -0
- package/src/client/game/population/projection.ts +227 -0
- package/src/client/game/population/rowSpecies.ts +15 -0
- package/src/client/game/population/signals.ts +24 -0
- package/src/client/game/population/speciesViewSlots.ts +55 -0
- package/src/client/game/population/wildlifeFeature.ts +208 -0
- package/src/client/game/population.merge.d.ts +9 -0
- package/src/client/game/practice/course.ts +154 -0
- package/src/client/game/practice/numericCourse.ts +35 -0
- package/src/client/game/practice/registration.ts +17 -0
- package/src/client/game/practice/scene.ts +47 -0
- package/src/client/game/quest/carriedProp.ts +113 -0
- package/src/client/game/quest/chapter.ts +355 -0
- package/src/client/game/quest/chapterDirector.ts +255 -0
- package/src/client/game/quest/chapterView.ts +165 -0
- package/src/client/game/quest/continuation.ts +53 -0
- package/src/client/game/quest/contractBoardPage.ts +85 -0
- package/src/client/game/quest/declaredPage.ts +199 -0
- package/src/client/game/quest/elitePage.ts +115 -0
- package/src/client/game/quest/figureOrbit.ts +32 -0
- package/src/client/game/quest/figures.ts +259 -0
- package/src/client/game/quest/finishedAfterSeen.ts +20 -0
- package/src/client/game/quest/hints.ts +90 -0
- package/src/client/game/quest/pageComposition.ts +331 -0
- package/src/client/game/quest/pageDoors.ts +25 -0
- package/src/client/game/quest/pageFacets.ts +76 -0
- package/src/client/game/quest/pageReference.ts +17 -0
- package/src/client/game/quest/presentation.css +4 -0
- package/src/client/game/quest/questPageViews.ts +168 -0
- package/src/client/game/quest/reward.ts +48 -0
- package/src/client/game/quest/story.ts +161 -0
- package/src/client/game/quest/trader.ts +176 -0
- package/src/client/game/riding/client.ts +373 -0
- package/src/client/game/riding/hud.ts +255 -0
- package/src/client/game/riding/mount.ts +317 -0
- package/src/client/game/riding/reins.ts +177 -0
- package/src/client/game/riding/ride.css +70 -0
- package/src/client/game/riding/seatedFigure.ts +78 -0
- package/src/client/game/saves.css +34 -0
- package/src/client/game/savesSettings.ts +189 -0
- package/src/client/game/session/clockSettings.ts +66 -0
- package/src/client/game/session/context.ts +61 -0
- package/src/client/game/session/crashResume.ts +36 -0
- package/src/client/game/session/data.ts +101 -0
- package/src/client/game/session/entryReadiness.ts +13 -0
- package/src/client/game/session/exitToTitle.ts +19 -0
- package/src/client/game/session/finish.ts +414 -0
- package/src/client/game/session/hudAccent.ts +30 -0
- package/src/client/game/session/loadout.ts +176 -0
- package/src/client/game/session/play.ts +824 -0
- package/src/client/game/session/positions.ts +8 -0
- package/src/client/game/session/readyFrame.ts +10 -0
- package/src/client/game/session/session.ts +193 -0
- package/src/client/game/session/settlePrograms.ts +29 -0
- package/src/client/game/session/titlePreparation.ts +43 -0
- package/src/client/game/session/world.ts +168 -0
- package/src/client/game/shard/declaredEntry.ts +44 -0
- package/src/client/game/shard/declaredPlumbing.ts +80 -0
- package/src/client/game/shard/declaredTargets.ts +64 -0
- package/src/client/game/shard/declaredUi.ts +23 -0
- package/src/client/game/shard/discovery.ts +80 -0
- package/src/client/game/shard/list.ts +26 -0
- package/src/client/game/shard/load.ts +94 -0
- package/src/client/game/shard/manifest.ts +910 -0
- package/src/client/game/shard/pageBoot.ts +52 -0
- package/src/client/game/shard/pagePolicy.ts +17 -0
- package/src/client/game/shard/registry.ts +74 -0
- package/src/client/game/shard/retainedHooks.ts +204 -0
- package/src/client/game/shard/scopedRuntime.ts +68 -0
- package/src/client/game/shard/spec.ts +69 -0
- package/src/client/game/shard/titleList.ts +86 -0
- package/src/client/game/shardfile/accent.ts +5 -0
- package/src/client/game/shardfile/assetCache.ts +46 -0
- package/src/client/game/shardfile/audioCatalogue.ts +16 -0
- package/src/client/game/shardfile/bakedKinds.ts +313 -0
- package/src/client/game/shardfile/bakedTiles.ts +253 -0
- package/src/client/game/shardfile/buildingCloud.ts +27 -0
- package/src/client/game/shardfile/calibrationScripts.ts +30 -0
- package/src/client/game/shardfile/caveInterior.ts +162 -0
- package/src/client/game/shardfile/client.ts +671 -0
- package/src/client/game/shardfile/clientAmbientLife.ts +31 -0
- package/src/client/game/shardfile/clientAssets.ts +163 -0
- package/src/client/game/shardfile/clientBossFight.ts +39 -0
- package/src/client/game/shardfile/clientBossTelegraph.ts +43 -0
- package/src/client/game/shardfile/clientCatalogue.ts +44 -0
- package/src/client/game/shardfile/clientCosmeticFinishes.ts +37 -0
- package/src/client/game/shardfile/clientCues.ts +22 -0
- package/src/client/game/shardfile/clientEliteConstruction.ts +44 -0
- package/src/client/game/shardfile/clientEliteEntry.ts +33 -0
- package/src/client/game/shardfile/clientEntryBinds.ts +32 -0
- package/src/client/game/shardfile/clientFinds.ts +20 -0
- package/src/client/game/shardfile/clientForestPage.ts +144 -0
- package/src/client/game/shardfile/clientGraphs.ts +319 -0
- package/src/client/game/shardfile/clientHeldMelee.ts +82 -0
- package/src/client/game/shardfile/clientItems.ts +25 -0
- package/src/client/game/shardfile/clientLibrary.ts +71 -0
- package/src/client/game/shardfile/clientMaterials.ts +296 -0
- package/src/client/game/shardfile/clientMeadow.ts +30 -0
- package/src/client/game/shardfile/clientModules.ts +24 -0
- package/src/client/game/shardfile/clientMoverOwners.ts +80 -0
- package/src/client/game/shardfile/clientNativeBook.ts +38 -0
- package/src/client/game/shardfile/clientPlaceSets.ts +74 -0
- package/src/client/game/shardfile/clientPlan.ts +529 -0
- package/src/client/game/shardfile/clientPlayerEnter.ts +22 -0
- package/src/client/game/shardfile/clientPopulation.ts +49 -0
- package/src/client/game/shardfile/clientPopulationProjection.ts +28 -0
- package/src/client/game/shardfile/clientPost.ts +94 -0
- package/src/client/game/shardfile/clientPropMaterials.ts +100 -0
- package/src/client/game/shardfile/clientQuestComposition.ts +87 -0
- package/src/client/game/shardfile/clientQuestPage.ts +98 -0
- package/src/client/game/shardfile/clientRecipes.ts +76 -0
- package/src/client/game/shardfile/clientResidency.ts +29 -0
- package/src/client/game/shardfile/clientReturnModules.ts +25 -0
- package/src/client/game/shardfile/clientRuntimeHooks.ts +66 -0
- package/src/client/game/shardfile/clientSceneHandles.ts +19 -0
- package/src/client/game/shardfile/clientScripts.ts +100 -0
- package/src/client/game/shardfile/clientSkins.ts +183 -0
- package/src/client/game/shardfile/clientSource.ts +221 -0
- package/src/client/game/shardfile/clientSpeciesProgram.ts +45 -0
- package/src/client/game/shardfile/clientSplatTerrain.ts +99 -0
- package/src/client/game/shardfile/clientStealthEntry.ts +72 -0
- package/src/client/game/shardfile/clientTargets.ts +73 -0
- package/src/client/game/shardfile/clientTimedEncounters.ts +42 -0
- package/src/client/game/shardfile/clientTrails.ts +42 -0
- package/src/client/game/shardfile/clientViewProgram.ts +101 -0
- package/src/client/game/shardfile/clientViews.ts +211 -0
- package/src/client/game/shardfile/clientWater.ts +108 -0
- package/src/client/game/shardfile/clientWaterSurfaces.ts +88 -0
- package/src/client/game/shardfile/clientWorker.ts +621 -0
- package/src/client/game/shardfile/clientWorldAssembly.ts +129 -0
- package/src/client/game/shardfile/constructionCheckpoint.ts +31 -0
- package/src/client/game/shardfile/controlFiles.ts +41 -0
- package/src/client/game/shardfile/controlRefinement.ts +229 -0
- package/src/client/game/shardfile/declaredTalks.ts +114 -0
- package/src/client/game/shardfile/emptyEquipment.ts +19 -0
- package/src/client/game/shardfile/emptyLook.ts +26 -0
- package/src/client/game/shardfile/enteredTileReadout.ts +27 -0
- package/src/client/game/shardfile/entryTransport.ts +222 -0
- package/src/client/game/shardfile/farStandIn.ts +79 -0
- package/src/client/game/shardfile/forestPage.ts +289 -0
- package/src/client/game/shardfile/groundMerge.ts +232 -0
- package/src/client/game/shardfile/heldClaimsEntry.ts +34 -0
- package/src/client/game/shardfile/homeBuildCache.ts +114 -0
- package/src/client/game/shardfile/homeGeometrySnapshot.ts +92 -0
- package/src/client/game/shardfile/hybrid.ts +537 -0
- package/src/client/game/shardfile/hybridPresentation.ts +16 -0
- package/src/client/game/shardfile/islandBook.ts +87 -0
- package/src/client/game/shardfile/itemModels.ts +78 -0
- package/src/client/game/shardfile/legacyAsset.ts +30 -0
- package/src/client/game/shardfile/lentLooks.ts +210 -0
- package/src/client/game/shardfile/lightEmitters.ts +100 -0
- package/src/client/game/shardfile/livingBuildings.ts +202 -0
- package/src/client/game/shardfile/look.ts +23 -0
- package/src/client/game/shardfile/mapImage.ts +49 -0
- package/src/client/game/shardfile/pageItems.ts +57 -0
- package/src/client/game/shardfile/pagePreparation.ts +40 -0
- package/src/client/game/shardfile/pageWater.ts +29 -0
- package/src/client/game/shardfile/paintedWorldStages.ts +132 -0
- package/src/client/game/shardfile/portalRideBinding.ts +62 -0
- package/src/client/game/shardfile/preparationReads.ts +61 -0
- package/src/client/game/shardfile/preparationTiming.ts +115 -0
- package/src/client/game/shardfile/presentation.ts +36 -0
- package/src/client/game/shardfile/product.ts +718 -0
- package/src/client/game/shardfile/productCacheCompletion.ts +53 -0
- package/src/client/game/shardfile/productChecks.ts +40 -0
- package/src/client/game/shardfile/productCost.ts +422 -0
- package/src/client/game/shardfile/productGround.ts +60 -0
- package/src/client/game/shardfile/productNavigation.ts +18 -0
- package/src/client/game/shardfile/productPreflight.ts +12 -0
- package/src/client/game/shardfile/questWorld.ts +17 -0
- package/src/client/game/shardfile/readAsset.ts +44 -0
- package/src/client/game/shardfile/reusableWholeLibrary.ts +102 -0
- package/src/client/game/shardfile/runtimeProduct.ts +396 -0
- package/src/client/game/shardfile/sceneBakeFiles.ts +22 -0
- package/src/client/game/shardfile/sceneBuffers.ts +207 -0
- package/src/client/game/shardfile/sceneDraws.ts +90 -0
- package/src/client/game/shardfile/sceneDressing.ts +456 -0
- package/src/client/game/shardfile/sceneHandles.ts +170 -0
- package/src/client/game/shardfile/sceneInputs.ts +21 -0
- package/src/client/game/shardfile/sceneInstances.ts +67 -0
- package/src/client/game/shardfile/sceneMotion.ts +161 -0
- package/src/client/game/shardfile/scenePools.ts +40 -0
- package/src/client/game/shardfile/sceneProfile.ts +12 -0
- package/src/client/game/shardfile/sceneRigFiles.ts +30 -0
- package/src/client/game/shardfile/sceneScatterPages.ts +47 -0
- package/src/client/game/shardfile/sceneSources.ts +153 -0
- package/src/client/game/shardfile/serverRoute.ts +38 -0
- package/src/client/game/shardfile/skinLayerPlayback.ts +67 -0
- package/src/client/game/shardfile/skinPlayback.ts +138 -0
- package/src/client/game/shardfile/slabLibrary.ts +203 -0
- package/src/client/game/shardfile/stillImage.ts +19 -0
- package/src/client/game/shardfile/streamingView.ts +78 -0
- package/src/client/game/shardfile/tileBufferedDraws.ts +49 -0
- package/src/client/game/shardfile/tileContent.ts +564 -0
- package/src/client/game/shardfile/tileDriver.ts +462 -0
- package/src/client/game/shardfile/tileEntry.ts +18 -0
- package/src/client/game/shardfile/tiledMesh.ts +146 -0
- package/src/client/game/shardfile/water.ts +8 -0
- package/src/client/game/shardfile/weatherFields.ts +31 -0
- package/src/client/game/shardfile/wholeGeometryPieces.ts +101 -0
- package/src/client/game/shardfile/wholeLibrary.ts +47 -0
- package/src/client/game/shardfile/wholeRefinementCover.ts +78 -0
- package/src/client/game/shardfile/wirePage.ts +260 -0
- package/src/client/game/shardfile/worldAssembly.ts +531 -0
- package/src/client/game/shardfile/worldBuildYield.ts +10 -0
- package/src/client/game/shardfile/worldEntry.ts +117 -0
- package/src/client/game/shardfile/worldSceneBatch.ts +105 -0
- package/src/client/game/shardfile/worldSceneGeometry.ts +171 -0
- package/src/client/game/shardfile/worldSceneMaterials.ts +90 -0
- package/src/client/game/shardfile/worldScenePlacement.ts +364 -0
- package/src/client/game/shardfile/worldScenePlacementPages.ts +61 -0
- package/src/client/game/shardfile/worldSceneReads.ts +83 -0
- package/src/client/game/shardfile/worldSceneStepSources.ts +69 -0
- package/src/client/game/shardfile/worldSceneSurface.ts +108 -0
- package/src/client/game/shardfile/worldSceneTextures.ts +134 -0
- package/src/client/game/shardfile/worldSceneUniforms.ts +17 -0
- package/src/client/game/shardfile/worldSceneWeld.ts +339 -0
- package/src/client/game/shardfile/worldScenes.ts +760 -0
- package/src/client/game/shardfile/worldUpdates.ts +149 -0
- package/src/client/game/stealth/controller.ts +115 -0
- package/src/client/game/stealth/stealth.css +70 -0
- package/src/client/game/summary.css +8 -0
- package/src/client/game/summary.ts +67 -0
- package/src/client/game/systems/audio/crossbowSounds.ts +71 -0
- package/src/client/game/systems/audio/firearmSounds.ts +43 -0
- package/src/client/game/systems/audio/meleeSounds.ts +40 -0
- package/src/client/game/systems/audio/silentScore.ts +6 -0
- package/src/client/game/systems/effects/starter.generated.ts +2 -0
- package/src/client/game/systems/effects/status.css +3 -0
- package/src/client/game/systems/effects/view.ts +35 -0
- package/src/client/game/systems/items/declaredSword.ts +149 -0
- package/src/client/game/systems/looks/fogProgram.ts +18 -0
- package/src/client/game/systems/looks/particles.ts +407 -0
- package/src/client/game/systems/looks/rainCurtain.ts +50 -0
- package/src/client/game/systems/looks/surfaceLooks.ts +138 -0
- package/src/client/game/systems/looks/trample.ts +139 -0
- package/src/client/game/systems/looks/waterSurface.ts +179 -0
- package/src/client/game/systems/npc/figureRows.ts +169 -0
- package/src/client/game/systems/npc/figureSkins.ts +130 -0
- package/src/client/game/systems/npc/kitFigure.ts +127 -0
- package/src/client/game/systems/npc/npcRig.ts +217 -0
- package/src/client/game/systems/npc/standingFigure.ts +111 -0
- package/src/client/game/systems/props/interact.ts +236 -0
- package/src/client/game/systems/species/bear.ts +30 -0
- package/src/client/game/systems/species/boar.ts +28 -0
- package/src/client/game/systems/species/install.ts +18 -0
- package/src/client/game/systems/species/view/bear.ts +246 -0
- package/src/client/game/systems/species/view/boar.ts +249 -0
- package/src/client/game/systems/tools/hoverboard.ts +107 -0
- package/src/client/game/systems/viewmodel/armAliases.json +24 -0
- package/src/client/game/systems/viewmodel/armClips.ts +8 -0
- package/src/client/game/systems/viewmodel/armRig.ts +293 -0
- package/src/client/game/systems/viewmodel/clips.generated.ts +2 -0
- package/src/client/game/systems/viewmodel/heldView.ts +458 -0
- package/src/client/game/systems/viewmodel/rigArms.ts +280 -0
- package/src/client/game/titleAssets.ts +9 -0
- package/src/client/game/titleDeck.ts +381 -0
- package/src/client/game/travel/travel.ts +99 -0
- package/src/client/game/ui/dataPanels.ts +95 -0
- package/src/client/game/ui/panelTemplates.ts +71 -0
- package/src/client/game/ui/panels.ts +109 -0
- package/src/client/game/upgrade.css +12 -0
- package/src/client/game/weapons/Bow.ts +14 -0
- package/src/client/game/weapons/Sword.ts +30 -0
- package/src/client/game/weapons/arcPower.ts +203 -0
- package/src/client/game/weapons/heldLauncher.ts +452 -0
- package/src/client/game/weapons/heldPolearm.ts +491 -0
- package/src/client/game/weapons/mountedBlade.ts +122 -0
- package/src/client/game/weather/forest.ts +281 -0
- package/src/client/game/weather/netClimate.ts +88 -0
- package/src/client/game/weather/pageSky.ts +31 -0
- package/src/client/game/weather/rainPresentation.ts +246 -0
- package/src/client/game/weather/weatherEvents.merge.d.ts +8 -0
- package/src/client/game/whatsNew.ts +31 -0
- package/src/client/game/whatsNewBanner.ts +125 -0
- package/src/client/host/online/chatCorner.ts +46 -0
- package/src/client/host/online/chatLines.ts +213 -0
- package/src/client/host/online/doctor.ts +321 -0
- package/src/client/host/online/doctorPage.ts +26 -0
- package/src/client/host/online/doctorView.ts +144 -0
- package/src/client/host/online/linkScreens.ts +300 -0
- package/src/client/host/online/reconnectStrip.ts +26 -0
- package/src/client/host/online/release.ts +28 -0
- package/src/client/host/online/shell.ts +312 -0
- package/src/client/host/online/voice.ts +468 -0
- package/src/client/host/online/voiceUi.ts +186 -0
- package/src/client/host/standalone/shell.ts +169 -0
- package/src/client/index.html +12 -0
- package/src/client/main.tsx +10 -0
- package/src/client/side.ts +2 -0
- package/src/client/tsconfig.json +13 -0
- package/src/cook/game/brotliSizeCache.d.mts +5 -0
- package/src/cook/game/brotliSizeCache.mjs +59 -0
- package/src/cook/game/contentNamed.ts +6 -0
- package/src/cook/game/cookJob.ts +103 -0
- package/src/cook/game/cookWorker.ts +413 -0
- package/src/cook/game/encodedBytes.ts +51 -0
- package/src/cook/game/engineHalf.ts +47 -0
- package/src/cook/game/entryDownloads.ts +36 -0
- package/src/cook/game/entryReadSet.ts +67 -0
- package/src/cook/game/entryTotals.ts +320 -0
- package/src/cook/game/fenceReads.ts +218 -0
- package/src/cook/game/gridCollision.ts +53 -0
- package/src/cook/game/gridEntryDownloads.ts +33 -0
- package/src/cook/game/gridStripPages.ts +239 -0
- package/src/cook/game/installedRuntimeReads.ts +48 -0
- package/src/cook/game/packStore.ts +120 -0
- package/src/cook/game/portableEncode.ts +7 -0
- package/src/cook/game/productTarball.ts +18 -0
- package/src/cook/game/shardCook.ts +350 -0
- package/src/cook/game/spawnParts.ts +294 -0
- package/src/cook/game/stripPack.ts +31 -0
- package/src/cook/side.ts +2 -0
- package/src/e2e/playwright.config.ts +60 -0
- package/src/e2e/smoke/game.ts +217 -0
- package/src/e2e/smoke/page-globals.d.ts +37 -0
- package/src/e2e/smoke/template2.spec.ts +146 -0
- package/src/e2e/status.spec.ts +13 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +142 -0
- package/src/scripts/check-sides.mjs +70 -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/engine/ai/CreatureBrain.ts +23 -0
- package/src/server/engine/ai/bossContenders.ts +101 -0
- package/src/server/engine/ai/burstFlyer.ts +31 -0
- package/src/server/engine/ai/challengeGrazer.ts +31 -0
- package/src/server/engine/ai/eliteContinuation.ts +141 -0
- package/src/server/engine/ai/eliteKernels.ts +187 -0
- package/src/server/engine/ai/eliteLifecycle.ts +126 -0
- package/src/server/engine/ai/eliteRoster.ts +357 -0
- package/src/server/engine/ai/grazer.ts +1360 -0
- package/src/server/engine/ai/guardian.ts +20 -0
- package/src/server/engine/ai/guardianPolicy.ts +264 -0
- package/src/server/engine/ai/herd.ts +17 -0
- package/src/server/engine/ai/hunt.ts +46 -0
- package/src/server/engine/ai/moves.ts +202 -0
- package/src/server/engine/ai/orbitDiver.ts +33 -0
- package/src/server/engine/ai/pack.ts +29 -0
- package/src/server/engine/ai/patrolDiver.ts +31 -0
- package/src/server/engine/ai/perchHunter.ts +20 -0
- package/src/server/engine/ai/phases.ts +121 -0
- package/src/server/engine/ai/platform.ts +140 -0
- package/src/server/engine/ai/ramGrazer.ts +31 -0
- package/src/server/engine/ai/scriptBrain.ts +147 -0
- package/src/server/engine/ai/skirmisher.ts +20 -0
- package/src/server/engine/ai/species.ts +33 -0
- package/src/server/engine/combat/EquipmentPickup.ts +28 -0
- package/src/server/engine/combat/contactWeapon.ts +251 -0
- package/src/server/engine/combat/damageBook.ts +45 -0
- package/src/server/engine/combat/rewind.ts +7 -0
- package/src/server/engine/entities/AnimalManager.ts +752 -0
- package/src/server/engine/entities/bodyClear.ts +47 -0
- package/src/server/engine/entities/creatureRefill.ts +119 -0
- package/src/server/engine/entities/killHeight.ts +18 -0
- package/src/server/engine/level/context.ts +111 -0
- package/src/server/engine/net/chat.ts +97 -0
- package/src/server/engine/net/combatWire.ts +49 -0
- package/src/server/engine/net/commandQueue.ts +95 -0
- package/src/server/engine/net/handles.ts +74 -0
- package/src/server/engine/net/hitHistory.ts +114 -0
- package/src/server/engine/net/ledgerBook.ts +65 -0
- package/src/server/engine/net/room.ts +560 -0
- package/src/server/engine/net/serverClock.ts +43 -0
- package/src/server/engine/net/simWorld.ts +131 -0
- package/src/server/engine/net/tiers.ts +14 -0
- package/src/server/engine/physics/edgeEntries.ts +40 -0
- package/src/server/engine/physics/rapierBindings.ts +4 -0
- package/src/server/engine/saves/forwardedStorage.ts +43 -0
- package/src/server/engine/script/composition.ts +219 -0
- package/src/server/engine/script/decision.ts +573 -0
- package/src/server/engine/script/inputInboxV2.ts +116 -0
- package/src/server/engine/script/lane.ts +185 -0
- package/src/server/engine/script/ownedSimBatchV2.ts +205 -0
- package/src/server/engine/script/queries.ts +37 -0
- package/src/server/engine/script/queriesV2.ts +149 -0
- package/src/server/engine/script/simBatchV2.ts +125 -0
- package/src/server/engine/sim/playerSim.ts +443 -0
- package/src/server/engine/sim/respawn.ts +74 -0
- package/src/server/engine/sim/restore.ts +37 -0
- package/src/server/engine/sim.ts +711 -0
- package/src/server/game/animation/limbPopulation.ts +138 -0
- package/src/server/game/bake/entryways.ts +186 -0
- package/src/server/game/boss/arenaRoomEntry.ts +97 -0
- package/src/server/game/boss/arenaRoomFight.ts +103 -0
- package/src/server/game/boss/arenaRoomNative.ts +142 -0
- package/src/server/game/boss/arenaWords.ts +46 -0
- package/src/server/game/boss/bounty.ts +37 -0
- package/src/server/game/boss/captainNative.ts +122 -0
- package/src/server/game/boss/continuation.ts +37 -0
- package/src/server/game/boss/headlessArenaPose.ts +40 -0
- package/src/server/game/boss/headlessArenaViews.ts +54 -0
- package/src/server/game/boss/headlessCloudBody.ts +93 -0
- package/src/server/game/boss/native.ts +220 -0
- package/src/server/game/boss/nativeArenaSand.ts +93 -0
- package/src/server/game/boss/nativeArenaSeal.ts +26 -0
- package/src/server/game/boss/nativeWake.ts +50 -0
- package/src/server/game/boss/openArenaNative.ts +200 -0
- package/src/server/game/boss/openArenaRoom.ts +69 -0
- package/src/server/game/boss/openArenaState.ts +25 -0
- package/src/server/game/boss/patrolNative.ts +286 -0
- package/src/server/game/boss/roaming.ts +77 -0
- package/src/server/game/boss/slotHeights.ts +103 -0
- package/src/server/game/boss/slotsNative.ts +175 -0
- package/src/server/game/boss/windEliteNative.ts +139 -0
- package/src/server/game/grapple/native.ts +181 -0
- package/src/server/game/grid/durability.ts +166 -0
- package/src/server/game/grid/room.ts +53 -0
- package/src/server/game/grid/roomNet.ts +85 -0
- package/src/server/game/grid/simulation.ts +345 -0
- package/src/server/game/items.merge.d.ts +7 -0
- package/src/server/game/loadout/nativeAmmunition.ts +139 -0
- package/src/server/game/loadout/ownedEffects.ts +68 -0
- package/src/server/game/loot/harvest.ts +43 -0
- package/src/server/game/loot/personal.ts +70 -0
- package/src/server/game/loot/playerOwned.ts +235 -0
- package/src/server/game/plugin/bossPhase.ts +904 -0
- package/src/server/game/plugin/brain.ts +1325 -0
- package/src/server/game/plugin/mover.ts +601 -0
- package/src/server/game/plugin/nativeItems.ts +437 -0
- package/src/server/game/plugin/nativeRewind.ts +37 -0
- package/src/server/game/plugin/nativeSwept.ts +249 -0
- package/src/server/game/plugin/playerSeats.ts +62 -0
- package/src/server/game/plugin/scriptSeats.ts +89 -0
- package/src/server/game/plugin/simulation.ts +1623 -0
- package/src/server/game/population/actorProjectionV2.ts +276 -0
- package/src/server/game/population/actors.ts +136 -0
- package/src/server/game/population/directedLaw.ts +69 -0
- package/src/server/game/population/encounterBook.ts +78 -0
- package/src/server/game/population/encounterIntake.ts +78 -0
- package/src/server/game/population/environment.ts +86 -0
- package/src/server/game/population/mixedRoster.ts +353 -0
- package/src/server/game/population/nativeBake.ts +202 -0
- package/src/server/game/population/nativeManager.ts +426 -0
- package/src/server/game/population/nativeReturns.ts +99 -0
- package/src/server/game/population/perchBody.ts +97 -0
- package/src/server/game/population/projectedSites.ts +41 -0
- package/src/server/game/population/relations.ts +45 -0
- package/src/server/game/population/roster.ts +259 -0
- package/src/server/game/population/scriptStrikes.ts +67 -0
- package/src/server/game/population/shelter.ts +193 -0
- package/src/server/game/population/signals.ts +9 -0
- package/src/server/game/population/spawnScript.ts +797 -0
- package/src/server/game/population/specCatalogue.ts +11 -0
- package/src/server/game/quest/bodyOps.ts +253 -0
- package/src/server/game/quest/chapterRecords.ts +97 -0
- package/src/server/game/quest/eliteDrops.ts +36 -0
- package/src/server/game/quest/eliteFeature.ts +141 -0
- package/src/server/game/quest/killSteps.ts +34 -0
- package/src/server/game/quest/nativeBodyScripts.ts +29 -0
- package/src/server/game/quest/nativeChapter.ts +80 -0
- package/src/server/game/quest/nativeComposition.ts +548 -0
- package/src/server/game/quest/nativeEntry.ts +128 -0
- package/src/server/game/quest/nativeInputs.ts +29 -0
- package/src/server/game/quest/nativeSecret.ts +80 -0
- package/src/server/game/quest/serverChapters.ts +192 -0
- package/src/server/game/quest/serverDoors.ts +89 -0
- package/src/server/game/quest/serverPlaces.ts +32 -0
- package/src/server/game/riding/native.ts +362 -0
- package/src/server/game/riding/nativePopulation.ts +384 -0
- package/src/server/game/riding/nativeTaming.ts +331 -0
- package/src/server/game/riding/pastureController.ts +131 -0
- package/src/server/game/riding/roster.ts +108 -0
- package/src/server/game/riding/wildRefill.ts +37 -0
- package/src/server/game/roomRespawn.ts +60 -0
- package/src/server/game/shard/declaredEncounters.ts +22 -0
- package/src/server/game/shard/manifest-closure.generated.json +683 -0
- package/src/server/game/shard/portShares.generated.ts +2 -0
- package/src/server/game/shard/world.ts +5 -0
- package/src/server/game/shardfile/borrowedDecisions.ts +281 -0
- package/src/server/game/shardfile/bossRow.ts +236 -0
- package/src/server/game/shardfile/brainRuntime.ts +162 -0
- package/src/server/game/shardfile/decisions.ts +597 -0
- package/src/server/game/shardfile/declaredClimate.ts +22 -0
- package/src/server/game/shardfile/declaredKitItems.ts +243 -0
- package/src/server/game/shardfile/declaredTalks.ts +52 -0
- package/src/server/game/shardfile/groupRuntime.ts +302 -0
- package/src/server/game/shardfile/homeKeeper.ts +565 -0
- package/src/server/game/shardfile/nativeAssembly.ts +102 -0
- package/src/server/game/shardfile/nativeAssemblyHosts.ts +301 -0
- package/src/server/game/shardfile/nativeAssemblyInput.ts +68 -0
- package/src/server/game/shardfile/nativePlan.ts +28 -0
- package/src/server/game/shardfile/nativeRuntimeLoans.ts +52 -0
- package/src/server/game/shardfile/phasedBossRoaming.ts +427 -0
- package/src/server/game/shardfile/portalLinkProof.ts +66 -0
- package/src/server/game/shardfile/scriptComposition.ts +57 -0
- package/src/server/game/shardfile/scripts.ts +56 -0
- package/src/server/game/shardfile/statusEffects.ts +68 -0
- package/src/server/game/stealth/nativeStealth.ts +74 -0
- package/src/server/game/weapons/nativeHeld.ts +333 -0
- package/src/server/game/weather/continuation.ts +97 -0
- package/src/server/game/weather/reactions.ts +219 -0
- package/src/server/game/weather/wire.ts +42 -0
- package/src/server/host/bake/headlessWorker.ts +132 -0
- package/src/server/host/dedicated/cellHost.ts +171 -0
- package/src/server/host/dedicated/cellProtocol.ts +64 -0
- package/src/server/host/dedicated/cellWorker.ts +33 -0
- package/src/server/host/dedicated/crossing.ts +44 -0
- package/src/server/host/dedicated/dedicatedRoom.ts +419 -0
- package/src/server/host/dedicated/doorTrust.ts +55 -0
- package/src/server/host/dedicated/gridCells.ts +53 -0
- package/src/server/host/dedicated/main.ts +134 -0
- package/src/server/host/dedicated/packReader.ts +68 -0
- package/src/server/host/dedicated/playerDoc.ts +96 -0
- package/src/server/host/dedicated/playerSaves.ts +62 -0
- package/src/server/host/dedicated/playerStore.ts +82 -0
- package/src/server/host/dedicated/playtest.ts +41 -0
- package/src/server/host/dedicated/releaseFile.ts +71 -0
- package/src/server/host/dedicated/roadRoom.ts +151 -0
- package/src/server/host/dedicated/saves/database.ts +15 -0
- package/src/server/host/dedicated/saves/migrate.ts +26 -0
- package/src/server/host/dedicated/saves/migrations/0001-saves.sql +48 -0
- package/src/server/host/dedicated/saves/migrations/0002-report-delivery.sql +3 -0
- package/src/server/host/dedicated/saves/migrations/0003-place.sql +11 -0
- package/src/server/host/dedicated/saves/migrations/0004-names.sql +4 -0
- package/src/server/host/dedicated/saves/migrations/0005-profile.sql +41 -0
- package/src/server/host/dedicated/saves/names.ts +56 -0
- package/src/server/host/dedicated/saves/pgDatabase.ts +43 -0
- package/src/server/host/dedicated/saves/profile.ts +44 -0
- package/src/server/host/dedicated/saves/reportQueue.ts +49 -0
- package/src/server/host/dedicated/saves/saveStore.ts +117 -0
- package/src/server/host/dedicated/saves/writeQueue.ts +94 -0
- package/src/server/host/dedicated/seats.ts +12 -0
- package/src/server/host/dedicated/serverReports.ts +81 -0
- package/src/server/host/dedicated/serverSentry.ts +124 -0
- package/src/server/host/dedicated/shopGate.ts +36 -0
- package/src/server/host/dedicated/socketPump.ts +74 -0
- package/src/server/host/dedicated/socketTransport.ts +123 -0
- package/src/server/host/dedicated/voiceRelay.ts +138 -0
- package/src/server/host/dedicated/workerTable.ts +29 -0
- package/src/server/host/dedicated/world.ts +428 -0
- package/src/server/host/headless.ts +280 -0
- package/src/server/host/headlessProduct.ts +52 -0
- package/src/server/host/headlessRuntime.ts +354 -0
- package/src/server/host/ropeDecks.ts +69 -0
- package/src/server/host/standalone/cellWorld.ts +188 -0
- package/src/server/host/standalone/continuation.ts +58 -0
- package/src/server/host/standalone/fallFloor.ts +83 -0
- package/src/server/host/standalone/gridServer.ts +282 -0
- package/src/server/host/standalone/ledgerFilings.ts +33 -0
- package/src/server/host/standalone/progressWatch.ts +90 -0
- package/src/server/host/standalone/roadWorld.ts +49 -0
- package/src/server/host/standalone/serverHost.ts +132 -0
- package/src/server/host/standalone/serverProduct.ts +149 -0
- package/src/server/host/standalone/serverRuntime.ts +43 -0
- package/src/server/host/standalone/serverWorker.ts +22 -0
- package/src/server/host/tickWorkerHost.ts +250 -0
- package/src/server/host/tickWorkerLoop.ts +123 -0
- package/src/server/serve.ts +49 -0
- package/src/server/side.ts +2 -0
- package/src/shared/engine/ai/BossBrain.ts +287 -0
- package/src/shared/engine/ai/GroupBrain.ts +152 -0
- package/src/shared/engine/ai/ambientFlight.ts +60 -0
- package/src/shared/engine/ai/ambientFlock.ts +297 -0
- package/src/shared/engine/ai/ambientForager.ts +289 -0
- package/src/shared/engine/ai/bossScale.ts +8 -0
- package/src/shared/engine/ai/director.ts +94 -0
- package/src/shared/engine/ai/diver.ts +540 -0
- package/src/shared/engine/ai/eliteScript.ts +85 -0
- package/src/shared/engine/ai/encounters.ts +124 -0
- package/src/shared/engine/ai/flight.ts +69 -0
- package/src/shared/engine/ai/flock.ts +334 -0
- package/src/shared/engine/ai/hfsm.ts +51 -0
- package/src/shared/engine/ai/huntPattern.ts +987 -0
- package/src/shared/engine/ai/inspect.ts +6 -0
- package/src/shared/engine/ai/pinning.ts +13 -0
- package/src/shared/engine/ai/reach.ts +19 -0
- package/src/shared/engine/ai/stalker.ts +1502 -0
- package/src/shared/engine/ai/strikeRows.ts +17 -0
- package/src/shared/engine/ai/strikeState.ts +19 -0
- package/src/shared/engine/ai/strikes.ts +199 -0
- package/src/shared/engine/ai/weighted.ts +27 -0
- package/src/shared/engine/app/identity.ts +66 -0
- package/src/shared/engine/app/ownership.ts +155 -0
- package/src/shared/engine/app/pageSeat.ts +12 -0
- package/src/shared/engine/app/resources.ts +7 -0
- package/src/shared/engine/app/scheduler.ts +162 -0
- package/src/shared/engine/app/scope.ts +557 -0
- package/src/shared/engine/app/scopeEnvironment.ts +27 -0
- package/src/shared/engine/app/scopedProperty.ts +38 -0
- package/src/shared/engine/audio/audioProfiles.ts +161 -0
- package/src/shared/engine/audio/bootAudio.ts +316 -0
- package/src/shared/engine/boot/loadingWaits.ts +62 -0
- package/src/shared/engine/boot/serverProgress.ts +27 -0
- package/src/shared/engine/boot/steps.ts +63 -0
- package/src/shared/engine/boot/tables.ts +48 -0
- package/src/shared/engine/boot/timeline.ts +189 -0
- package/src/shared/engine/boot/timing.ts +96 -0
- package/src/shared/engine/boot/waits.ts +114 -0
- package/src/shared/engine/boot/workerTiming.ts +74 -0
- package/src/shared/engine/combat/Equipment.ts +66 -0
- package/src/shared/engine/combat/Firearm.ts +200 -0
- package/src/shared/engine/combat/Melee.ts +46 -0
- package/src/shared/engine/combat/Tool.ts +8 -0
- package/src/shared/engine/combat/Weapon.ts +133 -0
- package/src/shared/engine/combat/ammo.ts +17 -0
- package/src/shared/engine/combat/blocks/ads.ts +5 -0
- package/src/shared/engine/combat/blocks/melee.ts +19 -0
- package/src/shared/engine/combat/bowDraw.ts +140 -0
- package/src/shared/engine/combat/bowLaw.ts +54 -0
- package/src/shared/engine/combat/effects/EffectService.ts +216 -0
- package/src/shared/engine/combat/effects/types.ts +47 -0
- package/src/shared/engine/combat/health.ts +92 -0
- package/src/shared/engine/combat/impact.ts +8 -0
- package/src/shared/engine/combat/itemFamilies.ts +34 -0
- package/src/shared/engine/combat/items.ts +147 -0
- package/src/shared/engine/combat/lungeTarget.ts +42 -0
- package/src/shared/engine/combat/meleeProfile.ts +48 -0
- package/src/shared/engine/combat/pipeline.ts +157 -0
- package/src/shared/engine/combat/projectileContact.ts +275 -0
- package/src/shared/engine/combat/projectileFlight.ts +89 -0
- package/src/shared/engine/combat/projectileLaw.ts +148 -0
- package/src/shared/engine/combat/shotSpread.ts +38 -0
- package/src/shared/engine/combat/sweptBasePose.ts +75 -0
- package/src/shared/engine/combat/sweptBlade.ts +108 -0
- package/src/shared/engine/combat/sweptMeleeCore.ts +223 -0
- package/src/shared/engine/combat/targets.ts +20 -0
- package/src/shared/engine/core/clock.ts +57 -0
- package/src/shared/engine/core/config.ts +66 -0
- package/src/shared/engine/core/faults.ts +129 -0
- package/src/shared/engine/core/fixedStep.ts +5 -0
- package/src/shared/engine/core/frameCost.ts +227 -0
- package/src/shared/engine/core/framePacing.ts +179 -0
- package/src/shared/engine/core/harnessTap.ts +15 -0
- package/src/shared/engine/core/memoryAttribution.ts +137 -0
- package/src/shared/engine/core/memoryResources.ts +20 -0
- package/src/shared/engine/core/noise.ts +53 -0
- package/src/shared/engine/core/perfLap.ts +37 -0
- package/src/shared/engine/core/portableMath.ts +204 -0
- package/src/shared/engine/core/portableMathFirst.ts +4 -0
- package/src/shared/engine/core/practiceRoomState.ts +3 -0
- package/src/shared/engine/core/rng.ts +101 -0
- package/src/shared/engine/core/time.ts +8 -0
- package/src/shared/engine/core/workSlice.ts +111 -0
- package/src/shared/engine/entities/AnimalSim.ts +390 -0
- package/src/shared/engine/entities/animalPose.ts +401 -0
- package/src/shared/engine/entities/animalRig.ts +76 -0
- package/src/shared/engine/entities/animalStates.ts +2 -0
- package/src/shared/engine/entities/creatureFloor.ts +13 -0
- package/src/shared/engine/entities/eliteBrain.ts +36 -0
- package/src/shared/engine/entities/fightRules.ts +80 -0
- package/src/shared/engine/entities/ids.ts +18 -0
- package/src/shared/engine/entities/poseCadence.ts +9 -0
- package/src/shared/engine/entities/species/registry.ts +382 -0
- package/src/shared/engine/entities/species/rigs.ts +53 -0
- package/src/shared/engine/events/events.ts +107 -0
- package/src/shared/engine/input/commands.ts +34 -0
- package/src/shared/engine/input/netButtons.ts +4 -0
- package/src/shared/engine/level/data.ts +163 -0
- package/src/shared/engine/level/selection.ts +44 -0
- package/src/shared/engine/level/spec.ts +132 -0
- package/src/shared/engine/net/acts.ts +48 -0
- package/src/shared/engine/net/animalNet.ts +43 -0
- package/src/shared/engine/net/bits.ts +104 -0
- package/src/shared/engine/net/chatFilter.ts +40 -0
- package/src/shared/engine/net/chatWire.ts +18 -0
- package/src/shared/engine/net/chatWords.ts +7 -0
- package/src/shared/engine/net/command.ts +96 -0
- package/src/shared/engine/net/encounterNet.ts +32 -0
- package/src/shared/engine/net/frame.ts +159 -0
- package/src/shared/engine/net/identity.ts +40 -0
- package/src/shared/engine/net/ledgerWire.ts +24 -0
- package/src/shared/engine/net/measurements.ts +14 -0
- package/src/shared/engine/net/messages.ts +213 -0
- package/src/shared/engine/net/netSchemas.ts +38 -0
- package/src/shared/engine/net/playerNet.ts +80 -0
- package/src/shared/engine/net/schema.ts +157 -0
- package/src/shared/engine/net/shardNet.ts +25 -0
- package/src/shared/engine/net/socketFrames.ts +84 -0
- package/src/shared/engine/net/transport.ts +19 -0
- package/src/shared/engine/net/wireFrames.ts +123 -0
- package/src/shared/engine/net/wireMessages.ts +115 -0
- package/src/shared/engine/net/wireValues.ts +142 -0
- package/src/shared/engine/physics/CharacterMotor.ts +429 -0
- package/src/shared/engine/physics/Physics.ts +211 -0
- package/src/shared/engine/physics/bodies.ts +600 -0
- package/src/shared/engine/physics/box.ts +42 -0
- package/src/shared/engine/physics/creatures.ts +188 -0
- package/src/shared/engine/physics/declaredProps.ts +26 -0
- package/src/shared/engine/physics/entrySockets.ts +44 -0
- package/src/shared/engine/physics/frame.ts +39 -0
- package/src/shared/engine/physics/gridBorders.ts +38 -0
- package/src/shared/engine/physics/groups.ts +64 -0
- package/src/shared/engine/physics/heightPatch.ts +49 -0
- package/src/shared/engine/physics/meshCollision.ts +84 -0
- package/src/shared/engine/physics/mover.ts +60 -0
- package/src/shared/engine/physics/navmesh.ts +206 -0
- package/src/shared/engine/physics/navmeshUrl.ts +8 -0
- package/src/shared/engine/physics/nearColliders.ts +55 -0
- package/src/shared/engine/physics/overlap.ts +26 -0
- package/src/shared/engine/physics/paths.ts +135 -0
- package/src/shared/engine/physics/pieces.ts +139 -0
- package/src/shared/engine/physics/query.ts +161 -0
- package/src/shared/engine/physics/queryBatchV2.ts +118 -0
- package/src/shared/engine/physics/rapier-bg.d.ts +5 -0
- package/src/shared/engine/physics/rapier.ts +34 -0
- package/src/shared/engine/physics/readinessWalls.ts +49 -0
- package/src/shared/engine/physics/ropeChain.ts +128 -0
- package/src/shared/engine/physics/stripColliders.ts +21 -0
- package/src/shared/engine/physics/surface.ts +31 -0
- package/src/shared/engine/physics/terrain.ts +155 -0
- package/src/shared/engine/physics/terrainTiles.ts +20 -0
- package/src/shared/engine/physics/trainingTargets.ts +51 -0
- package/src/shared/engine/physics/transferWalls.ts +84 -0
- package/src/shared/engine/physics/wasmUrl.ts +3 -0
- package/src/shared/engine/player/MeleeSweep.ts +50 -0
- package/src/shared/engine/player/board.ts +129 -0
- package/src/shared/engine/player/combatMotion.ts +5 -0
- package/src/shared/engine/player/dash.ts +60 -0
- package/src/shared/engine/player/dodge.ts +14 -0
- package/src/shared/engine/player/fall.ts +29 -0
- package/src/shared/engine/player/hoverSpeed.ts +22 -0
- package/src/shared/engine/player/impulse.ts +30 -0
- package/src/shared/engine/player/jump.ts +30 -0
- package/src/shared/engine/player/lockOrbit.ts +72 -0
- package/src/shared/engine/player/modes.ts +239 -0
- package/src/shared/engine/player/motion.ts +391 -0
- package/src/shared/engine/player/motionState.ts +84 -0
- package/src/shared/engine/player/shove.ts +27 -0
- package/src/shared/engine/player/swim.ts +196 -0
- package/src/shared/engine/player/walk.ts +25 -0
- package/src/shared/engine/quest/core.ts +174 -0
- package/src/shared/engine/quest/dialogueClock.ts +191 -0
- package/src/shared/engine/quest/discovery.ts +42 -0
- package/src/shared/engine/quest/lastPlace.ts +80 -0
- package/src/shared/engine/quest/players.ts +162 -0
- package/src/shared/engine/quest/progress.ts +25 -0
- package/src/shared/engine/quest/viewPort.ts +22 -0
- package/src/shared/engine/saves/environment.ts +13 -0
- package/src/shared/engine/saves/legacy.ts +65 -0
- package/src/shared/engine/saves/runtime.ts +28 -0
- package/src/shared/engine/saves/saves.lock.json +551 -0
- package/src/shared/engine/saves/shape.ts +157 -0
- package/src/shared/engine/saves/store.ts +423 -0
- package/src/shared/engine/script/checkpointBytes.ts +18 -0
- package/src/shared/engine/script/decisionModule.ts +158 -0
- package/src/shared/engine/script/effects.ts +111 -0
- package/src/shared/engine/script/fixedMemory.ts +92 -0
- package/src/shared/engine/script/groupBankV2.ts +376 -0
- package/src/shared/engine/script/groupStepV2.ts +987 -0
- package/src/shared/engine/script/host.ts +443 -0
- package/src/shared/engine/script/moduleV2.ts +160 -0
- package/src/shared/engine/script/observationColumnsV2.ts +431 -0
- package/src/shared/engine/script/observationsV2.ts +139 -0
- package/src/shared/engine/script/state.ts +183 -0
- package/src/shared/engine/script/strings.ts +5 -0
- package/src/shared/engine/script/viewLane.ts +335 -0
- package/src/shared/engine/script/viewProgram.ts +315 -0
- package/src/shared/engine/sim/actRoutes.ts +72 -0
- package/src/shared/engine/sim/apiVersion.ts +2 -0
- package/src/shared/engine/sim/bands.ts +174 -0
- package/src/shared/engine/sim/cableTraversal.ts +356 -0
- package/src/shared/engine/sim/dayClock.ts +76 -0
- package/src/shared/engine/sim/edgeProfiles.ts +123 -0
- package/src/shared/engine/sim/encounterRows.ts +49 -0
- package/src/shared/engine/sim/leadPlayer.ts +16 -0
- package/src/shared/engine/sim/moverLifecycle.ts +80 -0
- package/src/shared/engine/sim/moverMotion.ts +130 -0
- package/src/shared/engine/sim/nearPlayer.ts +21 -0
- package/src/shared/engine/sim/netMotion.ts +17 -0
- package/src/shared/engine/sim/readiness.ts +77 -0
- package/src/shared/engine/sim/seamError.ts +100 -0
- package/src/shared/engine/sim/seamGeometry.ts +365 -0
- package/src/shared/engine/sim/seamLattice.ts +127 -0
- package/src/shared/engine/sim/shardRows.ts +106 -0
- package/src/shared/engine/sim/shore.ts +14 -0
- package/src/shared/engine/sim/snapshot.ts +482 -0
- package/src/shared/engine/sim/snapshotBase64.ts +25 -0
- package/src/shared/engine/sim/snapshotData.ts +460 -0
- package/src/shared/engine/sim/snapshotPhysics.ts +163 -0
- package/src/shared/engine/sim/snapshotReferenceMemo.ts +271 -0
- package/src/shared/engine/sim/strips.ts +134 -0
- package/src/shared/engine/strings.ts +751 -0
- package/src/shared/engine/world/BakedTerrain.ts +131 -0
- package/src/shared/engine/world/Heightfield.ts +129 -0
- package/src/shared/engine/world/bakedTerrainField.ts +85 -0
- package/src/shared/engine/world/dayCycle.ts +198 -0
- package/src/shared/engine/world/easedFields.ts +32 -0
- package/src/shared/engine/world/forest/placement.ts +391 -0
- package/src/shared/engine/world/forest/treeSpec.ts +15 -0
- package/src/shared/engine/world/groundField.ts +21 -0
- package/src/shared/engine/world/interact/barrel.ts +114 -0
- package/src/shared/engine/world/interact/flags.ts +229 -0
- package/src/shared/engine/world/interact/pickup.ts +22 -0
- package/src/shared/engine/world/interact/prompts.ts +47 -0
- package/src/shared/engine/world/interact/types.ts +327 -0
- package/src/shared/engine/world/interact/validate.ts +67 -0
- package/src/shared/engine/world/scalarChannel.ts +146 -0
- package/src/shared/engine/world/steppeWind.ts +193 -0
- package/src/shared/engine/world/terrainField.ts +217 -0
- package/src/shared/engine/world/terrainHeight.ts +19 -0
- package/src/shared/engine/world/water/body.ts +88 -0
- package/src/shared/engine/world/water/declared.ts +106 -0
- package/src/shared/engine/world/waves.ts +57 -0
- package/src/shared/engine/world/weather.ts +166 -0
- package/src/shared/engine/world/weatherContinuation.ts +121 -0
- package/src/shared/engine/world/windField.ts +49 -0
- package/src/shared/engine/world/windStrength.ts +6 -0
- package/src/shared/engine/world/yawFrame.ts +38 -0
- package/src/shared/game/achievements.ts +140 -0
- package/src/shared/game/ambient/flock.ts +374 -0
- package/src/shared/game/animation/limbBlend.ts +70 -0
- package/src/shared/game/animation/limbRig.ts +208 -0
- package/src/shared/game/bag/findsCatalogue.ts +58 -0
- package/src/shared/game/bag/itemCatalog.ts +18 -0
- package/src/shared/game/bag/items.ts +5 -0
- package/src/shared/game/bag/starter.generated.ts +3 -0
- package/src/shared/game/bag/starterItems.json +62 -0
- package/src/shared/game/boss/arenaAnswers.ts +49 -0
- package/src/shared/game/boss/arenaCollision.ts +16 -0
- package/src/shared/game/boss/arenaGround.ts +121 -0
- package/src/shared/game/boss/arenaPortal.ts +63 -0
- package/src/shared/game/boss/arenaRoomRows.ts +403 -0
- package/src/shared/game/boss/arenaWhirls.ts +88 -0
- package/src/shared/game/boss/jointTargets.ts +41 -0
- package/src/shared/game/boss/lane.ts +62 -0
- package/src/shared/game/boss/openArenaFight.ts +644 -0
- package/src/shared/game/boss/patrolLaw.ts +136 -0
- package/src/shared/game/boss/slotLaw.ts +173 -0
- package/src/shared/game/boss/wake.ts +60 -0
- package/src/shared/game/compendium/finds.ts +49 -0
- package/src/shared/game/compendium/registry.ts +28 -0
- package/src/shared/game/compendium/rules.ts +136 -0
- package/src/shared/game/compendium/state.ts +23 -0
- package/src/shared/game/compendium/tracker.ts +138 -0
- package/src/shared/game/compendium/types.ts +115 -0
- package/src/shared/game/eliteSystem.ts +349 -0
- package/src/shared/game/grapple/course.ts +14 -0
- package/src/shared/game/grapple/feed.ts +27 -0
- package/src/shared/game/grapple/sim.ts +352 -0
- package/src/shared/game/grid/allocator.ts +479 -0
- package/src/shared/game/grid/assembly.ts +73 -0
- package/src/shared/game/grid/catalogue.ts +197 -0
- package/src/shared/game/grid/catalogueDocument.ts +6 -0
- package/src/shared/game/grid/catalogueSlot.ts +53 -0
- package/src/shared/game/grid/cellEvents.ts +37 -0
- package/src/shared/game/grid/collisionStrips.ts +18 -0
- package/src/shared/game/grid/compiledStrips.ts +282 -0
- package/src/shared/game/grid/continuations.ts +43 -0
- package/src/shared/game/grid/crossing.ts +143 -0
- package/src/shared/game/grid/edgeProfiles.ts +31 -0
- package/src/shared/game/grid/farProxy.ts +302 -0
- package/src/shared/game/grid/ghosts.ts +42 -0
- package/src/shared/game/grid/gridAssetBytes.ts +59 -0
- package/src/shared/game/grid/gridCollision.ts +37 -0
- package/src/shared/game/grid/instances.ts +9 -0
- package/src/shared/game/grid/pageMode.ts +32 -0
- package/src/shared/game/grid/platformInputs.ts +11 -0
- package/src/shared/game/grid/postPairs.ts +40 -0
- package/src/shared/game/grid/readinessEdges.ts +13 -0
- package/src/shared/game/grid/recovery.ts +221 -0
- package/src/shared/game/grid/roadLayout.ts +169 -0
- package/src/shared/game/grid/roadRecovery.ts +99 -0
- package/src/shared/game/grid/rules.ts +45 -0
- package/src/shared/game/grid/runtimeCheckpoint.ts +58 -0
- package/src/shared/game/grid/seamData.ts +74 -0
- package/src/shared/game/grid/seamGeometry.ts +219 -0
- package/src/shared/game/grid/singleplayer.json +701 -0
- package/src/shared/game/grid/travellerCombat.ts +34 -0
- package/src/shared/game/grid/wallet.ts +104 -0
- package/src/shared/game/harvest.ts +16 -0
- package/src/shared/game/instanceSaves.ts +14 -0
- package/src/shared/game/inventoryLaw.ts +131 -0
- package/src/shared/game/ledger.ts +188 -0
- package/src/shared/game/loadout/itemCatalogue.ts +44 -0
- package/src/shared/game/loadout/persistence.ts +20 -0
- package/src/shared/game/loadout/pouch.ts +46 -0
- package/src/shared/game/localSaveKeys.ts +9 -0
- package/src/shared/game/looks/dayClock.ts +112 -0
- package/src/shared/game/looks/dayLookPresets.ts +75 -0
- package/src/shared/game/looks/keyedSkyClock.ts +15 -0
- package/src/shared/game/loot/Bounty.ts +49 -0
- package/src/shared/game/loot/Owned.ts +112 -0
- package/src/shared/game/loot/Purse.ts +94 -0
- package/src/shared/game/loot/coinAmounts.ts +17 -0
- package/src/shared/game/loot/coinBurstState.ts +23 -0
- package/src/shared/game/loot/deaths.ts +14 -0
- package/src/shared/game/loot/exchange.ts +71 -0
- package/src/shared/game/loot/ownedRows.ts +24 -0
- package/src/shared/game/loot/tableRows.ts +11 -0
- package/src/shared/game/newGame.ts +56 -0
- package/src/shared/game/plugin/animation.ts +618 -0
- package/src/shared/game/plugin/bodyBoss.ts +119 -0
- package/src/shared/game/plugin/borrowed.ts +62 -0
- package/src/shared/game/plugin/bossRecord.ts +28 -0
- package/src/shared/game/plugin/channelPrograms.ts +307 -0
- package/src/shared/game/plugin/channels.ts +355 -0
- package/src/shared/game/plugin/creatureFrame.ts +46 -0
- package/src/shared/game/plugin/director.ts +435 -0
- package/src/shared/game/plugin/moduleHash.ts +49 -0
- package/src/shared/game/plugin/quests.ts +450 -0
- package/src/shared/game/plugin/runtimeRows.ts +288 -0
- package/src/shared/game/population/census.ts +67 -0
- package/src/shared/game/population/groupNotices.ts +34 -0
- package/src/shared/game/population/pageHomes.ts +125 -0
- package/src/shared/game/population/pageRows.ts +20 -0
- package/src/shared/game/population/perchRoot.ts +17 -0
- package/src/shared/game/population/respawn.ts +89 -0
- package/src/shared/game/population/returnProgram.ts +448 -0
- package/src/shared/game/population/returnProjectionV2.ts +203 -0
- package/src/shared/game/population/wildlifeOwner.ts +20 -0
- package/src/shared/game/quest/boundState.ts +55 -0
- package/src/shared/game/quest/carriedRound.ts +59 -0
- package/src/shared/game/quest/chapterBindings.ts +64 -0
- package/src/shared/game/quest/chapterClock.ts +56 -0
- package/src/shared/game/quest/chapterDecision.ts +31 -0
- package/src/shared/game/quest/chapterFlow.ts +54 -0
- package/src/shared/game/quest/chapterLeads.ts +10 -0
- package/src/shared/game/quest/contractBoard.ts +108 -0
- package/src/shared/game/quest/contracts.ts +145 -0
- package/src/shared/game/quest/declared.ts +152 -0
- package/src/shared/game/quest/effectPresentation.ts +23 -0
- package/src/shared/game/quest/effects.ts +61 -0
- package/src/shared/game/quest/eliteDecisions.ts +123 -0
- package/src/shared/game/quest/eliteStreams.ts +7 -0
- package/src/shared/game/quest/featCounters.ts +41 -0
- package/src/shared/game/quest/flagGates.ts +103 -0
- package/src/shared/game/quest/interactionRows.ts +214 -0
- package/src/shared/game/quest/ledger.ts +23 -0
- package/src/shared/game/quest/legacyRecords.ts +17 -0
- package/src/shared/game/quest/nativeProps.ts +117 -0
- package/src/shared/game/quest/pagePersistence.ts +91 -0
- package/src/shared/game/quest/pageReads.ts +39 -0
- package/src/shared/game/quest/pageResources.ts +19 -0
- package/src/shared/game/quest/pageState.ts +66 -0
- package/src/shared/game/quest/persistence.ts +110 -0
- package/src/shared/game/quest/questObservation.ts +50 -0
- package/src/shared/game/quest/steps.ts +116 -0
- package/src/shared/game/quest/storyLaw.ts +17 -0
- package/src/shared/game/riding/bindingTypes.ts +43 -0
- package/src/shared/game/riding/companions.ts +135 -0
- package/src/shared/game/riding/entered.ts +21 -0
- package/src/shared/game/riding/pagePopulation.ts +28 -0
- package/src/shared/game/riding/pastureCues.ts +24 -0
- package/src/shared/game/riding/physics.ts +691 -0
- package/src/shared/game/riding/presentation.ts +27 -0
- package/src/shared/game/riding/taming.ts +164 -0
- package/src/shared/game/rng.merge.d.ts +10 -0
- package/src/shared/game/saves.ts +90 -0
- package/src/shared/game/shard/api.ts +2 -0
- package/src/shared/game/shard/declaredRows.ts +121 -0
- package/src/shared/game/shard/enteredServices.ts +14 -0
- package/src/shared/game/shard/runtime.ts +90 -0
- package/src/shared/game/shard/slug.ts +9 -0
- package/src/shared/game/shard/terrainBake.ts +12 -0
- package/src/shared/game/shardfile/aimTargetFilter.ts +12 -0
- package/src/shared/game/shardfile/bakedPlacementPoses.ts +25 -0
- package/src/shared/game/shardfile/buildingDoor.ts +52 -0
- package/src/shared/game/shardfile/clientGround.ts +86 -0
- package/src/shared/game/shardfile/clientState.ts +133 -0
- package/src/shared/game/shardfile/collisionBindings.ts +31 -0
- package/src/shared/game/shardfile/contentHash.ts +7 -0
- package/src/shared/game/shardfile/crowdRuntime.ts +254 -0
- package/src/shared/game/shardfile/customSchema.ts +57 -0
- package/src/shared/game/shardfile/dataCreaturePorts.ts +239 -0
- package/src/shared/game/shardfile/entryOwners.ts +153 -0
- package/src/shared/game/shardfile/fileInputs.ts +21 -0
- package/src/shared/game/shardfile/identity.ts +18 -0
- package/src/shared/game/shardfile/items.ts +180 -0
- package/src/shared/game/shardfile/ktx2Targets.ts +62 -0
- package/src/shared/game/shardfile/ladder.ts +137 -0
- package/src/shared/game/shardfile/liftRider.ts +62 -0
- package/src/shared/game/shardfile/logicalState.ts +57 -0
- package/src/shared/game/shardfile/movers.ts +14 -0
- package/src/shared/game/shardfile/namedJsonChecks.ts +12 -0
- package/src/shared/game/shardfile/outputChecksNode.ts +11 -0
- package/src/shared/game/shardfile/outputDescriptor.ts +317 -0
- package/src/shared/game/shardfile/outputIndexChecks.ts +8 -0
- package/src/shared/game/shardfile/packReads.ts +93 -0
- package/src/shared/game/shardfile/playArea.ts +42 -0
- package/src/shared/game/shardfile/portalRide.ts +170 -0
- package/src/shared/game/shardfile/portalTraversal.ts +49 -0
- package/src/shared/game/shardfile/productData.ts +22 -0
- package/src/shared/game/shardfile/props.ts +11 -0
- package/src/shared/game/shardfile/resourceRole.ts +14 -0
- package/src/shared/game/shardfile/runtimeState.ts +69 -0
- package/src/shared/game/shardfile/schemaReferences.ts +33 -0
- package/src/shared/game/shardfile/scriptNotice.ts +38 -0
- package/src/shared/game/shardfile/serverPack.ts +23 -0
- package/src/shared/game/shardfile/shardProduct.ts +206 -0
- package/src/shared/game/shardfile/spawnManifest.ts +126 -0
- package/src/shared/game/shardfile/talks.ts +22 -0
- package/src/shared/game/shardfile/targets.ts +11 -0
- package/src/shared/game/shardfile/tileOrder.ts +64 -0
- package/src/shared/game/shardfile/walkInPortalRide.ts +160 -0
- package/src/shared/game/shardfile/wholeInputs.ts +18 -0
- package/src/shared/game/shardfile/wirePrompts.ts +35 -0
- package/src/shared/game/shardfile/worldActionsV2.ts +113 -0
- package/src/shared/game/shardfile/worldTargets.ts +71 -0
- package/src/shared/game/stealth/stealthLaw.ts +120 -0
- package/src/shared/game/strings.ts +88 -0
- package/src/shared/game/systems/cellField.ts +144 -0
- package/src/shared/game/systems/effects/starterEffects.ts +20 -0
- package/src/shared/game/systems/effects/starterRows.json +98 -0
- package/src/shared/game/systems/looks/grassField.ts +249 -0
- package/src/shared/game/systems/looks/trampleField.ts +263 -0
- package/src/shared/game/weapons/heldBowBase.ts +15 -0
- package/src/shared/game/weapons/heldDecision.ts +20 -0
- package/src/shared/game/weapons/javelinFlight.ts +139 -0
- package/src/shared/game/weapons/launcherSpring.ts +11 -0
- package/src/shared/game/weapons/mountedPass.ts +70 -0
- package/src/shared/game/weapons/polearmContact.ts +73 -0
- package/src/shared/game/weapons/polearmDecision.ts +152 -0
- package/src/shared/game/weapons/starter.generated.ts +2 -0
- package/src/shared/game/weapons/starterBow.json +21 -0
- package/src/shared/game/weapons/starterBowProfile.ts +17 -0
- package/src/shared/game/weapons/starterCombat.ts +19 -0
- package/src/shared/game/weapons/starterGlyphs.ts +9 -0
- package/src/shared/game/weapons/starterMeleeProfile.ts +67 -0
- package/src/shared/game/weapons/starterMoves.ts +101 -0
- package/src/shared/game/weather/feed.ts +57 -0
- package/src/shared/health.ts +10 -0
- package/src/shared/host/author.ts +14 -0
- package/src/shared/host/formatJsonSchema.ts +1114 -0
- package/src/shared/host/headlessJourney.ts +152 -0
- package/src/shared/host/headlessObservation.ts +16 -0
- package/src/shared/host/headlessSections.ts +18 -0
- package/src/shared/host/headlessTape.ts +99 -0
- package/src/shared/host/headlessTapeParts.ts +35 -0
- package/src/shared/host/immutable.ts +14 -0
- package/src/shared/host/releaseRows.ts +23 -0
- package/src/shared/host/shardfile.ts +23 -0
- package/src/shared/host/standalone/harnessPlace.ts +23 -0
- package/src/shared/host/standalone/heldReads.ts +45 -0
- package/src/shared/host/standalone/netInput.ts +112 -0
- package/src/shared/host/standalone/workerLoopback.ts +51 -0
- package/src/shared/host/tickProtocol.ts +246 -0
- package/src/shared/side.ts +2 -0
- package/src/test/engine/FakeGame.ts +123 -0
- package/src/test/engine/creatureStride.ts +29 -0
- package/src/test/engine/declarationConsumer.ts +24 -0
- package/src/test/engine/linkedGl.ts +7 -0
- package/src/test/engine/manager.ts +58 -0
- package/src/test/engine/nativeBytes.ts +5 -0
- package/src/test/engine/netLoopback.ts +64 -0
- package/src/test/engine/realGc.ts +34 -0
- package/src/test/engine/terrain.ts +32 -0
- package/src/test/engine/textureUploadRenderer.ts +34 -0
- package/src/test/engine/weaponParity.ts +119 -0
- package/src/test/engine/world.ts +48 -0
- package/src/test/game/creatureRecipe.ts +11 -0
- package/src/test/helpers/git.ts +94 -0
- package/src/test/tsconfig.app.json +28 -0
- package/src/test/tsconfig.engine.json +27 -0
- package/src/test/tsconfig.game.json +28 -0
- package/src/test/tsconfig.host.json +27 -0
- package/src/tools/build-web.ts +58 -0
- package/src/tsconfig.json +39 -0
- package/tsconfig.app.json +32 -0
- package/tsconfig.engine.json +22 -0
- package/tsconfig.game.json +34 -0
- package/tsconfig.host.json +33 -0
- package/tsconfig.json +54 -0
- package/tsconfig.layers.json +35 -0
- package/types/format-standards.d.ts +19 -0
- package/vite/rapier.ts +35 -0
- package/README.md +0 -8
|
@@ -0,0 +1,2083 @@
|
|
|
1
|
+
import { readWholePartition } from '../shardfile/wholeGeometryPieces';
|
|
2
|
+
import { materialColourGraph } from '@wildshard/engine/render/graph/colourFunction';
|
|
3
|
+
import { isJsonData } from '@wildshard/format/json';
|
|
4
|
+
import { clientPreparationBatch } from '../shardfile/preparationTiming';
|
|
5
|
+
import { unzlibSync } from 'fflate';
|
|
6
|
+
import { type NativeAttributeSchema as WholeAttribute, admitNativeWholeGeometry } from '@wildshard/engine/models/nativeGeometry';
|
|
7
|
+
import { fetchDeflatedBytes, fetchLaneBytes, unshuffleLanes as restoreLanes } from '@wildshard/engine/core/deflate';
|
|
8
|
+
import { geometryBoundsSteps } from '@wildshard/engine/world/geometryBounds';
|
|
9
|
+
import { BAKED_BYTES as codecBakedBytes, appendGeometry as codecAppendGeometry, bakedGeometryBytes as codecBakedGeometryBytes, pad4 as codecPad4, readBakedAttribute, readBakedGeometry as codecReadBakedGeometry, type BakedGeometryRow as CodecBakedGeometryRow, type BakedType as CodecBakedType } from './bakedGeometry';
|
|
10
|
+
import { workSlice } from '@wildshard/engine/core/workSlice';
|
|
11
|
+
import { presenting } from '@wildshard/engine/core/framePacing';
|
|
12
|
+
import { constructionCheckpoint } from '../shardfile/constructionCheckpoint';
|
|
13
|
+
import { PreparationReads } from '../shardfile/preparationReads';
|
|
14
|
+
import { wholeGeometryInputs } from '../../../shared/game/shardfile/wholeInputs';
|
|
15
|
+
import { TIER } from '@wildshard/engine/core/tier';
|
|
16
|
+
import { readHomeBuildGeometry, saveHomeBuildGeometry } from '../shardfile/homeBuildCache';
|
|
17
|
+
import { defineSceneModels, type BakedModelMetadata } from '@wildshard/engine/models/model';
|
|
18
|
+
import { identitySpaceGeometry } from '@wildshard/engine/models/ownedGeometry';
|
|
19
|
+
import * as wholeV from 'valibot';
|
|
20
|
+
import type { Scope as ResourceScope } from '@wildshard/engine/app/scope';
|
|
21
|
+
import { resourceScope } from '@wildshard/engine/app/resources';
|
|
22
|
+
import type { Shardfile } from '@wildshard/format/shardSchema';
|
|
23
|
+
import { prepareRigLoader, loadRigFile, type ClipName, type SocketName } from "@wildshard/engine/anim/rig";
|
|
24
|
+
import { retainCachedResources } from "@wildshard/engine/app/cachedAssets";
|
|
25
|
+
import { cacheUntilDisposed } from "@wildshard/engine/app/disposalCache";
|
|
26
|
+
import { releaseOnUpload } from "@wildshard/engine/render/memorySaver";
|
|
27
|
+
import { ktx2File, prepareCompressedTexture } from "@wildshard/engine/core/ktx2";
|
|
28
|
+
import { RepeatWrapping, Matrix4, Bone, FileLoader, SkinnedMesh, Texture, type AnimationClip, type Wrapping, type MinificationTextureFilter, type MagnificationTextureFilter, Box3, Sphere, BufferGeometry, Float32BufferAttribute, Group, Mesh, MeshStandardMaterial, Uint16BufferAttribute, Vector3, BufferAttribute, InterleavedBufferAttribute, type Object3D, CanvasTexture, LinearMipmapLinearFilter, SRGBColorSpace, Float16BufferAttribute, BoxGeometry, CylinderGeometry, ConeGeometry, SphereGeometry, TorusGeometry, IcosahedronGeometry, CapsuleGeometry, Shape, ExtrudeGeometry, Color, type MeshStandardMaterialParameters, type Material, InstancedMesh } from "three";
|
|
29
|
+
import { applySurfaceLooks, type SurfaceInputs } from "../systems/looks/surfaceLooks";
|
|
30
|
+
import type { SurfaceLook } from "@wildshard/format/surfaceLooks";
|
|
31
|
+
import { Rng } from "@wildshard/engine/core/rng";
|
|
32
|
+
import type { SpeciesLook } from "@wildshard/engine/entities/species/look";
|
|
33
|
+
import { NO_FUR } from "@wildshard/engine/entities/species/rigs";
|
|
34
|
+
import { clipAnimate, stepCreatureLift, type SpeciesClips } from "../../../shared/game/plugin/animation";
|
|
35
|
+
import { numericCreaturePoseFromBook } from '../../../shared/game/plugin/channelPrograms';
|
|
36
|
+
import { parsePackedCreatureLooks } from '@wildshard/format/speciesLooks';
|
|
37
|
+
import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
38
|
+
import type { NpcMotion, NpcRow } from "../../../shared/game/plugin/quests";
|
|
39
|
+
|
|
40
|
+
type AnimalSpecies = ReturnType<SpeciesLook['build']>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A model library (SHARD-PLATFORM M3; ex a dune shard's generated models): the GLBs a level loads once behind its loading
|
|
44
|
+
* screen and then copies synchronously while it builds, each list driven by rows. Nothing here knows a shard.
|
|
45
|
+
*
|
|
46
|
+
* - facet models: every mesh of the file flattened into one non-indexed geometry in world space: position, the facet
|
|
47
|
+
* colour (rgb × the baked AO in COLOR_0's alpha, kept down to the row's `aoFloor`) and flat normals;
|
|
48
|
+
* - hero models: the scene as loaded (its own maps on its own UVs), matte and smooth, each material then dressed by the
|
|
49
|
+
* model's `HdLookRow` (tint, roughness, fog, user flags, surface-look rows);
|
|
50
|
+
*
|
|
51
|
+
* A file that fails to load is a page fault (`console.error`; the boot smoke and the tests fail on it), never a silent
|
|
52
|
+
* stand-in: the caller's copy is null and the thing it would draw stands undrawn. The helpers below (`fitGeometry`,
|
|
53
|
+
* `undrawnRig`) shape the copies; generators bind rigid bodies with `bindRigid` (`@wildshard/sharddev/bake/skinned`).
|
|
54
|
+
*
|
|
55
|
+
* Creature bodies (`creatureBodies`, over `skinnedModel`): standard skinned GLBs a generator baked (bones with their bind
|
|
56
|
+
* positions, parts, clips and the shard's extras), copied per spawn, each with its stand-in skeleton when it did not load.
|
|
57
|
+
*
|
|
58
|
+
* A transitional bridge (Jake, a44511f05: "quests and geometry stay as bridges"): this module is deleted once the geometry
|
|
59
|
+
* lives in the shards' generators.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/** How a hero model's materials are dressed after the matte base: each field optional, applied in this order. */
|
|
67
|
+
export interface HdLookRow {
|
|
68
|
+
/** the material colour, linear RGB */
|
|
69
|
+
readonly color?: readonly [number, number, number];
|
|
70
|
+
readonly roughness?: number;
|
|
71
|
+
readonly fog?: boolean;
|
|
72
|
+
/** flags the caller's own passes read off the material's userData */
|
|
73
|
+
readonly userData?: Readonly<Record<string, boolean>>;
|
|
74
|
+
/** surface-look rows installed over the library's surface inputs */
|
|
75
|
+
readonly surface?: readonly SurfaceLook[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A model library's files and looks, as data. */
|
|
79
|
+
export interface ModelLibraryRows<M extends string, H extends string> {
|
|
80
|
+
/** Plain mapped material before a compiled look is borrowed (for model viewers). */
|
|
81
|
+
readonly mappedFallback?: { readonly roughness: number; readonly metalness: number };
|
|
82
|
+
/** Named rest geometry paired with existing painted atlases; never fitted at runtime. */
|
|
83
|
+
readonly paintedModels?: readonly PaintedModelRow[];
|
|
84
|
+
/** the facet models preloaded, and every facet model's file */
|
|
85
|
+
readonly meshes: readonly M[];
|
|
86
|
+
/** One identity-space, non-indexed rest mesh with final float32 position/normal/colour channels; never refit or renormalize. */
|
|
87
|
+
readonly preparedMeshes?: readonly M[];
|
|
88
|
+
/** Named ordinary rest primitives, with exact authored channels/index/groups; materials remain caller-owned ports. */
|
|
89
|
+
readonly geometryPools?: readonly ModelGeometryPool[];
|
|
90
|
+
readonly meshUrls: Readonly<Record<M, string>>;
|
|
91
|
+
/** the hero models preloaded, and every hero model's file */
|
|
92
|
+
readonly hd: readonly H[];
|
|
93
|
+
readonly hdUrls: Readonly<Record<H, string>>;
|
|
94
|
+
/** a facet in full occlusion keeps this share of its colour */
|
|
95
|
+
readonly aoFloor: number;
|
|
96
|
+
/** the hero models' dressing, by name */
|
|
97
|
+
readonly hdLooks: Readonly<Partial<Record<H, HdLookRow>>>;
|
|
98
|
+
/** Optional baked rigs and look rows; absent retains the original model preload. */
|
|
99
|
+
readonly rigs?: RigLibraryRows;
|
|
100
|
+
/** Manual rig preload preserves a caller's existing preparation phase. */
|
|
101
|
+
readonly rigLoad?: 'manual';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** How a copy is framed: turned `yaw` about +Y, centred on x / z, its lowest point at `floor`, `size` metres by span or height. */
|
|
105
|
+
/** How `fitGeometry` frames a model; `centre: 'base'` centres x / z on its footing (the lowest tenth), not its whole box. */
|
|
106
|
+
export interface ModelFit { readonly size: number; readonly by: 'span' | 'height'; readonly floor?: number; readonly yaw?: number; readonly centre?: 'base' }
|
|
107
|
+
|
|
108
|
+
/** Original rigid GLB streams, decoded through attribute accessors before their world transform.
|
|
109
|
+
* Absent retains strict identity-space rest-pool admission. first selects one mesh into one declared slot.
|
|
110
|
+
* white creates the same immutable vertex-colour channel formerly initialized by held callers.
|
|
111
|
+
*/
|
|
112
|
+
export interface NativeModelPartPolicy { readonly first?: boolean; readonly requireIndex: boolean; readonly white?: boolean; readonly disposeSource?: boolean }
|
|
113
|
+
export interface ModelPbrAtlas { readonly map: Texture; readonly normalMap: Texture; readonly armMap: Texture }
|
|
114
|
+
export interface ModelGeometryPool {
|
|
115
|
+
readonly url: string; readonly parts: readonly string[]; readonly native?: NativeModelPartPolicy;
|
|
116
|
+
/** Explicit Float32 application channels; a part subset requires that channel on exactly those meshes. */
|
|
117
|
+
readonly channels?: readonly { readonly name: string; readonly source: string; readonly width: number; readonly parts?: readonly string[] }[];
|
|
118
|
+
readonly atlases?: readonly { readonly id: string; readonly part: string; readonly anisotropy: number; readonly refresh?: boolean }[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A loaded model library: preload once, then take copies. */
|
|
122
|
+
export interface ModelLibrary<M extends string, H extends string> {
|
|
123
|
+
/** Borrow the caller's compiled look book until its scope ends; no material is copied. */
|
|
124
|
+
readonly bindLooks: (scope: ResourceScope, ports: { readonly materials: ReadonlyMap<string, Material>; readonly bindMeshMap: (id: string, map: Texture | Material) => Material }) => void;
|
|
125
|
+
readonly look: (id: string) => Material | undefined;
|
|
126
|
+
readonly material: (id: string) => Material;
|
|
127
|
+
readonly mappedLook: (id: string, map: Texture | Material) => Material;
|
|
128
|
+
/** Load every listed model once (a failed one is skipped and faulted). */
|
|
129
|
+
preload: (pause?: () => Promise<void>) => Promise<void>;
|
|
130
|
+
/** Owned prepared geometry copies sharing their declared original atlas. */
|
|
131
|
+
painted: (name: string) => PaintedModel | null;
|
|
132
|
+
/** A copy of a loaded facet model's geometry, or null (not loaded: the caller's code model stands in). */
|
|
133
|
+
mesh: (name: M) => BufferGeometry | null;
|
|
134
|
+
/** An owned copy by default. borrow:true lends the immutable cached primitive: never transform, recolour, change attributes or dispose it. */
|
|
135
|
+
geometry: (name: string, options?: { readonly borrow?: boolean }) => BufferGeometry | null;
|
|
136
|
+
/** Borrow immutable original PBR textures; no texture clone, retint or new upload is introduced. */
|
|
137
|
+
readonly atlas: (id: string) => ModelPbrAtlas | null;
|
|
138
|
+
/** A hero model fitted as `fit`, as a group sharing the loaded geometry and maps; null when it did not load. */
|
|
139
|
+
hd: (name: H, fit: ModelFit) => Group | null;
|
|
140
|
+
/** A recipe's named hero, validated against this library before copying its existing fit. */
|
|
141
|
+
model: (name: string, fit: ModelFit) => Group | null;
|
|
142
|
+
readonly rig: (name: string) => AnimalSpecies;
|
|
143
|
+
readonly bakedRig: (name: string) => AnimalSpecies | null;
|
|
144
|
+
readonly looks: readonly SpeciesLook[];
|
|
145
|
+
readonly preloadRigs: () => Promise<void>;
|
|
146
|
+
/** Ordered Explorer models on this library's actual rig copies. */
|
|
147
|
+
readonly models: (rows: readonly ModelSpecimenRow[]) => ReturnType<typeof defineSceneModels>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const isMesh = (o: Object3D): o is Mesh => o instanceof Mesh;
|
|
151
|
+
|
|
152
|
+
/** One mesh's triangles in world space, de-indexed, as plain float32 (meshopt quantizes the attributes). */
|
|
153
|
+
function flatten(mesh: Mesh, aoFloor: number): { pos: number[]; col: number[] } {
|
|
154
|
+
const g = mesh.geometry, p = g.getAttribute('position'), c = g.hasAttribute('color') ? g.getAttribute('color') : null;
|
|
155
|
+
const index = g.getIndex(), n = index ? index.count : p.count, pos: number[] = [], col: number[] = [], v = new Vector3();
|
|
156
|
+
for (let k = 0; k < n; k++) {
|
|
157
|
+
const i = index ? index.getX(k) : k;
|
|
158
|
+
v.fromBufferAttribute(p, i).applyMatrix4(mesh.matrixWorld); pos.push(v.x, v.y, v.z);
|
|
159
|
+
const ao = c?.itemSize === 4 ? aoFloor + (1 - aoFloor) * c.getW(i) : 1;
|
|
160
|
+
col.push((c ? c.getX(i) : 1) * ao, (c ? c.getY(i) : 1) * ao, (c ? c.getZ(i) : 1) * ao);
|
|
161
|
+
}
|
|
162
|
+
return { pos, col };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** A hero material's matte base, then its look row. */
|
|
166
|
+
function dressHd(m: MeshStandardMaterial, look: HdLookRow | undefined, inputs: SurfaceInputs): void {
|
|
167
|
+
m.metalness = 0; m.roughness = 0.85; m.flatShading = false;
|
|
168
|
+
if (look !== undefined) {
|
|
169
|
+
if (look.color !== undefined) m.color.setRGB(look.color[0], look.color[1], look.color[2]);
|
|
170
|
+
if (look.roughness !== undefined) m.roughness = look.roughness;
|
|
171
|
+
if (look.fog !== undefined) m.fog = look.fog;
|
|
172
|
+
if (look.userData !== undefined) for (const [key, value] of Object.entries(look.userData)) m.userData[key] = value;
|
|
173
|
+
if (look.surface !== undefined) applySurfaceLooks(m, look.surface, inputs);
|
|
174
|
+
}
|
|
175
|
+
m.needsUpdate = true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* A model library over `rows`. `fault` opens every page fault a failed file logs (e.g. the shard's name in brackets);
|
|
180
|
+
* `surfaceInputs` are the live uniforms the hero models' surface rows read.
|
|
181
|
+
*/
|
|
182
|
+
/** A rest primitive paired with a painted GLB and optional body/head/arm/fore slots; null explicitly declares an empty slot. */
|
|
183
|
+
export interface PaintedModelRow { readonly name: string; readonly url: string; readonly geometry: string; readonly pivots?: readonly (string | null)[]; readonly releaseImage?: boolean }
|
|
184
|
+
/** Geometry stays in the authored frame; the map is shared, and reads clone every geometry. */
|
|
185
|
+
export interface PaintedModel { readonly geometry: BufferGeometry; readonly map: Texture; readonly pivots?: { readonly body: BufferGeometry; readonly head: BufferGeometry; readonly arm: BufferGeometry; readonly fore: BufferGeometry } }
|
|
186
|
+
|
|
187
|
+
const nativeFloat32Some: unknown = Reflect.get(Float32Array.prototype, 'some');
|
|
188
|
+
function hasNonfiniteFloat32(values: Float32Array): boolean {
|
|
189
|
+
const some: unknown = Reflect.get(values, 'some');
|
|
190
|
+
// Native validation still refuses detached/out-of-bounds empty views. Custom
|
|
191
|
+
// methods and length/prototype overrides retain their original scan, too.
|
|
192
|
+
if (some !== nativeFloat32Some || Object.getPrototypeOf(values) !== Float32Array.prototype || Object.hasOwn(values, 'length') || values.length === 0) {
|
|
193
|
+
if (typeof some !== 'function') throw new TypeError('Rest channel scan is not callable');
|
|
194
|
+
return Boolean(Reflect.apply(some, values, [(value: number) => !Number.isFinite(value)]));
|
|
195
|
+
}
|
|
196
|
+
const count = values.length;
|
|
197
|
+
for (let index = 0; index < count; index++) if (!Number.isFinite(values[index])) return true;
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
interface ModelLoadState { loading: Promise<void> | null }
|
|
202
|
+
|
|
203
|
+
// Resource listeners outlive the library that loaded them. Build them outside
|
|
204
|
+
// its lexical scope so a live mesh cannot retain the reader's product context.
|
|
205
|
+
function cacheModelEntry<K, V extends object>(memo: Map<K, V>, key: K, value: V, state: ModelLoadState): void {
|
|
206
|
+
retainCachedResources(value); memo.set(key, value);
|
|
207
|
+
cacheUntilDisposed(value, () => {
|
|
208
|
+
if (memo.get(key) === value) { memo.delete(key); state.loading = null; }
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Load named resources once; each owner takes independent geometry over shared painted textures. */
|
|
213
|
+
export function createModelLibrary<M extends string, H extends string>(rows: ModelLibraryRows<M, H>, fault: string, surfaceInputs: SurfaceInputs = {}, readModel: (url: string) => Promise<{ readonly scene: Object3D }> = loadRigFile, readAtlas?: (url: string) => Promise<Texture | null>): ModelLibrary<M, H> {
|
|
214
|
+
let lookPorts: Parameters<ModelLibrary<M, H>['bindLooks']>[1] | null = null;
|
|
215
|
+
const fallback = rows.mappedFallback;
|
|
216
|
+
if (fallback !== undefined && [fallback.roughness, fallback.metalness].some(value => !Number.isFinite(value) || value < 0 || value > 1)) throw new Error('Invalid mapped look fallback');
|
|
217
|
+
const ready = new Map<M, BufferGeometry>(), hd = new Map<H, Object3D>();
|
|
218
|
+
const painted = new Map<string, PaintedModel>(), paintedRows = rows.paintedModels ?? [];
|
|
219
|
+
const rest = new Map<string, BufferGeometry>(), atlases = new Map<string, ModelPbrAtlas>();
|
|
220
|
+
const rigs = rows.rigs === undefined ? null : rigLibrary(rows.rigs);
|
|
221
|
+
const state: ModelLoadState = { loading: null };
|
|
222
|
+
const pools = rows.geometryPools ?? [], parts = pools.flatMap(pool => pool.parts), atlasRows = pools.flatMap(pool => pool.atlases ?? []);
|
|
223
|
+
if (pools.length > 16 || parts.length > 128 || new Set(parts).size !== parts.length) throw new Error('Model library requires unique bounded rest geometry parts');
|
|
224
|
+
if (atlasRows.length > 128 || new Set(atlasRows.map(row => row.id)).size !== atlasRows.length
|
|
225
|
+
|| pools.some(pool => pool.native?.first === true && pool.parts.length !== 1
|
|
226
|
+
|| (pool.atlases ?? []).some(row => !pool.parts.includes(row.part) || !Number.isFinite(row.anisotropy) || row.anisotropy < 1 || row.anisotropy > 32))) throw new Error('Invalid declared native pool/atlas slots');
|
|
227
|
+
for (const pool of pools) {
|
|
228
|
+
const channels = pool.channels ?? [];
|
|
229
|
+
if (channels.length > 16 || pool.native !== undefined && channels.length > 0
|
|
230
|
+
|| new Set(channels.map(row => row.name)).size !== channels.length || new Set(channels.map(row => row.source)).size !== channels.length
|
|
231
|
+
|| channels.some(row => !/^[A-Za-z][A-Za-z0-9_]{0,63}$/u.test(row.name) || ['position','normal','color','uv','uv1','tangent','constructor','prototype','__proto__'].includes(row.name)
|
|
232
|
+
|| (!/^_[a-z0-9_]{1,63}$/u.test(row.source) || row.source === '__proto__') || ![1,2,3,4].includes(row.width)
|
|
233
|
+
|| row.parts !== undefined && (row.parts.length === 0 || row.parts.length > pool.parts.length || new Set(row.parts).size !== row.parts.length || row.parts.some(part => !pool.parts.includes(part))))) throw new Error('Invalid declared rest channels');
|
|
234
|
+
}
|
|
235
|
+
if (paintedRows.length > 128 || new Set(paintedRows.map(row => row.name)).size !== paintedRows.length
|
|
236
|
+
|| paintedRows.some(row => !parts.includes(row.geometry) || row.pivots !== undefined && (row.pivots.length !== 4 || row.pivots.some(part => part !== null && !parts.includes(part))))) throw new Error('Painted models require declared rest primitives and four pivot slots');
|
|
237
|
+
|
|
238
|
+
async function loadPainted(row: PaintedModelRow, geometryReady: Promise<void>): Promise<void> {
|
|
239
|
+
try {
|
|
240
|
+
const maps: Texture[] = [];
|
|
241
|
+
if (readAtlas !== undefined) { const atlas = await readAtlas(row.url); if (atlas !== null) maps.push(atlas); }
|
|
242
|
+
else { const source = await readModel(row.url); source.scene.traverse(node => {
|
|
243
|
+
if (maps.length > 0 || !isMesh(node)) return;
|
|
244
|
+
const material = Array.isArray(node.material) ? node.material[0] : node.material;
|
|
245
|
+
if (material instanceof MeshStandardMaterial && material.map !== null && node.geometry.hasAttribute('uv') && node.geometry.index !== null) maps.push(material.map);
|
|
246
|
+
}); }
|
|
247
|
+
// Atlas transport can overlap rest geometry, but publication cannot.
|
|
248
|
+
await geometryReady;
|
|
249
|
+
const map = maps[0], geometry = rest.get(row.geometry);
|
|
250
|
+
if (map === undefined || geometry === undefined) throw new Error('Prepared painted resources unavailable');
|
|
251
|
+
const part = (index: number): BufferGeometry => {
|
|
252
|
+
const name = row.pivots?.[index];
|
|
253
|
+
if (name === undefined) throw new Error('Missing declared pivot slot');
|
|
254
|
+
if (name !== null) { const found = rest.get(name); if (found === undefined) throw new Error('Missing declared pivot geometry'); return found; }
|
|
255
|
+
const empty = new BufferGeometry();
|
|
256
|
+
for (const [channel, size] of [['position', 3], ['normal', 3], ['uv', 2]] as const) empty.setAttribute(channel, new Float32BufferAttribute([], size));
|
|
257
|
+
empty.computeBoundingBox(); empty.computeBoundingSphere(); return empty;
|
|
258
|
+
};
|
|
259
|
+
const made: PaintedModel = { geometry, map, ...(row.pivots === undefined ? {} : { pivots: { body: part(0), head: part(1), arm: part(2), fore: part(3) } }) };
|
|
260
|
+
const image: unknown = map.image;
|
|
261
|
+
if (row.releaseImage === true && typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) releaseOnUpload(map.source, () => { image.close(); });
|
|
262
|
+
cacheModelEntry(painted, row.name, made, state);
|
|
263
|
+
} catch (error: unknown) {
|
|
264
|
+
// Keep the geometry failure ahead of a later atlas fault.
|
|
265
|
+
await geometryReady;
|
|
266
|
+
console.error(`${fault} the painted model ${row.name} did not load:`, error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Overlap a bounded set of immutable model reads with the default parser's
|
|
271
|
+
// serial, shared-budget decode slot. Keep the caller's original pause order.
|
|
272
|
+
async function loadPaintedAhead(missing: readonly PaintedModelRow[], pause: () => Promise<void>, geometryReady: Promise<void>): Promise<void> {
|
|
273
|
+
const pending = new Map<number, Promise<void>>();
|
|
274
|
+
let next = 0;
|
|
275
|
+
const fill = (): void => {
|
|
276
|
+
while (pending.size < 4 && next < missing.length) {
|
|
277
|
+
const row = missing[next];
|
|
278
|
+
if (row === undefined) throw new Error('Missing painted model row');
|
|
279
|
+
const loading = loadPainted(row, geometryReady); void loading.catch(() => undefined);
|
|
280
|
+
pending.set(next++, loading);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
try {
|
|
284
|
+
fill();
|
|
285
|
+
for (let index = 0; index < missing.length; index++) {
|
|
286
|
+
const loading = pending.get(index);
|
|
287
|
+
if (loading === undefined) throw new Error('Missing painted model read');
|
|
288
|
+
await loading; pending.delete(index);
|
|
289
|
+
await pause(); fill();
|
|
290
|
+
}
|
|
291
|
+
} finally {
|
|
292
|
+
// A retired caller stops admitting rows, but releases its input lease only
|
|
293
|
+
// after every read/parse already started has settled.
|
|
294
|
+
await Promise.allSettled(pending.values());
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async function loadPool(pool: ModelGeometryPool): Promise<void> {
|
|
299
|
+
try {
|
|
300
|
+
const gltf = await readModel(pool.url), nodes: Mesh[] = [];
|
|
301
|
+
gltf.scene.updateMatrixWorld(true); gltf.scene.traverse(node => { if (isMesh(node)) nodes.push(node); });
|
|
302
|
+
if (nodes.length > 128 || new Set(nodes.map(node => node.name)).size !== nodes.length) throw new Error('Rest pool has repeated or excessive meshes');
|
|
303
|
+
const prepared = new Map<string, BufferGeometry>(), borrowed = new Map<string, ModelPbrAtlas>();
|
|
304
|
+
const selected = (name: string): Mesh => {
|
|
305
|
+
const node = pool.native?.first === true ? nodes[0] : nodes.find(candidate => candidate.name === name);
|
|
306
|
+
if (node?.type !== 'Mesh') throw new Error('Rest pool is missing an ordinary declared mesh'); return node;
|
|
307
|
+
};
|
|
308
|
+
for (const row of pool.atlases ?? []) {
|
|
309
|
+
const material = selected(row.part).material;
|
|
310
|
+
if (Array.isArray(material) || !(material instanceof MeshStandardMaterial)) throw new Error('Declared native atlas requires one PBR material');
|
|
311
|
+
const {map, normalMap, roughnessMap} = material;
|
|
312
|
+
if (map === null || normalMap === null || roughnessMap === null) throw new Error('Declared native PBR atlas map is missing');
|
|
313
|
+
for (const texture of [map, normalMap, roughnessMap]) { texture.anisotropy = row.anisotropy; if (row.refresh === true) texture.needsUpdate = true; }
|
|
314
|
+
borrowed.set(row.id, {map, normalMap, armMap: roughnessMap});
|
|
315
|
+
}
|
|
316
|
+
if (pool.native !== undefined) {
|
|
317
|
+
for (const name of pool.parts) {
|
|
318
|
+
const node = selected(name), source = node.geometry, position = source.attributes['position'], geometry = new BufferGeometry();
|
|
319
|
+
if (position === undefined || position.count < 1 || position.count > 400_000 || Object.keys(source.morphAttributes).length > 0) throw new Error('Native pool requires bounded rigid positions');
|
|
320
|
+
for (const [channel, width] of [['position',3],['normal',3],['uv',2]] as const) {
|
|
321
|
+
const input = source.attributes[channel]; if (input === undefined || input.count !== position.count || input.itemSize !== width) throw new Error('Native pool is missing its original vertex channels');
|
|
322
|
+
const values = new Float32Array(input.count * width);
|
|
323
|
+
for (let i = 0; i < input.count; i++) { values[i * width] = input.getX(i); values[i * width + 1] = input.getY(i); if (width > 2) values[i * width + 2] = input.getZ(i); }
|
|
324
|
+
if (values.some(value => !Number.isFinite(value))) throw new Error('Native pool has nonfinite vertices');
|
|
325
|
+
geometry.setAttribute(channel, new BufferAttribute(values, width));
|
|
326
|
+
}
|
|
327
|
+
const index = source.getIndex();
|
|
328
|
+
if (index === null && pool.native.requireIndex) throw new Error('Native pool requires the original index');
|
|
329
|
+
if (index !== null) { if (index.array.some(value => !Number.isInteger(value) || value < 0 || value >= position.count)) throw new Error('Native index is outside its vertex roster'); geometry.setIndex(new BufferAttribute(Uint32Array.from(index.array),1)); }
|
|
330
|
+
node.updateWorldMatrix(true, false); geometry.applyMatrix4(node.matrixWorld); geometry.computeBoundingSphere();
|
|
331
|
+
if (pool.native.white === true) geometry.setAttribute('color', new BufferAttribute(new Float32Array(position.count * 3).fill(1), 3));
|
|
332
|
+
if (pool.native.disposeSource === true) source.dispose(); prepared.set(name, geometry);
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
if (nodes.length !== pool.parts.length || new Set(nodes.map(node => node.name)).size !== nodes.length) throw new Error('Rest pool part roster differs');
|
|
336
|
+
for (const name of pool.parts) {
|
|
337
|
+
const node = nodes.find(candidate => candidate.name === name);
|
|
338
|
+
// I3: a grid-quantized cast (compactPhoneGlb: grid node, normalized channels) reads back as its identity-space Float32 mesh
|
|
339
|
+
const decoded = node?.type === 'Mesh' && !node.matrixWorld.equals(new Matrix4()) ? identitySpaceGeometry(node) : null;
|
|
340
|
+
if (node?.type !== 'Mesh' || (decoded === null && !node.matrixWorld.equals(new Matrix4()))) throw new Error('Rest pool requires named identity-space ordinary meshes');
|
|
341
|
+
if (decoded !== null) node.geometry.dispose();
|
|
342
|
+
const geometry = decoded ?? node.geometry, position = geometry.getAttribute('position');
|
|
343
|
+
if (!(position instanceof BufferAttribute) || position.count === 0 || position.count > 400_000 || Object.keys(geometry.morphAttributes).length > 0) throw new Error('Rest pool requires bounded rigid positions');
|
|
344
|
+
const channels = (pool.channels ?? []).filter(row => row.parts === undefined || row.parts.includes(name));
|
|
345
|
+
for (const [channel, attribute] of Object.entries(geometry.attributes)) {
|
|
346
|
+
const width = ['uv','uv1'].includes(channel) ? 2 : channel === 'tangent' ? 4 : ['position', 'normal', 'color'].includes(channel) ? 3 : channels.find(row => row.source === channel)?.width;
|
|
347
|
+
if (width === undefined || !(attribute instanceof BufferAttribute) || !(attribute.array instanceof Float32Array)
|
|
348
|
+
|| attribute.normalized || attribute.itemSize !== width || attribute.count !== position.count || hasNonfiniteFloat32(attribute.array)) throw new Error('Rest pool has incompatible Float32 channels');
|
|
349
|
+
}
|
|
350
|
+
for (const row of channels) {
|
|
351
|
+
const attribute: unknown = geometry.attributes[row.source];
|
|
352
|
+
if (!(attribute instanceof BufferAttribute) || geometry.hasAttribute(row.name)) throw new Error('Missing or colliding declared rest channel');
|
|
353
|
+
geometry.deleteAttribute(row.source); geometry.setAttribute(row.name, attribute);
|
|
354
|
+
}
|
|
355
|
+
const index = geometry.index;
|
|
356
|
+
if (index !== null && (!(index.array instanceof Uint16Array) && !(index.array instanceof Uint32Array)
|
|
357
|
+
|| index.normalized || index.itemSize !== 1 || index.array.some(value => value >= position.count))) throw new Error('Rest pool has incompatible index words');
|
|
358
|
+
const groups: unknown = node.userData['restGroups'], sphere: unknown = node.userData['restSphere'], box: unknown = node.userData['restBox'];
|
|
359
|
+
if (!Array.isArray(groups) || groups.length > 32) throw new Error('Rest pool has no bounded original groups');
|
|
360
|
+
geometry.clearGroups();
|
|
361
|
+
for (const group of groups) {
|
|
362
|
+
if (!Array.isArray(group) || group.length !== 3) throw new Error('Rest pool group differs');
|
|
363
|
+
const start: unknown = group[0], count: unknown = group[1], material: unknown = group[2];
|
|
364
|
+
if (typeof start !== 'number' || !Number.isSafeInteger(start) || start < 0 || typeof count !== 'number' || !Number.isSafeInteger(count) || count < 0
|
|
365
|
+
|| start + count > (index?.count ?? position.count) || typeof material !== 'number' || !Number.isSafeInteger(material) || material < 0 || material > 31) throw new Error('Rest pool group extent differs');
|
|
366
|
+
geometry.addGroup(start, count, material);
|
|
367
|
+
}
|
|
368
|
+
geometry.boundingBox = null;
|
|
369
|
+
if (box !== null) {
|
|
370
|
+
if (!Array.isArray(box) || box.length !== 6) throw new Error('Rest pool box differs');
|
|
371
|
+
const x: unknown = box[0], y: unknown = box[1], z: unknown = box[2], maxX: unknown = box[3], maxY: unknown = box[4], maxZ: unknown = box[5];
|
|
372
|
+
if (typeof x !== 'number' || !Number.isFinite(x) || typeof y !== 'number' || !Number.isFinite(y) || typeof z !== 'number' || !Number.isFinite(z)
|
|
373
|
+
|| typeof maxX !== 'number' || !Number.isFinite(maxX) || typeof maxY !== 'number' || !Number.isFinite(maxY) || typeof maxZ !== 'number' || !Number.isFinite(maxZ)
|
|
374
|
+
|| x > maxX || y > maxY || z > maxZ) throw new Error('Rest pool box differs');
|
|
375
|
+
geometry.boundingBox = new Box3(new Vector3(x,y,z),new Vector3(maxX,maxY,maxZ));
|
|
376
|
+
}
|
|
377
|
+
geometry.boundingSphere = null;
|
|
378
|
+
if (sphere !== null) {
|
|
379
|
+
if (!Array.isArray(sphere) || sphere.length !== 4) throw new Error('Rest pool sphere differs');
|
|
380
|
+
const x: unknown = sphere[0], y: unknown = sphere[1], z: unknown = sphere[2], radius: unknown = sphere[3];
|
|
381
|
+
if (typeof x !== 'number' || !Number.isFinite(x) || typeof y !== 'number' || !Number.isFinite(y) || typeof z !== 'number' || !Number.isFinite(z)
|
|
382
|
+
|| typeof radius !== 'number' || !Number.isFinite(radius) || radius < 0) throw new Error('Rest pool sphere differs');
|
|
383
|
+
geometry.boundingSphere = new Sphere(new Vector3(x, y, z), radius);
|
|
384
|
+
}
|
|
385
|
+
prepared.set(name, geometry);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
for (const [id, atlas] of borrowed) {
|
|
389
|
+
cacheModelEntry(atlases, id, atlas, state);
|
|
390
|
+
}
|
|
391
|
+
for (const [name, geometry] of prepared) {
|
|
392
|
+
cacheModelEntry(rest, name, geometry, state);
|
|
393
|
+
}
|
|
394
|
+
} catch (error: unknown) { console.error(`${fault} the rest geometry pool did not load:`, error); }
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async function load(name: M): Promise<void> {
|
|
398
|
+
try {
|
|
399
|
+
const gltf = await readModel(rows.meshUrls[name]);
|
|
400
|
+
gltf.scene.updateMatrixWorld(true);
|
|
401
|
+
let g: BufferGeometry;
|
|
402
|
+
if (rows.preparedMeshes?.includes(name) === true) {
|
|
403
|
+
const meshes: Mesh[] = []; gltf.scene.traverse(node => { if (isMesh(node)) meshes.push(node); });
|
|
404
|
+
const mesh = meshes[0], identity = new Matrix4();
|
|
405
|
+
if (meshes.length !== 1 || mesh === undefined || !mesh.matrixWorld.equals(identity) || mesh.geometry.index !== null
|
|
406
|
+
|| ['position', 'normal', 'color'].some(channel => { const a = mesh.geometry.getAttribute(channel); return !(a instanceof Float32BufferAttribute || a instanceof BufferAttribute) || !(a.array instanceof Float32Array) || a.normalized || a.itemSize !== 3 || a.count !== mesh.geometry.getAttribute('position').count; })) throw new Error(`${name}: incompatible prepared facet channels`);
|
|
407
|
+
g = mesh.geometry.clone(); g.boundingSphere = null;
|
|
408
|
+
} else {
|
|
409
|
+
const pos: number[] = [], col: number[] = [];
|
|
410
|
+
gltf.scene.traverse((o) => { if (isMesh(o)) { const f = flatten(o, rows.aoFloor); pos.push(...f.pos); col.push(...f.col); } });
|
|
411
|
+
if (pos.length === 0) throw new Error(`${name}: no mesh`);
|
|
412
|
+
g = new BufferGeometry();
|
|
413
|
+
g.setAttribute('position', new Float32BufferAttribute(pos, 3)); g.setAttribute('color', new Float32BufferAttribute(col, 3));
|
|
414
|
+
g.computeVertexNormals();
|
|
415
|
+
}
|
|
416
|
+
g.computeBoundingBox(); cacheModelEntry(ready, name, g, state);
|
|
417
|
+
} catch (e: unknown) { console.error(`${fault} the generated model ${name} did not load:`, e); }
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
async function loadHd(name: H): Promise<void> {
|
|
421
|
+
try {
|
|
422
|
+
const { scene } = await readModel(rows.hdUrls[name]), look = rows.hdLooks[name];
|
|
423
|
+
scene.traverse((o) => {
|
|
424
|
+
if (!isMesh(o)) return;
|
|
425
|
+
for (const m of Array.isArray(o.material) ? o.material : [o.material]) if (m instanceof MeshStandardMaterial) dressHd(m, look, surfaceInputs);
|
|
426
|
+
});
|
|
427
|
+
// Only the reusable scene belongs to the memo. Its disposal observer
|
|
428
|
+
// must not retain the consumed GLTF parser and transport dependencies.
|
|
429
|
+
cacheModelEntry(hd, name, scene, state);
|
|
430
|
+
} catch (e: unknown) { console.error(`${fault} the generated model ${name} did not load:`, e); }
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const heroCopy = (name: H, o: ModelFit): Group | null => {
|
|
434
|
+
const src = hd.get(name); if (!src) return null;
|
|
435
|
+
const inner = src.clone(true), holder = new Group(), turn = new Group();
|
|
436
|
+
turn.rotation.y = o.yaw ?? 0; turn.add(inner); holder.add(turn); holder.updateMatrixWorld(true);
|
|
437
|
+
const b = new Box3().setFromObject(holder);
|
|
438
|
+
const span = o.by === 'height' ? b.max.y - b.min.y : Math.max(b.max.x - b.min.x, b.max.z - b.min.z), k = o.size / Math.max(1e-6, span);
|
|
439
|
+
turn.position.set(-(b.min.x + b.max.x) / 2, -b.min.y, -(b.min.z + b.max.z) / 2);
|
|
440
|
+
const out = new Group(); out.add(holder); holder.scale.setScalar(k); holder.position.y = o.floor ?? 0;
|
|
441
|
+
return out;
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
return {
|
|
445
|
+
bindLooks: (scope, ports) => {
|
|
446
|
+
if (scope.disposed) throw new Error('Cannot borrow looks from a disposed scope');
|
|
447
|
+
lookPorts = ports; scope.onDispose(() => { if (lookPorts === ports) lookPorts = null; });
|
|
448
|
+
},
|
|
449
|
+
look: id => lookPorts?.materials.get(id),
|
|
450
|
+
material: id => { const material = lookPorts?.materials.get(id); if (material === undefined) throw new Error(`Missing borrowed model material ${id}`); return material; },
|
|
451
|
+
mappedLook: (id, map) => {
|
|
452
|
+
if (lookPorts?.materials.has(id) === true) return lookPorts.bindMeshMap(id, map);
|
|
453
|
+
if (fallback === undefined) throw new Error('Model library has no declared mapped fallback');
|
|
454
|
+
if (!(map instanceof Texture)) { const copied = map.clone(); Object.assign(copied, fallback); return copied; }
|
|
455
|
+
return new MeshStandardMaterial({ map, ...fallback });
|
|
456
|
+
},
|
|
457
|
+
preload: (pause) => {
|
|
458
|
+
state.loading ??= (async () => {
|
|
459
|
+
try {
|
|
460
|
+
const geometryReady = Promise.all([...rows.meshes.filter(name => !ready.has(name)).map(load), ...rows.hd.filter(name => !hd.has(name)).map(loadHd),
|
|
461
|
+
...pools.filter(pool => pool.parts.some(name => !rest.has(name)) || (pool.atlases ?? []).some(row => !atlases.has(row.id))).map(loadPool)]).then(() => undefined);
|
|
462
|
+
const missing = paintedRows.filter(row => !painted.has(row.name));
|
|
463
|
+
// Start at most the existing four atlas reads during geometry intake.
|
|
464
|
+
// Publish state.loading before an atlas reader can re-enter preload.
|
|
465
|
+
// Every model publication and caller pause still waits for geometry.
|
|
466
|
+
const painting = pause === undefined ? geometryReady.then(() => Promise.all(missing.map(row => loadPainted(row, geometryReady))))
|
|
467
|
+
: Promise.resolve().then(() => loadPaintedAhead(missing, pause, geometryReady));
|
|
468
|
+
const [geometryResult, paintedResult] = await Promise.allSettled([geometryReady, painting]);
|
|
469
|
+
if (geometryResult.status === 'rejected') throw geometryResult.reason;
|
|
470
|
+
if (paintedResult.status === 'rejected') throw paintedResult.reason;
|
|
471
|
+
} catch (error: unknown) { state.loading = null; throw error; }
|
|
472
|
+
})();
|
|
473
|
+
return rigs === null || rows.rigLoad === 'manual' ? state.loading : Promise.all([state.loading, rigs.bodies.preload()]).then(() => undefined);
|
|
474
|
+
},
|
|
475
|
+
rig: name => { if (rigs === null) throw new Error('Model library has no declared rigs'); return rigs.bodies.bodyOrStandIn(name); },
|
|
476
|
+
bakedRig: name => rigs?.bodies.body(name) ?? null,
|
|
477
|
+
looks: rigs?.looks ?? [],
|
|
478
|
+
preloadRigs: () => rigs?.bodies.preload() ?? Promise.resolve(),
|
|
479
|
+
models: specimens => modelCatalogue(specimens, { rig: name => { if (rigs === null) throw new Error('Model library has no declared rigs'); return rigs.bodies.bodyOrStandIn(name); } }),
|
|
480
|
+
mesh: name => ready.get(name)?.clone() ?? null,
|
|
481
|
+
geometry: (name, options) => { const value=rest.get(name); return value===undefined?null:options?.borrow===true?value:value.clone(); },
|
|
482
|
+
atlas: id => atlases.get(id) ?? null,
|
|
483
|
+
painted: name => {
|
|
484
|
+
const model = painted.get(name); if (model === undefined) return null;
|
|
485
|
+
return { geometry: model.geometry.clone(), map: model.map, ...(model.pivots === undefined ? {} : { pivots: { body: model.pivots.body.clone(), head: model.pivots.head.clone(), arm: model.pivots.arm.clone(), fore: model.pivots.fore.clone() } }) };
|
|
486
|
+
},
|
|
487
|
+
hd: heroCopy,
|
|
488
|
+
model: (name, fit) => { const key = rows.hd.find(candidate => candidate === name); if (key === undefined) throw new Error('Unknown declared hero model'); return heroCopy(key, fit); },
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/** How a painted image samples (each field optional: three's texture default otherwise) and whether it frees its decode. */
|
|
493
|
+
export interface PaintedSampler {
|
|
494
|
+
readonly wrapS?: Wrapping;
|
|
495
|
+
readonly wrapT?: Wrapping;
|
|
496
|
+
readonly mips?: boolean;
|
|
497
|
+
readonly minFilter?: MinificationTextureFilter;
|
|
498
|
+
readonly magFilter?: MagnificationTextureFilter;
|
|
499
|
+
readonly anisotropy?: number;
|
|
500
|
+
/** Memory saver: the decoded image goes at its upload (nothing reads it on the CPU) or when the texture retires */
|
|
501
|
+
readonly release?: boolean;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* A painted image as an sRGB texture named `name`, fetched and decoded off the main thread (an ImageBitmap, flipped at
|
|
506
|
+
* decode as the engine's own loader does, so its v runs up like a TextureLoader image's), sampled as `sampler`; null when
|
|
507
|
+
* it cannot be had (offline, a test page), with `console.warn(warn, error)`: the caller keeps its stand-in. A plain fetch
|
|
508
|
+
* fails fast where an <img> would hang a headless test. Already flipped, it is unflagged (`flipY` false, as the engine's
|
|
509
|
+
* loader leaves a bitmap): a graph's node sampler flips a flagged ImageBitmap again, so a flagged one sampled upside down
|
|
510
|
+
* until the Memory saver dropped its bitmap; a classic upload ignores the flag on a bitmap either way.
|
|
511
|
+
*/
|
|
512
|
+
export async function loadPaintedTexture(url: string, name: string, warn: string, sampler: PaintedSampler = {}): Promise<Texture | null> {
|
|
513
|
+
try {
|
|
514
|
+
const response = await fetch(url);
|
|
515
|
+
if (!response.ok) throw new Error(`${String(response.status)} ${url}`);
|
|
516
|
+
const bitmap = await createImageBitmap(await response.blob(), { imageOrientation: 'flipY' });
|
|
517
|
+
const tex = new Texture(bitmap); tex.colorSpace = SRGBColorSpace; tex.name = name; tex.flipY = false;
|
|
518
|
+
if (sampler.release === true) { cacheUntilDisposed(tex, () => { bitmap.close(); }); releaseOnUpload(tex.source, () => { bitmap.close(); }); }
|
|
519
|
+
if (sampler.wrapS !== undefined) tex.wrapS = sampler.wrapS;
|
|
520
|
+
if (sampler.wrapT !== undefined) tex.wrapT = sampler.wrapT;
|
|
521
|
+
if (sampler.mips !== undefined) tex.generateMipmaps = sampler.mips;
|
|
522
|
+
if (sampler.minFilter !== undefined) tex.minFilter = sampler.minFilter;
|
|
523
|
+
if (sampler.magFilter !== undefined) tex.magFilter = sampler.magFilter;
|
|
524
|
+
if (sampler.anisotropy !== undefined) tex.anisotropy = sampler.anisotropy;
|
|
525
|
+
tex.needsUpdate = true;
|
|
526
|
+
return tex;
|
|
527
|
+
} catch (error: unknown) {
|
|
528
|
+
console.warn(warn, error);
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** A creature that did not load stands undrawn: one zero-area triangle on bone 0 (a species needs a geometry part). */
|
|
534
|
+
export function undrawnRig(): BufferGeometry {
|
|
535
|
+
const g = new BufferGeometry();
|
|
536
|
+
g.setAttribute('position', new Float32BufferAttribute(new Float32Array(9), 3)); g.setAttribute('color', new Float32BufferAttribute(new Float32Array(9), 3));
|
|
537
|
+
g.setAttribute('normal', new Float32BufferAttribute(new Float32Array(9), 3));
|
|
538
|
+
g.setAttribute('skinIndex', new Uint16BufferAttribute(new Uint16Array(12), 4)); g.setAttribute('skinWeight', new Float32BufferAttribute([1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], 4));
|
|
539
|
+
return g;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** A baked joint: its name, its parent's name (null for a root) and its exact bind position (BoneDef's shape). */
|
|
543
|
+
export interface SkinnedJoint { readonly name: string; readonly parent: string | null; readonly pos: [number, number, number] }
|
|
544
|
+
/** One skinned part: an independent geometry copy (skinIndex / skinWeight over `bones`) and its shared base-colour map. */
|
|
545
|
+
export interface SkinnedAssetPart { readonly name: string; readonly geometry: BufferGeometry; readonly map: Texture | null }
|
|
546
|
+
export interface SkinnedAsset {
|
|
547
|
+
readonly bones: readonly SkinnedJoint[];
|
|
548
|
+
readonly parts: readonly SkinnedAssetPart[];
|
|
549
|
+
/** The baked animations (shared, never mutated). */
|
|
550
|
+
readonly clips: readonly AnimationClip[];
|
|
551
|
+
/** The shard's own JSON the generator wrote beside the model. */
|
|
552
|
+
readonly extras: unknown;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* An offline skinned model (`@wildshard/sharddev/bake/skinned` writes it): load once behind the loading screen, then take
|
|
556
|
+
* copies. Each `copy()` hands out independent geometry (safe to merge, scale or dispose) bit-exact to what the generator
|
|
557
|
+
* baked: every channel as written, the weights never renormalized, an authored triangle soup restored, the joints' exact
|
|
558
|
+
* bind positions. The maps, clips and extras are shared. No services are installed on import.
|
|
559
|
+
*/
|
|
560
|
+
export interface SkinnedModel {
|
|
561
|
+
/** Load the GLB through three's loading manager (the engine's tier / KTX2 / version URL policy applies, as to any
|
|
562
|
+
* three loader); explicit bytes let a Node baker or test use the identical intake. */
|
|
563
|
+
load: (bytes?: Uint8Array) => Promise<void>;
|
|
564
|
+
loaded: () => boolean;
|
|
565
|
+
copy: () => SkinnedAsset;
|
|
566
|
+
/** The shared maps every copy draws with (for the owner's cache and upload policy). */
|
|
567
|
+
textures: () => readonly Texture[];
|
|
568
|
+
/** The loaded parts every copy clones (kept once, for the owner's cache policy). */
|
|
569
|
+
geometries: () => readonly BufferGeometry[];
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const isSkinnedMesh = (node: Object3D): node is SkinnedMesh => node instanceof SkinnedMesh;
|
|
573
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
574
|
+
/** The meshopt decoder's glTF entry (three's bundled decoder). */
|
|
575
|
+
interface MeshoptGltf { decodeGltfBuffer: (target: Uint8Array, count: number, size: number, source: Uint8Array, mode: string, filter?: string) => void }
|
|
576
|
+
const numbers = (value: unknown): number[] | null => Array.isArray(value) && value.every((n: unknown) => typeof n === 'number') ? value : null;
|
|
577
|
+
|
|
578
|
+
/** Each primitive's raw WEIGHTS_0 floats, read from the GLB's bytes before three's loader renormalizes them in place (a
|
|
579
|
+
* meshopt view decoded here, once at load, losslessly). */
|
|
580
|
+
function rawWeights(bytes: Uint8Array, decoder: MeshoptGltf): Map<string, Float32Array> {
|
|
581
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength), length = view.getUint32(12, true);
|
|
582
|
+
const doc: unknown = JSON.parse(new TextDecoder().decode(bytes.subarray(20, 20 + length)));
|
|
583
|
+
const out = new Map<string, Float32Array>();
|
|
584
|
+
if (!isRecord(doc) || !Array.isArray(doc['meshes']) || !Array.isArray(doc['accessors']) || !Array.isArray(doc['bufferViews'])) return out;
|
|
585
|
+
const accessors: unknown[] = doc['accessors'], views: unknown[] = doc['bufferViews'], bin = bytes.subarray(28 + length);
|
|
586
|
+
const int = (record: Record<string, unknown>, key: string): number => typeof record[key] === 'number' ? record[key] : 0;
|
|
587
|
+
doc['meshes'].forEach((mesh: unknown, m) => {
|
|
588
|
+
if (!isRecord(mesh) || !Array.isArray(mesh['primitives'])) return;
|
|
589
|
+
mesh['primitives'].forEach((row: unknown, p) => {
|
|
590
|
+
const attributes = isRecord(row) && isRecord(row['attributes']) ? row['attributes'] : {}, id = attributes['WEIGHTS_0'];
|
|
591
|
+
const accessor = typeof id === 'number' ? accessors[id] : undefined, bufferView = isRecord(accessor) && typeof accessor['bufferView'] === 'number' ? views[accessor['bufferView']] : undefined;
|
|
592
|
+
if (!isRecord(accessor) || !isRecord(bufferView) || accessor['componentType'] !== 5126 || typeof accessor['count'] !== 'number') return;
|
|
593
|
+
const ext = isRecord(bufferView['extensions']) ? bufferView['extensions']['EXT_meshopt_compression'] : undefined;
|
|
594
|
+
let source = bin.subarray(int(bufferView, 'byteOffset'), int(bufferView, 'byteOffset') + int(bufferView, 'byteLength'));
|
|
595
|
+
if (isRecord(ext)) {
|
|
596
|
+
const count = int(ext, 'count'), stride = int(ext, 'byteStride'), at = int(ext, 'byteOffset'), decoded = new Uint8Array(count * stride);
|
|
597
|
+
decoder.decodeGltfBuffer(decoded, count, stride, bin.subarray(at, at + int(ext, 'byteLength')), String(ext['mode']), typeof ext['filter'] === 'string' ? ext['filter'] : 'NONE');
|
|
598
|
+
source = decoded;
|
|
599
|
+
}
|
|
600
|
+
const floats = new DataView(source.buffer, source.byteOffset, source.byteLength), start = int(accessor, 'byteOffset'), weights = new Float32Array(accessor['count'] * 4);
|
|
601
|
+
for (let i = 0; i < weights.length; i++) weights[i] = floats.getFloat32(start + i * 4, true);
|
|
602
|
+
out.set(`${String(m)}/${String(p)}`, weights);
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
return out;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** A skinned model over one baked GLB (`url`); nothing loads until `load()`. */
|
|
609
|
+
export function skinnedModel(url: string): SkinnedModel {
|
|
610
|
+
let template: SkinnedAsset | undefined, pending: Promise<void> | undefined;
|
|
611
|
+
const load = async (bytes?: Uint8Array): Promise<void> => {
|
|
612
|
+
const { MeshoptDecoder } = await import('three/examples/jsm/libs/meshopt_decoder.module.js');
|
|
613
|
+
let input = bytes;
|
|
614
|
+
if (input === undefined) {
|
|
615
|
+
const response: unknown = await new FileLoader().setResponseType('arraybuffer').loadAsync(url);
|
|
616
|
+
if (!(response instanceof ArrayBuffer)) throw new Error(`Skinned model load failed: ${url}`);
|
|
617
|
+
input = new Uint8Array(response);
|
|
618
|
+
}
|
|
619
|
+
await MeshoptDecoder.ready;
|
|
620
|
+
const weights = rawWeights(input, MeshoptDecoder);
|
|
621
|
+
const gltf = await (await prepareRigLoader()).createRigLoader().parseBytesAsync(input, '');
|
|
622
|
+
const meshes: SkinnedMesh[] = [];
|
|
623
|
+
gltf.scene.traverse((node: Object3D) => { if (isSkinnedMesh(node)) meshes.push(node); });
|
|
624
|
+
const first = meshes[0];
|
|
625
|
+
if (first === undefined) throw new Error(`Skinned model has no skinned mesh: ${url}`);
|
|
626
|
+
const joints = first.skeleton.bones;
|
|
627
|
+
const bones: SkinnedJoint[] = joints.map((bone) => {
|
|
628
|
+
const extras: unknown = bone.userData['wildshard'], bind = isRecord(extras) ? numbers(extras['bind']) : null;
|
|
629
|
+
if (bind?.length !== 3) throw new Error(`Skinned joint ${bone.name} has no bind position: ${url}`);
|
|
630
|
+
return { name: bone.name, parent: bone.parent instanceof Bone ? bone.parent.name : null, pos: [bind[0] ?? 0, bind[1] ?? 0, bind[2] ?? 0] };
|
|
631
|
+
});
|
|
632
|
+
const parts = meshes.map((mesh) => {
|
|
633
|
+
if (mesh.skeleton.bones.length !== joints.length || mesh.skeleton.bones.some((bone, i) => bone.name !== joints[i]?.name)) throw new Error(`Skinned parts must share one skeleton: ${url}`);
|
|
634
|
+
const association = gltf.parser.associations.get(mesh), exact = weights.get(`${String(association?.meshes ?? -1)}/${String(association?.primitives ?? 0)}`);
|
|
635
|
+
let geometry = mesh.geometry.clone();
|
|
636
|
+
const extras: unknown = geometry.userData['wildshard'];
|
|
637
|
+
geometry.userData = {};
|
|
638
|
+
if (exact === undefined || exact.length !== geometry.getAttribute('skinWeight').count * 4) throw new Error(`Skinned part has no float weights: ${url}`);
|
|
639
|
+
geometry.setAttribute('skinWeight', new Float32BufferAttribute(exact, 4));
|
|
640
|
+
if (isRecord(extras) && isRecord(extras['attributes'])) for (const [from, to] of Object.entries(extras['attributes'])) {
|
|
641
|
+
const channel = from.toLowerCase();
|
|
642
|
+
if (typeof to !== 'string' || !geometry.hasAttribute(channel)) throw new Error(`Skinned part is missing ${from}: ${url}`);
|
|
643
|
+
geometry.setAttribute(to, geometry.getAttribute(channel)); geometry.deleteAttribute(channel);
|
|
644
|
+
}
|
|
645
|
+
if (isRecord(extras) && extras['soup'] === true) { const soup = geometry.toNonIndexed(); geometry.dispose(); geometry = soup; }
|
|
646
|
+
geometry.computeBoundingBox(); geometry.computeBoundingSphere();
|
|
647
|
+
const material = Array.isArray(mesh.material) ? mesh.material[0] : mesh.material, map = material !== undefined && 'map' in material && material.map !== null && typeof material.map === 'object' ? material.map as Texture : null;
|
|
648
|
+
return { name: mesh.name, geometry, map };
|
|
649
|
+
});
|
|
650
|
+
for (const mesh of meshes) {
|
|
651
|
+
mesh.geometry.dispose();
|
|
652
|
+
for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) material.dispose();
|
|
653
|
+
}
|
|
654
|
+
const extras: unknown = isRecord(gltf.asset.extras) ? gltf.asset.extras['wildshard'] : null;
|
|
655
|
+
template = { bones, parts, clips: gltf.animations, extras };
|
|
656
|
+
};
|
|
657
|
+
const start = async (bytes?: Uint8Array): Promise<void> => {
|
|
658
|
+
try { await load(bytes); } catch (error: unknown) { pending = undefined; throw error; }
|
|
659
|
+
};
|
|
660
|
+
return {
|
|
661
|
+
load: (bytes) => { pending ??= start(bytes); return pending; },
|
|
662
|
+
loaded: () => template !== undefined,
|
|
663
|
+
textures: () => template === undefined ? [] : [...new Set(template.parts.flatMap((part) => part.map === null ? [] : [part.map]))],
|
|
664
|
+
geometries: () => template === undefined ? [] : template.parts.map((part) => part.geometry),
|
|
665
|
+
copy: () => {
|
|
666
|
+
if (template === undefined) throw new Error(`Skinned model was not loaded: ${url}`);
|
|
667
|
+
return { clips: template.clips, extras: template.extras, bones: template.bones.map((bone) => ({ name: bone.name, parent: bone.parent, pos: [bone.pos[0], bone.pos[1], bone.pos[2]] })),
|
|
668
|
+
parts: template.parts.map((part) => ({ name: part.name, map: part.map, geometry: part.geometry.clone() })) };
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/** A creature body's size (AnimalDims without its feet), as a baked body's extras and a stand-in row carry it. */
|
|
674
|
+
export interface CreatureDims { readonly bodyY: number; readonly bodyHalfLen: number; readonly bodyRadius: number; readonly headRadius: number; readonly legLen: number; readonly halfWidth: number }
|
|
675
|
+
/** What a creature stands as when its baked body did not load: its authored skeleton and size, drawn as `undrawnRig`. */
|
|
676
|
+
export interface CreatureStandIn { readonly bones: readonly { readonly name: string; readonly parent: string | null; readonly pos: readonly [number, number, number] }[]; readonly dims: CreatureDims }
|
|
677
|
+
/** A shard's baked creature bodies, as data: which load, from where, and each one's stand-in. */
|
|
678
|
+
export interface CreatureBodyRows<C extends string> {
|
|
679
|
+
readonly creatures: readonly C[];
|
|
680
|
+
readonly urls: Readonly<Record<C, string>>;
|
|
681
|
+
readonly standIns: Readonly<Record<C, CreatureStandIn>>;
|
|
682
|
+
/** opens every page fault (e.g. the shard's name in brackets) */
|
|
683
|
+
readonly fault: string;
|
|
684
|
+
/** the owner's upload policy for each shared map, once loaded (before it is retained) */
|
|
685
|
+
readonly onMap?: (map: Texture) => void;
|
|
686
|
+
/** Release an ImageBitmap decode at the original texture upload; no CPU consumer may retain it. */
|
|
687
|
+
readonly releaseDecoded?: boolean;
|
|
688
|
+
}
|
|
689
|
+
/** A shard's loaded creature bodies: preload once, then each spawn takes a copy. */
|
|
690
|
+
export interface CreatureBodies<C extends string> {
|
|
691
|
+
/** Load every body once (a failed one is a page fault). */
|
|
692
|
+
preload: () => Promise<void>;
|
|
693
|
+
/** A copy of a baked body, as a species look's `build()` returns it, or null (not loaded). */
|
|
694
|
+
body: (creature: C) => AnimalSpecies | null;
|
|
695
|
+
/** The baked copy, else its undrawn stand-in on its authored skeleton. */
|
|
696
|
+
bodyOrStandIn: (creature: C) => AnimalSpecies;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/** A part baked without normals (a smaller file) gets its flat normals from its own positions, per copy. */
|
|
700
|
+
const flatNormals = (g: BufferGeometry): BufferGeometry => { if (!g.hasAttribute('normal')) g.computeVertexNormals(); return g; };
|
|
701
|
+
const finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);
|
|
702
|
+
/** A baked body's extras as its look numbers (`dims`, optional `facetJitter` / `selfLight`), or null. */
|
|
703
|
+
function bodyExtras(value: unknown): { dims: CreatureDims; facetJitter?: number; selfLight?: number } | null {
|
|
704
|
+
if (!isRecord(value) || !isRecord(value['dims'])) return null;
|
|
705
|
+
const d = value['dims'], jitter = value['facetJitter'], light = value['selfLight'];
|
|
706
|
+
const { bodyY, bodyHalfLen, bodyRadius, headRadius, legLen, halfWidth } = d;
|
|
707
|
+
if (!finite(bodyY) || !finite(bodyHalfLen) || !finite(bodyRadius) || !finite(headRadius) || !finite(legLen) || !finite(halfWidth)) return null;
|
|
708
|
+
return { dims: { bodyY, bodyHalfLen, bodyRadius, headRadius, legLen, halfWidth }, ...(finite(jitter) ? { facetJitter: jitter } : {}), ...(finite(light) ? { selfLight: light } : {}) };
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* A shard's creature bodies baked offline as skinned GLBs (`skinnedModel`), each loaded once behind the loading screen;
|
|
713
|
+
* every spawn takes a copy: its bones, skin, dims and painted map exactly as the generator baked them. A body that fails
|
|
714
|
+
* to load is a `console.error` page fault and its species stands undrawn on its stand-in skeleton.
|
|
715
|
+
*/
|
|
716
|
+
export function creatureBodies<C extends string>(rows: CreatureBodyRows<C>): CreatureBodies<C> {
|
|
717
|
+
const models = new Map<C, SkinnedModel>();
|
|
718
|
+
let loading: Promise<void> | null = null;
|
|
719
|
+
async function load(creature: C): Promise<void> {
|
|
720
|
+
const model = skinnedModel(rows.urls[creature]);
|
|
721
|
+
try {
|
|
722
|
+
await model.load();
|
|
723
|
+
for (const map of model.textures()) {
|
|
724
|
+
rows.onMap?.(map);
|
|
725
|
+
const image: unknown = map.image;
|
|
726
|
+
if (rows.releaseDecoded === true && typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) releaseOnUpload(map.source, () => { image.close(); });
|
|
727
|
+
}
|
|
728
|
+
// the maps and the loaded parts are kept once, like the model library's models; a retired one reloads on the next preload
|
|
729
|
+
for (const kept of [...model.textures(), ...model.geometries()]) {
|
|
730
|
+
retainCachedResources(kept);
|
|
731
|
+
cacheUntilDisposed(kept, () => { if (models.get(creature) === model) { models.delete(creature); loading = null; } });
|
|
732
|
+
}
|
|
733
|
+
models.set(creature, model);
|
|
734
|
+
} catch (e: unknown) { console.error(`${rows.fault} the baked creature ${creature} did not load:`, e); }
|
|
735
|
+
}
|
|
736
|
+
const body = (creature: C): AnimalSpecies | null => {
|
|
737
|
+
const model = models.get(creature);
|
|
738
|
+
if (model === undefined) return null;
|
|
739
|
+
const asset = model.copy(), extras = bodyExtras(asset.extras), map = asset.parts[0]?.map ?? null;
|
|
740
|
+
if (extras === null) throw new Error(`${rows.fault} the baked creature ${creature} has no dims`);
|
|
741
|
+
return { bones: asset.bones.map((bone) => ({ name: bone.name, parent: bone.parent, pos: bone.pos })), furParts: [], eyeParts: [], hardParts: asset.parts.map((part) => flatNormals(part.geometry)),
|
|
742
|
+
dims: { ...extras.dims, feet: [] }, ...(map === null ? {} : { map }), ...(extras.facetJitter === undefined ? {} : { facetJitter: extras.facetJitter }),
|
|
743
|
+
...(extras.selfLight === undefined ? {} : { selfLight: extras.selfLight }) };
|
|
744
|
+
};
|
|
745
|
+
return {
|
|
746
|
+
preload: () => { loading ??= Promise.all(rows.creatures.filter((creature) => !models.has(creature)).map(load)).then(() => undefined); return loading; },
|
|
747
|
+
body,
|
|
748
|
+
bodyOrStandIn: (creature) => {
|
|
749
|
+
const stand = rows.standIns[creature];
|
|
750
|
+
return body(creature) ?? { bones: stand.bones.map((bone) => ({ name: bone.name, parent: bone.parent, pos: [bone.pos[0], bone.pos[1], bone.pos[2]] })), furParts: [], eyeParts: [],
|
|
751
|
+
hardParts: [undrawnRig()], dims: { ...stand.dims, feet: [] } };
|
|
752
|
+
},
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/** A baked body's species look as rows: its ids and rig contract (its dims ride in the baked body). */
|
|
757
|
+
export interface BakedLookRow {
|
|
758
|
+
/** An admitted pure colour graph decorates the original material; lighting, maps and hit flash stay owned by the factory. */
|
|
759
|
+
readonly colourTransform?: { readonly id: string; readonly row: unknown };
|
|
760
|
+
readonly id: string; readonly species: string; readonly kind: string;
|
|
761
|
+
readonly skeleton: string; readonly sockets: readonly SocketName[]; readonly clipNames: readonly ClipName[];
|
|
762
|
+
}
|
|
763
|
+
/** A species look on a baked creature body (`build`: a fresh copy each time, `creatureBodies(...).bodyOrStandIn`), animated
|
|
764
|
+
* by its clip rows. Signal Dunes' and Sky Reach's creatures declare their looks this way. */
|
|
765
|
+
export function bakedLook(row: BakedLookRow, build: () => AnimalSpecies, clips: SpeciesClips): SpeciesLook {
|
|
766
|
+
const transform = row.colourTransform, decorated = new WeakSet<Material>();
|
|
767
|
+
if (transform !== undefined && !/^[a-zA-Z][a-zA-Z0-9.:-]{0,127}$/u.test(transform.id)) throw new Error('Invalid baked look colour id');
|
|
768
|
+
return { id: row.id, species: row.species, kind: row.kind, rig: 'custom', fur: NO_FUR,
|
|
769
|
+
...(transform === undefined ? {} : { decorateMaterials: (materials: readonly Material[]): void => {
|
|
770
|
+
if (materials.length > 64) throw new Error('Baked look material roster exceeds its bound');
|
|
771
|
+
for (const material of materials) {
|
|
772
|
+
if (decorated.has(material)) continue; decorated.add(material);
|
|
773
|
+
materialColourGraph(material, transform.id, transform.row);
|
|
774
|
+
}
|
|
775
|
+
} }),
|
|
776
|
+
rigContract: { skeleton: row.skeleton, sockets: [...row.sockets], clips: [...row.clipNames] }, build, animate: clipAnimate(clips) };
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** One authored look on an existing baked body, with its original clip rows. */
|
|
780
|
+
export interface CreatureLookRow<C extends string> { readonly body: C; readonly look: BakedLookRow; readonly clips: SpeciesClips }
|
|
781
|
+
/** Build an ordered look catalogue on the existing body loader; every spawn keeps its own body copy and clip state. */
|
|
782
|
+
export function creatureLooks<C extends string>(bodies: Pick<CreatureBodies<C>, 'bodyOrStandIn'>, rows: readonly CreatureLookRow<C>[]): readonly SpeciesLook[] {
|
|
783
|
+
return rows.map(row => bakedLook(row.look, () => bodies.bodyOrStandIn(row.body), row.clips));
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/** A specimen's authored hard-part selection and unchanged standard material. */
|
|
787
|
+
export interface CreatureSpecimenRow {
|
|
788
|
+
readonly parts: 'all' | 'first'; readonly material: MeshStandardMaterialParameters; readonly scale?: number;
|
|
789
|
+
}
|
|
790
|
+
/** Build an Explorer specimen from an actual body copy without posing or fitting
|
|
791
|
+
* its geometry. All parts retain their order in a Group; first-part specimens
|
|
792
|
+
* retain the original Mesh and zero-area fallback for absent geometry. */
|
|
793
|
+
export function creatureSpecimen(body: AnimalSpecies, row: CreatureSpecimenRow): Group | Mesh {
|
|
794
|
+
const scale = row.scale ?? 1;
|
|
795
|
+
if (!Number.isFinite(scale) || scale <= 0) throw new Error('Creature specimen scale must be finite and positive');
|
|
796
|
+
if (row.parts === 'first') {
|
|
797
|
+
const mesh = new Mesh(body.hardParts[0] ?? undrawnRig(), new MeshStandardMaterial(row.material));
|
|
798
|
+
mesh.scale.setScalar(scale); return mesh;
|
|
799
|
+
}
|
|
800
|
+
const group = new Group();
|
|
801
|
+
for (const part of body.hardParts) group.add(new Mesh(part, new MeshStandardMaterial(row.material)));
|
|
802
|
+
group.scale.setScalar(scale); return group;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/** Fit a geometry into a frame (turned `yaw` radians about +Y first): centred on x / z, its lowest point at `floor`, scaled to `size`. */
|
|
806
|
+
export function fitGeometry(g: BufferGeometry, o: ModelFit): BufferGeometry {
|
|
807
|
+
if (o.yaw !== undefined) g.rotateY(o.yaw);
|
|
808
|
+
const p = g.getAttribute('position'), b = new Box3().setFromBufferAttribute(p as BufferAttribute);
|
|
809
|
+
if (o.centre === 'base') {
|
|
810
|
+
let x = 0, z = 0, n = 0; const top = b.min.y + (b.max.y - b.min.y) * 0.1;
|
|
811
|
+
for (let i = 0; i < p.count; i++) if (p.getY(i) <= top) { x += p.getX(i); z += p.getZ(i); n++; }
|
|
812
|
+
if (n > 0) { const cx = x / n, cz = z / n, hx = Math.max(b.max.x - cx, cx - b.min.x), hz = Math.max(b.max.z - cz, cz - b.min.z); b.min.x = cx - hx; b.max.x = cx + hx; b.min.z = cz - hz; b.max.z = cz + hz; }
|
|
813
|
+
}
|
|
814
|
+
const span = o.by === 'height' ? b.max.y - b.min.y : Math.max(b.max.x - b.min.x, b.max.z - b.min.z), k = o.size / Math.max(1e-6, span);
|
|
815
|
+
g.translate(-(b.min.x + b.max.x) / 2, -b.min.y, -(b.min.z + b.max.z) / 2);
|
|
816
|
+
g.scale(k, k, k); g.translate(0, o.floor ?? 0, 0); g.computeBoundingBox(); g.computeBoundingSphere();
|
|
817
|
+
return g;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// The canvas atlas (SHARD-PLATFORM M3): a 2D-canvas texture painted from draw steps that are data. A shard lists its
|
|
821
|
+
// decals (an engraved strip, a paper talisman, a label sheet) as rows; `paintCanvasAtlas` replays them on one canvas, in
|
|
822
|
+
// order, and returns it as a mipmapped sRGB texture. Each step is one canvas call or a small deterministic loop:
|
|
823
|
+
// - `set`: any of fill / stroke style, line width / cap / join, font, text align / baseline, global alpha;
|
|
824
|
+
// - `fillRect` / `strokeRect`; `save` / `restore` / `translate` / `scale` / `rotate` (angles in half turns, × π);
|
|
825
|
+
// - `path`: one beginPath, its segments (M / L / A: arcs with angles × π) and a stroke or fill; with a scale `s` every
|
|
826
|
+
// coordinate and radius is `s × value`, offset by `at` when given;
|
|
827
|
+
// - `text`: fillText at a point;
|
|
828
|
+
// - `radial`: a radial gradient (its stops) filling a rectangle;
|
|
829
|
+
// - `speckle`: n seeded random marks (a Park–Miller sequence) in two styles over a rectangle (paper fibre);
|
|
830
|
+
// - `grain`: n marks on a fixed stride pattern over a rectangle (a quieter fibre).
|
|
831
|
+
// Drawn at `scale` (the canvas `scale` times the authored size, every coordinate kept): a phone tier halves an atlas.
|
|
832
|
+
//
|
|
833
|
+
// Procedural painters (a fern frond, a pebble scatter, an end-grain disc) are the same rows with expressions: a value is
|
|
834
|
+
// a number or an expression string (`'128 + sin(t * 2.2) * 6'`), evaluated with JavaScript's operators, precedence and
|
|
835
|
+
// left-to-right order, so every double is the one the hand-written painter computed. A style string holding `{expr}`
|
|
836
|
+
// parts is a template (`'rgb({52 + hue * 6},{82 + hue * 8},34)'`, each part as JavaScript's `${}` prints it).
|
|
837
|
+
// - `rng`: the painter's random stream, the engine's `Rng` from a seed (`next()` and `range(a, b)` in expressions);
|
|
838
|
+
// - `let` / `assign` / `fn` / `list` / `push`: block-scoped values, expression functions and lists of tuples;
|
|
839
|
+
// - `loop` (n times) / `for` (from, while, next) / `each` (over numbers or a list) / `if`: control, each body a scope (`if` runs `yes` or `no`);
|
|
840
|
+
// - `call`: one path or rect call with expression arguments; `gradient`: a linear or radial gradient as the fill or
|
|
841
|
+
// stroke style; `valueNoise`: an octave value-noise ImageData from the stream (grey, opaque) put at the origin.
|
|
842
|
+
// Expression built-ins: PI, sin, cos, tan, atan2, sqrt, abs, floor, ceil, round, min, max, next, range, and the vars
|
|
843
|
+
// the caller passes (a level's seed).
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
/** one path segment: move, line, or arc (centre, radius, start and end angle in half turns, and when given whether it
|
|
848
|
+
* runs counter-clockwise) */
|
|
849
|
+
export type CanvasSegment = readonly ['M', number, number] | readonly ['L', number, number] | readonly ['A', number, number, number, number, number] | readonly ['A', number, number, number, number, number, boolean];
|
|
850
|
+
|
|
851
|
+
/** a number, or an expression string evaluated in the painter's scope */
|
|
852
|
+
export type CanvasExpr = number | string;
|
|
853
|
+
|
|
854
|
+
/** the canvas calls a `call` step makes, its arguments expressions */
|
|
855
|
+
export type CanvasCall = 'beginPath' | 'closePath' | 'fill' | 'stroke' | 'moveTo' | 'lineTo' | 'arc' | 'ellipse' | 'quadraticCurveTo' | 'bezierCurveTo' | 'fillRect' | 'strokeRect' | 'translate' | 'scale' | 'rotate' | 'save' | 'restore';
|
|
856
|
+
|
|
857
|
+
/** a draw step as data */
|
|
858
|
+
export type CanvasStep =
|
|
859
|
+
| { readonly op: 'set'; readonly fill?: string; readonly stroke?: string; readonly width?: CanvasExpr; readonly cap?: CanvasLineCap; readonly join?: CanvasLineJoin; readonly font?: string; readonly align?: CanvasTextAlign; readonly baseline?: CanvasTextBaseline; readonly alpha?: CanvasExpr }
|
|
860
|
+
| { readonly op: 'fillRect' | 'strokeRect'; readonly x: number; readonly y: number; readonly w: number; readonly h: number }
|
|
861
|
+
| { readonly op: 'save' | 'restore' }
|
|
862
|
+
| { readonly op: 'translate' | 'scale'; readonly x: number; readonly y: number }
|
|
863
|
+
| { readonly op: 'rotate'; readonly turns: number }
|
|
864
|
+
| { readonly op: 'path'; readonly segs: readonly CanvasSegment[]; readonly s?: number; readonly at?: readonly [number, number]; readonly fill?: boolean }
|
|
865
|
+
| { readonly op: 'text'; readonly text: string; readonly x: number; readonly y: number }
|
|
866
|
+
| { readonly op: 'radial'; readonly from: readonly [number, number, number]; readonly to: readonly [number, number, number]; readonly stops: readonly (readonly [number, string])[]; readonly x: number; readonly y: number; readonly w: number; readonly h: number }
|
|
867
|
+
| { readonly op: 'speckle'; readonly n: number; readonly seed: number; readonly split: number; readonly styles: readonly [string, string]; readonly x: number; readonly y: number; readonly w: number; readonly h: number; readonly mark: readonly [number, number, number, number] }
|
|
868
|
+
| { readonly op: 'grain'; readonly n: number; readonly stride: readonly [number, number]; readonly mark: readonly [number, number, number, number]; readonly x: number; readonly y: number; readonly w: number; readonly h: number }
|
|
869
|
+
| { readonly op: 'rng'; readonly seed: CanvasExpr }
|
|
870
|
+
| { readonly op: 'let' | 'assign'; readonly vars: readonly (readonly [string, CanvasExpr])[] }
|
|
871
|
+
| { readonly op: 'fn'; readonly name: string; readonly params: readonly string[]; readonly body: string }
|
|
872
|
+
| { readonly op: 'list'; readonly name: string }
|
|
873
|
+
| { readonly op: 'push'; readonly list: string; readonly vals: readonly CanvasExpr[] }
|
|
874
|
+
| { readonly op: 'loop'; readonly v: string; readonly n: CanvasExpr; readonly body: readonly CanvasStep[] }
|
|
875
|
+
| { readonly op: 'for'; readonly v: string; readonly from: CanvasExpr; readonly while: string; readonly next: string; readonly body: readonly CanvasStep[] }
|
|
876
|
+
| { readonly op: 'each'; readonly v: string | readonly string[]; readonly of: string | readonly number[]; readonly body: readonly CanvasStep[] }
|
|
877
|
+
| { readonly op: 'if'; readonly cond: string; readonly yes: readonly CanvasStep[]; readonly no?: readonly CanvasStep[] }
|
|
878
|
+
| { readonly op: 'call'; readonly fn: CanvasCall; readonly args?: readonly CanvasExpr[] }
|
|
879
|
+
| { readonly op: 'gradient'; readonly kind: 'linear' | 'radial'; readonly args: readonly CanvasExpr[]; readonly stops: readonly (readonly [CanvasExpr, string])[]; readonly to?: 'fill' | 'stroke' }
|
|
880
|
+
| { readonly op: 'valueNoise'; readonly size: number; readonly octaves: readonly number[]; readonly amp: number; readonly gain: number };
|
|
881
|
+
|
|
882
|
+
/** an atlas as data: its authored size, the draw scale (undefined: no scale call) and its steps */
|
|
883
|
+
export interface CanvasAtlasRow { readonly w: number; readonly h: number; readonly steps: readonly CanvasStep[] }
|
|
884
|
+
|
|
885
|
+
// ───────────────────────────── expressions ─────────────────────────────
|
|
886
|
+
|
|
887
|
+
type Value = number | string | boolean;
|
|
888
|
+
type Compiled = (s: Scope) => Value;
|
|
889
|
+
interface PaintState { readonly g: CanvasRenderingContext2D; rng: Rng | null }
|
|
890
|
+
interface ExprFn { readonly params: readonly string[]; readonly body: Compiled; readonly scope: Scope }
|
|
891
|
+
|
|
892
|
+
class Scope {
|
|
893
|
+
readonly vars = new Map<string, Value>();
|
|
894
|
+
readonly lists = new Map<string, Value[][]>();
|
|
895
|
+
readonly fns = new Map<string, ExprFn>();
|
|
896
|
+
readonly parent: Scope | null;
|
|
897
|
+
readonly paint: PaintState;
|
|
898
|
+
constructor(parent: Scope | null, paint: PaintState) { this.parent = parent; this.paint = paint; }
|
|
899
|
+
child(): Scope { return new Scope(this, this.paint); }
|
|
900
|
+
owner<K>(pick: (s: Scope) => Map<string, K>, name: string): Map<string, K> {
|
|
901
|
+
if (pick(this).has(name)) return pick(this);
|
|
902
|
+
if (this.parent === null) throw new Error(`canvas painter: unknown name ${name}`);
|
|
903
|
+
return this.parent.owner(pick, name);
|
|
904
|
+
}
|
|
905
|
+
get(name: string): Value { const v = this.owner((s) => s.vars, name).get(name); if (v === undefined) throw new Error(name); return v; }
|
|
906
|
+
list(name: string): Value[][] { const l = this.owner((s) => s.lists, name).get(name); if (l === undefined) throw new Error(name); return l; }
|
|
907
|
+
fn(name: string): ExprFn | undefined { return this.fns.get(name) ?? this.parent?.fn(name); }
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
const truthy = (v: Value): boolean => (typeof v === 'number' ? v !== 0 && !Number.isNaN(v) : typeof v === 'string' ? v !== '' : v);
|
|
911
|
+
function num(v: Value): number {
|
|
912
|
+
if (typeof v !== 'number') throw new Error(`canvas painter: ${String(v)} is not a number`);
|
|
913
|
+
return v;
|
|
914
|
+
}
|
|
915
|
+
function stream(s: Scope): Rng {
|
|
916
|
+
const r = s.paint.rng;
|
|
917
|
+
if (r === null) throw new Error('canvas painter: no rng step before next() / range()');
|
|
918
|
+
return r;
|
|
919
|
+
}
|
|
920
|
+
const MATH: Readonly<Record<string, (a: readonly number[]) => number>> = {
|
|
921
|
+
sin: (a) => Math.sin(canvasArgument(a, 0)), cos: (a) => Math.cos(canvasArgument(a, 0)), tan: (a) => Math.tan(canvasArgument(a, 0)), atan2: (a) => Math.atan2(canvasArgument(a, 0), canvasArgument(a, 1)),
|
|
922
|
+
sqrt: (a) => Math.sqrt(canvasArgument(a, 0)), abs: (a) => Math.abs(canvasArgument(a, 0)), floor: (a) => Math.floor(canvasArgument(a, 0)), ceil: (a) => Math.ceil(canvasArgument(a, 0)),
|
|
923
|
+
round: (a) => Math.round(canvasArgument(a, 0)), min: (a) => Math.min(...a), max: (a) => Math.max(...a),
|
|
924
|
+
};
|
|
925
|
+
function canvasArgument(a: readonly number[], i: number): number {
|
|
926
|
+
const v = a[i];
|
|
927
|
+
if (v === undefined) throw new Error('canvas painter: missing argument');
|
|
928
|
+
return v;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
const TOKEN = /\s*(?:(\d+(?:\.\d*)?(?:[eE][-+]?\d+)?|\.\d+(?:[eE][-+]?\d+)?)|([A-Za-z_]\w*)|'([^']*)'|(\*\*|===|!==|<=|>=|&&|\|\||[-+*/%<>()?:,!]))/yu;
|
|
932
|
+
const BINARY: Readonly<Record<string, (a: number, b: number) => Value>> = {
|
|
933
|
+
'+': (a, b) => a + b, '-': (a, b) => a - b, '*': (a, b) => a * b, '/': (a, b) => a / b, '%': (a, b) => a % b, '**': (a, b) => a ** b,
|
|
934
|
+
'<': (a, b) => a < b, '<=': (a, b) => a <= b, '>': (a, b) => a > b, '>=': (a, b) => a >= b,
|
|
935
|
+
};
|
|
936
|
+
const LEVELS: readonly (readonly string[])[] = [['===', '!=='], ['<', '<=', '>', '>='], ['+', '-'], ['*', '/', '%']];
|
|
937
|
+
|
|
938
|
+
interface Token { readonly k: 'n' | 'id' | 's' | 'op'; readonly t: string }
|
|
939
|
+
function tokens(src: string): Token[] {
|
|
940
|
+
const toks: Token[] = [];
|
|
941
|
+
TOKEN.lastIndex = 0;
|
|
942
|
+
while (TOKEN.lastIndex < src.length) {
|
|
943
|
+
if (/^\s*$/u.test(src.slice(TOKEN.lastIndex))) break;
|
|
944
|
+
const m = TOKEN.exec(src);
|
|
945
|
+
if (m === null) throw new Error(`canvas painter: cannot read "${src}" at ${TOKEN.lastIndex}`);
|
|
946
|
+
if (m[1] !== undefined) toks.push({ k: 'n', t: m[1] });
|
|
947
|
+
else if (m[2] !== undefined) toks.push({ k: 'id', t: m[2] });
|
|
948
|
+
else if (m[3] !== undefined) toks.push({ k: 's', t: m[3] });
|
|
949
|
+
else toks.push({ k: 'op', t: m[4] ?? '' });
|
|
950
|
+
}
|
|
951
|
+
return toks;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/** a recursive-descent parse of one expression into a closure (JavaScript's precedence, associativity and order) */
|
|
955
|
+
class Parser {
|
|
956
|
+
private p = 0;
|
|
957
|
+
private readonly toks: readonly Token[];
|
|
958
|
+
private readonly src: string;
|
|
959
|
+
constructor(src: string) { this.src = src; this.toks = tokens(src); }
|
|
960
|
+
parse(): Compiled {
|
|
961
|
+
const out = this.ternary();
|
|
962
|
+
if (this.p !== this.toks.length) throw new Error(`canvas painter: trailing input in "${this.src}"`);
|
|
963
|
+
return out;
|
|
964
|
+
}
|
|
965
|
+
private peek(t: string): boolean { const k = this.toks[this.p]; return k?.k === 'op' && k.t === t; }
|
|
966
|
+
private eat(t: string): void { if (!this.peek(t)) throw new Error(`canvas painter: expected ${t} in "${this.src}"`); this.p++; }
|
|
967
|
+
private ternary(): Compiled {
|
|
968
|
+
const c = this.or();
|
|
969
|
+
if (!this.peek('?')) return c;
|
|
970
|
+
this.p++;
|
|
971
|
+
const a = this.ternary(); this.eat(':'); const b = this.ternary();
|
|
972
|
+
return (s) => (truthy(c(s)) ? a(s) : b(s));
|
|
973
|
+
}
|
|
974
|
+
private or(): Compiled {
|
|
975
|
+
let l = this.and();
|
|
976
|
+
while (this.peek('||')) { this.p++; const a = l, b = this.and(); l = (s) => { const v = a(s); return truthy(v) ? v : b(s); }; }
|
|
977
|
+
return l;
|
|
978
|
+
}
|
|
979
|
+
private and(): Compiled {
|
|
980
|
+
let l = this.level(0);
|
|
981
|
+
while (this.peek('&&')) { this.p++; const a = l, b = this.level(0); l = (s) => { const v = a(s); return truthy(v) ? b(s) : v; }; }
|
|
982
|
+
return l;
|
|
983
|
+
}
|
|
984
|
+
private level(i: number): Compiled {
|
|
985
|
+
const ops = LEVELS[i];
|
|
986
|
+
if (ops === undefined) return this.unary();
|
|
987
|
+
let l = this.level(i + 1);
|
|
988
|
+
for (let t = this.toks[this.p]; t?.k === 'op' && ops.includes(t.t); t = this.toks[this.p]) {
|
|
989
|
+
this.p++;
|
|
990
|
+
const a = l, b = this.level(i + 1), op = t.t;
|
|
991
|
+
if (op === '===') l = (s) => a(s) === b(s);
|
|
992
|
+
else if (op === '!==') l = (s) => a(s) !== b(s);
|
|
993
|
+
else { const f = BINARY[op]; if (f === undefined) throw new Error(op); l = (s) => f(num(a(s)), num(b(s))); }
|
|
994
|
+
}
|
|
995
|
+
return l;
|
|
996
|
+
}
|
|
997
|
+
private unary(): Compiled {
|
|
998
|
+
if (this.peek('-')) { this.p++; const a = this.unary(); return (s) => -num(a(s)); }
|
|
999
|
+
if (this.peek('!')) { this.p++; const a = this.unary(); return (s) => !truthy(a(s)); }
|
|
1000
|
+
const base = this.primary();
|
|
1001
|
+
if (!this.peek('**')) return base;
|
|
1002
|
+
this.p++;
|
|
1003
|
+
const e = this.unary();
|
|
1004
|
+
return (s) => num(base(s)) ** num(e(s));
|
|
1005
|
+
}
|
|
1006
|
+
private primary(): Compiled {
|
|
1007
|
+
const t = this.toks[this.p++];
|
|
1008
|
+
if (t === undefined) throw new Error(`canvas painter: "${this.src}" ends early`);
|
|
1009
|
+
if (t.k === 'n') { const v = Number(t.t); return () => v; }
|
|
1010
|
+
if (t.k === 's') { const v = t.t; return () => v; }
|
|
1011
|
+
if (t.k === 'op') { if (t.t !== '(') throw new Error(`canvas painter: unexpected ${t.t} in "${this.src}"`); const e = this.ternary(); this.eat(')'); return e; }
|
|
1012
|
+
const name = t.t;
|
|
1013
|
+
if (!this.peek('(')) return name === 'PI' ? () => Math.PI : (s) => s.get(name);
|
|
1014
|
+
this.p++;
|
|
1015
|
+
const args: Compiled[] = [];
|
|
1016
|
+
while (!this.peek(')')) { args.push(this.ternary()); if (!this.peek(')')) this.eat(','); }
|
|
1017
|
+
this.p++;
|
|
1018
|
+
return callOf(name, args);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function callOf(name: string, args: readonly Compiled[]): Compiled {
|
|
1023
|
+
if (name === 'next') return (s) => stream(s).next();
|
|
1024
|
+
if (name === 'range') return (s) => { const a = num(argOf(args, 0)(s)), b = num(argOf(args, 1)(s)); return stream(s).range(a, b); };
|
|
1025
|
+
const m = MATH[name];
|
|
1026
|
+
if (m !== undefined) return (s) => m(args.map((a) => num(a(s))));
|
|
1027
|
+
return (s) => {
|
|
1028
|
+
const f = s.fn(name);
|
|
1029
|
+
if (f === undefined) throw new Error(`canvas painter: unknown function ${name}`);
|
|
1030
|
+
const vals = args.map((a) => a(s)), inner = f.scope.child();
|
|
1031
|
+
for (const [i, n] of f.params.entries()) inner.vars.set(n, vals[i] ?? 0);
|
|
1032
|
+
return f.body(inner);
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
function argOf(args: readonly Compiled[], i: number): Compiled {
|
|
1036
|
+
const a = args[i];
|
|
1037
|
+
if (a === undefined) throw new Error('canvas painter: missing argument');
|
|
1038
|
+
return a;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
const compiled = new Map<string, Compiled>();
|
|
1042
|
+
function compile(src: string): Compiled {
|
|
1043
|
+
let c = compiled.get(src);
|
|
1044
|
+
if (c === undefined) { c = new Parser(src).parse(); compiled.set(src, c); }
|
|
1045
|
+
return c;
|
|
1046
|
+
}
|
|
1047
|
+
const value = (e: CanvasExpr, s: Scope): Value => (typeof e === 'number' ? e : compile(e)(s));
|
|
1048
|
+
const number = (e: CanvasExpr, s: Scope): number => (typeof e === 'number' ? e : num(compile(e)(s)));
|
|
1049
|
+
|
|
1050
|
+
const templates = new Map<string, readonly (string | Compiled)[]>();
|
|
1051
|
+
/** a style string: literal, or a template whose `{expr}` parts print as JavaScript's `${}` does */
|
|
1052
|
+
function style(t: string, s: Scope): string {
|
|
1053
|
+
if (!t.includes('{')) return t;
|
|
1054
|
+
let parts = templates.get(t);
|
|
1055
|
+
if (parts === undefined) {
|
|
1056
|
+
const out: (string | Compiled)[] = [];
|
|
1057
|
+
for (const piece of t.split(/(\{[^}]*\})/u)) if (piece !== '') out.push(piece.startsWith('{') ? compile(piece.slice(1, -1)) : piece);
|
|
1058
|
+
parts = out;
|
|
1059
|
+
templates.set(t, parts);
|
|
1060
|
+
}
|
|
1061
|
+
let r = '';
|
|
1062
|
+
for (const part of parts) r += typeof part === 'string' ? part : String(part(s));
|
|
1063
|
+
return r;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// ───────────────────────────── steps ─────────────────────────────
|
|
1067
|
+
|
|
1068
|
+
function set(g: CanvasRenderingContext2D, st: Extract<CanvasStep, { op: 'set' }>, s: Scope): void {
|
|
1069
|
+
if (st.fill !== undefined) g.fillStyle = style(st.fill, s);
|
|
1070
|
+
if (st.stroke !== undefined) g.strokeStyle = style(st.stroke, s);
|
|
1071
|
+
if (st.width !== undefined) g.lineWidth = number(st.width, s);
|
|
1072
|
+
if (st.cap !== undefined) g.lineCap = st.cap;
|
|
1073
|
+
if (st.join !== undefined) g.lineJoin = st.join;
|
|
1074
|
+
if (st.font !== undefined) g.font = st.font;
|
|
1075
|
+
if (st.align !== undefined) g.textAlign = st.align;
|
|
1076
|
+
if (st.baseline !== undefined) g.textBaseline = st.baseline;
|
|
1077
|
+
if (st.alpha !== undefined) g.globalAlpha = number(st.alpha, s);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function path(g: CanvasRenderingContext2D, p: Extract<CanvasStep, { op: 'path' }>): void {
|
|
1081
|
+
const k = p.s, at0 = p.at;
|
|
1082
|
+
// a coordinate: the scaled value, offset by `at` (the same arithmetic an authored `x + s * k` performs)
|
|
1083
|
+
const cx = (v: number): number => (k === undefined ? v : at0 === undefined ? k * v : at0[0] + k * v);
|
|
1084
|
+
const cy = (v: number): number => (k === undefined ? v : at0 === undefined ? k * v : at0[1] + k * v);
|
|
1085
|
+
const r = (v: number): number => (k === undefined ? v : k * v);
|
|
1086
|
+
g.beginPath();
|
|
1087
|
+
for (const seg of p.segs) {
|
|
1088
|
+
if (seg[0] === 'M') g.moveTo(cx(seg[1]), cy(seg[2]));
|
|
1089
|
+
else if (seg[0] === 'L') g.lineTo(cx(seg[1]), cy(seg[2]));
|
|
1090
|
+
else if (seg.length === 7) g.arc(cx(seg[1]), cy(seg[2]), r(seg[3]), Math.PI * seg[4], Math.PI * seg[5], seg[6]);
|
|
1091
|
+
else g.arc(cx(seg[1]), cy(seg[2]), r(seg[3]), Math.PI * seg[4], Math.PI * seg[5]);
|
|
1092
|
+
}
|
|
1093
|
+
if (p.fill === true) g.fill(); else g.stroke();
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
function call(g: CanvasRenderingContext2D, fn: CanvasCall, a: readonly number[]): void {
|
|
1097
|
+
switch (fn) {
|
|
1098
|
+
case 'beginPath': g.beginPath(); break;
|
|
1099
|
+
case 'closePath': g.closePath(); break;
|
|
1100
|
+
case 'fill': g.fill(); break;
|
|
1101
|
+
case 'stroke': g.stroke(); break;
|
|
1102
|
+
case 'save': g.save(); break;
|
|
1103
|
+
case 'restore': g.restore(); break;
|
|
1104
|
+
case 'moveTo': g.moveTo(canvasArgument(a, 0), canvasArgument(a, 1)); break;
|
|
1105
|
+
case 'lineTo': g.lineTo(canvasArgument(a, 0), canvasArgument(a, 1)); break;
|
|
1106
|
+
case 'translate': g.translate(canvasArgument(a, 0), canvasArgument(a, 1)); break;
|
|
1107
|
+
case 'scale': g.scale(canvasArgument(a, 0), canvasArgument(a, 1)); break;
|
|
1108
|
+
case 'rotate': g.rotate(canvasArgument(a, 0)); break;
|
|
1109
|
+
case 'arc': g.arc(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3), canvasArgument(a, 4)); break;
|
|
1110
|
+
case 'ellipse': g.ellipse(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3), canvasArgument(a, 4), canvasArgument(a, 5), canvasArgument(a, 6)); break;
|
|
1111
|
+
case 'quadraticCurveTo': g.quadraticCurveTo(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3)); break;
|
|
1112
|
+
case 'bezierCurveTo': g.bezierCurveTo(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3), canvasArgument(a, 4), canvasArgument(a, 5)); break;
|
|
1113
|
+
case 'fillRect': g.fillRect(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3)); break;
|
|
1114
|
+
case 'strokeRect': g.strokeRect(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3)); break;
|
|
1115
|
+
default: { const unknown: never = fn; throw new Error(`unknown canvas call ${String(unknown)}`); }
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
/** octave value noise from the stream: one n × n lattice of `next()` per octave, smoothstep-blended, amplitudes from
|
|
1120
|
+
* `amp` falling by `gain`, written grey and opaque to a size × size ImageData put at the origin */
|
|
1121
|
+
function valueNoise(g: CanvasRenderingContext2D, st: Extract<CanvasStep, { op: 'valueNoise' }>, rng: Rng): void {
|
|
1122
|
+
const sz = st.size, img = g.createImageData(sz, sz);
|
|
1123
|
+
const oct = st.octaves.map((n) => { const a = new Float32Array(n * n); for (let i = 0; i < a.length; i++) a[i] = rng.next(); return { n, a }; });
|
|
1124
|
+
const sm = (t: number): number => t * t * (3 - 2 * t);
|
|
1125
|
+
for (let y = 0; y < sz; y++) for (let x = 0; x < sz; x++) {
|
|
1126
|
+
let v = 0, amp = st.amp, sum = 0;
|
|
1127
|
+
for (const { n, a } of oct) {
|
|
1128
|
+
const fx = (x / sz) * n, fy = (y / sz) * n, x0 = Math.floor(fx), y0 = Math.floor(fy), tx = sm(fx - x0), ty = sm(fy - y0);
|
|
1129
|
+
const q = (i: number, j: number): number => a[((j + n) % n) * n + ((i + n) % n)] ?? 0;
|
|
1130
|
+
const vv = (q(x0, y0) * (1 - tx) + q(x0 + 1, y0) * tx) * (1 - ty) + (q(x0, y0 + 1) * (1 - tx) + q(x0 + 1, y0 + 1) * tx) * ty;
|
|
1131
|
+
v += vv * amp; sum += amp; amp *= st.gain;
|
|
1132
|
+
}
|
|
1133
|
+
const b = Math.floor((v / sum) * 255), i = (y * sz + x) * 4;
|
|
1134
|
+
img.data[i] = img.data[i + 1] = img.data[i + 2] = b; img.data[i + 3] = 255;
|
|
1135
|
+
}
|
|
1136
|
+
g.putImageData(img, 0, 0);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
function run(g: CanvasRenderingContext2D, steps: readonly CanvasStep[], sc: Scope): void {
|
|
1140
|
+
for (const s of steps) {
|
|
1141
|
+
switch (s.op) {
|
|
1142
|
+
case 'set': set(g, s, sc); break;
|
|
1143
|
+
case 'fillRect': g.fillRect(s.x, s.y, s.w, s.h); break;
|
|
1144
|
+
case 'strokeRect': g.strokeRect(s.x, s.y, s.w, s.h); break;
|
|
1145
|
+
case 'save': g.save(); break;
|
|
1146
|
+
case 'restore': g.restore(); break;
|
|
1147
|
+
case 'translate': g.translate(s.x, s.y); break;
|
|
1148
|
+
case 'scale': g.scale(s.x, s.y); break;
|
|
1149
|
+
case 'rotate': g.rotate(Math.PI * s.turns); break;
|
|
1150
|
+
case 'path': path(g, s); break;
|
|
1151
|
+
case 'text': g.fillText(s.text, s.x, s.y); break;
|
|
1152
|
+
case 'radial': {
|
|
1153
|
+
const grd = g.createRadialGradient(s.from[0], s.from[1], s.from[2], s.to[0], s.to[1], s.to[2]);
|
|
1154
|
+
for (const [stop, colour] of s.stops) grd.addColorStop(stop, colour);
|
|
1155
|
+
g.fillStyle = grd;
|
|
1156
|
+
g.fillRect(s.x, s.y, s.w, s.h);
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
case 'speckle': {
|
|
1160
|
+
let q = s.seed;
|
|
1161
|
+
const rnd = (): number => { q = (q * 16807) % 2147483647; return q / 2147483647; };
|
|
1162
|
+
const [w0, w1, h0, h1] = s.mark;
|
|
1163
|
+
for (let i = 0; i < s.n; i++) {
|
|
1164
|
+
g.fillStyle = rnd() < s.split ? s.styles[0] : s.styles[1];
|
|
1165
|
+
g.fillRect(s.x + rnd() * s.w, s.y + rnd() * s.h, w0 + rnd() * w1, h0 + rnd() * h1);
|
|
1166
|
+
}
|
|
1167
|
+
break;
|
|
1168
|
+
}
|
|
1169
|
+
case 'grain': {
|
|
1170
|
+
const [w0, wm, h0, hm] = s.mark;
|
|
1171
|
+
for (let i = 0; i < s.n; i++) g.fillRect(s.x + ((i * s.stride[0]) % s.w), s.y + ((i * s.stride[1]) % s.h), w0 + (i % wm), h0 + (i % hm));
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
case 'rng': sc.paint.rng = new Rng(number(s.seed, sc)); break;
|
|
1175
|
+
case 'let': for (const [n, e] of s.vars) sc.vars.set(n, value(e, sc)); break;
|
|
1176
|
+
case 'assign': for (const [n, e] of s.vars) { const v = value(e, sc); sc.owner((x) => x.vars, n).set(n, v); } break;
|
|
1177
|
+
case 'fn': sc.fns.set(s.name, { params: s.params, body: compile(s.body), scope: sc }); break;
|
|
1178
|
+
case 'list': sc.lists.set(s.name, []); break;
|
|
1179
|
+
case 'push': { const l = sc.list(s.list); l.push(s.vals.map((e) => value(e, sc))); break; }
|
|
1180
|
+
case 'loop': { const n = number(s.n, sc); for (let i = 0; i < n; i++) { const it = sc.child(); it.vars.set(s.v, i); run(g, s.body, it); } break; }
|
|
1181
|
+
case 'for': {
|
|
1182
|
+
for (let cur = number(s.from, sc); ;) {
|
|
1183
|
+
const it = sc.child(); it.vars.set(s.v, cur);
|
|
1184
|
+
if (!truthy(compile(s.while)(it))) break;
|
|
1185
|
+
run(g, s.body, it);
|
|
1186
|
+
cur = num(compile(s.next)(it));
|
|
1187
|
+
}
|
|
1188
|
+
break;
|
|
1189
|
+
}
|
|
1190
|
+
case 'each': {
|
|
1191
|
+
if (typeof s.of === 'string') {
|
|
1192
|
+
const names = typeof s.v === 'string' ? [s.v] : s.v;
|
|
1193
|
+
for (const row of sc.list(s.of)) { const it = sc.child(); for (const [i, n] of names.entries()) it.vars.set(n, row[i] ?? 0); run(g, s.body, it); }
|
|
1194
|
+
} else for (const v of s.of) { const it = sc.child(); it.vars.set(typeof s.v === 'string' ? s.v : (s.v[0] ?? ''), v); run(g, s.body, it); }
|
|
1195
|
+
break;
|
|
1196
|
+
}
|
|
1197
|
+
case 'if': {
|
|
1198
|
+
if (truthy(compile(s.cond)(sc))) run(g, s.yes, sc.child());
|
|
1199
|
+
else if (s.no !== undefined) run(g, s.no, sc.child());
|
|
1200
|
+
break;
|
|
1201
|
+
}
|
|
1202
|
+
case 'call': call(g, s.fn, (s.args ?? []).map((e) => number(e, sc))); break;
|
|
1203
|
+
case 'gradient': {
|
|
1204
|
+
const a = s.args.map((e) => number(e, sc));
|
|
1205
|
+
const grd = s.kind === 'linear' ? g.createLinearGradient(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3)) : g.createRadialGradient(canvasArgument(a, 0), canvasArgument(a, 1), canvasArgument(a, 2), canvasArgument(a, 3), canvasArgument(a, 4), canvasArgument(a, 5));
|
|
1206
|
+
for (const [stop, colour] of s.stops) grd.addColorStop(number(stop, sc), style(colour, sc));
|
|
1207
|
+
if (s.to === 'stroke') g.strokeStyle = grd; else g.fillStyle = grd;
|
|
1208
|
+
break;
|
|
1209
|
+
}
|
|
1210
|
+
case 'valueNoise': valueNoise(g, s, stream(sc)); break;
|
|
1211
|
+
default: {
|
|
1212
|
+
const unknown: never = s;
|
|
1213
|
+
throw new Error(`unknown canvas step ${JSON.stringify(unknown)}`);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
/** replay an atlas's steps on a 2D context (already sized and scaled); `vars` seeds the expressions' scope (a level seed) */
|
|
1220
|
+
export function paintSteps(g: CanvasRenderingContext2D, steps: readonly CanvasStep[], vars: Readonly<Record<string, number>> = {}): void {
|
|
1221
|
+
const root = new Scope(null, { g, rng: null });
|
|
1222
|
+
for (const [k, v] of Object.entries(vars)) root.vars.set(k, v);
|
|
1223
|
+
run(g, steps, root);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/** paint an atlas row on a new canvas at `scale` (undefined: no scale call) and return it as a mipmapped sRGB texture */
|
|
1227
|
+
export function paintCanvasAtlas(row: CanvasAtlasRow, scale?: number): CanvasTexture {
|
|
1228
|
+
const cv = document.createElement('canvas');
|
|
1229
|
+
cv.width = row.w * (scale ?? 1);
|
|
1230
|
+
cv.height = row.h * (scale ?? 1);
|
|
1231
|
+
const g = cv.getContext('2d');
|
|
1232
|
+
if (g === null) throw new Error('2d canvas unavailable');
|
|
1233
|
+
if (scale !== undefined) g.scale(scale, scale); // preserve all authored UVs and drawing coordinates at any resolution
|
|
1234
|
+
paintSteps(g, row.steps);
|
|
1235
|
+
const tex = new CanvasTexture(cv);
|
|
1236
|
+
tex.colorSpace = SRGBColorSpace;
|
|
1237
|
+
tex.minFilter = LinearMipmapLinearFilter;
|
|
1238
|
+
tex.anisotropy = 8;
|
|
1239
|
+
return tex;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/** Fetch a zlib-deflated bake and inflate it (a failed fetch throws). */
|
|
1243
|
+
export function fetchDeflated(url: string): Promise<Uint8Array> {
|
|
1244
|
+
return fetchDeflatedBytes(url);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Fetch a trusted runtime's own build file (its generator's output, imported with Vite's `?url`) as its bytes, for a runtime
|
|
1249
|
+
* that decodes it in its own slices rather than evaluating it as module data (Nine Dragon's 6.8 MB layout). A failed fetch
|
|
1250
|
+
* throws.
|
|
1251
|
+
*/
|
|
1252
|
+
export async function fetchBuildFile(url: string): Promise<Uint8Array> {
|
|
1253
|
+
const response = await fetch(url);
|
|
1254
|
+
if (!response.ok) throw new Error(`${String(response.status)} ${url}`);
|
|
1255
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// Lane-shuffled bakes (SHARD-PLATFORM M3; Pine Hollow's crags, streams, timbers, lookout and wildlife): a binary of 4-byte
|
|
1259
|
+
// words whose bytes are split into four lanes (every word's first bytes, then its second …: floats compress ~30 % better
|
|
1260
|
+
// so), deflated. A shard's generator writes them; the page reads them here.
|
|
1261
|
+
|
|
1262
|
+
/** Restore byte lanes, optionally filling a word range in a distinct complete output. */
|
|
1263
|
+
export function unshuffleLanes(lanes: Uint8Array, out: Uint8Array<ArrayBuffer> = new Uint8Array(lanes.length), wordStart = 0, wordEnd: number = lanes.length / 4): Uint8Array {
|
|
1264
|
+
return restoreLanes(lanes, out, wordStart, wordEnd);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/** Fetch a lane-shuffled bake and restore its bytes within the live construction budget. */
|
|
1268
|
+
export function fetchLaneBake(url: string): Promise<Uint8Array> {
|
|
1269
|
+
return fetchLaneBytes(url);
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
// Built geometry as an offline bake stores it: the codec lives in `./bakedGeometry` (build-time producers import it
|
|
1273
|
+
// alone); the page's names stay here.
|
|
1274
|
+
/** an attribute's element type in the bake ('f16' is a half float held in a Uint16Array, Float16BufferAttribute) */
|
|
1275
|
+
export type BakedType = CodecBakedType;
|
|
1276
|
+
/** one baked geometry: its attributes [name, type, item size, normalized], vertex count, index (stored as deltas) */
|
|
1277
|
+
export type BakedGeometryRow = CodecBakedGeometryRow;
|
|
1278
|
+
/** bytes per element of each baked type */
|
|
1279
|
+
export const BAKED_BYTES: typeof codecBakedBytes = codecBakedBytes;
|
|
1280
|
+
/** a block's length padded to 4 bytes */
|
|
1281
|
+
export const pad4: typeof codecPad4 = codecPad4;
|
|
1282
|
+
/** the bytes a row's blocks take in the bake */
|
|
1283
|
+
export const bakedGeometryBytes: typeof codecBakedGeometryBytes = codecBakedGeometryBytes;
|
|
1284
|
+
/** read geometry `row` from `bytes` at `offset` (the arrays are copies the geometry owns) */
|
|
1285
|
+
export const readBakedGeometry: typeof codecReadBakedGeometry = codecReadBakedGeometry;
|
|
1286
|
+
|
|
1287
|
+
/** A baked read expanded to one vertex per corner (a row's `expand`): the same positions, so the read's bounds carry over
|
|
1288
|
+
* (G639: recomputing them over the expanded copy cost ~0.2 s of single Nalati entry frames). The read is disposed. */
|
|
1289
|
+
export function expandBakedGeometry(geometry: BufferGeometry): BufferGeometry {
|
|
1290
|
+
return carryBounds(geometry, geometry.toNonIndexed());
|
|
1291
|
+
}
|
|
1292
|
+
function carryBounds(geometry: BufferGeometry, flat: BufferGeometry): BufferGeometry {
|
|
1293
|
+
if (geometry.boundingBox === null) geometry.computeBoundingBox();
|
|
1294
|
+
flat.boundingBox = geometry.boundingBox; flat.boundingSphere = geometry.boundingSphere;
|
|
1295
|
+
geometry.dispose();
|
|
1296
|
+
return flat;
|
|
1297
|
+
}
|
|
1298
|
+
/** How long a packed body bake stays inflated after its last copy (ms): one entry's spawn bursts share one inflate. At
|
|
1299
|
+
* 2 s a cold Nalati crossing's boss spawn (2.4 s after the herd's) inflated the 8.7 MB bake again in script (fflate,
|
|
1300
|
+
* ~100 ms of one play frame at phone 4× CPU); the held bytes are the burst's own, so the peak does not rise. */
|
|
1301
|
+
const DECODED_HOLD_MS = 10000;
|
|
1302
|
+
/** A packed body catalogue: load its compressed source once, then lend fresh owned parts per spawn. */
|
|
1303
|
+
export interface PackedCreatureBodies {
|
|
1304
|
+
preload: () => Promise<void>;
|
|
1305
|
+
copy: (kind: string, variant: string) => AnimalSpecies;
|
|
1306
|
+
/** Bind inert look rows; a missing body family or numeric pose refuses admission. */
|
|
1307
|
+
looks: (input: unknown) => { all: readonly SpeciesLook[]; get: (kind: string) => SpeciesLook };
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/** zlib bytes inflated by the platform's stream decoder (off the script's own work), or in script where it has none. */
|
|
1311
|
+
async function inflateStream(bytes: Uint8Array): Promise<Uint8Array> {
|
|
1312
|
+
if (typeof DecompressionStream === 'undefined') return unzlibSync(bytes);
|
|
1313
|
+
const inflating = new Blob([bytes.slice()]).stream().pipeThrough(new DecompressionStream('deflate'));
|
|
1314
|
+
return new Uint8Array(await new Response(inflating).arrayBuffer());
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Admit offset-addressed typed geometry blocks, bones and dimensions without changing their packed representation.
|
|
1319
|
+
* The compressed bytes are retained once; each copy inflates and copies its parts, never sharing mutable geometry.
|
|
1320
|
+
* Missing keys, early copies, unsafe paths, truncated blocks and incompatible metadata refuse before handing out a body.
|
|
1321
|
+
*/
|
|
1322
|
+
export function packedCreatureBodies(input: unknown, decode: (bytes: Uint8Array) => Uint8Array = unzlibSync,
|
|
1323
|
+
read?: (name: string) => Promise<Uint8Array>): PackedCreatureBodies {
|
|
1324
|
+
const PackedBodyNumber = wholeV.pipe(wholeV.number(), wholeV.finite());
|
|
1325
|
+
const PackedBodyWhole = wholeV.pipe(PackedBodyNumber, wholeV.integer(), wholeV.minValue(0), wholeV.maxValue(268435456));
|
|
1326
|
+
const PackedBodyPart = wholeV.strictObject({ indexEncoding: wholeV.optional(wholeV.picklist(['delta', 'raw'])),
|
|
1327
|
+
groups: wholeV.optional(wholeV.pipe(wholeV.array(wholeV.tuple([PackedBodyWhole, PackedBodyWhole, PackedBodyWhole])), wholeV.maxLength(1024))),
|
|
1328
|
+
offsets: wholeV.pipe(wholeV.array(PackedBodyWhole), wholeV.maxLength(33)), row: wholeV.strictObject({
|
|
1329
|
+
attrs: wholeV.pipe(wholeV.array(wholeV.tuple([wholeV.string(), wholeV.picklist(['f32', 'f16', 'u16', 'i8', 'u8']), wholeV.pipe(PackedBodyWhole, wholeV.minValue(1), wholeV.maxValue(16)), wholeV.boolean()])), wholeV.maxLength(32)),
|
|
1330
|
+
count: PackedBodyWhole, index: wholeV.nullable(wholeV.picklist(['u16', 'u32'])), indexCount: PackedBodyWhole, box: wholeV.boolean() }) });
|
|
1331
|
+
const PackedBodyParts = wholeV.union([wholeV.null(), PackedBodyPart, wholeV.pipe(wholeV.array(PackedBodyPart), wholeV.maxLength(64))]);
|
|
1332
|
+
const PackedBody = wholeV.strictObject({ kind: wholeV.string(), variant: wholeV.string(),
|
|
1333
|
+
bones: wholeV.pipe(wholeV.array(wholeV.strictObject({ name: wholeV.string(), parent: wholeV.nullable(wholeV.string()), pos: wholeV.tuple([PackedBodyNumber, PackedBodyNumber, PackedBodyNumber]) })), wholeV.maxLength(512)),
|
|
1334
|
+
dims: wholeV.strictObject({ bodyY: PackedBodyNumber, bodyHalfLen: PackedBodyNumber, bodyRadius: PackedBodyNumber, headRadius: PackedBodyNumber, legLen: PackedBodyNumber,
|
|
1335
|
+
feet: wholeV.pipe(wholeV.array(wholeV.tuple([PackedBodyNumber, PackedBodyNumber])), wholeV.maxLength(512)), halfWidth: PackedBodyNumber, capsuleAxis: wholeV.optional(wholeV.picklist(['y', 'z'])) }),
|
|
1336
|
+
fur: PackedBodyParts, hard: PackedBodyParts, eye: PackedBodyParts });
|
|
1337
|
+
const publicBodyFile = wholeV.pipe(wholeV.string(), wholeV.regex(/^\/assets\/[a-zA-Z0-9/_-]+-[0-9a-f]{64}\.bin$/u));
|
|
1338
|
+
const namedBodyFile = wholeV.pipe(wholeV.string(), wholeV.maxLength(256),
|
|
1339
|
+
wholeV.regex(/^(?:[a-zA-Z0-9_-]+\/)*[a-zA-Z0-9_-][a-zA-Z0-9_.-]*\.bin$/u));
|
|
1340
|
+
const bake = wholeV.parse(wholeV.strictObject({ file: wholeV.union([publicBodyFile, namedBodyFile]),
|
|
1341
|
+
bytes: PackedBodyWhole, bodies: wholeV.pipe(wholeV.array(PackedBody), wholeV.maxLength(1024)) }), input);
|
|
1342
|
+
const load = bake.file.startsWith('/') ? fetchBuildFile : read;
|
|
1343
|
+
if (load === undefined) throw new Error('Named packed creature body requires its product reader');
|
|
1344
|
+
const keys = new Set<string>();
|
|
1345
|
+
for (const body of bake.bodies) {
|
|
1346
|
+
const key = JSON.stringify([body.kind, body.variant]);
|
|
1347
|
+
if (keys.has(key)) throw new Error('Duplicate packed creature body');
|
|
1348
|
+
keys.add(key);
|
|
1349
|
+
for (const part of [body.fur, body.hard, body.eye].flatMap(parts => parts === null ? [] : Array.isArray(parts) ? parts : [parts])) {
|
|
1350
|
+
const row = part.row;
|
|
1351
|
+
if (row.attrs[0]?.[0] !== 'position' || new Set(row.attrs.map(attr => attr[0])).size !== row.attrs.length
|
|
1352
|
+
|| part.offsets.length !== row.attrs.length + (row.index === null ? 0 : 1) || (row.index === null && row.indexCount !== 0)) throw new Error('Invalid packed creature part');
|
|
1353
|
+
const sizes = row.attrs.map(([, type, width]) => row.count * width * BAKED_BYTES[type]);
|
|
1354
|
+
if (row.index !== null) sizes.push(row.indexCount * (part.indexEncoding === 'raw' && row.index === 'u16' ? 2 : 4));
|
|
1355
|
+
if (part.offsets.some((offset, i) => offset % 4 !== 0 || offset + (sizes[i] ?? bake.bytes + 1) > bake.bytes)) throw new Error('Packed creature block exceeds its bake');
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
let compressed: Uint8Array | null = null, loading: Promise<void> | null = null, decoded: Uint8Array | null = null, hold: ReturnType<ResourceScope['timeout']> = 0;
|
|
1359
|
+
// The bake inflates once per spawn burst, not once per copy (Nalati's is 8.7 MB for 27 bodies: a herd inflated it per
|
|
1360
|
+
// animal, ~70 ms each on the Simulator). Copies slice their own arrays out, so the inflated bytes go a moment after the last.
|
|
1361
|
+
const inflated = (packed: Uint8Array): Uint8Array => {
|
|
1362
|
+
decoded ??= decode(packed);
|
|
1363
|
+
const scope = resourceScope(); scope.cancelTimer(hold); hold = scope.timeout(DECODED_HOLD_MS, () => { decoded = null; });
|
|
1364
|
+
return decoded;
|
|
1365
|
+
};
|
|
1366
|
+
const catalogue: PackedCreatureBodies = {
|
|
1367
|
+
// G639: the bake is inflated as it loads, by the platform's stream decoder where it can (a Nalati entry spent ~0.13 s of
|
|
1368
|
+
// one frame inflating 8.7 MB in script at its first spawn); it is held until the first burst's copies are done
|
|
1369
|
+
preload: () => {
|
|
1370
|
+
loading ??= load(bake.file).then(async bytes => { compressed = bytes; if (decode === unzlibSync) decoded ??= await inflateStream(bytes); return undefined; });
|
|
1371
|
+
return loading;
|
|
1372
|
+
},
|
|
1373
|
+
looks: lookInput => {
|
|
1374
|
+
const book = parsePackedCreatureLooks(lookInput);
|
|
1375
|
+
if (new Set(book.rows.map(row => row.id)).size !== book.rows.length || new Set(book.rows.map(row => row.kind)).size !== book.rows.length) throw new Error('Duplicate packed creature look');
|
|
1376
|
+
const all = book.rows.map((row): SpeciesLook => {
|
|
1377
|
+
const family = row.family ?? row.kind;
|
|
1378
|
+
const bodyKey = (source: NonNullable<typeof row.variants>[string]): string => typeof source === 'string' ? source : source.body;
|
|
1379
|
+
if (!bake.bodies.some(body => body.kind === family) || Object.values(row.variants ?? {}).some(variant => !keys.has(JSON.stringify([family, bodyKey(variant)])))) throw new Error('Missing packed creature look body');
|
|
1380
|
+
const poseRows = row.pose === undefined ? undefined : book.poses[row.pose];
|
|
1381
|
+
if (row.pose !== undefined && poseRows === undefined) throw new Error('Missing packed creature joint pose');
|
|
1382
|
+
const pose = row.pose === undefined ? undefined : numericCreaturePoseFromBook(book, row.pose);
|
|
1383
|
+
const look: SpeciesLook = { id: row.id, species: row.species, kind: row.kind, fur: NO_FUR,
|
|
1384
|
+
rigContract: { skeleton: row.skeleton, sockets: row.sockets, clips: row.clips },
|
|
1385
|
+
build: variant => {
|
|
1386
|
+
const source = row.variants?.[variant.id], key = row.variants === undefined ? variant.id : source === undefined ? undefined : bodyKey(source);
|
|
1387
|
+
if (key === undefined) throw new Error('Unknown packed creature look variant');
|
|
1388
|
+
const body = catalogue.copy(family, key); return row.facetJitter === undefined ? body : { ...body, facetJitter: row.facetJitter };
|
|
1389
|
+
},
|
|
1390
|
+
};
|
|
1391
|
+
if (row.rig !== undefined) look.rig = row.rig;
|
|
1392
|
+
if (row.standMem !== undefined) look.standMem = row.standMem;
|
|
1393
|
+
if (row.eyeGlow !== undefined) look.eyeGlow = row.eyeGlow;
|
|
1394
|
+
if (row.eyeGlowIntensity !== undefined) look.eyeGlowIntensity = row.eyeGlowIntensity;
|
|
1395
|
+
if (row.hitArc !== undefined) {
|
|
1396
|
+
// the blow travels against the heading when it lands from the front
|
|
1397
|
+
const front = Math.cos(row.hitArc.arc * Math.PI / 180), scale = row.hitArc.scale;
|
|
1398
|
+
look.damageMul = (a, _hit, dir) => Math.sin(a.yaw) * dir.x + Math.cos(a.yaw) * dir.z < -front ? scale : 1;
|
|
1399
|
+
}
|
|
1400
|
+
if (pose !== undefined || row.lift !== undefined) look.animate = context => {
|
|
1401
|
+
if (row.lift !== undefined) stepCreatureLift(context.animal, context.dt, ...row.lift);
|
|
1402
|
+
pose?.(context);
|
|
1403
|
+
};
|
|
1404
|
+
return look;
|
|
1405
|
+
});
|
|
1406
|
+
return { all, get: kind => { const look = all.find(row => row.kind === kind); if (look === undefined) throw new Error('Unknown packed creature look'); return look; } };
|
|
1407
|
+
},
|
|
1408
|
+
copy: (kind, variant) => {
|
|
1409
|
+
const body = bake.bodies.find(row => row.kind === kind && row.variant === variant);
|
|
1410
|
+
if (body === undefined) throw new Error(`no baked creature body ${kind}.${variant}`);
|
|
1411
|
+
if (compressed === null) throw new Error(`Packed creature bodies are not loaded (${kind}.${variant})`);
|
|
1412
|
+
const bytes = inflated(compressed);
|
|
1413
|
+
if (bytes.length !== bake.bytes) throw new Error('Packed creature bake does not match its rows');
|
|
1414
|
+
const part = (sources: wholeV.InferOutput<typeof PackedBodyParts>): BufferGeometry[] => (sources === null ? [] : Array.isArray(sources) ? sources : [sources]).map(source => {
|
|
1415
|
+
const at = (i: number): number => { const offset = source.offsets[i]; if (offset === undefined) throw new Error('Packed creature block is missing'); return offset; };
|
|
1416
|
+
const one = { ...source.row, index: null, indexCount: 0 }, [first, ...rest] = source.row.attrs;
|
|
1417
|
+
if (first === undefined) throw new Error('Packed creature part has no attributes');
|
|
1418
|
+
const g = readBakedGeometry(bytes, at(0), { ...one, attrs: [first] });
|
|
1419
|
+
// each further attribute is its own block: read straight into its attribute (a geometry and a bounds pass per block
|
|
1420
|
+
// were half of a Nalati entry's creature body copies at phone 4x, T10)
|
|
1421
|
+
rest.forEach((attr, i) => { g.setAttribute(attr[0], readBakedAttribute(bytes, at(i + 1), one.count, attr)); });
|
|
1422
|
+
if (source.row.index !== null) {
|
|
1423
|
+
const start = at(source.row.attrs.length), size = source.row.index === 'u16' ? 2 : 4;
|
|
1424
|
+
if (source.indexEncoding === 'raw') {
|
|
1425
|
+
const buffer = bytes.slice(start, start + source.row.indexCount * size).buffer;
|
|
1426
|
+
g.setIndex(new BufferAttribute(source.row.index === 'u16' ? new Uint16Array(buffer) : new Uint32Array(buffer), 1));
|
|
1427
|
+
} else g.setIndex(readBakedGeometry(bytes, start, { ...source.row, attrs: [] }).index);
|
|
1428
|
+
}
|
|
1429
|
+
for (const [start, count, material] of source.groups ?? []) g.addGroup(start, count, material);
|
|
1430
|
+
return g;
|
|
1431
|
+
});
|
|
1432
|
+
const { capsuleAxis, ...dims } = body.dims;
|
|
1433
|
+
return { bones: body.bones.map(bone => ({ name: bone.name, parent: bone.parent, pos: [bone.pos[0], bone.pos[1], bone.pos[2]] })),
|
|
1434
|
+
furParts: part(body.fur), hardParts: part(body.hard), eyeParts: part(body.eye),
|
|
1435
|
+
dims: { ...dims, feet: dims.feet.map((foot): [number, number] => [foot[0], foot[1]]), ...(capsuleAxis === undefined ? {} : { capsuleAxis }) } };
|
|
1436
|
+
},
|
|
1437
|
+
};
|
|
1438
|
+
return catalogue;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/** `a` (a baked builder's geometry) with `b` (what the page added to that builder since) after it */
|
|
1442
|
+
export const appendGeometry: typeof codecAppendGeometry = codecAppendGeometry;
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* Primitives as rows (SHARD-PLATFORM M3): a three.js primitive, the transforms applied to it in order (translate,
|
|
1446
|
+
* rotate about an axis, scale: the geometry's own methods, so every vertex is the one hand-written code computed), and
|
|
1447
|
+
* whether it is made non-indexed; a list of them merged in order into one geometry that keeps every part's attributes
|
|
1448
|
+
* (position, normal, uv). A lantern's iron frame, a ribcage's hoops or a skull plate is data; `standardMaterial` makes a
|
|
1449
|
+
* MeshStandardMaterial from a row (hex or working-space colours). Unlike `primitiveParts` (one colour per part, normals
|
|
1450
|
+
* recomputed) the parts keep their own normals and uvs.
|
|
1451
|
+
*
|
|
1452
|
+
* const frame = mergePrimitives(rows); // every row non-indexed, merged
|
|
1453
|
+
* const glass = buildPrimitive(row); // one part as it stands
|
|
1454
|
+
*/
|
|
1455
|
+
|
|
1456
|
+
/** A primitive's kind; `args` are its three.js constructor's, in order (a cylinder's sixth, open-ended, is 1 for true); an
|
|
1457
|
+
* `extrude` is its row's `shape` extruded by its `extrude` options. */
|
|
1458
|
+
export type PrimitiveKind = 'box' | 'cylinder' | 'cone' | 'sphere' | 'torus' | 'icosahedron' | 'capsule' | 'extrude';
|
|
1459
|
+
|
|
1460
|
+
/** One transform, applied by the geometry's own method (`rotateX` … angles in radians). */
|
|
1461
|
+
export type PrimitiveOp = readonly ['translate' | 'scale', number, number, number] | readonly ['rotateX' | 'rotateY' | 'rotateZ', number];
|
|
1462
|
+
|
|
1463
|
+
/** One step of a 2D outline (three's Shape path methods, in order). */
|
|
1464
|
+
export type ShapeStep = readonly ['moveTo' | 'lineTo', number, number] | readonly ['quadraticCurveTo', number, number, number, number];
|
|
1465
|
+
/** An outline's extrusion (three's ExtrudeGeometry options). */
|
|
1466
|
+
export interface ExtrudeRow {
|
|
1467
|
+
readonly depth: number; readonly bevelEnabled: boolean; readonly bevelThickness: number; readonly bevelSize: number;
|
|
1468
|
+
readonly bevelSegments: number; readonly curveSegments: number;
|
|
1469
|
+
}
|
|
1470
|
+
/** One primitive as data. */
|
|
1471
|
+
export interface PrimitiveRow {
|
|
1472
|
+
readonly kind: PrimitiveKind;
|
|
1473
|
+
readonly args: readonly number[];
|
|
1474
|
+
/** an `extrude`'s outline and options */
|
|
1475
|
+
readonly shape?: readonly ShapeStep[];
|
|
1476
|
+
readonly extrude?: ExtrudeRow;
|
|
1477
|
+
/** applied in order */
|
|
1478
|
+
readonly ops?: readonly PrimitiveOp[];
|
|
1479
|
+
}
|
|
1480
|
+
/** A primitive painted one colour (a CSS colour string) into a `color` vertex attribute. */
|
|
1481
|
+
export interface PaintedPrimitiveRow extends PrimitiveRow {
|
|
1482
|
+
readonly paint: string;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
/** A MeshStandardMaterial as data: colours a hex number or working-space (r, g, b). */
|
|
1486
|
+
export interface StandardMaterialRow {
|
|
1487
|
+
readonly color: number | readonly [number, number, number];
|
|
1488
|
+
readonly emissive?: number | readonly [number, number, number];
|
|
1489
|
+
readonly emissiveIntensity?: number;
|
|
1490
|
+
readonly roughness: number;
|
|
1491
|
+
readonly metalness: number;
|
|
1492
|
+
readonly fog?: boolean;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
const arg = (a: readonly number[], i: number): number | undefined => a[i];
|
|
1496
|
+
|
|
1497
|
+
function primitive(p: PrimitiveRow): BufferGeometry {
|
|
1498
|
+
const a = p.args;
|
|
1499
|
+
switch (p.kind) {
|
|
1500
|
+
case 'box': return new BoxGeometry(arg(a, 0), arg(a, 1), arg(a, 2));
|
|
1501
|
+
case 'cylinder': return new CylinderGeometry(arg(a, 0), arg(a, 1), arg(a, 2), arg(a, 3), arg(a, 4), arg(a, 5) === 1);
|
|
1502
|
+
case 'cone': return new ConeGeometry(arg(a, 0), arg(a, 1), arg(a, 2));
|
|
1503
|
+
case 'sphere': return new SphereGeometry(arg(a, 0), arg(a, 1), arg(a, 2));
|
|
1504
|
+
case 'torus': return new TorusGeometry(arg(a, 0), arg(a, 1), arg(a, 2), arg(a, 3), arg(a, 4));
|
|
1505
|
+
case 'icosahedron': return new IcosahedronGeometry(arg(a, 0), arg(a, 1));
|
|
1506
|
+
case 'capsule': return new CapsuleGeometry(arg(a, 0), arg(a, 1), arg(a, 2), arg(a, 3));
|
|
1507
|
+
case 'extrude': return extruded(p);
|
|
1508
|
+
default: {
|
|
1509
|
+
const unknown: never = p.kind;
|
|
1510
|
+
throw new Error(`unknown primitive ${String(unknown)}`);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/** an `extrude` row's outline, extruded */
|
|
1516
|
+
function extruded(p: PrimitiveRow): BufferGeometry {
|
|
1517
|
+
if (p.shape === undefined || p.extrude === undefined) throw new Error('an extrude primitive needs a shape and its options');
|
|
1518
|
+
const s = new Shape();
|
|
1519
|
+
for (const step of p.shape) {
|
|
1520
|
+
if (step[0] === 'quadraticCurveTo') s.quadraticCurveTo(step[1], step[2], step[3], step[4]);
|
|
1521
|
+
else if (step[0] === 'moveTo') s.moveTo(step[1], step[2]);
|
|
1522
|
+
else s.lineTo(step[1], step[2]);
|
|
1523
|
+
}
|
|
1524
|
+
const e = p.extrude;
|
|
1525
|
+
return new ExtrudeGeometry(s, { depth: e.depth, bevelEnabled: e.bevelEnabled, bevelThickness: e.bevelThickness, bevelSize: e.bevelSize, bevelSegments: e.bevelSegments, curveSegments: e.curveSegments });
|
|
1526
|
+
}
|
|
1527
|
+
/** One primitive with its transforms applied in order (indexed as three.js builds it). */
|
|
1528
|
+
export function buildPrimitive(row: PrimitiveRow): BufferGeometry {
|
|
1529
|
+
const g = primitive(row);
|
|
1530
|
+
for (const op of row.ops ?? []) {
|
|
1531
|
+
if (op[0] === 'translate') g.translate(op[1], op[2], op[3]);
|
|
1532
|
+
else if (op[0] === 'scale') g.scale(op[1], op[2], op[3]);
|
|
1533
|
+
else if (op[0] === 'rotateX') g.rotateX(op[1]);
|
|
1534
|
+
else if (op[0] === 'rotateY') g.rotateY(op[1]);
|
|
1535
|
+
else g.rotateZ(op[1]);
|
|
1536
|
+
}
|
|
1537
|
+
return g;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
const merged = (parts: BufferGeometry[]): BufferGeometry => mergeGeometries(parts, false);
|
|
1541
|
+
/** The rows built (`buildPrimitive`), each made non-indexed, merged in order into one geometry (no groups). */
|
|
1542
|
+
export function mergePrimitives(rows: readonly PrimitiveRow[]): BufferGeometry {
|
|
1543
|
+
return merged(rows.map((r) => buildPrimitive(r).toNonIndexed()));
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* The rows built (`buildPrimitive`), each non-indexed (an indexed one copied so), painted its colour into a `color`
|
|
1547
|
+
* attribute and stripped to position, normal, uv and color, merged in order into one geometry (no groups): a
|
|
1548
|
+
* vertex-coloured stand-in in one draw.
|
|
1549
|
+
*/
|
|
1550
|
+
export function paintedPrimitives(rows: readonly PaintedPrimitiveRow[]): BufferGeometry {
|
|
1551
|
+
return merged(rows.map((r) => {
|
|
1552
|
+
const g = buildPrimitive(r), out = g.index ? g.toNonIndexed() : g;
|
|
1553
|
+
const c = new Color(r.paint), n = out.getAttribute('position').count, col = new Float32Array(n * 3);
|
|
1554
|
+
for (let i = 0; i < n; i++) { col[i * 3] = c.r; col[i * 3 + 1] = c.g; col[i * 3 + 2] = c.b; }
|
|
1555
|
+
out.setAttribute('color', new BufferAttribute(col, 3));
|
|
1556
|
+
for (const k of Object.keys(out.attributes)) if (k !== 'position' && k !== 'normal' && k !== 'uv' && k !== 'color') out.deleteAttribute(k);
|
|
1557
|
+
return out;
|
|
1558
|
+
}));
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
const colour = (c: number | readonly [number, number, number]): Color => (typeof c === 'number' ? new Color(c) : new Color(c[0], c[1], c[2]));
|
|
1562
|
+
|
|
1563
|
+
/** A MeshStandardMaterial from its row (fog left at three's default unless the row says). */
|
|
1564
|
+
export function standardMaterial(row: StandardMaterialRow): MeshStandardMaterial {
|
|
1565
|
+
const p: MeshStandardMaterialParameters = { color: colour(row.color), roughness: row.roughness, metalness: row.metalness };
|
|
1566
|
+
if (row.emissive !== undefined) p.emissive = colour(row.emissive);
|
|
1567
|
+
if (row.emissiveIntensity !== undefined) p.emissiveIntensity = row.emissiveIntensity;
|
|
1568
|
+
if (row.fog !== undefined) p.fog = row.fog;
|
|
1569
|
+
return new MeshStandardMaterial(p);
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
/** Split a geometry by triangle centroid into `parts` (de-indexed, every attribute kept; flat normals recomputed when `flat`); disposes the input. */
|
|
1573
|
+
function partition(source: BufferGeometry, parts: number, of: (x: number, y: number, z: number) => number, flat: boolean): BufferGeometry[] {
|
|
1574
|
+
const p = source.getAttribute('position'), index = source.index, triangles = Math.floor((index?.count ?? p.count) / 3);
|
|
1575
|
+
const side = new Uint8Array(triangles), counts = new Uint32Array(parts);
|
|
1576
|
+
const vertex = (i: number): number => index === null ? i : index.getX(i);
|
|
1577
|
+
// Match toNonIndexed's base-attribute interpretation, including normalized and half storage.
|
|
1578
|
+
const attributes = Object.entries(source.attributes).map(([name, attribute]) => {
|
|
1579
|
+
const interleaved = 'isInterleavedBufferAttribute' in attribute;
|
|
1580
|
+
const reader = index === null ? attribute : new BufferAttribute(interleaved ? attribute.data.array : attribute.array,
|
|
1581
|
+
interleaved ? attribute.data.stride : attribute.itemSize, attribute.normalized);
|
|
1582
|
+
return { name, attribute, reader, offset: index !== null && interleaved ? attribute.offset : 0 };
|
|
1583
|
+
});
|
|
1584
|
+
const position = attributes.find(attribute => attribute.name === 'position');
|
|
1585
|
+
if (position === undefined) throw new Error('Missing pivot positions');
|
|
1586
|
+
const coordinate = (at: number, component: number): number => position.reader.getComponent(at, position.offset + component);
|
|
1587
|
+
for (let t = 0; t < triangles; t++) {
|
|
1588
|
+
const a = vertex(t * 3), b = vertex(t * 3 + 1), c = vertex(t * 3 + 2);
|
|
1589
|
+
const part = of((coordinate(a, 0) + coordinate(b, 0) + coordinate(c, 0)) / 3, (coordinate(a, 1) + coordinate(b, 1) + coordinate(c, 1)) / 3, (coordinate(a, 2) + coordinate(b, 2) + coordinate(c, 2)) / 3);
|
|
1590
|
+
side[t] = part; counts[part] = (counts[part] ?? 0) + 3;
|
|
1591
|
+
}
|
|
1592
|
+
const offsets = new Uint32Array(parts);
|
|
1593
|
+
const out = Array.from({ length: parts }, (_, part) => {
|
|
1594
|
+
const geometry = new BufferGeometry();
|
|
1595
|
+
for (const { name, attribute } of attributes) geometry.setAttribute(name, new Float32BufferAttribute((counts[part] ?? 0) * attribute.itemSize, attribute.itemSize));
|
|
1596
|
+
return geometry;
|
|
1597
|
+
});
|
|
1598
|
+
// Read indexed source components once, directly into each exactly sized part.
|
|
1599
|
+
const targets = out.map(geometry => attributes.map(({ name }) => geometry.getAttribute(name)));
|
|
1600
|
+
for (let t = 0; t < triangles; t++) {
|
|
1601
|
+
const part = side[t], target = part === undefined ? undefined : targets[part];
|
|
1602
|
+
if (part === undefined || target === undefined) throw new Error('Missing pivot partition');
|
|
1603
|
+
const offset = offsets[part] ?? 0;
|
|
1604
|
+
for (let local = 0; local < 3; local++) {
|
|
1605
|
+
const at = vertex(t * 3 + local);
|
|
1606
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
1607
|
+
const entry = attributes[i], destination = target[i];
|
|
1608
|
+
if (entry === undefined || destination === undefined) throw new Error('Missing pivot attribute');
|
|
1609
|
+
for (let c = 0; c < entry.attribute.itemSize; c++) destination.array[(offset + local) * entry.attribute.itemSize + c] = entry.reader.getComponent(at, entry.offset + c);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
offsets[part] = offset + 3;
|
|
1613
|
+
}
|
|
1614
|
+
for (const geometry of out) {
|
|
1615
|
+
if (flat) geometry.computeVertexNormals();
|
|
1616
|
+
geometry.computeBoundingBox(); geometry.computeBoundingSphere();
|
|
1617
|
+
}
|
|
1618
|
+
source.dispose(); return out;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
/** A baked pivot figure's body/head/upper-arm/forearm geometries, each already in its own pivot's local frame. */
|
|
1622
|
+
export interface PivotNpcGeometry { readonly body: BufferGeometry; readonly head: BufferGeometry; readonly arm: BufferGeometry; readonly fore: BufferGeometry }
|
|
1623
|
+
|
|
1624
|
+
/** A pivot NPC's figure on its pivots: the body under `root`, the head at the neck, the arm at the shoulder and its forearm at the elbow. */
|
|
1625
|
+
export interface PivotNpcParts { readonly root: Group; readonly head: Group; readonly arm: Group; readonly elbow: Group }
|
|
1626
|
+
/**
|
|
1627
|
+
* A pivot NPC's figure (SF27): the row's model (`source`) fitted to its height and cut onto pivots by its figure row
|
|
1628
|
+
* (`NpcRowSchema`): the body, the head at the neck, the arm at the shoulder and its forearm at the elbow, in `material`
|
|
1629
|
+
* (else one vertex-coloured standard material). Feet on y 0, facing +Z, at its own origin (the Model Explorer shows it so).
|
|
1630
|
+
*/
|
|
1631
|
+
export function pivotNpcParts(row: NpcRow, source: BufferGeometry | PivotNpcGeometry, material?: Material): PivotNpcParts {
|
|
1632
|
+
const fig = row.figure, neck = fig.neck, [sx, sy, sz] = fig.shoulder, top = fig.armTopY ?? (neck === undefined ? Infinity : neck[1] + 0.02);
|
|
1633
|
+
const slope = fig.armSlope ?? 0, cut = fig.elbow, [ex, ey, ez] = cut?.at ?? fig.shoulder;
|
|
1634
|
+
const prepared = !(source instanceof BufferGeometry);
|
|
1635
|
+
let parts: readonly BufferGeometry[];
|
|
1636
|
+
if (source instanceof BufferGeometry) {
|
|
1637
|
+
const whole = fitGeometry(source, { size: fig.height, by: 'height', ...(fig.centre === undefined ? {} : { centre: fig.centre }) });
|
|
1638
|
+
parts = partition(whole, 4, (x, y) => neck !== undefined && y >= neck[1] ? 1
|
|
1639
|
+
: x < fig.armBelowX + slope * y && y > fig.armAboveY && y < top ? (cut !== undefined && (x - ex) * cut.axis[0] + (y - ey) * cut.axis[1] > 0 ? 3 : 2) : 0, fig.flat);
|
|
1640
|
+
} else parts = [source.body, source.head, source.arm, source.fore];
|
|
1641
|
+
const [body, head, arm, fore] = parts;
|
|
1642
|
+
const paint = material ?? new MeshStandardMaterial({ vertexColors: true, roughness: fig.roughness, metalness: 0, flatShading: fig.flat });
|
|
1643
|
+
const root = new Group(), headPivot = new Group(), armPivot = new Group(), elbow = new Group();
|
|
1644
|
+
if (neck !== undefined) { headPivot.position.set(neck[0], neck[1], neck[2]); if (!prepared) head?.translate(-neck[0], -neck[1], -neck[2]); }
|
|
1645
|
+
armPivot.position.set(sx, sy, sz); elbow.position.set(ex - sx, ey - sy, ez - sz);
|
|
1646
|
+
for (const [g, pivot] of [[body, root], [head, headPivot], [prepared ? arm : arm?.translate(-sx, -sy, -sz), armPivot], [prepared ? fore : fore?.translate(-ex, -ey, -ez), elbow]] as const) {
|
|
1647
|
+
if (g === undefined) continue;
|
|
1648
|
+
if (g.getAttribute('position').count > 0) pivot.add(new Mesh(g, paint)); else g.dispose();
|
|
1649
|
+
}
|
|
1650
|
+
armPivot.add(elbow); root.add(headPivot, armPivot);
|
|
1651
|
+
return { root, head: headPivot, arm: armPivot, elbow };
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
/** The SF27 quest-giver's motion: it faces you, waves overhead until met, gestures at the chest as it talks and breathes. */
|
|
1655
|
+
export const PIVOT_NPC_MOTION: NpcMotion = { turns: true, waveUntilMet: true, ease: 8, breathe: { yaw: [0, 0], scale: [0.008, 1.3] },
|
|
1656
|
+
rest: { lift: [0, 0, 0], forward: [0, 0, 0], bend: [0, 0, 0] },
|
|
1657
|
+
wave: { lift: [-2.5, 0.3, 7], forward: [0, 0, 0], bend: [0, 0, 0] },
|
|
1658
|
+
talk: { lift: [-0.9, 0.2, 2.3], forward: [-0.5, -0.3, 1.7, 'half'], bend: [0, 0, 0] } };
|
|
1659
|
+
/** A pivot NPC in the world: its group, its head (the talk prompt's anchor), its speaker and its per-frame motion. */
|
|
1660
|
+
export interface PivotNpc { readonly group: Group; readonly head: Vector3; readonly speaker: { talking: boolean }; update: (dt: number, t: number, player: Vector3, met: boolean) => void }
|
|
1661
|
+
|
|
1662
|
+
const wrapAngle = (a: number): number => Math.atan2(Math.sin(a), Math.cos(a));
|
|
1663
|
+
const swingAt = (s: NpcMotion['rest']['lift'], t: number): number => s[0] + s[1] * (s.length === 4 ? Math.max(0, Math.sin(t * s[2])) : Math.sin(t * s[2]));
|
|
1664
|
+
/**
|
|
1665
|
+
* The row's NPC standing on the ground, moving by its motion row (`NpcMotionSchema`, else `PIVOT_NPC_MOTION`): it turns
|
|
1666
|
+
* to face the player within `faceRange` or while it talks (else back to `faceHome`), its head follows within ±0.7 rad,
|
|
1667
|
+
* its arm takes the talk pose while it talks, the wave pose within `waveRange` (until met, when the row says so), else
|
|
1668
|
+
* the rest pose, and it breathes. No source (its model did not load): no figure, the talk anchor and speaker still stand.
|
|
1669
|
+
*/
|
|
1670
|
+
export function pivotNpc(row: NpcRow, source: BufferGeometry | PivotNpcGeometry | null, groundAt: (x: number, z: number) => number, material?: Material): PivotNpc {
|
|
1671
|
+
const { x: ax, z: az } = row.at, y = groundAt(ax, az), m = row.motion ?? PIVOT_NPC_MOTION, group = new Group(), speaker = { talking: false };
|
|
1672
|
+
const head = new Vector3(ax, y + row.talkHeight, az), home = Math.atan2(row.faceHome.x - ax, row.faceHome.z - az);
|
|
1673
|
+
group.position.set(ax, y, az); group.rotation.y = home;
|
|
1674
|
+
if (source === null) return { group, head, speaker, update: () => undefined };
|
|
1675
|
+
const parts = pivotNpcParts(row, source, material); group.add(parts.root);
|
|
1676
|
+
let facing = home;
|
|
1677
|
+
return { group, head, speaker, update: (dt, t, player, met) => {
|
|
1678
|
+
const dx = player.x - ax, dz = player.z - az, d = Math.hypot(dx, dz), toYou = Math.atan2(dx, dz), k = 1 - Math.exp(-3 * dt);
|
|
1679
|
+
if (m.turns) facing += wrapAngle((d < row.faceRange || speaker.talking ? toYou : home) - facing) * k;
|
|
1680
|
+
group.rotation.y = facing + m.breathe.yaw[0] * Math.sin(t * m.breathe.yaw[1]);
|
|
1681
|
+
parts.head.rotation.y += (Math.max(-0.7, Math.min(0.7, wrapAngle(toYou - group.rotation.y))) * (d < row.faceRange ? 1 : 0) - parts.head.rotation.y) * k;
|
|
1682
|
+
parts.head.rotation.x = speaker.talking ? Math.sin(t * 5.2) * 0.05 : Math.sin(t * 0.7) * 0.02;
|
|
1683
|
+
const pose = speaker.talking ? m.talk : d < row.waveRange && !(m.waveUntilMet && met) ? m.wave : m.rest, e = Math.min(1, dt * m.ease);
|
|
1684
|
+
parts.arm.rotation.z += (swingAt(pose.lift, t) - parts.arm.rotation.z) * e; parts.arm.rotation.x += (swingAt(pose.forward, t) - parts.arm.rotation.x) * e;
|
|
1685
|
+
parts.elbow.rotation.z += (swingAt(pose.bend, t) - parts.elbow.rotation.z) * e;
|
|
1686
|
+
parts.root.scale.y = 1 + m.breathe.scale[0] * Math.sin(t * m.breathe.scale[1]);
|
|
1687
|
+
} };
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/** What `installPivotNpc` is lent: the model (null: not loaded), its material, the ground, the player, its met flag's reader, the piece's source file and the shard's dressing of the figure. */
|
|
1691
|
+
export interface PivotNpcPorts {
|
|
1692
|
+
readonly source: BufferGeometry | PivotNpcGeometry | null;
|
|
1693
|
+
/** the figure's material (a textured model's own); else one vertex-coloured standard material */
|
|
1694
|
+
readonly material?: Material;
|
|
1695
|
+
readonly groundAt: (x: number, z: number) => number;
|
|
1696
|
+
readonly player: Vector3;
|
|
1697
|
+
readonly met: () => boolean;
|
|
1698
|
+
/** the authored file the piece names (the Model Explorer and the physics bake list it) */
|
|
1699
|
+
readonly file: string;
|
|
1700
|
+
/** the shard's look on the figure (its light rim, resource ownership) */
|
|
1701
|
+
readonly dress?: (group: Group) => void;
|
|
1702
|
+
}
|
|
1703
|
+
type NpcSurface = NonNullable<NpcRow['collider']>['surface'];
|
|
1704
|
+
/** The level a pivot NPC is installed in (a LevelContext fits): its root, its piece registry and its systems. */
|
|
1705
|
+
export interface PivotNpcLevel {
|
|
1706
|
+
readonly root: Group;
|
|
1707
|
+
piece: (piece: { id: string; name: string; category: 'props'; file: string; object: Group; surface: NpcSurface;
|
|
1708
|
+
colliders: { kind: 'box'; x: number; y: number; z: number; hx: number; hy: number; hz: number; yaw: number; surface: NpcSurface }[] }) => void;
|
|
1709
|
+
system: (spec: { id: string; phase: 'update'; run: (dt: number, t: number) => void }) => void;
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Installs the row's NPC in a level: the figure under the level root, a solid column piece round it when the row has a
|
|
1713
|
+
* collider (it turns in place, so the box stays square), and its motion each frame.
|
|
1714
|
+
*/
|
|
1715
|
+
export function installPivotNpc(ctx: PivotNpcLevel, row: NpcRow, ports: PivotNpcPorts): PivotNpc {
|
|
1716
|
+
const npc = pivotNpc(row, ports.source, ports.groundAt, ports.material), c = row.collider, y = npc.group.position.y;
|
|
1717
|
+
ctx.root.add(npc.group); ports.dress?.(npc.group);
|
|
1718
|
+
if (c !== undefined) ctx.piece({ id: row.id, name: row.name, category: 'props', file: ports.file, object: npc.group,
|
|
1719
|
+
colliders: [{ kind: 'box', x: row.at.x, y: y + (c.above - c.below) / 2, z: row.at.z, hx: c.half, hy: Math.max(0.005, (c.above + c.below) / 2), hz: c.half, yaw: -0, surface: c.surface }], surface: c.surface });
|
|
1720
|
+
if (ports.source !== null) ctx.system({ id: row.id, phase: 'update', run: (dt, t) => { npc.update(dt, t, ports.player, ports.met()); } });
|
|
1721
|
+
return npc;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
const WHOLE_TIMING_PHASES = ['read-wait', 'decode', 'assemble', 'yield', 'release', 'finalize'] as const;
|
|
1725
|
+
const wholeArrayTag = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag);
|
|
1726
|
+
function wholeUnsignedIndex(index: unknown): boolean {
|
|
1727
|
+
if (index === null) return true;
|
|
1728
|
+
if (!ArrayBuffer.isView(index)) return false;
|
|
1729
|
+
const tag: unknown = wholeArrayTag?.get?.call(index);
|
|
1730
|
+
return tag === 'Uint16Array' || tag === 'Uint32Array';
|
|
1731
|
+
}
|
|
1732
|
+
function isWholeMesh(node: Object3D): node is Mesh { return node instanceof Mesh; }
|
|
1733
|
+
function wholeStorage(row: wholeV.InferOutput<typeof WholeAttribute>, count: number): BufferAttribute {
|
|
1734
|
+
const n = row.itemSize * count;
|
|
1735
|
+
if (row.storage === 'Float16Array') return new Float16BufferAttribute(new Uint16Array(n), row.itemSize, row.normalized);
|
|
1736
|
+
const array = row.storage === 'Float32Array' ? new Float32Array(n) : row.storage === 'Uint16Array' ? new Uint16Array(n)
|
|
1737
|
+
: row.storage === 'Uint32Array' ? new Uint32Array(n) : row.storage === 'Int16Array' ? new Int16Array(n)
|
|
1738
|
+
: row.storage === 'Int8Array' ? new Int8Array(n) : new Uint8Array(n);
|
|
1739
|
+
return new BufferAttribute(array, row.itemSize, row.normalized);
|
|
1740
|
+
}
|
|
1741
|
+
/** One original source draw reconstructed from exact subsets, at its original double-precision matrix. */
|
|
1742
|
+
export interface WholeGeometryView {
|
|
1743
|
+
readonly geometry: BufferGeometry; readonly matrix: Matrix4;
|
|
1744
|
+
/** Forget decoded-source ownership after adopting or copying it into a scope-owned render object. */
|
|
1745
|
+
readonly release?: () => void;
|
|
1746
|
+
}
|
|
1747
|
+
/** A verified subset of one original draw. Ordinals identify its exact source
|
|
1748
|
+
* vertices and triangles; completeness belongs to the full-model reader. */
|
|
1749
|
+
export interface WholeGeometryPiece extends WholeGeometryView {
|
|
1750
|
+
readonly part: string; readonly vertices: readonly number[]; readonly triangles: readonly number[];
|
|
1751
|
+
readonly vertexCount: number; readonly indexCount: number; readonly layout: string;
|
|
1752
|
+
}
|
|
1753
|
+
class WholeGeometryAssembler {
|
|
1754
|
+
private readonly groups = new Map<string, { output: BufferGeometry; matrix: Matrix4; seen: Uint8Array; triangles: Uint8Array; layout: string }>();
|
|
1755
|
+
add(node: Mesh, ownership: 'borrow' | 'take' = 'borrow'): void {
|
|
1756
|
+
const metadata: unknown = node.userData['wholePartition'], instances: unknown = node.userData['instances64'];
|
|
1757
|
+
const pose: unknown = node.userData['matrix64'] ?? (node instanceof InstancedMesh && node.count === 1 && Array.isArray(instances) && instances.length === 1 ? instances[0] : undefined);
|
|
1758
|
+
const row = readWholePartition(metadata);
|
|
1759
|
+
const values = wholeV.parse(wholeV.pipe(wholeV.array(wholeV.pipe(wholeV.number(), wholeV.finite())), wholeV.length(16)), pose);
|
|
1760
|
+
const { geometry: input, channels } = admitNativeWholeGeometry(node, ownership, true);
|
|
1761
|
+
try {
|
|
1762
|
+
const signature = JSON.stringify(channels);
|
|
1763
|
+
if (row.grid !== undefined) {
|
|
1764
|
+
const position = input.getAttribute('position');
|
|
1765
|
+
const source = position instanceof InterleavedBufferAttribute ? position.data.array : position.array;
|
|
1766
|
+
if (!(source instanceof Int16Array) || position.normalized || position.itemSize !== 3) throw new Error('Whole grid needs Int16 positions');
|
|
1767
|
+
}
|
|
1768
|
+
let group = this.groups.get(row.id);
|
|
1769
|
+
const denseVertexLength = row.denseVertices ? row.vertexLength : 0;
|
|
1770
|
+
const completeFreshVertices = group === undefined && row.denseVertices && denseVertexLength === row.vertexCount;
|
|
1771
|
+
if (group === undefined) {
|
|
1772
|
+
const output = new BufferGeometry();
|
|
1773
|
+
for (const [name, channel] of Object.entries(channels)) output.setAttribute(name, wholeStorage(row.grid !== undefined && name === 'position' ? { ...channel, storage: 'Float32Array', normalized: false } : channel, row.vertexCount));
|
|
1774
|
+
if (row.index !== 'none') output.setIndex(new BufferAttribute(row.index === 'u16' ? new Uint16Array(row.indexCount) : new Uint32Array(row.indexCount), 1));
|
|
1775
|
+
group = { output, matrix: new Matrix4().fromArray(values), seen: new Uint8Array(row.vertexCount), triangles: new Uint8Array((row.index === 'none' ? row.vertexCount : row.indexCount) / 3), layout: signature };
|
|
1776
|
+
this.groups.set(row.id, group);
|
|
1777
|
+
}
|
|
1778
|
+
if (signature !== group.layout || !group.matrix.equals(new Matrix4().fromArray(values)) || row.vertexCount !== group.seen.length || row.indexCount !== (group.output.index?.count ?? 0)) throw new Error('Whole source layout or transform differs');
|
|
1779
|
+
// The channels are resolved once per node and copied in plain index loops: the per-vertex entries / getAttribute /
|
|
1780
|
+
// subarray walk was one ~600 ms desktop (~1.5 s iOS Simulator) task for a Nine Dragon tile when a grid cell builds it
|
|
1781
|
+
// on the road (sp-o112). The bytes written, the shared-vertex check and every refusal are unchanged.
|
|
1782
|
+
const vertices = row.denseVertices ? undefined : row.vertices;
|
|
1783
|
+
const copies = (vertices?.length ?? denseVertexLength) === 0 ? [] : Object.entries(group.output.attributes).map(([name, destination]) => {
|
|
1784
|
+
const source = input.getAttribute(name);
|
|
1785
|
+
if (!(source instanceof BufferAttribute || source instanceof InterleavedBufferAttribute) || !(destination instanceof BufferAttribute)) throw new Error('Whole channel layout differs');
|
|
1786
|
+
return { from: source instanceof InterleavedBufferAttribute ? source.data.array : source.array, fromSize: source.itemSize,
|
|
1787
|
+
stride: source instanceof InterleavedBufferAttribute ? source.data.stride : source.itemSize, offset: source instanceof InterleavedBufferAttribute ? source.offset : 0,
|
|
1788
|
+
count: source.count, to: destination.array, toSize: destination.itemSize, grid: name === 'position' ? row.grid : undefined };
|
|
1789
|
+
});
|
|
1790
|
+
const seen = group.seen;
|
|
1791
|
+
// Which listed vertices an earlier node (or an earlier entry of this list) already wrote, then one channel at a
|
|
1792
|
+
// time: the per-vertex channel walk was ~0.4 s of a phone-4x Nine preparation. Writes and refusals are unchanged.
|
|
1793
|
+
const shared = new Uint8Array(completeFreshVertices ? 0 : (vertices?.length ?? denseVertexLength));
|
|
1794
|
+
if (completeFreshVertices) seen.fill(1);
|
|
1795
|
+
else for (let local = 0; local < (vertices?.length ?? denseVertexLength); local++) {
|
|
1796
|
+
const vertex = vertices === undefined ? local : vertices[local] ?? Number.NaN;
|
|
1797
|
+
if (!(vertex < seen.length)) throw new Error('Whole vertex ordinal outside source');
|
|
1798
|
+
shared[local] = seen[vertex] ?? 0; seen[vertex] = 1;
|
|
1799
|
+
}
|
|
1800
|
+
for (const { from, fromSize, stride, offset, count, to, toSize, grid } of copies) {
|
|
1801
|
+
if ((vertices?.length ?? denseVertexLength) > count) throw new Error('Whole channel layout differs');
|
|
1802
|
+
if (grid !== undefined) {
|
|
1803
|
+
// Restore directly into the final ordinal array. The original
|
|
1804
|
+
// temporary Float32 attribute rounded before shared-byte comparison;
|
|
1805
|
+
// keep that exact boundary without allocating/copying it first.
|
|
1806
|
+
const [originX, originY, originZ] = grid.origin, step = grid.step;
|
|
1807
|
+
if (completeFreshVertices) {
|
|
1808
|
+
for (let read = offset, write = 0; write < to.length; read += stride, write += 3) {
|
|
1809
|
+
to[write] = Math.fround((from[read] ?? 0) * step + originX);
|
|
1810
|
+
to[write + 1] = Math.fround((from[read + 1] ?? 0) * step + originY);
|
|
1811
|
+
to[write + 2] = Math.fround((from[read + 2] ?? 0) * step + originZ);
|
|
1812
|
+
}
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
for (let local = 0; local < (vertices?.length ?? denseVertexLength); local++) {
|
|
1816
|
+
const read = offset + local * stride, write = (vertices === undefined ? local : vertices[local] ?? 0) * toSize;
|
|
1817
|
+
if (write + fromSize > to.length) throw new RangeError('Whole channel write outside source');
|
|
1818
|
+
const x = Math.fround((from[read] ?? 0) * step + originX);
|
|
1819
|
+
const y = Math.fround((from[read + 1] ?? 0) * step + originY);
|
|
1820
|
+
const z = Math.fround((from[read + 2] ?? 0) * step + originZ);
|
|
1821
|
+
if (shared[local] === 1 && (!Object.is(x, to[write]) || !Object.is(y, to[write + 1]) || !Object.is(z, to[write + 2]))) throw new Error('Whole shared vertex differs');
|
|
1822
|
+
to[write] = x; to[write + 1] = y; to[write + 2] = z;
|
|
1823
|
+
}
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
// Ordinals arrive as start/length runs: a run of new vertices in the same element type is one block copy.
|
|
1827
|
+
const block = fromSize === toSize && stride === fromSize && offset === 0 && from.constructor === to.constructor;
|
|
1828
|
+
if (completeFreshVertices && fromSize === toSize) {
|
|
1829
|
+
if (block && (vertices?.length ?? denseVertexLength) * fromSize <= from.length) to.set(from.subarray(0, (vertices?.length ?? denseVertexLength) * fromSize));
|
|
1830
|
+
else for (let read = offset, write = 0; write < to.length; read += stride, write += toSize) {
|
|
1831
|
+
to[write] = from[read] ?? 0;
|
|
1832
|
+
if (fromSize > 1) to[write + 1] = from[read + 1] ?? 0;
|
|
1833
|
+
if (fromSize > 2) to[write + 2] = from[read + 2] ?? 0;
|
|
1834
|
+
if (fromSize > 3) to[write + 3] = from[read + 3] ?? 0;
|
|
1835
|
+
}
|
|
1836
|
+
continue;
|
|
1837
|
+
}
|
|
1838
|
+
for (let local = 0; local < (vertices?.length ?? denseVertexLength); local++) {
|
|
1839
|
+
const start = vertices === undefined ? local : vertices[local] ?? 0;
|
|
1840
|
+
if (block && shared[local] === 0) {
|
|
1841
|
+
let end = local + 1;
|
|
1842
|
+
while (end < (vertices?.length ?? denseVertexLength) && shared[end] === 0 && (vertices === undefined ? end : vertices[end]) === start + end - local) end++;
|
|
1843
|
+
if (end - local > 1 && end * fromSize <= from.length) {
|
|
1844
|
+
if ((start + end - local) * toSize > to.length) throw new RangeError('Whole channel write outside source');
|
|
1845
|
+
to.set(from.subarray(local * fromSize, end * fromSize), start * toSize);
|
|
1846
|
+
local = end - 1; continue;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
const read = offset + local * stride, write = start * toSize;
|
|
1850
|
+
if (write + fromSize > to.length) throw new RangeError('Whole channel write outside source');
|
|
1851
|
+
if (shared[local] === 1) for (let i = 0; i < fromSize; i++) if (!Object.is(from[read + i], to[write + i])) throw new Error('Whole shared vertex differs');
|
|
1852
|
+
if (fromSize >= 1 && fromSize <= 4 && Number.isInteger(fromSize)) {
|
|
1853
|
+
to[write] = from[read] ?? 0;
|
|
1854
|
+
if (fromSize > 1) to[write + 1] = from[read + 1] ?? 0;
|
|
1855
|
+
if (fromSize > 2) to[write + 2] = from[read + 2] ?? 0;
|
|
1856
|
+
if (fromSize > 3) to[write + 3] = from[read + 3] ?? 0;
|
|
1857
|
+
} else for (let i = 0; i < fromSize; i++) to[write + i] = from[read + i] ?? 0;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
const index = input.getIndex()?.array ?? null, output = group.output.index?.array ?? null, done = group.triangles;
|
|
1861
|
+
const triangles = row.denseTriangles ? undefined : row.triangles, triangleLength = row.denseTriangles ? row.triangleLength : 0;
|
|
1862
|
+
const integerIndex = wholeUnsignedIndex(index);
|
|
1863
|
+
for (let local = 0; local < (triangles?.length ?? triangleLength); local++) {
|
|
1864
|
+
const triangle = triangles === undefined ? local : triangles[local] ?? Number.NaN;
|
|
1865
|
+
if (!(triangle < done.length) || done[triangle] === 1) throw new Error('Whole duplicate or invalid triangle');
|
|
1866
|
+
for (let corner = 0; corner < 3; corner++) {
|
|
1867
|
+
const at = index === null ? local * 3 + corner : index[local * 3 + corner] ?? local * 3 + corner;
|
|
1868
|
+
let vertex: number | undefined;
|
|
1869
|
+
if (vertices !== undefined) vertex = vertices[at];
|
|
1870
|
+
else if (integerIndex ? at < denseVertexLength : Number.isInteger(at) && at >= 0 && at < denseVertexLength) vertex = at;
|
|
1871
|
+
if (vertex === undefined) throw new Error('Whole missing triangle vertex');
|
|
1872
|
+
if (output !== null) output[triangle * 3 + corner] = vertex;
|
|
1873
|
+
else if (vertex !== triangle * 3 + corner) throw new Error('Whole non-indexed topology differs');
|
|
1874
|
+
}
|
|
1875
|
+
done[triangle] = 1;
|
|
1876
|
+
}
|
|
1877
|
+
} finally { input.dispose(); }
|
|
1878
|
+
}
|
|
1879
|
+
*finishSteps(): Generator<void, Map<string, WholeGeometryView>> {
|
|
1880
|
+
const result = new Map<string, WholeGeometryView>();
|
|
1881
|
+
for (const [id, group] of this.groups) {
|
|
1882
|
+
for (const flags of [group.seen, group.triangles]) {
|
|
1883
|
+
for (let i = 0; i < flags.length; i++) {
|
|
1884
|
+
if (flags[i] === 0) throw new Error(`Whole source ${id} is incomplete`);
|
|
1885
|
+
if ((i & 32767) === 32767) yield;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
yield* geometryBoundsSteps(group.output, 'sphere');
|
|
1889
|
+
result.set(id, { geometry: group.output, matrix: group.matrix });
|
|
1890
|
+
yield;
|
|
1891
|
+
}
|
|
1892
|
+
return result;
|
|
1893
|
+
}
|
|
1894
|
+
finish(): Map<string, WholeGeometryView> {
|
|
1895
|
+
const steps = this.finishSteps();
|
|
1896
|
+
for (;;) { const step = steps.next(); if (step.done) return step.value; }
|
|
1897
|
+
}
|
|
1898
|
+
dispose(): void { for (const group of this.groups.values()) group.output.dispose(); }
|
|
1899
|
+
}
|
|
1900
|
+
/** Reconstruct source draws from parsed subsets; duplicate/missing triangles and conflicting shared bytes refuse. */
|
|
1901
|
+
export function assembleWholeGeometryViews(nodes: readonly Mesh[], ownership: 'borrow' | 'take' = 'borrow'): Map<string, WholeGeometryView> {
|
|
1902
|
+
const assembler = new WholeGeometryAssembler();
|
|
1903
|
+
try { for (const node of nodes) assembler.add(node, ownership); return assembler.finish(); }
|
|
1904
|
+
catch (error) { assembler.dispose(); throw error; }
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Read verified tile/library GLBs and assemble original draws; temporary decodes are freed after each bounded file.
|
|
1908
|
+
* Completeness checks and exact bounds scan in bounded steps on the shared frame budget.
|
|
1909
|
+
* `pause` (optional) runs after each assembled mesh and finalization step; otherwise the engine's work slice yields.
|
|
1910
|
+
* A slug reads its admitted/declared product's L0 tiles and whole library by default; unknown slugs refuse.
|
|
1911
|
+
* Source-object callers default to L0 tiles only. Explicit refs are unchanged; L1 proxies cannot rebuild exact originals.
|
|
1912
|
+
*/
|
|
1913
|
+
export async function readWholeGeometry(scope: ResourceScope, source: Shardfile | string, refs?: readonly string[], pause?: () => Promise<void>): Promise<Map<string, WholeGeometryView>> {
|
|
1914
|
+
const { runtimeProduct, slugRuntimeProduct } = await import('../shardfile/runtimeProduct');
|
|
1915
|
+
const product = typeof source === 'string' ? slugRuntimeProduct(source) : runtimeProduct(source);
|
|
1916
|
+
if (product === null) throw new Error('Whole geometry needs an admitted or declared product');
|
|
1917
|
+
const timing = clientPreparationBatch(product.source.identity.slug, 'whole', WHOLE_TIMING_PHASES);
|
|
1918
|
+
const props = typeof source === 'string' ? product.source.props : source.props;
|
|
1919
|
+
const hashes = refs ?? wholeGeometryInputs(props, typeof source === 'string');
|
|
1920
|
+
const homeKey = `whole:${JSON.stringify([hashes, TIER])}`;
|
|
1921
|
+
const restored = await readHomeBuildGeometry(product.source, homeKey);
|
|
1922
|
+
if (restored !== null) {
|
|
1923
|
+
try {
|
|
1924
|
+
if (scope.disposed || scope.disposing) throw new Error('Whole geometry unloaded while restoring');
|
|
1925
|
+
await product.releaseTransport(hashes);
|
|
1926
|
+
if (scope.disposed || scope.disposing) throw new Error('Whole geometry unloaded while restoring');
|
|
1927
|
+
const result = new Map<string, WholeGeometryView>();
|
|
1928
|
+
for (const [id, view] of restored) result.set(id, { ...view, release: scope.capture('geometries', () => view.geometry.dispose()) });
|
|
1929
|
+
product.assets.releaseTiles(); return result;
|
|
1930
|
+
} catch (error) { for (const view of restored.values()) view.geometry.dispose(); throw error; }
|
|
1931
|
+
finally { timing?.finish(); }
|
|
1932
|
+
}
|
|
1933
|
+
const assembler = new WholeGeometryAssembler();
|
|
1934
|
+
const slice = workSlice(undefined, scope);
|
|
1935
|
+
const assertLive = (): void => { if (scope.disposed) throw new Error('Whole geometry unloaded while reading'); };
|
|
1936
|
+
const check = (): Promise<void> | undefined => {
|
|
1937
|
+
assertLive();
|
|
1938
|
+
let wait = pause;
|
|
1939
|
+
if (wait === undefined) {
|
|
1940
|
+
if (presenting() || typeof document !== 'undefined') {
|
|
1941
|
+
// Transport, parsing and drawn frames can outlive this local slice's
|
|
1942
|
+
// clock. A completion uses the current shared budget, not that wait.
|
|
1943
|
+
const checkpoint = constructionCheckpoint(scope);
|
|
1944
|
+
if (checkpoint !== undefined) wait = () => checkpoint;
|
|
1945
|
+
} else if (slice.due()) wait = slice.yield;
|
|
1946
|
+
}
|
|
1947
|
+
if (wait === undefined) { assertLive(); return undefined; }
|
|
1948
|
+
// Keep real pauses and their retirement race; cheap default completions
|
|
1949
|
+
// need neither a pending promise nor a microtask handoff.
|
|
1950
|
+
const suspend = async (): Promise<void> => {
|
|
1951
|
+
let release = (): void => undefined;
|
|
1952
|
+
const stopped = new Promise<void>(resolve => { release = scope.capture('disposers', resolve); });
|
|
1953
|
+
try { await Promise.race([wait(), stopped]); } finally { release(); }
|
|
1954
|
+
assertLive();
|
|
1955
|
+
};
|
|
1956
|
+
return suspend();
|
|
1957
|
+
};
|
|
1958
|
+
// Transport refills on completion, independently of ordered parsing and
|
|
1959
|
+
// assembly. A slow decoder no longer holds back later phase files.
|
|
1960
|
+
const reads = new PreparationReads(hashes, hash => product.assets.read(hash), () => !scope.disposed && !scope.disposing);
|
|
1961
|
+
try {
|
|
1962
|
+
for (const [index, hash] of hashes.entries()) {
|
|
1963
|
+
assertLive();
|
|
1964
|
+
const pending = reads.take(index);
|
|
1965
|
+
const bytes = timing === undefined ? await pending : await timing.run('read-wait', () => pending);
|
|
1966
|
+
const gltf = timing === undefined ? await (await prepareRigLoader()).createRigLoader().parseBytesAsync(bytes, '')
|
|
1967
|
+
: await timing.run('decode', async () => (await prepareRigLoader()).createRigLoader().parseBytesAsync(bytes, ''));
|
|
1968
|
+
const cleanup: (() => void)[] = [];
|
|
1969
|
+
try {
|
|
1970
|
+
const meshes: Mesh[] = [];
|
|
1971
|
+
gltf.scene.traverse(object => {
|
|
1972
|
+
if (!isWholeMesh(object)) return;
|
|
1973
|
+
const original: unknown = object.geometry;
|
|
1974
|
+
if (!(original instanceof BufferGeometry)) throw new Error('Whole shape needs geometry');
|
|
1975
|
+
cleanup.push(() => { original.dispose(); for (const material of Array.isArray(object.material) ? object.material : [object.material]) material.dispose(); });
|
|
1976
|
+
meshes.push(object);
|
|
1977
|
+
});
|
|
1978
|
+
for (const mesh of meshes) {
|
|
1979
|
+
// This reader owns the temporary GLB. Reuse its plain channels
|
|
1980
|
+
// until cleanup; the assembler still writes independent final arrays.
|
|
1981
|
+
if (timing === undefined) assembler.add(mesh, 'take');
|
|
1982
|
+
else timing.sync('assemble', () => { assembler.add(mesh, 'take'); });
|
|
1983
|
+
const checkpoint = timing === undefined ? check() : timing.checkpoint('yield', check);
|
|
1984
|
+
if (checkpoint !== undefined) await checkpoint;
|
|
1985
|
+
}
|
|
1986
|
+
if (scope.disposed) throw new Error('Whole geometry unloaded while reading');
|
|
1987
|
+
} finally { for (const dispose of cleanup) dispose(); }
|
|
1988
|
+
await (timing === undefined ? product.releaseTransport([hash]) : timing.run('release', () => product.releaseTransport([hash])));
|
|
1989
|
+
}
|
|
1990
|
+
const steps = assembler.finishSteps();
|
|
1991
|
+
let finished = timing === undefined ? steps.next() : timing.sync('finalize', () => steps.next());
|
|
1992
|
+
while (!finished.done) {
|
|
1993
|
+
const checkpoint = timing === undefined ? check() : timing.checkpoint('yield', check);
|
|
1994
|
+
if (checkpoint !== undefined) await checkpoint;
|
|
1995
|
+
finished = timing === undefined ? steps.next() : timing.sync('finalize', () => steps.next());
|
|
1996
|
+
}
|
|
1997
|
+
const result = finished.value;
|
|
1998
|
+
void saveHomeBuildGeometry(product.source, homeKey, result);
|
|
1999
|
+
for (const [id, view] of result) {
|
|
2000
|
+
const release = scope.capture('geometries', () => view.geometry.dispose());
|
|
2001
|
+
result.set(id, { ...view, release });
|
|
2002
|
+
}
|
|
2003
|
+
product.assets.releaseTiles(); return result;
|
|
2004
|
+
} catch (error) { assembler.dispose(); throw error; }
|
|
2005
|
+
finally { await reads.close(); timing?.finish(); }
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
/** Authored skinned assets and their ordered look declarations. */
|
|
2009
|
+
export interface RigLibraryRows { readonly bodies: CreatureBodyRows<string>; readonly looks: readonly CreatureLookRow<string>[] }
|
|
2010
|
+
const rigLibraries = new WeakMap<RigLibraryRows, { bodies: CreatureBodies<string>; looks: readonly SpeciesLook[] }>();
|
|
2011
|
+
const declaredRigLibraries = new Map<string, { bodies: CreatureBodies<string>; looks: readonly SpeciesLook[] }>();
|
|
2012
|
+
/** Resolve one loader per actual descriptor across model, page and Explorer consumers. */
|
|
2013
|
+
export function rigLibrary(rows: RigLibraryRows): { bodies: CreatureBodies<string>; looks: readonly SpeciesLook[] } {
|
|
2014
|
+
// Named source JSON and native rows may deserialize the same descriptor twice.
|
|
2015
|
+
// Equal data must retain one actual body cache for live looks and specimens.
|
|
2016
|
+
const identity = isJsonData(rows) ? JSON.stringify(rows, (_key, jsonValue: unknown): unknown => jsonValue !== null && typeof jsonValue === 'object' && !Array.isArray(jsonValue)
|
|
2017
|
+
? Object.fromEntries(Object.entries(jsonValue as Readonly<Record<string, unknown>>).sort(([a], [b]) => a.localeCompare(b))) : jsonValue) : undefined;
|
|
2018
|
+
const prior = rigLibraries.get(rows) ?? (identity === undefined ? undefined : declaredRigLibraries.get(identity));
|
|
2019
|
+
if (prior !== undefined) { rigLibraries.set(rows, prior); return prior; }
|
|
2020
|
+
if (rows.bodies.creatures.length > 1024 || new Set(rows.bodies.creatures).size !== rows.bodies.creatures.length
|
|
2021
|
+
|| rows.looks.some(row => !rows.bodies.creatures.includes(row.body))) throw new Error('Rig library references an undeclared body');
|
|
2022
|
+
const bodies = creatureBodies(rows.bodies), catalogue = { bodies, looks: creatureLooks(bodies, rows.looks) };
|
|
2023
|
+
rigLibraries.set(rows, catalogue); if (identity !== undefined) declaredRigLibraries.set(identity, catalogue); return catalogue;
|
|
2024
|
+
}
|
|
2025
|
+
/** A model specimen is metadata and an existing library rig, with no private builder. */
|
|
2026
|
+
export interface ModelSpecimenRow { readonly model: BakedModelMetadata; readonly body: string; readonly specimen: CreatureSpecimenRow }
|
|
2027
|
+
/** Resolve the ordered native rig catalogue without private scene owners. */
|
|
2028
|
+
export function modelCatalogue(rows: readonly ModelSpecimenRow[], library: Pick<ModelLibrary<string, string>, 'rig'>): ReturnType<typeof defineSceneModels> {
|
|
2029
|
+
return defineSceneModels(rows.map((row, index) => ({ model: row.model, builder: `body${String(index)}` })),
|
|
2030
|
+
rows.map((row, index) => [`body${String(index)}`, () => creatureSpecimen(library.rig(row.body), row.specimen)] as const));
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/** One authored index range in a shared posed draw; instances still own all clocks. */
|
|
2034
|
+
export interface PosedAssetRange { readonly kind: number; readonly start: number; readonly count: number; readonly box: readonly [number, number, number, number, number, number] }
|
|
2035
|
+
export interface PosedAssetSet { readonly geometry: BufferGeometry; readonly ranges: readonly PosedAssetRange[]; readonly atlas: Texture | null }
|
|
2036
|
+
/**
|
|
2037
|
+
* A posed draw's atlas as its own KTX2 file (a built product's named blob), sampled as the glTF atlas it replaces:
|
|
2038
|
+
* flipY false, repeat wrap, mipmapped linear, anisotropy 4, sRGB; fenced before the set publishes it.
|
|
2039
|
+
*/
|
|
2040
|
+
async function posedAtlas(url: string): Promise<Texture> {
|
|
2041
|
+
const atlas = await ktx2File(url);
|
|
2042
|
+
atlas.wrapS = RepeatWrapping; atlas.wrapT = RepeatWrapping; atlas.anisotropy = 4; atlas.colorSpace = SRGBColorSpace;
|
|
2043
|
+
atlas.name = 'posed-atlas'; atlas.needsUpdate = true;
|
|
2044
|
+
return prepareCompressedTexture(atlas);
|
|
2045
|
+
}
|
|
2046
|
+
/**
|
|
2047
|
+
* Read packed channels and original image bytes without vertex packing or attribute copies. The atlas is either
|
|
2048
|
+
* `atlasModel` (a GLB whose material carries it, through the tier / GPU path) or `atlas` (its own KTX2 file: a product's
|
|
2049
|
+
* named blob); at most one of the two (a vertex-coloured draw has none).
|
|
2050
|
+
*/
|
|
2051
|
+
export async function posedAssets(input: unknown): Promise<PosedAssetSet> {
|
|
2052
|
+
const poseNumber = wholeV.pipe(wholeV.number(), wholeV.finite());
|
|
2053
|
+
const integer = wholeV.pipe(poseNumber, wholeV.integer(), wholeV.minValue(0), wholeV.maxValue(2_000_000));
|
|
2054
|
+
const text = wholeV.pipe(wholeV.string(), wholeV.minLength(1), wholeV.maxLength(256));
|
|
2055
|
+
const rows = wholeV.parse(wholeV.strictObject({geometry: text, atlasModel: wholeV.optional(text), atlas: wholeV.optional(text), name: text,
|
|
2056
|
+
channels: wholeV.pipe(wholeV.array(wholeV.strictObject({name: text, source: text, width: wholeV.picklist([1, 2, 3, 4])})), wholeV.minLength(1), wholeV.maxLength(16)),
|
|
2057
|
+
ranges: wholeV.pipe(wholeV.array(wholeV.strictObject({kind: integer, start: integer, count: integer,
|
|
2058
|
+
box: wholeV.tuple([poseNumber, poseNumber, poseNumber, poseNumber, poseNumber, poseNumber])})), wholeV.minLength(1), wholeV.maxLength(32))}), input);
|
|
2059
|
+
if (rows.atlasModel !== undefined && rows.atlas !== undefined) throw new Error('A posed draw names at most one atlas source');
|
|
2060
|
+
if (new Set(rows.channels.map(row => row.name)).size !== rows.channels.length || new Set(rows.ranges.map(row => row.kind)).size !== rows.ranges.length) throw new Error('Repeated posed channel or kind');
|
|
2061
|
+
const source = await loadRigFile(rows.geometry), node = source.scene.getObjectByName(rows.name);
|
|
2062
|
+
if (!(node instanceof Mesh) || node.type !== 'Mesh' || !node.matrix.equals(new Matrix4())) throw new Error('Missing identity-space posed draw');
|
|
2063
|
+
const original: unknown = node.geometry;
|
|
2064
|
+
if (!(original instanceof BufferGeometry)) throw new Error('Invalid posed geometry');
|
|
2065
|
+
const geometry = new BufferGeometry(), position: unknown = original.getAttribute('position'), index = original.getIndex();
|
|
2066
|
+
if (!(position instanceof BufferAttribute) || position.count < 1 || position.count > 400_000 || index === null || index.array.some(word => word >= position.count)) throw new Error('Invalid posed draw size');
|
|
2067
|
+
for (const row of rows.channels) {
|
|
2068
|
+
const channel: unknown = original.getAttribute(row.source);
|
|
2069
|
+
if (!(channel instanceof BufferAttribute) || !(channel.array instanceof Float32Array) || channel.normalized || channel.itemSize !== row.width
|
|
2070
|
+
|| channel.count !== position.count || channel.array.some(word => !Number.isFinite(word))) throw new Error(`Invalid posed channel ${row.name}`);
|
|
2071
|
+
geometry.setAttribute(row.name, channel);
|
|
2072
|
+
}
|
|
2073
|
+
geometry.setIndex(index);
|
|
2074
|
+
let end = 0;
|
|
2075
|
+
for (const range of rows.ranges) { if (range.start !== end || range.count === 0 || range.count % 3 !== 0) throw new Error('Invalid posed range'); end += range.count; }
|
|
2076
|
+
if (end !== index.count) throw new Error('Posed ranges do not cover the draw');
|
|
2077
|
+
if (rows.atlas !== undefined) return {geometry, ranges: rows.ranges, atlas: await posedAtlas(rows.atlas)};
|
|
2078
|
+
if (rows.atlasModel === undefined) return {geometry, ranges: rows.ranges, atlas: null};
|
|
2079
|
+
const atlasSource = await loadRigFile(rows.atlasModel), textures: Texture[] = [];
|
|
2080
|
+
atlasSource.scene.traverse(object => { if (isMesh(object) && !Array.isArray(object.material) && object.material instanceof MeshStandardMaterial && object.material.map !== null) textures.push(object.material.map); });
|
|
2081
|
+
const atlas = textures[0]; if (atlas === undefined) throw new Error('Missing posed asset atlas'); atlas.anisotropy = 4;
|
|
2082
|
+
return {geometry, ranges: rows.ranges, atlas};
|
|
2083
|
+
}
|