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