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 2.0.0-alpha.4 to 2.0.0-alpha.5

dist/composables/useSeek/index.d.ts

1

dist/composables/index.d.ts

@@ -9,1 +9,2 @@ export * from './useCamera';

export * from './useLogger';
export * from './useSeek';

287

dist/tres.js
/**
* name: @tresjs/core
* version: v2.0.0-alpha.4
* version: v2.0.0-alpha.5
* (c) 2023

@@ -8,13 +8,13 @@ * description: Declarative ThreeJS using Vue Components

*/
import { ref as M, watchEffect as Ee, toRef as xe, shallowRef as ne, toRefs as ae, computed as re, watch as O, shallowReactive as Pe, createRenderer as Te, defineComponent as Re, onUnmounted as Se, h as P } from "vue";
import { ref as M, watchEffect as Ee, toRef as xe, shallowRef as ne, toRefs as ae, computed as re, watch as O, shallowReactive as Pe, createRenderer as Se, defineComponent as Te, onUnmounted as Re, h as S } from "vue";
import * as oe from "three";
import { MathUtils as Ae, PerspectiveCamera as F, OrthographicCamera as Oe, Clock as ie, Color as I, sRGBEncoding as ke, ACESFilmicToneMapping as je, PCFSoftShadowMap as _e, PCFShadowMap as Be, LinearEncoding as Y, NoToneMapping as Q, WebGLRenderer as De, LoadingManager as Fe, TextureLoader as Ie, Raycaster as We, Vector2 as ze, Mesh as He, BufferAttribute as Ge } from "three";
import { createEventHook as U, useRafFn as Ue, resolveUnref as u, useWindowSize as Ne, useElementSize as $e, useDevicePixelRatio as Ve, unrefElement as W, useEventListener as qe, isFunction as Z } from "@vueuse/core";
const G = M({ uuid: Ae.generateUUID() }), se = (e) => void Object.assign(G.value, e);
import { MathUtils as Ae, PerspectiveCamera as F, OrthographicCamera as ke, Clock as ie, Color as I, sRGBEncoding as Oe, ACESFilmicToneMapping as je, PCFSoftShadowMap as Be, PCFShadowMap as _e, LinearEncoding as Y, NoToneMapping as Q, WebGLRenderer as De, LoadingManager as Fe, TextureLoader as Ie, Raycaster as We, Vector2 as ze, Mesh as He, BufferAttribute as $e } from "three";
import { createEventHook as G, useRafFn as Ge, resolveUnref as c, useWindowSize as Ne, useElementSize as Ue, useDevicePixelRatio as Ve, unrefElement as W, useEventListener as qe, isFunction as Z } from "@vueuse/core";
const $ = M({ uuid: Ae.generateUUID() }), se = (e) => void Object.assign($.value, e);
var Je = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Je || {});
const Ke = 45;
let y;
function ce() {
const { state: e, setState: t, aspectRatio: r } = L();
function o(a = "Perspective", s) {
function ue() {
const { state: e, setState: t, aspectRatio: o } = L();
function r(a = "Perspective", s) {
var l, p, d;

@@ -29,3 +29,3 @@ if (a === "Perspective") {

} else {
const { left: m, right: w, top: v, bottom: g, near: E, far: x } = s || {
const { left: m, right: w, top: v, bottom: g, near: x, far: P } = s || {
left: -100,

@@ -38,3 +38,3 @@ right: 100,

};
y = new Oe(m, w, v, g, E, x), (d = e.cameras) == null || d.push(y);
y = new ke(m, w, v, g, x, P), (d = e.cameras) == null || d.push(y);
}

@@ -51,20 +51,20 @@ return e.camera = y, t("camera", e.camera), y;

}
function c() {
function u() {
e.cameras = [];
}
return Ee(() => {
r != null && r.value && n();
o != null && o.value && n();
}), {
activeCamera: xe(e, "camera"),
createCamera: o,
createCamera: r,
updateCamera: n,
pushCamera: i,
clearCameras: c
clearCameras: u
};
}
const ue = U(), le = U(), N = U(), C = new ie();
let k = 0, j = 0;
const { pause: Xe, resume: Ye, isActive: Qe } = Ue(
const ce = G(), le = G(), N = G(), b = new ie();
let j = 0, B = 0;
const { pause: Xe, resume: Ye, isActive: Qe } = Ge(
() => {
ue.trigger({ delta: k, elapsed: j, clock: C }), le.trigger({ delta: k, elapsed: j, clock: C }), N.trigger({ delta: k, elapsed: j, clock: C });
ce.trigger({ delta: j, elapsed: B, clock: b }), le.trigger({ delta: j, elapsed: B, clock: b }), N.trigger({ delta: j, elapsed: B, clock: b });
},

@@ -74,7 +74,7 @@ { immediate: !1 }

N.on(() => {
k = C.getDelta(), j = C.getElapsedTime();
j = b.getDelta(), B = b.getElapsedTime();
});
function $() {
function U() {
return {
onBeforeLoop: ue.on,
onBeforeLoop: ce.on,
onLoop: le.on,

@@ -92,3 +92,3 @@ onAfterLoop: N.on,

realistic: {
outputEncoding: ke,
outputEncoding: Oe,
toneMapping: je,

@@ -98,26 +98,26 @@ toneMappingExposure: 3,

enabled: !0,
type: _e
type: Be
}
}
}, fe = (e, t) => {
for (const r of Object.keys(t))
t[r] instanceof Object && Object.assign(t[r], fe(e[r], t[r]));
for (const o of Object.keys(t))
t[o] instanceof Object && Object.assign(t[o], fe(e[o], t[o]));
return Object.assign(e || {}, t), e;
}, et = "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", tt = /* @__PURE__ */ nt(et);
function T(e) {
return e.replace(/-([a-z])/g, (t, r) => r.toUpperCase());
return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase());
}
function nt(e, t) {
const r = /* @__PURE__ */ Object.create(null), o = e.split(",");
for (let n = 0; n < o.length; n++)
r[o[n]] = !0;
return t ? (n) => !!r[n.toLowerCase()] : (n) => !!r[n];
const o = /* @__PURE__ */ Object.create(null), r = e.split(",");
for (let n = 0; n < r.length; n++)
o[r[n]] = !0;
return t ? (n) => !!o[n.toLowerCase()] : (n) => !!o[n];
}
const f = ne(), H = M(!1);
function at(e, t, r) {
function at(e, t, o) {
const {
alpha: o = !0,
alpha: r = !0,
antialias: n = !0,
depth: i,
logarithmicDepthBuffer: c,
logarithmicDepthBuffer: u,
failIfMajorPerformanceCaveat: a,

@@ -128,15 +128,15 @@ precision: s,

shadows: d = !1,
shadowMapType: m = Be,
shadowMapType: m = _e,
physicallyCorrectLights: w = !1,
useLegacyLights: v = !1,
outputEncoding: g = Y,
toneMapping: E = Q,
toneMappingExposure: x = 1,
toneMapping: x = Q,
toneMappingExposure: P = 1,
context: me = void 0,
powerPreference: ve = "default",
preserveDrawingBuffer: ge = !1,
clearColor: b,
clearColor: C,
windowSize: we = !1,
preset: he = void 0
} = ae(r), { setState: B } = L(), { width: V, height: q } = u(we) ? Ne() : $e(t), { logError: ye } = _(), { pixelRatio: J } = Ve(), { pause: Me, resume: be } = $(), D = re(() => V.value / q.value), K = () => {
} = ae(o), { setState: _ } = L(), { width: V, height: q } = c(we) ? Ne() : Ue(t), { logError: ye } = E(), { pixelRatio: J } = Ve(), { pause: Me, resume: Ce } = U(), D = re(() => V.value / q.value), K = () => {
f.value && (f.value.setSize(V.value, q.value), f.value.setPixelRatio(Math.min(J.value, 2)));

@@ -146,3 +146,3 @@ }, X = () => {

return;
const h = u(he);
const h = c(he);
if (h) {

@@ -152,19 +152,19 @@ h in z || ye("Renderer Preset must be one of these: " + Object.keys(z).join(", ")), fe(f.value, z[h]);

}
f.value.shadowMap.enabled = u(d), f.value.shadowMap.type = u(m), f.value.toneMapping = u(E) || Q, f.value.toneMappingExposure = u(x), f.value.outputEncoding = u(g) || Y, b != null && b.value && f.value.setClearColor(Ze(u(b))), f.value.useLegacyLights = u(v);
}, Ce = () => {
f.value.shadowMap.enabled = c(d), f.value.shadowMap.type = c(m), f.value.toneMapping = c(x) || Q, f.value.toneMappingExposure = c(P), f.value.outputEncoding = c(g) || Y, C != null && C.value && f.value.setClearColor(Ze(c(C))), f.value.useLegacyLights = c(v);
}, be = () => {
const h = W(e);
h && (f.value = new De({
canvas: h,
alpha: u(o),
antialias: u(n),
context: u(me),
depth: u(i),
failIfMajorPerformanceCaveat: u(a),
logarithmicDepthBuffer: u(c),
powerPreference: u(ve),
precision: u(s),
stencil: u(p),
preserveDrawingBuffer: u(ge),
premultipliedAlpha: u(l)
}), B("renderer", f.value), B("clock", new ie()), B("aspectRatio", D), X(), K(), be(), H.value = !0);
alpha: c(r),
antialias: c(n),
context: c(me),
depth: c(i),
failIfMajorPerformanceCaveat: c(a),
logarithmicDepthBuffer: c(u),
powerPreference: c(ve),
precision: c(s),
stencil: c(p),
preserveDrawingBuffer: c(ge),
premultipliedAlpha: c(l)
}), _("renderer", f.value), _("clock", new ie()), _("aspectRatio", D), X(), K(), Ce(), H.value = !0);
}, Le = () => {

@@ -174,3 +174,3 @@ f.value && (f.value.dispose(), f.value = void 0, H.value = !1, Me());

return O([D, J], K), O(
[d, m, g, v, E, x, b],
[d, m, g, v, x, P, C],
X

@@ -180,3 +180,3 @@ ), O(

() => {
W(e) && W(t) && Ce();
W(e) && W(t) && be();
},

@@ -194,12 +194,12 @@ { immediate: !0, deep: !0 }

const t = { nodes: {}, materials: {} };
return e && e.traverse((r) => {
r.name && (t.nodes[r.name] = r), r.material && !t.materials[r.material.name] && (t.materials[r.material.name] = r.material);
return e && e.traverse((o) => {
o.name && (t.nodes[o.name] = o), o.material && !t.materials[o.material.name] && (t.materials[o.material.name] = o.material);
}), t;
}
async function wt(e, t, r, o, n) {
const { logError: i } = _(), c = new e();
n && n(c), r && r(c);
async function wt(e, t, o, r, n) {
const { logError: i } = E(), u = new e();
n && n(u), o && o(u);
const s = (Array.isArray(t) ? t : [t]).map(
(l) => new Promise((p, d) => {
c.load(
u.load(
l,

@@ -209,3 +209,3 @@ (m) => {

},
o,
r,
(m) => d(i("[useLoader] - Failed to load resource", m))

@@ -218,4 +218,4 @@ );

async function ht(e) {
const t = new Fe(), r = new Ie(t), o = (n) => new Promise((i, c) => {
r.load(
const t = new Fe(), o = new Ie(t), r = (n) => new Promise((i, u) => {
o.load(
n,

@@ -225,3 +225,3 @@ (a) => i(a),

() => {
c(new Error("[useTextures] - Failed to load texture"));
u(new Error("[useTextures] - Failed to load texture"));
}

@@ -231,13 +231,13 @@ );

if (pe(e)) {
const n = await Promise.all(e.map((i) => o(i)));
const n = await Promise.all(e.map((i) => r(i)));
return e.length > 1 ? n : n[0];
} else {
const { map: n, displacementMap: i, normalMap: c, roughnessMap: a, metalnessMap: s, aoMap: l } = e;
const { map: n, displacementMap: i, normalMap: u, roughnessMap: a, metalnessMap: s, aoMap: l } = e;
return {
map: n ? await o(n) : null,
displacementMap: i ? await o(i) : null,
normalMap: c ? await o(c) : null,
roughnessMap: a ? await o(a) : null,
metalnessMap: s ? await o(s) : null,
aoMap: l ? await o(l) : null
map: n ? await r(n) : null,
displacementMap: i ? await r(i) : null,
normalMap: u ? await r(u) : null,
roughnessMap: a ? await r(a) : null,
metalnessMap: s ? await r(s) : null,
aoMap: l ? await r(l) : null
};

@@ -254,7 +254,7 @@ }

function L() {
function e(r) {
return R[r];
function e(o) {
return R[o];
}
function t(r, o) {
R[r] = o;
function t(o, r) {
R[o] = r;
}

@@ -268,23 +268,23 @@ return {

}
const ee = ne(new We()), S = M(new ze()), it = M(null);
const ee = ne(new We()), A = M(new ze()), it = M(null);
function de() {
const { setState: e } = L();
e("raycaster", ee.value), e("pointer", S), e("currentInstance", it);
function t(r) {
S.value.x = r.clientX / window.innerWidth * 2 - 1, S.value.y = -(r.clientY / window.innerHeight) * 2 + 1;
e("raycaster", ee.value), e("pointer", A), e("currentInstance", it);
function t(o) {
A.value.x = o.clientX / window.innerWidth * 2 - 1, A.value.y = -(o.clientY / window.innerHeight) * 2 + 1;
}
return window.addEventListener("pointermove", t), {
raycaster: ee,
pointer: S
pointer: A
};
}
const yt = !0, te = "[TresJS ▲ ■ ●] ";
function _() {
function e(o, n) {
console.error(`${te} ${o}`, n || "");
function E() {
function e(r, n) {
console.error(`${te} ${r}`, n || "");
}
function t(o) {
console.warn(`${te} ${o}`);
function t(r) {
console.warn(`${te} ${r}`);
}
function r(o, n) {
function o(r, n) {
}

@@ -294,7 +294,23 @@ return {

logWarning: t,
logMessage: r
logMessage: o
};
}
const { logWarning: st } = _();
function ct(e) {
function Mt() {
const { logWarning: e } = E();
function t(r, n, i) {
let u = null;
return r.traverse((a) => {
a[n] === i && (u = a);
}), u || e(`Child with ${n} '${i}' not found.`), u;
}
function o(r, n) {
return t(r, "name", n);
}
return {
seek: t,
seekByName: o
};
}
const { logWarning: st } = E();
function ut(e) {
for (const t in e)

@@ -305,31 +321,31 @@ if (t.indexOf("on") === 0)

}
let A = null;
const ut = {
createElement(e, t, r, o) {
let k = null;
const ct = {
createElement(e, t, o, r) {
if (e === "template" || tt(e))
return null;
let n;
if (o === null && (o = {}), o != null && o.args ? n = new G.value[e.replace("Tres", "")](...o.args) : n = new G.value[e.replace("Tres", "")](), n.isCamera) {
(!(o != null && o.position) || o != null && o.position.every((c) => c == 0)) && st(
if (r === null && (r = {}), r != null && r.args ? n = new $.value[e.replace("Tres", "")](...r.args) : n = new $.value[e.replace("Tres", "")](), n.isCamera) {
(!(r != null && r.position) || r != null && r.position.every((u) => u == 0)) && st(
// eslint-disable-next-line max-len
"Camera is positioned at the center of the scene [0,0,0], if this is not intentional try setting a position if your scene seems empty 🤗"
);
const { pushCamera: i } = ce();
const { pushCamera: i } = ue();
i(n);
}
return (o == null ? void 0 : o.attach) === void 0 && (n.isMaterial ? n.attach = "material" : n.isBufferGeometry && (n.attach = "geometry")), n;
return (r == null ? void 0 : r.attach) === void 0 && (n.isMaterial ? n.attach = "material" : n.isBufferGeometry && (n.attach = "geometry")), n;
},
insert(e, t, r) {
if (A === null && t.isScene && (A = t), t === null && (t = A), t != null && t.isObject3D && (e != null && e.isObject3D)) {
const a = r ? t.children.indexOf(r) : 0;
insert(e, t, o) {
if (k === null && t.isScene && (k = t), t === null && (t = k), t != null && t.isObject3D && (e != null && e.isObject3D)) {
const a = o ? t.children.indexOf(o) : 0;
e.parent = t, t.children.splice(a, 0, e), e.dispatchEvent({ type: "added" });
} else
typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
const { onLoop: o } = $();
const { onLoop: r } = U();
let n = null, i = null;
const { raycaster: c } = de();
e && e instanceof He && ct(e) && (o(() => {
const { raycaster: u } = de();
e && e instanceof He && ut(e) && (r(() => {
var a, s, l;
if (t != null && t.children && e && c) {
const p = c.value.intersectObjects(t.children);
if (t != null && t.children && e && u) {
const p = u.value.intersectObjects(t.children);
p.length > 0 && p[0].object.uuid === e.uuid ? (i = p[0], (n === null || n.object.uuid !== (i == null ? void 0 : i.object.uuid)) && ((a = e.onPointerEnter) == null || a.call(e, i)), (s = e.onPointerMove) == null || s.call(e, i)) : (i = null, n !== null && ((l = e.onPointerLeave) == null || l.call(e, n))), n = i;

@@ -348,10 +364,10 @@ }

},
patchProp(e, t, r, o) {
patchProp(e, t, o, r) {
if (e) {
let n = e, i = t;
const c = T(i);
let a = n == null ? void 0 : n[c];
if (e.parent || (e.parent = A), n.type === "BufferGeometry" && (i = i.split("-").pop(), n.setAttribute(
const u = T(i);
let a = n == null ? void 0 : n[u];
if (e.parent || (e.parent = k), n.type === "BufferGeometry" && (i = i.split("-").pop(), n.setAttribute(
T(i),
new Ge(...o)
new $e(...r)
)), i.includes("-") && a === void 0) {

@@ -361,8 +377,8 @@ const l = i.split("-");

}
let s = o;
let s = r;
if (s === "" && (s = !0), Z(a)) {
Array.isArray(s) ? e[c](...s) : e[c](s);
Array.isArray(s) ? e[u](...s) : e[u](s);
return;
}
!(a != null && a.set) && !Z(a) ? n[c] = s : a.constructor === s.constructor && (a != null && a.copy) ? a == null || a.copy(s) : Array.isArray(s) ? a.set(...s) : !a.isColor && a.setScalar ? a.setScalar(s) : a.set(s);
!(a != null && a.set) && !Z(a) ? n[u] = s : a.constructor === s.constructor && (a != null && a.copy) ? a == null || a.copy(s) : Array.isArray(s) ? a.set(...s) : !a.isColor && a.setScalar ? a.setScalar(s) : a.set(s);
}

@@ -382,5 +398,5 @@ },

insertStaticContent: () => void 0
}, { createApp: lt } = Te(ut), ft = (e) => {
const t = lt(r);
function r() {
}, { createApp: lt } = Se(ct), ft = (e) => {
const t = lt(o);
function o() {
return e && e.default ? e.default() : [];

@@ -391,3 +407,3 @@ }

se(oe);
const { logWarning: pt } = _(), dt = Re({
const { logWarning: pt } = E(), dt = Te({
name: "TresCanvas",

@@ -409,10 +425,10 @@ props: [

],
setup(e, { slots: t, expose: r }) {
setup(e, { slots: t, expose: o }) {
e.physicallyCorrectLights === !0 && pt("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
const o = M(), n = M(), i = new oe.Scene(), { setState: c } = L();
c("scene", i), Se(() => {
c("renderer", null);
const r = M(), n = M(), i = new oe.Scene(), { setState: u } = L();
u("scene", i), Re(() => {
u("renderer", null);
});
function a() {
const { renderer: p } = at(n, o, e), { activeCamera: d } = ce(), { onLoop: m } = $(), { raycaster: w, pointer: v } = de();
const { renderer: p } = at(n, r, e), { activeCamera: d } = ue(), { onLoop: m } = U(), { raycaster: w, pointer: v } = de();
m(() => {

@@ -428,9 +444,9 @@ var g;

}
return l(), r({
return l(), o({
scene: i
}), () => P(
P(
}), () => S(
S(
"div",
{
ref: o,
ref: r,
"data-scene": i.uuid,

@@ -447,3 +463,3 @@ key: i.uuid,

[
P(
S(
"div",

@@ -457,3 +473,3 @@ {

[
P("canvas", {
S("canvas", {
ref: n,

@@ -476,3 +492,3 @@ "data-scene": i.uuid,

}
}), Mt = {
}), Ct = {
install(e) {

@@ -485,15 +501,16 @@ e.component("TresCanvas", dt);

dt as TresCanvas,
G as catalogue,
Mt as default,
$ as catalogue,
Ct as default,
se as extend,
yt as isProd,
rt as trasverseObjects,
ce as useCamera,
ue as useCamera,
wt as useLoader,
_ as useLogger,
E as useLogger,
de as useRaycaster,
$ as useRenderLoop,
U as useRenderLoop,
at as useRenderer,
Mt as useSeek,
ht as useTexture,
L as useTres
};
{
"name": "@tresjs/core",
"description": "Declarative ThreeJS using Vue Components",
"version": "2.0.0-alpha.4",
"version": "2.0.0-alpha.5",
"type": "module",

@@ -6,0 +6,0 @@ "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",

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