@nebula-spatial/viewer 0.4.1 → 0.4.3
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/CHANGELOG.md +30 -0
- package/FBX-MATERIAL-CONVERSION.md +97 -0
- package/README.md +115 -6
- package/dist/assets/types.d.ts +16 -0
- package/dist/{index-D0lW4RQP.js → index-BDo6voB2.js} +618 -524
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mjcf-visual--X39MVO9.js +63 -0
- package/dist/session-1duLyM88.js +964 -0
- package/dist/session-DhZXy40-.js +653 -0
- package/dist/{stage-CFr9ZkwQ.js → stage-BKqg5vNe.js} +137 -134
- package/dist/urdf-session-C_LAfkkM.js +439 -0
- package/dist/usd-session-zyj46Bcg.js +1192 -0
- package/package.json +2 -1
- package/dist/session-B4uKXhdV.js +0 -266
- package/dist/session-DNMxzxd5.js +0 -762
- package/dist/usd-session-DDWM5msM.js +0 -522
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var b = (u, t, e) => t in u ? y(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
|
|
3
|
+
var a = (u, t, e) => b(u, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import * as o from "three";
|
|
5
|
-
import { V as p } from "./index-
|
|
6
|
-
const
|
|
5
|
+
import { V as p } from "./index-BDo6voB2.js";
|
|
6
|
+
const v = 1, M = (
|
|
7
7
|
/* glsl */
|
|
8
8
|
`
|
|
9
9
|
uniform mat4 textureMatrix;
|
|
@@ -19,7 +19,7 @@ const x = 1, b = (
|
|
|
19
19
|
gl_Position = projectionMatrix * mvPosition;
|
|
20
20
|
}
|
|
21
21
|
`
|
|
22
|
-
),
|
|
22
|
+
), w = (
|
|
23
23
|
/* glsl */
|
|
24
24
|
`
|
|
25
25
|
uniform sampler2D tDiffuse;
|
|
@@ -86,18 +86,18 @@ const x = 1, b = (
|
|
|
86
86
|
}
|
|
87
87
|
`
|
|
88
88
|
);
|
|
89
|
-
class
|
|
90
|
-
constructor({ size:
|
|
91
|
-
const s = new o.Matrix4(),
|
|
89
|
+
class P extends o.Mesh {
|
|
90
|
+
constructor({ size: e = 20, textureWidth: i = 512, textureHeight: r = 512 } = {}) {
|
|
91
|
+
const s = new o.Matrix4(), l = new o.WebGLRenderTarget(i, r, {
|
|
92
92
|
type: o.HalfFloatType,
|
|
93
93
|
minFilter: o.LinearFilter,
|
|
94
94
|
magFilter: o.LinearFilter,
|
|
95
95
|
format: o.RGBAFormat,
|
|
96
96
|
depthBuffer: !0,
|
|
97
97
|
samples: 0
|
|
98
|
-
}),
|
|
98
|
+
}), n = new o.ShaderMaterial({
|
|
99
99
|
uniforms: {
|
|
100
|
-
tDiffuse: { value:
|
|
100
|
+
tDiffuse: { value: l.texture },
|
|
101
101
|
textureMatrix: { value: s },
|
|
102
102
|
resolution: { value: new o.Vector2(i, r) },
|
|
103
103
|
fineGridColor: { value: new o.Color(2502702) },
|
|
@@ -107,17 +107,17 @@ class w extends o.Mesh {
|
|
|
107
107
|
gridOpacity: { value: 1 },
|
|
108
108
|
gridScale: { value: 0.2 },
|
|
109
109
|
groundCenter: { value: new o.Vector2() },
|
|
110
|
-
maxRadius: { value:
|
|
111
|
-
fadeSoftness: { value:
|
|
110
|
+
maxRadius: { value: e * 0.5 },
|
|
111
|
+
fadeSoftness: { value: e * 0.325 }
|
|
112
112
|
},
|
|
113
|
-
vertexShader:
|
|
114
|
-
fragmentShader:
|
|
113
|
+
vertexShader: M,
|
|
114
|
+
fragmentShader: w,
|
|
115
115
|
transparent: !0,
|
|
116
116
|
depthWrite: !1,
|
|
117
117
|
toneMapped: !0,
|
|
118
118
|
fog: !1
|
|
119
119
|
});
|
|
120
|
-
super(new o.PlaneGeometry(
|
|
120
|
+
super(new o.PlaneGeometry(e, e), n);
|
|
121
121
|
a(this, "renderTarget");
|
|
122
122
|
a(this, "textureMatrix");
|
|
123
123
|
a(this, "virtualCamera");
|
|
@@ -132,9 +132,9 @@ class w extends o.Mesh {
|
|
|
132
132
|
a(this, "view");
|
|
133
133
|
a(this, "target");
|
|
134
134
|
a(this, "q");
|
|
135
|
-
this.renderTarget =
|
|
135
|
+
this.renderTarget = l, this.textureMatrix = s, this.virtualCamera = new o.PerspectiveCamera(), this.virtualCamera.layers.set(v), this.clipBias = 3e-3, this.frustumCulled = !1, this.renderOrder = 1, this.position.z = 2e-3, this.reflectorPlane = new o.Plane(), this.normal = new o.Vector3(), this.reflectorWorldPosition = new o.Vector3(), this.cameraWorldPosition = new o.Vector3(), this.rotationMatrix = new o.Matrix4(), this.lookAtPosition = new o.Vector3(0, 0, -1), this.clipPlane = new o.Vector4(), this.view = new o.Vector3(), this.target = new o.Vector3(), this.q = new o.Vector4();
|
|
136
136
|
}
|
|
137
|
-
renderReflection(
|
|
137
|
+
renderReflection(e, i, r) {
|
|
138
138
|
if (this.reflectorWorldPosition.setFromMatrixPosition(this.matrixWorld), this.cameraWorldPosition.setFromMatrixPosition(r.matrixWorld), this.rotationMatrix.extractRotation(this.matrixWorld), this.normal.set(0, 0, 1).applyMatrix4(this.rotationMatrix), this.view.subVectors(this.reflectorWorldPosition, this.cameraWorldPosition), this.view.dot(this.normal) > 0) return;
|
|
139
139
|
this.view.reflect(this.normal).negate().add(this.reflectorWorldPosition), this.rotationMatrix.extractRotation(r.matrixWorld), this.lookAtPosition.set(0, 0, -1).applyMatrix4(this.rotationMatrix).add(this.cameraWorldPosition), this.target.subVectors(this.reflectorWorldPosition, this.lookAtPosition).reflect(this.normal).negate().add(this.reflectorWorldPosition), this.virtualCamera.position.copy(this.view), this.virtualCamera.up.set(0, 1, 0).applyMatrix4(this.rotationMatrix).reflect(this.normal), this.virtualCamera.lookAt(this.target), this.virtualCamera.near = r.near, this.virtualCamera.far = r.far, this.virtualCamera.updateMatrixWorld(), this.virtualCamera.projectionMatrix.copy(r.projectionMatrix), this.textureMatrix.set(
|
|
140
140
|
0.5,
|
|
@@ -166,19 +166,19 @@ class w extends o.Mesh {
|
|
|
166
166
|
-1,
|
|
167
167
|
(1 + s.elements[10]) / s.elements[14]
|
|
168
168
|
), this.clipPlane.multiplyScalar(2 / this.clipPlane.dot(this.q)), s.elements[2] = this.clipPlane.x, s.elements[6] = this.clipPlane.y, s.elements[10] = this.clipPlane.z + 1 - this.clipBias, s.elements[14] = this.clipPlane.w, this.virtualCamera.projectionMatrixInverse.copy(s).invert();
|
|
169
|
-
const
|
|
169
|
+
const l = e.getRenderTarget(), n = e.xr.enabled, c = e.shadowMap.autoUpdate, d = e.shadowMap.enabled;
|
|
170
170
|
try {
|
|
171
|
-
|
|
171
|
+
e.xr.enabled = !1, e.shadowMap.enabled = !1, e.shadowMap.autoUpdate = !1, e.setRenderTarget(this.renderTarget), e.state.buffers.depth.setMask(!0), e.clear(), e.render(i, this.virtualCamera);
|
|
172
172
|
} finally {
|
|
173
|
-
|
|
173
|
+
e.setRenderTarget(l), e.xr.enabled = n, e.shadowMap.enabled = d, e.shadowMap.autoUpdate = c;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
setRenderSize(
|
|
177
|
-
this.renderTarget.setSize(
|
|
176
|
+
setRenderSize(e, i) {
|
|
177
|
+
this.renderTarget.setSize(e, i), this.material.uniforms.resolution.value.set(e, i);
|
|
178
178
|
}
|
|
179
179
|
// Radius is in world units; the outer 65% fades before the square mesh edge.
|
|
180
|
-
setRadius(
|
|
181
|
-
this.scale.setScalar(
|
|
180
|
+
setRadius(e, i, r = this.material.uniforms.groundCenter.value) {
|
|
181
|
+
this.scale.setScalar(e * 2 / this.geometry.parameters.width), this.position.x = r.x, this.position.y = r.y, this.material.uniforms.groundCenter.value.set(r.x, r.y), this.material.uniforms.gridScale.value = i, this.material.uniforms.maxRadius.value = e, this.material.uniforms.fadeSoftness.value = e * 0.65;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
const g = {
|
|
@@ -196,45 +196,47 @@ const g = {
|
|
|
196
196
|
gridOpacity: 0.9,
|
|
197
197
|
reflectionMix: 0.06
|
|
198
198
|
}
|
|
199
|
-
},
|
|
199
|
+
}, C = {
|
|
200
200
|
simulation: 0.68,
|
|
201
201
|
model: 1.4
|
|
202
202
|
};
|
|
203
|
-
function
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
for (const
|
|
210
|
-
if (
|
|
211
|
-
|
|
212
|
-
for (const
|
|
213
|
-
|
|
214
|
-
i.add(d);
|
|
215
|
-
const h = (l = d.source) == null ? void 0 : l.data;
|
|
216
|
-
h && typeof h.close == "function" && r.add(h);
|
|
217
|
-
}
|
|
203
|
+
function x(u, t = []) {
|
|
204
|
+
var l;
|
|
205
|
+
const e = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), r = new Set(t), s = /* @__PURE__ */ new Set();
|
|
206
|
+
u.traverse((n) => {
|
|
207
|
+
const c = n;
|
|
208
|
+
c.geometry && e.add(c.geometry);
|
|
209
|
+
for (const d of Array.isArray(c.material) ? c.material : [c.material])
|
|
210
|
+
if (d) {
|
|
211
|
+
i.add(d);
|
|
212
|
+
for (const h of Object.values(d))
|
|
213
|
+
S(h) && r.add(h);
|
|
218
214
|
}
|
|
219
215
|
});
|
|
220
|
-
for (const
|
|
221
|
-
for (const
|
|
222
|
-
for (const
|
|
223
|
-
|
|
216
|
+
for (const n of e) n.dispose();
|
|
217
|
+
for (const n of i) n.dispose();
|
|
218
|
+
for (const n of r) {
|
|
219
|
+
const c = (l = n.source) == null ? void 0 : l.data;
|
|
220
|
+
c && typeof c.close == "function" && s.add(c), n.dispose();
|
|
221
|
+
}
|
|
222
|
+
for (const n of s) n.close();
|
|
224
223
|
}
|
|
225
|
-
function S(
|
|
226
|
-
return !!(
|
|
224
|
+
function S(u) {
|
|
225
|
+
return !!(u && typeof u == "object" && u.isTexture);
|
|
227
226
|
}
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
const F = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
228
|
+
__proto__: null,
|
|
229
|
+
disposeModelResources: x
|
|
230
|
+
}, Symbol.toStringTag, { value: "Module" })), f = 2213822, G = 6000111, R = 6;
|
|
231
|
+
function T(u, t, e) {
|
|
232
|
+
t.updateMatrixWorld();
|
|
231
233
|
const i = new o.Vector3();
|
|
232
|
-
return
|
|
234
|
+
return t.getWorldDirection(i).normalize(), u.setFromNormalAndCoplanarPoint(i, e);
|
|
233
235
|
}
|
|
234
|
-
class
|
|
235
|
-
constructor(
|
|
236
|
+
class W {
|
|
237
|
+
constructor(t, e = "dark", i, r = "simulation") {
|
|
236
238
|
a(this, "root", new o.Group());
|
|
237
|
-
a(this, "reflector", new
|
|
239
|
+
a(this, "reflector", new P({ size: 100, textureWidth: 256, textureHeight: 256 }));
|
|
238
240
|
a(this, "values");
|
|
239
241
|
a(this, "fog");
|
|
240
242
|
a(this, "raycaster", new o.Raycaster());
|
|
@@ -252,24 +254,24 @@ class F {
|
|
|
252
254
|
a(this, "size", "");
|
|
253
255
|
a(this, "groundVisible");
|
|
254
256
|
a(this, "disposed", !1);
|
|
255
|
-
this.model =
|
|
256
|
-
const s = this.values,
|
|
257
|
-
if (!Number.isFinite(
|
|
258
|
-
this.root.add(
|
|
259
|
-
m instanceof o.Mesh && m.layers.enable(
|
|
257
|
+
this.model = t, this.runtime = i, this.presentation = r, this.values = g[e];
|
|
258
|
+
const s = this.values, l = new o.Box3().setFromObject(t), n = Math.max(...l.getSize(new o.Vector3()).toArray());
|
|
259
|
+
if (!Number.isFinite(n) || n <= 0) throw new Error("Empty simulation geometry.");
|
|
260
|
+
this.root.add(t), this.forceLine = this.createForceLine(), this.root.add(this.forceLine), t.traverse((m) => {
|
|
261
|
+
m instanceof o.Mesh && m.layers.enable(v);
|
|
260
262
|
}), this.root.add(this.reflector);
|
|
261
|
-
const
|
|
262
|
-
d.fineGridColor.value.setHex(s.fineGrid), d.coarseGridColor.value.setHex(s.coarseGrid), d.gridOpacity.value = s.gridOpacity, d.reflectionMix.value = s.reflectionMix, this.layoutGround(
|
|
263
|
-
const h =
|
|
263
|
+
const c = Math.max(l.getSize(new o.Vector3()).length() * 0.5, 0.02), d = this.reflector.material.uniforms;
|
|
264
|
+
d.fineGridColor.value.setHex(s.fineGrid), d.coarseGridColor.value.setHex(s.coarseGrid), d.gridOpacity.value = s.gridOpacity, d.reflectionMix.value = s.reflectionMix, this.layoutGround(l, c), this.groundVisible = r === "simulation", this.setGroundVisible(this.groundVisible);
|
|
265
|
+
const h = c / Math.sin(o.MathUtils.degToRad(38) / 2) * 1.25;
|
|
264
266
|
this.fog = new o.Fog(s.background, h * 2.5, h * 8);
|
|
265
267
|
}
|
|
266
|
-
setTheme(
|
|
268
|
+
setTheme(t) {
|
|
267
269
|
if (this.disposed) return;
|
|
268
|
-
const
|
|
269
|
-
i.fineGridColor.value.setHex(
|
|
270
|
+
const e = this.values = g[t], i = this.reflector.material.uniforms;
|
|
271
|
+
i.fineGridColor.value.setHex(e.fineGrid), i.coarseGridColor.value.setHex(e.coarseGrid), i.gridOpacity.value = e.gridOpacity, i.reflectionMix.value = e.reflectionMix, this.fog.color.setHex(e.background);
|
|
270
272
|
}
|
|
271
|
-
layoutGround(
|
|
272
|
-
this.reflector.setRadius(
|
|
273
|
+
layoutGround(t, e) {
|
|
274
|
+
this.reflector.setRadius(e * 8, Math.pow(10, Math.floor(Math.log10(Math.max(e, 0.01)))), t.getCenter(new o.Vector3()));
|
|
273
275
|
}
|
|
274
276
|
/**
|
|
275
277
|
* Re-fits the ground disc and reflection to the model's current world bounds.
|
|
@@ -280,67 +282,67 @@ class F {
|
|
|
280
282
|
reseatGround() {
|
|
281
283
|
if (this.disposed) return;
|
|
282
284
|
this.root.updateMatrixWorld(!0);
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
+
const t = new o.Box3().setFromObject(this.model);
|
|
286
|
+
t.isEmpty() || this.layoutGround(t, Math.max(t.getSize(new o.Vector3()).length() * 0.5, 0.02));
|
|
285
287
|
}
|
|
286
288
|
createForceLine() {
|
|
287
|
-
const
|
|
289
|
+
const t = new o.BufferGeometry().setFromPoints([
|
|
288
290
|
new o.Vector3(),
|
|
289
291
|
new o.Vector3()
|
|
290
|
-
]),
|
|
292
|
+
]), e = new o.LineBasicMaterial({
|
|
291
293
|
color: f,
|
|
292
294
|
depthTest: !1,
|
|
293
295
|
transparent: !0
|
|
294
|
-
}), i = new o.Line(
|
|
296
|
+
}), i = new o.Line(t, e);
|
|
295
297
|
return i.renderOrder = 1e3, i.visible = !1, i;
|
|
296
298
|
}
|
|
297
|
-
findBodyGroup(
|
|
299
|
+
findBodyGroup(t) {
|
|
298
300
|
var i;
|
|
299
|
-
let
|
|
300
|
-
for (;
|
|
301
|
-
if (typeof ((i =
|
|
302
|
-
|
|
301
|
+
let e = t;
|
|
302
|
+
for (; e && e !== this.model && e !== this.root; ) {
|
|
303
|
+
if (typeof ((i = e.userData) == null ? void 0 : i.bodyId) == "number") return e;
|
|
304
|
+
e = e.parent;
|
|
303
305
|
}
|
|
304
306
|
return null;
|
|
305
307
|
}
|
|
306
|
-
getBodyGroup(
|
|
307
|
-
let
|
|
308
|
-
return
|
|
308
|
+
getBodyGroup(t) {
|
|
309
|
+
let e = this.bodyGroups.get(t);
|
|
310
|
+
return e || this.model.traverse((i) => {
|
|
309
311
|
var r;
|
|
310
|
-
((r = i.userData) == null ? void 0 : r.bodyId) ===
|
|
311
|
-
}),
|
|
312
|
+
((r = i.userData) == null ? void 0 : r.bodyId) === t && (e = i, this.bodyGroups.set(t, i));
|
|
313
|
+
}), e;
|
|
312
314
|
}
|
|
313
|
-
pointerRay(
|
|
315
|
+
pointerRay(t, e, i) {
|
|
314
316
|
const r = i.getBoundingClientRect();
|
|
315
317
|
this.pointer.set(
|
|
316
|
-
(
|
|
317
|
-
-((
|
|
318
|
-
), this.raycaster.setFromCamera(this.pointer,
|
|
318
|
+
(t.clientX - r.left) / r.width * 2 - 1,
|
|
319
|
+
-((t.clientY - r.top) / r.height) * 2 + 1
|
|
320
|
+
), this.raycaster.setFromCamera(this.pointer, e);
|
|
319
321
|
}
|
|
320
|
-
setForceBoost(
|
|
321
|
-
var
|
|
322
|
-
!((
|
|
322
|
+
setForceBoost(t) {
|
|
323
|
+
var e;
|
|
324
|
+
!((e = this.runtime) != null && e.grab) || t === this.forceBoosted || (this.forceBoosted = t, this.runtime.updateGrabStrength(t ? R : 1), this.forceLine.material.color.setHex(t ? G : f));
|
|
323
325
|
}
|
|
324
|
-
beginGrab(
|
|
326
|
+
beginGrab(t, e, i) {
|
|
325
327
|
if (!this.runtime || this.disposed) return !1;
|
|
326
|
-
this.pointerRay(
|
|
327
|
-
const r = this.raycaster.intersectObject(this.model, !0).find((
|
|
328
|
+
this.pointerRay(t, e, i);
|
|
329
|
+
const r = this.raycaster.intersectObject(this.model, !0).find((c) => c.object.isMesh);
|
|
328
330
|
if (!r) return !1;
|
|
329
331
|
const s = this.findBodyGroup(r.object);
|
|
330
332
|
if (!s) return !1;
|
|
331
|
-
const
|
|
332
|
-
this.dragTarget.copy(r.point),
|
|
333
|
-
const
|
|
333
|
+
const l = s.worldToLocal(r.point.clone());
|
|
334
|
+
this.dragTarget.copy(r.point), T(this.dragPlane, e, r.point), this.dragOffset.set(0, 0, 0);
|
|
335
|
+
const n = this.root.worldToLocal(r.point.clone());
|
|
334
336
|
return this.bodyGroups.set(s.userData.bodyId, s), this.runtime.beginGrab({
|
|
335
337
|
bodyId: s.userData.bodyId,
|
|
336
|
-
localPoint: [
|
|
337
|
-
target: [
|
|
338
|
-
}), this.forceBoosted = !1, this.setForceBoost(
|
|
338
|
+
localPoint: [l.x, l.y, l.z],
|
|
339
|
+
target: [n.x, n.y, n.z]
|
|
340
|
+
}), this.forceBoosted = !1, this.setForceBoost(t.shiftKey), this.forceLine.visible = !0, this.updateForceLine(), this.grabCanvas = i, i != null && i.style && (this.previousCursor = i.style.cursor, i.style.cursor = "grabbing"), !0;
|
|
339
341
|
}
|
|
340
|
-
moveGrab(
|
|
342
|
+
moveGrab(t, e, i) {
|
|
341
343
|
var s;
|
|
342
344
|
if (!((s = this.runtime) != null && s.grab)) return;
|
|
343
|
-
if (this.pointerRay(
|
|
345
|
+
if (this.pointerRay(t, e, i), this.setForceBoost(t.shiftKey), i != null && i.style && i.style.cursor !== "grabbing" && (i.style.cursor = "grabbing"), this.raycaster.ray.intersectPlane(this.dragPlane, this.dragIntersection))
|
|
344
346
|
this.dragTarget.copy(this.dragIntersection).add(this.dragOffset);
|
|
345
347
|
else
|
|
346
348
|
return;
|
|
@@ -348,45 +350,45 @@ class F {
|
|
|
348
350
|
this.runtime.updateGrabTarget([r.x, r.y, r.z]), this.updateForceLine();
|
|
349
351
|
}
|
|
350
352
|
endGrab() {
|
|
351
|
-
var
|
|
352
|
-
this.runtime && (this.runtime.endGrab(), this.forceBoosted = !1, this.forceLine.visible = !1, this.forceLine.material.color.setHex(f), (
|
|
353
|
+
var t;
|
|
354
|
+
this.runtime && (this.runtime.endGrab(), this.forceBoosted = !1, this.forceLine.visible = !1, this.forceLine.material.color.setHex(f), (t = this.grabCanvas) != null && t.style && (this.grabCanvas.style.cursor = this.previousCursor), this.grabCanvas = null);
|
|
353
355
|
}
|
|
354
356
|
updateForceLine() {
|
|
355
|
-
var
|
|
356
|
-
const
|
|
357
|
-
if (!e) return;
|
|
358
|
-
const t = this.getBodyGroup(e.bodyId);
|
|
357
|
+
var n;
|
|
358
|
+
const t = (n = this.runtime) == null ? void 0 : n.grab;
|
|
359
359
|
if (!t) return;
|
|
360
|
-
const
|
|
361
|
-
|
|
360
|
+
const e = this.getBodyGroup(t.bodyId);
|
|
361
|
+
if (!e) return;
|
|
362
|
+
const i = new o.Vector3().fromArray(t.localPoint), r = e.localToWorld(i), s = this.root.worldToLocal(r), l = this.forceLine.geometry.attributes.position;
|
|
363
|
+
l.setXYZ(0, s.x, s.y, s.z), l.setXYZ(1, t.target[0], t.target[1], t.target[2]), l.needsUpdate = !0;
|
|
362
364
|
}
|
|
363
|
-
beforeRender(
|
|
364
|
-
var
|
|
365
|
+
beforeRender(t, e, i) {
|
|
366
|
+
var l;
|
|
365
367
|
const r = {
|
|
366
|
-
tone:
|
|
367
|
-
exposure:
|
|
368
|
-
color:
|
|
369
|
-
environment:
|
|
370
|
-
fog:
|
|
371
|
-
background:
|
|
368
|
+
tone: t.toneMapping,
|
|
369
|
+
exposure: t.toneMappingExposure,
|
|
370
|
+
color: t.outputColorSpace,
|
|
371
|
+
environment: e.environment,
|
|
372
|
+
fog: e.fog,
|
|
373
|
+
background: e.background
|
|
372
374
|
}, s = () => {
|
|
373
|
-
|
|
375
|
+
t.toneMapping = r.tone, t.toneMappingExposure = r.exposure, t.outputColorSpace = r.color, e.environment = r.environment, e.fog = r.fog, e.background = r.background;
|
|
374
376
|
};
|
|
375
377
|
if (this.disposed) return s;
|
|
376
378
|
try {
|
|
377
|
-
(
|
|
378
|
-
const
|
|
379
|
-
return
|
|
380
|
-
} catch (
|
|
381
|
-
throw s(),
|
|
379
|
+
(l = this.runtime) != null && l.grab && this.updateForceLine(), t.toneMapping = o.ACESFilmicToneMapping, t.toneMappingExposure = C[this.presentation], t.outputColorSpace = o.SRGBColorSpace, e.background = new o.Color(this.values.background), e.fog = this.fog;
|
|
380
|
+
const n = t.getSize(new o.Vector2()), c = `${n.x}:${n.y}`;
|
|
381
|
+
return c !== this.size && (this.size = c, this.reflector.setRenderSize(Math.max(1, Math.floor(n.x * 0.35)), Math.max(1, Math.floor(n.y * 0.35)))), e.updateMatrixWorld(!0), i.updateMatrixWorld(!0), this.groundVisible && i instanceof o.PerspectiveCamera && this.reflector.renderReflection(t, e, i), s;
|
|
382
|
+
} catch (n) {
|
|
383
|
+
throw s(), n;
|
|
382
384
|
}
|
|
383
385
|
}
|
|
384
386
|
/**
|
|
385
387
|
* The reflector mesh carries both the grid lines and the reflection. Hiding
|
|
386
388
|
* it also skips the reflection render pass, which only feeds its shader.
|
|
387
389
|
*/
|
|
388
|
-
setGroundVisible(
|
|
389
|
-
this.groundVisible =
|
|
390
|
+
setGroundVisible(t) {
|
|
391
|
+
this.groundVisible = t, this.reflector.visible = t;
|
|
390
392
|
}
|
|
391
393
|
getGroundVisible() {
|
|
392
394
|
return this.groundVisible;
|
|
@@ -397,25 +399,26 @@ class F {
|
|
|
397
399
|
* so nesting hidden aids (collision meshes, which are far larger than the
|
|
398
400
|
* visual shell) would inflate both the reflection extent and the camera fit.
|
|
399
401
|
*/
|
|
400
|
-
attachAuxiliary(
|
|
401
|
-
this.auxiliaries.add(
|
|
402
|
+
attachAuxiliary(t) {
|
|
403
|
+
this.auxiliaries.add(t), this.root.add(t);
|
|
402
404
|
}
|
|
403
405
|
getModelBounds() {
|
|
404
406
|
this.root.updateMatrixWorld(!0);
|
|
405
|
-
const
|
|
406
|
-
if (!
|
|
407
|
-
const
|
|
408
|
-
return
|
|
407
|
+
const t = new o.Box3().setFromObject(this.model);
|
|
408
|
+
if (!t.isEmpty()) return t;
|
|
409
|
+
const e = new o.Box3();
|
|
410
|
+
return e.min.set(-5e3, -5e3, -5e3), e.max.set(5e3, 5e3, 5e3), e;
|
|
409
411
|
}
|
|
410
412
|
dispose() {
|
|
411
413
|
if (!this.disposed) {
|
|
412
414
|
this.disposed = !0, this.endGrab(), this.model.removeFromParent();
|
|
413
|
-
for (const
|
|
414
|
-
this.auxiliaries.clear(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(),
|
|
415
|
+
for (const t of this.auxiliaries) t.removeFromParent();
|
|
416
|
+
this.auxiliaries.clear(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(), x(this.root);
|
|
415
417
|
}
|
|
416
418
|
}
|
|
417
419
|
}
|
|
418
420
|
export {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
+
W as S,
|
|
422
|
+
x as d,
|
|
423
|
+
F as r
|
|
421
424
|
};
|