@tresjs/core 3.6.1 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/TresCanvas.vue.d.ts +1 -1
- package/dist/src/composables/useCamera/index.d.ts +12 -12
- package/dist/src/devtools/highlight.d.ts +7 -0
- package/dist/src/devtools/index.d.ts +1 -0
- package/dist/src/devtools/plugin.d.ts +15 -0
- package/dist/src/devtools/utils.d.ts +7 -0
- package/dist/src/directives/index.d.ts +5 -0
- package/dist/src/directives/vAlwaysLookAt.d.ts +6 -0
- package/dist/src/directives/vDistanceTo.d.ts +6 -0
- package/dist/src/directives/vLightHelper.d.ts +6 -0
- package/dist/src/directives/vLog.d.ts +6 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts +8 -0
- package/dist/tres.js +902 -464
- package/dist/tres.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/tres.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v3.
|
|
3
|
+
* version: v3.7.0
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
8
|
+
var je = Object.defineProperty;
|
|
9
|
+
var He = (e, r, t) => r in e ? je(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
10
|
+
var J = (e, r, t) => (He(e, typeof r != "symbol" ? r + "" : r, t), t);
|
|
11
|
+
import { ref as R, computed as P, watchEffect as O, onUnmounted as F, shallowRef as D, watch as me, reactive as ge, readonly as Re, provide as q, inject as $e, createRenderer as Ie, defineComponent as ne, useSlots as ze, getCurrentInstance as oe, onMounted as Ne, openBlock as Ve, createElementBlock as We, normalizeClass as Ue, unref as Fe, normalizeStyle as Ge, h as se, Fragment as Je } from "vue";
|
|
12
|
+
import * as ve from "three";
|
|
13
|
+
import { PerspectiveCamera as K, OrthographicCamera as Qe, Camera as Ye, Clock as qe, Vector3 as he, Color as V, MeshBasicMaterial as ye, DoubleSide as Ke, REVISION as Xe, SRGBColorSpace as Ze, ACESFilmicToneMapping as et, PCFSoftShadowMap as tt, WebGLRenderer as Q, LoadingManager as rt, TextureLoader as nt, Vector2 as ot, Raycaster as st, BufferAttribute as it, Scene as at, Line as lt, BufferGeometry as ie, Float32BufferAttribute as ae, LineBasicMaterial as ut, Mesh as ct, BackSide as dt, DirectionalLightHelper as ft, PointLightHelper as pt, SpotLightHelper as mt, HemisphereLightHelper as gt, ArrowHelper as vt } from "three";
|
|
14
|
+
import { createEventHook as H, useRafFn as we, toValue as M, unrefElement as ht, useDevicePixelRatio as yt, usePointer as wt, useElementBounding as bt, useWindowSize as _t, useElementSize as Et, refDebounced as Mt, useFps as Ct, useMemory as St } from "@vueuse/core";
|
|
15
|
+
const xt = "@tresjs/core", Pt = "module", kt = "3.7.0", At = "pnpm@8.10.2", Tt = "Declarative ThreeJS using Vue Components", Lt = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", Ot = "MIT", Dt = [
|
|
13
16
|
"vue",
|
|
14
17
|
"3d",
|
|
15
18
|
"threejs",
|
|
16
19
|
"three",
|
|
17
20
|
"threejs-vue"
|
|
18
|
-
],
|
|
21
|
+
], Bt = !1, jt = {
|
|
19
22
|
".": {
|
|
20
23
|
types: "./dist/index.d.ts",
|
|
21
24
|
require: "./dist/tres.umd.cjs",
|
|
@@ -34,12 +37,12 @@ const Xe = "@tresjs/core", Qe = "module", Ze = "3.6.1", et = "pnpm@8.10.2", tt =
|
|
|
34
37
|
types: "./dist/utils/index.d.ts"
|
|
35
38
|
},
|
|
36
39
|
"./*": "./*"
|
|
37
|
-
},
|
|
40
|
+
}, Ht = "./dist/tres.js", Rt = "./dist/tres.js", $t = "./dist/index.d.ts", It = [
|
|
38
41
|
"dist",
|
|
39
42
|
"*.d.ts"
|
|
40
|
-
],
|
|
43
|
+
], zt = {
|
|
41
44
|
access: "public"
|
|
42
|
-
},
|
|
45
|
+
}, Nt = {
|
|
43
46
|
dev: "cd playground && npm run dev",
|
|
44
47
|
build: "vite build",
|
|
45
48
|
playground: "cd playground && npm run dev",
|
|
@@ -54,13 +57,13 @@ const Xe = "@tresjs/core", Qe = "module", Ze = "3.6.1", et = "pnpm@8.10.2", tt =
|
|
|
54
57
|
"docs:serve": "vitepress serve docs",
|
|
55
58
|
"docs:preview": "vitepress preview docs",
|
|
56
59
|
"docs:contributors": "esno scripts/update-contributors.ts"
|
|
57
|
-
},
|
|
60
|
+
}, Vt = {
|
|
58
61
|
three: ">=0.133",
|
|
59
62
|
vue: ">=3.3"
|
|
60
|
-
},
|
|
63
|
+
}, Wt = {
|
|
61
64
|
"@alvarosabu/utils": "^3.1.1",
|
|
62
65
|
"@vueuse/core": "^10.7.0"
|
|
63
|
-
},
|
|
66
|
+
}, Ut = {
|
|
64
67
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
65
68
|
"@stackblitz/sdk": "^1.9.0",
|
|
66
69
|
"@tresjs/cientos": "3.6.0",
|
|
@@ -98,453 +101,512 @@ const Xe = "@tresjs/core", Qe = "module", Ze = "3.6.1", et = "pnpm@8.10.2", tt =
|
|
|
98
101
|
vitest: "^1.0.4",
|
|
99
102
|
vue: "^3.3.11",
|
|
100
103
|
"vue-demi": "^0.14.6"
|
|
101
|
-
},
|
|
102
|
-
name:
|
|
103
|
-
type:
|
|
104
|
-
version:
|
|
105
|
-
packageManager:
|
|
106
|
-
description:
|
|
107
|
-
author:
|
|
108
|
-
license:
|
|
109
|
-
keywords:
|
|
110
|
-
sideEffects:
|
|
111
|
-
exports:
|
|
112
|
-
main:
|
|
113
|
-
module:
|
|
114
|
-
types:
|
|
115
|
-
files:
|
|
116
|
-
publishConfig:
|
|
117
|
-
scripts:
|
|
118
|
-
peerDependencies:
|
|
119
|
-
dependencies:
|
|
120
|
-
devDependencies:
|
|
121
|
-
},
|
|
122
|
-
const t =
|
|
104
|
+
}, Ft = {
|
|
105
|
+
name: xt,
|
|
106
|
+
type: Pt,
|
|
107
|
+
version: kt,
|
|
108
|
+
packageManager: At,
|
|
109
|
+
description: Tt,
|
|
110
|
+
author: Lt,
|
|
111
|
+
license: Ot,
|
|
112
|
+
keywords: Dt,
|
|
113
|
+
sideEffects: Bt,
|
|
114
|
+
exports: jt,
|
|
115
|
+
main: Ht,
|
|
116
|
+
module: Rt,
|
|
117
|
+
types: $t,
|
|
118
|
+
files: It,
|
|
119
|
+
publishConfig: zt,
|
|
120
|
+
scripts: Nt,
|
|
121
|
+
peerDependencies: Vt,
|
|
122
|
+
dependencies: Wt,
|
|
123
|
+
devDependencies: Ut
|
|
124
|
+
}, Gt = ({ sizes: e, scene: r }) => {
|
|
125
|
+
const t = R([]), n = P(
|
|
123
126
|
() => t.value[0]
|
|
124
|
-
),
|
|
125
|
-
t.value.some(({ uuid: c }) => c ===
|
|
126
|
-
},
|
|
127
|
-
t.value = t.value.filter(({ uuid: l }) => l !==
|
|
128
|
-
},
|
|
129
|
-
const l =
|
|
127
|
+
), s = (i, l = !1) => {
|
|
128
|
+
t.value.some(({ uuid: c }) => c === i.uuid) || (l ? o(i) : t.value.push(i));
|
|
129
|
+
}, a = (i) => {
|
|
130
|
+
t.value = t.value.filter(({ uuid: l }) => l !== i.uuid);
|
|
131
|
+
}, o = (i) => {
|
|
132
|
+
const l = i instanceof Ye ? i : t.value.find((p) => p.uuid === i);
|
|
130
133
|
if (!l)
|
|
131
134
|
return;
|
|
132
|
-
const c = t.value.filter(({ uuid:
|
|
135
|
+
const c = t.value.filter(({ uuid: p }) => p !== l.uuid);
|
|
133
136
|
t.value = [l, ...c];
|
|
134
137
|
};
|
|
135
|
-
return
|
|
136
|
-
e.aspectRatio.value && t.value.forEach((
|
|
137
|
-
|
|
138
|
+
return O(() => {
|
|
139
|
+
e.aspectRatio.value && t.value.forEach((i) => {
|
|
140
|
+
i instanceof K && (i.aspect = e.aspectRatio.value), (i instanceof K || i instanceof Qe) && i.updateProjectionMatrix();
|
|
138
141
|
});
|
|
139
|
-
}),
|
|
142
|
+
}), r.userData.tres__registerCamera = s, r.userData.tres__deregisterCamera = a, F(() => {
|
|
140
143
|
t.value = [];
|
|
141
144
|
}), {
|
|
142
|
-
camera:
|
|
145
|
+
camera: n,
|
|
143
146
|
cameras: t,
|
|
144
|
-
registerCamera:
|
|
145
|
-
deregisterCamera:
|
|
146
|
-
setCameraActive:
|
|
147
|
+
registerCamera: s,
|
|
148
|
+
deregisterCamera: a,
|
|
149
|
+
setCameraActive: o
|
|
147
150
|
};
|
|
148
|
-
},
|
|
149
|
-
let
|
|
150
|
-
const { pause:
|
|
151
|
+
}, be = H(), _e = H(), ee = H(), j = new qe();
|
|
152
|
+
let W = 0, U = 0;
|
|
153
|
+
const { pause: Jt, resume: Qt, isActive: Yt } = we(
|
|
151
154
|
() => {
|
|
152
|
-
|
|
155
|
+
be.trigger({ delta: W, elapsed: U, clock: j }), _e.trigger({ delta: W, elapsed: U, clock: j }), ee.trigger({ delta: W, elapsed: U, clock: j });
|
|
153
156
|
},
|
|
154
157
|
{ immediate: !1 }
|
|
155
158
|
);
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
ee.on(() => {
|
|
160
|
+
W = j.getDelta(), U = j.getElapsedTime();
|
|
158
161
|
});
|
|
159
|
-
const
|
|
160
|
-
onBeforeLoop:
|
|
161
|
-
onLoop:
|
|
162
|
-
onAfterLoop:
|
|
163
|
-
pause:
|
|
164
|
-
resume:
|
|
165
|
-
isActive:
|
|
166
|
-
}),
|
|
167
|
-
function
|
|
168
|
-
function e(
|
|
169
|
-
console.error(`${
|
|
162
|
+
const te = () => ({
|
|
163
|
+
onBeforeLoop: be.on,
|
|
164
|
+
onLoop: _e.on,
|
|
165
|
+
onAfterLoop: ee.on,
|
|
166
|
+
pause: Jt,
|
|
167
|
+
resume: Qt,
|
|
168
|
+
isActive: Yt
|
|
169
|
+
}), Vr = !0, le = "[TresJS ▲ ■ ●] ";
|
|
170
|
+
function T() {
|
|
171
|
+
function e(n, s) {
|
|
172
|
+
console.error(`${le} ${n}`, s || "");
|
|
170
173
|
}
|
|
171
|
-
function
|
|
172
|
-
console.warn(`${
|
|
174
|
+
function r(n) {
|
|
175
|
+
console.warn(`${le} ${n}`);
|
|
173
176
|
}
|
|
174
|
-
function t(
|
|
177
|
+
function t(n, s) {
|
|
175
178
|
}
|
|
176
179
|
return {
|
|
177
180
|
logError: e,
|
|
178
|
-
logWarning:
|
|
181
|
+
logWarning: r,
|
|
179
182
|
logMessage: t
|
|
180
183
|
};
|
|
181
184
|
}
|
|
182
|
-
function
|
|
183
|
-
return typeof e == "number" ? [e, e, e] : e instanceof
|
|
185
|
+
function Wr(e) {
|
|
186
|
+
return typeof e == "number" ? [e, e, e] : e instanceof he ? [e.x, e.y, e.z] : e;
|
|
184
187
|
}
|
|
185
|
-
function
|
|
186
|
-
return e instanceof
|
|
188
|
+
function qt(e) {
|
|
189
|
+
return e instanceof V ? e : Array.isArray(e) ? new V(...e) : new V(e);
|
|
190
|
+
}
|
|
191
|
+
class Kt extends ve.Mesh {
|
|
192
|
+
constructor(...t) {
|
|
193
|
+
super(...t);
|
|
194
|
+
J(this, "type", "HightlightMesh");
|
|
195
|
+
J(this, "createTime");
|
|
196
|
+
this.createTime = Date.now();
|
|
197
|
+
}
|
|
198
|
+
onBeforeRender() {
|
|
199
|
+
const n = (Date.now() - this.createTime) / 1e3, o = 1 + 0.07 * Math.sin(2.5 * n);
|
|
200
|
+
this.scale.set(o, o, o);
|
|
201
|
+
}
|
|
187
202
|
}
|
|
188
|
-
const
|
|
189
|
-
for (const t of Object.keys(
|
|
190
|
-
|
|
191
|
-
return Object.assign(e || {},
|
|
192
|
-
},
|
|
193
|
-
function
|
|
203
|
+
const Ee = (e, r) => {
|
|
204
|
+
for (const t of Object.keys(r))
|
|
205
|
+
r[t] instanceof Object && Object.assign(r[t], Ee(e[t], r[t]));
|
|
206
|
+
return Object.assign(e || {}, r), e;
|
|
207
|
+
}, Xt = "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", Zt = /* @__PURE__ */ er(Xt);
|
|
208
|
+
function ue(e) {
|
|
194
209
|
return e && e.nodeType === 1;
|
|
195
210
|
}
|
|
196
|
-
function
|
|
197
|
-
return e.replace(/-([a-z])/g, (
|
|
211
|
+
function I(e) {
|
|
212
|
+
return e.replace(/-([a-z])/g, (r, t) => t.toUpperCase());
|
|
198
213
|
}
|
|
199
|
-
function
|
|
200
|
-
const t = /* @__PURE__ */ Object.create(null),
|
|
201
|
-
for (let
|
|
202
|
-
t[
|
|
203
|
-
return
|
|
214
|
+
function er(e, r) {
|
|
215
|
+
const t = /* @__PURE__ */ Object.create(null), n = e.split(",");
|
|
216
|
+
for (let s = 0; s < n.length; s++)
|
|
217
|
+
t[n[s]] = !0;
|
|
218
|
+
return r ? (s) => !!t[s.toLowerCase()] : (s) => !!t[s];
|
|
204
219
|
}
|
|
205
|
-
const
|
|
206
|
-
const t = /* @__PURE__ */ new Set(),
|
|
207
|
-
for (const
|
|
208
|
-
const
|
|
209
|
-
t.has(
|
|
220
|
+
const tr = (e, r) => {
|
|
221
|
+
const t = /* @__PURE__ */ new Set(), n = [];
|
|
222
|
+
for (const s of e) {
|
|
223
|
+
const a = r(s);
|
|
224
|
+
t.has(a) || (t.add(a), n.push(s));
|
|
210
225
|
}
|
|
211
|
-
return
|
|
212
|
-
},
|
|
213
|
-
if (!
|
|
226
|
+
return n;
|
|
227
|
+
}, ce = (e, r) => {
|
|
228
|
+
if (!r)
|
|
214
229
|
return;
|
|
215
|
-
const t = Array.isArray(
|
|
216
|
-
return t == null ? void 0 : t.reduce((
|
|
217
|
-
},
|
|
218
|
-
const
|
|
219
|
-
|
|
230
|
+
const t = Array.isArray(r) ? r : r.match(/([^[.\]])+/g);
|
|
231
|
+
return t == null ? void 0 : t.reduce((n, s) => n && n[s], e);
|
|
232
|
+
}, rr = (e, r, t) => {
|
|
233
|
+
const n = Array.isArray(r) ? r : r.match(/([^[.\]])+/g);
|
|
234
|
+
n && n.reduce((s, a, o) => (s[a] === void 0 && (s[a] = {}), o === n.length - 1 && (s[a] = t), s[a]), e);
|
|
220
235
|
};
|
|
221
|
-
function
|
|
222
|
-
if (
|
|
223
|
-
const
|
|
224
|
-
return
|
|
236
|
+
function Me(e, r) {
|
|
237
|
+
if (ue(e) && ue(r)) {
|
|
238
|
+
const s = e.attributes, a = r.attributes;
|
|
239
|
+
return s.length !== a.length ? !1 : Array.from(s).every(({ name: o, value: i }) => r.getAttribute(o) === i);
|
|
225
240
|
}
|
|
226
|
-
if (e ===
|
|
241
|
+
if (e === r)
|
|
227
242
|
return !0;
|
|
228
|
-
if (e === null || typeof e != "object" ||
|
|
243
|
+
if (e === null || typeof e != "object" || r === null || typeof r != "object")
|
|
229
244
|
return !1;
|
|
230
|
-
const t = Object.keys(e),
|
|
231
|
-
if (t.length !==
|
|
245
|
+
const t = Object.keys(e), n = Object.keys(r);
|
|
246
|
+
if (t.length !== n.length)
|
|
232
247
|
return !1;
|
|
233
|
-
for (const
|
|
234
|
-
if (!
|
|
248
|
+
for (const s of t)
|
|
249
|
+
if (!n.includes(s) || !Me(e[s], r[s]))
|
|
235
250
|
return !1;
|
|
236
251
|
return !0;
|
|
237
252
|
}
|
|
238
|
-
function
|
|
239
|
-
if (!Array.isArray(e) || !Array.isArray(
|
|
253
|
+
function nr(e, r) {
|
|
254
|
+
if (!Array.isArray(e) || !Array.isArray(r) || e.length !== r.length)
|
|
240
255
|
return !1;
|
|
241
256
|
for (let t = 0; t < e.length; t++)
|
|
242
|
-
if (!
|
|
257
|
+
if (!Me(e[t], r[t]))
|
|
243
258
|
return !1;
|
|
244
259
|
return !0;
|
|
245
260
|
}
|
|
246
|
-
const
|
|
261
|
+
const or = Array.isArray;
|
|
262
|
+
function sr(e, r, t, n) {
|
|
263
|
+
const s = (l) => {
|
|
264
|
+
if (l.uuid === r)
|
|
265
|
+
return l;
|
|
266
|
+
for (const c of l.children) {
|
|
267
|
+
const p = s(c);
|
|
268
|
+
if (p)
|
|
269
|
+
return p;
|
|
270
|
+
}
|
|
271
|
+
}, a = s(e);
|
|
272
|
+
if (!a) {
|
|
273
|
+
console.warn("Object with UUID not found in the scene.");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
let o = a;
|
|
277
|
+
for (let l = 0; l < t.length - 1; l++)
|
|
278
|
+
if (o[t[l]] !== void 0)
|
|
279
|
+
o = o[t[l]];
|
|
280
|
+
else {
|
|
281
|
+
console.warn(`Property path is not valid: ${t.join(".")}`);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const i = t[t.length - 1];
|
|
285
|
+
o[i] !== void 0 ? o[i] = n : console.warn(`Property path is not valid: ${t.join(".")}`);
|
|
286
|
+
}
|
|
287
|
+
function ir(e) {
|
|
288
|
+
const r = new ye({
|
|
289
|
+
color: 11003607,
|
|
290
|
+
// Highlight color, e.g., yellow
|
|
291
|
+
transparent: !0,
|
|
292
|
+
opacity: 0.2,
|
|
293
|
+
depthTest: !1,
|
|
294
|
+
// So the highlight is always visible
|
|
295
|
+
side: Ke
|
|
296
|
+
// To e
|
|
297
|
+
});
|
|
298
|
+
return new Kt(e.geometry.clone(), r);
|
|
299
|
+
}
|
|
300
|
+
function Ce(e) {
|
|
301
|
+
var t;
|
|
302
|
+
let r = e.value;
|
|
303
|
+
return e.value && ((t = e.value) != null && t.isMesh) && (r = e.value.position), Array.isArray(e.value) && (r = new he(...r)), r;
|
|
304
|
+
}
|
|
305
|
+
const ar = Number.parseInt(Xe.replace("dev", "")), z = {
|
|
247
306
|
realistic: {
|
|
248
307
|
shadows: !0,
|
|
249
308
|
physicallyCorrectLights: !0,
|
|
250
|
-
outputColorSpace:
|
|
251
|
-
toneMapping:
|
|
309
|
+
outputColorSpace: Ze,
|
|
310
|
+
toneMapping: et,
|
|
252
311
|
toneMappingExposure: 3,
|
|
253
312
|
shadowMap: {
|
|
254
313
|
enabled: !0,
|
|
255
|
-
type:
|
|
314
|
+
type: tt
|
|
256
315
|
}
|
|
257
316
|
}
|
|
258
317
|
};
|
|
259
|
-
function
|
|
318
|
+
function lr({
|
|
260
319
|
scene: e,
|
|
261
|
-
canvas:
|
|
320
|
+
canvas: r,
|
|
262
321
|
options: t,
|
|
263
|
-
disableRender:
|
|
264
|
-
contextParts: { sizes:
|
|
322
|
+
disableRender: n,
|
|
323
|
+
contextParts: { sizes: s, camera: a }
|
|
265
324
|
}) {
|
|
266
|
-
const
|
|
267
|
-
alpha:
|
|
268
|
-
depth:
|
|
269
|
-
canvas:
|
|
270
|
-
context:
|
|
271
|
-
stencil:
|
|
272
|
-
antialias:
|
|
273
|
-
precision:
|
|
274
|
-
powerPreference:
|
|
275
|
-
premultipliedAlpha:
|
|
276
|
-
preserveDrawingBuffer:
|
|
277
|
-
logarithmicDepthBuffer:
|
|
278
|
-
failIfMajorPerformanceCaveat:
|
|
279
|
-
})),
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}),
|
|
283
|
-
|
|
325
|
+
const o = P(() => ({
|
|
326
|
+
alpha: M(t.alpha),
|
|
327
|
+
depth: M(t.depth),
|
|
328
|
+
canvas: ht(r),
|
|
329
|
+
context: M(t.context),
|
|
330
|
+
stencil: M(t.stencil),
|
|
331
|
+
antialias: M(t.antialias) === void 0 ? !0 : M(t.antialias),
|
|
332
|
+
precision: M(t.precision),
|
|
333
|
+
powerPreference: M(t.powerPreference),
|
|
334
|
+
premultipliedAlpha: M(t.premultipliedAlpha),
|
|
335
|
+
preserveDrawingBuffer: M(t.preserveDrawingBuffer),
|
|
336
|
+
logarithmicDepthBuffer: M(t.logarithmicDepthBuffer),
|
|
337
|
+
failIfMajorPerformanceCaveat: M(t.failIfMajorPerformanceCaveat)
|
|
338
|
+
})), i = D(new Q(o.value));
|
|
339
|
+
me(o, () => {
|
|
340
|
+
i.value.dispose(), i.value = new Q(o.value);
|
|
341
|
+
}), O(() => {
|
|
342
|
+
i.value.setSize(s.width.value, s.height.value);
|
|
284
343
|
});
|
|
285
|
-
const { pixelRatio: l } =
|
|
286
|
-
|
|
287
|
-
|
|
344
|
+
const { pixelRatio: l } = yt();
|
|
345
|
+
O(() => {
|
|
346
|
+
i.value.setPixelRatio(l.value);
|
|
288
347
|
});
|
|
289
|
-
const { logError: c } =
|
|
290
|
-
const
|
|
348
|
+
const { logError: c } = T(), d = (() => {
|
|
349
|
+
const f = new Q(), h = {
|
|
291
350
|
shadowMap: {
|
|
292
|
-
enabled:
|
|
293
|
-
type:
|
|
351
|
+
enabled: f.shadowMap.enabled,
|
|
352
|
+
type: f.shadowMap.type
|
|
294
353
|
},
|
|
295
|
-
toneMapping:
|
|
296
|
-
toneMappingExposure:
|
|
297
|
-
outputColorSpace:
|
|
354
|
+
toneMapping: f.toneMapping,
|
|
355
|
+
toneMappingExposure: f.toneMappingExposure,
|
|
356
|
+
outputColorSpace: f.outputColorSpace
|
|
298
357
|
};
|
|
299
|
-
return
|
|
358
|
+
return f.dispose(), h;
|
|
300
359
|
})();
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
const
|
|
306
|
-
if (
|
|
307
|
-
return
|
|
360
|
+
O(() => {
|
|
361
|
+
const f = M(t.preset);
|
|
362
|
+
f && (f in z || c(`Renderer Preset must be one of these: ${Object.keys(z).join(", ")}`), Ee(i.value, z[f]));
|
|
363
|
+
const h = (C, S) => {
|
|
364
|
+
const b = M(C), x = () => {
|
|
365
|
+
if (f)
|
|
366
|
+
return ce(z[f], S);
|
|
308
367
|
};
|
|
309
|
-
if (
|
|
310
|
-
return
|
|
311
|
-
const
|
|
312
|
-
return
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
const w =
|
|
316
|
-
w &&
|
|
317
|
-
w ?
|
|
368
|
+
if (b !== void 0)
|
|
369
|
+
return b;
|
|
370
|
+
const g = x();
|
|
371
|
+
return g !== void 0 ? g : ce(d, S);
|
|
372
|
+
}, _ = (C, S) => rr(i.value, S, h(C, S));
|
|
373
|
+
_(t.shadows, "shadowMap.enabled"), _(t.toneMapping, "toneMapping"), _(t.shadowMapType, "shadowMap.type"), ar < 150 && _(!t.useLegacyLights, "physicallyCorrectLights"), _(t.outputColorSpace, "outputColorSpace"), _(t.toneMappingExposure, "toneMappingExposure");
|
|
374
|
+
const w = h(t.clearColor, "clearColor");
|
|
375
|
+
w && i.value.setClearColor(
|
|
376
|
+
w ? qt(w) : new V(0)
|
|
318
377
|
// default clear color is not easily/efficiently retrievable from three
|
|
319
378
|
);
|
|
320
379
|
});
|
|
321
|
-
const { pause:
|
|
322
|
-
return
|
|
323
|
-
|
|
324
|
-
}), m(),
|
|
325
|
-
|
|
380
|
+
const { pause: u, resume: m, onLoop: y } = te();
|
|
381
|
+
return y(() => {
|
|
382
|
+
a.value && !M(n) && i.value.render(e, a.value);
|
|
383
|
+
}), m(), F(() => {
|
|
384
|
+
u(), i.value.dispose(), i.value.forceContextLoss();
|
|
326
385
|
}), {
|
|
327
|
-
renderer:
|
|
386
|
+
renderer: i
|
|
328
387
|
};
|
|
329
388
|
}
|
|
330
|
-
const
|
|
331
|
-
function
|
|
332
|
-
const
|
|
389
|
+
const de = (e) => typeof e == "function", ur = (e) => !!e && e.constructor === Array;
|
|
390
|
+
function cr(e) {
|
|
391
|
+
const r = { nodes: {}, materials: {} };
|
|
333
392
|
return e && e.traverse((t) => {
|
|
334
|
-
t.name && (
|
|
335
|
-
}),
|
|
393
|
+
t.name && (r.nodes[t.name] = t), t.material && !r.materials[t.material.name] && (r.materials[t.material.name] = t.material);
|
|
394
|
+
}), r;
|
|
336
395
|
}
|
|
337
|
-
async function
|
|
338
|
-
const { logError:
|
|
339
|
-
|
|
340
|
-
const l = (Array.isArray(
|
|
341
|
-
(c) => new Promise((
|
|
342
|
-
|
|
396
|
+
async function Ur(e, r, t, n, s) {
|
|
397
|
+
const { logError: a } = T(), o = new e();
|
|
398
|
+
s && s(o), t && t(o);
|
|
399
|
+
const l = (Array.isArray(r) ? r : [r]).map(
|
|
400
|
+
(c) => new Promise((p, d) => {
|
|
401
|
+
o.load(
|
|
343
402
|
c,
|
|
344
|
-
(
|
|
345
|
-
|
|
403
|
+
(u) => {
|
|
404
|
+
u.scene && Object.assign(u, cr(u.scene)), p(u);
|
|
346
405
|
},
|
|
347
|
-
|
|
348
|
-
(
|
|
406
|
+
n,
|
|
407
|
+
(u) => d(a("[useLoader] - Failed to load resource", u))
|
|
349
408
|
);
|
|
350
409
|
})
|
|
351
410
|
);
|
|
352
|
-
return
|
|
411
|
+
return ur(r) ? await Promise.all(l) : await l[0];
|
|
353
412
|
}
|
|
354
|
-
async function
|
|
355
|
-
const
|
|
413
|
+
async function Fr(e) {
|
|
414
|
+
const r = new rt(), t = new nt(r), n = (s) => new Promise((a, o) => {
|
|
356
415
|
t.load(
|
|
357
|
-
|
|
358
|
-
(
|
|
416
|
+
s,
|
|
417
|
+
(i) => a(i),
|
|
359
418
|
() => null,
|
|
360
419
|
() => {
|
|
361
|
-
|
|
420
|
+
o(new Error("[useTextures] - Failed to load texture"));
|
|
362
421
|
}
|
|
363
422
|
);
|
|
364
423
|
});
|
|
365
|
-
if (
|
|
366
|
-
const
|
|
367
|
-
return e.length > 1 ?
|
|
424
|
+
if (or(e)) {
|
|
425
|
+
const s = await Promise.all(e.map((a) => n(a)));
|
|
426
|
+
return e.length > 1 ? s : s[0];
|
|
368
427
|
} else {
|
|
369
428
|
const {
|
|
370
|
-
map:
|
|
371
|
-
displacementMap:
|
|
372
|
-
normalMap:
|
|
373
|
-
roughnessMap:
|
|
429
|
+
map: s,
|
|
430
|
+
displacementMap: a,
|
|
431
|
+
normalMap: o,
|
|
432
|
+
roughnessMap: i,
|
|
374
433
|
metalnessMap: l,
|
|
375
434
|
aoMap: c,
|
|
376
|
-
alphaMap:
|
|
377
|
-
matcap:
|
|
435
|
+
alphaMap: p,
|
|
436
|
+
matcap: d
|
|
378
437
|
} = e;
|
|
379
438
|
return {
|
|
380
|
-
map:
|
|
381
|
-
displacementMap:
|
|
382
|
-
normalMap:
|
|
383
|
-
roughnessMap:
|
|
384
|
-
metalnessMap: l ? await
|
|
385
|
-
aoMap: c ? await
|
|
386
|
-
alphaMap:
|
|
387
|
-
matcap:
|
|
439
|
+
map: s ? await n(s) : null,
|
|
440
|
+
displacementMap: a ? await n(a) : null,
|
|
441
|
+
normalMap: o ? await n(o) : null,
|
|
442
|
+
roughnessMap: i ? await n(i) : null,
|
|
443
|
+
metalnessMap: l ? await n(l) : null,
|
|
444
|
+
aoMap: c ? await n(c) : null,
|
|
445
|
+
alphaMap: p ? await n(p) : null,
|
|
446
|
+
matcap: d ? await n(d) : null
|
|
388
447
|
};
|
|
389
448
|
}
|
|
390
449
|
}
|
|
391
|
-
const
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
450
|
+
const dr = (e, { renderer: r, camera: t, raycaster: n }) => {
|
|
451
|
+
const s = P(() => r.value.domElement), { x: a, y: o } = wt({ target: s }), { width: i, height: l, top: c, left: p } = bt(s), d = ({ x: g, y: E }) => {
|
|
452
|
+
if (s.value)
|
|
394
453
|
return {
|
|
395
|
-
x: (
|
|
396
|
-
y: -((
|
|
454
|
+
x: (g - p.value) / i.value * 2 - 1,
|
|
455
|
+
y: -((E - c.value) / l.value) * 2 + 1
|
|
397
456
|
};
|
|
398
|
-
},
|
|
457
|
+
}, u = ({ x: g, y: E }) => {
|
|
399
458
|
if (t.value)
|
|
400
|
-
return
|
|
401
|
-
}, m = (
|
|
402
|
-
const
|
|
403
|
-
x: (
|
|
404
|
-
y: (
|
|
459
|
+
return n.value.setFromCamera(new ot(g, E), t.value), n.value.intersectObjects(e.value, !1);
|
|
460
|
+
}, m = (g) => {
|
|
461
|
+
const E = d({
|
|
462
|
+
x: (g == null ? void 0 : g.clientX) ?? a.value,
|
|
463
|
+
y: (g == null ? void 0 : g.clientY) ?? o.value
|
|
405
464
|
});
|
|
406
|
-
return
|
|
407
|
-
},
|
|
408
|
-
|
|
409
|
-
}, w = (
|
|
410
|
-
|
|
465
|
+
return E ? u(E) || [] : [];
|
|
466
|
+
}, y = P(() => m()), f = H(), h = H(), _ = (g, E) => {
|
|
467
|
+
g.trigger({ event: E, intersects: m(E) });
|
|
468
|
+
}, w = (g) => {
|
|
469
|
+
_(h, g);
|
|
411
470
|
};
|
|
412
|
-
let
|
|
413
|
-
const
|
|
414
|
-
var
|
|
415
|
-
|
|
416
|
-
},
|
|
417
|
-
var
|
|
418
|
-
|
|
419
|
-
},
|
|
420
|
-
return
|
|
421
|
-
|
|
471
|
+
let C;
|
|
472
|
+
const S = (g) => {
|
|
473
|
+
var E;
|
|
474
|
+
C = (E = m(g)[0]) == null ? void 0 : E.object;
|
|
475
|
+
}, b = (g) => {
|
|
476
|
+
var E;
|
|
477
|
+
g instanceof PointerEvent && C === ((E = m(g)[0]) == null ? void 0 : E.object) && _(f, g);
|
|
478
|
+
}, x = (g) => h.trigger({ event: g, intersects: [] });
|
|
479
|
+
return s.value.addEventListener("pointerup", b), s.value.addEventListener("pointerdown", S), s.value.addEventListener("pointermove", w), s.value.addEventListener("pointerleave", x), F(() => {
|
|
480
|
+
s != null && s.value && (s.value.removeEventListener("pointerup", b), s.value.removeEventListener("pointerdown", S), s.value.removeEventListener("pointermove", w), s.value.removeEventListener("pointerleave", x));
|
|
422
481
|
}), {
|
|
423
|
-
intersects:
|
|
424
|
-
onClick: (
|
|
425
|
-
onPointerMove: (
|
|
482
|
+
intersects: y,
|
|
483
|
+
onClick: (g) => f.on(g).off,
|
|
484
|
+
onPointerMove: (g) => h.on(g).off
|
|
426
485
|
};
|
|
427
486
|
};
|
|
428
|
-
function
|
|
429
|
-
const { logWarning: e } =
|
|
430
|
-
function
|
|
487
|
+
function Gr() {
|
|
488
|
+
const { logWarning: e } = T();
|
|
489
|
+
function r(a, o, i) {
|
|
431
490
|
let l = null;
|
|
432
|
-
return
|
|
433
|
-
c[
|
|
434
|
-
}), l || e(`Child with ${
|
|
491
|
+
return a.traverse((c) => {
|
|
492
|
+
c[o] === i && (l = c);
|
|
493
|
+
}), l || e(`Child with ${o} '${i}' not found.`), l;
|
|
435
494
|
}
|
|
436
|
-
function t(
|
|
495
|
+
function t(a, o, i) {
|
|
437
496
|
const l = [];
|
|
438
|
-
return
|
|
439
|
-
c[
|
|
440
|
-
}), l.length || e(`Children with ${
|
|
497
|
+
return a.traverse((c) => {
|
|
498
|
+
c[o].includes(i) && l.push(c);
|
|
499
|
+
}), l.length || e(`Children with ${o} '${i}' not found.`), l;
|
|
441
500
|
}
|
|
442
|
-
function
|
|
443
|
-
return
|
|
501
|
+
function n(a, o) {
|
|
502
|
+
return r(a, "name", o);
|
|
444
503
|
}
|
|
445
|
-
function
|
|
446
|
-
return t(
|
|
504
|
+
function s(a, o) {
|
|
505
|
+
return t(a, "name", o);
|
|
447
506
|
}
|
|
448
507
|
return {
|
|
449
|
-
seek:
|
|
450
|
-
seekByName:
|
|
508
|
+
seek: r,
|
|
509
|
+
seekByName: n,
|
|
451
510
|
seekAll: t,
|
|
452
|
-
seekAllByName:
|
|
511
|
+
seekAllByName: s
|
|
453
512
|
};
|
|
454
513
|
}
|
|
455
|
-
const
|
|
456
|
-
const t =
|
|
514
|
+
const fr = ({ scene: e, contextParts: r }) => {
|
|
515
|
+
const t = ge({
|
|
457
516
|
click: /* @__PURE__ */ new Map(),
|
|
458
517
|
pointerMove: /* @__PURE__ */ new Map(),
|
|
459
518
|
pointerEnter: /* @__PURE__ */ new Map(),
|
|
460
519
|
pointerLeave: /* @__PURE__ */ new Map()
|
|
461
|
-
}),
|
|
462
|
-
|
|
463
|
-
},
|
|
464
|
-
|
|
465
|
-
},
|
|
466
|
-
Object.values(t).forEach((m) => m.delete(
|
|
467
|
-
},
|
|
468
|
-
const { onClick: m, onPointerMove:
|
|
469
|
-
m && t.click.set(
|
|
520
|
+
}), n = R(/* @__PURE__ */ new Set()), s = (u) => {
|
|
521
|
+
n.value.add(u);
|
|
522
|
+
}, a = (u) => {
|
|
523
|
+
n.value.delete(u);
|
|
524
|
+
}, o = (u) => {
|
|
525
|
+
Object.values(t).forEach((m) => m.delete(u)), a(u);
|
|
526
|
+
}, i = (u) => {
|
|
527
|
+
const { onClick: m, onPointerMove: y, onPointerEnter: f, onPointerLeave: h } = u;
|
|
528
|
+
m && t.click.set(u, m), y && t.pointerMove.set(u, y), f && t.pointerEnter.set(u, f), h && t.pointerLeave.set(u, h);
|
|
470
529
|
};
|
|
471
|
-
e.userData.tres__registerAtPointerEventHandler =
|
|
472
|
-
const l =
|
|
473
|
-
() =>
|
|
530
|
+
e.userData.tres__registerAtPointerEventHandler = i, e.userData.tres__deregisterAtPointerEventHandler = o, e.userData.tres__registerBlockingObjectAtPointerEventHandler = s, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = a;
|
|
531
|
+
const l = P(
|
|
532
|
+
() => tr(
|
|
474
533
|
[
|
|
475
|
-
...Array.from(
|
|
476
|
-
...Object.values(t).map((
|
|
534
|
+
...Array.from(n.value),
|
|
535
|
+
...Object.values(t).map((u) => Array.from(u.keys())).flat()
|
|
477
536
|
],
|
|
478
|
-
({ uuid:
|
|
537
|
+
({ uuid: u }) => u
|
|
479
538
|
)
|
|
480
|
-
), { onClick: c, onPointerMove:
|
|
481
|
-
c(({ intersects:
|
|
482
|
-
var
|
|
483
|
-
|
|
539
|
+
), { onClick: c, onPointerMove: p } = dr(l, r);
|
|
540
|
+
c(({ intersects: u, event: m }) => {
|
|
541
|
+
var y;
|
|
542
|
+
u.length && ((y = t.click.get(u[0].object)) == null || y(u[0], m));
|
|
484
543
|
});
|
|
485
|
-
let
|
|
486
|
-
return
|
|
487
|
-
var w,
|
|
488
|
-
const
|
|
489
|
-
|
|
544
|
+
let d;
|
|
545
|
+
return p(({ intersects: u, event: m }) => {
|
|
546
|
+
var w, C, S, b;
|
|
547
|
+
const y = (w = u == null ? void 0 : u[0]) == null ? void 0 : w.object, { pointerLeave: f, pointerEnter: h, pointerMove: _ } = t;
|
|
548
|
+
d && d !== y && ((C = f.get(d)) == null || C(d, m)), y && (d !== y && ((S = h.get(y)) == null || S(u[0], m)), (b = _.get(y)) == null || b(u[0], m)), d = y || null;
|
|
490
549
|
}), {
|
|
491
|
-
registerObject:
|
|
492
|
-
deregisterObject:
|
|
550
|
+
registerObject: i,
|
|
551
|
+
deregisterObject: o
|
|
493
552
|
};
|
|
494
553
|
};
|
|
495
|
-
function
|
|
496
|
-
let
|
|
554
|
+
function Se(e) {
|
|
555
|
+
let r = 0;
|
|
497
556
|
return e.traverse((t) => {
|
|
498
557
|
if (t.isMesh && t.geometry) {
|
|
499
|
-
const
|
|
500
|
-
|
|
558
|
+
const n = t.geometry, s = n.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, a = n.index ? n.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, o = n.attributes.normal ? n.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, i = n.attributes.uv ? n.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = s + a + o + i;
|
|
559
|
+
r += l;
|
|
501
560
|
}
|
|
502
|
-
}),
|
|
561
|
+
}), r;
|
|
562
|
+
}
|
|
563
|
+
function pr(e) {
|
|
564
|
+
return (e / 1024).toFixed(2);
|
|
503
565
|
}
|
|
504
|
-
const
|
|
505
|
-
function
|
|
566
|
+
const X = R({}), re = (e) => Object.assign(X.value, e);
|
|
567
|
+
function mr({
|
|
506
568
|
scene: e,
|
|
507
|
-
canvas:
|
|
569
|
+
canvas: r,
|
|
508
570
|
windowSize: t,
|
|
509
|
-
disableRender:
|
|
510
|
-
rendererOptions:
|
|
571
|
+
disableRender: n,
|
|
572
|
+
rendererOptions: s
|
|
511
573
|
}) {
|
|
512
|
-
const
|
|
513
|
-
() =>
|
|
514
|
-
),
|
|
574
|
+
const a = P(
|
|
575
|
+
() => M(t) ? _t() : Et(M(r).parentElement)
|
|
576
|
+
), o = D({
|
|
515
577
|
width: 0,
|
|
516
578
|
height: 0
|
|
517
|
-
}),
|
|
518
|
-
|
|
519
|
-
width:
|
|
520
|
-
height:
|
|
579
|
+
}), i = Mt(o, 10), l = O(() => {
|
|
580
|
+
o.value = {
|
|
581
|
+
width: a.value.width.value,
|
|
582
|
+
height: a.value.height.value
|
|
521
583
|
};
|
|
522
|
-
}), c =
|
|
523
|
-
height:
|
|
524
|
-
width:
|
|
584
|
+
}), c = P(() => i.value.width / i.value.height), p = {
|
|
585
|
+
height: P(() => i.value.height),
|
|
586
|
+
width: P(() => i.value.width),
|
|
525
587
|
aspectRatio: c
|
|
526
|
-
},
|
|
527
|
-
camera:
|
|
588
|
+
}, d = D(e), {
|
|
589
|
+
camera: u,
|
|
528
590
|
cameras: m,
|
|
529
|
-
registerCamera:
|
|
530
|
-
deregisterCamera:
|
|
531
|
-
setCameraActive:
|
|
532
|
-
} =
|
|
591
|
+
registerCamera: y,
|
|
592
|
+
deregisterCamera: f,
|
|
593
|
+
setCameraActive: h
|
|
594
|
+
} = Gt({ sizes: p, scene: e }), { renderer: _ } = lr(
|
|
533
595
|
{
|
|
534
596
|
scene: e,
|
|
535
|
-
canvas:
|
|
536
|
-
options:
|
|
537
|
-
contextParts: { sizes:
|
|
538
|
-
disableRender:
|
|
597
|
+
canvas: r,
|
|
598
|
+
options: s,
|
|
599
|
+
contextParts: { sizes: p, camera: u },
|
|
600
|
+
disableRender: n
|
|
539
601
|
}
|
|
540
602
|
), w = {
|
|
541
|
-
sizes:
|
|
542
|
-
scene:
|
|
543
|
-
camera:
|
|
544
|
-
cameras:
|
|
545
|
-
renderer:
|
|
546
|
-
raycaster:
|
|
547
|
-
controls:
|
|
603
|
+
sizes: p,
|
|
604
|
+
scene: d,
|
|
605
|
+
camera: u,
|
|
606
|
+
cameras: Re(m),
|
|
607
|
+
renderer: _,
|
|
608
|
+
raycaster: D(new st()),
|
|
609
|
+
controls: R(null),
|
|
548
610
|
perf: {
|
|
549
611
|
maxFrames: 160,
|
|
550
612
|
fps: {
|
|
@@ -557,136 +619,136 @@ function Rt({
|
|
|
557
619
|
accumulator: []
|
|
558
620
|
}
|
|
559
621
|
},
|
|
560
|
-
extend:
|
|
561
|
-
registerCamera:
|
|
562
|
-
setCameraActive:
|
|
563
|
-
deregisterCamera:
|
|
622
|
+
extend: re,
|
|
623
|
+
registerCamera: y,
|
|
624
|
+
setCameraActive: h,
|
|
625
|
+
deregisterCamera: f
|
|
564
626
|
};
|
|
565
|
-
|
|
566
|
-
const
|
|
567
|
-
let
|
|
568
|
-
const
|
|
569
|
-
w.scene.value && (w.perf.memory.allocatedMem =
|
|
627
|
+
q("useTres", w);
|
|
628
|
+
const C = 100, S = Ct({ every: C }), { isSupported: b, memory: x } = St({ interval: C }), g = 160;
|
|
629
|
+
let E = performance.now();
|
|
630
|
+
const Te = ({ timestamp: $ }) => {
|
|
631
|
+
w.scene.value && (w.perf.memory.allocatedMem = Se(w.scene.value)), $ - E >= C && (E = $, w.perf.fps.accumulator.push(S.value), w.perf.fps.accumulator.length > g && w.perf.fps.accumulator.shift(), w.perf.fps.value = S.value, b.value && x.value && (w.perf.memory.accumulator.push(x.value.usedJSHeapSize / 1024 / 1024), w.perf.memory.accumulator.length > g && w.perf.memory.accumulator.shift(), w.perf.memory.currentMem = w.perf.memory.accumulator.reduce((De, Be) => De + Be, 0) / w.perf.memory.accumulator.length));
|
|
570
632
|
};
|
|
571
|
-
let
|
|
572
|
-
const
|
|
573
|
-
window.__TRES__DEVTOOLS__ && (
|
|
633
|
+
let G = 0;
|
|
634
|
+
const Le = 1, { pause: Oe, resume: Rr } = we(({ delta: $ }) => {
|
|
635
|
+
window.__TRES__DEVTOOLS__ && (Te({ timestamp: performance.now() }), G += $, G >= Le && (window.__TRES__DEVTOOLS__.cb(w), G = 0));
|
|
574
636
|
}, { immediate: !0 });
|
|
575
|
-
return
|
|
576
|
-
l(),
|
|
637
|
+
return F(() => {
|
|
638
|
+
l(), Oe();
|
|
577
639
|
}), w;
|
|
578
640
|
}
|
|
579
|
-
function
|
|
580
|
-
const e =
|
|
641
|
+
function gr() {
|
|
642
|
+
const e = $e("useTres");
|
|
581
643
|
if (!e)
|
|
582
644
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
583
645
|
return e;
|
|
584
646
|
}
|
|
585
|
-
const
|
|
586
|
-
let
|
|
587
|
-
const { logError:
|
|
647
|
+
const Jr = gr;
|
|
648
|
+
let v = null;
|
|
649
|
+
const { logError: fe } = T(), Y = [
|
|
588
650
|
"onClick",
|
|
589
651
|
"onPointerMove",
|
|
590
652
|
"onPointerEnter",
|
|
591
653
|
"onPointerLeave"
|
|
592
|
-
],
|
|
593
|
-
createElement(e,
|
|
594
|
-
var
|
|
595
|
-
if (
|
|
654
|
+
], vr = {
|
|
655
|
+
createElement(e, r, t, n) {
|
|
656
|
+
var o, i;
|
|
657
|
+
if (n || (n = {}), n.args || (n.args = []), e === "template" || Zt(e))
|
|
596
658
|
return null;
|
|
597
|
-
let
|
|
659
|
+
let s = e.replace("Tres", ""), a;
|
|
598
660
|
if (e === "primitive") {
|
|
599
|
-
(
|
|
600
|
-
const l =
|
|
601
|
-
|
|
661
|
+
(n == null ? void 0 : n.object) === void 0 && fe("Tres primitives need a prop 'object'");
|
|
662
|
+
const l = n.object;
|
|
663
|
+
s = l.type, a = Object.assign(l, { type: s, attach: n.attach, primitive: !0 });
|
|
602
664
|
} else {
|
|
603
|
-
const l =
|
|
604
|
-
l ||
|
|
665
|
+
const l = X.value[s];
|
|
666
|
+
l || fe(`${s} is not defined on the THREE namespace. Use extend to add it to the catalog.`), a = new l(...n.args);
|
|
605
667
|
}
|
|
606
|
-
return
|
|
607
|
-
...
|
|
608
|
-
tres__name:
|
|
609
|
-
},
|
|
668
|
+
return a.isCamera && (n != null && n.position || a.position.set(3, 3, 3), n != null && n.lookAt || a.lookAt(0, 0, 0)), (n == null ? void 0 : n.attach) === void 0 && (a.isMaterial ? a.attach = "material" : a.isBufferGeometry && (a.attach = "geometry")), a.isObject3D && ((o = n == null ? void 0 : n.material) != null && o.isMaterial && (a.userData.tres__materialViaProp = !0), (i = n == null ? void 0 : n.geometry) != null && i.isBufferGeometry && (a.userData.tres__geometryViaProp = !0)), a.userData = {
|
|
669
|
+
...a.userData,
|
|
670
|
+
tres__name: s
|
|
671
|
+
}, a;
|
|
610
672
|
},
|
|
611
|
-
insert(e,
|
|
612
|
-
var
|
|
613
|
-
|
|
614
|
-
const t =
|
|
673
|
+
insert(e, r) {
|
|
674
|
+
var n, s, a, o;
|
|
675
|
+
r && r.isScene && (v = r);
|
|
676
|
+
const t = r || v;
|
|
615
677
|
if (e != null && e.isObject3D) {
|
|
616
678
|
if (e != null && e.isCamera) {
|
|
617
|
-
if (!(
|
|
679
|
+
if (!(v != null && v.userData.tres__registerCamera))
|
|
618
680
|
throw "could not find tres__registerCamera on scene's userData";
|
|
619
|
-
(
|
|
681
|
+
(s = v == null ? void 0 : (n = v.userData).tres__registerCamera) == null || s.call(n, e);
|
|
620
682
|
}
|
|
621
|
-
if (e &&
|
|
622
|
-
if (!(
|
|
683
|
+
if (e && Y.some((i) => e[i])) {
|
|
684
|
+
if (!(v != null && v.userData.tres__registerAtPointerEventHandler))
|
|
623
685
|
throw "could not find tres__registerAtPointerEventHandler on scene's userData";
|
|
624
|
-
(
|
|
686
|
+
(o = v == null ? void 0 : (a = v.userData).tres__registerAtPointerEventHandler) == null || o.call(a, e);
|
|
625
687
|
}
|
|
626
688
|
}
|
|
627
689
|
e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : e != null && e.isFog ? t.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
|
|
628
690
|
},
|
|
629
691
|
remove(e) {
|
|
630
|
-
var
|
|
692
|
+
var r, t;
|
|
631
693
|
if (e) {
|
|
632
694
|
if (e.isObject3D) {
|
|
633
|
-
const
|
|
634
|
-
var
|
|
635
|
-
const
|
|
636
|
-
c.userData.tres__materialViaProp || ((
|
|
637
|
-
},
|
|
638
|
-
var
|
|
639
|
-
if (!
|
|
695
|
+
const n = e, s = (c) => {
|
|
696
|
+
var d, u;
|
|
697
|
+
const p = c;
|
|
698
|
+
c.userData.tres__materialViaProp || ((d = p.material) == null || d.dispose(), p.material = void 0), c.userData.tres__geometryViaProp || ((u = p.geometry) == null || u.dispose(), p.geometry = void 0);
|
|
699
|
+
}, a = v == null ? void 0 : v.userData.tres__deregisterAtPointerEventHandler, o = v == null ? void 0 : v.userData.tres__deregisterBlockingObjectAtPointerEventHandler, i = (c) => {
|
|
700
|
+
var p, d;
|
|
701
|
+
if (!o)
|
|
640
702
|
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
|
|
641
|
-
if ((
|
|
703
|
+
if ((d = v == null ? void 0 : (p = v.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || d.call(p, c), !a)
|
|
642
704
|
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
|
|
643
|
-
c &&
|
|
705
|
+
c && Y.some((u) => c[u]) && (a == null || a(c));
|
|
644
706
|
}, l = (c) => {
|
|
645
|
-
const
|
|
646
|
-
if (!
|
|
707
|
+
const p = v == null ? void 0 : v.userData.tres__deregisterCamera;
|
|
708
|
+
if (!p)
|
|
647
709
|
throw "could not find tres__deregisterCamera on scene's userData";
|
|
648
|
-
c.isCamera && (
|
|
710
|
+
c.isCamera && (p == null || p(c));
|
|
649
711
|
};
|
|
650
|
-
(
|
|
651
|
-
|
|
652
|
-
}), n
|
|
712
|
+
(r = e.removeFromParent) == null || r.call(e), n.traverse((c) => {
|
|
713
|
+
s(c), l(c), i == null || i(c);
|
|
714
|
+
}), s(n), l(n), i == null || i(n);
|
|
653
715
|
}
|
|
654
716
|
(t = e.dispose) == null || t.call(e);
|
|
655
717
|
}
|
|
656
718
|
},
|
|
657
|
-
patchProp(e,
|
|
658
|
-
var
|
|
719
|
+
patchProp(e, r, t, n) {
|
|
720
|
+
var s, a, o, i;
|
|
659
721
|
if (e) {
|
|
660
|
-
let l = e, c =
|
|
722
|
+
let l = e, c = r;
|
|
661
723
|
if (e.isObject3D && c === "blocks-pointer-events") {
|
|
662
|
-
|
|
724
|
+
n || n === "" ? (a = v == null ? void 0 : (s = v.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || a.call(s, e) : (i = v == null ? void 0 : (o = v.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || i.call(o, e);
|
|
663
725
|
return;
|
|
664
726
|
}
|
|
665
|
-
let
|
|
727
|
+
let p = I(c), d = l == null ? void 0 : l[p];
|
|
666
728
|
if (c === "args") {
|
|
667
|
-
const m = e,
|
|
668
|
-
|
|
729
|
+
const m = e, y = t ?? [], f = n ?? [], h = e.userData.tres__name || e.type;
|
|
730
|
+
h && y.length && !nr(y, f) && (l = Object.assign(m, new X.value[h](...n)));
|
|
669
731
|
return;
|
|
670
732
|
}
|
|
671
733
|
if (l.type === "BufferGeometry") {
|
|
672
734
|
if (c === "args")
|
|
673
735
|
return;
|
|
674
736
|
l.setAttribute(
|
|
675
|
-
|
|
676
|
-
new
|
|
737
|
+
I(c),
|
|
738
|
+
new it(...n)
|
|
677
739
|
);
|
|
678
740
|
return;
|
|
679
741
|
}
|
|
680
|
-
if (c.includes("-") &&
|
|
742
|
+
if (c.includes("-") && d === void 0) {
|
|
681
743
|
const m = c.split("-");
|
|
682
|
-
|
|
744
|
+
d = m.reduce((y, f) => y[I(f)], l), c = m.pop(), p = c.toLowerCase(), d != null && d.set || (l = m.reduce((y, f) => y[I(f)], l));
|
|
683
745
|
}
|
|
684
|
-
let
|
|
685
|
-
if (
|
|
686
|
-
|
|
746
|
+
let u = n;
|
|
747
|
+
if (u === "" && (u = !0), de(d)) {
|
|
748
|
+
Y.includes(r) || (Array.isArray(u) ? e[p](...u) : e[p](u));
|
|
687
749
|
return;
|
|
688
750
|
}
|
|
689
|
-
!(
|
|
751
|
+
!(d != null && d.set) && !de(d) ? l[p] = u : d.constructor === u.constructor && (d != null && d.copy) ? d == null || d.copy(u) : Array.isArray(u) ? d.set(...u) : !d.isColor && d.setScalar ? d.setScalar(u) : d.set(u);
|
|
690
752
|
}
|
|
691
753
|
},
|
|
692
754
|
parentNode(e) {
|
|
@@ -701,9 +763,288 @@ const { logError: re } = j(), V = [
|
|
|
701
763
|
setScopeId: () => void 0,
|
|
702
764
|
cloneNode: () => void 0,
|
|
703
765
|
insertStaticContent: () => void 0
|
|
704
|
-
}, { render:
|
|
705
|
-
|
|
706
|
-
|
|
766
|
+
}, { render: hr } = Ie(vr);
|
|
767
|
+
re(ve);
|
|
768
|
+
function yr() {
|
|
769
|
+
return xe().__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
|
770
|
+
}
|
|
771
|
+
function xe() {
|
|
772
|
+
return typeof navigator < "u" && typeof window < "u" ? window : typeof global < "u" ? global : {};
|
|
773
|
+
}
|
|
774
|
+
const wr = typeof Proxy == "function", br = "devtools-plugin:setup", _r = "plugin:settings:set";
|
|
775
|
+
let L, Z;
|
|
776
|
+
function Er() {
|
|
777
|
+
var e;
|
|
778
|
+
return L !== void 0 || (typeof window < "u" && window.performance ? (L = !0, Z = window.performance) : typeof global < "u" && (!((e = global.perf_hooks) === null || e === void 0) && e.performance) ? (L = !0, Z = global.perf_hooks.performance) : L = !1), L;
|
|
779
|
+
}
|
|
780
|
+
function Mr() {
|
|
781
|
+
return Er() ? Z.now() : Date.now();
|
|
782
|
+
}
|
|
783
|
+
class Cr {
|
|
784
|
+
constructor(r, t) {
|
|
785
|
+
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = r, this.hook = t;
|
|
786
|
+
const n = {};
|
|
787
|
+
if (r.settings)
|
|
788
|
+
for (const o in r.settings) {
|
|
789
|
+
const i = r.settings[o];
|
|
790
|
+
n[o] = i.defaultValue;
|
|
791
|
+
}
|
|
792
|
+
const s = `__vue-devtools-plugin-settings__${r.id}`;
|
|
793
|
+
let a = Object.assign({}, n);
|
|
794
|
+
try {
|
|
795
|
+
const o = localStorage.getItem(s), i = JSON.parse(o);
|
|
796
|
+
Object.assign(a, i);
|
|
797
|
+
} catch {
|
|
798
|
+
}
|
|
799
|
+
this.fallbacks = {
|
|
800
|
+
getSettings() {
|
|
801
|
+
return a;
|
|
802
|
+
},
|
|
803
|
+
setSettings(o) {
|
|
804
|
+
try {
|
|
805
|
+
localStorage.setItem(s, JSON.stringify(o));
|
|
806
|
+
} catch {
|
|
807
|
+
}
|
|
808
|
+
a = o;
|
|
809
|
+
},
|
|
810
|
+
now() {
|
|
811
|
+
return Mr();
|
|
812
|
+
}
|
|
813
|
+
}, t && t.on(_r, (o, i) => {
|
|
814
|
+
o === this.plugin.id && this.fallbacks.setSettings(i);
|
|
815
|
+
}), this.proxiedOn = new Proxy({}, {
|
|
816
|
+
get: (o, i) => this.target ? this.target.on[i] : (...l) => {
|
|
817
|
+
this.onQueue.push({
|
|
818
|
+
method: i,
|
|
819
|
+
args: l
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
}), this.proxiedTarget = new Proxy({}, {
|
|
823
|
+
get: (o, i) => this.target ? this.target[i] : i === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(i) ? (...l) => (this.targetQueue.push({
|
|
824
|
+
method: i,
|
|
825
|
+
args: l,
|
|
826
|
+
resolve: () => {
|
|
827
|
+
}
|
|
828
|
+
}), this.fallbacks[i](...l)) : (...l) => new Promise((c) => {
|
|
829
|
+
this.targetQueue.push({
|
|
830
|
+
method: i,
|
|
831
|
+
args: l,
|
|
832
|
+
resolve: c
|
|
833
|
+
});
|
|
834
|
+
})
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
async setRealTarget(r) {
|
|
838
|
+
this.target = r;
|
|
839
|
+
for (const t of this.onQueue)
|
|
840
|
+
this.target.on[t.method](...t.args);
|
|
841
|
+
for (const t of this.targetQueue)
|
|
842
|
+
t.resolve(await this.target[t.method](...t.args));
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
function Sr(e, r) {
|
|
846
|
+
const t = e, n = xe(), s = yr(), a = wr && t.enableEarlyProxy;
|
|
847
|
+
if (s && (n.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !a))
|
|
848
|
+
s.emit(br, e, r);
|
|
849
|
+
else {
|
|
850
|
+
const o = a ? new Cr(t, s) : null;
|
|
851
|
+
(n.__VUE_DEVTOOLS_PLUGINS__ = n.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
852
|
+
pluginDescriptor: t,
|
|
853
|
+
setupFn: r,
|
|
854
|
+
proxy: o
|
|
855
|
+
}), o && r(o.proxiedTarget);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
function xr(e, r) {
|
|
859
|
+
const t = `▲ ■ ●${e}`;
|
|
860
|
+
typeof __VUE_DEVTOOLS_TOAST__ == "function" ? __VUE_DEVTOOLS_TOAST__(t, r) : r === "error" ? console.error(t) : r === "warn" ? console.warn(t) : console.log(t);
|
|
861
|
+
}
|
|
862
|
+
const Pe = (e) => {
|
|
863
|
+
const r = {
|
|
864
|
+
id: e.uuid,
|
|
865
|
+
label: e.type,
|
|
866
|
+
children: [],
|
|
867
|
+
tags: []
|
|
868
|
+
};
|
|
869
|
+
e.name !== "" && r.tags.push({
|
|
870
|
+
label: e.name,
|
|
871
|
+
textColor: 5750629,
|
|
872
|
+
backgroundColor: 15793395
|
|
873
|
+
});
|
|
874
|
+
const t = Se(e);
|
|
875
|
+
return t > 0 && r.tags.push({
|
|
876
|
+
label: `${pr(t)} KB`,
|
|
877
|
+
textColor: 15707189,
|
|
878
|
+
backgroundColor: 16775644,
|
|
879
|
+
tooltip: "Memory usage"
|
|
880
|
+
}), e.type.includes("Light") && (r.tags.push({
|
|
881
|
+
label: `${e.intensity}`,
|
|
882
|
+
textColor: 9738662,
|
|
883
|
+
backgroundColor: 16316922,
|
|
884
|
+
tooltip: "Intensity"
|
|
885
|
+
}), r.tags.push({
|
|
886
|
+
label: `#${e.color.getHexString()}`,
|
|
887
|
+
textColor: 9738662,
|
|
888
|
+
backgroundColor: 16316922,
|
|
889
|
+
tooltip: "Color"
|
|
890
|
+
})), e.type.includes("Camera") && (r.tags.push({
|
|
891
|
+
label: `${e.fov}°`,
|
|
892
|
+
textColor: 9738662,
|
|
893
|
+
backgroundColor: 16316922,
|
|
894
|
+
tooltip: "Field of view"
|
|
895
|
+
}), r.tags.push({
|
|
896
|
+
// eslint-disable-next-line max-len
|
|
897
|
+
label: `x: ${Math.round(e.position.x)} y: ${Math.round(e.position.y)} z: ${Math.round(e.position.z)}`,
|
|
898
|
+
textColor: 9738662,
|
|
899
|
+
backgroundColor: 16316922,
|
|
900
|
+
tooltip: "Position"
|
|
901
|
+
})), r;
|
|
902
|
+
};
|
|
903
|
+
function ke(e, r) {
|
|
904
|
+
e.children.forEach((t) => {
|
|
905
|
+
if (t.type === "HightlightMesh")
|
|
906
|
+
return;
|
|
907
|
+
const n = Pe(t);
|
|
908
|
+
r.children.push(n), ke(t, n);
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
const Pr = [], B = "tres:inspector", kr = ge({
|
|
912
|
+
sceneGraph: null
|
|
913
|
+
});
|
|
914
|
+
function Ar(e, r) {
|
|
915
|
+
Sr(
|
|
916
|
+
{
|
|
917
|
+
id: "dev.esm.tres",
|
|
918
|
+
label: "TresJS 🪐",
|
|
919
|
+
logo: "https://raw.githubusercontent.com/Tresjs/tres/main/public/favicon.svg",
|
|
920
|
+
packageName: "tresjs",
|
|
921
|
+
homepage: "https://tresjs.org",
|
|
922
|
+
componentStateTypes: Pr,
|
|
923
|
+
app: e
|
|
924
|
+
},
|
|
925
|
+
(t) => {
|
|
926
|
+
typeof t.now != "function" && xr(
|
|
927
|
+
// eslint-disable-next-line max-len
|
|
928
|
+
"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."
|
|
929
|
+
), t.addInspector({
|
|
930
|
+
id: B,
|
|
931
|
+
label: "TresJS 🪐",
|
|
932
|
+
icon: "account_tree",
|
|
933
|
+
treeFilterPlaceholder: "Search instances"
|
|
934
|
+
}), setInterval(() => {
|
|
935
|
+
t.sendInspectorTree(B);
|
|
936
|
+
}, 1e3), setInterval(() => {
|
|
937
|
+
t.notifyComponentUpdate();
|
|
938
|
+
}, 5e3), t.on.getInspectorTree((a) => {
|
|
939
|
+
if (a.inspectorId === B) {
|
|
940
|
+
const o = Pe(r.scene.value);
|
|
941
|
+
ke(r.scene.value, o), kr.sceneGraph = o, a.rootNodes = [o];
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
let n = null, s = null;
|
|
945
|
+
t.on.getInspectorState((a) => {
|
|
946
|
+
if (a.inspectorId === B) {
|
|
947
|
+
const [o] = r.scene.value.getObjectsByProperty("uuid", a.nodeId);
|
|
948
|
+
if (!o)
|
|
949
|
+
return;
|
|
950
|
+
if (s && n && n.parent && s.remove(n), o.isMesh) {
|
|
951
|
+
const i = ir(o);
|
|
952
|
+
o.add(i), n = i, s = o;
|
|
953
|
+
}
|
|
954
|
+
a.state = {
|
|
955
|
+
object: [
|
|
956
|
+
{
|
|
957
|
+
key: "uuid",
|
|
958
|
+
editable: !0,
|
|
959
|
+
value: o.uuid
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
key: "name",
|
|
963
|
+
editable: !0,
|
|
964
|
+
value: o.name
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
key: "type",
|
|
968
|
+
editable: !0,
|
|
969
|
+
value: o.type
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
key: "position",
|
|
973
|
+
editable: !0,
|
|
974
|
+
value: o.position
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
key: "rotation",
|
|
978
|
+
editable: !0,
|
|
979
|
+
value: o.rotation
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
key: "scale",
|
|
983
|
+
editable: !0,
|
|
984
|
+
value: o.scale
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
key: "geometry",
|
|
988
|
+
value: o.geometry
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
key: "material",
|
|
992
|
+
value: o.material
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
key: "color",
|
|
996
|
+
editable: !0,
|
|
997
|
+
value: o.color
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
key: "intensity",
|
|
1001
|
+
editable: !0,
|
|
1002
|
+
value: o.intensity
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
key: "castShadow",
|
|
1006
|
+
editable: !0,
|
|
1007
|
+
value: o.castShadow
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
key: "receiveShadow",
|
|
1011
|
+
editable: !0,
|
|
1012
|
+
value: o.receiveShadow
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
key: "frustumCulled",
|
|
1016
|
+
editable: !0,
|
|
1017
|
+
value: o.frustumCulled
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
key: "matrixAutoUpdate",
|
|
1021
|
+
editable: !0,
|
|
1022
|
+
value: o.matrixAutoUpdate
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
key: "matrixWorldNeedsUpdate",
|
|
1026
|
+
editable: !0,
|
|
1027
|
+
value: o.matrixWorldNeedsUpdate
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
key: "matrixWorld",
|
|
1031
|
+
value: o.matrixWorld
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
key: "visible",
|
|
1035
|
+
editable: !0,
|
|
1036
|
+
value: o.visible
|
|
1037
|
+
}
|
|
1038
|
+
]
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
}), t.on.editInspectorState((a) => {
|
|
1042
|
+
a.inspectorId === B && sr(r.scene.value, a.nodeId, a.path, a.state.value);
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
const Tr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ ne({
|
|
707
1048
|
__name: "TresCanvas",
|
|
708
1049
|
props: {
|
|
709
1050
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -729,108 +1070,205 @@ const $t = ["data-scene", "data-tres"], Nt = /* @__PURE__ */ J({
|
|
|
729
1070
|
logarithmicDepthBuffer: { type: Boolean, default: void 0 },
|
|
730
1071
|
failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
|
|
731
1072
|
},
|
|
732
|
-
setup(e, { expose:
|
|
733
|
-
var
|
|
734
|
-
const t = e, { logWarning:
|
|
1073
|
+
setup(e, { expose: r }) {
|
|
1074
|
+
var y;
|
|
1075
|
+
const t = e, { logWarning: n } = T(), s = R(), a = D(new at()), { resume: o } = te(), i = ze(), l = (y = oe()) == null ? void 0 : y.appContext.app, c = (f) => ne({
|
|
735
1076
|
setup() {
|
|
736
|
-
var
|
|
737
|
-
const
|
|
738
|
-
return
|
|
1077
|
+
var _;
|
|
1078
|
+
const h = (_ = oe()) == null ? void 0 : _.appContext;
|
|
1079
|
+
return h && (h.app = l), q("useTres", f), q("extend", re), typeof window < "u" && Ar(h.app, f), () => se(Je, null, i != null && i.default ? i.default() : []);
|
|
739
1080
|
}
|
|
740
|
-
}),
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
},
|
|
744
|
-
|
|
745
|
-
},
|
|
746
|
-
return
|
|
747
|
-
const
|
|
748
|
-
m.value =
|
|
749
|
-
scene:
|
|
750
|
-
canvas:
|
|
1081
|
+
}), p = (f) => {
|
|
1082
|
+
const h = c(f);
|
|
1083
|
+
hr(se(h), a.value);
|
|
1084
|
+
}, d = (f, h = !1) => {
|
|
1085
|
+
a.value.children = [], h && (f.renderer.value.dispose(), f.renderer.value.renderLists.dispose(), f.renderer.value.forceContextLoss()), p(f), o();
|
|
1086
|
+
}, u = P(() => t.disableRender), m = D(null);
|
|
1087
|
+
return r({ context: m, dispose: () => d(m.value, !0) }), Ne(() => {
|
|
1088
|
+
const f = s;
|
|
1089
|
+
m.value = mr({
|
|
1090
|
+
scene: a.value,
|
|
1091
|
+
canvas: f,
|
|
751
1092
|
windowSize: t.windowSize,
|
|
752
|
-
disableRender:
|
|
1093
|
+
disableRender: u,
|
|
753
1094
|
rendererOptions: t
|
|
754
|
-
}),
|
|
755
|
-
const { registerCamera:
|
|
756
|
-
|
|
757
|
-
const
|
|
758
|
-
const
|
|
1095
|
+
}), fr({ scene: a.value, contextParts: m.value });
|
|
1096
|
+
const { registerCamera: h, camera: _, cameras: w, deregisterCamera: C } = m.value;
|
|
1097
|
+
p(m.value);
|
|
1098
|
+
const S = () => {
|
|
1099
|
+
const b = new K(
|
|
759
1100
|
45,
|
|
760
1101
|
window.innerWidth / window.innerHeight,
|
|
761
1102
|
0.1,
|
|
762
1103
|
1e3
|
|
763
1104
|
);
|
|
764
|
-
|
|
765
|
-
const
|
|
766
|
-
w.value.length >= 2 && (
|
|
1105
|
+
b.position.set(3, 3, 3), b.lookAt(0, 0, 0), h(b);
|
|
1106
|
+
const x = O(() => {
|
|
1107
|
+
w.value.length >= 2 && (b.removeFromParent(), C(b), x == null || x());
|
|
767
1108
|
});
|
|
768
1109
|
};
|
|
769
|
-
|
|
1110
|
+
me(
|
|
770
1111
|
() => t.camera,
|
|
771
|
-
(
|
|
772
|
-
|
|
1112
|
+
(b, x) => {
|
|
1113
|
+
b && h(b), x && (x.removeFromParent(), C(x));
|
|
773
1114
|
},
|
|
774
1115
|
{
|
|
775
1116
|
immediate: !0
|
|
776
1117
|
}
|
|
777
|
-
),
|
|
1118
|
+
), _.value || (n(
|
|
778
1119
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
779
|
-
),
|
|
780
|
-
}), (
|
|
1120
|
+
), S());
|
|
1121
|
+
}), (f, h) => (Ve(), We("canvas", {
|
|
781
1122
|
ref_key: "canvas",
|
|
782
|
-
ref:
|
|
783
|
-
"data-scene":
|
|
784
|
-
class:
|
|
785
|
-
"data-tres": `tresjs ${
|
|
786
|
-
style:
|
|
1123
|
+
ref: s,
|
|
1124
|
+
"data-scene": a.value.uuid,
|
|
1125
|
+
class: Ue(f.$attrs.class),
|
|
1126
|
+
"data-tres": `tresjs ${Fe(Ft).version}`,
|
|
1127
|
+
style: Ge({
|
|
787
1128
|
display: "block",
|
|
788
1129
|
width: "100%",
|
|
789
1130
|
height: "100%",
|
|
790
|
-
position:
|
|
1131
|
+
position: f.windowSize ? "fixed" : "relative",
|
|
791
1132
|
top: 0,
|
|
792
1133
|
left: 0,
|
|
793
1134
|
pointerEvents: "auto",
|
|
794
1135
|
touchAction: "none",
|
|
795
|
-
...
|
|
1136
|
+
...f.$attrs.style
|
|
796
1137
|
})
|
|
797
|
-
}, null, 14,
|
|
1138
|
+
}, null, 14, Tr));
|
|
798
1139
|
}
|
|
799
|
-
}),
|
|
1140
|
+
}), Or = [
|
|
800
1141
|
"TresCanvas",
|
|
801
1142
|
"TresLeches",
|
|
802
1143
|
"TresScene"
|
|
803
|
-
],
|
|
1144
|
+
], Dr = {
|
|
804
1145
|
template: {
|
|
805
1146
|
compilerOptions: {
|
|
806
|
-
isCustomElement: (e) => e.startsWith("Tres") && !
|
|
1147
|
+
isCustomElement: (e) => e.startsWith("Tres") && !Or.includes(e) || e === "primitive"
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}, Qr = Dr, Yr = {
|
|
1151
|
+
mounted: (e, r) => {
|
|
1152
|
+
if (r.arg) {
|
|
1153
|
+
console.log(`v-log:${r.arg}`, e[r.arg]);
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
console.log("v-log", e);
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
class Ae extends lt {
|
|
1160
|
+
constructor(r, t) {
|
|
1161
|
+
const n = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new ie();
|
|
1162
|
+
s.setAttribute("position", new ae(n, 3)), s.computeBoundingSphere();
|
|
1163
|
+
const a = new ut({ fog: !1 });
|
|
1164
|
+
super(s, a), this.light = r, this.color = t, this.type = "RectAreaLightHelper";
|
|
1165
|
+
const o = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], i = new ie();
|
|
1166
|
+
i.setAttribute("position", new ae(o, 3)), i.computeBoundingSphere(), this.add(new ct(i, new ye({ side: dt, fog: !1 })));
|
|
1167
|
+
}
|
|
1168
|
+
updateMatrixWorld() {
|
|
1169
|
+
if (this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1), this.color !== void 0)
|
|
1170
|
+
this.material.color.set(this.color), this.children[0].material.color.set(this.color);
|
|
1171
|
+
else {
|
|
1172
|
+
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
|
|
1173
|
+
const r = this.material.color, t = Math.max(r.r, r.g, r.b);
|
|
1174
|
+
t > 1 && r.multiplyScalar(1 / t), this.children[0].material.color.copy(this.material.color);
|
|
807
1175
|
}
|
|
1176
|
+
this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld), this.children[0].matrixWorld.copy(this.matrixWorld);
|
|
808
1177
|
}
|
|
809
|
-
|
|
1178
|
+
dispose() {
|
|
1179
|
+
this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
const { logWarning: pe } = T();
|
|
1183
|
+
let N, A;
|
|
1184
|
+
const Br = {
|
|
1185
|
+
DirectionalLight: ft,
|
|
1186
|
+
PointLight: pt,
|
|
1187
|
+
SpotLight: mt,
|
|
1188
|
+
HemisphereLight: gt,
|
|
1189
|
+
RectAreaLight: Ae
|
|
1190
|
+
}, qr = {
|
|
1191
|
+
mounted: (e) => {
|
|
1192
|
+
if (!e.isLight) {
|
|
1193
|
+
pe(`${e.type} is not a light`);
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
N = Br[e.type], e.parent.add(new N(e, 1, e.color.getHex()));
|
|
1197
|
+
},
|
|
1198
|
+
updated: (e) => {
|
|
1199
|
+
A = e.parent.children.find((r) => r instanceof N), !(A instanceof Ae) && A.update();
|
|
1200
|
+
},
|
|
1201
|
+
unmounted: (e) => {
|
|
1202
|
+
if (!e.isLight) {
|
|
1203
|
+
pe(`${e.type} is not a light`);
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
A = e.parent.children.find((r) => r instanceof N), A && A.dispose && A.dispose(), e.parent.remove(A);
|
|
1207
|
+
}
|
|
1208
|
+
}, { logWarning: jr } = T(), Kr = {
|
|
1209
|
+
updated: (e, r) => {
|
|
1210
|
+
const t = Ce(r);
|
|
1211
|
+
if (!t) {
|
|
1212
|
+
jr(`v-always-look-at: problem with binding value: ${r.value}`);
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
const { onLoop: n } = te();
|
|
1216
|
+
n(() => {
|
|
1217
|
+
e.lookAt(t);
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
}, { logWarning: Hr } = T(), Xr = {
|
|
1221
|
+
updated: (e, r) => {
|
|
1222
|
+
var s;
|
|
1223
|
+
const t = Ce(r);
|
|
1224
|
+
if (!t) {
|
|
1225
|
+
Hr(`v-distance-to: problem with binding value: ${r.value}`);
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
k && (k.dispose(), e.parent.remove(k));
|
|
1229
|
+
const n = t.clone().sub(e.position);
|
|
1230
|
+
n.normalize(), k = new vt(n, e.position, e.position.distanceTo(t), 16776960), e.parent.add(k), console.table(
|
|
1231
|
+
[
|
|
1232
|
+
["Distance:", e.position.distanceTo(t)],
|
|
1233
|
+
[`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(s = e.position) == null ? void 0 : s.z}`],
|
|
1234
|
+
[`Destiny: ${e.name || e.type}`, `x:${t.x}, y:${t.y}, z:${t == null ? void 0 : t.z}`]
|
|
1235
|
+
]
|
|
1236
|
+
);
|
|
1237
|
+
},
|
|
1238
|
+
unmounted: (e) => {
|
|
1239
|
+
k == null || k.dispose(), e.parent.remove(k);
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
let k = null;
|
|
1243
|
+
const Zr = {
|
|
810
1244
|
install(e) {
|
|
811
|
-
e.component("TresCanvas",
|
|
1245
|
+
e.component("TresCanvas", Lr);
|
|
812
1246
|
}
|
|
813
1247
|
};
|
|
814
1248
|
export {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1249
|
+
Lr as TresCanvas,
|
|
1250
|
+
X as catalogue,
|
|
1251
|
+
Zr as default,
|
|
1252
|
+
re as extend,
|
|
1253
|
+
Vr as isProd,
|
|
1254
|
+
qt as normalizeColor,
|
|
1255
|
+
Wr as normalizeVectorFlexibleParam,
|
|
1256
|
+
Qr as templateCompilerOptions,
|
|
1257
|
+
cr as trasverseObjects,
|
|
1258
|
+
Gt as useCamera,
|
|
1259
|
+
Ur as useLoader,
|
|
1260
|
+
T as useLogger,
|
|
1261
|
+
fr as usePointerEventHandler,
|
|
1262
|
+
dr as useRaycaster,
|
|
1263
|
+
te as useRenderLoop,
|
|
1264
|
+
lr as useRenderer,
|
|
1265
|
+
Gr as useSeek,
|
|
1266
|
+
Fr as useTexture,
|
|
1267
|
+
Jr as useTres,
|
|
1268
|
+
gr as useTresContext,
|
|
1269
|
+
mr as useTresContextProvider,
|
|
1270
|
+
Kr as vAlwaysLookAt,
|
|
1271
|
+
Xr as vDistanceTo,
|
|
1272
|
+
qr as vLightHelper,
|
|
1273
|
+
Yr as vLog
|
|
836
1274
|
};
|