@nebula-spatial/viewer 0.5.5 → 0.5.7

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +142 -7
  3. package/USD-VISUAL-MATERIAL-SUPPORT.md +14 -3
  4. package/basis/basis_transcoder.js +19 -0
  5. package/basis/basis_transcoder.wasm +0 -0
  6. package/dist/assets/ground-grid.d.ts +6 -0
  7. package/dist/assets/types.d.ts +49 -0
  8. package/dist/assets/usd-worker-B-HuMXLo.js +1505 -0
  9. package/dist/collision-debug-B2CISPB9.js +792 -0
  10. package/dist/index-BTAC6njT.js +10123 -0
  11. package/dist/index.d.ts +10 -2
  12. package/dist/index.js +17 -12
  13. package/dist/inspection/types.d.ts +79 -2
  14. package/dist/{mjcf-visual-zWaLqVqd.js → mjcf-visual-BVT3h87h.js} +7 -7
  15. package/dist/mujoco-runtime-CAyK0LHM.js +698 -0
  16. package/dist/resources-CHhCm2f7.js +27 -0
  17. package/dist/session-BQ8eCFRL.js +786 -0
  18. package/dist/{session-DVCZX72J.js → session-Dwoi1H46.js} +6 -5
  19. package/dist/simulation/mujoco-wasm-module.d.ts +11 -0
  20. package/dist/simulation/openusd-wasm-module.d.ts +10 -0
  21. package/dist/simulation/usd-query.d.ts +50 -0
  22. package/dist/simulation/usd-resource-policy.d.ts +28 -0
  23. package/dist/{stage-DGMYxyAS.js → stage-DUC-YNhD.js} +158 -170
  24. package/dist/{urdf-session-CF8xOenk.js → urdf-session-E0Nnr4Vs.js} +559 -546
  25. package/dist/usd-session-BUD3KtCr.js +6875 -0
  26. package/dist/version.d.ts +1 -1
  27. package/dist/{xacro-DidnrxXF.js → xacro-F7rdDouN.js} +1 -1
  28. package/openusd/openusd-runtime-manifest.json +15 -0
  29. package/openusd/openusd_probe.js +14 -14
  30. package/openusd/openusd_probe.wasm +0 -0
  31. package/package.json +5 -2
  32. package/dist/index-bTlVsOHA.js +0 -8165
  33. package/dist/mujoco-runtime-DTxVmIzc.js +0 -349
  34. package/dist/session-CZghJvw6.js +0 -883
  35. package/dist/usd-session-DkwOFmds.js +0 -4254
