@nebula-spatial/viewer 0.4.4 → 0.4.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/CHANGELOG.md +33 -0
- package/README.md +59 -0
- package/USD-VISUAL-MATERIAL-SUPPORT.md +51 -0
- package/dist/assets/types.d.ts +7 -1
- package/dist/{index-D-o1ODOX.js → index-CxbZ--5C.js} +2032 -1790
- package/dist/index.js +1 -1
- package/dist/inspection/types.d.ts +13 -0
- package/dist/mjcf-visual-6_RqDf4z.js +73 -0
- package/dist/{session-c7xBLA4J.js → session-CnlODeFp.js} +2 -2
- package/dist/session-DNyPmQOW.js +795 -0
- package/dist/{stage-D113SHD8.js → stage-BPiGudYP.js} +131 -118
- package/dist/urdf-session-CuIZOiCF.js +3238 -0
- package/dist/usd-session-JDfuDgWv.js +1907 -0
- package/dist/xacro-DrBtv-gK.js +1537 -0
- package/package.json +4 -2
- package/dist/mjcf-visual-M1lmyjvw.js +0 -63
- package/dist/session-Cz6qHYMc.js +0 -676
- package/dist/urdf-session-AP-cMuwd.js +0 -3001
- package/dist/usd-session-CmSdkRw9.js +0 -1192
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var a = (u,
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var M = (u, t, e) => t in u ? b(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
|
|
3
|
+
var a = (u, t, e) => M(u, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import * as r from "three";
|
|
5
|
-
import { V as
|
|
6
|
-
const
|
|
5
|
+
import { V as x } from "./index-CxbZ--5C.js";
|
|
6
|
+
const p = 1, w = (
|
|
7
7
|
/* glsl */
|
|
8
8
|
`
|
|
9
9
|
uniform mat4 textureMatrix;
|
|
@@ -19,7 +19,7 @@ const m = 1, M = (
|
|
|
19
19
|
gl_Position = projectionMatrix * mvPosition;
|
|
20
20
|
}
|
|
21
21
|
`
|
|
22
|
-
),
|
|
22
|
+
), P = (
|
|
23
23
|
/* glsl */
|
|
24
24
|
`
|
|
25
25
|
uniform sampler2D tDiffuse;
|
|
@@ -86,8 +86,8 @@ const m = 1, M = (
|
|
|
86
86
|
}
|
|
87
87
|
`
|
|
88
88
|
);
|
|
89
|
-
class
|
|
90
|
-
constructor({ size:
|
|
89
|
+
class C extends r.Mesh {
|
|
90
|
+
constructor({ size: e = 20, textureWidth: i = 512, textureHeight: o = 512 } = {}) {
|
|
91
91
|
const s = new r.Matrix4(), l = new r.WebGLRenderTarget(i, o, {
|
|
92
92
|
type: r.HalfFloatType,
|
|
93
93
|
minFilter: r.LinearFilter,
|
|
@@ -107,17 +107,17 @@ class P extends r.Mesh {
|
|
|
107
107
|
gridOpacity: { value: 1 },
|
|
108
108
|
gridScale: { value: 0.2 },
|
|
109
109
|
groundCenter: { value: new r.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: w,
|
|
114
|
+
fragmentShader: P,
|
|
115
115
|
transparent: !0,
|
|
116
116
|
depthWrite: !1,
|
|
117
117
|
toneMapped: !0,
|
|
118
118
|
fog: !1
|
|
119
119
|
});
|
|
120
|
-
super(new r.PlaneGeometry(
|
|
120
|
+
super(new r.PlaneGeometry(e, e), n);
|
|
121
121
|
a(this, "renderTarget");
|
|
122
122
|
a(this, "textureMatrix");
|
|
123
123
|
a(this, "virtualCamera");
|
|
@@ -132,9 +132,9 @@ class P extends r.Mesh {
|
|
|
132
132
|
a(this, "view");
|
|
133
133
|
a(this, "target");
|
|
134
134
|
a(this, "q");
|
|
135
|
-
this.renderTarget = l, this.textureMatrix = s, this.virtualCamera = new r.PerspectiveCamera(), this.virtualCamera.layers.set(
|
|
135
|
+
this.renderTarget = l, this.textureMatrix = s, this.virtualCamera = new r.PerspectiveCamera(), this.virtualCamera.layers.set(p), this.clipBias = 3e-3, this.frustumCulled = !1, this.renderOrder = 1, this.position.z = 2e-3, this.reflectorPlane = new r.Plane(), this.normal = new r.Vector3(), this.reflectorWorldPosition = new r.Vector3(), this.cameraWorldPosition = new r.Vector3(), this.rotationMatrix = new r.Matrix4(), this.lookAtPosition = new r.Vector3(0, 0, -1), this.clipPlane = new r.Vector4(), this.view = new r.Vector3(), this.target = new r.Vector3(), this.q = new r.Vector4();
|
|
136
136
|
}
|
|
137
|
-
renderReflection(
|
|
137
|
+
renderReflection(e, i, o) {
|
|
138
138
|
if (this.reflectorWorldPosition.setFromMatrixPosition(this.matrixWorld), this.cameraWorldPosition.setFromMatrixPosition(o.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(o.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 = o.near, this.virtualCamera.far = o.far, this.virtualCamera.updateMatrixWorld(), this.virtualCamera.projectionMatrix.copy(o.projectionMatrix), this.textureMatrix.set(
|
|
140
140
|
0.5,
|
|
@@ -166,54 +166,54 @@ class P extends r.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 l =
|
|
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, o = this.material.uniforms.groundCenter.value) {
|
|
181
|
+
this.scale.setScalar(e * 2 / this.geometry.parameters.width), this.position.x = o.x, this.position.y = o.y, this.material.uniforms.groundCenter.value.set(o.x, o.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 v = {
|
|
185
185
|
light: {
|
|
186
|
-
background:
|
|
186
|
+
background: x.light,
|
|
187
187
|
fineGrid: 5859168,
|
|
188
188
|
coarseGrid: 3427136,
|
|
189
189
|
gridOpacity: 0.85,
|
|
190
190
|
reflectionMix: 0.06
|
|
191
191
|
},
|
|
192
192
|
dark: {
|
|
193
|
-
background:
|
|
193
|
+
background: x.dark,
|
|
194
194
|
fineGrid: 7375236,
|
|
195
195
|
coarseGrid: 5552554,
|
|
196
196
|
gridOpacity: 0.9,
|
|
197
197
|
reflectionMix: 0.06
|
|
198
198
|
}
|
|
199
|
-
},
|
|
199
|
+
}, S = {
|
|
200
200
|
simulation: 0.68,
|
|
201
201
|
model: 1.4
|
|
202
202
|
};
|
|
203
|
-
function
|
|
203
|
+
function y(u, t = []) {
|
|
204
204
|
var l;
|
|
205
|
-
const
|
|
205
|
+
const e = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), o = new Set(t), s = /* @__PURE__ */ new Set();
|
|
206
206
|
u.traverse((n) => {
|
|
207
207
|
const c = n;
|
|
208
|
-
c.geometry &&
|
|
208
|
+
c.geometry && e.add(c.geometry);
|
|
209
209
|
for (const d of Array.isArray(c.material) ? c.material : [c.material])
|
|
210
210
|
if (d) {
|
|
211
211
|
i.add(d);
|
|
212
212
|
for (const h of Object.values(d))
|
|
213
|
-
|
|
213
|
+
G(h) && o.add(h);
|
|
214
214
|
}
|
|
215
215
|
});
|
|
216
|
-
for (const n of
|
|
216
|
+
for (const n of e) n.dispose();
|
|
217
217
|
for (const n of i) n.dispose();
|
|
218
218
|
for (const n of o) {
|
|
219
219
|
const c = (l = n.source) == null ? void 0 : l.data;
|
|
@@ -221,22 +221,35 @@ function x(u, e = []) {
|
|
|
221
221
|
}
|
|
222
222
|
for (const n of s) n.close();
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function G(u) {
|
|
225
225
|
return !!(u && typeof u == "object" && u.isTexture);
|
|
226
226
|
}
|
|
227
|
-
const
|
|
227
|
+
const W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
228
228
|
__proto__: null,
|
|
229
|
-
disposeModelResources:
|
|
230
|
-
}, Symbol.toStringTag, { value: "Module" })), f = 2213822,
|
|
231
|
-
function
|
|
232
|
-
|
|
229
|
+
disposeModelResources: y
|
|
230
|
+
}, Symbol.toStringTag, { value: "Module" })), f = 2213822, R = 6000111, T = 6;
|
|
231
|
+
function L(u, t, e) {
|
|
232
|
+
t.updateMatrixWorld();
|
|
233
233
|
const i = new r.Vector3();
|
|
234
|
-
return
|
|
234
|
+
return t.getWorldDirection(i).normalize(), u.setFromNormalAndCoplanarPoint(i, e);
|
|
235
235
|
}
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
function m(u) {
|
|
237
|
+
u.updateWorldMatrix(!0, !0);
|
|
238
|
+
const t = new r.Box3();
|
|
239
|
+
return u.traverse((e) => {
|
|
240
|
+
if (!(e instanceof r.Mesh)) return;
|
|
241
|
+
let i = e;
|
|
242
|
+
for (; i; ) {
|
|
243
|
+
if (i.userData.excludeFromSimulationFit || !i.visible) return;
|
|
244
|
+
i = i.parent;
|
|
245
|
+
}
|
|
246
|
+
e.geometry.boundingBox || e.geometry.computeBoundingBox(), e.geometry.boundingBox && t.union(e.geometry.boundingBox.clone().applyMatrix4(e.matrixWorld));
|
|
247
|
+
}), t.isEmpty() ? new r.Box3().setFromObject(u) : t;
|
|
248
|
+
}
|
|
249
|
+
class B {
|
|
250
|
+
constructor(t, e = "dark", i, o = "simulation") {
|
|
238
251
|
a(this, "root", new r.Group());
|
|
239
|
-
a(this, "reflector", new
|
|
252
|
+
a(this, "reflector", new C({ size: 100, textureWidth: 256, textureHeight: 256 }));
|
|
240
253
|
a(this, "values");
|
|
241
254
|
a(this, "fog");
|
|
242
255
|
a(this, "raycaster", new r.Raycaster());
|
|
@@ -254,36 +267,36 @@ class W {
|
|
|
254
267
|
a(this, "size", "");
|
|
255
268
|
a(this, "groundVisible");
|
|
256
269
|
a(this, "disposed", !1);
|
|
257
|
-
this.model =
|
|
258
|
-
const s = this.values, l =
|
|
270
|
+
this.model = t, this.runtime = i, this.presentation = o, this.values = v[e];
|
|
271
|
+
const s = this.values, l = m(t), n = Math.max(...l.getSize(new r.Vector3()).toArray());
|
|
259
272
|
if (!Number.isFinite(n) || n <= 0) throw new Error("Empty simulation geometry.");
|
|
260
|
-
this.root.add(
|
|
261
|
-
|
|
273
|
+
this.root.add(t), this.forceLine = this.createForceLine(), this.root.add(this.forceLine), t.traverse((g) => {
|
|
274
|
+
g instanceof r.Mesh && g.layers.enable(p);
|
|
262
275
|
}), this.root.add(this.reflector);
|
|
263
276
|
const c = Math.max(l.getSize(new r.Vector3()).length() * 0.5, 0.02), d = this.reflector.material.uniforms;
|
|
264
277
|
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 = o === "simulation", this.setGroundVisible(this.groundVisible);
|
|
265
278
|
const h = c / Math.sin(r.MathUtils.degToRad(38) / 2) * 1.25;
|
|
266
279
|
this.fog = new r.Fog(s.background, h * 2.5, h * 8);
|
|
267
280
|
}
|
|
268
|
-
setRuntime(
|
|
269
|
-
this.disposed || this.runtime ===
|
|
281
|
+
setRuntime(t) {
|
|
282
|
+
this.disposed || this.runtime === t || (this.endGrab(), this.runtime = t, this.bodyGroups.clear());
|
|
270
283
|
}
|
|
271
|
-
replaceModel(
|
|
272
|
-
this.disposed ||
|
|
273
|
-
i instanceof r.Mesh && i.layers.enable(
|
|
274
|
-
}),
|
|
284
|
+
replaceModel(t, e = !0) {
|
|
285
|
+
this.disposed || t === this.model || (this.endGrab(), this.bodyGroups.clear(), this.model.removeFromParent(), this.model = t, this.root.add(t), t.traverse((i) => {
|
|
286
|
+
i instanceof r.Mesh && i.layers.enable(p);
|
|
287
|
+
}), e && this.reseatGround());
|
|
275
288
|
}
|
|
276
289
|
resetGround() {
|
|
277
|
-
var
|
|
278
|
-
this.disposed || (this.reflector.position.z = (((
|
|
290
|
+
var t;
|
|
291
|
+
this.disposed || (this.reflector.position.z = (((t = this.runtime) == null ? void 0 : t.defaultGroundHeight) ?? 0) + 2e-3);
|
|
279
292
|
}
|
|
280
|
-
setTheme(
|
|
293
|
+
setTheme(t) {
|
|
281
294
|
if (this.disposed) return;
|
|
282
|
-
const
|
|
283
|
-
i.fineGridColor.value.setHex(
|
|
295
|
+
const e = this.values = v[t], i = this.reflector.material.uniforms;
|
|
296
|
+
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);
|
|
284
297
|
}
|
|
285
|
-
layoutGround(
|
|
286
|
-
this.reflector.setRadius(
|
|
298
|
+
layoutGround(t, e) {
|
|
299
|
+
this.reflector.setRadius(e * 8, Math.pow(10, Math.floor(Math.log10(Math.max(e, 0.01)))), t.getCenter(new r.Vector3()));
|
|
287
300
|
}
|
|
288
301
|
/**
|
|
289
302
|
* Re-fits the ground disc and reflection to the model's current world bounds.
|
|
@@ -294,67 +307,67 @@ class W {
|
|
|
294
307
|
reseatGround() {
|
|
295
308
|
if (this.disposed) return;
|
|
296
309
|
this.root.updateMatrixWorld(!0);
|
|
297
|
-
const
|
|
298
|
-
|
|
310
|
+
const t = m(this.model);
|
|
311
|
+
t.isEmpty() || this.layoutGround(t, Math.max(t.getSize(new r.Vector3()).length() * 0.5, 0.02));
|
|
299
312
|
}
|
|
300
313
|
createForceLine() {
|
|
301
|
-
const
|
|
314
|
+
const t = new r.BufferGeometry().setFromPoints([
|
|
302
315
|
new r.Vector3(),
|
|
303
316
|
new r.Vector3()
|
|
304
|
-
]),
|
|
317
|
+
]), e = new r.LineBasicMaterial({
|
|
305
318
|
color: f,
|
|
306
319
|
depthTest: !1,
|
|
307
320
|
transparent: !0
|
|
308
|
-
}), i = new r.Line(
|
|
321
|
+
}), i = new r.Line(t, e);
|
|
309
322
|
return i.renderOrder = 1e3, i.visible = !1, i;
|
|
310
323
|
}
|
|
311
|
-
findBodyGroup(
|
|
324
|
+
findBodyGroup(t) {
|
|
312
325
|
var i;
|
|
313
|
-
let
|
|
314
|
-
for (;
|
|
315
|
-
if (typeof ((i =
|
|
316
|
-
|
|
326
|
+
let e = t;
|
|
327
|
+
for (; e && e !== this.model && e !== this.root; ) {
|
|
328
|
+
if (typeof ((i = e.userData) == null ? void 0 : i.bodyId) == "number") return e;
|
|
329
|
+
e = e.parent;
|
|
317
330
|
}
|
|
318
331
|
return null;
|
|
319
332
|
}
|
|
320
|
-
getBodyGroup(
|
|
321
|
-
let
|
|
322
|
-
return
|
|
333
|
+
getBodyGroup(t) {
|
|
334
|
+
let e = this.bodyGroups.get(t);
|
|
335
|
+
return e || this.model.traverse((i) => {
|
|
323
336
|
var o;
|
|
324
|
-
((o = i.userData) == null ? void 0 : o.bodyId) ===
|
|
325
|
-
}),
|
|
337
|
+
((o = i.userData) == null ? void 0 : o.bodyId) === t && (e = i, this.bodyGroups.set(t, i));
|
|
338
|
+
}), e;
|
|
326
339
|
}
|
|
327
|
-
pointerRay(
|
|
340
|
+
pointerRay(t, e, i) {
|
|
328
341
|
const o = i.getBoundingClientRect();
|
|
329
342
|
this.pointer.set(
|
|
330
|
-
(
|
|
331
|
-
-((
|
|
332
|
-
), this.raycaster.setFromCamera(this.pointer,
|
|
343
|
+
(t.clientX - o.left) / o.width * 2 - 1,
|
|
344
|
+
-((t.clientY - o.top) / o.height) * 2 + 1
|
|
345
|
+
), this.raycaster.setFromCamera(this.pointer, e);
|
|
333
346
|
}
|
|
334
|
-
setForceBoost(
|
|
335
|
-
var
|
|
336
|
-
!((
|
|
347
|
+
setForceBoost(t) {
|
|
348
|
+
var e;
|
|
349
|
+
!((e = this.runtime) != null && e.grab) || t === this.forceBoosted || (this.forceBoosted = t, this.runtime.updateGrabStrength(t ? T : 1), this.forceLine.material.color.setHex(t ? R : f));
|
|
337
350
|
}
|
|
338
|
-
beginGrab(
|
|
351
|
+
beginGrab(t, e, i) {
|
|
339
352
|
if (!this.runtime || this.disposed) return !1;
|
|
340
|
-
this.pointerRay(
|
|
353
|
+
this.pointerRay(t, e, i);
|
|
341
354
|
const o = this.raycaster.intersectObject(this.model, !0).find((c) => c.object.isMesh);
|
|
342
355
|
if (!o) return !1;
|
|
343
356
|
const s = this.findBodyGroup(o.object);
|
|
344
357
|
if (!s) return !1;
|
|
345
358
|
const l = s.worldToLocal(o.point.clone());
|
|
346
|
-
this.dragTarget.copy(o.point),
|
|
359
|
+
this.dragTarget.copy(o.point), L(this.dragPlane, e, o.point), this.dragOffset.set(0, 0, 0);
|
|
347
360
|
const n = this.root.worldToLocal(o.point.clone());
|
|
348
361
|
return this.bodyGroups.set(s.userData.bodyId, s), this.runtime.beginGrab({
|
|
349
362
|
bodyId: s.userData.bodyId,
|
|
350
363
|
localPoint: [l.x, l.y, l.z],
|
|
351
364
|
target: [n.x, n.y, n.z]
|
|
352
|
-
}), this.forceBoosted = !1, this.setForceBoost(
|
|
365
|
+
}), 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;
|
|
353
366
|
}
|
|
354
|
-
moveGrab(
|
|
367
|
+
moveGrab(t, e, i) {
|
|
355
368
|
var s;
|
|
356
369
|
if (!((s = this.runtime) != null && s.grab)) return;
|
|
357
|
-
if (this.pointerRay(
|
|
370
|
+
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))
|
|
358
371
|
this.dragTarget.copy(this.dragIntersection).add(this.dragOffset);
|
|
359
372
|
else
|
|
360
373
|
return;
|
|
@@ -362,37 +375,37 @@ class W {
|
|
|
362
375
|
this.runtime.updateGrabTarget([o.x, o.y, o.z]), this.updateForceLine();
|
|
363
376
|
}
|
|
364
377
|
endGrab() {
|
|
365
|
-
var
|
|
366
|
-
this.runtime && (this.runtime.endGrab(), this.forceBoosted = !1, this.forceLine.visible = !1, this.forceLine.material.color.setHex(f), (
|
|
378
|
+
var t;
|
|
379
|
+
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);
|
|
367
380
|
}
|
|
368
381
|
updateForceLine() {
|
|
369
382
|
var n;
|
|
370
|
-
const
|
|
371
|
-
if (!e) return;
|
|
372
|
-
const t = this.getBodyGroup(e.bodyId);
|
|
383
|
+
const t = (n = this.runtime) == null ? void 0 : n.grab;
|
|
373
384
|
if (!t) return;
|
|
374
|
-
const
|
|
375
|
-
|
|
385
|
+
const e = this.getBodyGroup(t.bodyId);
|
|
386
|
+
if (!e) return;
|
|
387
|
+
const i = new r.Vector3().fromArray(t.localPoint), o = e.localToWorld(i), s = this.root.worldToLocal(o), l = this.forceLine.geometry.attributes.position;
|
|
388
|
+
l.setXYZ(0, s.x, s.y, s.z), l.setXYZ(1, t.target[0], t.target[1], t.target[2]), l.needsUpdate = !0;
|
|
376
389
|
}
|
|
377
|
-
beforeRender(
|
|
390
|
+
beforeRender(t, e, i) {
|
|
378
391
|
var l, n;
|
|
379
392
|
const o = {
|
|
380
|
-
tone:
|
|
381
|
-
exposure:
|
|
382
|
-
color:
|
|
383
|
-
environment:
|
|
384
|
-
fog:
|
|
385
|
-
background:
|
|
393
|
+
tone: t.toneMapping,
|
|
394
|
+
exposure: t.toneMappingExposure,
|
|
395
|
+
color: t.outputColorSpace,
|
|
396
|
+
environment: e.environment,
|
|
397
|
+
fog: e.fog,
|
|
398
|
+
background: e.background
|
|
386
399
|
}, s = () => {
|
|
387
|
-
|
|
400
|
+
t.toneMapping = o.tone, t.toneMappingExposure = o.exposure, t.outputColorSpace = o.color, e.environment = o.environment, e.fog = o.fog, e.background = o.background;
|
|
388
401
|
};
|
|
389
402
|
if (this.disposed) return s;
|
|
390
403
|
try {
|
|
391
404
|
(l = this.runtime) != null && l.grab && this.updateForceLine();
|
|
392
405
|
const c = (n = this.runtime) == null ? void 0 : n.defaultGroundHeight;
|
|
393
|
-
c !== void 0 && (this.reflector.position.z = c + 2e-3),
|
|
394
|
-
const d =
|
|
395
|
-
return h !== this.size && (this.size = h, this.reflector.setRenderSize(Math.max(1, Math.floor(d.x * 0.35)), Math.max(1, Math.floor(d.y * 0.35)))),
|
|
406
|
+
c !== void 0 && (this.reflector.position.z = c + 2e-3), t.toneMapping = r.ACESFilmicToneMapping, t.toneMappingExposure = S[this.presentation], t.outputColorSpace = r.SRGBColorSpace, e.background = new r.Color(this.values.background), e.fog = this.fog;
|
|
407
|
+
const d = t.getSize(new r.Vector2()), h = `${d.x}:${d.y}`;
|
|
408
|
+
return h !== this.size && (this.size = h, this.reflector.setRenderSize(Math.max(1, Math.floor(d.x * 0.35)), Math.max(1, Math.floor(d.y * 0.35)))), e.updateMatrixWorld(!0), i.updateMatrixWorld(!0), this.groundVisible && i instanceof r.PerspectiveCamera && this.reflector.renderReflection(t, e, i), s;
|
|
396
409
|
} catch (c) {
|
|
397
410
|
throw s(), c;
|
|
398
411
|
}
|
|
@@ -401,8 +414,8 @@ class W {
|
|
|
401
414
|
* The reflector mesh carries both the grid lines and the reflection. Hiding
|
|
402
415
|
* it also skips the reflection render pass, which only feeds its shader.
|
|
403
416
|
*/
|
|
404
|
-
setGroundVisible(
|
|
405
|
-
this.groundVisible =
|
|
417
|
+
setGroundVisible(t) {
|
|
418
|
+
this.groundVisible = t, this.reflector.visible = t;
|
|
406
419
|
}
|
|
407
420
|
getGroundVisible() {
|
|
408
421
|
return this.groundVisible;
|
|
@@ -413,29 +426,29 @@ class W {
|
|
|
413
426
|
* so nesting hidden aids (collision meshes, which are far larger than the
|
|
414
427
|
* visual shell) would inflate both the reflection extent and the camera fit.
|
|
415
428
|
*/
|
|
416
|
-
attachAuxiliary(
|
|
417
|
-
this.auxiliaries.add(
|
|
429
|
+
attachAuxiliary(t) {
|
|
430
|
+
this.auxiliaries.add(t), this.root.add(t);
|
|
418
431
|
}
|
|
419
|
-
detachAuxiliary(
|
|
420
|
-
this.auxiliaries.delete(
|
|
432
|
+
detachAuxiliary(t) {
|
|
433
|
+
this.auxiliaries.delete(t) && t.removeFromParent();
|
|
421
434
|
}
|
|
422
435
|
getModelBounds() {
|
|
423
436
|
this.root.updateMatrixWorld(!0);
|
|
424
|
-
const
|
|
425
|
-
if (!
|
|
426
|
-
const
|
|
427
|
-
return
|
|
437
|
+
const t = m(this.model);
|
|
438
|
+
if (!t.isEmpty()) return t;
|
|
439
|
+
const e = new r.Box3();
|
|
440
|
+
return e.min.set(-5e3, -5e3, -5e3), e.max.set(5e3, 5e3, 5e3), e;
|
|
428
441
|
}
|
|
429
442
|
dispose() {
|
|
430
443
|
if (!this.disposed) {
|
|
431
444
|
this.disposed = !0, this.endGrab(), this.model.removeFromParent();
|
|
432
|
-
for (const
|
|
433
|
-
this.auxiliaries.clear(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(),
|
|
445
|
+
for (const t of this.auxiliaries) t.removeFromParent();
|
|
446
|
+
this.auxiliaries.clear(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(), y(this.root);
|
|
434
447
|
}
|
|
435
448
|
}
|
|
436
449
|
}
|
|
437
450
|
export {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
451
|
+
B as S,
|
|
452
|
+
y as d,
|
|
453
|
+
W as r
|
|
441
454
|
};
|