@tresjs/core
Advanced tools
Comparing version 1.5.0 to 1.5.1
import { EventHookOn, Fn } from '@vueuse/core'; | ||
import { Ref } from 'vue'; | ||
import { Clock } from 'three'; | ||
export interface RenderLoop { | ||
delta: number; | ||
elapsed: number; | ||
clock: Clock; | ||
} | ||
@@ -7,0 +9,0 @@ export interface UseRenderLoopReturn { |
374
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v1.5.0 | ||
* version: v1.5.1 | ||
* (c) 2023 | ||
@@ -8,23 +8,23 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { inject as M, computed as ne, watch as O, ref as b, defineComponent as V, shallowRef as j, reactive as ye, toRefs as re, provide as $, onBeforeUnmount as Ce, h as Q } from "vue"; | ||
import { createEventHook as N, useRafFn as Se, resolveUnref as d, useWindowSize as xe, useElementSize as Me, useDevicePixelRatio as Ee, unrefElement as F } from "@vueuse/core"; | ||
import * as X from "three"; | ||
import { PerspectiveCamera as I, OrthographicCamera as ae, Vector3 as Pe, Color as z, BufferAttribute as Te, Clock as Le, Scene as Re, LoadingManager as Ae, TextureLoader as be, PCFShadowMap as Be, LinearEncoding as Y, NoToneMapping as Z, WebGLRenderer as Oe } from "three"; | ||
var $e = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))($e || {}); | ||
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 = { | ||
cameras: [] | ||
}, Ie = 45; | ||
}, De = 45; | ||
let x; | ||
function oe() { | ||
const e = M("aspect-ratio"), { setState: n } = me(); | ||
function r(l = "Perspective", m) { | ||
if (l === "Perspective") { | ||
const { near: t, far: c, fov: u } = m || { | ||
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 || { | ||
near: 0.1, | ||
far: 1e3, | ||
fov: Ie | ||
fov: De | ||
}; | ||
x = new I(u, (e == null ? void 0 : e.value) || 1, t, c), T.cameras.push(x); | ||
x = new _(l, (e == null ? void 0 : e.value) || 1, t, c), T.cameras.push(x); | ||
} else { | ||
const { left: t, right: c, top: u, bottom: a, near: s, far: p } = m || { | ||
const { left: t, right: c, top: l, bottom: a, near: s, far: p } = m || { | ||
left: -100, | ||
@@ -37,17 +37,17 @@ right: 100, | ||
}; | ||
x = new ae(t, c, u, a, s, p), T.cameras.push(x); | ||
x = new ce(t, c, l, a, s, p), T.cameras.push(x); | ||
} | ||
return T.cameras.push(x), x; | ||
} | ||
const o = ne(() => T.cameras[0]); | ||
const o = se(() => T.cameras[0]); | ||
function i() { | ||
o.value instanceof I && e && (o.value.aspect = e.value), o.value.updateProjectionMatrix(); | ||
o.value instanceof _ && e && (o.value.aspect = e.value), o.value.updateProjectionMatrix(); | ||
} | ||
function f(l) { | ||
function f(u) { | ||
const m = M("camera"); | ||
l && m && (m.value = l, n("camera", m.value)), T.cameras.push(l), l instanceof I && e && (l.aspect = e.value), l.updateProjectionMatrix(); | ||
u && m && (m.value = u, r("camera", m.value)), T.cameras.push(u), u instanceof _ && e && (u.aspect = e.value), u.updateProjectionMatrix(); | ||
} | ||
return e && O(e, i), { | ||
return e && $(e, i), { | ||
activeCamera: o, | ||
createCamera: r, | ||
createCamera: n, | ||
updateCamera: i, | ||
@@ -57,34 +57,34 @@ pushCamera: f | ||
} | ||
const ee = "[TresJS ▲ ■ ●] "; | ||
function D() { | ||
const oe = "[TresJS ▲ ■ ●] "; | ||
function U() { | ||
function e(o, i) { | ||
console.error(`${ee} ${o}`, i || ""); | ||
console.error(`${oe} ${o}`, i || ""); | ||
} | ||
function n(o) { | ||
console.warn(`${ee} ${o}`); | ||
function r(o) { | ||
console.warn(`${oe} ${o}`); | ||
} | ||
function r(o, i) { | ||
function n(o, i) { | ||
} | ||
return { | ||
logError: e, | ||
logWarning: n, | ||
logMessage: r | ||
logWarning: r, | ||
logMessage: n | ||
}; | ||
} | ||
const A = b({ ...X, uuid: X.MathUtils.generateUUID() }); | ||
const A = B({ ...ne, uuid: ne.MathUtils.generateUUID() }); | ||
delete A.value.Scene; | ||
let L; | ||
function se(e, n = "Tres") { | ||
const { logMessage: r, logError: o } = D(); | ||
function fe(e, r = "Tres") { | ||
const { logMessage: n, logError: o } = U(); | ||
!L && e && (L = e); | ||
const { createComponentInstances: i } = ie(n); | ||
const { createComponentInstances: i } = pe(r); | ||
return { | ||
extend: (l) => { | ||
if (!l) { | ||
extend: (u) => { | ||
if (!u) { | ||
o("No objects provided to extend catalogue"); | ||
return; | ||
} | ||
A.value = Object.assign(A.value, l); | ||
const m = i(b(l)); | ||
r("Adding objects to catalogue", { objects: l, catalogue: A.value.uuid }), L && m.forEach(([t, c]) => { | ||
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); | ||
@@ -96,31 +96,31 @@ }); | ||
} | ||
const R = (e) => typeof e < "u", _e = (e) => typeof e == "function", _ = (e) => !!e && e.constructor === Array; | ||
function De(e) { | ||
return typeof e == "number" ? [e, e, e] : e instanceof Pe ? [e.x, e.y, e.z] : e; | ||
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; | ||
} | ||
function Fe(e) { | ||
return e instanceof z ? e : Array.isArray(e) ? new z(...e) : new z(e); | ||
function Ue(e) { | ||
return e instanceof V ? e : Array.isArray(e) ? new V(...e) : new V(e); | ||
} | ||
const ze = ["rotation", "scale", "position"]; | ||
function ie(e) { | ||
const { logMessage: n, logError: r } = D(); | ||
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(([u, a]) => { | ||
const s = u.replace(/(-\w)/g, (p) => p[1].toUpperCase()); | ||
c.setAttribute(s, new Te(...a)); | ||
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)); | ||
}); | ||
} | ||
function i(t, c) { | ||
R(t) && R(c) && Object.entries(t).forEach(([u, a]) => { | ||
const s = u.replace(/(-\w)/g, (p) => p[1].toUpperCase()); | ||
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)) { | ||
ze.includes(s) && a && (a = De(a)), t.ref && (t.ref = c); | ||
ke.includes(s) && a && (a = ze(a)), t.ref && (t.ref = c); | ||
try { | ||
if (c[s] && R(c[s].set)) | ||
c[s].set(..._(a) ? a : [a]); | ||
c[s].set(...z(a) ? a : [a]); | ||
else { | ||
if (a === "" && (a = !0), _e(c[s])) { | ||
if (u === "center" && !a) | ||
if (a === "" && (a = !0), Fe(c[s])) { | ||
if (l === "center" && !a) | ||
return; | ||
c[s](..._(a) ? a : [a]); | ||
c[s](...z(a) ? a : [a]); | ||
return; | ||
@@ -131,3 +131,3 @@ } | ||
} catch (p) { | ||
r(`There was an error setting ${s} property`, p); | ||
n(`There was an error setting ${s} property`, p); | ||
} | ||
@@ -139,9 +139,9 @@ } | ||
var a, s; | ||
const c = /^Symbol\(Fragment\)$/g, u = /^Symbol\(Text\)$/g; | ||
const c = /^Symbol\(Fragment\)$/g, l = /^Symbol\(Text\)$/g; | ||
if (c.test(t.type.toString())) | ||
return t.children.map((p) => f(p)); | ||
if (u.test(t.type.toString())) | ||
if (l.test(t.type.toString())) | ||
return; | ||
{ | ||
const p = t.type.name.replace(e, ""), { catalogue: C } = se(), h = M("catalogue") || C; | ||
const p = t.type.name.replace(e, ""), { catalogue: C } = fe(), h = M("catalogue") || C; | ||
let v; | ||
@@ -153,9 +153,9 @@ if (h) | ||
} else | ||
(s = t == null ? void 0 : t.props) != null && s.args ? h != null && h.value[p] ? v = new h.value[p](...t.props.args) : r(`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)), n(`Created ${p} instance`, v), v; | ||
(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; | ||
} | ||
} | ||
function l(t, c, u) { | ||
if (u.default && (u != null && u.default())) { | ||
const a = u.default().map((s) => f(s)); | ||
function u(t, c, l) { | ||
if (l.default && (l != null && l.default())) { | ||
const a = l.default().map((s) => f(s)); | ||
if (t.name === "Group") { | ||
@@ -172,12 +172,12 @@ const s = new t(); | ||
function m(t) { | ||
return Object.entries(t.value).filter(([c, u]) => { | ||
return Object.entries(t.value).filter(([c, l]) => { | ||
var a, s; | ||
return (s = (a = u == null ? void 0 : u.prototype) == null ? void 0 : a.constructor) == null ? void 0 : s.toString().includes("class"); | ||
}).map(([c, u]) => { | ||
const a = `${e}${c}`, s = V({ | ||
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({ | ||
name: a, | ||
setup(p, { slots: C, attrs: h, ...v }) { | ||
const { scene: E } = pe(), w = M("local-scene") || E, P = M("catalogue"), { pushCamera: S } = oe(); | ||
let y = l(u, h, C); | ||
return i(h, y), (y instanceof I || y instanceof ae) && S(y), y.isObject3D && (w == null || w.value.add(y)), w != null && w.value && y.isFog && (w.value.fog = y), v.expose(y), n(a, { | ||
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, | ||
@@ -203,40 +203,44 @@ catalogue: P == null ? void 0 : P.value.uuid, | ||
} | ||
const ce = N(), ue = N(), le = N(), te = new Le(), { pause: Ue, resume: Ve, isActive: je } = Se( | ||
const me = G(), de = G(), H = G(), b = new ue(); | ||
let D = 0, F = 0; | ||
const { pause: Ve, resume: je, isActive: Ne } = Ee( | ||
() => { | ||
const e = te.getElapsedTime(), n = te.getDelta(); | ||
ce.trigger({ delta: n, elapsed: e }), ue.trigger({ delta: n, elapsed: e }), le.trigger({ delta: n, elapsed: e }); | ||
me.trigger({ delta: D, elapsed: F, clock: b }), de.trigger({ delta: D, elapsed: F, clock: b }), H.trigger({ delta: D, elapsed: F, clock: b }); | ||
}, | ||
{ immediate: !1 } | ||
); | ||
function fe() { | ||
H.on(() => { | ||
D = b.getDelta(), F = b.getElapsedTime(); | ||
}); | ||
function ge() { | ||
return { | ||
onBeforeLoop: ce.on, | ||
onLoop: ue.on, | ||
onAfterLoop: le.on, | ||
pause: Ue, | ||
resume: Ve, | ||
isActive: je | ||
onBeforeLoop: me.on, | ||
onLoop: de.on, | ||
onAfterLoop: H.on, | ||
pause: Ve, | ||
resume: je, | ||
isActive: Ne | ||
}; | ||
} | ||
const Ne = j(new Re()); | ||
function pe() { | ||
const We = W(new be()); | ||
function he() { | ||
return { | ||
scene: Ne | ||
scene: We | ||
}; | ||
} | ||
function ke(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; | ||
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; | ||
} | ||
async function Xe(e, n, r, o, i) { | ||
const { logError: f } = D(), l = new e(); | ||
i && i(l), r && r(l); | ||
const t = (Array.isArray(n) ? n : [n]).map( | ||
(c) => new Promise((u, a) => { | ||
l.load( | ||
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, ke(s.scene)), u(s); | ||
s.scene && Object.assign(s, Ge(s.scene)), l(s); | ||
}, | ||
@@ -248,7 +252,7 @@ o, | ||
); | ||
return _(n) ? await Promise.all(t) : await t[0]; | ||
return z(r) ? await Promise.all(t) : await t[0]; | ||
} | ||
async function Ye(e) { | ||
const n = new Ae(), r = new be(n), o = (i) => new Promise((f, l) => { | ||
r.load( | ||
async function et(e) { | ||
const r = new Be(), n = new Oe(r), o = (i) => new Promise((f, u) => { | ||
n.load( | ||
i, | ||
@@ -258,15 +262,15 @@ (m) => f(m), | ||
() => { | ||
l(new Error("[useTextures] - Failed to load texture")); | ||
u(new Error("[useTextures] - Failed to load texture")); | ||
} | ||
); | ||
}); | ||
if (_(e)) { | ||
if (z(e)) { | ||
const i = await Promise.all(e.map((f) => o(f))); | ||
return e.length > 1 ? i : i[0]; | ||
} else { | ||
const { map: i, displacementMap: f, normalMap: l, roughnessMap: m, metalnessMap: t, aoMap: c } = e; | ||
const { map: i, displacementMap: f, normalMap: u, roughnessMap: m, metalnessMap: t, aoMap: c } = e; | ||
return { | ||
map: i ? await o(i) : null, | ||
displacementMap: f ? await o(f) : null, | ||
normalMap: l ? await o(l) : null, | ||
normalMap: u ? await o(u) : null, | ||
roughnessMap: m ? await o(m) : null, | ||
@@ -278,19 +282,19 @@ metalnessMap: t ? await o(t) : null, | ||
} | ||
const B = ye({}); | ||
function me() { | ||
function e(r) { | ||
return B[r]; | ||
const O = xe({}); | ||
function we() { | ||
function e(n) { | ||
return O[n]; | ||
} | ||
function n(r, o) { | ||
B[r] = o; | ||
function r(n, o) { | ||
O[n] = o; | ||
} | ||
return { | ||
state: B, | ||
...re(B), | ||
state: O, | ||
...ie(O), | ||
getState: e, | ||
setState: n | ||
setState: r | ||
}; | ||
} | ||
const g = j(), U = b(!1); | ||
function We(e, n, r) { | ||
const g = W(), j = B(!1); | ||
function He(e, r, n) { | ||
const { | ||
@@ -300,12 +304,12 @@ alpha: o = !0, | ||
depth: f, | ||
logarithmicDepthBuffer: l, | ||
logarithmicDepthBuffer: u, | ||
failIfMajorPerformanceCaveat: m, | ||
precision: t, | ||
premultipliedAlpha: c, | ||
stencil: u, | ||
stencil: l, | ||
shadows: a = !1, | ||
shadowMapType: s = Be, | ||
shadowMapType: s = $e, | ||
physicallyCorrectLights: p = !1, | ||
outputEncoding: C = Y, | ||
toneMapping: h = Z, | ||
outputEncoding: C = re, | ||
toneMapping: h = ae, | ||
toneMappingExposure: v = 1, | ||
@@ -317,12 +321,12 @@ context: E = void 0, | ||
windowSize: y = !1 | ||
} = re(r), { width: k, height: W } = d(y) ? xe() : Me(n), { pixelRatio: G } = Ee(), { pause: de, resume: ge } = fe(), H = ne(() => k.value / W.value), K = () => { | ||
g.value && (g.value.setSize(k.value, W.value), g.value.setPixelRatio(Math.min(G.value, 2))); | ||
}, J = () => { | ||
g.value && (g.value.shadowMap.enabled = d(a), g.value.shadowMap.type = d(s), g.value.toneMapping = d(h) || Z, g.value.toneMappingExposure = d(v), g.value.outputEncoding = d(C) || Y, S != null && S.value && g.value.setClearColor(Fe(d(S))), g.value.physicallyCorrectLights = d(p)); | ||
}, he = () => { | ||
const q = F(e); | ||
if (g.value || !q) | ||
} = 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) | ||
return; | ||
g.value = new Oe({ | ||
canvas: q, | ||
g.value = new Ie({ | ||
canvas: Z, | ||
alpha: d(o), | ||
@@ -333,21 +337,21 @@ antialias: d(i), | ||
failIfMajorPerformanceCaveat: d(m), | ||
logarithmicDepthBuffer: d(l), | ||
logarithmicDepthBuffer: d(u), | ||
powerPreference: d(w), | ||
precision: d(t), | ||
stencil: d(u), | ||
stencil: d(l), | ||
preserveDrawingBuffer: d(P), | ||
premultipliedAlpha: d(c) | ||
}); | ||
const { setState: ve } = me(); | ||
ve("renderer", g.value), J(), K(), ge(), U.value = !0; | ||
}, we = () => { | ||
g.value && (g.value.dispose(), g.value = void 0, U.value = !1, de()); | ||
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()); | ||
}; | ||
return O([H, G], K), O( | ||
return $([Q, q], X), $( | ||
[a, s, C, p, h, v, S], | ||
J | ||
), O( | ||
() => [e, n], | ||
Y | ||
), $( | ||
() => [e, r], | ||
() => { | ||
F(e) && F(n) && he(); | ||
k(e) && k(r) && Ce(); | ||
}, | ||
@@ -357,8 +361,8 @@ { immediate: !0, deep: !0 } | ||
renderer: g, | ||
isReady: U, | ||
dispose: we, | ||
aspectRatio: H | ||
isReady: j, | ||
dispose: Se, | ||
aspectRatio: Q | ||
}; | ||
} | ||
const Ge = V({ | ||
const Ke = N({ | ||
name: "TresCanvas", | ||
@@ -378,12 +382,12 @@ props: { | ||
}, | ||
setup(e, { slots: n, attrs: r }) { | ||
const { logError: o } = D(), i = b(), f = b(), { renderer: l, dispose: m, aspectRatio: t } = We(i, f, e); | ||
$("aspect-ratio", t), $("renderer", l); | ||
const c = j(); | ||
return $("camera", c), n.default && !n.default().some((u) => u.type.name === "Scene") && o("TresCanvas must contain a Scene component."), n.default && !n.default().some((u) => { | ||
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 = u.type.name) == null ? void 0 : a.includes("Camera"); | ||
}) && o("Scene must contain a Camera component."), Ce(() => m()), () => { | ||
if (n.default) | ||
return Q( | ||
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( | ||
"div", | ||
@@ -396,7 +400,7 @@ { | ||
height: "100vh", | ||
...r.style | ||
...n.style | ||
} | ||
}, | ||
[ | ||
Q("canvas", { | ||
te("canvas", { | ||
ref: i, | ||
@@ -411,3 +415,3 @@ style: { | ||
}), | ||
n.default() | ||
r.default() | ||
] | ||
@@ -417,20 +421,20 @@ ); | ||
} | ||
}), He = V({ | ||
}), Je = N({ | ||
name: "Scene", | ||
setup(e, { slots: n }) { | ||
const { scene: r } = pe(), o = M("renderer"), { activeCamera: i } = oe(), { onLoop: f } = fe(); | ||
return $("local-scene", r), f(() => { | ||
o != null && o.value && (i != null && i.value) && (r != null && r.value) && o.value.render(r == null ? void 0 : r.value, i.value); | ||
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); | ||
}), () => { | ||
if (n.default) | ||
return n.default(); | ||
if (r.default) | ||
return r.default(); | ||
}; | ||
} | ||
}), Ze = Symbol("UseTresState"), Ke = "1.5.0", et = { | ||
install(e, n) { | ||
const r = (n == null ? void 0 : n.prefix) || "Tres"; | ||
e.component(`${r}Canvas`, Ge), e.component(`${r}Scene`, He); | ||
const { catalogue: o, extend: i } = se(e, r); | ||
}), 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 } = ie(r); | ||
const { createComponentInstances: f } = pe(n); | ||
f(o).forEach(([m, t]) => { | ||
@@ -440,3 +444,3 @@ e.component(m, t); | ||
app: e, | ||
version: Ke | ||
version: qe | ||
}; | ||
@@ -446,15 +450,15 @@ } | ||
export { | ||
$e as CameraType, | ||
Ze as UseTresStateSymbol, | ||
et as default, | ||
ke as trasverseObjects, | ||
oe as useCamera, | ||
se as useCatalogue, | ||
ie as useInstanceCreator, | ||
Xe as useLoader, | ||
fe as useRenderLoop, | ||
We as useRenderer, | ||
pe as useScene, | ||
Ye as useTexture, | ||
me as useTres | ||
_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 | ||
}; |
@@ -12,3 +12,3 @@ import { Object3D } from 'three' | ||
} | ||
export type TresVNode = VNode & { children?: Array<VNode>; type: TresVNodeType } | ||
export type TresVNode = VNode & { children?: Array<VNode | { default: any }>; type: TresVNodeType } | ||
export type TresAttributes = Record<string, any> & { args?: number[] } | ||
@@ -15,0 +15,0 @@ |
{ | ||
"name": "@tresjs/core", | ||
"description": "Declarative ThreeJS using Vue Components", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"type": "module", | ||
@@ -41,4 +41,3 @@ "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", | ||
"@alvarosabu/utils": "^2.2.0", | ||
"@histoire/plugin-vue": "0.11.7", | ||
"@tresjs/cientos": "^1.4.0", | ||
"@tresjs/cientos": "^1.5.0", | ||
"@types/three": "^0.148.0", | ||
@@ -48,6 +47,5 @@ "@vitejs/plugin-vue": "^4.0.0", | ||
"@vitest/ui": "^0.25.8", | ||
"@vueuse/core": "^9.7.0", | ||
"@vueuse/core": "^9.11.0", | ||
"gl": "6.0.1", | ||
"happy-dom": "^8.1.0", | ||
"histoire": "0.11.9", | ||
"kolorist": "^1.6.0", | ||
@@ -59,6 +57,6 @@ "pathe": "^1.0.0", | ||
"unplugin-vue-components": "^0.22.12", | ||
"vite": "^4.0.3", | ||
"vite": "^4.0.4", | ||
"vite-plugin-banner": "^0.7.0", | ||
"vite-plugin-dts": "^1.7.1", | ||
"vite-plugin-glsl": "^1.0.1", | ||
"vite-plugin-glsl": "^1.1.0", | ||
"vite-plugin-require-transform": "^1.0.4", | ||
@@ -76,5 +74,2 @@ "vitest": "^0.25.8", | ||
"coverage": "vitest run --coverage", | ||
"story:dev": "histoire dev", | ||
"story:build": "histoire build", | ||
"story:preview": "histoire preview", | ||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue", | ||
@@ -81,0 +76,0 @@ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40644
22
810