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

@tresjs/core

Package Overview
Dependencies
Maintainers
1
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 3.6.0 to 3.6.1

dist/src/components/index.d.ts

20

dist/index.d.ts

@@ -1,17 +0,3 @@

import type { App } from 'vue';
import { normalizeColor, normalizeVectorFlexibleParam } from './utils/normalize';
import templateCompilerOptions from './utils/template-compiler-options';
export * from './composables';
export * from './core/catalogue';
export * from './components';
export * from './types';
export interface TresOptions {
extends?: Record<string, unknown>;
}
export interface TresPlugin {
[key: string]: any;
install: (app: App, options?: TresOptions) => void;
}
declare const plugin: TresPlugin;
export default plugin;
export { normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions, };
export * from './src/index'
import Tres from './src/index'
export default Tres
/**
* name: @tresjs/core
* version: v3.6.0
* (c) 2023
* version: v3.6.1
* (c) 2024
* description: Declarative ThreeJS using Vue Components
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
*/
import { ref as B, computed as b, watchEffect as D, onUnmounted as $, shallowRef as L, watch as re, reactive as pe, readonly as de, provide as V, inject as ve, createRenderer as ge, defineComponent as q, useSlots as ye, getCurrentInstance as J, onMounted as we, openBlock as Ee, createElementBlock as Ce, normalizeClass as _e, normalizeStyle as Me, h as K, Fragment as he } from "vue";
import * as Pe from "three";
import { PerspectiveCamera as G, OrthographicCamera as Ae, Camera as ke, Clock as be, Vector3 as De, Color as F, REVISION as Te, SRGBColorSpace as Le, ACESFilmicToneMapping as Se, PCFSoftShadowMap as Be, WebGLRenderer as I, LoadingManager as xe, TextureLoader as Oe, Vector2 as Re, Raycaster as He, BufferAttribute as Fe, Scene as je } from "three";
import { createEventHook as S, useRafFn as ne, toValue as M, unrefElement as ze, useDevicePixelRatio as $e, usePointer as Ne, useElementBounding as Ie, useWindowSize as Ve, useElementSize as Ge, useFps as We, useMemory as Ue } from "@vueuse/core";
const Ye = ({ sizes: e, scene: a }) => {
const t = B([]), r = b(
import { ref as L, computed as k, watchEffect as D, onUnmounted as $, shallowRef as x, watch as ne, reactive as ve, readonly as ge, provide as W, inject as ye, createRenderer as he, defineComponent as J, useSlots as we, getCurrentInstance as K, onMounted as Ee, openBlock as be, createElementBlock as Ce, normalizeClass as _e, unref as Me, normalizeStyle as Pe, h as X, Fragment as Ae } from "vue";
import * as ke from "three";
import { PerspectiveCamera as G, OrthographicCamera as De, Camera as xe, Clock as Te, Vector3 as Se, Color as H, REVISION as Le, SRGBColorSpace as je, ACESFilmicToneMapping as Be, PCFSoftShadowMap as Oe, WebGLRenderer as I, LoadingManager as Re, TextureLoader as He, Vector2 as ze, Raycaster as Fe, BufferAttribute as $e, Scene as Ne } from "three";
import { createEventHook as S, useRafFn as se, toValue as _, unrefElement as Ie, useDevicePixelRatio as Ve, usePointer as We, useElementBounding as Ge, useWindowSize as qe, useElementSize as Ue, refDebounced as Ye, useFps as Je, useMemory as Ke } from "@vueuse/core";
const Xe = "@tresjs/core", Qe = "module", Ze = "3.6.1", et = "pnpm@8.10.2", tt = "Declarative ThreeJS using Vue Components", rt = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", nt = "MIT", st = [
"vue",
"3d",
"threejs",
"three",
"threejs-vue"
], ot = !1, at = {
".": {
types: "./dist/index.d.ts",
require: "./dist/tres.umd.cjs",
import: "./dist/tres.js"
},
"./components": {
types: "./dist/components/index.d.ts"
},
"./composables": {
types: "./dist/composables/index.d.ts"
},
"./types": {
types: "./dist/types/index.d.ts"
},
"./utils": {
types: "./dist/utils/index.d.ts"
},
"./*": "./*"
}, it = "./dist/tres.js", lt = "./dist/tres.js", ut = "./dist/index.d.ts", ct = [
"dist",
"*.d.ts"
], ft = {
access: "public"
}, pt = {
dev: "cd playground && npm run dev",
build: "vite build",
playground: "cd playground && npm run dev",
test: "vitest",
"test:ci": "vitest run",
"test:ui": "vitest --ui",
release: "release-it",
coverage: "vitest run --coverage",
lint: "eslint . --ext .js,.jsx,.ts,.tsx,.vue",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:serve": "vitepress serve docs",
"docs:preview": "vitepress preview docs",
"docs:contributors": "esno scripts/update-contributors.ts"
}, dt = {
three: ">=0.133",
vue: ">=3.3"
}, mt = {
"@alvarosabu/utils": "^3.1.1",
"@vueuse/core": "^10.7.0"
}, vt = {
"@release-it/conventional-changelog": "^8.0.1",
"@stackblitz/sdk": "^1.9.0",
"@tresjs/cientos": "3.6.0",
"@tresjs/eslint-config-vue": "^0.2.1",
"@types/three": "^0.159.0",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-vue": "^4.5.2",
"@vitest/coverage-c8": "^0.33.0",
"@vitest/ui": "^1.0.4",
"@vue/test-utils": "^2.4.3",
eslint: "^8.55.0",
"eslint-plugin-vue": "^9.19.2",
esno: "^4.0.0",
gsap: "^3.12.3",
jsdom: "^23.0.1",
kolorist: "^1.8.0",
ohmyfetch: "^0.4.21",
pathe: "^1.1.1",
"release-it": "^17.0.1",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-visualizer": "^5.11.0",
three: "^0.159.0",
unocss: "^0.58.0",
unplugin: "^1.5.1",
"unplugin-vue-components": "^0.26.0",
vite: "^5.0.8",
"vite-plugin-banner": "^0.7.1",
"vite-plugin-dts": "3.6.4",
"vite-plugin-inspect": "^0.8.1",
"vite-plugin-require-transform": "^1.0.21",
"vite-svg-loader": "^5.1.0",
vitepress: "1.0.0-rc.31",
vitest: "^1.0.4",
vue: "^3.3.11",
"vue-demi": "^0.14.6"
}, gt = {
name: Xe,
type: Qe,
version: Ze,
packageManager: et,
description: tt,
author: rt,
license: nt,
keywords: st,
sideEffects: ot,
exports: at,
main: it,
module: lt,
types: ut,
files: ct,
publishConfig: ft,
scripts: pt,
peerDependencies: dt,
dependencies: mt,
devDependencies: vt
}, yt = ({ sizes: e, scene: s }) => {
const t = L([]), r = k(
() => t.value[0]
), n = (s, l = !1) => {
t.value.some(({ uuid: i }) => i === s.uuid) || (l ? c(s) : t.value.push(s));
}, o = (s) => {
t.value = t.value.filter(({ uuid: l }) => l !== s.uuid);
}, c = (s) => {
const l = s instanceof ke ? s : t.value.find((p) => p.uuid === s);
), n = (a, l = !1) => {
t.value.some(({ uuid: c }) => c === a.uuid) || (l ? u(a) : t.value.push(a));
}, o = (a) => {
t.value = t.value.filter(({ uuid: l }) => l !== a.uuid);
}, u = (a) => {
const l = a instanceof xe ? a : t.value.find((d) => d.uuid === a);
if (!l)
return;
const i = t.value.filter(({ uuid: p }) => p !== l.uuid);
t.value = [l, ...i];
const c = t.value.filter(({ uuid: d }) => d !== l.uuid);
t.value = [l, ...c];
};
return D(() => {
e.aspectRatio.value && t.value.forEach((s) => {
s instanceof G && (s.aspect = e.aspectRatio.value), (s instanceof G || s instanceof Ae) && s.updateProjectionMatrix();
e.aspectRatio.value && t.value.forEach((a) => {
a instanceof G && (a.aspect = e.aspectRatio.value), (a instanceof G || a instanceof De) && a.updateProjectionMatrix();
});
}), a.userData.tres__registerCamera = n, a.userData.tres__deregisterCamera = o, $(() => {
}), s.userData.tres__registerCamera = n, s.userData.tres__deregisterCamera = o, $(() => {
t.value = [];

@@ -37,9 +146,9 @@ }), {

deregisterCamera: o,
setCameraActive: c
setCameraActive: u
};
}, ae = S(), oe = S(), U = S(), T = new be();
let j = 0, z = 0;
const { pause: qe, resume: Je, isActive: Ke } = ne(
}, oe = S(), ae = S(), U = S(), T = new Te();
let z = 0, F = 0;
const { pause: ht, resume: wt, isActive: Et } = se(
() => {
ae.trigger({ delta: j, elapsed: z, clock: T }), oe.trigger({ delta: j, elapsed: z, clock: T }), U.trigger({ delta: j, elapsed: z, clock: T });
oe.trigger({ delta: z, elapsed: F, clock: T }), ae.trigger({ delta: z, elapsed: F, clock: T }), U.trigger({ delta: z, elapsed: F, clock: T });
},

@@ -49,18 +158,18 @@ { immediate: !1 }

U.on(() => {
j = T.getDelta(), z = T.getElapsedTime();
z = T.getDelta(), F = T.getElapsedTime();
});
const se = () => ({
onBeforeLoop: ae.on,
onLoop: oe.on,
const ie = () => ({
onBeforeLoop: oe.on,
onLoop: ae.on,
onAfterLoop: U.on,
pause: qe,
resume: Je,
isActive: Ke
}), Pt = !0, X = "[TresJS ▲ ■ ●] ";
function x() {
pause: ht,
resume: wt,
isActive: Et
}), Yt = !0, Q = "[TresJS ▲ ■ ●] ";
function j() {
function e(r, n) {
console.error(`${X} ${r}`, n || "");
console.error(`${Q} ${r}`, n || "");
}
function a(r) {
console.warn(`${X} ${r}`);
function s(r) {
console.warn(`${Q} ${r}`);
}

@@ -71,86 +180,86 @@ function t(r, n) {

logError: e,
logWarning: a,
logWarning: s,
logMessage: t
};
}
function At(e) {
return typeof e == "number" ? [e, e, e] : e instanceof De ? [e.x, e.y, e.z] : e;
function Jt(e) {
return typeof e == "number" ? [e, e, e] : e instanceof Se ? [e.x, e.y, e.z] : e;
}
function Xe(e) {
return e instanceof F ? e : Array.isArray(e) ? new F(...e) : new F(e);
function bt(e) {
return e instanceof H ? e : Array.isArray(e) ? new H(...e) : new H(e);
}
const ie = (e, a) => {
for (const t of Object.keys(a))
a[t] instanceof Object && Object.assign(a[t], ie(e[t], a[t]));
return Object.assign(e || {}, a), e;
}, Qe = "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", Ze = /* @__PURE__ */ et(Qe);
function Q(e) {
const le = (e, s) => {
for (const t of Object.keys(s))
s[t] instanceof Object && Object.assign(s[t], le(e[t], s[t]));
return Object.assign(e || {}, s), e;
}, Ct = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", _t = /* @__PURE__ */ Mt(Ct);
function Z(e) {
return e && e.nodeType === 1;
}
function R(e) {
return e.replace(/-([a-z])/g, (a, t) => t.toUpperCase());
function O(e) {
return e.replace(/-([a-z])/g, (s, t) => t.toUpperCase());
}
function et(e, a) {
function Mt(e, s) {
const t = /* @__PURE__ */ Object.create(null), r = e.split(",");
for (let n = 0; n < r.length; n++)
t[r[n]] = !0;
return a ? (n) => !!t[n.toLowerCase()] : (n) => !!t[n];
return s ? (n) => !!t[n.toLowerCase()] : (n) => !!t[n];
}
const tt = (e, a) => {
const Pt = (e, s) => {
const t = /* @__PURE__ */ new Set(), r = [];
for (const n of e) {
const o = a(n);
const o = s(n);
t.has(o) || (t.add(o), r.push(n));
}
return r;
}, Z = (e, a) => {
if (!a)
}, ee = (e, s) => {
if (!s)
return;
const t = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
const t = Array.isArray(s) ? s : s.match(/([^[.\]])+/g);
return t == null ? void 0 : t.reduce((r, n) => r && r[n], e);
}, rt = (e, a, t) => {
const r = Array.isArray(a) ? a : a.match(/([^[.\]])+/g);
r && r.reduce((n, o, c) => (n[o] === void 0 && (n[o] = {}), c === r.length - 1 && (n[o] = t), n[o]), e);
}, At = (e, s, t) => {
const r = Array.isArray(s) ? s : s.match(/([^[.\]])+/g);
r && r.reduce((n, o, u) => (n[o] === void 0 && (n[o] = {}), u === r.length - 1 && (n[o] = t), n[o]), e);
};
function ue(e, a) {
if (Q(e) && Q(a)) {
const n = e.attributes, o = a.attributes;
return n.length !== o.length ? !1 : Array.from(n).every(({ name: c, value: s }) => a.getAttribute(c) === s);
function ue(e, s) {
if (Z(e) && Z(s)) {
const n = e.attributes, o = s.attributes;
return n.length !== o.length ? !1 : Array.from(n).every(({ name: u, value: a }) => s.getAttribute(u) === a);
}
if (e === a)
if (e === s)
return !0;
if (e === null || typeof e != "object" || a === null || typeof a != "object")
if (e === null || typeof e != "object" || s === null || typeof s != "object")
return !1;
const t = Object.keys(e), r = Object.keys(a);
const t = Object.keys(e), r = Object.keys(s);
if (t.length !== r.length)
return !1;
for (const n of t)
if (!r.includes(n) || !ue(e[n], a[n]))
if (!r.includes(n) || !ue(e[n], s[n]))
return !1;
return !0;
}
function nt(e, a) {
if (!Array.isArray(e) || !Array.isArray(a) || e.length !== a.length)
function kt(e, s) {
if (!Array.isArray(e) || !Array.isArray(s) || e.length !== s.length)
return !1;
for (let t = 0; t < e.length; t++)
if (!ue(e[t], a[t]))
if (!ue(e[t], s[t]))
return !1;
return !0;
}
const at = Array.isArray, ot = Number.parseInt(Te.replace("dev", "")), H = {
const Dt = Array.isArray, xt = Number.parseInt(Le.replace("dev", "")), R = {
realistic: {
shadows: !0,
physicallyCorrectLights: !0,
outputColorSpace: Le,
toneMapping: Se,
outputColorSpace: je,
toneMapping: Be,
toneMappingExposure: 3,
shadowMap: {
enabled: !0,
type: Be
type: Oe
}
}
};
function st({
function Tt({
scene: e,
canvas: a,
canvas: s,
options: t,

@@ -160,102 +269,102 @@ disableRender: r,

}) {
const c = b(() => ({
alpha: M(t.alpha),
depth: M(t.depth),
canvas: ze(a),
context: M(t.context),
stencil: M(t.stencil),
antialias: M(t.antialias) === void 0 ? !0 : M(t.antialias),
precision: M(t.precision),
powerPreference: M(t.powerPreference),
premultipliedAlpha: M(t.premultipliedAlpha),
preserveDrawingBuffer: M(t.preserveDrawingBuffer),
logarithmicDepthBuffer: M(t.logarithmicDepthBuffer),
failIfMajorPerformanceCaveat: M(t.failIfMajorPerformanceCaveat)
})), s = L(new I(c.value));
re(c, () => {
s.value.dispose(), s.value = new I(c.value);
const u = k(() => ({
alpha: _(t.alpha),
depth: _(t.depth),
canvas: Ie(s),
context: _(t.context),
stencil: _(t.stencil),
antialias: _(t.antialias) === void 0 ? !0 : _(t.antialias),
precision: _(t.precision),
powerPreference: _(t.powerPreference),
premultipliedAlpha: _(t.premultipliedAlpha),
preserveDrawingBuffer: _(t.preserveDrawingBuffer),
logarithmicDepthBuffer: _(t.logarithmicDepthBuffer),
failIfMajorPerformanceCaveat: _(t.failIfMajorPerformanceCaveat)
})), a = x(new I(u.value));
ne(u, () => {
a.value.dispose(), a.value = new I(u.value);
}), D(() => {
s.value.setSize(n.width.value, n.height.value);
a.value.setSize(n.width.value, n.height.value);
});
const { pixelRatio: l } = $e();
const { pixelRatio: l } = Ve();
D(() => {
s.value.setPixelRatio(l.value);
a.value.setPixelRatio(l.value);
});
const { logError: i } = x(), f = (() => {
const m = new I(), w = {
const { logError: c } = j(), f = (() => {
const p = new I(), y = {
shadowMap: {
enabled: m.shadowMap.enabled,
type: m.shadowMap.type
enabled: p.shadowMap.enabled,
type: p.shadowMap.type
},
toneMapping: m.toneMapping,
toneMappingExposure: m.toneMappingExposure,
outputColorSpace: m.outputColorSpace
toneMapping: p.toneMapping,
toneMappingExposure: p.toneMappingExposure,
outputColorSpace: p.outputColorSpace
};
return m.dispose(), w;
return p.dispose(), y;
})();
D(() => {
const m = M(t.preset);
m && (m in H || i(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), ie(s.value, H[m]));
const w = (P, A) => {
const C = M(P), k = () => {
if (m)
return Z(H[m], A);
const p = _(t.preset);
p && (p in R || c(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), le(a.value, R[p]));
const y = (M, P) => {
const E = _(M), A = () => {
if (p)
return ee(R[p], P);
};
if (C !== void 0)
return C;
const g = k();
return g !== void 0 ? g : Z(f, A);
}, d = (P, A) => rt(s.value, A, w(P, A));
d(t.shadows, "shadowMap.enabled"), d(t.toneMapping, "toneMapping"), d(t.shadowMapType, "shadowMap.type"), ot < 150 && d(!t.useLegacyLights, "physicallyCorrectLights"), d(t.outputColorSpace, "outputColorSpace"), d(t.toneMappingExposure, "toneMappingExposure");
const h = w(t.clearColor, "clearColor");
h && s.value.setClearColor(
h ? Xe(h) : new F(0)
if (E !== void 0)
return E;
const v = A();
return v !== void 0 ? v : ee(f, P);
}, b = (M, P) => At(a.value, P, y(M, P));
b(t.shadows, "shadowMap.enabled"), b(t.toneMapping, "toneMapping"), b(t.shadowMapType, "shadowMap.type"), xt < 150 && b(!t.useLegacyLights, "physicallyCorrectLights"), b(t.outputColorSpace, "outputColorSpace"), b(t.toneMappingExposure, "toneMappingExposure");
const w = y(t.clearColor, "clearColor");
w && a.value.setClearColor(
w ? bt(w) : new H(0)
// default clear color is not easily/efficiently retrievable from three
);
});
const { pause: u, resume: v, onLoop: E } = se();
return E(() => {
o.value && !M(r) && s.value.render(e, o.value);
}), v(), $(() => {
u(), s.value.dispose(), s.value.forceContextLoss();
const { pause: i, resume: m, onLoop: h } = ie();
return h(() => {
o.value && !_(r) && a.value.render(e, o.value);
}), m(), $(() => {
i(), a.value.dispose(), a.value.forceContextLoss();
}), {
renderer: s
renderer: a
};
}
const ee = (e) => typeof e == "function", it = (e) => !!e && e.constructor === Array;
function ut(e) {
const a = { nodes: {}, materials: {} };
const te = (e) => typeof e == "function", St = (e) => !!e && e.constructor === Array;
function Lt(e) {
const s = { nodes: {}, materials: {} };
return e && e.traverse((t) => {
t.name && (a.nodes[t.name] = t), t.material && !a.materials[t.material.name] && (a.materials[t.material.name] = t.material);
}), a;
t.name && (s.nodes[t.name] = t), t.material && !s.materials[t.material.name] && (s.materials[t.material.name] = t.material);
}), s;
}
async function kt(e, a, t, r, n) {
const { logError: o } = x(), c = new e();
n && n(c), t && t(c);
const l = (Array.isArray(a) ? a : [a]).map(
(i) => new Promise((p, f) => {
c.load(
i,
(u) => {
u.scene && Object.assign(u, ut(u.scene)), p(u);
async function Kt(e, s, t, r, n) {
const { logError: o } = j(), u = new e();
n && n(u), t && t(u);
const l = (Array.isArray(s) ? s : [s]).map(
(c) => new Promise((d, f) => {
u.load(
c,
(i) => {
i.scene && Object.assign(i, Lt(i.scene)), d(i);
},
r,
(u) => f(o("[useLoader] - Failed to load resource", u))
(i) => f(o("[useLoader] - Failed to load resource", i))
);
})
);
return it(a) ? await Promise.all(l) : await l[0];
return St(s) ? await Promise.all(l) : await l[0];
}
async function bt(e) {
const a = new xe(), t = new Oe(a), r = (n) => new Promise((o, c) => {
async function Xt(e) {
const s = new Re(), t = new He(s), r = (n) => new Promise((o, u) => {
t.load(
n,
(s) => o(s),
(a) => o(a),
() => null,
() => {
c(new Error("[useTextures] - Failed to load texture"));
u(new Error("[useTextures] - Failed to load texture"));
}
);
});
if (at(e)) {
if (Dt(e)) {
const n = await Promise.all(e.map((o) => r(o)));

@@ -267,7 +376,7 @@ return e.length > 1 ? n : n[0];

displacementMap: o,
normalMap: c,
roughnessMap: s,
normalMap: u,
roughnessMap: a,
metalnessMap: l,
aoMap: i,
alphaMap: p,
aoMap: c,
alphaMap: d,
matcap: f

@@ -278,7 +387,7 @@ } = e;

displacementMap: o ? await r(o) : null,
normalMap: c ? await r(c) : null,
roughnessMap: s ? await r(s) : null,
normalMap: u ? await r(u) : null,
roughnessMap: a ? await r(a) : null,
metalnessMap: l ? await r(l) : null,
aoMap: i ? await r(i) : null,
alphaMap: p ? await r(p) : null,
aoMap: c ? await r(c) : null,
alphaMap: d ? await r(d) : null,
matcap: f ? await r(f) : null

@@ -288,61 +397,61 @@ };

}
const lt = (e, { renderer: a, camera: t, raycaster: r }) => {
const n = b(() => a.value.domElement), { x: o, y: c } = Ne({ target: n }), { width: s, height: l, top: i, left: p } = Ie(n), f = ({ x: g, y: _ }) => {
const jt = (e, { renderer: s, camera: t, raycaster: r }) => {
const n = k(() => s.value.domElement), { x: o, y: u } = We({ target: n }), { width: a, height: l, top: c, left: d } = Ge(n), f = ({ x: v, y: C }) => {
if (n.value)
return {
x: (g - p.value) / s.value * 2 - 1,
y: -((_ - i.value) / l.value) * 2 + 1
x: (v - d.value) / a.value * 2 - 1,
y: -((C - c.value) / l.value) * 2 + 1
};
}, u = ({ x: g, y: _ }) => {
}, i = ({ x: v, y: C }) => {
if (t.value)
return r.value.setFromCamera(new Re(g, _), t.value), r.value.intersectObjects(e.value, !1);
}, v = (g) => {
const _ = f({
x: (g == null ? void 0 : g.clientX) ?? o.value,
y: (g == null ? void 0 : g.clientY) ?? c.value
return r.value.setFromCamera(new ze(v, C), t.value), r.value.intersectObjects(e.value, !1);
}, m = (v) => {
const C = f({
x: (v == null ? void 0 : v.clientX) ?? o.value,
y: (v == null ? void 0 : v.clientY) ?? u.value
});
return _ ? u(_) || [] : [];
}, E = b(() => v()), m = S(), w = S(), d = (g, _) => {
g.trigger({ event: _, intersects: v(_) });
}, h = (g) => {
d(w, g);
return C ? i(C) || [] : [];
}, h = k(() => m()), p = S(), y = S(), b = (v, C) => {
v.trigger({ event: C, intersects: m(C) });
}, w = (v) => {
b(y, v);
};
let P;
const A = (g) => {
var _;
P = (_ = v(g)[0]) == null ? void 0 : _.object;
}, C = (g) => {
var _;
g instanceof PointerEvent && P === ((_ = v(g)[0]) == null ? void 0 : _.object) && d(m, g);
}, k = (g) => w.trigger({ event: g, intersects: [] });
return n.value.addEventListener("pointerup", C), n.value.addEventListener("pointerdown", A), n.value.addEventListener("pointermove", h), n.value.addEventListener("pointerleave", k), $(() => {
n != null && n.value && (n.value.removeEventListener("pointerup", C), n.value.removeEventListener("pointerdown", A), n.value.removeEventListener("pointermove", h), n.value.removeEventListener("pointerleave", k));
let M;
const P = (v) => {
var C;
M = (C = m(v)[0]) == null ? void 0 : C.object;
}, E = (v) => {
var C;
v instanceof PointerEvent && M === ((C = m(v)[0]) == null ? void 0 : C.object) && b(p, v);
}, A = (v) => y.trigger({ event: v, intersects: [] });
return n.value.addEventListener("pointerup", E), n.value.addEventListener("pointerdown", P), n.value.addEventListener("pointermove", w), n.value.addEventListener("pointerleave", A), $(() => {
n != null && n.value && (n.value.removeEventListener("pointerup", E), n.value.removeEventListener("pointerdown", P), n.value.removeEventListener("pointermove", w), n.value.removeEventListener("pointerleave", A));
}), {
intersects: E,
onClick: (g) => m.on(g).off,
onPointerMove: (g) => w.on(g).off
intersects: h,
onClick: (v) => p.on(v).off,
onPointerMove: (v) => y.on(v).off
};
};
function Dt() {
const { logWarning: e } = x();
function a(o, c, s) {
function Qt() {
const { logWarning: e } = j();
function s(o, u, a) {
let l = null;
return o.traverse((i) => {
i[c] === s && (l = i);
}), l || e(`Child with ${c} '${s}' not found.`), l;
return o.traverse((c) => {
c[u] === a && (l = c);
}), l || e(`Child with ${u} '${a}' not found.`), l;
}
function t(o, c, s) {
function t(o, u, a) {
const l = [];
return o.traverse((i) => {
i[c].includes(s) && l.push(i);
}), l.length || e(`Children with ${c} '${s}' not found.`), l;
return o.traverse((c) => {
c[u].includes(a) && l.push(c);
}), l.length || e(`Children with ${u} '${a}' not found.`), l;
}
function r(o, c) {
return a(o, "name", c);
function r(o, u) {
return s(o, "name", u);
}
function n(o, c) {
return t(o, "name", c);
function n(o, u) {
return t(o, "name", u);
}
return {
seek: a,
seek: s,
seekByName: r,

@@ -353,4 +462,4 @@ seekAll: t,

}
const ct = ({ scene: e, contextParts: a }) => {
const t = pe({
const Bt = ({ scene: e, contextParts: s }) => {
const t = ve({
click: /* @__PURE__ */ new Map(),

@@ -360,49 +469,49 @@ pointerMove: /* @__PURE__ */ new Map(),

pointerLeave: /* @__PURE__ */ new Map()
}), r = B(/* @__PURE__ */ new Set()), n = (u) => {
r.value.add(u);
}, o = (u) => {
r.value.delete(u);
}, c = (u) => {
Object.values(t).forEach((v) => v.delete(u)), o(u);
}, s = (u) => {
const { onClick: v, onPointerMove: E, onPointerEnter: m, onPointerLeave: w } = u;
v && t.click.set(u, v), E && t.pointerMove.set(u, E), m && t.pointerEnter.set(u, m), w && t.pointerLeave.set(u, w);
}), r = L(/* @__PURE__ */ new Set()), n = (i) => {
r.value.add(i);
}, o = (i) => {
r.value.delete(i);
}, u = (i) => {
Object.values(t).forEach((m) => m.delete(i)), o(i);
}, a = (i) => {
const { onClick: m, onPointerMove: h, onPointerEnter: p, onPointerLeave: y } = i;
m && t.click.set(i, m), h && t.pointerMove.set(i, h), p && t.pointerEnter.set(i, p), y && t.pointerLeave.set(i, y);
};
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = c, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
const l = b(
() => tt(
e.userData.tres__registerAtPointerEventHandler = a, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o;
const l = k(
() => Pt(
[
...Array.from(r.value),
...Object.values(t).map((u) => Array.from(u.keys())).flat()
...Object.values(t).map((i) => Array.from(i.keys())).flat()
],
({ uuid: u }) => u
({ uuid: i }) => i
)
), { onClick: i, onPointerMove: p } = lt(l, a);
i(({ intersects: u, event: v }) => {
var E;
u.length && ((E = t.click.get(u[0].object)) == null || E(u[0], v));
), { onClick: c, onPointerMove: d } = jt(l, s);
c(({ intersects: i, event: m }) => {
var h;
i.length && ((h = t.click.get(i[0].object)) == null || h(i[0], m));
});
let f;
return p(({ intersects: u, event: v }) => {
var h, P, A, C;
const E = (h = u == null ? void 0 : u[0]) == null ? void 0 : h.object, { pointerLeave: m, pointerEnter: w, pointerMove: d } = t;
f && f !== E && ((P = m.get(f)) == null || P(f, v)), E && (f !== E && ((A = w.get(E)) == null || A(u[0], v)), (C = d.get(E)) == null || C(u[0], v)), f = E || null;
return d(({ intersects: i, event: m }) => {
var w, M, P, E;
const h = (w = i == null ? void 0 : i[0]) == null ? void 0 : w.object, { pointerLeave: p, pointerEnter: y, pointerMove: b } = t;
f && f !== h && ((M = p.get(f)) == null || M(f, m)), h && (f !== h && ((P = y.get(h)) == null || P(i[0], m)), (E = b.get(h)) == null || E(i[0], m)), f = h || null;
}), {
registerObject: s,
deregisterObject: c
registerObject: a,
deregisterObject: u
};
};
function ft(e) {
let a = 0;
function Ot(e) {
let s = 0;
return e.traverse((t) => {
if (t.isMesh && t.geometry) {
const r = t.geometry, n = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, c = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, s = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = n + o + c + s;
a += l;
const r = t.geometry, n = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, u = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, a = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = n + o + u + a;
s += l;
}
}), a;
}), s;
}
const W = B({}), Y = (e) => Object.assign(W.value, e);
function mt({
const q = L({}), Y = (e) => Object.assign(q.value, e);
function Rt({
scene: e,
canvas: a,
canvas: s,
windowSize: t,

@@ -412,30 +521,38 @@ disableRender: r,

}) {
const o = b(
() => M(t) ? Ve() : Ge(M(a).parentElement)
), c = b(() => o.value.width.value), s = b(() => o.value.height.value), l = b(() => c.value / s.value), i = {
height: s,
width: c,
aspectRatio: l
}, p = L(e), {
camera: f,
cameras: u,
registerCamera: v,
deregisterCamera: E,
setCameraActive: m
} = Ye({ sizes: i, scene: e }), { renderer: w } = st(
const o = k(
() => _(t) ? qe() : Ue(_(s).parentElement)
), u = x({
width: 0,
height: 0
}), a = Ye(u, 10), l = D(() => {
u.value = {
width: o.value.width.value,
height: o.value.height.value
};
}), c = k(() => a.value.width / a.value.height), d = {
height: k(() => a.value.height),
width: k(() => a.value.width),
aspectRatio: c
}, f = x(e), {
camera: i,
cameras: m,
registerCamera: h,
deregisterCamera: p,
setCameraActive: y
} = yt({ sizes: d, scene: e }), { renderer: b } = Tt(
{
scene: e,
canvas: a,
canvas: s,
options: n,
contextParts: { sizes: i, camera: f },
contextParts: { sizes: d, camera: i },
disableRender: r
}
), d = {
sizes: i,
scene: p,
camera: f,
cameras: de(u),
renderer: w,
raycaster: L(new He()),
controls: B(null),
), w = {
sizes: d,
scene: f,
camera: i,
cameras: ge(m),
renderer: b,
raycaster: x(new Fe()),
controls: L(null),
perf: {

@@ -454,22 +571,22 @@ maxFrames: 160,

extend: Y,
registerCamera: v,
setCameraActive: m,
deregisterCamera: E
registerCamera: h,
setCameraActive: y,
deregisterCamera: p
};
V("useTres", d);
const h = 100, P = We({ every: h }), { isSupported: A, memory: C } = Ue({ interval: h }), k = 160;
let g = performance.now();
const _ = ({ timestamp: O }) => {
d.scene.value && (d.perf.memory.allocatedMem = ft(d.scene.value)), O - g >= h && (g = O, d.perf.fps.accumulator.push(P.value), d.perf.fps.accumulator.length > k && d.perf.fps.accumulator.shift(), d.perf.fps.value = P.value, A.value && C.value && (d.perf.memory.accumulator.push(C.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > k && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((fe, me) => fe + me, 0) / d.perf.memory.accumulator.length));
W("useTres", w);
const M = 100, P = Je({ every: M }), { isSupported: E, memory: A } = Ke({ interval: M }), v = 160;
let C = performance.now();
const ce = ({ timestamp: B }) => {
w.scene.value && (w.perf.memory.allocatedMem = Ot(w.scene.value)), B - C >= M && (C = B, w.perf.fps.accumulator.push(P.value), w.perf.fps.accumulator.length > v && w.perf.fps.accumulator.shift(), w.perf.fps.value = P.value, E.value && A.value && (w.perf.memory.accumulator.push(A.value.usedJSHeapSize / 1024 / 1024), w.perf.memory.accumulator.length > v && w.perf.memory.accumulator.shift(), w.perf.memory.currentMem = w.perf.memory.accumulator.reduce((de, me) => de + me, 0) / w.perf.memory.accumulator.length));
};
let N = 0;
const le = 1, { pause: ce, resume: Ct } = ne(({ delta: O }) => {
window.__TRES__DEVTOOLS__ && (_({ timestamp: performance.now() }), N += O, N >= le && (window.__TRES__DEVTOOLS__.cb(d), N = 0));
const fe = 1, { pause: pe, resume: Wt } = se(({ delta: B }) => {
window.__TRES__DEVTOOLS__ && (ce({ timestamp: performance.now() }), N += B, N >= fe && (window.__TRES__DEVTOOLS__.cb(w), N = 0));
}, { immediate: !0 });
return $(() => {
ce();
}), d;
l(), pe();
}), w;
}
function pt() {
const e = ve("useTres");
function Ht() {
const e = ye("useTres");
if (!e)

@@ -479,19 +596,24 @@ throw new Error("useTresContext must be used together with useTresContextProvider");

}
const Tt = pt;
let y = null;
const { logError: te } = x(), dt = {
createElement(e, a, t, r) {
var c, s;
if (r || (r = {}), r.args || (r.args = []), e === "template" || Ze(e))
const Zt = Ht;
let g = null;
const { logError: re } = j(), V = [
"onClick",
"onPointerMove",
"onPointerEnter",
"onPointerLeave"
], zt = {
createElement(e, s, t, r) {
var u, a;
if (r || (r = {}), r.args || (r.args = []), e === "template" || _t(e))
return null;
let n = e.replace("Tres", ""), o;
if (e === "primitive") {
(r == null ? void 0 : r.object) === void 0 && te("Tres primitives need a prop 'object'");
(r == null ? void 0 : r.object) === void 0 && re("Tres primitives need a prop 'object'");
const l = r.object;
n = l.type, o = Object.assign(l, { type: n, attach: r.attach, primitive: !0 });
} else {
const l = W.value[n];
l || te(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new l(...r.args);
const l = q.value[n];
l || re(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new l(...r.args);
}
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((c = r == null ? void 0 : r.material) != null && c.isMaterial && (o.userData.tres__materialViaProp = !0), (s = r == null ? void 0 : r.geometry) != null && s.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((u = r == null ? void 0 : r.material) != null && u.isMaterial && (o.userData.tres__materialViaProp = !0), (a = r == null ? void 0 : r.geometry) != null && a.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = {
...o.userData,

@@ -501,16 +623,16 @@ tres__name: n

},
insert(e, a) {
var r, n, o, c;
a && a.isScene && (y = a);
const t = a || y;
insert(e, s) {
var r, n, o, u;
s && s.isScene && (g = s);
const t = s || g;
if (e != null && e.isObject3D) {
if (e != null && e.isCamera) {
if (!(y != null && y.userData.tres__registerCamera))
if (!(g != null && g.userData.tres__registerCamera))
throw "could not find tres__registerCamera on scene's userData";
(n = y == null ? void 0 : (r = y.userData).tres__registerCamera) == null || n.call(r, e);
(n = g == null ? void 0 : (r = g.userData).tres__registerCamera) == null || n.call(r, e);
}
if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) {
if (!(y != null && y.userData.tres__registerAtPointerEventHandler))
if (e && V.some((a) => e[a])) {
if (!(g != null && g.userData.tres__registerAtPointerEventHandler))
throw "could not find tres__registerAtPointerEventHandler on scene's userData";
(c = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || c.call(o, e);
(u = g == null ? void 0 : (o = g.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e);
}

@@ -521,25 +643,25 @@ }

remove(e) {
var a, t;
var s, t;
if (e) {
if (e.isObject3D) {
const r = e, n = (i) => {
var f, u;
const p = i;
i.userData.tres__materialViaProp || ((f = p.material) == null || f.dispose(), p.material = void 0), i.userData.tres__geometryViaProp || ((u = p.geometry) == null || u.dispose(), p.geometry = void 0);
}, o = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, c = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => {
var p, f;
if (!c)
const r = e, n = (c) => {
var f, i;
const d = c;
c.userData.tres__materialViaProp || ((f = d.material) == null || f.dispose(), d.material = void 0), c.userData.tres__geometryViaProp || ((i = d.geometry) == null || i.dispose(), d.geometry = void 0);
}, o = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, u = g == null ? void 0 : g.userData.tres__deregisterBlockingObjectAtPointerEventHandler, a = (c) => {
var d, f;
if (!u)
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData";
if ((f = y == null ? void 0 : (p = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(p, i), !o)
if ((f = g == null ? void 0 : (d = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(d, c), !o)
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData";
(i != null && i.onClick || i != null && i.onPointerMove || i != null && i.onPointerEnter || i != null && i.onPointerLeave) && (o == null || o(i));
}, l = (i) => {
const p = y == null ? void 0 : y.userData.tres__deregisterCamera;
if (!p)
c && V.some((i) => c[i]) && (o == null || o(c));
}, l = (c) => {
const d = g == null ? void 0 : g.userData.tres__deregisterCamera;
if (!d)
throw "could not find tres__deregisterCamera on scene's userData";
i.isCamera && (p == null || p(i));
c.isCamera && (d == null || d(c));
};
(a = e.removeFromParent) == null || a.call(e), r.traverse((i) => {
n(i), l(i), s == null || s(i);
}), n(r), l(r), s == null || s(r);
(s = e.removeFromParent) == null || s.call(e), r.traverse((c) => {
n(c), l(c), a == null || a(c);
}), n(r), l(r), a == null || a(r);
}

@@ -549,35 +671,35 @@ (t = e.dispose) == null || t.call(e);

},
patchProp(e, a, t, r) {
var n, o, c, s;
patchProp(e, s, t, r) {
var n, o, u, a;
if (e) {
let l = e, i = a;
if (e.isObject3D && i === "blocks-pointer-events") {
r || r === "" ? (o = y == null ? void 0 : (n = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = y == null ? void 0 : (c = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(c, e);
let l = e, c = s;
if (e.isObject3D && c === "blocks-pointer-events") {
r || r === "" ? (o = g == null ? void 0 : (n = g.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (a = g == null ? void 0 : (u = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || a.call(u, e);
return;
}
let p = R(i), f = l == null ? void 0 : l[p];
if (i === "args") {
const v = e, E = t ?? [], m = r ?? [], w = e.userData.tres__name || e.type;
w && E.length && !nt(E, m) && (l = Object.assign(v, new W.value[w](...r)));
let d = O(c), f = l == null ? void 0 : l[d];
if (c === "args") {
const m = e, h = t ?? [], p = r ?? [], y = e.userData.tres__name || e.type;
y && h.length && !kt(h, p) && (l = Object.assign(m, new q.value[y](...r)));
return;
}
if (l.type === "BufferGeometry") {
if (i === "args")
if (c === "args")
return;
l.setAttribute(
R(i),
new Fe(...r)
O(c),
new $e(...r)
);
return;
}
if (i.includes("-") && f === void 0) {
const v = i.split("-");
f = v.reduce((E, m) => E[R(m)], l), i = v.pop(), p = i.toLowerCase(), f != null && f.set || (l = v.reduce((E, m) => E[R(m)], l));
if (c.includes("-") && f === void 0) {
const m = c.split("-");
f = m.reduce((h, p) => h[O(p)], l), c = m.pop(), d = c.toLowerCase(), f != null && f.set || (l = m.reduce((h, p) => h[O(p)], l));
}
let u = r;
if (u === "" && (u = !0), ee(f)) {
Array.isArray(u) ? e[p](...u) : e[p](u);
let i = r;
if (i === "" && (i = !0), te(f)) {
V.includes(s) || (Array.isArray(i) ? e[d](...i) : e[d](i));
return;
}
!(f != null && f.set) && !ee(f) ? l[p] = u : f.constructor === u.constructor && (f != null && f.copy) ? f == null || f.copy(u) : Array.isArray(u) ? f.set(...u) : !f.isColor && f.setScalar ? f.setScalar(u) : f.set(u);
!(f != null && f.set) && !te(f) ? l[d] = i : f.constructor === i.constructor && (f != null && f.copy) ? f == null || f.copy(i) : Array.isArray(i) ? f.set(...i) : !f.isColor && f.setScalar ? f.setScalar(i) : f.set(i);
}

@@ -597,5 +719,5 @@ },

insertStaticContent: () => void 0
}, { render: vt } = ge(dt);
Y(Pe);
const gt = ["data-scene"], yt = /* @__PURE__ */ q({
}, { render: Ft } = he(zt);
Y(ke);
const $t = ["data-scene", "data-tres"], Nt = /* @__PURE__ */ J({
__name: "TresCanvas",

@@ -626,29 +748,29 @@ props: {

},
setup(e, { expose: a }) {
var E;
const t = e, { logWarning: r } = x(), n = B(), o = L(new je()), { resume: c } = se(), s = ye(), l = (E = J()) == null ? void 0 : E.appContext.app, i = (m) => q({
setup(e, { expose: s }) {
var h;
const t = e, { logWarning: r } = j(), n = L(), o = x(new Ne()), { resume: u } = ie(), a = we(), l = (h = K()) == null ? void 0 : h.appContext.app, c = (p) => J({
setup() {
var d;
const w = (d = J()) == null ? void 0 : d.appContext;
return w && (w.app = l), V("useTres", m), V("extend", Y), () => K(he, null, s != null && s.default ? s.default() : []);
var b;
const y = (b = K()) == null ? void 0 : b.appContext;
return y && (y.app = l), W("useTres", p), W("extend", Y), () => X(Ae, null, a != null && a.default ? a.default() : []);
}
}), p = (m) => {
const w = i(m);
vt(K(w), o.value);
}, f = (m, w = !1) => {
o.value.children = [], w && (m.renderer.value.dispose(), m.renderer.value.renderLists.dispose(), m.renderer.value.forceContextLoss()), p(m), c();
}, u = b(() => t.disableRender), v = L(null);
return a({ context: v, dispose: () => f(v.value, !0) }), we(() => {
const m = n;
v.value = mt({
}), d = (p) => {
const y = c(p);
Ft(X(y), o.value);
}, f = (p, y = !1) => {
o.value.children = [], y && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), d(p), u();
}, i = k(() => t.disableRender), m = x(null);
return s({ context: m, dispose: () => f(m.value, !0) }), Ee(() => {
const p = n;
m.value = Rt({
scene: o.value,
canvas: m,
canvas: p,
windowSize: t.windowSize,
disableRender: u,
disableRender: i,
rendererOptions: t
}), ct({ scene: o.value, contextParts: v.value });
const { registerCamera: w, camera: d, cameras: h, deregisterCamera: P } = v.value;
p(v.value);
const A = () => {
const C = new G(
}), Bt({ scene: o.value, contextParts: m.value });
const { registerCamera: y, camera: b, cameras: w, deregisterCamera: M } = m.value;
d(m.value);
const P = () => {
const E = new G(
45,

@@ -659,11 +781,11 @@ window.innerWidth / window.innerHeight,

);
C.position.set(3, 3, 3), C.lookAt(0, 0, 0), w(C);
const k = D(() => {
h.value.length >= 2 && (C.removeFromParent(), P(C), k == null || k());
E.position.set(3, 3, 3), E.lookAt(0, 0, 0), y(E);
const A = D(() => {
w.value.length >= 2 && (E.removeFromParent(), M(E), A == null || A());
});
};
re(
ne(
() => t.camera,
(C, k) => {
C && w(C), k && (k.removeFromParent(), P(k));
(E, A) => {
E && y(E), A && (A.removeFromParent(), M(A));
},

@@ -673,15 +795,16 @@ {

}
), d.value || (r(
), b.value || (r(
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene."
), A());
}), (m, w) => (Ee(), Ce("canvas", {
), P());
}), (p, y) => (be(), Ce("canvas", {
ref_key: "canvas",
ref: n,
"data-scene": o.value.uuid,
class: _e(m.$attrs.class),
style: Me({
class: _e(p.$attrs.class),
"data-tres": `tresjs ${Me(gt).version}`,
style: Pe({
display: "block",
width: "100%",
height: "100%",
position: m.windowSize ? "fixed" : "relative",
position: p.windowSize ? "fixed" : "relative",
top: 0,

@@ -691,43 +814,43 @@ left: 0,

touchAction: "none",
...m.$attrs.style
...p.$attrs.style
})
}, null, 14, gt));
}, null, 14, $t));
}
}), wt = [
}), It = [
"TresCanvas",
"TresLeches",
"TresScene"
], Et = {
], Vt = {
template: {
compilerOptions: {
isCustomElement: (e) => e.startsWith("Tres") && !wt.includes(e) || e === "primitive"
isCustomElement: (e) => e.startsWith("Tres") && !It.includes(e) || e === "primitive"
}
}
}, Lt = Et, St = {
}, er = Vt, tr = {
install(e) {
e.component("TresCanvas", yt);
e.component("TresCanvas", Nt);
}
};
export {
yt as TresCanvas,
W as catalogue,
St as default,
Nt as TresCanvas,
q as catalogue,
tr as default,
Y as extend,
Pt as isProd,
Xe as normalizeColor,
At as normalizeVectorFlexibleParam,
Lt as templateCompilerOptions,
ut as trasverseObjects,
Ye as useCamera,
kt as useLoader,
x as useLogger,
ct as usePointerEventHandler,
lt as useRaycaster,
se as useRenderLoop,
st as useRenderer,
Dt as useSeek,
bt as useTexture,
Tt as useTres,
pt as useTresContext,
mt as useTresContextProvider
Yt as isProd,
bt as normalizeColor,
Jt as normalizeVectorFlexibleParam,
er as templateCompilerOptions,
Lt as trasverseObjects,
yt as useCamera,
Kt as useLoader,
j as useLogger,
Bt as usePointerEventHandler,
jt as useRaycaster,
ie as useRenderLoop,
Tt as useRenderer,
Qt as useSeek,
Xt as useTexture,
Zt as useTres,
Ht as useTresContext,
Rt as useTresContextProvider
};
{
"name": "@tresjs/core",
"type": "module",
"version": "3.6.0",
"version": "3.6.1",
"packageManager": "pnpm@8.10.2",

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

@@ -22,3 +22,3 @@ ![repo-banner](/public/repo-banner.png)

The goal is to provide the Vue's community an easy way of building 3D scenes with Vue, always up to date with the latest ThreeJS features and with 0-to-none mantainance.
The goal is to provide the Vue's community an easy way of building 3D scenes with Vue, always up to date with the latest ThreeJS features and with 0-to-none maintenance.

@@ -43,7 +43,7 @@ ## Installation

| --------------------------- | :------------------------------------------------------------------------------------------------- |
| [Tres](packages/tres) | ![tres version](https://img.shields.io/npm/v/@tresjs/core/latest.svg?label=%20&color=%2382DBCA) |
| [Cientos](packages/cientos) | ![cientos version](https://img.shields.io/npm/v/@tresjs/cientos/latest.svg?label=%20&color=%23f19b00) |
| [Post-processing](packages/post-processing) | ![post-processing version](https://img.shields.io/npm/v/@tresjs/post-processing/latest.svg?label=%20&color=ff7bac) |
| [Nuxt](packages/nuxt) | ![nuxt version](https://img.shields.io/npm/v/@tresjs/nuxt/latest.svg?label=%20&color=4f4f4f&logo=nuxt.js) |
| [TresLeches 🍰](packages/leches) | ![tresleches version](https://img.shields.io/npm/v/@tresjs/leches/latest.svg?label=%20&color=ffffff) |
| [Tres](https://github.com/TresJS/tres) | ![tres version](https://img.shields.io/npm/v/@tresjs/core/latest.svg?label=%20&color=%2382DBCA) |
| [Cientos](https://github.com/TresJS/cientos) | ![cientos version](https://img.shields.io/npm/v/@tresjs/cientos/latest.svg?label=%20&color=%23f19b00) |
| [Post-processing](https://github.com/TresJS/post-processing) | ![post-processing version](https://img.shields.io/npm/v/@tresjs/post-processing/latest.svg?label=%20&color=ff7bac) |
| [Nuxt](https://github.com/TresJS/nuxt) | ![nuxt version](https://img.shields.io/npm/v/@tresjs/nuxt/latest.svg?label=%20&color=4f4f4f&logo=nuxt.js) |
| [TresLeches 🍰](https://github.com/TresJS/leches) | ![tresleches version](https://img.shields.io/npm/v/@tresjs/leches/latest.svg?label=%20&color=ffffff) |

@@ -50,0 +50,0 @@ ## Contribution

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