u-space 0.0.28 → 0.0.30
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/README.md +9 -0
- package/dist/Viewer-BKNV67Jj.cjs +1 -0
- package/dist/Viewer-Cs_y7IiH.js +1256 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +1715 -1497
- package/dist/plugins/atmosphere/AgxToneMapping.d.ts +1 -1
- package/dist/plugins/atmosphere/index.cjs +1 -1
- package/dist/plugins/atmosphere/index.js +4 -4
- package/dist/plugins/curve-movement/index.cjs +1 -1
- package/dist/plugins/curve-movement/index.js +1 -1
- package/dist/plugins/fire/index.cjs +1 -1
- package/dist/plugins/fire/index.js +5 -5
- package/dist/plugins/object-controls/index.cjs +1 -1
- package/dist/plugins/object-controls/index.js +4 -4
- package/dist/plugins/tiles/index.cjs +1 -1
- package/dist/plugins/tiles/index.js +5 -5
- package/dist/plugins/u-manager/index.cjs +51 -51
- package/dist/plugins/u-manager/index.d.ts +1 -1
- package/dist/plugins/u-manager/index.js +8330 -8637
- package/dist/plugins/u-manager/loaders/SceneEditableBatchLayer.d.ts +17 -0
- package/dist/plugins/u-manager/loaders/SceneInstancedLayer.d.ts +3 -3
- package/dist/plugins/u-manager/loaders/SceneLoader.d.ts +20 -3
- package/dist/plugins/u-manager/loaders/UManagerLoader.d.ts +4 -4
- package/dist/plugins/u-manager/semantics/objects/BuildingGroup.d.ts +12 -5
- package/dist/plugins/u-manager/semantics/objects/FacilityInstancedLayer.d.ts +4 -4
- package/dist/plugins/u-manager/semantics/objects/FloorMesh.d.ts +28 -22
- package/dist/plugins/u-manager/semantics/objects/SemanticGroup.d.ts +6 -6
- package/dist/protocol-C-OMPz15.js +10 -0
- package/dist/protocol-IUAzx0lk.cjs +1 -0
- package/dist/src/batches/EditableGeometryBatchLayer.d.ts +50 -0
- package/dist/src/batches/ModelInstancedLayer.d.ts +42 -0
- package/dist/src/batches/index.d.ts +2 -0
- package/dist/src/effects/TSLEffects.d.ts +24 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/instances/InstanceObject.d.ts +57 -0
- package/dist/src/instances/index.d.ts +1 -0
- package/dist/src/interactions/MeshBVHRaycast.d.ts +9 -0
- package/dist/src/interactions/index.d.ts +1 -0
- package/dist/src/viewers/RenderPipeline.d.ts +37 -0
- package/dist/src/viewers/ReversedDepthSSGICompat.d.ts +10 -0
- package/dist/src/viewers/ReversedDepthSSRCompat.d.ts +20 -0
- package/dist/src/viewers/Viewer.d.ts +3 -1
- package/dist/src/viewers/renderInvalidation.d.ts +2 -0
- package/dist/src/worker/FrameTimingWindow.d.ts +16 -0
- package/dist/src/worker/OffscreenViewerHost.d.ts +20 -0
- package/dist/src/worker/WorkerDomTarget.d.ts +44 -0
- package/dist/src/worker/createWorkerViewer.d.ts +18 -0
- package/dist/src/worker/index.d.ts +2 -0
- package/dist/src/worker/installWorkerImageLoader.d.ts +5 -0
- package/dist/src/worker/protocol.d.ts +102 -0
- package/dist/src/worker/runtime.d.ts +2 -0
- package/dist/worker/index.cjs +1 -0
- package/dist/worker/index.js +224 -0
- package/dist/worker/runtime.cjs +1 -0
- package/dist/worker/runtime.js +418 -0
- package/docs/api-batches.md +112 -0
- package/docs/api-effects.md +2 -2
- package/docs/api-interactions.md +8 -0
- package/docs/api-managers.md +1 -1
- package/docs/api-objects.md +207 -0
- package/docs/api-plugin-u-manager.md +245 -96
- package/docs/api-render-pipeline.md +103 -5
- package/docs/api-viewer.md +188 -1
- package/docs/changelog.md +69 -6
- package/docs/examples-guide.md +111 -17
- package/docs/getting-started.md +1 -1
- package/docs/index.md +11 -4
- package/docs/mcp.md +29 -14
- package/docs/release.md +95 -0
- package/package.json +27 -4
- package/dist/plugins/u-manager/instances/SemanticInstanceObject.d.ts +0 -37
- package/dist/plugins/u-manager/instances/SemanticModelInstancedLayer.d.ts +0 -33
- package/dist/plugins/u-manager/instances/index.d.ts +0 -2
|
@@ -0,0 +1,1256 @@
|
|
|
1
|
+
import { Raycaster as U, Vector2 as O, Sphere as x, Mesh as G, InstancedMesh as Q, SkinnedMesh as K, Box3 as D, RenderPipeline as Y, DataTexture as X, RGBAFormat as J, FloatType as k, UnsignedByteType as M, PerspectiveCamera as v, Spherical as d, Matrix4 as Z, Quaternion as ee, Vector4 as te, Vector3 as C, MathUtils as se, PMREMGenerator as ie, OrthographicCamera as b, TimestampQuery as T, Cache as ne, EventDispatcher as re, Timer as ae, WebGPURenderer as oe, PCFShadowMap as he, AgXToneMapping as le, Scene as de, Color as N, Fog as ce, FogExp2 as pe } from "three/webgpu";
|
|
2
|
+
import { MeshBVH as ue } from "three-mesh-bvh";
|
|
3
|
+
import { nodeObject as p, convertToTexture as _, Fn as R, uv as j, ivec2 as me, floor as fe, screenCoordinate as ve, textureLoad as ge, float as Te, pass as I, vec4 as y, diffuseColor as B, materialMetalness as ye, packNormalToRGB as we, normalView as F, materialRoughness as Pe, mrt as Se, output as Ce, sample as z, unpackRGBToNormal as be, vec2 as xe, add as Re, blendColor as Ee, emissive as Me, velocity as Ne } from "three/tsl";
|
|
4
|
+
import { bloom as Oe } from "three/addons/tsl/display/BloomNode.js";
|
|
5
|
+
import { traa as Ie } from "three/addons/tsl/display/TRAANode.js";
|
|
6
|
+
import De from "three/addons/tsl/display/SSGINode.js";
|
|
7
|
+
import _e from "three/addons/tsl/display/RecurrentDenoiseNode.js";
|
|
8
|
+
import je from "three/addons/tsl/display/SSRNode.js";
|
|
9
|
+
import ke from "three/addons/tsl/display/TemporalReprojectNode.js";
|
|
10
|
+
import H from "camera-controls";
|
|
11
|
+
import { RoomEnvironment as Be } from "three/addons/environments/RoomEnvironment.js";
|
|
12
|
+
import { ViewHelper as Fe } from "three/addons/helpers/ViewHelper.js";
|
|
13
|
+
import { CSS2DRenderer as ze, CSS2DObject as Ae } from "three/addons/renderers/CSS2DRenderer.js";
|
|
14
|
+
import { CSS3DRenderer as Le, CSS3DSprite as Ue, CSS3DObject as Ge } from "three/addons/renderers/CSS3DRenderer.js";
|
|
15
|
+
class He {
|
|
16
|
+
/** The type of event (e.g., 'click', 'pointerdown'). */
|
|
17
|
+
type;
|
|
18
|
+
/** The original 3D object that triggered the event. */
|
|
19
|
+
target;
|
|
20
|
+
/** The current 3D object during the bubbling phase. */
|
|
21
|
+
currentTarget;
|
|
22
|
+
/** The intersection data from raycasting, or null if not applicable. */
|
|
23
|
+
intersect;
|
|
24
|
+
/** The original DOM event, or undefined if not applicable. */
|
|
25
|
+
originalEvent;
|
|
26
|
+
_propagationStopped = !1;
|
|
27
|
+
constructor(e) {
|
|
28
|
+
this.type = e.type, this.target = e.target, this.currentTarget = e.target, this.intersect = e.intersect, this.originalEvent = e.originalEvent;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Stops the event from bubbling up the parent chain.
|
|
32
|
+
*/
|
|
33
|
+
stopPropagation() {
|
|
34
|
+
this._propagationStopped = !0;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if `stopPropagation()` has been called.
|
|
38
|
+
*/
|
|
39
|
+
get propagationStopped() {
|
|
40
|
+
return this._propagationStopped;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
class Ve {
|
|
44
|
+
domElement;
|
|
45
|
+
scene;
|
|
46
|
+
camera;
|
|
47
|
+
raycaster = new U();
|
|
48
|
+
pointer = new O();
|
|
49
|
+
hoveredObject = null;
|
|
50
|
+
pointerDownTime = 0;
|
|
51
|
+
pointerDownPos = new O();
|
|
52
|
+
clickTimer = null;
|
|
53
|
+
longPressThreshold = 500;
|
|
54
|
+
moveThreshold = 0.01;
|
|
55
|
+
/**
|
|
56
|
+
* The objects to check for intersections. default to all children of the scene (including nested).
|
|
57
|
+
*/
|
|
58
|
+
targetObjects;
|
|
59
|
+
/**
|
|
60
|
+
* Whether to enable pointer move events (pointermove, pointerenter, pointerleave).
|
|
61
|
+
* Disabled by default for performance optimization.
|
|
62
|
+
*/
|
|
63
|
+
pointerMoveEventsEnabled = !1;
|
|
64
|
+
/**
|
|
65
|
+
* Whether interaction is enabled globally.
|
|
66
|
+
*/
|
|
67
|
+
_enabled = !0;
|
|
68
|
+
/**
|
|
69
|
+
* Objects excluded from raycasting (via addIgnore or setInteractable(false)).
|
|
70
|
+
*/
|
|
71
|
+
_excludeSet = /* @__PURE__ */ new Set();
|
|
72
|
+
constructor(e, t, s) {
|
|
73
|
+
this.domElement = e, this.scene = t, this.camera = s, this.raycaster.params.Points.threshold = 0.1, this.raycaster.params.Line.threshold = 0.1, this.raycaster.firstHitOnly = !0, this.targetObjects = this.scene.children, this._bindEvents();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Updates the camera reference (useful when switching cameras).
|
|
77
|
+
*/
|
|
78
|
+
setCamera(e) {
|
|
79
|
+
this.camera = e;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Enable all interactions.
|
|
83
|
+
*/
|
|
84
|
+
enable() {
|
|
85
|
+
this._enabled = !0;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Disable all interactions.
|
|
89
|
+
*/
|
|
90
|
+
disable() {
|
|
91
|
+
this._enabled = !1;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Set whether a specific object is interactable.
|
|
95
|
+
* When set to false, the object and its children are excluded from raycasting.
|
|
96
|
+
*/
|
|
97
|
+
setInteractable(e, t) {
|
|
98
|
+
t ? this._excludeSet.delete(e) : this._excludeSet.add(e);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Add an object to the exclude list (will not receive any events).
|
|
102
|
+
* Alias for `setInteractable(object, false)`.
|
|
103
|
+
*/
|
|
104
|
+
addIgnore(e) {
|
|
105
|
+
this._excludeSet.add(e);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Remove an object from the exclude list.
|
|
109
|
+
* Alias for `setInteractable(object, true)`.
|
|
110
|
+
*/
|
|
111
|
+
removeIgnore(e) {
|
|
112
|
+
this._excludeSet.delete(e);
|
|
113
|
+
}
|
|
114
|
+
_bindEvents() {
|
|
115
|
+
this.domElement.addEventListener("click", this._onClick), this.domElement.addEventListener("dblclick", this._onDblClick), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointerup", this._onPointerUp), this.domElement.addEventListener("pointermove", this._onPointerMove);
|
|
116
|
+
}
|
|
117
|
+
_updatePointer(e) {
|
|
118
|
+
const t = this.domElement.getBoundingClientRect();
|
|
119
|
+
this.pointer.x = (e.clientX - t.left) / t.width * 2 - 1, this.pointer.y = -((e.clientY - t.top) / t.height) * 2 + 1;
|
|
120
|
+
}
|
|
121
|
+
_getIntersects() {
|
|
122
|
+
this.raycaster.setFromCamera(this.pointer, this.camera);
|
|
123
|
+
const e = this.raycaster.intersectObjects(this.targetObjects, !0);
|
|
124
|
+
return this._excludeSet.size > 0 ? e.filter((t) => {
|
|
125
|
+
let s = t.object;
|
|
126
|
+
for (; s; ) {
|
|
127
|
+
if (this._excludeSet.has(s))
|
|
128
|
+
return !1;
|
|
129
|
+
s = s.parent;
|
|
130
|
+
}
|
|
131
|
+
return !0;
|
|
132
|
+
}) : e;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Dispatches an event to the target object and bubbles up the parent chain.
|
|
136
|
+
*/
|
|
137
|
+
_dispatchToTarget(e, t, s, i) {
|
|
138
|
+
const r = new He({
|
|
139
|
+
type: e,
|
|
140
|
+
target: t,
|
|
141
|
+
intersect: s,
|
|
142
|
+
originalEvent: i
|
|
143
|
+
});
|
|
144
|
+
let a = t;
|
|
145
|
+
for (; a && !r.propagationStopped; )
|
|
146
|
+
r.currentTarget = a, a.dispatchEvent({ type: e, event: r }), a = a.parent;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Handles a DOM event by raycasting and dispatching to the first intersected object.
|
|
150
|
+
*/
|
|
151
|
+
_handleEvent(e, t) {
|
|
152
|
+
if (!this._enabled) return;
|
|
153
|
+
this._updatePointer(t);
|
|
154
|
+
const s = this._getIntersects();
|
|
155
|
+
if (s.length === 0) return;
|
|
156
|
+
const i = s[0];
|
|
157
|
+
this._dispatchToTarget(e, i.object, i, t);
|
|
158
|
+
}
|
|
159
|
+
_onClick = (e) => {
|
|
160
|
+
const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
|
|
161
|
+
if (!(t > this.longPressThreshold || s > this.moveThreshold)) {
|
|
162
|
+
if (this.clickTimer) {
|
|
163
|
+
clearTimeout(this.clickTimer), this.clickTimer = null;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
this.clickTimer = setTimeout(() => {
|
|
167
|
+
this._handleEvent("click", e), this.clickTimer = null;
|
|
168
|
+
}, 200);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
_onDblClick = (e) => {
|
|
172
|
+
this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this._handleEvent("dblclick", e);
|
|
173
|
+
};
|
|
174
|
+
_onContextMenu = (e) => {
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
};
|
|
177
|
+
_onPointerDown = (e) => {
|
|
178
|
+
this.pointerDownTime = Date.now(), this._updatePointer(e), this.pointerDownPos.copy(this.pointer), this._handleEvent("pointerdown", e);
|
|
179
|
+
};
|
|
180
|
+
_onPointerUp = (e) => {
|
|
181
|
+
if (this._updatePointer(e), e.button === 2) {
|
|
182
|
+
const t = Date.now() - this.pointerDownTime, s = this.pointer.distanceTo(this.pointerDownPos);
|
|
183
|
+
t <= this.longPressThreshold && s <= this.moveThreshold && this._handleEvent("rightclick", e);
|
|
184
|
+
}
|
|
185
|
+
this._handleEvent("pointerup", e);
|
|
186
|
+
};
|
|
187
|
+
_onPointerMove = (e) => {
|
|
188
|
+
if (!this._enabled || !this.pointerMoveEventsEnabled) return;
|
|
189
|
+
this._updatePointer(e);
|
|
190
|
+
const t = this._getIntersects(), s = t.length > 0 ? t[0].object : null, i = t.length > 0 ? t[0] : null;
|
|
191
|
+
this.hoveredObject !== s && (this.hoveredObject && this._dispatchToTarget("pointerleave", this.hoveredObject, null, e), this.hoveredObject = s, s && i && this._dispatchToTarget("pointerenter", s, i, e)), s && i && this._dispatchToTarget("pointermove", s, i, e);
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Cleans up event listeners.
|
|
195
|
+
*/
|
|
196
|
+
dispose() {
|
|
197
|
+
this.domElement.removeEventListener("click", this._onClick), this.domElement.removeEventListener("dblclick", this._onDblClick), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.clickTimer && (clearTimeout(this.clickTimer), this.clickTimer = null), this.hoveredObject = null, this._excludeSet.clear();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const We = 1e4, w = /* @__PURE__ */ new WeakMap(), A = new x();
|
|
201
|
+
function qe(n) {
|
|
202
|
+
const e = n.getAttribute("position");
|
|
203
|
+
if (!e) return 0;
|
|
204
|
+
const t = n.index?.count ?? e.count, s = Math.min(t - n.drawRange.start, n.drawRange.count);
|
|
205
|
+
return Math.max(0, Math.floor(s / 3));
|
|
206
|
+
}
|
|
207
|
+
function $e(n) {
|
|
208
|
+
if (w.has(n))
|
|
209
|
+
return w.get(n) ?? null;
|
|
210
|
+
if (qe(n) < We)
|
|
211
|
+
return w.set(n, null), null;
|
|
212
|
+
let e = null;
|
|
213
|
+
try {
|
|
214
|
+
e = new ue(n, {
|
|
215
|
+
indirect: !0,
|
|
216
|
+
verbose: !1
|
|
217
|
+
});
|
|
218
|
+
} catch {
|
|
219
|
+
}
|
|
220
|
+
return w.set(n, e), e;
|
|
221
|
+
}
|
|
222
|
+
function Qe(n, e) {
|
|
223
|
+
const { geometry: t } = n;
|
|
224
|
+
return t.boundingSphere === null && t.computeBoundingSphere(), t.boundingSphere ? (A.copy(t.boundingSphere).applyMatrix4(n.matrixWorld), e.ray.intersectsSphere(A)) : !0;
|
|
225
|
+
}
|
|
226
|
+
function Ke(n) {
|
|
227
|
+
return !(n instanceof Q) && !(n instanceof K) && !n.morphTargetInfluences && n.raycast === G.prototype.raycast && !n.userData.raycastAcceleration;
|
|
228
|
+
}
|
|
229
|
+
function jt(n) {
|
|
230
|
+
return n.traverse((e) => {
|
|
231
|
+
if (!(e instanceof G) || !Ke(e)) return;
|
|
232
|
+
const t = e, s = t.raycast.bind(t);
|
|
233
|
+
let i;
|
|
234
|
+
t.userData.raycastAcceleration = "lazy", t.raycast = (r, a) => {
|
|
235
|
+
Qe(t, r) && (i === void 0 && (i = $e(t.geometry), t.userData.raycastAcceleration = i ? "three-mesh-bvh" : "default"), i ? i.raycastObject3D(t, r, a) : s(r, a));
|
|
236
|
+
};
|
|
237
|
+
}), n;
|
|
238
|
+
}
|
|
239
|
+
function P(n, e) {
|
|
240
|
+
const t = n;
|
|
241
|
+
if (t.setInstanceVisible) {
|
|
242
|
+
t.setInstanceVisible(e);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
n.visible = e, t.markInstanceRenderDirty?.();
|
|
246
|
+
}
|
|
247
|
+
class Ye {
|
|
248
|
+
idMap = /* @__PURE__ */ new Map();
|
|
249
|
+
nameMap = /* @__PURE__ */ new Map();
|
|
250
|
+
typeMap = /* @__PURE__ */ new Map();
|
|
251
|
+
objectIds = /* @__PURE__ */ new Map();
|
|
252
|
+
allObjects = /* @__PURE__ */ new Set();
|
|
253
|
+
/**
|
|
254
|
+
* Add an object with a custom id.
|
|
255
|
+
* One object can have multiple ids.
|
|
256
|
+
*/
|
|
257
|
+
add(e, t) {
|
|
258
|
+
if (this.idMap.has(e)) {
|
|
259
|
+
console.warn(`ObjectManager: Object with id ${e} already exists.`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
this.idMap.set(e, t), this.allObjects.add(t), this.objectIds.has(t) || this.objectIds.set(t, /* @__PURE__ */ new Set()), this.objectIds.get(t).add(e), t.name && (this.nameMap.has(t.name) || this.nameMap.set(t.name, /* @__PURE__ */ new Set()), this.nameMap.get(t.name).add(t)), t.type && (this.typeMap.has(t.type) || this.typeMap.set(t.type, /* @__PURE__ */ new Set()), this.typeMap.get(t.type).add(t));
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get an object by its custom id.
|
|
266
|
+
*/
|
|
267
|
+
getById(e) {
|
|
268
|
+
return this.idMap.get(e);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get all objects with a given name.
|
|
272
|
+
*/
|
|
273
|
+
getByName(e) {
|
|
274
|
+
return this.nameMap.get(e) || /* @__PURE__ */ new Set();
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get all objects with a given type.
|
|
278
|
+
*/
|
|
279
|
+
getByType(e) {
|
|
280
|
+
return this.typeMap.get(e) || /* @__PURE__ */ new Set();
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Get all ids associated with an object.
|
|
284
|
+
*/
|
|
285
|
+
getObjectIds(e) {
|
|
286
|
+
return this.objectIds.get(e) || /* @__PURE__ */ new Set();
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Remove an object and all its associated ids.
|
|
290
|
+
*/
|
|
291
|
+
remove(e) {
|
|
292
|
+
const t = this.objectIds.get(e);
|
|
293
|
+
if (t) {
|
|
294
|
+
for (const s of t)
|
|
295
|
+
this.idMap.delete(s);
|
|
296
|
+
this.objectIds.delete(e);
|
|
297
|
+
}
|
|
298
|
+
if (e.name && this.nameMap.has(e.name)) {
|
|
299
|
+
const s = this.nameMap.get(e.name);
|
|
300
|
+
s.delete(e), s.size === 0 && this.nameMap.delete(e.name);
|
|
301
|
+
}
|
|
302
|
+
if (e.type && this.typeMap.has(e.type)) {
|
|
303
|
+
const s = this.typeMap.get(e.type);
|
|
304
|
+
s.delete(e), s.size === 0 && this.typeMap.delete(e.type);
|
|
305
|
+
}
|
|
306
|
+
this.allObjects.delete(e);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Remove an object by its id.
|
|
310
|
+
*/
|
|
311
|
+
removeById(e) {
|
|
312
|
+
const t = this.idMap.get(e);
|
|
313
|
+
t && this.remove(t);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Remove all objects with a given name.
|
|
317
|
+
*/
|
|
318
|
+
removeByName(e) {
|
|
319
|
+
const t = this.getByName(e);
|
|
320
|
+
for (const s of t)
|
|
321
|
+
this.remove(s);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Remove all objects with a given type.
|
|
325
|
+
*/
|
|
326
|
+
removeByType(e) {
|
|
327
|
+
const t = this.getByType(e);
|
|
328
|
+
for (const s of t)
|
|
329
|
+
this.remove(s);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Clear all cached objects.
|
|
333
|
+
*/
|
|
334
|
+
clear() {
|
|
335
|
+
this.idMap.clear(), this.nameMap.clear(), this.typeMap.clear(), this.objectIds.clear(), this.allObjects.clear();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get all cached objects as a Set.
|
|
339
|
+
*/
|
|
340
|
+
getAll() {
|
|
341
|
+
return this.allObjects;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Get the number of unique cached objects.
|
|
345
|
+
*/
|
|
346
|
+
get size() {
|
|
347
|
+
return this.allObjects.size;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Show an object by id.
|
|
351
|
+
*/
|
|
352
|
+
show(e) {
|
|
353
|
+
const t = this.idMap.get(e);
|
|
354
|
+
t && P(t, !0);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Hide an object by id.
|
|
358
|
+
*/
|
|
359
|
+
hide(e) {
|
|
360
|
+
const t = this.idMap.get(e);
|
|
361
|
+
t && P(t, !1);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Show only the specified objects, hide all others.
|
|
365
|
+
*/
|
|
366
|
+
isolate(e) {
|
|
367
|
+
const t = new Set(e);
|
|
368
|
+
for (const s of this.allObjects) {
|
|
369
|
+
const i = this.objectIds.get(s) ?? /* @__PURE__ */ new Set();
|
|
370
|
+
P(s, [...i].some((r) => t.has(r)));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Set the opacity of an object's materials.
|
|
375
|
+
*/
|
|
376
|
+
setOpacity(e, t) {
|
|
377
|
+
const s = this.idMap.get(e);
|
|
378
|
+
if (!s) return;
|
|
379
|
+
const i = s;
|
|
380
|
+
if (i.setInstanceOpacity) {
|
|
381
|
+
i.setInstanceOpacity(t);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
s.traverse((r) => {
|
|
385
|
+
if (!r.isMesh) return;
|
|
386
|
+
const a = r.material;
|
|
387
|
+
if (!a) return;
|
|
388
|
+
const o = Array.isArray(a) ? a : [a];
|
|
389
|
+
for (const c of o)
|
|
390
|
+
c.transparent = t < 1, c.opacity = t, c.needsUpdate = !0;
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Get the bounding box of an object by id, or all objects if no id provided.
|
|
395
|
+
*/
|
|
396
|
+
getBoundingBox(e) {
|
|
397
|
+
const t = new D();
|
|
398
|
+
if (e) {
|
|
399
|
+
const s = this.idMap.get(e);
|
|
400
|
+
s && t.setFromObject(s);
|
|
401
|
+
} else
|
|
402
|
+
for (const s of this.allObjects)
|
|
403
|
+
t.expandByObject(s);
|
|
404
|
+
return t;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Iterate over all managed objects.
|
|
408
|
+
*/
|
|
409
|
+
forEach(e) {
|
|
410
|
+
for (const t of this.allObjects) {
|
|
411
|
+
const s = this.objectIds.get(t) || /* @__PURE__ */ new Set();
|
|
412
|
+
e(t, s);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Filter objects by a predicate.
|
|
417
|
+
*/
|
|
418
|
+
filter(e) {
|
|
419
|
+
const t = [];
|
|
420
|
+
for (const s of this.allObjects)
|
|
421
|
+
e(s) && t.push(s);
|
|
422
|
+
return t;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Show all managed objects.
|
|
426
|
+
*/
|
|
427
|
+
showAll() {
|
|
428
|
+
for (const e of this.allObjects)
|
|
429
|
+
P(e, !0);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function Xe(n) {
|
|
433
|
+
if (typeof n != "object" || n === null || !("_material" in n))
|
|
434
|
+
throw new Error(
|
|
435
|
+
"ReversedDepthSSGINode: Three.js no longer exposes _material."
|
|
436
|
+
);
|
|
437
|
+
const e = n._material;
|
|
438
|
+
if (typeof e != "object" || e === null || !("colorNode" in e) || !("needsUpdate" in e))
|
|
439
|
+
throw new Error(
|
|
440
|
+
"ReversedDepthSSGINode: Three.js _material is incompatible."
|
|
441
|
+
);
|
|
442
|
+
return e;
|
|
443
|
+
}
|
|
444
|
+
class Je extends De {
|
|
445
|
+
setup(e) {
|
|
446
|
+
const t = super.setup(e);
|
|
447
|
+
if (!e.renderer.reversedDepthBuffer) return t;
|
|
448
|
+
const s = Xe(this), i = s.colorNode;
|
|
449
|
+
if (i === null)
|
|
450
|
+
throw new Error(
|
|
451
|
+
"ReversedDepthSSGINode: Three.js did not build its color node."
|
|
452
|
+
);
|
|
453
|
+
return s.colorNode = R(() => (this.depthNode.sample(j()).r.lessThanEqual(0).discard(), i))().context(e.getSharedContext()), s.needsUpdate = !0, t;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const Ze = (n, e, t, s) => p(
|
|
457
|
+
new Je(
|
|
458
|
+
_(n),
|
|
459
|
+
p(e),
|
|
460
|
+
p(t),
|
|
461
|
+
s
|
|
462
|
+
)
|
|
463
|
+
);
|
|
464
|
+
function V(n, e, t) {
|
|
465
|
+
if (typeof n != "object" || n === null || !(e in n))
|
|
466
|
+
throw new Error(`${t}: Three.js no longer exposes ${e}.`);
|
|
467
|
+
const s = n[e];
|
|
468
|
+
if (typeof s != "object" || s === null || !("fragmentNode" in s) || !("needsUpdate" in s))
|
|
469
|
+
throw new Error(`${t}: Three.js ${e} is incompatible.`);
|
|
470
|
+
return s;
|
|
471
|
+
}
|
|
472
|
+
function W(n, e) {
|
|
473
|
+
if (n.fragmentNode === null)
|
|
474
|
+
throw new Error(`${e}: Three.js did not build its fragment node.`);
|
|
475
|
+
return n.fragmentNode;
|
|
476
|
+
}
|
|
477
|
+
function et(n) {
|
|
478
|
+
return "getTextureNode" in n && typeof n.getTextureNode == "function";
|
|
479
|
+
}
|
|
480
|
+
class tt extends je {
|
|
481
|
+
setup(e) {
|
|
482
|
+
const t = super.setup(e);
|
|
483
|
+
if (!e.renderer.reversedDepthBuffer) return t;
|
|
484
|
+
const s = this;
|
|
485
|
+
if (typeof s._ssrFn != "function" || typeof s._buildSSRMaterial != "function")
|
|
486
|
+
throw new Error(
|
|
487
|
+
"ReversedDepthSSRNode: Three.js SSR internals are incompatible."
|
|
488
|
+
);
|
|
489
|
+
const i = s._ssrFn;
|
|
490
|
+
return s._ssrFn = R(() => (this.depthNode.sample(j()).r.lessThanEqual(0).discard(), i())), s._buildSSRMaterial(), t;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
class st extends ke {
|
|
494
|
+
setup(e) {
|
|
495
|
+
const t = super.setup(e);
|
|
496
|
+
if (!e.renderer.reversedDepthBuffer) return t;
|
|
497
|
+
const s = V(
|
|
498
|
+
this,
|
|
499
|
+
"_resolveMaterial",
|
|
500
|
+
"ReversedDepthTemporalReprojectNode"
|
|
501
|
+
), i = W(
|
|
502
|
+
s,
|
|
503
|
+
"ReversedDepthTemporalReprojectNode"
|
|
504
|
+
);
|
|
505
|
+
return s.fragmentNode = R(() => {
|
|
506
|
+
const r = me(fe(ve.xy.sub(0.5)));
|
|
507
|
+
return ge(this.depthNode, r).r.lessThanEqual(0).discard(), i;
|
|
508
|
+
})().context(e.getSharedContext()), s.needsUpdate = !0, t;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
class it extends _e {
|
|
512
|
+
setup(e) {
|
|
513
|
+
const t = super.setup(e);
|
|
514
|
+
if (!e.renderer.reversedDepthBuffer) return t;
|
|
515
|
+
const s = V(
|
|
516
|
+
this,
|
|
517
|
+
"_material",
|
|
518
|
+
"ReversedDepthRecurrentDenoiseNode"
|
|
519
|
+
), i = W(
|
|
520
|
+
s,
|
|
521
|
+
"ReversedDepthRecurrentDenoiseNode"
|
|
522
|
+
);
|
|
523
|
+
return s.fragmentNode = R(() => ((this.depthNode ? this.depthNode.sample(j()).x : Te(0.5)).lessThanEqual(0).discard(), i))().context(e.getSharedContext()), s.needsUpdate = !0, t;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const nt = (n, e, t, s = {}) => p(
|
|
527
|
+
new tt(
|
|
528
|
+
p(n),
|
|
529
|
+
p(e),
|
|
530
|
+
p(t),
|
|
531
|
+
s
|
|
532
|
+
)
|
|
533
|
+
), rt = (n, e, t, s, i, r = {}) => p(
|
|
534
|
+
new st(
|
|
535
|
+
_(n),
|
|
536
|
+
p(e),
|
|
537
|
+
p(t),
|
|
538
|
+
p(s),
|
|
539
|
+
i,
|
|
540
|
+
r
|
|
541
|
+
)
|
|
542
|
+
), at = (n, e, t = {}) => {
|
|
543
|
+
const s = et(n) ? n.getTextureNode() : _(n);
|
|
544
|
+
return p(
|
|
545
|
+
new it(s, e, t)
|
|
546
|
+
);
|
|
547
|
+
};
|
|
548
|
+
class ot extends Y {
|
|
549
|
+
scene;
|
|
550
|
+
camera;
|
|
551
|
+
scenePass;
|
|
552
|
+
needsUpdateOutputNode;
|
|
553
|
+
#r;
|
|
554
|
+
#s;
|
|
555
|
+
#a = !1;
|
|
556
|
+
#l = { strength: 1, radius: 0, threshold: 0 };
|
|
557
|
+
#o = null;
|
|
558
|
+
#h = !1;
|
|
559
|
+
#d = {
|
|
560
|
+
sliceCount: 1,
|
|
561
|
+
stepCount: 12,
|
|
562
|
+
aoIntensity: 1,
|
|
563
|
+
giIntensity: 10,
|
|
564
|
+
radius: 12,
|
|
565
|
+
thickness: 1
|
|
566
|
+
};
|
|
567
|
+
#g = null;
|
|
568
|
+
#i = !1;
|
|
569
|
+
#c = {
|
|
570
|
+
resolutionScale: 1,
|
|
571
|
+
quality: 0.25,
|
|
572
|
+
mirrorBias: 0.5,
|
|
573
|
+
maxDistance: 0.4,
|
|
574
|
+
intensity: 1,
|
|
575
|
+
thickness: 0.1,
|
|
576
|
+
maxLuminance: 35,
|
|
577
|
+
stepExponent: 3,
|
|
578
|
+
binaryRefine: !1,
|
|
579
|
+
screenEdgeFade: 0.2,
|
|
580
|
+
screenEdgeFadeBlack: !0,
|
|
581
|
+
temporal: {
|
|
582
|
+
maxFrames: 16,
|
|
583
|
+
clampIntensity: 0.25,
|
|
584
|
+
flickerSuppression: 1,
|
|
585
|
+
hitPointReprojection: !0
|
|
586
|
+
},
|
|
587
|
+
denoise: {
|
|
588
|
+
lumaPhi: 0.75,
|
|
589
|
+
depthPhi: 20,
|
|
590
|
+
normalPhi: 0.3,
|
|
591
|
+
roughnessPhi: 100,
|
|
592
|
+
radius: 1.5,
|
|
593
|
+
alphaPhi: 5,
|
|
594
|
+
strength: 0.725,
|
|
595
|
+
adapt: 0.5,
|
|
596
|
+
smoothDisocclusions: !0,
|
|
597
|
+
flickerSuppression: 1,
|
|
598
|
+
adaptiveTrust: 1
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
#e = null;
|
|
602
|
+
#p = null;
|
|
603
|
+
#t = null;
|
|
604
|
+
#T = new X(
|
|
605
|
+
new Float32Array([0, 0, 0, 1]),
|
|
606
|
+
1,
|
|
607
|
+
1,
|
|
608
|
+
J,
|
|
609
|
+
k
|
|
610
|
+
);
|
|
611
|
+
#m = !1;
|
|
612
|
+
#f = null;
|
|
613
|
+
#y = null;
|
|
614
|
+
#v;
|
|
615
|
+
#u;
|
|
616
|
+
#w = !1;
|
|
617
|
+
#P = !0;
|
|
618
|
+
constructor(...e) {
|
|
619
|
+
const [t, s, i] = e;
|
|
620
|
+
super(t), this.scene = s, this.camera = i, this.scenePass = I(s, i), this.needsUpdateOutputNode = !0, this.#r = /* @__PURE__ */ new Set(), this.#s = [], this.#v = /* @__PURE__ */ new Set(), this.#u = /* @__PURE__ */ new Map(), this.#T.needsUpdate = !0, this.#C();
|
|
621
|
+
}
|
|
622
|
+
/** @deprecated Use `scenePass` instead */
|
|
623
|
+
get currentOutputNode() {
|
|
624
|
+
return this.scenePass;
|
|
625
|
+
}
|
|
626
|
+
addOverlayPass(e) {
|
|
627
|
+
this.#r.add(e), this.needsUpdateOutputNode = !0;
|
|
628
|
+
}
|
|
629
|
+
removeOverlayPass(e) {
|
|
630
|
+
this.#r.delete(e), this.needsUpdateOutputNode = !0;
|
|
631
|
+
}
|
|
632
|
+
setCamera(e) {
|
|
633
|
+
this.camera = e, this.#n();
|
|
634
|
+
}
|
|
635
|
+
/** @deprecated Use `setOutputComposer` instead */
|
|
636
|
+
setCurrentOutputNode(e) {
|
|
637
|
+
this.setOutputComposer(() => e);
|
|
638
|
+
}
|
|
639
|
+
/** @deprecated Use `setOutputComposer(null)` instead */
|
|
640
|
+
resetCurrentOutputNode() {
|
|
641
|
+
this.setOutputComposer(null);
|
|
642
|
+
}
|
|
643
|
+
setOutputComposer(e) {
|
|
644
|
+
this.#y = e, this.needsUpdateOutputNode = !0;
|
|
645
|
+
}
|
|
646
|
+
addOutputEffect(e) {
|
|
647
|
+
return this.#v.add(e), this.needsUpdateOutputNode = !0, this;
|
|
648
|
+
}
|
|
649
|
+
removeOutputEffect(e) {
|
|
650
|
+
return this.#v.delete(e), this.needsUpdateOutputNode = !0, this;
|
|
651
|
+
}
|
|
652
|
+
addMRTChannel(e, t) {
|
|
653
|
+
return this.#u.get(e) === t ? this : (this.#u.set(e, t), this.#n(), this);
|
|
654
|
+
}
|
|
655
|
+
removeMRTChannel(e) {
|
|
656
|
+
return this.#u.delete(e) && this.#n(), this;
|
|
657
|
+
}
|
|
658
|
+
enableBloom(e) {
|
|
659
|
+
e && Object.assign(this.#l, e), this.#a = !0, this.#n();
|
|
660
|
+
}
|
|
661
|
+
disableBloom() {
|
|
662
|
+
this.#a = !1, this.#o = null, this.#n();
|
|
663
|
+
}
|
|
664
|
+
updateBloom(e) {
|
|
665
|
+
Object.assign(this.#l, e), this.#a && (this.needsUpdateOutputNode = !0);
|
|
666
|
+
}
|
|
667
|
+
enableSSGI(e) {
|
|
668
|
+
e && Object.assign(this.#d, e), this.#h = !0, this.#n();
|
|
669
|
+
}
|
|
670
|
+
disableSSGI() {
|
|
671
|
+
this.#h = !1, this.#g = null, this.#n();
|
|
672
|
+
}
|
|
673
|
+
updateSSGI(e) {
|
|
674
|
+
if (Object.assign(this.#d, e), this.#g) {
|
|
675
|
+
const t = this.#g;
|
|
676
|
+
e.sliceCount !== void 0 && (t.sliceCount.value = e.sliceCount), e.stepCount !== void 0 && (t.stepCount.value = e.stepCount), e.aoIntensity !== void 0 && (t.aoIntensity.value = e.aoIntensity), e.giIntensity !== void 0 && (t.giIntensity.value = e.giIntensity), e.radius !== void 0 && (t.radius.value = e.radius), e.thickness !== void 0 && (t.thickness.value = e.thickness);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
enableSSR(e) {
|
|
680
|
+
e && this.#S(e), this.#i = !0, this.#n();
|
|
681
|
+
}
|
|
682
|
+
disableSSR() {
|
|
683
|
+
this.#i = !1, this.#e = null, this.#p = null, this.#t = null, this.#n();
|
|
684
|
+
}
|
|
685
|
+
updateSSR(e) {
|
|
686
|
+
if (this.#S(e), this.#e) {
|
|
687
|
+
const t = this.#c;
|
|
688
|
+
this.#e.resolutionScale = t.resolutionScale, this.#e.quality.value = t.quality, this.#e.mirrorBias.value = t.mirrorBias, this.#e.maxDistance.value = t.maxDistance, this.#e.intensity.value = t.intensity, this.#e.thickness.value = t.thickness, this.#e.maxLuminance.value = t.maxLuminance, this.#e.stepExponent = t.stepExponent, this.#e.binaryRefine = t.binaryRefine, this.#e.screenEdgeFade.value = t.screenEdgeFade, this.#e.screenEdgeFadeBlack = t.screenEdgeFadeBlack;
|
|
689
|
+
}
|
|
690
|
+
if (this.#p) {
|
|
691
|
+
const t = this.#c.temporal;
|
|
692
|
+
this.#p.maxFrames.value = t.maxFrames, this.#p.clampIntensity.value = t.clampIntensity, this.#p.flickerSuppression.value = t.flickerSuppression, this.#p.hitPointReprojection.value = t.hitPointReprojection;
|
|
693
|
+
}
|
|
694
|
+
if (this.#t) {
|
|
695
|
+
const t = this.#c.denoise;
|
|
696
|
+
this.#t.lumaPhi.value = t.lumaPhi, this.#t.depthPhi.value = t.depthPhi, this.#t.normalPhi.value = t.normalPhi, this.#t.roughnessPhi.value = t.roughnessPhi, this.#t.radius.value = t.radius, this.#t.alphaPhi.value = t.alphaPhi, this.#t.strength.value = t.strength, this.#t.adapt.value = t.adapt, this.#t.smoothDisocclusions.value = t.smoothDisocclusions, this.#t.flickerSuppression.value = t.flickerSuppression, this.#t.adaptiveTrust.value = t.adaptiveTrust;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
enableTRAA() {
|
|
700
|
+
this.#m = !0, this.#n();
|
|
701
|
+
}
|
|
702
|
+
disableTRAA() {
|
|
703
|
+
this.#m = !1, this.#f = null, this.#n();
|
|
704
|
+
}
|
|
705
|
+
#S(e) {
|
|
706
|
+
const { temporal: t, denoise: s, ...i } = e;
|
|
707
|
+
Object.assign(this.#c, i), t && Object.assign(this.#c.temporal, t), s && Object.assign(this.#c.denoise, s);
|
|
708
|
+
}
|
|
709
|
+
#n() {
|
|
710
|
+
const e = this.scenePass;
|
|
711
|
+
this.scenePass = I(this.scene, this.camera), this.#C(), this.needsUpdateOutputNode = !0, e.dispose();
|
|
712
|
+
}
|
|
713
|
+
#C() {
|
|
714
|
+
if (this.#a || this.#h || this.#i || this.#m || this.#u.size > 0) {
|
|
715
|
+
const t = { output: Ce };
|
|
716
|
+
this.#u.forEach((s, i) => {
|
|
717
|
+
i !== "output" && (t[i] = s);
|
|
718
|
+
}), this.#a && (t.emissive = Me), this.#h && (t.normal = F, this.#i || (t.ssgiDiffuse = B)), this.#i && (t.ssrDiffuse = y(B.rgb, ye), t.ssrNormal = y(we(F).rgb, Pe)), (this.#m || this.#i) && (t.velocity = Ne), this.scenePass.setMRT(Se(t)), this.#h && !this.#i && (this.scenePass.getTexture("ssgiDiffuse").type = M), this.#i && (this.scenePass.getTexture("ssrDiffuse").type = M, this.scenePass.getTexture("ssrNormal").type = M);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
#b() {
|
|
722
|
+
for (const e of this.#s)
|
|
723
|
+
e.dispose();
|
|
724
|
+
this.#s = [];
|
|
725
|
+
}
|
|
726
|
+
#x() {
|
|
727
|
+
let e = this.scenePass.getTextureNode();
|
|
728
|
+
if (this.#h)
|
|
729
|
+
if (!(this.camera instanceof v))
|
|
730
|
+
console.warn("RenderPipeline: SSGI requires a PerspectiveCamera, skipping.");
|
|
731
|
+
else {
|
|
732
|
+
const t = this.scenePass.getTextureNode(), s = this.scenePass.getTextureNode("depth"), i = this.scenePass.getTextureNode("normal"), r = this.scenePass.getTextureNode(
|
|
733
|
+
this.#i ? "ssrDiffuse" : "ssgiDiffuse"
|
|
734
|
+
), a = Ze(
|
|
735
|
+
t,
|
|
736
|
+
s,
|
|
737
|
+
i,
|
|
738
|
+
this.camera
|
|
739
|
+
);
|
|
740
|
+
a.sliceCount.value = this.#d.sliceCount, a.stepCount.value = this.#d.stepCount, a.aoIntensity.value = this.#d.aoIntensity, a.giIntensity.value = this.#d.giIntensity, a.radius.value = this.#d.radius, a.thickness.value = this.#d.thickness, this.#g = a;
|
|
741
|
+
const o = a.getAONode(), c = a.getGINode();
|
|
742
|
+
e = y(
|
|
743
|
+
e.rgb.mul(o.r).add(r.rgb.mul(c.rgb)),
|
|
744
|
+
e.a
|
|
745
|
+
), this.#s.push(a);
|
|
746
|
+
}
|
|
747
|
+
if (this.#i)
|
|
748
|
+
if (!(this.camera instanceof v))
|
|
749
|
+
console.warn("RenderPipeline: SSR requires a PerspectiveCamera, skipping.");
|
|
750
|
+
else {
|
|
751
|
+
const t = this.#c, s = this.scenePass.getTextureNode(), i = this.scenePass.getTextureNode("depth"), r = this.scenePass.getTextureNode("velocity"), a = this.scenePass.getTextureNode("ssrNormal"), o = this.scenePass.getTextureNode("ssrDiffuse"), c = z((g) => be(a.sample(g).rgb)), E = z(
|
|
752
|
+
(g) => xe(o.sample(g).a, a.sample(g).a)
|
|
753
|
+
), h = nt(
|
|
754
|
+
s,
|
|
755
|
+
i,
|
|
756
|
+
c,
|
|
757
|
+
{
|
|
758
|
+
stochastic: !0,
|
|
759
|
+
diffuseNode: o,
|
|
760
|
+
metalnessNode: o.a,
|
|
761
|
+
roughnessNode: a.a,
|
|
762
|
+
environmentNode: this.#T,
|
|
763
|
+
binaryRefine: t.binaryRefine,
|
|
764
|
+
camera: this.camera
|
|
765
|
+
}
|
|
766
|
+
);
|
|
767
|
+
h.resolutionScale = t.resolutionScale, h.quality.value = t.quality, h.mirrorBias.value = t.mirrorBias, h.maxDistance.value = t.maxDistance, h.intensity.value = t.intensity, h.thickness.value = t.thickness, h.maxLuminance.value = t.maxLuminance, h.stepExponent = t.stepExponent, h.screenEdgeFade.value = t.screenEdgeFade, h.screenEdgeFadeBlack = t.screenEdgeFadeBlack;
|
|
768
|
+
const m = t.temporal;
|
|
769
|
+
this.renderer.reversedDepthBuffer && (i.value.type = k);
|
|
770
|
+
const f = rt(
|
|
771
|
+
h,
|
|
772
|
+
i,
|
|
773
|
+
a,
|
|
774
|
+
r,
|
|
775
|
+
this.camera,
|
|
776
|
+
{
|
|
777
|
+
mode: "specular",
|
|
778
|
+
accumulate: !1,
|
|
779
|
+
hitPointReprojection: m.hitPointReprojection
|
|
780
|
+
}
|
|
781
|
+
), $ = f;
|
|
782
|
+
$._historyRenderTarget.depthTexture.type = i.value.type, f.maxFrames.value = m.maxFrames, f.clampIntensity.value = m.clampIntensity, f.flickerSuppression.value = m.flickerSuppression;
|
|
783
|
+
const u = t.denoise, l = at(
|
|
784
|
+
f,
|
|
785
|
+
this.camera,
|
|
786
|
+
{
|
|
787
|
+
depth: i,
|
|
788
|
+
normal: a,
|
|
789
|
+
raw: h,
|
|
790
|
+
metalRoughness: E,
|
|
791
|
+
mode: "specular",
|
|
792
|
+
accumulate: !0
|
|
793
|
+
}
|
|
794
|
+
);
|
|
795
|
+
l.alphaSource = "raylength", l.lumaPhi.value = u.lumaPhi, l.depthPhi.value = u.depthPhi, l.normalPhi.value = u.normalPhi, l.roughnessPhi.value = u.roughnessPhi, l.radius.value = u.radius, l.alphaPhi.value = u.alphaPhi, l.strength.value = u.strength, l.adapt.value = u.adapt, l.smoothDisocclusions.value = u.smoothDisocclusions, l.flickerSuppression.value = u.flickerSuppression, l.adaptiveTrust.value = u.adaptiveTrust, h.setHistory(l, r), f.setHistoryTexture(l), this.#e = h, this.#p = f, this.#t = l, this.#s.push(h, f, l), e = y(e.rgb.add(l.rgb), 1);
|
|
796
|
+
}
|
|
797
|
+
if (this.#a) {
|
|
798
|
+
const t = this.scenePass.getTextureNode("emissive");
|
|
799
|
+
this.#o = Oe(
|
|
800
|
+
t,
|
|
801
|
+
this.#l.strength,
|
|
802
|
+
this.#l.radius,
|
|
803
|
+
this.#l.threshold
|
|
804
|
+
), e = Re(e, this.#o), this.#s.push(this.#o);
|
|
805
|
+
}
|
|
806
|
+
return e;
|
|
807
|
+
}
|
|
808
|
+
#R(e) {
|
|
809
|
+
e ? (this.#w || (this.#P = this.outputColorTransform), this.outputColorTransform = !1) : this.#w && (this.outputColorTransform = this.#P), this.#w = e;
|
|
810
|
+
}
|
|
811
|
+
#E() {
|
|
812
|
+
this.#b();
|
|
813
|
+
let e, t = !1, s = !1;
|
|
814
|
+
const i = this.#y !== null;
|
|
815
|
+
if (i ? e = this.#y(this.scenePass) : this.#a || this.#h || this.#i ? e = this.#x() : e = this.#v.size > 0 ? this.scenePass.getTextureNode() : this.scenePass, i || this.#v.forEach((r) => {
|
|
816
|
+
t ||= r.includesTemporalAntialias === !0, s ||= r.includesOutputTransform === !0, e = r(this.scenePass, e);
|
|
817
|
+
}), this.#R(s), this.#m && !t) {
|
|
818
|
+
const r = this.scenePass.getTextureNode("depth"), a = this.scenePass.getTextureNode("velocity");
|
|
819
|
+
this.#f = Ie(e, r, a, this.camera), this.#s.push(this.#f), e = this.#f;
|
|
820
|
+
} else
|
|
821
|
+
this.#f = null;
|
|
822
|
+
this.#r.size > 0 && this.#r.forEach((r) => {
|
|
823
|
+
const a = Ee(e, r);
|
|
824
|
+
this.#s.push(a), e = a;
|
|
825
|
+
}), this.outputNode = e, this.needsUpdate = !0;
|
|
826
|
+
}
|
|
827
|
+
render() {
|
|
828
|
+
this.needsUpdateOutputNode && (this.#E(), this.needsUpdateOutputNode = !1), super.render();
|
|
829
|
+
}
|
|
830
|
+
dispose() {
|
|
831
|
+
this.#b(), this.#T.dispose(), this.scenePass.dispose(), super.dispose();
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
const ht = {
|
|
835
|
+
Vector2: O,
|
|
836
|
+
Vector3: C,
|
|
837
|
+
Vector4: te,
|
|
838
|
+
Quaternion: ee,
|
|
839
|
+
Matrix4: Z,
|
|
840
|
+
Spherical: d,
|
|
841
|
+
Box3: D,
|
|
842
|
+
Sphere: x,
|
|
843
|
+
Raycaster: U
|
|
844
|
+
};
|
|
845
|
+
H.install({ THREE: ht });
|
|
846
|
+
class lt extends H {
|
|
847
|
+
constructor(...e) {
|
|
848
|
+
super(...e), this.minDistance = 0.2, this.smoothTime = 0.2, this.dollySpeed = 0.2;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Set absolute angle for azimuth to avoid spinning
|
|
852
|
+
*/
|
|
853
|
+
absoluteRotations() {
|
|
854
|
+
this.azimuthAngle = ct(this.azimuthAngle, 0);
|
|
855
|
+
}
|
|
856
|
+
async flyToBox(e, t = {}) {
|
|
857
|
+
if (e.isEmpty())
|
|
858
|
+
return console.warn("CameraControls.flyToBox: The provided Box3 is empty."), !1;
|
|
859
|
+
this.absoluteRotations();
|
|
860
|
+
const { viewpoint: s = "frontTop", enableTransition: i = !0, padding: r = 0.1, cover: a = !1 } = t;
|
|
861
|
+
if (s !== "current") {
|
|
862
|
+
const o = s.toUpperCase(), c = L[o] ?? L.FRONTTOP, E = c.theta, h = c.phi;
|
|
863
|
+
if (await this.rotateTo(E, h, i), dt.has(o))
|
|
864
|
+
await this.fitToBox(e, i, {
|
|
865
|
+
paddingLeft: r,
|
|
866
|
+
paddingRight: r,
|
|
867
|
+
paddingTop: r,
|
|
868
|
+
paddingBottom: r,
|
|
869
|
+
cover: a
|
|
870
|
+
});
|
|
871
|
+
else {
|
|
872
|
+
const m = new x();
|
|
873
|
+
e.getBoundingSphere(m), m.radius += r, await this.fitToSphere(m, i);
|
|
874
|
+
}
|
|
875
|
+
} else {
|
|
876
|
+
const o = new x();
|
|
877
|
+
e.getBoundingSphere(o), o.radius += r, await this.fitToSphere(o, i);
|
|
878
|
+
}
|
|
879
|
+
return !0;
|
|
880
|
+
}
|
|
881
|
+
async flyToObject(e, t = {}) {
|
|
882
|
+
const s = new D().setFromObject(e);
|
|
883
|
+
return this.flyToBox(s, t);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Fly camera to a specific position and look-at target.
|
|
887
|
+
*/
|
|
888
|
+
async flyTo(e, t, s = {}) {
|
|
889
|
+
const { enableTransition: i = !0 } = s;
|
|
890
|
+
return this.absoluteRotations(), this.setLookAt(e.x, e.y, e.z, t.x, t.y, t.z, i);
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Get the current camera viewpoint data (position, target, zoom).
|
|
894
|
+
*/
|
|
895
|
+
getCameraViewpoint() {
|
|
896
|
+
const e = new C(), t = new C();
|
|
897
|
+
return this.getPosition(e), this.getTarget(t), {
|
|
898
|
+
position: { x: e.x, y: e.y, z: e.z },
|
|
899
|
+
target: { x: t.x, y: t.y, z: t.z },
|
|
900
|
+
zoom: this.camera.zoom
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Lock camera controls (disable all user interaction).
|
|
905
|
+
*/
|
|
906
|
+
lock() {
|
|
907
|
+
this.enabled = !1;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Unlock camera controls (re-enable user interaction).
|
|
911
|
+
*/
|
|
912
|
+
unlock() {
|
|
913
|
+
this.enabled = !0;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Switch between 2D top-down and 3D perspective views.
|
|
917
|
+
*/
|
|
918
|
+
async setViewMode(e, t = !0) {
|
|
919
|
+
if (e === "2d") {
|
|
920
|
+
const s = new C();
|
|
921
|
+
this.getTarget(s), await this.rotateTo(0, 0, t), this.minPolarAngle = 0, this.maxPolarAngle = 0;
|
|
922
|
+
} else
|
|
923
|
+
this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, await this.rotateTo(0, Math.PI / 4, t);
|
|
924
|
+
}
|
|
925
|
+
async setCameraViewpoint(e, t = !0) {
|
|
926
|
+
const { position: s, target: i, zoom: r = this.camera.zoom } = e;
|
|
927
|
+
return Promise.all([
|
|
928
|
+
this.zoomTo(r, t),
|
|
929
|
+
this.setLookAt(s.x, s.y, s.z, i.x, i.y, i.z, t)
|
|
930
|
+
]);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
const L = {
|
|
934
|
+
LEFT: new d(0, Math.PI / 2, -Math.PI / 2),
|
|
935
|
+
RIGHT: new d(0, Math.PI / 2, Math.PI / 2),
|
|
936
|
+
FRONT: new d(0, Math.PI / 2, 0),
|
|
937
|
+
BACK: new d(0, Math.PI / 2, Math.PI),
|
|
938
|
+
TOP: new d(0, 0, 0),
|
|
939
|
+
BOTTOM: new d(0, Math.PI, 0),
|
|
940
|
+
FRONTTOP: new d(0, Math.PI / 4, 0),
|
|
941
|
+
BACKTOP: new d(0, Math.PI / 4, Math.PI),
|
|
942
|
+
LEFTTOP: new d(0, Math.PI / 4, -Math.PI / 2),
|
|
943
|
+
RIGHTTOP: new d(0, Math.PI / 4, Math.PI / 2),
|
|
944
|
+
LEFTFRONTTOP: new d(0, Math.PI / 4, -Math.PI / 4),
|
|
945
|
+
RIGHTFRONTTOP: new d(0, Math.PI / 4, Math.PI / 4),
|
|
946
|
+
LEFTBACKTOP: new d(0, Math.PI / 4, -Math.PI / 4 * 3),
|
|
947
|
+
RIGHTBACKTOP: new d(0, Math.PI / 4, Math.PI / 4 * 3)
|
|
948
|
+
}, dt = /* @__PURE__ */ new Set(["LEFT", "RIGHT", "FRONT", "BACK", "TOP", "BOTTOM"]);
|
|
949
|
+
function ct(n, e) {
|
|
950
|
+
const t = n - e;
|
|
951
|
+
return se.euclideanModulo(t + Math.PI, Math.PI * 2) - Math.PI;
|
|
952
|
+
}
|
|
953
|
+
class pt {
|
|
954
|
+
environment = new Be();
|
|
955
|
+
renderer;
|
|
956
|
+
pmremGenerator;
|
|
957
|
+
envMap = null;
|
|
958
|
+
constructor(e) {
|
|
959
|
+
this.renderer = e, this.pmremGenerator = new ie(e);
|
|
960
|
+
}
|
|
961
|
+
update() {
|
|
962
|
+
this.envMap || (this.envMap = this.pmremGenerator.fromScene(this.environment).texture);
|
|
963
|
+
}
|
|
964
|
+
dispose() {
|
|
965
|
+
this.pmremGenerator.dispose(), this.envMap?.dispose();
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
const S = 128;
|
|
969
|
+
class ut extends Fe {
|
|
970
|
+
viewer;
|
|
971
|
+
overlayPass;
|
|
972
|
+
constructor(e) {
|
|
973
|
+
super(e.camera, e.el), this.viewer = e;
|
|
974
|
+
const t = new b(-2, 2, 2, -2, 0, 4);
|
|
975
|
+
t.position.set(0, 0, 2), this.overlayPass = I(this, t), this.setLabels("x", "y", "z");
|
|
976
|
+
}
|
|
977
|
+
_update = () => {
|
|
978
|
+
this.quaternion.copy(this.viewer.camera.quaternion).invert();
|
|
979
|
+
const e = this.location;
|
|
980
|
+
let t, s;
|
|
981
|
+
e.left !== null ? t = e.left : t = this.viewer.el.offsetWidth - S - e.right, e.top !== null ? s = e.top : s = this.viewer.el.offsetHeight - S - e.bottom, this.overlayPass.setViewport(t, s, S, S);
|
|
982
|
+
};
|
|
983
|
+
enable() {
|
|
984
|
+
return this.viewer.renderPipeline.addOverlayPass(this.overlayPass), this.viewer.addEventListener("beforeRender", this._update), this.viewer.invalidate(), this;
|
|
985
|
+
}
|
|
986
|
+
disable() {
|
|
987
|
+
return this.viewer.renderPipeline.removeOverlayPass(this.overlayPass), this.viewer.removeEventListener("beforeRender", this._update), this.viewer.invalidate(), this;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
const q = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;overflow:hidden;", mt = q + "z-index:0;", ft = q + "z-index:1;";
|
|
991
|
+
class vt {
|
|
992
|
+
el;
|
|
993
|
+
css2dRenderer = null;
|
|
994
|
+
css3dRenderer = null;
|
|
995
|
+
constructor(e) {
|
|
996
|
+
this.el = e, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
997
|
+
}
|
|
998
|
+
initCSS2DRenderer() {
|
|
999
|
+
const e = new ze();
|
|
1000
|
+
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = ft, this.el.appendChild(e.domElement), this.css2dRenderer = e, e;
|
|
1001
|
+
}
|
|
1002
|
+
initCSS3DRenderer() {
|
|
1003
|
+
const e = new Le();
|
|
1004
|
+
return e.setSize(this.el.clientWidth, this.el.clientHeight), e.domElement.style.cssText = mt, this.el.appendChild(e.domElement), this.css3dRenderer = e, e;
|
|
1005
|
+
}
|
|
1006
|
+
createCSS2DObject(e) {
|
|
1007
|
+
return this.css2dRenderer || this.initCSS2DRenderer(), new Ae(e);
|
|
1008
|
+
}
|
|
1009
|
+
createCSS25DObject(e) {
|
|
1010
|
+
return this.css3dRenderer || this.initCSS3DRenderer(), new Ue(e);
|
|
1011
|
+
}
|
|
1012
|
+
createCSS3DObject(e) {
|
|
1013
|
+
return this.css3dRenderer || this.initCSS3DRenderer(), new Ge(e);
|
|
1014
|
+
}
|
|
1015
|
+
render(e, t) {
|
|
1016
|
+
this.css2dRenderer && this.css2dRenderer.render(e, t), this.css3dRenderer && this.css3dRenderer.render(e, t);
|
|
1017
|
+
}
|
|
1018
|
+
resize(e, t) {
|
|
1019
|
+
this.css2dRenderer && this.css2dRenderer.setSize(e, t), this.css3dRenderer && this.css3dRenderer.setSize(e, t);
|
|
1020
|
+
}
|
|
1021
|
+
dispose() {
|
|
1022
|
+
this.css2dRenderer && (this.el.removeChild(this.css2dRenderer.domElement), this.css2dRenderer = null), this.css3dRenderer && (this.el.removeChild(this.css3dRenderer.domElement), this.css3dRenderer = null);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
const gt = "timestamp-query";
|
|
1026
|
+
class Tt {
|
|
1027
|
+
el;
|
|
1028
|
+
renderer;
|
|
1029
|
+
container;
|
|
1030
|
+
drawCallsText;
|
|
1031
|
+
frameCallsText;
|
|
1032
|
+
trianglesText;
|
|
1033
|
+
pointsText;
|
|
1034
|
+
linesText;
|
|
1035
|
+
timestampText;
|
|
1036
|
+
_enabled = !1;
|
|
1037
|
+
#r = !1;
|
|
1038
|
+
constructor(e, t) {
|
|
1039
|
+
this.el = e, this.renderer = t;
|
|
1040
|
+
const s = document.createElement("div");
|
|
1041
|
+
s.style.position = "absolute", s.style.left = "12px", s.style.bottom = "12px", s.style.fontSize = "12px", s.style.color = "#fff", s.style.pointerEvents = "none", this.container = s;
|
|
1042
|
+
function i(a, o = !0) {
|
|
1043
|
+
const c = document.createElement("span");
|
|
1044
|
+
return o && (c.style.marginLeft = "6px"), c.innerText = a, c;
|
|
1045
|
+
}
|
|
1046
|
+
function r() {
|
|
1047
|
+
return document.createElement("br");
|
|
1048
|
+
}
|
|
1049
|
+
this.drawCallsText = i("0"), this.frameCallsText = i("0"), this.trianglesText = i("0"), this.linesText = i("0"), this.pointsText = i("0"), this.timestampText = i("0"), this.container.appendChild(i("draw calls", !1)), this.container.appendChild(this.drawCallsText), this.container.appendChild(r()), this.container.appendChild(i("frame calls", !1)), this.container.appendChild(this.frameCallsText), this.container.appendChild(r()), this.container.appendChild(i("triangles", !1)), this.container.appendChild(this.trianglesText), this.container.appendChild(r()), this.container.appendChild(i("points", !1)), this.container.appendChild(this.pointsText), this.container.appendChild(r()), this.container.appendChild(i("lines", !1)), this.container.appendChild(this.linesText), this.container.appendChild(r()), this.container.appendChild(i("timestamp", !1)), this.container.appendChild(this.timestampText), this.container.appendChild(r());
|
|
1050
|
+
}
|
|
1051
|
+
update() {
|
|
1052
|
+
if (this._enabled) {
|
|
1053
|
+
const { render: e } = this.renderer.info;
|
|
1054
|
+
if (this.drawCallsText.innerText = e.drawCalls.toString(), this.frameCallsText.innerText = e.frameCalls.toString(), this.trianglesText.innerText = e.triangles.toString(), this.pointsText.innerText = e.points.toString(), this.linesText.innerText = e.lines.toString(), !this.#r) {
|
|
1055
|
+
this.timestampText.innerText = "0";
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
this.#o(T.RENDER).then((t) => {
|
|
1059
|
+
this._enabled && (this.timestampText.innerText = t?.toFixed(2) ?? "0");
|
|
1060
|
+
}), this.#o(T.COMPUTE);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
enable() {
|
|
1064
|
+
this._enabled = !0, this.#l(!0), this.el.appendChild(this.container);
|
|
1065
|
+
}
|
|
1066
|
+
disable() {
|
|
1067
|
+
this._enabled = !1, this.#l(!1), this.#h(), this.container.remove();
|
|
1068
|
+
}
|
|
1069
|
+
dispose() {
|
|
1070
|
+
this.disable();
|
|
1071
|
+
}
|
|
1072
|
+
#s() {
|
|
1073
|
+
return this.renderer.backend;
|
|
1074
|
+
}
|
|
1075
|
+
#a() {
|
|
1076
|
+
try {
|
|
1077
|
+
return this.renderer.hasFeature(gt);
|
|
1078
|
+
} catch {
|
|
1079
|
+
return !0;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
#l(e) {
|
|
1083
|
+
const t = this.#s();
|
|
1084
|
+
if (!t) {
|
|
1085
|
+
this.#r = !1;
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
t.trackTimestamp = e && this.#a(), this.#r = t.trackTimestamp === !0;
|
|
1089
|
+
}
|
|
1090
|
+
#o(e) {
|
|
1091
|
+
const t = this.#s()?.timestampQueryPool?.[e];
|
|
1092
|
+
return t?.resolveQueriesAsync ? Promise.resolve(t.resolveQueriesAsync()).catch(() => {
|
|
1093
|
+
}) : Promise.resolve(void 0);
|
|
1094
|
+
}
|
|
1095
|
+
#h() {
|
|
1096
|
+
this.#o(T.RENDER), this.#o(T.COMPUTE);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function yt(n, e = 1) {
|
|
1100
|
+
return Number.isFinite(e) ? Math.max(n, Math.max(0, Math.ceil(e))) : n;
|
|
1101
|
+
}
|
|
1102
|
+
ne.enabled = !0;
|
|
1103
|
+
class kt extends re {
|
|
1104
|
+
el;
|
|
1105
|
+
renderer;
|
|
1106
|
+
scene;
|
|
1107
|
+
camera;
|
|
1108
|
+
info;
|
|
1109
|
+
controls;
|
|
1110
|
+
renderPipeline;
|
|
1111
|
+
timer;
|
|
1112
|
+
roomEnvironment;
|
|
1113
|
+
interactionManager;
|
|
1114
|
+
objectManager;
|
|
1115
|
+
viewerHelper;
|
|
1116
|
+
cssRenderer;
|
|
1117
|
+
frameCount = 1;
|
|
1118
|
+
frameloop = "demand";
|
|
1119
|
+
constructor({ el: e, rendererOptions: t, pixelRatio: s }) {
|
|
1120
|
+
super(), this.el = e, this.renderer = this._initRenderer(t, s), this.scene = this.createScene(), this.camera = this.createPerspectiveCamera(), this.info = new Tt(this.el, this.renderer), this.controls = new lt(this.camera, this.renderer.domElement), this.renderPipeline = new ot(this.renderer, this.scene, this.camera), this.timer = new ae(), this.roomEnvironment = new pt(this.renderer), this.interactionManager = new Ve(this.renderer.domElement, this.scene, this.camera), this.objectManager = new Ye(), this.viewerHelper = new ut(this), this.cssRenderer = new vt(this.el), window.addEventListener("resize", this.onWindowResize);
|
|
1121
|
+
}
|
|
1122
|
+
onWindowResize = () => {
|
|
1123
|
+
const e = this.el.clientWidth, t = this.el.clientHeight;
|
|
1124
|
+
this.camera instanceof v ? (this.camera.aspect = e / t, this.camera.updateProjectionMatrix()) : this.camera instanceof b && (this.camera.left = -e / 2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = -t / 2, this.camera.updateProjectionMatrix()), this.renderer.setSize(e, t), this.cssRenderer.resize(e, t), this.invalidate();
|
|
1125
|
+
};
|
|
1126
|
+
async init() {
|
|
1127
|
+
await this.renderer.init(), this.roomEnvironment.update(), this.scene.environment = this.roomEnvironment.envMap;
|
|
1128
|
+
}
|
|
1129
|
+
setCamera(e) {
|
|
1130
|
+
this.camera = e, this.controls.camera = e, this.interactionManager.setCamera(e), this.renderPipeline.setCamera(e), this.onWindowResize(), this.dispatchEvent({ type: "cameraChange", camera: e });
|
|
1131
|
+
}
|
|
1132
|
+
setCameraByType(e) {
|
|
1133
|
+
e === "perspective" && !(this.camera instanceof v) ? this.setCamera(this.createPerspectiveCamera()) : e === "orthographic" && !(this.camera instanceof b) && this.setCamera(this.createOrthographicCamera());
|
|
1134
|
+
}
|
|
1135
|
+
invalidate(e = 1) {
|
|
1136
|
+
this.frameCount = yt(this.frameCount, e);
|
|
1137
|
+
}
|
|
1138
|
+
render(e = 1) {
|
|
1139
|
+
return this.invalidate(e), new Promise((t) => {
|
|
1140
|
+
const s = () => {
|
|
1141
|
+
this.removeEventListener("afterRender", s), t();
|
|
1142
|
+
};
|
|
1143
|
+
this.addEventListener("afterRender", s);
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
animate = (e) => {
|
|
1147
|
+
this.timer.update(e);
|
|
1148
|
+
const t = this.timer.getDelta();
|
|
1149
|
+
this.dispatchEvent({ type: "beforeControlsUpdate", time: e, delta: t });
|
|
1150
|
+
let s = this.controls.update(t);
|
|
1151
|
+
this.dispatchEvent({ type: "afterControlsUpdate", time: e, delta: t }), this.frameCount > 0 && (this.frameCount--, s = !0), this.frameloop === "always" && (s = !0), s && (this.dispatchEvent({ type: "beforeRender", time: e, delta: t }), this.renderer.info.reset(), this.renderPipeline.render(), this.cssRenderer.render(this.scene, this.camera), this.info.update(), this.dispatchEvent({ type: "afterRender", time: e, delta: t }));
|
|
1152
|
+
};
|
|
1153
|
+
_initRenderer(e, t = Math.min(window.devicePixelRatio, 1.5)) {
|
|
1154
|
+
const s = new oe({
|
|
1155
|
+
reversedDepthBuffer: !0,
|
|
1156
|
+
antialias: !1,
|
|
1157
|
+
depth: !1,
|
|
1158
|
+
trackTimestamp: !1,
|
|
1159
|
+
...e
|
|
1160
|
+
});
|
|
1161
|
+
return s.setPixelRatio(t), s.setSize(this.el.clientWidth, this.el.clientHeight), s.shadowMap.enabled = !0, s.shadowMap.type = he, s.toneMapping = le, s.toneMappingExposure = 1, s.info.autoReset = !1, s.setAnimationLoop(this.animate), this.el.appendChild(s.domElement), s;
|
|
1162
|
+
}
|
|
1163
|
+
createScene() {
|
|
1164
|
+
const e = new de();
|
|
1165
|
+
return e.background = new N(0), e;
|
|
1166
|
+
}
|
|
1167
|
+
createPerspectiveCamera() {
|
|
1168
|
+
const e = new v(50, this.el.clientWidth / this.el.clientHeight, 0.1, 1e5);
|
|
1169
|
+
return e.position.setScalar(5), e;
|
|
1170
|
+
}
|
|
1171
|
+
createOrthographicCamera() {
|
|
1172
|
+
const e = new b(
|
|
1173
|
+
-this.el.clientWidth / 2,
|
|
1174
|
+
this.el.clientWidth / 2,
|
|
1175
|
+
this.el.clientHeight / 2,
|
|
1176
|
+
-this.el.clientHeight / 2,
|
|
1177
|
+
0.1,
|
|
1178
|
+
1e5
|
|
1179
|
+
);
|
|
1180
|
+
return e.position.setScalar(5), e;
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Manually trigger a resize update.
|
|
1184
|
+
*/
|
|
1185
|
+
resize(e, t) {
|
|
1186
|
+
e !== void 0 && t !== void 0 && (this.el.style.width = `${e}px`, this.el.style.height = `${t}px`), this.onWindowResize();
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Capture a screenshot of the current render.
|
|
1190
|
+
*/
|
|
1191
|
+
async screenshot(e = {}) {
|
|
1192
|
+
const { type: t = "image/png", quality: s = 1 } = e, i = this.el.clientWidth, r = this.el.clientHeight, a = e.width && e.height;
|
|
1193
|
+
a && this.renderer.setSize(e.width, e.height), await this.render();
|
|
1194
|
+
const o = this.renderer.domElement.toDataURL(t, s);
|
|
1195
|
+
return a && (this.renderer.setSize(i, r), this.onWindowResize()), o;
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Set the scene background color, texture, or null.
|
|
1199
|
+
*/
|
|
1200
|
+
setBackground(e) {
|
|
1201
|
+
e === null ? this.scene.background = null : e instanceof N || typeof e == "number" || typeof e == "string" ? this.scene.background = new N(e) : this.scene.background = e, this.invalidate();
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Set the scene environment map for reflections / IBL.
|
|
1205
|
+
*/
|
|
1206
|
+
setEnvironment(e) {
|
|
1207
|
+
this.scene.environment = e, this.invalidate();
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Enable shadow rendering.
|
|
1211
|
+
*/
|
|
1212
|
+
enableShadow() {
|
|
1213
|
+
this.renderer.shadowMap.enabled = !0, this.invalidate();
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Disable shadow rendering.
|
|
1217
|
+
*/
|
|
1218
|
+
disableShadow() {
|
|
1219
|
+
this.renderer.shadowMap.enabled = !1, this.invalidate();
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Enable linear fog.
|
|
1223
|
+
*/
|
|
1224
|
+
enableFog(e = {}) {
|
|
1225
|
+
const { color: t = 13421772, near: s = 10, far: i = 100 } = e;
|
|
1226
|
+
this.scene.fog = new ce(t, s, i), this.invalidate();
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Enable exponential fog.
|
|
1230
|
+
*/
|
|
1231
|
+
enableFogExp2(e = {}) {
|
|
1232
|
+
const { color: t = 13421772, density: s = 0.01 } = e;
|
|
1233
|
+
this.scene.fog = new pe(t, s), this.invalidate();
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Disable fog.
|
|
1237
|
+
*/
|
|
1238
|
+
disableFog() {
|
|
1239
|
+
this.scene.fog = null, this.invalidate();
|
|
1240
|
+
}
|
|
1241
|
+
dispose() {
|
|
1242
|
+
this.el.removeChild(this.renderer.domElement), window.removeEventListener("resize", this.onWindowResize), this.info.dispose(), this.interactionManager.dispose(), this.roomEnvironment.dispose(), this.cssRenderer.dispose(), this.renderPipeline.dispose(), this.renderer.dispose();
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
export {
|
|
1246
|
+
vt as C,
|
|
1247
|
+
He as I,
|
|
1248
|
+
Ye as O,
|
|
1249
|
+
ot as R,
|
|
1250
|
+
kt as V,
|
|
1251
|
+
lt as a,
|
|
1252
|
+
Ve as b,
|
|
1253
|
+
pt as c,
|
|
1254
|
+
jt as e,
|
|
1255
|
+
$e as g
|
|
1256
|
+
};
|