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