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