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