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