@tresjs/core 4.0.1 → 4.0.2
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 +823 -809
- package/dist/tres.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/tres.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v4.0.
|
|
3
|
+
* version: v4.0.2
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
import { ref as
|
|
12
|
-
import * as
|
|
13
|
-
import { PerspectiveCamera as
|
|
14
|
-
import { createEventHook as
|
|
15
|
-
const
|
|
8
|
+
var at = Object.defineProperty;
|
|
9
|
+
var lt = (e, t, r) => t in e ? at(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
10
|
+
var ie = (e, t, r) => (lt(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
11
|
+
import { ref as L, computed as D, watchEffect as ge, onUnmounted as N, shallowRef as H, watch as G, reactive as ze, readonly as ce, unref as W, provide as fe, inject as ut, defineComponent as xe, useSlots as ct, getCurrentInstance as Te, onMounted as ft, openBlock as dt, createElementBlock as pt, normalizeClass as mt, normalizeStyle as vt, createRenderer as gt, h as Ae, Fragment as ht } from "vue";
|
|
12
|
+
import * as Ge from "three";
|
|
13
|
+
import { PerspectiveCamera as de, Camera as yt, Clock as Ve, Vector3 as he, Color as re, Scene as qe, MeshBasicMaterial as Ye, DoubleSide as bt, REVISION as wt, SRGBColorSpace as Mt, ACESFilmicToneMapping as Je, PCFSoftShadowMap as Pt, NoToneMapping as _t, WebGLRenderer as ae, TextureLoader as Ct, Vector2 as le, MathUtils as Et, Raycaster as kt, BufferAttribute as St, Object3D as xt, Line as Tt, BufferGeometry as Oe, Float32BufferAttribute as Le, LineBasicMaterial as At, Mesh as Ot, BackSide as Lt, DirectionalLightHelper as Dt, PointLightHelper as Bt, SpotLightHelper as jt, HemisphereLightHelper as Rt, ArrowHelper as It } from "three";
|
|
14
|
+
import { createEventHook as O, useRafFn as Qe, toValue as S, unrefElement as Ht, useDevicePixelRatio as Ut, usePointer as $t, useElementBounding as Ft, useWindowSize as Wt, useElementSize as Nt, refDebounced as De, tryOnScopeDispose as zt, useFps as Gt, useMemory as Vt } from "@vueuse/core";
|
|
15
|
+
const qt = "@tresjs/core", Yt = "module", Jt = "4.0.2", Qt = "pnpm@9.1.4", Kt = "Declarative ThreeJS using Vue Components", Xt = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", Zt = "MIT", er = [
|
|
16
16
|
"vue",
|
|
17
17
|
"3d",
|
|
18
18
|
"threejs",
|
|
19
19
|
"three",
|
|
20
20
|
"threejs-vue"
|
|
21
|
-
],
|
|
21
|
+
], tr = !1, rr = {
|
|
22
22
|
".": {
|
|
23
23
|
types: "./dist/index.d.ts",
|
|
24
24
|
import: "./dist/tres.js",
|
|
@@ -37,12 +37,12 @@ const zt = "@tresjs/core", Gt = "module", Vt = "4.0.1", qt = "pnpm@9.1.4", Yt =
|
|
|
37
37
|
types: "./dist/src/utils/index.d.ts"
|
|
38
38
|
},
|
|
39
39
|
"./*": "./*"
|
|
40
|
-
},
|
|
40
|
+
}, nr = "./dist/tres.js", or = "./dist/tres.js", sr = "./dist/index.d.ts", ir = [
|
|
41
41
|
"*.d.ts",
|
|
42
42
|
"dist"
|
|
43
|
-
],
|
|
43
|
+
], ar = {
|
|
44
44
|
access: "public"
|
|
45
|
-
},
|
|
45
|
+
}, lr = {
|
|
46
46
|
dev: "cd playground && npm run dev",
|
|
47
47
|
build: "vite build",
|
|
48
48
|
playground: "cd playground && npm run dev",
|
|
@@ -59,14 +59,14 @@ const zt = "@tresjs/core", Gt = "module", Vt = "4.0.1", qt = "pnpm@9.1.4", Yt =
|
|
|
59
59
|
"docs:preview": "vitepress preview docs",
|
|
60
60
|
"docs:contributors": "esno scripts/update-contributors.ts",
|
|
61
61
|
prepare: "node .husky/install.mjs"
|
|
62
|
-
},
|
|
62
|
+
}, ur = {
|
|
63
63
|
three: ">=0.133",
|
|
64
64
|
vue: ">=3.4"
|
|
65
|
-
},
|
|
65
|
+
}, cr = {
|
|
66
66
|
"@alvarosabu/utils": "^3.2.0",
|
|
67
67
|
"@vue/devtools-api": "^6.6.2",
|
|
68
68
|
"@vueuse/core": "^10.10.0"
|
|
69
|
-
},
|
|
69
|
+
}, fr = {
|
|
70
70
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
71
71
|
"@stackblitz/sdk": "^1.10.0",
|
|
72
72
|
"@tresjs/cientos": "3.9.0",
|
|
@@ -106,310 +106,310 @@ const zt = "@tresjs/core", Gt = "module", Vt = "4.0.1", qt = "pnpm@9.1.4", Yt =
|
|
|
106
106
|
vitest: "^1.6.0",
|
|
107
107
|
vue: "^3.4.27",
|
|
108
108
|
"vue-demi": "^0.14.8"
|
|
109
|
-
},
|
|
110
|
-
name:
|
|
111
|
-
type:
|
|
112
|
-
version:
|
|
113
|
-
packageManager:
|
|
114
|
-
description:
|
|
115
|
-
author:
|
|
116
|
-
license:
|
|
117
|
-
keywords:
|
|
118
|
-
sideEffects:
|
|
119
|
-
exports:
|
|
120
|
-
main:
|
|
121
|
-
module:
|
|
122
|
-
types:
|
|
123
|
-
files:
|
|
124
|
-
publishConfig:
|
|
125
|
-
scripts:
|
|
126
|
-
peerDependencies:
|
|
127
|
-
dependencies:
|
|
128
|
-
devDependencies:
|
|
129
|
-
},
|
|
130
|
-
const t =
|
|
109
|
+
}, dr = {
|
|
110
|
+
name: qt,
|
|
111
|
+
type: Yt,
|
|
112
|
+
version: Jt,
|
|
113
|
+
packageManager: Qt,
|
|
114
|
+
description: Kt,
|
|
115
|
+
author: Xt,
|
|
116
|
+
license: Zt,
|
|
117
|
+
keywords: er,
|
|
118
|
+
sideEffects: tr,
|
|
119
|
+
exports: rr,
|
|
120
|
+
main: nr,
|
|
121
|
+
module: or,
|
|
122
|
+
types: sr,
|
|
123
|
+
files: ir,
|
|
124
|
+
publishConfig: ar,
|
|
125
|
+
scripts: lr,
|
|
126
|
+
peerDependencies: ur,
|
|
127
|
+
dependencies: cr,
|
|
128
|
+
devDependencies: fr
|
|
129
|
+
}, pr = ({ sizes: e }) => {
|
|
130
|
+
const t = L([]), r = D(
|
|
131
131
|
() => t.value[0]
|
|
132
|
-
), o = (
|
|
133
|
-
const s =
|
|
132
|
+
), o = (a) => {
|
|
133
|
+
const s = a instanceof yt ? a : t.value.find((f) => f.uuid === a);
|
|
134
134
|
if (!s)
|
|
135
135
|
return;
|
|
136
|
-
const
|
|
137
|
-
t.value = [s, ...
|
|
138
|
-
}, i = (
|
|
139
|
-
t.value.some(({ uuid:
|
|
140
|
-
},
|
|
141
|
-
t.value = t.value.filter(({ uuid: s }) => s !==
|
|
136
|
+
const n = t.value.filter(({ uuid: f }) => f !== s.uuid);
|
|
137
|
+
t.value = [s, ...n];
|
|
138
|
+
}, i = (a, s = !1) => {
|
|
139
|
+
t.value.some(({ uuid: n }) => n === a.uuid) || (s ? o(a) : t.value.push(a));
|
|
140
|
+
}, u = (a) => {
|
|
141
|
+
t.value = t.value.filter(({ uuid: s }) => s !== a.uuid);
|
|
142
142
|
};
|
|
143
|
-
return
|
|
144
|
-
e.aspectRatio.value && t.value.forEach((
|
|
145
|
-
!
|
|
143
|
+
return ge(() => {
|
|
144
|
+
e.aspectRatio.value && t.value.forEach((a) => {
|
|
145
|
+
!a.manual && (a instanceof de || mr(a)) && (a instanceof de ? a.aspect = e.aspectRatio.value : (a.left = e.width.value * -0.5, a.right = e.width.value * 0.5, a.top = e.height.value * 0.5, a.bottom = e.height.value * -0.5), a.updateProjectionMatrix());
|
|
146
146
|
});
|
|
147
147
|
}), N(() => {
|
|
148
148
|
t.value = [];
|
|
149
149
|
}), {
|
|
150
|
-
camera:
|
|
150
|
+
camera: r,
|
|
151
151
|
cameras: t,
|
|
152
152
|
registerCamera: i,
|
|
153
|
-
deregisterCamera:
|
|
153
|
+
deregisterCamera: u,
|
|
154
154
|
setCameraActive: o
|
|
155
155
|
};
|
|
156
156
|
};
|
|
157
|
-
function
|
|
157
|
+
function mr(e) {
|
|
158
158
|
return e.hasOwnProperty("isOrthographicCamera") && e.isOrthographicCamera;
|
|
159
159
|
}
|
|
160
|
-
const
|
|
160
|
+
const Ke = O(), Xe = O(), ye = O(), V = new Ve();
|
|
161
161
|
let ne = 0, oe = 0;
|
|
162
|
-
const { pause:
|
|
162
|
+
const { pause: vr, resume: Be, isActive: gr } = Qe(
|
|
163
163
|
() => {
|
|
164
|
-
|
|
164
|
+
Ke.trigger({ delta: ne, elapsed: oe, clock: V }), Xe.trigger({ delta: ne, elapsed: oe, clock: V }), ye.trigger({ delta: ne, elapsed: oe, clock: V });
|
|
165
165
|
},
|
|
166
166
|
{ immediate: !1 }
|
|
167
167
|
);
|
|
168
|
-
|
|
169
|
-
ne =
|
|
168
|
+
ye.on(() => {
|
|
169
|
+
ne = V.getDelta(), oe = V.getElapsedTime();
|
|
170
170
|
});
|
|
171
|
-
let
|
|
172
|
-
const
|
|
173
|
-
onBeforeLoop:
|
|
174
|
-
onLoop:
|
|
175
|
-
onAfterLoop:
|
|
176
|
-
pause:
|
|
177
|
-
resume:
|
|
178
|
-
isActive:
|
|
179
|
-
}),
|
|
180
|
-
function
|
|
171
|
+
let je = !1;
|
|
172
|
+
const fn = () => (je || (je = !0, Be()), {
|
|
173
|
+
onBeforeLoop: Ke.on,
|
|
174
|
+
onLoop: Xe.on,
|
|
175
|
+
onAfterLoop: ye.on,
|
|
176
|
+
pause: vr,
|
|
177
|
+
resume: Be,
|
|
178
|
+
isActive: gr
|
|
179
|
+
}), dn = !0, K = "[TresJS ▲ ■ ●] ";
|
|
180
|
+
function U() {
|
|
181
181
|
function e(...o) {
|
|
182
182
|
typeof o[0] == "string" ? o[0] = K + o[0] : o.unshift(K), console.error(...o);
|
|
183
183
|
}
|
|
184
184
|
function t(...o) {
|
|
185
185
|
typeof o[0] == "string" ? o[0] = K + o[0] : o.unshift(K), console.warn(...o);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function r(o, i) {
|
|
188
188
|
}
|
|
189
189
|
return {
|
|
190
190
|
logError: e,
|
|
191
191
|
logWarning: t,
|
|
192
|
-
logMessage:
|
|
192
|
+
logMessage: r
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
return typeof e == "number" ? [e, e, e] : e instanceof
|
|
195
|
+
function pn(e) {
|
|
196
|
+
return typeof e == "number" ? [e, e, e] : e instanceof he ? [e.x, e.y, e.z] : e;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function hr(e) {
|
|
199
199
|
return e instanceof re ? e : Array.isArray(e) ? new re(...e) : new re(e);
|
|
200
200
|
}
|
|
201
|
-
class
|
|
202
|
-
constructor(...
|
|
203
|
-
super(...
|
|
204
|
-
|
|
205
|
-
|
|
201
|
+
class yr extends Ge.Mesh {
|
|
202
|
+
constructor(...r) {
|
|
203
|
+
super(...r);
|
|
204
|
+
ie(this, "type", "HightlightMesh");
|
|
205
|
+
ie(this, "createTime");
|
|
206
206
|
this.createTime = Date.now();
|
|
207
207
|
}
|
|
208
208
|
onBeforeRender() {
|
|
209
|
-
const o = (Date.now() - this.createTime) / 1e3,
|
|
210
|
-
this.scale.set(
|
|
209
|
+
const o = (Date.now() - this.createTime) / 1e3, a = 1 + 0.07 * Math.sin(2.5 * o);
|
|
210
|
+
this.scale.set(a, a, a);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
const
|
|
214
|
-
for (const
|
|
215
|
-
t[
|
|
213
|
+
const Ze = (e, t) => {
|
|
214
|
+
for (const r of Object.keys(t))
|
|
215
|
+
t[r] instanceof Object && Object.assign(t[r], Ze(e[r], t[r]));
|
|
216
216
|
return Object.assign(e || {}, t), e;
|
|
217
|
-
},
|
|
217
|
+
}, br = "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", wr = /* @__PURE__ */ _r(br);
|
|
218
218
|
function Re(e) {
|
|
219
219
|
return e && e.nodeType === 1;
|
|
220
220
|
}
|
|
221
221
|
function X(e) {
|
|
222
|
-
return e.replace(/-([a-z])/g, (t,
|
|
222
|
+
return e.replace(/-([a-z])/g, (t, r) => r.toUpperCase());
|
|
223
223
|
}
|
|
224
|
-
const
|
|
225
|
-
function
|
|
226
|
-
return e.replace(
|
|
224
|
+
const Mr = /\B([A-Z])/g;
|
|
225
|
+
function Pr(e) {
|
|
226
|
+
return e.replace(Mr, "-$1").toLowerCase();
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
const
|
|
228
|
+
function _r(e, t) {
|
|
229
|
+
const r = /* @__PURE__ */ Object.create(null), o = e.split(",");
|
|
230
230
|
for (let i = 0; i < o.length; i++)
|
|
231
|
-
|
|
232
|
-
return (i) => !!
|
|
231
|
+
r[o[i]] = !0;
|
|
232
|
+
return (i) => !!r[i];
|
|
233
233
|
}
|
|
234
|
-
const
|
|
235
|
-
const
|
|
234
|
+
const Cr = (e, t) => {
|
|
235
|
+
const r = /* @__PURE__ */ new Set(), o = [];
|
|
236
236
|
for (const i of e) {
|
|
237
|
-
const
|
|
238
|
-
|
|
237
|
+
const u = t(i);
|
|
238
|
+
r.has(u) || (r.add(u), o.push(i));
|
|
239
239
|
}
|
|
240
240
|
return o;
|
|
241
|
-
},
|
|
241
|
+
}, Ie = (e, t) => {
|
|
242
242
|
if (!t)
|
|
243
243
|
return;
|
|
244
|
-
const
|
|
245
|
-
return
|
|
246
|
-
},
|
|
244
|
+
const r = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
|
|
245
|
+
return r == null ? void 0 : r.reduce((o, i) => o && o[i], e);
|
|
246
|
+
}, Er = (e, t, r) => {
|
|
247
247
|
const o = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
|
|
248
|
-
o && o.reduce((i,
|
|
248
|
+
o && o.reduce((i, u, a) => (i[u] === void 0 && (i[u] = {}), a === o.length - 1 && (i[u] = r), i[u]), e);
|
|
249
249
|
};
|
|
250
|
-
function
|
|
250
|
+
function et(e, t) {
|
|
251
251
|
if (Re(e) && Re(t)) {
|
|
252
|
-
const i = e.attributes,
|
|
253
|
-
return i.length !==
|
|
252
|
+
const i = e.attributes, u = t.attributes;
|
|
253
|
+
return i.length !== u.length ? !1 : Array.from(i).every(({ name: a, value: s }) => t.getAttribute(a) === s);
|
|
254
254
|
}
|
|
255
255
|
if (e === t)
|
|
256
256
|
return !0;
|
|
257
257
|
if (e === null || typeof e != "object" || t === null || typeof t != "object")
|
|
258
258
|
return !1;
|
|
259
|
-
const
|
|
260
|
-
if (
|
|
259
|
+
const r = Object.keys(e), o = Object.keys(t);
|
|
260
|
+
if (r.length !== o.length)
|
|
261
261
|
return !1;
|
|
262
|
-
for (const i of
|
|
263
|
-
if (!o.includes(i) || !
|
|
262
|
+
for (const i of r)
|
|
263
|
+
if (!o.includes(i) || !et(e[i], t[i]))
|
|
264
264
|
return !1;
|
|
265
265
|
return !0;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function kr(e, t) {
|
|
268
268
|
if (!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length)
|
|
269
269
|
return !1;
|
|
270
|
-
for (let
|
|
271
|
-
if (!
|
|
270
|
+
for (let r = 0; r < e.length; r++)
|
|
271
|
+
if (!et(e[r], t[r]))
|
|
272
272
|
return !1;
|
|
273
273
|
return !0;
|
|
274
274
|
}
|
|
275
|
-
const
|
|
276
|
-
function
|
|
277
|
-
const i = (
|
|
278
|
-
if (
|
|
279
|
-
return
|
|
280
|
-
for (const
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
return
|
|
275
|
+
const Sr = Array.isArray;
|
|
276
|
+
function xr(e, t, r, o) {
|
|
277
|
+
const i = (n) => {
|
|
278
|
+
if (n.uuid === t)
|
|
279
|
+
return n;
|
|
280
|
+
for (const f of n.children) {
|
|
281
|
+
const h = i(f);
|
|
282
|
+
if (h)
|
|
283
|
+
return h;
|
|
284
284
|
}
|
|
285
|
-
},
|
|
286
|
-
if (!
|
|
285
|
+
}, u = i(e);
|
|
286
|
+
if (!u) {
|
|
287
287
|
console.warn("Object with UUID not found in the scene.");
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
|
-
let
|
|
291
|
-
for (let
|
|
292
|
-
if (r[n
|
|
293
|
-
|
|
290
|
+
let a = u;
|
|
291
|
+
for (let n = 0; n < r.length - 1; n++)
|
|
292
|
+
if (a[r[n]] !== void 0)
|
|
293
|
+
a = a[r[n]];
|
|
294
294
|
else {
|
|
295
|
-
console.warn(`Property path is not valid: ${
|
|
295
|
+
console.warn(`Property path is not valid: ${r.join(".")}`);
|
|
296
296
|
return;
|
|
297
297
|
}
|
|
298
|
-
const s =
|
|
299
|
-
|
|
298
|
+
const s = r[r.length - 1];
|
|
299
|
+
a[s] !== void 0 ? a[s] = o : console.warn(`Property path is not valid: ${r.join(".")}`);
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
const t = new
|
|
301
|
+
function Tr(e) {
|
|
302
|
+
const t = new Ye({
|
|
303
303
|
color: 11003607,
|
|
304
304
|
// Highlight color, e.g., yellow
|
|
305
305
|
transparent: !0,
|
|
306
306
|
opacity: 0.2,
|
|
307
307
|
depthTest: !1,
|
|
308
308
|
// So the highlight is always visible
|
|
309
|
-
side:
|
|
309
|
+
side: bt
|
|
310
310
|
// To e
|
|
311
311
|
});
|
|
312
|
-
return new
|
|
312
|
+
return new yr(e.geometry.clone(), t);
|
|
313
313
|
}
|
|
314
|
-
function
|
|
315
|
-
var
|
|
314
|
+
function Ar(e) {
|
|
315
|
+
var r;
|
|
316
316
|
let t = e.value;
|
|
317
|
-
return e.value && ((
|
|
317
|
+
return e.value && ((r = e.value) != null && r.isMesh) && (t = e.value.position), Array.isArray(e.value) && (t = new he(...t)), t;
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function Or(e) {
|
|
320
320
|
return "map" in e;
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
322
|
+
function He(e) {
|
|
323
|
+
Or(e) && e.map && e.map.dispose(), e.dispose();
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
var
|
|
327
|
-
if (e.parent && ((
|
|
325
|
+
function be(e) {
|
|
326
|
+
var r, o;
|
|
327
|
+
if (e.parent && ((r = e.removeFromParent) == null || r.call(e)), delete e.__tres, [...e.children].forEach((i) => be(i)), !(e instanceof qe)) {
|
|
328
328
|
const i = e;
|
|
329
|
-
e && ((o = e.dispose) == null || o.call(e)), i.geometry && (i.geometry.dispose(), delete i.geometry), Array.isArray(i.material) ? (i.material.forEach((
|
|
329
|
+
e && ((o = e.dispose) == null || o.call(e)), i.geometry && (i.geometry.dispose(), delete i.geometry), Array.isArray(i.material) ? (i.material.forEach((u) => He(u)), delete i.material) : i.material && (He(i.material), delete i.material);
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
const
|
|
332
|
+
const Lr = Number.parseInt(wt.replace("dev", "")), Z = {
|
|
333
333
|
realistic: {
|
|
334
334
|
shadows: !0,
|
|
335
335
|
physicallyCorrectLights: !0,
|
|
336
|
-
outputColorSpace:
|
|
337
|
-
toneMapping:
|
|
336
|
+
outputColorSpace: Mt,
|
|
337
|
+
toneMapping: Je,
|
|
338
338
|
toneMappingExposure: 3,
|
|
339
339
|
shadowMap: {
|
|
340
340
|
enabled: !0,
|
|
341
|
-
type:
|
|
341
|
+
type: Pt
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
344
|
flat: {
|
|
345
|
-
toneMapping:
|
|
345
|
+
toneMapping: _t,
|
|
346
346
|
toneMappingExposure: 1
|
|
347
347
|
}
|
|
348
348
|
};
|
|
349
|
-
function
|
|
349
|
+
function Dr({
|
|
350
350
|
canvas: e,
|
|
351
351
|
options: t,
|
|
352
|
-
contextParts: { sizes:
|
|
352
|
+
contextParts: { sizes: r, render: o, invalidate: i, advance: u }
|
|
353
353
|
}) {
|
|
354
|
-
const
|
|
355
|
-
alpha:
|
|
356
|
-
depth:
|
|
357
|
-
canvas:
|
|
358
|
-
context:
|
|
359
|
-
stencil:
|
|
360
|
-
antialias:
|
|
361
|
-
precision:
|
|
362
|
-
powerPreference:
|
|
363
|
-
premultipliedAlpha:
|
|
364
|
-
preserveDrawingBuffer:
|
|
365
|
-
logarithmicDepthBuffer:
|
|
366
|
-
failIfMajorPerformanceCaveat:
|
|
367
|
-
})), s =
|
|
368
|
-
function
|
|
354
|
+
const a = D(() => ({
|
|
355
|
+
alpha: S(t.alpha) ?? !0,
|
|
356
|
+
depth: S(t.depth),
|
|
357
|
+
canvas: Ht(e),
|
|
358
|
+
context: S(t.context),
|
|
359
|
+
stencil: S(t.stencil),
|
|
360
|
+
antialias: S(t.antialias) ?? !0,
|
|
361
|
+
precision: S(t.precision),
|
|
362
|
+
powerPreference: S(t.powerPreference),
|
|
363
|
+
premultipliedAlpha: S(t.premultipliedAlpha),
|
|
364
|
+
preserveDrawingBuffer: S(t.preserveDrawingBuffer),
|
|
365
|
+
logarithmicDepthBuffer: S(t.logarithmicDepthBuffer),
|
|
366
|
+
failIfMajorPerformanceCaveat: S(t.failIfMajorPerformanceCaveat)
|
|
367
|
+
})), s = H(new ae(a.value));
|
|
368
|
+
function n() {
|
|
369
369
|
t.renderMode === "on-demand" && i();
|
|
370
370
|
}
|
|
371
|
-
|
|
372
|
-
s.value.dispose(), s.value = new
|
|
373
|
-
}),
|
|
374
|
-
s.value.setSize(
|
|
371
|
+
G(a, () => {
|
|
372
|
+
s.value.dispose(), s.value = new ae(a.value), n();
|
|
373
|
+
}), G([r.width, r.height], () => {
|
|
374
|
+
s.value.setSize(r.width.value, r.height.value), n();
|
|
375
375
|
}, {
|
|
376
376
|
immediate: !0
|
|
377
|
-
}),
|
|
378
|
-
const { pixelRatio:
|
|
379
|
-
|
|
380
|
-
s.value.setPixelRatio(
|
|
377
|
+
}), G(() => t.clearColor, n);
|
|
378
|
+
const { pixelRatio: f } = Ut();
|
|
379
|
+
G(f, () => {
|
|
380
|
+
s.value.setPixelRatio(f.value);
|
|
381
381
|
});
|
|
382
|
-
const { logError:
|
|
383
|
-
const
|
|
382
|
+
const { logError: h } = U(), b = (() => {
|
|
383
|
+
const d = new ae(), P = {
|
|
384
384
|
shadowMap: {
|
|
385
|
-
enabled:
|
|
386
|
-
type:
|
|
385
|
+
enabled: d.shadowMap.enabled,
|
|
386
|
+
type: d.shadowMap.type
|
|
387
387
|
},
|
|
388
|
-
toneMapping:
|
|
389
|
-
toneMappingExposure:
|
|
390
|
-
outputColorSpace:
|
|
388
|
+
toneMapping: d.toneMapping,
|
|
389
|
+
toneMappingExposure: d.toneMappingExposure,
|
|
390
|
+
outputColorSpace: d.outputColorSpace
|
|
391
391
|
};
|
|
392
|
-
return
|
|
393
|
-
})(),
|
|
394
|
-
return
|
|
395
|
-
|
|
396
|
-
}, 100),
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
const _ =
|
|
401
|
-
if (
|
|
402
|
-
return
|
|
392
|
+
return d.dispose(), P;
|
|
393
|
+
})(), w = S(t.renderMode);
|
|
394
|
+
return w === "on-demand" && i(), w === "manual" && setTimeout(() => {
|
|
395
|
+
u();
|
|
396
|
+
}, 100), ge(() => {
|
|
397
|
+
const d = S(t.preset);
|
|
398
|
+
d && (d in Z || h(`Renderer Preset must be one of these: ${Object.keys(Z).join(", ")}`), Ze(s.value, Z[d])), w === "always" && (o.frames.value = Math.max(1, o.frames.value));
|
|
399
|
+
const P = (p, M) => {
|
|
400
|
+
const _ = S(p), c = () => {
|
|
401
|
+
if (d)
|
|
402
|
+
return Ie(Z[d], M);
|
|
403
403
|
};
|
|
404
404
|
if (_ !== void 0)
|
|
405
405
|
return _;
|
|
406
|
-
const
|
|
407
|
-
return
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
406
|
+
const g = c();
|
|
407
|
+
return g !== void 0 ? g : Ie(b, M);
|
|
408
|
+
}, y = (p, M) => Er(s.value, M, P(p, M));
|
|
409
|
+
y(t.shadows, "shadowMap.enabled"), y(t.toneMapping ?? Je, "toneMapping"), y(t.shadowMapType, "shadowMap.type"), Lr < 150 && y(!t.useLegacyLights, "physicallyCorrectLights"), y(t.outputColorSpace, "outputColorSpace"), y(t.toneMappingExposure, "toneMappingExposure");
|
|
410
|
+
const v = P(t.clearColor, "clearColor");
|
|
411
|
+
v && s.value.setClearColor(
|
|
412
|
+
v ? hr(v) : new re(0)
|
|
413
413
|
// default clear color is not easily/efficiently retrievable from three
|
|
414
414
|
);
|
|
415
415
|
}), N(() => {
|
|
@@ -418,371 +418,374 @@ function Ar({
|
|
|
418
418
|
renderer: s
|
|
419
419
|
};
|
|
420
420
|
}
|
|
421
|
-
const ee = (e) => typeof e == "function",
|
|
422
|
-
function
|
|
421
|
+
const ee = (e) => typeof e == "function", Br = (e) => !!e && e.constructor === Array;
|
|
422
|
+
function jr(e) {
|
|
423
423
|
const t = { nodes: {}, materials: {} };
|
|
424
|
-
return e && e.traverse((
|
|
425
|
-
|
|
424
|
+
return e && e.traverse((r) => {
|
|
425
|
+
r.name && (t.nodes[r.name] = r), r.material && !t.materials[r.material.name] && (t.materials[r.material.name] = r.material);
|
|
426
426
|
}), t;
|
|
427
427
|
}
|
|
428
|
-
async function
|
|
429
|
-
const { logError:
|
|
430
|
-
i && i(
|
|
431
|
-
const
|
|
432
|
-
(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
(
|
|
436
|
-
|
|
428
|
+
async function mn(e, t, r, o, i) {
|
|
429
|
+
const { logError: u } = U(), a = new e();
|
|
430
|
+
i && i(a), r && r(a);
|
|
431
|
+
const n = (Array.isArray(t) ? t : [t]).map(
|
|
432
|
+
(f) => new Promise((h, l) => {
|
|
433
|
+
a.load(
|
|
434
|
+
f,
|
|
435
|
+
(b) => {
|
|
436
|
+
b.scene && Object.assign(b, jr(b.scene)), h(b);
|
|
437
437
|
},
|
|
438
438
|
o,
|
|
439
|
-
(
|
|
439
|
+
(b) => l(u("[useLoader] - Failed to load resource", b))
|
|
440
440
|
);
|
|
441
441
|
})
|
|
442
442
|
);
|
|
443
|
-
return
|
|
443
|
+
return Br(t) ? await Promise.all(n) : await n[0];
|
|
444
444
|
}
|
|
445
|
-
async function
|
|
446
|
-
const
|
|
447
|
-
|
|
445
|
+
async function vn(e, t) {
|
|
446
|
+
const r = new Ct(t), o = (i) => new Promise((u, a) => {
|
|
447
|
+
r.load(
|
|
448
448
|
i,
|
|
449
|
-
(s) =>
|
|
449
|
+
(s) => u(s),
|
|
450
450
|
() => null,
|
|
451
451
|
() => {
|
|
452
|
-
|
|
452
|
+
a(new Error("[useTextures] - Failed to load texture"));
|
|
453
453
|
}
|
|
454
454
|
);
|
|
455
455
|
});
|
|
456
|
-
if (
|
|
457
|
-
const i = await Promise.all(e.map((
|
|
456
|
+
if (Sr(e)) {
|
|
457
|
+
const i = await Promise.all(e.map((u) => o(u)));
|
|
458
458
|
return e.length > 1 ? i : i[0];
|
|
459
459
|
} else {
|
|
460
460
|
const {
|
|
461
461
|
map: i,
|
|
462
|
-
displacementMap:
|
|
463
|
-
normalMap:
|
|
462
|
+
displacementMap: u,
|
|
463
|
+
normalMap: a,
|
|
464
464
|
roughnessMap: s,
|
|
465
|
-
metalnessMap:
|
|
466
|
-
aoMap:
|
|
467
|
-
alphaMap:
|
|
468
|
-
matcap:
|
|
465
|
+
metalnessMap: n,
|
|
466
|
+
aoMap: f,
|
|
467
|
+
alphaMap: h,
|
|
468
|
+
matcap: l
|
|
469
469
|
} = e;
|
|
470
470
|
return {
|
|
471
471
|
map: i ? await o(i) : null,
|
|
472
|
-
displacementMap:
|
|
473
|
-
normalMap:
|
|
472
|
+
displacementMap: u ? await o(u) : null,
|
|
473
|
+
normalMap: a ? await o(a) : null,
|
|
474
474
|
roughnessMap: s ? await o(s) : null,
|
|
475
|
-
metalnessMap:
|
|
476
|
-
aoMap:
|
|
477
|
-
alphaMap:
|
|
478
|
-
matcap:
|
|
475
|
+
metalnessMap: n ? await o(n) : null,
|
|
476
|
+
aoMap: f ? await o(f) : null,
|
|
477
|
+
alphaMap: h ? await o(h) : null,
|
|
478
|
+
matcap: l ? await o(l) : null
|
|
479
479
|
};
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
482
|
+
const tt = (e, t) => {
|
|
483
|
+
const r = D(() => t.renderer.value.domElement), o = H([]), { x: i, y: u } = $t({ target: r }), a = D(() => e.value.filter((m) => {
|
|
484
|
+
var C;
|
|
485
|
+
return ((C = m.__tres) == null ? void 0 : C.eventCount) > 0;
|
|
486
|
+
}));
|
|
487
|
+
let s = 0;
|
|
488
|
+
const { width: n, height: f, top: h, left: l } = Ft(r), b = ({ x: m, y: C }) => {
|
|
489
|
+
if (r.value)
|
|
487
490
|
return {
|
|
488
|
-
x: (
|
|
489
|
-
y: -((
|
|
491
|
+
x: (m - l.value) / n.value * 2 - 1,
|
|
492
|
+
y: -((C - h.value) / f.value) * 2 + 1
|
|
490
493
|
};
|
|
491
|
-
},
|
|
494
|
+
}, w = ({ x: m, y: C }) => {
|
|
492
495
|
if (t.camera.value)
|
|
493
|
-
return t.raycaster.value.setFromCamera(new
|
|
494
|
-
},
|
|
495
|
-
const
|
|
496
|
-
x: (
|
|
497
|
-
y: (
|
|
496
|
+
return t.raycaster.value.setFromCamera(new le(m, C), t.camera.value), o.value = t.raycaster.value.intersectObjects(a.value, !0), o.value;
|
|
497
|
+
}, d = (m) => {
|
|
498
|
+
const C = b({
|
|
499
|
+
x: (m == null ? void 0 : m.clientX) ?? i.value,
|
|
500
|
+
y: (m == null ? void 0 : m.clientY) ?? u.value
|
|
498
501
|
});
|
|
499
|
-
return
|
|
500
|
-
},
|
|
501
|
-
function
|
|
502
|
-
const
|
|
503
|
-
for (const
|
|
504
|
-
typeof
|
|
505
|
-
return
|
|
502
|
+
return C ? w(C) || [] : [];
|
|
503
|
+
}, P = O(), y = O(), v = O(), p = O(), M = O(), _ = O(), c = O(), g = O();
|
|
504
|
+
function E(m) {
|
|
505
|
+
const C = {};
|
|
506
|
+
for (const R in m)
|
|
507
|
+
typeof R != "function" && (C[R] = m[R]);
|
|
508
|
+
return C;
|
|
506
509
|
}
|
|
507
|
-
const
|
|
508
|
-
var
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
...
|
|
510
|
+
const k = (m, C) => {
|
|
511
|
+
var Ee, ke, Se;
|
|
512
|
+
const R = E(C), Q = new he(C == null ? void 0 : C.clientX, C == null ? void 0 : C.clientY, 0).unproject((Ee = t.camera) == null ? void 0 : Ee.value);
|
|
513
|
+
m.trigger({
|
|
514
|
+
...R,
|
|
512
515
|
intersections: o.value,
|
|
513
516
|
// The unprojectedPoint is wrong, math needs to be fixed
|
|
514
517
|
unprojectedPoint: Q,
|
|
515
|
-
ray: (
|
|
516
|
-
camera: (
|
|
517
|
-
sourceEvent:
|
|
518
|
-
delta:
|
|
518
|
+
ray: (ke = t.raycaster) == null ? void 0 : ke.value.ray,
|
|
519
|
+
camera: (Se = t.camera) == null ? void 0 : Se.value,
|
|
520
|
+
sourceEvent: C,
|
|
521
|
+
delta: s,
|
|
519
522
|
stopPropagating: !1
|
|
520
523
|
});
|
|
521
524
|
};
|
|
522
|
-
let
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
+
let B;
|
|
526
|
+
const x = (m) => {
|
|
527
|
+
d(m), k(v, m), B = m;
|
|
525
528
|
}, T = () => {
|
|
526
|
-
|
|
529
|
+
B && x(B);
|
|
527
530
|
};
|
|
528
|
-
let
|
|
529
|
-
const Y = (
|
|
530
|
-
var
|
|
531
|
-
|
|
532
|
-
(
|
|
533
|
-
(
|
|
534
|
-
),
|
|
531
|
+
let $, A, q;
|
|
532
|
+
const Y = (m) => {
|
|
533
|
+
var C;
|
|
534
|
+
$ = (C = o.value[0]) == null ? void 0 : C.object, s = 0, A = new le(
|
|
535
|
+
(m == null ? void 0 : m.clientX) ?? i.value,
|
|
536
|
+
(m == null ? void 0 : m.clientY) ?? u.value
|
|
537
|
+
), k(M, m);
|
|
535
538
|
};
|
|
536
|
-
let
|
|
537
|
-
const
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
(
|
|
541
|
-
(
|
|
542
|
-
),
|
|
543
|
-
},
|
|
544
|
-
J && (
|
|
545
|
-
},
|
|
546
|
-
return
|
|
547
|
-
|
|
539
|
+
let se, J = !1;
|
|
540
|
+
const Me = (m) => {
|
|
541
|
+
var C, R, Q;
|
|
542
|
+
m instanceof PointerEvent && (o.value.length === 0 && k(_, m), $ === ((C = o.value[0]) == null ? void 0 : C.object) && (q = new le(
|
|
543
|
+
(m == null ? void 0 : m.clientX) ?? i.value,
|
|
544
|
+
(m == null ? void 0 : m.clientY) ?? u.value
|
|
545
|
+
), s = A == null ? void 0 : A.distanceTo(q), m.button === 0 ? (k(P, m), se === ((R = o.value[0]) == null ? void 0 : R.object) ? J = !0 : (se = (Q = o.value[0]) == null ? void 0 : Q.object, J = !1)) : m.button === 2 && k(c, m)), k(p, m));
|
|
546
|
+
}, Pe = (m) => {
|
|
547
|
+
J && (k(y, m), se = void 0, J = !1);
|
|
548
|
+
}, _e = (m) => k(v, m), Ce = (m) => k(g, m);
|
|
549
|
+
return r.value.addEventListener("pointerup", Me), r.value.addEventListener("pointerdown", Y), r.value.addEventListener("pointermove", x), r.value.addEventListener("pointerleave", _e), r.value.addEventListener("dblclick", Pe), r.value.addEventListener("wheel", Ce), N(() => {
|
|
550
|
+
r != null && r.value && (r.value.removeEventListener("pointerup", Me), r.value.removeEventListener("pointerdown", Y), r.value.removeEventListener("pointermove", x), r.value.removeEventListener("pointerleave", _e), r.value.removeEventListener("dblclick", Pe), r.value.removeEventListener("wheel", Ce));
|
|
548
551
|
}), {
|
|
549
552
|
intersects: o,
|
|
550
|
-
onClick: (
|
|
551
|
-
onDblClick: (
|
|
552
|
-
onContextMenu: (
|
|
553
|
-
onPointerMove: (
|
|
554
|
-
onPointerUp: (
|
|
555
|
-
onPointerDown: (
|
|
556
|
-
onPointerMissed: (
|
|
557
|
-
onWheel: (
|
|
553
|
+
onClick: (m) => P.on(m).off,
|
|
554
|
+
onDblClick: (m) => y.on(m).off,
|
|
555
|
+
onContextMenu: (m) => c.on(m).off,
|
|
556
|
+
onPointerMove: (m) => v.on(m).off,
|
|
557
|
+
onPointerUp: (m) => p.on(m).off,
|
|
558
|
+
onPointerDown: (m) => M.on(m).off,
|
|
559
|
+
onPointerMissed: (m) => _.on(m).off,
|
|
560
|
+
onWheel: (m) => g.on(m).off,
|
|
558
561
|
forceUpdate: T
|
|
559
562
|
};
|
|
560
563
|
};
|
|
561
|
-
function
|
|
562
|
-
const { logWarning: e } =
|
|
563
|
-
function t(
|
|
564
|
-
let
|
|
565
|
-
return
|
|
566
|
-
a
|
|
567
|
-
}),
|
|
564
|
+
function gn() {
|
|
565
|
+
const { logWarning: e } = U();
|
|
566
|
+
function t(u, a, s) {
|
|
567
|
+
let n = null;
|
|
568
|
+
return u.traverse((f) => {
|
|
569
|
+
f[a] === s && (n = f);
|
|
570
|
+
}), n || e(`Child with ${a} '${s}' not found.`), n;
|
|
568
571
|
}
|
|
569
|
-
function
|
|
570
|
-
const
|
|
571
|
-
return
|
|
572
|
-
a
|
|
573
|
-
}),
|
|
572
|
+
function r(u, a, s) {
|
|
573
|
+
const n = [];
|
|
574
|
+
return u.traverse((f) => {
|
|
575
|
+
f[a].includes(s) && n.push(f);
|
|
576
|
+
}), n.length || e(`Children with ${a} '${s}' not found.`), n;
|
|
574
577
|
}
|
|
575
|
-
function o(
|
|
576
|
-
return t(
|
|
578
|
+
function o(u, a) {
|
|
579
|
+
return t(u, "name", a);
|
|
577
580
|
}
|
|
578
|
-
function i(
|
|
579
|
-
return
|
|
581
|
+
function i(u, a) {
|
|
582
|
+
return r(u, "name", a);
|
|
580
583
|
}
|
|
581
584
|
return {
|
|
582
585
|
seek: t,
|
|
583
586
|
seekByName: o,
|
|
584
|
-
seekAll:
|
|
587
|
+
seekAll: r,
|
|
585
588
|
seekAllByName: i
|
|
586
589
|
};
|
|
587
590
|
}
|
|
588
|
-
const
|
|
589
|
-
const t =
|
|
591
|
+
const hn = (e) => {
|
|
592
|
+
const t = ze({
|
|
590
593
|
click: /* @__PURE__ */ new Map(),
|
|
591
594
|
pointerMove: /* @__PURE__ */ new Map(),
|
|
592
595
|
pointerEnter: /* @__PURE__ */ new Map(),
|
|
593
596
|
pointerLeave: /* @__PURE__ */ new Map()
|
|
594
|
-
}),
|
|
595
|
-
|
|
596
|
-
}, i = (
|
|
597
|
-
|
|
598
|
-
},
|
|
599
|
-
Object.values(t).forEach((
|
|
600
|
-
},
|
|
601
|
-
const { onClick:
|
|
602
|
-
|
|
603
|
-
}, s =
|
|
604
|
-
() =>
|
|
597
|
+
}), r = L(/* @__PURE__ */ new Set()), o = (l) => {
|
|
598
|
+
r.value.add(l);
|
|
599
|
+
}, i = (l) => {
|
|
600
|
+
r.value.delete(l);
|
|
601
|
+
}, u = (l) => {
|
|
602
|
+
Object.values(t).forEach((b) => b.delete(l)), i(l);
|
|
603
|
+
}, a = (l) => {
|
|
604
|
+
const { onClick: b, onPointerMove: w, onPointerEnter: d, onPointerLeave: P } = l;
|
|
605
|
+
b && t.click.set(l, b), w && t.pointerMove.set(l, w), d && t.pointerEnter.set(l, d), P && t.pointerLeave.set(l, P);
|
|
606
|
+
}, s = D(
|
|
607
|
+
() => Cr(
|
|
605
608
|
[
|
|
606
|
-
...Array.from(
|
|
607
|
-
...Object.values(t).map((
|
|
609
|
+
...Array.from(r.value),
|
|
610
|
+
...Object.values(t).map((l) => Array.from(l.keys())).flat()
|
|
608
611
|
],
|
|
609
|
-
({ uuid:
|
|
612
|
+
({ uuid: l }) => l
|
|
610
613
|
)
|
|
611
614
|
);
|
|
612
|
-
e.registerObjectAtPointerEventHandler =
|
|
613
|
-
const { onClick:
|
|
614
|
-
|
|
615
|
-
var
|
|
616
|
-
|
|
615
|
+
e.registerObjectAtPointerEventHandler = a, e.deregisterObjectAtPointerEventHandler = u, e.registerBlockingObjectAtPointerEventHandler = o, e.deregisterBlockingObjectAtPointerEventHandler = i;
|
|
616
|
+
const { onClick: n, onPointerMove: f } = tt(s, e);
|
|
617
|
+
n(({ intersects: l, event: b }) => {
|
|
618
|
+
var w;
|
|
619
|
+
l.length && ((w = t.click.get(l[0].object)) == null || w(l[0], b));
|
|
617
620
|
});
|
|
618
|
-
let
|
|
619
|
-
return
|
|
620
|
-
var
|
|
621
|
-
const
|
|
622
|
-
|
|
621
|
+
let h;
|
|
622
|
+
return f(({ intersects: l, event: b }) => {
|
|
623
|
+
var v, p, M, _;
|
|
624
|
+
const w = (v = l == null ? void 0 : l[0]) == null ? void 0 : v.object, { pointerLeave: d, pointerEnter: P, pointerMove: y } = t;
|
|
625
|
+
h && h !== w && ((p = d.get(h)) == null || p(h, b)), w && (h !== w && ((M = P.get(w)) == null || M(l[0], b)), (_ = y.get(w)) == null || _(l[0], b)), h = w || null;
|
|
623
626
|
}), {
|
|
624
|
-
registerObject:
|
|
625
|
-
deregisterObject:
|
|
627
|
+
registerObject: a,
|
|
628
|
+
deregisterObject: u,
|
|
626
629
|
registerBlockingObject: o,
|
|
627
630
|
deregisterBlockingObject: i
|
|
628
631
|
};
|
|
629
632
|
};
|
|
630
|
-
function
|
|
633
|
+
function we(e) {
|
|
631
634
|
let t = 0;
|
|
632
|
-
return e.traverse((
|
|
633
|
-
if (
|
|
634
|
-
const o =
|
|
635
|
-
t +=
|
|
635
|
+
return e.traverse((r) => {
|
|
636
|
+
if (r.isMesh && r.geometry) {
|
|
637
|
+
const o = r.geometry, i = o.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, u = o.index ? o.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, a = o.attributes.normal ? o.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, s = o.attributes.uv ? o.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, n = i + u + a + s;
|
|
638
|
+
t += n;
|
|
636
639
|
}
|
|
637
640
|
}), t;
|
|
638
641
|
}
|
|
639
|
-
function
|
|
642
|
+
function Rr(e) {
|
|
640
643
|
return (e / 1024).toFixed(2);
|
|
641
644
|
}
|
|
642
|
-
const
|
|
643
|
-
function
|
|
644
|
-
const o =
|
|
645
|
+
const pe = L({}), me = (e) => Object.assign(pe.value, e);
|
|
646
|
+
function Ir(e, t, r = 10) {
|
|
647
|
+
const o = S(e) ? Wt() : Nt(D(() => S(t).parentElement)), i = ce(De(o.width, r)), u = ce(De(o.height, r)), a = D(() => i.value / u.value);
|
|
645
648
|
return {
|
|
646
|
-
height:
|
|
649
|
+
height: u,
|
|
647
650
|
width: i,
|
|
648
|
-
aspectRatio:
|
|
651
|
+
aspectRatio: a
|
|
649
652
|
};
|
|
650
653
|
}
|
|
651
|
-
function
|
|
654
|
+
function ue() {
|
|
652
655
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
653
|
-
let
|
|
656
|
+
let r = 0, o = !1;
|
|
654
657
|
const i = () => {
|
|
655
|
-
const
|
|
656
|
-
const
|
|
657
|
-
return
|
|
658
|
+
const f = Array.from(e.entries()).sort((h, l) => {
|
|
659
|
+
const b = h[1].priority - l[1].priority;
|
|
660
|
+
return b === 0 ? h[1].addI - l[1].addI : b;
|
|
658
661
|
});
|
|
659
|
-
t.clear(),
|
|
660
|
-
},
|
|
661
|
-
e.delete(
|
|
662
|
+
t.clear(), f.forEach((h) => t.add(h[0]));
|
|
663
|
+
}, u = (f) => {
|
|
664
|
+
e.delete(f), t.delete(f);
|
|
662
665
|
};
|
|
663
|
-
return { on: (
|
|
664
|
-
e.set(
|
|
665
|
-
const
|
|
666
|
-
return
|
|
667
|
-
off:
|
|
666
|
+
return { on: (f, h = 0) => {
|
|
667
|
+
e.set(f, { priority: h, addI: r++ });
|
|
668
|
+
const l = () => u(f);
|
|
669
|
+
return zt(l), o = !0, {
|
|
670
|
+
off: l
|
|
668
671
|
};
|
|
669
|
-
}, off:
|
|
670
|
-
o && (i(), o = !1), t.forEach((
|
|
672
|
+
}, off: u, trigger: (...f) => {
|
|
673
|
+
o && (i(), o = !1), t.forEach((h) => h(...f));
|
|
671
674
|
}, dispose: () => {
|
|
672
675
|
e.clear(), t.clear();
|
|
673
676
|
}, get count() {
|
|
674
677
|
return e.size;
|
|
675
678
|
} };
|
|
676
679
|
}
|
|
677
|
-
function
|
|
678
|
-
const e = new
|
|
680
|
+
function Hr() {
|
|
681
|
+
const e = new Ve(!1), t = L(!1), r = L(!1);
|
|
679
682
|
let o;
|
|
680
|
-
const i =
|
|
681
|
-
let
|
|
682
|
-
const
|
|
683
|
-
let
|
|
684
|
-
function
|
|
685
|
-
|
|
683
|
+
const i = Et.generateUUID();
|
|
684
|
+
let u = null;
|
|
685
|
+
const a = ue(), s = ue(), n = ue();
|
|
686
|
+
let f = {};
|
|
687
|
+
function h(M) {
|
|
688
|
+
f = M;
|
|
686
689
|
}
|
|
687
|
-
function
|
|
690
|
+
function l(M, _, c = 0) {
|
|
688
691
|
switch (_) {
|
|
689
692
|
case "before":
|
|
690
|
-
return
|
|
693
|
+
return a.on(M, c);
|
|
691
694
|
case "render":
|
|
692
|
-
return
|
|
695
|
+
return u || (u = M), s.dispose(), s.on(M);
|
|
693
696
|
case "after":
|
|
694
|
-
return
|
|
697
|
+
return n.on(M, c);
|
|
695
698
|
}
|
|
696
699
|
}
|
|
697
|
-
function
|
|
698
|
-
t.value || (e.start(), t.value = !0,
|
|
700
|
+
function b() {
|
|
701
|
+
t.value || (e.start(), t.value = !0, p());
|
|
699
702
|
}
|
|
700
|
-
function
|
|
703
|
+
function w() {
|
|
701
704
|
t.value && (e.stop(), cancelAnimationFrame(o), t.value = !1);
|
|
702
705
|
}
|
|
703
|
-
function
|
|
706
|
+
function d() {
|
|
704
707
|
e.stop(), t.value = !1;
|
|
705
708
|
}
|
|
706
|
-
function
|
|
709
|
+
function P() {
|
|
707
710
|
e.start(), t.value = !0;
|
|
708
711
|
}
|
|
709
|
-
function
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
function w() {
|
|
713
|
-
n.value = !1;
|
|
712
|
+
function y() {
|
|
713
|
+
r.value = !0;
|
|
714
714
|
}
|
|
715
715
|
function v() {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
716
|
+
r.value = !1;
|
|
717
|
+
}
|
|
718
|
+
function p() {
|
|
719
|
+
const M = e.getDelta(), _ = e.getElapsedTime(), c = {
|
|
720
|
+
camera: W(f.camera),
|
|
721
|
+
scene: W(f.scene),
|
|
722
|
+
renderer: W(f.renderer),
|
|
723
|
+
raycaster: W(f.raycaster),
|
|
724
|
+
controls: W(f.controls),
|
|
725
|
+
invalidate: f.invalidate,
|
|
726
|
+
advance: f.advance
|
|
727
|
+
}, g = { delta: M, elapsed: _, clock: e, ...c };
|
|
728
|
+
t.value && a.trigger(g), r.value || (s.count ? s.trigger(g) : u && u(g)), t.value && n.trigger(g), o = requestAnimationFrame(p);
|
|
726
729
|
}
|
|
727
730
|
return {
|
|
728
731
|
loopId: i,
|
|
729
|
-
register: (
|
|
730
|
-
start:
|
|
731
|
-
stop:
|
|
732
|
-
pause:
|
|
733
|
-
resume:
|
|
734
|
-
pauseRender:
|
|
735
|
-
resumeRender:
|
|
736
|
-
isRenderPaused:
|
|
732
|
+
register: (M, _, c) => l(M, _, c),
|
|
733
|
+
start: b,
|
|
734
|
+
stop: w,
|
|
735
|
+
pause: d,
|
|
736
|
+
resume: P,
|
|
737
|
+
pauseRender: y,
|
|
738
|
+
resumeRender: v,
|
|
739
|
+
isRenderPaused: r,
|
|
737
740
|
isActive: t,
|
|
738
|
-
setContext:
|
|
741
|
+
setContext: h
|
|
739
742
|
};
|
|
740
743
|
}
|
|
741
|
-
function
|
|
744
|
+
function Ur({
|
|
742
745
|
scene: e,
|
|
743
746
|
canvas: t,
|
|
744
|
-
windowSize:
|
|
747
|
+
windowSize: r,
|
|
745
748
|
disableRender: o,
|
|
746
749
|
rendererOptions: i,
|
|
747
|
-
emit:
|
|
750
|
+
emit: u
|
|
748
751
|
}) {
|
|
749
|
-
const { logWarning:
|
|
750
|
-
camera:
|
|
751
|
-
cameras:
|
|
752
|
-
registerCamera:
|
|
753
|
-
deregisterCamera:
|
|
754
|
-
setCameraActive:
|
|
755
|
-
} =
|
|
756
|
-
mode:
|
|
757
|
-
priority:
|
|
758
|
-
frames:
|
|
752
|
+
const { logWarning: a } = U(), s = H(e), n = Ir(r, t), {
|
|
753
|
+
camera: f,
|
|
754
|
+
cameras: h,
|
|
755
|
+
registerCamera: l,
|
|
756
|
+
deregisterCamera: b,
|
|
757
|
+
setCameraActive: w
|
|
758
|
+
} = pr({ sizes: n, scene: e }), d = {
|
|
759
|
+
mode: L(i.renderMode || "always"),
|
|
760
|
+
priority: L(0),
|
|
761
|
+
frames: L(0),
|
|
759
762
|
maxFrames: 60,
|
|
760
|
-
canBeInvalidated:
|
|
763
|
+
canBeInvalidated: D(() => d.mode.value === "on-demand" && d.frames.value === 0)
|
|
761
764
|
};
|
|
762
|
-
function
|
|
763
|
-
i.renderMode === "on-demand" ?
|
|
765
|
+
function P(A = 1) {
|
|
766
|
+
i.renderMode === "on-demand" ? d.frames.value = Math.min(d.maxFrames, d.frames.value + A) : a("`invalidate` can only be used when `renderMode` is set to `on-demand`");
|
|
764
767
|
}
|
|
765
|
-
function
|
|
766
|
-
i.renderMode === "manual" ?
|
|
768
|
+
function y() {
|
|
769
|
+
i.renderMode === "manual" ? d.frames.value = 1 : a("`advance` can only be used when `renderMode` is set to `manual`");
|
|
767
770
|
}
|
|
768
|
-
const { renderer:
|
|
771
|
+
const { renderer: v } = Dr(
|
|
769
772
|
{
|
|
770
773
|
scene: e,
|
|
771
774
|
canvas: t,
|
|
772
775
|
options: i,
|
|
773
|
-
emit:
|
|
776
|
+
emit: u,
|
|
774
777
|
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
|
|
775
|
-
contextParts: { sizes:
|
|
778
|
+
contextParts: { sizes: n, camera: f, render: d, invalidate: P, advance: y },
|
|
776
779
|
disableRender: o
|
|
777
780
|
}
|
|
778
|
-
),
|
|
779
|
-
sizes:
|
|
781
|
+
), p = {
|
|
782
|
+
sizes: n,
|
|
780
783
|
scene: s,
|
|
781
|
-
camera:
|
|
782
|
-
cameras:
|
|
783
|
-
renderer:
|
|
784
|
-
raycaster:
|
|
785
|
-
controls:
|
|
784
|
+
camera: f,
|
|
785
|
+
cameras: ce(h),
|
|
786
|
+
renderer: v,
|
|
787
|
+
raycaster: H(new kt()),
|
|
788
|
+
controls: L(null),
|
|
786
789
|
perf: {
|
|
787
790
|
maxFrames: 160,
|
|
788
791
|
fps: {
|
|
@@ -795,70 +798,70 @@ function jr({
|
|
|
795
798
|
accumulator: []
|
|
796
799
|
}
|
|
797
800
|
},
|
|
798
|
-
render:
|
|
799
|
-
advance:
|
|
800
|
-
extend:
|
|
801
|
-
invalidate:
|
|
802
|
-
registerCamera:
|
|
803
|
-
setCameraActive:
|
|
804
|
-
deregisterCamera:
|
|
805
|
-
loop:
|
|
801
|
+
render: d,
|
|
802
|
+
advance: y,
|
|
803
|
+
extend: me,
|
|
804
|
+
invalidate: P,
|
|
805
|
+
registerCamera: l,
|
|
806
|
+
setCameraActive: w,
|
|
807
|
+
deregisterCamera: b,
|
|
808
|
+
loop: Hr()
|
|
806
809
|
};
|
|
807
|
-
|
|
808
|
-
root:
|
|
809
|
-
},
|
|
810
|
-
|
|
811
|
-
}, "render"),
|
|
812
|
-
|
|
810
|
+
fe("useTres", p), p.scene.value.__tres = {
|
|
811
|
+
root: p
|
|
812
|
+
}, p.loop.register(() => {
|
|
813
|
+
f.value && d.frames.value > 0 && (v.value.render(e, f.value), u("render", p.renderer.value)), d.priority.value = 0, d.mode.value === "always" ? d.frames.value = 1 : d.frames.value = Math.max(0, d.frames.value - 1);
|
|
814
|
+
}, "render"), p.loop.start(), N(() => {
|
|
815
|
+
p.loop.stop();
|
|
813
816
|
});
|
|
814
|
-
const
|
|
815
|
-
let
|
|
816
|
-
const
|
|
817
|
-
|
|
817
|
+
const M = 100, _ = Gt({ every: M }), { isSupported: c, memory: g } = Vt({ interval: M }), E = 160;
|
|
818
|
+
let k = performance.now();
|
|
819
|
+
const B = ({ timestamp: A }) => {
|
|
820
|
+
p.scene.value && (p.perf.memory.allocatedMem = we(p.scene.value)), A - k >= M && (k = A, p.perf.fps.accumulator.push(_.value), p.perf.fps.accumulator.length > E && p.perf.fps.accumulator.shift(), p.perf.fps.value = _.value, c.value && g.value && (p.perf.memory.accumulator.push(g.value.usedJSHeapSize / 1024 / 1024), p.perf.memory.accumulator.length > E && p.perf.memory.accumulator.shift(), p.perf.memory.currentMem = p.perf.memory.accumulator.reduce((q, Y) => q + Y, 0) / p.perf.memory.accumulator.length));
|
|
818
821
|
};
|
|
819
|
-
let
|
|
820
|
-
const
|
|
821
|
-
window.__TRES__DEVTOOLS__ && (
|
|
822
|
+
let x = 0;
|
|
823
|
+
const T = 1, { pause: $ } = Qe(({ delta: A }) => {
|
|
824
|
+
window.__TRES__DEVTOOLS__ && (B({ timestamp: performance.now() }), x += A, x >= T && (window.__TRES__DEVTOOLS__.cb(p), x = 0));
|
|
822
825
|
}, { immediate: !0 });
|
|
823
826
|
return N(() => {
|
|
824
|
-
|
|
825
|
-
}),
|
|
827
|
+
$();
|
|
828
|
+
}), p;
|
|
826
829
|
}
|
|
827
|
-
function
|
|
828
|
-
const e =
|
|
830
|
+
function rt() {
|
|
831
|
+
const e = ut("useTres");
|
|
829
832
|
if (!e)
|
|
830
833
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
831
834
|
return e;
|
|
832
835
|
}
|
|
833
|
-
const
|
|
834
|
-
function
|
|
836
|
+
const yn = rt;
|
|
837
|
+
function bn() {
|
|
835
838
|
const {
|
|
836
839
|
camera: e,
|
|
837
840
|
scene: t,
|
|
838
|
-
renderer:
|
|
841
|
+
renderer: r,
|
|
839
842
|
loop: o,
|
|
840
843
|
raycaster: i,
|
|
841
|
-
controls:
|
|
842
|
-
invalidate:
|
|
844
|
+
controls: u,
|
|
845
|
+
invalidate: a,
|
|
843
846
|
advance: s
|
|
844
|
-
} =
|
|
847
|
+
} = rt();
|
|
845
848
|
o.setContext({
|
|
846
849
|
camera: e,
|
|
847
850
|
scene: t,
|
|
848
|
-
renderer:
|
|
851
|
+
renderer: r,
|
|
849
852
|
raycaster: i,
|
|
850
|
-
controls:
|
|
851
|
-
invalidate:
|
|
853
|
+
controls: u,
|
|
854
|
+
invalidate: a,
|
|
852
855
|
advance: s
|
|
853
856
|
});
|
|
854
|
-
function
|
|
855
|
-
return o.register(
|
|
857
|
+
function n(l, b = 0) {
|
|
858
|
+
return o.register(l, "before", b);
|
|
856
859
|
}
|
|
857
|
-
function
|
|
858
|
-
return o.register(
|
|
860
|
+
function f(l) {
|
|
861
|
+
return o.register(l, "render");
|
|
859
862
|
}
|
|
860
|
-
function
|
|
861
|
-
return o.register(
|
|
863
|
+
function h(l, b = 0) {
|
|
864
|
+
return o.register(l, "after", b);
|
|
862
865
|
}
|
|
863
866
|
return {
|
|
864
867
|
pause: o.pause,
|
|
@@ -866,81 +869,81 @@ function hn() {
|
|
|
866
869
|
pauseRender: o.pauseRender,
|
|
867
870
|
resumeRender: o.resumeRender,
|
|
868
871
|
isActive: o.isActive,
|
|
869
|
-
onBeforeRender:
|
|
870
|
-
render:
|
|
871
|
-
onAfterRender:
|
|
872
|
+
onBeforeRender: n,
|
|
873
|
+
render: f,
|
|
874
|
+
onAfterRender: h
|
|
872
875
|
};
|
|
873
876
|
}
|
|
874
|
-
function
|
|
875
|
-
const o =
|
|
877
|
+
function $r(e, t, r) {
|
|
878
|
+
const o = H(), i = H();
|
|
876
879
|
e && (o.value = e), t && (i.value = t);
|
|
877
|
-
const
|
|
880
|
+
const u = D(
|
|
878
881
|
() => o.value ? o.value.children : []
|
|
879
882
|
);
|
|
880
|
-
function
|
|
881
|
-
if (Array.isArray(
|
|
882
|
-
for (const
|
|
883
|
-
|
|
884
|
-
typeof
|
|
883
|
+
function a(c, g) {
|
|
884
|
+
if (Array.isArray(c))
|
|
885
|
+
for (const E of c)
|
|
886
|
+
E(g);
|
|
887
|
+
typeof c == "function" && c(g);
|
|
885
888
|
}
|
|
886
|
-
function s(
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
for (const
|
|
890
|
-
if (
|
|
889
|
+
function s(c, g) {
|
|
890
|
+
const E = [], k = () => g.stopPropagating = !0;
|
|
891
|
+
g.stopPropagation = k;
|
|
892
|
+
for (const B of g == null ? void 0 : g.intersections) {
|
|
893
|
+
if (g.stopPropagating)
|
|
891
894
|
return;
|
|
892
|
-
|
|
893
|
-
const { object:
|
|
894
|
-
|
|
895
|
-
let
|
|
896
|
-
for (;
|
|
897
|
-
|
|
898
|
-
const
|
|
899
|
-
|
|
895
|
+
g = { ...g, ...B };
|
|
896
|
+
const { object: x } = B;
|
|
897
|
+
g.eventObject = x, a(x[c], g), E.push(x);
|
|
898
|
+
let T = x.parent;
|
|
899
|
+
for (; T !== null && !g.stopPropagating && !E.includes(T); )
|
|
900
|
+
g.eventObject = T, a(T[c], g), E.push(T), T = T.parent;
|
|
901
|
+
const $ = Pr(c.slice(2));
|
|
902
|
+
r($, { intersection: B, event: g });
|
|
900
903
|
}
|
|
901
904
|
}
|
|
902
905
|
const {
|
|
903
|
-
onClick:
|
|
904
|
-
onDblClick:
|
|
905
|
-
onContextMenu:
|
|
906
|
-
onPointerMove:
|
|
907
|
-
onPointerDown:
|
|
908
|
-
onPointerUp:
|
|
909
|
-
onPointerMissed:
|
|
910
|
-
onWheel:
|
|
911
|
-
forceUpdate:
|
|
912
|
-
} =
|
|
913
|
-
|
|
914
|
-
let
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
}),
|
|
920
|
-
|
|
921
|
-
}), s("onPointerMove",
|
|
906
|
+
onClick: n,
|
|
907
|
+
onDblClick: f,
|
|
908
|
+
onContextMenu: h,
|
|
909
|
+
onPointerMove: l,
|
|
910
|
+
onPointerDown: b,
|
|
911
|
+
onPointerUp: w,
|
|
912
|
+
onPointerMissed: d,
|
|
913
|
+
onWheel: P,
|
|
914
|
+
forceUpdate: y
|
|
915
|
+
} = tt(u, t);
|
|
916
|
+
w((c) => s("onPointerUp", c)), b((c) => s("onPointerDown", c)), n((c) => s("onClick", c)), f((c) => s("onDoubleClick", c)), h((c) => s("onContextMenu", c)), P((c) => s("onWheel", c));
|
|
917
|
+
let v = [];
|
|
918
|
+
l((c) => {
|
|
919
|
+
const g = c.intersections.map(({ object: k }) => k), E = c.intersections;
|
|
920
|
+
v.forEach(({ object: k }) => {
|
|
921
|
+
g.includes(k) || (c.intersections = v, s("onPointerLeave", c), s("onPointerOut", c));
|
|
922
|
+
}), c.intersections = E, c.intersections.forEach(({ object: k }) => {
|
|
923
|
+
v.includes(k) || (s("onPointerEnter", c), s("onPointerOver", c));
|
|
924
|
+
}), s("onPointerMove", c), v = c.intersections;
|
|
922
925
|
});
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
}),
|
|
926
|
+
const p = [];
|
|
927
|
+
d((c) => {
|
|
928
|
+
const g = () => c.stopPropagating = !0;
|
|
929
|
+
c.stopPropagation = g, p.forEach((E) => {
|
|
930
|
+
c.stopPropagating || (c.eventObject = E, a(E.onPointerMissed, c));
|
|
931
|
+
}), r("pointer-missed", { event: c });
|
|
929
932
|
});
|
|
930
|
-
function
|
|
931
|
-
|
|
933
|
+
function M(c) {
|
|
934
|
+
p.push(c);
|
|
932
935
|
}
|
|
933
|
-
function _(
|
|
934
|
-
const
|
|
935
|
-
|
|
936
|
+
function _(c) {
|
|
937
|
+
const g = p.indexOf(c);
|
|
938
|
+
g > -1 && p.splice(g, 1);
|
|
936
939
|
}
|
|
937
940
|
return t.eventManager = {
|
|
938
|
-
forceUpdate:
|
|
939
|
-
registerPointerMissedObject:
|
|
941
|
+
forceUpdate: y,
|
|
942
|
+
registerPointerMissedObject: M,
|
|
940
943
|
deregisterPointerMissedObject: _
|
|
941
|
-
}, { forceUpdate:
|
|
944
|
+
}, { forceUpdate: y, registerPointerMissedObject: M, deregisterPointerMissedObject: _ };
|
|
942
945
|
}
|
|
943
|
-
const { logError:
|
|
946
|
+
const { logError: Ue } = U(), $e = [
|
|
944
947
|
"onClick",
|
|
945
948
|
"onContextMenu",
|
|
946
949
|
"onPointerMove",
|
|
@@ -956,233 +959,244 @@ const { logError: He } = $(), Hr = [
|
|
|
956
959
|
"onLostPointerCapture",
|
|
957
960
|
"onWheel"
|
|
958
961
|
];
|
|
959
|
-
function
|
|
960
|
-
var
|
|
961
|
-
const t = (
|
|
962
|
+
function Fe(e) {
|
|
963
|
+
var r;
|
|
964
|
+
const t = (r = e == null ? void 0 : e.__tres) == null ? void 0 : r.root;
|
|
962
965
|
t && t.render && t.render.canBeInvalidated.value && t.invalidate();
|
|
963
966
|
}
|
|
964
|
-
const
|
|
967
|
+
const Fr = () => {
|
|
965
968
|
let e = null;
|
|
966
|
-
function t(
|
|
967
|
-
if (
|
|
969
|
+
function t(n, f, h, l) {
|
|
970
|
+
if (l || (l = {}), l.args || (l.args = []), n === "template" || wr(n))
|
|
968
971
|
return null;
|
|
969
|
-
let
|
|
970
|
-
if (
|
|
971
|
-
(
|
|
972
|
-
const
|
|
973
|
-
|
|
972
|
+
let b = n.replace("Tres", ""), w;
|
|
973
|
+
if (n === "primitive") {
|
|
974
|
+
(l == null ? void 0 : l.object) === void 0 && Ue("Tres primitives need a prop 'object'");
|
|
975
|
+
const d = l.object;
|
|
976
|
+
b = d.type, w = Object.assign(d.clone(), { type: b });
|
|
974
977
|
} else {
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
`${
|
|
978
|
-
),
|
|
978
|
+
const d = pe.value[b];
|
|
979
|
+
d || Ue(
|
|
980
|
+
`${b} is not defined on the THREE namespace. Use extend to add it to the catalog.`
|
|
981
|
+
), w = new d(...l.args);
|
|
979
982
|
}
|
|
980
|
-
return
|
|
981
|
-
...
|
|
982
|
-
type:
|
|
983
|
-
memoizedProps:
|
|
983
|
+
return w ? (w.isCamera && (l != null && l.position || w.position.set(3, 3, 3), l != null && l.lookAt || w.lookAt(0, 0, 0)), (l == null ? void 0 : l.attach) === void 0 && (w.isMaterial ? w.attach = "material" : w.isBufferGeometry && (w.attach = "geometry")), w.__tres = {
|
|
984
|
+
...w.__tres,
|
|
985
|
+
type: b,
|
|
986
|
+
memoizedProps: l,
|
|
984
987
|
eventCount: 0,
|
|
985
988
|
disposable: !0,
|
|
986
|
-
primitive:
|
|
987
|
-
},
|
|
989
|
+
primitive: n === "primitive"
|
|
990
|
+
}, w.isObject3D && w.__tres && (l != null && l.material || l != null && l.geometry) && (w.__tres.disposable = !1), w) : null;
|
|
988
991
|
}
|
|
989
|
-
function n
|
|
990
|
-
var
|
|
991
|
-
if (!
|
|
992
|
+
function r(n, f) {
|
|
993
|
+
var l, b, w, d, P;
|
|
994
|
+
if (!n)
|
|
992
995
|
return;
|
|
993
|
-
|
|
994
|
-
const
|
|
995
|
-
if (
|
|
996
|
-
const { registerCamera:
|
|
997
|
-
|
|
996
|
+
f && f.isScene && (e = f), e && n.__tres && (n.__tres.root = e.__tres.root);
|
|
997
|
+
const h = f || e;
|
|
998
|
+
if (n != null && n.isObject3D) {
|
|
999
|
+
const { registerCamera: y } = (l = n == null ? void 0 : n.__tres) == null ? void 0 : l.root;
|
|
1000
|
+
n != null && n.isCamera && y(n), n.onPointerMissed && ((b = n == null ? void 0 : n.__tres) != null && b.root) && ((P = (d = (w = n == null ? void 0 : n.__tres) == null ? void 0 : w.root) == null ? void 0 : d.eventManager) == null || P.registerPointerMissedObject(n));
|
|
998
1001
|
}
|
|
999
|
-
|
|
1002
|
+
n != null && n.isObject3D && (h != null && h.isObject3D) ? (h.add(n), n.dispatchEvent({ type: "added" })) : n != null && n.isFog ? h.fog = n : typeof (n == null ? void 0 : n.attach) == "string" && (n.__previousAttach = n[h == null ? void 0 : h.attach], h && (h[n.attach] = n));
|
|
1000
1003
|
}
|
|
1001
|
-
function o(
|
|
1002
|
-
var
|
|
1003
|
-
if (!
|
|
1004
|
+
function o(n) {
|
|
1005
|
+
var h, l, b, w;
|
|
1006
|
+
if (!n)
|
|
1004
1007
|
return;
|
|
1005
|
-
const
|
|
1006
|
-
if (
|
|
1007
|
-
const
|
|
1008
|
-
var
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1008
|
+
const f = n.__tres;
|
|
1009
|
+
if (n.parent = n.parent || e, n.isObject3D) {
|
|
1010
|
+
const d = (y) => {
|
|
1011
|
+
var p, M;
|
|
1012
|
+
const v = (M = (p = n == null ? void 0 : n.__tres) == null ? void 0 : p.root) == null ? void 0 : M.deregisterCamera;
|
|
1013
|
+
y.isCamera && (v == null || v(y));
|
|
1011
1014
|
};
|
|
1012
|
-
(
|
|
1013
|
-
var
|
|
1014
|
-
|
|
1015
|
-
}),
|
|
1015
|
+
(h = n.removeFromParent) == null || h.call(n), n.traverse((y) => {
|
|
1016
|
+
var v, p;
|
|
1017
|
+
d(y), y.onPointerMissed && ((p = (v = f == null ? void 0 : f.root) == null ? void 0 : v.eventManager) == null || p.deregisterPointerMissedObject(y));
|
|
1018
|
+
}), d(n), Fe(n), !((l = n.__tres) == null ? void 0 : l.primitive) && ((b = n.__tres) != null && b.disposable) && be(n), (w = n.dispose) == null || w.call(n);
|
|
1016
1019
|
}
|
|
1017
1020
|
}
|
|
1018
|
-
function i(
|
|
1019
|
-
var
|
|
1020
|
-
if (
|
|
1021
|
-
let
|
|
1022
|
-
if ((
|
|
1023
|
-
const
|
|
1024
|
-
object:
|
|
1021
|
+
function i(n, f, h, l) {
|
|
1022
|
+
var b, w;
|
|
1023
|
+
if (n) {
|
|
1024
|
+
let d = n, P = f;
|
|
1025
|
+
if ((b = n == null ? void 0 : n.__tres) != null && b.primitive && P === "object" && h !== null) {
|
|
1026
|
+
const M = t("primitive", void 0, void 0, {
|
|
1027
|
+
object: l
|
|
1025
1028
|
});
|
|
1026
|
-
for (const
|
|
1027
|
-
if (
|
|
1029
|
+
for (const _ in M) {
|
|
1030
|
+
if (_ === "uuid")
|
|
1028
1031
|
continue;
|
|
1029
|
-
const
|
|
1030
|
-
!(
|
|
1032
|
+
const c = n[_], g = M[_];
|
|
1033
|
+
!(c != null && c.set) && !ee(c) ? n[_] = g : c.constructor === g.constructor && (c != null && c.copy) ? c == null || c.copy(g) : Array.isArray(g) ? c.set(...g) : !c.isColor && c.setScalar ? c.setScalar(g) : c.set(g);
|
|
1031
1034
|
}
|
|
1032
|
-
|
|
1035
|
+
M != null && M.__tres && (M.__tres.root = e == null ? void 0 : e.__tres.root), M != null && M.isGroup ? (n.geometry = void 0, n.material = void 0) : delete n.isGroup;
|
|
1033
1036
|
}
|
|
1034
|
-
if (
|
|
1035
|
-
|
|
1037
|
+
if (n != null && n.isObject3D && P === "blocks-pointer-events") {
|
|
1038
|
+
l || l === "" ? n[P] = l : delete n[P];
|
|
1036
1039
|
return;
|
|
1037
1040
|
}
|
|
1038
|
-
|
|
1041
|
+
$e.includes(f) && (n.__tres.eventCount += 1);
|
|
1042
|
+
let y = X(P), v = d == null ? void 0 : d[y];
|
|
1039
1043
|
if (P === "args") {
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
new
|
|
1044
|
+
const M = n, _ = h ?? [], c = l ?? [], g = ((w = n == null ? void 0 : n.__tres) == null ? void 0 : w.type) || n.type;
|
|
1045
|
+
g && _.length && !kr(_, c) && (d = Object.assign(
|
|
1046
|
+
M,
|
|
1047
|
+
new pe.value[g](...l)
|
|
1044
1048
|
));
|
|
1045
1049
|
return;
|
|
1046
1050
|
}
|
|
1047
|
-
if (
|
|
1051
|
+
if (d.type === "BufferGeometry") {
|
|
1048
1052
|
if (P === "args")
|
|
1049
1053
|
return;
|
|
1050
|
-
|
|
1054
|
+
d.setAttribute(
|
|
1051
1055
|
X(P),
|
|
1052
|
-
new
|
|
1056
|
+
new St(...l)
|
|
1053
1057
|
);
|
|
1054
1058
|
return;
|
|
1055
1059
|
}
|
|
1056
|
-
if (P.includes("-") &&
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1060
|
+
if (P.includes("-") && v === void 0) {
|
|
1061
|
+
const M = P.split("-");
|
|
1062
|
+
v = M.reduce((_, c) => _[X(c)], d), P = M.pop(), y = P, v != null && v.set || (d = M.reduce((_, c) => _[X(c)], d));
|
|
1059
1063
|
}
|
|
1060
|
-
let
|
|
1061
|
-
if (
|
|
1062
|
-
|
|
1064
|
+
let p = l;
|
|
1065
|
+
if (p === "" && (p = !0), ee(v)) {
|
|
1066
|
+
$e.includes(f) || (Array.isArray(p) ? n[y](...p) : n[y](p)), y.startsWith("on") && ee(p) && (d[y] = p);
|
|
1063
1067
|
return;
|
|
1064
1068
|
}
|
|
1065
|
-
!(
|
|
1069
|
+
!(v != null && v.set) && !ee(v) ? d[y] = p : v.constructor === p.constructor && (v != null && v.copy) ? v == null || v.copy(p) : Array.isArray(p) ? v.set(...p) : !v.isColor && v.setScalar ? v.setScalar(p) : v.set(p), Fe(n);
|
|
1066
1070
|
}
|
|
1067
1071
|
}
|
|
1068
|
-
function
|
|
1069
|
-
return (
|
|
1072
|
+
function u(n) {
|
|
1073
|
+
return (n == null ? void 0 : n.parent) || null;
|
|
1074
|
+
}
|
|
1075
|
+
function a(n) {
|
|
1076
|
+
const f = new xt();
|
|
1077
|
+
return f.name = n, f.__tres = { type: "Comment" }, f.__tres.root = e == null ? void 0 : e.__tres.root, f;
|
|
1078
|
+
}
|
|
1079
|
+
function s(n) {
|
|
1080
|
+
if (!n)
|
|
1081
|
+
return null;
|
|
1082
|
+
const f = n.parent || e, h = f.children.indexOf(n);
|
|
1083
|
+
return f.children[h + 1] || null;
|
|
1070
1084
|
}
|
|
1071
1085
|
return {
|
|
1072
|
-
insert:
|
|
1086
|
+
insert: r,
|
|
1073
1087
|
remove: o,
|
|
1074
1088
|
createElement: t,
|
|
1075
1089
|
patchProp: i,
|
|
1076
|
-
parentNode:
|
|
1090
|
+
parentNode: u,
|
|
1077
1091
|
createText: () => void 0,
|
|
1078
|
-
createComment:
|
|
1092
|
+
createComment: a,
|
|
1079
1093
|
setText: () => void 0,
|
|
1080
1094
|
setElementText: () => void 0,
|
|
1081
|
-
nextSibling:
|
|
1095
|
+
nextSibling: s,
|
|
1082
1096
|
querySelector: () => void 0,
|
|
1083
1097
|
setScopeId: () => void 0,
|
|
1084
1098
|
cloneNode: () => void 0,
|
|
1085
1099
|
insertStaticContent: () => void 0
|
|
1086
1100
|
};
|
|
1087
1101
|
};
|
|
1088
|
-
function
|
|
1089
|
-
return
|
|
1102
|
+
function Wr() {
|
|
1103
|
+
return nt().__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
|
1090
1104
|
}
|
|
1091
|
-
function
|
|
1105
|
+
function nt() {
|
|
1092
1106
|
return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
|
|
1093
1107
|
}
|
|
1094
|
-
const
|
|
1095
|
-
let F,
|
|
1096
|
-
function
|
|
1108
|
+
const Nr = typeof Proxy == "function", zr = "devtools-plugin:setup", Gr = "plugin:settings:set";
|
|
1109
|
+
let F, ve;
|
|
1110
|
+
function Vr() {
|
|
1097
1111
|
var e;
|
|
1098
|
-
return F !== void 0 || (typeof window < "u" && window.performance ? (F = !0,
|
|
1112
|
+
return F !== void 0 || (typeof window < "u" && window.performance ? (F = !0, ve = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (F = !0, ve = globalThis.perf_hooks.performance) : F = !1), F;
|
|
1099
1113
|
}
|
|
1100
|
-
function
|
|
1101
|
-
return
|
|
1114
|
+
function qr() {
|
|
1115
|
+
return Vr() ? ve.now() : Date.now();
|
|
1102
1116
|
}
|
|
1103
|
-
class
|
|
1104
|
-
constructor(t,
|
|
1105
|
-
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook =
|
|
1117
|
+
class Yr {
|
|
1118
|
+
constructor(t, r) {
|
|
1119
|
+
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = r;
|
|
1106
1120
|
const o = {};
|
|
1107
1121
|
if (t.settings)
|
|
1108
|
-
for (const
|
|
1109
|
-
const s = t.settings[
|
|
1110
|
-
o[
|
|
1122
|
+
for (const a in t.settings) {
|
|
1123
|
+
const s = t.settings[a];
|
|
1124
|
+
o[a] = s.defaultValue;
|
|
1111
1125
|
}
|
|
1112
1126
|
const i = `__vue-devtools-plugin-settings__${t.id}`;
|
|
1113
|
-
let
|
|
1127
|
+
let u = Object.assign({}, o);
|
|
1114
1128
|
try {
|
|
1115
|
-
const
|
|
1116
|
-
Object.assign(
|
|
1129
|
+
const a = localStorage.getItem(i), s = JSON.parse(a);
|
|
1130
|
+
Object.assign(u, s);
|
|
1117
1131
|
} catch {
|
|
1118
1132
|
}
|
|
1119
1133
|
this.fallbacks = {
|
|
1120
1134
|
getSettings() {
|
|
1121
|
-
return
|
|
1135
|
+
return u;
|
|
1122
1136
|
},
|
|
1123
|
-
setSettings(
|
|
1137
|
+
setSettings(a) {
|
|
1124
1138
|
try {
|
|
1125
|
-
localStorage.setItem(i, JSON.stringify(
|
|
1139
|
+
localStorage.setItem(i, JSON.stringify(a));
|
|
1126
1140
|
} catch {
|
|
1127
1141
|
}
|
|
1128
|
-
|
|
1142
|
+
u = a;
|
|
1129
1143
|
},
|
|
1130
1144
|
now() {
|
|
1131
|
-
return
|
|
1145
|
+
return qr();
|
|
1132
1146
|
}
|
|
1133
|
-
},
|
|
1134
|
-
|
|
1147
|
+
}, r && r.on(Gr, (a, s) => {
|
|
1148
|
+
a === this.plugin.id && this.fallbacks.setSettings(s);
|
|
1135
1149
|
}), this.proxiedOn = new Proxy({}, {
|
|
1136
|
-
get: (
|
|
1150
|
+
get: (a, s) => this.target ? this.target.on[s] : (...n) => {
|
|
1137
1151
|
this.onQueue.push({
|
|
1138
1152
|
method: s,
|
|
1139
|
-
args:
|
|
1153
|
+
args: n
|
|
1140
1154
|
});
|
|
1141
1155
|
}
|
|
1142
1156
|
}), this.proxiedTarget = new Proxy({}, {
|
|
1143
|
-
get: (
|
|
1157
|
+
get: (a, s) => this.target ? this.target[s] : s === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(s) ? (...n) => (this.targetQueue.push({
|
|
1144
1158
|
method: s,
|
|
1145
|
-
args:
|
|
1159
|
+
args: n,
|
|
1146
1160
|
resolve: () => {
|
|
1147
1161
|
}
|
|
1148
|
-
}), this.fallbacks[s](...
|
|
1162
|
+
}), this.fallbacks[s](...n)) : (...n) => new Promise((f) => {
|
|
1149
1163
|
this.targetQueue.push({
|
|
1150
1164
|
method: s,
|
|
1151
|
-
args:
|
|
1152
|
-
resolve:
|
|
1165
|
+
args: n,
|
|
1166
|
+
resolve: f
|
|
1153
1167
|
});
|
|
1154
1168
|
})
|
|
1155
1169
|
});
|
|
1156
1170
|
}
|
|
1157
1171
|
async setRealTarget(t) {
|
|
1158
1172
|
this.target = t;
|
|
1159
|
-
for (const
|
|
1160
|
-
this.target.on[
|
|
1161
|
-
for (const
|
|
1162
|
-
|
|
1173
|
+
for (const r of this.onQueue)
|
|
1174
|
+
this.target.on[r.method](...r.args);
|
|
1175
|
+
for (const r of this.targetQueue)
|
|
1176
|
+
r.resolve(await this.target[r.method](...r.args));
|
|
1163
1177
|
}
|
|
1164
1178
|
}
|
|
1165
|
-
function
|
|
1166
|
-
const
|
|
1167
|
-
if (i && (o.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !
|
|
1168
|
-
i.emit(
|
|
1179
|
+
function Jr(e, t) {
|
|
1180
|
+
const r = e, o = nt(), i = Wr(), u = Nr && r.enableEarlyProxy;
|
|
1181
|
+
if (i && (o.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !u))
|
|
1182
|
+
i.emit(zr, e, t);
|
|
1169
1183
|
else {
|
|
1170
|
-
const
|
|
1184
|
+
const a = u ? new Yr(r, i) : null;
|
|
1171
1185
|
(o.__VUE_DEVTOOLS_PLUGINS__ = o.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
1172
|
-
pluginDescriptor:
|
|
1186
|
+
pluginDescriptor: r,
|
|
1173
1187
|
setupFn: t,
|
|
1174
|
-
proxy:
|
|
1175
|
-
}),
|
|
1188
|
+
proxy: a
|
|
1189
|
+
}), a && t(a.proxiedTarget);
|
|
1176
1190
|
}
|
|
1177
1191
|
}
|
|
1178
|
-
function
|
|
1179
|
-
const
|
|
1180
|
-
typeof
|
|
1192
|
+
function Qr(e, t) {
|
|
1193
|
+
const r = `▲ ■ ●${e}`;
|
|
1194
|
+
typeof We == "function" ? We(r, t) : console.log(r);
|
|
1181
1195
|
}
|
|
1182
|
-
function
|
|
1196
|
+
function We(e, t) {
|
|
1183
1197
|
throw new Error(e + t);
|
|
1184
1198
|
}
|
|
1185
|
-
const
|
|
1199
|
+
const ot = (e) => {
|
|
1186
1200
|
const t = {
|
|
1187
1201
|
id: e.uuid,
|
|
1188
1202
|
label: e.type,
|
|
@@ -1194,9 +1208,9 @@ const rt = (e) => {
|
|
|
1194
1208
|
textColor: 5750629,
|
|
1195
1209
|
backgroundColor: 15793395
|
|
1196
1210
|
});
|
|
1197
|
-
const
|
|
1198
|
-
return
|
|
1199
|
-
label: `${
|
|
1211
|
+
const r = we(e);
|
|
1212
|
+
return r > 0 && t.tags.push({
|
|
1213
|
+
label: `${Rr(r)} KB`,
|
|
1200
1214
|
textColor: 15707189,
|
|
1201
1215
|
backgroundColor: 16775644,
|
|
1202
1216
|
tooltip: "Memory usage"
|
|
@@ -1222,58 +1236,58 @@ const rt = (e) => {
|
|
|
1222
1236
|
tooltip: "Position"
|
|
1223
1237
|
})), t;
|
|
1224
1238
|
};
|
|
1225
|
-
function
|
|
1239
|
+
function st(e, t, r = "") {
|
|
1226
1240
|
e.children.forEach((o) => {
|
|
1227
|
-
if (o.type === "HightlightMesh" ||
|
|
1241
|
+
if (o.type === "HightlightMesh" || r && !o.type.includes(r) && !o.name.includes(r))
|
|
1228
1242
|
return;
|
|
1229
|
-
const i =
|
|
1230
|
-
t.children.push(i),
|
|
1243
|
+
const i = ot(o);
|
|
1244
|
+
t.children.push(i), st(o, i, r);
|
|
1231
1245
|
});
|
|
1232
1246
|
}
|
|
1233
|
-
const
|
|
1247
|
+
const Kr = [], z = "tres:inspector", Xr = ze({
|
|
1234
1248
|
sceneGraph: null
|
|
1235
1249
|
});
|
|
1236
|
-
function
|
|
1237
|
-
|
|
1250
|
+
function Zr(e, t) {
|
|
1251
|
+
Jr(
|
|
1238
1252
|
{
|
|
1239
1253
|
id: "dev.esm.tres",
|
|
1240
1254
|
label: "TresJS 🪐",
|
|
1241
1255
|
logo: "https://raw.githubusercontent.com/Tresjs/tres/main/public/favicon.svg",
|
|
1242
1256
|
packageName: "tresjs",
|
|
1243
1257
|
homepage: "https://tresjs.org",
|
|
1244
|
-
componentStateTypes:
|
|
1258
|
+
componentStateTypes: Kr,
|
|
1245
1259
|
app: e
|
|
1246
1260
|
},
|
|
1247
|
-
(
|
|
1248
|
-
typeof
|
|
1261
|
+
(r) => {
|
|
1262
|
+
typeof r.now != "function" && Qr(
|
|
1249
1263
|
"You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html."
|
|
1250
|
-
),
|
|
1251
|
-
id:
|
|
1264
|
+
), r.addInspector({
|
|
1265
|
+
id: z,
|
|
1252
1266
|
label: "TresJS 🪐",
|
|
1253
1267
|
icon: "account_tree",
|
|
1254
1268
|
treeFilterPlaceholder: "Search instances"
|
|
1255
1269
|
}), setInterval(() => {
|
|
1256
|
-
|
|
1270
|
+
r.sendInspectorTree(z);
|
|
1257
1271
|
}, 1e3), setInterval(() => {
|
|
1258
|
-
|
|
1259
|
-
}, 5e3),
|
|
1260
|
-
if (
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1272
|
+
r.notifyComponentUpdate();
|
|
1273
|
+
}, 5e3), r.on.getInspectorTree((u) => {
|
|
1274
|
+
if (u.inspectorId === z) {
|
|
1275
|
+
const a = ot(t.scene.value);
|
|
1276
|
+
st(t.scene.value, a, u.filter), Xr.sceneGraph = a, u.rootNodes = [a];
|
|
1263
1277
|
}
|
|
1264
1278
|
});
|
|
1265
1279
|
let o = null, i = null;
|
|
1266
|
-
|
|
1267
|
-
var
|
|
1268
|
-
if (
|
|
1269
|
-
const [s] = t.scene.value.getObjectsByProperty("uuid",
|
|
1280
|
+
r.on.getInspectorState((u) => {
|
|
1281
|
+
var a;
|
|
1282
|
+
if (u.inspectorId === z) {
|
|
1283
|
+
const [s] = t.scene.value.getObjectsByProperty("uuid", u.nodeId);
|
|
1270
1284
|
if (!s)
|
|
1271
1285
|
return;
|
|
1272
1286
|
if (i && o && o.parent && i.remove(o), s.isMesh) {
|
|
1273
|
-
const
|
|
1274
|
-
s.add(
|
|
1287
|
+
const n = Tr(s);
|
|
1288
|
+
s.add(n), o = n, i = s;
|
|
1275
1289
|
}
|
|
1276
|
-
|
|
1290
|
+
u.state = {
|
|
1277
1291
|
object: [
|
|
1278
1292
|
{
|
|
1279
1293
|
key: "uuid",
|
|
@@ -1358,30 +1372,30 @@ function Kr(e, t) {
|
|
|
1358
1372
|
value: s.visible
|
|
1359
1373
|
}
|
|
1360
1374
|
]
|
|
1361
|
-
}, s.isScene && (
|
|
1362
|
-
memory:
|
|
1375
|
+
}, s.isScene && (u.state.info = {
|
|
1376
|
+
memory: we(s),
|
|
1363
1377
|
objects: s.children.length,
|
|
1364
1378
|
calls: t.renderer.value.info.render.calls,
|
|
1365
1379
|
triangles: t.renderer.value.info.render.triangles,
|
|
1366
1380
|
points: t.renderer.value.info.render.points,
|
|
1367
1381
|
lines: t.renderer.value.info.render.lines
|
|
1368
|
-
},
|
|
1369
|
-
key:
|
|
1382
|
+
}, u.state.programs = ((a = t.renderer.value.info.programs) == null ? void 0 : a.map((n) => ({
|
|
1383
|
+
key: n.name,
|
|
1370
1384
|
value: {
|
|
1371
|
-
...
|
|
1372
|
-
vertexShader:
|
|
1373
|
-
attributes:
|
|
1374
|
-
uniforms:
|
|
1385
|
+
...n,
|
|
1386
|
+
vertexShader: n.vertexShader,
|
|
1387
|
+
attributes: n.getAttributes(),
|
|
1388
|
+
uniforms: n.getUniforms()
|
|
1375
1389
|
}
|
|
1376
1390
|
}))) || []);
|
|
1377
1391
|
}
|
|
1378
|
-
}),
|
|
1379
|
-
|
|
1392
|
+
}), r.on.editInspectorState((u) => {
|
|
1393
|
+
u.inspectorId === z && xr(t.scene.value, u.nodeId, u.path, u.state.value);
|
|
1380
1394
|
});
|
|
1381
1395
|
}
|
|
1382
1396
|
);
|
|
1383
1397
|
}
|
|
1384
|
-
const
|
|
1398
|
+
const en = ["data-scene", "data-tres"], tn = /* @__PURE__ */ xe({
|
|
1385
1399
|
__name: "TresCanvas",
|
|
1386
1400
|
props: {
|
|
1387
1401
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -1423,91 +1437,91 @@ const Xr = ["data-scene", "data-tres"], Zr = /* @__PURE__ */ Se({
|
|
|
1423
1437
|
"pointer-missed",
|
|
1424
1438
|
"wheel"
|
|
1425
1439
|
],
|
|
1426
|
-
setup(e, { expose: t, emit:
|
|
1427
|
-
var
|
|
1428
|
-
const o = e, i =
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1440
|
+
setup(e, { expose: t, emit: r }) {
|
|
1441
|
+
var P;
|
|
1442
|
+
const o = e, i = r, u = ct(), { logWarning: a } = U(), s = L(), n = H(new qe()), f = (P = Te()) == null ? void 0 : P.appContext.app;
|
|
1443
|
+
me(Ge);
|
|
1444
|
+
const h = (y) => xe({
|
|
1431
1445
|
setup() {
|
|
1432
|
-
var
|
|
1433
|
-
const
|
|
1434
|
-
return
|
|
1446
|
+
var p;
|
|
1447
|
+
const v = (p = Te()) == null ? void 0 : p.appContext;
|
|
1448
|
+
return v && (v.app = f), fe("useTres", y), fe("extend", me), typeof window < "u" && Zr(v == null ? void 0 : v.app, y), () => Ae(ht, null, u != null && u.default ? u.default() : []);
|
|
1435
1449
|
}
|
|
1436
|
-
}),
|
|
1437
|
-
const
|
|
1438
|
-
|
|
1439
|
-
},
|
|
1440
|
-
|
|
1441
|
-
root:
|
|
1442
|
-
},
|
|
1443
|
-
},
|
|
1444
|
-
return t({ context:
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
scene:
|
|
1448
|
-
canvas:
|
|
1450
|
+
}), l = (y) => {
|
|
1451
|
+
const v = h(y), { render: p } = gt(Fr());
|
|
1452
|
+
p(Ae(v), n.value);
|
|
1453
|
+
}, b = (y, v = !1) => {
|
|
1454
|
+
be(y.scene.value), v && (y.renderer.value.dispose(), y.renderer.value.renderLists.dispose(), y.renderer.value.forceContextLoss()), n.value.__tres = {
|
|
1455
|
+
root: y
|
|
1456
|
+
}, l(y);
|
|
1457
|
+
}, w = D(() => o.disableRender), d = H(null);
|
|
1458
|
+
return t({ context: d, dispose: () => b(d.value, !0) }), ft(() => {
|
|
1459
|
+
const y = s;
|
|
1460
|
+
d.value = Ur({
|
|
1461
|
+
scene: n.value,
|
|
1462
|
+
canvas: y,
|
|
1449
1463
|
windowSize: o.windowSize ?? !1,
|
|
1450
|
-
disableRender:
|
|
1464
|
+
disableRender: w.value ?? !1,
|
|
1451
1465
|
rendererOptions: o,
|
|
1452
1466
|
emit: i
|
|
1453
|
-
}),
|
|
1454
|
-
const { registerCamera:
|
|
1455
|
-
|
|
1456
|
-
const
|
|
1457
|
-
const
|
|
1467
|
+
}), $r(n.value, d.value, i);
|
|
1468
|
+
const { registerCamera: v, camera: p, cameras: M, deregisterCamera: _ } = d.value;
|
|
1469
|
+
l(d.value);
|
|
1470
|
+
const c = () => {
|
|
1471
|
+
const g = new de(
|
|
1458
1472
|
45,
|
|
1459
1473
|
window.innerWidth / window.innerHeight,
|
|
1460
1474
|
0.1,
|
|
1461
1475
|
1e3
|
|
1462
1476
|
);
|
|
1463
|
-
|
|
1464
|
-
const
|
|
1465
|
-
|
|
1477
|
+
g.position.set(3, 3, 3), g.lookAt(0, 0, 0), v(g);
|
|
1478
|
+
const E = ge(() => {
|
|
1479
|
+
M.value.length >= 2 && (g.removeFromParent(), _(g), E == null || E());
|
|
1466
1480
|
});
|
|
1467
1481
|
};
|
|
1468
|
-
|
|
1482
|
+
G(
|
|
1469
1483
|
() => o.camera,
|
|
1470
|
-
(
|
|
1471
|
-
|
|
1484
|
+
(g, E) => {
|
|
1485
|
+
g && v(g), E && (E.removeFromParent(), _(E));
|
|
1472
1486
|
},
|
|
1473
1487
|
{
|
|
1474
1488
|
immediate: !0
|
|
1475
1489
|
}
|
|
1476
|
-
),
|
|
1490
|
+
), p.value || (a(
|
|
1477
1491
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
1478
|
-
),
|
|
1492
|
+
), c());
|
|
1479
1493
|
}), N(() => {
|
|
1480
|
-
|
|
1481
|
-
}), (
|
|
1494
|
+
b(d.value);
|
|
1495
|
+
}), (y, v) => (dt(), pt("canvas", {
|
|
1482
1496
|
ref_key: "canvas",
|
|
1483
1497
|
ref: s,
|
|
1484
|
-
"data-scene":
|
|
1485
|
-
class:
|
|
1486
|
-
"data-tres": `tresjs ${W(
|
|
1487
|
-
style:
|
|
1498
|
+
"data-scene": n.value.uuid,
|
|
1499
|
+
class: mt(y.$attrs.class),
|
|
1500
|
+
"data-tres": `tresjs ${W(dr).version}`,
|
|
1501
|
+
style: vt({
|
|
1488
1502
|
display: "block",
|
|
1489
1503
|
width: "100%",
|
|
1490
1504
|
height: "100%",
|
|
1491
|
-
position:
|
|
1505
|
+
position: y.windowSize ? "fixed" : "relative",
|
|
1492
1506
|
top: 0,
|
|
1493
1507
|
left: 0,
|
|
1494
1508
|
pointerEvents: "auto",
|
|
1495
1509
|
touchAction: "none",
|
|
1496
|
-
...
|
|
1510
|
+
...y.$attrs.style
|
|
1497
1511
|
})
|
|
1498
|
-
}, null, 14,
|
|
1512
|
+
}, null, 14, en));
|
|
1499
1513
|
}
|
|
1500
|
-
}),
|
|
1514
|
+
}), rn = [
|
|
1501
1515
|
"TresCanvas",
|
|
1502
1516
|
"TresLeches",
|
|
1503
1517
|
"TresScene"
|
|
1504
|
-
],
|
|
1518
|
+
], nn = {
|
|
1505
1519
|
template: {
|
|
1506
1520
|
compilerOptions: {
|
|
1507
|
-
isCustomElement: (e) => e.startsWith("Tres") && !
|
|
1521
|
+
isCustomElement: (e) => e.startsWith("Tres") && !rn.includes(e) || e === "primitive"
|
|
1508
1522
|
}
|
|
1509
1523
|
}
|
|
1510
|
-
},
|
|
1524
|
+
}, wn = nn, Mn = {
|
|
1511
1525
|
mounted: (e, t) => {
|
|
1512
1526
|
if (t.arg) {
|
|
1513
1527
|
console.log(`v-log:${t.arg}`, e[t.arg]);
|
|
@@ -1516,22 +1530,22 @@ const Xr = ["data-scene", "data-tres"], Zr = /* @__PURE__ */ Se({
|
|
|
1516
1530
|
console.log("v-log", e);
|
|
1517
1531
|
}
|
|
1518
1532
|
};
|
|
1519
|
-
class
|
|
1520
|
-
constructor(t,
|
|
1521
|
-
const o = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], i = new
|
|
1522
|
-
i.setAttribute("position", new
|
|
1523
|
-
const
|
|
1524
|
-
super(i,
|
|
1525
|
-
const
|
|
1526
|
-
s.setAttribute("position", new
|
|
1533
|
+
class it extends Tt {
|
|
1534
|
+
constructor(t, r) {
|
|
1535
|
+
const o = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], i = new Oe();
|
|
1536
|
+
i.setAttribute("position", new Le(o, 3)), i.computeBoundingSphere();
|
|
1537
|
+
const u = new At({ fog: !1 });
|
|
1538
|
+
super(i, u), this.light = t, this.color = r, this.type = "RectAreaLightHelper";
|
|
1539
|
+
const a = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], s = new Oe();
|
|
1540
|
+
s.setAttribute("position", new Le(a, 3)), s.computeBoundingSphere(), this.add(new Ot(s, new Ye({ side: Lt, fog: !1 })));
|
|
1527
1541
|
}
|
|
1528
1542
|
updateMatrixWorld() {
|
|
1529
1543
|
if (this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1), this.color !== void 0)
|
|
1530
1544
|
this.material.color.set(this.color), this.children[0].material.color.set(this.color);
|
|
1531
1545
|
else {
|
|
1532
1546
|
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
|
|
1533
|
-
const t = this.material.color,
|
|
1534
|
-
|
|
1547
|
+
const t = this.material.color, r = Math.max(t.r, t.g, t.b);
|
|
1548
|
+
r > 1 && t.multiplyScalar(1 / r), this.children[0].material.color.copy(this.material.color);
|
|
1535
1549
|
}
|
|
1536
1550
|
this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld), this.children[0].matrixWorld.copy(this.matrixWorld);
|
|
1537
1551
|
}
|
|
@@ -1539,87 +1553,87 @@ class ot extends kt {
|
|
|
1539
1553
|
this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
|
|
1540
1554
|
}
|
|
1541
1555
|
}
|
|
1542
|
-
const { logWarning:
|
|
1543
|
-
let te,
|
|
1544
|
-
const
|
|
1545
|
-
DirectionalLight:
|
|
1546
|
-
PointLight:
|
|
1547
|
-
SpotLight:
|
|
1548
|
-
HemisphereLight:
|
|
1549
|
-
RectAreaLight:
|
|
1550
|
-
},
|
|
1556
|
+
const { logWarning: Ne } = U();
|
|
1557
|
+
let te, I;
|
|
1558
|
+
const on = {
|
|
1559
|
+
DirectionalLight: Dt,
|
|
1560
|
+
PointLight: Bt,
|
|
1561
|
+
SpotLight: jt,
|
|
1562
|
+
HemisphereLight: Rt,
|
|
1563
|
+
RectAreaLight: it
|
|
1564
|
+
}, Pn = {
|
|
1551
1565
|
mounted: (e) => {
|
|
1552
1566
|
if (!e.isLight) {
|
|
1553
|
-
|
|
1567
|
+
Ne(`${e.type} is not a light`);
|
|
1554
1568
|
return;
|
|
1555
1569
|
}
|
|
1556
|
-
te =
|
|
1570
|
+
te = on[e.type], e.parent.add(new te(e, 1, e.color.getHex()));
|
|
1557
1571
|
},
|
|
1558
1572
|
updated: (e) => {
|
|
1559
|
-
|
|
1573
|
+
I = e.parent.children.find((t) => t instanceof te), !(I instanceof it) && I.update();
|
|
1560
1574
|
},
|
|
1561
1575
|
unmounted: (e) => {
|
|
1562
1576
|
if (!e.isLight) {
|
|
1563
|
-
|
|
1577
|
+
Ne(`${e.type} is not a light`);
|
|
1564
1578
|
return;
|
|
1565
1579
|
}
|
|
1566
|
-
|
|
1580
|
+
I = e.parent.children.find((t) => t instanceof te), I && I.dispose && I.dispose(), e.parent.remove(I);
|
|
1567
1581
|
}
|
|
1568
|
-
}, { logWarning:
|
|
1569
|
-
let
|
|
1570
|
-
const
|
|
1582
|
+
}, { logWarning: sn } = U();
|
|
1583
|
+
let j = null;
|
|
1584
|
+
const _n = {
|
|
1571
1585
|
updated: (e, t) => {
|
|
1572
1586
|
var i;
|
|
1573
|
-
const
|
|
1574
|
-
if (!
|
|
1575
|
-
|
|
1587
|
+
const r = Ar(t);
|
|
1588
|
+
if (!r) {
|
|
1589
|
+
sn(`v-distance-to: problem with binding value: ${t.value}`);
|
|
1576
1590
|
return;
|
|
1577
1591
|
}
|
|
1578
|
-
|
|
1579
|
-
const o =
|
|
1580
|
-
o.normalize(),
|
|
1592
|
+
j && (j.dispose(), e.parent.remove(j));
|
|
1593
|
+
const o = r.clone().sub(e.position);
|
|
1594
|
+
o.normalize(), j = new It(o, e.position, e.position.distanceTo(r), 16776960), e.parent.add(j), console.table(
|
|
1581
1595
|
[
|
|
1582
|
-
["Distance:", e.position.distanceTo(
|
|
1596
|
+
["Distance:", e.position.distanceTo(r)],
|
|
1583
1597
|
[`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(i = e.position) == null ? void 0 : i.z}`],
|
|
1584
|
-
[`Destiny: ${e.name || e.type}`, `x:${
|
|
1598
|
+
[`Destiny: ${e.name || e.type}`, `x:${r.x}, y:${r.y}, z:${r == null ? void 0 : r.z}`]
|
|
1585
1599
|
]
|
|
1586
1600
|
);
|
|
1587
1601
|
},
|
|
1588
1602
|
unmounted: (e) => {
|
|
1589
|
-
|
|
1603
|
+
j == null || j.dispose(), e.parent.remove(j);
|
|
1590
1604
|
}
|
|
1591
|
-
},
|
|
1605
|
+
}, Cn = {
|
|
1592
1606
|
install(e) {
|
|
1593
|
-
e.component("TresCanvas",
|
|
1607
|
+
e.component("TresCanvas", tn);
|
|
1594
1608
|
}
|
|
1595
1609
|
};
|
|
1596
1610
|
export {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1611
|
+
tn as TresCanvas,
|
|
1612
|
+
pe as catalogue,
|
|
1613
|
+
Hr as createRenderLoop,
|
|
1614
|
+
Cn as default,
|
|
1615
|
+
be as dispose,
|
|
1616
|
+
me as extend,
|
|
1617
|
+
dn as isProd,
|
|
1618
|
+
hr as normalizeColor,
|
|
1619
|
+
pn as normalizeVectorFlexibleParam,
|
|
1620
|
+
wn as templateCompilerOptions,
|
|
1621
|
+
jr as trasverseObjects,
|
|
1622
|
+
pr as useCamera,
|
|
1623
|
+
mn as useLoader,
|
|
1624
|
+
U as useLogger,
|
|
1625
|
+
bn as useLoop,
|
|
1626
|
+
hn as usePointerEventHandler,
|
|
1627
|
+
tt as useRaycaster,
|
|
1628
|
+
fn as useRenderLoop,
|
|
1629
|
+
Dr as useRenderer,
|
|
1630
|
+
gn as useSeek,
|
|
1631
|
+
vn as useTexture,
|
|
1632
|
+
yn as useTres,
|
|
1633
|
+
rt as useTresContext,
|
|
1634
|
+
Ur as useTresContextProvider,
|
|
1635
|
+
$r as useTresEventManager,
|
|
1636
|
+
_n as vDistanceTo,
|
|
1637
|
+
Pn as vLightHelper,
|
|
1638
|
+
Mn as vLog
|
|
1625
1639
|
};
|