@tresjs/core 4.2.9 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/src/components/TresCanvas.vue.d.ts +21 -58
- package/dist/src/components/index.d.ts +0 -1
- package/dist/src/composables/index.d.ts +8 -5
- package/dist/src/composables/useCamera/index.d.ts +4377 -488
- package/dist/src/composables/useLoader/component.vue.d.ts +25 -0
- package/dist/src/composables/useLoader/index.d.ts +0 -1
- package/dist/src/composables/useLoop/index.d.ts +1 -2
- package/dist/src/composables/useRaycaster/index.d.ts +1 -2
- package/dist/src/composables/useRenderLoop/index.d.ts +0 -1
- package/dist/src/composables/useRenderer/index.d.ts +3 -5
- package/dist/src/composables/useSeek/index.d.ts +0 -1
- package/dist/src/composables/useSizes/index.d.ts +2 -3
- package/dist/src/composables/useTexture/component.vue.d.ts +28 -0
- package/dist/src/composables/useTexture/index.d.ts +0 -1
- package/dist/src/composables/useTresContextProvider/index.d.ts +4 -6
- package/dist/src/composables/useTresEventManager/index.d.ts +1 -2
- package/dist/src/composables/useTresReady/createReadyEventHook/index.d.ts +0 -1
- package/dist/src/composables/useTresReady/index.d.ts +0 -1
- package/dist/src/core/catalogue.d.ts +1 -2
- package/dist/src/core/loop.d.ts +2 -3
- package/dist/src/core/nodeOps.d.ts +1 -2
- package/dist/src/devtools/plugin.d.ts +0 -1
- package/dist/src/directives/index.d.ts +3 -4
- package/dist/src/directives/vDistanceTo.d.ts +0 -1
- package/dist/src/directives/vLightHelper.d.ts +0 -1
- package/dist/src/directives/vLog.d.ts +0 -1
- package/dist/src/index.d.ts +5 -6
- package/dist/src/types/index.d.ts +14 -9
- package/dist/src/utils/createPriorityEventHook.d.ts +0 -1
- package/dist/src/utils/index.d.ts +2 -3
- package/dist/src/utils/is.d.ts +1 -2
- package/dist/src/utils/normalize.d.ts +0 -1
- package/dist/src/utils/perf.d.ts +0 -1
- package/dist/src/utils/test-utils.d.ts +0 -1
- package/dist/tres.js +935 -900
- package/dist/tres.umd.cjs +2 -2
- package/package.json +29 -30
package/dist/tres.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v4.
|
|
3
|
+
* version: v4.3.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 {
|
|
12
|
-
import * as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
const
|
|
8
|
+
var Et = Object.defineProperty;
|
|
9
|
+
var Tt = (e, t, n) => t in e ? Et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
10
|
+
var he = (e, t, n) => Tt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
11
|
+
import { defineComponent as fe, withAsyncContext as nt, reactive as Se, renderSlot as rt, unref as W, ref as I, computed as J, watchEffect as xe, onUnmounted as K, shallowRef as $, watch as ae, readonly as we, provide as le, inject as St, isRef as xt, useSlots as At, getCurrentInstance as He, onMounted as kt, openBlock as Lt, createElementBlock as Ot, normalizeClass as Rt, normalizeStyle as Dt, createRenderer as jt, h as Ue, Fragment as Bt } from "vue";
|
|
12
|
+
import * as ot from "three";
|
|
13
|
+
import { Scene as st, Vector3 as Ae, MathUtils as it, MeshBasicMaterial as at, DoubleSide as It, TextureLoader as $t, PerspectiveCamera as be, Camera as Ht, Clock as lt, REVISION as Ut, Color as Z, SRGBColorSpace as Ft, ACESFilmicToneMapping as ct, PCFSoftShadowMap as Wt, NoToneMapping as Nt, WebGLRenderer as ge, Vector2 as ve, Raycaster as zt, BufferAttribute as Gt, Object3D as Vt, ArrowHelper as Yt, Line as qt, BufferGeometry as Fe, Float32BufferAttribute as We, LineBasicMaterial as Jt, Mesh as Kt, BackSide as Qt, DirectionalLightHelper as Xt, PointLightHelper as Zt, SpotLightHelper as en, HemisphereLightHelper as tn } from "three";
|
|
14
|
+
import { tryOnScopeDispose as nn, toValue as x, unrefElement as rn, useDevicePixelRatio as on, useWindowSize as sn, useElementSize as an, refDebounced as Ne, usePointer as ln, useElementBounding as cn, createEventHook as D, useFps as un, useMemory as fn, useRafFn as ut } from "@vueuse/core";
|
|
15
|
+
const pn = "@tresjs/core", dn = "module", mn = "4.3.0", hn = "pnpm@9.1.4", gn = "Declarative ThreeJS using Vue Components", vn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", yn = "MIT", _n = {
|
|
16
16
|
type: "git",
|
|
17
17
|
url: "git+https://github.com/Tresjs/tres.git"
|
|
18
|
-
},
|
|
18
|
+
}, wn = [
|
|
19
19
|
"vue",
|
|
20
20
|
"3d",
|
|
21
21
|
"threejs",
|
|
22
22
|
"three",
|
|
23
23
|
"threejs-vue"
|
|
24
|
-
],
|
|
24
|
+
], bn = !1, Mn = {
|
|
25
25
|
".": {
|
|
26
26
|
types: "./dist/index.d.ts",
|
|
27
27
|
import: "./dist/tres.js",
|
|
@@ -40,12 +40,12 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.9", dn = "pnpm@9.1.4", pn =
|
|
|
40
40
|
types: "./dist/src/utils/index.d.ts"
|
|
41
41
|
},
|
|
42
42
|
"./*": "./*"
|
|
43
|
-
},
|
|
43
|
+
}, Pn = "./dist/tres.js", Cn = "./dist/tres.js", En = "./dist/index.d.ts", Tn = [
|
|
44
44
|
"*.d.ts",
|
|
45
45
|
"dist"
|
|
46
|
-
],
|
|
46
|
+
], Sn = {
|
|
47
47
|
access: "public"
|
|
48
|
-
},
|
|
48
|
+
}, xn = {
|
|
49
49
|
dev: "cd playground/vue && npm run dev",
|
|
50
50
|
"dev:nuxt": "cd playground/nuxt && npm run dev",
|
|
51
51
|
build: "vite build",
|
|
@@ -60,34 +60,33 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.9", dn = "pnpm@9.1.4", pn =
|
|
|
60
60
|
"docs:build": "vitepress build docs",
|
|
61
61
|
"docs:serve": "vitepress serve docs",
|
|
62
62
|
"docs:preview": "vitepress preview docs",
|
|
63
|
-
"docs:contributors": "esno scripts/update-contributors.ts"
|
|
64
|
-
|
|
65
|
-
}, Tn = {
|
|
63
|
+
"docs:contributors": "esno scripts/update-contributors.ts"
|
|
64
|
+
}, An = {
|
|
66
65
|
three: ">=0.133",
|
|
67
66
|
vue: ">=3.4"
|
|
68
|
-
},
|
|
67
|
+
}, kn = {
|
|
69
68
|
"@alvarosabu/utils": "^3.2.0",
|
|
70
69
|
"@vue/devtools-api": "^6.6.3",
|
|
71
|
-
"@vueuse/core": "^
|
|
72
|
-
},
|
|
73
|
-
"@release-it/conventional-changelog": "^8.0.
|
|
70
|
+
"@vueuse/core": "^11.1.0"
|
|
71
|
+
}, Ln = {
|
|
72
|
+
"@release-it/conventional-changelog": "^8.0.2",
|
|
74
73
|
"@stackblitz/sdk": "^1.11.0",
|
|
75
|
-
"@tresjs/cientos": "
|
|
76
|
-
"@tresjs/eslint-config": "^1.1
|
|
77
|
-
"@types/three": "^0.
|
|
78
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
79
|
-
"@typescript-eslint/parser": "^
|
|
80
|
-
"@vitejs/plugin-vue": "^5.
|
|
74
|
+
"@tresjs/cientos": "4.0.2",
|
|
75
|
+
"@tresjs/eslint-config": "^1.3.1",
|
|
76
|
+
"@types/three": "^0.168.0",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
|
78
|
+
"@typescript-eslint/parser": "^8.6.0",
|
|
79
|
+
"@vitejs/plugin-vue": "^5.1.3",
|
|
81
80
|
"@vitest/coverage-c8": "^0.33.0",
|
|
82
|
-
"@vitest/coverage-v8": "^2.
|
|
83
|
-
"@vitest/ui": "^2.
|
|
81
|
+
"@vitest/coverage-v8": "^2.1.1",
|
|
82
|
+
"@vitest/ui": "^2.1.1",
|
|
84
83
|
"@vue/test-utils": "^2.4.6",
|
|
85
|
-
eslint: "^9.
|
|
86
|
-
"eslint-plugin-vue": "^9.
|
|
84
|
+
eslint: "^9.10.0",
|
|
85
|
+
"eslint-plugin-vue": "^9.28.0",
|
|
87
86
|
esno: "^4.7.0",
|
|
88
87
|
gsap: "^3.12.5",
|
|
89
|
-
husky: "^9.
|
|
90
|
-
jsdom: "^
|
|
88
|
+
husky: "^9.1.6",
|
|
89
|
+
jsdom: "^25.0.0",
|
|
91
90
|
kolorist: "^1.8.0",
|
|
92
91
|
ohmyfetch: "^0.4.21",
|
|
93
92
|
pathe: "^1.1.2",
|
|
@@ -95,189 +94,143 @@ const cn = "@tresjs/core", un = "module", fn = "4.2.9", dn = "pnpm@9.1.4", pn =
|
|
|
95
94
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
96
95
|
"rollup-plugin-copy": "^3.5.0",
|
|
97
96
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
98
|
-
sponsorkit: "^0.
|
|
99
|
-
three: "^0.
|
|
100
|
-
unocss: "^0.
|
|
101
|
-
unplugin: "^1.
|
|
102
|
-
"unplugin-vue-components": "^0.27.
|
|
103
|
-
vite: "^5.
|
|
104
|
-
"vite-plugin-banner": "^0.
|
|
105
|
-
"vite-plugin-dts": "
|
|
106
|
-
"vite-plugin-inspect": "^0.8.
|
|
97
|
+
sponsorkit: "^0.15.5",
|
|
98
|
+
three: "^0.168.0",
|
|
99
|
+
unocss: "^0.62.4",
|
|
100
|
+
unplugin: "^1.14.1",
|
|
101
|
+
"unplugin-vue-components": "^0.27.4",
|
|
102
|
+
vite: "^5.4.6",
|
|
103
|
+
"vite-plugin-banner": "^0.8.0",
|
|
104
|
+
"vite-plugin-dts": "4.2.1",
|
|
105
|
+
"vite-plugin-inspect": "^0.8.7",
|
|
107
106
|
"vite-plugin-require-transform": "^1.0.21",
|
|
108
107
|
"vite-svg-loader": "^5.1.0",
|
|
109
|
-
vitepress: "1.3.
|
|
110
|
-
vitest: "^2.
|
|
111
|
-
vue: "
|
|
112
|
-
"vue-demi": "^0.14.
|
|
113
|
-
},
|
|
114
|
-
name:
|
|
115
|
-
type:
|
|
116
|
-
version:
|
|
117
|
-
packageManager:
|
|
118
|
-
description:
|
|
119
|
-
author:
|
|
120
|
-
license:
|
|
121
|
-
repository:
|
|
122
|
-
keywords:
|
|
123
|
-
sideEffects:
|
|
124
|
-
exports:
|
|
125
|
-
main:
|
|
126
|
-
module:
|
|
127
|
-
types:
|
|
128
|
-
files:
|
|
129
|
-
publishConfig:
|
|
130
|
-
scripts:
|
|
131
|
-
peerDependencies:
|
|
132
|
-
dependencies:
|
|
133
|
-
devDependencies:
|
|
108
|
+
vitepress: "1.3.4",
|
|
109
|
+
vitest: "^2.1.1",
|
|
110
|
+
vue: "3.5.6",
|
|
111
|
+
"vue-demi": "^0.14.10"
|
|
112
|
+
}, On = {
|
|
113
|
+
name: pn,
|
|
114
|
+
type: dn,
|
|
115
|
+
version: mn,
|
|
116
|
+
packageManager: hn,
|
|
117
|
+
description: gn,
|
|
118
|
+
author: vn,
|
|
119
|
+
license: yn,
|
|
120
|
+
repository: _n,
|
|
121
|
+
keywords: wn,
|
|
122
|
+
sideEffects: bn,
|
|
123
|
+
exports: Mn,
|
|
124
|
+
main: Pn,
|
|
125
|
+
module: Cn,
|
|
126
|
+
types: En,
|
|
127
|
+
files: Tn,
|
|
128
|
+
publishConfig: Sn,
|
|
129
|
+
scripts: xn,
|
|
130
|
+
peerDependencies: An,
|
|
131
|
+
dependencies: kn,
|
|
132
|
+
devDependencies: Ln
|
|
134
133
|
};
|
|
135
|
-
function
|
|
134
|
+
function Rn(e) {
|
|
135
|
+
const t = { nodes: {}, materials: {} };
|
|
136
|
+
return e && e.traverse((n) => {
|
|
137
|
+
n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material);
|
|
138
|
+
}), t;
|
|
139
|
+
}
|
|
140
|
+
async function Dn(e, t, n, r, s) {
|
|
141
|
+
const { logError: l } = V(), i = new e();
|
|
142
|
+
return s && s(i), n && n(i), await new Promise((a, c) => {
|
|
143
|
+
i.load(
|
|
144
|
+
t,
|
|
145
|
+
(o) => {
|
|
146
|
+
const f = o;
|
|
147
|
+
f.scene && Object.assign(f, Rn(f.scene)), a(f);
|
|
148
|
+
},
|
|
149
|
+
r,
|
|
150
|
+
(o) => {
|
|
151
|
+
l("[useLoader] - Failed to load resource", o), c(o);
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const qr = /* @__PURE__ */ fe({
|
|
157
|
+
__name: "component",
|
|
158
|
+
props: {
|
|
159
|
+
loader: {},
|
|
160
|
+
url: {}
|
|
161
|
+
},
|
|
162
|
+
async setup(e) {
|
|
163
|
+
let t, n;
|
|
164
|
+
const r = e, s = ([t, n] = nt(() => Se(Dn(r.loader, r.url))), t = await t, n(), t);
|
|
165
|
+
return (l, i) => rt(l.$slots, "default", { data: W(s) });
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
class jn extends ot.Mesh {
|
|
169
|
+
constructor(...n) {
|
|
170
|
+
super(...n);
|
|
171
|
+
he(this, "type", "HightlightMesh");
|
|
172
|
+
he(this, "createTime");
|
|
173
|
+
this.createTime = Date.now();
|
|
174
|
+
}
|
|
175
|
+
onBeforeRender() {
|
|
176
|
+
const r = (Date.now() - this.createTime) / 1e3, i = 1 + 0.07 * Math.sin(2.5 * r);
|
|
177
|
+
this.scale.set(i, i, i);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function Me(e) {
|
|
136
181
|
return typeof e > "u";
|
|
137
182
|
}
|
|
138
|
-
function
|
|
183
|
+
function pe(e) {
|
|
139
184
|
return Array.isArray(e);
|
|
140
185
|
}
|
|
141
|
-
function
|
|
186
|
+
function Bn(e) {
|
|
142
187
|
return typeof e == "number";
|
|
143
188
|
}
|
|
144
|
-
function
|
|
189
|
+
function ft(e) {
|
|
145
190
|
return typeof e == "string";
|
|
146
191
|
}
|
|
147
192
|
function G(e) {
|
|
148
193
|
return typeof e == "function";
|
|
149
194
|
}
|
|
150
|
-
function
|
|
151
|
-
return e === Object(e) && !
|
|
195
|
+
function H(e) {
|
|
196
|
+
return e === Object(e) && !pe(e) && !G(e);
|
|
152
197
|
}
|
|
153
198
|
function N(e) {
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
function We(e) {
|
|
157
|
-
return U(e) && "isCamera" in e && !!e.isCamera;
|
|
158
|
-
}
|
|
159
|
-
function Ln(e) {
|
|
160
|
-
return U(e) && "isBufferGeometry" in e && !!e.isBufferGeometry;
|
|
161
|
-
}
|
|
162
|
-
function Rn(e) {
|
|
163
|
-
return U(e) && "isMaterial" in e && !!e.isMaterial;
|
|
164
|
-
}
|
|
165
|
-
function On(e) {
|
|
166
|
-
return U(e) && "isLight" in e && !!e.isLight;
|
|
167
|
-
}
|
|
168
|
-
function Dn(e) {
|
|
169
|
-
return U(e) && "isFog" in e && !!e.isFog;
|
|
199
|
+
return H(e) && "isObject3D" in e && !!e.isObject3D;
|
|
170
200
|
}
|
|
171
|
-
function
|
|
172
|
-
return
|
|
201
|
+
function ze(e) {
|
|
202
|
+
return H(e) && "isCamera" in e && !!e.isCamera;
|
|
173
203
|
}
|
|
174
|
-
function
|
|
175
|
-
return
|
|
204
|
+
function In(e) {
|
|
205
|
+
return H(e) && "isBufferGeometry" in e && !!e.isBufferGeometry;
|
|
176
206
|
}
|
|
177
|
-
function
|
|
178
|
-
return
|
|
207
|
+
function $n(e) {
|
|
208
|
+
return H(e) && "isMaterial" in e && !!e.isMaterial;
|
|
179
209
|
}
|
|
180
|
-
const In = ({ sizes: e }) => {
|
|
181
|
-
const t = H([]), n = V(
|
|
182
|
-
() => t.value[0]
|
|
183
|
-
), r = (i) => {
|
|
184
|
-
const a = i instanceof Dt ? i : t.value.find((o) => o.uuid === i);
|
|
185
|
-
if (!a)
|
|
186
|
-
return;
|
|
187
|
-
const c = t.value.filter(({ uuid: o }) => o !== a.uuid);
|
|
188
|
-
t.value = [a, ...c];
|
|
189
|
-
}, s = (i, a = !1) => {
|
|
190
|
-
if (We(i)) {
|
|
191
|
-
const c = i;
|
|
192
|
-
if (t.value.some(({ uuid: o }) => o === c.uuid))
|
|
193
|
-
return;
|
|
194
|
-
a ? r(c) : t.value.push(c);
|
|
195
|
-
}
|
|
196
|
-
}, l = (i) => {
|
|
197
|
-
if (We(i)) {
|
|
198
|
-
const a = i;
|
|
199
|
-
t.value = t.value.filter(({ uuid: c }) => c !== a.uuid);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
return Te(() => {
|
|
203
|
-
e.aspectRatio.value && t.value.forEach((i) => {
|
|
204
|
-
!i.manual && (i instanceof we || Hn(i)) && (i instanceof we ? i.aspect = e.aspectRatio.value : (i.left = e.width.value * -0.5, i.right = e.width.value * 0.5, i.top = e.height.value * 0.5, i.bottom = e.height.value * -0.5), i.updateProjectionMatrix());
|
|
205
|
-
});
|
|
206
|
-
}), K(() => {
|
|
207
|
-
t.value = [];
|
|
208
|
-
}), {
|
|
209
|
-
camera: n,
|
|
210
|
-
cameras: t,
|
|
211
|
-
registerCamera: s,
|
|
212
|
-
deregisterCamera: l,
|
|
213
|
-
setCameraActive: r
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
210
|
function Hn(e) {
|
|
217
|
-
return e
|
|
211
|
+
return H(e) && "isLight" in e && !!e.isLight;
|
|
218
212
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const { pause: $n, resume: Ne, isActive: Un } = it(
|
|
222
|
-
() => {
|
|
223
|
-
lt.trigger({ delta: ue, elapsed: fe, clock: ee }), ct.trigger({ delta: ue, elapsed: fe, clock: ee }), Ae.trigger({ delta: ue, elapsed: fe, clock: ee });
|
|
224
|
-
},
|
|
225
|
-
{ immediate: !1 }
|
|
226
|
-
);
|
|
227
|
-
Ae.on(() => {
|
|
228
|
-
ue = ee.getDelta(), fe = ee.getElapsedTime();
|
|
229
|
-
});
|
|
230
|
-
let ze = !1;
|
|
231
|
-
const Ur = () => (ze || (ze = !0, Ne()), {
|
|
232
|
-
onBeforeLoop: lt.on,
|
|
233
|
-
onLoop: ct.on,
|
|
234
|
-
onAfterLoop: Ae.on,
|
|
235
|
-
pause: $n,
|
|
236
|
-
resume: Ne,
|
|
237
|
-
isActive: Un
|
|
238
|
-
}), Fr = !0, se = "[TresJS ▲ ■ ●] ";
|
|
239
|
-
function Y() {
|
|
240
|
-
function e(...r) {
|
|
241
|
-
typeof r[0] == "string" ? r[0] = se + r[0] : r.unshift(se), console.error(...r);
|
|
242
|
-
}
|
|
243
|
-
function t(...r) {
|
|
244
|
-
typeof r[0] == "string" ? r[0] = se + r[0] : r.unshift(se), console.warn(...r);
|
|
245
|
-
}
|
|
246
|
-
function n(r, s) {
|
|
247
|
-
}
|
|
248
|
-
return {
|
|
249
|
-
logError: e,
|
|
250
|
-
logWarning: t,
|
|
251
|
-
logMessage: n
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
function Wr(e) {
|
|
255
|
-
return typeof e == "number" ? [e, e, e] : e instanceof Se ? [e.x, e.y, e.z] : e;
|
|
213
|
+
function Un(e) {
|
|
214
|
+
return H(e) && "isFog" in e && !!e.isFog;
|
|
256
215
|
}
|
|
257
216
|
function Fn(e) {
|
|
258
|
-
return
|
|
217
|
+
return H(e) && "isScene" in e && !!e.isScene;
|
|
259
218
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.createTime = Date.now();
|
|
266
|
-
}
|
|
267
|
-
onBeforeRender() {
|
|
268
|
-
const r = (Date.now() - this.createTime) / 1e3, i = 1 + 0.07 * Math.sin(2.5 * r);
|
|
269
|
-
this.scale.set(i, i, i);
|
|
270
|
-
}
|
|
219
|
+
function re(e) {
|
|
220
|
+
return N(e) || In(e) || $n(e) || Un(e);
|
|
221
|
+
}
|
|
222
|
+
function Wn(e) {
|
|
223
|
+
return H(e) && !!e.isPrimitive;
|
|
271
224
|
}
|
|
272
|
-
const
|
|
225
|
+
const pt = (e, t) => {
|
|
273
226
|
for (const n of Object.keys(t))
|
|
274
|
-
t[n] instanceof Object && Object.assign(t[n],
|
|
227
|
+
t[n] instanceof Object && Object.assign(t[n], pt(e[n], t[n]));
|
|
275
228
|
return Object.assign(e || {}, t), e;
|
|
276
229
|
}, Nn = "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", zn = /* @__PURE__ */ Yn(Nn);
|
|
277
230
|
function Ge(e) {
|
|
278
231
|
return e && e.nodeType === 1;
|
|
279
232
|
}
|
|
280
|
-
function
|
|
233
|
+
function oe(e) {
|
|
281
234
|
return e.replace(/-([a-z])/g, (t, n) => n.toUpperCase());
|
|
282
235
|
}
|
|
283
236
|
const Gn = /\B([A-Z])/g;
|
|
@@ -299,7 +252,7 @@ const Ve = (e, t) => {
|
|
|
299
252
|
const r = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
|
|
300
253
|
r && r.reduce((s, l, i) => (s[l] === void 0 && (s[l] = {}), i === r.length - 1 && (s[l] = n), s[l]), e);
|
|
301
254
|
};
|
|
302
|
-
function
|
|
255
|
+
function dt(e, t) {
|
|
303
256
|
if (Ge(e) && Ge(t)) {
|
|
304
257
|
const s = e.attributes, l = t.attributes;
|
|
305
258
|
return s.length !== l.length ? !1 : Array.from(s).every(({ name: i, value: a }) => t.getAttribute(i) === a);
|
|
@@ -312,7 +265,7 @@ function ft(e, t) {
|
|
|
312
265
|
if (n.length !== r.length)
|
|
313
266
|
return !1;
|
|
314
267
|
for (const s of n)
|
|
315
|
-
if (!r.includes(s) || !
|
|
268
|
+
if (!r.includes(s) || !dt(e[s], t[s]))
|
|
316
269
|
return !1;
|
|
317
270
|
return !0;
|
|
318
271
|
}
|
|
@@ -320,7 +273,7 @@ function Jn(e, t) {
|
|
|
320
273
|
if (!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length)
|
|
321
274
|
return !1;
|
|
322
275
|
for (let n = 0; n < e.length; n++)
|
|
323
|
-
if (!
|
|
276
|
+
if (!dt(e[n], t[n]))
|
|
324
277
|
return !1;
|
|
325
278
|
return !0;
|
|
326
279
|
}
|
|
@@ -330,9 +283,9 @@ function Qn(e, t, n, r) {
|
|
|
330
283
|
if (c.uuid === t)
|
|
331
284
|
return c;
|
|
332
285
|
for (const o of c.children) {
|
|
333
|
-
const
|
|
334
|
-
if (
|
|
335
|
-
return
|
|
286
|
+
const f = s(o);
|
|
287
|
+
if (f)
|
|
288
|
+
return f;
|
|
336
289
|
}
|
|
337
290
|
}, l = s(e);
|
|
338
291
|
if (!l) {
|
|
@@ -351,22 +304,22 @@ function Qn(e, t, n, r) {
|
|
|
351
304
|
i[a] !== void 0 ? i[a] = r : console.warn(`Property path is not valid: ${n.join(".")}`);
|
|
352
305
|
}
|
|
353
306
|
function Xn(e) {
|
|
354
|
-
const t = new
|
|
307
|
+
const t = new at({
|
|
355
308
|
color: 11003607,
|
|
356
309
|
// Highlight color, e.g., yellow
|
|
357
310
|
transparent: !0,
|
|
358
311
|
opacity: 0.2,
|
|
359
312
|
depthTest: !1,
|
|
360
313
|
// So the highlight is always visible
|
|
361
|
-
side:
|
|
314
|
+
side: It
|
|
362
315
|
// To e
|
|
363
316
|
});
|
|
364
|
-
return new
|
|
317
|
+
return new jn(e.geometry.clone(), t);
|
|
365
318
|
}
|
|
366
319
|
function Zn(e) {
|
|
367
320
|
var n;
|
|
368
321
|
let t = e.value;
|
|
369
|
-
return e.value && ((n = e.value) != null && n.isMesh) && (t = e.value.position), Array.isArray(e.value) && (t = new
|
|
322
|
+
return e.value && ((n = e.value) != null && n.isMesh) && (t = e.value.position), Array.isArray(e.value) && (t = new Ae(...t)), t;
|
|
370
323
|
}
|
|
371
324
|
function er(e) {
|
|
372
325
|
return "map" in e;
|
|
@@ -374,9 +327,9 @@ function er(e) {
|
|
|
374
327
|
function Ye(e) {
|
|
375
328
|
er(e) && e.map && e.map.dispose(), e.dispose();
|
|
376
329
|
}
|
|
377
|
-
function
|
|
330
|
+
function mt(e) {
|
|
378
331
|
var n, r;
|
|
379
|
-
if (e.parent && ((n = e.removeFromParent) == null || n.call(e)), delete e.__tres, [...e.children].forEach((s) =>
|
|
332
|
+
if (e.parent && ((n = e.removeFromParent) == null || n.call(e)), delete e.__tres, [...e.children].forEach((s) => mt(s)), !(e instanceof st)) {
|
|
380
333
|
const s = e;
|
|
381
334
|
e && ((r = e.dispose) == null || r.call(e)), s.geometry && (s.geometry.dispose(), delete s.geometry), Array.isArray(s.material) ? (s.material.forEach((l) => Ye(l)), delete s.material) : s.material && (Ye(s.material), delete s.material);
|
|
382
335
|
}
|
|
@@ -387,7 +340,7 @@ function tr(e, t) {
|
|
|
387
340
|
t(e[r], r) && (e[n] = e[r], n++);
|
|
388
341
|
return e.length = n, e;
|
|
389
342
|
}
|
|
390
|
-
function
|
|
343
|
+
function Pe(e, t) {
|
|
391
344
|
let n = e;
|
|
392
345
|
if (t.includes("-")) {
|
|
393
346
|
const r = t.split("-");
|
|
@@ -403,25 +356,25 @@ function qe(...e) {
|
|
|
403
356
|
}
|
|
404
357
|
const Je = /-\d+$/;
|
|
405
358
|
function nr(e, t, n) {
|
|
406
|
-
if (
|
|
359
|
+
if (ft(n)) {
|
|
407
360
|
if (Je.test(n)) {
|
|
408
|
-
const l = n.replace(Je, ""), { target: i, key: a } =
|
|
361
|
+
const l = n.replace(Je, ""), { target: i, key: a } = Pe(e, l);
|
|
409
362
|
if (!Array.isArray(i[a])) {
|
|
410
363
|
const c = i[a], o = [];
|
|
411
364
|
o.__tresDetach = () => {
|
|
412
|
-
o.every((
|
|
365
|
+
o.every((f) => Me(f)) && (i[a] = c);
|
|
413
366
|
}, i[a] = o;
|
|
414
367
|
}
|
|
415
368
|
}
|
|
416
|
-
const { target: r, key: s } =
|
|
369
|
+
const { target: r, key: s } = Pe(e, n);
|
|
417
370
|
t.__tres.previousAttach = r[s], r[s] = Q(t);
|
|
418
371
|
} else
|
|
419
372
|
t.__tres.previousAttach = n(e, t);
|
|
420
373
|
}
|
|
421
374
|
function rr(e, t, n) {
|
|
422
375
|
var r, s, l;
|
|
423
|
-
if (
|
|
424
|
-
const { target: i, key: a } =
|
|
376
|
+
if (ft(n)) {
|
|
377
|
+
const { target: i, key: a } = Pe(e, n), c = t.__tres.previousAttach;
|
|
425
378
|
c === void 0 ? delete i[a] : i[a] = c, "__tresDetach" in i && i.__tresDetach();
|
|
426
379
|
} else
|
|
427
380
|
(s = (r = t.__tres) == null ? void 0 : r.previousAttach) == null || s.call(r, e, t);
|
|
@@ -441,7 +394,7 @@ function z(e, t, n) {
|
|
|
441
394
|
...t
|
|
442
395
|
}, r.__tres.attach || (r.isMaterial ? r.__tres.attach = "material" : r.isBufferGeometry ? r.__tres.attach = "geometry" : r.isFog && (r.__tres.attach = "fog")), r;
|
|
443
396
|
}
|
|
444
|
-
function
|
|
397
|
+
function ht(e) {
|
|
445
398
|
var n;
|
|
446
399
|
const t = (n = e == null ? void 0 : e.__tres) == null ? void 0 : n.root;
|
|
447
400
|
t && t.render && t.render.canBeInvalidated.value && t.invalidate();
|
|
@@ -451,10 +404,10 @@ function or(e, t, n) {
|
|
|
451
404
|
if (!G(e.setPixelRatio))
|
|
452
405
|
return;
|
|
453
406
|
let r = 0;
|
|
454
|
-
if (
|
|
407
|
+
if (pe(n) && n.length >= 2) {
|
|
455
408
|
const [l, i] = n;
|
|
456
|
-
r =
|
|
457
|
-
} else
|
|
409
|
+
r = it.clamp(t, l, i);
|
|
410
|
+
} else Bn(n) ? r = n : r = t;
|
|
458
411
|
r !== ((s = e.getPixelRatio) == null ? void 0 : s.call(e)) && e.setPixelRatio(r);
|
|
459
412
|
}
|
|
460
413
|
function sr(e, t, n, r, s) {
|
|
@@ -463,79 +416,309 @@ function sr(e, t, n, r, s) {
|
|
|
463
416
|
return !0;
|
|
464
417
|
const a = z(e, t.__tres ?? {}, s), c = t.parent ?? t.__tres.parent ?? null, o = { ...t.__tres.memoizedProps };
|
|
465
418
|
delete o.object;
|
|
466
|
-
for (const
|
|
467
|
-
|
|
419
|
+
for (const f of l)
|
|
420
|
+
gt(f, s), vt(f, s);
|
|
468
421
|
i.__tres.objects = [], r.remove(t);
|
|
469
|
-
for (const [
|
|
470
|
-
r.patchProp(a,
|
|
422
|
+
for (const [f, y] of Object.entries(o))
|
|
423
|
+
r.patchProp(a, f, a[f], y);
|
|
471
424
|
n(e), r.insert(t, c);
|
|
472
|
-
for (const
|
|
473
|
-
r.insert(
|
|
425
|
+
for (const f of l)
|
|
426
|
+
r.insert(f, t);
|
|
474
427
|
return !0;
|
|
475
428
|
}
|
|
476
429
|
function Q(e) {
|
|
477
|
-
return
|
|
430
|
+
return Wn(e) ? (e.object.__tres = e.__tres, e.object) : e;
|
|
478
431
|
}
|
|
479
|
-
function
|
|
432
|
+
function gt(e, t) {
|
|
480
433
|
var r, s, l, i;
|
|
481
434
|
const n = ((r = e.__tres) == null ? void 0 : r.parent) || t.scene.value;
|
|
482
435
|
e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && tr(n.__tres.objects, (a) => a !== e), (s = e.__tres) != null && s.attach ? rr(n, e, e.__tres.attach) : ((i = (l = e.parent) == null ? void 0 : l.remove) == null || i.call(l, Q(e)), e.parent = null);
|
|
483
436
|
}
|
|
484
|
-
function
|
|
437
|
+
function vt(e, t) {
|
|
485
438
|
var n;
|
|
486
439
|
(n = e.traverse) == null || n.call(e, (r) => {
|
|
487
440
|
var s;
|
|
488
441
|
t.deregisterCamera(r), (s = t.eventManager) == null || s.deregisterPointerMissedObject(r);
|
|
489
|
-
}), t.deregisterCamera(e),
|
|
442
|
+
}), t.deregisterCamera(e), ht(e);
|
|
490
443
|
}
|
|
491
|
-
|
|
444
|
+
async function ir(e, t) {
|
|
445
|
+
const n = new $t(t), r = (s) => new Promise((l, i) => {
|
|
446
|
+
n.load(
|
|
447
|
+
s,
|
|
448
|
+
(a) => l(a),
|
|
449
|
+
() => null,
|
|
450
|
+
() => {
|
|
451
|
+
i(new Error("[useTextures] - Failed to load texture"));
|
|
452
|
+
}
|
|
453
|
+
);
|
|
454
|
+
});
|
|
455
|
+
if (Kn(e)) {
|
|
456
|
+
const s = await Promise.all(e.map((l) => r(l)));
|
|
457
|
+
return e.length > 1 ? s : s[0];
|
|
458
|
+
} else {
|
|
459
|
+
const {
|
|
460
|
+
map: s,
|
|
461
|
+
displacementMap: l,
|
|
462
|
+
normalMap: i,
|
|
463
|
+
roughnessMap: a,
|
|
464
|
+
metalnessMap: c,
|
|
465
|
+
aoMap: o,
|
|
466
|
+
alphaMap: f,
|
|
467
|
+
matcap: y
|
|
468
|
+
} = e;
|
|
469
|
+
return {
|
|
470
|
+
map: s ? await r(s) : null,
|
|
471
|
+
displacementMap: l ? await r(l) : null,
|
|
472
|
+
normalMap: i ? await r(i) : null,
|
|
473
|
+
roughnessMap: a ? await r(a) : null,
|
|
474
|
+
metalnessMap: c ? await r(c) : null,
|
|
475
|
+
aoMap: o ? await r(o) : null,
|
|
476
|
+
alphaMap: f ? await r(f) : null,
|
|
477
|
+
matcap: y ? await r(y) : null
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const Jr = /* @__PURE__ */ fe({
|
|
482
|
+
__name: "component",
|
|
483
|
+
props: {
|
|
484
|
+
map: {},
|
|
485
|
+
displacementMap: {},
|
|
486
|
+
normalMap: {},
|
|
487
|
+
roughnessMap: {},
|
|
488
|
+
metalnessMap: {},
|
|
489
|
+
aoMap: {},
|
|
490
|
+
alphaMap: {},
|
|
491
|
+
matcap: {}
|
|
492
|
+
},
|
|
493
|
+
async setup(e) {
|
|
494
|
+
let t, n;
|
|
495
|
+
const r = e, s = ([t, n] = nt(() => Se(ir(r))), t = await t, n(), t);
|
|
496
|
+
return (l, i) => rt(l.$slots, "default", { textures: W(s) });
|
|
497
|
+
}
|
|
498
|
+
}), ar = ({ sizes: e }) => {
|
|
499
|
+
const t = I([]), n = J(
|
|
500
|
+
() => t.value[0]
|
|
501
|
+
), r = (i) => {
|
|
502
|
+
const a = i instanceof Ht ? i : t.value.find((o) => o.uuid === i);
|
|
503
|
+
if (!a)
|
|
504
|
+
return;
|
|
505
|
+
const c = t.value.filter(({ uuid: o }) => o !== a.uuid);
|
|
506
|
+
t.value = [a, ...c];
|
|
507
|
+
}, s = (i, a = !1) => {
|
|
508
|
+
if (ze(i)) {
|
|
509
|
+
const c = i;
|
|
510
|
+
if (t.value.some(({ uuid: o }) => o === c.uuid))
|
|
511
|
+
return;
|
|
512
|
+
a ? r(c) : t.value.push(c);
|
|
513
|
+
}
|
|
514
|
+
}, l = (i) => {
|
|
515
|
+
if (ze(i)) {
|
|
516
|
+
const a = i;
|
|
517
|
+
t.value = t.value.filter(({ uuid: c }) => c !== a.uuid);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
return xe(() => {
|
|
521
|
+
e.aspectRatio.value && t.value.forEach((i) => {
|
|
522
|
+
!i.manual && (i instanceof be || lr(i)) && (i instanceof be ? i.aspect = e.aspectRatio.value : (i.left = e.width.value * -0.5, i.right = e.width.value * 0.5, i.top = e.height.value * 0.5, i.bottom = e.height.value * -0.5), i.updateProjectionMatrix());
|
|
523
|
+
});
|
|
524
|
+
}), K(() => {
|
|
525
|
+
t.value = [];
|
|
526
|
+
}), {
|
|
527
|
+
camera: n,
|
|
528
|
+
cameras: t,
|
|
529
|
+
registerCamera: s,
|
|
530
|
+
deregisterCamera: l,
|
|
531
|
+
setCameraActive: r
|
|
532
|
+
};
|
|
533
|
+
};
|
|
534
|
+
function lr(e) {
|
|
535
|
+
return e.hasOwnProperty("isOrthographicCamera") && e.isOrthographicCamera;
|
|
536
|
+
}
|
|
537
|
+
const Kr = !0, de = "[TresJS ▲ ■ ●] ";
|
|
538
|
+
function cr(...e) {
|
|
539
|
+
typeof e[0] == "string" ? e[0] = de + e[0] : e.unshift(de), console.error(...e);
|
|
540
|
+
}
|
|
541
|
+
function ur(...e) {
|
|
542
|
+
typeof e[0] == "string" ? e[0] = de + e[0] : e.unshift(de), console.warn(...e);
|
|
543
|
+
}
|
|
544
|
+
function fr(e, t) {
|
|
545
|
+
}
|
|
546
|
+
function V() {
|
|
547
|
+
return {
|
|
548
|
+
logError: cr,
|
|
549
|
+
logWarning: ur,
|
|
550
|
+
logMessage: fr
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
const Ce = I({}), Ee = (e) => Object.assign(Ce.value, e);
|
|
554
|
+
function ye() {
|
|
555
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
556
|
+
let n = 0, r = !1;
|
|
557
|
+
const s = () => {
|
|
558
|
+
const o = Array.from(e.entries()).sort((f, y) => {
|
|
559
|
+
const u = f[1].priority - y[1].priority;
|
|
560
|
+
return u === 0 ? f[1].addI - y[1].addI : u;
|
|
561
|
+
});
|
|
562
|
+
t.clear(), o.forEach((f) => t.add(f[0]));
|
|
563
|
+
}, l = (o) => {
|
|
564
|
+
e.delete(o), t.delete(o);
|
|
565
|
+
};
|
|
566
|
+
return { on: (o, f = 0) => {
|
|
567
|
+
e.set(o, { priority: f, addI: n++ });
|
|
568
|
+
const y = () => l(o);
|
|
569
|
+
return nn(y), r = !0, {
|
|
570
|
+
off: y
|
|
571
|
+
};
|
|
572
|
+
}, off: l, trigger: (...o) => {
|
|
573
|
+
r && (s(), r = !1), t.forEach((f) => f(...o));
|
|
574
|
+
}, dispose: () => {
|
|
575
|
+
e.clear(), t.clear();
|
|
576
|
+
}, get count() {
|
|
577
|
+
return e.size;
|
|
578
|
+
} };
|
|
579
|
+
}
|
|
580
|
+
function pr() {
|
|
581
|
+
let e = !0, t = !0, n = !1;
|
|
582
|
+
const r = new lt(!1), s = I(r.running), l = I(!1);
|
|
583
|
+
let i;
|
|
584
|
+
const a = it.generateUUID();
|
|
585
|
+
let c = null;
|
|
586
|
+
const o = ye(), f = ye(), y = ye();
|
|
587
|
+
P();
|
|
588
|
+
let u = {};
|
|
589
|
+
function v(M) {
|
|
590
|
+
u = M;
|
|
591
|
+
}
|
|
592
|
+
function h(M, A, d = 0) {
|
|
593
|
+
switch (A) {
|
|
594
|
+
case "before":
|
|
595
|
+
return o.on(M, d);
|
|
596
|
+
case "render":
|
|
597
|
+
return c || (c = M), f.dispose(), f.on(M);
|
|
598
|
+
case "after":
|
|
599
|
+
return y.on(M, d);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function g() {
|
|
603
|
+
t && (t = !1, P(), b());
|
|
604
|
+
}
|
|
605
|
+
function p() {
|
|
606
|
+
t = !0, P(), cancelAnimationFrame(i);
|
|
607
|
+
}
|
|
608
|
+
function _() {
|
|
609
|
+
n = !1, P();
|
|
610
|
+
}
|
|
611
|
+
function C() {
|
|
612
|
+
n = !0, P();
|
|
613
|
+
}
|
|
614
|
+
function E() {
|
|
615
|
+
l.value = !0;
|
|
616
|
+
}
|
|
617
|
+
function T() {
|
|
618
|
+
l.value = !1;
|
|
619
|
+
}
|
|
620
|
+
function b() {
|
|
621
|
+
if (!e) {
|
|
622
|
+
i = requestAnimationFrame(b);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const M = r.getDelta(), A = r.getElapsedTime(), d = {
|
|
626
|
+
camera: W(u.camera),
|
|
627
|
+
scene: W(u.scene),
|
|
628
|
+
renderer: W(u.renderer),
|
|
629
|
+
raycaster: W(u.raycaster),
|
|
630
|
+
controls: W(u.controls),
|
|
631
|
+
invalidate: u.invalidate,
|
|
632
|
+
advance: u.advance
|
|
633
|
+
}, w = { delta: M, elapsed: A, clock: r, ...d };
|
|
634
|
+
s.value && o.trigger(w), l.value || (f.count ? f.trigger(w) : c && c(w)), s.value && y.trigger(w), i = requestAnimationFrame(b);
|
|
635
|
+
}
|
|
636
|
+
function P() {
|
|
637
|
+
const M = !t && !n;
|
|
638
|
+
r.running !== M && (r.running ? r.stop() : r.start()), s.value = r.running;
|
|
639
|
+
}
|
|
640
|
+
return {
|
|
641
|
+
loopId: a,
|
|
642
|
+
register: (M, A, d) => h(M, A, d),
|
|
643
|
+
start: g,
|
|
644
|
+
stop: p,
|
|
645
|
+
pause: C,
|
|
646
|
+
resume: _,
|
|
647
|
+
pauseRender: E,
|
|
648
|
+
resumeRender: T,
|
|
649
|
+
isRenderPaused: l,
|
|
650
|
+
isActive: s,
|
|
651
|
+
setContext: v,
|
|
652
|
+
setReady: (M) => e = M
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function ke(e) {
|
|
656
|
+
let t = 0;
|
|
657
|
+
return e.traverse((n) => {
|
|
658
|
+
if (n.isMesh && n.geometry && n.type !== "HightlightMesh") {
|
|
659
|
+
const r = n.geometry, s = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, l = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, i = 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, c = s + l + i + a;
|
|
660
|
+
t += c;
|
|
661
|
+
}
|
|
662
|
+
}), t;
|
|
663
|
+
}
|
|
664
|
+
function dr(e) {
|
|
665
|
+
return (e / 1024).toFixed(2);
|
|
666
|
+
}
|
|
667
|
+
const mr = Number.parseInt(Ut.replace("dev", ""));
|
|
668
|
+
function Qr(e) {
|
|
669
|
+
return typeof e == "number" ? [e, e, e] : e instanceof Ae ? [e.x, e.y, e.z] : e;
|
|
670
|
+
}
|
|
671
|
+
function hr(e) {
|
|
672
|
+
return e instanceof Z ? e : Array.isArray(e) ? new Z(...e) : new Z(e);
|
|
673
|
+
}
|
|
674
|
+
const se = {
|
|
492
675
|
realistic: {
|
|
493
676
|
shadows: !0,
|
|
494
677
|
physicallyCorrectLights: !0,
|
|
495
|
-
outputColorSpace:
|
|
496
|
-
toneMapping:
|
|
678
|
+
outputColorSpace: Ft,
|
|
679
|
+
toneMapping: ct,
|
|
497
680
|
toneMappingExposure: 3,
|
|
498
681
|
shadowMap: {
|
|
499
682
|
enabled: !0,
|
|
500
|
-
type:
|
|
683
|
+
type: Wt
|
|
501
684
|
}
|
|
502
685
|
},
|
|
503
686
|
flat: {
|
|
504
|
-
toneMapping:
|
|
687
|
+
toneMapping: Nt,
|
|
505
688
|
toneMappingExposure: 1
|
|
506
689
|
}
|
|
507
690
|
};
|
|
508
|
-
function
|
|
691
|
+
function gr({
|
|
509
692
|
canvas: e,
|
|
510
693
|
options: t,
|
|
511
694
|
contextParts: { sizes: n, render: r, invalidate: s, advance: l }
|
|
512
695
|
}) {
|
|
513
|
-
const i =
|
|
514
|
-
alpha:
|
|
515
|
-
depth:
|
|
516
|
-
canvas:
|
|
517
|
-
context:
|
|
518
|
-
stencil:
|
|
519
|
-
antialias:
|
|
520
|
-
precision:
|
|
521
|
-
powerPreference:
|
|
522
|
-
premultipliedAlpha:
|
|
523
|
-
preserveDrawingBuffer:
|
|
524
|
-
logarithmicDepthBuffer:
|
|
525
|
-
failIfMajorPerformanceCaveat:
|
|
526
|
-
})), a = $(new
|
|
696
|
+
const i = J(() => ({
|
|
697
|
+
alpha: x(t.alpha) ?? !0,
|
|
698
|
+
depth: x(t.depth),
|
|
699
|
+
canvas: rn(e),
|
|
700
|
+
context: x(t.context),
|
|
701
|
+
stencil: x(t.stencil),
|
|
702
|
+
antialias: x(t.antialias) ?? !0,
|
|
703
|
+
precision: x(t.precision),
|
|
704
|
+
powerPreference: x(t.powerPreference),
|
|
705
|
+
premultipliedAlpha: x(t.premultipliedAlpha),
|
|
706
|
+
preserveDrawingBuffer: x(t.preserveDrawingBuffer),
|
|
707
|
+
logarithmicDepthBuffer: x(t.logarithmicDepthBuffer),
|
|
708
|
+
failIfMajorPerformanceCaveat: x(t.failIfMajorPerformanceCaveat)
|
|
709
|
+
})), a = $(new ge(i.value));
|
|
527
710
|
function c() {
|
|
528
711
|
t.renderMode === "on-demand" && s();
|
|
529
712
|
}
|
|
530
|
-
|
|
531
|
-
a.value.dispose(), a.value = new
|
|
532
|
-
}),
|
|
713
|
+
ae(i, () => {
|
|
714
|
+
a.value.dispose(), a.value = new ge(i.value), c();
|
|
715
|
+
}), ae([n.width, n.height], () => {
|
|
533
716
|
a.value.setSize(n.width.value, n.height.value), c();
|
|
534
717
|
}, {
|
|
535
718
|
immediate: !0
|
|
536
|
-
}),
|
|
537
|
-
const { pixelRatio: o } =
|
|
538
|
-
const h = new
|
|
719
|
+
}), ae(() => t.clearColor, c);
|
|
720
|
+
const { pixelRatio: o } = on(), { logError: f } = V(), u = (() => {
|
|
721
|
+
const h = new ge(), g = {
|
|
539
722
|
shadowMap: {
|
|
540
723
|
enabled: h.shadowMap.enabled,
|
|
541
724
|
type: h.shadowMap.type
|
|
@@ -544,27 +727,27 @@ function ar({
|
|
|
544
727
|
toneMappingExposure: h.toneMappingExposure,
|
|
545
728
|
outputColorSpace: h.outputColorSpace
|
|
546
729
|
};
|
|
547
|
-
return h.dispose(),
|
|
548
|
-
})(),
|
|
549
|
-
return
|
|
730
|
+
return h.dispose(), g;
|
|
731
|
+
})(), v = x(t.renderMode);
|
|
732
|
+
return v === "on-demand" && s(), v === "manual" && setTimeout(() => {
|
|
550
733
|
l();
|
|
551
|
-
}, 100),
|
|
552
|
-
const h =
|
|
553
|
-
h && (h in
|
|
554
|
-
const
|
|
555
|
-
const
|
|
734
|
+
}, 100), xe(() => {
|
|
735
|
+
const h = x(t.preset);
|
|
736
|
+
h && (h in se || f(`Renderer Preset must be one of these: ${Object.keys(se).join(", ")}`), pt(a.value, se[h])), or(a.value, o.value, x(t.dpr)), v === "always" && (r.frames.value = Math.max(1, r.frames.value));
|
|
737
|
+
const g = (C, E) => {
|
|
738
|
+
const T = x(C), b = () => {
|
|
556
739
|
if (h)
|
|
557
|
-
return Ve(
|
|
740
|
+
return Ve(se[h], E);
|
|
558
741
|
};
|
|
559
|
-
if (
|
|
560
|
-
return
|
|
561
|
-
const
|
|
562
|
-
return
|
|
563
|
-
},
|
|
564
|
-
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
742
|
+
if (T !== void 0)
|
|
743
|
+
return T;
|
|
744
|
+
const P = b();
|
|
745
|
+
return P !== void 0 ? P : Ve(u, E);
|
|
746
|
+
}, p = (C, E) => qn(a.value, E, g(C, E));
|
|
747
|
+
p(t.shadows, "shadowMap.enabled"), p(t.toneMapping ?? ct, "toneMapping"), p(t.shadowMapType, "shadowMap.type"), mr < 150 && p(!t.useLegacyLights, "physicallyCorrectLights"), p(t.outputColorSpace, "outputColorSpace"), p(t.toneMappingExposure, "toneMappingExposure");
|
|
748
|
+
const _ = g(t.clearColor, "clearColor");
|
|
749
|
+
_ && a.value.setClearColor(
|
|
750
|
+
_ ? hr(_) : new Z(0)
|
|
568
751
|
// default clear color is not easily/efficiently retrievable from three
|
|
569
752
|
);
|
|
570
753
|
}), K(() => {
|
|
@@ -573,408 +756,208 @@ function ar({
|
|
|
573
756
|
renderer: a
|
|
574
757
|
};
|
|
575
758
|
}
|
|
576
|
-
function
|
|
577
|
-
const
|
|
578
|
-
return
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const { logError: l } = Y(), i = new e();
|
|
584
|
-
return s && s(i), n && n(i), await new Promise((a, c) => {
|
|
585
|
-
i.load(
|
|
586
|
-
t,
|
|
587
|
-
(o) => {
|
|
588
|
-
const u = o;
|
|
589
|
-
u.scene && Object.assign(u, lr(u.scene)), a(u);
|
|
590
|
-
},
|
|
591
|
-
r,
|
|
592
|
-
(o) => {
|
|
593
|
-
l("[useLoader] - Failed to load resource", o), c(o);
|
|
594
|
-
}
|
|
595
|
-
);
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
async function zr(e, t) {
|
|
599
|
-
const n = new Ut(t), r = (s) => new Promise((l, i) => {
|
|
600
|
-
n.load(
|
|
601
|
-
s,
|
|
602
|
-
(a) => l(a),
|
|
603
|
-
() => null,
|
|
604
|
-
() => {
|
|
605
|
-
i(new Error("[useTextures] - Failed to load texture"));
|
|
606
|
-
}
|
|
607
|
-
);
|
|
608
|
-
});
|
|
609
|
-
if (Kn(e)) {
|
|
610
|
-
const s = await Promise.all(e.map((l) => r(l)));
|
|
611
|
-
return e.length > 1 ? s : s[0];
|
|
612
|
-
} else {
|
|
613
|
-
const {
|
|
614
|
-
map: s,
|
|
615
|
-
displacementMap: l,
|
|
616
|
-
normalMap: i,
|
|
617
|
-
roughnessMap: a,
|
|
618
|
-
metalnessMap: c,
|
|
619
|
-
aoMap: o,
|
|
620
|
-
alphaMap: u,
|
|
621
|
-
matcap: v
|
|
622
|
-
} = e;
|
|
623
|
-
return {
|
|
624
|
-
map: s ? await r(s) : null,
|
|
625
|
-
displacementMap: l ? await r(l) : null,
|
|
626
|
-
normalMap: i ? await r(i) : null,
|
|
627
|
-
roughnessMap: a ? await r(a) : null,
|
|
628
|
-
metalnessMap: c ? await r(c) : null,
|
|
629
|
-
aoMap: o ? await r(o) : null,
|
|
630
|
-
alphaMap: u ? await r(u) : null,
|
|
631
|
-
matcap: v ? await r(v) : null
|
|
632
|
-
};
|
|
633
|
-
}
|
|
759
|
+
function vr(e, t, n = 10) {
|
|
760
|
+
const r = x(e) ? sn() : an(J(() => x(t).parentElement)), s = we(Ne(r.width, n)), l = we(Ne(r.height, n)), i = J(() => s.value / l.value);
|
|
761
|
+
return {
|
|
762
|
+
height: l,
|
|
763
|
+
width: s,
|
|
764
|
+
aspectRatio: i
|
|
765
|
+
};
|
|
634
766
|
}
|
|
635
|
-
const
|
|
636
|
-
const n =
|
|
767
|
+
const yr = (e, t) => {
|
|
768
|
+
const n = J(() => t.renderer.value.domElement), r = $([]), { x: s, y: l } = ln({ target: n });
|
|
637
769
|
let i = 0;
|
|
638
|
-
const { width: a, height: c, top: o, left:
|
|
770
|
+
const { width: a, height: c, top: o, left: f } = cn(n), y = ({ x: m, y: S }) => {
|
|
639
771
|
if (n.value)
|
|
640
772
|
return {
|
|
641
|
-
x: (m -
|
|
642
|
-
y: -((
|
|
773
|
+
x: (m - f.value) / a.value * 2 - 1,
|
|
774
|
+
y: -((S - o.value) / c.value) * 2 + 1
|
|
643
775
|
};
|
|
644
|
-
},
|
|
776
|
+
}, u = ({ x: m, y: S }) => {
|
|
645
777
|
if (t.camera.value)
|
|
646
|
-
return t.raycaster.value.setFromCamera(new
|
|
647
|
-
},
|
|
648
|
-
const
|
|
778
|
+
return t.raycaster.value.setFromCamera(new ve(m, S), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
|
|
779
|
+
}, v = (m) => {
|
|
780
|
+
const S = y({
|
|
649
781
|
x: (m == null ? void 0 : m.clientX) ?? s.value,
|
|
650
782
|
y: (m == null ? void 0 : m.clientY) ?? l.value
|
|
651
783
|
});
|
|
652
|
-
return
|
|
653
|
-
}, h =
|
|
654
|
-
function
|
|
655
|
-
const
|
|
656
|
-
for (const
|
|
657
|
-
typeof
|
|
658
|
-
return
|
|
784
|
+
return S ? u(S) || [] : [];
|
|
785
|
+
}, h = D(), g = D(), p = D(), _ = D(), C = D(), E = D(), T = D(), b = D();
|
|
786
|
+
function P(m) {
|
|
787
|
+
const S = {};
|
|
788
|
+
for (const U in m)
|
|
789
|
+
typeof U != "function" && (S[U] = m[U]);
|
|
790
|
+
return S;
|
|
659
791
|
}
|
|
660
|
-
const
|
|
661
|
-
var
|
|
662
|
-
const
|
|
792
|
+
const M = (m, S) => {
|
|
793
|
+
var Be, Ie, $e;
|
|
794
|
+
const U = P(S), ne = new Ae(S == null ? void 0 : S.clientX, S == null ? void 0 : S.clientY, 0).unproject((Be = t.camera) == null ? void 0 : Be.value);
|
|
663
795
|
m.trigger({
|
|
664
|
-
...
|
|
796
|
+
...U,
|
|
665
797
|
intersections: r.value,
|
|
666
798
|
// The unprojectedPoint is wrong, math needs to be fixed
|
|
667
|
-
unprojectedPoint:
|
|
668
|
-
ray: (
|
|
669
|
-
camera: (
|
|
670
|
-
sourceEvent:
|
|
799
|
+
unprojectedPoint: ne,
|
|
800
|
+
ray: (Ie = t.raycaster) == null ? void 0 : Ie.value.ray,
|
|
801
|
+
camera: ($e = t.camera) == null ? void 0 : $e.value,
|
|
802
|
+
sourceEvent: S,
|
|
671
803
|
delta: i,
|
|
672
804
|
stopPropagating: !1
|
|
673
805
|
});
|
|
674
806
|
};
|
|
675
807
|
let A;
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
},
|
|
679
|
-
A &&
|
|
808
|
+
const d = (m) => {
|
|
809
|
+
v(m), M(p, m), A = m;
|
|
810
|
+
}, w = () => {
|
|
811
|
+
A && d(A);
|
|
680
812
|
};
|
|
681
|
-
let
|
|
682
|
-
const
|
|
683
|
-
var
|
|
684
|
-
|
|
813
|
+
let k, L, O;
|
|
814
|
+
const j = (m) => {
|
|
815
|
+
var S;
|
|
816
|
+
k = (S = r.value[0]) == null ? void 0 : S.object, i = 0, L = new ve(
|
|
685
817
|
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
686
818
|
(m == null ? void 0 : m.clientY) ?? l.value
|
|
687
|
-
),
|
|
819
|
+
), M(C, m);
|
|
688
820
|
};
|
|
689
|
-
let
|
|
690
|
-
const
|
|
691
|
-
var
|
|
692
|
-
m instanceof PointerEvent && (r.value.length === 0 &&
|
|
821
|
+
let R, Y = !1;
|
|
822
|
+
const Oe = (m) => {
|
|
823
|
+
var S, U, ne;
|
|
824
|
+
m instanceof PointerEvent && (r.value.length === 0 && M(E, m), k === ((S = r.value[0]) == null ? void 0 : S.object) && (O = new ve(
|
|
693
825
|
(m == null ? void 0 : m.clientX) ?? s.value,
|
|
694
826
|
(m == null ? void 0 : m.clientY) ?? l.value
|
|
695
|
-
), i =
|
|
696
|
-
},
|
|
697
|
-
|
|
698
|
-
},
|
|
699
|
-
return n.value.addEventListener("pointerup",
|
|
700
|
-
n != null && n.value && (n.value.removeEventListener("pointerup",
|
|
827
|
+
), i = L == null ? void 0 : L.distanceTo(O), m.button === 0 ? (M(h, m), R === ((U = r.value[0]) == null ? void 0 : U.object) ? Y = !0 : (R = (ne = r.value[0]) == null ? void 0 : ne.object, Y = !1)) : m.button === 2 && M(T, m)), M(_, m));
|
|
828
|
+
}, Re = (m) => {
|
|
829
|
+
Y && (M(g, m), R = void 0, Y = !1);
|
|
830
|
+
}, De = (m) => M(p, m), je = (m) => M(b, m);
|
|
831
|
+
return n.value.addEventListener("pointerup", Oe), n.value.addEventListener("pointerdown", j), n.value.addEventListener("pointermove", d), n.value.addEventListener("pointerleave", De), n.value.addEventListener("dblclick", Re), n.value.addEventListener("wheel", je), K(() => {
|
|
832
|
+
n != null && n.value && (n.value.removeEventListener("pointerup", Oe), n.value.removeEventListener("pointerdown", j), n.value.removeEventListener("pointermove", d), n.value.removeEventListener("pointerleave", De), n.value.removeEventListener("dblclick", Re), n.value.removeEventListener("wheel", je));
|
|
701
833
|
}), {
|
|
702
834
|
intersects: r,
|
|
703
835
|
onClick: (m) => h.on(m).off,
|
|
704
|
-
onDblClick: (m) =>
|
|
705
|
-
onContextMenu: (m) =>
|
|
706
|
-
onPointerMove: (m) =>
|
|
707
|
-
onPointerUp: (m) =>
|
|
708
|
-
onPointerDown: (m) =>
|
|
709
|
-
onPointerMissed: (m) =>
|
|
710
|
-
onWheel: (m) =>
|
|
711
|
-
forceUpdate:
|
|
836
|
+
onDblClick: (m) => g.on(m).off,
|
|
837
|
+
onContextMenu: (m) => T.on(m).off,
|
|
838
|
+
onPointerMove: (m) => p.on(m).off,
|
|
839
|
+
onPointerUp: (m) => _.on(m).off,
|
|
840
|
+
onPointerDown: (m) => C.on(m).off,
|
|
841
|
+
onPointerMissed: (m) => E.on(m).off,
|
|
842
|
+
onWheel: (m) => b.on(m).off,
|
|
843
|
+
forceUpdate: w
|
|
712
844
|
};
|
|
713
845
|
};
|
|
714
|
-
function
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
function n(l, i, a) {
|
|
723
|
-
const c = [];
|
|
724
|
-
return l.traverse((o) => {
|
|
725
|
-
o[i].includes(a) && c.push(o);
|
|
726
|
-
}), c.length || e(`Children with ${i} '${a}' not found.`), c;
|
|
727
|
-
}
|
|
728
|
-
function r(l, i) {
|
|
729
|
-
return t(l, "name", i);
|
|
730
|
-
}
|
|
731
|
-
function s(l, i) {
|
|
732
|
-
return n(l, "name", i);
|
|
733
|
-
}
|
|
734
|
-
return {
|
|
735
|
-
seek: t,
|
|
736
|
-
seekByName: r,
|
|
737
|
-
seekAll: n,
|
|
738
|
-
seekAllByName: s
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
function xe(e) {
|
|
742
|
-
let t = 0;
|
|
743
|
-
return e.traverse((n) => {
|
|
744
|
-
if (n.isMesh && n.geometry && n.type !== "HightlightMesh") {
|
|
745
|
-
const r = n.geometry, s = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, l = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, i = 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, c = s + l + i + a;
|
|
746
|
-
t += c;
|
|
747
|
-
}
|
|
748
|
-
}), t;
|
|
749
|
-
}
|
|
750
|
-
function ur(e) {
|
|
751
|
-
return (e / 1024).toFixed(2);
|
|
752
|
-
}
|
|
753
|
-
const Me = H({}), Pe = (e) => Object.assign(Me.value, e);
|
|
754
|
-
function fr(e, t, n) {
|
|
755
|
-
var L;
|
|
846
|
+
function _e(e, t) {
|
|
847
|
+
if (Array.isArray(e))
|
|
848
|
+
for (const n of e)
|
|
849
|
+
n(t);
|
|
850
|
+
typeof e == "function" && e(t);
|
|
851
|
+
}
|
|
852
|
+
function _r(e, t, n) {
|
|
853
|
+
var A;
|
|
756
854
|
const r = $(), s = $();
|
|
757
855
|
e && (r.value = e), t && (s.value = t);
|
|
758
|
-
const l = (
|
|
856
|
+
const l = (d) => {
|
|
759
857
|
var w;
|
|
760
|
-
return ((w =
|
|
761
|
-
}, i = (
|
|
858
|
+
return ((w = d.__tres) == null ? void 0 : w.eventCount) > 0;
|
|
859
|
+
}, i = (d) => {
|
|
762
860
|
var w;
|
|
763
|
-
return ((w =
|
|
764
|
-
}, a = $(((
|
|
765
|
-
function c(
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
x(w);
|
|
769
|
-
typeof p == "function" && p(w);
|
|
770
|
-
}
|
|
771
|
-
function o(p, w) {
|
|
772
|
-
const x = [], D = () => w.stopPropagating = !0;
|
|
773
|
-
w.stopPropagation = D;
|
|
861
|
+
return ((w = d.children) == null ? void 0 : w.some((k) => i(k))) || l(d);
|
|
862
|
+
}, a = $(((A = r.value) == null ? void 0 : A.children).filter(i) || []);
|
|
863
|
+
function c(d, w) {
|
|
864
|
+
const k = [], L = () => w.stopPropagating = !0;
|
|
865
|
+
w.stopPropagation = L;
|
|
774
866
|
for (const O of w == null ? void 0 : w.intersections) {
|
|
775
867
|
if (w.stopPropagating)
|
|
776
868
|
return;
|
|
777
869
|
w = { ...w, ...O };
|
|
778
|
-
const { object:
|
|
779
|
-
w.eventObject =
|
|
780
|
-
let R =
|
|
781
|
-
for (; R !== null && !w.stopPropagating && !
|
|
782
|
-
w.eventObject = R,
|
|
783
|
-
const
|
|
784
|
-
n(
|
|
870
|
+
const { object: j } = O;
|
|
871
|
+
w.eventObject = j, _e(j[d], w), k.push(j);
|
|
872
|
+
let R = j.parent;
|
|
873
|
+
for (; R !== null && !w.stopPropagating && !k.includes(R); )
|
|
874
|
+
w.eventObject = R, _e(R[d], w), k.push(R), R = R.parent;
|
|
875
|
+
const Y = Vn(d.slice(2));
|
|
876
|
+
n(Y, { intersection: O, event: w });
|
|
785
877
|
}
|
|
786
878
|
}
|
|
787
879
|
const {
|
|
788
|
-
onClick:
|
|
789
|
-
onDblClick:
|
|
790
|
-
onContextMenu:
|
|
791
|
-
onPointerMove:
|
|
792
|
-
onPointerDown:
|
|
793
|
-
onPointerUp:
|
|
794
|
-
onPointerMissed:
|
|
795
|
-
onWheel:
|
|
796
|
-
forceUpdate:
|
|
797
|
-
} =
|
|
798
|
-
|
|
799
|
-
let
|
|
800
|
-
|
|
801
|
-
const w =
|
|
802
|
-
|
|
803
|
-
w.includes(
|
|
804
|
-
}),
|
|
805
|
-
|
|
806
|
-
}),
|
|
880
|
+
onClick: o,
|
|
881
|
+
onDblClick: f,
|
|
882
|
+
onContextMenu: y,
|
|
883
|
+
onPointerMove: u,
|
|
884
|
+
onPointerDown: v,
|
|
885
|
+
onPointerUp: h,
|
|
886
|
+
onPointerMissed: g,
|
|
887
|
+
onWheel: p,
|
|
888
|
+
forceUpdate: _
|
|
889
|
+
} = yr(a, t);
|
|
890
|
+
h((d) => c("onPointerUp", d)), v((d) => c("onPointerDown", d)), o((d) => c("onClick", d)), f((d) => c("onDoubleClick", d)), y((d) => c("onContextMenu", d)), p((d) => c("onWheel", d));
|
|
891
|
+
let C = [];
|
|
892
|
+
u((d) => {
|
|
893
|
+
const w = d.intersections.map(({ object: L }) => L), k = d.intersections;
|
|
894
|
+
C.forEach(({ object: L }) => {
|
|
895
|
+
w.includes(L) || (d.intersections = C, c("onPointerLeave", d), c("onPointerOut", d));
|
|
896
|
+
}), d.intersections = k, d.intersections.forEach(({ object: L }) => {
|
|
897
|
+
C.includes(L) || (c("onPointerEnter", d), c("onPointerOver", d));
|
|
898
|
+
}), c("onPointerMove", d), C = d.intersections;
|
|
807
899
|
});
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
const w = () =>
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}), n("pointer-missed", { event:
|
|
900
|
+
const E = [];
|
|
901
|
+
g((d) => {
|
|
902
|
+
const w = () => d.stopPropagating = !0;
|
|
903
|
+
d.stopPropagation = w, E.forEach((k) => {
|
|
904
|
+
d.stopPropagating || (d.eventObject = k, _e(k.onPointerMissed, d));
|
|
905
|
+
}), n("pointer-missed", { event: d });
|
|
814
906
|
});
|
|
815
|
-
function
|
|
816
|
-
|
|
907
|
+
function T(d) {
|
|
908
|
+
re(d) && N(d) && a.value.push(d);
|
|
817
909
|
}
|
|
818
|
-
function
|
|
819
|
-
if (
|
|
820
|
-
const w = a.value.indexOf(
|
|
910
|
+
function b(d) {
|
|
911
|
+
if (re(d) && N(d)) {
|
|
912
|
+
const w = a.value.indexOf(d);
|
|
821
913
|
w > -1 && a.value.splice(w, 1);
|
|
822
914
|
}
|
|
823
915
|
}
|
|
824
|
-
function
|
|
825
|
-
|
|
916
|
+
function P(d) {
|
|
917
|
+
re(d) && N(d) && d.onPointerMissed && E.push(d);
|
|
826
918
|
}
|
|
827
|
-
function
|
|
828
|
-
if (
|
|
829
|
-
const w =
|
|
830
|
-
w > -1 &&
|
|
919
|
+
function M(d) {
|
|
920
|
+
if (re(d) && N(d)) {
|
|
921
|
+
const w = E.indexOf(d);
|
|
922
|
+
w > -1 && E.splice(w, 1);
|
|
831
923
|
}
|
|
832
924
|
}
|
|
833
925
|
return t.eventManager = {
|
|
834
|
-
forceUpdate:
|
|
835
|
-
registerObject:
|
|
836
|
-
deregisterObject:
|
|
837
|
-
registerPointerMissedObject:
|
|
838
|
-
deregisterPointerMissedObject:
|
|
926
|
+
forceUpdate: _,
|
|
927
|
+
registerObject: T,
|
|
928
|
+
deregisterObject: b,
|
|
929
|
+
registerPointerMissedObject: P,
|
|
930
|
+
deregisterPointerMissedObject: M
|
|
839
931
|
}, {
|
|
840
|
-
forceUpdate:
|
|
841
|
-
registerObject:
|
|
842
|
-
deregisterObject:
|
|
843
|
-
registerPointerMissedObject:
|
|
844
|
-
deregisterPointerMissedObject:
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
function dr(e, t, n = 10) {
|
|
848
|
-
const r = k(e) ? rn() : on(V(() => k(t).parentElement)), s = ye(Fe(r.width, n)), l = ye(Fe(r.height, n)), i = V(() => s.value / l.value);
|
|
849
|
-
return {
|
|
850
|
-
height: l,
|
|
851
|
-
width: s,
|
|
852
|
-
aspectRatio: i
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
function ve() {
|
|
856
|
-
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
857
|
-
let n = 0, r = !1;
|
|
858
|
-
const s = () => {
|
|
859
|
-
const o = Array.from(e.entries()).sort((u, v) => {
|
|
860
|
-
const d = u[1].priority - v[1].priority;
|
|
861
|
-
return d === 0 ? u[1].addI - v[1].addI : d;
|
|
862
|
-
});
|
|
863
|
-
t.clear(), o.forEach((u) => t.add(u[0]));
|
|
864
|
-
}, l = (o) => {
|
|
865
|
-
e.delete(o), t.delete(o);
|
|
932
|
+
forceUpdate: _,
|
|
933
|
+
registerObject: T,
|
|
934
|
+
deregisterObject: b,
|
|
935
|
+
registerPointerMissedObject: P,
|
|
936
|
+
deregisterPointerMissedObject: M
|
|
866
937
|
};
|
|
867
|
-
return { on: (o, u = 0) => {
|
|
868
|
-
e.set(o, { priority: u, addI: n++ });
|
|
869
|
-
const v = () => l(o);
|
|
870
|
-
return sn(v), r = !0, {
|
|
871
|
-
off: v
|
|
872
|
-
};
|
|
873
|
-
}, off: l, trigger: (...o) => {
|
|
874
|
-
r && (s(), r = !1), t.forEach((u) => u(...o));
|
|
875
|
-
}, dispose: () => {
|
|
876
|
-
e.clear(), t.clear();
|
|
877
|
-
}, get count() {
|
|
878
|
-
return e.size;
|
|
879
|
-
} };
|
|
880
938
|
}
|
|
881
|
-
function
|
|
882
|
-
let e = !0, t = !0, n = !1;
|
|
883
|
-
const r = new tt(!1), s = H(r.running), l = H(!1);
|
|
884
|
-
let i;
|
|
885
|
-
const a = rt.generateUUID();
|
|
886
|
-
let c = null;
|
|
887
|
-
const o = ve(), u = ve(), v = ve();
|
|
888
|
-
S();
|
|
889
|
-
let d = {};
|
|
890
|
-
function g(_) {
|
|
891
|
-
d = _;
|
|
892
|
-
}
|
|
893
|
-
function h(_, A, L = 0) {
|
|
894
|
-
switch (A) {
|
|
895
|
-
case "before":
|
|
896
|
-
return o.on(_, L);
|
|
897
|
-
case "render":
|
|
898
|
-
return c || (c = _), u.dispose(), u.on(_);
|
|
899
|
-
case "after":
|
|
900
|
-
return v.on(_, L);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
function b() {
|
|
904
|
-
t && (t = !1, S(), E());
|
|
905
|
-
}
|
|
906
|
-
function y() {
|
|
907
|
-
t = !0, S(), cancelAnimationFrame(i);
|
|
908
|
-
}
|
|
909
|
-
function f() {
|
|
910
|
-
n = !1, S();
|
|
911
|
-
}
|
|
912
|
-
function M() {
|
|
913
|
-
n = !0, S();
|
|
914
|
-
}
|
|
915
|
-
function P() {
|
|
916
|
-
l.value = !0;
|
|
917
|
-
}
|
|
918
|
-
function C() {
|
|
919
|
-
l.value = !1;
|
|
920
|
-
}
|
|
921
|
-
function E() {
|
|
922
|
-
if (!e) {
|
|
923
|
-
i = requestAnimationFrame(E);
|
|
924
|
-
return;
|
|
925
|
-
}
|
|
926
|
-
const _ = r.getDelta(), A = r.getElapsedTime(), L = {
|
|
927
|
-
camera: J(d.camera),
|
|
928
|
-
scene: J(d.scene),
|
|
929
|
-
renderer: J(d.renderer),
|
|
930
|
-
raycaster: J(d.raycaster),
|
|
931
|
-
controls: J(d.controls),
|
|
932
|
-
invalidate: d.invalidate,
|
|
933
|
-
advance: d.advance
|
|
934
|
-
}, p = { delta: _, elapsed: A, clock: r, ...L };
|
|
935
|
-
s.value && o.trigger(p), l.value || (u.count ? u.trigger(p) : c && c(p)), s.value && v.trigger(p), i = requestAnimationFrame(E);
|
|
936
|
-
}
|
|
937
|
-
function S() {
|
|
938
|
-
const _ = !t && !n;
|
|
939
|
-
r.running !== _ && (r.running ? r.stop() : r.start()), s.value = r.running;
|
|
940
|
-
}
|
|
941
|
-
return {
|
|
942
|
-
loopId: a,
|
|
943
|
-
register: (_, A, L) => h(_, A, L),
|
|
944
|
-
start: b,
|
|
945
|
-
stop: y,
|
|
946
|
-
pause: M,
|
|
947
|
-
resume: f,
|
|
948
|
-
pauseRender: P,
|
|
949
|
-
resumeRender: C,
|
|
950
|
-
isRenderPaused: l,
|
|
951
|
-
isActive: s,
|
|
952
|
-
setContext: g,
|
|
953
|
-
setReady: (_) => e = _
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
function mr(e, t, n = 100) {
|
|
939
|
+
function wr(e, t, n = 100) {
|
|
957
940
|
n = n <= 0 ? 100 : n;
|
|
958
|
-
const r =
|
|
941
|
+
const r = D(), s = /* @__PURE__ */ new Set();
|
|
959
942
|
let l = !1, i = !1, a = null;
|
|
960
943
|
function c() {
|
|
961
|
-
a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((
|
|
944
|
+
a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((u) => u()), s.clear(), l = !0) : !i && !l && (a = setTimeout(c, n));
|
|
962
945
|
}
|
|
963
946
|
function o() {
|
|
964
947
|
i = !0, a && clearTimeout(a);
|
|
965
948
|
}
|
|
966
949
|
c();
|
|
967
|
-
const
|
|
968
|
-
|
|
950
|
+
const f = (u, ...v) => {
|
|
951
|
+
u(...v);
|
|
969
952
|
};
|
|
970
953
|
return {
|
|
971
|
-
on: (
|
|
954
|
+
on: (u) => {
|
|
972
955
|
if (l)
|
|
973
|
-
return u
|
|
956
|
+
return f(u, t), { off: () => {
|
|
974
957
|
} };
|
|
975
958
|
{
|
|
976
|
-
const
|
|
977
|
-
return s.add(
|
|
959
|
+
const v = r.on(u);
|
|
960
|
+
return s.add(v.off), r.on(u);
|
|
978
961
|
}
|
|
979
962
|
},
|
|
980
963
|
off: r.off,
|
|
@@ -982,11 +965,11 @@ function mr(e, t, n = 100) {
|
|
|
982
965
|
cancel: o
|
|
983
966
|
};
|
|
984
967
|
}
|
|
985
|
-
const
|
|
986
|
-
function
|
|
987
|
-
if (e = e ||
|
|
988
|
-
return
|
|
989
|
-
const t = 100, n = Date.now(), l =
|
|
968
|
+
const ee = /* @__PURE__ */ new WeakMap();
|
|
969
|
+
function yt(e) {
|
|
970
|
+
if (e = e || me(), ee.has(e))
|
|
971
|
+
return ee.get(e);
|
|
972
|
+
const t = 100, n = Date.now(), l = wr(() => {
|
|
990
973
|
if (Date.now() - n >= t)
|
|
991
974
|
return !0;
|
|
992
975
|
{
|
|
@@ -994,58 +977,56 @@ function gt(e) {
|
|
|
994
977
|
return !!(i && a.width > 0 && a.height > 0);
|
|
995
978
|
}
|
|
996
979
|
}, e);
|
|
997
|
-
return
|
|
980
|
+
return ee.set(e, l), l;
|
|
998
981
|
}
|
|
999
|
-
function
|
|
1000
|
-
const t =
|
|
982
|
+
function Xr(e) {
|
|
983
|
+
const t = me();
|
|
1001
984
|
if (t)
|
|
1002
|
-
return
|
|
985
|
+
return ee.has(t) ? ee.get(t).on(e) : yt(t).on(e);
|
|
1003
986
|
}
|
|
1004
|
-
function
|
|
987
|
+
function br({
|
|
1005
988
|
scene: e,
|
|
1006
989
|
canvas: t,
|
|
1007
990
|
windowSize: n,
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
emit: l
|
|
991
|
+
rendererOptions: r,
|
|
992
|
+
emit: s
|
|
1011
993
|
}) {
|
|
1012
|
-
const
|
|
1013
|
-
camera:
|
|
1014
|
-
cameras:
|
|
1015
|
-
registerCamera:
|
|
1016
|
-
deregisterCamera:
|
|
1017
|
-
setCameraActive:
|
|
1018
|
-
} =
|
|
1019
|
-
mode:
|
|
1020
|
-
priority:
|
|
1021
|
-
frames:
|
|
994
|
+
const l = $(e), i = vr(n, t), {
|
|
995
|
+
camera: a,
|
|
996
|
+
cameras: c,
|
|
997
|
+
registerCamera: o,
|
|
998
|
+
deregisterCamera: f,
|
|
999
|
+
setCameraActive: y
|
|
1000
|
+
} = ar({ sizes: i, scene: e }), u = {
|
|
1001
|
+
mode: I(r.renderMode || "always"),
|
|
1002
|
+
priority: I(0),
|
|
1003
|
+
frames: I(0),
|
|
1022
1004
|
maxFrames: 60,
|
|
1023
|
-
canBeInvalidated:
|
|
1005
|
+
canBeInvalidated: J(() => u.mode.value === "on-demand" && u.frames.value === 0)
|
|
1024
1006
|
};
|
|
1025
|
-
function
|
|
1026
|
-
|
|
1007
|
+
function v(O = 1) {
|
|
1008
|
+
r.renderMode === "on-demand" && (u.frames.value = Math.min(u.maxFrames, u.frames.value + O));
|
|
1027
1009
|
}
|
|
1028
|
-
function
|
|
1029
|
-
|
|
1010
|
+
function h() {
|
|
1011
|
+
r.renderMode === "manual" && (u.frames.value = 1);
|
|
1030
1012
|
}
|
|
1031
|
-
const { renderer:
|
|
1013
|
+
const { renderer: g } = gr(
|
|
1032
1014
|
{
|
|
1033
1015
|
scene: e,
|
|
1034
1016
|
canvas: t,
|
|
1035
|
-
options:
|
|
1036
|
-
emit:
|
|
1017
|
+
options: r,
|
|
1018
|
+
emit: s,
|
|
1037
1019
|
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
|
|
1038
|
-
contextParts: { sizes:
|
|
1039
|
-
disableRender: r
|
|
1020
|
+
contextParts: { sizes: i, camera: a, render: u, invalidate: v, advance: h }
|
|
1040
1021
|
}
|
|
1041
|
-
),
|
|
1042
|
-
sizes:
|
|
1043
|
-
scene:
|
|
1044
|
-
camera:
|
|
1045
|
-
cameras:
|
|
1046
|
-
renderer:
|
|
1047
|
-
raycaster: $(new
|
|
1048
|
-
controls:
|
|
1022
|
+
), p = {
|
|
1023
|
+
sizes: i,
|
|
1024
|
+
scene: l,
|
|
1025
|
+
camera: a,
|
|
1026
|
+
cameras: we(c),
|
|
1027
|
+
renderer: g,
|
|
1028
|
+
raycaster: $(new zt()),
|
|
1029
|
+
controls: I(null),
|
|
1049
1030
|
perf: {
|
|
1050
1031
|
maxFrames: 160,
|
|
1051
1032
|
fps: {
|
|
@@ -1058,47 +1039,47 @@ function hr({
|
|
|
1058
1039
|
accumulator: []
|
|
1059
1040
|
}
|
|
1060
1041
|
},
|
|
1061
|
-
render:
|
|
1062
|
-
advance:
|
|
1063
|
-
extend:
|
|
1064
|
-
invalidate:
|
|
1065
|
-
registerCamera:
|
|
1066
|
-
setCameraActive:
|
|
1067
|
-
deregisterCamera:
|
|
1042
|
+
render: u,
|
|
1043
|
+
advance: h,
|
|
1044
|
+
extend: Ee,
|
|
1045
|
+
invalidate: v,
|
|
1046
|
+
registerCamera: o,
|
|
1047
|
+
setCameraActive: y,
|
|
1048
|
+
deregisterCamera: f,
|
|
1068
1049
|
loop: pr()
|
|
1069
1050
|
};
|
|
1070
|
-
|
|
1071
|
-
root:
|
|
1072
|
-
},
|
|
1073
|
-
|
|
1051
|
+
le("useTres", p), p.scene.value.__tres = {
|
|
1052
|
+
root: p
|
|
1053
|
+
}, p.loop.register(() => {
|
|
1054
|
+
a.value && u.frames.value > 0 && (g.value.render(e, a.value), s("render", p.renderer.value)), u.priority.value = 0, u.mode.value === "always" ? u.frames.value = 1 : u.frames.value = Math.max(0, u.frames.value - 1);
|
|
1074
1055
|
}, "render");
|
|
1075
|
-
const { on:
|
|
1076
|
-
|
|
1077
|
-
|
|
1056
|
+
const { on: _, cancel: C } = yt(p);
|
|
1057
|
+
p.loop.setReady(!1), p.loop.start(), _(() => {
|
|
1058
|
+
s("ready", p), p.loop.setReady(!0), _r(e, p, s);
|
|
1078
1059
|
}), K(() => {
|
|
1079
|
-
|
|
1060
|
+
C(), p.loop.stop();
|
|
1080
1061
|
});
|
|
1081
|
-
const
|
|
1082
|
-
let
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1062
|
+
const E = 100, T = un({ every: E }), { isSupported: b, memory: P } = fn({ interval: E }), M = 160;
|
|
1063
|
+
let A = performance.now();
|
|
1064
|
+
const d = ({ timestamp: O }) => {
|
|
1065
|
+
p.scene.value && (p.perf.memory.allocatedMem = ke(p.scene.value)), O - A >= E && (A = O, p.perf.fps.accumulator.push(T.value), p.perf.fps.accumulator.length > M && p.perf.fps.accumulator.shift(), p.perf.fps.value = T.value, b.value && P.value && (p.perf.memory.accumulator.push(P.value.usedJSHeapSize / 1024 / 1024), p.perf.memory.accumulator.length > M && p.perf.memory.accumulator.shift(), p.perf.memory.currentMem = p.perf.memory.accumulator.reduce((j, R) => j + R, 0) / p.perf.memory.accumulator.length));
|
|
1085
1066
|
};
|
|
1086
1067
|
let w = 0;
|
|
1087
|
-
const
|
|
1088
|
-
window.__TRES__DEVTOOLS__ && (
|
|
1068
|
+
const k = 1, { pause: L } = ut(({ delta: O }) => {
|
|
1069
|
+
window.__TRES__DEVTOOLS__ && (d({ timestamp: performance.now() }), w += O, w >= k && (window.__TRES__DEVTOOLS__.cb(p), w = 0));
|
|
1089
1070
|
}, { immediate: !0 });
|
|
1090
1071
|
return K(() => {
|
|
1091
|
-
|
|
1092
|
-
}),
|
|
1072
|
+
L();
|
|
1073
|
+
}), p;
|
|
1093
1074
|
}
|
|
1094
|
-
function
|
|
1095
|
-
const e =
|
|
1075
|
+
function me() {
|
|
1076
|
+
const e = St("useTres");
|
|
1096
1077
|
if (!e)
|
|
1097
1078
|
throw new Error("useTresContext must be used together with useTresContextProvider");
|
|
1098
1079
|
return e;
|
|
1099
1080
|
}
|
|
1100
|
-
const
|
|
1101
|
-
function
|
|
1081
|
+
const Zr = me;
|
|
1082
|
+
function eo() {
|
|
1102
1083
|
const {
|
|
1103
1084
|
camera: e,
|
|
1104
1085
|
scene: t,
|
|
@@ -1108,7 +1089,7 @@ function qr() {
|
|
|
1108
1089
|
controls: l,
|
|
1109
1090
|
invalidate: i,
|
|
1110
1091
|
advance: a
|
|
1111
|
-
} =
|
|
1092
|
+
} = me();
|
|
1112
1093
|
r.setContext({
|
|
1113
1094
|
camera: e,
|
|
1114
1095
|
scene: t,
|
|
@@ -1118,14 +1099,14 @@ function qr() {
|
|
|
1118
1099
|
invalidate: i,
|
|
1119
1100
|
advance: a
|
|
1120
1101
|
});
|
|
1121
|
-
function c(
|
|
1122
|
-
return r.register(
|
|
1102
|
+
function c(y, u = 0) {
|
|
1103
|
+
return r.register(y, "before", u);
|
|
1123
1104
|
}
|
|
1124
|
-
function o(
|
|
1125
|
-
return r.register(
|
|
1105
|
+
function o(y) {
|
|
1106
|
+
return r.register(y, "render");
|
|
1126
1107
|
}
|
|
1127
|
-
function
|
|
1128
|
-
return r.register(
|
|
1108
|
+
function f(y, u = 0) {
|
|
1109
|
+
return r.register(y, "after", u);
|
|
1129
1110
|
}
|
|
1130
1111
|
return {
|
|
1131
1112
|
pause: r.pause,
|
|
@@ -1135,10 +1116,57 @@ function qr() {
|
|
|
1135
1116
|
isActive: r.isActive,
|
|
1136
1117
|
onBeforeRender: c,
|
|
1137
1118
|
render: o,
|
|
1138
|
-
onAfterRender:
|
|
1119
|
+
onAfterRender: f
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
const _t = D(), wt = D(), Le = D(), te = new lt();
|
|
1123
|
+
let ce = 0, ue = 0;
|
|
1124
|
+
const { pause: Mr, resume: Ke, isActive: Pr } = ut(
|
|
1125
|
+
() => {
|
|
1126
|
+
_t.trigger({ delta: ce, elapsed: ue, clock: te }), wt.trigger({ delta: ce, elapsed: ue, clock: te }), Le.trigger({ delta: ce, elapsed: ue, clock: te });
|
|
1127
|
+
},
|
|
1128
|
+
{ immediate: !1 }
|
|
1129
|
+
);
|
|
1130
|
+
Le.on(() => {
|
|
1131
|
+
ce = te.getDelta(), ue = te.getElapsedTime();
|
|
1132
|
+
});
|
|
1133
|
+
let Qe = !1;
|
|
1134
|
+
const to = () => (Qe || (Qe = !0, Ke()), {
|
|
1135
|
+
onBeforeLoop: _t.on,
|
|
1136
|
+
onLoop: wt.on,
|
|
1137
|
+
onAfterLoop: Le.on,
|
|
1138
|
+
pause: Mr,
|
|
1139
|
+
resume: Ke,
|
|
1140
|
+
isActive: Pr
|
|
1141
|
+
});
|
|
1142
|
+
function no() {
|
|
1143
|
+
const { logWarning: e } = V();
|
|
1144
|
+
function t(l, i, a) {
|
|
1145
|
+
let c = null;
|
|
1146
|
+
return l.traverse((o) => {
|
|
1147
|
+
o[i] === a && (c = o);
|
|
1148
|
+
}), c || e(`Child with ${i} '${a}' not found.`), c;
|
|
1149
|
+
}
|
|
1150
|
+
function n(l, i, a) {
|
|
1151
|
+
const c = [];
|
|
1152
|
+
return l.traverse((o) => {
|
|
1153
|
+
o[i].includes(a) && c.push(o);
|
|
1154
|
+
}), c.length || e(`Children with ${i} '${a}' not found.`), c;
|
|
1155
|
+
}
|
|
1156
|
+
function r(l, i) {
|
|
1157
|
+
return t(l, "name", i);
|
|
1158
|
+
}
|
|
1159
|
+
function s(l, i) {
|
|
1160
|
+
return n(l, "name", i);
|
|
1161
|
+
}
|
|
1162
|
+
return {
|
|
1163
|
+
seek: t,
|
|
1164
|
+
seekByName: r,
|
|
1165
|
+
seekAll: n,
|
|
1166
|
+
seekAllByName: s
|
|
1139
1167
|
};
|
|
1140
1168
|
}
|
|
1141
|
-
function
|
|
1169
|
+
function Cr(e, t = {}, n = {}) {
|
|
1142
1170
|
let r = e;
|
|
1143
1171
|
const s = (a) => {
|
|
1144
1172
|
r = a;
|
|
@@ -1157,7 +1185,7 @@ function gr(e, t = {}, n = {}) {
|
|
|
1157
1185
|
};
|
|
1158
1186
|
return l = new Proxy({}, i), l;
|
|
1159
1187
|
}
|
|
1160
|
-
const { logError:
|
|
1188
|
+
const { logError: Xe } = V(), Ze = [
|
|
1161
1189
|
"onClick",
|
|
1162
1190
|
"onContextMenu",
|
|
1163
1191
|
"onPointerMove",
|
|
@@ -1172,67 +1200,67 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1172
1200
|
"onPointerMissed",
|
|
1173
1201
|
"onLostPointerCapture",
|
|
1174
1202
|
"onWheel"
|
|
1175
|
-
],
|
|
1203
|
+
], Er = (e) => {
|
|
1176
1204
|
const t = e.scene.value;
|
|
1177
|
-
function n(o,
|
|
1178
|
-
if (
|
|
1205
|
+
function n(o, f, y, u) {
|
|
1206
|
+
if (u || (u = {}), u.args || (u.args = []), o === "template" || zn(o))
|
|
1179
1207
|
return null;
|
|
1180
|
-
let
|
|
1208
|
+
let v = o.replace("Tres", ""), h;
|
|
1181
1209
|
if (o === "primitive") {
|
|
1182
|
-
(!
|
|
1210
|
+
(!H(u.object) || xt(u.object)) && Xe(
|
|
1183
1211
|
"Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>"
|
|
1184
|
-
),
|
|
1185
|
-
const
|
|
1186
|
-
h =
|
|
1187
|
-
|
|
1212
|
+
), v = u.object.type;
|
|
1213
|
+
const g = {};
|
|
1214
|
+
h = Cr(
|
|
1215
|
+
u.object,
|
|
1188
1216
|
{
|
|
1189
|
-
object: (
|
|
1217
|
+
object: (_) => _,
|
|
1190
1218
|
isPrimitive: () => !0,
|
|
1191
|
-
__tres: () =>
|
|
1219
|
+
__tres: () => g
|
|
1192
1220
|
},
|
|
1193
1221
|
{
|
|
1194
|
-
object: (
|
|
1195
|
-
sr(
|
|
1222
|
+
object: (_, C, E, T) => {
|
|
1223
|
+
sr(_, E, T, { patchProp: l, remove: s, insert: r }, e);
|
|
1196
1224
|
},
|
|
1197
|
-
__tres: (
|
|
1198
|
-
Object.assign(
|
|
1225
|
+
__tres: (_) => {
|
|
1226
|
+
Object.assign(g, _);
|
|
1199
1227
|
}
|
|
1200
1228
|
}
|
|
1201
1229
|
);
|
|
1202
1230
|
} else {
|
|
1203
|
-
const
|
|
1204
|
-
|
|
1205
|
-
`${
|
|
1206
|
-
), h = new
|
|
1231
|
+
const g = Ce.value[v];
|
|
1232
|
+
g || Xe(
|
|
1233
|
+
`${v} is not defined on the THREE namespace. Use extend to add it to the catalog.`
|
|
1234
|
+
), h = new g(...u.args);
|
|
1207
1235
|
}
|
|
1208
|
-
return h ? (h.isCamera && (
|
|
1236
|
+
return h ? (h.isCamera && (u != null && u.position || h.position.set(3, 3, 3), u != null && u.lookAt || h.lookAt(0, 0, 0)), h = z(h, {
|
|
1209
1237
|
...h.__tres,
|
|
1210
|
-
type:
|
|
1211
|
-
memoizedProps:
|
|
1238
|
+
type: v,
|
|
1239
|
+
memoizedProps: u,
|
|
1212
1240
|
eventCount: 0,
|
|
1213
1241
|
primitive: o === "primitive",
|
|
1214
|
-
attach:
|
|
1242
|
+
attach: u.attach
|
|
1215
1243
|
}, e), h) : null;
|
|
1216
1244
|
}
|
|
1217
|
-
function r(o,
|
|
1218
|
-
var
|
|
1245
|
+
function r(o, f) {
|
|
1246
|
+
var v, h, g;
|
|
1219
1247
|
if (!o)
|
|
1220
1248
|
return;
|
|
1221
|
-
|
|
1222
|
-
const
|
|
1223
|
-
o = Q(
|
|
1249
|
+
f = f || t;
|
|
1250
|
+
const y = o.__tres ? o : z(o, {}, e), u = f.__tres ? f : z(f, {}, e);
|
|
1251
|
+
o = Q(y), f = Q(u), o.__tres && ((v = o.__tres) == null ? void 0 : v.eventCount) > 0 && ((h = e.eventManager) == null || h.registerObject(o)), e.registerCamera(o), (g = e.eventManager) == null || g.registerPointerMissedObject(o), y.__tres.attach ? nr(u, y, y.__tres.attach) : N(o) && N(u) && (u.add(o), o.dispatchEvent({ type: "added" })), y.__tres.parent = u, u.__tres.objects && !u.__tres.objects.includes(y) && u.__tres.objects.push(y);
|
|
1224
1252
|
}
|
|
1225
|
-
function s(o,
|
|
1226
|
-
var h,
|
|
1253
|
+
function s(o, f) {
|
|
1254
|
+
var h, g, p, _;
|
|
1227
1255
|
if (!o)
|
|
1228
1256
|
return;
|
|
1229
|
-
o != null && o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
const
|
|
1233
|
-
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((
|
|
1234
|
-
if (G(
|
|
1235
|
-
|
|
1257
|
+
o != null && o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((g = e.eventManager) == null || g.deregisterObject(o)), f = Me(f) ? "default" : f;
|
|
1258
|
+
const y = (p = o.__tres) == null ? void 0 : p.dispose;
|
|
1259
|
+
Me(y) || (y === null ? f = !1 : f = y);
|
|
1260
|
+
const u = (_ = o.__tres) == null ? void 0 : _.primitive, v = f === "default" ? !u : !!f;
|
|
1261
|
+
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((C) => s(C, f)), v && o.children && [...o.children].forEach((C) => s(C, f)), gt(o, e), vt(o, e), v && !Fn(o)) {
|
|
1262
|
+
if (G(f))
|
|
1263
|
+
f(o);
|
|
1236
1264
|
else if (G(o.dispose))
|
|
1237
1265
|
try {
|
|
1238
1266
|
o.dispose();
|
|
@@ -1241,66 +1269,66 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1241
1269
|
}
|
|
1242
1270
|
"__tres" in o && delete o.__tres;
|
|
1243
1271
|
}
|
|
1244
|
-
function l(o,
|
|
1245
|
-
var
|
|
1272
|
+
function l(o, f, y, u) {
|
|
1273
|
+
var C, E;
|
|
1246
1274
|
if (!o)
|
|
1247
1275
|
return;
|
|
1248
|
-
let
|
|
1249
|
-
if (o.__tres && (o.__tres.memoizedProps[
|
|
1250
|
-
const
|
|
1251
|
-
s(o), z(o, { attach:
|
|
1276
|
+
let v = o, h = f;
|
|
1277
|
+
if (o.__tres && (o.__tres.memoizedProps[f] = u), f === "attach") {
|
|
1278
|
+
const T = ((C = o.__tres) == null ? void 0 : C.parent) || o.parent;
|
|
1279
|
+
s(o), z(o, { attach: u }, e), T && r(o, T);
|
|
1252
1280
|
return;
|
|
1253
1281
|
}
|
|
1254
|
-
if (
|
|
1255
|
-
o.__tres || (o = z(o, {}, e)), o.__tres.dispose =
|
|
1282
|
+
if (f === "dispose") {
|
|
1283
|
+
o.__tres || (o = z(o, {}, e)), o.__tres.dispose = u;
|
|
1256
1284
|
return;
|
|
1257
1285
|
}
|
|
1258
1286
|
if (N(o) && h === "blocks-pointer-events") {
|
|
1259
|
-
|
|
1287
|
+
u || u === "" ? o[h] = u : delete o[h];
|
|
1260
1288
|
return;
|
|
1261
1289
|
}
|
|
1262
|
-
|
|
1263
|
-
let
|
|
1290
|
+
Ze.includes(f) && o.__tres && (o.__tres.eventCount += 1);
|
|
1291
|
+
let g = oe(h), p = v == null ? void 0 : v[g];
|
|
1264
1292
|
if (h === "args") {
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
new
|
|
1293
|
+
const T = o, b = y ?? [], P = u ?? [], M = ((E = o.__tres) == null ? void 0 : E.type) || o.type;
|
|
1294
|
+
M && b.length && !Jn(b, P) && (v = Object.assign(
|
|
1295
|
+
T,
|
|
1296
|
+
new Ce.value[M](...u)
|
|
1269
1297
|
));
|
|
1270
1298
|
return;
|
|
1271
1299
|
}
|
|
1272
|
-
if (
|
|
1300
|
+
if (v.type === "BufferGeometry") {
|
|
1273
1301
|
if (h === "args")
|
|
1274
1302
|
return;
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
new
|
|
1303
|
+
v.setAttribute(
|
|
1304
|
+
oe(h),
|
|
1305
|
+
new Gt(...u)
|
|
1278
1306
|
);
|
|
1279
1307
|
return;
|
|
1280
1308
|
}
|
|
1281
|
-
if (h.includes("-") &&
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1309
|
+
if (h.includes("-") && p === void 0) {
|
|
1310
|
+
const T = h.split("-");
|
|
1311
|
+
p = T.reduce((b, P) => b[oe(P)], v), h = T.pop(), g = h, p != null && p.set || (v = T.reduce((b, P) => b[oe(P)], v));
|
|
1284
1312
|
}
|
|
1285
|
-
let
|
|
1286
|
-
if (
|
|
1287
|
-
|
|
1313
|
+
let _ = u;
|
|
1314
|
+
if (_ === "" && (_ = !0), G(p)) {
|
|
1315
|
+
Ze.includes(f) || (pe(_) ? o[g](..._) : o[g](_)), g.startsWith("on") && G(_) && (v[g] = _);
|
|
1288
1316
|
return;
|
|
1289
1317
|
}
|
|
1290
|
-
!(
|
|
1318
|
+
!(p != null && p.set) && !G(p) ? v[g] = _ : p.constructor === _.constructor && (p != null && p.copy) ? p == null || p.copy(_) : pe(_) ? p.set(..._) : !p.isColor && p.setScalar ? p.setScalar(_) : p.set(_), ht(o);
|
|
1291
1319
|
}
|
|
1292
1320
|
function i(o) {
|
|
1293
|
-
var
|
|
1294
|
-
return ((
|
|
1321
|
+
var f;
|
|
1322
|
+
return ((f = o == null ? void 0 : o.__tres) == null ? void 0 : f.parent) || null;
|
|
1295
1323
|
}
|
|
1296
1324
|
function a(o) {
|
|
1297
|
-
const
|
|
1298
|
-
return
|
|
1325
|
+
const f = z(new Vt(), { type: "Comment" }, e);
|
|
1326
|
+
return f.name = o, f;
|
|
1299
1327
|
}
|
|
1300
1328
|
function c(o) {
|
|
1301
|
-
var
|
|
1302
|
-
const
|
|
1303
|
-
return
|
|
1329
|
+
var v;
|
|
1330
|
+
const f = i(o), y = ((v = f == null ? void 0 : f.__tres) == null ? void 0 : v.objects) || [], u = y.indexOf(o);
|
|
1331
|
+
return u < 0 || u >= y.length - 1 ? null : y[u + 1];
|
|
1304
1332
|
}
|
|
1305
1333
|
return {
|
|
1306
1334
|
insert: r,
|
|
@@ -1319,22 +1347,22 @@ const { logError: Ke } = Y(), Qe = [
|
|
|
1319
1347
|
insertStaticContent: () => void 0
|
|
1320
1348
|
};
|
|
1321
1349
|
};
|
|
1322
|
-
function
|
|
1323
|
-
return
|
|
1350
|
+
function Tr() {
|
|
1351
|
+
return bt().__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
|
1324
1352
|
}
|
|
1325
|
-
function
|
|
1353
|
+
function bt() {
|
|
1326
1354
|
return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
|
|
1327
1355
|
}
|
|
1328
|
-
const
|
|
1329
|
-
let q,
|
|
1330
|
-
function
|
|
1356
|
+
const Sr = typeof Proxy == "function", xr = "devtools-plugin:setup", Ar = "plugin:settings:set";
|
|
1357
|
+
let q, Te;
|
|
1358
|
+
function kr() {
|
|
1331
1359
|
var e;
|
|
1332
|
-
return q !== void 0 || (typeof window < "u" && window.performance ? (q = !0,
|
|
1360
|
+
return q !== void 0 || (typeof window < "u" && window.performance ? (q = !0, Te = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (q = !0, Te = globalThis.perf_hooks.performance) : q = !1), q;
|
|
1333
1361
|
}
|
|
1334
|
-
function
|
|
1335
|
-
return
|
|
1362
|
+
function Lr() {
|
|
1363
|
+
return kr() ? Te.now() : Date.now();
|
|
1336
1364
|
}
|
|
1337
|
-
class
|
|
1365
|
+
class Or {
|
|
1338
1366
|
constructor(t, n) {
|
|
1339
1367
|
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;
|
|
1340
1368
|
const r = {};
|
|
@@ -1362,9 +1390,9 @@ class Pr {
|
|
|
1362
1390
|
l = i;
|
|
1363
1391
|
},
|
|
1364
1392
|
now() {
|
|
1365
|
-
return
|
|
1393
|
+
return Lr();
|
|
1366
1394
|
}
|
|
1367
|
-
}, n && n.on(
|
|
1395
|
+
}, n && n.on(Ar, (i, a) => {
|
|
1368
1396
|
i === this.plugin.id && this.fallbacks.setSettings(a);
|
|
1369
1397
|
}), this.proxiedOn = new Proxy({}, {
|
|
1370
1398
|
get: (i, a) => this.target ? this.target.on[a] : (...c) => {
|
|
@@ -1396,12 +1424,12 @@ class Pr {
|
|
|
1396
1424
|
n.resolve(await this.target[n.method](...n.args));
|
|
1397
1425
|
}
|
|
1398
1426
|
}
|
|
1399
|
-
function
|
|
1400
|
-
const n = e, r =
|
|
1427
|
+
function Rr(e, t) {
|
|
1428
|
+
const n = e, r = bt(), s = Tr(), l = Sr && n.enableEarlyProxy;
|
|
1401
1429
|
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l))
|
|
1402
|
-
s.emit(
|
|
1430
|
+
s.emit(xr, e, t);
|
|
1403
1431
|
else {
|
|
1404
|
-
const i = l ? new
|
|
1432
|
+
const i = l ? new Or(n, s) : null;
|
|
1405
1433
|
(r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({
|
|
1406
1434
|
pluginDescriptor: n,
|
|
1407
1435
|
setupFn: t,
|
|
@@ -1409,14 +1437,14 @@ function Er(e, t) {
|
|
|
1409
1437
|
}), i && t(i.proxiedTarget);
|
|
1410
1438
|
}
|
|
1411
1439
|
}
|
|
1412
|
-
function
|
|
1440
|
+
function Dr(e, t) {
|
|
1413
1441
|
const n = `▲ ■ ●${e}`;
|
|
1414
|
-
typeof
|
|
1442
|
+
typeof et == "function" ? et(n, t) : console.log(n);
|
|
1415
1443
|
}
|
|
1416
|
-
function
|
|
1444
|
+
function et(e, t) {
|
|
1417
1445
|
throw new Error(e + t);
|
|
1418
1446
|
}
|
|
1419
|
-
const
|
|
1447
|
+
const Mt = (e) => {
|
|
1420
1448
|
const t = {
|
|
1421
1449
|
id: e.uuid,
|
|
1422
1450
|
label: e.type,
|
|
@@ -1428,13 +1456,13 @@ const yt = (e) => {
|
|
|
1428
1456
|
textColor: 5750629,
|
|
1429
1457
|
backgroundColor: 15793395
|
|
1430
1458
|
});
|
|
1431
|
-
const n =
|
|
1459
|
+
const n = ke(e);
|
|
1432
1460
|
return n > 0 && t.tags.push({
|
|
1433
|
-
label: `${
|
|
1461
|
+
label: `${dr(n)} KB`,
|
|
1434
1462
|
textColor: 15707189,
|
|
1435
1463
|
backgroundColor: 16775644,
|
|
1436
1464
|
tooltip: "Memory usage"
|
|
1437
|
-
}), e.type.includes("Light") && (
|
|
1465
|
+
}), e.type.includes("Light") && (Hn(e) && t.tags.push({
|
|
1438
1466
|
label: `${e.intensity}`,
|
|
1439
1467
|
textColor: 9738662,
|
|
1440
1468
|
backgroundColor: 16316922,
|
|
@@ -1456,30 +1484,30 @@ const yt = (e) => {
|
|
|
1456
1484
|
tooltip: "Position"
|
|
1457
1485
|
})), t;
|
|
1458
1486
|
};
|
|
1459
|
-
function
|
|
1487
|
+
function Pt(e, t, n = "") {
|
|
1460
1488
|
e.children.forEach((r) => {
|
|
1461
1489
|
if (r.type === "HightlightMesh" || n && !r.type.includes(n) && !r.name.includes(n))
|
|
1462
1490
|
return;
|
|
1463
|
-
const s =
|
|
1464
|
-
t.children.push(s),
|
|
1491
|
+
const s = Mt(r);
|
|
1492
|
+
t.children.push(s), Pt(r, s, n);
|
|
1465
1493
|
});
|
|
1466
1494
|
}
|
|
1467
|
-
const
|
|
1495
|
+
const jr = [], X = "tres:inspector", Br = Se({
|
|
1468
1496
|
sceneGraph: null
|
|
1469
1497
|
});
|
|
1470
|
-
function
|
|
1471
|
-
|
|
1498
|
+
function Ir(e, t) {
|
|
1499
|
+
Rr(
|
|
1472
1500
|
{
|
|
1473
1501
|
id: "dev.esm.tres",
|
|
1474
1502
|
label: "TresJS 🪐",
|
|
1475
1503
|
logo: "https://raw.githubusercontent.com/Tresjs/tres/main/public/favicon.svg",
|
|
1476
1504
|
packageName: "tresjs",
|
|
1477
1505
|
homepage: "https://tresjs.org",
|
|
1478
|
-
componentStateTypes:
|
|
1506
|
+
componentStateTypes: jr,
|
|
1479
1507
|
app: e
|
|
1480
1508
|
},
|
|
1481
1509
|
(n) => {
|
|
1482
|
-
typeof n.now != "function" &&
|
|
1510
|
+
typeof n.now != "function" && Dr(
|
|
1483
1511
|
"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."
|
|
1484
1512
|
), n.addInspector({
|
|
1485
1513
|
id: X,
|
|
@@ -1492,8 +1520,8 @@ function xr(e, t) {
|
|
|
1492
1520
|
n.notifyComponentUpdate();
|
|
1493
1521
|
}, 5e3), n.on.getInspectorTree((l) => {
|
|
1494
1522
|
if (l.inspectorId === X) {
|
|
1495
|
-
const i =
|
|
1496
|
-
|
|
1523
|
+
const i = Mt(t.scene.value);
|
|
1524
|
+
Pt(t.scene.value, i, l.filter), Br.sceneGraph = i, l.rootNodes = [i];
|
|
1497
1525
|
}
|
|
1498
1526
|
});
|
|
1499
1527
|
let r = null, s = null;
|
|
@@ -1508,10 +1536,10 @@ function xr(e, t) {
|
|
|
1508
1536
|
a.add(c), r = c, s = a;
|
|
1509
1537
|
}
|
|
1510
1538
|
l.state = {
|
|
1511
|
-
object: Object.entries(a).map(([c, o]) => c === "children" ? { key: c, value: o.filter((
|
|
1539
|
+
object: Object.entries(a).map(([c, o]) => c === "children" ? { key: c, value: o.filter((f) => f.type !== "HightlightMesh") } : { key: c, value: o, editable: !0 }).filter(({ key: c }) => c !== "parent")
|
|
1512
1540
|
}, a.isScene && (l.state.info = {
|
|
1513
|
-
memory: xe(a),
|
|
1514
1541
|
objects: a.children.length,
|
|
1542
|
+
memory: ke(a),
|
|
1515
1543
|
calls: t.renderer.value.info.render.calls,
|
|
1516
1544
|
triangles: t.renderer.value.info.render.triangles,
|
|
1517
1545
|
points: t.renderer.value.info.render.points,
|
|
@@ -1532,7 +1560,7 @@ function xr(e, t) {
|
|
|
1532
1560
|
}
|
|
1533
1561
|
);
|
|
1534
1562
|
}
|
|
1535
|
-
const
|
|
1563
|
+
const $r = ["data-scene", "data-tres"], Hr = /* @__PURE__ */ fe({
|
|
1536
1564
|
__name: "TresCanvas",
|
|
1537
1565
|
props: {
|
|
1538
1566
|
shadows: { type: Boolean, default: void 0 },
|
|
@@ -1547,7 +1575,7 @@ const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
|
|
|
1547
1575
|
camera: {},
|
|
1548
1576
|
preset: {},
|
|
1549
1577
|
windowSize: { type: Boolean, default: void 0 },
|
|
1550
|
-
|
|
1578
|
+
enableProvideBridge: { type: Boolean, default: !0 },
|
|
1551
1579
|
context: {},
|
|
1552
1580
|
precision: {},
|
|
1553
1581
|
alpha: { type: Boolean, default: void 0 },
|
|
@@ -1577,108 +1605,128 @@ const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
|
|
|
1577
1605
|
"ready"
|
|
1578
1606
|
],
|
|
1579
1607
|
setup(e, { expose: t, emit: n }) {
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
const u = (f, M = !1) => Be({
|
|
1608
|
+
const r = e, s = n, l = At(), { logWarning: i } = V(), a = I(), c = $(new st()), o = He();
|
|
1609
|
+
Ee(ot);
|
|
1610
|
+
const f = (g, p = !1) => fe({
|
|
1584
1611
|
setup() {
|
|
1585
|
-
var
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1612
|
+
var T;
|
|
1613
|
+
const _ = (T = He()) == null ? void 0 : T.appContext;
|
|
1614
|
+
_ && (_.app = o == null ? void 0 : o.appContext.app);
|
|
1615
|
+
const C = {};
|
|
1616
|
+
function E(b) {
|
|
1617
|
+
b && (b.parent && E(b.parent), b.provides && Object.assign(C, b.provides));
|
|
1618
|
+
}
|
|
1619
|
+
return o != null && o.parent && r.enableProvideBridge && (E(o.parent), Object.entries(C).forEach(([b, P]) => {
|
|
1620
|
+
le(b, P);
|
|
1621
|
+
})), le("useTres", g), le("extend", Ee), typeof window < "u" && Ir(_ == null ? void 0 : _.app, g), () => Ue(Bt, null, p ? [] : l.default());
|
|
1588
1622
|
}
|
|
1589
|
-
}),
|
|
1590
|
-
const
|
|
1591
|
-
C(
|
|
1592
|
-
},
|
|
1593
|
-
|
|
1594
|
-
root:
|
|
1623
|
+
}), y = (g, p = !1) => {
|
|
1624
|
+
const _ = f(g, p), { render: C } = jt(Er(g));
|
|
1625
|
+
C(Ue(_), c.value);
|
|
1626
|
+
}, u = (g, p = !1) => {
|
|
1627
|
+
mt(g.scene.value), p && (g.renderer.value.dispose(), g.renderer.value.renderLists.dispose(), g.renderer.value.forceContextLoss()), c.value.__tres = {
|
|
1628
|
+
root: g
|
|
1595
1629
|
};
|
|
1596
|
-
},
|
|
1597
|
-
t({ context:
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1630
|
+
}, v = $(null);
|
|
1631
|
+
t({ context: v, dispose: () => u(v.value, !0) });
|
|
1632
|
+
const h = () => {
|
|
1633
|
+
u(v.value), y(v.value, !0);
|
|
1600
1634
|
};
|
|
1601
|
-
return
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1635
|
+
return kt(() => {
|
|
1636
|
+
const g = a;
|
|
1637
|
+
v.value = br({
|
|
1604
1638
|
scene: c.value,
|
|
1605
|
-
canvas:
|
|
1639
|
+
canvas: g,
|
|
1606
1640
|
windowSize: r.windowSize ?? !1,
|
|
1607
|
-
disableRender: g.value ?? !1,
|
|
1608
1641
|
rendererOptions: r,
|
|
1609
1642
|
emit: s
|
|
1610
1643
|
});
|
|
1611
|
-
const { registerCamera:
|
|
1612
|
-
v
|
|
1613
|
-
const
|
|
1614
|
-
const
|
|
1644
|
+
const { registerCamera: p, camera: _, cameras: C, deregisterCamera: E } = v.value;
|
|
1645
|
+
y(v.value);
|
|
1646
|
+
const T = () => {
|
|
1647
|
+
const b = new be(
|
|
1615
1648
|
45,
|
|
1616
1649
|
window.innerWidth / window.innerHeight,
|
|
1617
1650
|
0.1,
|
|
1618
1651
|
1e3
|
|
1619
1652
|
);
|
|
1620
|
-
|
|
1621
|
-
const
|
|
1622
|
-
C.value.length >= 2 && (
|
|
1653
|
+
b.position.set(3, 3, 3), b.lookAt(0, 0, 0), p(b);
|
|
1654
|
+
const P = xe(() => {
|
|
1655
|
+
C.value.length >= 2 && (b.removeFromParent(), E(b), P == null || P());
|
|
1623
1656
|
});
|
|
1624
1657
|
};
|
|
1625
|
-
|
|
1658
|
+
ae(
|
|
1626
1659
|
() => r.camera,
|
|
1627
|
-
(
|
|
1628
|
-
|
|
1660
|
+
(b, P) => {
|
|
1661
|
+
b && p(b), P && (P.removeFromParent(), E(P));
|
|
1629
1662
|
},
|
|
1630
1663
|
{
|
|
1631
1664
|
immediate: !0
|
|
1632
1665
|
}
|
|
1633
|
-
),
|
|
1666
|
+
), _.value || (i(
|
|
1634
1667
|
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
|
|
1635
|
-
),
|
|
1636
|
-
}), K(
|
|
1668
|
+
), T());
|
|
1669
|
+
}), K(h), (g, p) => (Lt(), Ot("canvas", {
|
|
1637
1670
|
ref_key: "canvas",
|
|
1638
1671
|
ref: a,
|
|
1639
1672
|
"data-scene": c.value.uuid,
|
|
1640
|
-
class:
|
|
1641
|
-
"data-tres": `tresjs ${
|
|
1642
|
-
style:
|
|
1673
|
+
class: Rt(g.$attrs.class),
|
|
1674
|
+
"data-tres": `tresjs ${W(On).version}`,
|
|
1675
|
+
style: Dt({
|
|
1643
1676
|
display: "block",
|
|
1644
1677
|
width: "100%",
|
|
1645
1678
|
height: "100%",
|
|
1646
|
-
position:
|
|
1679
|
+
position: g.windowSize ? "fixed" : "relative",
|
|
1647
1680
|
top: 0,
|
|
1648
1681
|
left: 0,
|
|
1649
1682
|
pointerEvents: "auto",
|
|
1650
1683
|
touchAction: "none",
|
|
1651
|
-
...
|
|
1684
|
+
...g.$attrs.style
|
|
1652
1685
|
})
|
|
1653
|
-
}, null, 14,
|
|
1686
|
+
}, null, 14, $r));
|
|
1654
1687
|
}
|
|
1655
|
-
}),
|
|
1688
|
+
}), Ur = [
|
|
1656
1689
|
"TresCanvas",
|
|
1657
1690
|
"TresLeches",
|
|
1658
1691
|
"TresScene"
|
|
1659
|
-
],
|
|
1692
|
+
], Fr = {
|
|
1660
1693
|
template: {
|
|
1661
1694
|
compilerOptions: {
|
|
1662
|
-
isCustomElement: (e) => e.startsWith("Tres") && !
|
|
1695
|
+
isCustomElement: (e) => e.startsWith("Tres") && !Ur.includes(e) || e === "primitive"
|
|
1663
1696
|
}
|
|
1664
1697
|
}
|
|
1665
|
-
},
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1698
|
+
}, ro = Fr, { logWarning: Wr } = V();
|
|
1699
|
+
let B = null;
|
|
1700
|
+
const oo = {
|
|
1701
|
+
updated: (e, t) => {
|
|
1702
|
+
var s;
|
|
1703
|
+
const n = Zn(t);
|
|
1704
|
+
if (!n) {
|
|
1705
|
+
Wr(`v-distance-to: problem with binding value: ${t.value}`);
|
|
1669
1706
|
return;
|
|
1670
1707
|
}
|
|
1671
|
-
|
|
1708
|
+
B && (B.dispose(), e.parent.remove(B));
|
|
1709
|
+
const r = n.clone().sub(e.position);
|
|
1710
|
+
r.normalize(), B = new Yt(r, e.position, e.position.distanceTo(n), 16776960), e.parent.add(B), console.table(
|
|
1711
|
+
[
|
|
1712
|
+
["Distance:", e.position.distanceTo(n)],
|
|
1713
|
+
[`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(s = e.position) == null ? void 0 : s.z}`],
|
|
1714
|
+
[`Destiny: ${e.name || e.type}`, `x:${n.x}, y:${n.y}, z:${n == null ? void 0 : n.z}`]
|
|
1715
|
+
]
|
|
1716
|
+
);
|
|
1717
|
+
},
|
|
1718
|
+
unmounted: (e) => {
|
|
1719
|
+
B == null || B.dispose(), e.parent.remove(B);
|
|
1672
1720
|
}
|
|
1673
1721
|
};
|
|
1674
|
-
class
|
|
1722
|
+
class Ct extends qt {
|
|
1675
1723
|
constructor(t, n) {
|
|
1676
|
-
const r = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new
|
|
1677
|
-
s.setAttribute("position", new
|
|
1678
|
-
const l = new
|
|
1724
|
+
const r = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new Fe();
|
|
1725
|
+
s.setAttribute("position", new We(r, 3)), s.computeBoundingSphere();
|
|
1726
|
+
const l = new Jt({ fog: !1 });
|
|
1679
1727
|
super(s, l), this.light = t, this.color = n, this.type = "RectAreaLightHelper";
|
|
1680
|
-
const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new
|
|
1681
|
-
a.setAttribute("position", new
|
|
1728
|
+
const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new Fe();
|
|
1729
|
+
a.setAttribute("position", new We(i, 3)), a.computeBoundingSphere(), this.add(new Kt(a, new at({ side: Qt, fog: !1 })));
|
|
1682
1730
|
}
|
|
1683
1731
|
updateMatrixWorld() {
|
|
1684
1732
|
if (this.scale.set(0.5 * this.light.width, 0.5 * this.light.height, 1), this.color !== void 0)
|
|
@@ -1694,87 +1742,74 @@ class wt extends zt {
|
|
|
1694
1742
|
this.geometry.dispose(), this.material.dispose(), this.children[0].geometry.dispose(), this.children[0].material.dispose();
|
|
1695
1743
|
}
|
|
1696
1744
|
}
|
|
1697
|
-
const { logWarning:
|
|
1698
|
-
let
|
|
1699
|
-
const
|
|
1700
|
-
DirectionalLight:
|
|
1701
|
-
PointLight:
|
|
1702
|
-
SpotLight:
|
|
1703
|
-
HemisphereLight:
|
|
1704
|
-
RectAreaLight:
|
|
1705
|
-
},
|
|
1745
|
+
const { logWarning: tt } = V();
|
|
1746
|
+
let ie, F;
|
|
1747
|
+
const Nr = {
|
|
1748
|
+
DirectionalLight: Xt,
|
|
1749
|
+
PointLight: Zt,
|
|
1750
|
+
SpotLight: en,
|
|
1751
|
+
HemisphereLight: tn,
|
|
1752
|
+
RectAreaLight: Ct
|
|
1753
|
+
}, so = {
|
|
1706
1754
|
mounted: (e) => {
|
|
1707
1755
|
if (!e.isLight) {
|
|
1708
|
-
|
|
1756
|
+
tt(`${e.type} is not a light`);
|
|
1709
1757
|
return;
|
|
1710
1758
|
}
|
|
1711
|
-
|
|
1759
|
+
ie = Nr[e.type], e.parent.add(new ie(e, 1, e.color.getHex()));
|
|
1712
1760
|
},
|
|
1713
1761
|
updated: (e) => {
|
|
1714
|
-
|
|
1762
|
+
F = e.parent.children.find((t) => t instanceof ie), !(F instanceof Ct) && F.update();
|
|
1715
1763
|
},
|
|
1716
1764
|
unmounted: (e) => {
|
|
1717
1765
|
if (!e.isLight) {
|
|
1718
|
-
|
|
1766
|
+
tt(`${e.type} is not a light`);
|
|
1719
1767
|
return;
|
|
1720
1768
|
}
|
|
1721
|
-
|
|
1769
|
+
F = e.parent.children.find((t) => t instanceof ie), F && F.dispose && F.dispose(), e.parent.remove(F);
|
|
1722
1770
|
}
|
|
1723
|
-
},
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
var s;
|
|
1728
|
-
const n = Zn(t);
|
|
1729
|
-
if (!n) {
|
|
1730
|
-
jr(`v-distance-to: problem with binding value: ${t.value}`);
|
|
1771
|
+
}, io = {
|
|
1772
|
+
mounted: (e, t) => {
|
|
1773
|
+
if (t.arg) {
|
|
1774
|
+
console.log(`v-log:${t.arg}`, e[t.arg]);
|
|
1731
1775
|
return;
|
|
1732
1776
|
}
|
|
1733
|
-
|
|
1734
|
-
const r = n.clone().sub(e.position);
|
|
1735
|
-
r.normalize(), I = new Xt(r, e.position, e.position.distanceTo(n), 16776960), e.parent.add(I), console.table(
|
|
1736
|
-
[
|
|
1737
|
-
["Distance:", e.position.distanceTo(n)],
|
|
1738
|
-
[`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(s = e.position) == null ? void 0 : s.z}`],
|
|
1739
|
-
[`Destiny: ${e.name || e.type}`, `x:${n.x}, y:${n.y}, z:${n == null ? void 0 : n.z}`]
|
|
1740
|
-
]
|
|
1741
|
-
);
|
|
1742
|
-
},
|
|
1743
|
-
unmounted: (e) => {
|
|
1744
|
-
I == null || I.dispose(), e.parent.remove(I);
|
|
1777
|
+
console.log("v-log", e);
|
|
1745
1778
|
}
|
|
1746
|
-
},
|
|
1779
|
+
}, ao = {
|
|
1747
1780
|
install(e) {
|
|
1748
|
-
e.component("TresCanvas",
|
|
1781
|
+
e.component("TresCanvas", Hr);
|
|
1749
1782
|
}
|
|
1750
1783
|
};
|
|
1751
1784
|
export {
|
|
1752
|
-
|
|
1753
|
-
|
|
1785
|
+
Hr as TresCanvas,
|
|
1786
|
+
qr as UseLoader,
|
|
1787
|
+
Jr as UseTexture,
|
|
1788
|
+
Ce as catalogue,
|
|
1754
1789
|
pr as createRenderLoop,
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1790
|
+
ao as default,
|
|
1791
|
+
mt as dispose,
|
|
1792
|
+
Ee as extend,
|
|
1793
|
+
Kr as isProd,
|
|
1794
|
+
hr as normalizeColor,
|
|
1795
|
+
Qr as normalizeVectorFlexibleParam,
|
|
1796
|
+
Xr as onTresReady,
|
|
1797
|
+
ro as templateCompilerOptions,
|
|
1798
|
+
Rn as trasverseObjects,
|
|
1799
|
+
ar as useCamera,
|
|
1800
|
+
Dn as useLoader,
|
|
1801
|
+
V as useLogger,
|
|
1802
|
+
eo as useLoop,
|
|
1803
|
+
yr as useRaycaster,
|
|
1804
|
+
to as useRenderLoop,
|
|
1805
|
+
gr as useRenderer,
|
|
1806
|
+
no as useSeek,
|
|
1807
|
+
ir as useTexture,
|
|
1808
|
+
Zr as useTres,
|
|
1809
|
+
me as useTresContext,
|
|
1810
|
+
br as useTresContextProvider,
|
|
1811
|
+
_r as useTresEventManager,
|
|
1812
|
+
oo as vDistanceTo,
|
|
1813
|
+
so as vLightHelper,
|
|
1814
|
+
io as vLog
|
|
1780
1815
|
};
|