@nebula-spatial/viewer 0.4.3 → 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.
@@ -1,9 +1,9 @@
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
- import * as o from "three";
5
- import { V as p } from "./index-BDo6voB2.js";
6
- const v = 1, M = (
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
+ import * as r from "three";
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 v = 1, M = (
19
19
  gl_Position = projectionMatrix * mvPosition;
20
20
  }
21
21
  `
22
- ), w = (
22
+ ), P = (
23
23
  /* glsl */
24
24
  `
25
25
  uniform sampler2D tDiffuse;
@@ -86,38 +86,38 @@ const v = 1, M = (
86
86
  }
87
87
  `
88
88
  );
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
- type: o.HalfFloatType,
93
- minFilter: o.LinearFilter,
94
- magFilter: o.LinearFilter,
95
- format: o.RGBAFormat,
89
+ class C extends r.Mesh {
90
+ constructor({ size: e = 20, textureWidth: i = 512, textureHeight: o = 512 } = {}) {
91
+ const s = new r.Matrix4(), l = new r.WebGLRenderTarget(i, o, {
92
+ type: r.HalfFloatType,
93
+ minFilter: r.LinearFilter,
94
+ magFilter: r.LinearFilter,
95
+ format: r.RGBAFormat,
96
96
  depthBuffer: !0,
97
97
  samples: 0
98
- }), n = new o.ShaderMaterial({
98
+ }), n = new r.ShaderMaterial({
99
99
  uniforms: {
100
100
  tDiffuse: { value: l.texture },
101
101
  textureMatrix: { value: s },
102
- resolution: { value: new o.Vector2(i, r) },
103
- fineGridColor: { value: new o.Color(2502702) },
104
- coarseGridColor: { value: new o.Color(7897726) },
102
+ resolution: { value: new r.Vector2(i, o) },
103
+ fineGridColor: { value: new r.Color(2502702) },
104
+ coarseGridColor: { value: new r.Color(7897726) },
105
105
  blurIntensity: { value: 1.7 },
106
106
  reflectionMix: { value: 0.07 },
107
107
  gridOpacity: { value: 1 },
108
108
  gridScale: { value: 0.2 },
109
- groundCenter: { value: new o.Vector2() },
109
+ groundCenter: { value: new r.Vector2() },
110
110
  maxRadius: { value: e * 0.5 },
111
111
  fadeSoftness: { value: e * 0.325 }
112
112
  },
113
- vertexShader: M,
114
- fragmentShader: w,
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 o.PlaneGeometry(e, e), n);
120
+ super(new r.PlaneGeometry(e, e), n);
121
121
  a(this, "renderTarget");
122
122
  a(this, "textureMatrix");
123
123
  a(this, "virtualCamera");
@@ -132,11 +132,11 @@ class P extends o.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 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();
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(e, i, r) {
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
- 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(
137
+ renderReflection(e, i, o) {
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
+ 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,
141
141
  0,
142
142
  0,
@@ -177,32 +177,32 @@ class P extends o.Mesh {
177
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(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;
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
- const g = {
184
+ const v = {
185
185
  light: {
186
- background: p.light,
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: p.dark,
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
- }, C = {
199
+ }, S = {
200
200
  simulation: 0.68,
201
201
  model: 1.4
202
202
  };
203
- function x(u, t = []) {
203
+ function y(u, t = []) {
204
204
  var l;
205
- const e = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), r = new Set(t), s = /* @__PURE__ */ new Set();
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
208
  c.geometry && e.add(c.geometry);
@@ -210,41 +210,54 @@ function x(u, t = []) {
210
210
  if (d) {
211
211
  i.add(d);
212
212
  for (const h of Object.values(d))
213
- S(h) && r.add(h);
213
+ G(h) && o.add(h);
214
214
  }
215
215
  });
216
216
  for (const n of e) n.dispose();
217
217
  for (const n of i) n.dispose();
218
- for (const n of r) {
218
+ for (const n of o) {
219
219
  const c = (l = n.source) == null ? void 0 : l.data;
220
220
  c && typeof c.close == "function" && s.add(c), n.dispose();
221
221
  }
222
222
  for (const n of s) n.close();
223
223
  }
224
- function S(u) {
224
+ function G(u) {
225
225
  return !!(u && typeof u == "object" && u.isTexture);
226
226
  }
227
- const F = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
227
+ const W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
228
228
  __proto__: null,
229
- disposeModelResources: x
230
- }, Symbol.toStringTag, { value: "Module" })), f = 2213822, G = 6000111, R = 6;
231
- function T(u, t, e) {
229
+ disposeModelResources: y
230
+ }, Symbol.toStringTag, { value: "Module" })), f = 2213822, R = 6000111, T = 6;
231
+ function L(u, t, e) {
232
232
  t.updateMatrixWorld();
233
- const i = new o.Vector3();
233
+ const i = new r.Vector3();
234
234
  return t.getWorldDirection(i).normalize(), u.setFromNormalAndCoplanarPoint(i, e);
235
235
  }
236
- class W {
237
- constructor(t, e = "dark", i, r = "simulation") {
238
- a(this, "root", new o.Group());
239
- a(this, "reflector", new P({ size: 100, textureWidth: 256, textureHeight: 256 }));
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") {
251
+ a(this, "root", new r.Group());
252
+ a(this, "reflector", new C({ size: 100, textureWidth: 256, textureHeight: 256 }));
240
253
  a(this, "values");
241
254
  a(this, "fog");
242
- a(this, "raycaster", new o.Raycaster());
243
- a(this, "pointer", new o.Vector2());
244
- a(this, "dragPlane", new o.Plane());
245
- a(this, "dragTarget", new o.Vector3());
246
- a(this, "dragIntersection", new o.Vector3());
247
- a(this, "dragOffset", new o.Vector3());
255
+ a(this, "raycaster", new r.Raycaster());
256
+ a(this, "pointer", new r.Vector2());
257
+ a(this, "dragPlane", new r.Plane());
258
+ a(this, "dragTarget", new r.Vector3());
259
+ a(this, "dragIntersection", new r.Vector3());
260
+ a(this, "dragOffset", new r.Vector3());
248
261
  a(this, "bodyGroups", /* @__PURE__ */ new Map());
249
262
  a(this, "auxiliaries", /* @__PURE__ */ new Set());
250
263
  a(this, "forceLine");
@@ -254,24 +267,36 @@ class W {
254
267
  a(this, "size", "");
255
268
  a(this, "groundVisible");
256
269
  a(this, "disposed", !1);
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());
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(t), this.forceLine = this.createForceLine(), this.root.add(this.forceLine), t.traverse((m) => {
261
- m instanceof o.Mesh && m.layers.enable(v);
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
- 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;
266
- this.fog = new o.Fog(s.background, h * 2.5, h * 8);
276
+ const c = Math.max(l.getSize(new r.Vector3()).length() * 0.5, 0.02), d = this.reflector.material.uniforms;
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);
278
+ const h = c / Math.sin(r.MathUtils.degToRad(38) / 2) * 1.25;
279
+ this.fog = new r.Fog(s.background, h * 2.5, h * 8);
280
+ }
281
+ setRuntime(t) {
282
+ this.disposed || this.runtime === t || (this.endGrab(), this.runtime = t, this.bodyGroups.clear());
283
+ }
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());
288
+ }
289
+ resetGround() {
290
+ var t;
291
+ this.disposed || (this.reflector.position.z = (((t = this.runtime) == null ? void 0 : t.defaultGroundHeight) ?? 0) + 2e-3);
267
292
  }
268
293
  setTheme(t) {
269
294
  if (this.disposed) return;
270
- const e = this.values = g[t], i = this.reflector.material.uniforms;
295
+ const e = this.values = v[t], i = this.reflector.material.uniforms;
271
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);
272
297
  }
273
298
  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()));
299
+ this.reflector.setRadius(e * 8, Math.pow(10, Math.floor(Math.log10(Math.max(e, 0.01)))), t.getCenter(new r.Vector3()));
275
300
  }
276
301
  /**
277
302
  * Re-fits the ground disc and reflection to the model's current world bounds.
@@ -282,18 +307,18 @@ class W {
282
307
  reseatGround() {
283
308
  if (this.disposed) return;
284
309
  this.root.updateMatrixWorld(!0);
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));
310
+ const t = m(this.model);
311
+ t.isEmpty() || this.layoutGround(t, Math.max(t.getSize(new r.Vector3()).length() * 0.5, 0.02));
287
312
  }
288
313
  createForceLine() {
289
- const t = new o.BufferGeometry().setFromPoints([
290
- new o.Vector3(),
291
- new o.Vector3()
292
- ]), e = new o.LineBasicMaterial({
314
+ const t = new r.BufferGeometry().setFromPoints([
315
+ new r.Vector3(),
316
+ new r.Vector3()
317
+ ]), e = new r.LineBasicMaterial({
293
318
  color: f,
294
319
  depthTest: !1,
295
320
  transparent: !0
296
- }), i = new o.Line(t, e);
321
+ }), i = new r.Line(t, e);
297
322
  return i.renderOrder = 1e3, i.visible = !1, i;
298
323
  }
299
324
  findBodyGroup(t) {
@@ -308,31 +333,31 @@ class W {
308
333
  getBodyGroup(t) {
309
334
  let e = this.bodyGroups.get(t);
310
335
  return e || this.model.traverse((i) => {
311
- var r;
312
- ((r = i.userData) == null ? void 0 : r.bodyId) === t && (e = i, this.bodyGroups.set(t, i));
336
+ var o;
337
+ ((o = i.userData) == null ? void 0 : o.bodyId) === t && (e = i, this.bodyGroups.set(t, i));
313
338
  }), e;
314
339
  }
315
340
  pointerRay(t, e, i) {
316
- const r = i.getBoundingClientRect();
341
+ const o = i.getBoundingClientRect();
317
342
  this.pointer.set(
318
- (t.clientX - r.left) / r.width * 2 - 1,
319
- -((t.clientY - r.top) / r.height) * 2 + 1
343
+ (t.clientX - o.left) / o.width * 2 - 1,
344
+ -((t.clientY - o.top) / o.height) * 2 + 1
320
345
  ), this.raycaster.setFromCamera(this.pointer, e);
321
346
  }
322
347
  setForceBoost(t) {
323
348
  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));
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));
325
350
  }
326
351
  beginGrab(t, e, i) {
327
352
  if (!this.runtime || this.disposed) return !1;
328
353
  this.pointerRay(t, e, i);
329
- const r = this.raycaster.intersectObject(this.model, !0).find((c) => c.object.isMesh);
330
- if (!r) return !1;
331
- const s = this.findBodyGroup(r.object);
354
+ const o = this.raycaster.intersectObject(this.model, !0).find((c) => c.object.isMesh);
355
+ if (!o) return !1;
356
+ const s = this.findBodyGroup(o.object);
332
357
  if (!s) return !1;
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());
358
+ const l = s.worldToLocal(o.point.clone());
359
+ this.dragTarget.copy(o.point), L(this.dragPlane, e, o.point), this.dragOffset.set(0, 0, 0);
360
+ const n = this.root.worldToLocal(o.point.clone());
336
361
  return this.bodyGroups.set(s.userData.bodyId, s), this.runtime.beginGrab({
337
362
  bodyId: s.userData.bodyId,
338
363
  localPoint: [l.x, l.y, l.z],
@@ -346,8 +371,8 @@ class W {
346
371
  this.dragTarget.copy(this.dragIntersection).add(this.dragOffset);
347
372
  else
348
373
  return;
349
- const r = this.root.worldToLocal(this.dragTarget.clone());
350
- this.runtime.updateGrabTarget([r.x, r.y, r.z]), this.updateForceLine();
374
+ const o = this.root.worldToLocal(this.dragTarget.clone());
375
+ this.runtime.updateGrabTarget([o.x, o.y, o.z]), this.updateForceLine();
351
376
  }
352
377
  endGrab() {
353
378
  var t;
@@ -359,12 +384,12 @@ class W {
359
384
  if (!t) return;
360
385
  const e = this.getBodyGroup(t.bodyId);
361
386
  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;
387
+ const i = new r.Vector3().fromArray(t.localPoint), o = e.localToWorld(i), s = this.root.worldToLocal(o), l = this.forceLine.geometry.attributes.position;
363
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;
364
389
  }
365
390
  beforeRender(t, e, i) {
366
- var l;
367
- const r = {
391
+ var l, n;
392
+ const o = {
368
393
  tone: t.toneMapping,
369
394
  exposure: t.toneMappingExposure,
370
395
  color: t.outputColorSpace,
@@ -372,15 +397,17 @@ class W {
372
397
  fog: e.fog,
373
398
  background: e.background
374
399
  }, s = () => {
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;
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;
376
401
  };
377
402
  if (this.disposed) return s;
378
403
  try {
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;
404
+ (l = this.runtime) != null && l.grab && this.updateForceLine();
405
+ const c = (n = this.runtime) == null ? void 0 : n.defaultGroundHeight;
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;
409
+ } catch (c) {
410
+ throw s(), c;
384
411
  }
385
412
  }
386
413
  /**
@@ -402,23 +429,26 @@ class W {
402
429
  attachAuxiliary(t) {
403
430
  this.auxiliaries.add(t), this.root.add(t);
404
431
  }
432
+ detachAuxiliary(t) {
433
+ this.auxiliaries.delete(t) && t.removeFromParent();
434
+ }
405
435
  getModelBounds() {
406
436
  this.root.updateMatrixWorld(!0);
407
- const t = new o.Box3().setFromObject(this.model);
437
+ const t = m(this.model);
408
438
  if (!t.isEmpty()) return t;
409
- const e = new o.Box3();
439
+ const e = new r.Box3();
410
440
  return e.min.set(-5e3, -5e3, -5e3), e.max.set(5e3, 5e3, 5e3), e;
411
441
  }
412
442
  dispose() {
413
443
  if (!this.disposed) {
414
444
  this.disposed = !0, this.endGrab(), this.model.removeFromParent();
415
445
  for (const t of this.auxiliaries) t.removeFromParent();
416
- this.auxiliaries.clear(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(), x(this.root);
446
+ this.auxiliaries.clear(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(), y(this.root);
417
447
  }
418
448
  }
419
449
  }
420
450
  export {
421
- W as S,
422
- x as d,
423
- F as r
451
+ B as S,
452
+ y as d,
453
+ W as r
424
454
  };
package/dist/types.d.ts CHANGED
@@ -88,6 +88,8 @@ export interface ViewerFitViewOptions {
88
88
  viewMode?: ViewerViewMode;
89
89
  }
90
90
  export interface ViewerPickOptions {
91
+ /** Stop at the nearest intersection when accelerated picking is available. */
92
+ firstHitOnly?: boolean;
91
93
  roots?: readonly Object3D[];
92
94
  recursive?: boolean;
93
95
  includeInvisible?: boolean;
@@ -33,6 +33,8 @@ export interface ViewerUiOptions {
33
33
  cad?: ViewerCadUiOptions;
34
34
  /** Shared scene controls for model and simulation assets, gated by capabilities. */
35
35
  scene?: ViewerSceneUiOptions;
36
+ /** Built-in URDF review workbench. Defaults to true for preset 'auto'. */
37
+ urdf?: boolean;
36
38
  }
37
39
  export interface ViewerUiTokens {
38
40
  accent?: string;