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 1.5.1 to 1.6.0

dist/core/useRaycaster/index.d.ts

577

dist/tres.js
/**
* name: @tresjs/core
* version: v1.5.1
* version: v1.6.0
* (c) 2023

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

*/
import { inject as M, computed as se, watch as $, ref as B, defineComponent as N, shallowRef as W, reactive as xe, toRefs as ie, provide as I, onBeforeUnmount as Me, h as te } from "vue";
import { createEventHook as G, useRafFn as Ee, resolveUnref as d, useWindowSize as Pe, useElementSize as Te, useDevicePixelRatio as Le, unrefElement as k } from "@vueuse/core";
import * as ne from "three";
import { PerspectiveCamera as _, OrthographicCamera as ce, Vector3 as Re, Color as V, BufferAttribute as Ae, Clock as ue, Scene as be, LoadingManager as Be, TextureLoader as Oe, PCFShadowMap as $e, LinearEncoding as re, NoToneMapping as ae, WebGLRenderer as Ie } from "three";
var _e = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(_e || {});
const T = {
import { inject as R, computed as fe, watch as z, ref as L, defineComponent as X, onUnmounted as pe, shallowRef as W, shallowReactive as Le, toRefs as me, provide as x, onBeforeUnmount as Pe, h as ae } from "vue";
import { useEventListener as Te, createEventHook as Y, useRafFn as Re, resolveUnref as m, useWindowSize as be, useElementSize as Ae, useDevicePixelRatio as Be, unrefElement as H } from "@vueuse/core";
import * as ie from "three";
import { PerspectiveCamera as U, OrthographicCamera as de, Vector3 as Oe, Color as K, BufferAttribute as Ie, Clock as ge, Scene as $e, LoadingManager as _e, TextureLoader as Fe, PCFShadowMap as De, LinearEncoding as se, NoToneMapping as ce, WebGLRenderer as ze, Raycaster as Ue, Vector2 as je } from "three";
var ke = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(ke || {});
const A = {
cameras: []
}, De = 45;
let x;
function le() {
const e = M("aspect-ratio"), { setState: r } = we();
function n(u = "Perspective", m) {
if (u === "Perspective") {
const { near: t, far: c, fov: l } = m || {
}, Ve = 45;
let T;
function we() {
const e = R("aspect-ratio"), { setState: n } = Z();
function r(f = "Perspective", t) {
if (f === "Perspective") {
const { near: i, far: u, fov: a } = t || {
near: 0.1,
far: 1e3,
fov: De
fov: Ve
};
x = new _(l, (e == null ? void 0 : e.value) || 1, t, c), T.cameras.push(x);
T = new U(a, (e == null ? void 0 : e.value) || 1, i, u), A.cameras.push(T);
} else {
const { left: t, right: c, top: l, bottom: a, near: s, far: p } = m || {
const { left: i, right: u, top: a, bottom: c, near: l, far: S } = t || {
left: -100,

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

};
x = new ce(t, c, l, a, s, p), T.cameras.push(x);
T = new de(i, u, a, c, l, S), A.cameras.push(T);
}
return T.cameras.push(x), x;
return A.cameras.push(T), T;
}
const o = se(() => T.cameras[0]);
function i() {
o.value instanceof _ && e && (o.value.aspect = e.value), o.value.updateProjectionMatrix();
const o = fe(() => A.cameras[0]);
function s() {
o.value instanceof U && e && (o.value.aspect = e.value), o.value.updateProjectionMatrix();
}
function f(u) {
const m = M("camera");
u && m && (m.value = u, r("camera", m.value)), T.cameras.push(u), u instanceof _ && e && (u.aspect = e.value), u.updateProjectionMatrix();
function p(f) {
const t = R("camera");
f && t && (t.value = f, n("camera", t.value)), A.cameras.push(f), f instanceof U && e && (f.aspect = e.value), f.updateProjectionMatrix();
}
return e && $(e, i), {
return e && z(e, s), {
activeCamera: o,
createCamera: n,
updateCamera: i,
pushCamera: f
createCamera: r,
updateCamera: s,
pushCamera: p
};
}
const oe = "[TresJS ▲ ■ ●] ";
function U() {
function e(o, i) {
console.error(`${oe} ${o}`, i || "");
const ue = "[TresJS ▲ ■ ●] ";
function G() {
function e(o, s) {
console.error(`${ue} ${o}`, s || "");
}
function r(o) {
console.warn(`${oe} ${o}`);
function n(o) {
console.warn(`${ue} ${o}`);
}
function n(o, i) {
function r(o, s) {
}
return {
logError: e,
logWarning: r,
logMessage: n
logWarning: n,
logMessage: r
};
}
const A = B({ ...ne, uuid: ne.MathUtils.generateUUID() });
delete A.value.Scene;
let L;
function fe(e, r = "Tres") {
const { logMessage: n, logError: o } = U();
!L && e && (L = e);
const { createComponentInstances: i } = pe(r);
const j = L({ ...ie, uuid: ie.MathUtils.generateUUID() });
delete j.value.Scene;
let B;
function he(e, n = "Tres") {
const { logError: r } = G();
!B && e && (B = e);
const { createComponentInstances: o } = ve(n);
return {
extend: (u) => {
if (!u) {
o("No objects provided to extend catalogue");
extend: (p) => {
if (!p) {
r("No objects provided to extend catalogue");
return;
}
A.value = Object.assign(A.value, u);
const m = i(B(u));
n("Adding objects to catalogue", { objects: u, catalogue: A.value.uuid }), L && m.forEach(([t, c]) => {
L._context.components[t] || L.component(t, c);
j.value = Object.assign(j.value, p);
const f = o(L(p));
B && f.forEach(([t, i]) => {
B._context.components[t] || B.component(t, i);
});
},
catalogue: A
catalogue: j
};
}
const R = (e) => typeof e < "u", Fe = (e) => typeof e == "function", z = (e) => !!e && e.constructor === Array;
function ze(e) {
return typeof e == "number" ? [e, e, e] : e instanceof Re ? [e.x, e.y, e.z] : e;
const O = (e) => typeof e < "u", Ne = (e) => typeof e == "function", N = (e) => !!e && e.constructor === Array;
function We(e) {
return typeof e == "number" ? [e, e, e] : e instanceof Oe ? [e.x, e.y, e.z] : e;
}
function Ue(e) {
return e instanceof V ? e : Array.isArray(e) ? new V(...e) : new V(e);
function Ge(e) {
return e instanceof K ? e : Array.isArray(e) ? new K(...e) : new K(e);
}
const ke = ["rotation", "scale", "position"];
function pe(e) {
const { logMessage: r, logError: n } = U();
function o(t, c) {
R(t) && R(c) && Object.entries(t).forEach(([l, a]) => {
const s = l.replace(/(-\w)/g, (p) => p[1].toUpperCase());
c.setAttribute(s, new Ae(...a));
const He = ["rotation", "scale", "position"];
function ve(e) {
const { logError: n } = G();
function r(t, i) {
O(t) && O(i) && Object.entries(t).forEach(([u, a]) => {
const c = u.replace(/(-\w)/g, (l) => l[1].toUpperCase());
i.setAttribute(c, new Ie(...a));
});
}
function i(t, c) {
R(t) && R(c) && Object.entries(t).forEach(([l, a]) => {
const s = l.replace(/(-\w)/g, (p) => p[1].toUpperCase());
if (!(s === "args" || a === void 0)) {
ke.includes(s) && a && (a = ze(a)), t.ref && (t.ref = c);
function o(t, i) {
O(t) && O(i) && Object.entries(t).forEach(([u, a]) => {
const c = u.replace(/(-\w)/g, (l) => l[1].toUpperCase());
if (!(c === "args" || a === void 0)) {
He.includes(c) && a && (a = We(a)), t.ref && (t.ref = i);
try {
if (c[s] && R(c[s].set))
c[s].set(...z(a) ? a : [a]);
if (i[c] && O(i[c].set))
i[c].set(...N(a) ? a : [a]);
else {
if (a === "" && (a = !0), Fe(c[s])) {
if (l === "center" && !a)
if (a === "" && (a = !0), Ne(i[c])) {
if (u === "center" && !a)
return;
c[s](...z(a) ? a : [a]);
i[c](...N(a) ? a : [a]);
return;
}
c[s] = a;
i[c] = a;
}
} catch (p) {
n(`There was an error setting ${s} property`, p);
} catch (l) {
n(`There was an error setting ${c} property`, l);
}

@@ -134,222 +134,230 @@ }

}
function f(t) {
var a, s;
const c = /^Symbol\(Fragment\)$/g, l = /^Symbol\(Text\)$/g;
if (c.test(t.type.toString()))
return t.children.map((p) => f(p));
if (l.test(t.type.toString()))
function s(t) {
var a, c;
const i = /^Symbol\(Fragment\)$/g, u = /^Symbol\(Text\)$/g;
if (i.test(t.type.toString()))
return t.children.map((l) => s(l));
if (u.test(t.type.toString()))
return;
{
const p = t.type.name.replace(e, ""), { catalogue: C } = fe(), h = M("catalogue") || C;
let v;
if (h)
const l = t.type.name.replace(e, ""), { catalogue: S } = he(), g = R("catalogue") || S;
let w;
if (g)
if ((a = t.children) != null && a.default) {
const E = t.children.default().map((w) => f(w));
v = new h.value[p](...E.flat().filter(Boolean));
const P = t.children.default().map((b) => s(b));
w = new g.value[l](...P.flat().filter(Boolean));
} else
(s = t == null ? void 0 : t.props) != null && s.args ? h != null && h.value[p] ? v = new h.value[p](...t.props.args) : n(`There is no ${p} in the catalogue`, h == null ? void 0 : h.value.uuid) : v = new h.value[p]();
return t != null && t.props && (p === "BufferGeometry" ? o(t.props, v) : i(t.props, v)), r(`Created ${p} instance`, v), v;
(c = t == null ? void 0 : t.props) != null && c.args ? g != null && g.value[l] ? w = new g.value[l](...t.props.args) : n(`There is no ${l} in the catalogue`, g == null ? void 0 : g.value.uuid) : w = new g.value[l]();
return t != null && t.props && (l === "BufferGeometry" ? r(t.props, w) : o(t.props, w)), w;
}
}
function u(t, c, l) {
if (l.default && (l != null && l.default())) {
const a = l.default().map((s) => f(s));
function p(t, i, u) {
if (u.default && (u != null && u.default())) {
const a = u.default().map((c) => s(c));
if (t.name === "Group") {
const s = new t();
return a.forEach((p) => {
s.add(p);
}), s;
const c = new t();
return a.forEach((l) => {
c.add(l);
}), c;
} else
return new t(...a.flat().filter(Boolean));
} else
return c.args ? new t(...c.args) : new t();
return i.args ? new t(...i.args) : new t();
}
function m(t) {
return Object.entries(t.value).filter(([c, l]) => {
var a, s;
return (s = (a = l == null ? void 0 : l.prototype) == null ? void 0 : a.constructor) == null ? void 0 : s.toString().includes("class");
}).map(([c, l]) => {
const a = `${e}${c}`, s = N({
function f(t) {
return Object.entries(t.value).filter(([i, 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(([i, u]) => {
const a = `${e}${i}`, c = X({
name: a,
setup(p, { slots: C, attrs: h, ...v }) {
const { scene: E } = he(), w = M("local-scene") || E, P = M("catalogue"), { pushCamera: S } = le();
let y = u(l, h, C);
return i(h, y), (y instanceof _ || y instanceof ce) && S(y), y.isObject3D && (w == null || w.value.add(y)), w != null && w.value && y.isFog && (w.value.fog = y), v.expose(y), r(a, {
sceneuuid: w == null ? void 0 : w.value.uuid,
catalogue: P == null ? void 0 : P.value.uuid,
props: p,
slots: C.default ? C.default() : void 0,
attrs: h,
ctx: v,
scene: w
}), () => {
setup(l, { slots: S, attrs: g, ...w }) {
const { scene: P } = Se(), { onLoop: b } = Q(), y = R("local-scene") || P, E = R("raycaster"), { pushCamera: M } = we();
let h = p(u, g, S);
o(g, h), (h instanceof U || h instanceof de) && M(h), h.isObject3D && (y == null || y.value.add(h));
let C = null, v = null;
if (h.isMesh) {
b(() => {
if (h && (E != null && E.value)) {
const _ = E == null ? void 0 : E.value.intersectObjects(y.value.children);
_.length > 0 ? (v = _[0], (C === null || C.object.uuid !== (v == null ? void 0 : v.object.uuid)) && w.emit("pointer-enter", v), w.emit("pointer-move", v)) : (v = null, C !== null && w.emit("pointer-leave", C)), C = v;
}
});
const $ = Te(window, "click", () => {
w.emit("click", C);
});
pe(() => {
$();
});
}
return y != null && y.value && h.isFog && (y.value.fog = h), w.expose(h), () => {
};
}
});
return [a, s];
return [a, c];
});
}
return {
createComponentInstances: m,
processProps: i,
createInstanceFromVNode: f
createComponentInstances: f,
processProps: o,
createInstanceFromVNode: s
};
}
const me = G(), de = G(), H = G(), b = new ue();
let D = 0, F = 0;
const { pause: Ve, resume: je, isActive: Ne } = Ee(
const ye = Y(), Ce = Y(), q = Y(), I = new ge();
let k = 0, V = 0;
const { pause: Ke, resume: Je, isActive: Xe } = Re(
() => {
me.trigger({ delta: D, elapsed: F, clock: b }), de.trigger({ delta: D, elapsed: F, clock: b }), H.trigger({ delta: D, elapsed: F, clock: b });
ye.trigger({ delta: k, elapsed: V, clock: I }), Ce.trigger({ delta: k, elapsed: V, clock: I }), q.trigger({ delta: k, elapsed: V, clock: I });
},
{ immediate: !1 }
);
H.on(() => {
D = b.getDelta(), F = b.getElapsedTime();
q.on(() => {
k = I.getDelta(), V = I.getElapsedTime();
});
function ge() {
function Q() {
return {
onBeforeLoop: me.on,
onLoop: de.on,
onAfterLoop: H.on,
pause: Ve,
resume: je,
isActive: Ne
onBeforeLoop: ye.on,
onLoop: Ce.on,
onAfterLoop: q.on,
pause: Ke,
resume: Je,
isActive: Xe
};
}
const We = W(new be());
function he() {
const Ye = W(new $e());
function Se() {
return {
scene: We
scene: Ye
};
}
function Ge(e) {
const r = { nodes: {}, materials: {} };
return e && e.traverse((n) => {
n.name && (r.nodes[n.name] = n), n.material && !r.materials[n.material.name] && (r.materials[n.material.name] = n.material);
}), r;
function qe(e) {
const n = { nodes: {}, materials: {} };
return e && e.traverse((r) => {
r.name && (n.nodes[r.name] = r), r.material && !n.materials[r.material.name] && (n.materials[r.material.name] = r.material);
}), n;
}
async function Ze(e, r, n, o, i) {
const { logError: f } = U(), u = new e();
i && i(u), n && n(u);
const t = (Array.isArray(r) ? r : [r]).map(
(c) => new Promise((l, a) => {
u.load(
c,
(s) => {
s.scene && Object.assign(s, Ge(s.scene)), l(s);
async function st(e, n, r, o, s) {
const { logError: p } = G(), f = new e();
s && s(f), r && r(f);
const i = (Array.isArray(n) ? n : [n]).map(
(u) => new Promise((a, c) => {
f.load(
u,
(l) => {
l.scene && Object.assign(l, qe(l.scene)), a(l);
},
o,
(s) => a(f("[useLoader] - Failed to load resource", s))
(l) => c(p("[useLoader] - Failed to load resource", l))
);
})
);
return z(r) ? await Promise.all(t) : await t[0];
return N(n) ? await Promise.all(i) : await i[0];
}
async function et(e) {
const r = new Be(), n = new Oe(r), o = (i) => new Promise((f, u) => {
n.load(
i,
(m) => f(m),
async function ct(e) {
const n = new _e(), r = new Fe(n), o = (s) => new Promise((p, f) => {
r.load(
s,
(t) => p(t),
() => null,
() => {
u(new Error("[useTextures] - Failed to load texture"));
f(new Error("[useTextures] - Failed to load texture"));
}
);
});
if (z(e)) {
const i = await Promise.all(e.map((f) => o(f)));
return e.length > 1 ? i : i[0];
if (N(e)) {
const s = await Promise.all(e.map((p) => o(p)));
return e.length > 1 ? s : s[0];
} else {
const { map: i, displacementMap: f, normalMap: u, roughnessMap: m, metalnessMap: t, aoMap: c } = e;
const { map: s, displacementMap: p, normalMap: f, roughnessMap: t, metalnessMap: i, aoMap: u } = e;
return {
map: i ? await o(i) : null,
displacementMap: f ? await o(f) : null,
normalMap: u ? await o(u) : null,
roughnessMap: m ? await o(m) : null,
metalnessMap: t ? await o(t) : null,
aoMap: c ? await o(c) : null
map: s ? await o(s) : null,
displacementMap: p ? await o(p) : null,
normalMap: f ? await o(f) : null,
roughnessMap: t ? await o(t) : null,
metalnessMap: i ? await o(i) : null,
aoMap: u ? await o(u) : null
};
}
}
const O = xe({});
function we() {
function e(n) {
return O[n];
const F = Le({});
function Z() {
function e(r) {
return F[r];
}
function r(n, o) {
O[n] = o;
function n(r, o) {
F[r] = o;
}
return {
state: O,
...ie(O),
state: F,
...me(F),
getState: e,
setState: r
setState: n
};
}
const g = W(), j = B(!1);
function He(e, r, n) {
const d = W(), J = L(!1);
function Qe(e, n, r) {
const {
alpha: o = !0,
antialias: i = !0,
depth: f,
logarithmicDepthBuffer: u,
failIfMajorPerformanceCaveat: m,
precision: t,
premultipliedAlpha: c,
stencil: l,
shadows: a = !1,
shadowMapType: s = $e,
physicallyCorrectLights: p = !1,
outputEncoding: C = re,
toneMapping: h = ae,
toneMappingExposure: v = 1,
context: E = void 0,
powerPreference: w = "default",
preserveDrawingBuffer: P = !1,
clearColor: S,
windowSize: y = !1
} = ie(n), { width: K, height: J } = d(y) ? Pe() : Te(r), { pixelRatio: q } = Le(), { pause: ve, resume: ye } = ge(), Q = se(() => K.value / J.value), X = () => {
g.value && (g.value.setSize(K.value, J.value), g.value.setPixelRatio(Math.min(q.value, 2)));
}, Y = () => {
g.value && (g.value.shadowMap.enabled = d(a), g.value.shadowMap.type = d(s), g.value.toneMapping = d(h) || ae, g.value.toneMappingExposure = d(v), g.value.outputEncoding = d(C) || re, S != null && S.value && g.value.setClearColor(Ue(d(S))), g.value.physicallyCorrectLights = d(p));
}, Ce = () => {
const Z = k(e);
if (g.value || !Z)
antialias: s = !0,
depth: p,
logarithmicDepthBuffer: f,
failIfMajorPerformanceCaveat: t,
precision: i,
premultipliedAlpha: u,
stencil: a,
shadows: c = !1,
shadowMapType: l = De,
physicallyCorrectLights: S = !1,
outputEncoding: g = se,
toneMapping: w = ce,
toneMappingExposure: P = 1,
context: b = void 0,
powerPreference: y = "default",
preserveDrawingBuffer: E = !1,
clearColor: M,
windowSize: h = !1
} = me(r), { width: C, height: v } = m(h) ? be() : Ae(n), { pixelRatio: $ } = Be(), { pause: _, resume: Ee } = Q(), ee = fe(() => C.value / v.value), te = () => {
d.value && (d.value.setSize(C.value, v.value), d.value.setPixelRatio(Math.min($.value, 2)));
}, ne = () => {
d.value && (d.value.shadowMap.enabled = m(c), d.value.shadowMap.type = m(l), d.value.toneMapping = m(w) || ce, d.value.toneMappingExposure = m(P), d.value.outputEncoding = m(g) || se, M != null && M.value && d.value.setClearColor(Ge(m(M))), d.value.physicallyCorrectLights = m(S));
}, Me = () => {
const re = H(e);
if (d.value || !re)
return;
g.value = new Ie({
canvas: Z,
alpha: d(o),
antialias: d(i),
context: d(E),
depth: d(f),
failIfMajorPerformanceCaveat: d(m),
logarithmicDepthBuffer: d(u),
powerPreference: d(w),
precision: d(t),
stencil: d(l),
preserveDrawingBuffer: d(P),
premultipliedAlpha: d(c)
d.value = new ze({
canvas: re,
alpha: m(o),
antialias: m(s),
context: m(b),
depth: m(p),
failIfMajorPerformanceCaveat: m(t),
logarithmicDepthBuffer: m(f),
powerPreference: m(y),
precision: m(i),
stencil: m(a),
preserveDrawingBuffer: m(E),
premultipliedAlpha: m(u)
});
const { setState: ee } = we();
ee("renderer", g.value), ee("clock", new ue()), Y(), X(), ye(), j.value = !0;
}, Se = () => {
g.value && (g.value.dispose(), g.value = void 0, j.value = !1, ve());
const { setState: oe } = Z();
oe("renderer", d.value), oe("clock", new ge()), ne(), te(), Ee(), J.value = !0;
}, xe = () => {
d.value && (d.value.dispose(), d.value = void 0, J.value = !1, _());
};
return $([Q, q], X), $(
[a, s, C, p, h, v, S],
Y
), $(
() => [e, r],
return z([ee, $], te), z(
[c, l, g, S, w, P, M],
ne
), z(
() => [e, n],
() => {
k(e) && k(r) && Ce();
H(e) && H(n) && Me();
},
{ immediate: !0, deep: !0 }
), {
renderer: g,
isReady: j,
dispose: Se,
aspectRatio: Q
renderer: d,
isReady: J,
dispose: xe,
aspectRatio: ee
};
}
const Ke = N({
const Ze = X({
name: "TresCanvas",

@@ -369,15 +377,15 @@ props: {

},
setup(e, { slots: r, attrs: n }) {
const { logError: o } = U(), i = B(), f = B(), { renderer: u, dispose: m, aspectRatio: t } = He(i, f, e);
I("aspect-ratio", t), I("renderer", u);
const c = W();
return I("camera", c), r.default && !r.default().some((l) => l.type.name === "Scene") && o("TresCanvas must contain a Scene component."), r.default && !r.default().some((l) => {
var a;
return (a = l.type.name) == null ? void 0 : a.includes("Camera");
}) && o("Scene must contain a Camera component."), Me(() => m()), () => {
if (r.default)
return te(
setup(e, { slots: n, attrs: r }) {
const { logError: o } = G(), s = L(), p = L(), { renderer: f, dispose: t, aspectRatio: i } = Qe(s, p, e);
x("aspect-ratio", i), x("renderer", f);
const u = W();
return x("camera", u), n.default && !n.default().some((a) => a.type.name === "Scene") && o("TresCanvas must contain a Scene component."), n.default && !n.default().some((a) => {
var c;
return (c = a.type.name) == null ? void 0 : c.includes("Camera");
}) && o("Scene must contain a Camera component."), Pe(() => t()), () => {
if (n.default)
return ae(
"div",
{
ref: f,
ref: p,
style: {

@@ -387,8 +395,8 @@ position: "relative",

height: "100vh",
...n.style
...r.style
}
},
[
te("canvas", {
ref: i,
ae("canvas", {
ref: s,
style: {

@@ -402,3 +410,3 @@ width: "100%",

}),
r.default()
n.default()
]

@@ -408,25 +416,38 @@ );

}
}), Je = N({
}), le = W(new Ue()), D = L(new je()), et = L(null);
function tt() {
x("raycaster", le), x("pointer", D), x("currentInstance", et);
function e(n) {
D.value.x = n.clientX / window.innerWidth * 2 - 1, D.value.y = -(n.clientY / window.innerHeight) * 2 + 1;
}
return window.addEventListener("pointermove", e), pe(() => {
window.removeEventListener("pointermove", e);
}), {
raycaster: le,
pointer: D
};
}
const nt = X({
name: "Scene",
setup(e, { slots: r }) {
const { scene: n } = he(), o = M("renderer"), { activeCamera: i } = le(), { onLoop: f } = ge();
return I("local-scene", n), f(({ clock: u }) => {
o != null && o.value && (i != null && i.value) && (n != null && n.value) && o.value.render(n == null ? void 0 : n.value, i.value);
setup(e, { slots: n }) {
const { scene: r } = Se(), o = R("renderer"), { activeCamera: s } = we(), { raycaster: p, pointer: f } = tt(), { onLoop: t } = Q();
return x("local-scene", r), t(() => {
p.value.setFromCamera(f.value, s.value), o != null && o.value && (s != null && s.value) && (r != null && r.value) && o.value.render(r == null ? void 0 : r.value, s.value);
}), () => {
if (r.default)
return r.default();
if (n.default)
return n.default();
};
}
}), tt = Symbol("UseTresState"), qe = "1.5.1", nt = {
install(e, r) {
const n = (r == null ? void 0 : r.prefix) || "Tres";
e.component(`${n}Canvas`, Ke), e.component(`${n}Scene`, Je);
const { catalogue: o, extend: i } = fe(e, n);
e.provide("catalogue", o), e.provide("extend", i);
const { createComponentInstances: f } = pe(n);
f(o).forEach(([m, t]) => {
e.component(m, t);
}), ut = Symbol("UseTresState"), rt = "1.6.0", lt = {
install(e, n) {
const r = (n == null ? void 0 : n.prefix) || "Tres";
e.component(`${r}Canvas`, Ze), e.component(`${r}Scene`, nt);
const { catalogue: o, extend: s } = he(e, r);
e.provide("catalogue", o), e.provide("extend", s), e.provide("useTres", Z());
const { createComponentInstances: p } = ve(r);
p(o).forEach(([t, i]) => {
e.component(t, i);
}), window.__TRES__ = {
app: e,
version: qe
version: rt
};

@@ -436,15 +457,15 @@ }

export {
_e as CameraType,
tt as UseTresStateSymbol,
nt as default,
Ge as trasverseObjects,
le as useCamera,
fe as useCatalogue,
pe as useInstanceCreator,
Ze as useLoader,
ge as useRenderLoop,
He as useRenderer,
he as useScene,
et as useTexture,
we as useTres
ke as CameraType,
ut as UseTresStateSymbol,
lt as default,
qe as trasverseObjects,
we as useCamera,
he as useCatalogue,
ve as useInstanceCreator,
st as useLoader,
Q as useRenderLoop,
Qe as useRenderer,
Se as useScene,
ct as useTexture,
Z as useTres
};

@@ -16,2 +16,12 @@ import { Object3D } from 'three'

export type TresColor = string | number | Color | number[]
export interface TresEvent extends Intersection<Object3D<Event>> {
object: Object3D
distance: number
face?: Face3
faceIndex?: number | undefined
point: Vector3
uv?: Vector2
}
declare global {

@@ -18,0 +28,0 @@ // Define the window interface, with type annotations for the properties and methods of the window object

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

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

"@alvarosabu/utils": "^2.2.0",
"@tresjs/cientos": "^1.5.0",
"@tresjs/cientos": "^1.6.0",
"@types/three": "^0.148.0",

@@ -44,0 +44,0 @@ "@vitejs/plugin-vue": "^4.0.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