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