@threenative/core 0.3.10 → 0.3.12
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 +1096 -26
- package/dist/camera-shake-CZKOfGn4.d.ts +46 -0
- package/dist/{canvas-layer-vCtanIeB.d.ts → canvas-layer-CWuFRT7G.d.ts} +1 -1
- package/dist/chunk-2Z44XSI2.js +35 -0
- package/dist/chunk-5O73CDMR.js +1849 -0
- package/dist/chunk-6KLNISRJ.js +153 -0
- package/dist/chunk-7UUT3TY5.js +133 -0
- package/dist/chunk-CFGTPFUH.js +231 -0
- package/dist/chunk-DBELTTTM.js +615 -0
- package/dist/chunk-GMHATRPW.js +7701 -0
- package/dist/chunk-GXY7B3JG.js +46 -0
- package/dist/chunk-KIRUKTBQ.js +187 -0
- package/dist/chunk-N5LRP4BR.js +220 -0
- package/dist/chunk-OKXUCASC.js +2238 -0
- package/dist/chunk-QWJEMUUT.js +94 -0
- package/dist/chunk-VAZM36TV.js +497 -0
- package/dist/{game-DzMcitDO.d.ts → game-D7pAzZUY.d.ts} +15 -3
- package/dist/hot.d.ts +3 -3
- package/dist/hot.js +2 -46
- package/dist/index.d.ts +329 -302
- package/dist/index.js +10565 -22533
- package/dist/{model-lod-CTpZ6imz.d.ts → model-lod-B6BMqS1r.d.ts} +33 -3
- package/dist/playtest.d.ts +3 -3
- package/dist/playtest.js +24 -75
- package/dist/react-css.js +1 -215
- package/dist/react.d.ts +2 -2
- package/dist/{renderer-rZm0hVqq.d.ts → renderer-DvFVoAgj.d.ts} +13 -4
- 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 +5 -384
- package/dist/worker.js +4 -41
- package/dist/world.d.ts +725 -259
- package/dist/world.js +16714 -18284
- package/mcp/animation-server.mjs +1 -1
- package/mcp/animation.mjs +2 -3
- package/mcp/engine-server.mjs +142 -47
- package/mcp/servers.mjs +9 -2
- package/mcp/terrain.mjs +8 -0
- package/package.json +14 -6
- package/patches/three@0.187.0-prd269-upgrade.patch +2102 -0
- package/patches/three@0.187.0.patch +2004 -407
- package/src/assets.ts +9 -2
- package/src/card-lod.ts +152 -0
- package/src/compressed-texture-preparation.ts +1008 -0
- package/src/frame-budget.ts +31 -20
- package/src/game-dev-tools.ts +93 -0
- package/src/game-frame-loop.ts +995 -0
- package/src/game-renderer-metrics.ts +77 -0
- package/src/game-startup.ts +1001 -0
- package/src/game-validate.ts +70 -0
- package/src/game.ts +253 -1935
- package/src/index.ts +27 -2
- package/src/launch-diagnostics.ts +22 -12
- package/src/look/ao-admission.ts +24 -0
- package/src/look/filmic-tone-mapping.ts +15 -13
- package/src/look/look-diagnostics.ts +3 -3
- package/src/look/quality.ts +10 -5
- package/src/look/world-environment.ts +76 -9
- package/src/loop.ts +29 -0
- package/src/model-lod.ts +42 -3
- package/src/particle-kinds.ts +515 -0
- package/src/picking.ts +17 -3
- package/src/playtest.ts +27 -1
- package/src/projection-apply.ts +4 -1
- package/src/projection-plan.ts +9 -6
- package/src/render/mesh-pool.ts +1 -1
- 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.ts +213 -992
- package/src/render/world-impostor-surface.ts +293 -34
- package/src/render-camera-cull.ts +32 -1
- package/src/render-pass-budget.ts +34 -7
- package/src/renderProjection.ts +22 -0
- package/src/renderer.ts +92 -37
- package/src/snow-field.ts +1 -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-readiness.ts +128 -34
- package/src/version.ts +1 -1
- package/src/warmup.ts +56 -8
- package/src/water-surface.ts +9 -3
- package/src/world-bundle-safety.ts +401 -0
- package/src/world-cell-batches.ts +1216 -0
- package/src/world-cell-chunks.ts +1132 -0
- package/src/world-cell-data.ts +995 -0
- package/src/world-cell-impostors.ts +1449 -0
- package/src/world-cell-lod-bias.ts +151 -0
- package/src/world-cell-models.ts +1074 -0
- package/src/world-cell-options.ts +189 -0
- package/src/world-cell-placements.ts +694 -0
- package/src/world-cell-prewarm.ts +557 -0
- package/src/world-cell-readiness.ts +357 -0
- package/src/world-cell-render-bundles.ts +459 -0
- package/src/world-cell-render-gpu-dress.ts +714 -0
- package/src/world-cell-render-main-cull.ts +484 -0
- package/src/world-cell-render-shadow-claims.ts +198 -0
- package/src/world-cell-render-util.ts +246 -0
- package/src/world-cell-render.ts +1493 -0
- package/src/world-cell-residency.ts +745 -0
- package/src/world-cells.ts +1318 -10418
- package/src/world-chunk-shadow.ts +308 -0
- package/src/world-collar.ts +315 -0
- package/src/world-gpu-flags.ts +163 -0
- package/src/world-gpu-readback.ts +881 -0
- package/src/world-gpu-reference.ts +510 -0
- package/src/world-gpu-scene.ts +214 -2264
- package/src/world-gpu-shadow.ts +190 -0
- package/src/world-gpu-types.ts +381 -0
- package/src/world-gpu-validation.ts +518 -0
- package/src/world-heightfield.ts +802 -0
- package/src/world-load-limiter.ts +106 -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-terrain-splat.ts +365 -149
- package/src/world-tile-budget.ts +256 -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 +170 -1745
- package/src/world-water-bodies.ts +359 -0
- package/src/world.ts +35 -741
package/src/assets.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "./asset-cache.js";
|
|
23
23
|
import { TN_VIRTUAL_GEOMETRY, VirtualGeometryPlugin } from "./clustered-mesh.js";
|
|
24
24
|
import { GEOMETRY_ASSET_KEY } from "./geometry-capture.js";
|
|
25
|
+
import { attachInstancedLod } from "./instanced-batch-lod.js";
|
|
25
26
|
import { DiscreteLodPlugin, type IModelLodPolicy, TN_DISCRETE_LOD } from "./model-lod.js";
|
|
26
27
|
import { countDebug, debugRequested, measureDebug } from "./profiling/debug-telemetry.js";
|
|
27
28
|
|
|
@@ -1442,8 +1443,14 @@ export function createAssetLoader(options: IAssetLoaderOptions = {}): IAssetLoad
|
|
|
1442
1443
|
// The cluster DAG the asset pipeline baked in. Registered only when the file declares it,
|
|
1443
1444
|
// so a game whose models are ordinary meshes never pays for the plugin — and a game whose
|
|
1444
1445
|
// models are not gets a plain `Mesh`, with no runtime switch either way.
|
|
1446
|
+
// The Wasm engine's loader hosts no cluster plugin and refuses any it does not host. The
|
|
1447
|
+
// pipeline never marks the bake required, so there the file's source triangles draw.
|
|
1445
1448
|
if (extensions.has(TN_VIRTUAL_GEOMETRY)) {
|
|
1446
|
-
|
|
1449
|
+
if ((loader as { failClosed?: boolean }).failClosed === true)
|
|
1450
|
+
console.info(
|
|
1451
|
+
`TN_VIRTUAL_GEOMETRY_SKIPPED ${path}: this engine's glTF loader hosts no cluster plugin; the source mesh draws`,
|
|
1452
|
+
);
|
|
1453
|
+
else loader.register((parser) => new VirtualGeometryPlugin(parser as never) as never);
|
|
1447
1454
|
}
|
|
1448
1455
|
// The discrete chain the asset pipeline baked in. Registered only when the file declares it,
|
|
1449
1456
|
// so a game with no auto LOD never pays for the plugin. Levels are built after the quantized
|
|
@@ -1480,7 +1487,7 @@ export function createAssetLoader(options: IAssetLoaderOptions = {}): IAssetLoad
|
|
|
1480
1487
|
// Built here, after both widenings, so the derived levels share the widened base
|
|
1481
1488
|
// attributes instead of pinning the quantized ones.
|
|
1482
1489
|
if (root !== undefined && discreteLod !== undefined)
|
|
1483
|
-
discreteLod.attach(root, await discretePolicy(path));
|
|
1490
|
+
discreteLod.attach(root, await discretePolicy(path), attachInstancedLod);
|
|
1484
1491
|
// Before the game ever sees it: clips z-mirrored against their own bind pose play every
|
|
1485
1492
|
// animal backwards, silently. See `reconcileMirroredClips`.
|
|
1486
1493
|
const clips = modelClips(value);
|
package/src/card-lod.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type BufferGeometry, Vector3 } from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A far level for a card mesh: keep `keep` of its cards and grow each kept card about its own
|
|
5
|
+
* centre so the mesh holds its total surface area.
|
|
6
|
+
*
|
|
7
|
+
* Needle and leaf cards are disconnected quads, so an edge-collapse simplifier cannot reduce them
|
|
8
|
+
* (the asset cook's chain skips them, and a far tree drew every card of its middle level to the
|
|
9
|
+
* horizon). Dropping cards alone thins the crown, so the kept ones take the lost area, as Unreal's
|
|
10
|
+
* Nanite "Preserve Area" foliage does (UE 5.8.3:
|
|
11
|
+
* Engine/Source/Developer/MeshSimplifier/Private/MeshSimplify.cpp `PreserveSurfaceArea`).
|
|
12
|
+
*
|
|
13
|
+
* A card is one island of triangles joined by shared vertex indices. The choice is deterministic: a
|
|
14
|
+
* fixed-seed shuffle of the islands, taken until the triangle share is met. Positions move; every
|
|
15
|
+
* other attribute is kept, and a uniform scale about the centre leaves normals and UVs valid.
|
|
16
|
+
*
|
|
17
|
+
* Only the drawn range counts: a material section cut from a shared index by `setDrawRange` thins its
|
|
18
|
+
* own triangles, and the result, whose index holds just the kept ones, draws its whole index.
|
|
19
|
+
*/
|
|
20
|
+
export function thinCards(geometry: BufferGeometry, keep: number): BufferGeometry {
|
|
21
|
+
if (!(keep > 0 && keep <= 1)) throw new Error(`thinCards keep must be in (0, 1], got ${keep}.`);
|
|
22
|
+
const index = geometry.index;
|
|
23
|
+
if (index === null) throw new Error("thinCards needs an indexed geometry.");
|
|
24
|
+
if (geometry.groups.length > 0) throw new Error("thinCards cannot keep material groups.");
|
|
25
|
+
const [first, end] = drawnRange(geometry);
|
|
26
|
+
const triangles = (end - first) / 3;
|
|
27
|
+
const target = Math.max(1, Math.round(triangles * keep));
|
|
28
|
+
if (target >= triangles) return geometry;
|
|
29
|
+
|
|
30
|
+
const position = geometry.getAttribute("position");
|
|
31
|
+
const { kept, scale } = pickCards([...cardIslands(geometry, first, end).values()], target);
|
|
32
|
+
|
|
33
|
+
const out = geometry.clone();
|
|
34
|
+
const moved = out.getAttribute("position");
|
|
35
|
+
const indices: number[] = [];
|
|
36
|
+
const vertex = new Vector3();
|
|
37
|
+
for (const island of kept) {
|
|
38
|
+
// An island of zero area accumulated nothing in the weighted centre, so it takes the plain mean of
|
|
39
|
+
// its triangle centroids; the origin would scale the card about the world origin instead.
|
|
40
|
+
const centre =
|
|
41
|
+
island.area > 0
|
|
42
|
+
? island.centre.divideScalar(island.area)
|
|
43
|
+
: island.plain.divideScalar(island.firsts.length);
|
|
44
|
+
const own = new Set<number>();
|
|
45
|
+
for (const t of island.firsts)
|
|
46
|
+
for (let k = 0; k < 3; k++) {
|
|
47
|
+
const v = index.getX(t + k);
|
|
48
|
+
indices.push(v);
|
|
49
|
+
own.add(v);
|
|
50
|
+
}
|
|
51
|
+
for (const v of own) {
|
|
52
|
+
vertex.fromBufferAttribute(position, v).sub(centre).multiplyScalar(scale).add(centre);
|
|
53
|
+
moved.setXYZ(v, vertex.x, vertex.y, vertex.z);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
moved.needsUpdate = true;
|
|
57
|
+
out.setIndex(indices);
|
|
58
|
+
out.setDrawRange(0, Number.POSITIVE_INFINITY);
|
|
59
|
+
out.computeBoundingBox();
|
|
60
|
+
out.computeBoundingSphere();
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface ICardIsland {
|
|
65
|
+
readonly firsts: number[];
|
|
66
|
+
area: number;
|
|
67
|
+
/** Area-weighted sum of the triangle centroids; the centre once divided by `area`. */
|
|
68
|
+
readonly centre: Vector3;
|
|
69
|
+
/** Unweighted sum of the triangle centroids, the centre of an island whose area is zero. */
|
|
70
|
+
readonly plain: Vector3;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The index entries the geometry draws, [first, end), whole triangles. */
|
|
74
|
+
function drawnRange(geometry: BufferGeometry): [number, number] {
|
|
75
|
+
const count = (geometry.index as NonNullable<BufferGeometry["index"]>).count;
|
|
76
|
+
const first = Math.min(count, Math.max(0, geometry.drawRange.start));
|
|
77
|
+
const end = Math.min(count, first + geometry.drawRange.count);
|
|
78
|
+
return [first - (first % 3), end - ((end - first) % 3)];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Islands of the drawn triangles joined by shared vertex indices, with their area and centres. */
|
|
82
|
+
function cardIslands(
|
|
83
|
+
geometry: BufferGeometry,
|
|
84
|
+
first: number,
|
|
85
|
+
end: number,
|
|
86
|
+
): Map<number, ICardIsland> {
|
|
87
|
+
const index = geometry.index as NonNullable<BufferGeometry["index"]>;
|
|
88
|
+
const position = geometry.getAttribute("position");
|
|
89
|
+
const parent = Int32Array.from({ length: position.count }, (_, i) => i);
|
|
90
|
+
const find = (vertex: number): number => {
|
|
91
|
+
let at = vertex;
|
|
92
|
+
while (parent[at] !== at) {
|
|
93
|
+
parent[at] = parent[parent[at] as number] as number;
|
|
94
|
+
at = parent[at] as number;
|
|
95
|
+
}
|
|
96
|
+
return at;
|
|
97
|
+
};
|
|
98
|
+
for (let t = first; t < end; t += 3) {
|
|
99
|
+
const root = find(index.getX(t));
|
|
100
|
+
parent[find(index.getX(t + 1))] = root;
|
|
101
|
+
parent[find(index.getX(t + 2))] = root;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const islands = new Map<number, ICardIsland>();
|
|
105
|
+
const a = new Vector3();
|
|
106
|
+
const b = new Vector3();
|
|
107
|
+
const c = new Vector3();
|
|
108
|
+
for (let t = first; t < end; t += 3) {
|
|
109
|
+
a.fromBufferAttribute(position, index.getX(t));
|
|
110
|
+
b.fromBufferAttribute(position, index.getX(t + 1));
|
|
111
|
+
c.fromBufferAttribute(position, index.getX(t + 2));
|
|
112
|
+
const centre = a.clone().add(b).add(c).divideScalar(3);
|
|
113
|
+
const area = b.sub(a).cross(c.sub(a)).length() / 2;
|
|
114
|
+
const root = find(index.getX(t));
|
|
115
|
+
const island = islands.get(root) ?? {
|
|
116
|
+
firsts: [],
|
|
117
|
+
area: 0,
|
|
118
|
+
centre: new Vector3(),
|
|
119
|
+
plain: new Vector3(),
|
|
120
|
+
};
|
|
121
|
+
island.firsts.push(t);
|
|
122
|
+
island.area += area;
|
|
123
|
+
island.centre.addScaledVector(centre, area);
|
|
124
|
+
island.plain.add(centre);
|
|
125
|
+
islands.set(root, island);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return islands;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** A fixed-seed shuffle of the islands, taken until `target` triangles, and the scale that keeps the area. */
|
|
132
|
+
function pickCards(order: ICardIsland[], target: number): { kept: ICardIsland[]; scale: number } {
|
|
133
|
+
let seed = 0x9e3779b9;
|
|
134
|
+
for (let i = order.length - 1; i > 0; i--) {
|
|
135
|
+
seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
|
|
136
|
+
const j = seed % (i + 1);
|
|
137
|
+
[order[i], order[j]] = [order[j] as ICardIsland, order[i] as ICardIsland];
|
|
138
|
+
}
|
|
139
|
+
const total = order.reduce((sum, island) => sum + island.area, 0);
|
|
140
|
+
const kept: ICardIsland[] = [];
|
|
141
|
+
let keptTriangles = 0;
|
|
142
|
+
let keptArea = 0;
|
|
143
|
+
for (const island of order) {
|
|
144
|
+
if (keptTriangles >= target) break;
|
|
145
|
+
kept.push(island);
|
|
146
|
+
keptTriangles += island.firsts.length;
|
|
147
|
+
keptArea += island.area;
|
|
148
|
+
}
|
|
149
|
+
const scale = keptArea > 0 ? Math.sqrt(total / keptArea) : 1;
|
|
150
|
+
|
|
151
|
+
return { kept, scale };
|
|
152
|
+
}
|