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