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