@@ -1,10 +1,11 @@
1
- var P = Object.defineProperty;
2
- var C = (u, t, e) => t in u ? P(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
3
- var s = (u, t, e) => C(u, typeof t != "symbol" ? t + "" : t, e);
4
- import * as o from "three";
5
- import { Quaternion as G, Vector3 as F } from "three";
6
- import { V as v, D as S, e as R } from "./index-bTlVsOHA.js";
7
- const y = 1, A = (
1
+ var R = Object.defineProperty;
2
+ var S = (a, t, e) => t in a ? R(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var s = (a, t, e) => S(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import * as i from "three";
5
+ import { Quaternion as C, Vector3 as V } from "three";
6
+ import { V as b, D as A, w as W } from "./index-BTAC6njT.js";
7
+ import { disposeModelResources as T } from "./resources-CHhCm2f7.js";
8
+ const v = 1, B = (
8
9
  /* glsl */
9
10
  `
10
11
  uniform mat4 textureMatrix;
@@ -20,7 +21,7 @@ const y = 1, A = (
20
21
  gl_Position = projectionMatrix * mvPosition;
21
22
  }
22
23
  `
23
- ), V = (
24
+ ), L = (
24
25
  /* glsl */
25
26
  `
26
27
  uniform sampler2D tDiffuse;
@@ -87,38 +88,38 @@ const y = 1, A = (
87
88
  }
88
89
  `
89
90
  );
90
- class T extends o.Mesh {
91
- constructor({ size: e = 20, textureWidth: r = 512, textureHeight: i = 512 } = {}) {
92
- const n = new o.Matrix4(), l = new o.WebGLRenderTarget(r, i, {
93
- type: o.HalfFloatType,
94
- minFilter: o.LinearFilter,
95
- magFilter: o.LinearFilter,
96
- format: o.RGBAFormat,
91
+ class O extends i.Mesh {
92
+ constructor({ size: e = 20, textureWidth: r = 512, textureHeight: o = 512 } = {}) {
93
+ const n = new i.Matrix4(), l = new i.WebGLRenderTarget(r, o, {
94
+ type: i.HalfFloatType,
95
+ minFilter: i.LinearFilter,
96
+ magFilter: i.LinearFilter,
97
+ format: i.RGBAFormat,
97
98
  depthBuffer: !0,
98
99
  samples: 0
99
- }), a = new o.ShaderMaterial({
100
+ }), u = new i.ShaderMaterial({
100
101
  uniforms: {
101
102
  tDiffuse: { value: l.texture },
102
103
  textureMatrix: { value: n },
103
- resolution: { value: new o.Vector2(r, i) },
104
- fineGridColor: { value: new o.Color(2502702) },
105
- coarseGridColor: { value: new o.Color(7897726) },
104
+ resolution: { value: new i.Vector2(r, o) },
105
+ fineGridColor: { value: new i.Color(2502702) },
106
+ coarseGridColor: { value: new i.Color(7897726) },
106
107
  blurIntensity: { value: 1.7 },
107
108
  reflectionMix: { value: 0.07 },
108
109
  gridOpacity: { value: 1 },
109
110
  gridScale: { value: 0.2 },
110
- groundCenter: { value: new o.Vector2() },
111
+ groundCenter: { value: new i.Vector2() },
111
112
  maxRadius: { value: e * 0.5 },
112
113
  fadeSoftness: { value: e * 0.325 }
113
114
  },
114
- vertexShader: A,
115
- fragmentShader: V,
115
+ vertexShader: B,
116
+ fragmentShader: L,
116
117
  transparent: !0,
117
118
  depthWrite: !1,
118
119
  toneMapped: !0,
119
120
  fog: !1
120
121
  });
121
- super(new o.PlaneGeometry(e, e), a);
122
+ super(new i.PlaneGeometry(e, e), u);
122
123
  s(this, "renderTarget");
123
124
  s(this, "textureMatrix");
124
125
  s(this, "virtualCamera");
@@ -133,11 +134,11 @@ class T extends o.Mesh {
133
134
  s(this, "view");
134
135
  s(this, "target");
135
136
  s(this, "q");
136
- this.renderTarget = l, this.textureMatrix = n, this.virtualCamera = new o.PerspectiveCamera(), this.virtualCamera.layers.set(y), 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();
137
+ this.renderTarget = l, this.textureMatrix = n, this.virtualCamera = new i.PerspectiveCamera(), this.virtualCamera.layers.set(v), this.clipBias = 3e-3, this.frustumCulled = !1, this.renderOrder = 1, this.position.z = 2e-3, this.reflectorPlane = new i.Plane(), this.normal = new i.Vector3(), this.reflectorWorldPosition = new i.Vector3(), this.cameraWorldPosition = new i.Vector3(), this.rotationMatrix = new i.Matrix4(), this.lookAtPosition = new i.Vector3(0, 0, -1), this.clipPlane = new i.Vector4(), this.view = new i.Vector3(), this.target = new i.Vector3(), this.q = new i.Vector4();
137
138
  }
138
- renderReflection(e, r, i) {
139
- if (this.reflectorWorldPosition.setFromMatrixPosition(this.matrixWorld), this.cameraWorldPosition.setFromMatrixPosition(i.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;
140
- this.view.reflect(this.normal).negate().add(this.reflectorWorldPosition), this.rotationMatrix.extractRotation(i.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 = i.near, this.virtualCamera.far = i.far, this.virtualCamera.updateMatrixWorld(), this.virtualCamera.projectionMatrix.copy(i.projectionMatrix), this.textureMatrix.set(
139
+ renderReflection(e, r, o) {
140
+ 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;
141
+ 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(
141
142
  0.5,
142
143
  0,
143
144
  0,
@@ -167,100 +168,89 @@ class T extends o.Mesh {
167
168
  -1,
168
169
  (1 + n.elements[10]) / n.elements[14]
169
170
  ), this.clipPlane.multiplyScalar(2 / this.clipPlane.dot(this.q)), n.elements[2] = this.clipPlane.x, n.elements[6] = this.clipPlane.y, n.elements[10] = this.clipPlane.z + 1 - this.clipBias, n.elements[14] = this.clipPlane.w, this.virtualCamera.projectionMatrixInverse.copy(n).invert();
170
- const l = e.getRenderTarget(), a = e.xr.enabled, d = e.shadowMap.autoUpdate, c = e.shadowMap.enabled;
171
+ const l = e.getRenderTarget(), u = e.xr.enabled, d = e.shadowMap.autoUpdate, c = e.shadowMap.enabled;
171
172
  try {
172
173
  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(r, this.virtualCamera);
173
174
  } finally {
174
- e.setRenderTarget(l), e.xr.enabled = a, e.shadowMap.enabled = c, e.shadowMap.autoUpdate = d;
175
+ e.setRenderTarget(l), e.xr.enabled = u, e.shadowMap.enabled = c, e.shadowMap.autoUpdate = d;
175
176
  }
176
177
  }
177
178
  setRenderSize(e, r) {
178
179
  this.renderTarget.setSize(e, r), this.material.uniforms.resolution.value.set(e, r);
179
180
  }
180
181
  // Radius is in world units; the outer 65% fades before the square mesh edge.
181
- setRadius(e, r, i = this.material.uniforms.groundCenter.value) {
182
- this.scale.setScalar(e * 2 / this.geometry.parameters.width), this.position.x = i.x, this.position.y = i.y, this.material.uniforms.groundCenter.value.set(i.x, i.y), this.material.uniforms.gridScale.value = r, this.material.uniforms.maxRadius.value = e, this.material.uniforms.fadeSoftness.value = e * 0.65;
182
+ setRadius(e, r, o = this.material.uniforms.groundCenter.value) {
183
+ 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 = r, this.material.uniforms.maxRadius.value = e, this.material.uniforms.fadeSoftness.value = e * 0.65;
183
184
  }
184
185
  }
185
- const b = {
186
+ const G = {
186
187
  light: {
187
- background: v.light,
188
+ background: b.light,
188
189
  fineGrid: 5859168,
189
190
  coarseGrid: 3427136,
190
191
  gridOpacity: 0.85,
191
192
  reflectionMix: 0.06
192
193
  },
193
194
  dark: {
194
- background: v.dark,
195
+ background: b.dark,
195
196
  fineGrid: 7375236,
196
197
  coarseGrid: 5552554,
197
198
  gridOpacity: 0.9,
198
199
  reflectionMix: 0.06
199
200
  }
200
- }, W = {
201
+ }, E = {
201
202
  simulation: 1.2,
202
203
  model: 1.2
203
- };
204
- function M(u, t = []) {
205
- var l;
206
- const e = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = new Set(t), n = /* @__PURE__ */ new Set();
207
- u.traverse((a) => {
208
- const d = a;
209
- d.geometry && e.add(d.geometry);
210
- for (const c of Array.isArray(d.material) ? d.material : [d.material])
211
- if (c) {
212
- r.add(c);
213
- for (const h of Object.values(c))
214
- L(h) && i.add(h);
215
- }
216
- });
217
- for (const a of e) a.dispose();
218
- for (const a of r) a.dispose();
219
- for (const a of i) {
220
- const d = (l = a.source) == null ? void 0 : l.data;
221
- d && typeof d.close == "function" && n.add(d), a.dispose();
222
- }
223
- for (const a of n) a.close();
224
- }
225
- function L(u) {
226
- return !!(u && typeof u == "object" && u.isTexture);
204
+ }, I = new C().setFromAxisAngle(new V(1, 0, 0), Math.PI / 2), D = new C();
205
+ function tt(a) {
206
+ return a === "glb" || a === "gltf" || a === "fbx" ? "y" : "z";
227
207
  }
228
- const X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
229
- __proto__: null,
230
- disposeModelResources: M
231
- }, Symbol.toStringTag, { value: "Module" })), O = new G().setFromAxisAngle(new F(1, 0, 0), Math.PI / 2), B = new G();
232
- function J(u) {
233
- return u === "glb" || u === "gltf" || u === "fbx" ? "y" : "z";
208
+ function F(a) {
209
+ return a === "y" ? I : D;
234
210
  }
235
- function w(u) {
236
- return u === "y" ? O : B;
211
+ function et(a, t) {
212
+ const e = F(t);
213
+ return e.equals(a.quaternion) ? !1 : (a.quaternion.copy(e), a.updateMatrixWorld(!0), !0);
237
214
  }
238
- function K(u, t) {
239
- const e = w(t);
240
- return e.equals(u.quaternion) ? !1 : (u.quaternion.copy(e), u.updateMatrixWorld(!0), !0);
241
- }
242
- const m = 2213822, E = 6000111, _ = 6, x = 2e-3, D = 1e-4, z = 1e-4, I = 0.18, U = 0.35, N = 0.18, H = 0.75, k = Math.PI / 3;
243
- function q(u, t, e) {
215
+ const m = 2213822, _ = 6000111, z = 6, x = 2e-3, U = 1e-4, N = 1e-4, H = 0.18, k = 0.35, q = 0.18, j = 0.75, Y = Math.PI / 3, y = new i.Vector3(), M = new i.Matrix4(), w = new i.Matrix4();
216
+ function Q(a, t, e) {
244
217
  t.updateMatrixWorld();
245
- const r = new o.Vector3();
246
- return t.getWorldDirection(r).normalize(), u.setFromNormalAndCoplanarPoint(r, e);
218
+ const r = new i.Vector3();
219
+ return t.getWorldDirection(r).normalize(), a.setFromNormalAndCoplanarPoint(r, e);
247
220
  }
248
- function p(u) {
249
- u.updateWorldMatrix(!0, !0);
250
- const t = new o.Box3();
251
- return u.traverse((e) => {
252
- if (!(e instanceof o.Mesh)) return;
221
+ function p(a) {
222
+ a.updateWorldMatrix(!0, !0);
223
+ const t = new i.Box3();
224
+ return a.traverse((e) => {
225
+ if (!(e instanceof i.Mesh)) return;
253
226
  let r = e;
254
227
  for (; r; ) {
255
228
  if (r.userData.excludeFromSimulationFit || !r.visible) return;
256
229
  r = r.parent;
257
230
  }
258
- e.geometry.boundingBox || e.geometry.computeBoundingBox(), e.geometry.boundingBox && t.union(e.geometry.boundingBox.clone().applyMatrix4(e.matrixWorld));
259
- }), t.isEmpty() ? new o.Box3().setFromObject(u) : t;
231
+ X(t, e);
232
+ }), t.isEmpty() ? new i.Box3().setFromObject(a) : t;
233
+ }
234
+ function X(a, t) {
235
+ const e = t.geometry.getAttribute("position");
236
+ if (!e) {
237
+ t.geometry.boundingBox || t.geometry.computeBoundingBox(), t.geometry.boundingBox && a.union(t.geometry.boundingBox.clone().applyMatrix4(t.matrixWorld));
238
+ return;
239
+ }
240
+ if (t instanceof i.InstancedMesh) {
241
+ for (let r = 0; r < t.count; r += 1)
242
+ t.getMatrixAt(r, M), w.multiplyMatrices(t.matrixWorld, M), P(a, t, e.count, w);
243
+ return;
244
+ }
245
+ P(a, t, e.count, t.matrixWorld);
246
+ }
247
+ function P(a, t, e, r) {
248
+ for (let o = 0; o < e; o += 1)
249
+ t.getVertexPosition(o, y), y.applyMatrix4(r), a.expandByPoint(y);
260
250
  }
261
- class Z {
262
- constructor(t, e = "dark", r, i = "simulation", n) {
263
- s(this, "root", new o.Group());
251
+ class rt {
252
+ constructor(t, e = "dark", r, o = "simulation", n) {
253
+ s(this, "root", new i.Group());
264
254
  /**
265
255
  * Owns the up-axis rotation for everything that is *not* driven by the
266
256
  * physics runtime: the URDF kinematic preview, the static collision overlay
@@ -268,30 +258,30 @@ class Z {
268
258
  * the compiled model instead (see `applyUpAxis`), because rotating the scene
269
259
  * graph on top of an already-rotated physics pose would apply it twice.
270
260
  */
271
- s(this, "modelWrapper", new o.Group());
261
+ s(this, "modelWrapper", new i.Group());
272
262
  s(this, "upAxis", "z");
273
263
  /** A flip changes the asset footprint; the ground disc follows on the next frame. */
274
264
  s(this, "groundNeedsRefit", !1);
275
- s(this, "reflector", new T({ size: 100, textureWidth: 256, textureHeight: 256 }));
265
+ s(this, "reflector", new O({ size: 100, textureWidth: 256, textureHeight: 256 }));
276
266
  s(this, "values");
277
267
  s(this, "fog");
278
- s(this, "raycaster", new o.Raycaster());
279
- s(this, "pointer", new o.Vector2());
280
- s(this, "dragPlane", new o.Plane());
281
- s(this, "dragTarget", new o.Vector3());
282
- s(this, "dragIntersection", new o.Vector3());
283
- s(this, "dragOffset", new o.Vector3());
284
- s(this, "groundPlane", new o.Plane(new o.Vector3(0, 0, 1), 0));
285
- s(this, "groundRaycaster", new o.Raycaster());
286
- s(this, "groundNdc", new o.Vector2());
287
- s(this, "groundHit", new o.Vector3());
288
- s(this, "groundGrabPoint", new o.Vector3());
289
- s(this, "groundCenter", new o.Vector2());
290
- s(this, "groundModelFocus", new o.Vector2());
291
- s(this, "groundCameraFocus", new o.Vector2());
292
- s(this, "groundGrabFocus", new o.Vector2());
293
- s(this, "groundCameraPosition", new o.Vector3());
294
- s(this, "groundCameraQuaternion", new o.Quaternion());
268
+ s(this, "raycaster", new i.Raycaster());
269
+ s(this, "pointer", new i.Vector2());
270
+ s(this, "dragPlane", new i.Plane());
271
+ s(this, "dragTarget", new i.Vector3());
272
+ s(this, "dragIntersection", new i.Vector3());
273
+ s(this, "dragOffset", new i.Vector3());
274
+ s(this, "groundPlane", new i.Plane(new i.Vector3(0, 0, 1), 0));
275
+ s(this, "groundRaycaster", new i.Raycaster());
276
+ s(this, "groundNdc", new i.Vector2());
277
+ s(this, "groundHit", new i.Vector3());
278
+ s(this, "groundGrabPoint", new i.Vector3());
279
+ s(this, "groundCenter", new i.Vector2());
280
+ s(this, "groundModelFocus", new i.Vector2());
281
+ s(this, "groundCameraFocus", new i.Vector2());
282
+ s(this, "groundGrabFocus", new i.Vector2());
283
+ s(this, "groundCameraPosition", new i.Vector3());
284
+ s(this, "groundCameraQuaternion", new i.Quaternion());
295
285
  s(this, "bodyGroups", /* @__PURE__ */ new Map());
296
286
  s(this, "auxiliaries", /* @__PURE__ */ new Set());
297
287
  s(this, "forceLine");
@@ -300,7 +290,7 @@ class Z {
300
290
  s(this, "previousCursor", "");
301
291
  s(this, "size", "");
302
292
  s(this, "groundVisible");
303
- s(this, "groundGridScale", S);
293
+ s(this, "groundGridScale", A);
304
294
  s(this, "groundPlacement");
305
295
  s(this, "groundFollowDirty", !0);
306
296
  s(this, "groundInteractionActive", !1);
@@ -308,23 +298,23 @@ class Z {
308
298
  s(this, "groundGrabBlend", 0);
309
299
  s(this, "groundCameraPoseValid", !1);
310
300
  s(this, "disposed", !1);
311
- this.model = t, this.runtime = r, this.presentation = i, this.groundPlacement = n ?? (i === "model" ? "visual" : "physics"), this.values = b[e];
312
- const l = this.values, a = p(t), d = Math.max(...a.getSize(new o.Vector3()).toArray());
301
+ this.model = t, this.runtime = r, this.presentation = o, this.groundPlacement = n ?? (o === "model" ? "visual" : "physics"), this.values = G[e];
302
+ const l = this.values, u = p(t), d = Math.max(...u.getSize(new i.Vector3()).toArray());
313
303
  if (!Number.isFinite(d) || d <= 0) throw new Error("Empty simulation geometry.");
314
304
  this.modelWrapper.name = "simulation-model-wrapper", this.root.add(this.modelWrapper), this.modelWrapper.add(t), this.forceLine = this.createForceLine(), this.root.add(this.forceLine), t.traverse((g) => {
315
- g instanceof o.Mesh && g.layers.enable(y);
305
+ g instanceof i.Mesh && g.layers.enable(v);
316
306
  }), this.root.add(this.reflector);
317
- const c = Math.max(a.getSize(new o.Vector3()).length() * 0.5, 0.02), h = this.reflector.material.uniforms;
318
- h.fineGridColor.value.setHex(l.fineGrid), h.coarseGridColor.value.setHex(l.coarseGrid), h.gridOpacity.value = l.gridOpacity, h.reflectionMix.value = l.reflectionMix, this.layoutGround(a, c), this.groundVisible = i === "simulation", this.setGroundVisible(this.groundVisible);
319
- const f = c / Math.sin(o.MathUtils.degToRad(38) / 2) * 1.25;
320
- this.fog = new o.Fog(l.background, f * 2.5, f * 8);
307
+ const c = Math.max(u.getSize(new i.Vector3()).length() * 0.5, 0.02), h = this.reflector.material.uniforms;
308
+ h.fineGridColor.value.setHex(l.fineGrid), h.coarseGridColor.value.setHex(l.coarseGrid), h.gridOpacity.value = l.gridOpacity, h.reflectionMix.value = l.reflectionMix, this.layoutGround(u, c), this.groundVisible = !0, this.setGroundVisible(this.groundVisible);
309
+ const f = c / Math.sin(i.MathUtils.degToRad(38) / 2) * 1.25;
310
+ this.fog = new i.Fog(l.background, f * 2.5, f * 8);
321
311
  }
322
312
  setRuntime(t) {
323
313
  this.disposed || this.runtime === t || (this.endGrab(), this.runtime = t, t && (this.groundPlacement = "physics"), this.bodyGroups.clear(), this.groundGrabFocusValid = !1, this.groundGrabBlend = 0, this.groundFollowDirty = !0, this.applyUpAxis());
324
314
  }
325
315
  replaceModel(t, e = !0) {
326
316
  this.disposed || t === this.model || (this.endGrab(), this.bodyGroups.clear(), this.model.removeFromParent(), this.model = t, this.modelWrapper.add(t), t.traverse((r) => {
327
- r instanceof o.Mesh && r.layers.enable(y);
317
+ r instanceof i.Mesh && r.layers.enable(v);
328
318
  }), e && this.reseatGround());
329
319
  }
330
320
  /**
@@ -344,7 +334,7 @@ class Z {
344
334
  return this.upAxis;
345
335
  }
346
336
  applyUpAxis() {
347
- const t = w(this.upAxis);
337
+ const t = F(this.upAxis);
348
338
  this.runtime ? (this.modelWrapper.quaternion.identity(), this.runtime.setWorldRotation(t)) : this.modelWrapper.quaternion.copy(t), this.modelWrapper.updateMatrixWorld(!0), this.groundNeedsRefit = !0;
349
339
  }
350
340
  resetGround() {
@@ -359,14 +349,14 @@ class Z {
359
349
  }
360
350
  setTheme(t) {
361
351
  if (this.disposed) return;
362
- const e = this.values = b[t], r = this.reflector.material.uniforms;
352
+ const e = this.values = G[t], r = this.reflector.material.uniforms;
363
353
  r.fineGridColor.value.setHex(e.fineGrid), r.coarseGridColor.value.setHex(e.coarseGrid), r.gridOpacity.value = e.gridOpacity, r.reflectionMix.value = e.reflectionMix, this.fog.color.setHex(e.background);
364
354
  }
365
355
  layoutGround(t, e) {
366
- this.groundGridScale = R(t.getSize(new o.Vector3()).length()), this.setGroundModelFocus(t), this.groundCenter.copy(this.groundModelFocus), this.groundInteractionActive = !1, this.groundGrabFocusValid = !1, this.groundGrabBlend = 0, this.groundFollowDirty = !0, this.reflector.setRadius(e * 8, this.groundGridScale, this.groundCenter), this.positionGround(t);
356
+ this.groundGridScale = W(t.getSize(new i.Vector3()).length()), this.setGroundModelFocus(t), this.groundCenter.copy(this.groundModelFocus), this.groundInteractionActive = !1, this.groundGrabFocusValid = !1, this.groundGrabBlend = 0, this.groundFollowDirty = !0, this.reflector.setRadius(e * 8, this.groundGridScale, this.groundCenter), this.positionGround(t);
367
357
  }
368
358
  setGroundModelFocus(t) {
369
- const e = t.getCenter(new o.Vector3());
359
+ const e = t.getCenter(new i.Vector3());
370
360
  this.groundModelFocus.set(e.x, e.y);
371
361
  }
372
362
  /**
@@ -384,8 +374,8 @@ class Z {
384
374
  this.reflector.position.z = x;
385
375
  return;
386
376
  }
387
- const r = t.getSize(new o.Vector3()).length(), i = Math.max(r * D, z);
388
- this.reflector.position.z = t.min.z - i;
377
+ const r = t.getSize(new i.Vector3()).length(), o = Math.max(r * U, N);
378
+ this.reflector.position.z = t.min.z - o;
389
379
  }
390
380
  /**
391
381
  * The ground keeps its model-sized fade radius; only this local pool follows
@@ -393,28 +383,28 @@ class Z {
393
383
  * stationary while the illuminated patch moves like a handheld light.
394
384
  */
395
385
  refreshGroundFocus(t) {
396
- const e = this.reflector.material.uniforms.maxRadius.value, r = this.detectGroundCameraJump(t, e), i = this.groundInteractionActive && this.measureGrabbedBodyFocus(), n = this.measureCameraGroundFocus(t, this.reflector.position.z);
386
+ const e = this.reflector.material.uniforms.maxRadius.value, r = this.detectGroundCameraJump(t, e), o = this.groundInteractionActive && this.measureGrabbedBodyFocus(), n = this.measureCameraGroundFocus(t, this.reflector.position.z);
397
387
  n && (this.limitCameraGroundFocus(e), this.groundCameraFocus.set(this.groundHit.x, this.groundHit.y));
398
388
  const l = this.groundInteractionActive && this.groundGrabFocusValid ? 1 : 0;
399
- if (this.groundGrabBlend += (l - this.groundGrabBlend) * N, Math.abs(l - this.groundGrabBlend) < 1e-3 && (this.groundGrabBlend = l), this.groundFollowDirty) {
400
- i ? this.groundCenter.copy(this.groundGrabFocus) : this.groundCenter.copy(this.groundModelFocus), this.reflector.setRadius(e, this.groundGridScale, this.groundCenter), this.reflector.updateMatrixWorld(!0), this.groundFollowDirty = !1;
389
+ if (this.groundGrabBlend += (l - this.groundGrabBlend) * q, Math.abs(l - this.groundGrabBlend) < 1e-3 && (this.groundGrabBlend = l), this.groundFollowDirty) {
390
+ o ? this.groundCenter.copy(this.groundGrabFocus) : this.groundCenter.copy(this.groundModelFocus), this.reflector.setRadius(e, this.groundGridScale, this.groundCenter), this.reflector.updateMatrixWorld(!0), this.groundFollowDirty = !1;
401
391
  return;
402
392
  }
403
- let a = n ? this.groundCameraFocus.x : this.groundCenter.x, d = n ? this.groundCameraFocus.y : this.groundCenter.y;
404
- i && this.groundModelFocus.copy(this.groundGrabFocus), this.groundGrabFocusValid && this.groundGrabBlend > 0 && (a += (this.groundGrabFocus.x - a) * this.groundGrabBlend, d += (this.groundGrabFocus.y - d) * this.groundGrabBlend);
405
- const c = a - this.groundCenter.x, h = d - this.groundCenter.y, f = Math.hypot(c, h);
393
+ let u = n ? this.groundCameraFocus.x : this.groundCenter.x, d = n ? this.groundCameraFocus.y : this.groundCenter.y;
394
+ o && this.groundModelFocus.copy(this.groundGrabFocus), this.groundGrabFocusValid && this.groundGrabBlend > 0 && (u += (this.groundGrabFocus.x - u) * this.groundGrabBlend, d += (this.groundGrabFocus.y - d) * this.groundGrabBlend);
395
+ const c = u - this.groundCenter.x, h = d - this.groundCenter.y, f = Math.hypot(c, h);
406
396
  if (!(!r && f <= Math.max(e * 5e-4, 1e-5))) {
407
397
  if (r)
408
- this.groundCenter.set(a, d);
398
+ this.groundCenter.set(u, d);
409
399
  else {
410
- const g = this.groundInteractionActive ? U : I;
400
+ const g = this.groundInteractionActive ? k : H;
411
401
  this.groundCenter.x += c * g, this.groundCenter.y += h * g;
412
402
  }
413
403
  this.reflector.setRadius(e, this.groundGridScale, this.groundCenter), this.reflector.updateMatrixWorld(!0);
414
404
  }
415
405
  }
416
406
  detectGroundCameraJump(t, e) {
417
- const r = this.groundCameraPoseValid && (t.position.distanceTo(this.groundCameraPosition) > Math.max(e * H, 0.1) || t.quaternion.angleTo(this.groundCameraQuaternion) > k);
407
+ const r = this.groundCameraPoseValid && (t.position.distanceTo(this.groundCameraPosition) > Math.max(e * j, 0.1) || t.quaternion.angleTo(this.groundCameraQuaternion) > Y);
418
408
  return this.groundCameraPosition.copy(t.position), this.groundCameraQuaternion.copy(t.quaternion), this.groundCameraPoseValid = !0, r;
419
409
  }
420
410
  measureGrabbedBodyFocus() {
@@ -425,10 +415,10 @@ class Z {
425
415
  return e ? (this.groundGrabPoint.fromArray(t.localPoint), e.localToWorld(this.groundGrabPoint), this.root.worldToLocal(this.groundGrabPoint), this.groundHit.copy(this.groundGrabPoint), this.groundGrabFocus.set(this.groundGrabPoint.x, this.groundGrabPoint.y), this.groundGrabFocusValid = !0, !0) : !1;
426
416
  }
427
417
  limitCameraGroundFocus(t) {
428
- const e = t * 0.25, r = this.groundHit.x - this.groundModelFocus.x, i = this.groundHit.y - this.groundModelFocus.y, n = Math.hypot(r, i);
418
+ const e = t * 0.25, r = this.groundHit.x - this.groundModelFocus.x, o = this.groundHit.y - this.groundModelFocus.y, n = Math.hypot(r, o);
429
419
  if (n <= e || n <= 0) return;
430
420
  const l = e / n;
431
- this.groundHit.x = this.groundModelFocus.x + r * l, this.groundHit.y = this.groundModelFocus.y + i * l;
421
+ this.groundHit.x = this.groundModelFocus.x + r * l, this.groundHit.y = this.groundModelFocus.y + o * l;
432
422
  }
433
423
  measureCameraGroundFocus(t, e) {
434
424
  return this.groundPlane.constant = -e, this.groundNdc.set(0, 0), this.groundRaycaster.setFromCamera(this.groundNdc, t), this.groundRaycaster.ray.intersectPlane(this.groundPlane, this.groundHit) !== null;
@@ -443,18 +433,18 @@ class Z {
443
433
  if (this.disposed) return;
444
434
  this.root.updateMatrixWorld(!0);
445
435
  const t = p(this.model);
446
- t.isEmpty() || this.layoutGround(t, Math.max(t.getSize(new o.Vector3()).length() * 0.5, 0.02));
436
+ t.isEmpty() || this.layoutGround(t, Math.max(t.getSize(new i.Vector3()).length() * 0.5, 0.02));
447
437
  }
448
438
  createForceLine() {
449
- const t = new o.BufferGeometry().setFromPoints([
450
- new o.Vector3(),
451
- new o.Vector3()
452
- ]), e = new o.LineBasicMaterial({
439
+ const t = new i.BufferGeometry().setFromPoints([
440
+ new i.Vector3(),
441
+ new i.Vector3()
442
+ ]), e = new i.LineBasicMaterial({
453
443
  color: m,
454
444
  depthTest: !1,
455
445
  transparent: !0
456
- }), r = new o.Line(t, e);
457
- return r.renderOrder = 1e3, r.visible = !1, r;
446
+ }), r = new i.Line(t, e);
447
+ return r.frustumCulled = !1, r.renderOrder = 1e3, r.visible = !1, r;
458
448
  }
459
449
  findBodyGroup(t) {
460
450
  var r;
@@ -468,35 +458,35 @@ class Z {
468
458
  getBodyGroup(t) {
469
459
  let e = this.bodyGroups.get(t);
470
460
  return e || this.model.traverse((r) => {
471
- var i;
472
- ((i = r.userData) == null ? void 0 : i.bodyId) === t && (e = r, this.bodyGroups.set(t, r));
461
+ var o;
462
+ ((o = r.userData) == null ? void 0 : o.bodyId) === t && (e = r, this.bodyGroups.set(t, r));
473
463
  }), e;
474
464
  }
475
465
  pointerRay(t, e, r) {
476
- const i = r.getBoundingClientRect();
466
+ const o = r.getBoundingClientRect();
477
467
  this.pointer.set(
478
- (t.clientX - i.left) / i.width * 2 - 1,
479
- -((t.clientY - i.top) / i.height) * 2 + 1
468
+ (t.clientX - o.left) / o.width * 2 - 1,
469
+ -((t.clientY - o.top) / o.height) * 2 + 1
480
470
  ), this.raycaster.setFromCamera(this.pointer, e);
481
471
  }
482
472
  setForceBoost(t) {
483
473
  var e;
484
- !((e = this.runtime) != null && e.grab) || t === this.forceBoosted || (this.forceBoosted = t, this.runtime.updateGrabStrength(t ? _ : 1), this.forceLine.material.color.setHex(t ? E : m));
474
+ !((e = this.runtime) != null && e.grab) || t === this.forceBoosted || (this.forceBoosted = t, this.runtime.updateGrabStrength(t ? z : 1), this.forceLine.material.color.setHex(t ? _ : m));
485
475
  }
486
476
  beginGrab(t, e, r) {
487
477
  if (!this.runtime || this.disposed) return !1;
488
478
  this.pointerRay(t, e, r);
489
- const i = this.raycaster.intersectObject(this.model, !0).find((d) => d.object.isMesh);
490
- if (!i) return !1;
491
- const n = this.findBodyGroup(i.object);
479
+ const o = this.raycaster.intersectObject(this.model, !0).find((d) => d.object.isMesh);
480
+ if (!o) return !1;
481
+ const n = this.findBodyGroup(o.object);
492
482
  if (!n) return !1;
493
- const l = n.worldToLocal(i.point.clone());
494
- this.dragTarget.copy(i.point), q(this.dragPlane, e, i.point), this.dragOffset.set(0, 0, 0);
495
- const a = this.root.worldToLocal(i.point.clone());
483
+ const l = n.worldToLocal(o.point.clone());
484
+ this.dragTarget.copy(o.point), Q(this.dragPlane, e, o.point), this.dragOffset.set(0, 0, 0);
485
+ const u = this.root.worldToLocal(o.point.clone());
496
486
  return this.groundInteractionActive = !0, this.bodyGroups.set(n.userData.bodyId, n), this.runtime.beginGrab({
497
487
  bodyId: n.userData.bodyId,
498
488
  localPoint: [l.x, l.y, l.z],
499
- target: [a.x, a.y, a.z]
489
+ target: [u.x, u.y, u.z]
500
490
  }), this.forceBoosted = !1, this.setForceBoost(t.shiftKey), this.forceLine.visible = !0, this.updateForceLine(), this.grabCanvas = r, r != null && r.style && (this.previousCursor = r.style.cursor, r.style.cursor = "grabbing"), !0;
501
491
  }
502
492
  moveGrab(t, e, r) {
@@ -506,25 +496,25 @@ class Z {
506
496
  this.dragTarget.copy(this.dragIntersection).add(this.dragOffset);
507
497
  else
508
498
  return;
509
- const i = this.root.worldToLocal(this.dragTarget.clone());
510
- this.runtime.updateGrabTarget([i.x, i.y, i.z]), this.updateForceLine();
499
+ const o = this.root.worldToLocal(this.dragTarget.clone());
500
+ this.runtime.updateGrabTarget([o.x, o.y, o.z]), this.updateForceLine();
511
501
  }
512
502
  endGrab() {
513
503
  var t;
514
504
  this.runtime && (this.runtime.endGrab(), this.groundInteractionActive = !1, this.forceBoosted = !1, this.forceLine.visible = !1, this.forceLine.material.color.setHex(m), (t = this.grabCanvas) != null && t.style && (this.grabCanvas.style.cursor = this.previousCursor), this.grabCanvas = null);
515
505
  }
516
506
  updateForceLine() {
517
- var a;
518
- const t = (a = this.runtime) == null ? void 0 : a.grab;
507
+ var u;
508
+ const t = (u = this.runtime) == null ? void 0 : u.grab;
519
509
  if (!t) return;
520
510
  const e = this.getBodyGroup(t.bodyId);
521
511
  if (!e) return;
522
- const r = new o.Vector3().fromArray(t.localPoint), i = e.localToWorld(r), n = this.root.worldToLocal(i), l = this.forceLine.geometry.attributes.position;
512
+ const r = new i.Vector3().fromArray(t.localPoint), o = e.localToWorld(r), n = this.root.worldToLocal(o), l = this.forceLine.geometry.attributes.position;
523
513
  l.setXYZ(0, n.x, n.y, n.z), l.setXYZ(1, t.target[0], t.target[1], t.target[2]), l.needsUpdate = !0;
524
514
  }
525
515
  beforeRender(t, e, r) {
526
- var l, a;
527
- const i = {
516
+ var l, u;
517
+ const o = {
528
518
  tone: t.toneMapping,
529
519
  exposure: t.toneMappingExposure,
530
520
  color: t.outputColorSpace,
@@ -532,15 +522,15 @@ class Z {
532
522
  fog: e.fog,
533
523
  background: e.background
534
524
  }, n = () => {
535
- t.toneMapping = i.tone, t.toneMappingExposure = i.exposure, t.outputColorSpace = i.color, e.environment = i.environment, e.fog = i.fog, e.background = i.background;
525
+ t.toneMapping = o.tone, t.toneMappingExposure = o.exposure, t.outputColorSpace = o.color, e.environment = o.environment, e.fog = o.fog, e.background = o.background;
536
526
  };
537
527
  if (this.disposed) return n;
538
528
  try {
539
529
  this.groundNeedsRefit && (this.groundNeedsRefit = !1, this.reseatGround()), (l = this.runtime) != null && l.grab && this.updateForceLine();
540
- const d = (a = this.runtime) == null ? void 0 : a.defaultGroundHeight;
541
- d !== void 0 && (this.reflector.position.z = d + 2e-3), t.toneMapping = o.ACESFilmicToneMapping, t.toneMappingExposure = W[this.presentation], t.outputColorSpace = o.SRGBColorSpace, e.background = new o.Color(this.values.background), e.fog = this.fog;
542
- const c = t.getSize(new o.Vector2()), h = `${c.x}:${c.y}`;
543
- return h !== this.size && (this.size = h, this.reflector.setRenderSize(Math.max(1, Math.floor(c.x * 0.35)), Math.max(1, Math.floor(c.y * 0.35)))), e.updateMatrixWorld(!0), r.updateMatrixWorld(!0), this.groundVisible && this.refreshGroundFocus(r), this.groundVisible && r instanceof o.PerspectiveCamera && this.reflector.renderReflection(t, e, r), n;
530
+ const d = (u = this.runtime) == null ? void 0 : u.defaultGroundHeight;
531
+ d !== void 0 && (this.reflector.position.z = d + 2e-3), t.toneMapping = i.ACESFilmicToneMapping, t.toneMappingExposure = E[this.presentation], t.outputColorSpace = i.SRGBColorSpace, e.background = new i.Color(this.values.background), e.fog = this.fog;
532
+ const c = t.getSize(new i.Vector2()), h = `${c.x}:${c.y}`;
533
+ return h !== this.size && (this.size = h, this.reflector.setRenderSize(Math.max(1, Math.floor(c.x * 0.35)), Math.max(1, Math.floor(c.y * 0.35)))), e.updateMatrixWorld(!0), r.updateMatrixWorld(!0), this.groundVisible && this.refreshGroundFocus(r), this.groundVisible && r instanceof i.PerspectiveCamera && this.reflector.renderReflection(t, e, r), n;
544
534
  } catch (d) {
545
535
  throw n(), d;
546
536
  }
@@ -576,22 +566,20 @@ class Z {
576
566
  this.root.updateMatrixWorld(!0);
577
567
  const t = p(this.model);
578
568
  if (!t.isEmpty()) return t;
579
- const e = new o.Box3();
569
+ const e = new i.Box3();
580
570
  return e.min.set(-5e3, -5e3, -5e3), e.max.set(5e3, 5e3, 5e3), e;
581
571
  }
582
572
  dispose() {
583
573
  if (!this.disposed) {
584
574
  this.disposed = !0, this.endGrab(), this.model.removeFromParent();
585
575
  for (const t of this.auxiliaries) t.removeFromParent();
586
- this.auxiliaries.clear(), this.modelWrapper.removeFromParent(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(), M(this.root);
576
+ this.auxiliaries.clear(), this.modelWrapper.removeFromParent(), this.root.removeFromParent(), this.reflector.renderTarget.dispose(), T(this.root);
587
577
  }
588
578
  }
589
579
  }
590
580
  export {
591
- Z as S,
592
- K as a,
593
- M as b,
594
- J as d,
595
- w as m,
596
- X as r
581
+ rt as S,
582
+ et as a,
583
+ tt as d,
584
+ F as m
597
585
  };