@tresjs/core 2.0.0-beta.8 → 2.0.0-beta.9
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/tres.js +215 -215
- package/dist/tres.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/tres.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v2.0.0-beta.
|
|
3
|
+
* version: v2.0.0-beta.9
|
|
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 { MathUtils as
|
|
11
|
-
import { createEventHook as q, useRafFn as
|
|
12
|
-
const
|
|
13
|
-
var
|
|
14
|
-
const
|
|
8
|
+
import { ref as P, watchEffect as ue, toRef as Se, shallowRef as fe, toRefs as le, computed as de, watch as W, shallowReactive as pe, provide as Oe, inject as ke, onUnmounted as me, createRenderer as je, defineComponent as ve, onMounted as De, h as O } from "vue";
|
|
9
|
+
import * as ge from "three";
|
|
10
|
+
import { MathUtils as Ie, PerspectiveCamera as H, OrthographicCamera as Be, Clock as he, Color as Y, sRGBEncoding as ze, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ge, PCFShadowMap as Ve, LinearEncoding as te, NoToneMapping as ae, WebGLRenderer as Ue, LoadingManager as We, TextureLoader as He, Raycaster as Ye, Vector2 as $e, BufferAttribute as Ne } from "three";
|
|
11
|
+
import { createEventHook as q, useRafFn as qe, resolveUnref as f, useWindowSize as Ke, useElementSize as Je, useDevicePixelRatio as Xe, unrefElement as $, isFunction as ne, useEventListener as Qe } from "@vueuse/core";
|
|
12
|
+
const we = P({ uuid: Ie.generateUUID() }), be = (e) => void Object.assign(we.value, e);
|
|
13
|
+
var Ze = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ze || {});
|
|
14
|
+
const et = 45;
|
|
15
15
|
let _;
|
|
16
|
-
function
|
|
17
|
-
const { state: e, setState: t, aspectRatio: o } =
|
|
18
|
-
function a(i = "Perspective",
|
|
19
|
-
var
|
|
16
|
+
function ye() {
|
|
17
|
+
const { state: e, setState: t, aspectRatio: o } = j();
|
|
18
|
+
function a(i = "Perspective", s) {
|
|
19
|
+
var l, u, p;
|
|
20
20
|
if (i === "Perspective") {
|
|
21
|
-
const { near: d, far:
|
|
21
|
+
const { near: d, far: w, fov: M } = s || {
|
|
22
22
|
near: 0.1,
|
|
23
23
|
far: 1e3,
|
|
24
|
-
fov:
|
|
24
|
+
fov: et
|
|
25
25
|
};
|
|
26
|
-
_ = new
|
|
26
|
+
_ = new H(M, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, d, w), (u = e.cameras) == null || u.push(_);
|
|
27
27
|
} else {
|
|
28
|
-
const { left: d, right:
|
|
28
|
+
const { left: d, right: w, top: M, bottom: x, near: L, far: b } = s || {
|
|
29
29
|
left: -100,
|
|
30
30
|
right: 100,
|
|
31
31
|
top: 100,
|
|
@@ -33,227 +33,227 @@ function N() {
|
|
|
33
33
|
near: 0.1,
|
|
34
34
|
far: 1e3
|
|
35
35
|
};
|
|
36
|
-
_ = new
|
|
36
|
+
_ = new Be(d, w, M, x, L, b), (p = e.cameras) == null || p.push(_);
|
|
37
37
|
}
|
|
38
38
|
return e.camera = _, t("camera", e.camera), _;
|
|
39
39
|
}
|
|
40
40
|
function n() {
|
|
41
41
|
var i;
|
|
42
|
-
e.camera instanceof
|
|
42
|
+
e.camera instanceof H && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (i = e.camera) == null || i.updateProjectionMatrix();
|
|
43
43
|
}
|
|
44
44
|
function r(i) {
|
|
45
|
-
var
|
|
46
|
-
(
|
|
45
|
+
var s;
|
|
46
|
+
(s = e.cameras) == null || s.push(i), i instanceof H && e.aspectRatio && (i.aspect = e.aspectRatio.value), i.updateProjectionMatrix(), t("camera", i);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function c() {
|
|
49
49
|
e.cameras = [];
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return ue(() => {
|
|
52
52
|
o != null && o.value && n();
|
|
53
53
|
}), {
|
|
54
|
-
activeCamera:
|
|
54
|
+
activeCamera: Se(e, "camera"),
|
|
55
55
|
createCamera: a,
|
|
56
56
|
updateCamera: n,
|
|
57
57
|
pushCamera: r,
|
|
58
|
-
clearCameras:
|
|
58
|
+
clearCameras: c
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const Me = q(), xe = q(), K = q(), k = new he();
|
|
62
62
|
let G = 0, V = 0;
|
|
63
|
-
const { pause:
|
|
63
|
+
const { pause: tt, resume: at, isActive: nt } = qe(
|
|
64
64
|
() => {
|
|
65
|
-
|
|
65
|
+
Me.trigger({ delta: G, elapsed: V, clock: k }), xe.trigger({ delta: G, elapsed: V, clock: k }), K.trigger({ delta: G, elapsed: V, clock: k });
|
|
66
66
|
},
|
|
67
67
|
{ immediate: !1 }
|
|
68
68
|
);
|
|
69
69
|
K.on(() => {
|
|
70
|
-
G =
|
|
70
|
+
G = k.getDelta(), V = k.getElapsedTime();
|
|
71
71
|
});
|
|
72
|
-
function
|
|
72
|
+
function Ee() {
|
|
73
73
|
return {
|
|
74
|
-
onBeforeLoop:
|
|
75
|
-
onLoop:
|
|
74
|
+
onBeforeLoop: Me.on,
|
|
75
|
+
onLoop: xe.on,
|
|
76
76
|
onAfterLoop: K.on,
|
|
77
|
-
pause:
|
|
78
|
-
resume:
|
|
79
|
-
isActive:
|
|
77
|
+
pause: tt,
|
|
78
|
+
resume: at,
|
|
79
|
+
isActive: nt
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
return e instanceof
|
|
82
|
+
function rt(e) {
|
|
83
|
+
return e instanceof Y ? e : Array.isArray(e) ? new Y(...e) : new Y(e);
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const N = {
|
|
86
86
|
realistic: {
|
|
87
|
-
outputEncoding:
|
|
88
|
-
toneMapping:
|
|
87
|
+
outputEncoding: ze,
|
|
88
|
+
toneMapping: Fe,
|
|
89
89
|
toneMappingExposure: 3,
|
|
90
90
|
shadowMap: {
|
|
91
91
|
enabled: !0,
|
|
92
|
-
type:
|
|
92
|
+
type: Ge
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
},
|
|
95
|
+
}, Ce = (e, t) => {
|
|
96
96
|
for (const o of Object.keys(t))
|
|
97
|
-
t[o] instanceof Object && Object.assign(t[o],
|
|
97
|
+
t[o] instanceof Object && Object.assign(t[o], Ce(e[o], t[o]));
|
|
98
98
|
return Object.assign(e || {}, t), e;
|
|
99
|
-
},
|
|
100
|
-
function
|
|
99
|
+
}, ot = "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", it = /* @__PURE__ */ st(ot);
|
|
100
|
+
function F(e) {
|
|
101
101
|
return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase());
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function st(e, t) {
|
|
104
104
|
const o = /* @__PURE__ */ Object.create(null), a = e.split(",");
|
|
105
105
|
for (let n = 0; n < a.length; n++)
|
|
106
106
|
o[a[n]] = !0;
|
|
107
107
|
return t ? (n) => !!o[n.toLowerCase()] : (n) => !!o[n];
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function ct(e) {
|
|
110
110
|
var Z, ee;
|
|
111
|
-
const t =
|
|
111
|
+
const t = fe(), o = P(!1), {
|
|
112
112
|
alpha: a = !0,
|
|
113
113
|
antialias: n = !0,
|
|
114
114
|
depth: r,
|
|
115
|
-
logarithmicDepthBuffer:
|
|
115
|
+
logarithmicDepthBuffer: c,
|
|
116
116
|
failIfMajorPerformanceCaveat: i,
|
|
117
|
-
precision:
|
|
118
|
-
premultipliedAlpha:
|
|
119
|
-
stencil:
|
|
120
|
-
shadows:
|
|
121
|
-
shadowMapType: d =
|
|
122
|
-
physicallyCorrectLights:
|
|
123
|
-
useLegacyLights:
|
|
124
|
-
outputEncoding:
|
|
125
|
-
toneMapping:
|
|
126
|
-
toneMappingExposure:
|
|
127
|
-
context:
|
|
128
|
-
powerPreference:
|
|
117
|
+
precision: s,
|
|
118
|
+
premultipliedAlpha: l,
|
|
119
|
+
stencil: u,
|
|
120
|
+
shadows: p = !1,
|
|
121
|
+
shadowMapType: d = Ve,
|
|
122
|
+
physicallyCorrectLights: w = !1,
|
|
123
|
+
useLegacyLights: M = !1,
|
|
124
|
+
outputEncoding: x = te,
|
|
125
|
+
toneMapping: L = ae,
|
|
126
|
+
toneMappingExposure: b = 1,
|
|
127
|
+
context: v = void 0,
|
|
128
|
+
powerPreference: E = "default",
|
|
129
129
|
preserveDrawingBuffer: y = !1,
|
|
130
|
-
clearColor:
|
|
131
|
-
windowSize:
|
|
132
|
-
preset:
|
|
133
|
-
} =
|
|
134
|
-
!
|
|
130
|
+
clearColor: g,
|
|
131
|
+
windowSize: C = !1,
|
|
132
|
+
preset: I = void 0
|
|
133
|
+
} = le(e), { state: h, setState: T } = j(), { width: S, height: R } = f(C) == !0 || f(C) === "" || f(C) === "true" ? Ke() : Je(h.container), { logError: B, logWarning: z } = D(), { pixelRatio: J } = Xe(), { pause: Le, resume: Te } = Ee(), U = de(() => S.value / R.value);
|
|
134
|
+
!f(C) && ((ee = (Z = h.container) == null ? void 0 : Z.value) == null ? void 0 : ee.offsetHeight) === 0 && z(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
|
|
135
135
|
You could set windowSize=true to force the canvas to be the size of the window.`);
|
|
136
136
|
const X = () => {
|
|
137
|
-
t.value && (t.value.setSize(
|
|
137
|
+
t.value && (t.value.setSize(S.value, R.value), t.value.setPixelRatio(Math.min(J.value, 2)));
|
|
138
138
|
}, Q = () => {
|
|
139
139
|
if (!t.value)
|
|
140
140
|
return;
|
|
141
|
-
const A =
|
|
141
|
+
const A = f(I);
|
|
142
142
|
if (A) {
|
|
143
|
-
A in
|
|
143
|
+
A in N || B("Renderer Preset must be one of these: " + Object.keys(N).join(", ")), Ce(t.value, N[A]);
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
t.value.shadowMap.enabled =
|
|
147
|
-
}, Te = () => {
|
|
148
|
-
const A = Y(h.canvas);
|
|
149
|
-
A && (t.value = new Ve({
|
|
150
|
-
canvas: A,
|
|
151
|
-
alpha: l(a),
|
|
152
|
-
antialias: l(n),
|
|
153
|
-
context: l(x),
|
|
154
|
-
depth: l(r),
|
|
155
|
-
failIfMajorPerformanceCaveat: l(i),
|
|
156
|
-
logarithmicDepthBuffer: l(s),
|
|
157
|
-
powerPreference: l(b),
|
|
158
|
-
precision: l(c),
|
|
159
|
-
stencil: l(f),
|
|
160
|
-
preserveDrawingBuffer: l(y),
|
|
161
|
-
premultipliedAlpha: l(u)
|
|
162
|
-
}), T("renderer", t.value), T("clock", new ge()), T("aspectRatio", U), Q(), X(), Le(), o.value = !0);
|
|
146
|
+
t.value.shadowMap.enabled = f(p), t.value.shadowMap.type = f(d), t.value.toneMapping = f(L) || ae, t.value.toneMappingExposure = f(b), t.value.outputEncoding = f(x) || te, g != null && g.value && t.value.setClearColor(rt(f(g))), t.value.useLegacyLights = f(M);
|
|
163
147
|
}, Ae = () => {
|
|
164
|
-
|
|
148
|
+
const A = $(h.canvas);
|
|
149
|
+
A && (t.value = new Ue({
|
|
150
|
+
canvas: A,
|
|
151
|
+
alpha: f(a),
|
|
152
|
+
antialias: f(n),
|
|
153
|
+
context: f(v),
|
|
154
|
+
depth: f(r),
|
|
155
|
+
failIfMajorPerformanceCaveat: f(i),
|
|
156
|
+
logarithmicDepthBuffer: f(c),
|
|
157
|
+
powerPreference: f(E),
|
|
158
|
+
precision: f(s),
|
|
159
|
+
stencil: f(u),
|
|
160
|
+
preserveDrawingBuffer: f(y),
|
|
161
|
+
premultipliedAlpha: f(l)
|
|
162
|
+
}), T("renderer", t.value), T("clock", new he()), T("aspectRatio", U), Q(), X(), Te(), o.value = !0);
|
|
163
|
+
}, _e = () => {
|
|
164
|
+
t.value && (t.value.dispose(), t.value = void 0, o.value = !1, Le());
|
|
165
165
|
};
|
|
166
166
|
return W([U, J], X), W(
|
|
167
|
-
[
|
|
167
|
+
[p, d, x, M, L, b, g],
|
|
168
168
|
Q
|
|
169
169
|
), W(
|
|
170
170
|
() => [h.canvas, h.container],
|
|
171
171
|
() => {
|
|
172
|
-
|
|
172
|
+
$(h.canvas) && $(h.container) && Ae();
|
|
173
173
|
},
|
|
174
174
|
{ immediate: !0, deep: !0 }
|
|
175
175
|
), {
|
|
176
176
|
renderer: t,
|
|
177
177
|
isReady: o,
|
|
178
|
-
dispose:
|
|
178
|
+
dispose: _e,
|
|
179
179
|
aspectRatio: U
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
const
|
|
183
|
-
function
|
|
182
|
+
const ut = (e) => typeof e == "string", Re = (e) => !!e && e.constructor === Array;
|
|
183
|
+
function ft(e) {
|
|
184
184
|
const t = { nodes: {}, materials: {} };
|
|
185
185
|
return e && e.traverse((o) => {
|
|
186
186
|
o.name && (t.nodes[o.name] = o), o.material && !t.materials[o.material.name] && (t.materials[o.material.name] = o.material);
|
|
187
187
|
}), t;
|
|
188
188
|
}
|
|
189
|
-
async function
|
|
190
|
-
const { logError: r } =
|
|
191
|
-
n && n(
|
|
192
|
-
const
|
|
193
|
-
(
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
async function Ct(e, t, o, a, n) {
|
|
190
|
+
const { logError: r } = D(), c = new e();
|
|
191
|
+
n && n(c), o && o(c);
|
|
192
|
+
const s = (Array.isArray(t) ? t : [t]).map(
|
|
193
|
+
(l) => new Promise((u, p) => {
|
|
194
|
+
c.load(
|
|
195
|
+
l,
|
|
196
196
|
(d) => {
|
|
197
|
-
d.scene && Object.assign(d,
|
|
197
|
+
d.scene && Object.assign(d, ft(d.scene)), u(d);
|
|
198
198
|
},
|
|
199
199
|
a,
|
|
200
|
-
(d) =>
|
|
200
|
+
(d) => p(r("[useLoader] - Failed to load resource", d))
|
|
201
201
|
);
|
|
202
202
|
})
|
|
203
203
|
);
|
|
204
|
-
return
|
|
204
|
+
return Re(t) ? await Promise.all(s) : await s[0];
|
|
205
205
|
}
|
|
206
206
|
async function Rt(e) {
|
|
207
|
-
const t = new
|
|
207
|
+
const t = new We(), o = new He(t), a = (n) => new Promise((r, c) => {
|
|
208
208
|
o.load(
|
|
209
209
|
n,
|
|
210
210
|
(i) => r(i),
|
|
211
211
|
() => null,
|
|
212
212
|
() => {
|
|
213
|
-
|
|
213
|
+
c(new Error("[useTextures] - Failed to load texture"));
|
|
214
214
|
}
|
|
215
215
|
);
|
|
216
216
|
});
|
|
217
|
-
if (
|
|
217
|
+
if (Re(e)) {
|
|
218
218
|
const n = await Promise.all(e.map((r) => a(r)));
|
|
219
219
|
return e.length > 1 ? n : n[0];
|
|
220
220
|
} else {
|
|
221
221
|
const {
|
|
222
222
|
map: n,
|
|
223
223
|
displacementMap: r,
|
|
224
|
-
normalMap:
|
|
224
|
+
normalMap: c,
|
|
225
225
|
roughnessMap: i,
|
|
226
|
-
metalnessMap:
|
|
227
|
-
aoMap:
|
|
228
|
-
alphaMap:
|
|
229
|
-
matcap:
|
|
226
|
+
metalnessMap: s,
|
|
227
|
+
aoMap: l,
|
|
228
|
+
alphaMap: u,
|
|
229
|
+
matcap: p
|
|
230
230
|
} = e;
|
|
231
231
|
return {
|
|
232
232
|
map: n ? await a(n) : null,
|
|
233
233
|
displacementMap: r ? await a(r) : null,
|
|
234
|
-
normalMap:
|
|
234
|
+
normalMap: c ? await a(c) : null,
|
|
235
235
|
roughnessMap: i ? await a(i) : null,
|
|
236
|
-
metalnessMap:
|
|
237
|
-
aoMap:
|
|
238
|
-
alphaMap:
|
|
239
|
-
matcap:
|
|
236
|
+
metalnessMap: s ? await a(s) : null,
|
|
237
|
+
aoMap: l ? await a(l) : null,
|
|
238
|
+
alphaMap: u ? await a(u) : null,
|
|
239
|
+
matcap: p ? await a(p) : null
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
const
|
|
244
|
-
function
|
|
243
|
+
const m = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
|
|
244
|
+
function lt() {
|
|
245
245
|
const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, o = Math.random() * 4294967295 | 0, a = Math.random() * 4294967295 | 0;
|
|
246
|
-
return (
|
|
246
|
+
return (m[e & 255] + m[e >> 8 & 255] + m[e >> 16 & 255] + m[e >> 24 & 255] + "-" + m[t & 255] + m[t >> 8 & 255] + "-" + m[t >> 16 & 15 | 64] + m[t >> 24 & 255] + "-" + m[o & 63 | 128] + m[o >> 8 & 255] + "-" + m[o >> 16 & 255] + m[o >> 24 & 255] + m[a & 255] + m[a >> 8 & 255] + m[a >> 16 & 255] + m[a >> 24 & 255]).toLowerCase();
|
|
247
247
|
}
|
|
248
|
-
const
|
|
249
|
-
function
|
|
250
|
-
const e =
|
|
251
|
-
uuid:
|
|
248
|
+
const Pe = Symbol();
|
|
249
|
+
function dt() {
|
|
250
|
+
const e = pe({
|
|
251
|
+
uuid: lt(),
|
|
252
252
|
camera: void 0,
|
|
253
253
|
cameras: [],
|
|
254
254
|
scene: void 0,
|
|
255
255
|
renderer: void 0,
|
|
256
|
-
aspectRatio:
|
|
256
|
+
aspectRatio: de(() => window.innerWidth / window.innerHeight)
|
|
257
257
|
});
|
|
258
258
|
function t(n) {
|
|
259
259
|
return e[n];
|
|
@@ -263,28 +263,28 @@ function ft() {
|
|
|
263
263
|
}
|
|
264
264
|
const a = {
|
|
265
265
|
state: e,
|
|
266
|
-
...
|
|
266
|
+
...le(e),
|
|
267
267
|
getState: t,
|
|
268
268
|
setState: o
|
|
269
269
|
};
|
|
270
|
-
return
|
|
270
|
+
return Oe(Pe, a), a;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
state:
|
|
272
|
+
const j = () => ke(Pe, {
|
|
273
|
+
state: pe({
|
|
274
274
|
camera: void 0,
|
|
275
275
|
cameras: [],
|
|
276
276
|
scene: void 0,
|
|
277
277
|
renderer: void 0
|
|
278
278
|
})
|
|
279
279
|
});
|
|
280
|
-
function
|
|
281
|
-
var
|
|
282
|
-
const e =
|
|
280
|
+
function pt() {
|
|
281
|
+
var c;
|
|
282
|
+
const e = fe(new Ye()), t = P(new $e()), o = P(null), { setState: a, state: n } = j();
|
|
283
283
|
a("raycaster", e.value), a("pointer", t), a("currentInstance", o);
|
|
284
284
|
function r(i) {
|
|
285
285
|
t.value.x = i.clientX / window.innerWidth * 2 - 1, t.value.y = -(i.clientY / window.innerHeight) * 2 + 1;
|
|
286
286
|
}
|
|
287
|
-
return (
|
|
287
|
+
return (c = n == null ? void 0 : n.renderer) == null || c.domElement.addEventListener("pointermove", r), me(() => {
|
|
288
288
|
var i;
|
|
289
289
|
(i = n == null ? void 0 : n.renderer) == null || i.domElement.removeEventListener("pointermove", r);
|
|
290
290
|
}), {
|
|
@@ -292,8 +292,8 @@ function lt() {
|
|
|
292
292
|
pointer: t
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
|
-
const
|
|
296
|
-
function
|
|
295
|
+
const Pt = !0, re = "[TresJS ▲ ■ ●] ";
|
|
296
|
+
function D() {
|
|
297
297
|
function e(a, n) {
|
|
298
298
|
console.error(`${re} ${a}`, n || "");
|
|
299
299
|
}
|
|
@@ -308,13 +308,13 @@ function I() {
|
|
|
308
308
|
logMessage: o
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
function
|
|
312
|
-
const { logWarning: e } =
|
|
311
|
+
function Lt() {
|
|
312
|
+
const { logWarning: e } = D();
|
|
313
313
|
function t(a, n, r) {
|
|
314
|
-
let
|
|
314
|
+
let c = null;
|
|
315
315
|
return a.traverse((i) => {
|
|
316
|
-
i[n] === r && (
|
|
317
|
-
}),
|
|
316
|
+
i[n] === r && (c = i);
|
|
317
|
+
}), c || e(`Child with ${n} '${r}' not found.`), c;
|
|
318
318
|
}
|
|
319
319
|
function o(a, n) {
|
|
320
320
|
return t(a, "name", n);
|
|
@@ -324,33 +324,33 @@ function Pt() {
|
|
|
324
324
|
seekByName: o
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
|
-
const
|
|
327
|
+
const mt = /^on[^a-z]/, vt = (e) => mt.test(e);
|
|
328
328
|
let oe = null;
|
|
329
329
|
const ie = {
|
|
330
330
|
GEOMETRY_VIA_PROP: "tres__geometryViaProp",
|
|
331
331
|
MATERIAL_VIA_PROP: "tres__materialViaProp"
|
|
332
|
-
}, { logError: se } =
|
|
332
|
+
}, { logError: se } = D(), gt = {
|
|
333
333
|
createElement(e, t, o, a) {
|
|
334
|
-
var
|
|
335
|
-
if (a || (a = {}), a.args || (a.args = []), e === "template" ||
|
|
334
|
+
var s, l;
|
|
335
|
+
if (a || (a = {}), a.args || (a.args = []), e === "template" || it(e))
|
|
336
336
|
return null;
|
|
337
337
|
let n = e.replace("Tres", ""), r;
|
|
338
338
|
if (e === "primitive") {
|
|
339
339
|
(a == null ? void 0 : a.object) === void 0 && se("Tres primitives need a prop 'object'");
|
|
340
|
-
const
|
|
341
|
-
n =
|
|
340
|
+
const u = a.object;
|
|
341
|
+
n = u.type, r = Object.assign(u, { type: n, attach: a.attach, primitive: !0 });
|
|
342
342
|
} else {
|
|
343
|
-
const
|
|
344
|
-
|
|
343
|
+
const u = we.value[n];
|
|
344
|
+
u || se(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), r = new u(...a.args);
|
|
345
345
|
}
|
|
346
346
|
if (r.isCamera) {
|
|
347
347
|
a != null && a.position || r.position.set(3, 3, 3), a != null && a.lookAt || r.lookAt(0, 0, 0);
|
|
348
|
-
const { pushCamera:
|
|
349
|
-
|
|
348
|
+
const { pushCamera: u } = ye();
|
|
349
|
+
u(r);
|
|
350
350
|
}
|
|
351
351
|
(a == null ? void 0 : a.attach) === void 0 && (r.isMaterial ? r.attach = "material" : r.isBufferGeometry && (r.attach = "geometry"));
|
|
352
|
-
const { GEOMETRY_VIA_PROP:
|
|
353
|
-
return r.isObject3D && ((
|
|
352
|
+
const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ie;
|
|
353
|
+
return r.isObject3D && ((s = a == null ? void 0 : a.material) != null && s.isMaterial && (r.userData[i] = !0), (l = a == null ? void 0 : a.geometry) != null && l.isBufferGeometry && (r.userData[c] = !0)), r.events = {}, r;
|
|
354
354
|
},
|
|
355
355
|
insert(e, t) {
|
|
356
356
|
var o, a;
|
|
@@ -365,9 +365,9 @@ const ie = {
|
|
|
365
365
|
if (e) {
|
|
366
366
|
if (e.isObject3D) {
|
|
367
367
|
const a = e, n = (r) => {
|
|
368
|
-
var
|
|
369
|
-
const { GEOMETRY_VIA_PROP:
|
|
370
|
-
r.userData[i] || (
|
|
368
|
+
var s, l;
|
|
369
|
+
const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ie;
|
|
370
|
+
r.userData[i] || (s = r.material) == null || s.dispose(), r.userData[c] || (l = r.geometry) == null || l.dispose();
|
|
371
371
|
};
|
|
372
372
|
a.traverse((r) => n(r)), n(a);
|
|
373
373
|
}
|
|
@@ -376,25 +376,25 @@ const ie = {
|
|
|
376
376
|
},
|
|
377
377
|
patchProp(e, t, o, a) {
|
|
378
378
|
if (e) {
|
|
379
|
-
let n = e, r = t,
|
|
379
|
+
let n = e, r = t, c = F(r), i = n == null ? void 0 : n[c];
|
|
380
380
|
if (n.type === "BufferGeometry") {
|
|
381
381
|
n.setAttribute(
|
|
382
|
-
|
|
383
|
-
new
|
|
382
|
+
F(r),
|
|
383
|
+
new Ne(...a)
|
|
384
384
|
);
|
|
385
385
|
return;
|
|
386
386
|
}
|
|
387
387
|
if (r.includes("-") && i === void 0) {
|
|
388
|
-
const
|
|
389
|
-
i =
|
|
388
|
+
const l = r.split("-");
|
|
389
|
+
i = l.reduce((u, p) => u[F(p)], n), r = l.pop(), c = r.toLowerCase(), i != null && i.set || (n = l.reduce((u, p) => u[F(p)], n));
|
|
390
390
|
}
|
|
391
|
-
|
|
392
|
-
let
|
|
393
|
-
if (
|
|
394
|
-
Array.isArray(
|
|
391
|
+
vt(r) && (e.events[r] = a);
|
|
392
|
+
let s = a;
|
|
393
|
+
if (s === "" && (s = !0), ne(i)) {
|
|
394
|
+
Array.isArray(s) ? e[c](...s) : e[c](s);
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
|
-
!(i != null && i.set) && !ne(i) ? n[
|
|
397
|
+
!(i != null && i.set) && !ne(i) ? n[c] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
|
|
398
398
|
}
|
|
399
399
|
},
|
|
400
400
|
parentNode(e) {
|
|
@@ -409,15 +409,15 @@ const ie = {
|
|
|
409
409
|
setScopeId: () => void 0,
|
|
410
410
|
cloneNode: () => void 0,
|
|
411
411
|
insertStaticContent: () => void 0
|
|
412
|
-
}, { createApp:
|
|
413
|
-
const t =
|
|
412
|
+
}, { createApp: ht } = je(gt), wt = (e) => {
|
|
413
|
+
const t = ht(o);
|
|
414
414
|
function o() {
|
|
415
415
|
return e && e.default ? e.default() : [];
|
|
416
416
|
}
|
|
417
417
|
return t;
|
|
418
418
|
};
|
|
419
|
-
|
|
420
|
-
const { logWarning:
|
|
419
|
+
be(ge);
|
|
420
|
+
const { logWarning: ce } = D(), bt = ve({
|
|
421
421
|
name: "TresScene",
|
|
422
422
|
props: [
|
|
423
423
|
"shadows",
|
|
@@ -436,39 +436,39 @@ const { logWarning: ht } = I(), wt = me({
|
|
|
436
436
|
"disableRender"
|
|
437
437
|
],
|
|
438
438
|
setup(e, { slots: t, expose: o }) {
|
|
439
|
-
e.physicallyCorrectLights === !0 &&
|
|
440
|
-
const a =
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
i(
|
|
444
|
-
|
|
445
|
-
}),
|
|
446
|
-
|
|
439
|
+
e.physicallyCorrectLights === !0 && ce("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
|
|
440
|
+
const a = P(), n = P(), r = new ge.Scene(), { setState: c } = j();
|
|
441
|
+
c("scene", r), c("canvas", n), c("container", a);
|
|
442
|
+
const i = P(), s = t && t.default && t.default();
|
|
443
|
+
(s == null ? void 0 : s.length) > 0 && (i.value = s.some((d) => ut(d.type) && d.type.includes("Camera")), i.value || ce("No camera found in the scene, please add one!")), De(() => {
|
|
444
|
+
l();
|
|
445
|
+
}), me(() => {
|
|
446
|
+
c("renderer", null);
|
|
447
447
|
});
|
|
448
|
-
function
|
|
449
|
-
const { renderer:
|
|
450
|
-
let
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}),
|
|
454
|
-
var
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
|
|
448
|
+
function l() {
|
|
449
|
+
const { renderer: d } = ct(e), { activeCamera: w } = ye(), { onLoop: M } = Ee(), { raycaster: x, pointer: L } = pt();
|
|
450
|
+
let b = null, v = null;
|
|
451
|
+
ue(() => {
|
|
452
|
+
w.value && x.value.setFromCamera(L.value, w.value);
|
|
453
|
+
}), M(() => {
|
|
454
|
+
var E, y, g, C, I, h, T, S, R, B;
|
|
455
|
+
if (w.value && e.disableRender !== !0 && e.disableRender !== "" && ((E = d.value) == null || E.render(r, w.value)), x.value) {
|
|
456
|
+
const z = x.value.intersectObjects(r.children);
|
|
457
|
+
z.length > 0 ? (v = z[0], b === null && ((C = (g = (y = v.object) == null ? void 0 : y.events) == null ? void 0 : g.onPointerEnter) == null || C.call(g, v)), (T = (h = (I = v.object) == null ? void 0 : I.events) == null ? void 0 : h.onPointerMove) == null || T.call(h, v)) : b !== null && ((B = (R = (S = v == null ? void 0 : v.object) == null ? void 0 : S.events) == null ? void 0 : R.onPointerLeave) == null || B.call(R, b), v = null), b = v;
|
|
458
458
|
}
|
|
459
|
-
}),
|
|
460
|
-
var
|
|
461
|
-
|
|
459
|
+
}), Qe(n.value, "click", () => {
|
|
460
|
+
var E, y, g;
|
|
461
|
+
v !== null && ((g = (y = (E = v.object) == null ? void 0 : E.events) == null ? void 0 : y.onClick) == null || g.call(y, v));
|
|
462
462
|
});
|
|
463
463
|
}
|
|
464
464
|
let u;
|
|
465
|
-
function
|
|
466
|
-
u =
|
|
465
|
+
function p() {
|
|
466
|
+
u = wt(t), u.provide("useTres", j()), u.provide("extend", be), u.mount(r);
|
|
467
467
|
}
|
|
468
|
-
return
|
|
468
|
+
return p(), o({
|
|
469
469
|
scene: r
|
|
470
|
-
}), () =>
|
|
471
|
-
|
|
470
|
+
}), () => O(
|
|
471
|
+
O(
|
|
472
472
|
"div",
|
|
473
473
|
{
|
|
474
474
|
ref: a,
|
|
@@ -483,7 +483,7 @@ const { logWarning: ht } = I(), wt = me({
|
|
|
483
483
|
}
|
|
484
484
|
},
|
|
485
485
|
[
|
|
486
|
-
|
|
486
|
+
O(
|
|
487
487
|
"div",
|
|
488
488
|
{
|
|
489
489
|
style: {
|
|
@@ -492,7 +492,7 @@ const { logWarning: ht } = I(), wt = me({
|
|
|
492
492
|
}
|
|
493
493
|
},
|
|
494
494
|
[
|
|
495
|
-
|
|
495
|
+
O("canvas", {
|
|
496
496
|
ref: n,
|
|
497
497
|
"data-scene": r.uuid,
|
|
498
498
|
style: {
|
|
@@ -510,7 +510,7 @@ const { logWarning: ht } = I(), wt = me({
|
|
|
510
510
|
)
|
|
511
511
|
);
|
|
512
512
|
}
|
|
513
|
-
}),
|
|
513
|
+
}), yt = ve({
|
|
514
514
|
name: "TresCanvas",
|
|
515
515
|
props: [
|
|
516
516
|
"shadows",
|
|
@@ -529,30 +529,30 @@ const { logWarning: ht } = I(), wt = me({
|
|
|
529
529
|
"disableRender"
|
|
530
530
|
],
|
|
531
531
|
setup(e, { slots: t, expose: o }) {
|
|
532
|
-
const a =
|
|
533
|
-
return o(a), () =>
|
|
532
|
+
const a = dt();
|
|
533
|
+
return o(a), () => O(bt, e, t);
|
|
534
534
|
}
|
|
535
|
-
}),
|
|
535
|
+
}), Tt = {
|
|
536
536
|
install(e) {
|
|
537
|
-
e.component("TresCanvas",
|
|
537
|
+
e.component("TresCanvas", yt);
|
|
538
538
|
}
|
|
539
539
|
};
|
|
540
540
|
export {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
541
|
+
Ze as CameraType,
|
|
542
|
+
yt as TresCanvas,
|
|
543
|
+
we as catalogue,
|
|
544
|
+
Tt as default,
|
|
545
|
+
be as extend,
|
|
546
|
+
Pt as isProd,
|
|
547
|
+
ft as trasverseObjects,
|
|
548
|
+
ye as useCamera,
|
|
549
|
+
Ct as useLoader,
|
|
550
|
+
D as useLogger,
|
|
551
|
+
pt as useRaycaster,
|
|
552
|
+
Ee as useRenderLoop,
|
|
553
|
+
ct as useRenderer,
|
|
554
|
+
Lt as useSeek,
|
|
555
555
|
Rt as useTexture,
|
|
556
|
-
|
|
557
|
-
|
|
556
|
+
j as useTres,
|
|
557
|
+
dt as useTresProvider
|
|
558
558
|
};
|
package/dist/tres.umd.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v2.0.0-beta.
|
|
3
|
+
* version: v2.0.0-beta.9
|
|
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
|
-
(function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("three"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","three","@vueuse/core"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.tres={},d.Vue,d.Three,d.VueUseCore))})(this,function(d,s,
|
|
9
|
-
You could set windowSize=true to force the canvas to be the size of the window.`);const de=()=>{t.value&&(t.value.setSize(x.value,B.value),t.value.setPixelRatio(Math.min(ue.value,2)))},me=()=>{if(!t.value)return;const D=c.resolveUnref(R);if(D){D in q||E("Renderer Preset must be one of these: "+Object.keys(q).join(", ")),H(t.value,q[D]);return}t.value.shadowMap.enabled=c.resolveUnref(w),t.value.shadowMap.type=c.resolveUnref(v),t.value.toneMapping=c.resolveUnref(M)||u.NoToneMapping,t.value.toneMappingExposure=c.resolveUnref(g),t.value.outputEncoding=c.resolveUnref(T)||u.LinearEncoding,L!=null&&L.value&&t.value.setClearColor(Me(c.resolveUnref(L))),t.value.useLegacyLights=c.resolveUnref(b)},Ge=()=>{const D=c.unrefElement(y.canvas);D&&(t.value=new u.WebGLRenderer({canvas:D,alpha:c.resolveUnref(n),antialias:c.resolveUnref(a),context:c.resolveUnref(_),depth:c.resolveUnref(o),failIfMajorPerformanceCaveat:c.resolveUnref(i),logarithmicDepthBuffer:c.resolveUnref(f),powerPreference:c.resolveUnref(C),precision:c.resolveUnref(l),stencil:c.resolveUnref(p),preserveDrawingBuffer:c.resolveUnref(P),premultipliedAlpha:c.resolveUnref(m)}),j("renderer",t.value),j("clock",new u.Clock),j("aspectRatio",K),me(),de(),Fe(),r.value=!0)},Ve=()=>{t.value&&(t.value.dispose(),t.value=void 0,r.value=!1,ze())};return s.watch([K,ue],de),s.watch([w,v,T,b,M,g,L],me),s.watch(()=>[y.canvas,y.container],()=>{c.unrefElement(y.canvas)&&c.unrefElement(y.container)&&Ge()},{immediate:!0,deep:!0}),{renderer:t,isReady:r,dispose:Ve,aspectRatio:K}}const te=e=>!!e&&e.constructor===Array;function ne(e){const t={nodes:{},materials:{}};return e&&e.traverse(r=>{r.name&&(t.nodes[r.name]=r),r.material&&!t.materials[r.material.name]&&(t.materials[r.material.name]=r.material)}),t}async function Le(e,t,r,n,a){const{logError:o}=U(),f=new e;a&&a(f),r&&r(f);const l=(Array.isArray(t)?t:[t]).map(m=>new Promise((p,w)=>{f.load(m,v=>{v.scene&&Object.assign(v,ne(v.scene)),p(v)},n,v=>w(o("[useLoader] - Failed to load resource",v)))}));return te(t)?await Promise.all(l):await l[0]}async function _e(e){const t=new u.LoadingManager,r=new u.TextureLoader(t),n=a=>new Promise((o,f)=>{r.load(a,i=>o(i),()=>null,()=>{f(new Error("[useTextures] - Failed to load texture"))})});if(te(e)){const a=await Promise.all(e.map(o=>n(o)));return e.length>1?a:a[0]}else{const{map:a,displacementMap:o,normalMap:f,roughnessMap:i,metalnessMap:l,aoMap:m,alphaMap:p,matcap:w}=e;return{map:a?await n(a):null,displacementMap:o?await n(o):null,normalMap:f?await n(f):null,roughnessMap:i?await n(i):null,metalnessMap:l?await n(l):null,aoMap:m?await n(m):null,alphaMap:p?await n(p):null,matcap:w?await n(w):null}}}const h=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function Se(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(h[e&255]+h[e>>8&255]+h[e>>16&255]+h[e>>24&255]+"-"+h[t&255]+h[t>>8&255]+"-"+h[t>>16&15|64]+h[t>>24&255]+"-"+h[r&63|128]+h[r>>8&255]+"-"+h[r>>16&255]+h[r>>24&255]+h[n&255]+h[n>>8&255]+h[n>>16&255]+h[n>>24&255]).toLowerCase()}const ae=Symbol();function re(){const e=s.shallowReactive({uuid:Se(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:s.computed(()=>window.innerWidth/window.innerHeight)});function t(a){return e[a]}function r(a,o){e[a]=o}const n={state:e,...s.toRefs(e),getState:t,setState:r};return s.provide(ae,n),n}const A=()=>s.inject(ae,{state:s.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})});function oe(){var f;const e=s.shallowRef(new u.Raycaster),t=s.ref(new u.Vector2),r=s.ref(null),{setState:n,state:a}=A();n("raycaster",e.value),n("pointer",t),n("currentInstance",r);function o(i){t.value.x=i.clientX/window.innerWidth*2-1,t.value.y=-(i.clientY/window.innerHeight)*2+1}return(f=a==null?void 0:a.renderer)==null||f.domElement.addEventListener("pointermove",o),s.onUnmounted(()=>{var i;(i=a==null?void 0:a.renderer)==null||i.domElement.removeEventListener("pointermove",o)}),{raycaster:e,pointer:t}}const xe=!0,ie="[TresJS ▲ ■ ●] ";function U(){function e(n,a){console.error(`${ie} ${n}`,a||"")}function t(n){console.warn(`${ie} ${n}`)}function r(n,a){}return{logError:e,logWarning:t,logMessage:r}}function Oe(){const{logWarning:e}=U();function t(n,a,o){let f=null;return n.traverse(i=>{i[a]===o&&(f=i)}),f||e(`Child with ${a} '${o}' not found.`),f}function r(n,a){return t(n,"name",a)}return{seek:t,seekByName:r}}const Ae=/^on[^a-z]/,Ue=e=>Ae.test(e);function We(e){}let se=null;const ce={GEOMETRY_VIA_PROP:"tres__geometryViaProp",MATERIAL_VIA_PROP:"tres__materialViaProp"},{logError:fe}=U(),ke={createElement(e,t,r,n){var l,m;if(n||(n={}),n.args||(n.args=[]),e==="template"||Ce(e))return null;let a=e.replace("Tres",""),o;if(e==="primitive"){(n==null?void 0:n.object)===void 0&&fe("Tres primitives need a prop 'object'");const p=n.object;a=p.type,o=Object.assign(p,{type:a,attach:n.attach,primitive:!0})}else{const p=W.value[a];p||fe(`${a} is not defined on the THREE namespace. Use extend to add it to the catalog.`),o=new p(...n.args)}if(o.isCamera){n!=null&&n.position||o.position.set(3,3,3),n!=null&&n.lookAt||o.lookAt(0,0,0);const{pushCamera:p}=z();p(o)}(n==null?void 0:n.attach)===void 0&&(o.isMaterial?o.attach="material":o.isBufferGeometry&&(o.attach="geometry"));const{GEOMETRY_VIA_PROP:f,MATERIAL_VIA_PROP:i}=ce;return o.isObject3D&&((l=n==null?void 0:n.material)!=null&&l.isMaterial&&(o.userData[i]=!0),(m=n==null?void 0:n.geometry)!=null&&m.isBufferGeometry&&(o.userData[f]=!0)),o.events={},o},insert(e,t){var r,n;if(((e==null?void 0:e.__vnode.type)==="TresGroup"||(e==null?void 0:e.__vnode.type)==="TresObject3D")&&t===null&&!((n=(r=e==null?void 0:e.__vnode)==null?void 0:r.ctx)!=null&&n.asyncResolved)){se=e;return}t||(t=se),e!=null&&e.isObject3D&&(t!=null&&t.isObject3D)?(t.add(e),e.dispatchEvent({type:"added"})):typeof(e==null?void 0:e.attach)=="string"&&(e.__previousAttach=e[t==null?void 0:t.attach],t&&(t[e.attach]=e))},remove(e){var t,r;if(e){if(e.isObject3D){const n=e,a=o=>{var l,m;const{GEOMETRY_VIA_PROP:f,MATERIAL_VIA_PROP:i}=ce;o.userData[i]||(l=o.material)==null||l.dispose(),o.userData[f]||(m=o.geometry)==null||m.dispose()};n.traverse(o=>a(o)),a(n)}(t=e.removeFromParent)==null||t.call(e),(r=e.dispose)==null||r.call(e)}},patchProp(e,t,r,n){if(e){let a=e,o=t,f=V(o),i=a==null?void 0:a[f];if(a.type==="BufferGeometry"){a.setAttribute(V(o),new u.BufferAttribute(...n));return}if(o.includes("-")&&i===void 0){const m=o.split("-");i=m.reduce((p,w)=>p[V(w)],a),o=m.pop(),f=o.toLowerCase(),i!=null&&i.set||(a=m.reduce((p,w)=>p[V(w)],a))}Ue(o)&&(e.events[o]=n);let l=n;if(l===""&&(l=!0),c.isFunction(i)){Array.isArray(l)?e[f](...l):e[f](l);return}!(i!=null&&i.set)&&!c.isFunction(i)?a[f]=l:i.constructor===l.constructor&&(i!=null&&i.copy)?i==null||i.copy(l):Array.isArray(l)?i.set(...l):!i.isColor&&i.setScalar?i.setScalar(l):i.set(l)}},parentNode(e){return(e==null?void 0:e.parent)||null},createText:()=>void 0,createComment:()=>void 0,setText:()=>void 0,setElementText:()=>void 0,nextSibling:()=>void 0,querySelector:()=>void 0,setScopeId:()=>void 0,cloneNode:()=>void 0,insertStaticContent:()=>void 0},{createApp:Te}=s.createRenderer(ke),Re=e=>{const t=Te(r);function r(){return e&&e.default?e.default():[]}return t};N(J);const{logWarning:je}=U(),De=s.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender"],setup(e,{slots:t,expose:r}){e.physicallyCorrectLights===!0&&je("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const n=s.ref(),a=s.ref(),o=new J.Scene,{setState:f}=A();f("scene",o),f("canvas",a),f("container",n);const{pushCamera:i}=z();i(new u.PerspectiveCamera),s.onMounted(()=>{l()}),s.onUnmounted(()=>{f("renderer",null)});function l(){const{renderer:w}=ee(e),{activeCamera:v}=z(),{onLoop:k}=$(),{raycaster:b,pointer:T}=oe();let M=null,g=null;s.watchEffect(()=>{v.value&&b.value.setFromCamera(T.value,v.value)}),k(()=>{var _,C,P,L,S,R,y,j,x,B;if(v.value&&e.disableRender===!0&&((_=w.value)==null||_.render(o,v.value)),b.value){const E=b.value.intersectObjects(o.children);E.length>0?(g=E[0],M===null&&((L=(P=(C=g.object)==null?void 0:C.events)==null?void 0:P.onPointerEnter)==null||L.call(P,g)),(y=(R=(S=g.object)==null?void 0:S.events)==null?void 0:R.onPointerMove)==null||y.call(R,g)):M!==null&&((B=(x=(j=g==null?void 0:g.object)==null?void 0:j.events)==null?void 0:x.onPointerLeave)==null||B.call(x,M),g=null),M=g}}),c.useEventListener(a.value,"click",()=>{var _,C,P;g!==null&&((P=(C=(_=g.object)==null?void 0:_.events)==null?void 0:C.onClick)==null||P.call(C,g))})}let m;function p(){m=Re(t),m.provide("useTres",A()),m.provide("extend",N),m.mount(o)}return p(),r({scene:o}),()=>s.h(s.h("div",{ref:n,"data-scene":o.uuid,key:o.uuid,style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto",touchAction:"none"}},[s.h("div",{style:{width:"100%",height:"100%"}},[s.h("canvas",{ref:a,"data-scene":o.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),le=s.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender"],setup(e,{slots:t,expose:r}){const n=re();return r(n),()=>s.h(De,e,t)}}),Ie={install(e){e.component("TresCanvas",le)}};d.CameraType=X,d.TresCanvas=le,d.catalogue=W,d.default=Ie,d.extend=N,d.isProd=xe,d.trasverseObjects=ne,d.useCamera=z,d.useLoader=Le,d.useLogger=U,d.useRaycaster=oe,d.useRenderLoop=$,d.useRenderer=ee,d.useSeek=Oe,d.useTexture=_e,d.useTres=A,d.useTresProvider=re,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
8
|
+
(function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue"),require("three"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","three","@vueuse/core"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.tres={},d.Vue,d.Three,d.VueUseCore))})(this,function(d,s,m,f){"use strict";function be(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const X=be(m),W=s.ref({uuid:m.MathUtils.generateUUID()}),N=e=>void Object.assign(W.value,e);var Q=(e=>(e.Perspective="Perspective",e.Orthographic="Orthographic",e))(Q||{});const we=45;let O;function Y(){const{state:e,setState:t,aspectRatio:r}=T();function n(i="Perspective",c){var p,u,h;if(i==="Perspective"){const{near:v,far:M,fov:L}=c||{near:.1,far:1e3,fov:we};O=new m.PerspectiveCamera(L,((p=e.aspectRatio)==null?void 0:p.value)||window.innerWidth/window.innerHeight,v,M),(u=e.cameras)==null||u.push(O)}else{const{left:v,right:M,top:L,bottom:_,near:k,far:C}=c||{left:-100,right:100,top:100,bottom:-100,near:.1,far:1e3};O=new m.OrthographicCamera(v,M,L,_,k,C),(h=e.cameras)==null||h.push(O)}return e.camera=O,t("camera",e.camera),O}function a(){var i;e.camera instanceof m.PerspectiveCamera&&e.aspectRatio&&(e.camera.aspect=e.aspectRatio.value),(i=e.camera)==null||i.updateProjectionMatrix()}function o(i){var c;(c=e.cameras)==null||c.push(i),i instanceof m.PerspectiveCamera&&e.aspectRatio&&(i.aspect=e.aspectRatio.value),i.updateProjectionMatrix(),t("camera",i)}function l(){e.cameras=[]}return s.watchEffect(()=>{r!=null&&r.value&&a()}),{activeCamera:s.toRef(e,"camera"),createCamera:n,updateCamera:a,pushCamera:o,clearCameras:l}}const Z=f.createEventHook(),H=f.createEventHook(),$=f.createEventHook(),D=new m.Clock;let B=0,z=0;const{pause:ye,resume:Me,isActive:Ce}=f.useRafFn(()=>{Z.trigger({delta:B,elapsed:z,clock:D}),H.trigger({delta:B,elapsed:z,clock:D}),$.trigger({delta:B,elapsed:z,clock:D})},{immediate:!1});$.on(()=>{B=D.getDelta(),z=D.getElapsedTime()});function q(){return{onBeforeLoop:Z.on,onLoop:H.on,onAfterLoop:$.on,pause:ye,resume:Me,isActive:Ce}}function Pe(e){return e instanceof m.Color?e:Array.isArray(e)?new m.Color(...e):new m.Color(e)}const K={realistic:{outputEncoding:m.sRGBEncoding,toneMapping:m.ACESFilmicToneMapping,toneMappingExposure:3,shadowMap:{enabled:!0,type:m.PCFSoftShadowMap}}},ee=(e,t)=>{for(const r of Object.keys(t))t[r]instanceof Object&&Object.assign(t[r],ee(e[r],t[r]));return Object.assign(e||{},t),e},Le=_e("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");function E(e){return e.replace(/-([a-z])/g,(t,r)=>r.toUpperCase())}function _e(e,t){const r=Object.create(null),n=e.split(",");for(let a=0;a<n.length;a++)r[n[a]]=!0;return t?a=>!!r[a.toLowerCase()]:a=>!!r[a]}function te(e){var ge,he;const t=s.shallowRef(),r=s.ref(!1),{alpha:n=!0,antialias:a=!0,depth:o,logarithmicDepthBuffer:l,failIfMajorPerformanceCaveat:i,precision:c,premultipliedAlpha:p,stencil:u,shadows:h=!1,shadowMapType:v=m.PCFShadowMap,physicallyCorrectLights:M=!1,useLegacyLights:L=!1,outputEncoding:_=m.LinearEncoding,toneMapping:k=m.NoToneMapping,toneMappingExposure:C=1,context:b=void 0,powerPreference:S="default",preserveDrawingBuffer:P=!1,clearColor:w,windowSize:x=!1,preset:F=void 0}=s.toRefs(e),{state:y,setState:R}=T(),{width:I,height:A}=f.resolveUnref(x)==!0||f.resolveUnref(x)===""||f.resolveUnref(x)==="true"?f.useWindowSize():f.useElementSize(y.container),{logError:G,logWarning:V}=U(),{pixelRatio:me}=f.useDevicePixelRatio(),{pause:Ee,resume:Fe}=q(),J=s.computed(()=>I.value/A.value);!f.resolveUnref(x)&&((he=(ge=y.container)==null?void 0:ge.value)==null?void 0:he.offsetHeight)===0&&V(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
|
|
9
|
+
You could set windowSize=true to force the canvas to be the size of the window.`);const pe=()=>{t.value&&(t.value.setSize(I.value,A.value),t.value.setPixelRatio(Math.min(me.value,2)))},ve=()=>{if(!t.value)return;const j=f.resolveUnref(F);if(j){j in K||G("Renderer Preset must be one of these: "+Object.keys(K).join(", ")),ee(t.value,K[j]);return}t.value.shadowMap.enabled=f.resolveUnref(h),t.value.shadowMap.type=f.resolveUnref(v),t.value.toneMapping=f.resolveUnref(k)||m.NoToneMapping,t.value.toneMappingExposure=f.resolveUnref(C),t.value.outputEncoding=f.resolveUnref(_)||m.LinearEncoding,w!=null&&w.value&&t.value.setClearColor(Pe(f.resolveUnref(w))),t.value.useLegacyLights=f.resolveUnref(L)},Ge=()=>{const j=f.unrefElement(y.canvas);j&&(t.value=new m.WebGLRenderer({canvas:j,alpha:f.resolveUnref(n),antialias:f.resolveUnref(a),context:f.resolveUnref(b),depth:f.resolveUnref(o),failIfMajorPerformanceCaveat:f.resolveUnref(i),logarithmicDepthBuffer:f.resolveUnref(l),powerPreference:f.resolveUnref(S),precision:f.resolveUnref(c),stencil:f.resolveUnref(u),preserveDrawingBuffer:f.resolveUnref(P),premultipliedAlpha:f.resolveUnref(p)}),R("renderer",t.value),R("clock",new m.Clock),R("aspectRatio",J),ve(),pe(),Fe(),r.value=!0)},Ve=()=>{t.value&&(t.value.dispose(),t.value=void 0,r.value=!1,Ee())};return s.watch([J,me],pe),s.watch([h,v,_,L,k,C,w],ve),s.watch(()=>[y.canvas,y.container],()=>{f.unrefElement(y.canvas)&&f.unrefElement(y.container)&&Ge()},{immediate:!0,deep:!0}),{renderer:t,isReady:r,dispose:Ve,aspectRatio:J}}const Se=e=>typeof e=="string",ne=e=>!!e&&e.constructor===Array;function ae(e){const t={nodes:{},materials:{}};return e&&e.traverse(r=>{r.name&&(t.nodes[r.name]=r),r.material&&!t.materials[r.material.name]&&(t.materials[r.material.name]=r.material)}),t}async function xe(e,t,r,n,a){const{logError:o}=U(),l=new e;a&&a(l),r&&r(l);const c=(Array.isArray(t)?t:[t]).map(p=>new Promise((u,h)=>{l.load(p,v=>{v.scene&&Object.assign(v,ae(v.scene)),u(v)},n,v=>h(o("[useLoader] - Failed to load resource",v)))}));return ne(t)?await Promise.all(c):await c[0]}async function Ae(e){const t=new m.LoadingManager,r=new m.TextureLoader(t),n=a=>new Promise((o,l)=>{r.load(a,i=>o(i),()=>null,()=>{l(new Error("[useTextures] - Failed to load texture"))})});if(ne(e)){const a=await Promise.all(e.map(o=>n(o)));return e.length>1?a:a[0]}else{const{map:a,displacementMap:o,normalMap:l,roughnessMap:i,metalnessMap:c,aoMap:p,alphaMap:u,matcap:h}=e;return{map:a?await n(a):null,displacementMap:o?await n(o):null,normalMap:l?await n(l):null,roughnessMap:i?await n(i):null,metalnessMap:c?await n(c):null,aoMap:p?await n(p):null,alphaMap:u?await n(u):null,matcap:h?await n(h):null}}}const g=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function Oe(){const e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(g[e&255]+g[e>>8&255]+g[e>>16&255]+g[e>>24&255]+"-"+g[t&255]+g[t>>8&255]+"-"+g[t>>16&15|64]+g[t>>24&255]+"-"+g[r&63|128]+g[r>>8&255]+"-"+g[r>>16&255]+g[r>>24&255]+g[n&255]+g[n>>8&255]+g[n>>16&255]+g[n>>24&255]).toLowerCase()}const re=Symbol();function oe(){const e=s.shallowReactive({uuid:Oe(),camera:void 0,cameras:[],scene:void 0,renderer:void 0,aspectRatio:s.computed(()=>window.innerWidth/window.innerHeight)});function t(a){return e[a]}function r(a,o){e[a]=o}const n={state:e,...s.toRefs(e),getState:t,setState:r};return s.provide(re,n),n}const T=()=>s.inject(re,{state:s.shallowReactive({camera:void 0,cameras:[],scene:void 0,renderer:void 0})});function ie(){var l;const e=s.shallowRef(new m.Raycaster),t=s.ref(new m.Vector2),r=s.ref(null),{setState:n,state:a}=T();n("raycaster",e.value),n("pointer",t),n("currentInstance",r);function o(i){t.value.x=i.clientX/window.innerWidth*2-1,t.value.y=-(i.clientY/window.innerHeight)*2+1}return(l=a==null?void 0:a.renderer)==null||l.domElement.addEventListener("pointermove",o),s.onUnmounted(()=>{var i;(i=a==null?void 0:a.renderer)==null||i.domElement.removeEventListener("pointermove",o)}),{raycaster:e,pointer:t}}const Te=!0,se="[TresJS ▲ ■ ●] ";function U(){function e(n,a){console.error(`${se} ${n}`,a||"")}function t(n){console.warn(`${se} ${n}`)}function r(n,a){}return{logError:e,logWarning:t,logMessage:r}}function Ue(){const{logWarning:e}=U();function t(n,a,o){let l=null;return n.traverse(i=>{i[a]===o&&(l=i)}),l||e(`Child with ${a} '${o}' not found.`),l}function r(n,a){return t(n,"name",a)}return{seek:t,seekByName:r}}const ke=/^on[^a-z]/,Re=e=>ke.test(e);function Ne(e){}let ce=null;const fe={GEOMETRY_VIA_PROP:"tres__geometryViaProp",MATERIAL_VIA_PROP:"tres__materialViaProp"},{logError:le}=U(),je={createElement(e,t,r,n){var c,p;if(n||(n={}),n.args||(n.args=[]),e==="template"||Le(e))return null;let a=e.replace("Tres",""),o;if(e==="primitive"){(n==null?void 0:n.object)===void 0&&le("Tres primitives need a prop 'object'");const u=n.object;a=u.type,o=Object.assign(u,{type:a,attach:n.attach,primitive:!0})}else{const u=W.value[a];u||le(`${a} is not defined on the THREE namespace. Use extend to add it to the catalog.`),o=new u(...n.args)}if(o.isCamera){n!=null&&n.position||o.position.set(3,3,3),n!=null&&n.lookAt||o.lookAt(0,0,0);const{pushCamera:u}=Y();u(o)}(n==null?void 0:n.attach)===void 0&&(o.isMaterial?o.attach="material":o.isBufferGeometry&&(o.attach="geometry"));const{GEOMETRY_VIA_PROP:l,MATERIAL_VIA_PROP:i}=fe;return o.isObject3D&&((c=n==null?void 0:n.material)!=null&&c.isMaterial&&(o.userData[i]=!0),(p=n==null?void 0:n.geometry)!=null&&p.isBufferGeometry&&(o.userData[l]=!0)),o.events={},o},insert(e,t){var r,n;if(((e==null?void 0:e.__vnode.type)==="TresGroup"||(e==null?void 0:e.__vnode.type)==="TresObject3D")&&t===null&&!((n=(r=e==null?void 0:e.__vnode)==null?void 0:r.ctx)!=null&&n.asyncResolved)){ce=e;return}t||(t=ce),e!=null&&e.isObject3D&&(t!=null&&t.isObject3D)?(t.add(e),e.dispatchEvent({type:"added"})):typeof(e==null?void 0:e.attach)=="string"&&(e.__previousAttach=e[t==null?void 0:t.attach],t&&(t[e.attach]=e))},remove(e){var t,r;if(e){if(e.isObject3D){const n=e,a=o=>{var c,p;const{GEOMETRY_VIA_PROP:l,MATERIAL_VIA_PROP:i}=fe;o.userData[i]||(c=o.material)==null||c.dispose(),o.userData[l]||(p=o.geometry)==null||p.dispose()};n.traverse(o=>a(o)),a(n)}(t=e.removeFromParent)==null||t.call(e),(r=e.dispose)==null||r.call(e)}},patchProp(e,t,r,n){if(e){let a=e,o=t,l=E(o),i=a==null?void 0:a[l];if(a.type==="BufferGeometry"){a.setAttribute(E(o),new m.BufferAttribute(...n));return}if(o.includes("-")&&i===void 0){const p=o.split("-");i=p.reduce((u,h)=>u[E(h)],a),o=p.pop(),l=o.toLowerCase(),i!=null&&i.set||(a=p.reduce((u,h)=>u[E(h)],a))}Re(o)&&(e.events[o]=n);let c=n;if(c===""&&(c=!0),f.isFunction(i)){Array.isArray(c)?e[l](...c):e[l](c);return}!(i!=null&&i.set)&&!f.isFunction(i)?a[l]=c:i.constructor===c.constructor&&(i!=null&&i.copy)?i==null||i.copy(c):Array.isArray(c)?i.set(...c):!i.isColor&&i.setScalar?i.setScalar(c):i.set(c)}},parentNode(e){return(e==null?void 0:e.parent)||null},createText:()=>void 0,createComment:()=>void 0,setText:()=>void 0,setElementText:()=>void 0,nextSibling:()=>void 0,querySelector:()=>void 0,setScopeId:()=>void 0,cloneNode:()=>void 0,insertStaticContent:()=>void 0},{createApp:De}=s.createRenderer(je),Ie=e=>{const t=De(r);function r(){return e&&e.default?e.default():[]}return t};N(X);const{logWarning:ue}=U(),Be=s.defineComponent({name:"TresScene",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender"],setup(e,{slots:t,expose:r}){e.physicallyCorrectLights===!0&&ue("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");const n=s.ref(),a=s.ref(),o=new X.Scene,{setState:l}=T();l("scene",o),l("canvas",a),l("container",n);const i=s.ref(),c=t&&t.default&&t.default();(c==null?void 0:c.length)>0&&(i.value=c.some(v=>Se(v.type)&&v.type.includes("Camera")),i.value||ue("No camera found in the scene, please add one!")),s.onMounted(()=>{p()}),s.onUnmounted(()=>{l("renderer",null)});function p(){const{renderer:v}=te(e),{activeCamera:M}=Y(),{onLoop:L}=q(),{raycaster:_,pointer:k}=ie();let C=null,b=null;s.watchEffect(()=>{M.value&&_.value.setFromCamera(k.value,M.value)}),L(()=>{var S,P,w,x,F,y,R,I,A,G;if(M.value&&e.disableRender!==!0&&e.disableRender!==""&&((S=v.value)==null||S.render(o,M.value)),_.value){const V=_.value.intersectObjects(o.children);V.length>0?(b=V[0],C===null&&((x=(w=(P=b.object)==null?void 0:P.events)==null?void 0:w.onPointerEnter)==null||x.call(w,b)),(R=(y=(F=b.object)==null?void 0:F.events)==null?void 0:y.onPointerMove)==null||R.call(y,b)):C!==null&&((G=(A=(I=b==null?void 0:b.object)==null?void 0:I.events)==null?void 0:A.onPointerLeave)==null||G.call(A,C),b=null),C=b}}),f.useEventListener(a.value,"click",()=>{var S,P,w;b!==null&&((w=(P=(S=b.object)==null?void 0:S.events)==null?void 0:P.onClick)==null||w.call(P,b))})}let u;function h(){u=Ie(t),u.provide("useTres",T()),u.provide("extend",N),u.mount(o)}return h(),r({scene:o}),()=>s.h(s.h("div",{ref:n,"data-scene":o.uuid,key:o.uuid,style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto",touchAction:"none"}},[s.h("div",{style:{width:"100%",height:"100%"}},[s.h("canvas",{ref:a,"data-scene":o.uuid,style:{display:"block",width:"100%",height:"100%",position:e.windowSize?"fixed":"absolute",top:0,left:0}})])]))}}),de=s.defineComponent({name:"TresCanvas",props:["shadows","shadowMapType","physicallyCorrectLights","useLegacyLights","outputEncoding","toneMapping","toneMappingExposure","context","powerPreference","preserveDrawingBuffer","clearColor","windowSize","preset","disableRender"],setup(e,{slots:t,expose:r}){const n=oe();return r(n),()=>s.h(Be,e,t)}}),ze={install(e){e.component("TresCanvas",de)}};d.CameraType=Q,d.TresCanvas=de,d.catalogue=W,d.default=ze,d.extend=N,d.isProd=Te,d.trasverseObjects=ae,d.useCamera=Y,d.useLoader=xe,d.useLogger=U,d.useRaycaster=ie,d.useRenderLoop=q,d.useRenderer=te,d.useSeek=Ue,d.useTexture=Ae,d.useTres=T,d.useTresProvider=oe,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/core",
|
|
3
3
|
"description": "Declarative ThreeJS using Vue Components",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
7
|
"files": [
|