@tresjs/core 4.0.0-rc.1 → 4.0.0-rc.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/src/composables/useLoop/index.d.ts +14 -8
- package/dist/src/core/loop.d.ts +22 -9
- package/dist/src/index.d.ts +1 -0
- package/dist/tres.js +214 -205
- package/dist/tres.umd.cjs +2 -2
- package/package.json +9 -9
package/dist/tres.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v4.0.0-rc.
|
|
3
|
+
* version: v4.0.0-rc.2
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
var nt = Object.defineProperty;
|
|
9
9
|
var ot = (e, t, n) => t in e ? nt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
10
10
|
var se = (e, t, n) => (ot(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
11
|
-
import { ref as A, computed as B, watchEffect as ve, onUnmounted as N, shallowRef as U, watch as V, reactive as $e, readonly as ue,
|
|
11
|
+
import { ref as A, computed as B, watchEffect as ve, onUnmounted as N, shallowRef as U, watch as V, reactive as $e, readonly as ue, unref as W, provide as ce, inject as st, defineComponent as Se, useSlots as it, getCurrentInstance as xe, onMounted as at, openBlock as lt, createElementBlock as ut, normalizeClass as ct, normalizeStyle as ft, createRenderer as dt, h as Te, Fragment as pt } from "vue";
|
|
12
12
|
import * as Fe from "three";
|
|
13
13
|
import { PerspectiveCamera as fe, Camera as mt, Clock as We, Vector3 as ge, Color as re, Scene as Ne, MeshBasicMaterial as ze, DoubleSide as vt, REVISION as gt, SRGBColorSpace as ht, ACESFilmicToneMapping as Ge, PCFSoftShadowMap as yt, NoToneMapping as bt, WebGLRenderer as ie, TextureLoader as wt, Vector2 as ae, MathUtils as Mt, Raycaster as Pt, BufferAttribute as Ct, Line as _t, BufferGeometry as Ae, Float32BufferAttribute as Oe, LineBasicMaterial as Et, Mesh as kt, BackSide as St, DirectionalLightHelper as xt, PointLightHelper as Tt, SpotLightHelper as At, HemisphereLightHelper as Ot, ArrowHelper as Lt } from "three";
|
|
14
14
|
import { createEventHook as x, useRafFn as Ve, toValue as k, unrefElement as Dt, useDevicePixelRatio as Bt, usePointer as Rt, useElementBounding as jt, useWindowSize as It, useElementSize as Ht, refDebounced as Le, tryOnScopeDispose as Ut, useFps as $t, useMemory as Ft } from "@vueuse/core";
|
|
15
|
-
const Wt = "@tresjs/core", Nt = "module", zt = "4.0.0-rc.
|
|
15
|
+
const Wt = "@tresjs/core", Nt = "module", zt = "4.0.0-rc.2", Gt = "pnpm@8.15.6", Vt = "Declarative ThreeJS using Vue Components", qt = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", Yt = "MIT", Jt = [
|
|
16
16
|
"vue",
|
|
17
17
|
"3d",
|
|
18
18
|
"threejs",
|
|
@@ -70,16 +70,16 @@ const Wt = "@tresjs/core", Nt = "module", zt = "4.0.0-rc.1", Gt = "pnpm@8.15.6",
|
|
|
70
70
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
71
71
|
"@stackblitz/sdk": "^1.10.0",
|
|
72
72
|
"@tresjs/cientos": "3.9.0",
|
|
73
|
-
"@tresjs/eslint-config": "^1.
|
|
74
|
-
"@types/three": "^0.164.
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
76
|
-
"@typescript-eslint/parser": "^7.
|
|
73
|
+
"@tresjs/eslint-config": "^1.1.0",
|
|
74
|
+
"@types/three": "^0.164.1",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^7.10.0",
|
|
76
|
+
"@typescript-eslint/parser": "^7.10.0",
|
|
77
77
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
78
78
|
"@vitest/coverage-c8": "^0.33.0",
|
|
79
79
|
"@vitest/coverage-v8": "^1.6.0",
|
|
80
80
|
"@vitest/ui": "^1.6.0",
|
|
81
81
|
"@vue/test-utils": "^2.4.6",
|
|
82
|
-
eslint: "^9.
|
|
82
|
+
eslint: "^9.3.0",
|
|
83
83
|
"eslint-plugin-vue": "^9.26.0",
|
|
84
84
|
esno: "^4.7.0",
|
|
85
85
|
gsap: "^3.12.5",
|
|
@@ -88,12 +88,12 @@ const Wt = "@tresjs/core", Nt = "module", zt = "4.0.0-rc.1", Gt = "pnpm@8.15.6",
|
|
|
88
88
|
kolorist: "^1.8.0",
|
|
89
89
|
ohmyfetch: "^0.4.21",
|
|
90
90
|
pathe: "^1.1.2",
|
|
91
|
-
"release-it": "^17.
|
|
91
|
+
"release-it": "^17.3.0",
|
|
92
92
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
93
93
|
"rollup-plugin-copy": "^3.5.0",
|
|
94
94
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
95
95
|
three: "^0.164.1",
|
|
96
|
-
unocss: "^0.60.
|
|
96
|
+
unocss: "^0.60.3",
|
|
97
97
|
unplugin: "^1.10.1",
|
|
98
98
|
"unplugin-vue-components": "^0.27.0",
|
|
99
99
|
vite: "^5.2.11",
|
|
@@ -102,7 +102,7 @@ const Wt = "@tresjs/core", Nt = "module", zt = "4.0.0-rc.1", Gt = "pnpm@8.15.6",
|
|
|
102
102
|
"vite-plugin-inspect": "^0.8.4",
|
|
103
103
|
"vite-plugin-require-transform": "^1.0.21",
|
|
104
104
|
"vite-svg-loader": "^5.1.0",
|
|
105
|
-
vitepress: "1.
|
|
105
|
+
vitepress: "1.2.2",
|
|
106
106
|
vitest: "^1.6.0",
|
|
107
107
|
vue: "^3.4.27",
|
|
108
108
|
"vue-demi": "^0.14.7"
|
|
@@ -130,14 +130,14 @@ const Wt = "@tresjs/core", Nt = "module", zt = "4.0.0-rc.1", Gt = "pnpm@8.15.6",
|
|
|
130
130
|
const t = A([]), n = B(
|
|
131
131
|
() => t.value[0]
|
|
132
132
|
), o = (r) => {
|
|
133
|
-
const s = r instanceof mt ? r : t.value.find((
|
|
133
|
+
const s = r instanceof mt ? r : t.value.find((a) => a.uuid === r);
|
|
134
134
|
if (!s)
|
|
135
135
|
return;
|
|
136
|
-
const u = t.value.filter(({ uuid:
|
|
136
|
+
const u = t.value.filter(({ uuid: a }) => a !== s.uuid);
|
|
137
137
|
t.value = [s, ...u];
|
|
138
138
|
}, i = (r, s = !1) => {
|
|
139
139
|
t.value.some(({ uuid: u }) => u === r.uuid) || (s ? o(r) : t.value.push(r));
|
|
140
|
-
},
|
|
140
|
+
}, l = (r) => {
|
|
141
141
|
t.value = t.value.filter(({ uuid: s }) => s !== r.uuid);
|
|
142
142
|
};
|
|
143
143
|
return ve(() => {
|
|
@@ -150,7 +150,7 @@ const Wt = "@tresjs/core", Nt = "module", zt = "4.0.0-rc.1", Gt = "pnpm@8.15.6",
|
|
|
150
150
|
camera: n,
|
|
151
151
|
cameras: t,
|
|
152
152
|
registerCamera: i,
|
|
153
|
-
deregisterCamera:
|
|
153
|
+
deregisterCamera: l,
|
|
154
154
|
setCameraActive: o
|
|
155
155
|
};
|
|
156
156
|
};
|
|
@@ -233,8 +233,8 @@ function br(e, t) {
|
|
|
233
233
|
const wr = (e, t) => {
|
|
234
234
|
const n = /* @__PURE__ */ new Set(), o = [];
|
|
235
235
|
for (const i of e) {
|
|
236
|
-
const
|
|
237
|
-
n.has(
|
|
236
|
+
const l = t(i);
|
|
237
|
+
n.has(l) || (n.add(l), o.push(i));
|
|
238
238
|
}
|
|
239
239
|
return o;
|
|
240
240
|
}, Be = (e, t) => {
|
|
@@ -244,12 +244,12 @@ const wr = (e, t) => {
|
|
|
244
244
|
return n == null ? void 0 : n.reduce((o, i) => o && o[i], e);
|
|
245
245
|
}, Mr = (e, t, n) => {
|
|
246
246
|
const o = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
|
|
247
|
-
o && o.reduce((i,
|
|
247
|
+
o && o.reduce((i, l, r) => (i[l] === void 0 && (i[l] = {}), r === o.length - 1 && (i[l] = n), i[l]), e);
|
|
248
248
|
};
|
|
249
249
|
function Qe(e, t) {
|
|
250
250
|
if (De(e) && De(t)) {
|
|
251
|
-
const i = e.attributes,
|
|
252
|
-
return i.length !==
|
|
251
|
+
const i = e.attributes, l = t.attributes;
|
|
252
|
+
return i.length !== l.length ? !1 : Array.from(i).every(({ name: r, value: s }) => t.getAttribute(r) === s);
|
|
253
253
|
}
|
|
254
254
|
if (e === t)
|
|
255
255
|
return !0;
|
|
@@ -276,17 +276,17 @@ function _r(e, t, n, o) {
|
|
|
276
276
|
const i = (u) => {
|
|
277
277
|
if (u.uuid === t)
|
|
278
278
|
return u;
|
|
279
|
-
for (const
|
|
280
|
-
const y = i(
|
|
279
|
+
for (const a of u.children) {
|
|
280
|
+
const y = i(a);
|
|
281
281
|
if (y)
|
|
282
282
|
return y;
|
|
283
283
|
}
|
|
284
|
-
},
|
|
285
|
-
if (!
|
|
284
|
+
}, l = i(e);
|
|
285
|
+
if (!l) {
|
|
286
286
|
console.warn("Object with UUID not found in the scene.");
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
let r =
|
|
289
|
+
let r = l;
|
|
290
290
|
for (let u = 0; u < n.length - 1; u++)
|
|
291
291
|
if (r[n[u]] !== void 0)
|
|
292
292
|
r = r[n[u]];
|
|
@@ -325,7 +325,7 @@ function ye(e) {
|
|
|
325
325
|
var n, o;
|
|
326
326
|
if (e.parent && ((n = e.removeFromParent) == null || n.call(e)), delete e.__tres, [...e.children].forEach((i) => ye(i)), !(e instanceof Ne)) {
|
|
327
327
|
const i = e;
|
|
328
|
-
e && ((o = e.dispose) == null || o.call(e)), i.geometry && (i.geometry.dispose(), delete i.geometry), Array.isArray(i.material) ? (i.material.forEach((
|
|
328
|
+
e && ((o = e.dispose) == null || o.call(e)), i.geometry && (i.geometry.dispose(), delete i.geometry), Array.isArray(i.material) ? (i.material.forEach((l) => Re(l)), delete i.material) : i.material && (Re(i.material), delete i.material);
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
const xr = Number.parseInt(gt.replace("dev", "")), Z = {
|
|
@@ -348,7 +348,7 @@ const xr = Number.parseInt(gt.replace("dev", "")), Z = {
|
|
|
348
348
|
function Tr({
|
|
349
349
|
canvas: e,
|
|
350
350
|
options: t,
|
|
351
|
-
contextParts: { sizes: n, render: o, invalidate: i, advance:
|
|
351
|
+
contextParts: { sizes: n, render: o, invalidate: i, advance: l }
|
|
352
352
|
}) {
|
|
353
353
|
const r = B(() => ({
|
|
354
354
|
alpha: k(t.alpha) ?? !0,
|
|
@@ -374,9 +374,9 @@ function Tr({
|
|
|
374
374
|
}, {
|
|
375
375
|
immediate: !0
|
|
376
376
|
}), V(() => t.clearColor, u);
|
|
377
|
-
const { pixelRatio:
|
|
378
|
-
V(
|
|
379
|
-
s.value.setPixelRatio(
|
|
377
|
+
const { pixelRatio: a } = Bt();
|
|
378
|
+
V(a, () => {
|
|
379
|
+
s.value.setPixelRatio(a.value);
|
|
380
380
|
});
|
|
381
381
|
const { logError: y } = $(), p = (() => {
|
|
382
382
|
const f = new ie(), b = {
|
|
@@ -389,12 +389,12 @@ function Tr({
|
|
|
389
389
|
outputColorSpace: f.outputColorSpace
|
|
390
390
|
};
|
|
391
391
|
return f.dispose(), b;
|
|
392
|
-
})(),
|
|
393
|
-
return
|
|
394
|
-
|
|
395
|
-
},
|
|
392
|
+
})(), P = k(t.renderMode);
|
|
393
|
+
return P === "on-demand" && i(), P === "manual" && setTimeout(() => {
|
|
394
|
+
l();
|
|
395
|
+
}, 100), ve(() => {
|
|
396
396
|
const f = k(t.preset);
|
|
397
|
-
f && (f in Z || y(`Renderer Preset must be one of these: ${Object.keys(Z).join(", ")}`), Je(s.value, Z[f])),
|
|
397
|
+
f && (f in Z || y(`Renderer Preset must be one of these: ${Object.keys(Z).join(", ")}`), Je(s.value, Z[f])), P === "always" && (o.frames.value = Math.max(1, o.frames.value));
|
|
398
398
|
const b = (v, h) => {
|
|
399
399
|
const _ = k(v), g = () => {
|
|
400
400
|
if (f)
|
|
@@ -402,8 +402,8 @@ function Tr({
|
|
|
402
402
|
};
|
|
403
403
|
if (_ !== void 0)
|
|
404
404
|
return _;
|
|
405
|
-
const
|
|
406
|
-
return
|
|
405
|
+
const M = g();
|
|
406
|
+
return M !== void 0 ? M : Be(p, h);
|
|
407
407
|
}, m = (v, h) => Mr(s.value, h, b(v, h));
|
|
408
408
|
m(t.shadows, "shadowMap.enabled"), m(t.toneMapping ?? Ge, "toneMapping"), m(t.shadowMapType, "shadowMap.type"), xr < 150 && m(!t.useLegacyLights, "physicallyCorrectLights"), m(t.outputColorSpace, "outputColorSpace"), m(t.toneMappingExposure, "toneMappingExposure");
|
|
409
409
|
const w = b(t.clearColor, "clearColor");
|
|
@@ -425,27 +425,27 @@ function Or(e) {
|
|
|
425
425
|
}), t;
|
|
426
426
|
}
|
|
427
427
|
async function fn(e, t, n, o, i) {
|
|
428
|
-
const { logError:
|
|
428
|
+
const { logError: l } = $(), r = new e();
|
|
429
429
|
i && i(r), n && n(r);
|
|
430
430
|
const u = (Array.isArray(t) ? t : [t]).map(
|
|
431
|
-
(
|
|
431
|
+
(a) => new Promise((y, c) => {
|
|
432
432
|
r.load(
|
|
433
|
-
|
|
433
|
+
a,
|
|
434
434
|
(p) => {
|
|
435
435
|
p.scene && Object.assign(p, Or(p.scene)), y(p);
|
|
436
436
|
},
|
|
437
437
|
o,
|
|
438
|
-
(p) => c(
|
|
438
|
+
(p) => c(l("[useLoader] - Failed to load resource", p))
|
|
439
439
|
);
|
|
440
440
|
})
|
|
441
441
|
);
|
|
442
442
|
return Ar(t) ? await Promise.all(u) : await u[0];
|
|
443
443
|
}
|
|
444
444
|
async function dn(e, t) {
|
|
445
|
-
const n = new wt(t), o = (i) => new Promise((
|
|
445
|
+
const n = new wt(t), o = (i) => new Promise((l, r) => {
|
|
446
446
|
n.load(
|
|
447
447
|
i,
|
|
448
|
-
(s) =>
|
|
448
|
+
(s) => l(s),
|
|
449
449
|
() => null,
|
|
450
450
|
() => {
|
|
451
451
|
r(new Error("[useTextures] - Failed to load texture"));
|
|
@@ -453,51 +453,51 @@ async function dn(e, t) {
|
|
|
453
453
|
);
|
|
454
454
|
});
|
|
455
455
|
if (Cr(e)) {
|
|
456
|
-
const i = await Promise.all(e.map((
|
|
456
|
+
const i = await Promise.all(e.map((l) => o(l)));
|
|
457
457
|
return e.length > 1 ? i : i[0];
|
|
458
458
|
} else {
|
|
459
459
|
const {
|
|
460
460
|
map: i,
|
|
461
|
-
displacementMap:
|
|
461
|
+
displacementMap: l,
|
|
462
462
|
normalMap: r,
|
|
463
463
|
roughnessMap: s,
|
|
464
464
|
metalnessMap: u,
|
|
465
|
-
aoMap:
|
|
465
|
+
aoMap: a,
|
|
466
466
|
alphaMap: y,
|
|
467
467
|
matcap: c
|
|
468
468
|
} = e;
|
|
469
469
|
return {
|
|
470
470
|
map: i ? await o(i) : null,
|
|
471
|
-
displacementMap:
|
|
471
|
+
displacementMap: l ? await o(l) : null,
|
|
472
472
|
normalMap: r ? await o(r) : null,
|
|
473
473
|
roughnessMap: s ? await o(s) : null,
|
|
474
474
|
metalnessMap: u ? await o(u) : null,
|
|
475
|
-
aoMap:
|
|
475
|
+
aoMap: a ? await o(a) : null,
|
|
476
476
|
alphaMap: y ? await o(y) : null,
|
|
477
477
|
matcap: c ? await o(c) : null
|
|
478
478
|
};
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
const Ke = (e, t) => {
|
|
482
|
-
const n = B(() => t.renderer.value.domElement), o = U([]), { x: i, y:
|
|
482
|
+
const n = B(() => t.renderer.value.domElement), o = U([]), { x: i, y: l } = Rt({ target: n });
|
|
483
483
|
let r = 0;
|
|
484
|
-
const { width: s, height: u, top:
|
|
484
|
+
const { width: s, height: u, top: a, left: y } = jt(n), c = ({ x: d, y: E }) => {
|
|
485
485
|
if (n.value)
|
|
486
486
|
return {
|
|
487
487
|
x: (d - y.value) / s.value * 2 - 1,
|
|
488
|
-
y: -((E -
|
|
488
|
+
y: -((E - a.value) / u.value) * 2 + 1
|
|
489
489
|
};
|
|
490
490
|
}, p = ({ x: d, y: E }) => {
|
|
491
491
|
if (t.camera.value)
|
|
492
492
|
return t.raycaster.value.setFromCamera(new ae(d, E), t.camera.value), o.value = t.raycaster.value.intersectObjects(e.value, !0), o.value;
|
|
493
|
-
},
|
|
493
|
+
}, P = (d) => {
|
|
494
494
|
const E = c({
|
|
495
495
|
x: (d == null ? void 0 : d.clientX) ?? i.value,
|
|
496
|
-
y: (d == null ? void 0 : d.clientY) ??
|
|
496
|
+
y: (d == null ? void 0 : d.clientY) ?? l.value
|
|
497
497
|
});
|
|
498
498
|
return E ? p(E) || [] : [];
|
|
499
499
|
}, f = x(), b = x(), m = x(), w = x(), v = x(), h = x(), _ = x(), g = x();
|
|
500
|
-
function
|
|
500
|
+
function M(d) {
|
|
501
501
|
const E = {};
|
|
502
502
|
for (const I in d)
|
|
503
503
|
typeof I != "function" && (E[I] = d[I]);
|
|
@@ -505,7 +505,7 @@ const Ke = (e, t) => {
|
|
|
505
505
|
}
|
|
506
506
|
const C = (d, E) => {
|
|
507
507
|
var _e, Ee, ke;
|
|
508
|
-
const I =
|
|
508
|
+
const I = M(E), Q = new ge(E == null ? void 0 : E.clientX, E == null ? void 0 : E.clientY, 0).unproject((_e = t.camera) == null ? void 0 : _e.value);
|
|
509
509
|
d.trigger({
|
|
510
510
|
...I,
|
|
511
511
|
intersections: o.value,
|
|
@@ -520,7 +520,7 @@ const Ke = (e, t) => {
|
|
|
520
520
|
};
|
|
521
521
|
let R;
|
|
522
522
|
const O = (d) => {
|
|
523
|
-
|
|
523
|
+
P(d), C(m, d), R = d;
|
|
524
524
|
}, T = () => {
|
|
525
525
|
R && O(R);
|
|
526
526
|
};
|
|
@@ -529,7 +529,7 @@ const Ke = (e, t) => {
|
|
|
529
529
|
var E;
|
|
530
530
|
S = (E = o.value[0]) == null ? void 0 : E.object, r = 0, j = new ae(
|
|
531
531
|
(d == null ? void 0 : d.clientX) ?? i.value,
|
|
532
|
-
(d == null ? void 0 : d.clientY) ??
|
|
532
|
+
(d == null ? void 0 : d.clientY) ?? l.value
|
|
533
533
|
), C(v, d);
|
|
534
534
|
};
|
|
535
535
|
let z, J = !1;
|
|
@@ -537,7 +537,7 @@ const Ke = (e, t) => {
|
|
|
537
537
|
var E, I, Q;
|
|
538
538
|
d instanceof PointerEvent && (o.value.length === 0 && C(h, d), S === ((E = o.value[0]) == null ? void 0 : E.object) && (L = new ae(
|
|
539
539
|
(d == null ? void 0 : d.clientX) ?? i.value,
|
|
540
|
-
(d == null ? void 0 : d.clientY) ??
|
|
540
|
+
(d == null ? void 0 : d.clientY) ?? l.value
|
|
541
541
|
), r = j == null ? void 0 : j.distanceTo(L), d.button === 0 ? (C(f, d), z === ((I = o.value[0]) == null ? void 0 : I.object) ? J = !0 : (z = (Q = o.value[0]) == null ? void 0 : Q.object, J = !1)) : d.button === 2 && C(_, d)), C(w, d));
|
|
542
542
|
}, Me = (d) => {
|
|
543
543
|
J && (C(b, d), z = void 0, J = !1);
|
|
@@ -559,23 +559,23 @@ const Ke = (e, t) => {
|
|
|
559
559
|
};
|
|
560
560
|
function pn() {
|
|
561
561
|
const { logWarning: e } = $();
|
|
562
|
-
function t(
|
|
562
|
+
function t(l, r, s) {
|
|
563
563
|
let u = null;
|
|
564
|
-
return
|
|
565
|
-
|
|
564
|
+
return l.traverse((a) => {
|
|
565
|
+
a[r] === s && (u = a);
|
|
566
566
|
}), u || e(`Child with ${r} '${s}' not found.`), u;
|
|
567
567
|
}
|
|
568
|
-
function n(
|
|
568
|
+
function n(l, r, s) {
|
|
569
569
|
const u = [];
|
|
570
|
-
return
|
|
571
|
-
|
|
570
|
+
return l.traverse((a) => {
|
|
571
|
+
a[r].includes(s) && u.push(a);
|
|
572
572
|
}), u.length || e(`Children with ${r} '${s}' not found.`), u;
|
|
573
573
|
}
|
|
574
|
-
function o(
|
|
575
|
-
return t(
|
|
574
|
+
function o(l, r) {
|
|
575
|
+
return t(l, "name", r);
|
|
576
576
|
}
|
|
577
|
-
function i(
|
|
578
|
-
return n(
|
|
577
|
+
function i(l, r) {
|
|
578
|
+
return n(l, "name", r);
|
|
579
579
|
}
|
|
580
580
|
return {
|
|
581
581
|
seek: t,
|
|
@@ -594,11 +594,11 @@ const mn = (e) => {
|
|
|
594
594
|
n.value.add(c);
|
|
595
595
|
}, i = (c) => {
|
|
596
596
|
n.value.delete(c);
|
|
597
|
-
},
|
|
597
|
+
}, l = (c) => {
|
|
598
598
|
Object.values(t).forEach((p) => p.delete(c)), i(c);
|
|
599
599
|
}, r = (c) => {
|
|
600
|
-
const { onClick: p, onPointerMove:
|
|
601
|
-
p && t.click.set(c, p),
|
|
600
|
+
const { onClick: p, onPointerMove: P, onPointerEnter: f, onPointerLeave: b } = c;
|
|
601
|
+
p && t.click.set(c, p), P && t.pointerMove.set(c, P), f && t.pointerEnter.set(c, f), b && t.pointerLeave.set(c, b);
|
|
602
602
|
}, s = B(
|
|
603
603
|
() => wr(
|
|
604
604
|
[
|
|
@@ -608,20 +608,20 @@ const mn = (e) => {
|
|
|
608
608
|
({ uuid: c }) => c
|
|
609
609
|
)
|
|
610
610
|
);
|
|
611
|
-
e.registerObjectAtPointerEventHandler = r, e.deregisterObjectAtPointerEventHandler =
|
|
612
|
-
const { onClick: u, onPointerMove:
|
|
611
|
+
e.registerObjectAtPointerEventHandler = r, e.deregisterObjectAtPointerEventHandler = l, e.registerBlockingObjectAtPointerEventHandler = o, e.deregisterBlockingObjectAtPointerEventHandler = i;
|
|
612
|
+
const { onClick: u, onPointerMove: a } = Ke(s, e);
|
|
613
613
|
u(({ intersects: c, event: p }) => {
|
|
614
|
-
var
|
|
615
|
-
c.length && ((
|
|
614
|
+
var P;
|
|
615
|
+
c.length && ((P = t.click.get(c[0].object)) == null || P(c[0], p));
|
|
616
616
|
});
|
|
617
617
|
let y;
|
|
618
|
-
return
|
|
618
|
+
return a(({ intersects: c, event: p }) => {
|
|
619
619
|
var w, v, h, _;
|
|
620
|
-
const
|
|
621
|
-
y && y !==
|
|
620
|
+
const P = (w = c == null ? void 0 : c[0]) == null ? void 0 : w.object, { pointerLeave: f, pointerEnter: b, pointerMove: m } = t;
|
|
621
|
+
y && y !== P && ((v = f.get(y)) == null || v(y, p)), P && (y !== P && ((h = b.get(P)) == null || h(c[0], p)), (_ = m.get(P)) == null || _(c[0], p)), y = P || null;
|
|
622
622
|
}), {
|
|
623
623
|
registerObject: r,
|
|
624
|
-
deregisterObject:
|
|
624
|
+
deregisterObject: l,
|
|
625
625
|
registerBlockingObject: o,
|
|
626
626
|
deregisterBlockingObject: i
|
|
627
627
|
};
|
|
@@ -630,7 +630,7 @@ function be(e) {
|
|
|
630
630
|
let t = 0;
|
|
631
631
|
return e.traverse((n) => {
|
|
632
632
|
if (n.isMesh && n.geometry) {
|
|
633
|
-
const o = n.geometry, i = o.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT,
|
|
633
|
+
const o = n.geometry, i = o.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, l = o.index ? o.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, r = o.attributes.normal ? o.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, s = o.attributes.uv ? o.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, u = i + l + r + s;
|
|
634
634
|
t += u;
|
|
635
635
|
}
|
|
636
636
|
}), t;
|
|
@@ -640,9 +640,9 @@ function Lr(e) {
|
|
|
640
640
|
}
|
|
641
641
|
const de = A({}), pe = (e) => Object.assign(de.value, e);
|
|
642
642
|
function Dr(e, t, n = 10) {
|
|
643
|
-
const o = k(e) ? It() : Ht(B(() => k(t).parentElement)), i = ue(Le(o.width, n)),
|
|
643
|
+
const o = k(e) ? It() : Ht(B(() => k(t).parentElement)), i = ue(Le(o.width, n)), l = ue(Le(o.height, n)), r = B(() => i.value / l.value);
|
|
644
644
|
return {
|
|
645
|
-
height:
|
|
645
|
+
height: l,
|
|
646
646
|
width: i,
|
|
647
647
|
aspectRatio: r
|
|
648
648
|
};
|
|
@@ -651,22 +651,22 @@ function le() {
|
|
|
651
651
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
652
652
|
let n = 0, o = !1;
|
|
653
653
|
const i = () => {
|
|
654
|
-
const
|
|
654
|
+
const a = Array.from(e.entries()).sort((y, c) => {
|
|
655
655
|
const p = y[1].priority - c[1].priority;
|
|
656
656
|
return p === 0 ? y[1].addI - c[1].addI : p;
|
|
657
657
|
});
|
|
658
|
-
t.clear(),
|
|
659
|
-
},
|
|
660
|
-
e.delete(
|
|
658
|
+
t.clear(), a.forEach((y) => t.add(y[0]));
|
|
659
|
+
}, l = (a) => {
|
|
660
|
+
e.delete(a), t.delete(a);
|
|
661
661
|
};
|
|
662
|
-
return { on: (
|
|
663
|
-
e.set(
|
|
664
|
-
const c = () => a
|
|
662
|
+
return { on: (a, y = 0) => {
|
|
663
|
+
e.set(a, { priority: y, addI: n++ });
|
|
664
|
+
const c = () => l(a);
|
|
665
665
|
return Ut(c), o = !0, {
|
|
666
666
|
off: c
|
|
667
667
|
};
|
|
668
|
-
}, off:
|
|
669
|
-
o && (i(), o = !1), t.forEach((y) => y(...
|
|
668
|
+
}, off: l, trigger: (...a) => {
|
|
669
|
+
o && (i(), o = !1), t.forEach((y) => y(...a));
|
|
670
670
|
}, dispose: () => {
|
|
671
671
|
e.clear(), t.clear();
|
|
672
672
|
}, get count() {
|
|
@@ -677,18 +677,18 @@ function Br() {
|
|
|
677
677
|
const e = new We(!1), t = A(!1), n = A(!1);
|
|
678
678
|
let o;
|
|
679
679
|
const i = Mt.generateUUID();
|
|
680
|
-
let
|
|
680
|
+
let l = null;
|
|
681
681
|
const r = le(), s = le(), u = le();
|
|
682
|
-
let
|
|
682
|
+
let a = {};
|
|
683
683
|
function y(h) {
|
|
684
|
-
|
|
684
|
+
a = h;
|
|
685
685
|
}
|
|
686
686
|
function c(h, _, g = 0) {
|
|
687
687
|
switch (_) {
|
|
688
688
|
case "before":
|
|
689
689
|
return r.on(h, g);
|
|
690
690
|
case "render":
|
|
691
|
-
return
|
|
691
|
+
return l || (l = h), s.dispose(), s.on(h);
|
|
692
692
|
case "after":
|
|
693
693
|
return u.on(h, g);
|
|
694
694
|
}
|
|
@@ -696,7 +696,7 @@ function Br() {
|
|
|
696
696
|
function p() {
|
|
697
697
|
t.value || (e.start(), t.value = !0, v());
|
|
698
698
|
}
|
|
699
|
-
function
|
|
699
|
+
function P() {
|
|
700
700
|
t.value && (e.stop(), cancelAnimationFrame(o), t.value = !1);
|
|
701
701
|
}
|
|
702
702
|
function f() {
|
|
@@ -712,14 +712,22 @@ function Br() {
|
|
|
712
712
|
n.value = !1;
|
|
713
713
|
}
|
|
714
714
|
function v() {
|
|
715
|
-
const h = e.getDelta(), _ = e.getElapsedTime(), g = {
|
|
716
|
-
|
|
715
|
+
const h = e.getDelta(), _ = e.getElapsedTime(), g = {
|
|
716
|
+
camera: W(a.camera),
|
|
717
|
+
scene: W(a.scene),
|
|
718
|
+
renderer: W(a.renderer),
|
|
719
|
+
raycaster: W(a.raycaster),
|
|
720
|
+
controls: W(a.controls),
|
|
721
|
+
invalidate: a.invalidate,
|
|
722
|
+
advance: a.advance
|
|
723
|
+
}, M = { delta: h, elapsed: _, clock: e, ...g };
|
|
724
|
+
t.value && r.trigger(M), n.value || (s.count ? s.trigger(M) : l && l(M)), t.value && u.trigger(M), o = requestAnimationFrame(v);
|
|
717
725
|
}
|
|
718
726
|
return {
|
|
719
727
|
loopId: i,
|
|
720
728
|
register: (h, _, g) => c(h, _, g),
|
|
721
729
|
start: p,
|
|
722
|
-
stop:
|
|
730
|
+
stop: P,
|
|
723
731
|
pause: f,
|
|
724
732
|
resume: b,
|
|
725
733
|
pauseRender: m,
|
|
@@ -735,14 +743,14 @@ function Rr({
|
|
|
735
743
|
windowSize: n,
|
|
736
744
|
disableRender: o,
|
|
737
745
|
rendererOptions: i,
|
|
738
|
-
emit:
|
|
746
|
+
emit: l
|
|
739
747
|
}) {
|
|
740
748
|
const { logWarning: r } = $(), s = U(e), u = Dr(n, t), {
|
|
741
|
-
camera:
|
|
749
|
+
camera: a,
|
|
742
750
|
cameras: y,
|
|
743
751
|
registerCamera: c,
|
|
744
752
|
deregisterCamera: p,
|
|
745
|
-
setCameraActive:
|
|
753
|
+
setCameraActive: P
|
|
746
754
|
} = lr({ sizes: u, scene: e }), f = {
|
|
747
755
|
mode: A(i.renderMode || "always"),
|
|
748
756
|
priority: A(0),
|
|
@@ -761,15 +769,15 @@ function Rr({
|
|
|
761
769
|
scene: e,
|
|
762
770
|
canvas: t,
|
|
763
771
|
options: i,
|
|
764
|
-
emit:
|
|
772
|
+
emit: l,
|
|
765
773
|
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
|
|
766
|
-
contextParts: { sizes: u, camera:
|
|
774
|
+
contextParts: { sizes: u, camera: a, render: f, invalidate: b, advance: m },
|
|
767
775
|
disableRender: o
|
|
768
776
|
}
|
|
769
777
|
), v = {
|
|
770
778
|
sizes: u,
|
|
771
779
|
scene: s,
|
|
772
|
-
camera:
|
|
780
|
+
camera: a,
|
|
773
781
|
cameras: ue(y),
|
|
774
782
|
renderer: w,
|
|
775
783
|
raycaster: U(new Pt()),
|
|
@@ -791,21 +799,21 @@ function Rr({
|
|
|
791
799
|
extend: pe,
|
|
792
800
|
invalidate: b,
|
|
793
801
|
registerCamera: c,
|
|
794
|
-
setCameraActive:
|
|
802
|
+
setCameraActive: P,
|
|
795
803
|
deregisterCamera: p,
|
|
796
804
|
loop: Br()
|
|
797
805
|
};
|
|
798
806
|
ce("useTres", v), v.scene.value.__tres = {
|
|
799
807
|
root: v
|
|
800
808
|
}, v.loop.register(() => {
|
|
801
|
-
|
|
809
|
+
a.value && f.frames.value > 0 && (w.value.render(e, a.value), l("render", v.renderer.value)), f.priority.value = 0, f.mode.value === "always" ? f.frames.value = 1 : f.frames.value = Math.max(0, f.frames.value - 1);
|
|
802
810
|
}, "render"), v.loop.start(), N(() => {
|
|
803
811
|
v.loop.stop();
|
|
804
812
|
});
|
|
805
|
-
const h = 100, _ = $t({ every: h }), { isSupported: g, memory:
|
|
813
|
+
const h = 100, _ = $t({ every: h }), { isSupported: g, memory: M } = Ft({ interval: h }), C = 160;
|
|
806
814
|
let R = performance.now();
|
|
807
815
|
const O = ({ timestamp: L }) => {
|
|
808
|
-
v.scene.value && (v.perf.memory.allocatedMem = be(v.scene.value)), L - R >= h && (R = L, v.perf.fps.accumulator.push(_.value), v.perf.fps.accumulator.length > C && v.perf.fps.accumulator.shift(), v.perf.fps.value = _.value, g.value &&
|
|
816
|
+
v.scene.value && (v.perf.memory.allocatedMem = be(v.scene.value)), L - R >= h && (R = L, v.perf.fps.accumulator.push(_.value), v.perf.fps.accumulator.length > C && v.perf.fps.accumulator.shift(), v.perf.fps.value = _.value, g.value && M.value && (v.perf.memory.accumulator.push(M.value.usedJSHeapSize / 1024 / 1024), v.perf.memory.accumulator.length > C && v.perf.memory.accumulator.shift(), v.perf.memory.currentMem = v.perf.memory.accumulator.reduce((Y, z) => Y + z, 0) / v.perf.memory.accumulator.length));
|
|
809
817
|
};
|
|
810
818
|
let T = 0;
|
|
811
819
|
const S = 1, { pause: j } = Ve(({ delta: L }) => {
|
|
@@ -829,23 +837,23 @@ function gn() {
|
|
|
829
837
|
renderer: n,
|
|
830
838
|
loop: o,
|
|
831
839
|
raycaster: i,
|
|
832
|
-
controls:
|
|
840
|
+
controls: l,
|
|
833
841
|
invalidate: r,
|
|
834
842
|
advance: s
|
|
835
843
|
} = Xe();
|
|
836
844
|
o.setContext({
|
|
837
|
-
camera:
|
|
838
|
-
scene:
|
|
839
|
-
renderer:
|
|
840
|
-
raycaster:
|
|
841
|
-
controls:
|
|
845
|
+
camera: e,
|
|
846
|
+
scene: t,
|
|
847
|
+
renderer: n,
|
|
848
|
+
raycaster: i,
|
|
849
|
+
controls: l,
|
|
842
850
|
invalidate: r,
|
|
843
851
|
advance: s
|
|
844
852
|
});
|
|
845
853
|
function u(c, p = 0) {
|
|
846
854
|
return o.register(c, "before", p);
|
|
847
855
|
}
|
|
848
|
-
function
|
|
856
|
+
function a(c) {
|
|
849
857
|
return o.register(c, "render");
|
|
850
858
|
}
|
|
851
859
|
function y(c, p = 0) {
|
|
@@ -858,63 +866,63 @@ function gn() {
|
|
|
858
866
|
resumeRender: o.resumeRender,
|
|
859
867
|
isActive: o.isActive,
|
|
860
868
|
onBeforeRender: u,
|
|
861
|
-
render:
|
|
869
|
+
render: a,
|
|
862
870
|
onAfterRender: y
|
|
863
871
|
};
|
|
864
872
|
}
|
|
865
873
|
function jr(e, t, n) {
|
|
866
874
|
const o = U(), i = U();
|
|
867
875
|
e && (o.value = e), t && (i.value = t);
|
|
868
|
-
const
|
|
876
|
+
const l = B(
|
|
869
877
|
() => o.value ? o.value.children : []
|
|
870
878
|
);
|
|
871
|
-
function r(g,
|
|
879
|
+
function r(g, M) {
|
|
872
880
|
if (Array.isArray(g))
|
|
873
881
|
for (const C of g)
|
|
874
|
-
C(
|
|
875
|
-
typeof g == "function" && g(
|
|
882
|
+
C(M);
|
|
883
|
+
typeof g == "function" && g(M);
|
|
876
884
|
}
|
|
877
|
-
function s(g,
|
|
878
|
-
const C = [], R = () =>
|
|
879
|
-
|
|
880
|
-
for (const O of
|
|
881
|
-
if (
|
|
885
|
+
function s(g, M) {
|
|
886
|
+
const C = [], R = () => M.stopPropagating = !0;
|
|
887
|
+
M.stopPropagation = R;
|
|
888
|
+
for (const O of M == null ? void 0 : M.intersections) {
|
|
889
|
+
if (M.stopPropagating)
|
|
882
890
|
return;
|
|
883
|
-
|
|
891
|
+
M = { ...M, ...O };
|
|
884
892
|
const { object: T } = O;
|
|
885
|
-
|
|
893
|
+
M.eventObject = T, r(T[g], M), C.push(T);
|
|
886
894
|
let S = T.parent;
|
|
887
|
-
for (; S !== null && !
|
|
888
|
-
|
|
895
|
+
for (; S !== null && !M.stopPropagating && !C.includes(S); )
|
|
896
|
+
M.eventObject = S, r(S[g], M), C.push(S), S = S.parent;
|
|
889
897
|
const j = yr(g.slice(2));
|
|
890
|
-
n(j, { intersection: O, event:
|
|
898
|
+
n(j, { intersection: O, event: M });
|
|
891
899
|
}
|
|
892
900
|
}
|
|
893
901
|
const {
|
|
894
902
|
onClick: u,
|
|
895
|
-
onDblClick:
|
|
903
|
+
onDblClick: a,
|
|
896
904
|
onContextMenu: y,
|
|
897
905
|
onPointerMove: c,
|
|
898
906
|
onPointerDown: p,
|
|
899
|
-
onPointerUp:
|
|
907
|
+
onPointerUp: P,
|
|
900
908
|
onPointerMissed: f,
|
|
901
909
|
onWheel: b,
|
|
902
910
|
forceUpdate: m
|
|
903
|
-
} = Ke(
|
|
904
|
-
|
|
911
|
+
} = Ke(l, t);
|
|
912
|
+
P((g) => s("onPointerUp", g)), p((g) => s("onPointerDown", g)), u((g) => s("onClick", g)), a((g) => s("onDoubleClick", g)), y((g) => s("onContextMenu", g)), b((g) => s("onWheel", g));
|
|
905
913
|
let w = [];
|
|
906
914
|
c((g) => {
|
|
907
|
-
const
|
|
915
|
+
const M = g.intersections.map(({ object: C }) => C);
|
|
908
916
|
w.forEach((C) => {
|
|
909
|
-
|
|
917
|
+
M.includes(C) || (s("onPointerLeave", g), s("onPointerOut", g));
|
|
910
918
|
}), g.intersections.forEach(({ object: C }) => {
|
|
911
919
|
w.includes(C) || (s("onPointerEnter", g), s("onPointerOver", g));
|
|
912
|
-
}), s("onPointerMove", g), w =
|
|
920
|
+
}), s("onPointerMove", g), w = M;
|
|
913
921
|
});
|
|
914
922
|
const v = [];
|
|
915
923
|
f((g) => {
|
|
916
|
-
const
|
|
917
|
-
g.stopPropagation =
|
|
924
|
+
const M = () => g.stopPropagating = !0;
|
|
925
|
+
g.stopPropagation = M, v.forEach((C) => {
|
|
918
926
|
g.stopPropagating || (g.eventObject = C, r(C.onPointerMissed, g));
|
|
919
927
|
}), n("pointer-missed", { event: g });
|
|
920
928
|
});
|
|
@@ -922,8 +930,8 @@ function jr(e, t, n) {
|
|
|
922
930
|
v.push(g);
|
|
923
931
|
}
|
|
924
932
|
function _(g) {
|
|
925
|
-
const
|
|
926
|
-
|
|
933
|
+
const M = v.indexOf(g);
|
|
934
|
+
M > -1 && v.splice(M, 1);
|
|
927
935
|
}
|
|
928
936
|
return t.eventManager = {
|
|
929
937
|
forceUpdate: m,
|
|
@@ -954,43 +962,43 @@ function Ie(e) {
|
|
|
954
962
|
}
|
|
955
963
|
const Hr = () => {
|
|
956
964
|
let e = null;
|
|
957
|
-
function t(r, s, u,
|
|
958
|
-
if (
|
|
965
|
+
function t(r, s, u, a) {
|
|
966
|
+
if (a || (a = {}), a.args || (a.args = []), r === "template" || gr(r))
|
|
959
967
|
return null;
|
|
960
968
|
let y = r.replace("Tres", ""), c;
|
|
961
969
|
if (r === "primitive") {
|
|
962
|
-
(
|
|
963
|
-
const p =
|
|
970
|
+
(a == null ? void 0 : a.object) === void 0 && je("Tres primitives need a prop 'object'");
|
|
971
|
+
const p = a.object;
|
|
964
972
|
y = p.type, c = Object.assign(p.clone(), { type: y });
|
|
965
973
|
} else {
|
|
966
974
|
const p = de.value[y];
|
|
967
975
|
p || je(
|
|
968
976
|
`${y} is not defined on the THREE namespace. Use extend to add it to the catalog.`
|
|
969
|
-
), c = new p(...
|
|
977
|
+
), c = new p(...a.args);
|
|
970
978
|
}
|
|
971
|
-
return c ? (c.isCamera && (
|
|
979
|
+
return c ? (c.isCamera && (a != null && a.position || c.position.set(3, 3, 3), a != null && a.lookAt || c.lookAt(0, 0, 0)), (a == null ? void 0 : a.attach) === void 0 && (c.isMaterial ? c.attach = "material" : c.isBufferGeometry && (c.attach = "geometry")), c.__tres = {
|
|
972
980
|
...c.__tres,
|
|
973
981
|
type: y,
|
|
974
|
-
memoizedProps:
|
|
982
|
+
memoizedProps: a,
|
|
975
983
|
eventCount: 0,
|
|
976
984
|
disposable: !0,
|
|
977
985
|
primitive: r === "primitive"
|
|
978
|
-
}, c.isObject3D && c.__tres && (
|
|
986
|
+
}, c.isObject3D && c.__tres && (a != null && a.material || a != null && a.geometry) && (c.__tres.disposable = !1), c) : null;
|
|
979
987
|
}
|
|
980
988
|
function n(r, s) {
|
|
981
|
-
var
|
|
989
|
+
var a, y, c, p, P;
|
|
982
990
|
if (!r)
|
|
983
991
|
return;
|
|
984
992
|
s && s.isScene && (e = s), e && r.__tres && (r.__tres.root = e.__tres.root);
|
|
985
993
|
const u = s || e;
|
|
986
994
|
if (r != null && r.isObject3D) {
|
|
987
|
-
const { registerCamera: f } = (
|
|
988
|
-
r != null && r.isCamera && f(r), r.onPointerMissed && ((y = r == null ? void 0 : r.__tres) != null && y.root) && ((
|
|
995
|
+
const { registerCamera: f } = (a = r == null ? void 0 : r.__tres) == null ? void 0 : a.root;
|
|
996
|
+
r != null && r.isCamera && f(r), r.onPointerMissed && ((y = r == null ? void 0 : r.__tres) != null && y.root) && ((P = (p = (c = r == null ? void 0 : r.__tres) == null ? void 0 : c.root) == null ? void 0 : p.eventManager) == null || P.registerPointerMissedObject(r));
|
|
989
997
|
}
|
|
990
998
|
r != null && r.isObject3D && (u != null && u.isObject3D) ? (u.add(r), r.dispatchEvent({ type: "added" })) : r != null && r.isFog ? u.fog = r : typeof (r == null ? void 0 : r.attach) == "string" && (r.__previousAttach = r[u == null ? void 0 : u.attach], u && (u[r.attach] = r));
|
|
991
999
|
}
|
|
992
1000
|
function o(r) {
|
|
993
|
-
var u,
|
|
1001
|
+
var u, a, y, c;
|
|
994
1002
|
if (!r)
|
|
995
1003
|
return;
|
|
996
1004
|
const s = r.__tres;
|
|
@@ -1003,16 +1011,16 @@ const Hr = () => {
|
|
|
1003
1011
|
(u = r.removeFromParent) == null || u.call(r), r.traverse((f) => {
|
|
1004
1012
|
var b, m;
|
|
1005
1013
|
p(f), f.onPointerMissed && ((m = (b = s == null ? void 0 : s.root) == null ? void 0 : b.eventManager) == null || m.deregisterPointerMissedObject(f));
|
|
1006
|
-
}), p(r), Ie(r), !((
|
|
1014
|
+
}), p(r), Ie(r), !((a = r.__tres) == null ? void 0 : a.primitive) && ((y = r.__tres) != null && y.disposable) && ye(r), (c = r.dispose) == null || c.call(r);
|
|
1007
1015
|
}
|
|
1008
1016
|
}
|
|
1009
|
-
function i(r, s, u,
|
|
1017
|
+
function i(r, s, u, a) {
|
|
1010
1018
|
var y, c;
|
|
1011
1019
|
if (r) {
|
|
1012
|
-
let p = r,
|
|
1013
|
-
if ((y = r == null ? void 0 : r.__tres) != null && y.primitive &&
|
|
1020
|
+
let p = r, P = s;
|
|
1021
|
+
if ((y = r == null ? void 0 : r.__tres) != null && y.primitive && P === "object" && u !== null) {
|
|
1014
1022
|
const w = t("primitive", void 0, void 0, {
|
|
1015
|
-
object:
|
|
1023
|
+
object: a
|
|
1016
1024
|
});
|
|
1017
1025
|
for (const v in w) {
|
|
1018
1026
|
if (v === "uuid")
|
|
@@ -1022,33 +1030,33 @@ const Hr = () => {
|
|
|
1022
1030
|
}
|
|
1023
1031
|
w != null && w.__tres && (w.__tres.root = e == null ? void 0 : e.__tres.root), w != null && w.isGroup ? (r.geometry = void 0, r.material = void 0) : delete r.isGroup;
|
|
1024
1032
|
}
|
|
1025
|
-
if (r != null && r.isObject3D &&
|
|
1026
|
-
|
|
1033
|
+
if (r != null && r.isObject3D && P === "blocks-pointer-events") {
|
|
1034
|
+
a || a === "" ? r[P] = a : delete r[P];
|
|
1027
1035
|
return;
|
|
1028
1036
|
}
|
|
1029
|
-
let f = X(
|
|
1030
|
-
if (
|
|
1031
|
-
const w = r, v = u ?? [], h =
|
|
1037
|
+
let f = X(P), b = p == null ? void 0 : p[f];
|
|
1038
|
+
if (P === "args") {
|
|
1039
|
+
const w = r, v = u ?? [], h = a ?? [], _ = ((c = r == null ? void 0 : r.__tres) == null ? void 0 : c.type) || r.type;
|
|
1032
1040
|
_ && v.length && !Pr(v, h) && (p = Object.assign(
|
|
1033
1041
|
w,
|
|
1034
|
-
new de.value[_](...
|
|
1042
|
+
new de.value[_](...a)
|
|
1035
1043
|
));
|
|
1036
1044
|
return;
|
|
1037
1045
|
}
|
|
1038
1046
|
if (p.type === "BufferGeometry") {
|
|
1039
|
-
if (
|
|
1047
|
+
if (P === "args")
|
|
1040
1048
|
return;
|
|
1041
1049
|
p.setAttribute(
|
|
1042
|
-
X(
|
|
1043
|
-
new Ct(...
|
|
1050
|
+
X(P),
|
|
1051
|
+
new Ct(...a)
|
|
1044
1052
|
);
|
|
1045
1053
|
return;
|
|
1046
1054
|
}
|
|
1047
|
-
if (
|
|
1048
|
-
const w =
|
|
1049
|
-
b = w.reduce((v, h) => v[X(h)], p),
|
|
1055
|
+
if (P.includes("-") && b === void 0) {
|
|
1056
|
+
const w = P.split("-");
|
|
1057
|
+
b = w.reduce((v, h) => v[X(h)], p), P = w.pop(), f = P, b != null && b.set || (p = w.reduce((v, h) => v[X(h)], p));
|
|
1050
1058
|
}
|
|
1051
|
-
let m =
|
|
1059
|
+
let m = a;
|
|
1052
1060
|
if (m === "" && (m = !0), ee(b)) {
|
|
1053
1061
|
Ir.includes(s) || (Array.isArray(m) ? r[f](...m) : r[f](m)), f.startsWith("on") && ee(m) && (p[f] = m);
|
|
1054
1062
|
return;
|
|
@@ -1056,7 +1064,7 @@ const Hr = () => {
|
|
|
1056
1064
|
!(b != null && b.set) && !ee(b) ? p[f] = m : b.constructor === m.constructor && (b != null && b.copy) ? b == null || b.copy(m) : Array.isArray(m) ? b.set(...m) : !b.isColor && b.setScalar ? b.setScalar(m) : b.set(m), Ie(r);
|
|
1057
1065
|
}
|
|
1058
1066
|
}
|
|
1059
|
-
function
|
|
1067
|
+
function l(r) {
|
|
1060
1068
|
return (r == null ? void 0 : r.parent) || null;
|
|
1061
1069
|
}
|
|
1062
1070
|
return {
|
|
@@ -1064,7 +1072,7 @@ const Hr = () => {
|
|
|
1064
1072
|
remove: o,
|
|
1065
1073
|
createElement: t,
|
|
1066
1074
|
patchProp: i,
|
|
1067
|
-
parentNode:
|
|
1075
|
+
parentNode: l,
|
|
1068
1076
|
createText: () => void 0,
|
|
1069
1077
|
createComment: () => void 0,
|
|
1070
1078
|
setText: () => void 0,
|
|
@@ -1101,22 +1109,22 @@ class Gr {
|
|
|
1101
1109
|
o[r] = s.defaultValue;
|
|
1102
1110
|
}
|
|
1103
1111
|
const i = `__vue-devtools-plugin-settings__${t.id}`;
|
|
1104
|
-
let
|
|
1112
|
+
let l = Object.assign({}, o);
|
|
1105
1113
|
try {
|
|
1106
1114
|
const r = localStorage.getItem(i), s = JSON.parse(r);
|
|
1107
|
-
Object.assign(
|
|
1115
|
+
Object.assign(l, s);
|
|
1108
1116
|
} catch {
|
|
1109
1117
|
}
|
|
1110
1118
|
this.fallbacks = {
|
|
1111
1119
|
getSettings() {
|
|
1112
|
-
return
|
|
1120
|
+
return l;
|
|
1113
1121
|
},
|
|
1114
1122
|
setSettings(r) {
|
|
1115
1123
|
try {
|
|
1116
1124
|
localStorage.setItem(i, JSON.stringify(r));
|
|
1117
1125
|
} catch {
|
|
1118
1126
|
}
|
|
1119
|
-
|
|
1127
|
+
l = r;
|
|
1120
1128
|
},
|
|
1121
1129
|
now() {
|
|
1122
1130
|
return zr();
|
|
@@ -1136,11 +1144,11 @@ class Gr {
|
|
|
1136
1144
|
args: u,
|
|
1137
1145
|
resolve: () => {
|
|
1138
1146
|
}
|
|
1139
|
-
}), this.fallbacks[s](...u)) : (...u) => new Promise((
|
|
1147
|
+
}), this.fallbacks[s](...u)) : (...u) => new Promise((a) => {
|
|
1140
1148
|
this.targetQueue.push({
|
|
1141
1149
|
method: s,
|
|
1142
1150
|
args: u,
|
|
1143
|
-
resolve:
|
|
1151
|
+
resolve: a
|
|
1144
1152
|
});
|
|
1145
1153
|
})
|
|
1146
1154
|
});
|
|
@@ -1154,11 +1162,11 @@ class Gr {
|
|
|
1154
1162
|
}
|
|
1155
1163
|
}
|
|
1156
1164
|
function Vr(e, t) {
|
|
1157
|
-
const n = e, o = Ze(), i = Ur(),
|
|
1158
|
-
if (i && (o.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !
|
|
1165
|
+
const n = e, o = Ze(), i = Ur(), l = $r && n.enableEarlyProxy;
|
|
1166
|
+
if (i && (o.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l))
|
|
1159
1167
|
i.emit(Fr, e, t);
|
|
1160
1168
|
else {
|
|
1161
|
-
const r =
|
|
1169
|
+
const r = l ? new Gr(n, i) : null;
|
|
1162
1170
|
(o.__VUE_DEVTOOLS_PLUGINS__ = o.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
1163
1171
|
pluginDescriptor: n,
|
|
1164
1172
|
setupFn: t,
|
|
@@ -1247,24 +1255,24 @@ function Qr(e, t) {
|
|
|
1247
1255
|
n.sendInspectorTree(G);
|
|
1248
1256
|
}, 1e3), setInterval(() => {
|
|
1249
1257
|
n.notifyComponentUpdate();
|
|
1250
|
-
}, 5e3), n.on.getInspectorTree((
|
|
1251
|
-
if (
|
|
1258
|
+
}, 5e3), n.on.getInspectorTree((l) => {
|
|
1259
|
+
if (l.inspectorId === G) {
|
|
1252
1260
|
const r = et(t.scene.value);
|
|
1253
|
-
tt(t.scene.value, r,
|
|
1261
|
+
tt(t.scene.value, r, l.filter), Jr.sceneGraph = r, l.rootNodes = [r];
|
|
1254
1262
|
}
|
|
1255
1263
|
});
|
|
1256
1264
|
let o = null, i = null;
|
|
1257
|
-
n.on.getInspectorState((
|
|
1265
|
+
n.on.getInspectorState((l) => {
|
|
1258
1266
|
var r;
|
|
1259
|
-
if (
|
|
1260
|
-
const [s] = t.scene.value.getObjectsByProperty("uuid",
|
|
1267
|
+
if (l.inspectorId === G) {
|
|
1268
|
+
const [s] = t.scene.value.getObjectsByProperty("uuid", l.nodeId);
|
|
1261
1269
|
if (!s)
|
|
1262
1270
|
return;
|
|
1263
1271
|
if (i && o && o.parent && i.remove(o), s.isMesh) {
|
|
1264
1272
|
const u = Er(s);
|
|
1265
1273
|
s.add(u), o = u, i = s;
|
|
1266
1274
|
}
|
|
1267
|
-
|
|
1275
|
+
l.state = {
|
|
1268
1276
|
object: [
|
|
1269
1277
|
{
|
|
1270
1278
|
key: "uuid",
|
|
@@ -1349,14 +1357,14 @@ function Qr(e, t) {
|
|
|
1349
1357
|
value: s.visible
|
|
1350
1358
|
}
|
|
1351
1359
|
]
|
|
1352
|
-
}, s.isScene && (
|
|
1360
|
+
}, s.isScene && (l.state.info = {
|
|
1353
1361
|
memory: be(s),
|
|
1354
1362
|
objects: s.children.length,
|
|
1355
1363
|
calls: t.renderer.value.info.render.calls,
|
|
1356
1364
|
triangles: t.renderer.value.info.render.triangles,
|
|
1357
1365
|
points: t.renderer.value.info.render.points,
|
|
1358
1366
|
lines: t.renderer.value.info.render.lines
|
|
1359
|
-
},
|
|
1367
|
+
}, l.state.programs = ((r = t.renderer.value.info.programs) == null ? void 0 : r.map((u) => ({
|
|
1360
1368
|
key: u.name,
|
|
1361
1369
|
value: {
|
|
1362
1370
|
...u,
|
|
@@ -1366,8 +1374,8 @@ function Qr(e, t) {
|
|
|
1366
1374
|
}
|
|
1367
1375
|
}))) || []);
|
|
1368
1376
|
}
|
|
1369
|
-
}), n.on.editInspectorState((
|
|
1370
|
-
|
|
1377
|
+
}), n.on.editInspectorState((l) => {
|
|
1378
|
+
l.inspectorId === G && _r(t.scene.value, l.nodeId, l.path, l.state.value);
|
|
1371
1379
|
});
|
|
1372
1380
|
}
|
|
1373
1381
|
);
|
|
@@ -1416,13 +1424,13 @@ const Kr = ["data-scene", "data-tres"], Xr = /* @__PURE__ */ Se({
|
|
|
1416
1424
|
],
|
|
1417
1425
|
setup(e, { expose: t, emit: n }) {
|
|
1418
1426
|
var b;
|
|
1419
|
-
const o = e, i = n,
|
|
1427
|
+
const o = e, i = n, l = it(), { logWarning: r } = $(), s = A(), u = U(new Ne()), a = (b = xe()) == null ? void 0 : b.appContext.app;
|
|
1420
1428
|
pe(Fe);
|
|
1421
1429
|
const y = (m) => Se({
|
|
1422
1430
|
setup() {
|
|
1423
1431
|
var v;
|
|
1424
1432
|
const w = (v = xe()) == null ? void 0 : v.appContext;
|
|
1425
|
-
return w && (w.app =
|
|
1433
|
+
return w && (w.app = a), ce("useTres", m), ce("extend", pe), typeof window < "u" && Qr(w == null ? void 0 : w.app, m), () => Te(pt, null, l != null && l.default ? l.default() : []);
|
|
1426
1434
|
}
|
|
1427
1435
|
}), c = (m) => {
|
|
1428
1436
|
const w = y(m), { render: v } = dt(Hr());
|
|
@@ -1431,35 +1439,35 @@ const Kr = ["data-scene", "data-tres"], Xr = /* @__PURE__ */ Se({
|
|
|
1431
1439
|
ye(m.scene.value), w && (m.renderer.value.dispose(), m.renderer.value.renderLists.dispose(), m.renderer.value.forceContextLoss()), u.value.__tres = {
|
|
1432
1440
|
root: m
|
|
1433
1441
|
}, c(m);
|
|
1434
|
-
},
|
|
1442
|
+
}, P = B(() => o.disableRender), f = U(null);
|
|
1435
1443
|
return t({ context: f, dispose: () => p(f.value, !0) }), at(() => {
|
|
1436
1444
|
const m = s;
|
|
1437
1445
|
f.value = Rr({
|
|
1438
1446
|
scene: u.value,
|
|
1439
1447
|
canvas: m,
|
|
1440
1448
|
windowSize: o.windowSize ?? !1,
|
|
1441
|
-
disableRender:
|
|
1449
|
+
disableRender: P.value ?? !1,
|
|
1442
1450
|
rendererOptions: o,
|
|
1443
1451
|
emit: i
|
|
1444
1452
|
}), jr(u.value, f.value, i);
|
|
1445
1453
|
const { registerCamera: w, camera: v, cameras: h, deregisterCamera: _ } = f.value;
|
|
1446
1454
|
c(f.value);
|
|
1447
1455
|
const g = () => {
|
|
1448
|
-
const
|
|
1456
|
+
const M = new fe(
|
|
1449
1457
|
45,
|
|
1450
1458
|
window.innerWidth / window.innerHeight,
|
|
1451
1459
|
0.1,
|
|
1452
1460
|
1e3
|
|
1453
1461
|
);
|
|
1454
|
-
|
|
1462
|
+
M.position.set(3, 3, 3), M.lookAt(0, 0, 0), w(M);
|
|
1455
1463
|
const C = ve(() => {
|
|
1456
|
-
h.value.length >= 2 && (
|
|
1464
|
+
h.value.length >= 2 && (M.removeFromParent(), _(M), C == null || C());
|
|
1457
1465
|
});
|
|
1458
1466
|
};
|
|
1459
1467
|
V(
|
|
1460
1468
|
() => o.camera,
|
|
1461
|
-
(
|
|
1462
|
-
|
|
1469
|
+
(M, C) => {
|
|
1470
|
+
M && w(M), C && (C.removeFromParent(), _(C));
|
|
1463
1471
|
},
|
|
1464
1472
|
{
|
|
1465
1473
|
immediate: !0
|
|
@@ -1511,8 +1519,8 @@ class rt extends _t {
|
|
|
1511
1519
|
constructor(t, n) {
|
|
1512
1520
|
const o = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], i = new Ae();
|
|
1513
1521
|
i.setAttribute("position", new Oe(o, 3)), i.computeBoundingSphere();
|
|
1514
|
-
const
|
|
1515
|
-
super(i,
|
|
1522
|
+
const l = new Et({ fog: !1 });
|
|
1523
|
+
super(i, l), this.light = t, this.color = n, this.type = "RectAreaLightHelper";
|
|
1516
1524
|
const r = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], s = new Ae();
|
|
1517
1525
|
s.setAttribute("position", new Oe(r, 3)), s.computeBoundingSphere(), this.add(new kt(s, new ze({ side: St, fog: !1 })));
|
|
1518
1526
|
}
|
|
@@ -1587,6 +1595,7 @@ const wn = {
|
|
|
1587
1595
|
export {
|
|
1588
1596
|
Xr as TresCanvas,
|
|
1589
1597
|
de as catalogue,
|
|
1598
|
+
Br as createRenderLoop,
|
|
1590
1599
|
Mn as default,
|
|
1591
1600
|
ye as dispose,
|
|
1592
1601
|
pe as extend,
|