@tresjs/core
Advanced tools
Comparing version 4.0.0-next.1 to 4.0.0-next.2
1500
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v4.0.0-next.1 | ||
* version: v4.0.0-next.2 | ||
* (c) 2024 | ||
@@ -8,10 +8,10 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
var He = Object.defineProperty; | ||
var Ne = (t, e, r) => e in t ? He(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; | ||
var Y = (t, e, r) => (Ne(t, typeof e != "symbol" ? e + "" : e, r), r); | ||
import { ref as T, computed as x, watchEffect as se, onUnmounted as J, shallowRef as $, watch as I, reactive as be, readonly as Z, provide as ee, inject as Fe, defineComponent as le, useSlots as We, getCurrentInstance as ue, onMounted as Ue, openBlock as Ge, createElementBlock as ze, normalizeClass as Ve, unref as Je, normalizeStyle as Qe, createRenderer as Ye, h as ce, Fragment as qe } from "vue"; | ||
var $e = Object.defineProperty; | ||
var He = (e, r, t) => r in e ? $e(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t; | ||
var Y = (e, r, t) => (He(e, typeof r != "symbol" ? r + "" : r, t), t); | ||
import { ref as k, computed as x, watchEffect as se, onUnmounted as J, shallowRef as $, watch as I, reactive as be, readonly as Z, provide as ee, inject as Ne, defineComponent as le, useSlots as Fe, getCurrentInstance as ue, onMounted as We, openBlock as Ue, createElementBlock as Ge, normalizeClass as ze, unref as Ve, normalizeStyle as Je, createRenderer as Qe, h as ce, Fragment as Ye } from "vue"; | ||
import * as Me from "three"; | ||
import { PerspectiveCamera as te, Camera as Ke, Clock as Xe, Vector3 as _e, Color as G, MeshBasicMaterial as Ee, DoubleSide as Ze, REVISION as et, SRGBColorSpace as tt, ACESFilmicToneMapping as Ce, PCFSoftShadowMap as rt, NoToneMapping as nt, WebGLRenderer as q, LoadingManager as ot, TextureLoader as st, Vector2 as it, Raycaster as at, BufferAttribute as lt, Scene as ut, Line as ct, BufferGeometry as de, Float32BufferAttribute as fe, LineBasicMaterial as dt, Mesh as ft, BackSide as pt, DirectionalLightHelper as mt, PointLightHelper as vt, SpotLightHelper as gt, HemisphereLightHelper as ht, ArrowHelper as yt } from "three"; | ||
import { createEventHook as H, useRafFn as Se, toValue as M, unrefElement as wt, useDevicePixelRatio as bt, usePointer as Mt, useElementBounding as _t, useWindowSize as Et, useElementSize as Ct, refDebounced as pe, useFps as St, useMemory as xt } from "@vueuse/core"; | ||
const kt = "@tresjs/core", Tt = "module", Pt = "4.0.0-next.1", At = "pnpm@8.10.2", Lt = "Declarative ThreeJS using Vue Components", Ot = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", Bt = "MIT", jt = [ | ||
import { PerspectiveCamera as te, Camera as qe, Clock as Ke, Vector3 as _e, Color as G, MeshBasicMaterial as Ce, DoubleSide as Xe, REVISION as Ze, SRGBColorSpace as et, ACESFilmicToneMapping as Ee, PCFSoftShadowMap as tt, NoToneMapping as nt, WebGLRenderer as q, LoadingManager as rt, TextureLoader as ot, Vector2 as st, Raycaster as it, BufferAttribute as at, Scene as lt, Line as ut, BufferGeometry as de, Float32BufferAttribute as fe, LineBasicMaterial as ct, Mesh as dt, BackSide as ft, DirectionalLightHelper as pt, PointLightHelper as mt, SpotLightHelper as vt, HemisphereLightHelper as gt, ArrowHelper as ht } from "three"; | ||
import { createEventHook as H, useRafFn as Se, toValue as _, unrefElement as yt, useDevicePixelRatio as wt, usePointer as bt, useElementBounding as Mt, useWindowSize as _t, useElementSize as Ct, refDebounced as pe, useFps as Et, useMemory as St } from "@vueuse/core"; | ||
const xt = "@tresjs/core", Tt = "module", kt = "4.0.0-next.2", Pt = "pnpm@8.10.2", At = "Declarative ThreeJS using Vue Components", Lt = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", Ot = "MIT", Bt = [ | ||
"vue", | ||
@@ -22,3 +22,3 @@ "3d", | ||
"threejs-vue" | ||
], Dt = !1, It = { | ||
], jt = !1, Dt = { | ||
".": { | ||
@@ -42,8 +42,8 @@ types: "./dist/index.d.ts", | ||
"./*": "./*" | ||
}, Rt = "./dist/tres.js", $t = "./dist/tres.js", Ht = "./dist/index.d.ts", Nt = [ | ||
}, It = "./dist/tres.js", Rt = "./dist/tres.js", $t = "./dist/index.d.ts", Ht = [ | ||
"dist", | ||
"*.d.ts" | ||
], Ft = { | ||
], Nt = { | ||
access: "public" | ||
}, Wt = { | ||
}, Ft = { | ||
dev: "cd playground && npm run dev", | ||
@@ -63,102 +63,103 @@ build: "vite build", | ||
"docs:contributors": "esno scripts/update-contributors.ts" | ||
}, Ut = { | ||
}, Wt = { | ||
three: ">=0.133", | ||
vue: ">=3.4" | ||
}, Ut = { | ||
"@alvarosabu/utils": "^3.2.0", | ||
"@vue/devtools-api": "^6.6.1", | ||
"@vueuse/core": "^10.9.0" | ||
}, Gt = { | ||
"@alvarosabu/utils": "^3.1.1", | ||
"@vueuse/core": "^10.7.1" | ||
}, zt = { | ||
"@release-it/conventional-changelog": "^8.0.1", | ||
"@stackblitz/sdk": "^1.9.0", | ||
"@tresjs/cientos": "3.7.0", | ||
"@tresjs/cientos": "3.8.0", | ||
"@tresjs/eslint-config-vue": "^0.2.1", | ||
"@types/three": "^0.160.0", | ||
"@typescript-eslint/eslint-plugin": "^6.17.0", | ||
"@typescript-eslint/parser": "^6.17.0", | ||
"@vitejs/plugin-vue": "^5.0.2", | ||
"@types/three": "^0.162.0", | ||
"@typescript-eslint/eslint-plugin": "^7.4.0", | ||
"@typescript-eslint/parser": "^7.4.0", | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"@vitest/ui": "^1.1.1", | ||
"@vue/test-utils": "^2.4.3", | ||
eslint: "^8.56.0", | ||
"eslint-plugin-vue": "^9.19.2", | ||
esno: "^4.0.0", | ||
gsap: "^3.12.4", | ||
jsdom: "^23.0.1", | ||
"@vitest/ui": "^1.4.0", | ||
"@vue/test-utils": "^2.4.5", | ||
eslint: "^8.57.0", | ||
"eslint-plugin-vue": "^9.24.0", | ||
esno: "^4.7.0", | ||
gsap: "^3.12.5", | ||
jsdom: "^24.0.0", | ||
kolorist: "^1.8.0", | ||
ohmyfetch: "^0.4.21", | ||
pathe: "^1.1.1", | ||
"release-it": "^17.0.1", | ||
pathe: "^1.1.2", | ||
"release-it": "^17.1.1", | ||
"rollup-plugin-analyzer": "^4.0.0", | ||
"rollup-plugin-copy": "^3.5.0", | ||
"rollup-plugin-visualizer": "^5.12.0", | ||
three: "^0.160.0", | ||
unocss: "^0.58.3", | ||
unplugin: "^1.6.0", | ||
three: "^0.162.0", | ||
unocss: "^0.58.7", | ||
unplugin: "^1.10.0", | ||
"unplugin-vue-components": "^0.26.0", | ||
vite: "^5.0.10", | ||
vite: "^5.2.6", | ||
"vite-plugin-banner": "^0.7.1", | ||
"vite-plugin-dts": "3.7.0", | ||
"vite-plugin-inspect": "^0.8.1", | ||
"vite-plugin-dts": "3.7.3", | ||
"vite-plugin-inspect": "^0.8.3", | ||
"vite-plugin-require-transform": "^1.0.21", | ||
"vite-svg-loader": "^5.1.0", | ||
vitepress: "1.0.0-rc.34", | ||
vitest: "^1.1.1", | ||
vue: "^3.4.3", | ||
"vue-demi": "^0.14.6" | ||
}, Vt = { | ||
name: kt, | ||
vitepress: "1.0.1", | ||
vitest: "^1.4.0", | ||
vue: "^3.4.21", | ||
"vue-demi": "^0.14.7" | ||
}, zt = { | ||
name: xt, | ||
type: Tt, | ||
version: Pt, | ||
packageManager: At, | ||
description: Lt, | ||
author: Ot, | ||
license: Bt, | ||
keywords: jt, | ||
sideEffects: Dt, | ||
exports: It, | ||
main: Rt, | ||
module: $t, | ||
types: Ht, | ||
files: Nt, | ||
publishConfig: Ft, | ||
scripts: Wt, | ||
peerDependencies: Ut, | ||
dependencies: Gt, | ||
devDependencies: zt | ||
}, Jt = ({ sizes: t, scene: e }) => { | ||
const r = T([]), s = x( | ||
() => r.value[0] | ||
), o = (a, l = !1) => { | ||
r.value.some(({ uuid: f }) => f === a.uuid) || (l ? n(a) : r.value.push(a)); | ||
}, i = (a) => { | ||
r.value = r.value.filter(({ uuid: l }) => l !== a.uuid); | ||
}, n = (a) => { | ||
const l = a instanceof Ke ? a : r.value.find((c) => c.uuid === a); | ||
if (!l) | ||
version: kt, | ||
packageManager: Pt, | ||
description: At, | ||
author: Lt, | ||
license: Ot, | ||
keywords: Bt, | ||
sideEffects: jt, | ||
exports: Dt, | ||
main: It, | ||
module: Rt, | ||
types: $t, | ||
files: Ht, | ||
publishConfig: Nt, | ||
scripts: Ft, | ||
peerDependencies: Wt, | ||
dependencies: Ut, | ||
devDependencies: Gt | ||
}, Vt = ({ sizes: e, scene: r }) => { | ||
const t = k([]), s = x( | ||
() => t.value[0] | ||
), i = (o, u = !1) => { | ||
t.value.some(({ uuid: c }) => c === o.uuid) || (u ? n(o) : t.value.push(o)); | ||
}, l = (o) => { | ||
t.value = t.value.filter(({ uuid: u }) => u !== o.uuid); | ||
}, n = (o) => { | ||
const u = o instanceof qe ? o : t.value.find((f) => f.uuid === o); | ||
if (!u) | ||
return; | ||
const f = r.value.filter(({ uuid: c }) => c !== l.uuid); | ||
r.value = [l, ...f]; | ||
const c = t.value.filter(({ uuid: f }) => f !== u.uuid); | ||
t.value = [u, ...c]; | ||
}; | ||
return se(() => { | ||
t.aspectRatio.value && r.value.forEach((a) => { | ||
!a.manual && (a instanceof te || Qt(a)) && (a instanceof te ? a.aspect = t.aspectRatio.value : (a.left = t.width.value * -0.5, a.right = t.width.value * 0.5, a.top = t.height.value * 0.5, a.bottom = t.height.value * -0.5), a.updateProjectionMatrix()); | ||
e.aspectRatio.value && t.value.forEach((o) => { | ||
!o.manual && (o instanceof te || Jt(o)) && (o instanceof te ? o.aspect = e.aspectRatio.value : (o.left = e.width.value * -0.5, o.right = e.width.value * 0.5, o.top = e.height.value * 0.5, o.bottom = e.height.value * -0.5), o.updateProjectionMatrix()); | ||
}); | ||
}), J(() => { | ||
r.value = []; | ||
t.value = []; | ||
}), { | ||
camera: s, | ||
cameras: r, | ||
registerCamera: o, | ||
deregisterCamera: i, | ||
cameras: t, | ||
registerCamera: i, | ||
deregisterCamera: l, | ||
setCameraActive: n | ||
}; | ||
}; | ||
function Qt(t) { | ||
return t.hasOwnProperty("isOrthographicCamera") && t.isOrthographicCamera; | ||
function Jt(e) { | ||
return e.hasOwnProperty("isOrthographicCamera") && e.isOrthographicCamera; | ||
} | ||
const xe = H(), ke = H(), ie = H(), R = new Xe(); | ||
const xe = H(), Te = H(), ie = H(), R = new Ke(); | ||
let z = 0, V = 0; | ||
const { pause: Yt, resume: qt, isActive: Kt } = Se( | ||
const { pause: Qt, resume: Yt, isActive: qt } = Se( | ||
() => { | ||
xe.trigger({ delta: z, elapsed: V, clock: R }), ke.trigger({ delta: z, elapsed: V, clock: R }), ie.trigger({ delta: z, elapsed: V, clock: R }); | ||
xe.trigger({ delta: z, elapsed: V, clock: R }), Te.trigger({ delta: z, elapsed: V, clock: R }), ie.trigger({ delta: z, elapsed: V, clock: R }); | ||
}, | ||
@@ -172,32 +173,32 @@ { immediate: !1 } | ||
onBeforeLoop: xe.on, | ||
onLoop: ke.on, | ||
onLoop: Te.on, | ||
onAfterLoop: ie.on, | ||
pause: Yt, | ||
resume: qt, | ||
isActive: Kt | ||
}), Wr = !0, me = "[TresJS ▲ ■ ●] "; | ||
pause: Qt, | ||
resume: Yt, | ||
isActive: qt | ||
}), Un = !0, me = "[TresJS ▲ ■ ●] "; | ||
function P() { | ||
function t(s, o) { | ||
console.error(`${me} ${s}`, o || ""); | ||
function e(s, i) { | ||
console.error(`${me} ${s}`, i || ""); | ||
} | ||
function e(s) { | ||
function r(s) { | ||
console.warn(`${me} ${s}`); | ||
} | ||
function r(s, o) { | ||
function t(s, i) { | ||
} | ||
return { | ||
logError: t, | ||
logWarning: e, | ||
logMessage: r | ||
logError: e, | ||
logWarning: r, | ||
logMessage: t | ||
}; | ||
} | ||
function Ur(t) { | ||
return typeof t == "number" ? [t, t, t] : t instanceof _e ? [t.x, t.y, t.z] : t; | ||
function Gn(e) { | ||
return typeof e == "number" ? [e, e, e] : e instanceof _e ? [e.x, e.y, e.z] : e; | ||
} | ||
function Xt(t) { | ||
return t instanceof G ? t : Array.isArray(t) ? new G(...t) : new G(t); | ||
function Kt(e) { | ||
return e instanceof G ? e : Array.isArray(e) ? new G(...e) : new G(e); | ||
} | ||
class Zt extends Me.Mesh { | ||
constructor(...r) { | ||
super(...r); | ||
class Xt extends Me.Mesh { | ||
constructor(...t) { | ||
super(...t); | ||
Y(this, "type", "HightlightMesh"); | ||
@@ -212,88 +213,88 @@ Y(this, "createTime"); | ||
} | ||
const Te = (t, e) => { | ||
for (const r of Object.keys(e)) | ||
e[r] instanceof Object && Object.assign(e[r], Te(t[r], e[r])); | ||
return Object.assign(t || {}, e), t; | ||
}, er = "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", tr = /* @__PURE__ */ rr(er); | ||
function ve(t) { | ||
return t && t.nodeType === 1; | ||
const ke = (e, r) => { | ||
for (const t of Object.keys(r)) | ||
r[t] instanceof Object && Object.assign(r[t], ke(e[t], r[t])); | ||
return Object.assign(e || {}, r), e; | ||
}, Zt = "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", en = /* @__PURE__ */ tn(Zt); | ||
function ve(e) { | ||
return e && e.nodeType === 1; | ||
} | ||
function F(t) { | ||
return t.replace(/-([a-z])/g, (e, r) => r.toUpperCase()); | ||
function F(e) { | ||
return e.replace(/-([a-z])/g, (r, t) => t.toUpperCase()); | ||
} | ||
function rr(t, e) { | ||
const r = /* @__PURE__ */ Object.create(null), s = t.split(","); | ||
for (let o = 0; o < s.length; o++) | ||
r[s[o]] = !0; | ||
return e ? (o) => !!r[o.toLowerCase()] : (o) => !!r[o]; | ||
function tn(e, r) { | ||
const t = /* @__PURE__ */ Object.create(null), s = e.split(","); | ||
for (let i = 0; i < s.length; i++) | ||
t[s[i]] = !0; | ||
return r ? (i) => !!t[i.toLowerCase()] : (i) => !!t[i]; | ||
} | ||
const nr = (t, e) => { | ||
const r = /* @__PURE__ */ new Set(), s = []; | ||
for (const o of t) { | ||
const i = e(o); | ||
r.has(i) || (r.add(i), s.push(o)); | ||
const nn = (e, r) => { | ||
const t = /* @__PURE__ */ new Set(), s = []; | ||
for (const i of e) { | ||
const l = r(i); | ||
t.has(l) || (t.add(l), s.push(i)); | ||
} | ||
return s; | ||
}, ge = (t, e) => { | ||
if (!e) | ||
}, ge = (e, r) => { | ||
if (!r) | ||
return; | ||
const r = Array.isArray(e) ? e : e.match(/([^[.\]])+/g); | ||
return r == null ? void 0 : r.reduce((s, o) => s && s[o], t); | ||
}, or = (t, e, r) => { | ||
const s = Array.isArray(e) ? e : e.match(/([^[.\]])+/g); | ||
s && s.reduce((o, i, n) => (o[i] === void 0 && (o[i] = {}), n === s.length - 1 && (o[i] = r), o[i]), t); | ||
const t = Array.isArray(r) ? r : r.match(/([^[.\]])+/g); | ||
return t == null ? void 0 : t.reduce((s, i) => s && s[i], e); | ||
}, rn = (e, r, t) => { | ||
const s = Array.isArray(r) ? r : r.match(/([^[.\]])+/g); | ||
s && s.reduce((i, l, n) => (i[l] === void 0 && (i[l] = {}), n === s.length - 1 && (i[l] = t), i[l]), e); | ||
}; | ||
function Pe(t, e) { | ||
if (ve(t) && ve(e)) { | ||
const o = t.attributes, i = e.attributes; | ||
return o.length !== i.length ? !1 : Array.from(o).every(({ name: n, value: a }) => e.getAttribute(n) === a); | ||
function Pe(e, r) { | ||
if (ve(e) && ve(r)) { | ||
const i = e.attributes, l = r.attributes; | ||
return i.length !== l.length ? !1 : Array.from(i).every(({ name: n, value: o }) => r.getAttribute(n) === o); | ||
} | ||
if (t === e) | ||
if (e === r) | ||
return !0; | ||
if (t === null || typeof t != "object" || e === null || typeof e != "object") | ||
if (e === null || typeof e != "object" || r === null || typeof r != "object") | ||
return !1; | ||
const r = Object.keys(t), s = Object.keys(e); | ||
if (r.length !== s.length) | ||
const t = Object.keys(e), s = Object.keys(r); | ||
if (t.length !== s.length) | ||
return !1; | ||
for (const o of r) | ||
if (!s.includes(o) || !Pe(t[o], e[o])) | ||
for (const i of t) | ||
if (!s.includes(i) || !Pe(e[i], r[i])) | ||
return !1; | ||
return !0; | ||
} | ||
function sr(t, e) { | ||
if (!Array.isArray(t) || !Array.isArray(e) || t.length !== e.length) | ||
function on(e, r) { | ||
if (!Array.isArray(e) || !Array.isArray(r) || e.length !== r.length) | ||
return !1; | ||
for (let r = 0; r < t.length; r++) | ||
if (!Pe(t[r], e[r])) | ||
for (let t = 0; t < e.length; t++) | ||
if (!Pe(e[t], r[t])) | ||
return !1; | ||
return !0; | ||
} | ||
const ir = Array.isArray; | ||
function ar(t, e, r, s) { | ||
const o = (l) => { | ||
if (l.uuid === e) | ||
return l; | ||
for (const f of l.children) { | ||
const c = o(f); | ||
if (c) | ||
return c; | ||
const sn = Array.isArray; | ||
function an(e, r, t, s) { | ||
const i = (u) => { | ||
if (u.uuid === r) | ||
return u; | ||
for (const c of u.children) { | ||
const f = i(c); | ||
if (f) | ||
return f; | ||
} | ||
}, i = o(t); | ||
if (!i) { | ||
}, l = i(e); | ||
if (!l) { | ||
console.warn("Object with UUID not found in the scene."); | ||
return; | ||
} | ||
let n = i; | ||
for (let l = 0; l < r.length - 1; l++) | ||
if (n[r[l]] !== void 0) | ||
n = n[r[l]]; | ||
let n = l; | ||
for (let u = 0; u < t.length - 1; u++) | ||
if (n[t[u]] !== void 0) | ||
n = n[t[u]]; | ||
else { | ||
console.warn(`Property path is not valid: ${r.join(".")}`); | ||
console.warn(`Property path is not valid: ${t.join(".")}`); | ||
return; | ||
} | ||
const a = r[r.length - 1]; | ||
n[a] !== void 0 ? n[a] = s : console.warn(`Property path is not valid: ${r.join(".")}`); | ||
const o = t[t.length - 1]; | ||
n[o] !== void 0 ? n[o] = s : console.warn(`Property path is not valid: ${t.join(".")}`); | ||
} | ||
function lr(t) { | ||
const e = new Ee({ | ||
function ln(e) { | ||
const r = new Ce({ | ||
color: 11003607, | ||
@@ -305,22 +306,22 @@ // Highlight color, e.g., yellow | ||
// So the highlight is always visible | ||
side: Ze | ||
side: Xe | ||
// To e | ||
}); | ||
return new Zt(t.geometry.clone(), e); | ||
return new Xt(e.geometry.clone(), r); | ||
} | ||
function Ae(t) { | ||
var r; | ||
let e = t.value; | ||
return t.value && ((r = t.value) != null && r.isMesh) && (e = t.value.position), Array.isArray(t.value) && (e = new _e(...e)), e; | ||
function Ae(e) { | ||
var t; | ||
let r = e.value; | ||
return e.value && ((t = e.value) != null && t.isMesh) && (r = e.value.position), Array.isArray(e.value) && (r = new _e(...r)), r; | ||
} | ||
const ur = Number.parseInt(et.replace("dev", "")), W = { | ||
const un = Number.parseInt(Ze.replace("dev", "")), W = { | ||
realistic: { | ||
shadows: !0, | ||
physicallyCorrectLights: !0, | ||
outputColorSpace: tt, | ||
toneMapping: Ce, | ||
outputColorSpace: et, | ||
toneMapping: Ee, | ||
toneMappingExposure: 3, | ||
shadowMap: { | ||
enabled: !0, | ||
type: rt | ||
type: tt | ||
} | ||
@@ -333,63 +334,63 @@ }, | ||
}; | ||
function cr({ | ||
scene: t, | ||
canvas: e, | ||
options: r, | ||
function cn({ | ||
scene: e, | ||
canvas: r, | ||
options: t, | ||
disableRender: s, | ||
emit: o, | ||
contextParts: { sizes: i, camera: n, render: a, invalidate: l, advance: f } | ||
emit: i, | ||
contextParts: { sizes: l, camera: n, render: o, invalidate: u, advance: c } | ||
}) { | ||
const c = x(() => ({ | ||
alpha: M(r.alpha) ?? !0, | ||
depth: M(r.depth), | ||
canvas: wt(e), | ||
context: M(r.context), | ||
stencil: M(r.stencil), | ||
antialias: M(r.antialias) ?? !0, | ||
precision: M(r.precision), | ||
powerPreference: M(r.powerPreference), | ||
premultipliedAlpha: M(r.premultipliedAlpha), | ||
preserveDrawingBuffer: M(r.preserveDrawingBuffer), | ||
logarithmicDepthBuffer: M(r.logarithmicDepthBuffer), | ||
failIfMajorPerformanceCaveat: M(r.failIfMajorPerformanceCaveat) | ||
})), u = $(new q(c.value)); | ||
function d() { | ||
r.renderMode === "on-demand" && l(); | ||
const f = x(() => ({ | ||
alpha: _(t.alpha) ?? !0, | ||
depth: _(t.depth), | ||
canvas: yt(r), | ||
context: _(t.context), | ||
stencil: _(t.stencil), | ||
antialias: _(t.antialias) ?? !0, | ||
precision: _(t.precision), | ||
powerPreference: _(t.powerPreference), | ||
premultipliedAlpha: _(t.premultipliedAlpha), | ||
preserveDrawingBuffer: _(t.preserveDrawingBuffer), | ||
logarithmicDepthBuffer: _(t.logarithmicDepthBuffer), | ||
failIfMajorPerformanceCaveat: _(t.failIfMajorPerformanceCaveat) | ||
})), a = $(new q(f.value)); | ||
function g() { | ||
t.renderMode === "on-demand" && u(); | ||
} | ||
I(c, () => { | ||
u.value.dispose(), u.value = new q(c.value), d(); | ||
}), I([i.width, i.height], () => { | ||
u.value.setSize(i.width.value, i.height.value), d(); | ||
I(f, () => { | ||
a.value.dispose(), a.value = new q(f.value), g(); | ||
}), I([l.width, l.height], () => { | ||
a.value.setSize(l.width.value, l.height.value), g(); | ||
}, { | ||
immediate: !0 | ||
}), I(() => r.clearColor, d); | ||
const { pixelRatio: p } = bt(); | ||
I(p, () => { | ||
u.value.setPixelRatio(p.value); | ||
}), I(() => t.clearColor, g); | ||
const { pixelRatio: d } = wt(); | ||
I(d, () => { | ||
a.value.setPixelRatio(d.value); | ||
}); | ||
const { logError: h } = P(), { resume: _, onLoop: y } = ae(); | ||
y(() => { | ||
n.value && !M(s) && a.frames.value > 0 && (u.value.render(t, n.value), o("render", u.value)), a.priority.value = 0, M(r.renderMode) === "always" ? a.frames.value = 1 : a.frames.value = Math.max(0, a.frames.value - 1); | ||
}), _(); | ||
const g = (() => { | ||
const w = new q(), m = { | ||
const { logError: h } = P(), { resume: y, onLoop: p } = ae(); | ||
p(() => { | ||
n.value && !_(s) && o.frames.value > 0 && (a.value.render(e, n.value), i("render", a.value)), o.priority.value = 0, _(t.renderMode) === "always" ? o.frames.value = 1 : o.frames.value = Math.max(0, o.frames.value - 1); | ||
}), y(); | ||
const v = (() => { | ||
const M = new q(), w = { | ||
shadowMap: { | ||
enabled: w.shadowMap.enabled, | ||
type: w.shadowMap.type | ||
enabled: M.shadowMap.enabled, | ||
type: M.shadowMap.type | ||
}, | ||
toneMapping: w.toneMapping, | ||
toneMappingExposure: w.toneMappingExposure, | ||
outputColorSpace: w.outputColorSpace | ||
toneMapping: M.toneMapping, | ||
toneMappingExposure: M.toneMappingExposure, | ||
outputColorSpace: M.outputColorSpace | ||
}; | ||
return w.dispose(), m; | ||
})(), E = M(r.renderMode); | ||
return E === "on-demand" && l(), E === "manual" && setTimeout(() => { | ||
f(); | ||
return M.dispose(), w; | ||
})(), C = _(t.renderMode); | ||
return C === "on-demand" && u(), C === "manual" && setTimeout(() => { | ||
c(); | ||
}, 1), se(() => { | ||
const w = M(r.preset); | ||
w && (w in W || h(`Renderer Preset must be one of these: ${Object.keys(W).join(", ")}`), Te(u.value, W[w])), E === "always" && (a.frames.value = Math.max(1, a.frames.value)); | ||
const m = (L, A) => { | ||
const O = M(L), Q = () => { | ||
if (w) | ||
return ge(W[w], A); | ||
const M = _(t.preset); | ||
M && (M in W || h(`Renderer Preset must be one of these: ${Object.keys(W).join(", ")}`), ke(a.value, W[M])), C === "always" && (o.frames.value = Math.max(1, o.frames.value)); | ||
const w = (L, A) => { | ||
const O = _(L), Q = () => { | ||
if (M) | ||
return ge(W[M], A); | ||
}; | ||
@@ -399,45 +400,45 @@ if (O !== void 0) | ||
const N = Q(); | ||
return N !== void 0 ? N : ge(g, A); | ||
}, v = (L, A) => or(u.value, A, m(L, A)); | ||
v(r.shadows, "shadowMap.enabled"), v(r.toneMapping ?? Ce, "toneMapping"), v(r.shadowMapType, "shadowMap.type"), ur < 150 && v(!r.useLegacyLights, "physicallyCorrectLights"), v(r.outputColorSpace, "outputColorSpace"), v(r.toneMappingExposure, "toneMappingExposure"); | ||
const C = m(r.clearColor, "clearColor"); | ||
C && u.value.setClearColor( | ||
C ? Xt(C) : new G(0) | ||
return N !== void 0 ? N : ge(v, A); | ||
}, b = (L, A) => rn(a.value, A, w(L, A)); | ||
b(t.shadows, "shadowMap.enabled"), b(t.toneMapping ?? Ee, "toneMapping"), b(t.shadowMapType, "shadowMap.type"), un < 150 && b(!t.useLegacyLights, "physicallyCorrectLights"), b(t.outputColorSpace, "outputColorSpace"), b(t.toneMappingExposure, "toneMappingExposure"); | ||
const E = w(t.clearColor, "clearColor"); | ||
E && a.value.setClearColor( | ||
E ? Kt(E) : new G(0) | ||
// default clear color is not easily/efficiently retrievable from three | ||
); | ||
}), J(() => { | ||
u.value.dispose(), u.value.forceContextLoss(); | ||
a.value.dispose(), a.value.forceContextLoss(); | ||
}), { | ||
renderer: u | ||
renderer: a | ||
}; | ||
} | ||
const K = (t) => typeof t == "function", dr = (t) => !!t && t.constructor === Array; | ||
function fr(t) { | ||
const e = { nodes: {}, materials: {} }; | ||
return t && t.traverse((r) => { | ||
r.name && (e.nodes[r.name] = r), r.material && !e.materials[r.material.name] && (e.materials[r.material.name] = r.material); | ||
}), e; | ||
const K = (e) => typeof e == "function", dn = (e) => !!e && e.constructor === Array; | ||
function fn(e) { | ||
const r = { nodes: {}, materials: {} }; | ||
return e && e.traverse((t) => { | ||
t.name && (r.nodes[t.name] = t), t.material && !r.materials[t.material.name] && (r.materials[t.material.name] = t.material); | ||
}), r; | ||
} | ||
async function Gr(t, e, r, s, o) { | ||
const { logError: i } = P(), n = new t(); | ||
o && o(n), r && r(n); | ||
const l = (Array.isArray(e) ? e : [e]).map( | ||
(f) => new Promise((c, u) => { | ||
async function zn(e, r, t, s, i) { | ||
const { logError: l } = P(), n = new e(); | ||
i && i(n), t && t(n); | ||
const u = (Array.isArray(r) ? r : [r]).map( | ||
(c) => new Promise((f, a) => { | ||
n.load( | ||
f, | ||
(d) => { | ||
d.scene && Object.assign(d, fr(d.scene)), c(d); | ||
c, | ||
(g) => { | ||
g.scene && Object.assign(g, fn(g.scene)), f(g); | ||
}, | ||
s, | ||
(d) => u(i("[useLoader] - Failed to load resource", d)) | ||
(g) => a(l("[useLoader] - Failed to load resource", g)) | ||
); | ||
}) | ||
); | ||
return dr(e) ? await Promise.all(l) : await l[0]; | ||
return dn(r) ? await Promise.all(u) : await u[0]; | ||
} | ||
async function zr(t) { | ||
const e = new ot(), r = new st(e), s = (o) => new Promise((i, n) => { | ||
r.load( | ||
o, | ||
(a) => i(a), | ||
async function Vn(e) { | ||
const r = new rt(), t = new ot(r), s = (i) => new Promise((l, n) => { | ||
t.load( | ||
i, | ||
(o) => l(o), | ||
() => null, | ||
@@ -449,94 +450,94 @@ () => { | ||
}); | ||
if (ir(t)) { | ||
const o = await Promise.all(t.map((i) => s(i))); | ||
return t.length > 1 ? o : o[0]; | ||
if (sn(e)) { | ||
const i = await Promise.all(e.map((l) => s(l))); | ||
return e.length > 1 ? i : i[0]; | ||
} else { | ||
const { | ||
map: o, | ||
displacementMap: i, | ||
map: i, | ||
displacementMap: l, | ||
normalMap: n, | ||
roughnessMap: a, | ||
metalnessMap: l, | ||
aoMap: f, | ||
alphaMap: c, | ||
matcap: u | ||
} = t; | ||
roughnessMap: o, | ||
metalnessMap: u, | ||
aoMap: c, | ||
alphaMap: f, | ||
matcap: a | ||
} = e; | ||
return { | ||
map: o ? await s(o) : null, | ||
displacementMap: i ? await s(i) : null, | ||
map: i ? await s(i) : null, | ||
displacementMap: l ? await s(l) : null, | ||
normalMap: n ? await s(n) : null, | ||
roughnessMap: a ? await s(a) : null, | ||
metalnessMap: l ? await s(l) : null, | ||
aoMap: f ? await s(f) : null, | ||
alphaMap: c ? await s(c) : null, | ||
matcap: u ? await s(u) : null | ||
roughnessMap: o ? await s(o) : null, | ||
metalnessMap: u ? await s(u) : null, | ||
aoMap: c ? await s(c) : null, | ||
alphaMap: f ? await s(f) : null, | ||
matcap: a ? await s(a) : null | ||
}; | ||
} | ||
} | ||
const pr = (t, e) => { | ||
const r = x(() => e.renderer.value.domElement), { x: s, y: o } = Mt({ target: r }), { width: i, height: n, top: a, left: l } = _t(r), f = ({ x: m, y: v }) => { | ||
if (r.value) | ||
const pn = (e, r) => { | ||
const t = x(() => r.renderer.value.domElement), { x: s, y: i } = bt({ target: t }), { width: l, height: n, top: o, left: u } = Mt(t), c = ({ x: w, y: b }) => { | ||
if (t.value) | ||
return { | ||
x: (m - l.value) / i.value * 2 - 1, | ||
y: -((v - a.value) / n.value) * 2 + 1 | ||
x: (w - u.value) / l.value * 2 - 1, | ||
y: -((b - o.value) / n.value) * 2 + 1 | ||
}; | ||
}, c = ({ x: m, y: v }) => { | ||
if (e.camera.value) | ||
return e.raycaster.value.setFromCamera(new it(m, v), e.camera.value), e.raycaster.value.intersectObjects(t.value, !1); | ||
}, u = (m) => { | ||
const v = f({ | ||
x: (m == null ? void 0 : m.clientX) ?? s.value, | ||
y: (m == null ? void 0 : m.clientY) ?? o.value | ||
}, f = ({ x: w, y: b }) => { | ||
if (r.camera.value) | ||
return r.raycaster.value.setFromCamera(new st(w, b), r.camera.value), r.raycaster.value.intersectObjects(e.value, !1); | ||
}, a = (w) => { | ||
const b = c({ | ||
x: (w == null ? void 0 : w.clientX) ?? s.value, | ||
y: (w == null ? void 0 : w.clientY) ?? i.value | ||
}); | ||
return v ? c(v) || [] : []; | ||
}, d = x(() => u()), p = H(), h = H(), _ = (m, v) => { | ||
m.trigger({ event: v, intersects: u(v) }); | ||
}, y = (m) => { | ||
_(h, m); | ||
return b ? f(b) || [] : []; | ||
}, g = x(() => a()), d = H(), h = H(), y = (w, b) => { | ||
w.trigger({ event: b, intersects: a(b) }); | ||
}, p = (w) => { | ||
y(h, w); | ||
}; | ||
let b; | ||
const g = (m) => { | ||
var v; | ||
b = (v = u(m)[0]) == null ? void 0 : v.object; | ||
}, E = (m) => { | ||
var v; | ||
m instanceof PointerEvent && b === ((v = u(m)[0]) == null ? void 0 : v.object) && _(p, m); | ||
}, w = (m) => h.trigger({ event: m, intersects: [] }); | ||
return r.value.addEventListener("pointerup", E), r.value.addEventListener("pointerdown", g), r.value.addEventListener("pointermove", y), r.value.addEventListener("pointerleave", w), J(() => { | ||
r != null && r.value && (r.value.removeEventListener("pointerup", E), r.value.removeEventListener("pointerdown", g), r.value.removeEventListener("pointermove", y), r.value.removeEventListener("pointerleave", w)); | ||
let m; | ||
const v = (w) => { | ||
var b; | ||
m = (b = a(w)[0]) == null ? void 0 : b.object; | ||
}, C = (w) => { | ||
var b; | ||
w instanceof PointerEvent && m === ((b = a(w)[0]) == null ? void 0 : b.object) && y(d, w); | ||
}, M = (w) => h.trigger({ event: w, intersects: [] }); | ||
return t.value.addEventListener("pointerup", C), t.value.addEventListener("pointerdown", v), t.value.addEventListener("pointermove", p), t.value.addEventListener("pointerleave", M), J(() => { | ||
t != null && t.value && (t.value.removeEventListener("pointerup", C), t.value.removeEventListener("pointerdown", v), t.value.removeEventListener("pointermove", p), t.value.removeEventListener("pointerleave", M)); | ||
}), { | ||
intersects: d, | ||
onClick: (m) => p.on(m).off, | ||
onPointerMove: (m) => h.on(m).off | ||
intersects: g, | ||
onClick: (w) => d.on(w).off, | ||
onPointerMove: (w) => h.on(w).off | ||
}; | ||
}; | ||
function Vr() { | ||
const { logWarning: t } = P(); | ||
function e(i, n, a) { | ||
let l = null; | ||
return i.traverse((f) => { | ||
f[n] === a && (l = f); | ||
}), l || t(`Child with ${n} '${a}' not found.`), l; | ||
function Jn() { | ||
const { logWarning: e } = P(); | ||
function r(l, n, o) { | ||
let u = null; | ||
return l.traverse((c) => { | ||
c[n] === o && (u = c); | ||
}), u || e(`Child with ${n} '${o}' not found.`), u; | ||
} | ||
function r(i, n, a) { | ||
const l = []; | ||
return i.traverse((f) => { | ||
f[n].includes(a) && l.push(f); | ||
}), l.length || t(`Children with ${n} '${a}' not found.`), l; | ||
function t(l, n, o) { | ||
const u = []; | ||
return l.traverse((c) => { | ||
c[n].includes(o) && u.push(c); | ||
}), u.length || e(`Children with ${n} '${o}' not found.`), u; | ||
} | ||
function s(i, n) { | ||
return e(i, "name", n); | ||
function s(l, n) { | ||
return r(l, "name", n); | ||
} | ||
function o(i, n) { | ||
return r(i, "name", n); | ||
function i(l, n) { | ||
return t(l, "name", n); | ||
} | ||
return { | ||
seek: e, | ||
seek: r, | ||
seekByName: s, | ||
seekAll: r, | ||
seekAllByName: o | ||
seekAll: t, | ||
seekAllByName: i | ||
}; | ||
} | ||
const mr = (t) => { | ||
const e = be({ | ||
const mn = (e) => { | ||
const r = be({ | ||
click: /* @__PURE__ */ new Map(), | ||
@@ -546,104 +547,104 @@ pointerMove: /* @__PURE__ */ new Map(), | ||
pointerLeave: /* @__PURE__ */ new Map() | ||
}), r = T(/* @__PURE__ */ new Set()), s = (u) => { | ||
r.value.add(u); | ||
}, o = (u) => { | ||
r.value.delete(u); | ||
}, i = (u) => { | ||
Object.values(e).forEach((d) => d.delete(u)), o(u); | ||
}, n = (u) => { | ||
const { onClick: d, onPointerMove: p, onPointerEnter: h, onPointerLeave: _ } = u; | ||
d && e.click.set(u, d), p && e.pointerMove.set(u, p), h && e.pointerEnter.set(u, h), _ && e.pointerLeave.set(u, _); | ||
}, a = x( | ||
() => nr( | ||
}), t = k(/* @__PURE__ */ new Set()), s = (a) => { | ||
t.value.add(a); | ||
}, i = (a) => { | ||
t.value.delete(a); | ||
}, l = (a) => { | ||
Object.values(r).forEach((g) => g.delete(a)), i(a); | ||
}, n = (a) => { | ||
const { onClick: g, onPointerMove: d, onPointerEnter: h, onPointerLeave: y } = a; | ||
g && r.click.set(a, g), d && r.pointerMove.set(a, d), h && r.pointerEnter.set(a, h), y && r.pointerLeave.set(a, y); | ||
}, o = x( | ||
() => nn( | ||
[ | ||
...Array.from(r.value), | ||
...Object.values(e).map((u) => Array.from(u.keys())).flat() | ||
...Array.from(t.value), | ||
...Object.values(r).map((a) => Array.from(a.keys())).flat() | ||
], | ||
({ uuid: u }) => u | ||
({ uuid: a }) => a | ||
) | ||
); | ||
t.registerObjectAtPointerEventHandler = n, t.deregisterObjectAtPointerEventHandler = i, t.registerBlockingObjectAtPointerEventHandler = s, t.deregisterBlockingObjectAtPointerEventHandler = o; | ||
const { onClick: l, onPointerMove: f } = pr(a, t); | ||
l(({ intersects: u, event: d }) => { | ||
var p; | ||
u.length && ((p = e.click.get(u[0].object)) == null || p(u[0], d)); | ||
e.registerObjectAtPointerEventHandler = n, e.deregisterObjectAtPointerEventHandler = l, e.registerBlockingObjectAtPointerEventHandler = s, e.deregisterBlockingObjectAtPointerEventHandler = i; | ||
const { onClick: u, onPointerMove: c } = pn(o, e); | ||
u(({ intersects: a, event: g }) => { | ||
var d; | ||
a.length && ((d = r.click.get(a[0].object)) == null || d(a[0], g)); | ||
}); | ||
let c; | ||
return f(({ intersects: u, event: d }) => { | ||
var b, g, E, w; | ||
const p = (b = u == null ? void 0 : u[0]) == null ? void 0 : b.object, { pointerLeave: h, pointerEnter: _, pointerMove: y } = e; | ||
c && c !== p && ((g = h.get(c)) == null || g(c, d)), p && (c !== p && ((E = _.get(p)) == null || E(u[0], d)), (w = y.get(p)) == null || w(u[0], d)), c = p || null; | ||
let f; | ||
return c(({ intersects: a, event: g }) => { | ||
var m, v, C, M; | ||
const d = (m = a == null ? void 0 : a[0]) == null ? void 0 : m.object, { pointerLeave: h, pointerEnter: y, pointerMove: p } = r; | ||
f && f !== d && ((v = h.get(f)) == null || v(f, g)), d && (f !== d && ((C = y.get(d)) == null || C(a[0], g)), (M = p.get(d)) == null || M(a[0], g)), f = d || null; | ||
}), { | ||
registerObject: n, | ||
deregisterObject: i, | ||
deregisterObject: l, | ||
registerBlockingObject: s, | ||
deregisterBlockingObject: o | ||
deregisterBlockingObject: i | ||
}; | ||
}; | ||
function Le(t) { | ||
let e = 0; | ||
return t.traverse((r) => { | ||
if (r.isMesh && r.geometry) { | ||
const s = r.geometry, o = s.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, i = s.index ? s.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, n = s.attributes.normal ? s.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, a = s.attributes.uv ? s.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = o + i + n + a; | ||
e += l; | ||
function Le(e) { | ||
let r = 0; | ||
return e.traverse((t) => { | ||
if (t.isMesh && t.geometry) { | ||
const s = t.geometry, i = s.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, l = s.index ? s.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, n = s.attributes.normal ? s.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, o = s.attributes.uv ? s.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, u = i + l + n + o; | ||
r += u; | ||
} | ||
}), e; | ||
}), r; | ||
} | ||
function vr(t) { | ||
return (t / 1024).toFixed(2); | ||
function vn(e) { | ||
return (e / 1024).toFixed(2); | ||
} | ||
const re = T({}), ne = (t) => Object.assign(re.value, t); | ||
function gr(t, e, r = 10) { | ||
const s = M(t) ? Et() : Ct(x(() => M(e).parentElement)), o = Z(pe(s.width, r)), i = Z(pe(s.height, r)), n = x(() => o.value / i.value); | ||
const ne = k({}), re = (e) => Object.assign(ne.value, e); | ||
function gn(e, r, t = 10) { | ||
const s = _(e) ? _t() : Ct(x(() => _(r).parentElement)), i = Z(pe(s.width, t)), l = Z(pe(s.height, t)), n = x(() => i.value / l.value); | ||
return { | ||
height: i, | ||
width: o, | ||
height: l, | ||
width: i, | ||
aspectRatio: n | ||
}; | ||
} | ||
function hr({ | ||
scene: t, | ||
canvas: e, | ||
windowSize: r, | ||
function hn({ | ||
scene: e, | ||
canvas: r, | ||
windowSize: t, | ||
disableRender: s, | ||
rendererOptions: o, | ||
emit: i | ||
rendererOptions: i, | ||
emit: l | ||
}) { | ||
const { logWarning: n } = P(), a = $(t), l = gr(r, e), { | ||
camera: f, | ||
cameras: c, | ||
registerCamera: u, | ||
deregisterCamera: d, | ||
setCameraActive: p | ||
} = Jt({ sizes: l, scene: t }), h = { | ||
mode: T(o.renderMode || "always"), | ||
priority: T(0), | ||
frames: T(0), | ||
const { logWarning: n } = P(), o = $(e), u = gn(t, r), { | ||
camera: c, | ||
cameras: f, | ||
registerCamera: a, | ||
deregisterCamera: g, | ||
setCameraActive: d | ||
} = Vt({ sizes: u, scene: e }), h = { | ||
mode: k(i.renderMode || "always"), | ||
priority: k(0), | ||
frames: k(0), | ||
maxFrames: 60, | ||
canBeInvalidated: x(() => h.mode.value === "on-demand" && h.frames.value === 0) | ||
}; | ||
function _(B = 1) { | ||
o.renderMode === "on-demand" ? h.frames.value = Math.min(h.maxFrames, h.frames.value + B) : n("`invalidate` can only be used when `renderMode` is set to `on-demand`"); | ||
function y(B = 1) { | ||
i.renderMode === "on-demand" ? h.frames.value = Math.min(h.maxFrames, h.frames.value + B) : n("`invalidate` can only be used when `renderMode` is set to `on-demand`"); | ||
} | ||
function y() { | ||
o.renderMode === "manual" ? h.frames.value = 1 : n("`advance` can only be used when `renderMode` is set to `manual`"); | ||
function p() { | ||
i.renderMode === "manual" ? h.frames.value = 1 : n("`advance` can only be used when `renderMode` is set to `manual`"); | ||
} | ||
const { renderer: b } = cr( | ||
const { renderer: m } = cn( | ||
{ | ||
scene: t, | ||
canvas: e, | ||
options: o, | ||
emit: i, | ||
scene: e, | ||
canvas: r, | ||
options: i, | ||
emit: l, | ||
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516 | ||
contextParts: { sizes: l, camera: f, render: h, invalidate: _, advance: y }, | ||
contextParts: { sizes: u, camera: c, render: h, invalidate: y, advance: p }, | ||
disableRender: s | ||
} | ||
), g = { | ||
sizes: l, | ||
scene: a, | ||
camera: f, | ||
cameras: Z(c), | ||
renderer: b, | ||
raycaster: $(new at()), | ||
controls: T(null), | ||
), v = { | ||
sizes: u, | ||
scene: o, | ||
camera: c, | ||
cameras: Z(f), | ||
renderer: m, | ||
raycaster: $(new it()), | ||
controls: k(null), | ||
perf: { | ||
@@ -662,32 +663,32 @@ maxFrames: 160, | ||
render: h, | ||
advance: y, | ||
extend: ne, | ||
invalidate: _, | ||
registerCamera: u, | ||
setCameraActive: p, | ||
deregisterCamera: d | ||
advance: p, | ||
extend: re, | ||
invalidate: y, | ||
registerCamera: a, | ||
setCameraActive: d, | ||
deregisterCamera: g | ||
}; | ||
ee("useTres", g), g.scene.value.__tres = { | ||
root: g | ||
ee("useTres", v), v.scene.value.__tres = { | ||
root: v | ||
}; | ||
const E = 100, w = St({ every: E }), { isSupported: m, memory: v } = xt({ interval: E }), C = 160; | ||
const C = 100, M = Et({ every: C }), { isSupported: w, memory: b } = St({ interval: C }), E = 160; | ||
let L = performance.now(); | ||
const A = ({ timestamp: B }) => { | ||
g.scene.value && (g.perf.memory.allocatedMem = Le(g.scene.value)), B - L >= E && (L = B, g.perf.fps.accumulator.push(w.value), g.perf.fps.accumulator.length > C && g.perf.fps.accumulator.shift(), g.perf.fps.value = w.value, m.value && v.value && (g.perf.memory.accumulator.push(v.value.usedJSHeapSize / 1024 / 1024), g.perf.memory.accumulator.length > C && g.perf.memory.accumulator.shift(), g.perf.memory.currentMem = g.perf.memory.accumulator.reduce((Re, $e) => Re + $e, 0) / g.perf.memory.accumulator.length)); | ||
v.scene.value && (v.perf.memory.allocatedMem = Le(v.scene.value)), B - L >= C && (L = B, v.perf.fps.accumulator.push(M.value), v.perf.fps.accumulator.length > E && v.perf.fps.accumulator.shift(), v.perf.fps.value = M.value, w.value && b.value && (v.perf.memory.accumulator.push(b.value.usedJSHeapSize / 1024 / 1024), v.perf.memory.accumulator.length > E && v.perf.memory.accumulator.shift(), v.perf.memory.currentMem = v.perf.memory.accumulator.reduce((Ie, Re) => Ie + Re, 0) / v.perf.memory.accumulator.length)); | ||
}; | ||
let O = 0; | ||
const Q = 1, { pause: N } = Se(({ delta: B }) => { | ||
window.__TRES__DEVTOOLS__ && (A({ timestamp: performance.now() }), O += B, O >= Q && (window.__TRES__DEVTOOLS__.cb(g), O = 0)); | ||
window.__TRES__DEVTOOLS__ && (A({ timestamp: performance.now() }), O += B, O >= Q && (window.__TRES__DEVTOOLS__.cb(v), O = 0)); | ||
}, { immediate: !0 }); | ||
return J(() => { | ||
N(); | ||
}), g; | ||
}), v; | ||
} | ||
function yr() { | ||
const t = Fe("useTres"); | ||
if (!t) | ||
function yn() { | ||
const e = Ne("useTres"); | ||
if (!e) | ||
throw new Error("useTresContext must be used together with useTresContextProvider"); | ||
return t; | ||
return e; | ||
} | ||
const Jr = yr; | ||
const Qn = yn; | ||
const { logError: he } = P(), X = [ | ||
@@ -699,122 +700,127 @@ "onClick", | ||
]; | ||
function ye(t) { | ||
const e = t.__tres.root; | ||
e && e.render && e.render.canBeInvalidated.value && e.invalidate(); | ||
function ye(e) { | ||
const r = e.__tres.root; | ||
r && r.render && r.render.canBeInvalidated.value && r.invalidate(); | ||
} | ||
const Oe = () => { | ||
let t = null; | ||
return { | ||
createElement(e, r, s, o) { | ||
if (o || (o = {}), o.args || (o.args = []), e === "template" || tr(e)) | ||
return null; | ||
let i = e.replace("Tres", ""), n; | ||
if (e === "primitive") { | ||
(o == null ? void 0 : o.object) === void 0 && he("Tres primitives need a prop 'object'"); | ||
const a = o.object; | ||
i = a.type, n = Object.assign(a.clone(), { type: i }); | ||
} else { | ||
const a = re.value[i]; | ||
a || he(`${i} is not defined on the THREE namespace. Use extend to add it to the catalog.`), n = new a(...o.args); | ||
const wn = () => { | ||
let e = null; | ||
function r(n, o, u, c) { | ||
if (c || (c = {}), c.args || (c.args = []), n === "template" || en(n)) | ||
return null; | ||
let f = n.replace("Tres", ""), a; | ||
if (n === "primitive") { | ||
(c == null ? void 0 : c.object) === void 0 && he("Tres primitives need a prop 'object'"); | ||
const g = c.object; | ||
f = g.type, a = Object.assign(g.clone(), { type: f }); | ||
} else { | ||
const g = ne.value[f]; | ||
g || he(`${f} is not defined on the THREE namespace. Use extend to add it to the catalog.`), a = new g(...c.args); | ||
} | ||
return a ? (a.isCamera && (c != null && c.position || a.position.set(3, 3, 3), c != null && c.lookAt || a.lookAt(0, 0, 0)), (c == null ? void 0 : c.attach) === void 0 && (a.isMaterial ? a.attach = "material" : a.isBufferGeometry && (a.attach = "geometry")), a.__tres = { | ||
...a.__tres, | ||
type: f, | ||
memoizedProps: c, | ||
eventCount: 0, | ||
disposable: !0, | ||
primitive: n === "primitive" | ||
}, a.isObject3D && (c != null && c.material || c != null && c.geometry) && (a.__tres.disposable = !1), a) : null; | ||
} | ||
function t(n, o) { | ||
if (!n) | ||
return; | ||
o && o.isScene && (e = o), e && (n.__tres.root = e.__tres.root); | ||
const u = o || e; | ||
if (n != null && n.isObject3D) { | ||
const { registerCamera: c, registerObjectAtPointerEventHandler: f } = n.__tres.root; | ||
n != null && n.isCamera && c(n), n && X.some((a) => n[a]) && f(n); | ||
} | ||
n != null && n.isObject3D && (u != null && u.isObject3D) ? (u.add(n), n.dispatchEvent({ type: "added" })) : n != null && n.isFog ? u.fog = n : typeof (n == null ? void 0 : n.attach) == "string" && (n.__previousAttach = n[u == null ? void 0 : u.attach], u && (u[n.attach] = n)); | ||
} | ||
function s(n) { | ||
var f, a; | ||
if (!n) | ||
return; | ||
const o = n.__tres; | ||
n.parent = n.parent || e; | ||
const { | ||
deregisterObjectAtPointerEventHandler: u, | ||
deregisterBlockingObjectAtPointerEventHandler: c | ||
} = o.root; | ||
if (n.isObject3D) { | ||
const g = (y) => { | ||
var m, v; | ||
const p = y; | ||
o.disposable && ((m = p.material) == null || m.dispose(), p.material = void 0, (v = p.geometry) == null || v.dispose(), p.geometry = void 0); | ||
}, d = (y) => { | ||
c(y), y && X.some((p) => y[p]) && (u == null || u(y)); | ||
}, h = (y) => { | ||
const p = n.__tres.root.deregisterCamera; | ||
y.isCamera && (p == null || p(y)); | ||
}; | ||
(f = n.removeFromParent) == null || f.call(n), n.traverse((y) => { | ||
g(y), h(y), d == null || d(y); | ||
}), g(n), h(n), d == null || d(n), ye(n), (a = n.dispose) == null || a.call(n); | ||
} | ||
} | ||
function i(n, o, u, c) { | ||
if (n) { | ||
let f = n, a = o; | ||
if (n.__tres.primitive && a === "object" && u !== null) { | ||
const y = r("primitive", void 0, void 0, { | ||
object: c | ||
}); | ||
for (const p in y) { | ||
if (p === "uuid") | ||
continue; | ||
const m = n[p], v = y[p]; | ||
!(m != null && m.set) && !K(m) ? n[p] = v : m.constructor === v.constructor && (m != null && m.copy) ? m == null || m.copy(v) : Array.isArray(v) ? m.set(...v) : !m.isColor && m.setScalar ? m.setScalar(v) : m.set(v); | ||
} | ||
y.__tres.root = e == null ? void 0 : e.__tres.root, y.isGroup ? (n.geometry = void 0, n.material = void 0) : delete n.isGroup; | ||
} | ||
return n ? (n.isCamera && (o != null && o.position || n.position.set(3, 3, 3), o != null && o.lookAt || n.lookAt(0, 0, 0)), (o == null ? void 0 : o.attach) === void 0 && (n.isMaterial ? n.attach = "material" : n.isBufferGeometry && (n.attach = "geometry")), n.__tres = { | ||
...n.__tres, | ||
type: i, | ||
memoizedProps: o, | ||
eventCount: 0, | ||
disposable: !0, | ||
primitive: e === "primitive" | ||
}, n.isObject3D && (o != null && o.material || o != null && o.geometry) && (n.__tres.disposable = !1), n) : null; | ||
}, | ||
insert(e, r) { | ||
if (!e) | ||
return; | ||
r && r.isScene && (t = r), t && (e.__tres.root = t.__tres.root); | ||
const s = r || t; | ||
if (e != null && e.isObject3D) { | ||
const { registerCamera: o, registerObjectAtPointerEventHandler: i } = e.__tres.root; | ||
e != null && e.isCamera && o(e), e && X.some((n) => e[n]) && i(e); | ||
if (n.__tres.root) { | ||
const { | ||
registerBlockingObjectAtPointerEventHandler: y, | ||
deregisterBlockingObjectAtPointerEventHandler: p | ||
} = n.__tres.root; | ||
if (n.isObject3D && a === "blocks-pointer-events") { | ||
c || c === "" ? y(n) : p(n); | ||
return; | ||
} | ||
} | ||
e != null && e.isObject3D && (s != null && s.isObject3D) ? (s.add(e), e.dispatchEvent({ type: "added" })) : e != null && e.isFog ? s.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[s == null ? void 0 : s.attach], s && (s[e.attach] = e)); | ||
}, | ||
remove(e) { | ||
var i, n; | ||
if (!e) | ||
let g = F(a), d = f == null ? void 0 : f[g]; | ||
if (a === "args") { | ||
const y = n, p = u ?? [], m = c ?? [], v = n.__tres.type || n.type; | ||
v && p.length && !on(p, m) && (f = Object.assign(y, new ne.value[v](...c))); | ||
return; | ||
const r = e.__tres; | ||
e.parent = e.parent || t; | ||
const { | ||
deregisterObjectAtPointerEventHandler: s, | ||
deregisterBlockingObjectAtPointerEventHandler: o | ||
} = r.root; | ||
if (e.isObject3D) { | ||
const a = (c) => { | ||
var d, p; | ||
const u = c; | ||
r.disposable && ((d = u.material) == null || d.dispose(), u.material = void 0, (p = u.geometry) == null || p.dispose(), u.geometry = void 0); | ||
}, l = (c) => { | ||
o(c), c && X.some((u) => c[u]) && (s == null || s(c)); | ||
}, f = (c) => { | ||
const u = e.__tres.root.deregisterCamera; | ||
c.isCamera && (u == null || u(c)); | ||
}; | ||
(i = e.removeFromParent) == null || i.call(e), e.traverse((c) => { | ||
a(c), f(c), l == null || l(c); | ||
}), a(e), f(e), l == null || l(e), ye(e), (n = e.dispose) == null || n.call(e); | ||
} | ||
}, | ||
patchProp(e, r, s, o) { | ||
if (e) { | ||
let i = e, n = r; | ||
if (e.__tres.primitive && n === "object" && s !== null) { | ||
const c = Oe.createElement("primitive", void 0, void 0, { | ||
object: o | ||
}); | ||
for (const u in c) { | ||
if (u === "uuid") | ||
continue; | ||
const d = e[u], p = c[u]; | ||
!(d != null && d.set) && !K(d) ? e[u] = p : d.constructor === p.constructor && (d != null && d.copy) ? d == null || d.copy(p) : Array.isArray(p) ? d.set(...p) : !d.isColor && d.setScalar ? d.setScalar(p) : d.set(p); | ||
} | ||
c.__tres.root = t == null ? void 0 : t.__tres.root, c.isGroup ? (e.geometry = void 0, e.material = void 0) : delete e.isGroup; | ||
} | ||
if (e.__tres.root) { | ||
const { | ||
registerBlockingObjectAtPointerEventHandler: c, | ||
deregisterBlockingObjectAtPointerEventHandler: u | ||
} = e.__tres.root; | ||
if (e.isObject3D && n === "blocks-pointer-events") { | ||
o || o === "" ? c(e) : u(e); | ||
return; | ||
} | ||
} | ||
let a = F(n), l = i == null ? void 0 : i[a]; | ||
if (n === "args") { | ||
const c = e, u = s ?? [], d = o ?? [], p = e.__tres.type || e.type; | ||
p && u.length && !sr(u, d) && (i = Object.assign(c, new re.value[p](...o))); | ||
if (f.type === "BufferGeometry") { | ||
if (a === "args") | ||
return; | ||
} | ||
if (i.type === "BufferGeometry") { | ||
if (n === "args") | ||
return; | ||
i.setAttribute( | ||
F(n), | ||
new lt(...o) | ||
); | ||
return; | ||
} | ||
if (n.includes("-") && l === void 0) { | ||
const c = n.split("-"); | ||
l = c.reduce((u, d) => u[F(d)], i), n = c.pop(), a = n.toLowerCase(), l != null && l.set || (i = c.reduce((u, d) => u[F(d)], i)); | ||
} | ||
let f = o; | ||
if (f === "" && (f = !0), K(l)) { | ||
X.includes(r) || (Array.isArray(f) ? e[a](...f) : e[a](f)); | ||
return; | ||
} | ||
!(l != null && l.set) && !K(l) ? i[a] = f : l.constructor === f.constructor && (l != null && l.copy) ? l == null || l.copy(f) : Array.isArray(f) ? l.set(...f) : !l.isColor && l.setScalar ? l.setScalar(f) : l.set(f), ye(e); | ||
f.setAttribute( | ||
F(a), | ||
new at(...c) | ||
); | ||
return; | ||
} | ||
}, | ||
parentNode(e) { | ||
return (e == null ? void 0 : e.parent) || null; | ||
}, | ||
if (a.includes("-") && d === void 0) { | ||
const y = a.split("-"); | ||
d = y.reduce((p, m) => p[F(m)], f), a = y.pop(), g = a.toLowerCase(), d != null && d.set || (f = y.reduce((p, m) => p[F(m)], f)); | ||
} | ||
let h = c; | ||
if (h === "" && (h = !0), K(d)) { | ||
X.includes(o) || (Array.isArray(h) ? n[g](...h) : n[g](h)); | ||
return; | ||
} | ||
!(d != null && d.set) && !K(d) ? f[g] = h : d.constructor === h.constructor && (d != null && d.copy) ? d == null || d.copy(h) : Array.isArray(h) ? d.set(...h) : !d.isColor && d.setScalar ? d.setScalar(h) : d.set(h), ye(n); | ||
} | ||
} | ||
function l(n) { | ||
return (n == null ? void 0 : n.parent) || null; | ||
} | ||
return { | ||
insert: t, | ||
remove: s, | ||
createElement: r, | ||
patchProp: i, | ||
parentNode: l, | ||
createText: () => void 0, | ||
@@ -831,31 +837,31 @@ createComment: () => void 0, | ||
}; | ||
function wr() { | ||
return Be().__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
function bn() { | ||
return Oe().__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
} | ||
function Be() { | ||
return typeof navigator < "u" && typeof window < "u" ? window : typeof global < "u" ? global : {}; | ||
function Oe() { | ||
return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {}; | ||
} | ||
const br = typeof Proxy == "function", Mr = "devtools-plugin:setup", _r = "plugin:settings:set"; | ||
const Mn = typeof Proxy == "function", _n = "devtools-plugin:setup", Cn = "plugin:settings:set"; | ||
let j, oe; | ||
function Er() { | ||
var t; | ||
return j !== void 0 || (typeof window < "u" && window.performance ? (j = !0, oe = window.performance) : typeof global < "u" && (!((t = global.perf_hooks) === null || t === void 0) && t.performance) ? (j = !0, oe = global.perf_hooks.performance) : j = !1), j; | ||
function En() { | ||
var e; | ||
return j !== void 0 || (typeof window < "u" && window.performance ? (j = !0, oe = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (j = !0, oe = globalThis.perf_hooks.performance) : j = !1), j; | ||
} | ||
function Cr() { | ||
return Er() ? oe.now() : Date.now(); | ||
function Sn() { | ||
return En() ? oe.now() : Date.now(); | ||
} | ||
class Sr { | ||
constructor(e, r) { | ||
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = e, this.hook = r; | ||
class xn { | ||
constructor(r, t) { | ||
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = r, this.hook = t; | ||
const s = {}; | ||
if (e.settings) | ||
for (const n in e.settings) { | ||
const a = e.settings[n]; | ||
s[n] = a.defaultValue; | ||
if (r.settings) | ||
for (const n in r.settings) { | ||
const o = r.settings[n]; | ||
s[n] = o.defaultValue; | ||
} | ||
const o = `__vue-devtools-plugin-settings__${e.id}`; | ||
let i = Object.assign({}, s); | ||
const i = `__vue-devtools-plugin-settings__${r.id}`; | ||
let l = Object.assign({}, s); | ||
try { | ||
const n = localStorage.getItem(o), a = JSON.parse(n); | ||
Object.assign(i, a); | ||
const n = localStorage.getItem(i), o = JSON.parse(n); | ||
Object.assign(l, o); | ||
} catch { | ||
@@ -865,34 +871,34 @@ } | ||
getSettings() { | ||
return i; | ||
return l; | ||
}, | ||
setSettings(n) { | ||
try { | ||
localStorage.setItem(o, JSON.stringify(n)); | ||
localStorage.setItem(i, JSON.stringify(n)); | ||
} catch { | ||
} | ||
i = n; | ||
l = n; | ||
}, | ||
now() { | ||
return Cr(); | ||
return Sn(); | ||
} | ||
}, r && r.on(_r, (n, a) => { | ||
n === this.plugin.id && this.fallbacks.setSettings(a); | ||
}, t && t.on(Cn, (n, o) => { | ||
n === this.plugin.id && this.fallbacks.setSettings(o); | ||
}), this.proxiedOn = new Proxy({}, { | ||
get: (n, a) => this.target ? this.target.on[a] : (...l) => { | ||
get: (n, o) => this.target ? this.target.on[o] : (...u) => { | ||
this.onQueue.push({ | ||
method: a, | ||
args: l | ||
method: o, | ||
args: u | ||
}); | ||
} | ||
}), this.proxiedTarget = new Proxy({}, { | ||
get: (n, a) => this.target ? this.target[a] : a === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(a) ? (...l) => (this.targetQueue.push({ | ||
method: a, | ||
args: l, | ||
get: (n, o) => this.target ? this.target[o] : o === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(o) ? (...u) => (this.targetQueue.push({ | ||
method: o, | ||
args: u, | ||
resolve: () => { | ||
} | ||
}), this.fallbacks[a](...l)) : (...l) => new Promise((f) => { | ||
}), this.fallbacks[o](...u)) : (...u) => new Promise((c) => { | ||
this.targetQueue.push({ | ||
method: a, | ||
args: l, | ||
resolve: f | ||
method: o, | ||
args: u, | ||
resolve: c | ||
}); | ||
@@ -902,81 +908,81 @@ }) | ||
} | ||
async setRealTarget(e) { | ||
this.target = e; | ||
for (const r of this.onQueue) | ||
this.target.on[r.method](...r.args); | ||
for (const r of this.targetQueue) | ||
r.resolve(await this.target[r.method](...r.args)); | ||
async setRealTarget(r) { | ||
this.target = r; | ||
for (const t of this.onQueue) | ||
this.target.on[t.method](...t.args); | ||
for (const t of this.targetQueue) | ||
t.resolve(await this.target[t.method](...t.args)); | ||
} | ||
} | ||
function xr(t, e) { | ||
const r = t, s = Be(), o = wr(), i = br && r.enableEarlyProxy; | ||
if (o && (s.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !i)) | ||
o.emit(Mr, t, e); | ||
function Tn(e, r) { | ||
const t = e, s = Oe(), i = bn(), l = Mn && t.enableEarlyProxy; | ||
if (i && (s.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l)) | ||
i.emit(_n, e, r); | ||
else { | ||
const n = i ? new Sr(r, o) : null; | ||
const n = l ? new xn(t, i) : null; | ||
(s.__VUE_DEVTOOLS_PLUGINS__ = s.__VUE_DEVTOOLS_PLUGINS__ || []).push({ | ||
pluginDescriptor: r, | ||
setupFn: e, | ||
pluginDescriptor: t, | ||
setupFn: r, | ||
proxy: n | ||
}), n && e(n.proxiedTarget); | ||
}), n && r(n.proxiedTarget); | ||
} | ||
} | ||
function kr(t, e) { | ||
const r = `▲ ■ ●${t}`; | ||
typeof __VUE_DEVTOOLS_TOAST__ == "function" ? __VUE_DEVTOOLS_TOAST__(r, e) : e === "error" ? console.error(r) : e === "warn" ? console.warn(r) : console.log(r); | ||
function kn(e, r) { | ||
const t = `▲ ■ ●${e}`; | ||
typeof __VUE_DEVTOOLS_TOAST__ == "function" ? __VUE_DEVTOOLS_TOAST__(t, r) : r === "error" ? console.error(t) : r === "warn" ? console.warn(t) : console.log(t); | ||
} | ||
const je = (t) => { | ||
const e = { | ||
id: t.uuid, | ||
label: t.type, | ||
const Be = (e) => { | ||
const r = { | ||
id: e.uuid, | ||
label: e.type, | ||
children: [], | ||
tags: [] | ||
}; | ||
t.name !== "" && e.tags.push({ | ||
label: t.name, | ||
e.name !== "" && r.tags.push({ | ||
label: e.name, | ||
textColor: 5750629, | ||
backgroundColor: 15793395 | ||
}); | ||
const r = Le(t); | ||
return r > 0 && e.tags.push({ | ||
label: `${vr(r)} KB`, | ||
const t = Le(e); | ||
return t > 0 && r.tags.push({ | ||
label: `${vn(t)} KB`, | ||
textColor: 15707189, | ||
backgroundColor: 16775644, | ||
tooltip: "Memory usage" | ||
}), t.type.includes("Light") && (e.tags.push({ | ||
label: `${t.intensity}`, | ||
}), e.type.includes("Light") && (r.tags.push({ | ||
label: `${e.intensity}`, | ||
textColor: 9738662, | ||
backgroundColor: 16316922, | ||
tooltip: "Intensity" | ||
}), e.tags.push({ | ||
label: `#${t.color.getHexString()}`, | ||
}), r.tags.push({ | ||
label: `#${e.color.getHexString()}`, | ||
textColor: 9738662, | ||
backgroundColor: 16316922, | ||
tooltip: "Color" | ||
})), t.type.includes("Camera") && (e.tags.push({ | ||
label: `${t.fov}°`, | ||
})), e.type.includes("Camera") && (r.tags.push({ | ||
label: `${e.fov}°`, | ||
textColor: 9738662, | ||
backgroundColor: 16316922, | ||
tooltip: "Field of view" | ||
}), e.tags.push({ | ||
}), r.tags.push({ | ||
// eslint-disable-next-line max-len | ||
label: `x: ${Math.round(t.position.x)} y: ${Math.round(t.position.y)} z: ${Math.round(t.position.z)}`, | ||
label: `x: ${Math.round(e.position.x)} y: ${Math.round(e.position.y)} z: ${Math.round(e.position.z)}`, | ||
textColor: 9738662, | ||
backgroundColor: 16316922, | ||
tooltip: "Position" | ||
})), e; | ||
})), r; | ||
}; | ||
function De(t, e) { | ||
t.children.forEach((r) => { | ||
if (r.type === "HightlightMesh") | ||
function je(e, r) { | ||
e.children.forEach((t) => { | ||
if (t.type === "HightlightMesh") | ||
return; | ||
const s = je(r); | ||
e.children.push(s), De(r, s); | ||
const s = Be(t); | ||
r.children.push(s), je(t, s); | ||
}); | ||
} | ||
const Tr = [], D = "tres:inspector", Pr = be({ | ||
const Pn = [], D = "tres:inspector", An = be({ | ||
sceneGraph: null | ||
}); | ||
function Ar(t, e) { | ||
xr( | ||
function Ln(e, r) { | ||
Tn( | ||
{ | ||
@@ -988,10 +994,10 @@ id: "dev.esm.tres", | ||
homepage: "https://tresjs.org", | ||
componentStateTypes: Tr, | ||
app: t | ||
componentStateTypes: Pn, | ||
app: e | ||
}, | ||
(r) => { | ||
typeof r.now != "function" && kr( | ||
(t) => { | ||
typeof t.now != "function" && kn( | ||
// eslint-disable-next-line max-len | ||
"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." | ||
), r.addInspector({ | ||
), t.addInspector({ | ||
id: D, | ||
@@ -1002,22 +1008,22 @@ label: "TresJS 🪐", | ||
}), setInterval(() => { | ||
r.sendInspectorTree(D); | ||
t.sendInspectorTree(D); | ||
}, 1e3), setInterval(() => { | ||
r.notifyComponentUpdate(); | ||
}, 5e3), r.on.getInspectorTree((i) => { | ||
if (i.inspectorId === D) { | ||
const n = je(e.scene.value); | ||
De(e.scene.value, n), Pr.sceneGraph = n, i.rootNodes = [n]; | ||
t.notifyComponentUpdate(); | ||
}, 5e3), t.on.getInspectorTree((l) => { | ||
if (l.inspectorId === D) { | ||
const n = Be(r.scene.value); | ||
je(r.scene.value, n), An.sceneGraph = n, l.rootNodes = [n]; | ||
} | ||
}); | ||
let s = null, o = null; | ||
r.on.getInspectorState((i) => { | ||
if (i.inspectorId === D) { | ||
const [n] = e.scene.value.getObjectsByProperty("uuid", i.nodeId); | ||
let s = null, i = null; | ||
t.on.getInspectorState((l) => { | ||
if (l.inspectorId === D) { | ||
const [n] = r.scene.value.getObjectsByProperty("uuid", l.nodeId); | ||
if (!n) | ||
return; | ||
if (o && s && s.parent && o.remove(s), n.isMesh) { | ||
const a = lr(n); | ||
n.add(a), s = a, o = n; | ||
if (i && s && s.parent && i.remove(s), n.isMesh) { | ||
const o = ln(n); | ||
n.add(o), s = o, i = n; | ||
} | ||
i.state = { | ||
l.state = { | ||
object: [ | ||
@@ -1109,4 +1115,4 @@ { | ||
} | ||
}), r.on.editInspectorState((i) => { | ||
i.inspectorId === D && ar(e.scene.value, i.nodeId, i.path, i.state.value); | ||
}), t.on.editInspectorState((l) => { | ||
l.inspectorId === D && an(r.scene.value, l.nodeId, l.path, l.state.value); | ||
}); | ||
@@ -1116,3 +1122,3 @@ } | ||
} | ||
const Lr = ["data-scene", "data-tres"], Or = /* @__PURE__ */ le({ | ||
const On = ["data-scene", "data-tres"], Bn = /* @__PURE__ */ le({ | ||
__name: "TresCanvas", | ||
@@ -1145,32 +1151,32 @@ props: { | ||
emits: ["render"], | ||
setup(t, { expose: e, emit: r }) { | ||
var _; | ||
const s = t, o = r, i = T(), n = $(new ut()), { resume: a } = ae(), l = We(), f = (_ = ue()) == null ? void 0 : _.appContext.app; | ||
ne(Me); | ||
const c = (y) => le({ | ||
setup(e, { expose: r, emit: t }) { | ||
var y; | ||
const s = e, i = t, l = k(), n = $(new lt()), { resume: o } = ae(), u = Fe(), c = (y = ue()) == null ? void 0 : y.appContext.app; | ||
re(Me); | ||
const f = (p) => le({ | ||
setup() { | ||
var g; | ||
const b = (g = ue()) == null ? void 0 : g.appContext; | ||
return b && (b.app = f), ee("useTres", y), ee("extend", ne), typeof window < "u" && Ar(b == null ? void 0 : b.app, y), () => ce(qe, null, l != null && l.default ? l.default() : []); | ||
var v; | ||
const m = (v = ue()) == null ? void 0 : v.appContext; | ||
return m && (m.app = c), ee("useTres", p), ee("extend", re), typeof window < "u" && Ln(m == null ? void 0 : m.app, p), () => ce(Ye, null, u != null && u.default ? u.default() : []); | ||
} | ||
}), u = (y) => { | ||
const b = c(y), { render: g } = Ye(Oe()); | ||
g(ce(b), n.value); | ||
}, d = (y, b = !1) => { | ||
n.value.children = [], b && (y.renderer.value.dispose(), y.renderer.value.renderLists.dispose(), y.renderer.value.forceContextLoss()), u(y), a(); | ||
}, p = x(() => s.disableRender), h = $(null); | ||
return e({ context: h, dispose: () => d(h.value, !0) }), Ue(() => { | ||
const y = i; | ||
h.value = hr({ | ||
}), a = (p) => { | ||
const m = f(p), { render: v } = Qe(wn()); | ||
v(ce(m), n.value); | ||
}, g = (p, m = !1) => { | ||
n.value.children = [], m && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), a(p), o(); | ||
}, d = x(() => s.disableRender), h = $(null); | ||
return r({ context: h, dispose: () => g(h.value, !0) }), We(() => { | ||
const p = l; | ||
h.value = hn({ | ||
scene: n.value, | ||
canvas: y, | ||
canvas: p, | ||
windowSize: s.windowSize ?? !1, | ||
disableRender: p.value ?? !1, | ||
disableRender: d.value ?? !1, | ||
rendererOptions: s, | ||
emit: o | ||
}), mr(h.value); | ||
const { registerCamera: b, camera: g, cameras: E, deregisterCamera: w } = h.value; | ||
u(h.value); | ||
const m = () => { | ||
const v = new te( | ||
emit: i | ||
}), mn(h.value); | ||
const { registerCamera: m, camera: v, cameras: C, deregisterCamera: M } = h.value; | ||
a(h.value); | ||
const w = () => { | ||
const b = new te( | ||
45, | ||
@@ -1181,5 +1187,5 @@ window.innerWidth / window.innerHeight, | ||
); | ||
v.position.set(3, 3, 3), v.lookAt(0, 0, 0), b(v); | ||
const C = se(() => { | ||
E.value.length >= 2 && (v.removeFromParent(), w(v), C == null || C()); | ||
b.position.set(3, 3, 3), b.lookAt(0, 0, 0), m(b); | ||
const E = se(() => { | ||
C.value.length >= 2 && (b.removeFromParent(), M(b), E == null || E()); | ||
}); | ||
@@ -1189,4 +1195,4 @@ }; | ||
() => s.camera, | ||
(v, C) => { | ||
v && b(v), C && (C.removeFromParent(), w(C)); | ||
(b, E) => { | ||
b && m(b), E && (E.removeFromParent(), M(E)); | ||
}, | ||
@@ -1196,14 +1202,14 @@ { | ||
} | ||
), g.value || m(); | ||
}), (y, b) => (Ge(), ze("canvas", { | ||
), v.value || w(); | ||
}), (p, m) => (Ue(), Ge("canvas", { | ||
ref_key: "canvas", | ||
ref: i, | ||
ref: l, | ||
"data-scene": n.value.uuid, | ||
class: Ve(y.$attrs.class), | ||
"data-tres": `tresjs ${Je(Vt).version}`, | ||
style: Qe({ | ||
class: ze(p.$attrs.class), | ||
"data-tres": `tresjs ${Ve(zt).version}`, | ||
style: Je({ | ||
display: "block", | ||
width: "100%", | ||
height: "100%", | ||
position: y.windowSize ? "fixed" : "relative", | ||
position: p.windowSize ? "fixed" : "relative", | ||
top: 0, | ||
@@ -1213,33 +1219,33 @@ left: 0, | ||
touchAction: "none", | ||
...y.$attrs.style | ||
...p.$attrs.style | ||
}) | ||
}, null, 14, Lr)); | ||
}, null, 14, On)); | ||
} | ||
}), Br = [ | ||
}), jn = [ | ||
"TresCanvas", | ||
"TresLeches", | ||
"TresScene" | ||
], jr = { | ||
], Dn = { | ||
template: { | ||
compilerOptions: { | ||
isCustomElement: (t) => t.startsWith("Tres") && !Br.includes(t) || t === "primitive" | ||
isCustomElement: (e) => e.startsWith("Tres") && !jn.includes(e) || e === "primitive" | ||
} | ||
} | ||
}, Qr = jr, Yr = { | ||
mounted: (t, e) => { | ||
if (e.arg) { | ||
console.log(`v-log:${e.arg}`, t[e.arg]); | ||
}, Yn = Dn, qn = { | ||
mounted: (e, r) => { | ||
if (r.arg) { | ||
console.log(`v-log:${r.arg}`, e[r.arg]); | ||
return; | ||
} | ||
console.log("v-log", t); | ||
console.log("v-log", e); | ||
} | ||
}; | ||
class Ie extends ct { | ||
constructor(e, r) { | ||
const s = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], o = new de(); | ||
o.setAttribute("position", new fe(s, 3)), o.computeBoundingSphere(); | ||
const i = new dt({ fog: !1 }); | ||
super(o, i), this.light = e, this.color = r, this.type = "RectAreaLightHelper"; | ||
const n = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new de(); | ||
a.setAttribute("position", new fe(n, 3)), a.computeBoundingSphere(), this.add(new ft(a, new Ee({ side: pt, fog: !1 }))); | ||
class De extends ut { | ||
constructor(r, t) { | ||
const s = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], i = new de(); | ||
i.setAttribute("position", new fe(s, 3)), i.computeBoundingSphere(); | ||
const l = new ct({ fog: !1 }); | ||
super(i, l), this.light = r, this.color = t, this.type = "RectAreaLightHelper"; | ||
const n = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], o = new de(); | ||
o.setAttribute("position", new fe(n, 3)), o.computeBoundingSphere(), this.add(new dt(o, new Ce({ side: ft, fog: !1 }))); | ||
} | ||
@@ -1251,4 +1257,4 @@ updateMatrixWorld() { | ||
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity); | ||
const e = this.material.color, r = Math.max(e.r, e.g, e.b); | ||
r > 1 && e.multiplyScalar(1 / r), this.children[0].material.color.copy(this.material.color); | ||
const r = this.material.color, t = Math.max(r.r, r.g, r.b); | ||
t > 1 && r.multiplyScalar(1 / t), this.children[0].material.color.copy(this.material.color); | ||
} | ||
@@ -1262,32 +1268,32 @@ this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld), this.children[0].matrixWorld.copy(this.matrixWorld); | ||
const { logWarning: we } = P(); | ||
let U, k; | ||
const Dr = { | ||
DirectionalLight: mt, | ||
PointLight: vt, | ||
SpotLight: gt, | ||
HemisphereLight: ht, | ||
RectAreaLight: Ie | ||
}, qr = { | ||
mounted: (t) => { | ||
if (!t.isLight) { | ||
we(`${t.type} is not a light`); | ||
let U, T; | ||
const In = { | ||
DirectionalLight: pt, | ||
PointLight: mt, | ||
SpotLight: vt, | ||
HemisphereLight: gt, | ||
RectAreaLight: De | ||
}, Kn = { | ||
mounted: (e) => { | ||
if (!e.isLight) { | ||
we(`${e.type} is not a light`); | ||
return; | ||
} | ||
U = Dr[t.type], t.parent.add(new U(t, 1, t.color.getHex())); | ||
U = In[e.type], e.parent.add(new U(e, 1, e.color.getHex())); | ||
}, | ||
updated: (t) => { | ||
k = t.parent.children.find((e) => e instanceof U), !(k instanceof Ie) && k.update(); | ||
updated: (e) => { | ||
T = e.parent.children.find((r) => r instanceof U), !(T instanceof De) && T.update(); | ||
}, | ||
unmounted: (t) => { | ||
if (!t.isLight) { | ||
we(`${t.type} is not a light`); | ||
unmounted: (e) => { | ||
if (!e.isLight) { | ||
we(`${e.type} is not a light`); | ||
return; | ||
} | ||
k = t.parent.children.find((e) => e instanceof U), k && k.dispose && k.dispose(), t.parent.remove(k); | ||
T = e.parent.children.find((r) => r instanceof U), T && T.dispose && T.dispose(), e.parent.remove(T); | ||
} | ||
}, { logWarning: Ir } = P(), Kr = { | ||
updated: (t, e) => { | ||
const r = Ae(e); | ||
if (!r) { | ||
Ir(`v-always-look-at: problem with binding value: ${e.value}`); | ||
}, { logWarning: Rn } = P(), Xn = { | ||
updated: (e, r) => { | ||
const t = Ae(r); | ||
if (!t) { | ||
Rn(`v-always-look-at: problem with binding value: ${r.value}`); | ||
return; | ||
@@ -1297,59 +1303,59 @@ } | ||
s(() => { | ||
t.lookAt(r); | ||
e.lookAt(t); | ||
}); | ||
} | ||
}, { logWarning: Rr } = P(), Xr = { | ||
updated: (t, e) => { | ||
var o; | ||
const r = Ae(e); | ||
if (!r) { | ||
Rr(`v-distance-to: problem with binding value: ${e.value}`); | ||
}, { logWarning: $n } = P(), Zn = { | ||
updated: (e, r) => { | ||
var i; | ||
const t = Ae(r); | ||
if (!t) { | ||
$n(`v-distance-to: problem with binding value: ${r.value}`); | ||
return; | ||
} | ||
S && (S.dispose(), t.parent.remove(S)); | ||
const s = r.clone().sub(t.position); | ||
s.normalize(), S = new yt(s, t.position, t.position.distanceTo(r), 16776960), t.parent.add(S), console.table( | ||
S && (S.dispose(), e.parent.remove(S)); | ||
const s = t.clone().sub(e.position); | ||
s.normalize(), S = new ht(s, e.position, e.position.distanceTo(t), 16776960), e.parent.add(S), console.table( | ||
[ | ||
["Distance:", t.position.distanceTo(r)], | ||
[`origin: ${t.name || t.type}`, `x:${t.position.x}, y:${t.position.y}, z:${(o = t.position) == null ? void 0 : o.z}`], | ||
[`Destiny: ${t.name || t.type}`, `x:${r.x}, y:${r.y}, z:${r == null ? void 0 : r.z}`] | ||
["Distance:", e.position.distanceTo(t)], | ||
[`origin: ${e.name || e.type}`, `x:${e.position.x}, y:${e.position.y}, z:${(i = e.position) == null ? void 0 : i.z}`], | ||
[`Destiny: ${e.name || e.type}`, `x:${t.x}, y:${t.y}, z:${t == null ? void 0 : t.z}`] | ||
] | ||
); | ||
}, | ||
unmounted: (t) => { | ||
S == null || S.dispose(), t.parent.remove(S); | ||
unmounted: (e) => { | ||
S == null || S.dispose(), e.parent.remove(S); | ||
} | ||
}; | ||
let S = null; | ||
const Zr = { | ||
install(t) { | ||
t.component("TresCanvas", Or); | ||
const er = { | ||
install(e) { | ||
e.component("TresCanvas", Bn); | ||
} | ||
}; | ||
export { | ||
Or as TresCanvas, | ||
re as catalogue, | ||
Zr as default, | ||
ne as extend, | ||
Wr as isProd, | ||
Xt as normalizeColor, | ||
Ur as normalizeVectorFlexibleParam, | ||
Qr as templateCompilerOptions, | ||
fr as trasverseObjects, | ||
Jt as useCamera, | ||
Gr as useLoader, | ||
Bn as TresCanvas, | ||
ne as catalogue, | ||
er as default, | ||
re as extend, | ||
Un as isProd, | ||
Kt as normalizeColor, | ||
Gn as normalizeVectorFlexibleParam, | ||
Yn as templateCompilerOptions, | ||
fn as trasverseObjects, | ||
Vt as useCamera, | ||
zn as useLoader, | ||
P as useLogger, | ||
mr as usePointerEventHandler, | ||
pr as useRaycaster, | ||
mn as usePointerEventHandler, | ||
pn as useRaycaster, | ||
ae as useRenderLoop, | ||
cr as useRenderer, | ||
Vr as useSeek, | ||
zr as useTexture, | ||
Jr as useTres, | ||
yr as useTresContext, | ||
hr as useTresContextProvider, | ||
Kr as vAlwaysLookAt, | ||
Xr as vDistanceTo, | ||
qr as vLightHelper, | ||
Yr as vLog | ||
cn as useRenderer, | ||
Jn as useSeek, | ||
Vn as useTexture, | ||
Qn as useTres, | ||
yn as useTresContext, | ||
hn as useTresContextProvider, | ||
Xn as vAlwaysLookAt, | ||
Zn as vDistanceTo, | ||
Kn as vLightHelper, | ||
qn as vLog | ||
}; |
{ | ||
"name": "@tresjs/core", | ||
"type": "module", | ||
"version": "4.0.0-next.1", | ||
"version": "4.0.0-next.2", | ||
"packageManager": "pnpm@8.10.2", | ||
@@ -68,4 +68,5 @@ "description": "Declarative ThreeJS using Vue Components", | ||
"dependencies": { | ||
"@alvarosabu/utils": "^3.1.1", | ||
"@vueuse/core": "^10.7.1" | ||
"@alvarosabu/utils": "^3.2.0", | ||
"@vue/devtools-api": "^6.6.1", | ||
"@vueuse/core": "^10.9.0" | ||
}, | ||
@@ -75,38 +76,38 @@ "devDependencies": { | ||
"@stackblitz/sdk": "^1.9.0", | ||
"@tresjs/cientos": "3.7.0", | ||
"@tresjs/cientos": "3.8.0", | ||
"@tresjs/eslint-config-vue": "^0.2.1", | ||
"@types/three": "^0.160.0", | ||
"@typescript-eslint/eslint-plugin": "^6.17.0", | ||
"@typescript-eslint/parser": "^6.17.0", | ||
"@vitejs/plugin-vue": "^5.0.2", | ||
"@types/three": "^0.162.0", | ||
"@typescript-eslint/eslint-plugin": "^7.4.0", | ||
"@typescript-eslint/parser": "^7.4.0", | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"@vitest/ui": "^1.1.1", | ||
"@vue/test-utils": "^2.4.3", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-vue": "^9.19.2", | ||
"esno": "^4.0.0", | ||
"gsap": "^3.12.4", | ||
"jsdom": "^23.0.1", | ||
"@vitest/ui": "^1.4.0", | ||
"@vue/test-utils": "^2.4.5", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-vue": "^9.24.0", | ||
"esno": "^4.7.0", | ||
"gsap": "^3.12.5", | ||
"jsdom": "^24.0.0", | ||
"kolorist": "^1.8.0", | ||
"ohmyfetch": "^0.4.21", | ||
"pathe": "^1.1.1", | ||
"release-it": "^17.0.1", | ||
"pathe": "^1.1.2", | ||
"release-it": "^17.1.1", | ||
"rollup-plugin-analyzer": "^4.0.0", | ||
"rollup-plugin-copy": "^3.5.0", | ||
"rollup-plugin-visualizer": "^5.12.0", | ||
"three": "^0.160.0", | ||
"unocss": "^0.58.3", | ||
"unplugin": "^1.6.0", | ||
"three": "^0.162.0", | ||
"unocss": "^0.58.7", | ||
"unplugin": "^1.10.0", | ||
"unplugin-vue-components": "^0.26.0", | ||
"vite": "^5.0.10", | ||
"vite": "^5.2.6", | ||
"vite-plugin-banner": "^0.7.1", | ||
"vite-plugin-dts": "3.7.0", | ||
"vite-plugin-inspect": "^0.8.1", | ||
"vite-plugin-dts": "3.7.3", | ||
"vite-plugin-inspect": "^0.8.3", | ||
"vite-plugin-require-transform": "^1.0.21", | ||
"vite-svg-loader": "^5.1.0", | ||
"vitepress": "1.0.0-rc.34", | ||
"vitest": "^1.1.1", | ||
"vue": "^3.4.3", | ||
"vue-demi": "^0.14.6" | ||
"vitepress": "1.0.1", | ||
"vitest": "^1.4.0", | ||
"vue": "^3.4.21", | ||
"vue-demi": "^0.14.7" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
450123
5
41
6567
+ Added@vue/devtools-api@^6.6.1
+ Added@vue/devtools-api@6.6.4(transitive)
Updated@alvarosabu/utils@^3.2.0
Updated@vueuse/core@^10.9.0