@tresjs/core 3.6.0-next.0 → 3.7.0-next.0
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/README.md +6 -6
- package/dist/components/TresCanvas.vue.d.ts +1 -0
- package/dist/composables/useCamera/index.d.ts +18 -18
- package/dist/index.d.ts +2 -1
- package/dist/tres.js +431 -412
- package/dist/tres.umd.cjs +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.d.ts +8 -0
- package/package.json +22 -22
package/dist/tres.js
CHANGED
|
@@ -1,433 +1,441 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v3.
|
|
3
|
+
* version: v3.7.0-next.0
|
|
4
4
|
* (c) 2023
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
import { ref as
|
|
9
|
-
import * as
|
|
10
|
-
import { PerspectiveCamera as
|
|
11
|
-
import { createEventHook as x, useRafFn as ne, toValue as
|
|
12
|
-
const
|
|
13
|
-
const t =
|
|
8
|
+
import { ref as L, computed as D, watchEffect as k, onUnmounted as O, shallowRef as S, watch as ae, reactive as ge, readonly as ye, provide as G, inject as he, createRenderer as we, defineComponent as J, useSlots as Ee, getCurrentInstance as K, onMounted as _e, openBlock as Ce, createElementBlock as Me, normalizeClass as Pe, normalizeStyle as Ae, h as X, Fragment as be } from "vue";
|
|
9
|
+
import * as De from "three";
|
|
10
|
+
import { PerspectiveCamera as W, OrthographicCamera as ke, Camera as Te, Clock as Se, Vector3 as xe, Color as F, REVISION as Le, SRGBColorSpace as Oe, ACESFilmicToneMapping as Be, PCFSoftShadowMap as Re, WebGLRenderer as N, LoadingManager as je, TextureLoader as He, Vector2 as Fe, Raycaster as ze, BufferAttribute as $e, Scene as Ie } from "three";
|
|
11
|
+
import { createEventHook as x, useRafFn as ne, toValue as C, unrefElement as Ne, useDevicePixelRatio as Ve, usePointer as Ge, useElementBounding as We, useWindowSize as qe, useElementSize as Ue, useFps as Ye, useMemory as Je } from "@vueuse/core";
|
|
12
|
+
const Ke = ({ sizes: e, scene: n }) => {
|
|
13
|
+
const t = L([]), r = D(
|
|
14
14
|
() => t.value[0]
|
|
15
|
-
),
|
|
16
|
-
t.value.some(({ uuid:
|
|
17
|
-
}, o = (
|
|
18
|
-
t.value = t.value.filter(({ uuid: c }) => c !==
|
|
19
|
-
},
|
|
20
|
-
const c =
|
|
15
|
+
), a = (l, c = !1) => {
|
|
16
|
+
t.value.some(({ uuid: m }) => m === l.uuid) || (c ? u(l) : t.value.push(l));
|
|
17
|
+
}, o = (l) => {
|
|
18
|
+
t.value = t.value.filter(({ uuid: c }) => c !== l.uuid);
|
|
19
|
+
}, u = (l) => {
|
|
20
|
+
const c = l instanceof Te ? l : t.value.find((h) => h.uuid === l);
|
|
21
21
|
if (!c)
|
|
22
22
|
return;
|
|
23
|
-
const
|
|
24
|
-
t.value = [c, ...
|
|
23
|
+
const m = t.value.filter(({ uuid: h }) => h !== c.uuid);
|
|
24
|
+
t.value = [c, ...m];
|
|
25
25
|
};
|
|
26
|
-
return
|
|
27
|
-
e.aspectRatio.value && t.value.forEach((
|
|
28
|
-
|
|
26
|
+
return k(() => {
|
|
27
|
+
e.aspectRatio.value && t.value.forEach((l) => {
|
|
28
|
+
l instanceof W && (l.aspect = e.aspectRatio.value), (l instanceof W || l instanceof ke) && l.updateProjectionMatrix();
|
|
29
29
|
});
|
|
30
|
-
}),
|
|
30
|
+
}), n.userData.tres__registerCamera = a, n.userData.tres__deregisterCamera = o, O(() => {
|
|
31
31
|
t.value = [];
|
|
32
32
|
}), {
|
|
33
33
|
camera: r,
|
|
34
34
|
cameras: t,
|
|
35
|
-
registerCamera:
|
|
35
|
+
registerCamera: a,
|
|
36
36
|
deregisterCamera: o,
|
|
37
|
-
setCameraActive:
|
|
37
|
+
setCameraActive: u
|
|
38
38
|
};
|
|
39
|
-
},
|
|
40
|
-
let
|
|
41
|
-
const { pause:
|
|
39
|
+
}, oe = x(), se = x(), U = x(), T = new Se();
|
|
40
|
+
let z = 0, $ = 0;
|
|
41
|
+
const { pause: Xe, resume: Qe, isActive: Ze } = ne(
|
|
42
42
|
() => {
|
|
43
|
-
|
|
43
|
+
oe.trigger({ delta: z, elapsed: $, clock: T }), se.trigger({ delta: z, elapsed: $, clock: T }), U.trigger({ delta: z, elapsed: $, clock: T });
|
|
44
44
|
},
|
|
45
45
|
{ immediate: !1 }
|
|
46
46
|
);
|
|
47
47
|
U.on(() => {
|
|
48
|
-
|
|
48
|
+
z = T.getDelta(), $ = T.getElapsedTime();
|
|
49
49
|
});
|
|
50
|
-
const
|
|
51
|
-
onBeforeLoop:
|
|
52
|
-
onLoop:
|
|
50
|
+
const ie = () => ({
|
|
51
|
+
onBeforeLoop: oe.on,
|
|
52
|
+
onLoop: se.on,
|
|
53
53
|
onAfterLoop: U.on,
|
|
54
|
-
pause:
|
|
55
|
-
resume:
|
|
56
|
-
isActive:
|
|
57
|
-
}),
|
|
54
|
+
pause: Xe,
|
|
55
|
+
resume: Qe,
|
|
56
|
+
isActive: Ze
|
|
57
|
+
}), bt = !0, Q = "[TresJS ▲ ■ ●] ";
|
|
58
58
|
function B() {
|
|
59
|
-
function e(r,
|
|
60
|
-
console.error(`${
|
|
59
|
+
function e(r, a) {
|
|
60
|
+
console.error(`${Q} ${r}`, a || "");
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
console.warn(`${
|
|
62
|
+
function n(r) {
|
|
63
|
+
console.warn(`${Q} ${r}`);
|
|
64
64
|
}
|
|
65
|
-
function t(r,
|
|
65
|
+
function t(r, a) {
|
|
66
66
|
}
|
|
67
67
|
return {
|
|
68
68
|
logError: e,
|
|
69
|
-
logWarning:
|
|
69
|
+
logWarning: n,
|
|
70
70
|
logMessage: t
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
return typeof e == "number" ? [e, e, e] : e instanceof
|
|
73
|
+
function Dt(e) {
|
|
74
|
+
return typeof e == "number" ? [e, e, e] : e instanceof xe ? [e.x, e.y, e.z] : e;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function et(e) {
|
|
77
77
|
return e instanceof F ? e : Array.isArray(e) ? new F(...e) : new F(e);
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
for (const t of Object.keys(
|
|
81
|
-
|
|
82
|
-
return Object.assign(e || {},
|
|
83
|
-
},
|
|
84
|
-
function
|
|
79
|
+
const le = (e, n) => {
|
|
80
|
+
for (const t of Object.keys(n))
|
|
81
|
+
n[t] instanceof Object && Object.assign(n[t], le(e[t], n[t]));
|
|
82
|
+
return Object.assign(e || {}, n), e;
|
|
83
|
+
}, tt = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", rt = /* @__PURE__ */ at(tt);
|
|
84
|
+
function Z(e) {
|
|
85
85
|
return e && e.nodeType === 1;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
return e.replace(/-([a-z])/g, (
|
|
87
|
+
function j(e) {
|
|
88
|
+
return e.replace(/-([a-z])/g, (n, t) => t.toUpperCase());
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function at(e, n) {
|
|
91
91
|
const t = /* @__PURE__ */ Object.create(null), r = e.split(",");
|
|
92
|
-
for (let
|
|
93
|
-
t[r[
|
|
94
|
-
return
|
|
92
|
+
for (let a = 0; a < r.length; a++)
|
|
93
|
+
t[r[a]] = !0;
|
|
94
|
+
return n ? (a) => !!t[a.toLowerCase()] : (a) => !!t[a];
|
|
95
95
|
}
|
|
96
|
-
const
|
|
96
|
+
const nt = (e, n) => {
|
|
97
97
|
const t = /* @__PURE__ */ new Set(), r = [];
|
|
98
|
-
for (const
|
|
99
|
-
const o = a
|
|
100
|
-
t.has(o) || (t.add(o), r.push(
|
|
98
|
+
for (const a of e) {
|
|
99
|
+
const o = n(a);
|
|
100
|
+
t.has(o) || (t.add(o), r.push(a));
|
|
101
101
|
}
|
|
102
102
|
return r;
|
|
103
|
-
},
|
|
104
|
-
if (!
|
|
103
|
+
}, ee = (e, n) => {
|
|
104
|
+
if (!n)
|
|
105
105
|
return;
|
|
106
|
-
const t = Array.isArray(
|
|
107
|
-
return t == null ? void 0 : t.reduce((r,
|
|
108
|
-
},
|
|
109
|
-
const r = Array.isArray(
|
|
110
|
-
r && r.reduce((
|
|
106
|
+
const t = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
|
|
107
|
+
return t == null ? void 0 : t.reduce((r, a) => r && r[a], e);
|
|
108
|
+
}, ot = (e, n, t) => {
|
|
109
|
+
const r = Array.isArray(n) ? n : n.match(/([^[.\]])+/g);
|
|
110
|
+
r && r.reduce((a, o, u) => (a[o] === void 0 && (a[o] = {}), u === r.length - 1 && (a[o] = t), a[o]), e);
|
|
111
111
|
};
|
|
112
|
-
function ue(e,
|
|
113
|
-
if (
|
|
114
|
-
const
|
|
115
|
-
return
|
|
112
|
+
function ue(e, n) {
|
|
113
|
+
if (Z(e) && Z(n)) {
|
|
114
|
+
const a = e.attributes, o = n.attributes;
|
|
115
|
+
return a.length !== o.length ? !1 : Array.from(a).every(({ name: u, value: l }) => n.getAttribute(u) === l);
|
|
116
116
|
}
|
|
117
|
-
if (e ===
|
|
117
|
+
if (e === n)
|
|
118
118
|
return !0;
|
|
119
|
-
if (e === null || typeof e != "object" ||
|
|
119
|
+
if (e === null || typeof e != "object" || n === null || typeof n != "object")
|
|
120
120
|
return !1;
|
|
121
|
-
const t = Object.keys(e), r = Object.keys(
|
|
121
|
+
const t = Object.keys(e), r = Object.keys(n);
|
|
122
122
|
if (t.length !== r.length)
|
|
123
123
|
return !1;
|
|
124
|
-
for (const
|
|
125
|
-
if (!r.includes(
|
|
124
|
+
for (const a of t)
|
|
125
|
+
if (!r.includes(a) || !ue(e[a], n[a]))
|
|
126
126
|
return !1;
|
|
127
127
|
return !0;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
if (!Array.isArray(e) || !Array.isArray(
|
|
129
|
+
function st(e, n) {
|
|
130
|
+
if (!Array.isArray(e) || !Array.isArray(n) || e.length !== n.length)
|
|
131
131
|
return !1;
|
|
132
132
|
for (let t = 0; t < e.length; t++)
|
|
133
|
-
if (!ue(e[t],
|
|
133
|
+
if (!ue(e[t], n[t]))
|
|
134
134
|
return !1;
|
|
135
135
|
return !0;
|
|
136
136
|
}
|
|
137
|
-
const
|
|
137
|
+
const it = Array.isArray;
|
|
138
|
+
function ce(e) {
|
|
139
|
+
var n, t;
|
|
140
|
+
e.children && e.children.forEach((r) => ce(r));
|
|
141
|
+
for (const r in e)
|
|
142
|
+
(t = (n = e[r]) == null ? void 0 : n.dispose) == null || t.call(n), delete e[r];
|
|
143
|
+
e.dispose && e.type !== "Scene" && e.dispose();
|
|
144
|
+
}
|
|
145
|
+
const lt = Number.parseInt(Le.replace("dev", "")), H = {
|
|
138
146
|
realistic: {
|
|
139
147
|
shadows: !0,
|
|
140
148
|
physicallyCorrectLights: !0,
|
|
141
|
-
outputColorSpace:
|
|
142
|
-
toneMapping:
|
|
149
|
+
outputColorSpace: Oe,
|
|
150
|
+
toneMapping: Be,
|
|
143
151
|
toneMappingExposure: 3,
|
|
144
152
|
shadowMap: {
|
|
145
153
|
enabled: !0,
|
|
146
|
-
type:
|
|
154
|
+
type: Re
|
|
147
155
|
}
|
|
148
156
|
}
|
|
149
157
|
};
|
|
150
|
-
function
|
|
158
|
+
function ut({
|
|
151
159
|
scene: e,
|
|
152
|
-
canvas:
|
|
160
|
+
canvas: n,
|
|
153
161
|
options: t,
|
|
154
162
|
disableRender: r,
|
|
155
|
-
contextParts: { sizes:
|
|
163
|
+
contextParts: { sizes: a, camera: o }
|
|
156
164
|
}) {
|
|
157
|
-
const
|
|
158
|
-
alpha:
|
|
159
|
-
depth:
|
|
160
|
-
canvas:
|
|
161
|
-
context:
|
|
162
|
-
stencil:
|
|
163
|
-
antialias:
|
|
164
|
-
precision:
|
|
165
|
-
powerPreference:
|
|
166
|
-
premultipliedAlpha:
|
|
167
|
-
preserveDrawingBuffer:
|
|
168
|
-
logarithmicDepthBuffer:
|
|
169
|
-
failIfMajorPerformanceCaveat:
|
|
170
|
-
})),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}),
|
|
174
|
-
|
|
165
|
+
const u = D(() => ({
|
|
166
|
+
alpha: C(t.alpha),
|
|
167
|
+
depth: C(t.depth),
|
|
168
|
+
canvas: Ne(n),
|
|
169
|
+
context: C(t.context),
|
|
170
|
+
stencil: C(t.stencil),
|
|
171
|
+
antialias: C(t.antialias) === void 0 ? !0 : C(t.antialias),
|
|
172
|
+
precision: C(t.precision),
|
|
173
|
+
powerPreference: C(t.powerPreference),
|
|
174
|
+
premultipliedAlpha: C(t.premultipliedAlpha),
|
|
175
|
+
preserveDrawingBuffer: C(t.preserveDrawingBuffer),
|
|
176
|
+
logarithmicDepthBuffer: C(t.logarithmicDepthBuffer),
|
|
177
|
+
failIfMajorPerformanceCaveat: C(t.failIfMajorPerformanceCaveat)
|
|
178
|
+
})), l = S(new N(u.value));
|
|
179
|
+
ae(u, () => {
|
|
180
|
+
l.value.dispose(), l.value = new N(u.value);
|
|
181
|
+
}), k(() => {
|
|
182
|
+
l.value.setSize(a.width.value, a.height.value);
|
|
175
183
|
});
|
|
176
|
-
const { pixelRatio: c } =
|
|
177
|
-
|
|
178
|
-
|
|
184
|
+
const { pixelRatio: c } = Ve();
|
|
185
|
+
k(() => {
|
|
186
|
+
l.value.setPixelRatio(c.value);
|
|
179
187
|
});
|
|
180
|
-
const { logError:
|
|
181
|
-
const
|
|
188
|
+
const { logError: m } = B(), i = (() => {
|
|
189
|
+
const p = new N(), w = {
|
|
182
190
|
shadowMap: {
|
|
183
|
-
enabled:
|
|
184
|
-
type:
|
|
191
|
+
enabled: p.shadowMap.enabled,
|
|
192
|
+
type: p.shadowMap.type
|
|
185
193
|
},
|
|
186
|
-
toneMapping:
|
|
187
|
-
toneMappingExposure:
|
|
188
|
-
outputColorSpace:
|
|
194
|
+
toneMapping: p.toneMapping,
|
|
195
|
+
toneMappingExposure: p.toneMappingExposure,
|
|
196
|
+
outputColorSpace: p.outputColorSpace
|
|
189
197
|
};
|
|
190
|
-
return
|
|
198
|
+
return p.dispose(), w;
|
|
191
199
|
})();
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
198
|
-
return
|
|
200
|
+
k(() => {
|
|
201
|
+
const p = C(t.preset);
|
|
202
|
+
p && (p in H || m(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), le(l.value, H[p]));
|
|
203
|
+
const w = (P, A) => {
|
|
204
|
+
const E = C(P), b = () => {
|
|
205
|
+
if (p)
|
|
206
|
+
return ee(H[p], A);
|
|
199
207
|
};
|
|
200
|
-
if (
|
|
201
|
-
return
|
|
208
|
+
if (E !== void 0)
|
|
209
|
+
return E;
|
|
202
210
|
const g = b();
|
|
203
|
-
return g !== void 0 ? g :
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
return g !== void 0 ? g : ee(i, A);
|
|
212
|
+
}, v = (P, A) => ot(l.value, A, w(P, A));
|
|
213
|
+
v(t.shadows, "shadowMap.enabled"), v(t.toneMapping, "toneMapping"), v(t.shadowMapType, "shadowMap.type"), lt < 150 && v(!t.useLegacyLights, "physicallyCorrectLights"), v(t.outputColorSpace, "outputColorSpace"), v(t.toneMappingExposure, "toneMappingExposure");
|
|
214
|
+
const M = w(t.clearColor, "clearColor");
|
|
215
|
+
M && l.value.setClearColor(
|
|
216
|
+
M ? et(M) : new F(0)
|
|
209
217
|
// default clear color is not easily/efficiently retrievable from three
|
|
210
218
|
);
|
|
211
219
|
});
|
|
212
|
-
const { pause:
|
|
213
|
-
return
|
|
214
|
-
o.value && !
|
|
215
|
-
}),
|
|
216
|
-
|
|
220
|
+
const { pause: s, resume: f, onLoop: d } = ie();
|
|
221
|
+
return d(() => {
|
|
222
|
+
o.value && !C(r) && l.value.render(e, o.value);
|
|
223
|
+
}), f(), O(() => {
|
|
224
|
+
s(), l.value.dispose(), l.value.forceContextLoss();
|
|
217
225
|
}), {
|
|
218
|
-
renderer:
|
|
226
|
+
renderer: l
|
|
219
227
|
};
|
|
220
228
|
}
|
|
221
|
-
const
|
|
222
|
-
function
|
|
223
|
-
const
|
|
229
|
+
const te = (e) => typeof e == "function", ct = (e) => !!e && e.constructor === Array;
|
|
230
|
+
function ft(e) {
|
|
231
|
+
const n = { nodes: {}, materials: {} };
|
|
224
232
|
return e && e.traverse((t) => {
|
|
225
|
-
t.name && (
|
|
226
|
-
}),
|
|
233
|
+
t.name && (n.nodes[t.name] = t), t.material && !n.materials[t.material.name] && (n.materials[t.material.name] = t.material);
|
|
234
|
+
}), n;
|
|
227
235
|
}
|
|
228
|
-
async function kt(e,
|
|
229
|
-
const { logError: o } = B(),
|
|
230
|
-
|
|
231
|
-
const c = (Array.isArray(
|
|
232
|
-
(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
(
|
|
236
|
-
|
|
236
|
+
async function kt(e, n, t, r, a) {
|
|
237
|
+
const { logError: o } = B(), u = new e();
|
|
238
|
+
a && a(u), t && t(u);
|
|
239
|
+
const c = (Array.isArray(n) ? n : [n]).map(
|
|
240
|
+
(m) => new Promise((h, i) => {
|
|
241
|
+
u.load(
|
|
242
|
+
m,
|
|
243
|
+
(s) => {
|
|
244
|
+
s.scene && Object.assign(s, ft(s.scene)), h(s);
|
|
237
245
|
},
|
|
238
246
|
r,
|
|
239
|
-
(
|
|
247
|
+
(s) => i(o("[useLoader] - Failed to load resource", s))
|
|
240
248
|
);
|
|
241
249
|
})
|
|
242
250
|
);
|
|
243
|
-
return
|
|
251
|
+
return ct(n) ? await Promise.all(c) : await c[0];
|
|
244
252
|
}
|
|
245
|
-
async function
|
|
246
|
-
const
|
|
253
|
+
async function Tt(e) {
|
|
254
|
+
const n = new je(), t = new He(n), r = (a) => new Promise((o, u) => {
|
|
247
255
|
t.load(
|
|
248
|
-
|
|
249
|
-
(
|
|
256
|
+
a,
|
|
257
|
+
(l) => o(l),
|
|
250
258
|
() => null,
|
|
251
259
|
() => {
|
|
252
|
-
|
|
260
|
+
u(new Error("[useTextures] - Failed to load texture"));
|
|
253
261
|
}
|
|
254
262
|
);
|
|
255
263
|
});
|
|
256
|
-
if (
|
|
257
|
-
const
|
|
258
|
-
return e.length > 1 ?
|
|
264
|
+
if (it(e)) {
|
|
265
|
+
const a = await Promise.all(e.map((o) => r(o)));
|
|
266
|
+
return e.length > 1 ? a : a[0];
|
|
259
267
|
} else {
|
|
260
268
|
const {
|
|
261
|
-
map:
|
|
269
|
+
map: a,
|
|
262
270
|
displacementMap: o,
|
|
263
|
-
normalMap:
|
|
264
|
-
roughnessMap:
|
|
271
|
+
normalMap: u,
|
|
272
|
+
roughnessMap: l,
|
|
265
273
|
metalnessMap: c,
|
|
266
|
-
aoMap:
|
|
267
|
-
alphaMap:
|
|
268
|
-
matcap:
|
|
274
|
+
aoMap: m,
|
|
275
|
+
alphaMap: h,
|
|
276
|
+
matcap: i
|
|
269
277
|
} = e;
|
|
270
278
|
return {
|
|
271
|
-
map:
|
|
279
|
+
map: a ? await r(a) : null,
|
|
272
280
|
displacementMap: o ? await r(o) : null,
|
|
273
|
-
normalMap:
|
|
274
|
-
roughnessMap:
|
|
281
|
+
normalMap: u ? await r(u) : null,
|
|
282
|
+
roughnessMap: l ? await r(l) : null,
|
|
275
283
|
metalnessMap: c ? await r(c) : null,
|
|
276
|
-
aoMap:
|
|
277
|
-
alphaMap:
|
|
278
|
-
matcap:
|
|
284
|
+
aoMap: m ? await r(m) : null,
|
|
285
|
+
alphaMap: h ? await r(h) : null,
|
|
286
|
+
matcap: i ? await r(i) : null
|
|
279
287
|
};
|
|
280
288
|
}
|
|
281
289
|
}
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
290
|
+
const mt = (e, { renderer: n, camera: t, raycaster: r }) => {
|
|
291
|
+
const a = D(() => n.value.domElement), { x: o, y: u } = Ge({ target: a }), { width: l, height: c, top: m, left: h } = We(a), i = ({ x: g, y: _ }) => {
|
|
292
|
+
if (a.value)
|
|
285
293
|
return {
|
|
286
|
-
x: (g -
|
|
287
|
-
y: -((
|
|
294
|
+
x: (g - h.value) / l.value * 2 - 1,
|
|
295
|
+
y: -((_ - m.value) / c.value) * 2 + 1
|
|
288
296
|
};
|
|
289
|
-
},
|
|
297
|
+
}, s = ({ x: g, y: _ }) => {
|
|
290
298
|
if (t.value)
|
|
291
|
-
return r.value.setFromCamera(new
|
|
292
|
-
},
|
|
293
|
-
const
|
|
299
|
+
return r.value.setFromCamera(new Fe(g, _), t.value), r.value.intersectObjects(e.value, !1);
|
|
300
|
+
}, f = (g) => {
|
|
301
|
+
const _ = i({
|
|
294
302
|
x: (g == null ? void 0 : g.clientX) ?? o.value,
|
|
295
|
-
y: (g == null ? void 0 : g.clientY) ??
|
|
303
|
+
y: (g == null ? void 0 : g.clientY) ?? u.value
|
|
296
304
|
});
|
|
297
|
-
return
|
|
298
|
-
},
|
|
299
|
-
g.trigger({ event:
|
|
300
|
-
},
|
|
301
|
-
w
|
|
305
|
+
return _ ? s(_) || [] : [];
|
|
306
|
+
}, d = D(() => f()), p = x(), w = x(), v = (g, _) => {
|
|
307
|
+
g.trigger({ event: _, intersects: f(_) });
|
|
308
|
+
}, M = (g) => {
|
|
309
|
+
v(w, g);
|
|
302
310
|
};
|
|
303
|
-
let
|
|
304
|
-
const
|
|
305
|
-
var
|
|
306
|
-
|
|
307
|
-
},
|
|
308
|
-
var
|
|
309
|
-
g instanceof PointerEvent &&
|
|
310
|
-
}, b = (g) =>
|
|
311
|
-
return
|
|
312
|
-
|
|
311
|
+
let P;
|
|
312
|
+
const A = (g) => {
|
|
313
|
+
var _;
|
|
314
|
+
P = (_ = f(g)[0]) == null ? void 0 : _.object;
|
|
315
|
+
}, E = (g) => {
|
|
316
|
+
var _;
|
|
317
|
+
g instanceof PointerEvent && P === ((_ = f(g)[0]) == null ? void 0 : _.object) && v(p, g);
|
|
318
|
+
}, b = (g) => w.trigger({ event: g, intersects: [] });
|
|
319
|
+
return a.value.addEventListener("pointerup", E), a.value.addEventListener("pointerdown", A), a.value.addEventListener("pointermove", M), a.value.addEventListener("pointerleave", b), O(() => {
|
|
320
|
+
a != null && a.value && (a.value.removeEventListener("pointerup", E), a.value.removeEventListener("pointerdown", A), a.value.removeEventListener("pointermove", M), a.value.removeEventListener("pointerleave", b));
|
|
313
321
|
}), {
|
|
314
|
-
intersects:
|
|
315
|
-
onClick: (g) =>
|
|
316
|
-
onPointerMove: (g) =>
|
|
322
|
+
intersects: d,
|
|
323
|
+
onClick: (g) => p.on(g).off,
|
|
324
|
+
onPointerMove: (g) => w.on(g).off
|
|
317
325
|
};
|
|
318
326
|
};
|
|
319
|
-
function
|
|
327
|
+
function St() {
|
|
320
328
|
const { logWarning: e } = B();
|
|
321
|
-
function
|
|
329
|
+
function n(o, u, l) {
|
|
322
330
|
let c = null;
|
|
323
|
-
return o.traverse((
|
|
324
|
-
|
|
325
|
-
}), c || e(`Child with ${
|
|
331
|
+
return o.traverse((m) => {
|
|
332
|
+
m[u] === l && (c = m);
|
|
333
|
+
}), c || e(`Child with ${u} '${l}' not found.`), c;
|
|
326
334
|
}
|
|
327
|
-
function t(o,
|
|
335
|
+
function t(o, u, l) {
|
|
328
336
|
const c = [];
|
|
329
|
-
return o.traverse((
|
|
330
|
-
|
|
331
|
-
}), c.length || e(`Children with ${
|
|
337
|
+
return o.traverse((m) => {
|
|
338
|
+
m[u].includes(l) && c.push(m);
|
|
339
|
+
}), c.length || e(`Children with ${u} '${l}' not found.`), c;
|
|
332
340
|
}
|
|
333
|
-
function r(o,
|
|
334
|
-
return
|
|
341
|
+
function r(o, u) {
|
|
342
|
+
return n(o, "name", u);
|
|
335
343
|
}
|
|
336
|
-
function
|
|
337
|
-
return t(o, "name",
|
|
344
|
+
function a(o, u) {
|
|
345
|
+
return t(o, "name", u);
|
|
338
346
|
}
|
|
339
347
|
return {
|
|
340
|
-
seek:
|
|
348
|
+
seek: n,
|
|
341
349
|
seekByName: r,
|
|
342
350
|
seekAll: t,
|
|
343
|
-
seekAllByName:
|
|
351
|
+
seekAllByName: a
|
|
344
352
|
};
|
|
345
353
|
}
|
|
346
|
-
const
|
|
347
|
-
const t =
|
|
354
|
+
const pt = ({ scene: e, contextParts: n }) => {
|
|
355
|
+
const t = ge({
|
|
348
356
|
click: /* @__PURE__ */ new Map(),
|
|
349
357
|
pointerMove: /* @__PURE__ */ new Map(),
|
|
350
358
|
pointerEnter: /* @__PURE__ */ new Map(),
|
|
351
359
|
pointerLeave: /* @__PURE__ */ new Map()
|
|
352
|
-
}), r =
|
|
353
|
-
r.value.add(
|
|
354
|
-
}, o = (
|
|
355
|
-
r.value.delete(
|
|
356
|
-
},
|
|
357
|
-
Object.values(t).forEach((
|
|
358
|
-
},
|
|
359
|
-
const { onClick:
|
|
360
|
-
|
|
360
|
+
}), r = L(/* @__PURE__ */ new Set()), a = (s) => {
|
|
361
|
+
r.value.add(s);
|
|
362
|
+
}, o = (s) => {
|
|
363
|
+
r.value.delete(s);
|
|
364
|
+
}, u = (s) => {
|
|
365
|
+
Object.values(t).forEach((f) => f.delete(s)), o(s);
|
|
366
|
+
}, l = (s) => {
|
|
367
|
+
const { onClick: f, onPointerMove: d, onPointerEnter: p, onPointerLeave: w } = s;
|
|
368
|
+
f && t.click.set(s, f), d && t.pointerMove.set(s, d), p && t.pointerEnter.set(s, p), w && t.pointerLeave.set(s, w);
|
|
361
369
|
};
|
|
362
|
-
e.userData.tres__registerAtPointerEventHandler =
|
|
363
|
-
const c =
|
|
364
|
-
() =>
|
|
370
|
+
e.userData.tres__registerAtPointerEventHandler = l, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = a, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
|
|
371
|
+
const c = D(
|
|
372
|
+
() => nt(
|
|
365
373
|
[
|
|
366
374
|
...Array.from(r.value),
|
|
367
|
-
...Object.values(t).map((
|
|
375
|
+
...Object.values(t).map((s) => Array.from(s.keys())).flat()
|
|
368
376
|
],
|
|
369
|
-
({ uuid:
|
|
377
|
+
({ uuid: s }) => s
|
|
370
378
|
)
|
|
371
|
-
), { onClick:
|
|
372
|
-
|
|
373
|
-
var
|
|
374
|
-
|
|
379
|
+
), { onClick: m, onPointerMove: h } = mt(c, n);
|
|
380
|
+
m(({ intersects: s, event: f }) => {
|
|
381
|
+
var d;
|
|
382
|
+
s.length && ((d = t.click.get(s[0].object)) == null || d(s[0], f));
|
|
375
383
|
});
|
|
376
|
-
let
|
|
377
|
-
return
|
|
378
|
-
var
|
|
379
|
-
const
|
|
380
|
-
|
|
384
|
+
let i;
|
|
385
|
+
return h(({ intersects: s, event: f }) => {
|
|
386
|
+
var M, P, A, E;
|
|
387
|
+
const d = (M = s == null ? void 0 : s[0]) == null ? void 0 : M.object, { pointerLeave: p, pointerEnter: w, pointerMove: v } = t;
|
|
388
|
+
i && i !== d && ((P = p.get(i)) == null || P(i, f)), d && (i !== d && ((A = w.get(d)) == null || A(s[0], f)), (E = v.get(d)) == null || E(s[0], f)), i = d || null;
|
|
381
389
|
}), {
|
|
382
|
-
registerObject:
|
|
383
|
-
deregisterObject:
|
|
390
|
+
registerObject: l,
|
|
391
|
+
deregisterObject: u
|
|
384
392
|
};
|
|
385
393
|
};
|
|
386
|
-
function
|
|
387
|
-
let
|
|
394
|
+
function dt(e) {
|
|
395
|
+
let n = 0;
|
|
388
396
|
return e.traverse((t) => {
|
|
389
397
|
if (t.isMesh && t.geometry) {
|
|
390
|
-
const r = t.geometry,
|
|
391
|
-
|
|
398
|
+
const r = t.geometry, a = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, u = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, l = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = a + o + u + l;
|
|
399
|
+
n += c;
|
|
392
400
|
}
|
|
393
|
-
}),
|
|
401
|
+
}), n;
|
|
394
402
|
}
|
|
395
|
-
const
|
|
396
|
-
function
|
|
403
|
+
const q = L({}), Y = (e) => Object.assign(q.value, e);
|
|
404
|
+
function vt({
|
|
397
405
|
scene: e,
|
|
398
|
-
canvas:
|
|
406
|
+
canvas: n,
|
|
399
407
|
windowSize: t,
|
|
400
408
|
disableRender: r,
|
|
401
|
-
rendererOptions:
|
|
409
|
+
rendererOptions: a
|
|
402
410
|
}) {
|
|
403
|
-
const o =
|
|
404
|
-
() =>
|
|
405
|
-
),
|
|
406
|
-
height:
|
|
407
|
-
width:
|
|
411
|
+
const o = D(
|
|
412
|
+
() => C(t) ? qe() : Ue(C(n).parentElement)
|
|
413
|
+
), u = D(() => o.value.width.value), l = D(() => o.value.height.value), c = D(() => u.value / l.value), m = {
|
|
414
|
+
height: l,
|
|
415
|
+
width: u,
|
|
408
416
|
aspectRatio: c
|
|
409
|
-
},
|
|
410
|
-
camera:
|
|
411
|
-
cameras:
|
|
412
|
-
registerCamera:
|
|
413
|
-
deregisterCamera:
|
|
414
|
-
setCameraActive:
|
|
415
|
-
} =
|
|
417
|
+
}, h = S(e), {
|
|
418
|
+
camera: i,
|
|
419
|
+
cameras: s,
|
|
420
|
+
registerCamera: f,
|
|
421
|
+
deregisterCamera: d,
|
|
422
|
+
setCameraActive: p
|
|
423
|
+
} = Ke({ sizes: m, scene: e }), { renderer: w } = ut(
|
|
416
424
|
{
|
|
417
425
|
scene: e,
|
|
418
|
-
canvas:
|
|
419
|
-
options:
|
|
420
|
-
contextParts: { sizes:
|
|
426
|
+
canvas: n,
|
|
427
|
+
options: a,
|
|
428
|
+
contextParts: { sizes: m, camera: i },
|
|
421
429
|
disableRender: r
|
|
422
430
|
}
|
|
423
|
-
),
|
|
424
|
-
sizes:
|
|
425
|
-
scene:
|
|
426
|
-
camera:
|
|
427
|
-
cameras:
|
|
428
|
-
renderer:
|
|
429
|
-
raycaster:
|
|
430
|
-
controls:
|
|
431
|
+
), v = {
|
|
432
|
+
sizes: m,
|
|
433
|
+
scene: h,
|
|
434
|
+
camera: i,
|
|
435
|
+
cameras: ye(s),
|
|
436
|
+
renderer: w,
|
|
437
|
+
raycaster: S(new ze()),
|
|
438
|
+
controls: L(null),
|
|
431
439
|
perf: {
|
|
432
440
|
maxFrames: 160,
|
|
433
441
|
fps: {
|
|
@@ -441,130 +449,135 @@ function mt({
|
|
|
441
449
|
}
|
|
442
450
|
},
|
|
443
451
|
extend: Y,
|
|
444
|
-
registerCamera:
|
|
445
|
-
setCameraActive:
|
|
446
|
-
deregisterCamera:
|
|
452
|
+
registerCamera: f,
|
|
453
|
+
setCameraActive: p,
|
|
454
|
+
deregisterCamera: d
|
|
447
455
|
};
|
|
448
|
-
|
|
449
|
-
const
|
|
456
|
+
G("useTres", v);
|
|
457
|
+
const M = 100, P = Ye({ every: M }), { isSupported: A, memory: E } = Je({ interval: M }), b = 160;
|
|
450
458
|
let g = performance.now();
|
|
451
|
-
const
|
|
452
|
-
|
|
459
|
+
const _ = ({ timestamp: R }) => {
|
|
460
|
+
v.scene.value && (v.perf.memory.allocatedMem = dt(v.scene.value)), R - g >= M && (g = R, v.perf.fps.accumulator.push(P.value), v.perf.fps.accumulator.length > b && v.perf.fps.accumulator.shift(), v.perf.fps.value = P.value, A.value && E.value && (v.perf.memory.accumulator.push(E.value.usedJSHeapSize / 1024 / 1024), v.perf.memory.accumulator.length > b && v.perf.memory.accumulator.shift(), v.perf.memory.currentMem = v.perf.memory.accumulator.reduce((de, ve) => de + ve, 0) / v.perf.memory.accumulator.length));
|
|
453
461
|
};
|
|
454
|
-
let
|
|
455
|
-
const
|
|
456
|
-
window.__TRES__DEVTOOLS__ && (
|
|
462
|
+
let I = 0;
|
|
463
|
+
const me = 1, { pause: pe, resume: Ct } = ne(({ delta: R }) => {
|
|
464
|
+
window.__TRES__DEVTOOLS__ && (_({ timestamp: performance.now() }), I += R, I >= me && (window.__TRES__DEVTOOLS__.cb(v), I = 0));
|
|
457
465
|
}, { immediate: !0 });
|
|
458
|
-
return
|
|
459
|
-
|
|
460
|
-
}),
|
|
466
|
+
return O(() => {
|
|
467
|
+
pe();
|
|
468
|
+
}), v;
|
|
461
469
|
}
|
|
462
|
-
function
|
|
463
|
-
const e =
|
|
470
|
+
function gt() {
|
|
471
|
+
const e = he("useTres");
|
|
464
472
|
if (!e)
|
|
465
473
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
466
474
|
return e;
|
|
467
475
|
}
|
|
468
|
-
const
|
|
476
|
+
const xt = gt;
|
|
469
477
|
let y = null;
|
|
470
|
-
const { logError:
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
478
|
+
const { logError: re } = B(), V = [
|
|
479
|
+
"onClick",
|
|
480
|
+
"onPointerMove",
|
|
481
|
+
"onPointerEnter",
|
|
482
|
+
"onPointerLeave"
|
|
483
|
+
], fe = {
|
|
484
|
+
createElement(e, n, t, r) {
|
|
485
|
+
var u, l;
|
|
486
|
+
if (r || (r = {}), r.args || (r.args = []), e === "template" || rt(e))
|
|
474
487
|
return null;
|
|
475
|
-
let
|
|
488
|
+
let a = e.replace("Tres", ""), o;
|
|
476
489
|
if (e === "primitive") {
|
|
477
|
-
(r == null ? void 0 : r.object) === void 0 &&
|
|
490
|
+
(r == null ? void 0 : r.object) === void 0 && re("Tres primitives need a prop 'object'");
|
|
478
491
|
const c = r.object;
|
|
479
|
-
|
|
492
|
+
a = c.type, o = Object.assign(c, { type: a, attach: r.attach, primitive: !0 });
|
|
480
493
|
} else {
|
|
481
|
-
const c =
|
|
482
|
-
c ||
|
|
494
|
+
const c = q.value[a];
|
|
495
|
+
c || re(`${a} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new c(...r.args);
|
|
483
496
|
}
|
|
484
|
-
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((
|
|
497
|
+
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((u = r == null ? void 0 : r.material) != null && u.isMaterial && (o.userData.tres__materialViaProp = !0), (l = r == null ? void 0 : r.geometry) != null && l.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
|
|
485
498
|
...o.userData,
|
|
486
|
-
tres__name:
|
|
499
|
+
tres__name: a
|
|
487
500
|
}, o;
|
|
488
501
|
},
|
|
489
|
-
insert(e,
|
|
490
|
-
var r,
|
|
491
|
-
|
|
492
|
-
const t =
|
|
502
|
+
insert(e, n) {
|
|
503
|
+
var r, a, o, u;
|
|
504
|
+
n && n.isScene && (y = n);
|
|
505
|
+
const t = n || y;
|
|
493
506
|
if (e != null && e.isObject3D) {
|
|
494
507
|
if (e != null && e.isCamera) {
|
|
495
508
|
if (!(y != null && y.userData.tres__registerCamera))
|
|
496
509
|
throw "could not find tres__registerCamera on scene's userData";
|
|
497
|
-
(
|
|
510
|
+
(a = y == null ? void 0 : (r = y.userData).tres__registerCamera) == null || a.call(r, e);
|
|
498
511
|
}
|
|
499
|
-
if (e
|
|
512
|
+
if (e && V.some((l) => e[l])) {
|
|
500
513
|
if (!(y != null && y.userData.tres__registerAtPointerEventHandler))
|
|
501
514
|
throw "could not find tres__registerAtPointerEventHandler on scene's userData";
|
|
502
|
-
(
|
|
515
|
+
(u = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e);
|
|
503
516
|
}
|
|
504
517
|
}
|
|
505
518
|
e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : e != null && e.isFog ? t.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
|
|
506
519
|
},
|
|
507
520
|
remove(e) {
|
|
508
|
-
var
|
|
509
|
-
if (e)
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
(a = e.removeFromParent) == null || a.call(e), (t = e.dispose) == null || t.call(e);
|
|
521
|
+
var c, m, h;
|
|
522
|
+
if (!e)
|
|
523
|
+
return;
|
|
524
|
+
const n = (i) => {
|
|
525
|
+
var f, d;
|
|
526
|
+
const s = i;
|
|
527
|
+
i.userData.tres__materialViaProp || ((f = s.material) == null || f.dispose(), delete s.material), i.userData.tres__geometryViaProp || ((d = s.geometry) == null || d.dispose(), delete s.geometry);
|
|
528
|
+
}, t = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, r = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, a = (i) => {
|
|
529
|
+
var s, f;
|
|
530
|
+
if (!r)
|
|
531
|
+
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
|
|
532
|
+
if ((f = y == null ? void 0 : (s = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(s, i), !t)
|
|
533
|
+
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
|
|
534
|
+
i && V.some((d) => i[d]) && (t == null || t(i));
|
|
535
|
+
}, o = (i) => {
|
|
536
|
+
const s = y == null ? void 0 : y.userData.tres__deregisterCamera;
|
|
537
|
+
if (!s)
|
|
538
|
+
throw "could not find tres__deregisterCamera on scene's userData";
|
|
539
|
+
i.isCamera && (s == null || s(i));
|
|
540
|
+
}, u = e == null ? void 0 : e.primitive, l = !u && (e.dispose === void 0 ? e.dispose !== null : !1);
|
|
541
|
+
if (e != null && e.isObject3D && ((c = e.parent) != null && c.isObject3D) && (e.parent.remove(e), (m = e.removeFromParent) == null || m.call(e)), !u && (e != null && e.isObject3D)) {
|
|
542
|
+
e.children.forEach((i) => fe.remove(i)), n(e), o(e), a == null || a(e);
|
|
543
|
+
for (const i in e)
|
|
544
|
+
i !== "geometry" && i !== "material" && ((h = i.dispose) == null || h.call(i), delete e[i]);
|
|
533
545
|
}
|
|
546
|
+
l && e.dispose && e.type !== "Scene" && e.dispose();
|
|
534
547
|
},
|
|
535
|
-
patchProp(e,
|
|
536
|
-
var
|
|
548
|
+
patchProp(e, n, t, r) {
|
|
549
|
+
var a, o, u, l;
|
|
537
550
|
if (e) {
|
|
538
|
-
let c = e,
|
|
539
|
-
if (e.isObject3D &&
|
|
540
|
-
r || r === "" ? (o = y == null ? void 0 : (
|
|
551
|
+
let c = e, m = n;
|
|
552
|
+
if (e.isObject3D && m === "blocks-pointer-events") {
|
|
553
|
+
r || r === "" ? (o = y == null ? void 0 : (a = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(a, e) : (l = y == null ? void 0 : (u = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || l.call(u, e);
|
|
541
554
|
return;
|
|
542
555
|
}
|
|
543
|
-
let
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
|
|
556
|
+
let h = j(m), i = c == null ? void 0 : c[h];
|
|
557
|
+
if (m === "args") {
|
|
558
|
+
const f = e, d = t ?? [], p = r ?? [], w = e.userData.tres__name || e.type;
|
|
559
|
+
w && d.length && !st(d, p) && (c = Object.assign(f, new q.value[w](...r)));
|
|
547
560
|
return;
|
|
548
561
|
}
|
|
549
562
|
if (c.type === "BufferGeometry") {
|
|
550
|
-
if (
|
|
563
|
+
if (m === "args")
|
|
551
564
|
return;
|
|
552
565
|
c.setAttribute(
|
|
553
|
-
|
|
554
|
-
new
|
|
566
|
+
j(m),
|
|
567
|
+
new $e(...r)
|
|
555
568
|
);
|
|
556
569
|
return;
|
|
557
570
|
}
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
|
|
571
|
+
if (m.includes("-") && i === void 0) {
|
|
572
|
+
const f = m.split("-");
|
|
573
|
+
i = f.reduce((d, p) => d[j(p)], c), m = f.pop(), h = m.toLowerCase(), i != null && i.set || (c = f.reduce((d, p) => d[j(p)], c));
|
|
561
574
|
}
|
|
562
|
-
let
|
|
563
|
-
if (
|
|
564
|
-
Array.isArray(
|
|
575
|
+
let s = r;
|
|
576
|
+
if (s === "" && (s = !0), te(i)) {
|
|
577
|
+
V.includes(n) || (Array.isArray(s) ? e[h](...s) : e[h](s));
|
|
565
578
|
return;
|
|
566
579
|
}
|
|
567
|
-
!(
|
|
580
|
+
!(i != null && i.set) && !te(i) ? c[h] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
|
|
568
581
|
}
|
|
569
582
|
},
|
|
570
583
|
parentNode(e) {
|
|
@@ -579,9 +592,9 @@ const { logError: te } = B(), vt = {
|
|
|
579
592
|
setScopeId: () => void 0,
|
|
580
593
|
cloneNode: () => void 0,
|
|
581
594
|
insertStaticContent: () => void 0
|
|
582
|
-
}, { render:
|
|
583
|
-
Y(
|
|
584
|
-
const
|
|
595
|
+
}, { render: yt } = we(fe);
|
|
596
|
+
Y(De);
|
|
597
|
+
const ht = ["data-scene"], wt = /* @__PURE__ */ J({
|
|
585
598
|
__name: "TresCanvas",
|
|
586
599
|
props: {
|
|
587
600
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -607,107 +620,113 @@ const gt = ["data-scene"], yt = /* @__PURE__ */ q({
|
|
|
607
620
|
logarithmicDepthBuffer: { type: Boolean, default: void 0 },
|
|
608
621
|
failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
|
|
609
622
|
},
|
|
610
|
-
setup(e, { expose:
|
|
611
|
-
var
|
|
612
|
-
const t = e, { logWarning: r } = B(),
|
|
613
|
-
|
|
614
|
-
const
|
|
623
|
+
setup(e, { expose: n }) {
|
|
624
|
+
var d;
|
|
625
|
+
const t = e, { logWarning: r } = B(), a = L(), o = S(new Ie());
|
|
626
|
+
ie();
|
|
627
|
+
const u = Ee(), l = (d = K()) == null ? void 0 : d.appContext.app;
|
|
628
|
+
let c = null;
|
|
629
|
+
const m = (p) => J({
|
|
615
630
|
setup() {
|
|
616
|
-
var
|
|
617
|
-
const
|
|
618
|
-
return
|
|
631
|
+
var v;
|
|
632
|
+
const w = (v = K()) == null ? void 0 : v.appContext;
|
|
633
|
+
return w && (w.app = l), G("useTres", p), G("extend", Y), () => X(be, null, u != null && u.default ? u.default() : []);
|
|
619
634
|
}
|
|
620
|
-
}),
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
635
|
+
}), h = (p) => {
|
|
636
|
+
c = m(p), yt(X(c), o.value);
|
|
637
|
+
}, i = (p) => {
|
|
638
|
+
ce(o.value), o.value = null;
|
|
639
|
+
}, s = D(() => t.disableRender), f = S(null);
|
|
640
|
+
return n({ context: f, dispose: () => i(f.value) }), _e(() => {
|
|
641
|
+
const p = a;
|
|
642
|
+
f.value = vt({
|
|
627
643
|
scene: o.value,
|
|
628
|
-
canvas:
|
|
644
|
+
canvas: p,
|
|
629
645
|
windowSize: t.windowSize,
|
|
630
|
-
disableRender:
|
|
646
|
+
disableRender: s,
|
|
631
647
|
rendererOptions: t
|
|
632
|
-
}),
|
|
633
|
-
const { registerCamera:
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
const E = new
|
|
648
|
+
}), pt({ scene: o.value, contextParts: f.value });
|
|
649
|
+
const { registerCamera: w, camera: v, cameras: M, deregisterCamera: P } = f.value;
|
|
650
|
+
h(f.value);
|
|
651
|
+
const A = () => {
|
|
652
|
+
const E = new W(
|
|
637
653
|
45,
|
|
638
654
|
window.innerWidth / window.innerHeight,
|
|
639
655
|
0.1,
|
|
640
656
|
1e3
|
|
641
657
|
);
|
|
642
|
-
E.position.set(3, 3, 3), E.lookAt(0, 0, 0),
|
|
643
|
-
const
|
|
644
|
-
|
|
658
|
+
E.position.set(3, 3, 3), E.lookAt(0, 0, 0), w(E);
|
|
659
|
+
const b = k(() => {
|
|
660
|
+
M.value.length >= 2 && (E.removeFromParent(), P(E), b == null || b());
|
|
645
661
|
});
|
|
646
662
|
};
|
|
647
|
-
|
|
663
|
+
ae(
|
|
648
664
|
() => t.camera,
|
|
649
|
-
(E,
|
|
650
|
-
E &&
|
|
665
|
+
(E, b) => {
|
|
666
|
+
E && w(E), b && (b.removeFromParent(), P(b));
|
|
651
667
|
},
|
|
652
668
|
{
|
|
653
669
|
immediate: !0
|
|
654
670
|
}
|
|
655
|
-
),
|
|
671
|
+
), v.value || (r(
|
|
656
672
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
657
|
-
),
|
|
658
|
-
}), (
|
|
673
|
+
), A());
|
|
674
|
+
}), O(() => {
|
|
675
|
+
f.value && i(f.value);
|
|
676
|
+
}), (p, w) => (Ce(), Me("canvas", {
|
|
659
677
|
ref_key: "canvas",
|
|
660
|
-
ref:
|
|
678
|
+
ref: a,
|
|
661
679
|
"data-scene": o.value.uuid,
|
|
662
|
-
class:
|
|
663
|
-
style:
|
|
680
|
+
class: Pe(p.$attrs.class),
|
|
681
|
+
style: Ae({
|
|
664
682
|
display: "block",
|
|
665
683
|
width: "100%",
|
|
666
684
|
height: "100%",
|
|
667
|
-
position:
|
|
685
|
+
position: p.windowSize ? "fixed" : "relative",
|
|
668
686
|
top: 0,
|
|
669
687
|
left: 0,
|
|
670
688
|
pointerEvents: "auto",
|
|
671
689
|
touchAction: "none",
|
|
672
|
-
...
|
|
690
|
+
...p.$attrs.style
|
|
673
691
|
})
|
|
674
|
-
}, null, 14,
|
|
692
|
+
}, null, 14, ht));
|
|
675
693
|
}
|
|
676
|
-
}),
|
|
694
|
+
}), Et = [
|
|
677
695
|
"TresCanvas",
|
|
678
696
|
"TresLeches",
|
|
679
697
|
"TresScene"
|
|
680
|
-
],
|
|
698
|
+
], _t = {
|
|
681
699
|
template: {
|
|
682
700
|
compilerOptions: {
|
|
683
|
-
isCustomElement: (e) => e.startsWith("Tres") && !
|
|
701
|
+
isCustomElement: (e) => e.startsWith("Tres") && !Et.includes(e) || e === "primitive"
|
|
684
702
|
}
|
|
685
703
|
}
|
|
686
|
-
}, Lt =
|
|
704
|
+
}, Lt = _t, Ot = {
|
|
687
705
|
install(e) {
|
|
688
|
-
e.component("TresCanvas",
|
|
706
|
+
e.component("TresCanvas", wt);
|
|
689
707
|
}
|
|
690
708
|
};
|
|
691
709
|
export {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
710
|
+
wt as TresCanvas,
|
|
711
|
+
q as catalogue,
|
|
712
|
+
Ot as default,
|
|
713
|
+
ce as dispose,
|
|
695
714
|
Y as extend,
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
715
|
+
bt as isProd,
|
|
716
|
+
et as normalizeColor,
|
|
717
|
+
Dt as normalizeVectorFlexibleParam,
|
|
699
718
|
Lt as templateCompilerOptions,
|
|
700
|
-
|
|
701
|
-
|
|
719
|
+
ft as trasverseObjects,
|
|
720
|
+
Ke as useCamera,
|
|
702
721
|
kt as useLoader,
|
|
703
722
|
B as useLogger,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
723
|
+
pt as usePointerEventHandler,
|
|
724
|
+
mt as useRaycaster,
|
|
725
|
+
ie as useRenderLoop,
|
|
726
|
+
ut as useRenderer,
|
|
727
|
+
St as useSeek,
|
|
728
|
+
Tt as useTexture,
|
|
729
|
+
xt as useTres,
|
|
730
|
+
gt as useTresContext,
|
|
731
|
+
vt as useTresContextProvider
|
|
713
732
|
};
|