@tresjs/core 4.2.4 → 4.2.6
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,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v4.2.
|
|
3
|
+
* version: v4.2.6
|
|
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 bt = Object.defineProperty;
|
|
9
9
|
var Pt = (e, t, n) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
10
10
|
var me = (e, t, n) => Pt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
11
|
-
import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as ce, readonly as ye, unref as J, provide as _e, inject as
|
|
11
|
+
import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as ce, readonly as ye, unref as J, provide as _e, inject as Ct, isRef as Mt, reactive as Et, defineComponent as Be, useSlots as Tt, getCurrentInstance as Ie, onMounted as St, openBlock as At, createElementBlock as xt, normalizeClass as kt, normalizeStyle as Lt, createRenderer as Rt, h as He, Fragment as Ot } from "vue";
|
|
12
12
|
import * as et from "three";
|
|
13
13
|
import { PerspectiveCamera as we, Camera as Dt, Clock as tt, Vector3 as Se, Color as Z, Scene as nt, MathUtils as rt, MeshBasicMaterial as ot, DoubleSide as jt, REVISION as Bt, SRGBColorSpace as It, ACESFilmicToneMapping as st, PCFSoftShadowMap as Ht, NoToneMapping as $t, WebGLRenderer as he, TextureLoader as Ut, Vector2 as ge, Raycaster as Ft, BufferAttribute as Wt, Object3D as Nt, Line as zt, BufferGeometry as $e, Float32BufferAttribute as Ue, LineBasicMaterial as Gt, Mesh as Vt, BackSide as Yt, DirectionalLightHelper as qt, PointLightHelper as Jt, SpotLightHelper as Kt, HemisphereLightHelper as Qt, ArrowHelper as Xt } from "three";
|
|
14
14
|
import { createEventHook as j, useRafFn as it, toValue as k, unrefElement as Zt, useDevicePixelRatio as en, usePointer as tn, useElementBounding as nn, useWindowSize as rn, useElementSize as on, refDebounced as Fe, tryOnScopeDispose as sn, useFps as an, useMemory as ln } from "@vueuse/core";
|
|
15
|
-
const cn = "@tresjs/core", un = "module", fn = "4.2.
|
|
15
|
+
const cn = "@tresjs/core", un = "module", fn = "4.2.6", dn = "pnpm@9.1.4", pn = "Declarative ThreeJS using Vue Components", mn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", hn = "MIT", gn = [
|
|
16
16
|
"vue",
|
|
17
17
|
"3d",
|
|
18
18
|
"threejs",
|
|
@@ -40,9 +40,9 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.4", dn = "pnpm@9.1.4", pn =
|
|
|
40
40
|
}, _n = "./dist/tres.js", wn = "./dist/tres.js", bn = "./dist/index.d.ts", Pn = [
|
|
41
41
|
"*.d.ts",
|
|
42
42
|
"dist"
|
|
43
|
-
],
|
|
43
|
+
], Cn = {
|
|
44
44
|
access: "public"
|
|
45
|
-
},
|
|
45
|
+
}, Mn = {
|
|
46
46
|
dev: "cd playground && npm run dev",
|
|
47
47
|
build: "vite build",
|
|
48
48
|
playground: "cd playground && npm run dev",
|
|
@@ -122,8 +122,8 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.4", dn = "pnpm@9.1.4", pn =
|
|
|
122
122
|
module: wn,
|
|
123
123
|
types: bn,
|
|
124
124
|
files: Pn,
|
|
125
|
-
publishConfig:
|
|
126
|
-
scripts:
|
|
125
|
+
publishConfig: Cn,
|
|
126
|
+
scripts: Mn,
|
|
127
127
|
peerDependencies: En,
|
|
128
128
|
dependencies: Tn,
|
|
129
129
|
devDependencies: Sn
|
|
@@ -134,7 +134,7 @@ function be(e) {
|
|
|
134
134
|
function de(e) {
|
|
135
135
|
return Array.isArray(e);
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function xn(e) {
|
|
138
138
|
return typeof e == "number";
|
|
139
139
|
}
|
|
140
140
|
function at(e) {
|
|
@@ -152,7 +152,7 @@ function N(e) {
|
|
|
152
152
|
function We(e) {
|
|
153
153
|
return U(e) && "isCamera" in e && !!e.isCamera;
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function kn(e) {
|
|
156
156
|
return U(e) && "isBufferGeometry" in e && !!e.isBufferGeometry;
|
|
157
157
|
}
|
|
158
158
|
function Ln(e) {
|
|
@@ -168,7 +168,7 @@ function Dn(e) {
|
|
|
168
168
|
return U(e) && "isScene" in e && !!e.isScene;
|
|
169
169
|
}
|
|
170
170
|
function oe(e) {
|
|
171
|
-
return N(e) ||
|
|
171
|
+
return N(e) || kn(e) || Ln(e) || On(e);
|
|
172
172
|
}
|
|
173
173
|
function jn(e) {
|
|
174
174
|
return U(e) && !!e.isPrimitive;
|
|
@@ -177,22 +177,22 @@ const Bn = ({ sizes: e }) => {
|
|
|
177
177
|
const t = H([]), n = V(
|
|
178
178
|
() => t.value[0]
|
|
179
179
|
), r = (i) => {
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
180
|
+
const a = i instanceof Dt ? i : t.value.find((o) => o.uuid === i);
|
|
181
|
+
if (!a)
|
|
182
182
|
return;
|
|
183
|
-
const c = t.value.filter(({ uuid: o }) => o !==
|
|
184
|
-
t.value = [
|
|
185
|
-
}, s = (i,
|
|
183
|
+
const c = t.value.filter(({ uuid: o }) => o !== a.uuid);
|
|
184
|
+
t.value = [a, ...c];
|
|
185
|
+
}, s = (i, a = !1) => {
|
|
186
186
|
if (We(i)) {
|
|
187
187
|
const c = i;
|
|
188
188
|
if (t.value.some(({ uuid: o }) => o === c.uuid))
|
|
189
189
|
return;
|
|
190
|
-
|
|
190
|
+
a ? r(c) : t.value.push(c);
|
|
191
191
|
}
|
|
192
|
-
},
|
|
192
|
+
}, l = (i) => {
|
|
193
193
|
if (We(i)) {
|
|
194
|
-
const
|
|
195
|
-
t.value = t.value.filter(({ uuid: c }) => c !==
|
|
194
|
+
const a = i;
|
|
195
|
+
t.value = t.value.filter(({ uuid: c }) => c !== a.uuid);
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
return Te(() => {
|
|
@@ -205,7 +205,7 @@ const Bn = ({ sizes: e }) => {
|
|
|
205
205
|
camera: n,
|
|
206
206
|
cameras: t,
|
|
207
207
|
registerCamera: s,
|
|
208
|
-
deregisterCamera:
|
|
208
|
+
deregisterCamera: l,
|
|
209
209
|
setCameraActive: r
|
|
210
210
|
};
|
|
211
211
|
};
|
|
@@ -293,12 +293,12 @@ const Ve = (e, t) => {
|
|
|
293
293
|
return n == null ? void 0 : n.reduce((r, s) => r && r[s], e);
|
|
294
294
|
}, Yn = (e, t, n) => {
|
|
295
295
|
const r = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
|
|
296
|
-
r && r.reduce((s,
|
|
296
|
+
r && r.reduce((s, l, i) => (s[l] === void 0 && (s[l] = {}), i === r.length - 1 && (s[l] = n), s[l]), e);
|
|
297
297
|
};
|
|
298
298
|
function ft(e, t) {
|
|
299
299
|
if (Ge(e) && Ge(t)) {
|
|
300
|
-
const s = e.attributes,
|
|
301
|
-
return s.length !==
|
|
300
|
+
const s = e.attributes, l = t.attributes;
|
|
301
|
+
return s.length !== l.length ? !1 : Array.from(s).every(({ name: i, value: a }) => t.getAttribute(i) === a);
|
|
302
302
|
}
|
|
303
303
|
if (e === t)
|
|
304
304
|
return !0;
|
|
@@ -330,12 +330,12 @@ function Kn(e, t, n, r) {
|
|
|
330
330
|
if (u)
|
|
331
331
|
return u;
|
|
332
332
|
}
|
|
333
|
-
},
|
|
334
|
-
if (!
|
|
333
|
+
}, l = s(e);
|
|
334
|
+
if (!l) {
|
|
335
335
|
console.warn("Object with UUID not found in the scene.");
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
|
-
let i =
|
|
338
|
+
let i = l;
|
|
339
339
|
for (let c = 0; c < n.length - 1; c++)
|
|
340
340
|
if (i[n[c]] !== void 0)
|
|
341
341
|
i = i[n[c]];
|
|
@@ -343,8 +343,8 @@ function Kn(e, t, n, r) {
|
|
|
343
343
|
console.warn(`Property path is not valid: ${n.join(".")}`);
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
|
-
const
|
|
347
|
-
i[
|
|
346
|
+
const a = n[n.length - 1];
|
|
347
|
+
i[a] !== void 0 ? i[a] = r : console.warn(`Property path is not valid: ${n.join(".")}`);
|
|
348
348
|
}
|
|
349
349
|
function Qn(e) {
|
|
350
350
|
const t = new ot({
|
|
@@ -374,7 +374,7 @@ function dt(e) {
|
|
|
374
374
|
var n, r;
|
|
375
375
|
if (e.parent && ((n = e.removeFromParent) == null || n.call(e)), delete e.__tres, [...e.children].forEach((s) => dt(s)), !(e instanceof nt)) {
|
|
376
376
|
const s = e;
|
|
377
|
-
e && ((r = e.dispose) == null || r.call(e)), s.geometry && (s.geometry.dispose(), delete s.geometry), Array.isArray(s.material) ? (s.material.forEach((
|
|
377
|
+
e && ((r = e.dispose) == null || r.call(e)), s.geometry && (s.geometry.dispose(), delete s.geometry), Array.isArray(s.material) ? (s.material.forEach((l) => Ye(l)), delete s.material) : s.material && (Ye(s.material), delete s.material);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
function er(e, t) {
|
|
@@ -401,12 +401,12 @@ const Je = /-\d+$/;
|
|
|
401
401
|
function tr(e, t, n) {
|
|
402
402
|
if (at(n)) {
|
|
403
403
|
if (Je.test(n)) {
|
|
404
|
-
const
|
|
405
|
-
if (!Array.isArray(i[
|
|
406
|
-
const c = i[
|
|
404
|
+
const l = n.replace(Je, ""), { target: i, key: a } = Pe(e, l);
|
|
405
|
+
if (!Array.isArray(i[a])) {
|
|
406
|
+
const c = i[a], o = [];
|
|
407
407
|
o.__tresDetach = () => {
|
|
408
|
-
o.every((u) => be(u)) && (i[
|
|
409
|
-
}, i[
|
|
408
|
+
o.every((u) => be(u)) && (i[a] = c);
|
|
409
|
+
}, i[a] = o;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
const { target: r, key: s } = Pe(e, n);
|
|
@@ -415,13 +415,13 @@ function tr(e, t, n) {
|
|
|
415
415
|
t.__tres.previousAttach = n(e, t);
|
|
416
416
|
}
|
|
417
417
|
function nr(e, t, n) {
|
|
418
|
-
var r, s,
|
|
418
|
+
var r, s, l;
|
|
419
419
|
if (at(n)) {
|
|
420
|
-
const { target: i, key:
|
|
421
|
-
c === void 0 ? delete i[
|
|
420
|
+
const { target: i, key: a } = Pe(e, n), c = t.__tres.previousAttach;
|
|
421
|
+
c === void 0 ? delete i[a] : i[a] = c, "__tresDetach" in i && i.__tresDetach();
|
|
422
422
|
} else
|
|
423
423
|
(s = (r = t.__tres) == null ? void 0 : r.previousAttach) == null || s.call(r, e, t);
|
|
424
|
-
(
|
|
424
|
+
(l = t.__tres) == null || delete l.previousAttach;
|
|
425
425
|
}
|
|
426
426
|
function z(e, t, n) {
|
|
427
427
|
const r = e;
|
|
@@ -448,24 +448,24 @@ function rr(e, t, n) {
|
|
|
448
448
|
return;
|
|
449
449
|
let r = 0;
|
|
450
450
|
if (de(n) && n.length >= 2) {
|
|
451
|
-
const [
|
|
452
|
-
r = rt.clamp(t,
|
|
453
|
-
} else
|
|
451
|
+
const [l, i] = n;
|
|
452
|
+
r = rt.clamp(t, l, i);
|
|
453
|
+
} else xn(n) ? r = n : r = t;
|
|
454
454
|
r !== ((s = e.getPixelRatio) == null ? void 0 : s.call(e)) && e.setPixelRatio(r);
|
|
455
455
|
}
|
|
456
456
|
function or(e, t, n, r, s) {
|
|
457
|
-
const
|
|
457
|
+
const l = [...t.__tres.objects], i = Q(t);
|
|
458
458
|
if (e = Q(e), i === e)
|
|
459
459
|
return !0;
|
|
460
|
-
const
|
|
460
|
+
const a = z(e, t.__tres ?? {}, s), c = t.parent ?? t.__tres.parent ?? null, o = { ...t.__tres.memoizedProps };
|
|
461
461
|
delete o.object;
|
|
462
|
-
for (const u of
|
|
462
|
+
for (const u of l)
|
|
463
463
|
mt(u, s), ht(u, s);
|
|
464
464
|
i.__tres.objects = [], r.remove(t);
|
|
465
|
-
for (const [u,
|
|
466
|
-
r.patchProp(
|
|
465
|
+
for (const [u, v] of Object.entries(o))
|
|
466
|
+
r.patchProp(a, u, a[u], v);
|
|
467
467
|
n(e), r.insert(t, c);
|
|
468
|
-
for (const u of
|
|
468
|
+
for (const u of l)
|
|
469
469
|
r.insert(u, t);
|
|
470
470
|
return !0;
|
|
471
471
|
}
|
|
@@ -473,9 +473,9 @@ function Q(e) {
|
|
|
473
473
|
return jn(e) ? (e.object.__tres = e.__tres, e.object) : e;
|
|
474
474
|
}
|
|
475
475
|
function mt(e, t) {
|
|
476
|
-
var r, s,
|
|
476
|
+
var r, s, l, i;
|
|
477
477
|
const n = ((r = e.__tres) == null ? void 0 : r.parent) || t.scene.value;
|
|
478
|
-
e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && er(n.__tres.objects, (
|
|
478
|
+
e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && er(n.__tres.objects, (a) => a !== e), (s = e.__tres) != null && s.attach ? nr(n, e, e.__tres.attach) : ((i = (l = e.parent) == null ? void 0 : l.remove) == null || i.call(l, Q(e)), e.parent = null);
|
|
479
479
|
}
|
|
480
480
|
function ht(e, t) {
|
|
481
481
|
var n;
|
|
@@ -504,7 +504,7 @@ const sr = Number.parseInt(Bt.replace("dev", "")), ae = {
|
|
|
504
504
|
function ir({
|
|
505
505
|
canvas: e,
|
|
506
506
|
options: t,
|
|
507
|
-
contextParts: { sizes: n, render: r, invalidate: s, advance:
|
|
507
|
+
contextParts: { sizes: n, render: r, invalidate: s, advance: l }
|
|
508
508
|
}) {
|
|
509
509
|
const i = V(() => ({
|
|
510
510
|
alpha: k(t.alpha) ?? !0,
|
|
@@ -519,54 +519,54 @@ function ir({
|
|
|
519
519
|
preserveDrawingBuffer: k(t.preserveDrawingBuffer),
|
|
520
520
|
logarithmicDepthBuffer: k(t.logarithmicDepthBuffer),
|
|
521
521
|
failIfMajorPerformanceCaveat: k(t.failIfMajorPerformanceCaveat)
|
|
522
|
-
})),
|
|
522
|
+
})), a = $(new he(i.value));
|
|
523
523
|
function c() {
|
|
524
524
|
t.renderMode === "on-demand" && s();
|
|
525
525
|
}
|
|
526
526
|
ce(i, () => {
|
|
527
|
-
|
|
527
|
+
a.value.dispose(), a.value = new he(i.value), c();
|
|
528
528
|
}), ce([n.width, n.height], () => {
|
|
529
|
-
|
|
529
|
+
a.value.setSize(n.width.value, n.height.value), c();
|
|
530
530
|
}, {
|
|
531
531
|
immediate: !0
|
|
532
532
|
}), ce(() => t.clearColor, c);
|
|
533
533
|
const { pixelRatio: o } = en(), { logError: u } = Y(), f = (() => {
|
|
534
|
-
const
|
|
534
|
+
const g = new he(), b = {
|
|
535
535
|
shadowMap: {
|
|
536
|
-
enabled:
|
|
537
|
-
type:
|
|
536
|
+
enabled: g.shadowMap.enabled,
|
|
537
|
+
type: g.shadowMap.type
|
|
538
538
|
},
|
|
539
|
-
toneMapping:
|
|
540
|
-
toneMappingExposure:
|
|
541
|
-
outputColorSpace:
|
|
539
|
+
toneMapping: g.toneMapping,
|
|
540
|
+
toneMappingExposure: g.toneMappingExposure,
|
|
541
|
+
outputColorSpace: g.outputColorSpace
|
|
542
542
|
};
|
|
543
|
-
return
|
|
544
|
-
})(),
|
|
545
|
-
return
|
|
546
|
-
|
|
543
|
+
return g.dispose(), b;
|
|
544
|
+
})(), h = k(t.renderMode);
|
|
545
|
+
return h === "on-demand" && s(), h === "manual" && setTimeout(() => {
|
|
546
|
+
l();
|
|
547
547
|
}, 100), Te(() => {
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
const b = (C,
|
|
551
|
-
const P = k(C),
|
|
552
|
-
if (
|
|
553
|
-
return Ve(ae[
|
|
548
|
+
const g = k(t.preset);
|
|
549
|
+
g && (g in ae || u(`Renderer Preset must be one of these: ${Object.keys(ae).join(", ")}`), ut(a.value, ae[g])), rr(a.value, o.value, k(t.dpr)), h === "always" && (r.frames.value = Math.max(1, r.frames.value));
|
|
550
|
+
const b = (C, M) => {
|
|
551
|
+
const P = k(C), E = () => {
|
|
552
|
+
if (g)
|
|
553
|
+
return Ve(ae[g], M);
|
|
554
554
|
};
|
|
555
555
|
if (P !== void 0)
|
|
556
556
|
return P;
|
|
557
|
-
const
|
|
558
|
-
return
|
|
559
|
-
},
|
|
560
|
-
|
|
557
|
+
const S = E();
|
|
558
|
+
return S !== void 0 ? S : Ve(f, M);
|
|
559
|
+
}, y = (C, M) => Yn(a.value, M, b(C, M));
|
|
560
|
+
y(t.shadows, "shadowMap.enabled"), y(t.toneMapping ?? st, "toneMapping"), y(t.shadowMapType, "shadowMap.type"), sr < 150 && y(!t.useLegacyLights, "physicallyCorrectLights"), y(t.outputColorSpace, "outputColorSpace"), y(t.toneMappingExposure, "toneMappingExposure");
|
|
561
561
|
const d = b(t.clearColor, "clearColor");
|
|
562
|
-
d &&
|
|
562
|
+
d && a.value.setClearColor(
|
|
563
563
|
d ? Un(d) : new Z(0)
|
|
564
564
|
// default clear color is not easily/efficiently retrievable from three
|
|
565
565
|
);
|
|
566
566
|
}), K(() => {
|
|
567
|
-
|
|
567
|
+
a.value.dispose(), a.value.forceContextLoss();
|
|
568
568
|
}), {
|
|
569
|
-
renderer:
|
|
569
|
+
renderer: a
|
|
570
570
|
};
|
|
571
571
|
}
|
|
572
572
|
const ar = (e) => !!e && e.constructor === Array;
|
|
@@ -577,28 +577,28 @@ function lr(e) {
|
|
|
577
577
|
}), t;
|
|
578
578
|
}
|
|
579
579
|
async function Nr(e, t, n, r, s) {
|
|
580
|
-
const { logError:
|
|
580
|
+
const { logError: l } = Y(), i = new e();
|
|
581
581
|
s && s(i), n && n(i);
|
|
582
582
|
const c = (Array.isArray(t) ? t : [t]).map(
|
|
583
|
-
(o) => new Promise((u,
|
|
583
|
+
(o) => new Promise((u, v) => {
|
|
584
584
|
i.load(
|
|
585
585
|
o,
|
|
586
586
|
(f) => {
|
|
587
|
-
const
|
|
588
|
-
|
|
587
|
+
const h = f;
|
|
588
|
+
h.scene && Object.assign(h, lr(h.scene)), u(h);
|
|
589
589
|
},
|
|
590
590
|
r,
|
|
591
|
-
(f) =>
|
|
591
|
+
(f) => v(l("[useLoader] - Failed to load resource", f))
|
|
592
592
|
);
|
|
593
593
|
})
|
|
594
594
|
);
|
|
595
595
|
return ar(t) ? await Promise.all(c) : await c[0];
|
|
596
596
|
}
|
|
597
597
|
async function zr(e, t) {
|
|
598
|
-
const n = new Ut(t), r = (s) => new Promise((
|
|
598
|
+
const n = new Ut(t), r = (s) => new Promise((l, i) => {
|
|
599
599
|
n.load(
|
|
600
600
|
s,
|
|
601
|
-
(
|
|
601
|
+
(a) => l(a),
|
|
602
602
|
() => null,
|
|
603
603
|
() => {
|
|
604
604
|
i(new Error("[useTextures] - Failed to load texture"));
|
|
@@ -606,60 +606,60 @@ async function zr(e, t) {
|
|
|
606
606
|
);
|
|
607
607
|
});
|
|
608
608
|
if (Jn(e)) {
|
|
609
|
-
const s = await Promise.all(e.map((
|
|
609
|
+
const s = await Promise.all(e.map((l) => r(l)));
|
|
610
610
|
return e.length > 1 ? s : s[0];
|
|
611
611
|
} else {
|
|
612
612
|
const {
|
|
613
613
|
map: s,
|
|
614
|
-
displacementMap:
|
|
614
|
+
displacementMap: l,
|
|
615
615
|
normalMap: i,
|
|
616
|
-
roughnessMap:
|
|
616
|
+
roughnessMap: a,
|
|
617
617
|
metalnessMap: c,
|
|
618
618
|
aoMap: o,
|
|
619
619
|
alphaMap: u,
|
|
620
|
-
matcap:
|
|
620
|
+
matcap: v
|
|
621
621
|
} = e;
|
|
622
622
|
return {
|
|
623
623
|
map: s ? await r(s) : null,
|
|
624
|
-
displacementMap:
|
|
624
|
+
displacementMap: l ? await r(l) : null,
|
|
625
625
|
normalMap: i ? await r(i) : null,
|
|
626
|
-
roughnessMap:
|
|
626
|
+
roughnessMap: a ? await r(a) : null,
|
|
627
627
|
metalnessMap: c ? await r(c) : null,
|
|
628
628
|
aoMap: o ? await r(o) : null,
|
|
629
629
|
alphaMap: u ? await r(u) : null,
|
|
630
|
-
matcap:
|
|
630
|
+
matcap: v ? await r(v) : null
|
|
631
631
|
};
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
const cr = (e, t) => {
|
|
635
|
-
const n = V(() => t.renderer.value.domElement), r = $([]), { x: s, y:
|
|
635
|
+
const n = V(() => t.renderer.value.domElement), r = $([]), { x: s, y: l } = tn({ target: n });
|
|
636
636
|
let i = 0;
|
|
637
|
-
const { width:
|
|
637
|
+
const { width: a, height: c, top: o, left: u } = nn(n), v = ({ x: m, y: T }) => {
|
|
638
638
|
if (n.value)
|
|
639
639
|
return {
|
|
640
|
-
x: (
|
|
640
|
+
x: (m - u.value) / a.value * 2 - 1,
|
|
641
641
|
y: -((T - o.value) / c.value) * 2 + 1
|
|
642
642
|
};
|
|
643
|
-
}, f = ({ x:
|
|
643
|
+
}, f = ({ x: m, y: T }) => {
|
|
644
644
|
if (t.camera.value)
|
|
645
|
-
return t.raycaster.value.setFromCamera(new ge(
|
|
646
|
-
},
|
|
647
|
-
const T =
|
|
648
|
-
x: (
|
|
649
|
-
y: (
|
|
645
|
+
return t.raycaster.value.setFromCamera(new ge(m, T), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
|
|
646
|
+
}, h = (m) => {
|
|
647
|
+
const T = v({
|
|
648
|
+
x: (m == null ? void 0 : m.clientX) ?? s.value,
|
|
649
|
+
y: (m == null ? void 0 : m.clientY) ?? l.value
|
|
650
650
|
});
|
|
651
651
|
return T ? f(T) || [] : [];
|
|
652
|
-
},
|
|
653
|
-
function
|
|
652
|
+
}, g = j(), b = j(), y = j(), d = j(), C = j(), M = j(), P = j(), E = j();
|
|
653
|
+
function S(m) {
|
|
654
654
|
const T = {};
|
|
655
|
-
for (const F in
|
|
656
|
-
typeof F != "function" && (T[F] =
|
|
655
|
+
for (const F in m)
|
|
656
|
+
typeof F != "function" && (T[F] = m[F]);
|
|
657
657
|
return T;
|
|
658
658
|
}
|
|
659
|
-
const _ = (
|
|
659
|
+
const _ = (m, T) => {
|
|
660
660
|
var Oe, De, je;
|
|
661
|
-
const F =
|
|
662
|
-
|
|
661
|
+
const F = S(T), re = new Se(T == null ? void 0 : T.clientX, T == null ? void 0 : T.clientY, 0).unproject((Oe = t.camera) == null ? void 0 : Oe.value);
|
|
662
|
+
m.trigger({
|
|
663
663
|
...F,
|
|
664
664
|
intersections: r.value,
|
|
665
665
|
// The unprojectedPoint is wrong, math needs to be fixed
|
|
@@ -671,64 +671,64 @@ const cr = (e, t) => {
|
|
|
671
671
|
stopPropagating: !1
|
|
672
672
|
});
|
|
673
673
|
};
|
|
674
|
-
let
|
|
675
|
-
const
|
|
676
|
-
|
|
674
|
+
let A;
|
|
675
|
+
const L = (m) => {
|
|
676
|
+
h(m), _(y, m), A = m;
|
|
677
677
|
}, p = () => {
|
|
678
|
-
|
|
678
|
+
A && L(A);
|
|
679
679
|
};
|
|
680
|
-
let w,
|
|
681
|
-
const O = (
|
|
680
|
+
let w, x, D;
|
|
681
|
+
const O = (m) => {
|
|
682
682
|
var T;
|
|
683
|
-
w = (T = r.value[0]) == null ? void 0 : T.object, i = 0,
|
|
684
|
-
(
|
|
685
|
-
(
|
|
686
|
-
), _(C,
|
|
683
|
+
w = (T = r.value[0]) == null ? void 0 : T.object, i = 0, x = new ge(
|
|
684
|
+
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
685
|
+
(m == null ? void 0 : m.clientY) ?? l.value
|
|
686
|
+
), _(C, m);
|
|
687
687
|
};
|
|
688
688
|
let B, R = !1;
|
|
689
|
-
const ne = (
|
|
689
|
+
const ne = (m) => {
|
|
690
690
|
var T, F, re;
|
|
691
|
-
|
|
692
|
-
(
|
|
693
|
-
(
|
|
694
|
-
), i =
|
|
695
|
-
},
|
|
696
|
-
R && (_(b,
|
|
697
|
-
}, Le = (
|
|
698
|
-
return n.value.addEventListener("pointerup", ne), n.value.addEventListener("pointerdown", O), n.value.addEventListener("pointermove",
|
|
699
|
-
n != null && n.value && (n.value.removeEventListener("pointerup", ne), n.value.removeEventListener("pointerdown", O), n.value.removeEventListener("pointermove",
|
|
691
|
+
m instanceof PointerEvent && (r.value.length === 0 && _(M, m), w === ((T = r.value[0]) == null ? void 0 : T.object) && (D = new ge(
|
|
692
|
+
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
693
|
+
(m == null ? void 0 : m.clientY) ?? l.value
|
|
694
|
+
), i = x == null ? void 0 : x.distanceTo(D), m.button === 0 ? (_(g, m), B === ((F = r.value[0]) == null ? void 0 : F.object) ? R = !0 : (B = (re = r.value[0]) == null ? void 0 : re.object, R = !1)) : m.button === 2 && _(P, m)), _(d, m));
|
|
695
|
+
}, ke = (m) => {
|
|
696
|
+
R && (_(b, m), B = void 0, R = !1);
|
|
697
|
+
}, Le = (m) => _(y, m), Re = (m) => _(E, m);
|
|
698
|
+
return n.value.addEventListener("pointerup", ne), n.value.addEventListener("pointerdown", O), n.value.addEventListener("pointermove", L), n.value.addEventListener("pointerleave", Le), n.value.addEventListener("dblclick", ke), n.value.addEventListener("wheel", Re), K(() => {
|
|
699
|
+
n != null && n.value && (n.value.removeEventListener("pointerup", ne), n.value.removeEventListener("pointerdown", O), n.value.removeEventListener("pointermove", L), n.value.removeEventListener("pointerleave", Le), n.value.removeEventListener("dblclick", ke), n.value.removeEventListener("wheel", Re));
|
|
700
700
|
}), {
|
|
701
701
|
intersects: r,
|
|
702
|
-
onClick: (
|
|
703
|
-
onDblClick: (
|
|
704
|
-
onContextMenu: (
|
|
705
|
-
onPointerMove: (
|
|
706
|
-
onPointerUp: (
|
|
707
|
-
onPointerDown: (
|
|
708
|
-
onPointerMissed: (
|
|
709
|
-
onWheel: (
|
|
702
|
+
onClick: (m) => g.on(m).off,
|
|
703
|
+
onDblClick: (m) => b.on(m).off,
|
|
704
|
+
onContextMenu: (m) => P.on(m).off,
|
|
705
|
+
onPointerMove: (m) => y.on(m).off,
|
|
706
|
+
onPointerUp: (m) => d.on(m).off,
|
|
707
|
+
onPointerDown: (m) => C.on(m).off,
|
|
708
|
+
onPointerMissed: (m) => M.on(m).off,
|
|
709
|
+
onWheel: (m) => E.on(m).off,
|
|
710
710
|
forceUpdate: p
|
|
711
711
|
};
|
|
712
712
|
};
|
|
713
713
|
function Gr() {
|
|
714
714
|
const { logWarning: e } = Y();
|
|
715
|
-
function t(
|
|
715
|
+
function t(l, i, a) {
|
|
716
716
|
let c = null;
|
|
717
|
-
return
|
|
718
|
-
o[i] ===
|
|
719
|
-
}), c || e(`Child with ${i} '${
|
|
717
|
+
return l.traverse((o) => {
|
|
718
|
+
o[i] === a && (c = o);
|
|
719
|
+
}), c || e(`Child with ${i} '${a}' not found.`), c;
|
|
720
720
|
}
|
|
721
|
-
function n(
|
|
721
|
+
function n(l, i, a) {
|
|
722
722
|
const c = [];
|
|
723
|
-
return
|
|
724
|
-
o[i].includes(
|
|
725
|
-
}), c.length || e(`Children with ${i} '${
|
|
723
|
+
return l.traverse((o) => {
|
|
724
|
+
o[i].includes(a) && c.push(o);
|
|
725
|
+
}), c.length || e(`Children with ${i} '${a}' not found.`), c;
|
|
726
726
|
}
|
|
727
|
-
function r(
|
|
728
|
-
return t(
|
|
727
|
+
function r(l, i) {
|
|
728
|
+
return t(l, "name", i);
|
|
729
729
|
}
|
|
730
|
-
function s(
|
|
731
|
-
return n(
|
|
730
|
+
function s(l, i) {
|
|
731
|
+
return n(l, "name", i);
|
|
732
732
|
}
|
|
733
733
|
return {
|
|
734
734
|
seek: t,
|
|
@@ -737,11 +737,11 @@ function Gr() {
|
|
|
737
737
|
seekAllByName: s
|
|
738
738
|
};
|
|
739
739
|
}
|
|
740
|
-
function
|
|
740
|
+
function xe(e) {
|
|
741
741
|
let t = 0;
|
|
742
742
|
return e.traverse((n) => {
|
|
743
743
|
if (n.isMesh && n.geometry && n.type !== "HightlightMesh") {
|
|
744
|
-
const r = n.geometry, s = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT,
|
|
744
|
+
const r = n.geometry, s = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, l = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, i = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, a = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = s + l + i + a;
|
|
745
745
|
t += c;
|
|
746
746
|
}
|
|
747
747
|
}), t;
|
|
@@ -749,81 +749,81 @@ function ke(e) {
|
|
|
749
749
|
function ur(e) {
|
|
750
750
|
return (e / 1024).toFixed(2);
|
|
751
751
|
}
|
|
752
|
-
const
|
|
752
|
+
const Ce = H({}), Me = (e) => Object.assign(Ce.value, e);
|
|
753
753
|
function fr(e, t, n) {
|
|
754
|
-
var
|
|
754
|
+
var L;
|
|
755
755
|
const r = $(), s = $();
|
|
756
756
|
e && (r.value = e), t && (s.value = t);
|
|
757
|
-
const
|
|
757
|
+
const l = (p) => {
|
|
758
758
|
var w;
|
|
759
759
|
return ((w = p.__tres) == null ? void 0 : w.eventCount) > 0;
|
|
760
760
|
}, i = (p) => {
|
|
761
761
|
var w;
|
|
762
|
-
return ((w = p.children) == null ? void 0 : w.some((
|
|
763
|
-
},
|
|
762
|
+
return ((w = p.children) == null ? void 0 : w.some((x) => i(x))) || l(p);
|
|
763
|
+
}, a = $(((L = r.value) == null ? void 0 : L.children).filter(i) || []);
|
|
764
764
|
function c(p, w) {
|
|
765
765
|
if (Array.isArray(p))
|
|
766
|
-
for (const
|
|
767
|
-
|
|
766
|
+
for (const x of p)
|
|
767
|
+
x(w);
|
|
768
768
|
typeof p == "function" && p(w);
|
|
769
769
|
}
|
|
770
770
|
function o(p, w) {
|
|
771
|
-
const
|
|
771
|
+
const x = [], D = () => w.stopPropagating = !0;
|
|
772
772
|
w.stopPropagation = D;
|
|
773
773
|
for (const O of w == null ? void 0 : w.intersections) {
|
|
774
774
|
if (w.stopPropagating)
|
|
775
775
|
return;
|
|
776
776
|
w = { ...w, ...O };
|
|
777
777
|
const { object: B } = O;
|
|
778
|
-
w.eventObject = B, c(B[p], w),
|
|
778
|
+
w.eventObject = B, c(B[p], w), x.push(B);
|
|
779
779
|
let R = B.parent;
|
|
780
|
-
for (; R !== null && !w.stopPropagating && !
|
|
781
|
-
w.eventObject = R, c(R[p], w),
|
|
780
|
+
for (; R !== null && !w.stopPropagating && !x.includes(R); )
|
|
781
|
+
w.eventObject = R, c(R[p], w), x.push(R), R = R.parent;
|
|
782
782
|
const ne = Gn(p.slice(2));
|
|
783
783
|
n(ne, { intersection: O, event: w });
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
const {
|
|
787
787
|
onClick: u,
|
|
788
|
-
onDblClick:
|
|
788
|
+
onDblClick: v,
|
|
789
789
|
onContextMenu: f,
|
|
790
|
-
onPointerMove:
|
|
791
|
-
onPointerDown:
|
|
790
|
+
onPointerMove: h,
|
|
791
|
+
onPointerDown: g,
|
|
792
792
|
onPointerUp: b,
|
|
793
|
-
onPointerMissed:
|
|
793
|
+
onPointerMissed: y,
|
|
794
794
|
onWheel: d,
|
|
795
795
|
forceUpdate: C
|
|
796
|
-
} = cr(
|
|
797
|
-
b((p) => o("onPointerUp", p)),
|
|
798
|
-
let
|
|
799
|
-
|
|
800
|
-
const w = p.intersections.map(({ object: D }) => D),
|
|
801
|
-
|
|
802
|
-
w.includes(D) || (p.intersections =
|
|
803
|
-
}), p.intersections =
|
|
804
|
-
|
|
805
|
-
}), o("onPointerMove", p),
|
|
796
|
+
} = cr(a, t);
|
|
797
|
+
b((p) => o("onPointerUp", p)), g((p) => o("onPointerDown", p)), u((p) => o("onClick", p)), v((p) => o("onDoubleClick", p)), f((p) => o("onContextMenu", p)), d((p) => o("onWheel", p));
|
|
798
|
+
let M = [];
|
|
799
|
+
h((p) => {
|
|
800
|
+
const w = p.intersections.map(({ object: D }) => D), x = p.intersections;
|
|
801
|
+
M.forEach(({ object: D }) => {
|
|
802
|
+
w.includes(D) || (p.intersections = M, o("onPointerLeave", p), o("onPointerOut", p));
|
|
803
|
+
}), p.intersections = x, p.intersections.forEach(({ object: D }) => {
|
|
804
|
+
M.includes(D) || (o("onPointerEnter", p), o("onPointerOver", p));
|
|
805
|
+
}), o("onPointerMove", p), M = p.intersections;
|
|
806
806
|
});
|
|
807
807
|
const P = [];
|
|
808
|
-
|
|
808
|
+
y((p) => {
|
|
809
809
|
const w = () => p.stopPropagating = !0;
|
|
810
|
-
p.stopPropagation = w, P.forEach((
|
|
811
|
-
p.stopPropagating || (p.eventObject =
|
|
810
|
+
p.stopPropagation = w, P.forEach((x) => {
|
|
811
|
+
p.stopPropagating || (p.eventObject = x, c(x.onPointerMissed, p));
|
|
812
812
|
}), n("pointer-missed", { event: p });
|
|
813
813
|
});
|
|
814
|
-
function
|
|
815
|
-
oe(p) && N(p) &&
|
|
814
|
+
function E(p) {
|
|
815
|
+
oe(p) && N(p) && a.value.push(p);
|
|
816
816
|
}
|
|
817
|
-
function
|
|
817
|
+
function S(p) {
|
|
818
818
|
if (oe(p) && N(p)) {
|
|
819
|
-
const w =
|
|
820
|
-
w > -1 &&
|
|
819
|
+
const w = a.value.indexOf(p);
|
|
820
|
+
w > -1 && a.value.splice(w, 1);
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
823
|
function _(p) {
|
|
824
824
|
oe(p) && N(p) && p.onPointerMissed && P.push(p);
|
|
825
825
|
}
|
|
826
|
-
function
|
|
826
|
+
function A(p) {
|
|
827
827
|
if (oe(p) && N(p)) {
|
|
828
828
|
const w = P.indexOf(p);
|
|
829
829
|
w > -1 && P.splice(w, 1);
|
|
@@ -831,22 +831,22 @@ function fr(e, t, n) {
|
|
|
831
831
|
}
|
|
832
832
|
return t.eventManager = {
|
|
833
833
|
forceUpdate: C,
|
|
834
|
-
registerObject:
|
|
835
|
-
deregisterObject:
|
|
834
|
+
registerObject: E,
|
|
835
|
+
deregisterObject: S,
|
|
836
836
|
registerPointerMissedObject: _,
|
|
837
|
-
deregisterPointerMissedObject:
|
|
837
|
+
deregisterPointerMissedObject: A
|
|
838
838
|
}, {
|
|
839
839
|
forceUpdate: C,
|
|
840
|
-
registerObject:
|
|
841
|
-
deregisterObject:
|
|
840
|
+
registerObject: E,
|
|
841
|
+
deregisterObject: S,
|
|
842
842
|
registerPointerMissedObject: _,
|
|
843
|
-
deregisterPointerMissedObject:
|
|
843
|
+
deregisterPointerMissedObject: A
|
|
844
844
|
};
|
|
845
845
|
}
|
|
846
846
|
function dr(e, t, n = 10) {
|
|
847
|
-
const r = k(e) ? rn() : on(V(() => k(t).parentElement)), s = ye(Fe(r.width, n)),
|
|
847
|
+
const r = k(e) ? rn() : on(V(() => k(t).parentElement)), s = ye(Fe(r.width, n)), l = ye(Fe(r.height, n)), i = V(() => s.value / l.value);
|
|
848
848
|
return {
|
|
849
|
-
height:
|
|
849
|
+
height: l,
|
|
850
850
|
width: s,
|
|
851
851
|
aspectRatio: i
|
|
852
852
|
};
|
|
@@ -855,21 +855,21 @@ function ve() {
|
|
|
855
855
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
856
856
|
let n = 0, r = !1;
|
|
857
857
|
const s = () => {
|
|
858
|
-
const o = Array.from(e.entries()).sort((u,
|
|
859
|
-
const f = u[1].priority -
|
|
860
|
-
return f === 0 ? u[1].addI -
|
|
858
|
+
const o = Array.from(e.entries()).sort((u, v) => {
|
|
859
|
+
const f = u[1].priority - v[1].priority;
|
|
860
|
+
return f === 0 ? u[1].addI - v[1].addI : f;
|
|
861
861
|
});
|
|
862
862
|
t.clear(), o.forEach((u) => t.add(u[0]));
|
|
863
|
-
},
|
|
863
|
+
}, l = (o) => {
|
|
864
864
|
e.delete(o), t.delete(o);
|
|
865
865
|
};
|
|
866
866
|
return { on: (o, u = 0) => {
|
|
867
867
|
e.set(o, { priority: u, addI: n++ });
|
|
868
|
-
const
|
|
869
|
-
return sn(
|
|
870
|
-
off:
|
|
868
|
+
const v = () => l(o);
|
|
869
|
+
return sn(v), r = !0, {
|
|
870
|
+
off: v
|
|
871
871
|
};
|
|
872
|
-
}, off:
|
|
872
|
+
}, off: l, trigger: (...o) => {
|
|
873
873
|
r && (s(), r = !1), t.forEach((u) => u(...o));
|
|
874
874
|
}, dispose: () => {
|
|
875
875
|
e.clear(), t.clear();
|
|
@@ -879,50 +879,50 @@ function ve() {
|
|
|
879
879
|
}
|
|
880
880
|
function pr() {
|
|
881
881
|
let e = !0, t = !0, n = !1;
|
|
882
|
-
const r = new tt(!1), s = H(r.running),
|
|
882
|
+
const r = new tt(!1), s = H(r.running), l = H(!1);
|
|
883
883
|
let i;
|
|
884
|
-
const
|
|
884
|
+
const a = rt.generateUUID();
|
|
885
885
|
let c = null;
|
|
886
|
-
const o = ve(), u = ve(),
|
|
887
|
-
|
|
886
|
+
const o = ve(), u = ve(), v = ve();
|
|
887
|
+
S();
|
|
888
888
|
let f = {};
|
|
889
|
-
function
|
|
889
|
+
function h(_) {
|
|
890
890
|
f = _;
|
|
891
891
|
}
|
|
892
|
-
function
|
|
893
|
-
switch (
|
|
892
|
+
function g(_, A, L = 0) {
|
|
893
|
+
switch (A) {
|
|
894
894
|
case "before":
|
|
895
|
-
return o.on(_,
|
|
895
|
+
return o.on(_, L);
|
|
896
896
|
case "render":
|
|
897
897
|
return c || (c = _), u.dispose(), u.on(_);
|
|
898
898
|
case "after":
|
|
899
|
-
return
|
|
899
|
+
return v.on(_, L);
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
902
|
function b() {
|
|
903
|
-
t && (t = !1,
|
|
903
|
+
t && (t = !1, S(), E());
|
|
904
904
|
}
|
|
905
|
-
function
|
|
906
|
-
t = !0,
|
|
905
|
+
function y() {
|
|
906
|
+
t = !0, S(), cancelAnimationFrame(i);
|
|
907
907
|
}
|
|
908
908
|
function d() {
|
|
909
|
-
n = !1,
|
|
909
|
+
n = !1, S();
|
|
910
910
|
}
|
|
911
911
|
function C() {
|
|
912
|
-
n = !0,
|
|
912
|
+
n = !0, S();
|
|
913
913
|
}
|
|
914
|
-
function
|
|
915
|
-
|
|
914
|
+
function M() {
|
|
915
|
+
l.value = !0;
|
|
916
916
|
}
|
|
917
917
|
function P() {
|
|
918
|
-
|
|
918
|
+
l.value = !1;
|
|
919
919
|
}
|
|
920
|
-
function
|
|
920
|
+
function E() {
|
|
921
921
|
if (!e) {
|
|
922
|
-
i = requestAnimationFrame(
|
|
922
|
+
i = requestAnimationFrame(E);
|
|
923
923
|
return;
|
|
924
924
|
}
|
|
925
|
-
const _ = r.getDelta(),
|
|
925
|
+
const _ = r.getDelta(), A = r.getElapsedTime(), L = {
|
|
926
926
|
camera: J(f.camera),
|
|
927
927
|
scene: J(f.scene),
|
|
928
928
|
renderer: J(f.renderer),
|
|
@@ -930,50 +930,50 @@ function pr() {
|
|
|
930
930
|
controls: J(f.controls),
|
|
931
931
|
invalidate: f.invalidate,
|
|
932
932
|
advance: f.advance
|
|
933
|
-
}, p = { delta: _, elapsed:
|
|
934
|
-
s.value && o.trigger(p),
|
|
933
|
+
}, p = { delta: _, elapsed: A, clock: r, ...L };
|
|
934
|
+
s.value && o.trigger(p), l.value || (u.count ? u.trigger(p) : c && c(p)), s.value && v.trigger(p), i = requestAnimationFrame(E);
|
|
935
935
|
}
|
|
936
|
-
function
|
|
936
|
+
function S() {
|
|
937
937
|
const _ = !t && !n;
|
|
938
938
|
r.running !== _ && (r.running ? r.stop() : r.start()), s.value = r.running;
|
|
939
939
|
}
|
|
940
940
|
return {
|
|
941
|
-
loopId:
|
|
942
|
-
register: (_,
|
|
941
|
+
loopId: a,
|
|
942
|
+
register: (_, A, L) => g(_, A, L),
|
|
943
943
|
start: b,
|
|
944
|
-
stop:
|
|
944
|
+
stop: y,
|
|
945
945
|
pause: C,
|
|
946
946
|
resume: d,
|
|
947
|
-
pauseRender:
|
|
947
|
+
pauseRender: M,
|
|
948
948
|
resumeRender: P,
|
|
949
|
-
isRenderPaused:
|
|
949
|
+
isRenderPaused: l,
|
|
950
950
|
isActive: s,
|
|
951
|
-
setContext:
|
|
951
|
+
setContext: h,
|
|
952
952
|
setReady: (_) => e = _
|
|
953
953
|
};
|
|
954
954
|
}
|
|
955
955
|
function mr(e, t, n = 100) {
|
|
956
956
|
n = n <= 0 ? 100 : n;
|
|
957
957
|
const r = j(), s = /* @__PURE__ */ new Set();
|
|
958
|
-
let
|
|
958
|
+
let l = !1, i = !1, a = null;
|
|
959
959
|
function c() {
|
|
960
|
-
|
|
960
|
+
a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((f) => f()), s.clear(), l = !0) : !i && !l && (a = setTimeout(c, n));
|
|
961
961
|
}
|
|
962
962
|
function o() {
|
|
963
|
-
i = !0,
|
|
963
|
+
i = !0, a && clearTimeout(a);
|
|
964
964
|
}
|
|
965
965
|
c();
|
|
966
|
-
const u = (f, ...
|
|
967
|
-
f(...
|
|
966
|
+
const u = (f, ...h) => {
|
|
967
|
+
f(...h);
|
|
968
968
|
};
|
|
969
969
|
return {
|
|
970
970
|
on: (f) => {
|
|
971
|
-
if (
|
|
971
|
+
if (l)
|
|
972
972
|
return u(f, t), { off: () => {
|
|
973
973
|
} };
|
|
974
974
|
{
|
|
975
|
-
const
|
|
976
|
-
return s.add(
|
|
975
|
+
const h = r.on(f);
|
|
976
|
+
return s.add(h.off), r.on(f);
|
|
977
977
|
}
|
|
978
978
|
},
|
|
979
979
|
off: r.off,
|
|
@@ -985,15 +985,15 @@ const te = /* @__PURE__ */ new WeakMap();
|
|
|
985
985
|
function gt(e) {
|
|
986
986
|
if (e = e || pe(), te.has(e))
|
|
987
987
|
return te.get(e);
|
|
988
|
-
const t = 100, n = Date.now(),
|
|
988
|
+
const t = 100, n = Date.now(), l = mr(() => {
|
|
989
989
|
if (Date.now() - n >= t)
|
|
990
990
|
return !0;
|
|
991
991
|
{
|
|
992
|
-
const i = e.renderer.value,
|
|
993
|
-
return !!(i &&
|
|
992
|
+
const i = e.renderer.value, a = (i == null ? void 0 : i.domElement) || { width: 0, height: 0 };
|
|
993
|
+
return !!(i && a.width > 0 && a.height > 0);
|
|
994
994
|
}
|
|
995
995
|
}, e);
|
|
996
|
-
return te.set(e,
|
|
996
|
+
return te.set(e, l), l;
|
|
997
997
|
}
|
|
998
998
|
function Vr(e) {
|
|
999
999
|
const t = pe();
|
|
@@ -1006,43 +1006,43 @@ function hr({
|
|
|
1006
1006
|
windowSize: n,
|
|
1007
1007
|
disableRender: r,
|
|
1008
1008
|
rendererOptions: s,
|
|
1009
|
-
emit:
|
|
1009
|
+
emit: l
|
|
1010
1010
|
}) {
|
|
1011
|
-
const i = $(e),
|
|
1011
|
+
const i = $(e), a = dr(n, t), {
|
|
1012
1012
|
camera: c,
|
|
1013
1013
|
cameras: o,
|
|
1014
1014
|
registerCamera: u,
|
|
1015
|
-
deregisterCamera:
|
|
1015
|
+
deregisterCamera: v,
|
|
1016
1016
|
setCameraActive: f
|
|
1017
|
-
} = Bn({ sizes:
|
|
1017
|
+
} = Bn({ sizes: a, scene: e }), h = {
|
|
1018
1018
|
mode: H(s.renderMode || "always"),
|
|
1019
1019
|
priority: H(0),
|
|
1020
1020
|
frames: H(0),
|
|
1021
1021
|
maxFrames: 60,
|
|
1022
|
-
canBeInvalidated: V(() =>
|
|
1022
|
+
canBeInvalidated: V(() => h.mode.value === "on-demand" && h.frames.value === 0)
|
|
1023
1023
|
};
|
|
1024
|
-
function
|
|
1025
|
-
s.renderMode === "on-demand" && (
|
|
1024
|
+
function g(O = 1) {
|
|
1025
|
+
s.renderMode === "on-demand" && (h.frames.value = Math.min(h.maxFrames, h.frames.value + O));
|
|
1026
1026
|
}
|
|
1027
1027
|
function b() {
|
|
1028
|
-
s.renderMode === "manual" && (
|
|
1028
|
+
s.renderMode === "manual" && (h.frames.value = 1);
|
|
1029
1029
|
}
|
|
1030
|
-
const { renderer:
|
|
1030
|
+
const { renderer: y } = ir(
|
|
1031
1031
|
{
|
|
1032
1032
|
scene: e,
|
|
1033
1033
|
canvas: t,
|
|
1034
1034
|
options: s,
|
|
1035
|
-
emit:
|
|
1035
|
+
emit: l,
|
|
1036
1036
|
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
|
|
1037
|
-
contextParts: { sizes:
|
|
1037
|
+
contextParts: { sizes: a, camera: c, render: h, invalidate: g, advance: b },
|
|
1038
1038
|
disableRender: r
|
|
1039
1039
|
}
|
|
1040
1040
|
), d = {
|
|
1041
|
-
sizes:
|
|
1041
|
+
sizes: a,
|
|
1042
1042
|
scene: i,
|
|
1043
1043
|
camera: c,
|
|
1044
1044
|
cameras: ye(o),
|
|
1045
|
-
renderer:
|
|
1045
|
+
renderer: y,
|
|
1046
1046
|
raycaster: $(new Ft()),
|
|
1047
1047
|
controls: H(null),
|
|
1048
1048
|
perf: {
|
|
@@ -1057,41 +1057,41 @@ function hr({
|
|
|
1057
1057
|
accumulator: []
|
|
1058
1058
|
}
|
|
1059
1059
|
},
|
|
1060
|
-
render:
|
|
1060
|
+
render: h,
|
|
1061
1061
|
advance: b,
|
|
1062
|
-
extend:
|
|
1063
|
-
invalidate:
|
|
1062
|
+
extend: Me,
|
|
1063
|
+
invalidate: g,
|
|
1064
1064
|
registerCamera: u,
|
|
1065
1065
|
setCameraActive: f,
|
|
1066
|
-
deregisterCamera:
|
|
1066
|
+
deregisterCamera: v,
|
|
1067
1067
|
loop: pr()
|
|
1068
1068
|
};
|
|
1069
1069
|
_e("useTres", d), d.scene.value.__tres = {
|
|
1070
1070
|
root: d
|
|
1071
1071
|
}, d.loop.register(() => {
|
|
1072
|
-
c.value &&
|
|
1072
|
+
c.value && h.frames.value > 0 && (y.value.render(e, c.value), l("render", d.renderer.value)), h.priority.value = 0, h.mode.value === "always" ? h.frames.value = 1 : h.frames.value = Math.max(0, h.frames.value - 1);
|
|
1073
1073
|
}, "render");
|
|
1074
|
-
const { on: C, cancel:
|
|
1074
|
+
const { on: C, cancel: M } = gt(d);
|
|
1075
1075
|
d.loop.setReady(!1), d.loop.start(), C(() => {
|
|
1076
|
-
|
|
1076
|
+
l("ready", d), d.loop.setReady(!0), fr(e, d, l);
|
|
1077
1077
|
}), K(() => {
|
|
1078
|
-
|
|
1078
|
+
M(), d.loop.stop();
|
|
1079
1079
|
});
|
|
1080
|
-
const P = 100,
|
|
1081
|
-
let
|
|
1080
|
+
const P = 100, E = an({ every: P }), { isSupported: S, memory: _ } = ln({ interval: P }), A = 160;
|
|
1081
|
+
let L = performance.now();
|
|
1082
1082
|
const p = ({ timestamp: O }) => {
|
|
1083
|
-
d.scene.value && (d.perf.memory.allocatedMem =
|
|
1083
|
+
d.scene.value && (d.perf.memory.allocatedMem = xe(d.scene.value)), O - L >= P && (L = O, d.perf.fps.accumulator.push(E.value), d.perf.fps.accumulator.length > A && d.perf.fps.accumulator.shift(), d.perf.fps.value = E.value, S.value && _.value && (d.perf.memory.accumulator.push(_.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > A && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((B, R) => B + R, 0) / d.perf.memory.accumulator.length));
|
|
1084
1084
|
};
|
|
1085
1085
|
let w = 0;
|
|
1086
|
-
const
|
|
1087
|
-
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >=
|
|
1086
|
+
const x = 1, { pause: D } = it(({ delta: O }) => {
|
|
1087
|
+
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >= x && (window.__TRES__DEVTOOLS__.cb(d), w = 0));
|
|
1088
1088
|
}, { immediate: !0 });
|
|
1089
1089
|
return K(() => {
|
|
1090
1090
|
D();
|
|
1091
1091
|
}), d;
|
|
1092
1092
|
}
|
|
1093
1093
|
function pe() {
|
|
1094
|
-
const e =
|
|
1094
|
+
const e = Ct("useTres");
|
|
1095
1095
|
if (!e)
|
|
1096
1096
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
1097
1097
|
return e;
|
|
@@ -1104,27 +1104,27 @@ function qr() {
|
|
|
1104
1104
|
renderer: n,
|
|
1105
1105
|
loop: r,
|
|
1106
1106
|
raycaster: s,
|
|
1107
|
-
controls:
|
|
1107
|
+
controls: l,
|
|
1108
1108
|
invalidate: i,
|
|
1109
|
-
advance:
|
|
1109
|
+
advance: a
|
|
1110
1110
|
} = pe();
|
|
1111
1111
|
r.setContext({
|
|
1112
1112
|
camera: e,
|
|
1113
1113
|
scene: t,
|
|
1114
1114
|
renderer: n,
|
|
1115
1115
|
raycaster: s,
|
|
1116
|
-
controls:
|
|
1116
|
+
controls: l,
|
|
1117
1117
|
invalidate: i,
|
|
1118
|
-
advance:
|
|
1118
|
+
advance: a
|
|
1119
1119
|
});
|
|
1120
|
-
function c(
|
|
1121
|
-
return r.register(
|
|
1120
|
+
function c(v, f = 0) {
|
|
1121
|
+
return r.register(v, "before", f);
|
|
1122
1122
|
}
|
|
1123
|
-
function o(
|
|
1124
|
-
return r.register(
|
|
1123
|
+
function o(v) {
|
|
1124
|
+
return r.register(v, "render");
|
|
1125
1125
|
}
|
|
1126
|
-
function u(
|
|
1127
|
-
return r.register(
|
|
1126
|
+
function u(v, f = 0) {
|
|
1127
|
+
return r.register(v, "after", f);
|
|
1128
1128
|
}
|
|
1129
1129
|
return {
|
|
1130
1130
|
pause: r.pause,
|
|
@@ -1139,22 +1139,22 @@ function qr() {
|
|
|
1139
1139
|
}
|
|
1140
1140
|
function gr(e, t = {}, n = {}) {
|
|
1141
1141
|
let r = e;
|
|
1142
|
-
const s = (
|
|
1143
|
-
r =
|
|
1142
|
+
const s = (a) => {
|
|
1143
|
+
r = a;
|
|
1144
1144
|
};
|
|
1145
|
-
let
|
|
1145
|
+
let l = new Proxy({}, {});
|
|
1146
1146
|
const i = {
|
|
1147
|
-
has(
|
|
1147
|
+
has(a, c) {
|
|
1148
1148
|
return c in t || c in r;
|
|
1149
1149
|
},
|
|
1150
|
-
get(
|
|
1150
|
+
get(a, c, o) {
|
|
1151
1151
|
return c in t ? t[c](r) : r[c];
|
|
1152
1152
|
},
|
|
1153
|
-
set(
|
|
1154
|
-
return n[c] ? n[c](o, r,
|
|
1153
|
+
set(a, c, o) {
|
|
1154
|
+
return n[c] ? n[c](o, r, l, s) : r[c] = o, !0;
|
|
1155
1155
|
}
|
|
1156
1156
|
};
|
|
1157
|
-
return
|
|
1157
|
+
return l = new Proxy({}, i), l;
|
|
1158
1158
|
}
|
|
1159
1159
|
const { logError: Ke } = Y(), Qe = [
|
|
1160
1160
|
"onClick",
|
|
@@ -1173,16 +1173,16 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1173
1173
|
"onWheel"
|
|
1174
1174
|
], vr = (e) => {
|
|
1175
1175
|
const t = e.scene.value;
|
|
1176
|
-
function n(o, u,
|
|
1176
|
+
function n(o, u, v, f) {
|
|
1177
1177
|
if (f || (f = {}), f.args || (f.args = []), o === "template" || Nn(o))
|
|
1178
1178
|
return null;
|
|
1179
|
-
let
|
|
1179
|
+
let h = o.replace("Tres", ""), g;
|
|
1180
1180
|
if (o === "primitive") {
|
|
1181
|
-
(!U(f.object) ||
|
|
1181
|
+
(!U(f.object) || Mt(f.object)) && Ke(
|
|
1182
1182
|
"Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>"
|
|
1183
|
-
),
|
|
1183
|
+
), h = f.object.type;
|
|
1184
1184
|
const b = {};
|
|
1185
|
-
|
|
1185
|
+
g = gr(
|
|
1186
1186
|
f.object,
|
|
1187
1187
|
{
|
|
1188
1188
|
object: (d) => d,
|
|
@@ -1190,8 +1190,8 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1190
1190
|
__tres: () => b
|
|
1191
1191
|
},
|
|
1192
1192
|
{
|
|
1193
|
-
object: (d, C,
|
|
1194
|
-
or(d,
|
|
1193
|
+
object: (d, C, M, P) => {
|
|
1194
|
+
or(d, M, P, { patchProp: l, remove: s, insert: r }, e);
|
|
1195
1195
|
},
|
|
1196
1196
|
__tres: (d) => {
|
|
1197
1197
|
Object.assign(b, d);
|
|
@@ -1199,37 +1199,37 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1199
1199
|
}
|
|
1200
1200
|
);
|
|
1201
1201
|
} else {
|
|
1202
|
-
const b =
|
|
1202
|
+
const b = Ce.value[h];
|
|
1203
1203
|
b || Ke(
|
|
1204
|
-
`${
|
|
1205
|
-
),
|
|
1204
|
+
`${h} is not defined on the THREE namespace. Use extend to add it to the catalog.`
|
|
1205
|
+
), g = new b(...f.args);
|
|
1206
1206
|
}
|
|
1207
|
-
return
|
|
1208
|
-
...
|
|
1209
|
-
type:
|
|
1207
|
+
return g ? (g.isCamera && (f != null && f.position || g.position.set(3, 3, 3), f != null && f.lookAt || g.lookAt(0, 0, 0)), g = z(g, {
|
|
1208
|
+
...g.__tres,
|
|
1209
|
+
type: h,
|
|
1210
1210
|
memoizedProps: f,
|
|
1211
1211
|
eventCount: 0,
|
|
1212
1212
|
primitive: o === "primitive",
|
|
1213
1213
|
attach: f.attach
|
|
1214
|
-
}, e),
|
|
1214
|
+
}, e), g) : null;
|
|
1215
1215
|
}
|
|
1216
1216
|
function r(o, u) {
|
|
1217
|
-
var
|
|
1217
|
+
var h, g, b;
|
|
1218
1218
|
if (!o)
|
|
1219
1219
|
return;
|
|
1220
1220
|
u = u || t;
|
|
1221
|
-
const
|
|
1222
|
-
o = Q(
|
|
1221
|
+
const v = o.__tres ? o : z(o, {}, e), f = u.__tres ? u : z(u, {}, e);
|
|
1222
|
+
o = Q(v), u = Q(f), o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((g = e.eventManager) == null || g.registerObject(o)), e.registerCamera(o), (b = e.eventManager) == null || b.registerPointerMissedObject(o), v.__tres.attach ? tr(f, v, v.__tres.attach) : N(o) && N(f) && (f.add(o), o.dispatchEvent({ type: "added" })), v.__tres.parent = f, f.__tres.objects && !f.__tres.objects.includes(v) && f.__tres.objects.push(v);
|
|
1223
1223
|
}
|
|
1224
1224
|
function s(o, u) {
|
|
1225
|
-
var
|
|
1225
|
+
var g, b, y, d;
|
|
1226
1226
|
if (!o)
|
|
1227
1227
|
return;
|
|
1228
|
-
o != null && o.__tres && ((
|
|
1229
|
-
const
|
|
1230
|
-
be(
|
|
1231
|
-
const f = (d = o.__tres) == null ? void 0 : d.primitive,
|
|
1232
|
-
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((C) => s(C, u)),
|
|
1228
|
+
o != null && o.__tres && ((g = o.__tres) == null ? void 0 : g.eventCount) > 0 && ((b = e.eventManager) == null || b.deregisterObject(o)), u = be(u) ? "default" : u;
|
|
1229
|
+
const v = (y = o.__tres) == null ? void 0 : y.dispose;
|
|
1230
|
+
be(v) || (v === null ? u = !1 : u = v);
|
|
1231
|
+
const f = (d = o.__tres) == null ? void 0 : d.primitive, h = u === "default" ? !f : !!u;
|
|
1232
|
+
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((C) => s(C, u)), h && o.children && [...o.children].forEach((C) => s(C, u)), mt(o, e), ht(o, e), h && !Dn(o)) {
|
|
1233
1233
|
if (G(u))
|
|
1234
1234
|
u(o);
|
|
1235
1235
|
else if (G(o.dispose))
|
|
@@ -1240,11 +1240,11 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1240
1240
|
}
|
|
1241
1241
|
"__tres" in o && delete o.__tres;
|
|
1242
1242
|
}
|
|
1243
|
-
function
|
|
1244
|
-
var C,
|
|
1243
|
+
function l(o, u, v, f) {
|
|
1244
|
+
var C, M;
|
|
1245
1245
|
if (!o)
|
|
1246
1246
|
return;
|
|
1247
|
-
let
|
|
1247
|
+
let h = o, g = u;
|
|
1248
1248
|
if (o.__tres && (o.__tres.memoizedProps[u] = f), u === "attach") {
|
|
1249
1249
|
const P = ((C = o.__tres) == null ? void 0 : C.parent) || o.parent;
|
|
1250
1250
|
s(o), z(o, { attach: f }, e), P && r(o, P);
|
|
@@ -1254,61 +1254,61 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1254
1254
|
o.__tres || (o = z(o, {}, e)), o.__tres.dispose = f;
|
|
1255
1255
|
return;
|
|
1256
1256
|
}
|
|
1257
|
-
if (N(o) &&
|
|
1258
|
-
f || f === "" ? o[
|
|
1257
|
+
if (N(o) && g === "blocks-pointer-events") {
|
|
1258
|
+
f || f === "" ? o[g] = f : delete o[g];
|
|
1259
1259
|
return;
|
|
1260
1260
|
}
|
|
1261
1261
|
Qe.includes(u) && o.__tres && (o.__tres.eventCount += 1);
|
|
1262
|
-
let b = ie(
|
|
1263
|
-
if (
|
|
1264
|
-
const P = o,
|
|
1265
|
-
_ &&
|
|
1262
|
+
let b = ie(g), y = h == null ? void 0 : h[b];
|
|
1263
|
+
if (g === "args") {
|
|
1264
|
+
const P = o, E = v ?? [], S = f ?? [], _ = ((M = o.__tres) == null ? void 0 : M.type) || o.type;
|
|
1265
|
+
_ && E.length && !qn(E, S) && (h = Object.assign(
|
|
1266
1266
|
P,
|
|
1267
|
-
new
|
|
1267
|
+
new Ce.value[_](...f)
|
|
1268
1268
|
));
|
|
1269
1269
|
return;
|
|
1270
1270
|
}
|
|
1271
|
-
if (
|
|
1272
|
-
if (
|
|
1271
|
+
if (h.type === "BufferGeometry") {
|
|
1272
|
+
if (g === "args")
|
|
1273
1273
|
return;
|
|
1274
|
-
|
|
1275
|
-
ie(
|
|
1274
|
+
h.setAttribute(
|
|
1275
|
+
ie(g),
|
|
1276
1276
|
new Wt(...f)
|
|
1277
1277
|
);
|
|
1278
1278
|
return;
|
|
1279
1279
|
}
|
|
1280
|
-
if (
|
|
1281
|
-
const P =
|
|
1282
|
-
|
|
1280
|
+
if (g.includes("-") && y === void 0) {
|
|
1281
|
+
const P = g.split("-");
|
|
1282
|
+
y = P.reduce((E, S) => E[ie(S)], h), g = P.pop(), b = g, y != null && y.set || (h = P.reduce((E, S) => E[ie(S)], h));
|
|
1283
1283
|
}
|
|
1284
1284
|
let d = f;
|
|
1285
|
-
if (d === "" && (d = !0), G(
|
|
1286
|
-
Qe.includes(u) || (de(d) ? o[b](...d) : o[b](d)), b.startsWith("on") && G(d) && (
|
|
1285
|
+
if (d === "" && (d = !0), G(y)) {
|
|
1286
|
+
Qe.includes(u) || (de(d) ? o[b](...d) : o[b](d)), b.startsWith("on") && G(d) && (h[b] = d);
|
|
1287
1287
|
return;
|
|
1288
1288
|
}
|
|
1289
|
-
!(
|
|
1289
|
+
!(y != null && y.set) && !G(y) ? h[b] = d : y.constructor === d.constructor && (y != null && y.copy) ? y == null || y.copy(d) : de(d) ? y.set(...d) : !y.isColor && y.setScalar ? y.setScalar(d) : y.set(d), pt(o);
|
|
1290
1290
|
}
|
|
1291
1291
|
function i(o) {
|
|
1292
1292
|
var u;
|
|
1293
1293
|
return ((u = o == null ? void 0 : o.__tres) == null ? void 0 : u.parent) || null;
|
|
1294
1294
|
}
|
|
1295
|
-
function
|
|
1295
|
+
function a(o) {
|
|
1296
1296
|
const u = z(new Nt(), { type: "Comment" }, e);
|
|
1297
1297
|
return u.name = o, u;
|
|
1298
1298
|
}
|
|
1299
1299
|
function c(o) {
|
|
1300
|
-
var
|
|
1301
|
-
const u = i(o),
|
|
1302
|
-
return f < 0 || f >=
|
|
1300
|
+
var h;
|
|
1301
|
+
const u = i(o), v = ((h = u == null ? void 0 : u.__tres) == null ? void 0 : h.objects) || [], f = v.indexOf(o);
|
|
1302
|
+
return f < 0 || f >= v.length - 1 ? null : v[f + 1];
|
|
1303
1303
|
}
|
|
1304
1304
|
return {
|
|
1305
1305
|
insert: r,
|
|
1306
1306
|
remove: s,
|
|
1307
1307
|
createElement: n,
|
|
1308
|
-
patchProp:
|
|
1308
|
+
patchProp: l,
|
|
1309
1309
|
parentNode: i,
|
|
1310
1310
|
createText: () => void 0,
|
|
1311
|
-
createComment:
|
|
1311
|
+
createComment: a,
|
|
1312
1312
|
setText: () => void 0,
|
|
1313
1313
|
setElementText: () => void 0,
|
|
1314
1314
|
nextSibling: c,
|
|
@@ -1330,57 +1330,57 @@ function Pr() {
|
|
|
1330
1330
|
var e;
|
|
1331
1331
|
return q !== void 0 || (typeof window < "u" && window.performance ? (q = !0, Ee = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (q = !0, Ee = globalThis.perf_hooks.performance) : q = !1), q;
|
|
1332
1332
|
}
|
|
1333
|
-
function
|
|
1333
|
+
function Cr() {
|
|
1334
1334
|
return Pr() ? Ee.now() : Date.now();
|
|
1335
1335
|
}
|
|
1336
|
-
class
|
|
1336
|
+
class Mr {
|
|
1337
1337
|
constructor(t, n) {
|
|
1338
1338
|
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;
|
|
1339
1339
|
const r = {};
|
|
1340
1340
|
if (t.settings)
|
|
1341
1341
|
for (const i in t.settings) {
|
|
1342
|
-
const
|
|
1343
|
-
r[i] =
|
|
1342
|
+
const a = t.settings[i];
|
|
1343
|
+
r[i] = a.defaultValue;
|
|
1344
1344
|
}
|
|
1345
1345
|
const s = `__vue-devtools-plugin-settings__${t.id}`;
|
|
1346
|
-
let
|
|
1346
|
+
let l = Object.assign({}, r);
|
|
1347
1347
|
try {
|
|
1348
|
-
const i = localStorage.getItem(s),
|
|
1349
|
-
Object.assign(
|
|
1348
|
+
const i = localStorage.getItem(s), a = JSON.parse(i);
|
|
1349
|
+
Object.assign(l, a);
|
|
1350
1350
|
} catch {
|
|
1351
1351
|
}
|
|
1352
1352
|
this.fallbacks = {
|
|
1353
1353
|
getSettings() {
|
|
1354
|
-
return
|
|
1354
|
+
return l;
|
|
1355
1355
|
},
|
|
1356
1356
|
setSettings(i) {
|
|
1357
1357
|
try {
|
|
1358
1358
|
localStorage.setItem(s, JSON.stringify(i));
|
|
1359
1359
|
} catch {
|
|
1360
1360
|
}
|
|
1361
|
-
|
|
1361
|
+
l = i;
|
|
1362
1362
|
},
|
|
1363
1363
|
now() {
|
|
1364
|
-
return
|
|
1364
|
+
return Cr();
|
|
1365
1365
|
}
|
|
1366
|
-
}, n && n.on(br, (i,
|
|
1367
|
-
i === this.plugin.id && this.fallbacks.setSettings(
|
|
1366
|
+
}, n && n.on(br, (i, a) => {
|
|
1367
|
+
i === this.plugin.id && this.fallbacks.setSettings(a);
|
|
1368
1368
|
}), this.proxiedOn = new Proxy({}, {
|
|
1369
|
-
get: (i,
|
|
1369
|
+
get: (i, a) => this.target ? this.target.on[a] : (...c) => {
|
|
1370
1370
|
this.onQueue.push({
|
|
1371
|
-
method:
|
|
1371
|
+
method: a,
|
|
1372
1372
|
args: c
|
|
1373
1373
|
});
|
|
1374
1374
|
}
|
|
1375
1375
|
}), this.proxiedTarget = new Proxy({}, {
|
|
1376
|
-
get: (i,
|
|
1377
|
-
method:
|
|
1376
|
+
get: (i, a) => this.target ? this.target[a] : a === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(a) ? (...c) => (this.targetQueue.push({
|
|
1377
|
+
method: a,
|
|
1378
1378
|
args: c,
|
|
1379
1379
|
resolve: () => {
|
|
1380
1380
|
}
|
|
1381
|
-
}), this.fallbacks[
|
|
1381
|
+
}), this.fallbacks[a](...c)) : (...c) => new Promise((o) => {
|
|
1382
1382
|
this.targetQueue.push({
|
|
1383
|
-
method:
|
|
1383
|
+
method: a,
|
|
1384
1384
|
args: c,
|
|
1385
1385
|
resolve: o
|
|
1386
1386
|
});
|
|
@@ -1396,11 +1396,11 @@ class Cr {
|
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
1398
|
function Er(e, t) {
|
|
1399
|
-
const n = e, r = vt(), s = yr(),
|
|
1400
|
-
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !
|
|
1399
|
+
const n = e, r = vt(), s = yr(), l = _r && n.enableEarlyProxy;
|
|
1400
|
+
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l))
|
|
1401
1401
|
s.emit(wr, e, t);
|
|
1402
1402
|
else {
|
|
1403
|
-
const i =
|
|
1403
|
+
const i = l ? new Mr(n, s) : null;
|
|
1404
1404
|
(r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
1405
1405
|
pluginDescriptor: n,
|
|
1406
1406
|
setupFn: t,
|
|
@@ -1427,7 +1427,7 @@ const yt = (e) => {
|
|
|
1427
1427
|
textColor: 5750629,
|
|
1428
1428
|
backgroundColor: 15793395
|
|
1429
1429
|
});
|
|
1430
|
-
const n =
|
|
1430
|
+
const n = xe(e);
|
|
1431
1431
|
return n > 0 && t.tags.push({
|
|
1432
1432
|
label: `${ur(n)} KB`,
|
|
1433
1433
|
textColor: 15707189,
|
|
@@ -1466,7 +1466,7 @@ function _t(e, t, n = "") {
|
|
|
1466
1466
|
const Sr = [], X = "tres:inspector", Ar = Et({
|
|
1467
1467
|
sceneGraph: null
|
|
1468
1468
|
});
|
|
1469
|
-
function
|
|
1469
|
+
function xr(e, t) {
|
|
1470
1470
|
Er(
|
|
1471
1471
|
{
|
|
1472
1472
|
id: "dev.esm.tres",
|
|
@@ -1489,33 +1489,33 @@ function kr(e, t) {
|
|
|
1489
1489
|
n.sendInspectorTree(X);
|
|
1490
1490
|
}, 1e3), setInterval(() => {
|
|
1491
1491
|
n.notifyComponentUpdate();
|
|
1492
|
-
}, 5e3), n.on.getInspectorTree((
|
|
1493
|
-
if (
|
|
1492
|
+
}, 5e3), n.on.getInspectorTree((l) => {
|
|
1493
|
+
if (l.inspectorId === X) {
|
|
1494
1494
|
const i = yt(t.scene.value);
|
|
1495
|
-
_t(t.scene.value, i,
|
|
1495
|
+
_t(t.scene.value, i, l.filter), Ar.sceneGraph = i, l.rootNodes = [i];
|
|
1496
1496
|
}
|
|
1497
1497
|
});
|
|
1498
1498
|
let r = null, s = null;
|
|
1499
|
-
n.on.getInspectorState((
|
|
1499
|
+
n.on.getInspectorState((l) => {
|
|
1500
1500
|
var i;
|
|
1501
|
-
if (
|
|
1502
|
-
const [
|
|
1503
|
-
if (!
|
|
1501
|
+
if (l.inspectorId === X) {
|
|
1502
|
+
const [a] = t.scene.value.getObjectsByProperty("uuid", l.nodeId);
|
|
1503
|
+
if (!a)
|
|
1504
1504
|
return;
|
|
1505
|
-
if (s && r && r.parent && s.remove(r),
|
|
1506
|
-
const c = Qn(
|
|
1507
|
-
|
|
1505
|
+
if (s && r && r.parent && s.remove(r), a.isMesh) {
|
|
1506
|
+
const c = Qn(a);
|
|
1507
|
+
a.add(c), r = c, s = a;
|
|
1508
1508
|
}
|
|
1509
|
-
|
|
1510
|
-
object: Object.entries(
|
|
1511
|
-
},
|
|
1512
|
-
memory:
|
|
1513
|
-
objects:
|
|
1509
|
+
l.state = {
|
|
1510
|
+
object: Object.entries(a).map(([c, o]) => c === "children" ? { key: c, value: o.filter((u) => u.type !== "HightlightMesh") } : { key: c, value: o, editable: !0 }).filter(({ key: c }) => c !== "parent")
|
|
1511
|
+
}, a.isScene && (l.state.info = {
|
|
1512
|
+
memory: xe(a),
|
|
1513
|
+
objects: a.children.length,
|
|
1514
1514
|
calls: t.renderer.value.info.render.calls,
|
|
1515
1515
|
triangles: t.renderer.value.info.render.triangles,
|
|
1516
1516
|
points: t.renderer.value.info.render.points,
|
|
1517
1517
|
lines: t.renderer.value.info.render.lines
|
|
1518
|
-
},
|
|
1518
|
+
}, l.state.programs = ((i = t.renderer.value.info.programs) == null ? void 0 : i.map((c) => ({
|
|
1519
1519
|
key: c.name,
|
|
1520
1520
|
value: {
|
|
1521
1521
|
...c,
|
|
@@ -1525,13 +1525,13 @@ function kr(e, t) {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
}))) || []);
|
|
1527
1527
|
}
|
|
1528
|
-
}), n.on.editInspectorState((
|
|
1529
|
-
|
|
1528
|
+
}), n.on.editInspectorState((l) => {
|
|
1529
|
+
l.inspectorId === X && Kn(t.scene.value, l.nodeId, l.path, l.state.value);
|
|
1530
1530
|
});
|
|
1531
1531
|
}
|
|
1532
1532
|
);
|
|
1533
1533
|
}
|
|
1534
|
-
const
|
|
1534
|
+
const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
|
|
1535
1535
|
__name: "TresCanvas",
|
|
1536
1536
|
props: {
|
|
1537
1537
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -1576,78 +1576,80 @@ const xr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
|
|
|
1576
1576
|
"ready"
|
|
1577
1577
|
],
|
|
1578
1578
|
setup(e, { expose: t, emit: n }) {
|
|
1579
|
-
var
|
|
1580
|
-
const r = e, s = n,
|
|
1581
|
-
|
|
1582
|
-
const u = (
|
|
1579
|
+
var y;
|
|
1580
|
+
const r = e, s = n, l = Tt(), { logWarning: i } = Y(), a = H(), c = $(new nt()), o = (y = Ie()) == null ? void 0 : y.appContext.app;
|
|
1581
|
+
Me(et);
|
|
1582
|
+
const u = (d, C = !1) => Be({
|
|
1583
1583
|
setup() {
|
|
1584
|
-
var
|
|
1585
|
-
const
|
|
1586
|
-
return
|
|
1584
|
+
var P;
|
|
1585
|
+
const M = (P = Ie()) == null ? void 0 : P.appContext;
|
|
1586
|
+
return M && (M.app = o), _e("useTres", d), _e("extend", Me), typeof window < "u" && xr(M == null ? void 0 : M.app, d), () => He(Ot, null, C ? [] : l.default());
|
|
1587
1587
|
}
|
|
1588
|
-
}),
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
}, f = (
|
|
1592
|
-
dt(
|
|
1593
|
-
root:
|
|
1594
|
-
}
|
|
1595
|
-
},
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
v.value
|
|
1588
|
+
}), v = (d, C = !1) => {
|
|
1589
|
+
const M = u(d, C), { render: P } = Rt(vr(d));
|
|
1590
|
+
P(He(M), c.value);
|
|
1591
|
+
}, f = (d, C = !1) => {
|
|
1592
|
+
dt(d.scene.value), C && (d.renderer.value.dispose(), d.renderer.value.renderLists.dispose(), d.renderer.value.forceContextLoss()), c.value.__tres = {
|
|
1593
|
+
root: d
|
|
1594
|
+
};
|
|
1595
|
+
}, h = V(() => r.disableRender), g = $(null);
|
|
1596
|
+
t({ context: g, dispose: () => f(g.value, !0) });
|
|
1597
|
+
const b = () => {
|
|
1598
|
+
f(g.value), v(g.value, !0);
|
|
1599
|
+
};
|
|
1600
|
+
return St(() => {
|
|
1601
|
+
const d = a;
|
|
1602
|
+
g.value = hr({
|
|
1599
1603
|
scene: c.value,
|
|
1600
|
-
canvas:
|
|
1604
|
+
canvas: d,
|
|
1601
1605
|
windowSize: r.windowSize ?? !1,
|
|
1602
|
-
disableRender:
|
|
1606
|
+
disableRender: h.value ?? !1,
|
|
1603
1607
|
rendererOptions: r,
|
|
1604
1608
|
emit: s
|
|
1605
1609
|
});
|
|
1606
|
-
const { registerCamera:
|
|
1607
|
-
|
|
1610
|
+
const { registerCamera: C, camera: M, cameras: P, deregisterCamera: E } = g.value;
|
|
1611
|
+
v(g.value);
|
|
1608
1612
|
const S = () => {
|
|
1609
|
-
const
|
|
1613
|
+
const _ = new we(
|
|
1610
1614
|
45,
|
|
1611
1615
|
window.innerWidth / window.innerHeight,
|
|
1612
1616
|
0.1,
|
|
1613
1617
|
1e3
|
|
1614
1618
|
);
|
|
1615
|
-
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1619
|
+
_.position.set(3, 3, 3), _.lookAt(0, 0, 0), C(_);
|
|
1620
|
+
const A = Te(() => {
|
|
1621
|
+
P.value.length >= 2 && (_.removeFromParent(), E(_), A == null || A());
|
|
1618
1622
|
});
|
|
1619
1623
|
};
|
|
1620
1624
|
ce(
|
|
1621
1625
|
() => r.camera,
|
|
1622
|
-
(
|
|
1623
|
-
|
|
1626
|
+
(_, A) => {
|
|
1627
|
+
_ && C(_), A && (A.removeFromParent(), E(A));
|
|
1624
1628
|
},
|
|
1625
1629
|
{
|
|
1626
1630
|
immediate: !0
|
|
1627
1631
|
}
|
|
1628
|
-
),
|
|
1632
|
+
), M.value || (i(
|
|
1629
1633
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
1630
1634
|
), S());
|
|
1631
|
-
}), K(() => {
|
|
1632
|
-
f(v.value);
|
|
1633
|
-
}), (m, d) => (At(), kt("canvas", {
|
|
1635
|
+
}), K(b), (d, C) => (At(), xt("canvas", {
|
|
1634
1636
|
ref_key: "canvas",
|
|
1635
|
-
ref:
|
|
1637
|
+
ref: a,
|
|
1636
1638
|
"data-scene": c.value.uuid,
|
|
1637
|
-
class:
|
|
1639
|
+
class: kt(d.$attrs.class),
|
|
1638
1640
|
"data-tres": `tresjs ${J(An).version}`,
|
|
1639
1641
|
style: Lt({
|
|
1640
1642
|
display: "block",
|
|
1641
1643
|
width: "100%",
|
|
1642
1644
|
height: "100%",
|
|
1643
|
-
position:
|
|
1645
|
+
position: d.windowSize ? "fixed" : "relative",
|
|
1644
1646
|
top: 0,
|
|
1645
1647
|
left: 0,
|
|
1646
1648
|
pointerEvents: "auto",
|
|
1647
1649
|
touchAction: "none",
|
|
1648
|
-
...
|
|
1650
|
+
...d.$attrs.style
|
|
1649
1651
|
})
|
|
1650
|
-
}, null, 14,
|
|
1652
|
+
}, null, 14, kr));
|
|
1651
1653
|
}
|
|
1652
1654
|
}), Rr = [
|
|
1653
1655
|
"TresCanvas",
|
|
@@ -1672,10 +1674,10 @@ class wt extends zt {
|
|
|
1672
1674
|
constructor(t, n) {
|
|
1673
1675
|
const r = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new $e();
|
|
1674
1676
|
s.setAttribute("position", new Ue(r, 3)), s.computeBoundingSphere();
|
|
1675
|
-
const
|
|
1676
|
-
super(s,
|
|
1677
|
-
const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],
|
|
1678
|
-
|
|
1677
|
+
const l = new Gt({ fog: !1 });
|
|
1678
|
+
super(s, l), this.light = t, this.color = n, this.type = "RectAreaLightHelper";
|
|
1679
|
+
const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new $e();
|
|
1680
|
+
a.setAttribute("position", new Ue(i, 3)), a.computeBoundingSphere(), this.add(new Vt(a, new ot({ side: Yt, fog: !1 })));
|
|
1679
1681
|
}
|
|
1680
1682
|
updateMatrixWorld() {
|
|
1681
1683
|
if (this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1), this.color !== void 0)
|
|
@@ -1747,11 +1749,11 @@ const Xr = {
|
|
|
1747
1749
|
};
|
|
1748
1750
|
export {
|
|
1749
1751
|
Lr as TresCanvas,
|
|
1750
|
-
|
|
1752
|
+
Ce as catalogue,
|
|
1751
1753
|
pr as createRenderLoop,
|
|
1752
1754
|
Zr as default,
|
|
1753
1755
|
dt as dispose,
|
|
1754
|
-
|
|
1756
|
+
Me as extend,
|
|
1755
1757
|
Fr as isProd,
|
|
1756
1758
|
Un as normalizeColor,
|
|
1757
1759
|
Wr as normalizeVectorFlexibleParam,
|