@tresjs/core 3.7.0-next.0 → 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/index.d.ts +3 -18
- package/dist/{components → src/components}/TresCanvas.vue.d.ts +4 -3
- package/dist/{composables → src/composables}/useRenderer/index.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 +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 +18 -0
- package/dist/{utils → src/utils}/index.d.ts +8 -8
- package/dist/tres.js +1010 -468
- package/dist/tres.umd.cjs +3 -3
- package/package.json +1 -1
- /package/dist/{components → src/components}/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useCamera/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useLoader/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useLogger.d.ts +0 -0
- /package/dist/{composables → src/composables}/usePointerEventHandler/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useRaycaster/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useRenderLoop/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useRenderer/const.d.ts +0 -0
- /package/dist/{composables → src/composables}/useSeek/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useTexture/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useTresContextProvider/index.d.ts +0 -0
- /package/dist/{core → src/core}/catalogue.d.ts +0 -0
- /package/dist/{core → src/core}/nodeOps.d.ts +0 -0
- /package/dist/{core → src/core}/renderer.d.ts +0 -0
- /package/dist/{core → src/core}/revision.d.ts +0 -0
- /package/dist/{types → src/types}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/normalize.d.ts +0 -0
- /package/dist/{utils → src/utils}/perf.d.ts +0 -0
- /package/dist/{utils → src/utils}/template-compiler-options.d.ts +0 -0
- /package/dist/{utils → src/utils}/test-utils.d.ts +0 -0
package/dist/tres.js
CHANGED
|
@@ -1,441 +1,612 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v3.7.0
|
|
4
|
-
* (c)
|
|
3
|
+
* version: v3.7.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 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 = [
|
|
16
|
+
"vue",
|
|
17
|
+
"3d",
|
|
18
|
+
"threejs",
|
|
19
|
+
"three",
|
|
20
|
+
"threejs-vue"
|
|
21
|
+
], Bt = !1, jt = {
|
|
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
|
+
}, Ht = "./dist/tres.js", Rt = "./dist/tres.js", $t = "./dist/index.d.ts", It = [
|
|
41
|
+
"dist",
|
|
42
|
+
"*.d.ts"
|
|
43
|
+
], zt = {
|
|
44
|
+
access: "public"
|
|
45
|
+
}, Nt = {
|
|
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
|
+
}, Vt = {
|
|
61
|
+
three: ">=0.133",
|
|
62
|
+
vue: ">=3.3"
|
|
63
|
+
}, Wt = {
|
|
64
|
+
"@alvarosabu/utils": "^3.1.1",
|
|
65
|
+
"@vueuse/core": "^10.7.0"
|
|
66
|
+
}, Ut = {
|
|
67
|
+
"@release-it/conventional-changelog": "^8.0.1",
|
|
68
|
+
"@stackblitz/sdk": "^1.9.0",
|
|
69
|
+
"@tresjs/cientos": "3.6.0",
|
|
70
|
+
"@tresjs/eslint-config-vue": "^0.2.1",
|
|
71
|
+
"@types/three": "^0.159.0",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
73
|
+
"@typescript-eslint/parser": "^6.14.0",
|
|
74
|
+
"@vitejs/plugin-vue": "^4.5.2",
|
|
75
|
+
"@vitest/coverage-c8": "^0.33.0",
|
|
76
|
+
"@vitest/ui": "^1.0.4",
|
|
77
|
+
"@vue/test-utils": "^2.4.3",
|
|
78
|
+
eslint: "^8.55.0",
|
|
79
|
+
"eslint-plugin-vue": "^9.19.2",
|
|
80
|
+
esno: "^4.0.0",
|
|
81
|
+
gsap: "^3.12.3",
|
|
82
|
+
jsdom: "^23.0.1",
|
|
83
|
+
kolorist: "^1.8.0",
|
|
84
|
+
ohmyfetch: "^0.4.21",
|
|
85
|
+
pathe: "^1.1.1",
|
|
86
|
+
"release-it": "^17.0.1",
|
|
87
|
+
"rollup-plugin-analyzer": "^4.0.0",
|
|
88
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
89
|
+
"rollup-plugin-visualizer": "^5.11.0",
|
|
90
|
+
three: "^0.159.0",
|
|
91
|
+
unocss: "^0.58.0",
|
|
92
|
+
unplugin: "^1.5.1",
|
|
93
|
+
"unplugin-vue-components": "^0.26.0",
|
|
94
|
+
vite: "^5.0.8",
|
|
95
|
+
"vite-plugin-banner": "^0.7.1",
|
|
96
|
+
"vite-plugin-dts": "3.6.4",
|
|
97
|
+
"vite-plugin-inspect": "^0.8.1",
|
|
98
|
+
"vite-plugin-require-transform": "^1.0.21",
|
|
99
|
+
"vite-svg-loader": "^5.1.0",
|
|
100
|
+
vitepress: "1.0.0-rc.31",
|
|
101
|
+
vitest: "^1.0.4",
|
|
102
|
+
vue: "^3.3.11",
|
|
103
|
+
"vue-demi": "^0.14.6"
|
|
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(
|
|
14
126
|
() => t.value[0]
|
|
15
|
-
),
|
|
16
|
-
t.value.some(({ uuid:
|
|
17
|
-
},
|
|
18
|
-
t.value = t.value.filter(({ uuid:
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
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);
|
|
133
|
+
if (!l)
|
|
22
134
|
return;
|
|
23
|
-
const
|
|
24
|
-
t.value = [
|
|
135
|
+
const c = t.value.filter(({ uuid: p }) => p !== l.uuid);
|
|
136
|
+
t.value = [l, ...c];
|
|
25
137
|
};
|
|
26
|
-
return
|
|
27
|
-
e.aspectRatio.value && t.value.forEach((
|
|
28
|
-
|
|
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();
|
|
29
141
|
});
|
|
30
|
-
}),
|
|
142
|
+
}), r.userData.tres__registerCamera = s, r.userData.tres__deregisterCamera = a, F(() => {
|
|
31
143
|
t.value = [];
|
|
32
144
|
}), {
|
|
33
|
-
camera:
|
|
145
|
+
camera: n,
|
|
34
146
|
cameras: t,
|
|
35
|
-
registerCamera:
|
|
36
|
-
deregisterCamera:
|
|
37
|
-
setCameraActive:
|
|
147
|
+
registerCamera: s,
|
|
148
|
+
deregisterCamera: a,
|
|
149
|
+
setCameraActive: o
|
|
38
150
|
};
|
|
39
|
-
},
|
|
40
|
-
let
|
|
41
|
-
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(
|
|
42
154
|
() => {
|
|
43
|
-
|
|
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 });
|
|
44
156
|
},
|
|
45
157
|
{ immediate: !1 }
|
|
46
158
|
);
|
|
47
|
-
|
|
48
|
-
|
|
159
|
+
ee.on(() => {
|
|
160
|
+
W = j.getDelta(), U = j.getElapsedTime();
|
|
49
161
|
});
|
|
50
|
-
const
|
|
51
|
-
onBeforeLoop:
|
|
52
|
-
onLoop:
|
|
53
|
-
onAfterLoop:
|
|
54
|
-
pause:
|
|
55
|
-
resume:
|
|
56
|
-
isActive:
|
|
57
|
-
}),
|
|
58
|
-
function
|
|
59
|
-
function e(
|
|
60
|
-
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 || "");
|
|
61
173
|
}
|
|
62
|
-
function n
|
|
63
|
-
console.warn(`${
|
|
174
|
+
function r(n) {
|
|
175
|
+
console.warn(`${le} ${n}`);
|
|
64
176
|
}
|
|
65
|
-
function t(
|
|
177
|
+
function t(n, s) {
|
|
66
178
|
}
|
|
67
179
|
return {
|
|
68
180
|
logError: e,
|
|
69
|
-
logWarning:
|
|
181
|
+
logWarning: r,
|
|
70
182
|
logMessage: t
|
|
71
183
|
};
|
|
72
184
|
}
|
|
73
|
-
function
|
|
74
|
-
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;
|
|
75
187
|
}
|
|
76
|
-
function
|
|
77
|
-
return e instanceof
|
|
188
|
+
function qt(e) {
|
|
189
|
+
return e instanceof V ? e : Array.isArray(e) ? new V(...e) : new V(e);
|
|
78
190
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
}
|
|
202
|
+
}
|
|
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) {
|
|
85
209
|
return e && e.nodeType === 1;
|
|
86
210
|
}
|
|
87
|
-
function
|
|
88
|
-
return e.replace(/-([a-z])/g, (
|
|
211
|
+
function I(e) {
|
|
212
|
+
return e.replace(/-([a-z])/g, (r, t) => t.toUpperCase());
|
|
89
213
|
}
|
|
90
|
-
function
|
|
91
|
-
const t = /* @__PURE__ */ Object.create(null),
|
|
92
|
-
for (let
|
|
93
|
-
t[
|
|
94
|
-
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];
|
|
95
219
|
}
|
|
96
|
-
const
|
|
97
|
-
const t = /* @__PURE__ */ new Set(),
|
|
98
|
-
for (const
|
|
99
|
-
const
|
|
100
|
-
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));
|
|
101
225
|
}
|
|
102
|
-
return
|
|
103
|
-
},
|
|
104
|
-
if (!
|
|
226
|
+
return n;
|
|
227
|
+
}, ce = (e, r) => {
|
|
228
|
+
if (!r)
|
|
105
229
|
return;
|
|
106
|
-
const t = Array.isArray(
|
|
107
|
-
return t == null ? void 0 : t.reduce((
|
|
108
|
-
},
|
|
109
|
-
const
|
|
110
|
-
|
|
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);
|
|
111
235
|
};
|
|
112
|
-
function
|
|
113
|
-
if (
|
|
114
|
-
const
|
|
115
|
-
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);
|
|
116
240
|
}
|
|
117
|
-
if (e ===
|
|
241
|
+
if (e === r)
|
|
118
242
|
return !0;
|
|
119
|
-
if (e === null || typeof e != "object" ||
|
|
243
|
+
if (e === null || typeof e != "object" || r === null || typeof r != "object")
|
|
120
244
|
return !1;
|
|
121
|
-
const t = Object.keys(e),
|
|
122
|
-
if (t.length !==
|
|
245
|
+
const t = Object.keys(e), n = Object.keys(r);
|
|
246
|
+
if (t.length !== n.length)
|
|
123
247
|
return !1;
|
|
124
|
-
for (const
|
|
125
|
-
if (!
|
|
248
|
+
for (const s of t)
|
|
249
|
+
if (!n.includes(s) || !Me(e[s], r[s]))
|
|
126
250
|
return !1;
|
|
127
251
|
return !0;
|
|
128
252
|
}
|
|
129
|
-
function
|
|
130
|
-
if (!Array.isArray(e) || !Array.isArray(
|
|
253
|
+
function nr(e, r) {
|
|
254
|
+
if (!Array.isArray(e) || !Array.isArray(r) || e.length !== r.length)
|
|
131
255
|
return !1;
|
|
132
256
|
for (let t = 0; t < e.length; t++)
|
|
133
|
-
if (!
|
|
257
|
+
if (!Me(e[t], r[t]))
|
|
134
258
|
return !1;
|
|
135
259
|
return !0;
|
|
136
260
|
}
|
|
137
|
-
const
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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;
|
|
144
304
|
}
|
|
145
|
-
const
|
|
305
|
+
const ar = Number.parseInt(Xe.replace("dev", "")), z = {
|
|
146
306
|
realistic: {
|
|
147
307
|
shadows: !0,
|
|
148
308
|
physicallyCorrectLights: !0,
|
|
149
|
-
outputColorSpace:
|
|
150
|
-
toneMapping:
|
|
309
|
+
outputColorSpace: Ze,
|
|
310
|
+
toneMapping: et,
|
|
151
311
|
toneMappingExposure: 3,
|
|
152
312
|
shadowMap: {
|
|
153
313
|
enabled: !0,
|
|
154
|
-
type:
|
|
314
|
+
type: tt
|
|
155
315
|
}
|
|
156
316
|
}
|
|
157
317
|
};
|
|
158
|
-
function
|
|
318
|
+
function lr({
|
|
159
319
|
scene: e,
|
|
160
|
-
canvas:
|
|
320
|
+
canvas: r,
|
|
161
321
|
options: t,
|
|
162
|
-
disableRender:
|
|
163
|
-
contextParts: { sizes:
|
|
322
|
+
disableRender: n,
|
|
323
|
+
contextParts: { sizes: s, camera: a }
|
|
164
324
|
}) {
|
|
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
|
-
|
|
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);
|
|
183
343
|
});
|
|
184
|
-
const { pixelRatio:
|
|
185
|
-
|
|
186
|
-
|
|
344
|
+
const { pixelRatio: l } = yt();
|
|
345
|
+
O(() => {
|
|
346
|
+
i.value.setPixelRatio(l.value);
|
|
187
347
|
});
|
|
188
|
-
const { logError:
|
|
189
|
-
const
|
|
348
|
+
const { logError: c } = T(), d = (() => {
|
|
349
|
+
const f = new Q(), h = {
|
|
190
350
|
shadowMap: {
|
|
191
|
-
enabled:
|
|
192
|
-
type:
|
|
351
|
+
enabled: f.shadowMap.enabled,
|
|
352
|
+
type: f.shadowMap.type
|
|
193
353
|
},
|
|
194
|
-
toneMapping:
|
|
195
|
-
toneMappingExposure:
|
|
196
|
-
outputColorSpace:
|
|
354
|
+
toneMapping: f.toneMapping,
|
|
355
|
+
toneMappingExposure: f.toneMappingExposure,
|
|
356
|
+
outputColorSpace: f.outputColorSpace
|
|
197
357
|
};
|
|
198
|
-
return
|
|
358
|
+
return f.dispose(), h;
|
|
199
359
|
})();
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
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);
|
|
207
367
|
};
|
|
208
|
-
if (
|
|
209
|
-
return
|
|
210
|
-
const g =
|
|
211
|
-
return g !== void 0 ? g :
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
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)
|
|
217
377
|
// default clear color is not easily/efficiently retrievable from three
|
|
218
378
|
);
|
|
219
379
|
});
|
|
220
|
-
const { pause:
|
|
221
|
-
return
|
|
222
|
-
|
|
223
|
-
}),
|
|
224
|
-
|
|
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();
|
|
225
385
|
}), {
|
|
226
|
-
renderer:
|
|
386
|
+
renderer: i
|
|
227
387
|
};
|
|
228
388
|
}
|
|
229
|
-
const
|
|
230
|
-
function
|
|
231
|
-
const
|
|
389
|
+
const de = (e) => typeof e == "function", ur = (e) => !!e && e.constructor === Array;
|
|
390
|
+
function cr(e) {
|
|
391
|
+
const r = { nodes: {}, materials: {} };
|
|
232
392
|
return e && e.traverse((t) => {
|
|
233
|
-
t.name && (
|
|
234
|
-
}),
|
|
393
|
+
t.name && (r.nodes[t.name] = t), t.material && !r.materials[t.material.name] && (r.materials[t.material.name] = t.material);
|
|
394
|
+
}), r;
|
|
235
395
|
}
|
|
236
|
-
async function
|
|
237
|
-
const { logError:
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
(
|
|
244
|
-
|
|
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(
|
|
402
|
+
c,
|
|
403
|
+
(u) => {
|
|
404
|
+
u.scene && Object.assign(u, cr(u.scene)), p(u);
|
|
245
405
|
},
|
|
246
|
-
|
|
247
|
-
(
|
|
406
|
+
n,
|
|
407
|
+
(u) => d(a("[useLoader] - Failed to load resource", u))
|
|
248
408
|
);
|
|
249
409
|
})
|
|
250
410
|
);
|
|
251
|
-
return
|
|
411
|
+
return ur(r) ? await Promise.all(l) : await l[0];
|
|
252
412
|
}
|
|
253
|
-
async function
|
|
254
|
-
const
|
|
413
|
+
async function Fr(e) {
|
|
414
|
+
const r = new rt(), t = new nt(r), n = (s) => new Promise((a, o) => {
|
|
255
415
|
t.load(
|
|
256
|
-
|
|
257
|
-
(
|
|
416
|
+
s,
|
|
417
|
+
(i) => a(i),
|
|
258
418
|
() => null,
|
|
259
419
|
() => {
|
|
260
|
-
|
|
420
|
+
o(new Error("[useTextures] - Failed to load texture"));
|
|
261
421
|
}
|
|
262
422
|
);
|
|
263
423
|
});
|
|
264
|
-
if (
|
|
265
|
-
const
|
|
266
|
-
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];
|
|
267
427
|
} else {
|
|
268
428
|
const {
|
|
269
|
-
map:
|
|
270
|
-
displacementMap:
|
|
271
|
-
normalMap:
|
|
272
|
-
roughnessMap:
|
|
273
|
-
metalnessMap:
|
|
274
|
-
aoMap:
|
|
275
|
-
alphaMap:
|
|
276
|
-
matcap:
|
|
429
|
+
map: s,
|
|
430
|
+
displacementMap: a,
|
|
431
|
+
normalMap: o,
|
|
432
|
+
roughnessMap: i,
|
|
433
|
+
metalnessMap: l,
|
|
434
|
+
aoMap: c,
|
|
435
|
+
alphaMap: p,
|
|
436
|
+
matcap: d
|
|
277
437
|
} = e;
|
|
278
438
|
return {
|
|
279
|
-
map:
|
|
280
|
-
displacementMap:
|
|
281
|
-
normalMap:
|
|
282
|
-
roughnessMap:
|
|
283
|
-
metalnessMap:
|
|
284
|
-
aoMap:
|
|
285
|
-
alphaMap:
|
|
286
|
-
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
|
|
287
447
|
};
|
|
288
448
|
}
|
|
289
449
|
}
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
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)
|
|
293
453
|
return {
|
|
294
|
-
x: (g -
|
|
295
|
-
y: -((
|
|
454
|
+
x: (g - p.value) / i.value * 2 - 1,
|
|
455
|
+
y: -((E - c.value) / l.value) * 2 + 1
|
|
296
456
|
};
|
|
297
|
-
},
|
|
457
|
+
}, u = ({ x: g, y: E }) => {
|
|
298
458
|
if (t.value)
|
|
299
|
-
return
|
|
300
|
-
},
|
|
301
|
-
const
|
|
302
|
-
x: (g == null ? void 0 : g.clientX) ??
|
|
303
|
-
y: (g == null ? void 0 : g.clientY) ??
|
|
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
|
|
304
464
|
});
|
|
305
|
-
return
|
|
306
|
-
},
|
|
307
|
-
g.trigger({ event:
|
|
308
|
-
},
|
|
309
|
-
|
|
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);
|
|
310
470
|
};
|
|
311
|
-
let
|
|
312
|
-
const
|
|
313
|
-
var
|
|
314
|
-
|
|
315
|
-
},
|
|
316
|
-
var
|
|
317
|
-
g instanceof PointerEvent &&
|
|
318
|
-
},
|
|
319
|
-
return
|
|
320
|
-
|
|
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));
|
|
321
481
|
}), {
|
|
322
|
-
intersects:
|
|
323
|
-
onClick: (g) =>
|
|
324
|
-
onPointerMove: (g) =>
|
|
482
|
+
intersects: y,
|
|
483
|
+
onClick: (g) => f.on(g).off,
|
|
484
|
+
onPointerMove: (g) => h.on(g).off
|
|
325
485
|
};
|
|
326
486
|
};
|
|
327
|
-
function
|
|
328
|
-
const { logWarning: e } =
|
|
329
|
-
function
|
|
330
|
-
let
|
|
331
|
-
return
|
|
332
|
-
|
|
333
|
-
}),
|
|
487
|
+
function Gr() {
|
|
488
|
+
const { logWarning: e } = T();
|
|
489
|
+
function r(a, o, i) {
|
|
490
|
+
let l = null;
|
|
491
|
+
return a.traverse((c) => {
|
|
492
|
+
c[o] === i && (l = c);
|
|
493
|
+
}), l || e(`Child with ${o} '${i}' not found.`), l;
|
|
334
494
|
}
|
|
335
|
-
function t(
|
|
336
|
-
const
|
|
337
|
-
return
|
|
338
|
-
|
|
339
|
-
}),
|
|
495
|
+
function t(a, o, i) {
|
|
496
|
+
const l = [];
|
|
497
|
+
return a.traverse((c) => {
|
|
498
|
+
c[o].includes(i) && l.push(c);
|
|
499
|
+
}), l.length || e(`Children with ${o} '${i}' not found.`), l;
|
|
340
500
|
}
|
|
341
|
-
function
|
|
342
|
-
return
|
|
501
|
+
function n(a, o) {
|
|
502
|
+
return r(a, "name", o);
|
|
343
503
|
}
|
|
344
|
-
function a
|
|
345
|
-
return t(
|
|
504
|
+
function s(a, o) {
|
|
505
|
+
return t(a, "name", o);
|
|
346
506
|
}
|
|
347
507
|
return {
|
|
348
|
-
seek:
|
|
349
|
-
seekByName:
|
|
508
|
+
seek: r,
|
|
509
|
+
seekByName: n,
|
|
350
510
|
seekAll: t,
|
|
351
|
-
seekAllByName:
|
|
511
|
+
seekAllByName: s
|
|
352
512
|
};
|
|
353
513
|
}
|
|
354
|
-
const
|
|
514
|
+
const fr = ({ scene: e, contextParts: r }) => {
|
|
355
515
|
const t = ge({
|
|
356
516
|
click: /* @__PURE__ */ new Map(),
|
|
357
517
|
pointerMove: /* @__PURE__ */ new Map(),
|
|
358
518
|
pointerEnter: /* @__PURE__ */ new Map(),
|
|
359
519
|
pointerLeave: /* @__PURE__ */ new Map()
|
|
360
|
-
}),
|
|
361
|
-
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
},
|
|
365
|
-
Object.values(t).forEach((
|
|
366
|
-
},
|
|
367
|
-
const { onClick:
|
|
368
|
-
|
|
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);
|
|
369
529
|
};
|
|
370
|
-
e.userData.tres__registerAtPointerEventHandler =
|
|
371
|
-
const
|
|
372
|
-
() =>
|
|
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(
|
|
373
533
|
[
|
|
374
|
-
...Array.from(
|
|
375
|
-
...Object.values(t).map((
|
|
534
|
+
...Array.from(n.value),
|
|
535
|
+
...Object.values(t).map((u) => Array.from(u.keys())).flat()
|
|
376
536
|
],
|
|
377
|
-
({ uuid:
|
|
537
|
+
({ uuid: u }) => u
|
|
378
538
|
)
|
|
379
|
-
), { onClick:
|
|
380
|
-
|
|
381
|
-
var
|
|
382
|
-
|
|
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));
|
|
383
543
|
});
|
|
384
|
-
let
|
|
385
|
-
return
|
|
386
|
-
var
|
|
387
|
-
const
|
|
388
|
-
|
|
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;
|
|
389
549
|
}), {
|
|
390
|
-
registerObject:
|
|
391
|
-
deregisterObject:
|
|
550
|
+
registerObject: i,
|
|
551
|
+
deregisterObject: o
|
|
392
552
|
};
|
|
393
553
|
};
|
|
394
|
-
function
|
|
395
|
-
let
|
|
554
|
+
function Se(e) {
|
|
555
|
+
let r = 0;
|
|
396
556
|
return e.traverse((t) => {
|
|
397
557
|
if (t.isMesh && t.geometry) {
|
|
398
|
-
const
|
|
399
|
-
|
|
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;
|
|
400
560
|
}
|
|
401
|
-
}),
|
|
561
|
+
}), r;
|
|
402
562
|
}
|
|
403
|
-
|
|
404
|
-
|
|
563
|
+
function pr(e) {
|
|
564
|
+
return (e / 1024).toFixed(2);
|
|
565
|
+
}
|
|
566
|
+
const X = R({}), re = (e) => Object.assign(X.value, e);
|
|
567
|
+
function mr({
|
|
405
568
|
scene: e,
|
|
406
|
-
canvas:
|
|
569
|
+
canvas: r,
|
|
407
570
|
windowSize: t,
|
|
408
|
-
disableRender:
|
|
409
|
-
rendererOptions:
|
|
571
|
+
disableRender: n,
|
|
572
|
+
rendererOptions: s
|
|
410
573
|
}) {
|
|
411
|
-
const
|
|
412
|
-
() =>
|
|
413
|
-
),
|
|
414
|
-
|
|
415
|
-
|
|
574
|
+
const a = P(
|
|
575
|
+
() => M(t) ? _t() : Et(M(r).parentElement)
|
|
576
|
+
), o = D({
|
|
577
|
+
width: 0,
|
|
578
|
+
height: 0
|
|
579
|
+
}), i = Mt(o, 10), l = O(() => {
|
|
580
|
+
o.value = {
|
|
581
|
+
width: a.value.width.value,
|
|
582
|
+
height: a.value.height.value
|
|
583
|
+
};
|
|
584
|
+
}), c = P(() => i.value.width / i.value.height), p = {
|
|
585
|
+
height: P(() => i.value.height),
|
|
586
|
+
width: P(() => i.value.width),
|
|
416
587
|
aspectRatio: c
|
|
417
|
-
},
|
|
418
|
-
camera:
|
|
419
|
-
cameras:
|
|
420
|
-
registerCamera:
|
|
421
|
-
deregisterCamera:
|
|
422
|
-
setCameraActive:
|
|
423
|
-
} =
|
|
588
|
+
}, d = D(e), {
|
|
589
|
+
camera: u,
|
|
590
|
+
cameras: m,
|
|
591
|
+
registerCamera: y,
|
|
592
|
+
deregisterCamera: f,
|
|
593
|
+
setCameraActive: h
|
|
594
|
+
} = Gt({ sizes: p, scene: e }), { renderer: _ } = lr(
|
|
424
595
|
{
|
|
425
596
|
scene: e,
|
|
426
|
-
canvas:
|
|
427
|
-
options:
|
|
428
|
-
contextParts: { sizes:
|
|
429
|
-
disableRender:
|
|
597
|
+
canvas: r,
|
|
598
|
+
options: s,
|
|
599
|
+
contextParts: { sizes: p, camera: u },
|
|
600
|
+
disableRender: n
|
|
430
601
|
}
|
|
431
|
-
),
|
|
432
|
-
sizes:
|
|
433
|
-
scene:
|
|
434
|
-
camera:
|
|
435
|
-
cameras:
|
|
436
|
-
renderer:
|
|
437
|
-
raycaster:
|
|
438
|
-
controls:
|
|
602
|
+
), w = {
|
|
603
|
+
sizes: p,
|
|
604
|
+
scene: d,
|
|
605
|
+
camera: u,
|
|
606
|
+
cameras: Re(m),
|
|
607
|
+
renderer: _,
|
|
608
|
+
raycaster: D(new st()),
|
|
609
|
+
controls: R(null),
|
|
439
610
|
perf: {
|
|
440
611
|
maxFrames: 160,
|
|
441
612
|
fps: {
|
|
@@ -448,136 +619,136 @@ function vt({
|
|
|
448
619
|
accumulator: []
|
|
449
620
|
}
|
|
450
621
|
},
|
|
451
|
-
extend:
|
|
452
|
-
registerCamera:
|
|
453
|
-
setCameraActive:
|
|
454
|
-
deregisterCamera:
|
|
622
|
+
extend: re,
|
|
623
|
+
registerCamera: y,
|
|
624
|
+
setCameraActive: h,
|
|
625
|
+
deregisterCamera: f
|
|
455
626
|
};
|
|
456
|
-
|
|
457
|
-
const
|
|
458
|
-
let
|
|
459
|
-
const
|
|
460
|
-
|
|
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));
|
|
461
632
|
};
|
|
462
|
-
let
|
|
463
|
-
const
|
|
464
|
-
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));
|
|
465
636
|
}, { immediate: !0 });
|
|
466
|
-
return
|
|
467
|
-
|
|
468
|
-
}),
|
|
637
|
+
return F(() => {
|
|
638
|
+
l(), Oe();
|
|
639
|
+
}), w;
|
|
469
640
|
}
|
|
470
|
-
function
|
|
471
|
-
const e =
|
|
641
|
+
function gr() {
|
|
642
|
+
const e = $e("useTres");
|
|
472
643
|
if (!e)
|
|
473
644
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
474
645
|
return e;
|
|
475
646
|
}
|
|
476
|
-
const
|
|
477
|
-
let
|
|
478
|
-
const { logError:
|
|
647
|
+
const Jr = gr;
|
|
648
|
+
let v = null;
|
|
649
|
+
const { logError: fe } = T(), Y = [
|
|
479
650
|
"onClick",
|
|
480
651
|
"onPointerMove",
|
|
481
652
|
"onPointerEnter",
|
|
482
653
|
"onPointerLeave"
|
|
483
|
-
],
|
|
484
|
-
createElement(e,
|
|
485
|
-
var
|
|
486
|
-
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))
|
|
487
658
|
return null;
|
|
488
|
-
let
|
|
659
|
+
let s = e.replace("Tres", ""), a;
|
|
489
660
|
if (e === "primitive") {
|
|
490
|
-
(
|
|
491
|
-
const
|
|
492
|
-
|
|
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 });
|
|
493
664
|
} else {
|
|
494
|
-
const
|
|
495
|
-
|
|
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);
|
|
496
667
|
}
|
|
497
|
-
return
|
|
498
|
-
...
|
|
499
|
-
tres__name:
|
|
500
|
-
},
|
|
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;
|
|
501
672
|
},
|
|
502
|
-
insert(e,
|
|
503
|
-
var
|
|
504
|
-
|
|
505
|
-
const t =
|
|
673
|
+
insert(e, r) {
|
|
674
|
+
var n, s, a, o;
|
|
675
|
+
r && r.isScene && (v = r);
|
|
676
|
+
const t = r || v;
|
|
506
677
|
if (e != null && e.isObject3D) {
|
|
507
678
|
if (e != null && e.isCamera) {
|
|
508
|
-
if (!(
|
|
679
|
+
if (!(v != null && v.userData.tres__registerCamera))
|
|
509
680
|
throw "could not find tres__registerCamera on scene's userData";
|
|
510
|
-
(
|
|
681
|
+
(s = v == null ? void 0 : (n = v.userData).tres__registerCamera) == null || s.call(n, e);
|
|
511
682
|
}
|
|
512
|
-
if (e &&
|
|
513
|
-
if (!(
|
|
683
|
+
if (e && Y.some((i) => e[i])) {
|
|
684
|
+
if (!(v != null && v.userData.tres__registerAtPointerEventHandler))
|
|
514
685
|
throw "could not find tres__registerAtPointerEventHandler on scene's userData";
|
|
515
|
-
(
|
|
686
|
+
(o = v == null ? void 0 : (a = v.userData).tres__registerAtPointerEventHandler) == null || o.call(a, e);
|
|
516
687
|
}
|
|
517
688
|
}
|
|
518
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));
|
|
519
690
|
},
|
|
520
691
|
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
|
-
|
|
692
|
+
var r, t;
|
|
693
|
+
if (e) {
|
|
694
|
+
if (e.isObject3D) {
|
|
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)
|
|
702
|
+
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
|
|
703
|
+
if ((d = v == null ? void 0 : (p = v.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || d.call(p, c), !a)
|
|
704
|
+
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
|
|
705
|
+
c && Y.some((u) => c[u]) && (a == null || a(c));
|
|
706
|
+
}, l = (c) => {
|
|
707
|
+
const p = v == null ? void 0 : v.userData.tres__deregisterCamera;
|
|
708
|
+
if (!p)
|
|
709
|
+
throw "could not find tres__deregisterCamera on scene's userData";
|
|
710
|
+
c.isCamera && (p == null || p(c));
|
|
711
|
+
};
|
|
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);
|
|
715
|
+
}
|
|
716
|
+
(t = e.dispose) == null || t.call(e);
|
|
545
717
|
}
|
|
546
|
-
l && e.dispose && e.type !== "Scene" && e.dispose();
|
|
547
718
|
},
|
|
548
|
-
patchProp(e,
|
|
549
|
-
var a, o,
|
|
719
|
+
patchProp(e, r, t, n) {
|
|
720
|
+
var s, a, o, i;
|
|
550
721
|
if (e) {
|
|
551
|
-
let
|
|
552
|
-
if (e.isObject3D &&
|
|
553
|
-
|
|
722
|
+
let l = e, c = r;
|
|
723
|
+
if (e.isObject3D && c === "blocks-pointer-events") {
|
|
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);
|
|
554
725
|
return;
|
|
555
726
|
}
|
|
556
|
-
let
|
|
557
|
-
if (
|
|
558
|
-
const
|
|
559
|
-
|
|
727
|
+
let p = I(c), d = l == null ? void 0 : l[p];
|
|
728
|
+
if (c === "args") {
|
|
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)));
|
|
560
731
|
return;
|
|
561
732
|
}
|
|
562
|
-
if (
|
|
563
|
-
if (
|
|
733
|
+
if (l.type === "BufferGeometry") {
|
|
734
|
+
if (c === "args")
|
|
564
735
|
return;
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
new
|
|
736
|
+
l.setAttribute(
|
|
737
|
+
I(c),
|
|
738
|
+
new it(...n)
|
|
568
739
|
);
|
|
569
740
|
return;
|
|
570
741
|
}
|
|
571
|
-
if (
|
|
572
|
-
const
|
|
573
|
-
|
|
742
|
+
if (c.includes("-") && d === void 0) {
|
|
743
|
+
const m = c.split("-");
|
|
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));
|
|
574
745
|
}
|
|
575
|
-
let
|
|
576
|
-
if (
|
|
577
|
-
|
|
746
|
+
let u = n;
|
|
747
|
+
if (u === "" && (u = !0), de(d)) {
|
|
748
|
+
Y.includes(r) || (Array.isArray(u) ? e[p](...u) : e[p](u));
|
|
578
749
|
return;
|
|
579
750
|
}
|
|
580
|
-
!(
|
|
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);
|
|
581
752
|
}
|
|
582
753
|
},
|
|
583
754
|
parentNode(e) {
|
|
@@ -592,9 +763,288 @@ const { logError: re } = B(), V = [
|
|
|
592
763
|
setScopeId: () => void 0,
|
|
593
764
|
cloneNode: () => void 0,
|
|
594
765
|
insertStaticContent: () => void 0
|
|
595
|
-
}, { render:
|
|
596
|
-
|
|
597
|
-
|
|
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({
|
|
598
1048
|
__name: "TresCanvas",
|
|
599
1049
|
props: {
|
|
600
1050
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -620,113 +1070,205 @@ const ht = ["data-scene"], wt = /* @__PURE__ */ J({
|
|
|
620
1070
|
logarithmicDepthBuffer: { type: Boolean, default: void 0 },
|
|
621
1071
|
failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
|
|
622
1072
|
},
|
|
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({
|
|
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({
|
|
630
1076
|
setup() {
|
|
631
|
-
var
|
|
632
|
-
const
|
|
633
|
-
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() : []);
|
|
634
1080
|
}
|
|
635
|
-
}),
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
f
|
|
643
|
-
|
|
644
|
-
|
|
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,
|
|
645
1092
|
windowSize: t.windowSize,
|
|
646
|
-
disableRender:
|
|
1093
|
+
disableRender: u,
|
|
647
1094
|
rendererOptions: t
|
|
648
|
-
}),
|
|
649
|
-
const { registerCamera:
|
|
650
|
-
|
|
651
|
-
const
|
|
652
|
-
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(
|
|
653
1100
|
45,
|
|
654
1101
|
window.innerWidth / window.innerHeight,
|
|
655
1102
|
0.1,
|
|
656
1103
|
1e3
|
|
657
1104
|
);
|
|
658
|
-
|
|
659
|
-
const
|
|
660
|
-
|
|
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());
|
|
661
1108
|
});
|
|
662
1109
|
};
|
|
663
|
-
|
|
1110
|
+
me(
|
|
664
1111
|
() => t.camera,
|
|
665
|
-
(
|
|
666
|
-
|
|
1112
|
+
(b, x) => {
|
|
1113
|
+
b && h(b), x && (x.removeFromParent(), C(x));
|
|
667
1114
|
},
|
|
668
1115
|
{
|
|
669
1116
|
immediate: !0
|
|
670
1117
|
}
|
|
671
|
-
),
|
|
1118
|
+
), _.value || (n(
|
|
672
1119
|
"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", {
|
|
1120
|
+
), S());
|
|
1121
|
+
}), (f, h) => (Ve(), We("canvas", {
|
|
677
1122
|
ref_key: "canvas",
|
|
678
|
-
ref:
|
|
679
|
-
"data-scene":
|
|
680
|
-
class:
|
|
681
|
-
|
|
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({
|
|
682
1128
|
display: "block",
|
|
683
1129
|
width: "100%",
|
|
684
1130
|
height: "100%",
|
|
685
|
-
position:
|
|
1131
|
+
position: f.windowSize ? "fixed" : "relative",
|
|
686
1132
|
top: 0,
|
|
687
1133
|
left: 0,
|
|
688
1134
|
pointerEvents: "auto",
|
|
689
1135
|
touchAction: "none",
|
|
690
|
-
...
|
|
1136
|
+
...f.$attrs.style
|
|
691
1137
|
})
|
|
692
|
-
}, null, 14,
|
|
1138
|
+
}, null, 14, Tr));
|
|
693
1139
|
}
|
|
694
|
-
}),
|
|
1140
|
+
}), Or = [
|
|
695
1141
|
"TresCanvas",
|
|
696
1142
|
"TresLeches",
|
|
697
1143
|
"TresScene"
|
|
698
|
-
],
|
|
1144
|
+
], Dr = {
|
|
699
1145
|
template: {
|
|
700
1146
|
compilerOptions: {
|
|
701
|
-
isCustomElement: (e) => e.startsWith("Tres") && !
|
|
1147
|
+
isCustomElement: (e) => e.startsWith("Tres") && !Or.includes(e) || e === "primitive"
|
|
702
1148
|
}
|
|
703
1149
|
}
|
|
704
|
-
},
|
|
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);
|
|
1175
|
+
}
|
|
1176
|
+
this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld), this.children[0].matrixWorld.copy(this.matrixWorld);
|
|
1177
|
+
}
|
|
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 = {
|
|
705
1244
|
install(e) {
|
|
706
|
-
e.component("TresCanvas",
|
|
1245
|
+
e.component("TresCanvas", Lr);
|
|
707
1246
|
}
|
|
708
1247
|
};
|
|
709
1248
|
export {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
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
|
|
732
1274
|
};
|