@tresjs/core 3.5.0 → 3.5.2

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/dist/tres.js CHANGED
@@ -1,29 +1,29 @@
1
1
  /**
2
2
  * name: @tresjs/core
3
- * version: v3.5.0
3
+ * version: v3.5.2
4
4
  * (c) 2023
5
5
  * description: Declarative ThreeJS using Vue Components
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
7
7
  */
8
- import { ref as L, computed as A, watchEffect as D, onUnmounted as N, shallowRef as x, watch as ee, reactive as se, readonly as ie, provide as z, inject as le, createRenderer as ue, defineComponent as q, useSlots as ce, getCurrentInstance as U, onMounted as fe, openBlock as pe, createElementBlock as me, normalizeClass as de, normalizeStyle as ve, h as J, Fragment as ge } from "vue";
8
+ import { ref as O, computed as D, watchEffect as b, onUnmounted as N, shallowRef as B, watch as ee, reactive as se, readonly as ie, provide as z, inject as le, createRenderer as ue, defineComponent as q, useSlots as ce, getCurrentInstance as U, onMounted as fe, openBlock as pe, createElementBlock as me, normalizeClass as de, normalizeStyle as ve, h as J, Fragment as ge } from "vue";
9
9
  import * as ye from "three";
10
- import { PerspectiveCamera as I, OrthographicCamera as we, Camera as Ce, Clock as Pe, Vector3 as he, Color as H, REVISION as Ee, SRGBColorSpace as _e, ACESFilmicToneMapping as Me, PCFSoftShadowMap as Ae, WebGLRenderer as $, LoadingManager as ke, TextureLoader as De, Vector2 as be, Raycaster as xe, BufferAttribute as Be, Scene as Le } from "three";
11
- import { createEventHook as B, useRafFn as Oe, toValue as E, unrefElement as Te, useDevicePixelRatio as Se, usePointer as Re, useElementBounding as He, useWindowSize as je, useElementSize as Fe } from "@vueuse/core";
10
+ import { PerspectiveCamera as I, OrthographicCamera as we, Camera as Ce, Clock as Pe, Vector3 as he, Color as H, REVISION as Ee, SRGBColorSpace as _e, ACESFilmicToneMapping as Me, PCFSoftShadowMap as Ae, WebGLRenderer as $, LoadingManager as ke, TextureLoader as De, Vector2 as be, Raycaster as Le, BufferAttribute as Be, Scene as xe } from "three";
11
+ import { createEventHook as x, useRafFn as Oe, toValue as h, unrefElement as Te, useDevicePixelRatio as Se, usePointer as Re, useElementBounding as He, useWindowSize as je, useElementSize as Fe } from "@vueuse/core";
12
12
  const $e = ({ sizes: e, scene: a }) => {
13
- const t = L([]), r = A(
13
+ const t = O([]), r = D(
14
14
  () => t.value[0]
15
- ), n = (s, f = !1) => {
16
- t.value.some(({ uuid: i }) => i === s.uuid) || (f ? u(s) : t.value.push(s));
15
+ ), n = (s, u = !1) => {
16
+ t.value.some(({ uuid: i }) => i === s.uuid) || (u ? c(s) : t.value.push(s));
17
17
  }, o = (s) => {
18
- t.value = t.value.filter(({ uuid: f }) => f !== s.uuid);
19
- }, u = (s) => {
20
- const f = s instanceof Ce ? s : t.value.find((m) => m.uuid === s);
21
- if (!f)
18
+ t.value = t.value.filter(({ uuid: u }) => u !== s.uuid);
19
+ }, c = (s) => {
20
+ const u = s instanceof Ce ? s : t.value.find((m) => m.uuid === s);
21
+ if (!u)
22
22
  return;
23
- const i = t.value.filter(({ uuid: m }) => m !== f.uuid);
24
- t.value = [f, ...i];
23
+ const i = t.value.filter(({ uuid: m }) => m !== u.uuid);
24
+ t.value = [u, ...i];
25
25
  };
26
- return D(() => {
26
+ return b(() => {
27
27
  e.aspectRatio.value && t.value.forEach((s) => {
28
28
  s instanceof I && (s.aspect = e.aspectRatio.value), (s instanceof I || s instanceof we) && s.updateProjectionMatrix();
29
29
  });
@@ -34,18 +34,18 @@ const $e = ({ sizes: e, scene: a }) => {
34
34
  cameras: t,
35
35
  registerCamera: n,
36
36
  deregisterCamera: o,
37
- setCameraActive: u
37
+ setCameraActive: c
38
38
  };
39
- }, te = B(), re = B(), W = B(), b = new Pe();
39
+ }, te = x(), re = x(), W = x(), L = new Pe();
40
40
  let j = 0, F = 0;
41
41
  const { pause: ze, resume: Ie, isActive: Ge } = Oe(
42
42
  () => {
43
- te.trigger({ delta: j, elapsed: F, clock: b }), re.trigger({ delta: j, elapsed: F, clock: b }), W.trigger({ delta: j, elapsed: F, clock: b });
43
+ te.trigger({ delta: j, elapsed: F, clock: L }), re.trigger({ delta: j, elapsed: F, clock: L }), W.trigger({ delta: j, elapsed: F, clock: L });
44
44
  },
45
45
  { immediate: !1 }
46
46
  );
47
47
  W.on(() => {
48
- j = b.getDelta(), F = b.getElapsedTime();
48
+ j = L.getDelta(), F = L.getElapsedTime();
49
49
  });
50
50
  const ne = () => ({
51
51
  onBeforeLoop: te.on,
@@ -55,7 +55,7 @@ const ne = () => ({
55
55
  resume: Ie,
56
56
  isActive: Ge
57
57
  }), dt = !0, K = "[TresJS ▲ ■ ●] ";
58
- function O() {
58
+ function T() {
59
59
  function e(r, n) {
60
60
  console.error(`${K} ${r}`, n || "");
61
61
  }
@@ -107,12 +107,12 @@ const Ue = (e, a) => {
107
107
  return t == null ? void 0 : t.reduce((r, n) => r && r[n], e);
108
108
  }, Je = (e, a, t) => {
109
109
  const r = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
110
- r && r.reduce((n, o, u) => (n[o] === void 0 && (n[o] = {}), u === r.length - 1 && (n[o] = t), n[o]), e);
110
+ r && r.reduce((n, o, c) => (n[o] === void 0 && (n[o] = {}), c === r.length - 1 && (n[o] = t), n[o]), e);
111
111
  };
112
112
  function oe(e, a) {
113
113
  if (X(e) && X(a)) {
114
114
  const n = e.attributes, o = a.attributes;
115
- return n.length !== o.length ? !1 : Array.from(n).every(({ name: u, value: s }) => a.getAttribute(u) === s);
115
+ return n.length !== o.length ? !1 : Array.from(n).every(({ name: c, value: s }) => a.getAttribute(c) === s);
116
116
  }
117
117
  if (e === a)
118
118
  return !0;
@@ -154,65 +154,65 @@ function Qe({
154
154
  disableRender: r,
155
155
  contextParts: { sizes: n, camera: o }
156
156
  }) {
157
- const u = A(() => ({
158
- alpha: E(t.alpha),
159
- depth: E(t.depth),
157
+ const c = D(() => ({
158
+ alpha: h(t.alpha),
159
+ depth: h(t.depth),
160
160
  canvas: Te(a),
161
- context: E(t.context),
162
- stencil: E(t.stencil),
163
- antialias: E(t.antialias) === void 0 ? !0 : E(t.antialias),
164
- precision: E(t.precision),
165
- powerPreference: E(t.powerPreference),
166
- premultipliedAlpha: E(t.premultipliedAlpha),
167
- preserveDrawingBuffer: E(t.preserveDrawingBuffer),
168
- logarithmicDepthBuffer: E(t.logarithmicDepthBuffer),
169
- failIfMajorPerformanceCaveat: E(t.failIfMajorPerformanceCaveat)
170
- })), s = x(new $(u.value));
171
- ee(u, () => {
172
- s.value.dispose(), s.value = new $(u.value);
173
- }), D(() => {
161
+ context: h(t.context),
162
+ stencil: h(t.stencil),
163
+ antialias: h(t.antialias) === void 0 ? !0 : h(t.antialias),
164
+ precision: h(t.precision),
165
+ powerPreference: h(t.powerPreference),
166
+ premultipliedAlpha: h(t.premultipliedAlpha),
167
+ preserveDrawingBuffer: h(t.preserveDrawingBuffer),
168
+ logarithmicDepthBuffer: h(t.logarithmicDepthBuffer),
169
+ failIfMajorPerformanceCaveat: h(t.failIfMajorPerformanceCaveat)
170
+ })), s = B(new $(c.value));
171
+ ee(c, () => {
172
+ s.value.dispose(), s.value = new $(c.value);
173
+ }), b(() => {
174
174
  s.value.setSize(n.width.value, n.height.value);
175
175
  });
176
- const { pixelRatio: f } = Se();
177
- D(() => {
178
- s.value.setPixelRatio(f.value);
176
+ const { pixelRatio: u } = Se();
177
+ b(() => {
178
+ s.value.setPixelRatio(u.value);
179
179
  });
180
- const { logError: i } = O(), c = (() => {
181
- const v = new $(), w = {
180
+ const { logError: i } = T(), f = (() => {
181
+ const p = new $(), g = {
182
182
  shadowMap: {
183
- enabled: v.shadowMap.enabled,
184
- type: v.shadowMap.type
183
+ enabled: p.shadowMap.enabled,
184
+ type: p.shadowMap.type
185
185
  },
186
- toneMapping: v.toneMapping,
187
- toneMappingExposure: v.toneMappingExposure,
188
- outputColorSpace: v.outputColorSpace
186
+ toneMapping: p.toneMapping,
187
+ toneMappingExposure: p.toneMappingExposure,
188
+ outputColorSpace: p.outputColorSpace
189
189
  };
190
- return v.dispose(), w;
190
+ return p.dispose(), g;
191
191
  })();
192
- D(() => {
193
- const v = E(t.preset);
194
- v && (v in R || i(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), ae(s.value, R[v]));
195
- const w = (P, C) => {
196
- const k = E(P), T = () => {
197
- if (v)
198
- return Y(R[v], C);
192
+ b(() => {
193
+ const p = h(t.preset);
194
+ p && (p in R || i(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), ae(s.value, R[p]));
195
+ const g = (M, _) => {
196
+ const P = h(M), A = () => {
197
+ if (p)
198
+ return Y(R[p], _);
199
199
  };
200
- if (k !== void 0)
201
- return k;
202
- const y = T();
203
- return y !== void 0 ? y : Y(c, C);
204
- }, h = (P, C) => Je(s.value, C, w(P, C));
205
- h(t.shadows, "shadowMap.enabled"), h(t.toneMapping, "toneMapping"), h(t.shadowMapType, "shadowMap.type"), Ye < 150 && h(!t.useLegacyLights, "physicallyCorrectLights"), h(t.outputColorSpace, "outputColorSpace"), h(t.toneMappingExposure, "toneMappingExposure");
206
- const M = w(t.clearColor, "clearColor");
207
- M && s.value.setClearColor(
208
- M ? Ne(M) : new H(0)
200
+ if (P !== void 0)
201
+ return P;
202
+ const y = A();
203
+ return y !== void 0 ? y : Y(f, _);
204
+ }, C = (M, _) => Je(s.value, _, g(M, _));
205
+ C(t.shadows, "shadowMap.enabled"), C(t.toneMapping, "toneMapping"), C(t.shadowMapType, "shadowMap.type"), Ye < 150 && C(!t.useLegacyLights, "physicallyCorrectLights"), C(t.outputColorSpace, "outputColorSpace"), C(t.toneMappingExposure, "toneMappingExposure");
206
+ const k = g(t.clearColor, "clearColor");
207
+ k && s.value.setClearColor(
208
+ k ? Ne(k) : new H(0)
209
209
  // default clear color is not easily/efficiently retrievable from three
210
210
  );
211
211
  });
212
- const { pause: l, resume: p, onLoop: d } = ne();
213
- return d(() => {
214
- o.value && !E(r) && s.value.render(e, o.value);
215
- }), p(), N(() => {
212
+ const { pause: l, resume: d, onLoop: w } = ne();
213
+ return w(() => {
214
+ o.value && !h(r) && s.value.render(e, o.value);
215
+ }), d(), N(() => {
216
216
  l(), s.value.dispose(), s.value.forceContextLoss();
217
217
  }), {
218
218
  renderer: s
@@ -226,30 +226,30 @@ function et(e) {
226
226
  }), a;
227
227
  }
228
228
  async function gt(e, a, t, r, n) {
229
- const { logError: o } = O(), u = new e();
230
- n && n(u), t && t(u);
231
- const f = (Array.isArray(a) ? a : [a]).map(
232
- (i) => new Promise((m, c) => {
233
- u.load(
229
+ const { logError: o } = T(), c = new e();
230
+ n && n(c), t && t(c);
231
+ const u = (Array.isArray(a) ? a : [a]).map(
232
+ (i) => new Promise((m, f) => {
233
+ c.load(
234
234
  i,
235
235
  (l) => {
236
236
  l.scene && Object.assign(l, et(l.scene)), m(l);
237
237
  },
238
238
  r,
239
- (l) => c(o("[useLoader] - Failed to load resource", l))
239
+ (l) => f(o("[useLoader] - Failed to load resource", l))
240
240
  );
241
241
  })
242
242
  );
243
- return Ze(a) ? await Promise.all(f) : await f[0];
243
+ return Ze(a) ? await Promise.all(u) : await u[0];
244
244
  }
245
245
  async function yt(e) {
246
- const a = new ke(), t = new De(a), r = (n) => new Promise((o, u) => {
246
+ const a = new ke(), t = new De(a), r = (n) => new Promise((o, c) => {
247
247
  t.load(
248
248
  n,
249
249
  (s) => o(s),
250
250
  () => null,
251
251
  () => {
252
- u(new Error("[useTextures] - Failed to load texture"));
252
+ c(new Error("[useTextures] - Failed to load texture"));
253
253
  }
254
254
  );
255
255
  });
@@ -260,81 +260,81 @@ async function yt(e) {
260
260
  const {
261
261
  map: n,
262
262
  displacementMap: o,
263
- normalMap: u,
263
+ normalMap: c,
264
264
  roughnessMap: s,
265
- metalnessMap: f,
265
+ metalnessMap: u,
266
266
  aoMap: i,
267
267
  alphaMap: m,
268
- matcap: c
268
+ matcap: f
269
269
  } = e;
270
270
  return {
271
271
  map: n ? await r(n) : null,
272
272
  displacementMap: o ? await r(o) : null,
273
- normalMap: u ? await r(u) : null,
273
+ normalMap: c ? await r(c) : null,
274
274
  roughnessMap: s ? await r(s) : null,
275
- metalnessMap: f ? await r(f) : null,
275
+ metalnessMap: u ? await r(u) : null,
276
276
  aoMap: i ? await r(i) : null,
277
277
  alphaMap: m ? await r(m) : null,
278
- matcap: c ? await r(c) : null
278
+ matcap: f ? await r(f) : null
279
279
  };
280
280
  }
281
281
  }
282
282
  const tt = (e, { renderer: a, camera: t, raycaster: r }) => {
283
- const n = A(() => a.value.domElement), { x: o, y: u } = Re({ target: n }), { width: s, height: f, top: i, left: m } = He(n), c = ({ x: y, y: _ }) => {
283
+ const n = D(() => a.value.domElement), { x: o, y: c } = Re({ target: n }), { width: s, height: u, top: i, left: m } = He(n), f = ({ x: y, y: E }) => {
284
284
  if (n.value)
285
285
  return {
286
286
  x: (y - m.value) / s.value * 2 - 1,
287
- y: -((_ - i.value) / f.value) * 2 + 1
287
+ y: -((E - i.value) / u.value) * 2 + 1
288
288
  };
289
- }, l = ({ x: y, y: _ }) => {
289
+ }, l = ({ x: y, y: E }) => {
290
290
  if (t.value)
291
- return r.value.setFromCamera(new be(y, _), t.value), r.value.intersectObjects(e.value, !1);
292
- }, p = (y) => {
293
- const _ = c({
291
+ return r.value.setFromCamera(new be(y, E), t.value), r.value.intersectObjects(e.value, !1);
292
+ }, d = (y) => {
293
+ const E = f({
294
294
  x: (y == null ? void 0 : y.clientX) ?? o.value,
295
- y: (y == null ? void 0 : y.clientY) ?? u.value
295
+ y: (y == null ? void 0 : y.clientY) ?? c.value
296
296
  });
297
- return _ ? l(_) || [] : [];
298
- }, d = A(() => p()), v = B(), w = B(), h = (y, _) => {
299
- y.trigger({ event: _, intersects: p(_) });
300
- }, M = (y) => {
301
- h(w, y);
302
- };
303
- let P;
304
- const C = (y) => {
305
- var _;
306
- P = (_ = p(y)[0]) == null ? void 0 : _.object;
297
+ return E ? l(E) || [] : [];
298
+ }, w = D(() => d()), p = x(), g = x(), C = (y, E) => {
299
+ y.trigger({ event: E, intersects: d(E) });
307
300
  }, k = (y) => {
308
- var _;
309
- y instanceof PointerEvent && P === ((_ = p(y)[0]) == null ? void 0 : _.object) && h(v, y);
310
- }, T = (y) => w.trigger({ event: y, intersects: [] });
311
- return n.value.addEventListener("pointerup", k), n.value.addEventListener("pointerdown", C), n.value.addEventListener("pointermove", M), n.value.addEventListener("pointerleave", T), N(() => {
312
- n != null && n.value && (n.value.removeEventListener("pointerup", k), n.value.removeEventListener("pointerdown", C), n.value.removeEventListener("pointermove", M), n.value.removeEventListener("pointerleave", T));
301
+ C(g, y);
302
+ };
303
+ let M;
304
+ const _ = (y) => {
305
+ var E;
306
+ M = (E = d(y)[0]) == null ? void 0 : E.object;
307
+ }, P = (y) => {
308
+ var E;
309
+ y instanceof PointerEvent && M === ((E = d(y)[0]) == null ? void 0 : E.object) && C(p, y);
310
+ }, A = (y) => g.trigger({ event: y, intersects: [] });
311
+ return n.value.addEventListener("pointerup", P), n.value.addEventListener("pointerdown", _), n.value.addEventListener("pointermove", k), n.value.addEventListener("pointerleave", A), N(() => {
312
+ n != null && n.value && (n.value.removeEventListener("pointerup", P), n.value.removeEventListener("pointerdown", _), n.value.removeEventListener("pointermove", k), n.value.removeEventListener("pointerleave", A));
313
313
  }), {
314
- intersects: d,
315
- onClick: (y) => v.on(y).off,
316
- onPointerMove: (y) => w.on(y).off
314
+ intersects: w,
315
+ onClick: (y) => p.on(y).off,
316
+ onPointerMove: (y) => g.on(y).off
317
317
  };
318
318
  };
319
319
  function wt() {
320
- const { logWarning: e } = O();
321
- function a(o, u, s) {
322
- let f = null;
320
+ const { logWarning: e } = T();
321
+ function a(o, c, s) {
322
+ let u = null;
323
323
  return o.traverse((i) => {
324
- i[u] === s && (f = i);
325
- }), f || e(`Child with ${u} '${s}' not found.`), f;
324
+ i[c] === s && (u = i);
325
+ }), u || e(`Child with ${c} '${s}' not found.`), u;
326
326
  }
327
- function t(o, u, s) {
328
- const f = [];
327
+ function t(o, c, s) {
328
+ const u = [];
329
329
  return o.traverse((i) => {
330
- i[u].includes(s) && f.push(i);
331
- }), f.length || e(`Children with ${u} '${s}' not found.`), f;
330
+ i[c].includes(s) && u.push(i);
331
+ }), u.length || e(`Children with ${c} '${s}' not found.`), u;
332
332
  }
333
- function r(o, u) {
334
- return a(o, "name", u);
333
+ function r(o, c) {
334
+ return a(o, "name", c);
335
335
  }
336
- function n(o, u) {
337
- return t(o, "name", u);
336
+ function n(o, c) {
337
+ return t(o, "name", c);
338
338
  }
339
339
  return {
340
340
  seek: a,
@@ -349,18 +349,18 @@ const rt = ({ scene: e, contextParts: a }) => {
349
349
  pointerMove: /* @__PURE__ */ new Map(),
350
350
  pointerEnter: /* @__PURE__ */ new Map(),
351
351
  pointerLeave: /* @__PURE__ */ new Map()
352
- }), r = L(/* @__PURE__ */ new Set()), n = (l) => {
352
+ }), r = O(/* @__PURE__ */ new Set()), n = (l) => {
353
353
  r.value.add(l);
354
354
  }, o = (l) => {
355
355
  r.value.delete(l);
356
- }, u = (l) => {
357
- Object.values(t).forEach((p) => p.delete(l)), o(l);
356
+ }, c = (l) => {
357
+ Object.values(t).forEach((d) => d.delete(l)), o(l);
358
358
  }, s = (l) => {
359
- const { onClick: p, onPointerMove: d, onPointerEnter: v, onPointerLeave: w } = l;
360
- p && t.click.set(l, p), d && t.pointerMove.set(l, d), v && t.pointerEnter.set(l, v), w && t.pointerLeave.set(l, w);
359
+ const { onClick: d, onPointerMove: w, onPointerEnter: p, onPointerLeave: g } = l;
360
+ d && t.click.set(l, d), w && t.pointerMove.set(l, w), p && t.pointerEnter.set(l, p), g && t.pointerLeave.set(l, g);
361
361
  };
362
- e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
363
- const f = A(
362
+ e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = c, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
363
+ const u = D(
364
364
  () => Ue(
365
365
  [
366
366
  ...Array.from(r.value),
@@ -368,21 +368,21 @@ const rt = ({ scene: e, contextParts: a }) => {
368
368
  ],
369
369
  ({ uuid: l }) => l
370
370
  )
371
- ), { onClick: i, onPointerMove: m } = tt(f, a);
372
- i(({ intersects: l, event: p }) => {
373
- var d;
374
- l.length && ((d = t.click.get(l[0].object)) == null || d(l[0], p));
371
+ ), { onClick: i, onPointerMove: m } = tt(u, a);
372
+ i(({ intersects: l, event: d }) => {
373
+ var w;
374
+ l.length && ((w = t.click.get(l[0].object)) == null || w(l[0], d));
375
375
  });
376
- let c;
377
- return m(({ intersects: l, event: p }) => {
378
- var M, P, C, k;
379
- const d = (M = l == null ? void 0 : l[0]) == null ? void 0 : M.object, { pointerLeave: v, pointerEnter: w, pointerMove: h } = t;
380
- c && c !== d && ((P = v.get(c)) == null || P(c, p)), d && (c !== d && ((C = w.get(d)) == null || C(l[0], p)), (k = h.get(d)) == null || k(l[0], p)), c = d || null;
376
+ let f;
377
+ return m(({ intersects: l, event: d }) => {
378
+ var k, M, _, P;
379
+ const w = (k = l == null ? void 0 : l[0]) == null ? void 0 : k.object, { pointerLeave: p, pointerEnter: g, pointerMove: C } = t;
380
+ f && f !== w && ((M = p.get(f)) == null || M(f, d)), w && (f !== w && ((_ = g.get(w)) == null || _(l[0], d)), (P = C.get(w)) == null || P(l[0], d)), f = w || null;
381
381
  }), {
382
382
  registerObject: s,
383
- deregisterObject: u
383
+ deregisterObject: c
384
384
  };
385
- }, G = L({}), V = (e) => Object.assign(G.value, e);
385
+ }, G = O({}), V = (e) => Object.assign(G.value, e);
386
386
  function nt({
387
387
  scene: e,
388
388
  canvas: a,
@@ -390,40 +390,40 @@ function nt({
390
390
  disableRender: r,
391
391
  rendererOptions: n
392
392
  }) {
393
- const o = A(
394
- () => E(t) ? je() : Fe(E(a).parentElement)
395
- ), u = A(() => o.value.width.value), s = A(() => o.value.height.value), f = A(() => u.value / s.value), i = {
393
+ const o = D(
394
+ () => h(t) ? je() : Fe(h(a).parentElement)
395
+ ), c = D(() => o.value.width.value), s = D(() => o.value.height.value), u = D(() => c.value / s.value), i = {
396
396
  height: s,
397
- width: u,
398
- aspectRatio: f
399
- }, m = x(e), {
400
- camera: c,
397
+ width: c,
398
+ aspectRatio: u
399
+ }, m = B(e), {
400
+ camera: f,
401
401
  cameras: l,
402
- registerCamera: p,
403
- deregisterCamera: d,
404
- setCameraActive: v
405
- } = $e({ sizes: i, scene: e }), { renderer: w } = Qe(
402
+ registerCamera: d,
403
+ deregisterCamera: w,
404
+ setCameraActive: p
405
+ } = $e({ sizes: i, scene: e }), { renderer: g } = Qe(
406
406
  {
407
407
  scene: e,
408
408
  canvas: a,
409
409
  options: n,
410
- contextParts: { sizes: i, camera: c },
410
+ contextParts: { sizes: i, camera: f },
411
411
  disableRender: r
412
412
  }
413
- ), h = {
413
+ ), C = {
414
414
  sizes: i,
415
415
  scene: m,
416
- camera: c,
416
+ camera: f,
417
417
  cameras: ie(l),
418
- renderer: w,
419
- raycaster: x(new xe()),
420
- controls: L(null),
418
+ renderer: g,
419
+ raycaster: B(new Le()),
420
+ controls: O(null),
421
421
  extend: V,
422
- registerCamera: p,
423
- setCameraActive: v,
424
- deregisterCamera: d
422
+ registerCamera: d,
423
+ setCameraActive: p,
424
+ deregisterCamera: w
425
425
  };
426
- return z("useTres", h), h;
426
+ return z("useTres", C), C;
427
427
  }
428
428
  function at() {
429
429
  const e = le("useTres");
@@ -432,40 +432,40 @@ function at() {
432
432
  return e;
433
433
  }
434
434
  const Ct = at;
435
- let g = null;
436
- const { logError: Z } = O(), ot = {
435
+ let v = null;
436
+ const { logError: Z } = T(), ot = {
437
437
  createElement(e, a, t, r) {
438
- var u, s;
438
+ var c, s;
439
439
  if (r || (r = {}), r.args || (r.args = []), e === "template" || Ve(e))
440
440
  return null;
441
441
  let n = e.replace("Tres", ""), o;
442
442
  if (e === "primitive") {
443
443
  (r == null ? void 0 : r.object) === void 0 && Z("Tres primitives need a prop 'object'");
444
- const f = r.object;
445
- n = f.type, o = Object.assign(f, { type: n, attach: r.attach, primitive: !0 });
444
+ const u = r.object;
445
+ n = u.type, o = Object.assign(u, { type: n, attach: r.attach, primitive: !0 });
446
446
  } else {
447
- const f = G.value[n];
448
- f || Z(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new f(...r.args);
447
+ const u = G.value[n];
448
+ u || Z(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new u(...r.args);
449
449
  }
450
- return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((u = r == null ? void 0 : r.material) != null && u.isMaterial && (o.userData.tres__materialViaProp = !0), (s = r == null ? void 0 : r.geometry) != null && s.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
450
+ return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((c = r == null ? void 0 : r.material) != null && c.isMaterial && (o.userData.tres__materialViaProp = !0), (s = r == null ? void 0 : r.geometry) != null && s.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
451
451
  ...o.userData,
452
452
  tres__name: n
453
453
  }, o;
454
454
  },
455
455
  insert(e, a) {
456
- var r, n, o, u;
457
- a && a.isScene && (g = a);
458
- const t = a || g;
456
+ var r, n, o, c;
457
+ a && a.isScene && (v = a);
458
+ const t = a || v;
459
459
  if (e != null && e.isObject3D) {
460
460
  if (e != null && e.isCamera) {
461
- if (!(g != null && g.userData.tres__registerCamera))
461
+ if (!(v != null && v.userData.tres__registerCamera))
462
462
  throw "could not find tres__registerCamera on scene's userData";
463
- (n = g == null ? void 0 : (r = g.userData).tres__registerCamera) == null || n.call(r, e);
463
+ (n = v == null ? void 0 : (r = v.userData).tres__registerCamera) == null || n.call(r, e);
464
464
  }
465
465
  if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) {
466
- if (!(g != null && g.userData.tres__registerAtPointerEventHandler))
466
+ if (!(v != null && v.userData.tres__registerAtPointerEventHandler))
467
467
  throw "could not find tres__registerAtPointerEventHandler on scene's userData";
468
- (u = g == null ? void 0 : (o = g.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e);
468
+ (c = v == null ? void 0 : (o = v.userData).tres__registerAtPointerEventHandler) == null || c.call(o, e);
469
469
  }
470
470
  }
471
471
  e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : e != null && e.isFog ? t.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
@@ -475,62 +475,62 @@ const { logError: Z } = O(), ot = {
475
475
  if (e) {
476
476
  if (e.isObject3D) {
477
477
  const r = e, n = (i) => {
478
- var c, l;
478
+ var f, l;
479
479
  const m = i;
480
- i.userData.tres__materialViaProp || (c = m.material) == null || c.dispose(), i.userData.tres__geometryViaProp || (l = m.geometry) == null || l.dispose();
481
- }, o = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, u = g == null ? void 0 : g.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => {
482
- var m, c;
483
- if (!u)
480
+ i.userData.tres__materialViaProp || ((f = m.material) == null || f.dispose(), m.material = void 0), i.userData.tres__geometryViaProp || ((l = m.geometry) == null || l.dispose(), m.geometry = void 0);
481
+ }, o = v == null ? void 0 : v.userData.tres__deregisterAtPointerEventHandler, c = v == null ? void 0 : v.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => {
482
+ var m, f;
483
+ if (!c)
484
484
  throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
485
- if ((c = g == null ? void 0 : (m = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || c.call(m, i), !o)
485
+ if ((f = v == null ? void 0 : (m = v.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(m, i), !o)
486
486
  throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
487
487
  (i != null && i.onClick || i != null && i.onPointerMove || i != null && i.onPointerEnter || i != null && i.onPointerLeave) && (o == null || o(i));
488
- }, f = (i) => {
489
- const m = g == null ? void 0 : g.userData.tres__deregisterCamera;
488
+ }, u = (i) => {
489
+ const m = v == null ? void 0 : v.userData.tres__deregisterCamera;
490
490
  if (!m)
491
491
  throw "could not find tres__deregisterCamera on scene's userData";
492
492
  i.isCamera && (m == null || m(i));
493
493
  };
494
- r.traverse((i) => {
495
- n(i), f(i), s == null || s(i);
496
- }), n(r), f(r), s == null || s(r);
494
+ (a = e.removeFromParent) == null || a.call(e), r.traverse((i) => {
495
+ n(i), u(i), s == null || s(i);
496
+ }), n(r), u(r), s == null || s(r);
497
497
  }
498
- (a = e.removeFromParent) == null || a.call(e), (t = e.dispose) == null || t.call(e);
498
+ (t = e.dispose) == null || t.call(e);
499
499
  }
500
500
  },
501
501
  patchProp(e, a, t, r) {
502
- var n, o, u, s;
502
+ var n, o, c, s;
503
503
  if (e) {
504
- let f = e, i = a;
504
+ let u = e, i = a;
505
505
  if (e.isObject3D && i === "blocks-pointer-events") {
506
- r || r === "" ? (o = g == null ? void 0 : (n = g.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = g == null ? void 0 : (u = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(u, e);
506
+ r || r === "" ? (o = v == null ? void 0 : (n = v.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = v == null ? void 0 : (c = v.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(c, e);
507
507
  return;
508
508
  }
509
- let m = S(i), c = f == null ? void 0 : f[m];
509
+ let m = S(i), f = u == null ? void 0 : u[m];
510
510
  if (i === "args") {
511
- const p = e, d = t ?? [], v = r ?? [], w = e.userData.tres__name || e.type;
512
- w && d.length && !Ke(d, v) && (f = Object.assign(p, new G.value[w](...r)));
511
+ const d = e, w = t ?? [], p = r ?? [], g = e.userData.tres__name || e.type;
512
+ g && w.length && !Ke(w, p) && (u = Object.assign(d, new G.value[g](...r)));
513
513
  return;
514
514
  }
515
- if (f.type === "BufferGeometry") {
515
+ if (u.type === "BufferGeometry") {
516
516
  if (i === "args")
517
517
  return;
518
- f.setAttribute(
518
+ u.setAttribute(
519
519
  S(i),
520
520
  new Be(...r)
521
521
  );
522
522
  return;
523
523
  }
524
- if (i.includes("-") && c === void 0) {
525
- const p = i.split("-");
526
- c = p.reduce((d, v) => d[S(v)], f), i = p.pop(), m = i.toLowerCase(), c != null && c.set || (f = p.reduce((d, v) => d[S(v)], f));
524
+ if (i.includes("-") && f === void 0) {
525
+ const d = i.split("-");
526
+ f = d.reduce((w, p) => w[S(p)], u), i = d.pop(), m = i.toLowerCase(), f != null && f.set || (u = d.reduce((w, p) => w[S(p)], u));
527
527
  }
528
528
  let l = r;
529
- if (l === "" && (l = !0), Q(c)) {
529
+ if (l === "" && (l = !0), Q(f)) {
530
530
  Array.isArray(l) ? e[m](...l) : e[m](l);
531
531
  return;
532
532
  }
533
- !(c != null && c.set) && !Q(c) ? f[m] = l : c.constructor === l.constructor && (c != null && c.copy) ? c == null || c.copy(l) : Array.isArray(l) ? c.set(...l) : !c.isColor && c.setScalar ? c.setScalar(l) : c.set(l);
533
+ !(f != null && f.set) && !Q(f) ? u[m] = l : f.constructor === l.constructor && (f != null && f.copy) ? f == null || f.copy(l) : Array.isArray(l) ? f.set(...l) : !f.isColor && f.setScalar ? f.setScalar(l) : f.set(l);
534
534
  }
535
535
  },
536
536
  parentNode(e) {
@@ -574,54 +574,54 @@ const it = ["data-scene"], lt = /* @__PURE__ */ q({
574
574
  failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
575
575
  },
576
576
  setup(e, { expose: a }) {
577
- var l;
578
- const t = e, { logWarning: r } = O(), n = L(), o = x(new Le());
579
- ne();
580
- const u = ce(), s = (l = U()) == null ? void 0 : l.appContext.app, f = (p) => q({
577
+ var w;
578
+ const t = e, { logWarning: r } = T(), n = O(), o = B(new xe()), { resume: c } = ne(), s = ce(), u = (w = U()) == null ? void 0 : w.appContext.app, i = (p) => q({
581
579
  setup() {
582
- var v;
583
- const d = (v = U()) == null ? void 0 : v.appContext;
584
- return d && (d.app = s), z("useTres", p), z("extend", V), () => J(ge, null, u != null && u.default ? u.default() : []);
580
+ var C;
581
+ const g = (C = U()) == null ? void 0 : C.appContext;
582
+ return g && (g.app = u), z("useTres", p), z("extend", V), () => J(ge, null, s != null && s.default ? s.default() : []);
585
583
  }
586
- }), i = (p) => {
587
- const d = f(p);
588
- st(J(d), o.value);
589
- }, m = A(() => t.disableRender), c = x(null);
590
- return a({ context: c }), fe(() => {
584
+ }), m = (p) => {
585
+ const g = i(p);
586
+ st(J(g), o.value);
587
+ }, f = (p, g = !1) => {
588
+ o.value.children = [], g && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), m(p), c();
589
+ }, l = D(() => t.disableRender), d = B(null);
590
+ return a({ context: d, dispose: () => f(d.value, !0) }), fe(() => {
591
591
  const p = n;
592
- c.value = nt({
592
+ d.value = nt({
593
593
  scene: o.value,
594
594
  canvas: p,
595
595
  windowSize: t.windowSize,
596
- disableRender: m,
596
+ disableRender: l,
597
597
  rendererOptions: t
598
- }), rt({ scene: o.value, contextParts: c.value });
599
- const { registerCamera: d, camera: v, cameras: w, deregisterCamera: h } = c.value;
600
- i(c.value);
601
- const M = () => {
598
+ }), rt({ scene: o.value, contextParts: d.value });
599
+ const { registerCamera: g, camera: C, cameras: k, deregisterCamera: M } = d.value;
600
+ m(d.value);
601
+ const _ = () => {
602
602
  const P = new I(
603
603
  45,
604
604
  window.innerWidth / window.innerHeight,
605
605
  0.1,
606
606
  1e3
607
607
  );
608
- P.position.set(3, 3, 3), P.lookAt(0, 0, 0), d(P);
609
- const C = D(() => {
610
- w.value.length >= 2 && (P.removeFromParent(), h(P), C == null || C());
608
+ P.position.set(3, 3, 3), P.lookAt(0, 0, 0), g(P);
609
+ const A = b(() => {
610
+ k.value.length >= 2 && (P.removeFromParent(), M(P), A == null || A());
611
611
  });
612
612
  };
613
613
  ee(
614
614
  () => t.camera,
615
- (P, C) => {
616
- P && d(P), C && (C.removeFromParent(), h(C));
615
+ (P, A) => {
616
+ P && g(P), A && (A.removeFromParent(), M(A));
617
617
  },
618
618
  {
619
619
  immediate: !0
620
620
  }
621
- ), v.value || (r(
621
+ ), C.value || (r(
622
622
  "No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
623
- ), M());
624
- }), (p, d) => (pe(), me("canvas", {
623
+ ), _());
624
+ }), (p, g) => (pe(), me("canvas", {
625
625
  ref_key: "canvas",
626
626
  ref: n,
627
627
  "data-scene": o.value.uuid,
@@ -666,7 +666,7 @@ export {
666
666
  et as trasverseObjects,
667
667
  $e as useCamera,
668
668
  gt as useLoader,
669
- O as useLogger,
669
+ T as useLogger,
670
670
  rt as usePointerEventHandler,
671
671
  tt as useRaycaster,
672
672
  ne as useRenderLoop,