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-beta.0 to 2.0.0-beta.1

139

dist/tres.js
/**
* name: @tresjs/core
* version: v2.0.0-beta.0
* version: v2.0.0-beta.1
* (c) 2023

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

*/
import { ref as M, watchEffect as oe, toRef as Re, shallowRef as ie, toRefs as se, computed as ce, watch as z, shallowReactive as ke, provide as Ae, inject as Oe, createRenderer as je, defineComponent as ue, onMounted as _e, onUnmounted as Be, h as E } from "vue";
import * as fe from "three";
import { MathUtils as De, PerspectiveCamera as O, OrthographicCamera as ze, Clock as le, Color as W, sRGBEncoding as We, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ie, PCFShadowMap as He, LinearEncoding as ee, NoToneMapping as te, WebGLRenderer as Ue, LoadingManager as $e, TextureLoader as Ge, Raycaster as Ne, Vector2 as Ve, Mesh as qe, BufferAttribute as Ye } from "three";
import { ref as M, watchEffect as oe, toRef as ke, shallowRef as ie, toRefs as se, computed as ce, watch as z, shallowReactive as ue, provide as Ae, inject as Oe, createRenderer as je, defineComponent as fe, onMounted as _e, onUnmounted as Be, h as L } from "vue";
import * as le from "three";
import { MathUtils as De, PerspectiveCamera as O, OrthographicCamera as ze, Clock as de, Color as W, sRGBEncoding as We, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ie, PCFShadowMap as He, LinearEncoding as ee, NoToneMapping as te, WebGLRenderer as Ue, LoadingManager as $e, TextureLoader as Ge, Raycaster as Ne, Vector2 as Ve, Mesh as qe, BufferAttribute as Ye } from "three";
import { createEventHook as $, useRafFn as Ke, resolveUnref as f, useWindowSize as Xe, useElementSize as Je, useDevicePixelRatio as Qe, unrefElement as F, useEventListener as Ze, isFunction as ne } from "@vueuse/core";
const H = M({ uuid: De.generateUUID() }), de = (e) => void Object.assign(H.value, e);
const H = M({ uuid: De.generateUUID() }), pe = (e) => void Object.assign(H.value, e);
var et = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(et || {});

@@ -18,3 +18,3 @@ const tt = 45;

