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.0 to 4.2.1

18

dist/src/composables/useLoader/index.d.ts

@@ -1,8 +0,8 @@

import { Loader, Object3D } from 'three';
import { Loader, LoadingManager, Object3D } from 'three';
export interface TresLoader<T> extends Loader {
load: (url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) => unknown;
load: (url: string, onLoad: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) => void;
loadAsync: (url: string, onProgress?: (event: ProgressEvent) => void) => Promise<T>;
}
export type LoaderProto<T> = new (...args: any) => TresLoader<T extends unknown ? any : T>;
export type LoaderProto<T> = new (manager?: LoadingManager) => TresLoader<T>;
export type LoaderReturnType<T, L extends LoaderProto<T>> = T extends unknown ? Awaited<ReturnType<InstanceType<L>['loadAsync']>> : T;

@@ -36,7 +36,7 @@ /**

* @export
* @template T
* @template U
* @param {T} Loader
* @param {U} url
* @param {Extensions<T>} [extensions]
* @template LoaderProto<T>
* @template string | string[],
* @param {LoaderProto<T>} Loader
* @param {string | string[],} url
* @param {Extensions<TresLoader<T>>} [extensions]
* @param {(event: ProgressEvent<EventTarget>) => void} [onProgress]

@@ -46,2 +46,2 @@ * @param {(proto: TresLoader<T>) => void} [cb]

*/
export declare function useLoader<T extends LoaderProto<T>, U extends string | string[]>(Loader: T, url: U, extensions?: Extensions<T>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cb?: (proto: TresLoader<T>) => void): Promise<U extends any[] ? LoaderReturnType<T, T>[] : LoaderReturnType<T, T>>;
export declare function useLoader<T>(Loader: LoaderProto<T>, url: string | string[], extensions?: (loader: TresLoader<T>) => void, onProgress?: (event: ProgressEvent<EventTarget>) => void, cb?: (proto: TresLoader<T>) => void): Promise<T | T[]>;
/**
* name: @tresjs/core
* version: v4.2.0
* version: v4.2.1
* (c) 2024

@@ -15,3 +15,3 @@ * description: Declarative ThreeJS using Vue Components

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.0", 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.1", 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",

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

for (const o of c.children) {
const f = s(o);
if (f)
return f;
const u = s(o);
if (u)
return u;
}

@@ -407,3 +407,3 @@ }, a = s(e);

o.__tresDetach = () => {
o.every((f) => be(f)) && (i[l] = c);
o.every((u) => be(u)) && (i[l] = c);
}, i[l] = o;

@@ -462,10 +462,10 @@ }

delete o.object;
for (const f of a)
mt(f, s), ht(f, s);
for (const u of a)
mt(u, s), ht(u, s);
i.__tres.objects = [], r.remove(t);
for (const [f, v] of Object.entries(o))
r.patchProp(l, f, l[f], v);
for (const [u, v] of Object.entries(o))
r.patchProp(l, u, l[u], v);
n(e), r.insert(t, c);
for (const f of a)
r.insert(f, t);
for (const u of a)
r.insert(u, t);
return !0;

@@ -534,3 +534,3 @@ }

}), le(() => t.clearColor, c);
const { pixelRatio: o } = en(), { logError: f } = z(), u = (() => {
const { pixelRatio: o } = en(), { logError: u } = z(), f = (() => {
const p = new he(), P = {

@@ -551,3 +551,3 @@ shadowMap: {

const p = k(t.preset);
p && (p in ie || f(`Renderer Preset must be one of these: ${Object.keys(ie).join(", ")}`), ut(l.value, ie[p])), nr(l.value, o.value, k(t.dpr)), _ === "always" && (r.frames.value = Math.max(1, r.frames.value));
p && (p in ie || u(`Renderer Preset must be one of these: ${Object.keys(ie).join(", ")}`), ut(l.value, ie[p])), nr(l.value, o.value, k(t.dpr)), _ === "always" && (r.frames.value = Math.max(1, r.frames.value));
const P = (g, E) => {

@@ -561,3 +561,3 @@ const C = k(g), T = () => {

const M = T();
return M !== void 0 ? M : Ve(u, E);
return M !== void 0 ? M : Ve(f, E);
}, m = (g, E) => Vn(l.value, E, P(g, E));

@@ -587,10 +587,11 @@ m(t.shadows, "shadowMap.enabled"), m(t.toneMapping ?? st, "toneMapping"), m(t.shadowMapType, "shadowMap.type"), or < 150 && m(!t.useLegacyLights, "physicallyCorrectLights"), m(t.outputColorSpace, "outputColorSpace"), m(t.toneMappingExposure, "toneMappingExposure");

const c = (Array.isArray(t) ? t : [t]).map(
(o) => new Promise((f, v) => {
(o) => new Promise((u, v) => {
i.load(
o,
(u) => {
u.scene && Object.assign(u, ar(u.scene)), f(u);
(f) => {
const _ = f;
_.scene && Object.assign(_, ar(_.scene)), u(_);
},
r,
(u) => v(a("[useLoader] - Failed to load resource", u))
(f) => v(a("[useLoader] - Failed to load resource", f))
);

@@ -623,3 +624,3 @@ })

aoMap: o,
alphaMap: f,
alphaMap: u,
matcap: v

@@ -634,3 +635,3 @@ } = e;

aoMap: o ? await r(o) : null,
alphaMap: f ? await r(f) : null,
alphaMap: u ? await r(u) : null,
matcap: v ? await r(v) : null

@@ -643,9 +644,9 @@ };

let i = 0;
const { width: l, height: c, top: o, left: f } = nn(n), v = ({ x: h, y: S }) => {
const { width: l, height: c, top: o, left: u } = nn(n), v = ({ x: h, y: S }) => {
if (n.value)
return {
x: (h - f.value) / l.value * 2 - 1,
x: (h - u.value) / l.value * 2 - 1,
y: -((S - o.value) / c.value) * 2 + 1
};
}, u = ({ x: h, y: S }) => {
}, f = ({ x: h, y: S }) => {
if (t.camera.value)

@@ -658,3 +659,3 @@ return t.raycaster.value.setFromCamera(new ge(h, S), t.camera.value), r.value = t.raycaster.value.intersectObjects(e.value, !0), r.value;

});
return S ? u(S) || [] : [];
return S ? f(S) || [] : [];
}, p = j(), P = j(), m = j(), y = j(), g = j(), E = j(), C = j(), T = j();

@@ -795,5 +796,5 @@ function M(h) {

const {
onClick: f,
onClick: u,
onDblClick: v,
onContextMenu: u,
onContextMenu: f,
onPointerMove: _,

@@ -806,3 +807,3 @@ onPointerDown: p,

} = lr(l, t);
P((d) => o("onPointerUp", d)), p((d) => o("onPointerDown", d)), f((d) => o("onClick", d)), v((d) => o("onDoubleClick", d)), u((d) => o("onContextMenu", d)), y((d) => o("onWheel", d));
P((d) => o("onPointerUp", d)), p((d) => o("onPointerDown", d)), u((d) => o("onClick", d)), v((d) => o("onDoubleClick", d)), f((d) => o("onContextMenu", d)), y((d) => o("onWheel", d));
let E = [];

@@ -868,12 +869,12 @@ _((d) => {

const s = () => {
const o = Array.from(e.entries()).sort((f, v) => {
const u = f[1].priority - v[1].priority;
return u === 0 ? f[1].addI - v[1].addI : u;
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((f) => t.add(f[0]));
t.clear(), o.forEach((u) => t.add(u[0]));
}, a = (o) => {
e.delete(o), t.delete(o);
};
return { on: (o, f = 0) => {
e.set(o, { priority: f, addI: n++ });
return { on: (o, u = 0) => {
e.set(o, { priority: u, addI: n++ });
const v = () => a(o);

@@ -884,3 +885,3 @@ return sn(v), r = !0, {

}, off: a, trigger: (...o) => {
r && (s(), r = !1), t.forEach((f) => f(...o));
r && (s(), r = !1), t.forEach((u) => u(...o));
}, dispose: () => {

@@ -898,7 +899,7 @@ e.clear(), t.clear();

let c = null;
const o = ve(), f = ve(), v = ve();
const o = ve(), u = ve(), v = ve();
M();
let u = {};
let f = {};
function _(w) {
u = w;
f = w;
}

@@ -910,3 +911,3 @@ function p(w, L, x = 0) {

case "render":
return c || (c = w), f.dispose(), f.on(w);
return c || (c = w), u.dispose(), u.on(w);
case "after":

@@ -940,11 +941,11 @@ return v.on(w, x);

const w = r.getDelta(), L = r.getElapsedTime(), x = {
camera: K(u.camera),
scene: K(u.scene),
renderer: K(u.renderer),
raycaster: K(u.raycaster),
controls: K(u.controls),
invalidate: u.invalidate,
advance: u.advance
camera: K(f.camera),
scene: K(f.scene),
renderer: K(f.renderer),
raycaster: K(f.raycaster),
controls: K(f.controls),
invalidate: f.invalidate,
advance: f.advance
}, d = { delta: w, elapsed: L, clock: r, ...x };
s.value && o.trigger(d), a.value || (f.count ? f.trigger(d) : c && c(d)), s.value && v.trigger(d), i = requestAnimationFrame(T);
s.value && o.trigger(d), a.value || (u.count ? u.trigger(d) : c && c(d)), s.value && v.trigger(d), i = requestAnimationFrame(T);
}

@@ -975,3 +976,3 @@ function M() {

function c() {
l && clearTimeout(l), !i && !a && e() ? (r.trigger(t), s.forEach((u) => u()), s.clear(), a = !0) : !i && !a && (l = setTimeout(c, n));
l && clearTimeout(l), !i && !a && e() ? (r.trigger(t), s.forEach((f) => f()), s.clear(), a = !0) : !i && !a && (l = setTimeout(c, n));
}

@@ -982,13 +983,13 @@ function o() {

c();
const f = (u, ..._) => {
u(..._);
const u = (f, ..._) => {
f(..._);
};
return {
on: (u) => {
on: (f) => {
if (a)
return f(u, t), { off: () => {
return u(f, t), { off: () => {
} };
{
const _ = r.on(u);
return s.add(_.off), r.on(u);
const _ = r.on(f);
return s.add(_.off), r.on(f);
}

@@ -1030,5 +1031,5 @@ },

camera: o,
cameras: f,
cameras: u,
registerCamera: v,
deregisterCamera: u,
deregisterCamera: f,
setCameraActive: _

@@ -1062,3 +1063,3 @@ } = jn({ sizes: c, scene: e }), p = {

camera: o,
cameras: ye(f),
cameras: ye(u),
renderer: y,

@@ -1085,3 +1086,3 @@ raycaster: H(new Ft()),

setCameraActive: _,
deregisterCamera: u,
deregisterCamera: f,
loop: dr()

@@ -1140,4 +1141,4 @@ };

});
function c(v, u = 0) {
return r.register(v, "before", u);
function c(v, f = 0) {
return r.register(v, "before", f);
}

@@ -1147,4 +1148,4 @@ function o(v) {

}
function f(v, u = 0) {
return r.register(v, "after", u);
function u(v, f = 0) {
return r.register(v, "after", f);
}

@@ -1159,3 +1160,3 @@ return {

render: o,
onAfterRender: f
onAfterRender: u
};

@@ -1199,13 +1200,13 @@ }

const t = e.scene.value;
function n(o, f, v, u) {
if (u || (u = {}), u.args || (u.args = []), o === "template" || Wn(o))
function n(o, u, v, f) {
if (f || (f = {}), f.args || (f.args = []), o === "template" || Wn(o))
return null;
let _ = o.replace("Tres", ""), p;
if (o === "primitive") {
(!N(u.object) || Ct(u.object)) && Ke(
(!N(f.object) || Ct(f.object)) && Ke(
"Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>"
), _ = u.object.type;
), _ = f.object.type;
const P = {};
p = hr(
u.object,
f.object,
{

@@ -1229,32 +1230,32 @@ object: (y) => y,

`${_} is not defined on the THREE namespace. Use extend to add it to the catalog.`
), p = new P(...u.args);
), p = new P(...f.args);
}
return p ? (p.isCamera && (u != null && u.position || p.position.set(3, 3, 3), u != null && u.lookAt || p.lookAt(0, 0, 0)), p = G(p, {
return p ? (p.isCamera && (f != null && f.position || p.position.set(3, 3, 3), f != null && f.lookAt || p.lookAt(0, 0, 0)), p = G(p, {
...p.__tres,
type: _,
memoizedProps: u,
memoizedProps: f,
eventCount: 0,
primitive: o === "primitive",
attach: u.attach
attach: f.attach
}, e), p) : null;
}
function r(o, f) {
function r(o, u) {
var _, p, P;
if (!o)
return;
f = f || t;
const v = o.__tres ? o : G(o, {}, e), u = f.__tres ? f : G(f, {}, e);
o = X(v), f = X(u), o.__tres && ((_ = o.__tres) == null ? void 0 : _.eventCount) > 0 && ((p = e.eventManager) == null || p.registerObject(o)), e.registerCamera(o), (P = e.eventManager) == null || P.registerPointerMissedObject(o), v.__tres.attach ? er(u, v, v.__tres.attach) : W(o) && W(u) && (u.add(o), o.dispatchEvent({ type: "added" })), v.__tres.parent = u, u.__tres.objects && !u.__tres.objects.includes(v) && u.__tres.objects.push(v);
u = u || t;
const v = o.__tres ? o : G(o, {}, e), f = u.__tres ? u : G(u, {}, e);
o = X(v), u = X(f), o.__tres && ((_ = o.__tres) == null ? void 0 : _.eventCount) > 0 && ((p = e.eventManager) == null || p.registerObject(o)), e.registerCamera(o), (P = e.eventManager) == null || P.registerPointerMissedObject(o), v.__tres.attach ? er(f, v, v.__tres.attach) : W(o) && W(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, f) {
function s(o, u) {
var p, P, m, y;
if (!o)
return;
o != null && o.__tres && ((p = o.__tres) == null ? void 0 : p.eventCount) > 0 && ((P = e.eventManager) == null || P.deregisterObject(o)), f = be(f) ? "default" : f;
o != null && o.__tres && ((p = o.__tres) == null ? void 0 : p.eventCount) > 0 && ((P = e.eventManager) == null || P.deregisterObject(o)), u = be(u) ? "default" : u;
const v = (m = o.__tres) == null ? void 0 : m.dispose;
be(v) || (v === null ? f = !1 : f = v);
const u = (y = o.__tres) == null ? void 0 : y.primitive, _ = f === "default" ? !u : !!f;
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((g) => s(g, f)), _ && o.children && [...o.children].forEach((g) => s(g, f)), mt(o, e), ht(o, e), _ && !On(o)) {
if (V(f))
f(o);
be(v) || (v === null ? u = !1 : u = v);
const f = (y = o.__tres) == null ? void 0 : y.primitive, _ = u === "default" ? !f : !!u;
if (o.__tres && "objects" in o.__tres && [...o.__tres.objects].forEach((g) => s(g, u)), _ && o.children && [...o.children].forEach((g) => s(g, u)), mt(o, e), ht(o, e), _ && !On(o)) {
if (V(u))
u(o);
else if (V(o.dispose))

@@ -1268,27 +1269,27 @@ try {

}
function a(o, f, v, u) {
function a(o, u, v, f) {
var g, E;
if (!o)
return;
let _ = o, p = f;
if (o.__tres && (o.__tres.memoizedProps[f] = u), f === "attach") {
let _ = o, p = u;
if (o.__tres && (o.__tres.memoizedProps[u] = f), u === "attach") {
const C = ((g = o.__tres) == null ? void 0 : g.parent) || o.parent;
s(o), G(o, { attach: u }, e), C && r(o, C);
s(o), G(o, { attach: f }, e), C && r(o, C);
return;
}
if (f === "dispose") {
o.__tres || (o = G(o, {}, e)), o.__tres.dispose = u;
if (u === "dispose") {
o.__tres || (o = G(o, {}, e)), o.__tres.dispose = f;
return;
}
if (W(o) && p === "blocks-pointer-events") {
u || u === "" ? o[p] = u : delete o[p];
f || f === "" ? o[p] = f : delete o[p];
return;
}
Qe.includes(f) && o.__tres && (o.__tres.eventCount += 1);
Qe.includes(u) && o.__tres && (o.__tres.eventCount += 1);
let P = se(p), m = _ == null ? void 0 : _[P];
if (p === "args") {
const C = o, T = v ?? [], M = u ?? [], w = ((E = o.__tres) == null ? void 0 : E.type) || o.type;
const C = o, T = v ?? [], M = f ?? [], w = ((E = o.__tres) == null ? void 0 : E.type) || o.type;
w && T.length && !Yn(T, M) && (_ = Object.assign(
C,
new Me.value[w](...u)
new Me.value[w](...f)
));

@@ -1302,3 +1303,3 @@ return;

se(p),
new Wt(...u)
new Wt(...f)
);

@@ -1311,5 +1312,5 @@ return;

}
let y = u;
let y = f;
if (y === "" && (y = !0), V(m)) {
Qe.includes(f) || (de(y) ? o[P](...y) : o[P](y)), P.startsWith("on") && V(y) && (_[P] = y);
Qe.includes(u) || (de(y) ? o[P](...y) : o[P](y)), P.startsWith("on") && V(y) && (_[P] = y);
return;

@@ -1320,13 +1321,13 @@ }

function i(o) {
var f;
return ((f = o == null ? void 0 : o.__tres) == null ? void 0 : f.parent) || null;
var u;
return ((u = o == null ? void 0 : o.__tres) == null ? void 0 : u.parent) || null;
}
function l(o) {
const f = G(new Nt(), { type: "Comment" }, e);
return f.name = o, f;
const u = G(new Nt(), { type: "Comment" }, e);
return u.name = o, u;
}
function c(o) {
var _;
const f = i(o), v = ((_ = f == null ? void 0 : f.__tres) == null ? void 0 : _.objects) || [], u = v.indexOf(o);
return u < 0 || u >= v.length - 1 ? null : v[u + 1];
const u = i(o), v = ((_ = u == null ? void 0 : u.__tres) == null ? void 0 : _.objects) || [], f = v.indexOf(o);
return f < 0 || f >= v.length - 1 ? null : v[f + 1];
}

@@ -1611,3 +1612,3 @@ return {

Ce(et);
const f = (m) => Be({
const u = (m) => Be({
setup() {

@@ -1619,5 +1620,5 @@ var g;

}), v = (m) => {
const y = f(m), { render: g } = Rt(gr(m));
const y = u(m), { render: g } = Rt(gr(m));
g(He(y), c.value);
}, u = (m, y = !1) => {
}, f = (m, y = !1) => {
dt(m.scene.value), y && (m.renderer.value.dispose(), m.renderer.value.renderLists.dispose(), m.renderer.value.forceContextLoss()), c.value.__tres = {

@@ -1627,3 +1628,3 @@ root: m

}, _ = Y(() => r.disableRender), p = H(null);
return t({ context: p, dispose: () => u(p.value, !0) }), St(() => {
return t({ context: p, dispose: () => f(p.value, !0) }), St(() => {
const m = l;

@@ -1664,3 +1665,3 @@ p.value = mr({

}), Q(() => {
u(p.value);
f(p.value);
}), (m, y) => (At(), kt("canvas", {

@@ -1667,0 +1668,0 @@ ref_key: "canvas",

{
"name": "@tresjs/core",
"type": "module",
"version": "4.2.0",
"version": "4.2.1",
"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