@tresjs/core 3.6.0 → 3.6.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 +6 -6
- package/dist/index.d.ts +3 -17
- package/dist/{components → src/components}/TresCanvas.vue.d.ts +5 -4
- package/dist/{composables → src/composables}/useCamera/index.d.ts +12 -12
- package/dist/{composables → src/composables}/useRenderer/index.d.ts +1 -1
- package/dist/src/index.d.ts +17 -0
- package/dist/{types → src/types}/index.d.ts +1 -1
- package/dist/tres.js +509 -386
- package/dist/tres.umd.cjs +3 -3
- package/package.json +1 -1
- /package/dist/{components → src/components}/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useLoader/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useLogger.d.ts +0 -0
- /package/dist/{composables → src/composables}/usePointerEventHandler/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useRaycaster/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useRenderLoop/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useRenderer/const.d.ts +0 -0
- /package/dist/{composables → src/composables}/useSeek/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useTexture/index.d.ts +0 -0
- /package/dist/{composables → src/composables}/useTresContextProvider/index.d.ts +0 -0
- /package/dist/{core → src/core}/catalogue.d.ts +0 -0
- /package/dist/{core → src/core}/nodeOps.d.ts +0 -0
- /package/dist/{core → src/core}/renderer.d.ts +0 -0
- /package/dist/{core → src/core}/revision.d.ts +0 -0
- /package/dist/{utils → src/utils}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/normalize.d.ts +0 -0
- /package/dist/{utils → src/utils}/perf.d.ts +0 -0
- /package/dist/{utils → src/utils}/template-compiler-options.d.ts +0 -0
- /package/dist/{utils → src/utils}/test-utils.d.ts +0 -0
package/dist/tres.js
CHANGED
|
@@ -1,433 +1,550 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v3.6.
|
|
4
|
-
* (c)
|
|
3
|
+
* version: v3.6.1
|
|
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
|
-
import { ref as
|
|
9
|
-
import * as
|
|
10
|
-
import { PerspectiveCamera as G, OrthographicCamera as
|
|
11
|
-
import { createEventHook as S, useRafFn as
|
|
12
|
-
const
|
|
13
|
-
|
|
8
|
+
import { ref as L, computed as k, watchEffect as D, onUnmounted as $, shallowRef as x, watch as ne, reactive as ve, readonly as ge, provide as W, inject as ye, createRenderer as he, defineComponent as J, useSlots as we, getCurrentInstance as K, onMounted as Ee, openBlock as be, createElementBlock as Ce, normalizeClass as _e, unref as Me, normalizeStyle as Pe, h as X, Fragment as Ae } from "vue";
|
|
9
|
+
import * as ke from "three";
|
|
10
|
+
import { PerspectiveCamera as G, OrthographicCamera as De, Camera as xe, Clock as Te, Vector3 as Se, Color as H, REVISION as Le, SRGBColorSpace as je, ACESFilmicToneMapping as Be, PCFSoftShadowMap as Oe, WebGLRenderer as I, LoadingManager as Re, TextureLoader as He, Vector2 as ze, Raycaster as Fe, BufferAttribute as $e, Scene as Ne } from "three";
|
|
11
|
+
import { createEventHook as S, useRafFn as se, toValue as _, unrefElement as Ie, useDevicePixelRatio as Ve, usePointer as We, useElementBounding as Ge, useWindowSize as qe, useElementSize as Ue, refDebounced as Ye, useFps as Je, useMemory as Ke } from "@vueuse/core";
|
|
12
|
+
const Xe = "@tresjs/core", Qe = "module", Ze = "3.6.1", et = "pnpm@8.10.2", tt = "Declarative ThreeJS using Vue Components", rt = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", nt = "MIT", st = [
|
|
13
|
+
"vue",
|
|
14
|
+
"3d",
|
|
15
|
+
"threejs",
|
|
16
|
+
"three",
|
|
17
|
+
"threejs-vue"
|
|
18
|
+
], ot = !1, at = {
|
|
19
|
+
".": {
|
|
20
|
+
types: "./dist/index.d.ts",
|
|
21
|
+
require: "./dist/tres.umd.cjs",
|
|
22
|
+
import: "./dist/tres.js"
|
|
23
|
+
},
|
|
24
|
+
"./components": {
|
|
25
|
+
types: "./dist/components/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./composables": {
|
|
28
|
+
types: "./dist/composables/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./types": {
|
|
31
|
+
types: "./dist/types/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./utils": {
|
|
34
|
+
types: "./dist/utils/index.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./*": "./*"
|
|
37
|
+
}, it = "./dist/tres.js", lt = "./dist/tres.js", ut = "./dist/index.d.ts", ct = [
|
|
38
|
+
"dist",
|
|
39
|
+
"*.d.ts"
|
|
40
|
+
], ft = {
|
|
41
|
+
access: "public"
|
|
42
|
+
}, pt = {
|
|
43
|
+
dev: "cd playground && npm run dev",
|
|
44
|
+
build: "vite build",
|
|
45
|
+
playground: "cd playground && npm run dev",
|
|
46
|
+
test: "vitest",
|
|
47
|
+
"test:ci": "vitest run",
|
|
48
|
+
"test:ui": "vitest --ui",
|
|
49
|
+
release: "release-it",
|
|
50
|
+
coverage: "vitest run --coverage",
|
|
51
|
+
lint: "eslint . --ext .js,.jsx,.ts,.tsx,.vue",
|
|
52
|
+
"docs:dev": "vitepress dev docs",
|
|
53
|
+
"docs:build": "vitepress build docs",
|
|
54
|
+
"docs:serve": "vitepress serve docs",
|
|
55
|
+
"docs:preview": "vitepress preview docs",
|
|
56
|
+
"docs:contributors": "esno scripts/update-contributors.ts"
|
|
57
|
+
}, dt = {
|
|
58
|
+
three: ">=0.133",
|
|
59
|
+
vue: ">=3.3"
|
|
60
|
+
}, mt = {
|
|
61
|
+
"@alvarosabu/utils": "^3.1.1",
|
|
62
|
+
"@vueuse/core": "^10.7.0"
|
|
63
|
+
}, vt = {
|
|
64
|
+
"@release-it/conventional-changelog": "^8.0.1",
|
|
65
|
+
"@stackblitz/sdk": "^1.9.0",
|
|
66
|
+
"@tresjs/cientos": "3.6.0",
|
|
67
|
+
"@tresjs/eslint-config-vue": "^0.2.1",
|
|
68
|
+
"@types/three": "^0.159.0",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
70
|
+
"@typescript-eslint/parser": "^6.14.0",
|
|
71
|
+
"@vitejs/plugin-vue": "^4.5.2",
|
|
72
|
+
"@vitest/coverage-c8": "^0.33.0",
|
|
73
|
+
"@vitest/ui": "^1.0.4",
|
|
74
|
+
"@vue/test-utils": "^2.4.3",
|
|
75
|
+
eslint: "^8.55.0",
|
|
76
|
+
"eslint-plugin-vue": "^9.19.2",
|
|
77
|
+
esno: "^4.0.0",
|
|
78
|
+
gsap: "^3.12.3",
|
|
79
|
+
jsdom: "^23.0.1",
|
|
80
|
+
kolorist: "^1.8.0",
|
|
81
|
+
ohmyfetch: "^0.4.21",
|
|
82
|
+
pathe: "^1.1.1",
|
|
83
|
+
"release-it": "^17.0.1",
|
|
84
|
+
"rollup-plugin-analyzer": "^4.0.0",
|
|
85
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
86
|
+
"rollup-plugin-visualizer": "^5.11.0",
|
|
87
|
+
three: "^0.159.0",
|
|
88
|
+
unocss: "^0.58.0",
|
|
89
|
+
unplugin: "^1.5.1",
|
|
90
|
+
"unplugin-vue-components": "^0.26.0",
|
|
91
|
+
vite: "^5.0.8",
|
|
92
|
+
"vite-plugin-banner": "^0.7.1",
|
|
93
|
+
"vite-plugin-dts": "3.6.4",
|
|
94
|
+
"vite-plugin-inspect": "^0.8.1",
|
|
95
|
+
"vite-plugin-require-transform": "^1.0.21",
|
|
96
|
+
"vite-svg-loader": "^5.1.0",
|
|
97
|
+
vitepress: "1.0.0-rc.31",
|
|
98
|
+
vitest: "^1.0.4",
|
|
99
|
+
vue: "^3.3.11",
|
|
100
|
+
"vue-demi": "^0.14.6"
|
|
101
|
+
}, gt = {
|
|
102
|
+
name: Xe,
|
|
103
|
+
type: Qe,
|
|
104
|
+
version: Ze,
|
|
105
|
+
packageManager: et,
|
|
106
|
+
description: tt,
|
|
107
|
+
author: rt,
|
|
108
|
+
license: nt,
|
|
109
|
+
keywords: st,
|
|
110
|
+
sideEffects: ot,
|
|
111
|
+
exports: at,
|
|
112
|
+
main: it,
|
|
113
|
+
module: lt,
|
|
114
|
+
types: ut,
|
|
115
|
+
files: ct,
|
|
116
|
+
publishConfig: ft,
|
|
117
|
+
scripts: pt,
|
|
118
|
+
peerDependencies: dt,
|
|
119
|
+
dependencies: mt,
|
|
120
|
+
devDependencies: vt
|
|
121
|
+
}, yt = ({ sizes: e, scene: s }) => {
|
|
122
|
+
const t = L([]), r = k(
|
|
14
123
|
() => t.value[0]
|
|
15
|
-
), n = (
|
|
16
|
-
t.value.some(({ uuid:
|
|
17
|
-
}, o = (
|
|
18
|
-
t.value = t.value.filter(({ uuid: l }) => l !==
|
|
19
|
-
},
|
|
20
|
-
const l =
|
|
124
|
+
), n = (a, l = !1) => {
|
|
125
|
+
t.value.some(({ uuid: c }) => c === a.uuid) || (l ? u(a) : t.value.push(a));
|
|
126
|
+
}, o = (a) => {
|
|
127
|
+
t.value = t.value.filter(({ uuid: l }) => l !== a.uuid);
|
|
128
|
+
}, u = (a) => {
|
|
129
|
+
const l = a instanceof xe ? a : t.value.find((d) => d.uuid === a);
|
|
21
130
|
if (!l)
|
|
22
131
|
return;
|
|
23
|
-
const
|
|
24
|
-
t.value = [l, ...
|
|
132
|
+
const c = t.value.filter(({ uuid: d }) => d !== l.uuid);
|
|
133
|
+
t.value = [l, ...c];
|
|
25
134
|
};
|
|
26
135
|
return D(() => {
|
|
27
|
-
e.aspectRatio.value && t.value.forEach((
|
|
28
|
-
|
|
136
|
+
e.aspectRatio.value && t.value.forEach((a) => {
|
|
137
|
+
a instanceof G && (a.aspect = e.aspectRatio.value), (a instanceof G || a instanceof De) && a.updateProjectionMatrix();
|
|
29
138
|
});
|
|
30
|
-
}),
|
|
139
|
+
}), s.userData.tres__registerCamera = n, s.userData.tres__deregisterCamera = o, $(() => {
|
|
31
140
|
t.value = [];
|
|
32
141
|
}), {
|
|
33
142
|
camera: r,
|
|
34
143
|
cameras: t,
|
|
35
144
|
registerCamera: n,
|
|
36
145
|
deregisterCamera: o,
|
|
37
|
-
setCameraActive:
|
|
146
|
+
setCameraActive: u
|
|
38
147
|
};
|
|
39
|
-
},
|
|
40
|
-
let
|
|
41
|
-
const { pause:
|
|
148
|
+
}, oe = S(), ae = S(), U = S(), T = new Te();
|
|
149
|
+
let z = 0, F = 0;
|
|
150
|
+
const { pause: ht, resume: wt, isActive: Et } = se(
|
|
42
151
|
() => {
|
|
43
|
-
|
|
152
|
+
oe.trigger({ delta: z, elapsed: F, clock: T }), ae.trigger({ delta: z, elapsed: F, clock: T }), U.trigger({ delta: z, elapsed: F, clock: T });
|
|
44
153
|
},
|
|
45
154
|
{ immediate: !1 }
|
|
46
155
|
);
|
|
47
156
|
U.on(() => {
|
|
48
|
-
|
|
157
|
+
z = T.getDelta(), F = T.getElapsedTime();
|
|
49
158
|
});
|
|
50
|
-
const
|
|
51
|
-
onBeforeLoop:
|
|
52
|
-
onLoop:
|
|
159
|
+
const ie = () => ({
|
|
160
|
+
onBeforeLoop: oe.on,
|
|
161
|
+
onLoop: ae.on,
|
|
53
162
|
onAfterLoop: U.on,
|
|
54
|
-
pause:
|
|
55
|
-
resume:
|
|
56
|
-
isActive:
|
|
57
|
-
}),
|
|
58
|
-
function
|
|
163
|
+
pause: ht,
|
|
164
|
+
resume: wt,
|
|
165
|
+
isActive: Et
|
|
166
|
+
}), Yt = !0, Q = "[TresJS ▲ ■ ●] ";
|
|
167
|
+
function j() {
|
|
59
168
|
function e(r, n) {
|
|
60
|
-
console.error(`${
|
|
169
|
+
console.error(`${Q} ${r}`, n || "");
|
|
61
170
|
}
|
|
62
|
-
function
|
|
63
|
-
console.warn(`${
|
|
171
|
+
function s(r) {
|
|
172
|
+
console.warn(`${Q} ${r}`);
|
|
64
173
|
}
|
|
65
174
|
function t(r, n) {
|
|
66
175
|
}
|
|
67
176
|
return {
|
|
68
177
|
logError: e,
|
|
69
|
-
logWarning:
|
|
178
|
+
logWarning: s,
|
|
70
179
|
logMessage: t
|
|
71
180
|
};
|
|
72
181
|
}
|
|
73
|
-
function
|
|
74
|
-
return typeof e == "number" ? [e, e, e] : e instanceof
|
|
182
|
+
function Jt(e) {
|
|
183
|
+
return typeof e == "number" ? [e, e, e] : e instanceof Se ? [e.x, e.y, e.z] : e;
|
|
75
184
|
}
|
|
76
|
-
function
|
|
77
|
-
return e instanceof
|
|
185
|
+
function bt(e) {
|
|
186
|
+
return e instanceof H ? e : Array.isArray(e) ? new H(...e) : new H(e);
|
|
78
187
|
}
|
|
79
|
-
const
|
|
80
|
-
for (const t of Object.keys(
|
|
81
|
-
|
|
82
|
-
return Object.assign(e || {},
|
|
83
|
-
},
|
|
84
|
-
function
|
|
188
|
+
const le = (e, s) => {
|
|
189
|
+
for (const t of Object.keys(s))
|
|
190
|
+
s[t] instanceof Object && Object.assign(s[t], le(e[t], s[t]));
|
|
191
|
+
return Object.assign(e || {}, s), e;
|
|
192
|
+
}, Ct = "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", _t = /* @__PURE__ */ Mt(Ct);
|
|
193
|
+
function Z(e) {
|
|
85
194
|
return e && e.nodeType === 1;
|
|
86
195
|
}
|
|
87
|
-
function
|
|
88
|
-
return e.replace(/-([a-z])/g, (
|
|
196
|
+
function O(e) {
|
|
197
|
+
return e.replace(/-([a-z])/g, (s, t) => t.toUpperCase());
|
|
89
198
|
}
|
|
90
|
-
function
|
|
199
|
+
function Mt(e, s) {
|
|
91
200
|
const t = /* @__PURE__ */ Object.create(null), r = e.split(",");
|
|
92
201
|
for (let n = 0; n < r.length; n++)
|
|
93
202
|
t[r[n]] = !0;
|
|
94
|
-
return
|
|
203
|
+
return s ? (n) => !!t[n.toLowerCase()] : (n) => !!t[n];
|
|
95
204
|
}
|
|
96
|
-
const
|
|
205
|
+
const Pt = (e, s) => {
|
|
97
206
|
const t = /* @__PURE__ */ new Set(), r = [];
|
|
98
207
|
for (const n of e) {
|
|
99
|
-
const o =
|
|
208
|
+
const o = s(n);
|
|
100
209
|
t.has(o) || (t.add(o), r.push(n));
|
|
101
210
|
}
|
|
102
211
|
return r;
|
|
103
|
-
},
|
|
104
|
-
if (!
|
|
212
|
+
}, ee = (e, s) => {
|
|
213
|
+
if (!s)
|
|
105
214
|
return;
|
|
106
|
-
const t = Array.isArray(
|
|
215
|
+
const t = Array.isArray(s) ? s : s.match(/([^[.\]])+/g);
|
|
107
216
|
return t == null ? void 0 : t.reduce((r, n) => r && r[n], e);
|
|
108
|
-
},
|
|
109
|
-
const r = Array.isArray(
|
|
110
|
-
r && r.reduce((n, o,
|
|
217
|
+
}, At = (e, s, t) => {
|
|
218
|
+
const r = Array.isArray(s) ? s : s.match(/([^[.\]])+/g);
|
|
219
|
+
r && r.reduce((n, o, u) => (n[o] === void 0 && (n[o] = {}), u === r.length - 1 && (n[o] = t), n[o]), e);
|
|
111
220
|
};
|
|
112
|
-
function ue(e,
|
|
113
|
-
if (
|
|
114
|
-
const n = e.attributes, o =
|
|
115
|
-
return n.length !== o.length ? !1 : Array.from(n).every(({ name:
|
|
221
|
+
function ue(e, s) {
|
|
222
|
+
if (Z(e) && Z(s)) {
|
|
223
|
+
const n = e.attributes, o = s.attributes;
|
|
224
|
+
return n.length !== o.length ? !1 : Array.from(n).every(({ name: u, value: a }) => s.getAttribute(u) === a);
|
|
116
225
|
}
|
|
117
|
-
if (e ===
|
|
226
|
+
if (e === s)
|
|
118
227
|
return !0;
|
|
119
|
-
if (e === null || typeof e != "object" ||
|
|
228
|
+
if (e === null || typeof e != "object" || s === null || typeof s != "object")
|
|
120
229
|
return !1;
|
|
121
|
-
const t = Object.keys(e), r = Object.keys(
|
|
230
|
+
const t = Object.keys(e), r = Object.keys(s);
|
|
122
231
|
if (t.length !== r.length)
|
|
123
232
|
return !1;
|
|
124
233
|
for (const n of t)
|
|
125
|
-
if (!r.includes(n) || !ue(e[n],
|
|
234
|
+
if (!r.includes(n) || !ue(e[n], s[n]))
|
|
126
235
|
return !1;
|
|
127
236
|
return !0;
|
|
128
237
|
}
|
|
129
|
-
function
|
|
130
|
-
if (!Array.isArray(e) || !Array.isArray(
|
|
238
|
+
function kt(e, s) {
|
|
239
|
+
if (!Array.isArray(e) || !Array.isArray(s) || e.length !== s.length)
|
|
131
240
|
return !1;
|
|
132
241
|
for (let t = 0; t < e.length; t++)
|
|
133
|
-
if (!ue(e[t],
|
|
242
|
+
if (!ue(e[t], s[t]))
|
|
134
243
|
return !1;
|
|
135
244
|
return !0;
|
|
136
245
|
}
|
|
137
|
-
const
|
|
246
|
+
const Dt = Array.isArray, xt = Number.parseInt(Le.replace("dev", "")), R = {
|
|
138
247
|
realistic: {
|
|
139
248
|
shadows: !0,
|
|
140
249
|
physicallyCorrectLights: !0,
|
|
141
|
-
outputColorSpace:
|
|
142
|
-
toneMapping:
|
|
250
|
+
outputColorSpace: je,
|
|
251
|
+
toneMapping: Be,
|
|
143
252
|
toneMappingExposure: 3,
|
|
144
253
|
shadowMap: {
|
|
145
254
|
enabled: !0,
|
|
146
|
-
type:
|
|
255
|
+
type: Oe
|
|
147
256
|
}
|
|
148
257
|
}
|
|
149
258
|
};
|
|
150
|
-
function
|
|
259
|
+
function Tt({
|
|
151
260
|
scene: e,
|
|
152
|
-
canvas:
|
|
261
|
+
canvas: s,
|
|
153
262
|
options: t,
|
|
154
263
|
disableRender: r,
|
|
155
264
|
contextParts: { sizes: n, camera: o }
|
|
156
265
|
}) {
|
|
157
|
-
const
|
|
158
|
-
alpha:
|
|
159
|
-
depth:
|
|
160
|
-
canvas:
|
|
161
|
-
context:
|
|
162
|
-
stencil:
|
|
163
|
-
antialias:
|
|
164
|
-
precision:
|
|
165
|
-
powerPreference:
|
|
166
|
-
premultipliedAlpha:
|
|
167
|
-
preserveDrawingBuffer:
|
|
168
|
-
logarithmicDepthBuffer:
|
|
169
|
-
failIfMajorPerformanceCaveat:
|
|
170
|
-
})),
|
|
171
|
-
|
|
172
|
-
|
|
266
|
+
const u = k(() => ({
|
|
267
|
+
alpha: _(t.alpha),
|
|
268
|
+
depth: _(t.depth),
|
|
269
|
+
canvas: Ie(s),
|
|
270
|
+
context: _(t.context),
|
|
271
|
+
stencil: _(t.stencil),
|
|
272
|
+
antialias: _(t.antialias) === void 0 ? !0 : _(t.antialias),
|
|
273
|
+
precision: _(t.precision),
|
|
274
|
+
powerPreference: _(t.powerPreference),
|
|
275
|
+
premultipliedAlpha: _(t.premultipliedAlpha),
|
|
276
|
+
preserveDrawingBuffer: _(t.preserveDrawingBuffer),
|
|
277
|
+
logarithmicDepthBuffer: _(t.logarithmicDepthBuffer),
|
|
278
|
+
failIfMajorPerformanceCaveat: _(t.failIfMajorPerformanceCaveat)
|
|
279
|
+
})), a = x(new I(u.value));
|
|
280
|
+
ne(u, () => {
|
|
281
|
+
a.value.dispose(), a.value = new I(u.value);
|
|
173
282
|
}), D(() => {
|
|
174
|
-
|
|
283
|
+
a.value.setSize(n.width.value, n.height.value);
|
|
175
284
|
});
|
|
176
|
-
const { pixelRatio: l } =
|
|
285
|
+
const { pixelRatio: l } = Ve();
|
|
177
286
|
D(() => {
|
|
178
|
-
|
|
287
|
+
a.value.setPixelRatio(l.value);
|
|
179
288
|
});
|
|
180
|
-
const { logError:
|
|
181
|
-
const
|
|
289
|
+
const { logError: c } = j(), f = (() => {
|
|
290
|
+
const p = new I(), y = {
|
|
182
291
|
shadowMap: {
|
|
183
|
-
enabled:
|
|
184
|
-
type:
|
|
292
|
+
enabled: p.shadowMap.enabled,
|
|
293
|
+
type: p.shadowMap.type
|
|
185
294
|
},
|
|
186
|
-
toneMapping:
|
|
187
|
-
toneMappingExposure:
|
|
188
|
-
outputColorSpace:
|
|
295
|
+
toneMapping: p.toneMapping,
|
|
296
|
+
toneMappingExposure: p.toneMappingExposure,
|
|
297
|
+
outputColorSpace: p.outputColorSpace
|
|
189
298
|
};
|
|
190
|
-
return
|
|
299
|
+
return p.dispose(), y;
|
|
191
300
|
})();
|
|
192
301
|
D(() => {
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
198
|
-
return
|
|
302
|
+
const p = _(t.preset);
|
|
303
|
+
p && (p in R || c(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), le(a.value, R[p]));
|
|
304
|
+
const y = (M, P) => {
|
|
305
|
+
const E = _(M), A = () => {
|
|
306
|
+
if (p)
|
|
307
|
+
return ee(R[p], P);
|
|
199
308
|
};
|
|
200
|
-
if (
|
|
201
|
-
return
|
|
202
|
-
const
|
|
203
|
-
return
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
309
|
+
if (E !== void 0)
|
|
310
|
+
return E;
|
|
311
|
+
const v = A();
|
|
312
|
+
return v !== void 0 ? v : ee(f, P);
|
|
313
|
+
}, b = (M, P) => At(a.value, P, y(M, P));
|
|
314
|
+
b(t.shadows, "shadowMap.enabled"), b(t.toneMapping, "toneMapping"), b(t.shadowMapType, "shadowMap.type"), xt < 150 && b(!t.useLegacyLights, "physicallyCorrectLights"), b(t.outputColorSpace, "outputColorSpace"), b(t.toneMappingExposure, "toneMappingExposure");
|
|
315
|
+
const w = y(t.clearColor, "clearColor");
|
|
316
|
+
w && a.value.setClearColor(
|
|
317
|
+
w ? bt(w) : new H(0)
|
|
209
318
|
// default clear color is not easily/efficiently retrievable from three
|
|
210
319
|
);
|
|
211
320
|
});
|
|
212
|
-
const { pause:
|
|
213
|
-
return
|
|
214
|
-
o.value && !
|
|
215
|
-
}),
|
|
216
|
-
|
|
321
|
+
const { pause: i, resume: m, onLoop: h } = ie();
|
|
322
|
+
return h(() => {
|
|
323
|
+
o.value && !_(r) && a.value.render(e, o.value);
|
|
324
|
+
}), m(), $(() => {
|
|
325
|
+
i(), a.value.dispose(), a.value.forceContextLoss();
|
|
217
326
|
}), {
|
|
218
|
-
renderer:
|
|
327
|
+
renderer: a
|
|
219
328
|
};
|
|
220
329
|
}
|
|
221
|
-
const
|
|
222
|
-
function
|
|
223
|
-
const
|
|
330
|
+
const te = (e) => typeof e == "function", St = (e) => !!e && e.constructor === Array;
|
|
331
|
+
function Lt(e) {
|
|
332
|
+
const s = { nodes: {}, materials: {} };
|
|
224
333
|
return e && e.traverse((t) => {
|
|
225
|
-
t.name && (
|
|
226
|
-
}),
|
|
334
|
+
t.name && (s.nodes[t.name] = t), t.material && !s.materials[t.material.name] && (s.materials[t.material.name] = t.material);
|
|
335
|
+
}), s;
|
|
227
336
|
}
|
|
228
|
-
async function
|
|
229
|
-
const { logError: o } =
|
|
230
|
-
n && n(
|
|
231
|
-
const l = (Array.isArray(
|
|
232
|
-
(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
(
|
|
236
|
-
|
|
337
|
+
async function Kt(e, s, t, r, n) {
|
|
338
|
+
const { logError: o } = j(), u = new e();
|
|
339
|
+
n && n(u), t && t(u);
|
|
340
|
+
const l = (Array.isArray(s) ? s : [s]).map(
|
|
341
|
+
(c) => new Promise((d, f) => {
|
|
342
|
+
u.load(
|
|
343
|
+
c,
|
|
344
|
+
(i) => {
|
|
345
|
+
i.scene && Object.assign(i, Lt(i.scene)), d(i);
|
|
237
346
|
},
|
|
238
347
|
r,
|
|
239
|
-
(
|
|
348
|
+
(i) => f(o("[useLoader] - Failed to load resource", i))
|
|
240
349
|
);
|
|
241
350
|
})
|
|
242
351
|
);
|
|
243
|
-
return
|
|
352
|
+
return St(s) ? await Promise.all(l) : await l[0];
|
|
244
353
|
}
|
|
245
|
-
async function
|
|
246
|
-
const
|
|
354
|
+
async function Xt(e) {
|
|
355
|
+
const s = new Re(), t = new He(s), r = (n) => new Promise((o, u) => {
|
|
247
356
|
t.load(
|
|
248
357
|
n,
|
|
249
|
-
(
|
|
358
|
+
(a) => o(a),
|
|
250
359
|
() => null,
|
|
251
360
|
() => {
|
|
252
|
-
|
|
361
|
+
u(new Error("[useTextures] - Failed to load texture"));
|
|
253
362
|
}
|
|
254
363
|
);
|
|
255
364
|
});
|
|
256
|
-
if (
|
|
365
|
+
if (Dt(e)) {
|
|
257
366
|
const n = await Promise.all(e.map((o) => r(o)));
|
|
258
367
|
return e.length > 1 ? n : n[0];
|
|
259
368
|
} else {
|
|
260
369
|
const {
|
|
261
370
|
map: n,
|
|
262
371
|
displacementMap: o,
|
|
263
|
-
normalMap:
|
|
264
|
-
roughnessMap:
|
|
372
|
+
normalMap: u,
|
|
373
|
+
roughnessMap: a,
|
|
265
374
|
metalnessMap: l,
|
|
266
|
-
aoMap:
|
|
267
|
-
alphaMap:
|
|
375
|
+
aoMap: c,
|
|
376
|
+
alphaMap: d,
|
|
268
377
|
matcap: f
|
|
269
378
|
} = e;
|
|
270
379
|
return {
|
|
271
380
|
map: n ? await r(n) : null,
|
|
272
381
|
displacementMap: o ? await r(o) : null,
|
|
273
|
-
normalMap:
|
|
274
|
-
roughnessMap:
|
|
382
|
+
normalMap: u ? await r(u) : null,
|
|
383
|
+
roughnessMap: a ? await r(a) : null,
|
|
275
384
|
metalnessMap: l ? await r(l) : null,
|
|
276
|
-
aoMap:
|
|
277
|
-
alphaMap:
|
|
385
|
+
aoMap: c ? await r(c) : null,
|
|
386
|
+
alphaMap: d ? await r(d) : null,
|
|
278
387
|
matcap: f ? await r(f) : null
|
|
279
388
|
};
|
|
280
389
|
}
|
|
281
390
|
}
|
|
282
|
-
const
|
|
283
|
-
const n =
|
|
391
|
+
const jt = (e, { renderer: s, camera: t, raycaster: r }) => {
|
|
392
|
+
const n = k(() => s.value.domElement), { x: o, y: u } = We({ target: n }), { width: a, height: l, top: c, left: d } = Ge(n), f = ({ x: v, y: C }) => {
|
|
284
393
|
if (n.value)
|
|
285
394
|
return {
|
|
286
|
-
x: (
|
|
287
|
-
y: -((
|
|
395
|
+
x: (v - d.value) / a.value * 2 - 1,
|
|
396
|
+
y: -((C - c.value) / l.value) * 2 + 1
|
|
288
397
|
};
|
|
289
|
-
},
|
|
398
|
+
}, i = ({ x: v, y: C }) => {
|
|
290
399
|
if (t.value)
|
|
291
|
-
return r.value.setFromCamera(new
|
|
292
|
-
},
|
|
293
|
-
const
|
|
294
|
-
x: (
|
|
295
|
-
y: (
|
|
400
|
+
return r.value.setFromCamera(new ze(v, C), t.value), r.value.intersectObjects(e.value, !1);
|
|
401
|
+
}, m = (v) => {
|
|
402
|
+
const C = f({
|
|
403
|
+
x: (v == null ? void 0 : v.clientX) ?? o.value,
|
|
404
|
+
y: (v == null ? void 0 : v.clientY) ?? u.value
|
|
296
405
|
});
|
|
297
|
-
return
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
},
|
|
301
|
-
|
|
406
|
+
return C ? i(C) || [] : [];
|
|
407
|
+
}, h = k(() => m()), p = S(), y = S(), b = (v, C) => {
|
|
408
|
+
v.trigger({ event: C, intersects: m(C) });
|
|
409
|
+
}, w = (v) => {
|
|
410
|
+
b(y, v);
|
|
302
411
|
};
|
|
303
|
-
let
|
|
304
|
-
const
|
|
305
|
-
var
|
|
306
|
-
|
|
307
|
-
},
|
|
308
|
-
var
|
|
309
|
-
|
|
310
|
-
},
|
|
311
|
-
return n.value.addEventListener("pointerup",
|
|
312
|
-
n != null && n.value && (n.value.removeEventListener("pointerup",
|
|
412
|
+
let M;
|
|
413
|
+
const P = (v) => {
|
|
414
|
+
var C;
|
|
415
|
+
M = (C = m(v)[0]) == null ? void 0 : C.object;
|
|
416
|
+
}, E = (v) => {
|
|
417
|
+
var C;
|
|
418
|
+
v instanceof PointerEvent && M === ((C = m(v)[0]) == null ? void 0 : C.object) && b(p, v);
|
|
419
|
+
}, A = (v) => y.trigger({ event: v, intersects: [] });
|
|
420
|
+
return n.value.addEventListener("pointerup", E), n.value.addEventListener("pointerdown", P), n.value.addEventListener("pointermove", w), n.value.addEventListener("pointerleave", A), $(() => {
|
|
421
|
+
n != null && n.value && (n.value.removeEventListener("pointerup", E), n.value.removeEventListener("pointerdown", P), n.value.removeEventListener("pointermove", w), n.value.removeEventListener("pointerleave", A));
|
|
313
422
|
}), {
|
|
314
|
-
intersects:
|
|
315
|
-
onClick: (
|
|
316
|
-
onPointerMove: (
|
|
423
|
+
intersects: h,
|
|
424
|
+
onClick: (v) => p.on(v).off,
|
|
425
|
+
onPointerMove: (v) => y.on(v).off
|
|
317
426
|
};
|
|
318
427
|
};
|
|
319
|
-
function
|
|
320
|
-
const { logWarning: e } =
|
|
321
|
-
function
|
|
428
|
+
function Qt() {
|
|
429
|
+
const { logWarning: e } = j();
|
|
430
|
+
function s(o, u, a) {
|
|
322
431
|
let l = null;
|
|
323
|
-
return o.traverse((
|
|
324
|
-
|
|
325
|
-
}), l || e(`Child with ${
|
|
432
|
+
return o.traverse((c) => {
|
|
433
|
+
c[u] === a && (l = c);
|
|
434
|
+
}), l || e(`Child with ${u} '${a}' not found.`), l;
|
|
326
435
|
}
|
|
327
|
-
function t(o,
|
|
436
|
+
function t(o, u, a) {
|
|
328
437
|
const l = [];
|
|
329
|
-
return o.traverse((
|
|
330
|
-
|
|
331
|
-
}), l.length || e(`Children with ${
|
|
438
|
+
return o.traverse((c) => {
|
|
439
|
+
c[u].includes(a) && l.push(c);
|
|
440
|
+
}), l.length || e(`Children with ${u} '${a}' not found.`), l;
|
|
332
441
|
}
|
|
333
|
-
function r(o,
|
|
334
|
-
return
|
|
442
|
+
function r(o, u) {
|
|
443
|
+
return s(o, "name", u);
|
|
335
444
|
}
|
|
336
|
-
function n(o,
|
|
337
|
-
return t(o, "name",
|
|
445
|
+
function n(o, u) {
|
|
446
|
+
return t(o, "name", u);
|
|
338
447
|
}
|
|
339
448
|
return {
|
|
340
|
-
seek:
|
|
449
|
+
seek: s,
|
|
341
450
|
seekByName: r,
|
|
342
451
|
seekAll: t,
|
|
343
452
|
seekAllByName: n
|
|
344
453
|
};
|
|
345
454
|
}
|
|
346
|
-
const
|
|
347
|
-
const t =
|
|
455
|
+
const Bt = ({ scene: e, contextParts: s }) => {
|
|
456
|
+
const t = ve({
|
|
348
457
|
click: /* @__PURE__ */ new Map(),
|
|
349
458
|
pointerMove: /* @__PURE__ */ new Map(),
|
|
350
459
|
pointerEnter: /* @__PURE__ */ new Map(),
|
|
351
460
|
pointerLeave: /* @__PURE__ */ new Map()
|
|
352
|
-
}), r =
|
|
353
|
-
r.value.add(
|
|
354
|
-
}, o = (
|
|
355
|
-
r.value.delete(
|
|
356
|
-
},
|
|
357
|
-
Object.values(t).forEach((
|
|
358
|
-
},
|
|
359
|
-
const { onClick:
|
|
360
|
-
|
|
461
|
+
}), r = L(/* @__PURE__ */ new Set()), n = (i) => {
|
|
462
|
+
r.value.add(i);
|
|
463
|
+
}, o = (i) => {
|
|
464
|
+
r.value.delete(i);
|
|
465
|
+
}, u = (i) => {
|
|
466
|
+
Object.values(t).forEach((m) => m.delete(i)), o(i);
|
|
467
|
+
}, a = (i) => {
|
|
468
|
+
const { onClick: m, onPointerMove: h, onPointerEnter: p, onPointerLeave: y } = i;
|
|
469
|
+
m && t.click.set(i, m), h && t.pointerMove.set(i, h), p && t.pointerEnter.set(i, p), y && t.pointerLeave.set(i, y);
|
|
361
470
|
};
|
|
362
|
-
e.userData.tres__registerAtPointerEventHandler =
|
|
363
|
-
const l =
|
|
364
|
-
() =>
|
|
471
|
+
e.userData.tres__registerAtPointerEventHandler = a, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
|
|
472
|
+
const l = k(
|
|
473
|
+
() => Pt(
|
|
365
474
|
[
|
|
366
475
|
...Array.from(r.value),
|
|
367
|
-
...Object.values(t).map((
|
|
476
|
+
...Object.values(t).map((i) => Array.from(i.keys())).flat()
|
|
368
477
|
],
|
|
369
|
-
({ uuid:
|
|
478
|
+
({ uuid: i }) => i
|
|
370
479
|
)
|
|
371
|
-
), { onClick:
|
|
372
|
-
|
|
373
|
-
var
|
|
374
|
-
|
|
480
|
+
), { onClick: c, onPointerMove: d } = jt(l, s);
|
|
481
|
+
c(({ intersects: i, event: m }) => {
|
|
482
|
+
var h;
|
|
483
|
+
i.length && ((h = t.click.get(i[0].object)) == null || h(i[0], m));
|
|
375
484
|
});
|
|
376
485
|
let f;
|
|
377
|
-
return
|
|
378
|
-
var
|
|
379
|
-
const
|
|
380
|
-
f && f !==
|
|
486
|
+
return d(({ intersects: i, event: m }) => {
|
|
487
|
+
var w, M, P, E;
|
|
488
|
+
const h = (w = i == null ? void 0 : i[0]) == null ? void 0 : w.object, { pointerLeave: p, pointerEnter: y, pointerMove: b } = t;
|
|
489
|
+
f && f !== h && ((M = p.get(f)) == null || M(f, m)), h && (f !== h && ((P = y.get(h)) == null || P(i[0], m)), (E = b.get(h)) == null || E(i[0], m)), f = h || null;
|
|
381
490
|
}), {
|
|
382
|
-
registerObject:
|
|
383
|
-
deregisterObject:
|
|
491
|
+
registerObject: a,
|
|
492
|
+
deregisterObject: u
|
|
384
493
|
};
|
|
385
494
|
};
|
|
386
|
-
function
|
|
387
|
-
let
|
|
495
|
+
function Ot(e) {
|
|
496
|
+
let s = 0;
|
|
388
497
|
return e.traverse((t) => {
|
|
389
498
|
if (t.isMesh && t.geometry) {
|
|
390
|
-
const r = t.geometry, n = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0,
|
|
391
|
-
|
|
499
|
+
const r = t.geometry, n = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, u = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, a = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = n + o + u + a;
|
|
500
|
+
s += l;
|
|
392
501
|
}
|
|
393
|
-
}),
|
|
502
|
+
}), s;
|
|
394
503
|
}
|
|
395
|
-
const
|
|
396
|
-
function
|
|
504
|
+
const q = L({}), Y = (e) => Object.assign(q.value, e);
|
|
505
|
+
function Rt({
|
|
397
506
|
scene: e,
|
|
398
|
-
canvas:
|
|
507
|
+
canvas: s,
|
|
399
508
|
windowSize: t,
|
|
400
509
|
disableRender: r,
|
|
401
510
|
rendererOptions: n
|
|
402
511
|
}) {
|
|
403
|
-
const o =
|
|
404
|
-
() =>
|
|
405
|
-
),
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
512
|
+
const o = k(
|
|
513
|
+
() => _(t) ? qe() : Ue(_(s).parentElement)
|
|
514
|
+
), u = x({
|
|
515
|
+
width: 0,
|
|
516
|
+
height: 0
|
|
517
|
+
}), a = Ye(u, 10), l = D(() => {
|
|
518
|
+
u.value = {
|
|
519
|
+
width: o.value.width.value,
|
|
520
|
+
height: o.value.height.value
|
|
521
|
+
};
|
|
522
|
+
}), c = k(() => a.value.width / a.value.height), d = {
|
|
523
|
+
height: k(() => a.value.height),
|
|
524
|
+
width: k(() => a.value.width),
|
|
525
|
+
aspectRatio: c
|
|
526
|
+
}, f = x(e), {
|
|
527
|
+
camera: i,
|
|
528
|
+
cameras: m,
|
|
529
|
+
registerCamera: h,
|
|
530
|
+
deregisterCamera: p,
|
|
531
|
+
setCameraActive: y
|
|
532
|
+
} = yt({ sizes: d, scene: e }), { renderer: b } = Tt(
|
|
416
533
|
{
|
|
417
534
|
scene: e,
|
|
418
|
-
canvas:
|
|
535
|
+
canvas: s,
|
|
419
536
|
options: n,
|
|
420
|
-
contextParts: { sizes:
|
|
537
|
+
contextParts: { sizes: d, camera: i },
|
|
421
538
|
disableRender: r
|
|
422
539
|
}
|
|
423
|
-
),
|
|
424
|
-
sizes:
|
|
425
|
-
scene:
|
|
426
|
-
camera:
|
|
427
|
-
cameras:
|
|
428
|
-
renderer:
|
|
429
|
-
raycaster:
|
|
430
|
-
controls:
|
|
540
|
+
), w = {
|
|
541
|
+
sizes: d,
|
|
542
|
+
scene: f,
|
|
543
|
+
camera: i,
|
|
544
|
+
cameras: ge(m),
|
|
545
|
+
renderer: b,
|
|
546
|
+
raycaster: x(new Fe()),
|
|
547
|
+
controls: L(null),
|
|
431
548
|
perf: {
|
|
432
549
|
maxFrames: 160,
|
|
433
550
|
fps: {
|
|
@@ -441,130 +558,135 @@ function mt({
|
|
|
441
558
|
}
|
|
442
559
|
},
|
|
443
560
|
extend: Y,
|
|
444
|
-
registerCamera:
|
|
445
|
-
setCameraActive:
|
|
446
|
-
deregisterCamera:
|
|
561
|
+
registerCamera: h,
|
|
562
|
+
setCameraActive: y,
|
|
563
|
+
deregisterCamera: p
|
|
447
564
|
};
|
|
448
|
-
|
|
449
|
-
const
|
|
450
|
-
let
|
|
451
|
-
const
|
|
452
|
-
|
|
565
|
+
W("useTres", w);
|
|
566
|
+
const M = 100, P = Je({ every: M }), { isSupported: E, memory: A } = Ke({ interval: M }), v = 160;
|
|
567
|
+
let C = performance.now();
|
|
568
|
+
const ce = ({ timestamp: B }) => {
|
|
569
|
+
w.scene.value && (w.perf.memory.allocatedMem = Ot(w.scene.value)), B - C >= M && (C = B, w.perf.fps.accumulator.push(P.value), w.perf.fps.accumulator.length > v && w.perf.fps.accumulator.shift(), w.perf.fps.value = P.value, E.value && A.value && (w.perf.memory.accumulator.push(A.value.usedJSHeapSize / 1024 / 1024), w.perf.memory.accumulator.length > v && w.perf.memory.accumulator.shift(), w.perf.memory.currentMem = w.perf.memory.accumulator.reduce((de, me) => de + me, 0) / w.perf.memory.accumulator.length));
|
|
453
570
|
};
|
|
454
571
|
let N = 0;
|
|
455
|
-
const
|
|
456
|
-
window.__TRES__DEVTOOLS__ && (
|
|
572
|
+
const fe = 1, { pause: pe, resume: Wt } = se(({ delta: B }) => {
|
|
573
|
+
window.__TRES__DEVTOOLS__ && (ce({ timestamp: performance.now() }), N += B, N >= fe && (window.__TRES__DEVTOOLS__.cb(w), N = 0));
|
|
457
574
|
}, { immediate: !0 });
|
|
458
575
|
return $(() => {
|
|
459
|
-
|
|
460
|
-
}),
|
|
576
|
+
l(), pe();
|
|
577
|
+
}), w;
|
|
461
578
|
}
|
|
462
|
-
function
|
|
463
|
-
const e =
|
|
579
|
+
function Ht() {
|
|
580
|
+
const e = ye("useTres");
|
|
464
581
|
if (!e)
|
|
465
582
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
466
583
|
return e;
|
|
467
584
|
}
|
|
468
|
-
const
|
|
469
|
-
let
|
|
470
|
-
const { logError:
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
585
|
+
const Zt = Ht;
|
|
586
|
+
let g = null;
|
|
587
|
+
const { logError: re } = j(), V = [
|
|
588
|
+
"onClick",
|
|
589
|
+
"onPointerMove",
|
|
590
|
+
"onPointerEnter",
|
|
591
|
+
"onPointerLeave"
|
|
592
|
+
], zt = {
|
|
593
|
+
createElement(e, s, t, r) {
|
|
594
|
+
var u, a;
|
|
595
|
+
if (r || (r = {}), r.args || (r.args = []), e === "template" || _t(e))
|
|
474
596
|
return null;
|
|
475
597
|
let n = e.replace("Tres", ""), o;
|
|
476
598
|
if (e === "primitive") {
|
|
477
|
-
(r == null ? void 0 : r.object) === void 0 &&
|
|
599
|
+
(r == null ? void 0 : r.object) === void 0 && re("Tres primitives need a prop 'object'");
|
|
478
600
|
const l = r.object;
|
|
479
601
|
n = l.type, o = Object.assign(l, { type: n, attach: r.attach, primitive: !0 });
|
|
480
602
|
} else {
|
|
481
|
-
const l =
|
|
482
|
-
l ||
|
|
603
|
+
const l = q.value[n];
|
|
604
|
+
l || re(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new l(...r.args);
|
|
483
605
|
}
|
|
484
|
-
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((
|
|
606
|
+
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((u = r == null ? void 0 : r.material) != null && u.isMaterial && (o.userData.tres__materialViaProp = !0), (a = r == null ? void 0 : r.geometry) != null && a.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
|
|
485
607
|
...o.userData,
|
|
486
608
|
tres__name: n
|
|
487
609
|
}, o;
|
|
488
610
|
},
|
|
489
|
-
insert(e,
|
|
490
|
-
var r, n, o,
|
|
491
|
-
|
|
492
|
-
const t =
|
|
611
|
+
insert(e, s) {
|
|
612
|
+
var r, n, o, u;
|
|
613
|
+
s && s.isScene && (g = s);
|
|
614
|
+
const t = s || g;
|
|
493
615
|
if (e != null && e.isObject3D) {
|
|
494
616
|
if (e != null && e.isCamera) {
|
|
495
|
-
if (!(
|
|
617
|
+
if (!(g != null && g.userData.tres__registerCamera))
|
|
496
618
|
throw "could not find tres__registerCamera on scene's userData";
|
|
497
|
-
(n =
|
|
619
|
+
(n = g == null ? void 0 : (r = g.userData).tres__registerCamera) == null || n.call(r, e);
|
|
498
620
|
}
|
|
499
|
-
if (e
|
|
500
|
-
if (!(
|
|
621
|
+
if (e && V.some((a) => e[a])) {
|
|
622
|
+
if (!(g != null && g.userData.tres__registerAtPointerEventHandler))
|
|
501
623
|
throw "could not find tres__registerAtPointerEventHandler on scene's userData";
|
|
502
|
-
(
|
|
624
|
+
(u = g == null ? void 0 : (o = g.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e);
|
|
503
625
|
}
|
|
504
626
|
}
|
|
505
627
|
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));
|
|
506
628
|
},
|
|
507
629
|
remove(e) {
|
|
508
|
-
var
|
|
630
|
+
var s, t;
|
|
509
631
|
if (e) {
|
|
510
632
|
if (e.isObject3D) {
|
|
511
|
-
const r = e, n = (
|
|
512
|
-
var f,
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
}, o =
|
|
516
|
-
var
|
|
517
|
-
if (!
|
|
633
|
+
const r = e, n = (c) => {
|
|
634
|
+
var f, i;
|
|
635
|
+
const d = c;
|
|
636
|
+
c.userData.tres__materialViaProp || ((f = d.material) == null || f.dispose(), d.material = void 0), c.userData.tres__geometryViaProp || ((i = d.geometry) == null || i.dispose(), d.geometry = void 0);
|
|
637
|
+
}, o = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, u = g == null ? void 0 : g.userData.tres__deregisterBlockingObjectAtPointerEventHandler, a = (c) => {
|
|
638
|
+
var d, f;
|
|
639
|
+
if (!u)
|
|
518
640
|
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
|
|
519
|
-
if ((f =
|
|
641
|
+
if ((f = g == null ? void 0 : (d = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(d, c), !o)
|
|
520
642
|
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
|
|
521
|
-
|
|
522
|
-
}, l = (
|
|
523
|
-
const
|
|
524
|
-
if (!
|
|
643
|
+
c && V.some((i) => c[i]) && (o == null || o(c));
|
|
644
|
+
}, l = (c) => {
|
|
645
|
+
const d = g == null ? void 0 : g.userData.tres__deregisterCamera;
|
|
646
|
+
if (!d)
|
|
525
647
|
throw "could not find tres__deregisterCamera on scene's userData";
|
|
526
|
-
|
|
648
|
+
c.isCamera && (d == null || d(c));
|
|
527
649
|
};
|
|
528
|
-
(
|
|
529
|
-
n(
|
|
530
|
-
}), n(r), l(r),
|
|
650
|
+
(s = e.removeFromParent) == null || s.call(e), r.traverse((c) => {
|
|
651
|
+
n(c), l(c), a == null || a(c);
|
|
652
|
+
}), n(r), l(r), a == null || a(r);
|
|
531
653
|
}
|
|
532
654
|
(t = e.dispose) == null || t.call(e);
|
|
533
655
|
}
|
|
534
656
|
},
|
|
535
|
-
patchProp(e,
|
|
536
|
-
var n, o,
|
|
657
|
+
patchProp(e, s, t, r) {
|
|
658
|
+
var n, o, u, a;
|
|
537
659
|
if (e) {
|
|
538
|
-
let l = e,
|
|
539
|
-
if (e.isObject3D &&
|
|
540
|
-
r || r === "" ? (o =
|
|
660
|
+
let l = e, c = s;
|
|
661
|
+
if (e.isObject3D && c === "blocks-pointer-events") {
|
|
662
|
+
r || r === "" ? (o = g == null ? void 0 : (n = g.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (a = g == null ? void 0 : (u = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || a.call(u, e);
|
|
541
663
|
return;
|
|
542
664
|
}
|
|
543
|
-
let
|
|
544
|
-
if (
|
|
545
|
-
const
|
|
546
|
-
|
|
665
|
+
let d = O(c), f = l == null ? void 0 : l[d];
|
|
666
|
+
if (c === "args") {
|
|
667
|
+
const m = e, h = t ?? [], p = r ?? [], y = e.userData.tres__name || e.type;
|
|
668
|
+
y && h.length && !kt(h, p) && (l = Object.assign(m, new q.value[y](...r)));
|
|
547
669
|
return;
|
|
548
670
|
}
|
|
549
671
|
if (l.type === "BufferGeometry") {
|
|
550
|
-
if (
|
|
672
|
+
if (c === "args")
|
|
551
673
|
return;
|
|
552
674
|
l.setAttribute(
|
|
553
|
-
|
|
554
|
-
new
|
|
675
|
+
O(c),
|
|
676
|
+
new $e(...r)
|
|
555
677
|
);
|
|
556
678
|
return;
|
|
557
679
|
}
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
f =
|
|
680
|
+
if (c.includes("-") && f === void 0) {
|
|
681
|
+
const m = c.split("-");
|
|
682
|
+
f = m.reduce((h, p) => h[O(p)], l), c = m.pop(), d = c.toLowerCase(), f != null && f.set || (l = m.reduce((h, p) => h[O(p)], l));
|
|
561
683
|
}
|
|
562
|
-
let
|
|
563
|
-
if (
|
|
564
|
-
Array.isArray(
|
|
684
|
+
let i = r;
|
|
685
|
+
if (i === "" && (i = !0), te(f)) {
|
|
686
|
+
V.includes(s) || (Array.isArray(i) ? e[d](...i) : e[d](i));
|
|
565
687
|
return;
|
|
566
688
|
}
|
|
567
|
-
!(f != null && f.set) && !
|
|
689
|
+
!(f != null && f.set) && !te(f) ? l[d] = i : f.constructor === i.constructor && (f != null && f.copy) ? f == null || f.copy(i) : Array.isArray(i) ? f.set(...i) : !f.isColor && f.setScalar ? f.setScalar(i) : f.set(i);
|
|
568
690
|
}
|
|
569
691
|
},
|
|
570
692
|
parentNode(e) {
|
|
@@ -579,9 +701,9 @@ const { logError: te } = x(), dt = {
|
|
|
579
701
|
setScopeId: () => void 0,
|
|
580
702
|
cloneNode: () => void 0,
|
|
581
703
|
insertStaticContent: () => void 0
|
|
582
|
-
}, { render:
|
|
583
|
-
Y(
|
|
584
|
-
const
|
|
704
|
+
}, { render: Ft } = he(zt);
|
|
705
|
+
Y(ke);
|
|
706
|
+
const $t = ["data-scene", "data-tres"], Nt = /* @__PURE__ */ J({
|
|
585
707
|
__name: "TresCanvas",
|
|
586
708
|
props: {
|
|
587
709
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -607,107 +729,108 @@ const gt = ["data-scene"], yt = /* @__PURE__ */ q({
|
|
|
607
729
|
logarithmicDepthBuffer: { type: Boolean, default: void 0 },
|
|
608
730
|
failIfMajorPerformanceCaveat: { type: Boolean, default: void 0 }
|
|
609
731
|
},
|
|
610
|
-
setup(e, { expose:
|
|
611
|
-
var
|
|
612
|
-
const t = e, { logWarning: r } =
|
|
732
|
+
setup(e, { expose: s }) {
|
|
733
|
+
var h;
|
|
734
|
+
const t = e, { logWarning: r } = j(), n = L(), o = x(new Ne()), { resume: u } = ie(), a = we(), l = (h = K()) == null ? void 0 : h.appContext.app, c = (p) => J({
|
|
613
735
|
setup() {
|
|
614
|
-
var
|
|
615
|
-
const
|
|
616
|
-
return
|
|
736
|
+
var b;
|
|
737
|
+
const y = (b = K()) == null ? void 0 : b.appContext;
|
|
738
|
+
return y && (y.app = l), W("useTres", p), W("extend", Y), () => X(Ae, null, a != null && a.default ? a.default() : []);
|
|
617
739
|
}
|
|
618
|
-
}),
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
}, f = (
|
|
622
|
-
o.value.children = [],
|
|
623
|
-
},
|
|
624
|
-
return
|
|
625
|
-
const
|
|
626
|
-
|
|
740
|
+
}), d = (p) => {
|
|
741
|
+
const y = c(p);
|
|
742
|
+
Ft(X(y), o.value);
|
|
743
|
+
}, f = (p, y = !1) => {
|
|
744
|
+
o.value.children = [], y && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), d(p), u();
|
|
745
|
+
}, i = k(() => t.disableRender), m = x(null);
|
|
746
|
+
return s({ context: m, dispose: () => f(m.value, !0) }), Ee(() => {
|
|
747
|
+
const p = n;
|
|
748
|
+
m.value = Rt({
|
|
627
749
|
scene: o.value,
|
|
628
|
-
canvas:
|
|
750
|
+
canvas: p,
|
|
629
751
|
windowSize: t.windowSize,
|
|
630
|
-
disableRender:
|
|
752
|
+
disableRender: i,
|
|
631
753
|
rendererOptions: t
|
|
632
|
-
}),
|
|
633
|
-
const { registerCamera:
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
const
|
|
754
|
+
}), Bt({ scene: o.value, contextParts: m.value });
|
|
755
|
+
const { registerCamera: y, camera: b, cameras: w, deregisterCamera: M } = m.value;
|
|
756
|
+
d(m.value);
|
|
757
|
+
const P = () => {
|
|
758
|
+
const E = new G(
|
|
637
759
|
45,
|
|
638
760
|
window.innerWidth / window.innerHeight,
|
|
639
761
|
0.1,
|
|
640
762
|
1e3
|
|
641
763
|
);
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
|
|
764
|
+
E.position.set(3, 3, 3), E.lookAt(0, 0, 0), y(E);
|
|
765
|
+
const A = D(() => {
|
|
766
|
+
w.value.length >= 2 && (E.removeFromParent(), M(E), A == null || A());
|
|
645
767
|
});
|
|
646
768
|
};
|
|
647
|
-
|
|
769
|
+
ne(
|
|
648
770
|
() => t.camera,
|
|
649
|
-
(
|
|
650
|
-
|
|
771
|
+
(E, A) => {
|
|
772
|
+
E && y(E), A && (A.removeFromParent(), M(A));
|
|
651
773
|
},
|
|
652
774
|
{
|
|
653
775
|
immediate: !0
|
|
654
776
|
}
|
|
655
|
-
),
|
|
777
|
+
), b.value || (r(
|
|
656
778
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
657
|
-
),
|
|
658
|
-
}), (
|
|
779
|
+
), P());
|
|
780
|
+
}), (p, y) => (be(), Ce("canvas", {
|
|
659
781
|
ref_key: "canvas",
|
|
660
782
|
ref: n,
|
|
661
783
|
"data-scene": o.value.uuid,
|
|
662
|
-
class: _e(
|
|
663
|
-
|
|
784
|
+
class: _e(p.$attrs.class),
|
|
785
|
+
"data-tres": `tresjs ${Me(gt).version}`,
|
|
786
|
+
style: Pe({
|
|
664
787
|
display: "block",
|
|
665
788
|
width: "100%",
|
|
666
789
|
height: "100%",
|
|
667
|
-
position:
|
|
790
|
+
position: p.windowSize ? "fixed" : "relative",
|
|
668
791
|
top: 0,
|
|
669
792
|
left: 0,
|
|
670
793
|
pointerEvents: "auto",
|
|
671
794
|
touchAction: "none",
|
|
672
|
-
...
|
|
795
|
+
...p.$attrs.style
|
|
673
796
|
})
|
|
674
|
-
}, null, 14,
|
|
797
|
+
}, null, 14, $t));
|
|
675
798
|
}
|
|
676
|
-
}),
|
|
799
|
+
}), It = [
|
|
677
800
|
"TresCanvas",
|
|
678
801
|
"TresLeches",
|
|
679
802
|
"TresScene"
|
|
680
|
-
],
|
|
803
|
+
], Vt = {
|
|
681
804
|
template: {
|
|
682
805
|
compilerOptions: {
|
|
683
|
-
isCustomElement: (e) => e.startsWith("Tres") && !
|
|
806
|
+
isCustomElement: (e) => e.startsWith("Tres") && !It.includes(e) || e === "primitive"
|
|
684
807
|
}
|
|
685
808
|
}
|
|
686
|
-
},
|
|
809
|
+
}, er = Vt, tr = {
|
|
687
810
|
install(e) {
|
|
688
|
-
e.component("TresCanvas",
|
|
811
|
+
e.component("TresCanvas", Nt);
|
|
689
812
|
}
|
|
690
813
|
};
|
|
691
814
|
export {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
815
|
+
Nt as TresCanvas,
|
|
816
|
+
q as catalogue,
|
|
817
|
+
tr as default,
|
|
695
818
|
Y as extend,
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
819
|
+
Yt as isProd,
|
|
820
|
+
bt as normalizeColor,
|
|
821
|
+
Jt as normalizeVectorFlexibleParam,
|
|
822
|
+
er as templateCompilerOptions,
|
|
823
|
+
Lt as trasverseObjects,
|
|
824
|
+
yt as useCamera,
|
|
825
|
+
Kt as useLoader,
|
|
826
|
+
j as useLogger,
|
|
827
|
+
Bt as usePointerEventHandler,
|
|
828
|
+
jt as useRaycaster,
|
|
829
|
+
ie as useRenderLoop,
|
|
830
|
+
Tt as useRenderer,
|
|
831
|
+
Qt as useSeek,
|
|
832
|
+
Xt as useTexture,
|
|
833
|
+
Zt as useTres,
|
|
834
|
+
Ht as useTresContext,
|
|
835
|
+
Rt as useTresContextProvider
|
|
713
836
|
};
|