@threenative/core 0.3.4 → 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 +1505 -79
- package/dist/{audio-7i3Xl0l3.d.ts → audio-DIJE5HTr.d.ts} +43 -3
- package/dist/{canvas-layer-DDmC_VVF.d.ts → canvas-layer-C1-5CviZ.d.ts} +5 -1
- package/dist/{game-CljaDv4D.d.ts → game-Bj8G1wmD.d.ts} +102 -11
- package/dist/hot.d.ts +4 -4
- package/dist/index.d.ts +712 -118
- package/dist/index.js +12423 -4955
- package/dist/{gpu-readback-CqJEfWNQ.d.ts → model-lod-BDAUYgsS.d.ts} +80 -5
- package/dist/playtest.d.ts +6 -10
- package/dist/playtest.js +47 -24
- 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-CfsS2hxi.d.ts → renderer-9yEo9hPa.d.ts} +489 -22
- package/dist/terrain-jobs-worker.d.ts +2 -0
- package/dist/terrain-jobs-worker.js +130 -0
- package/dist/ui-layer.js +59 -8
- package/dist/world.d.ts +766 -73
- package/dist/world.js +9307 -3543
- package/gpl/recipes/export_world.py +18 -1
- package/mcp/blender-server.mjs +7 -4
- package/mcp/blender.mjs +3 -4
- package/mcp/engine-server.mjs +2 -2
- 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 +6594 -700
- package/scripts/apply-three-patch.mjs +62 -4
- 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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine-installed `onBeforeRender` / `onAfterRender` callbacks, and the one place that knows
|
|
3
|
+
* which of them are the engine's own.
|
|
4
|
+
*
|
|
5
|
+
* The scene-render projection declines a frame when an object carries a render hook, because three
|
|
6
|
+
* hands the callback the object it is about to draw and neither a batch nor a proxy can hand back
|
|
7
|
+
* the game's own object. That is right for a *game* hook and wrong for the engine's: `WorldCells`
|
|
8
|
+
* borrows `onBeforeRender` on each prewarmed batch to count its first submitted draw, so on a
|
|
9
|
+
* streamed world almost every batch is "hooked" and the projection never engages at all — the very
|
|
10
|
+
* collapse it exists for.
|
|
11
|
+
*
|
|
12
|
+
* A borrow marked here is bookkeeping about the draw, not a claim on the object, so the mirror is
|
|
13
|
+
* free to fold it. Anything unmarked is the game's and still blocks the frame.
|
|
14
|
+
*/
|
|
15
|
+
const engineRenderHooks = new WeakSet<object>();
|
|
16
|
+
|
|
17
|
+
/** Mark a render callback the engine installed on an object as its own bookkeeping. */
|
|
18
|
+
export function markEngineRenderHook(hook: unknown): void {
|
|
19
|
+
if (typeof hook === "function") engineRenderHooks.add(hook);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** True when `hook` is an engine-installed render callback rather than the game's own. */
|
|
23
|
+
export function isEngineRenderHook(hook: unknown): boolean {
|
|
24
|
+
return typeof hook === "function" && engineRenderHooks.has(hook);
|
|
25
|
+
}
|
package/src/entities.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { assertNotIterating, disposeEntity, snapshotEntities } from "./entity-snapshot.js";
|
|
2
|
+
export { autoFields } from "./entity-snapshot.js";
|
|
3
|
+
export type { EntitySnapshot, IDebuggable } from "./entity-snapshot.js";
|
|
4
|
+
import type { EntitySnapshot } from "./entity-snapshot.js";
|
|
5
|
+
export class Registry {
|
|
6
|
+
#named = new Map<string, object>();
|
|
7
|
+
#pendingFree = new Set<string>();
|
|
8
|
+
#iterating = false;
|
|
9
|
+
readonly #namesOf = new WeakMap<object, string[]>();
|
|
10
|
+
add<T extends object>(name: string, entity: T): T {
|
|
11
|
+
if (this.#named.has(name)) throw new Error(`Entity "${name}" already registered.`);
|
|
12
|
+
this.#named.set(name, entity);
|
|
13
|
+
const names = this.#namesOf.get(entity);
|
|
14
|
+
if (names === undefined) this.#namesOf.set(entity, [name]);
|
|
15
|
+
else names.push(name);
|
|
16
|
+
return entity;
|
|
17
|
+
}
|
|
18
|
+
get<T extends object = object>(name: string): T | undefined {
|
|
19
|
+
return this.#named.get(name) as T | undefined;
|
|
20
|
+
}
|
|
21
|
+
forEach(callback: (name: string, entity: object) => void): void {
|
|
22
|
+
this.#iterating = true;
|
|
23
|
+
try {
|
|
24
|
+
for (const [name, entity] of this.#named) callback(name, entity);
|
|
25
|
+
} finally {
|
|
26
|
+
this.#iterating = false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
remove(name: string): void {
|
|
30
|
+
assertNotIterating(this.#iterating, "remove");
|
|
31
|
+
this.#pendingFree.delete(name);
|
|
32
|
+
const entity = this.#named.get(name);
|
|
33
|
+
this.#named.delete(name);
|
|
34
|
+
if (entity !== undefined) {
|
|
35
|
+
const names = this.#namesOf.get(entity);
|
|
36
|
+
if (names !== undefined) {
|
|
37
|
+
const at = names.indexOf(name);
|
|
38
|
+
if (at >= 0) names.splice(at, 1);
|
|
39
|
+
}
|
|
40
|
+
disposeEntity(entity);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
queueFree(target: string | object): void {
|
|
44
|
+
const name = typeof target === "string" ? target : this.#nameOf(target);
|
|
45
|
+
if (name === undefined || !this.#named.has(name))
|
|
46
|
+
throw new Error("Cannot queue an entity that is not registered.");
|
|
47
|
+
this.#pendingFree.add(name);
|
|
48
|
+
}
|
|
49
|
+
sweep(): void {
|
|
50
|
+
assertNotIterating(this.#iterating, "sweep");
|
|
51
|
+
if (this.#pendingFree.size === 0) return;
|
|
52
|
+
const pending = [...this.#pendingFree];
|
|
53
|
+
this.#pendingFree.clear();
|
|
54
|
+
for (const name of pending) {
|
|
55
|
+
const entity = this.#named.get(name);
|
|
56
|
+
if (entity === undefined) continue;
|
|
57
|
+
this.#named.delete(name);
|
|
58
|
+
disposeEntity(entity);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
clear(): void {
|
|
62
|
+
assertNotIterating(this.#iterating, "clear");
|
|
63
|
+
this.#pendingFree.clear();
|
|
64
|
+
const entities = [...new Set(this.#named.values())];
|
|
65
|
+
this.#named.clear();
|
|
66
|
+
for (const entity of entities) disposeEntity(entity);
|
|
67
|
+
}
|
|
68
|
+
snapshot(): EntitySnapshot {
|
|
69
|
+
this.#iterating = true;
|
|
70
|
+
try {
|
|
71
|
+
return snapshotEntities(this.#named);
|
|
72
|
+
} finally {
|
|
73
|
+
this.#iterating = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
#nameOf(entity: object): string | undefined {
|
|
77
|
+
return this.#namesOf.get(entity)?.[0];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type EntitySnapshot = Record<string, Record<string, unknown> & { tags?: string[] }>;
|
|
2
|
+
|
|
3
|
+
export interface IDebuggable {
|
|
4
|
+
debug(): Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface IDisposable {
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ITaggedEntity {
|
|
12
|
+
tags?: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function autoFields(entity: object): Record<string, unknown> {
|
|
16
|
+
const fields: Record<string, unknown> = {};
|
|
17
|
+
for (const key of Object.keys(entity)) {
|
|
18
|
+
if (Object.keys(fields).length >= 24) break;
|
|
19
|
+
const value = (entity as Record<string, unknown>)[key];
|
|
20
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
|
|
21
|
+
fields[key] = value;
|
|
22
|
+
} else if (value !== null && typeof value === "object" && "toArray" in value) {
|
|
23
|
+
const toArray = (value as { toArray?: unknown }).toArray;
|
|
24
|
+
if (typeof toArray === "function") fields[key] = toArray.call(value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return fields;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function disposeEntity(entity: object): void {
|
|
31
|
+
const dispose = (entity as Partial<IDisposable>).dispose;
|
|
32
|
+
if (typeof dispose === "function") dispose.call(entity);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function assertNotIterating(iterating: boolean, operation: string): void {
|
|
36
|
+
if (iterating) throw new TypeError(`Registry.${operation}() cannot mutate during snapshot.`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function snapshotEntities(named: ReadonlyMap<string, object>): EntitySnapshot {
|
|
40
|
+
const result: EntitySnapshot = {};
|
|
41
|
+
for (const [name, entity] of named) {
|
|
42
|
+
const debug = (entity as Partial<IDebuggable>).debug;
|
|
43
|
+
const fields = typeof debug === "function" ? debug.call(entity) : autoFields(entity);
|
|
44
|
+
const tags = (entity as ITaggedEntity).tags;
|
|
45
|
+
result[name] = {
|
|
46
|
+
...fields,
|
|
47
|
+
...(Array.isArray(tags) && tags.every((tag) => typeof tag === "string")
|
|
48
|
+
? { tags: [...tags] }
|
|
49
|
+
: {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|