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