@threenative/core 0.3.3 → 0.3.5
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/capabilities.json +2019 -59
- package/dist/{assets-CYKk2WTu.d.ts → assets-CqvE429w.d.ts} +45 -3
- package/dist/{audio-7i3Xl0l3.d.ts → audio-DIJE5HTr.d.ts} +43 -3
- package/dist/{canvas-layer-C1SnMoJ-.d.ts → canvas-layer-C1-5CviZ.d.ts} +5 -1
- package/dist/{game-D_6r-k4Y.d.ts → game-Bj8G1wmD.d.ts} +242 -17
- package/dist/hot.d.ts +5 -5
- package/dist/index.d.ts +1131 -105
- package/dist/index.js +15201 -4782
- package/dist/model-lod-BDAUYgsS.d.ts +197 -0
- package/dist/playtest.d.ts +6 -4
- package/dist/playtest.js +84 -11
- package/dist/react-css.d.ts +62 -0
- package/dist/react-css.js +591 -0
- package/dist/react.d.ts +2 -2
- package/dist/{renderer-Cy4qeBOA.d.ts → renderer-9yEo9hPa.d.ts} +676 -21
- package/dist/terrain-jobs-worker.d.ts +2 -0
- package/dist/terrain-jobs-worker.js +130 -0
- package/dist/ui-layer.d.ts +5 -3
- package/dist/ui-layer.js +59 -8
- package/dist/world.d.ts +1596 -17
- package/dist/world.js +17035 -521
- package/gpl/fixtures/make_world_fixture.py +184 -0
- package/gpl/recipes/_common.py +11 -0
- package/gpl/recipes/decimate.py +11 -5
- package/gpl/recipes/export_world.py +699 -0
- package/mcp/blender-server.mjs +61 -4
- package/mcp/blender.mjs +3 -4
- package/mcp/engine-server.mjs +55 -21
- package/mcp/servers.mjs +4 -4
- package/package.json +15 -9
- package/patches/three@0.185.1-prd269-upgrade.patch +22418 -0
- package/patches/three@0.185.1.patch +8246 -389
- package/scripts/apply-three-patch.mjs +123 -41
- package/src/animation-blend.ts +264 -0
- package/src/animation-composition.ts +362 -0
- package/src/animation-layers.ts +260 -0
- package/src/animation-root-motion.ts +283 -0
- package/src/animation.ts +896 -0
- package/src/assets.ts +1303 -0
- package/src/atmosphere/index.ts +335 -0
- package/src/atmosphere/luts.ts +298 -0
- package/src/atmosphere/params.ts +323 -0
- package/src/audio.ts +912 -0
- package/src/billboard.ts +124 -0
- package/src/bone-lengths.ts +157 -0
- package/src/camera-shake.ts +116 -0
- package/src/canvas-layer.ts +47 -0
- package/src/clip-audit.ts +401 -0
- package/src/clustered-batch.ts +492 -0
- package/src/clustered-mesh.ts +638 -0
- package/src/compute-driven.ts +176 -0
- package/src/compute-timing.ts +318 -0
- package/src/config.ts +593 -0
- package/src/debug.ts +82 -0
- package/src/engine-render-hook.ts +25 -0
- package/src/entities.ts +79 -0
- package/src/entity-snapshot.ts +53 -0
- package/src/flight.ts +683 -0
- package/src/fluid-field.ts +748 -0
- package/src/fluid-particles.ts +1253 -0
- package/src/frame-budget.ts +1368 -0
- package/src/game.ts +2390 -0
- package/src/geometry-capture.ts +1098 -0
- package/src/gpu-class.ts +160 -0
- package/src/gpu-frame-observation.ts +424 -0
- package/src/gpu-readback.ts +143 -0
- package/src/gpu-scene-bvh.ts +464 -0
- package/src/grounding.ts +100 -0
- package/src/hot.ts +161 -0
- package/src/import-meta.d.ts +13 -0
- package/src/index.ts +1536 -0
- package/src/input.ts +690 -0
- package/src/instanced-batch-lod.ts +283 -0
- package/src/instanced-batch.ts +274 -0
- package/src/interpolation.ts +129 -0
- package/src/launch-diagnostics.ts +161 -0
- package/src/loop.ts +564 -0
- package/src/matrix-world.ts +245 -0
- package/src/merge-parts.ts +812 -0
- package/src/model-lod.ts +1315 -0
- package/src/net-protocol.ts +333 -0
- package/src/net-session.ts +477 -0
- package/src/net.ts +80 -0
- package/src/ocean/fft.ts +72 -0
- package/src/ocean/spectral.ts +728 -0
- package/src/particle-significance.ts +102 -0
- package/src/particles.ts +648 -0
- package/src/path-follow.ts +175 -0
- package/src/picking.ts +250 -0
- package/src/pipeline-census.ts +1566 -0
- package/src/platform.ts +210 -0
- package/src/playtest.ts +839 -0
- package/src/pointer-events.ts +411 -0
- package/src/pose-measure.ts +435 -0
- package/src/profiling/FrameCounters.ts +231 -0
- package/src/profiling/Spans.ts +548 -0
- package/src/profiling/opacity-convention.ts +21 -0
- package/src/profiling/render-list-validate.ts +175 -0
- package/src/profiling/render-trap-audit.ts +84 -0
- package/src/profiling/scene-warning.ts +190 -0
- package/src/profiling/span-probes.ts +191 -0
- package/src/profiling/unlit-foliage-warning.ts +149 -0
- package/src/projection-apply.ts +1529 -0
- package/src/projection-marker.ts +142 -0
- package/src/projection-plan.ts +1258 -0
- package/src/projection-skinned.ts +419 -0
- package/src/projection-stability.ts +409 -0
- package/src/projection-uniform.ts +328 -0
- package/src/random.ts +41 -0
- package/src/react-css.ts +604 -0
- package/src/react-glyphs.ts +114 -0
- package/src/react-host.ts +576 -0
- package/src/react-layout.ts +265 -0
- package/src/react.ts +60 -0
- package/src/render/alpha-antialiasing.ts +159 -0
- package/src/render/batched-velocity.ts +126 -0
- package/src/render/chain.ts +1021 -0
- package/src/render/daylight.ts +189 -0
- package/src/render/depth-pyramid.ts +596 -0
- package/src/render/foliage-alpha.ts +166 -0
- package/src/render/material-key.ts +60 -0
- package/src/render/mesh-pool.ts +144 -0
- package/src/render/probe-volume.ts +1668 -0
- package/src/render/resolution-subrect.ts +253 -0
- package/src/render/velocity.ts +442 -0
- package/src/render/virtual-shadow-pages.ts +827 -0
- package/src/render/virtual-shadow-partial.ts +174 -0
- package/src/render/virtual-shadow.ts +3330 -0
- package/src/render/world-impostor-surface.ts +722 -0
- package/src/render/world-impostor.ts +558 -0
- package/src/render-camera-cull.ts +441 -0
- package/src/render-pass-budget.ts +501 -0
- package/src/renderProjection.ts +758 -0
- package/src/renderer-config.ts +127 -0
- package/src/renderer.ts +1847 -0
- package/src/replay-protocol.ts +85 -0
- package/src/replay.ts +205 -0
- package/src/resolution-scaler.ts +819 -0
- package/src/rig-preparation.ts +271 -0
- package/src/ripple-field.ts +432 -0
- package/src/scale.ts +109 -0
- package/src/scene.ts +239 -0
- package/src/schedule.ts +155 -0
- package/src/skeletal-mesh.ts +61 -0
- package/src/skeleton.ts +100 -0
- package/src/snow-field.ts +744 -0
- package/src/softbody-topology.ts +269 -0
- package/src/softbody.ts +516 -0
- package/src/sprite-animator.ts +222 -0
- package/src/startup-readiness.ts +386 -0
- package/src/state.ts +66 -0
- package/src/static-transform.ts +274 -0
- package/src/storage-buffer.ts +253 -0
- package/src/streaming.ts +308 -0
- package/src/target-fps.ts +92 -0
- package/src/terrain-jobs-worker.ts +17 -0
- package/src/terrain-jobs.ts +353 -0
- package/src/textures.ts +39 -0
- package/src/tracers.ts +237 -0
- package/src/ui-bridge.ts +368 -0
- package/src/ui-hit-regions.ts +380 -0
- package/src/ui-layer.ts +83 -0
- package/src/ui-state.ts +220 -0
- package/src/version.ts +2 -0
- package/src/viewport.ts +253 -0
- package/src/warmup.ts +1357 -0
- package/src/water-surface.ts +384 -0
- package/src/wave-field.ts +524 -0
- package/src/world-capabilities.ts +131 -0
- package/src/world-cell-proxy.ts +392 -0
- package/src/world-cells.ts +10564 -0
- package/src/world-gpu-scene.ts +3354 -0
- package/src/world-heightmap.ts +82 -0
- package/src/world-package.ts +469 -0
- package/src/world-passes.ts +582 -0
- package/src/world-region.ts +17 -0
- package/src/world-terrain-splat.ts +564 -0
- package/src/world-tiles.ts +3826 -0
- package/src/world-topology.ts +370 -0
- package/src/world-validate.ts +48 -0
- package/src/world.ts +805 -0
- package/dist/gpu-readback-CMklJs6r.d.ts +0 -112
package/src/platform.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
export type PlatformRuntime = "web" | "native";
|
|
2
|
+
export type PlatformOS = "android" | "ios" | "linux" | "macos" | "windows" | "unknown";
|
|
3
|
+
export type PlatformFormFactor = "mobile" | "desktop" | "unknown";
|
|
4
|
+
|
|
5
|
+
export interface IPlatformInfo {
|
|
6
|
+
readonly runtime: PlatformRuntime;
|
|
7
|
+
readonly os: PlatformOS;
|
|
8
|
+
readonly formFactor: PlatformFormFactor;
|
|
9
|
+
readonly maxTouchPoints: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface IPlatformDetectionSource {
|
|
13
|
+
readonly document?: unknown;
|
|
14
|
+
readonly native?: unknown;
|
|
15
|
+
readonly navigator?: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface IUserAgentData {
|
|
19
|
+
readonly mobile?: unknown;
|
|
20
|
+
readonly platform?: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DESKTOP_OS = new Set<PlatformOS>(["linux", "macos", "windows"]);
|
|
24
|
+
const MOBILE_OS = new Set<PlatformOS>(["android", "ios"]);
|
|
25
|
+
|
|
26
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
27
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function freezePlatform(value: IPlatformInfo): Readonly<IPlatformInfo> {
|
|
31
|
+
return Object.freeze(value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function invalidNativePlatform(reason: string): never {
|
|
35
|
+
throw new Error(`TN_NATIVE_PLATFORM_INVALID: ${reason}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function nativePlatform(source: unknown): Readonly<IPlatformInfo> {
|
|
39
|
+
if (!isRecord(source)) invalidNativePlatform("the native marker is not an object");
|
|
40
|
+
const descriptor = source.platform;
|
|
41
|
+
if (!isRecord(descriptor)) invalidNativePlatform("platform descriptor is missing");
|
|
42
|
+
|
|
43
|
+
const runtime = descriptor.runtime;
|
|
44
|
+
const os = descriptor.os;
|
|
45
|
+
const formFactor = descriptor.formFactor;
|
|
46
|
+
const maxTouchPoints = descriptor.maxTouchPoints;
|
|
47
|
+
if (runtime !== "native") invalidNativePlatform("runtime must be native");
|
|
48
|
+
if (
|
|
49
|
+
os !== "android" &&
|
|
50
|
+
os !== "ios" &&
|
|
51
|
+
os !== "linux" &&
|
|
52
|
+
os !== "macos" &&
|
|
53
|
+
os !== "windows" &&
|
|
54
|
+
os !== "unknown"
|
|
55
|
+
) {
|
|
56
|
+
invalidNativePlatform("os is unknown");
|
|
57
|
+
}
|
|
58
|
+
if (formFactor !== "mobile" && formFactor !== "desktop" && formFactor !== "unknown") {
|
|
59
|
+
invalidNativePlatform("formFactor is unknown");
|
|
60
|
+
}
|
|
61
|
+
if (!Number.isInteger(maxTouchPoints) || (maxTouchPoints as number) < 0) {
|
|
62
|
+
invalidNativePlatform("maxTouchPoints must be a non-negative integer");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const expectedFormFactor = MOBILE_OS.has(os as PlatformOS)
|
|
66
|
+
? "mobile"
|
|
67
|
+
: DESKTOP_OS.has(os as PlatformOS)
|
|
68
|
+
? "desktop"
|
|
69
|
+
: "unknown";
|
|
70
|
+
if (formFactor !== expectedFormFactor) {
|
|
71
|
+
invalidNativePlatform("os and formFactor disagree");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return freezePlatform({
|
|
75
|
+
formFactor,
|
|
76
|
+
maxTouchPoints,
|
|
77
|
+
os,
|
|
78
|
+
runtime,
|
|
79
|
+
} as IPlatformInfo);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function text(value: unknown): string | undefined {
|
|
83
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function parseOS(value: string | undefined): PlatformOS | undefined {
|
|
87
|
+
if (value === undefined) return undefined;
|
|
88
|
+
const normalized = value.toLowerCase();
|
|
89
|
+
if (normalized.includes("android")) return "android";
|
|
90
|
+
if (/(iphone|ipad|ipod|ios)/u.test(normalized)) return "ios";
|
|
91
|
+
if (/(windows|win32|win64|winnt|wince)/u.test(normalized)) return "windows";
|
|
92
|
+
if (/(macintosh|mac os|macos|macintel|macppc|mac68k)/u.test(normalized)) return "macos";
|
|
93
|
+
if (/(linux|x11)/u.test(normalized)) return "linux";
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function compatibleBrowserOS(left: PlatformOS, right: PlatformOS, iosUserAgent: boolean): boolean {
|
|
98
|
+
if (left === right) return true;
|
|
99
|
+
if ((left === "android" && right === "linux") || (left === "linux" && right === "android"))
|
|
100
|
+
return true;
|
|
101
|
+
if (
|
|
102
|
+
iosUserAgent &&
|
|
103
|
+
((left === "ios" && right === "macos") || (left === "macos" && right === "ios"))
|
|
104
|
+
)
|
|
105
|
+
return true;
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function resolveBrowserOS(
|
|
110
|
+
userAgentDataOS: PlatformOS | undefined,
|
|
111
|
+
navigatorOS: PlatformOS | undefined,
|
|
112
|
+
userAgentOS: PlatformOS | undefined,
|
|
113
|
+
iosUserAgent: boolean,
|
|
114
|
+
): PlatformOS {
|
|
115
|
+
let resolved: PlatformOS | undefined;
|
|
116
|
+
for (const candidate of [userAgentDataOS, navigatorOS, userAgentOS]) {
|
|
117
|
+
if (candidate === undefined) continue;
|
|
118
|
+
if (resolved === undefined) {
|
|
119
|
+
resolved = candidate;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (!compatibleBrowserOS(resolved, candidate, iosUserAgent)) return "unknown";
|
|
123
|
+
if (
|
|
124
|
+
(resolved === "linux" && candidate === "android") ||
|
|
125
|
+
(resolved === "macos" && candidate === "ios")
|
|
126
|
+
) {
|
|
127
|
+
resolved = candidate;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return resolved ?? "unknown";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function readTouchPoints(value: unknown): number {
|
|
134
|
+
return Number.isInteger(value) && (value as number) >= 0 ? (value as number) : 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function browserPlatform(source: unknown): Readonly<IPlatformInfo> {
|
|
138
|
+
if (!isRecord(source)) {
|
|
139
|
+
return freezePlatform({
|
|
140
|
+
formFactor: "unknown",
|
|
141
|
+
maxTouchPoints: 0,
|
|
142
|
+
os: "unknown",
|
|
143
|
+
runtime: "web",
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const userAgentData = isRecord(source.userAgentData)
|
|
148
|
+
? (source.userAgentData as IUserAgentData)
|
|
149
|
+
: undefined;
|
|
150
|
+
const userAgentDataOS = parseOS(text(userAgentData?.platform));
|
|
151
|
+
const navigatorOS = parseOS(text(source.platform));
|
|
152
|
+
const userAgent = text(source.userAgent);
|
|
153
|
+
const userAgentOS = parseOS(userAgent);
|
|
154
|
+
const iosUserAgent = userAgentOS === "ios";
|
|
155
|
+
const os = resolveBrowserOS(userAgentDataOS, navigatorOS, userAgentOS, iosUserAgent);
|
|
156
|
+
|
|
157
|
+
let formFactor: PlatformFormFactor = "unknown";
|
|
158
|
+
if (typeof userAgentData?.mobile === "boolean") {
|
|
159
|
+
formFactor = userAgentData.mobile ? "mobile" : "desktop";
|
|
160
|
+
} else if (MOBILE_OS.has(os)) {
|
|
161
|
+
formFactor = "mobile";
|
|
162
|
+
} else if (DESKTOP_OS.has(os)) {
|
|
163
|
+
formFactor = "desktop";
|
|
164
|
+
}
|
|
165
|
+
if (os === "unknown") formFactor = "unknown";
|
|
166
|
+
|
|
167
|
+
return freezePlatform({
|
|
168
|
+
formFactor,
|
|
169
|
+
maxTouchPoints: readTouchPoints(source.maxTouchPoints),
|
|
170
|
+
os,
|
|
171
|
+
runtime: "web",
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function globalPlatformSource(): IPlatformDetectionSource {
|
|
176
|
+
const globals = globalThis as Record<string, unknown>;
|
|
177
|
+
return { native: globals.__THREENATIVE_NATIVE__, navigator: globals.navigator };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Internal source seam for unit tests; it is intentionally not a root package export. */
|
|
181
|
+
export function detectPlatform(
|
|
182
|
+
source: IPlatformDetectionSource = globalPlatformSource(),
|
|
183
|
+
): Readonly<IPlatformInfo> {
|
|
184
|
+
return source.native === undefined
|
|
185
|
+
? browserPlatform(source.navigator)
|
|
186
|
+
: nativePlatform(source.native);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
let platformSnapshot: Readonly<IPlatformInfo> | undefined;
|
|
190
|
+
|
|
191
|
+
export function getPlatform(): Readonly<IPlatformInfo> {
|
|
192
|
+
platformSnapshot ??= detectPlatform();
|
|
193
|
+
return platformSnapshot;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function isWeb(): boolean {
|
|
197
|
+
return getPlatform().runtime === "web";
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function isNative(): boolean {
|
|
201
|
+
return getPlatform().runtime === "native";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function isMobile(): boolean {
|
|
205
|
+
return getPlatform().formFactor === "mobile";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function isTouchscreenAvailable(): boolean {
|
|
209
|
+
return getPlatform().maxTouchPoints > 0;
|
|
210
|
+
}
|