Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tresjs/core

Package Overview
Dependencies
Maintainers
2
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tresjs/core - npm Package Compare versions

Comparing version 4.2.5 to 4.2.6

838

dist/tres.js
/**
* name: @tresjs/core
* version: v4.2.5
* version: v4.2.6
* (c) 2024

@@ -11,7 +11,7 @@ * description: Declarative ThreeJS using Vue Components

var me = (e, t, n) => Pt(e, typeof t != "symbol" ? t + "" : t, n);
import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as ce, readonly as ye, unref as J, provide as _e, inject as Mt, isRef as Ct, reactive as Et, defineComponent as Be, useSlots as Tt, getCurrentInstance as Ie, onMounted as St, openBlock as At, createElementBlock as kt, normalizeClass as xt, normalizeStyle as Lt, createRenderer as Rt, h as He, Fragment as Ot } from "vue";
import { ref as H, computed as V, watchEffect as Te, onUnmounted as K, shallowRef as $, watch as ce, readonly as ye, unref as J, provide as _e, inject as Ct, isRef as Mt, reactive as Et, defineComponent as Be, useSlots as Tt, getCurrentInstance as Ie, onMounted as St, openBlock as At, createElementBlock as xt, normalizeClass as kt, normalizeStyle as Lt, createRenderer as Rt, h as He, Fragment as Ot } from "vue";
import * as et from "three";
import { PerspectiveCamera as we, Camera as Dt, Clock as tt, Vector3 as Se, Color as Z, Scene as nt, MathUtils as rt, MeshBasicMaterial as ot, DoubleSide as jt, REVISION as Bt, SRGBColorSpace as It, ACESFilmicToneMapping as st, PCFSoftShadowMap as Ht, NoToneMapping as $t, WebGLRenderer as he, TextureLoader as Ut, Vector2 as ge, Raycaster as Ft, BufferAttribute as Wt, Object3D as Nt, Line as zt, BufferGeometry as $e, Float32BufferAttribute as Ue, LineBasicMaterial as Gt, Mesh as Vt, BackSide as Yt, DirectionalLightHelper as qt, PointLightHelper as Jt, SpotLightHelper as Kt, HemisphereLightHelper as Qt, ArrowHelper as Xt } from "three";
import { createEventHook as j, useRafFn as it, toValue as k, unrefElement as Zt, useDevicePixelRatio as en, usePointer as tn, useElementBounding as nn, useWindowSize as rn, useElementSize as on, refDebounced as Fe, tryOnScopeDispose as sn, useFps as an, useMemory as ln } from "@vueuse/core";
const cn = "@tresjs/core", un = "module", fn = "4.2.5", dn = "pnpm@9.1.4", pn = "Declarative ThreeJS using Vue Components", mn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", hn = "MIT", gn = [
const cn = "@tresjs/core", un = "module", fn = "4.2.6", dn = "pnpm@9.1.4", pn = "Declarative ThreeJS using Vue Components", mn = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", hn = "MIT", gn = [
"vue",

@@ -44,5 +44,5 @@ "3d",

"dist"
], Mn = {
], Cn = {
access: "public"
}, Cn = {
}, Mn = {
dev: "cd playground && npm run dev",

@@ -127,4 +127,4 @@ build: "vite build",

files: Pn,
publishConfig: Mn,
scripts: Cn,
publishConfig: Cn,
scripts: Mn,
peerDependencies: En,

@@ -140,3 +140,3 @@ dependencies: Tn,

}
function kn(e) {
function xn(e) {
return typeof e == "number";

@@ -159,3 +159,3 @@ }

}
function xn(e) {
function kn(e) {
return U(e) && "isBufferGeometry" in e && !!e.isBufferGeometry;

@@ -176,3 +176,3 @@ }

function oe(e) {
return N(e) || xn(e) || Ln(e) || On(e);
return N(e) || kn(e) || Ln(e) || On(e);
}

@@ -186,8 +186,8 @@ function jn(e) {

), r = (i) => {
const l = i instanceof Dt ? i : t.value.find((o) => o.uuid === i);
if (!l)
const a = i instanceof Dt ? i : t.value.find((o) => o.uuid === i);
if (!a)
return;
const c = t.value.filter(({ uuid: o }) => o !== l.uuid);
t.value = [l, ...c];
}, s = (i, l = !1) => {
const c = t.value.filter(({ uuid: o }) => o !== a.uuid);
t.value = [a, ...c];
}, s = (i, a = !1) => {
if (We(i)) {

@@ -197,8 +197,8 @@ const c = i;

return;
l ? r(c) : t.value.push(c);
a ? r(c) : t.value.push(c);
}
}, a = (i) => {
}, l = (i) => {
if (We(i)) {
const l = i;
t.value = t.value.filter(({ uuid: c }) => c !== l.uuid);
const a = i;
t.value = t.value.filter(({ uuid: c }) => c !== a.uuid);
}

@@ -216,3 +216,3 @@ };

registerCamera: s,
deregisterCamera: a,
deregisterCamera: l,
setCameraActive: r

@@ -305,8 +305,8 @@ };

const r = Array.isArray(t) ? t : t.match(/([^[.\]])+/g);
r && r.reduce((s, a, i) => (s[a] === void 0 && (s[a] = {}), i === r.length - 1 && (s[a] = n), s[a]), e);
r && r.reduce((s, l, i) => (s[l] === void 0 && (s[l] = {}), i === r.length - 1 && (s[l] = n), s[l]), e);
};
function ft(e, t) {
if (Ge(e) && Ge(t)) {
const s = e.attributes, a = t.attributes;
return s.length !== a.length ? !1 : Array.from(s).every(({ name: i, value: l }) => t.getAttribute(i) === l);
const s = e.attributes, l = t.attributes;
return s.length !== l.length ? !1 : Array.from(s).every(({ name: i, value: a }) => t.getAttribute(i) === a);
}

@@ -343,8 +343,8 @@ if (e === t)

}
}, a = s(e);
if (!a) {
}, l = s(e);
if (!l) {
console.warn("Object with UUID not found in the scene.");
return;
}
let i = a;
let i = l;
for (let c = 0; c < n.length - 1; c++)

@@ -357,4 +357,4 @@ if (i[n[c]] !== void 0)

}
const l = n[n.length - 1];
i[l] !== void 0 ? i[l] = r : console.warn(`Property path is not valid: ${n.join(".")}`);
const a = n[n.length - 1];
i[a] !== void 0 ? i[a] = r : console.warn(`Property path is not valid: ${n.join(".")}`);
}

@@ -389,3 +389,3 @@ function Qn(e) {

const s = e;
e && ((r = e.dispose) == null || r.call(e)), s.geometry && (s.geometry.dispose(), delete s.geometry), Array.isArray(s.material) ? (s.material.forEach((a) => Ye(a)), delete s.material) : s.material && (Ye(s.material), delete s.material);
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);
}

@@ -417,8 +417,8 @@ }

if (Je.test(n)) {
const a = n.replace(Je, ""), { target: i, key: l } = Pe(e, a);
if (!Array.isArray(i[l])) {
const c = i[l], o = [];
const l = n.replace(Je, ""), { target: i, key: a } = Pe(e, l);
if (!Array.isArray(i[a])) {
const c = i[a], o = [];
o.__tresDetach = () => {
o.every((u) => be(u)) && (i[l] = c);
}, i[l] = o;
o.every((u) => be(u)) && (i[a] = c);
}, i[a] = o;
}

@@ -432,9 +432,9 @@ }

function nr(e, t, n) {
var r, s, a;
var r, s, l;
if (at(n)) {
const { target: i, key: l } = Pe(e, n), c = t.__tres.previousAttach;
c === void 0 ? delete i[l] : i[l] = c, "__tresDetach" in i && i.__tresDetach();
const { target: i, key: a } = Pe(e, n), c = t.__tres.previousAttach;
c === void 0 ? delete i[a] : i[a] = c, "__tresDetach" in i && i.__tresDetach();
} else
(s = (r = t.__tres) == null ? void 0 : r.previousAttach) == null || s.call(r, e, t);
(a = t.__tres) == null || delete a.previousAttach;
(l = t.__tres) == null || delete l.previousAttach;
}

@@ -466,20 +466,20 @@ function z(e, t, n) {

if (de(n) && n.length >= 2) {
const [a, i] = n;
r = rt.clamp(t, a, i);
} else kn(n) ? r = n : r = t;
const [l, i] = n;
r = rt.clamp(t, l, i);
} else xn(n) ? r = n : r = t;
r !== ((s = e.getPixelRatio) == null ? void 0 : s.call(e)) && e.setPixelRatio(r);
}
function or(e, t, n, r, s) {
const a = [...t.__tres.objects], i = Q(t);
const l = [...t.__tres.objects], i = Q(t);
if (e = Q(e), i === e)
return !0;
const l = z(e, t.__tres ?? {}, s), c = t.parent ?? t.__tres.parent ?? null, o = { ...t.__tres.memoizedProps };
const a = z(e, t.__tres ?? {}, s), c = t.parent ?? t.__tres.parent ?? null, o = { ...t.__tres.memoizedProps };
delete o.object;
for (const u of a)
for (const u of l)
mt(u, s), ht(u, s);
i.__tres.objects = [], r.remove(t);
for (const [u, y] of Object.entries(o))
r.patchProp(l, u, l[u], y);
for (const [u, v] of Object.entries(o))
r.patchProp(a, u, a[u], v);
n(e), r.insert(t, c);
for (const u of a)
for (const u of l)
r.insert(u, t);

@@ -492,5 +492,5 @@ return !0;

function mt(e, t) {
var r, s, a, i;
var r, s, l, i;
const n = ((r = e.__tres) == null ? void 0 : r.parent) || t.scene.value;
e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && er(n.__tres.objects, (l) => l !== e), (s = e.__tres) != null && s.attach ? nr(n, e, e.__tres.attach) : ((i = (a = e.parent) == null ? void 0 : a.remove) == null || i.call(a, Q(e)), e.parent = null);
e.__tres && (e.__tres.parent = null), n && n.__tres && "objects" in n.__tres && er(n.__tres.objects, (a) => a !== e), (s = e.__tres) != null && s.attach ? nr(n, e, e.__tres.attach) : ((i = (l = e.parent) == null ? void 0 : l.remove) == null || i.call(l, Q(e)), e.parent = null);
}

@@ -524,3 +524,3 @@ function ht(e, t) {

options: t,
contextParts: { sizes: n, render: r, invalidate: s, advance: a }
contextParts: { sizes: n, render: r, invalidate: s, advance: l }
}) {

@@ -540,3 +540,3 @@ const i = V(() => ({

failIfMajorPerformanceCaveat: k(t.failIfMajorPerformanceCaveat)
})), l = $(new he(i.value));
})), a = $(new he(i.value));
function c() {

@@ -546,5 +546,5 @@ t.renderMode === "on-demand" && s();

ce(i, () => {
l.value.dispose(), l.value = new he(i.value), c();
a.value.dispose(), a.value = new he(i.value), c();
}), ce([n.width, n.height], () => {
l.value.setSize(n.width.value, n.height.value), c();
a.value.setSize(n.width.value, n.height.value), c();
}, {

@@ -554,31 +554,31 @@ immediate: !0

const { pixelRatio: o } = en(), { logError: u } = Y(), f = (() => {
const v = new he(), b = {
const g = new he(), b = {
shadowMap: {
enabled: v.shadowMap.enabled,
type: v.shadowMap.type
enabled: g.shadowMap.enabled,
type: g.shadowMap.type
},
toneMapping: v.toneMapping,
toneMappingExposure: v.toneMappingExposure,
outputColorSpace: v.outputColorSpace
toneMapping: g.toneMapping,
toneMappingExposure: g.toneMappingExposure,
outputColorSpace: g.outputColorSpace
};
return v.dispose(), b;
})(), g = k(t.renderMode);
return g === "on-demand" && s(), g === "manual" && setTimeout(() => {
a();
return g.dispose(), b;
})(), h = k(t.renderMode);
return h === "on-demand" && s(), h === "manual" && setTimeout(() => {
l();
}, 100), Te(() => {
const v = k(t.preset);
v && (v in ae || u(`Renderer Preset must be one of these: ${Object.keys(ae).join(", ")}`), ut(l.value, ae[v])), rr(l.value, o.value, k(t.dpr)), g === "always" && (r.frames.value = Math.max(1, r.frames.value));
const b = (C, E) => {
const P = k(C), S = () => {
if (v)
return Ve(ae[v], E);
const g = k(t.preset);
g && (g in ae || u(`Renderer Preset must be one of these: ${Object.keys(ae).join(", ")}`), ut(a.value, ae[g])), rr(a.value, o.value, k(t.dpr)), h === "always" && (r.frames.value = Math.max(1, r.frames.value));
const b = (C, M) => {
const P = k(C), E = () => {
if (g)
return Ve(ae[g], M);
};
if (P !== void 0)
return P;
const M = S();
return M !== void 0 ? M : Ve(f, E);
}, m = (C, E) => Yn(l.value, E, b(C, E));
m(t.shadows, "shadowMap.enabled"), m(t.toneMapping ?? st, "toneMapping"), m(t.shadowMapType, "shadowMap.type"), sr < 150 && m(!t.useLegacyLights, "physicallyCorrectLights"), m(t.outputColorSpace, "outputColorSpace"), m(t.toneMappingExposure, "toneMappingExposure");
const S = E();
return S !== void 0 ? S : Ve(f, M);
}, y = (C, M) => Yn(a.value, M, b(C, M));
y(t.shadows, "shadowMap.enabled"), y(t.toneMapping ?? st, "toneMapping"), y(t.shadowMapType, "shadowMap.type"), sr < 150 && y(!t.useLegacyLights, "physicallyCorrectLights"), y(t.outputColorSpace, "outputColorSpace"), y(t.toneMappingExposure, "toneMappingExposure");
const d = b(t.clearColor, "clearColor");
d && l.value.setClearColor(
d && a.value.setClearColor(
d ? Un(d) : new Z(0)

@@ -588,5 +588,5 @@ // default clear color is not easily/efficiently retrievable from three

}), K(() => {
l.value.dispose(), l.value.forceContextLoss();
a.value.dispose(), a.value.forceContextLoss();
}), {
renderer: l
renderer: a
};

@@ -602,14 +602,14 @@ }

async function Nr(e, t, n, r, s) {
const { logError: a } = Y(), i = new e();
const { logError: l } = Y(), i = new e();
s && s(i), n && n(i);
const c = (Array.isArray(t) ? t : [t]).map(
(o) => new Promise((u, y) => {
(o) => new Promise((u, v) => {
i.load(
o,
(f) => {
const g = f;
g.scene && Object.assign(g, lr(g.scene)), u(g);
const h = f;
h.scene && Object.assign(h, lr(h.scene)), u(h);
},
r,
(f) => y(a("[useLoader] - Failed to load resource", f))
(f) => v(l("[useLoader] - Failed to load resource", f))
);

@@ -621,6 +621,6 @@ })

async function zr(e, t) {
const n = new Ut(t), r = (s) => new Promise((a, i) => {
const n = new Ut(t), r = (s) => new Promise((l, i) => {
n.load(
s,
(l) => a(l),
(a) => l(a),
() => null,

@@ -633,3 +633,3 @@ () => {

if (Jn(e)) {
const s = await Promise.all(e.map((a) => r(a)));
const s = await Promise.all(e.map((l) => r(l)));
return e.length > 1 ? s : s[0];

@@ -639,19 +639,19 @@ } else {

map: s,
displacementMap: a,
displacementMap: l,
normalMap: i,
roughnessMap: l,
roughnessMap: a,
metalnessMap: c,
aoMap: o,
alphaMap: u,
matcap: y
matcap: v
} = e;
return {
map: s ? await r(s) : null,
displacementMap: a ? await r(a) : null,
displacementMap: l ? await r(l) : null,
normalMap: i ? await r(i) : null,
roughnessMap: l ? await r(l) : null,
roughnessMap: a ? await r(a) : null,
metalnessMap: c ? await r(c) : null,
aoMap: o ? await r(o) : null,
alphaMap: u ? await r(u) : null,
matcap: y ? await r(y) : null
matcap: v ? await r(v) : null
};

@@ -661,30 +661,30 @@ }

const cr = (e, t) => {
const n = V(() => t.renderer.value.domElement), r = $([]), { x: s, y: a } = tn({ target: n });
const n = V(() => t.renderer.value.domElement), r = $([]), { x: s, y: l } = tn({ target: n });
let i = 0;
const { width: l, height: c, top: o, left: u } = nn(n), y = ({ x: h, y: T }) => {
const { width: a, height: c, top: o, left: u } = nn(n), v = ({ x: m, y: T }) => {
if (n.value)
return {
x: (h - u.value) / l.value * 2 - 1,
x: (m - u.value) / a.value * 2 - 1,
y: -((T - o.value) / c.value) * 2 + 1
};
}, f = ({ x: h, y: T }) => {
}, f = ({ x: m, y: T }) => {
if (t.camera.value)
return t.raycaster.value.setFromCamera(new ge(h, T), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
}, g = (h) => {
const T = y({
x: (h == null ? void 0 : h.clientX) ?? s.value,
y: (h == null ? void 0 : h.clientY) ?? a.value
return t.raycaster.value.setFromCamera(new ge(m, T), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;
}, h = (m) => {
const T = v({
x: (m == null ? void 0 : m.clientX) ?? s.value,
y: (m == null ? void 0 : m.clientY) ?? l.value
});
return T ? f(T) || [] : [];
}, v = j(), b = j(), m = j(), d = j(), C = j(), E = j(), P = j(), S = j();
function M(h) {
}, g = j(), b = j(), y = j(), d = j(), C = j(), M = j(), P = j(), E = j();
function S(m) {
const T = {};
for (const F in h)
typeof F != "function" && (T[F] = h[F]);
for (const F in m)
typeof F != "function" && (T[F] = m[F]);
return T;
}
const _ = (h, T) => {
const _ = (m, T) => {
var Oe, De, je;
const F = M(T), re = new Se(T == null ? void 0 : T.clientX, T == null ? void 0 : T.clientY, 0).unproject((Oe = t.camera) == null ? void 0 : Oe.value);
h.trigger({
const F = S(T), re = new Se(T == null ? void 0 : T.clientX, T == null ? void 0 : T.clientY, 0).unproject((Oe = t.camera) == null ? void 0 : Oe.value);
m.trigger({
...F,

@@ -701,38 +701,38 @@ intersections: r.value,

};
let L;
const x = (h) => {
g(h), _(m, h), L = h;
let A;
const L = (m) => {
h(m), _(y, m), A = m;
}, p = () => {
L && x(L);
A && L(A);
};
let w, A, D;
const O = (h) => {
let w, x, D;
const O = (m) => {
var T;
w = (T = r.value[0]) == null ? void 0 : T.object, i = 0, A = new ge(
(h == null ? void 0 : h.clientX) ?? s.value,
(h == null ? void 0 : h.clientY) ?? a.value
), _(C, h);
w = (T = r.value[0]) == null ? void 0 : T.object, i = 0, x = new ge(
(m == null ? void 0 : m.clientX) ?? s.value,
(m == null ? void 0 : m.clientY) ?? l.value
), _(C, m);
};
let B, R = !1;
const ne = (h) => {
const ne = (m) => {
var T, F, re;
h instanceof PointerEvent && (r.value.length === 0 && _(E, h), w === ((T = r.value[0]) == null ? void 0 : T.object) && (D = new ge(
(h == null ? void 0 : h.clientX) ?? s.value,
(h == null ? void 0 : h.clientY) ?? a.value
), i = A == null ? void 0 : A.distanceTo(D), h.button === 0 ? (_(v, h), B === ((F = r.value[0]) == null ? void 0 : F.object) ? R = !0 : (B = (re = r.value[0]) == null ? void 0 : re.object, R = !1)) : h.button === 2 && _(P, h)), _(d, h));
}, xe = (h) => {
R && (_(b, h), B = void 0, R = !1);
}, Le = (h) => _(m, h), Re = (h) => _(S, h);
return n.value.addEventListener("pointerup", ne), n.value.addEventListener("pointerdown", O), n.value.addEventListener("pointermove", x), n.value.addEventListener("pointerleave", Le), n.value.addEventListener("dblclick", xe), n.value.addEventListener("wheel", Re), K(() => {
n != null && n.value && (n.value.removeEventListener("pointerup", ne), n.value.removeEventListener("pointerdown", O), n.value.removeEventListener("pointermove", x), n.value.removeEventListener("pointerleave", Le), n.value.removeEventListener("dblclick", xe), n.value.removeEventListener("wheel", Re));
m instanceof PointerEvent && (r.value.length === 0 && _(M, m), w === ((T = r.value[0]) == null ? void 0 : T.object) && (D = new ge(
(m == null ? void 0 : m.clientX) ?? s.value,
(m == null ? void 0 : m.clientY) ?? l.value
), i = x == null ? void 0 : x.distanceTo(D), m.button === 0 ? (_(g, m), B === ((F = r.value[0]) == null ? void 0 : F.object) ? R = !0 : (B = (re = r.value[0]) == null ? void 0 : re.object, R = !1)) : m.button === 2 && _(P, m)), _(d, m));
}, ke = (m) => {
R && (_(b, m), B = void 0, R = !1);
}, Le = (m) => _(y, m), Re = (m) => _(E, m);
return n.value.addEventListener("pointerup", ne), n.value.addEventListener("pointerdown", O), n.value.addEventListener("pointermove", L), n.value.addEventListener("pointerleave", Le), n.value.addEventListener("dblclick", ke), n.value.addEventListener("wheel", Re), K(() => {
n != null && n.value && (n.value.removeEventListener("pointerup", ne), n.value.removeEventListener("pointerdown", O), n.value.removeEventListener("pointermove", L), n.value.removeEventListener("pointerleave", Le), n.value.removeEventListener("dblclick", ke), n.value.removeEventListener("wheel", Re));
}), {
intersects: r,
onClick: (h) => v.on(h).off,
onDblClick: (h) => b.on(h).off,
onContextMenu: (h) => P.on(h).off,
onPointerMove: (h) => m.on(h).off,
onPointerUp: (h) => d.on(h).off,
onPointerDown: (h) => C.on(h).off,
onPointerMissed: (h) => E.on(h).off,
onWheel: (h) => S.on(h).off,
onClick: (m) => g.on(m).off,
onDblClick: (m) => b.on(m).off,
onContextMenu: (m) => P.on(m).off,
onPointerMove: (m) => y.on(m).off,
onPointerUp: (m) => d.on(m).off,
onPointerDown: (m) => C.on(m).off,
onPointerMissed: (m) => M.on(m).off,
onWheel: (m) => E.on(m).off,
forceUpdate: p

@@ -743,19 +743,19 @@ };

const { logWarning: e } = Y();
function t(a, i, l) {
function t(l, i, a) {
let c = null;
return a.traverse((o) => {
o[i] === l && (c = o);
}), c || e(`Child with ${i} '${l}' not found.`), c;
return l.traverse((o) => {
o[i] === a && (c = o);
}), c || e(`Child with ${i} '${a}' not found.`), c;
}
function n(a, i, l) {
function n(l, i, a) {
const c = [];
return a.traverse((o) => {
o[i].includes(l) && c.push(o);
}), c.length || e(`Children with ${i} '${l}' not found.`), c;
return l.traverse((o) => {
o[i].includes(a) && c.push(o);
}), c.length || e(`Children with ${i} '${a}' not found.`), c;
}
function r(a, i) {
return t(a, "name", i);
function r(l, i) {
return t(l, "name", i);
}
function s(a, i) {
return n(a, "name", i);
function s(l, i) {
return n(l, "name", i);
}

@@ -769,7 +769,7 @@ return {

}
function ke(e) {
function xe(e) {
let t = 0;
return e.traverse((n) => {
if (n.isMesh && n.geometry && n.type !== "HightlightMesh") {
const r = n.geometry, s = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, a = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, i = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, l = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = s + a + i + l;
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;
t += c;

@@ -782,8 +782,8 @@ }

}
const Me = H({}), Ce = (e) => Object.assign(Me.value, e);
const Ce = H({}), Me = (e) => Object.assign(Ce.value, e);
function fr(e, t, n) {
var x;
var L;
const r = $(), s = $();
e && (r.value = e), t && (s.value = t);
const a = (p) => {
const l = (p) => {
var w;

@@ -793,12 +793,12 @@ return ((w = p.__tres) == null ? void 0 : w.eventCount) > 0;

var w;
return ((w = p.children) == null ? void 0 : w.some((A) => i(A))) || a(p);
}, l = $(((x = r.value) == null ? void 0 : x.children).filter(i) || []);
return ((w = p.children) == null ? void 0 : w.some((x) => i(x))) || l(p);
}, a = $(((L = r.value) == null ? void 0 : L.children).filter(i) || []);
function c(p, w) {
if (Array.isArray(p))
for (const A of p)
A(w);
for (const x of p)
x(w);
typeof p == "function" && p(w);
}
function o(p, w) {
const A = [], D = () => w.stopPropagating = !0;
const x = [], D = () => w.stopPropagating = !0;
w.stopPropagation = D;

@@ -810,6 +810,6 @@ for (const O of w == null ? void 0 : w.intersections) {

const { object: B } = O;
w.eventObject = B, c(B[p], w), A.push(B);
w.eventObject = B, c(B[p], w), x.push(B);
let R = B.parent;
for (; R !== null && !w.stopPropagating && !A.includes(R); )
w.eventObject = R, c(R[p], w), A.push(R), R = R.parent;
for (; R !== null && !w.stopPropagating && !x.includes(R); )
w.eventObject = R, c(R[p], w), x.push(R), R = R.parent;
const ne = Gn(p.slice(2));

@@ -821,35 +821,35 @@ n(ne, { intersection: O, event: w });

onClick: u,
onDblClick: y,
onDblClick: v,
onContextMenu: f,
onPointerMove: g,
onPointerDown: v,
onPointerMove: h,
onPointerDown: g,
onPointerUp: b,
onPointerMissed: m,
onPointerMissed: y,
onWheel: d,
forceUpdate: C
} = cr(l, t);
b((p) => o("onPointerUp", p)), v((p) => o("onPointerDown", p)), u((p) => o("onClick", p)), y((p) => o("onDoubleClick", p)), f((p) => o("onContextMenu", p)), d((p) => o("onWheel", p));
let E = [];
g((p) => {
const w = p.intersections.map(({ object: D }) => D), A = p.intersections;
E.forEach(({ object: D }) => {
w.includes(D) || (p.intersections = E, o("onPointerLeave", p), o("onPointerOut", p));
}), p.intersections = A, p.intersections.forEach(({ object: D }) => {
E.includes(D) || (o("onPointerEnter", p), o("onPointerOver", p));
}), o("onPointerMove", p), E = p.intersections;
} = cr(a, t);
b((p) => o("onPointerUp", p)), g((p) => o("onPointerDown", p)), u((p) => o("onClick", p)), v((p) => o("onDoubleClick", p)), f((p) => o("onContextMenu", p)), d((p) => o("onWheel", p));
let M = [];
h((p) => {
const w = p.intersections.map(({ object: D }) => D), x = p.intersections;
M.forEach(({ object: D }) => {
w.includes(D) || (p.intersections = M, o("onPointerLeave", p), o("onPointerOut", p));
}), p.intersections = x, p.intersections.forEach(({ object: D }) => {
M.includes(D) || (o("onPointerEnter", p), o("onPointerOver", p));
}), o("onPointerMove", p), M = p.intersections;
});
const P = [];
m((p) => {
y((p) => {
const w = () => p.stopPropagating = !0;
p.stopPropagation = w, P.forEach((A) => {
p.stopPropagating || (p.eventObject = A, c(A.onPointerMissed, p));
p.stopPropagation = w, P.forEach((x) => {
p.stopPropagating || (p.eventObject = x, c(x.onPointerMissed, p));
}), n("pointer-missed", { event: p });
});
function E(p) {
oe(p) && N(p) && a.value.push(p);
}
function S(p) {
oe(p) && N(p) && l.value.push(p);
}
function M(p) {
if (oe(p) && N(p)) {
const w = l.value.indexOf(p);
w > -1 && l.value.splice(w, 1);
const w = a.value.indexOf(p);
w > -1 && a.value.splice(w, 1);
}

@@ -860,3 +860,3 @@ }

}
function L(p) {
function A(p) {
if (oe(p) && N(p)) {

@@ -869,18 +869,18 @@ const w = P.indexOf(p);

forceUpdate: C,
registerObject: S,
deregisterObject: M,
registerObject: E,
deregisterObject: S,
registerPointerMissedObject: _,
deregisterPointerMissedObject: L
deregisterPointerMissedObject: A
}, {
forceUpdate: C,
registerObject: S,
deregisterObject: M,
registerObject: E,
deregisterObject: S,
registerPointerMissedObject: _,
deregisterPointerMissedObject: L
deregisterPointerMissedObject: A
};
}
function dr(e, t, n = 10) {
const r = k(e) ? rn() : on(V(() => k(t).parentElement)), s = ye(Fe(r.width, n)), a = ye(Fe(r.height, n)), i = V(() => s.value / a.value);
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);
return {
height: a,
height: l,
width: s,

@@ -894,8 +894,8 @@ aspectRatio: i

const s = () => {
const o = Array.from(e.entries()).sort((u, y) => {
const f = u[1].priority - y[1].priority;
return f === 0 ? u[1].addI - y[1].addI : f;
const o = Array.from(e.entries()).sort((u, v) => {
const f = u[1].priority - v[1].priority;
return f === 0 ? u[1].addI - v[1].addI : f;
});
t.clear(), o.forEach((u) => t.add(u[0]));
}, a = (o) => {
}, l = (o) => {
e.delete(o), t.delete(o);

@@ -905,7 +905,7 @@ };

e.set(o, { priority: u, addI: n++ });
const y = () => a(o);
return sn(y), r = !0, {
off: y
const v = () => l(o);
return sn(v), r = !0, {
off: v
};
}, off: a, trigger: (...o) => {
}, off: l, trigger: (...o) => {
r && (s(), r = !1), t.forEach((u) => u(...o));

@@ -920,46 +920,46 @@ }, dispose: () => {

let e = !0, t = !0, n = !1;
const r = new tt(!1), s = H(r.running), a = H(!1);
const r = new tt(!1), s = H(r.running), l = H(!1);
let i;
const l = rt.generateUUID();
const a = rt.generateUUID();
let c = null;
const o = ve(), u = ve(), y = ve();
M();
const o = ve(), u = ve(), v = ve();
S();
let f = {};
function g(_) {
function h(_) {
f = _;
}
function v(_, L, x = 0) {
switch (L) {
function g(_, A, L = 0) {
switch (A) {
case "before":
return o.on(_, x);
return o.on(_, L);
case "render":
return c || (c = _), u.dispose(), u.on(_);
case "after":
return y.on(_, x);
return v.on(_, L);
}
}
function b() {
t && (t = !1, M(), S());
t && (t = !1, S(), E());
}
function m() {
t = !0, M(), cancelAnimationFrame(i);
function y() {
t = !0, S(), cancelAnimationFrame(i);
}
function d() {
n = !1, M();
n = !1, S();
}
function C() {
n = !0, M();
n = !0, S();
}
function E() {
a.value = !0;
function M() {
l.value = !0;
}
function P() {
a.value = !1;
l.value = !1;
}
function S() {
function E() {
if (!e) {
i = requestAnimationFrame(S);
i = requestAnimationFrame(E);
return;
}
const _ = r.getDelta(), L = r.getElapsedTime(), x = {
const _ = r.getDelta(), A = r.getElapsedTime(), L = {
camera: J(f.camera),

@@ -972,6 +972,6 @@ scene: J(f.scene),

advance: f.advance
}, p = { delta: _, elapsed: L, clock: r, ...x };
s.value && o.trigger(p), a.value || (u.count ? u.trigger(p) : c && c(p)), s.value && y.trigger(p), i = requestAnimationFrame(S);
}, p = { delta: _, elapsed: A, clock: r, ...L };
s.value && o.trigger(p), l.value || (u.count ? u.trigger(p) : c && c(p)), s.value && v.trigger(p), i = requestAnimationFrame(E);
}
function M() {
function S() {
const _ = !t && !n;

@@ -981,13 +981,13 @@ r.running !== _ && (r.running ? r.stop() : r.start()), s.value = r.running;

return {
loopId: l,
register: (_, L, x) => v(_, L, x),
loopId: a,
register: (_, A, L) => g(_, A, L),
start: b,
stop: m,
stop: y,
pause: C,
resume: d,
pauseRender: E,
pauseRender: M,
resumeRender: P,
isRenderPaused: a,
isRenderPaused: l,
isActive: s,
setContext: g,
setContext: h,
setReady: (_) => e = _

@@ -999,21 +999,21 @@ };

const r = j(), s = /* @__PURE__ */ new Set();
let a = !1, i = !1, l = null;
let l = !1, i = !1, a = null;
function c() {
l && clearTimeout(l), !i && !a && e() ? (r.trigger(t), s.forEach((f) => f()), s.clear(), a = !0) : !i && !a && (l = setTimeout(c, n));
a && clearTimeout(a), !i && !l && e() ? (r.trigger(t), s.forEach((f) => f()), s.clear(), l = !0) : !i && !l && (a = setTimeout(c, n));
}
function o() {
i = !0, l && clearTimeout(l);
i = !0, a && clearTimeout(a);
}
c();
const u = (f, ...g) => {
f(...g);
const u = (f, ...h) => {
f(...h);
};
return {
on: (f) => {
if (a)
if (l)
return u(f, t), { off: () => {
} };
{
const g = r.on(f);
return s.add(g.off), r.on(f);
const h = r.on(f);
return s.add(h.off), r.on(f);
}

@@ -1030,11 +1030,11 @@ },

return te.get(e);
const t = 100, n = Date.now(), a = mr(() => {
const t = 100, n = Date.now(), l = mr(() => {
if (Date.now() - n >= t)
return !0;
{
const i = e.renderer.value, l = (i == null ? void 0 : i.domElement) || { width: 0, height: 0 };
return !!(i && l.width > 0 && l.height > 0);
const i = e.renderer.value, a = (i == null ? void 0 : i.domElement) || { width: 0, height: 0 };
return !!(i && a.width > 0 && a.height > 0);
}
}, e);
return te.set(e, a), a;
return te.set(e, l), l;
}

@@ -1052,11 +1052,11 @@ function Vr(e) {

rendererOptions: s,
emit: a
emit: l
}) {
const i = $(e), l = dr(n, t), {
const i = $(e), a = dr(n, t), {
camera: c,
cameras: o,
registerCamera: u,
deregisterCamera: y,
deregisterCamera: v,
setCameraActive: f
} = Bn({ sizes: l, scene: e }), g = {
} = Bn({ sizes: a, scene: e }), h = {
mode: H(s.renderMode || "always"),

@@ -1066,11 +1066,11 @@ priority: H(0),

maxFrames: 60,
canBeInvalidated: V(() => g.mode.value === "on-demand" && g.frames.value === 0)
canBeInvalidated: V(() => h.mode.value === "on-demand" && h.frames.value === 0)
};
function v(O = 1) {
s.renderMode === "on-demand" && (g.frames.value = Math.min(g.maxFrames, g.frames.value + O));
function g(O = 1) {
s.renderMode === "on-demand" && (h.frames.value = Math.min(h.maxFrames, h.frames.value + O));
}
function b() {
s.renderMode === "manual" && (g.frames.value = 1);
s.renderMode === "manual" && (h.frames.value = 1);
}
const { renderer: m } = ir(
const { renderer: y } = ir(
{

@@ -1080,13 +1080,13 @@ scene: e,

options: s,
emit: a,
emit: l,
// TODO: replace contextParts with full ctx at https://github.com/Tresjs/tres/issues/516
contextParts: { sizes: l, camera: c, render: g, invalidate: v, advance: b },
contextParts: { sizes: a, camera: c, render: h, invalidate: g, advance: b },
disableRender: r
}
), d = {
sizes: l,
sizes: a,
scene: i,
camera: c,
cameras: ye(o),
renderer: m,
renderer: y,
raycaster: $(new Ft()),

@@ -1106,9 +1106,9 @@ controls: H(null),

},
render: g,
render: h,
advance: b,
extend: Ce,
invalidate: v,
extend: Me,
invalidate: g,
registerCamera: u,
setCameraActive: f,
deregisterCamera: y,
deregisterCamera: v,
loop: pr()

@@ -1119,18 +1119,18 @@ };

}, d.loop.register(() => {
c.value && g.frames.value > 0 && (m.value.render(e, c.value), a("render", d.renderer.value)), g.priority.value = 0, g.mode.value === "always" ? g.frames.value = 1 : g.frames.value = Math.max(0, g.frames.value - 1);
c.value && h.frames.value > 0 && (y.value.render(e, c.value), l("render", d.renderer.value)), h.priority.value = 0, h.mode.value === "always" ? h.frames.value = 1 : h.frames.value = Math.max(0, h.frames.value - 1);
}, "render");
const { on: C, cancel: E } = gt(d);
const { on: C, cancel: M } = gt(d);
d.loop.setReady(!1), d.loop.start(), C(() => {
a("ready", d), d.loop.setReady(!0), fr(e, d, a);
l("ready", d), d.loop.setReady(!0), fr(e, d, l);
}), K(() => {
E(), d.loop.stop();
M(), d.loop.stop();
});
const P = 100, S = an({ every: P }), { isSupported: M, memory: _ } = ln({ interval: P }), L = 160;
let x = performance.now();
const P = 100, E = an({ every: P }), { isSupported: S, memory: _ } = ln({ interval: P }), A = 160;
let L = performance.now();
const p = ({ timestamp: O }) => {
d.scene.value && (d.perf.memory.allocatedMem = ke(d.scene.value)), O - x >= P && (x = O, d.perf.fps.accumulator.push(S.value), d.perf.fps.accumulator.length > L && d.perf.fps.accumulator.shift(), d.perf.fps.value = S.value, M.value && _.value && (d.perf.memory.accumulator.push(_.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > L && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((B, R) => B + R, 0) / d.perf.memory.accumulator.length));
d.scene.value && (d.perf.memory.allocatedMem = xe(d.scene.value)), O - L >= P && (L = O, d.perf.fps.accumulator.push(E.value), d.perf.fps.accumulator.length > A && d.perf.fps.accumulator.shift(), d.perf.fps.value = E.value, S.value && _.value && (d.perf.memory.accumulator.push(_.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > A && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((B, R) => B + R, 0) / d.perf.memory.accumulator.length));
};
let w = 0;
const A = 1, { pause: D } = it(({ delta: O }) => {
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >= A && (window.__TRES__DEVTOOLS__.cb(d), w = 0));
const x = 1, { pause: D } = it(({ delta: O }) => {
window.__TRES__DEVTOOLS__ && (p({ timestamp: performance.now() }), w += O, w >= x && (window.__TRES__DEVTOOLS__.cb(d), w = 0));
}, { immediate: !0 });

@@ -1142,3 +1142,3 @@ return K(() => {

function pe() {
const e = Mt("useTres");
const e = Ct("useTres");
if (!e)

@@ -1156,5 +1156,5 @@ throw new Error("useTresContext must be used together with useTresContextProvider");

raycaster: s,
controls: a,
controls: l,
invalidate: i,
advance: l
advance: a
} = pe();

@@ -1166,14 +1166,14 @@ r.setContext({

raycaster: s,
controls: a,
controls: l,
invalidate: i,
advance: l
advance: a
});
function c(y, f = 0) {
return r.register(y, "before", f);
function c(v, f = 0) {
return r.register(v, "before", f);
}
function o(y) {
return r.register(y, "render");
function o(v) {
return r.register(v, "render");
}
function u(y, f = 0) {
return r.register(y, "after", f);
function u(v, f = 0) {
return r.register(v, "after", f);
}

@@ -1193,18 +1193,18 @@ return {

let r = e;
const s = (l) => {
r = l;
const s = (a) => {
r = a;
};
let a = new Proxy({}, {});
let l = new Proxy({}, {});
const i = {
has(l, c) {
has(a, c) {
return c in t || c in r;
},
get(l, c, o) {
get(a, c, o) {
return c in t ? t[c](r) : r[c];
},
set(l, c, o) {
return n[c] ? n[c](o, r, a, s) : r[c] = o, !0;
set(a, c, o) {
return n[c] ? n[c](o, r, l, s) : r[c] = o, !0;
}
};
return a = new Proxy({}, i), a;
return l = new Proxy({}, i), l;
}

@@ -1228,12 +1228,12 @@ const { logError: Ke } = Y(), Qe = [

const t = e.scene.value;
function n(o, u, y, f) {
function n(o, u, v, f) {
if (f || (f = {}), f.args || (f.args = []), o === "template" || Nn(o))
return null;
let g = o.replace("Tres", ""), v;
let h = o.replace("Tres", ""), g;
if (o === "primitive") {
(!U(f.object) || Ct(f.object)) && Ke(
(!U(f.object) || Mt(f.object)) && Ke(
"Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>"
), g = f.object.type;
), h = f.object.type;
const b = {};
v = gr(
g = gr(
f.object,

@@ -1246,4 +1246,4 @@ {

{
object: (d, C, E, P) => {
or(d, E, P, { patchProp: a, remove: s, insert: r }, e);
object: (d, C, M, P) => {
or(d, M, P, { patchProp: l, remove: s, insert: r }, e);
},

@@ -1256,10 +1256,10 @@ __tres: (d) => {

} else {
const b = Me.value[g];
const b = Ce.value[h];
b || Ke(
`${g} is not defined on the THREE namespace. Use extend to add it to the catalog.`
), v = new b(...f.args);
`${h} is not defined on the THREE namespace. Use extend to add it to the catalog.`
), g = new b(...f.args);
}
return v ? (v.isCamera && (f != null && f.position || v.position.set(3, 3, 3), f != null && f.lookAt || v.lookAt(0, 0, 0)), v = z(v, {
...v.__tres,
type: g,
return g ? (g.isCamera && (f != null && f.position || g.position.set(3, 3, 3), f != null && f.lookAt || g.lookAt(0, 0, 0)), g = z(g, {
...g.__tres,
type: h,
memoizedProps: f,

@@ -1269,21 +1269,21 @@ eventCount: 0,

attach: f.attach
}, e), v) : null;
}, e), g) : null;
}
function r(o, u) {
var g, v, b;
var h, g, b;
if (!o)
return;
u = u || t;
const y = o.__tres ? o : z(o, {}, e), f = u.__tres ? u : z(u, {}, e);
o = Q(y), u = Q(f), o.__tres && ((g = o.__tres) == null ? void 0 : g.eventCount) > 0 && ((v = e.eventManager) == null || v.registerObject(o)), e.registerCamera(o), (b = e.eventManager) == null || b.registerPointerMissedObject(o), y.__tres.attach ? tr(f, y, y.__tres.attach) : N(o) && N(f) && (f.add(o), o.dispatchEvent({ type: "added" })), y.__tres.parent = f, f.__tres.objects && !f.__tres.objects.includes(y) && f.__tres.objects.push(y);
const v = o.__tres ? o : z(o, {}, e), f = u.__tres ? u : z(u, {}, e);
o = Q(v), u = Q(f), o.__tres && ((h = o.__tres) == null ? void 0 : h.eventCount) > 0 && ((g = e.eventManager) == null || g.registerObject(o)), e.registerCamera(o), (b = e.eventManager) == null || b.registerPointerMissedObject(o), v.__tres.attach ? tr(f, v, v.__tres.attach) : N(o) && N(f) && (f.add(o), o.dispatchEvent({ type: "added" })), v.__tres.parent = f, f.__tres.objects && !f.__tres.objects.includes(v) && f.__tres.objects.push(v);
}
function s(o, u) {
var v, b, m, d;
var g, b, y, d;
if (!o)
return;
o != null && o.__tres && ((v = o.__tres) == null ? void 0 : v.eventCount) > 0 && ((b = e.eventManager) == null || b.deregisterObject(o)), u = be(u) ? "default" : u;
const y = (m = o.__tres) == null ? void 0 : m.dispose;
be(y) || (y === null ? u = !1 : u = y);
const f = (d = o.__tres) == null ? void 0 : d.primitive, g = u === "default" ? !f : !!u;
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((C) => s(C, u)), g && o.children && [...o.children].forEach((C) => s(C, u)), mt(o, e), ht(o, e), g && !Dn(o)) {
o != null && o.__tres && ((g = o.__tres) == null ? void 0 : g.eventCount) > 0 && ((b = e.eventManager) == null || b.deregisterObject(o)), u = be(u) ? "default" : u;
const v = (y = o.__tres) == null ? void 0 : y.dispose;
be(v) || (v === null ? u = !1 : u = v);
const f = (d = o.__tres) == null ? void 0 : d.primitive, h = u === "default" ? !f : !!u;
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((C) => s(C, u)), h && o.children && [...o.children].forEach((C) => s(C, u)), mt(o, e), ht(o, e), h && !Dn(o)) {
if (G(u))

@@ -1299,7 +1299,7 @@ u(o);

}
function a(o, u, y, f) {
var C, E;
function l(o, u, v, f) {
var C, M;
if (!o)
return;
let g = o, v = u;
let h = o, g = u;
if (o.__tres && (o.__tres.memoizedProps[u] = f), u === "attach") {

@@ -1314,21 +1314,21 @@ const P = ((C = o.__tres) == null ? void 0 : C.parent) || o.parent;

}
if (N(o) && v === "blocks-pointer-events") {
f || f === "" ? o[v] = f : delete o[v];
if (N(o) && g === "blocks-pointer-events") {
f || f === "" ? o[g] = f : delete o[g];
return;
}
Qe.includes(u) && o.__tres && (o.__tres.eventCount += 1);
let b = ie(v), m = g == null ? void 0 : g[b];
if (v === "args") {
const P = o, S = y ?? [], M = f ?? [], _ = ((E = o.__tres) == null ? void 0 : E.type) || o.type;
_ && S.length && !qn(S, M) && (g = Object.assign(
let b = ie(g), y = h == null ? void 0 : h[b];
if (g === "args") {
const P = o, E = v ?? [], S = f ?? [], _ = ((M = o.__tres) == null ? void 0 : M.type) || o.type;
_ && E.length && !qn(E, S) && (h = Object.assign(
P,
new Me.value[_](...f)
new Ce.value[_](...f)
));
return;
}
if (g.type === "BufferGeometry") {
if (v === "args")
if (h.type === "BufferGeometry") {
if (g === "args")
return;
g.setAttribute(
ie(v),
h.setAttribute(
ie(g),
new Wt(...f)

@@ -1338,12 +1338,12 @@ );

}
if (v.includes("-") && m === void 0) {
const P = v.split("-");
m = P.reduce((S, M) => S[ie(M)], g), v = P.pop(), b = v, m != null && m.set || (g = P.reduce((S, M) => S[ie(M)], g));
if (g.includes("-") && y === void 0) {
const P = g.split("-");
y = P.reduce((E, S) => E[ie(S)], h), g = P.pop(), b = g, y != null && y.set || (h = P.reduce((E, S) => E[ie(S)], h));
}
let d = f;
if (d === "" && (d = !0), G(m)) {
Qe.includes(u) || (de(d) ? o[b](...d) : o[b](d)), b.startsWith("on") && G(d) && (g[b] = d);
if (d === "" && (d = !0), G(y)) {
Qe.includes(u) || (de(d) ? o[b](...d) : o[b](d)), b.startsWith("on") && G(d) && (h[b] = d);
return;
}
!(m != null && m.set) && !G(m) ? g[b] = d : m.constructor === d.constructor && (m != null && m.copy) ? m == null || m.copy(d) : de(d) ? m.set(...d) : !m.isColor && m.setScalar ? m.setScalar(d) : m.set(d), pt(o);
!(y != null && y.set) && !G(y) ? h[b] = d : y.constructor === d.constructor && (y != null && y.copy) ? y == null || y.copy(d) : de(d) ? y.set(...d) : !y.isColor && y.setScalar ? y.setScalar(d) : y.set(d), pt(o);
}

@@ -1354,3 +1354,3 @@ function i(o) {

}
function l(o) {
function a(o) {
const u = z(new Nt(), { type: "Comment" }, e);

@@ -1360,5 +1360,5 @@ return u.name = o, u;

function c(o) {
var g;
const u = i(o), y = ((g = u == null ? void 0 : u.__tres) == null ? void 0 : g.objects) || [], f = y.indexOf(o);
return f < 0 || f >= y.length - 1 ? null : y[f + 1];
var h;
const u = i(o), v = ((h = u == null ? void 0 : u.__tres) == null ? void 0 : h.objects) || [], f = v.indexOf(o);
return f < 0 || f >= v.length - 1 ? null : v[f + 1];
}

@@ -1369,6 +1369,6 @@ return {

createElement: n,
patchProp: a,
patchProp: l,
parentNode: i,
createText: () => void 0,
createComment: l,
createComment: a,
setText: () => void 0,

@@ -1395,6 +1395,6 @@ setElementText: () => void 0,

}
function Mr() {
function Cr() {
return Pr() ? Ee.now() : Date.now();
}
class Cr {
class Mr {
constructor(t, n) {

@@ -1405,10 +1405,10 @@ this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;

for (const i in t.settings) {
const l = t.settings[i];
r[i] = l.defaultValue;
const a = t.settings[i];
r[i] = a.defaultValue;
}
const s = `__vue-devtools-plugin-settings__${t.id}`;
let a = Object.assign({}, r);
let l = Object.assign({}, r);
try {
const i = localStorage.getItem(s), l = JSON.parse(i);
Object.assign(a, l);
const i = localStorage.getItem(s), a = JSON.parse(i);
Object.assign(l, a);
} catch {

@@ -1418,3 +1418,3 @@ }

getSettings() {
return a;
return l;
},

@@ -1426,13 +1426,13 @@ setSettings(i) {

}
a = i;
l = i;
},
now() {
return Mr();
return Cr();
}
}, n && n.on(br, (i, l) => {
i === this.plugin.id && this.fallbacks.setSettings(l);
}, n && n.on(br, (i, a) => {
i === this.plugin.id && this.fallbacks.setSettings(a);
}), this.proxiedOn = new Proxy({}, {
get: (i, l) => this.target ? this.target.on[l] : (...c) => {
get: (i, a) => this.target ? this.target.on[a] : (...c) => {
this.onQueue.push({
method: l,
method: a,
args: c

@@ -1442,10 +1442,10 @@ });

}), this.proxiedTarget = new Proxy({}, {
get: (i, l) => this.target ? this.target[l] : l === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(l) ? (...c) => (this.targetQueue.push({
method: l,
get: (i, a) => this.target ? this.target[a] : a === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(a) ? (...c) => (this.targetQueue.push({
method: a,
args: c,
resolve: () => {
}
}), this.fallbacks[l](...c)) : (...c) => new Promise((o) => {
}), this.fallbacks[a](...c)) : (...c) => new Promise((o) => {
this.targetQueue.push({
method: l,
method: a,
args: c,

@@ -1466,7 +1466,7 @@ resolve: o

function Er(e, t) {
const n = e, r = vt(), s = yr(), a = _r && n.enableEarlyProxy;
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !a))
const n = e, r = vt(), s = yr(), l = _r && n.enableEarlyProxy;
if (s && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !l))
s.emit(wr, e, t);
else {
const i = a ? new Cr(n, s) : null;
const i = l ? new Mr(n, s) : null;
(r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({

@@ -1498,3 +1498,3 @@ pluginDescriptor: n,

});
const n = ke(e);
const n = xe(e);
return n > 0 && t.tags.push({

@@ -1538,3 +1538,3 @@ label: `${ur(n)} KB`,

});
function kr(e, t) {
function xr(e, t) {
Er(

@@ -1562,24 +1562,24 @@ {

n.notifyComponentUpdate();
}, 5e3), n.on.getInspectorTree((a) => {
if (a.inspectorId === X) {
}, 5e3), n.on.getInspectorTree((l) => {
if (l.inspectorId === X) {
const i = yt(t.scene.value);
_t(t.scene.value, i, a.filter), Ar.sceneGraph = i, a.rootNodes = [i];
_t(t.scene.value, i, l.filter), Ar.sceneGraph = i, l.rootNodes = [i];
}
});
let r = null, s = null;
n.on.getInspectorState((a) => {
n.on.getInspectorState((l) => {
var i;
if (a.inspectorId === X) {
const [l] = t.scene.value.getObjectsByProperty("uuid", a.nodeId);
if (!l)
if (l.inspectorId === X) {
const [a] = t.scene.value.getObjectsByProperty("uuid", l.nodeId);
if (!a)
return;
if (s && r && r.parent && s.remove(r), l.isMesh) {
const c = Qn(l);
l.add(c), r = c, s = l;
if (s && r && r.parent && s.remove(r), a.isMesh) {
const c = Qn(a);
a.add(c), r = c, s = a;
}
a.state = {
object: Object.entries(l).map(([c, o]) => c === "children" ? { key: c, value: o.filter((u) => u.type !== "HightlightMesh") } : { key: c, value: o, editable: !0 }).filter(({ key: c }) => c !== "parent")
}, l.isScene && (a.state.info = {
memory: ke(l),
objects: l.children.length,
l.state = {
object: Object.entries(a).map(([c, o]) => c === "children" ? { key: c, value: o.filter((u) => u.type !== "HightlightMesh") } : { key: c, value: o, editable: !0 }).filter(({ key: c }) => c !== "parent")
}, a.isScene && (l.state.info = {
memory: xe(a),
objects: a.children.length,
calls: t.renderer.value.info.render.calls,

@@ -1589,3 +1589,3 @@ triangles: t.renderer.value.info.render.triangles,

lines: t.renderer.value.info.render.lines
}, a.state.programs = ((i = t.renderer.value.info.programs) == null ? void 0 : i.map((c) => ({
}, l.state.programs = ((i = t.renderer.value.info.programs) == null ? void 0 : i.map((c) => ({
key: c.name,

@@ -1600,4 +1600,4 @@ value: {

}
}), n.on.editInspectorState((a) => {
a.inspectorId === X && Kn(t.scene.value, a.nodeId, a.path, a.state.value);
}), n.on.editInspectorState((l) => {
l.inspectorId === X && Kn(t.scene.value, l.nodeId, l.path, l.state.value);
});

@@ -1607,3 +1607,3 @@ }

}
const xr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
const kr = ["data-scene", "data-tres"], Lr = /* @__PURE__ */ Be({
__name: "TresCanvas",

@@ -1653,33 +1653,37 @@ props: {

setup(e, { expose: t, emit: n }) {
var b;
const r = e, s = n, a = Tt(), { logWarning: i } = Y(), l = H(), c = $(new nt()), o = (b = Ie()) == null ? void 0 : b.appContext.app;
Ce(et);
const u = (m) => Be({
var y;
const r = e, s = n, l = Tt(), { logWarning: i } = Y(), a = H(), c = $(new nt()), o = (y = Ie()) == null ? void 0 : y.appContext.app;
Me(et);
const u = (d, C = !1) => Be({
setup() {
var C;
const d = (C = Ie()) == null ? void 0 : C.appContext;
return d && (d.app = o), _e("useTres", m), _e("extend", Ce), typeof window < "u" && kr(d == null ? void 0 : d.app, m), () => He(Ot, null, a != null && a.default ? a.default() : []);
var P;
const M = (P = Ie()) == null ? void 0 : P.appContext;
return M && (M.app = o), _e("useTres", d), _e("extend", Me), typeof window < "u" && xr(M == null ? void 0 : M.app, d), () => He(Ot, null, C ? [] : l.default());
}
}), y = (m) => {
const d = u(m), { render: C } = Rt(vr(m));
C(He(d), c.value);
}, f = (m, d = !1) => {
dt(m.scene.value), d && (m.renderer.value.dispose(), m.renderer.value.renderLists.dispose(), m.renderer.value.forceContextLoss()), c.value.__tres = {
root: m
}, y(m);
}, g = V(() => r.disableRender), v = $(null);
return t({ context: v, dispose: () => f(v.value, !0) }), St(() => {
const m = l;
v.value = hr({
}), v = (d, C = !1) => {
const M = u(d, C), { render: P } = Rt(vr(d));
P(He(M), c.value);
}, f = (d, C = !1) => {
dt(d.scene.value), C && (d.renderer.value.dispose(), d.renderer.value.renderLists.dispose(), d.renderer.value.forceContextLoss()), c.value.__tres = {
root: d
};
}, h = V(() => r.disableRender), g = $(null);
t({ context: g, dispose: () => f(g.value, !0) });
const b = () => {
f(g.value), v(g.value, !0);
};
return St(() => {
const d = a;
g.value = hr({
scene: c.value,
canvas: m,
canvas: d,
windowSize: r.windowSize ?? !1,
disableRender: g.value ?? !1,
disableRender: h.value ?? !1,
rendererOptions: r,
emit: s
});
const { registerCamera: d, camera: C, cameras: E, deregisterCamera: P } = v.value;
y(v.value);
const { registerCamera: C, camera: M, cameras: P, deregisterCamera: E } = g.value;
v(g.value);
const S = () => {
const M = new we(
const _ = new we(
45,

@@ -1690,5 +1694,5 @@ window.innerWidth / window.innerHeight,

);
M.position.set(3, 3, 3), M.lookAt(0, 0, 0), d(M);
const _ = Te(() => {
E.value.length >= 2 && (M.removeFromParent(), P(M), _ == null || _());
_.position.set(3, 3, 3), _.lookAt(0, 0, 0), C(_);
const A = Te(() => {
P.value.length >= 2 && (_.removeFromParent(), E(_), A == null || A());
});

@@ -1698,4 +1702,4 @@ };

() => r.camera,
(M, _) => {
M && d(M), _ && (_.removeFromParent(), P(_));
(_, A) => {
_ && C(_), A && (A.removeFromParent(), E(A));
},

@@ -1705,12 +1709,10 @@ {

}
), C.value || (i(
), M.value || (i(
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
), S());
}), K(() => {
f(v.value);
}), (m, d) => (At(), kt("canvas", {
}), K(b), (d, C) => (At(), xt("canvas", {
ref_key: "canvas",
ref: l,
ref: a,
"data-scene": c.value.uuid,
class: xt(m.$attrs.class),
class: kt(d.$attrs.class),
"data-tres": `tresjs ${J(An).version}`,

@@ -1721,3 +1723,3 @@ style: Lt({

height: "100%",
position: m.windowSize ? "fixed" : "relative",
position: d.windowSize ? "fixed" : "relative",
top: 0,

@@ -1727,5 +1729,5 @@ left: 0,

touchAction: "none",
...m.$attrs.style
...d.$attrs.style
})
}, null, 14, xr));
}, null, 14, kr));
}

@@ -1755,6 +1757,6 @@ }), Rr = [

s.setAttribute("position", new Ue(r, 3)), s.computeBoundingSphere();
const a = new Gt({ fog: !1 });
super(s, a), this.light = t, this.color = n, this.type = "RectAreaLightHelper";
const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], l = new $e();
l.setAttribute("position", new Ue(i, 3)), l.computeBoundingSphere(), this.add(new Vt(l, new ot({ side: Yt, fog: !1 })));
const l = new Gt({ fog: !1 });
super(s, l), this.light = t, this.color = n, this.type = "RectAreaLightHelper";
const i = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new $e();
a.setAttribute("position", new Ue(i, 3)), a.computeBoundingSphere(), this.add(new Vt(a, new ot({ side: Yt, fog: !1 })));
}

@@ -1831,7 +1833,7 @@ updateMatrixWorld() {

Lr as TresCanvas,
Me as catalogue,
Ce as catalogue,
pr as createRenderLoop,
Zr as default,
dt as dispose,
Ce as extend,
Me as extend,
Fr as isProd,

@@ -1838,0 +1840,0 @@ Un as normalizeColor,

{
"name": "@tresjs/core",
"type": "module",
"version": "4.2.5",
"version": "4.2.6",
"packageManager": "pnpm@9.1.4",

@@ -6,0 +6,0 @@ "description": "Declarative ThreeJS using Vue Components",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc