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