New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tresjs/core

Package Overview
Dependencies
Maintainers
1
Versions
128
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 1.2.1 to 1.3.0

242

dist/tres.js
/**
* name: @tresjs/core
* version: v1.2.0
* version: v1.2.1
* (c) 2022

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

*/
import { computed as j, watch as O, inject as T, ref as P, defineComponent as k, shallowRef as N, reactive as ve, toRefs as ye, provide as b, onBeforeUnmount as Ce, h as q } from "vue";
import { computed as j, watch as O, inject as T, ref as P, defineComponent as N, shallowRef as k, reactive as ve, toRefs as ye, provide as b, onBeforeUnmount as Ce, h as q } from "vue";
import { useWindowSize as ee, createEventHook as W, useRafFn as Se, useElementSize as Me, useDevicePixelRatio as xe, unrefElement as z, resolveUnref as y } from "@vueuse/core";
import * as Q from "three";
import { PerspectiveCamera as A, OrthographicCamera as te, Color as D, Vector3 as Ee, Clock as Te, Scene as Pe, LoadingManager as Re, TextureLoader as Le, PCFShadowMap as Oe, LinearEncoding as be, NoToneMapping as Ae, WebGLRenderer as $e } from "three";
var Be = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Be || {});
import { PerspectiveCamera as $, OrthographicCamera as te, Color as D, Vector3 as Ee, Clock as Te, Scene as Pe, LoadingManager as Re, TextureLoader as Le, PCFShadowMap as Oe, LinearEncoding as be, NoToneMapping as $e, WebGLRenderer as Ae } from "three";
var Ie = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ie || {});
const M = {
cameras: []
}, Ie = 45;
}, _e = 45;
let C;
function ne() {
const { width: e, height: t } = ee(), { setState: n } = le();
function o(r = "Perspective", u) {
function s(r = "Perspective", u) {
if (r === "Perspective") {
const { near: s, far: c, fov: p } = u || {
const { near: a, far: c, fov: p } = u || {
near: 0.1,
far: 1e3,
fov: Ie
fov: _e
};
C = new A(p, i.value, s, c), M.cameras.push(C);
C = new $(p, i.value, a, c), M.cameras.push(C);
} else {
const { left: s, right: c, top: p, bottom: m, near: g, far: v } = u || {
const { left: a, right: c, top: p, bottom: m, near: g, far: v } = u || {
left: -100,

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

};
C = new te(s, c, p, m, g, v), M.cameras.push(C);
C = new te(a, c, p, m, g, v), M.cameras.push(C);
}

@@ -44,24 +44,24 @@ return M.cameras.push(C), C;

function f() {
l.value instanceof A && (l.value.aspect = i.value), l.value.updateProjectionMatrix();
l.value instanceof $ && (l.value.aspect = i.value), l.value.updateProjectionMatrix();
}
function a(r) {
function o(r) {
const u = T("camera");
r && u && (u.value = r, n("camera", u.value)), M.cameras.push(r), r instanceof A && (r.aspect = i.value), r.updateProjectionMatrix();
r && u && (u.value = r, n("camera", u.value)), M.cameras.push(r), r instanceof $ && (r.aspect = i.value), r.updateProjectionMatrix();
}
return O(i, f), {
activeCamera: l,
createCamera: o,
createCamera: s,
updateCamera: f,
pushCamera: a
pushCamera: o
};
}
const X = "[TresJS \u25B2 \u25A0 \u25CF] ";
function B() {
function e(o, i) {
console.error(`${X} ${o}`, i || "");
const X = "[TresJS ▲ ■ ●] ";
function I() {
function e(s, i) {
console.error(`${X} ${s}`, i || "");
}
function t(o) {
console.warn(`${X} ${o}`);
function t(s) {
console.warn(`${X} ${s}`);
}
function n(o, i) {
function n(s, i) {
}

@@ -78,14 +78,14 @@ return {

function re(e, t = "Tres") {
const { logMessage: n, logError: o } = B();
const { logMessage: n, logError: s } = I();
!x && e && (x = e);
const { createComponentInstances: i } = ae(t);
const { createComponentInstances: i } = oe(t);
return {
extend: (f) => {
if (!f) {
o("No objects provided to extend catalogue");
s("No objects provided to extend catalogue");
return;
}
E.value = Object.assign(E.value, f);
const a = i(P(f));
n("Adding objects to catalogue", { objects: f, catalogue: E.value.uuid }), x && a.forEach(([r, u]) => {
const o = i(P(f));
n("Adding objects to catalogue", { objects: f, catalogue: E.value.uuid }), x && o.forEach(([r, u]) => {
x._context.components[r] || x.component(r, u);

@@ -97,3 +97,3 @@ });

}
const U = (e) => typeof e < "u", _e = (e) => typeof e == "function", $ = (e) => !!e && e.constructor === Array;
const U = (e) => typeof e < "u", Be = (e) => typeof e == "function", A = (e) => !!e && e.constructor === Array;
function Fe(e) {

@@ -106,18 +106,20 @@ return typeof e == "number" ? [e, e, e] : e instanceof Ee ? [e.x, e.y, e.z] : e;

const ze = ["rotation", "scale", "position"];
function ae(e) {
const { logMessage: t, logError: n } = B();
function o(a, r) {
!U(a) || !U(r) || Object.entries(a).forEach(([u, s]) => {
function oe(e) {
const { logMessage: t, logError: n } = I();
function s(o, r) {
U(o) && U(r) && Object.entries(o).forEach(([u, a]) => {
const c = u.replace(/(-\w)/g, (p) => p[1].toUpperCase());
if (!(c === "args" || s === void 0)) {
ze.includes(c) && s && (s = Fe(s)), a.ref && (a.ref = r);
if (!(c === "args" || a === void 0)) {
ze.includes(c) && a && (a = Fe(a)), o.ref && (o.ref = r);
try {
if (r[c] && U(r[c].set))
r[c].set(...$(s) ? s : [s]);
r[c].set(...A(a) ? a : [a]);
else {
if (s === "" && (s = !0), _e(r[c])) {
r[c](...$(s) ? s : [s]);
if (a === "" && (a = !0), Be(r[c])) {
if (u === "center" && !a)
return;
r[c](...A(a) ? a : [a]);
return;
}
r[c] = s;
r[c] = a;
}

@@ -130,33 +132,33 @@ } catch (p) {

}
function i(a) {
var s;
function i(o) {
var a;
const r = /^Symbol\(Fragment\)$/g, u = /^Symbol\(Text\)$/g;
if (r.test(a.type.toString()))
return a.children.map((c) => i(c));
if (u.test(a.type.toString()))
if (r.test(o.type.toString()))
return o.children.map((c) => i(c));
if (u.test(o.type.toString()))
return;
{
const c = a.type.name.replace(e, ""), { catalogue: p } = re(), m = T("catalogue") || p;
const c = o.type.name.replace(e, ""), { catalogue: p } = re(), m = T("catalogue") || p;
let g;
return m && ((s = a == null ? void 0 : a.props) != null && s.args ? m != null && m.value[c] ? g = new m.value[c](...a.props.args) : n(`There is no ${c} in the catalogue`, m == null ? void 0 : m.value.uuid) : g = new m.value[c]()), a != null && a.props && o(a.props, g), g;
return m && ((a = o == null ? void 0 : o.props) != null && a.args ? m != null && m.value[c] ? g = new m.value[c](...o.props.args) : n(`There is no ${c} in the catalogue`, m == null ? void 0 : m.value.uuid) : g = new m.value[c]()), o != null && o.props && s(o.props, g), g;
}
}
function l(a, r, u) {
if (u.default && (u == null ? void 0 : u.default())) {
const s = u.default().map((c) => i(c));
return new a(...s.flat().filter(Boolean));
function l(o, r, u) {
if (u.default && (u != null && u.default())) {
const a = u.default().map((c) => i(c));
return new o(...a.flat().filter(Boolean));
} else
return r.args ? new a(...r.args) : new a();
return r.args ? new o(...r.args) : new o();
}
function f(a) {
return Object.entries(a.value).filter(([r, u]) => {
var s, c;
return (c = (s = u == null ? void 0 : u.prototype) == null ? void 0 : s.constructor) == null ? void 0 : c.toString().includes("class");
function f(o) {
return Object.entries(o.value).filter(([r, u]) => {
var a, c;
return (c = (a = u == null ? void 0 : u.prototype) == null ? void 0 : a.constructor) == null ? void 0 : c.toString().includes("class");
}).map(([r, u]) => {
const s = `${e}${r}`, c = k({
name: s,
const a = `${e}${r}`, c = N({
name: a,
setup(p, { slots: m, attrs: g, ...v }) {
const { scene: R } = ue(), w = T("local-scene") || R, S = T("catalogue"), { pushCamera: I } = ne();
const { scene: R } = ue(), w = T("local-scene") || R, S = T("catalogue"), { pushCamera: _ } = ne();
let h = l(u, g, m);
return o(g, h), (h instanceof A || h instanceof te) && I(h), h.isObject3D && (w == null || w.value.add(h)), v.expose(h), t(s, {
return s(g, h), (h instanceof $ || h instanceof te) && _(h), h.isObject3D && (w == null || w.value.add(h)), v.expose(h), t(a, {
sceneuuid: w == null ? void 0 : w.value.uuid,

@@ -173,3 +175,3 @@ catalogue: S == null ? void 0 : S.value.uuid,

});
return [s, c];
return [a, c];
});

@@ -179,10 +181,10 @@ }

createComponentInstances: f,
processProps: o,
processProps: s,
createInstanceFromVNode: i
};
}
const oe = W(), se = W(), ie = W(), Z = new Te(), { pause: De, resume: Ue, isActive: Ve } = Se(
const ae = W(), se = W(), ie = W(), Z = new Te(), { pause: De, resume: Ue, isActive: Ve } = Se(
() => {
const e = Z.getElapsedTime(), t = Z.getDelta();
oe.trigger({ delta: t, elapsed: e }), se.trigger({ delta: t, elapsed: e }), ie.trigger({ delta: t, elapsed: e });
ae.trigger({ delta: t, elapsed: e }), se.trigger({ delta: t, elapsed: e }), ie.trigger({ delta: t, elapsed: e });
},

@@ -193,3 +195,3 @@ { immediate: !1 }

return {
onBeforeLoop: oe.on,
onBeforeLoop: ae.on,
onLoop: se.on,

@@ -202,3 +204,3 @@ onAfterLoop: ie.on,

}
const je = N(new Pe());
const je = k(new Pe());
function ue() {

@@ -209,3 +211,3 @@ return {

}
function ke(e) {
function Ne(e) {
const t = { nodes: {}, materials: {} };

@@ -216,13 +218,13 @@ return e && e.traverse((n) => {

}
async function Qe(e, t, n, o, i) {
const { logError: l } = B(), f = new e();
async function Qe(e, t, n, s, i) {
const { logError: l } = I(), f = new e();
i && i(f), n && n(e);
const r = (Array.isArray(t) ? t : [t]).map(
(u) => new Promise((s, c) => {
(u) => new Promise((a, c) => {
f.load(
u,
(p) => {
p.scene && Object.assign(p, ke(p.scene)), s(p);
p.scene && Object.assign(p, Ne(p.scene)), a(p);
},
o,
s,
(p) => c(l("[useLoader] - Failed to load resource", p))

@@ -232,9 +234,9 @@ );

);
return $(t) ? await Promise.all(r) : await r[0];
return A(t) ? await Promise.all(r) : await r[0];
}
async function Xe(e) {
const t = new Re(), n = new Le(t), o = (i) => new Promise((l, f) => {
const t = new Re(), n = new Le(t), s = (i) => new Promise((l, f) => {
n.load(
i,
(a) => l(a),
(o) => l(o),
() => null,

@@ -246,14 +248,14 @@ () => {

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

@@ -267,4 +269,4 @@ }

}
function t(n, o) {
L[n] = o;
function t(n, s) {
L[n] = s;
}

@@ -278,13 +280,13 @@ return {

}
const d = N(), V = P(!1);
function Ne(e, t, n) {
const d = k(), V = P(!1);
function ke(e, t, n) {
const {
alpha: o = !1,
alpha: s = !1,
antialias: i,
depth: l,
logarithmicDepthBuffer: f,
failIfMajorPerformanceCaveat: a,
failIfMajorPerformanceCaveat: o,
precision: r,
premultipliedAlpha: u,
stencil: s,
stencil: a,
shadows: c = !1,

@@ -294,13 +296,13 @@ shadowMapType: p = Oe,

outputEncoding: g = be,
toneMapping: v = Ae,
toneMapping: v = $e,
toneMappingExposure: R = 1,
context: w = void 0,
powerPreference: S = "default",
preserveDrawingBuffer: I = !1,
preserveDrawingBuffer: _ = !1,
clearColor: h = Y("#000000"),
windowSize: fe = !1
} = n, { width: _, height: F } = fe ? ee() : Me(t), { pixelRatio: H } = xe(), { pause: pe, resume: me } = ce(), de = j(() => _.value / F.value), G = () => {
!d.value || (d.value.setSize(_.value, F.value), d.value.setPixelRatio(Math.min(H.value, 2)));
} = n, { width: B, height: F } = fe ? ee() : Me(t), { pixelRatio: H } = xe(), { pause: pe, resume: me } = ce(), de = j(() => B.value / F.value), G = () => {
d.value && (d.value.setSize(B.value, F.value), d.value.setPixelRatio(Math.min(H.value, 2)));
}, J = () => {
!d.value || (d.value.shadowMap.enabled = y(c), d.value.outputEncoding = y(g), d.value.shadowMap.type = y(p), d.value.physicallyCorrectLights = y(m), d.value.toneMapping = y(v), d.value.toneMappingExposure = y(R), d.value.setClearColor(Y(y(h))));
d.value && (d.value.shadowMap.enabled = y(c), d.value.outputEncoding = y(g), d.value.shadowMap.type = y(p), d.value.physicallyCorrectLights = y(m), d.value.toneMapping = y(v), d.value.toneMappingExposure = y(R), d.value.setClearColor(Y(y(h))));
}, ge = () => {

@@ -310,14 +312,14 @@ const K = z(e);

return;
d.value = new $e({
d.value = new Ae({
canvas: K,
alpha: o,
alpha: s,
antialias: i,
context: w,
depth: l,
failIfMajorPerformanceCaveat: a,
failIfMajorPerformanceCaveat: o,
logarithmicDepthBuffer: f,
powerPreference: S,
precision: r,
stencil: s,
preserveDrawingBuffer: I,
stencil: a,
preserveDrawingBuffer: _,
premultipliedAlpha: u

@@ -328,5 +330,5 @@ });

}, he = () => {
!d.value || (d.value.dispose(), d.value = void 0, V.value = !1, pe());
d.value && (d.value.dispose(), d.value = void 0, V.value = !1, pe());
};
return O([_, F, H], G), O(
return O([B, F, H], G), O(
() => [

@@ -355,3 +357,3 @@ c,

}
const We = k({
const We = N({
name: "TresCanvas",

@@ -372,7 +374,7 @@ props: {

setup(e, { slots: t, attrs: n }) {
const { logError: o } = B(), i = P(), l = P(), { renderer: f, dispose: a, aspectRatio: r } = Ne(i, l, e), u = N();
return b("camera", u), b("renderer", f), b("aspect-ratio", r), t.default && !t.default().some((s) => s.type.name === "Scene") && o("TresCanvas must contain a Scene component."), t.default && !t.default().some((s) => {
const { logError: s } = I(), i = P(), l = P(), { renderer: f, dispose: o, aspectRatio: r } = ke(i, l, e), u = k();
return b("camera", u), b("renderer", f), b("aspect-ratio", r), t.default && !t.default().some((a) => a.type.name === "Scene") && s("TresCanvas must contain a Scene component."), t.default && !t.default().some((a) => {
var c;
return (c = s.type.name) == null ? void 0 : c.includes("Camera");
}) && o("Scene must contain a Camera component."), Ce(() => a()), () => {
return (c = a.type.name) == null ? void 0 : c.includes("Camera");
}) && s("Scene must contain a Camera component."), Ce(() => o()), () => {
if (t.default)

@@ -400,8 +402,8 @@ return q(

}
}), He = k({
}), He = N({
name: "Scene",
setup(e, { slots: t }) {
const { scene: n } = ue(), o = T("renderer"), { activeCamera: i } = ne(), { onLoop: l } = ce();
const { scene: n } = ue(), s = T("renderer"), { activeCamera: i } = ne(), { onLoop: l } = ce();
return b("local-scene", n), l(() => {
(o == null ? void 0 : o.value) && (i == null ? void 0 : i.value) && (n == null ? void 0 : n.value) && o.value.render(n == null ? void 0 : n.value, i.value);
s != null && s.value && (i != null && i.value) && (n != null && n.value) && s.value.render(n == null ? void 0 : n.value, i.value);
}), () => {

@@ -412,11 +414,11 @@ if (t.default)

}
}), Ye = Symbol("UseTresState"), Ge = "1.2.0", Ze = {
}), Ye = Symbol("UseTresState"), Ge = "1.2.1", Ze = {
install(e, t) {
const n = (t == null ? void 0 : t.prefix) || "Tres";
e.component(`${n}Canvas`, We), e.component(`${n}Scene`, He);
const { catalogue: o, extend: i } = re(e, n);
e.provide("catalogue", o), e.provide("extend", i);
const { createComponentInstances: l } = ae(n);
l(o).forEach(([a, r]) => {
e.component(a, r);
const { catalogue: s, extend: i } = re(e, n);
e.provide("catalogue", s), e.provide("extend", i);
const { createComponentInstances: l } = oe(n);
l(s).forEach(([o, r]) => {
e.component(o, r);
}), window.__TRES__ = {

@@ -429,12 +431,12 @@ app: e,

export {
Be as CameraType,
Ie as CameraType,
Ye as UseTresStateSymbol,
Ze as default,
ke as trasverseObjects,
Ne as trasverseObjects,
ne as useCamera,
re as useCatalogue,
ae as useInstanceCreator,
oe as useInstanceCreator,
Qe as useLoader,
ce as useRenderLoop,
Ne as useRenderer,
ke as useRenderer,
ue as useScene,

@@ -441,0 +443,0 @@ Xe as useTexture,

{
"name": "@tresjs/core",
"description": "Declarative ThreeJS using Vue Components",
"version": "1.2.1",
"version": "1.3.0",
"type": "module",

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

"dependencies": {
"three": "^0.146.0",
"three": "^0.147.0",
"vue": "^3.2.45"

@@ -45,20 +45,20 @@ },

"@types/three": "^0.146.0",
"@vitejs/plugin-vue": "^3.2.0",
"@vitest/coverage-c8": "^0.25.1",
"@vitest/ui": "^0.25.1",
"@vueuse/core": "^9.5.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitest/coverage-c8": "^0.25.8",
"@vitest/ui": "^0.25.8",
"@vueuse/core": "^9.7.0",
"gl": "6.0.1",
"happy-dom": "^7.7.0",
"histoire": "0.11.7",
"happy-dom": "^8.1.0",
"histoire": "0.11.9",
"kolorist": "^1.6.0",
"pathe": "^0.3.9",
"pathe": "^1.0.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-visualizer": "^5.8.3",
"unplugin-vue-components": "^0.22.9",
"vite": "^3.2.3",
"vite-plugin-banner": "^0.6.1",
"vite-plugin-dts": "^1.7.0",
"vite-plugin-glsl": "^0.5.3",
"unplugin-vue-components": "^0.22.12",
"vite": "^4.0.2",
"vite-plugin-banner": "^0.7.0",
"vite-plugin-dts": "^1.7.1",
"vite-plugin-glsl": "^1.0.1",
"vite-plugin-require-transform": "^1.0.4",
"vitest": "^0.25.1",
"vitest": "^0.25.8",
"vue-demi": "^0.13.11"

@@ -65,0 +65,0 @@ },

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