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