function U() {
const { state: e, setState: t, aspectRatio: r } = T();
const { state: e, setState: t, aspectRatio: r } = S();
function a(o = "Perspective", c) {

@@ -56,3 +56,3 @@ var u, l, p;

}), {
activeCamera: Re(e, "camera"),
activeCamera: ke(e, "camera"),
createCamera: a,

@@ -64,7 +64,7 @@ updateCamera: n,

}
const pe = $(), me = $(), G = $(), S = new le();
const me = $(), ve = $(), G = $(), E = new de();
let j = 0, _ = 0;
const { pause: nt, resume: at, isActive: rt } = Ke(
() => {
pe.trigger({ delta: j, elapsed: _, clock: S }), me.trigger({ delta: j, elapsed: _, clock: S }), G.trigger({ delta: j, elapsed: _, clock: S });
me.trigger({ delta: j, elapsed: _, clock: E }), ve.trigger({ delta: j, elapsed: _, clock: E }), G.trigger({ delta: j, elapsed: _, clock: E });
},

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

G.on(() => {
j = S.getDelta(), _ = S.getElapsedTime();
j = E.getDelta(), _ = E.getElapsedTime();
});
function N() {
return {
onBeforeLoop: pe.on,
onLoop: me.on,
onBeforeLoop: me.on,
onLoop: ve.on,
onAfterLoop: G.on,

@@ -100,5 +100,5 @@ pause: nt,

}
}, ve = (e, t) => {
}, ge = (e, t) => {
for (const r of Object.keys(t))
t[r] instanceof Object && Object.assign(t[r], ve(e[r], t[r]));
t[r] instanceof Object && Object.assign(t[r], ge(e[r], t[r]));
return Object.assign(e || {}, t), e;

@@ -133,10 +133,10 @@ }, it = "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", st = /* @__PURE__ */ ct(it);

toneMappingExposure: P = 1,
context: be = void 0,
powerPreference: ye = "default",
preserveDrawingBuffer: xe = !1,
clearColor: L,
context: ye = void 0,
powerPreference: xe = "default",
preserveDrawingBuffer: Me = !1,
clearColor: C,
windowSize: V = !1,
preset: Me = void 0
} = se(e), { state: h, setState: B } = T(), { width: q, height: Y } = f(V) ? Xe() : Je(h.container), { logError: Ce, logWarning: Le } = C(), { pixelRatio: K } = Qe(), { pause: Ee, resume: Se } = N(), D = ce(() => q.value / Y.value);
!f(V) && ((Z = (Q = h.container) == null ? void 0 : Q.value) == null ? void 0 : Z.offsetHeight) === 0 && Le(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
preset: Ce = void 0
} = se(e), { state: h, setState: B } = S(), { width: q, height: Y } = f(V) ? Xe() : Je(h.container), { logError: Le, logWarning: Ee } = T(), { pixelRatio: K } = Qe(), { pause: Se, resume: Te } = N(), D = ce(() => q.value / Y.value);
!f(V) && ((Z = (Q = h.container) == null ? void 0 : Q.value) == null ? void 0 : Z.offsetHeight) === 0 && Ee(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
You could set windowSize=true to force the canvas to be the size of the window.`);

@@ -148,9 +148,9 @@ const X = () => {

return;
const y = f(Me);
const y = f(Ce);
if (y) {
y in I || Ce("Renderer Preset must be one of these: " + Object.keys(I).join(", ")), ve(t.value, I[y]);
y in I || Le("Renderer Preset must be one of these: " + Object.keys(I).join(", ")), ge(t.value, I[y]);
return;
}
t.value.shadowMap.enabled = f(p), t.value.shadowMap.type = f(d), t.value.toneMapping = f(g) || te, t.value.toneMappingExposure = f(P), t.value.outputEncoding = f(b) || ee, L != null && L.value && t.value.setClearColor(ot(f(L))), t.value.useLegacyLights = f(v);
}, Te = () => {
t.value.shadowMap.enabled = f(p), t.value.shadowMap.type = f(d), t.value.toneMapping = f(g) || te, t.value.toneMappingExposure = f(P), t.value.outputEncoding = f(b) || ee, C != null && C.value && t.value.setClearColor(ot(f(C))), t.value.useLegacyLights = f(v);
}, Pe = () => {
const y = F(h.canvas);

@@ -161,17 +161,17 @@ y && (t.value = new Ue({

antialias: f(n),
context: f(be),
context: f(ye),
depth: f(i),
failIfMajorPerformanceCaveat: f(o),
logarithmicDepthBuffer: f(s),
powerPreference: f(ye),
powerPreference: f(xe),
precision: f(c),
stencil: f(l),
preserveDrawingBuffer: f(xe),
preserveDrawingBuffer: f(Me),
premultipliedAlpha: f(u)
}), B("renderer", t.value), B("clock", new le()), B("aspectRatio", D), J(), X(), Se(), r.value = !0);
}, Pe = () => {
t.value && (t.value.dispose(), t.value = void 0, r.value = !1, Ee());
}), B("renderer", t.value), B("clock", new de()), B("aspectRatio", D), J(), X(), Te(), r.value = !0);
}, Re = () => {
t.value && (t.value.dispose(), t.value = void 0, r.value = !1, Se());
};
return z([D, K], X), z(
[p, d, b, v, g, P, L],
[p, d, b, v, g, P, C],
J

@@ -181,3 +181,3 @@ ), z(

() => {
F(h.canvas) && F(h.container) && Te();
F(h.canvas) && F(h.container) && Pe();
},

@@ -188,7 +188,7 @@ { immediate: !0, deep: !0 }

isReady: r,
dispose: Pe,
dispose: Re,
aspectRatio: D
};
}
const ge = (e) => !!e && e.constructor === Array;
const he = (e) => !!e && e.constructor === Array;
function ft(e) {

@@ -201,3 +201,3 @@ const t = { nodes: {}, materials: {} };

async function Et(e, t, r, a, n) {
const { logError: i } = C(), s = new e();
const { logError: i } = T(), s = new e();
n && n(s), r && r(s);

@@ -216,3 +216,3 @@ const c = (Array.isArray(t) ? t : [t]).map(

);
return ge(t) ? await Promise.all(c) : await c[0];
return he(t) ? await Promise.all(c) : await c[0];
}

@@ -230,3 +230,3 @@ async function St(e) {

});
if (ge(e)) {
if (he(e)) {
const n = await Promise.all(e.map((i) => a(i)));

@@ -262,5 +262,5 @@ return e.length > 1 ? n : n[0];

}
const he = Symbol();
const we = Symbol();
function dt() {
const e = ke({
const e = ue({
uuid: lt(),

@@ -285,10 +285,14 @@ camera: void 0,

};
return Ae(he, a), a;
return Ae(we, a), a;
}
const T = () => {
const e = Oe(he), { logError: t } = C();
return e || t("useTres must be used together with useTresProvider"), e;
}, ae = ie(new Ne()), k = M(new Ve()), pt = M(null);
function we() {
const { setState: e } = T();
const S = () => Oe(we, {
state: ue({
camera: void 0,
cameras: [],
scene: void 0,
renderer: void 0
})
}), ae = ie(new Ne()), k = M(new Ve()), pt = M(null);
function be() {
const { setState: e } = S();
e("raycaster", ae.value), e("pointer", k), e("currentInstance", pt);

@@ -304,3 +308,3 @@ function t(r) {

const Tt = !0, re = "[TresJS ▲ ■ ●] ";
function C() {
function T() {
function e(a, n) {

@@ -321,3 +325,3 @@ console.error(`${re} ${a}`, n || "");

function Pt() {
const { logWarning: e } = C();
const { logWarning: e } = T();
function t(a, n, i) {

@@ -337,3 +341,3 @@ let s = null;

}
const { logWarning: mt } = C();
const { logWarning: mt } = T();
function vt(e) {

@@ -370,3 +374,3 @@ for (const t in e)

if (e && e instanceof qe && vt(e)) {
const { raycaster: s } = we();
const { raycaster: s } = be();
a(() => {

@@ -433,4 +437,4 @@ var o, c, u;

};
de(fe);
const { logWarning: bt } = C(), yt = ue({
pe(le);
const { logWarning: bt } = T(), yt = fe({
name: "TresScene",

@@ -454,3 +458,3 @@ props: [

e.physicallyCorrectLights === !0 && bt("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
const a = M(), n = M(), i = new fe.Scene(), { setState: s } = T();
const a = M(), n = M(), i = new le.Scene(), { setState: s } = S();
s("scene", i), s("canvas", n), s("container", a);

@@ -464,3 +468,3 @@ const { pushCamera: o } = U();

function c() {
const { renderer: p } = ut(e), { activeCamera: d } = U(), { onLoop: w } = N(), { raycaster: v, pointer: b } = we();
const { renderer: p } = ut(e), { activeCamera: d } = U(), { onLoop: w } = N(), { raycaster: v, pointer: b } = be();
oe(() => {

@@ -475,8 +479,8 @@ d.value && v.value.setFromCamera(b.value, d.value);

function l() {
u = wt(t), u.provide("useTres", T()), u.provide("extend", de), u.mount(i);
u = wt(t), u.provide("useTres", S()), u.provide("extend", pe), u.mount(i);
}
return l(), r({
scene: i
}), () => E(
E(
}), () => L(
L(
"div",

@@ -496,3 +500,3 @@ {

[
E(
L(
"div",

@@ -506,3 +510,3 @@ {

[
E("canvas", {
L("canvas", {
ref: n,

@@ -525,3 +529,3 @@ "data-scene": i.uuid,

}
}), xt = ue({
}), xt = fe({
name: "TresCanvas",

@@ -543,4 +547,5 @@ props: [

],
setup(e, { slots: t }) {
return dt(), () => E(yt, e, t);
setup(e, { slots: t, expose: r }) {
const a = dt();
return r(a), () => L(yt, e, t);
}

@@ -557,3 +562,3 @@ }), Rt = {

Rt as default,
de as extend,
pe as extend,
Tt as isProd,

@@ -563,4 +568,4 @@ ft as trasverseObjects,

Et as useLoader,
C as useLogger,
we as useRaycaster,
T as useLogger,
be as useRaycaster,
N as useRenderLoop,

@@ -570,4 +575,4 @@ ut as useRenderer,

St as useTexture,
T as useTres,
S as useTres,
dt as useTresProvider
};
{
"name": "@tresjs/core",
"description": "Declarative ThreeJS using Vue Components",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"type": "module",

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

"@types/three": "latest",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitest/coverage-c8": "^0.29.2",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@vitejs/plugin-vue": "^4.1.0",
"@vitest/coverage-c8": "^0.29.8",
"@vitest/ui": "^0.29.2",
"@vue/test-utils": "^2.3.1",
"eslint": "^8.26.0",
"@vue/test-utils": "^2.3.2",
"eslint": "^8.37.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-vue": "^9.7.0",
"eslint-plugin-vue": "^9.10.0",
"gsap": "^3.11.4",

@@ -85,4 +85,4 @@ "happy-dom": "^8.7.1",

"pathe": "^1.1.0",
"prettier": "^2.8.6",
"release-it": "^15.9.1",
"prettier": "^2.8.7",
"release-it": "^15.10.1",
"rollup-plugin-analyzer": "^4.0.0",

@@ -92,15 +92,15 @@ "rollup-plugin-copy": "^3.4.0",

"three": "latest",
"unocss": "^0.48.0",
"unocss": "^0.50.6",
"unplugin": "^1.3.1",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.1.4",
"vite": "^4.2.1",
"vite-plugin-banner": "^0.7.0",
"vite-plugin-dts": "2.1.0",
"vite-plugin-inspect": "^0.7.16",
"vite-plugin-require-transform": "^1.0.9",
"vite-plugin-dts": "2.2.0",
"vite-plugin-inspect": "^0.7.18",
"vite-plugin-require-transform": "^1.0.12",
"vite-svg-loader": "^4.0.0",
"vitepress": "1.0.0-alpha.38",
"vitest": "^0.29.2",
"vitepress": "1.0.0-alpha.65",
"vitest": "^0.29.8",
"vue-demi": "^0.13.11"
}
}

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