@threenative/core 0.3.12 → 0.3.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/README.md +1 -1
- package/capabilities.json +1047 -44
- package/dist/{assets-YUbXa3-Y.d.ts → assets-CfMKnOsK.d.ts} +78 -1
- package/dist/{canvas-layer-CWuFRT7G.d.ts → canvas-layer-G7ttVy7y.d.ts} +1 -1
- package/dist/{chunk-7UUT3TY5.js → chunk-2GPHICV6.js} +1 -1
- package/dist/{chunk-GMHATRPW.js → chunk-GEMQJBY4.js} +1650 -383
- package/dist/{chunk-VAZM36TV.js → chunk-H4J6IAJE.js} +17 -10
- package/dist/{chunk-5O73CDMR.js → chunk-QAMSM3Z5.js} +415 -27
- package/dist/{chunk-2Z44XSI2.js → chunk-QAQHYOWY.js} +3 -7
- package/dist/{chunk-DBELTTTM.js → chunk-U4YHUKKL.js} +1 -1
- package/dist/{chunk-OKXUCASC.js → chunk-VBBYWGAT.js} +3 -4
- package/dist/chunk-VP43GIWW.js +18 -0
- package/dist/{chunk-N5LRP4BR.js → chunk-VQRPEOKY.js} +66 -3
- package/dist/{chunk-6KLNISRJ.js → chunk-XDTZ4QMO.js} +11 -4
- package/dist/default-tone-mapping-GgKPTiBP.d.ts +4 -0
- package/dist/{game-D7pAzZUY.d.ts → game-k8K3hZai.d.ts} +72 -8
- package/dist/hot.d.ts +5 -4
- package/dist/hot.js +5 -8
- package/dist/index.d.ts +871 -1018
- package/dist/index.js +4786 -1631
- package/dist/{model-lod-B6BMqS1r.d.ts → model-lod-DPTzeCcD.d.ts} +4 -2
- package/dist/playtest.d.ts +5 -4
- package/dist/playtest.js +6 -5
- package/dist/quality-BADStsTn.d.ts +868 -0
- package/dist/react.d.ts +3 -2
- package/dist/render-environment.d.ts +170 -0
- package/dist/render-environment.js +352 -0
- package/dist/{renderer-DvFVoAgj.d.ts → renderer-BtOSseYf.d.ts} +29 -31
- package/dist/spells/index.js +1 -1
- package/dist/ui-layer.js +3 -2
- package/dist/worker.js +12 -5
- package/dist/world.d.ts +280 -16
- package/dist/world.js +1529 -642
- package/mcp/animation-server.mjs +1 -1
- package/mcp/engine-server.mjs +135 -11
- package/mcp/servers.mjs +4 -4
- package/package.json +10 -6
- package/scripts/ensure-mcp.mjs +6 -1
- package/src/animation-batch.ts +193 -0
- package/src/animation-layers.ts +7 -3
- package/src/animation.ts +209 -29
- package/src/asset-cache.ts +3 -3
- package/src/asset-memo.ts +202 -0
- package/src/assets.ts +436 -131
- package/src/auto-batch.ts +190 -44
- package/src/clustered-batch.ts +146 -3
- package/src/clustered-mesh.ts +548 -20
- package/src/compute-driven.ts +1 -1
- package/src/config.ts +8 -0
- package/src/debug.ts +119 -22
- package/src/dev-global.ts +54 -0
- package/src/displaced-surface.ts +428 -0
- package/src/engine-hooks.ts +37 -0
- package/src/frame-budget.ts +35 -3
- package/src/game-boot-phase.ts +269 -0
- package/src/game-dev-tools.ts +7 -14
- package/src/game-frame-loop.ts +45 -82
- package/src/game-startup.ts +145 -70
- package/src/game-ui.ts +84 -0
- package/src/game.ts +168 -552
- package/src/gamepad-mappings.ts +269 -0
- package/src/generated/console-markers.ts +14 -0
- package/src/geometry-capture.ts +28 -4
- package/src/gpu-readings.ts +98 -0
- package/src/gpu-scene-bvh.ts +149 -36
- package/src/grass-field.ts +628 -0
- package/src/hot.ts +4 -7
- package/src/index.ts +227 -8
- package/src/input.ts +237 -25
- package/src/instanced-batch-lod.ts +3 -8
- package/src/interpolation.ts +171 -40
- package/src/look/ao-admission.ts +4 -3
- package/src/look/auto-exposure.ts +5 -16
- package/src/look/default-tone-mapping.ts +41 -5
- package/src/look/local-exposure.ts +2 -7
- package/src/look/quad-pass.ts +21 -0
- package/src/look/quality.ts +4 -0
- package/src/look/unreal-bloom.ts +4 -13
- package/src/look/world-environment.ts +58 -115
- package/src/merge-parts.ts +20 -24
- package/src/model-lod.ts +97 -14
- package/src/particle-significance.ts +12 -0
- package/src/particles.ts +19 -10
- package/src/platform.ts +23 -4
- package/src/profiling/FrameStages.ts +5 -6
- package/src/profiling/Spans.ts +3 -17
- package/src/profiling/debug-telemetry.ts +2 -6
- package/src/profiling/render-list-validate.ts +6 -15
- package/src/projection-marker.ts +2 -1
- package/src/quiet-markers.ts +3 -10
- package/src/render/cpu-bvh.ts +100 -0
- package/src/render/depth-pyramid.ts +6 -14
- package/src/render/environment/environmentContribution.ts +202 -0
- package/src/render/environment/environmentRadiance.ts +44 -0
- package/src/render/environment/environmentSampleCache.ts +56 -0
- package/src/render/environment/environmentSampling.ts +201 -0
- package/src/render/environment/environmentSnapshot.ts +71 -0
- package/src/render/environment/gate.ts +57 -0
- package/src/render/material-key.ts +21 -1
- package/src/render/mesh-pool.ts +3 -19
- package/src/render/probe-trace.ts +872 -0
- package/src/render/probe-volume.ts +780 -34
- package/src/render/radiance-cache.ts +17 -0
- package/src/render/screen-probe-gather.ts +303 -0
- package/src/render/short-range-ao.ts +274 -0
- package/src/render/virtual-shadow-partial.ts +13 -0
- package/src/render/virtual-shadow.ts +18 -16
- package/src/render/world-impostor-surface.ts +207 -9
- package/src/render/world-impostor.ts +5 -2
- package/src/render-camera-cull.ts +105 -4
- package/src/render-environment.ts +41 -0
- package/src/renderer-config.ts +36 -0
- package/src/renderer-facts.ts +37 -0
- package/src/renderer.ts +78 -32
- package/src/resolution-scaler.ts +3 -2
- package/src/scatter-field.ts +496 -0
- package/src/scene-entry-inspectors.ts +61 -0
- package/src/snow-field.ts +1 -0
- package/src/startup-offscreen-bytes.ts +84 -0
- package/src/state.ts +16 -3
- package/src/static-transform.ts +100 -25
- package/src/streamed-textures.ts +112 -0
- package/src/streaming.ts +68 -4
- package/src/texture-streaming.ts +331 -0
- package/src/tile-ring.ts +294 -0
- package/src/version.ts +1 -1
- package/src/warmup.ts +15 -2
- package/src/worker.ts +12 -2
- package/src/world-bundle-safety.ts +55 -10
- package/src/world-cell-batches.ts +166 -200
- package/src/world-cell-chunks.ts +3 -7
- package/src/world-cell-data.ts +7 -0
- package/src/world-cell-impostors.ts +20 -8
- package/src/world-cell-models.ts +36 -8
- package/src/world-cell-options.ts +2 -14
- package/src/world-cell-placements.ts +194 -90
- package/src/world-cell-prewarm.ts +39 -4
- package/src/world-cell-records.ts +401 -0
- package/src/world-cell-render-bundles.ts +2 -2
- package/src/world-cell-render-gpu-dress.ts +17 -19
- package/src/world-cell-render-main-cull.ts +73 -17
- package/src/world-cell-render-util.ts +18 -5
- package/src/world-cell-render.ts +13 -5
- package/src/world-cell-residency.ts +15 -6
- package/src/world-cell-stale.ts +238 -0
- package/src/world-cells.ts +23 -6
- package/src/world-gpu-flags.ts +18 -50
- package/src/world-gpu-reference.ts +22 -8
- package/src/world-gpu-scene.ts +44 -24
- package/src/world-gpu-shadow.ts +21 -8
- package/src/world-gpu-types.ts +41 -13
- package/src/world-load-limiter.ts +5 -0
- package/src/world-model-sections.ts +80 -0
- package/src/world-river-ribbon.ts +273 -0
- package/src/world-root-frame.ts +39 -0
- package/src/world-shore-field.ts +91 -0
- package/src/world-static-pose.ts +163 -0
- package/src/world-surface-sampler.ts +48 -0
- package/src/world-terrain-splat.ts +10 -18
- package/src/world-tile-budget.ts +4 -11
- package/src/world-tiles.ts +79 -12
- package/src/world-validate.ts +6 -14
- package/src/world-warm.ts +51 -0
- package/src/world-water-bodies.ts +113 -3
- package/src/world.ts +13 -0
package/src/worker.ts
CHANGED
|
@@ -711,6 +711,7 @@ export function startWorkerGame(
|
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
713
|
|
|
714
|
+
let started = false;
|
|
714
715
|
let resolveReady: () => void = () => undefined;
|
|
715
716
|
let rejectReady: (error: Error) => void = () => undefined;
|
|
716
717
|
const ready = new Promise<void>((resolve, reject) => {
|
|
@@ -789,6 +790,7 @@ export function startWorkerGame(
|
|
|
789
790
|
installMirror(message.name, message.epoch);
|
|
790
791
|
break;
|
|
791
792
|
case "tn-worker-started":
|
|
793
|
+
started = true;
|
|
792
794
|
resolveReady();
|
|
793
795
|
break;
|
|
794
796
|
case "tn-worker-failed":
|
|
@@ -833,8 +835,16 @@ export function startWorkerGame(
|
|
|
833
835
|
|
|
834
836
|
listen(worker, "message", onWorkerMessage);
|
|
835
837
|
const onWorkerError = (event: Event): void => {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
+
// A worker's ErrorEvent carries where it threw; without it the page sees only the message, and a
|
|
839
|
+
// stack-less "worker died" is unactionable (the 0.3.13 release proof lost a red this way).
|
|
840
|
+
const error = event as ErrorEvent;
|
|
841
|
+
const origin = [error.filename, error.lineno, error.colno].filter(Boolean).join(":");
|
|
842
|
+
const message = `${error.message || `worker ${event.type}`}${origin ? ` (${origin})` : ""}`;
|
|
843
|
+
// Once started, nothing awaits `ready`: without this line a frame that threw removed the canvas
|
|
844
|
+
// and printed nothing (PRD-857).
|
|
845
|
+
if (started && !stopped)
|
|
846
|
+
console.error(`TN_WORKER_FAILED: the running worker game stopped: ${message}`);
|
|
847
|
+
stop(new Error(message));
|
|
838
848
|
};
|
|
839
849
|
listen(worker, "error", onWorkerError);
|
|
840
850
|
listen(worker, "messageerror", onWorkerError);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Material, type Mesh, Object3D } from "three";
|
|
2
2
|
import { isEngineRenderHook } from "./engine-render-hook.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -69,9 +69,16 @@ const BUNDLE_PROOF_ROWS_PER_FRAME = 256;
|
|
|
69
69
|
*/
|
|
70
70
|
const BUNDLE_PROOF_MAX_PERIOD = 600;
|
|
71
71
|
|
|
72
|
+
/** The owned engine's witness of each proved material's surface flags (PRD-879). */
|
|
73
|
+
interface IMaterialWitnessHost {
|
|
74
|
+
__tnMaterialWatch?(materials: readonly Material[]): number;
|
|
75
|
+
__tnMaterialCheck?(): ArrayLike<number>;
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
/** Own-link and installed-Node child snapshots avoid inherited TSL method scans. Deep unversioned
|
|
73
79
|
* edits still invalidate: version/root identity alone cannot certify a mutable node graph. The
|
|
74
|
-
* shallow witness (version, transparency, visibility, transmission)
|
|
80
|
+
* shallow witness (version, transparency, visibility, transmission) holds on every check: read per
|
|
81
|
+
* check, or for a `deep: false` check the flags are the owned engine's one answer a frame. The deep
|
|
75
82
|
* rows are proved once per `staleFrames` period: the rows the last frame tested over a per-frame
|
|
76
83
|
* budget, so a small world proves every frame and a forest spreads its proofs evenly, each material
|
|
77
84
|
* in its own slot of the period. Three itself rebuilds a draw only when `material.version` moves
|
|
@@ -79,6 +86,16 @@ const BUNDLE_PROOF_MAX_PERIOD = 600;
|
|
|
79
86
|
* window. A graph past the witness caps uses the uncached safety walk. */
|
|
80
87
|
export class BundleSurfaceSafety {
|
|
81
88
|
#checks = new WeakMap<Material, IBundleMaterialCheck>();
|
|
89
|
+
/**
|
|
90
|
+
* The owned engine holds every cached verdict's `transparent`, `visible` and `transmission` and
|
|
91
|
+
* answers which moved in one call a frame, so a settled `deep: false` test reads none of them.
|
|
92
|
+
* Upstream three has no such host method and reads them per test, as before.
|
|
93
|
+
*
|
|
94
|
+
* ponytail: the list keeps every proved material until `clear`, which a world bounds by its assets.
|
|
95
|
+
*/
|
|
96
|
+
readonly #witness = new Object3D() as Object3D & IMaterialWitnessHost;
|
|
97
|
+
#witnessed: Material[] = [];
|
|
98
|
+
readonly #moved = new Set<Material>();
|
|
82
99
|
#revision = 0;
|
|
83
100
|
#frame = 0;
|
|
84
101
|
#frameRows = 0;
|
|
@@ -93,6 +110,9 @@ export class BundleSurfaceSafety {
|
|
|
93
110
|
|
|
94
111
|
clear(): void {
|
|
95
112
|
this.#checks = new WeakMap();
|
|
113
|
+
this.#witnessed = [];
|
|
114
|
+
this.#moved.clear();
|
|
115
|
+
this.#witness.__tnMaterialWatch?.(this.#witnessed);
|
|
96
116
|
}
|
|
97
117
|
|
|
98
118
|
/** Opens a frame: the period every deep proof is spread over follows the last frame's rows. */
|
|
@@ -103,6 +123,12 @@ export class BundleSurfaceSafety {
|
|
|
103
123
|
Math.max(1, Math.ceil(this.#frameRows / BUNDLE_PROOF_ROWS_PER_FRAME)),
|
|
104
124
|
);
|
|
105
125
|
this.#frameRows = 0;
|
|
126
|
+
// A moved material stays moved until its next test re-proves it, because that re-proof
|
|
127
|
+
// re-stamps the whole list and the engine would not answer for it again.
|
|
128
|
+
const moved = this.#witness.__tnMaterialCheck?.();
|
|
129
|
+
if (moved !== undefined)
|
|
130
|
+
for (let at = 0; at < moved.length; at++)
|
|
131
|
+
this.#moved.add(this.#witnessed[moved[at] as number] as Material);
|
|
106
132
|
}
|
|
107
133
|
|
|
108
134
|
/**
|
|
@@ -114,13 +140,7 @@ export class BundleSurfaceSafety {
|
|
|
114
140
|
test(material: Material, deep = true): IBundleMaterialCheck {
|
|
115
141
|
this.stats.checks++;
|
|
116
142
|
const previous = this.#checks.get(material);
|
|
117
|
-
if (
|
|
118
|
-
previous !== undefined &&
|
|
119
|
-
previous.version === material.version &&
|
|
120
|
-
previous.transparent === material.transparent &&
|
|
121
|
-
previous.visible === material.visible &&
|
|
122
|
-
previous.transmission === Reflect.get(material, "transmission")
|
|
123
|
-
) {
|
|
143
|
+
if (previous !== undefined && this.#shallowHolds(material, previous, deep)) {
|
|
124
144
|
if (!deep) return previous;
|
|
125
145
|
if (previous.testedFrame !== this.#frame) {
|
|
126
146
|
previous.testedFrame = this.#frame;
|
|
@@ -157,9 +177,34 @@ export class BundleSurfaceSafety {
|
|
|
157
177
|
if (capture.overflow) {
|
|
158
178
|
this.stats.uncached++;
|
|
159
179
|
this.#checks.delete(material);
|
|
160
|
-
} else
|
|
180
|
+
} else {
|
|
181
|
+
this.#checks.set(material, checked);
|
|
182
|
+
this.#rewatch(material);
|
|
183
|
+
}
|
|
161
184
|
return checked;
|
|
162
185
|
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Whether the material still holds the cached verdict's shallow witness. `version` is JS-side;
|
|
189
|
+
* the flags are the engine's answer when it witnesses them and a `deep: false` test asks.
|
|
190
|
+
*/
|
|
191
|
+
#shallowHolds(material: Material, previous: IBundleMaterialCheck, deep: boolean): boolean {
|
|
192
|
+
if (previous.version !== material.version) return false;
|
|
193
|
+
if (!deep && this.#witness.__tnMaterialCheck !== undefined) return !this.#moved.has(material);
|
|
194
|
+
return (
|
|
195
|
+
previous.transparent === material.transparent &&
|
|
196
|
+
previous.visible === material.visible &&
|
|
197
|
+
previous.transmission === Reflect.get(material, "transmission")
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Re-stamp the engine's witness after a verdict was (re)taken, so it answers from this state. */
|
|
202
|
+
#rewatch(material: Material): void {
|
|
203
|
+
if (this.#witness.__tnMaterialWatch === undefined) return;
|
|
204
|
+
if (!this.#witnessed.includes(material)) this.#witnessed.push(material);
|
|
205
|
+
this.#moved.delete(material);
|
|
206
|
+
this.#witness.__tnMaterialWatch(this.#witnessed);
|
|
207
|
+
}
|
|
163
208
|
}
|
|
164
209
|
|
|
165
210
|
function graphSnapshotCurrent(row: IBundleGraphSnapshot): boolean {
|