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