@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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine telling the agent that built the scene what a human finds by playing it once.
|
|
3
|
+
*
|
|
4
|
+
* Imported foliage drawn with no image-based light looks like cardboard, and nothing in the build
|
|
5
|
+
* says so. A GLB's leaf card is `MeshStandardMaterial` (or its Node twin), `alphaTest` above zero,
|
|
6
|
+
* `side: DoubleSide`; with `scene.environment === null` and no `envMap` on the material, `envMapIntensity`
|
|
7
|
+
* has nothing to apply — three r185's WebGPU path only uses it when the material carries its own
|
|
8
|
+
* `envMap`, and `scene.environmentIntensity` only reaches a scene that has an environment. What is
|
|
9
|
+
* left is a hemisphere fill, so a shaded needle card and its back face land on one flat dark value
|
|
10
|
+
* and the author compensates with a tint or a fake emissive, which is the paperboard.
|
|
11
|
+
*
|
|
12
|
+
* So the rule is derived from the scene graph, never from a constant: cutout PBR, counted by
|
|
13
|
+
* material, with no environment anywhere in the scene. It fires once per scene entry, warns, and
|
|
14
|
+
* changes nothing — the fix is the game's own `scene.environment`, which is appearance and therefore
|
|
15
|
+
* the game's to set.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { Object3D } from "three";
|
|
19
|
+
|
|
20
|
+
/** Marker printed once per scene entry, for a log reader and a harness to grep. */
|
|
21
|
+
export const UNLIT_FOLIAGE_MARKER = "TN_UNLIT_FOLIAGE";
|
|
22
|
+
|
|
23
|
+
/** The one line that says what to change. Never a second sentence: the fix is one decision. */
|
|
24
|
+
export const UNLIT_FOLIAGE_FIX =
|
|
25
|
+
"set scene.environment (an HDRI or a sky texture) or give these materials an envMap; do not tint or flatten their normals to compensate";
|
|
26
|
+
|
|
27
|
+
/** How many examples the line carries before it stops being readable. */
|
|
28
|
+
const MAX_EXAMPLES = 5;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The part of a `THREE.Material` this reads. Structural, like the alpha-antialiasing convention's,
|
|
32
|
+
* so a native adapter, a Node material and a test stub are all the same input.
|
|
33
|
+
*/
|
|
34
|
+
interface IUnlitFoliageMaterial {
|
|
35
|
+
alphaHash?: boolean;
|
|
36
|
+
alphaTest?: number;
|
|
37
|
+
alphaToCoverage?: boolean;
|
|
38
|
+
envMap?: unknown;
|
|
39
|
+
name?: string;
|
|
40
|
+
type?: string;
|
|
41
|
+
userData?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The verdict: what is affected, and enough names to find it in the scene graph. */
|
|
45
|
+
export interface IUnlitFoliageWarning {
|
|
46
|
+
/** Distinct materials with no image-based light, the number an author can act on. */
|
|
47
|
+
readonly materials: number;
|
|
48
|
+
/** Meshes drawn with them, so one shared material is not mistaken for a scene-wide one. */
|
|
49
|
+
readonly meshes: number;
|
|
50
|
+
readonly examples: readonly string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* PBR lit by an environment, in three's own spelling. The Node variants are named separately and
|
|
55
|
+
* set no `isMeshStandardMaterial`, so the type name is the one test that covers web and WebGPU.
|
|
56
|
+
*/
|
|
57
|
+
const LIT_PBR = /^(?:MeshStandard|MeshPhysical)(?:Node)?Material$/u;
|
|
58
|
+
|
|
59
|
+
/** A material whose silhouette an alpha test carves, whatever mechanism the game chose. */
|
|
60
|
+
function isCutout(material: IUnlitFoliageMaterial): boolean {
|
|
61
|
+
return (
|
|
62
|
+
(typeof material.alphaTest === "number" && material.alphaTest > 0) ||
|
|
63
|
+
material.alphaHash === true ||
|
|
64
|
+
material.alphaToCoverage === true
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The one condition: cutout PBR with no environment of its own, in a scene with none either.
|
|
70
|
+
*
|
|
71
|
+
* A game that means to render its cutouts unlit says so — `material.userData.tnUnlitOk = true`,
|
|
72
|
+
* the same `userData.tn*` naming the alpha and impostor conventions already use — and is silent.
|
|
73
|
+
*/
|
|
74
|
+
function isUnlitFoliage(value: unknown): value is IUnlitFoliageMaterial {
|
|
75
|
+
if (typeof value !== "object" || value === null) return false;
|
|
76
|
+
const material = value as IUnlitFoliageMaterial;
|
|
77
|
+
if (material.userData?.tnUnlitOk === true) return false;
|
|
78
|
+
if (material.envMap != null) return false;
|
|
79
|
+
return LIT_PBR.test(material.type ?? "") && isCutout(material);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Walk what the scene actually draws.
|
|
84
|
+
*
|
|
85
|
+
* `Object3D.traverse` would visit hidden subtrees too, and three does not draw them, so the walk
|
|
86
|
+
* prunes on `visible` — otherwise a cutout the author disabled would be reported as paperboard.
|
|
87
|
+
* One walk, every node kind: an `InstancedMesh`, a `BatchedMesh` and a `SkinnedMesh` are all an
|
|
88
|
+
* object with a `material`.
|
|
89
|
+
*/
|
|
90
|
+
function eachDrawnNode(node: Object3D, visit: (object: Object3D) => void): void {
|
|
91
|
+
if (node.visible === false) return;
|
|
92
|
+
visit(node);
|
|
93
|
+
const children = (node as { children?: readonly Object3D[] }).children;
|
|
94
|
+
if (children === undefined) return;
|
|
95
|
+
for (const child of children) eachDrawnNode(child, visit);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The material's own name first, then the mesh's, then something a reader can search for. */
|
|
99
|
+
function example(object: Object3D, material: IUnlitFoliageMaterial): string {
|
|
100
|
+
if (material.name !== undefined && material.name !== "") return material.name;
|
|
101
|
+
if (object.name !== "") return object.name;
|
|
102
|
+
return material.type ?? "unnamed material";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The walk's running tally: the materials counted once each, and the meshes that drew them. */
|
|
106
|
+
interface IUnlitTally {
|
|
107
|
+
readonly examples: string[];
|
|
108
|
+
readonly materials: Set<object>;
|
|
109
|
+
meshes: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function countNode(tally: IUnlitTally, object: Object3D): void {
|
|
113
|
+
const slot = (object as { material?: unknown }).material;
|
|
114
|
+
if (slot === undefined || slot === null) return;
|
|
115
|
+
const materials = Array.isArray(slot) ? slot : [slot];
|
|
116
|
+
let drawn = false;
|
|
117
|
+
for (const material of materials) {
|
|
118
|
+
if (!isUnlitFoliage(material)) continue;
|
|
119
|
+
drawn = true;
|
|
120
|
+
if (tally.materials.has(material)) continue;
|
|
121
|
+
tally.materials.add(material);
|
|
122
|
+
if (tally.examples.length < MAX_EXAMPLES) tally.examples.push(example(object, material));
|
|
123
|
+
}
|
|
124
|
+
if (drawn) tally.meshes += 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The warning for one scene entry, or `undefined` when nothing in it is unlit.
|
|
129
|
+
*
|
|
130
|
+
* Fails closed on the reading it needs: a scene with an environment, or a material carrying its own
|
|
131
|
+
* `envMap`, gets no warning, because the absence of an image-based light is the whole claim and
|
|
132
|
+
* anything else is speculation. Materials are counted once however many meshes share them, because
|
|
133
|
+
* a hundred instances of one imported atlas are one decision, not a hundred.
|
|
134
|
+
*/
|
|
135
|
+
export function unlitFoliageWarning(
|
|
136
|
+
scene: Object3D & { environment?: unknown },
|
|
137
|
+
): IUnlitFoliageWarning | undefined {
|
|
138
|
+
if (typeof scene !== "object" || scene === null) return undefined;
|
|
139
|
+
if (scene.environment != null) return undefined;
|
|
140
|
+
const tally: IUnlitTally = { examples: [], materials: new Set(), meshes: 0 };
|
|
141
|
+
eachDrawnNode(scene, (object) => countNode(tally, object));
|
|
142
|
+
if (tally.materials.size === 0) return undefined;
|
|
143
|
+
return { examples: tally.examples, materials: tally.materials.size, meshes: tally.meshes };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The marker line. */
|
|
147
|
+
export function formatUnlitFoliageWarning(warning: IUnlitFoliageWarning): string {
|
|
148
|
+
return `${UNLIT_FOLIAGE_MARKER}:${JSON.stringify(warning)}`;
|
|
149
|
+
}
|