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