@threenative/core 0.3.11 → 0.3.13
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 +1988 -204
- package/dist/{assets-YUbXa3-Y.d.ts → assets-CfMKnOsK.d.ts} +78 -1
- package/dist/camera-shake-CZKOfGn4.d.ts +46 -0
- package/dist/{canvas-layer-vCtanIeB.d.ts → canvas-layer-G7ttVy7y.d.ts} +1 -1
- package/dist/chunk-4SRAQFTU.js +133 -0
- package/dist/chunk-CFGTPFUH.js +231 -0
- package/dist/chunk-DIPIJICH.js +8916 -0
- package/dist/chunk-EEABDLUC.js +2237 -0
- package/dist/chunk-EFWZWLPY.js +1895 -0
- package/dist/chunk-GXY7B3JG.js +46 -0
- package/dist/chunk-GYUZJQ7U.js +280 -0
- package/dist/chunk-H4J6IAJE.js +504 -0
- package/dist/chunk-KIRUKTBQ.js +187 -0
- package/dist/chunk-QWJEMUUT.js +94 -0
- package/dist/chunk-SV4QVUTQ.js +31 -0
- package/dist/chunk-U4YHUKKL.js +615 -0
- package/dist/chunk-VP43GIWW.js +18 -0
- package/dist/chunk-XDTZ4QMO.js +160 -0
- package/dist/default-tone-mapping-GgKPTiBP.d.ts +4 -0
- package/dist/{game-DzMcitDO.d.ts → game-k8K3hZai.d.ts} +85 -9
- package/dist/hot.d.ts +5 -4
- package/dist/hot.js +5 -52
- package/dist/index.d.ts +633 -1351
- package/dist/index.js +12873 -23068
- package/dist/{model-lod-CTpZ6imz.d.ts → model-lod-DPTzeCcD.d.ts} +35 -3
- package/dist/playtest.d.ts +5 -4
- package/dist/playtest.js +25 -75
- package/dist/quality-BYqKGAwo.d.ts +868 -0
- package/dist/react-css.js +1 -215
- 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-rZm0hVqq.d.ts → renderer-BtOSseYf.d.ts} +42 -35
- package/dist/spells/index.d.ts +643 -0
- package/dist/spells/index.js +1558 -0
- package/dist/spells/ultra/index.d.ts +1600 -0
- package/dist/spells/ultra/index.js +6804 -0
- package/dist/terrain-jobs-worker.js +1 -123
- package/dist/two-sided-foliage-W523J3UM.js +1 -0
- package/dist/ui-layer.js +6 -384
- package/dist/worker.js +13 -43
- package/dist/world.d.ts +988 -268
- package/dist/world.js +17464 -18290
- package/mcp/animation-server.mjs +1 -1
- package/mcp/animation.mjs +2 -3
- package/mcp/engine-server.mjs +245 -52
- package/mcp/servers.mjs +10 -3
- package/mcp/terrain.mjs +8 -0
- package/package.json +19 -7
- package/patches/three@0.187.0-prd269-upgrade.patch +2102 -0
- package/patches/three@0.187.0.patch +2004 -407
- 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 +437 -125
- package/src/auto-batch.ts +190 -44
- package/src/card-lod.ts +152 -0
- package/src/compressed-texture-preparation.ts +1008 -0
- package/src/compute-driven.ts +1 -1
- package/src/config.ts +8 -0
- package/src/debug.ts +103 -22
- package/src/dev-global.ts +54 -0
- package/src/engine-hooks.ts +37 -0
- package/src/frame-budget.ts +50 -23
- package/src/game-boot-phase.ts +269 -0
- package/src/game-dev-tools.ts +86 -0
- package/src/game-frame-loop.ts +958 -0
- package/src/game-renderer-metrics.ts +77 -0
- package/src/game-startup.ts +1076 -0
- package/src/game-ui.ts +84 -0
- package/src/game-validate.ts +70 -0
- package/src/game.ts +198 -2264
- package/src/gamepad-mappings.ts +269 -0
- package/src/generated/console-markers.ts +13 -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/hot.ts +4 -7
- package/src/index.ts +141 -9
- package/src/input.ts +237 -25
- package/src/instanced-batch-lod.ts +3 -8
- package/src/interpolation.ts +171 -40
- package/src/launch-diagnostics.ts +22 -12
- package/src/look/ao-admission.ts +25 -0
- package/src/look/auto-exposure.ts +5 -16
- package/src/look/default-tone-mapping.ts +41 -5
- package/src/look/filmic-tone-mapping.ts +15 -13
- package/src/look/local-exposure.ts +2 -7
- package/src/look/look-diagnostics.ts +3 -3
- package/src/look/quad-pass.ts +21 -0
- package/src/look/quality.ts +14 -5
- package/src/look/unreal-bloom.ts +4 -13
- package/src/look/world-environment.ts +113 -103
- package/src/loop.ts +29 -0
- package/src/merge-parts.ts +20 -24
- package/src/model-lod.ts +139 -17
- package/src/particle-kinds.ts +515 -0
- package/src/particle-significance.ts +12 -0
- package/src/particles.ts +19 -10
- package/src/picking.ts +17 -3
- package/src/platform.ts +23 -4
- package/src/playtest.ts +27 -1
- 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-apply.ts +4 -1
- package/src/projection-marker.ts +2 -1
- package/src/projection-plan.ts +9 -6
- 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/mesh-pool.ts +4 -20
- 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/resolution-subrect.ts +2 -0
- package/src/render/rough-diffuse.ts +46 -12
- package/src/render/soft-shadow.ts +27 -12
- package/src/render/virtual-shadow-adaptive.ts +55 -0
- package/src/render/virtual-shadow-casters.ts +175 -0
- package/src/render/virtual-shadow-layers.ts +76 -0
- package/src/render/virtual-shadow-level.ts +224 -0
- package/src/render/virtual-shadow-markers.ts +193 -0
- package/src/render/virtual-shadow-options.ts +370 -0
- package/src/render/virtual-shadow-pages.ts +5 -0
- package/src/render/virtual-shadow-partial.ts +13 -0
- package/src/render/virtual-shadow.ts +231 -1008
- package/src/render/world-impostor-surface.ts +402 -40
- package/src/render/world-impostor.ts +5 -2
- package/src/render-camera-cull.ts +98 -3
- package/src/render-environment.ts +41 -0
- package/src/render-pass-budget.ts +34 -7
- package/src/renderProjection.ts +22 -0
- package/src/renderer-config.ts +36 -0
- package/src/renderer-facts.ts +37 -0
- package/src/renderer.ts +144 -65
- package/src/resolution-scaler.ts +3 -2
- package/src/scene-entry-inspectors.ts +61 -0
- package/src/snow-field.ts +2 -1
- package/src/spells/cast-pool.ts +361 -0
- package/src/spells/index.ts +177 -0
- package/src/spells/mechanisms.ts +295 -0
- package/src/spells/reaction-field.ts +415 -0
- package/src/spells/spell-lights.ts +139 -0
- package/src/spells/spell-world.ts +187 -0
- package/src/spells/spell.ts +397 -0
- package/src/spells/spells.ts +283 -0
- package/src/spells/ultra/engine/camera.ts +184 -0
- package/src/spells/ultra/engine/quality.ts +96 -0
- package/src/spells/ultra/index.ts +52 -0
- package/src/spells/ultra/main.ts +305 -0
- package/src/spells/ultra/scene/arenaMaterial.ts +325 -0
- package/src/spells/ultra/spells/cast.ts +233 -0
- package/src/spells/ultra/spells/fire.ts +1267 -0
- package/src/spells/ultra/vfx/FluidVolume.ts +816 -0
- package/src/spells/ultra/vfx/FluidVolume.tsl.ts +855 -0
- package/src/spells/ultra/vfx/FxTarget.ts +61 -0
- package/src/spells/ultra/vfx/GroundField.ts +1399 -0
- package/src/spells/ultra/vfx/Particles.ts +1475 -0
- package/src/spells/ultra/vfx/Ribbons.ts +645 -0
- package/src/spells/ultra/vfx/Shockwaves.ts +286 -0
- package/src/spells/ultra/vfx/Volumes.ts +489 -0
- package/src/spells/ultra/vfx/common.ts +1195 -0
- package/src/spells/ultra/vfx/noise.ts +441 -0
- package/src/startup-offscreen-bytes.ts +78 -0
- package/src/startup-readiness.ts +128 -34
- package/src/static-transform.ts +25 -19
- package/src/streamed-textures.ts +112 -0
- package/src/streaming.ts +68 -4
- package/src/texture-streaming.ts +331 -0
- package/src/version.ts +1 -1
- package/src/warmup.ts +56 -8
- package/src/water-surface.ts +9 -3
- package/src/worker.ts +12 -2
- package/src/world-bundle-safety.ts +446 -0
- package/src/world-cell-batches.ts +1178 -0
- package/src/world-cell-chunks.ts +1128 -0
- package/src/world-cell-data.ts +995 -0
- package/src/world-cell-impostors.ts +1461 -0
- package/src/world-cell-lod-bias.ts +151 -0
- package/src/world-cell-models.ts +1074 -0
- package/src/world-cell-options.ts +177 -0
- package/src/world-cell-placements.ts +798 -0
- package/src/world-cell-prewarm.ts +592 -0
- package/src/world-cell-readiness.ts +357 -0
- package/src/world-cell-records.ts +401 -0
- package/src/world-cell-render-bundles.ts +459 -0
- package/src/world-cell-render-gpu-dress.ts +710 -0
- package/src/world-cell-render-main-cull.ts +540 -0
- package/src/world-cell-render-shadow-claims.ts +198 -0
- package/src/world-cell-render-util.ts +259 -0
- package/src/world-cell-render.ts +1501 -0
- package/src/world-cell-residency.ts +754 -0
- package/src/world-cell-stale.ts +238 -0
- package/src/world-cells.ts +1335 -10418
- package/src/world-chunk-shadow.ts +308 -0
- package/src/world-collar.ts +315 -0
- package/src/world-gpu-flags.ts +131 -0
- package/src/world-gpu-readback.ts +881 -0
- package/src/world-gpu-reference.ts +524 -0
- package/src/world-gpu-scene.ts +256 -2286
- package/src/world-gpu-shadow.ts +203 -0
- package/src/world-gpu-types.ts +409 -0
- package/src/world-gpu-validation.ts +518 -0
- package/src/world-heightfield.ts +802 -0
- package/src/world-load-limiter.ts +111 -0
- package/src/world-model-sections.ts +80 -0
- package/src/world-noise.ts +241 -0
- package/src/world-package.ts +42 -0
- package/src/world-region.ts +1 -1
- package/src/world-river-ribbon.ts +282 -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 +361 -153
- package/src/world-tile-budget.ts +249 -0
- package/src/world-tile-geometry.ts +469 -0
- package/src/world-tile-lod.ts +408 -0
- package/src/world-tile-observation.ts +566 -0
- package/src/world-tile-stitch.ts +166 -0
- package/src/world-tiles.ts +247 -1755
- package/src/world-validate.ts +6 -14
- package/src/world-warm.ts +51 -0
- package/src/world-water-bodies.ts +359 -0
- package/src/world.ts +48 -741
package/src/game-ui.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { IBootState } from "./game-boot-phase.js";
|
|
2
|
+
import type { IGameUi } from "./game.js";
|
|
3
|
+
import {
|
|
4
|
+
type IUiBridge,
|
|
5
|
+
UI_READY_INTENT,
|
|
6
|
+
UI_STARTUP_MESSAGE,
|
|
7
|
+
connectUiBridge,
|
|
8
|
+
} from "./ui-bridge.js";
|
|
9
|
+
import { type IUiStatePublisher, onUiIntent, publishUiState } from "./ui-state.js";
|
|
10
|
+
|
|
11
|
+
/** The slice of the boot state the UI seam reads and writes. */
|
|
12
|
+
export type IGameUiState<TState extends Record<string, unknown>> = Pick<
|
|
13
|
+
IBootState<TState, unknown>,
|
|
14
|
+
"state" | "uiBridge" | "uiReady" | "uiRevealed"
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
/** The game's UI seam: one bridge, connected on first use, with the state published through it. */
|
|
18
|
+
export interface IGameUiSeam {
|
|
19
|
+
/** Connects the bridge once, however many callers ask. */
|
|
20
|
+
connect(): IUiBridge;
|
|
21
|
+
/** Closes the bridge and forgets that a UI was ready or the cover had lifted. */
|
|
22
|
+
disconnect(): void;
|
|
23
|
+
/** What `game.ui` returns; it connects early so a game can register intents before `start()`. */
|
|
24
|
+
facade(): IGameUi;
|
|
25
|
+
/** Tells a waiting page whether the loading cover is still up. */
|
|
26
|
+
postStartup(): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createGameUi<TState extends Record<string, unknown>>(
|
|
30
|
+
boot: IGameUiState<TState>,
|
|
31
|
+
): IGameUiSeam {
|
|
32
|
+
let publisher: IUiStatePublisher | undefined;
|
|
33
|
+
|
|
34
|
+
const postStartup = (): void => {
|
|
35
|
+
boot.uiBridge?.post({
|
|
36
|
+
type: UI_STARTUP_MESSAGE,
|
|
37
|
+
phase: boot.uiRevealed ? "ready" : "covered",
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const connect = (): IUiBridge => {
|
|
42
|
+
if (boot.uiBridge !== undefined) return boot.uiBridge;
|
|
43
|
+
const bridge = connectUiBridge({ end: "game" });
|
|
44
|
+
boot.uiBridge = bridge;
|
|
45
|
+
// The store already coalesces writes at flush. Deferring this again waits for the native
|
|
46
|
+
// host's next microtask pump, after that frame's WebView event pump has already passed.
|
|
47
|
+
// Ahead of the first state, which `publishUiState` sends at once when a UI is already waiting.
|
|
48
|
+
if (bridge.hasPeer()) postStartup();
|
|
49
|
+
publisher = publishUiState(bridge, boot.state, { schedule: (flush) => flush() });
|
|
50
|
+
onUiIntent(bridge, (intent) => {
|
|
51
|
+
if (intent !== UI_READY_INTENT) return;
|
|
52
|
+
boot.uiReady = true;
|
|
53
|
+
// Before the state: a UI that mounts after the reveal must learn the cover is gone, and one
|
|
54
|
+
// that mounts before it must learn to hide.
|
|
55
|
+
postStartup();
|
|
56
|
+
// Publish immediately: the UI has just rendered against nothing, and waiting for the store's
|
|
57
|
+
// next change would leave a HUD showing its initial values for up to a tick.
|
|
58
|
+
publisher?.publish();
|
|
59
|
+
});
|
|
60
|
+
return bridge;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const disconnect = (): void => {
|
|
64
|
+
boot.uiRevealed = false;
|
|
65
|
+
publisher?.stop();
|
|
66
|
+
publisher = undefined;
|
|
67
|
+
boot.uiReady = false;
|
|
68
|
+
boot.uiBridge?.close();
|
|
69
|
+
boot.uiBridge = undefined;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const facade = (): IGameUi => {
|
|
73
|
+
const bridge = connect();
|
|
74
|
+
return {
|
|
75
|
+
get connected() {
|
|
76
|
+
return bridge.hasPeer() && boot.uiReady;
|
|
77
|
+
},
|
|
78
|
+
onIntent: (listener) => onUiIntent(bridge, listener),
|
|
79
|
+
publish: () => publisher?.publish(),
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return { connect, disconnect, facade, postStartup };
|
|
84
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type Camera, OrthographicCamera, PerspectiveCamera } from "three";
|
|
2
|
+
import type { CameraConfig } from "./game.js";
|
|
3
|
+
|
|
4
|
+
function positiveCameraValue(name: string, value: number): number {
|
|
5
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
6
|
+
throw new Error(`camera.${name} must be finite and positive.`);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function assertJsonSafe(value: unknown, path = "$", seen = new WeakSet<object>()): void {
|
|
11
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return;
|
|
12
|
+
if (typeof value === "number") {
|
|
13
|
+
if (Number.isFinite(value)) return;
|
|
14
|
+
throw new TypeError(`${path} must contain only finite JSON numbers.`);
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === "object") {
|
|
17
|
+
if (seen.has(value)) throw new TypeError(`${path} must be JSON-safe and cannot be cyclic.`);
|
|
18
|
+
seen.add(value);
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
if (Object.getPrototypeOf(value) !== Array.prototype) {
|
|
21
|
+
throw new TypeError(`${path} must be a JSON-safe array.`);
|
|
22
|
+
}
|
|
23
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
24
|
+
assertJsonSafe(value[index], `${path}[${index}]`, seen);
|
|
25
|
+
}
|
|
26
|
+
seen.delete(value);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const prototype = Object.getPrototypeOf(value);
|
|
30
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
31
|
+
throw new TypeError(`${path} must be a JSON-safe plain object.`);
|
|
32
|
+
}
|
|
33
|
+
for (const [key, item] of Object.entries(value)) assertJsonSafe(item, `${path}.${key}`, seen);
|
|
34
|
+
seen.delete(value);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
throw new TypeError(`${path} must be JSON-safe.`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function assertCarry(value: unknown): asserts value is Record<string, unknown> {
|
|
41
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
42
|
+
throw new TypeError("goto carry must be a JSON object.");
|
|
43
|
+
}
|
|
44
|
+
assertJsonSafe(value, "$.carry");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function validateCameraConfig(config: CameraConfig | undefined): void {
|
|
48
|
+
if (config === undefined) return;
|
|
49
|
+
const near = positiveCameraValue("near", config.near ?? 0.1);
|
|
50
|
+
const far = positiveCameraValue("far", config.far ?? 2_000);
|
|
51
|
+
if (far <= near) throw new Error("camera.far must be greater than camera.near.");
|
|
52
|
+
if (config.projection === "perspective") {
|
|
53
|
+
const fov = config.fov ?? 60;
|
|
54
|
+
if (!Number.isFinite(fov) || fov <= 0 || fov >= 180)
|
|
55
|
+
throw new Error("camera.fov must be finite and between 0 and 180 degrees.");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
positiveCameraValue("size", config.size);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function createCamera(config: CameraConfig | undefined): Camera {
|
|
62
|
+
if (config === undefined) return new PerspectiveCamera(60, 1, 0.1, 2_000);
|
|
63
|
+
validateCameraConfig(config);
|
|
64
|
+
const near = config.near ?? 0.1;
|
|
65
|
+
const far = config.far ?? 2_000;
|
|
66
|
+
if (config.projection === "perspective")
|
|
67
|
+
return new PerspectiveCamera(config.fov ?? 60, 1, near, far);
|
|
68
|
+
const size = config.size;
|
|
69
|
+
return new OrthographicCamera(-size, size, size, -size, near, far);
|
|
70
|
+
}
|