@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,174 @@
|
|
|
1
|
+
import { AlwaysDepth, Mesh, OrthographicCamera, PlaneGeometry, Scene, type Vector3 } from "three";
|
|
2
|
+
import { positionGeometry, vec4 } from "three/tsl";
|
|
3
|
+
import {
|
|
4
|
+
MeshBasicNodeMaterial,
|
|
5
|
+
type NodeFrame,
|
|
6
|
+
type RenderTarget,
|
|
7
|
+
type Renderer,
|
|
8
|
+
} from "three/webgpu";
|
|
9
|
+
import type { IPageRect } from "./virtual-shadow-pages.js";
|
|
10
|
+
|
|
11
|
+
/** A rectangle of a shadow map in texels, measured from its top-left corner. */
|
|
12
|
+
export interface IPixelRect {
|
|
13
|
+
readonly height: number;
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly x: number;
|
|
16
|
+
readonly y: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One rectangle of a level's map redrawn on its own: the pages it covers, whether the depth it
|
|
21
|
+
* holds must be put back to the far plane first, and the texels the camera aimed at.
|
|
22
|
+
*/
|
|
23
|
+
export interface IPartialPass {
|
|
24
|
+
/** Set by the level when it aims its camera at {@link rect}; a pass without it renders whole. */
|
|
25
|
+
pixels: IPixelRect | undefined;
|
|
26
|
+
readonly rect: IPageRect;
|
|
27
|
+
/** The pass follows an eviction, so the old depth in {@link rect} is cleared before drawing. */
|
|
28
|
+
readonly reset: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The stock shadow node, which this module replaces one method of. */
|
|
32
|
+
export interface IPartialShadowNode {
|
|
33
|
+
readonly shadow: {
|
|
34
|
+
readonly camera: OrthographicCamera & { reversedDepth?: boolean };
|
|
35
|
+
readonly mapSize: { readonly height: number; readonly width: number };
|
|
36
|
+
};
|
|
37
|
+
readonly shadowMap: RenderTarget;
|
|
38
|
+
renderShadow(frame: NodeFrame): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The texels of a `size` x `size` map that a set of world points land on through `camera`, rounded
|
|
43
|
+
* out to whole texels. The camera is read as it stands, so whichever way the level's axes fall the
|
|
44
|
+
* rectangle is the one the stock render would have drawn those pages into.
|
|
45
|
+
*/
|
|
46
|
+
export function pixelRect(
|
|
47
|
+
camera: OrthographicCamera,
|
|
48
|
+
size: number,
|
|
49
|
+
corners: readonly Vector3[],
|
|
50
|
+
): IPixelRect {
|
|
51
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
52
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
53
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
54
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
55
|
+
for (const corner of corners) {
|
|
56
|
+
const ndc = corner
|
|
57
|
+
.clone()
|
|
58
|
+
.applyMatrix4(camera.matrixWorldInverse)
|
|
59
|
+
.applyMatrix4(camera.projectionMatrix);
|
|
60
|
+
const px = ((ndc.x + 1) / 2) * size;
|
|
61
|
+
const py = ((1 - ndc.y) / 2) * size;
|
|
62
|
+
minX = Math.min(minX, px);
|
|
63
|
+
maxX = Math.max(maxX, px);
|
|
64
|
+
minY = Math.min(minY, py);
|
|
65
|
+
maxY = Math.max(maxY, py);
|
|
66
|
+
}
|
|
67
|
+
// A corner computed to a hair either side of a texel edge must not drop or add a texel row.
|
|
68
|
+
const x = Math.max(0, Math.round(minX));
|
|
69
|
+
const y = Math.max(0, Math.round(minY));
|
|
70
|
+
return {
|
|
71
|
+
height: Math.min(size, Math.round(maxY)) - y,
|
|
72
|
+
width: Math.min(size, Math.round(maxX)) - x,
|
|
73
|
+
x,
|
|
74
|
+
y,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const quadScene = new Scene();
|
|
79
|
+
const quadCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
80
|
+
const quads = new Map<number, Mesh>();
|
|
81
|
+
|
|
82
|
+
/** A quad whose every fragment writes `far` to depth and the stock clear's transparent black to colour. */
|
|
83
|
+
function farQuad(far: number): Mesh {
|
|
84
|
+
let quad = quads.get(far);
|
|
85
|
+
if (quad === undefined) {
|
|
86
|
+
const material = new MeshBasicNodeMaterial({
|
|
87
|
+
colorWrite: true,
|
|
88
|
+
depthTest: true,
|
|
89
|
+
depthWrite: true,
|
|
90
|
+
});
|
|
91
|
+
material.fragmentNode = vec4(0);
|
|
92
|
+
material.depthFunc = AlwaysDepth;
|
|
93
|
+
material.vertexNode = vec4(positionGeometry.x, positionGeometry.y, far, 1);
|
|
94
|
+
quad = new Mesh(new PlaneGeometry(2, 2), material);
|
|
95
|
+
quad.frustumCulled = false;
|
|
96
|
+
quads.set(far, quad);
|
|
97
|
+
}
|
|
98
|
+
return quad;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Reset depth to the far plane and transmitted-shadow colour to transparent black in the viewport. A WebGPU clear wipes the whole
|
|
103
|
+
* attachment whatever the viewport, so the rectangle is cleared by drawing over it.
|
|
104
|
+
*/
|
|
105
|
+
function resetDepth(renderer: Renderer, reversed: boolean): void {
|
|
106
|
+
const quad = farQuad(reversed ? 0 : 1);
|
|
107
|
+
quadScene.add(quad);
|
|
108
|
+
// The shadow pass owns the render-object function and would draw the quad with the depth material.
|
|
109
|
+
const held = renderer.getRenderObjectFunction();
|
|
110
|
+
renderer.setRenderObjectFunction(null);
|
|
111
|
+
try {
|
|
112
|
+
renderer.render(quadScene, quadCamera);
|
|
113
|
+
} finally {
|
|
114
|
+
renderer.setRenderObjectFunction(held);
|
|
115
|
+
quadScene.remove(quad);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Make a stock shadow node draw only the rectangle its level aimed at, when the level has one.
|
|
121
|
+
*
|
|
122
|
+
* The level has already aimed the shadow camera with a view offset and baked the receivers' matrix
|
|
123
|
+
* from the full projection, so this does not call `updateMatrices` again. The viewport is the same
|
|
124
|
+
* rectangle, so a texel here is the texel the whole-map render would have written, and the depth
|
|
125
|
+
* load is kept: the shadow pass forces an auto clear, which this turns off for the draw.
|
|
126
|
+
*/
|
|
127
|
+
export function installPartialRender(
|
|
128
|
+
node: IPartialShadowNode,
|
|
129
|
+
current: () => IPartialPass | undefined,
|
|
130
|
+
): void {
|
|
131
|
+
const stock = node.renderShadow.bind(node);
|
|
132
|
+
node.renderShadow = (frame) => {
|
|
133
|
+
const pass = current();
|
|
134
|
+
const pixels = pass?.pixels;
|
|
135
|
+
if (pass === undefined || pixels === undefined) {
|
|
136
|
+
stock(frame);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const { renderer, scene, camera, object, material } = frame;
|
|
140
|
+
if (renderer === null || scene === null) {
|
|
141
|
+
stock(frame);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const { shadow, shadowMap } = node;
|
|
145
|
+
const { height, width } = shadow.mapSize;
|
|
146
|
+
const scissor = shadowMap.scissor.clone();
|
|
147
|
+
const scissorTest = renderer.getScissorTest();
|
|
148
|
+
// `setSize` puts the viewport back to the whole map, so the rectangle is set after it.
|
|
149
|
+
shadowMap.setSize(width, height, shadowMap.depth);
|
|
150
|
+
shadowMap.viewport.set(pixels.x, pixels.y, pixels.width, pixels.height);
|
|
151
|
+
const autoClear = renderer.autoClear;
|
|
152
|
+
const name = scene.name;
|
|
153
|
+
try {
|
|
154
|
+
renderer.autoClear = false;
|
|
155
|
+
shadowMap.scissor.copy(shadowMap.viewport);
|
|
156
|
+
// Three reads the target rectangle but the renderer's scissor-test flag.
|
|
157
|
+
renderer.setScissorTest(true);
|
|
158
|
+
if (pass.reset) resetDepth(renderer, shadow.camera.reversedDepth === true);
|
|
159
|
+
scene.name = "Shadow Map [ partial ]";
|
|
160
|
+
renderer.render(scene, shadow.camera);
|
|
161
|
+
} finally {
|
|
162
|
+
// Nested renders overwrite Three's shared NodeFrame; the next rectangle needs its caller.
|
|
163
|
+
frame.scene = scene;
|
|
164
|
+
frame.camera = camera;
|
|
165
|
+
frame.object = object;
|
|
166
|
+
frame.material = material;
|
|
167
|
+
renderer.autoClear = autoClear;
|
|
168
|
+
scene.name = name;
|
|
169
|
+
shadowMap.viewport.set(0, 0, width, height);
|
|
170
|
+
shadowMap.scissor.copy(scissor);
|
|
171
|
+
renderer.setScissorTest(scissorTest);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|