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