@tresjs/core
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,6 +0,6 @@ | ||
export declare function useCatalogue(): { | ||
import { App, Ref } from 'vue'; | ||
import { TresCatalogue } from '../../types'; | ||
export declare function useCatalogue(app?: App, prefix?: string): { | ||
extend: (objects: any) => void; | ||
catalogue: { | ||
[key: string]: any; | ||
}; | ||
catalogue: Ref<TresCatalogue>; | ||
}; |
@@ -0,3 +1,7 @@ | ||
import { Ref } from 'vue'; | ||
import { TresCatalogue, TresInstance, TresVNode } from '../../types'; | ||
export declare function useInstanceCreator(prefix: string): { | ||
createComponentInstances: (newObjects: Record<string, any>) => (string | import("vue").DefineComponent<{}, () => void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>)[][]; | ||
createComponentInstances: (catalogue: Ref<TresCatalogue>) => (string | import("vue").DefineComponent<{}, () => void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>)[][]; | ||
processProps: (props: Record<string, any>, instance: TresInstance) => void; | ||
createInstanceFromVNode: (vnode: TresVNode, catalogue: Ref<TresCatalogue>) => TresInstance; | ||
}; |
468
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v1.0.0 | ||
* version: v1.1.0 | ||
* (c) 2022 | ||
@@ -8,23 +8,23 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { computed as D, watch as O, inject as X, defineComponent as _, shallowRef as j, reactive as fe, toRefs as me, ref as F, provide as A, onBeforeUnmount as de, h as J } from "vue"; | ||
import { useWindowSize as Y, createEventHook as U, useRafFn as ge, useElementSize as he, useDevicePixelRatio as we, unrefElement as B, resolveUnref as S } from "@vueuse/core"; | ||
import * as ve from "three"; | ||
import { PerspectiveCamera as $, OrthographicCamera as Ce, Color as I, Vector3 as ye, Clock as Me, Scene as Se, LoadingManager as xe, TextureLoader as Ee, PCFShadowMap as Pe, LinearEncoding as Le, NoToneMapping as Te, WebGLRenderer as Re } from "three"; | ||
var Oe = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Oe || {}); | ||
const P = { | ||
import { computed as D, watch as x, inject as X, ref as S, defineComponent as _, shallowRef as V, reactive as he, toRefs as we, provide as P, onBeforeUnmount as ve, h as J, watchEffect as Ce } from "vue"; | ||
import { useWindowSize as Y, createEventHook as j, useRafFn as ye, useElementSize as Me, useDevicePixelRatio as Se, unrefElement as I, resolveUnref as C } from "@vueuse/core"; | ||
import * as Ee from "three"; | ||
import { PerspectiveCamera as T, OrthographicCamera as Z, Color as $, Vector3 as xe, Clock as Pe, Scene as Te, LoadingManager as Le, TextureLoader as Re, PCFShadowMap as Oe, LinearEncoding as Ae, NoToneMapping as Be, WebGLRenderer as Ie } from "three"; | ||
var $e = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))($e || {}); | ||
const M = { | ||
cameras: [] | ||
}, Ae = 45; | ||
let E; | ||
function Z() { | ||
const { width: e, height: t } = Y(), { setState: n } = oe(); | ||
function a(i = "Perspective", f) { | ||
if (i === "Perspective") { | ||
const { near: u, far: m, fov: d } = f || { | ||
}, be = 45; | ||
let y; | ||
function ee() { | ||
const { width: e, height: t } = Y(), { setState: r } = ce(); | ||
function a(o = "Perspective", u) { | ||
if (o === "Perspective") { | ||
const { near: n, far: i, fov: p } = u || { | ||
near: 0.1, | ||
far: 1e3, | ||
fov: Ae | ||
fov: be | ||
}; | ||
E = new $(d, r.value, u, m), P.cameras.push(E); | ||
y = new T(p, s.value, n, i), M.cameras.push(y); | ||
} else { | ||
const { left: u, right: m, top: d, bottom: w, near: C, far: x } = f || { | ||
const { left: n, right: i, top: p, bottom: h, near: g, far: w } = u || { | ||
left: -100, | ||
@@ -37,47 +37,52 @@ right: 100, | ||
}; | ||
E = new Ce(u, m, d, w, C, x), P.cameras.push(E); | ||
y = new Z(n, i, p, h, g, w), M.cameras.push(y); | ||
} | ||
return P.cameras.push(E), E; | ||
return M.cameras.push(y), y; | ||
} | ||
const r = D(() => e.value / t.value), o = D(() => P.cameras[0]); | ||
function s() { | ||
o.value instanceof $ && (o.value.aspect = r.value), o.value.updateProjectionMatrix(); | ||
const s = D(() => e.value / t.value), l = D(() => M.cameras[0]); | ||
function f() { | ||
l.value instanceof T && (l.value.aspect = s.value), l.value.updateProjectionMatrix(); | ||
} | ||
function c(i) { | ||
const f = X("camera"); | ||
i && f && (f.value = i, n("camera", f.value)), P.cameras.push(i), i instanceof $ && (i.aspect = r.value), i.updateProjectionMatrix(); | ||
function c(o) { | ||
const u = X("camera"); | ||
o && u && (u.value = o, r("camera", u.value)), M.cameras.push(o), o instanceof T && (o.aspect = s.value), o.updateProjectionMatrix(); | ||
} | ||
return O(r, s), { | ||
activeCamera: o, | ||
return x(s, f), { | ||
activeCamera: l, | ||
createCamera: a, | ||
updateCamera: s, | ||
updateCamera: f, | ||
pushCamera: c | ||
}; | ||
} | ||
let b = { ...ve }; | ||
delete b.Scene; | ||
function be() { | ||
const L = S({ ...Ee }); | ||
delete L.value.Scene; | ||
let b; | ||
function Fe(e, t = "Tres") { | ||
!b && e && (b = e); | ||
const { createComponentInstances: r } = te(t); | ||
return { | ||
extend: (t) => { | ||
b = Object.assign(b, t); | ||
extend: (s) => { | ||
L.value = Object.assign(L.value, s), r(S(s)).forEach(([f, c]) => { | ||
b.component(f, c); | ||
}); | ||
}, | ||
catalogue: b | ||
catalogue: L | ||
}; | ||
} | ||
const Be = (e) => typeof e < "u", V = (e) => !!e && e.constructor === Array; | ||
function $e(e) { | ||
return typeof e == "number" ? [e, e, e] : e instanceof ye ? [e.x, e.y, e.z] : e; | ||
const F = (e) => typeof e < "u", ze = (e) => typeof e == "function", R = (e) => !!e && e.constructor === Array; | ||
function De(e) { | ||
return typeof e == "number" ? [e, e, e] : e instanceof xe ? [e.x, e.y, e.z] : e; | ||
} | ||
function q(e) { | ||
return e instanceof I ? e : Array.isArray(e) ? new I(...e) : new I(e); | ||
function K(e) { | ||
return e instanceof $ ? e : Array.isArray(e) ? new $(...e) : new $(e); | ||
} | ||
const K = "[TresJS \u25B2 \u25A0 \u25CF] "; | ||
function W() { | ||
function e(a, r) { | ||
console.error(`${K} ${a}`, r || ""); | ||
const q = "[TresJS \u25B2 \u25A0 \u25CF] "; | ||
function U() { | ||
function e(a, s) { | ||
console.error(`${q} ${a}`, s || ""); | ||
} | ||
function t(a) { | ||
console.warn(`${K} ${a}`); | ||
console.warn(`${q} ${a}`); | ||
} | ||
function n(a, r) { | ||
function r(a, s) { | ||
} | ||
@@ -87,144 +92,153 @@ return { | ||
logWarning: t, | ||
logMessage: n | ||
logMessage: r | ||
}; | ||
} | ||
const Ie = ["rotation", "scale", "position"]; | ||
function ze(e) { | ||
const { logMessage: t, logError: n } = W(); | ||
function a(r) { | ||
return Object.entries(r).filter(([o, s]) => { | ||
var c, i; | ||
return (i = (c = s == null ? void 0 : s.prototype) == null ? void 0 : c.constructor) == null ? void 0 : i.toString().includes("class"); | ||
}).map(([o, s]) => { | ||
const c = `${e}${o}`, i = _({ | ||
name: c, | ||
setup(f, { slots: u, attrs: m, ...d }) { | ||
t(c, { | ||
props: f, | ||
slots: u, | ||
attrs: m, | ||
ctx: d | ||
}); | ||
let w; | ||
const { scene: C } = ae(), { pushCamera: x } = Z(); | ||
function L() { | ||
if ((u == null ? void 0 : u.default) && (u == null ? void 0 : u.default())) { | ||
const y = u.default().map((l) => { | ||
var h; | ||
let v; | ||
const g = l.type.name.replace(e, ""); | ||
return (h = l == null ? void 0 : l.props) != null && h.args ? v = new r[g](...l.props.args) : v = new r[g](), l != null && l.props && T(l.props, v), v; | ||
}); | ||
w = new s(...y); | ||
} else | ||
m.args ? w = new s(...m.args) : w = new s(); | ||
T(m, w), c.includes("Camera") && x(w), w.isObject3D && (C == null || C.value.add(w)), t("Instance added", C), d.expose(w); | ||
const _e = ["rotation", "scale", "position"]; | ||
function te(e) { | ||
const { logMessage: t, logError: r } = U(); | ||
function a(c, o) { | ||
!F(c) || !F(o) || Object.entries(c).forEach(([u, n]) => { | ||
const i = u.replace(/(-\w)/g, (p) => p[1].toUpperCase()); | ||
if (!(i === "args" || n === void 0)) { | ||
_e.includes(i) && n && (n = De(n)), c.ref && (c.ref = o); | ||
try { | ||
if (o[i] && F(o[i].set)) | ||
o[i].set(...R(n) ? n : [n]); | ||
else { | ||
if (n === "" && (n = !0), ze(o[i])) { | ||
o[i](...R(n) ? n : [n]); | ||
return; | ||
} | ||
o[i] = n; | ||
} | ||
function T(y, l) { | ||
Object.entries(y).forEach(([v, g]) => { | ||
const h = v.replace(/(-\w)/g, (M) => M[1].toUpperCase()); | ||
if (!(h === "args" || g === void 0)) { | ||
Ie.includes(v) && g && (g = $e(g)); | ||
try { | ||
l[h] && Be(l[h].set) ? V(g) ? l[h].set(...g) : l[h].set(g) : (g === "" && (g = !0), l[h] = g); | ||
} catch (M) { | ||
n(`There was an error setting ${h} property`, M); | ||
} | ||
} | ||
}), y.ref && (y.ref = l); | ||
} | ||
return L(), () => { | ||
} catch (p) { | ||
r(`There was an error setting ${i} property`, p); | ||
} | ||
} | ||
}); | ||
} | ||
function s(c, o) { | ||
var i; | ||
const u = c.type.name.replace(e, ""); | ||
let n; | ||
return (i = c == null ? void 0 : c.props) != null && i.args ? n = new o.value[u](...c.props.args) : n = new o.value[u](), c != null && c.props && a(c.props, n), n; | ||
} | ||
function l(c, o, u, n) { | ||
if (n.default && (n == null ? void 0 : n.default())) { | ||
const i = n.default().map((p) => s(p, c)); | ||
return new o(...i); | ||
} else | ||
return u.args ? new o(...u.args) : new o(); | ||
} | ||
function f(c) { | ||
return Object.entries(c.value).filter(([o, u]) => { | ||
var n, i; | ||
return (i = (n = u == null ? void 0 : u.prototype) == null ? void 0 : n.constructor) == null ? void 0 : i.toString().includes("class"); | ||
}).map(([o, u]) => { | ||
const n = `${e}${o}`, i = _({ | ||
name: n, | ||
setup(p, { slots: h, attrs: g, ...w }) { | ||
const { scene: v } = se(), { pushCamera: O } = ee(), d = l(c, u, g, h); | ||
return a(g, d), (d instanceof T || d instanceof Z) && O(d), d.isObject3D && (v == null || v.value.add(d)), w.expose(d), t(n, { | ||
props: p, | ||
slots: h, | ||
attrs: g, | ||
ctx: w, | ||
scene: v | ||
}), () => { | ||
}; | ||
} | ||
}); | ||
return [c, i]; | ||
return [n, i]; | ||
}); | ||
} | ||
return { | ||
createComponentInstances: a | ||
createComponentInstances: f, | ||
processProps: a, | ||
createInstanceFromVNode: s | ||
}; | ||
} | ||
const ee = U(), te = U(), ne = U(), Q = new Me(), { pause: De, resume: Fe, isActive: _e } = ge( | ||
const ne = j(), re = j(), oe = j(), Q = new Pe(), { pause: Ve, resume: je, isActive: Ue } = ye( | ||
() => { | ||
const e = Q.getElapsedTime(), t = Q.getDelta(); | ||
ee.trigger({ delta: t, elapsed: e }), te.trigger({ delta: t, elapsed: e }), ne.trigger({ delta: t, elapsed: e }); | ||
ne.trigger({ delta: t, elapsed: e }), re.trigger({ delta: t, elapsed: e }), oe.trigger({ delta: t, elapsed: e }); | ||
}, | ||
{ immediate: !1 } | ||
); | ||
function re() { | ||
function ae() { | ||
return { | ||
onBeforeLoop: ee.on, | ||
onLoop: te.on, | ||
onAfterLoop: ne.on, | ||
pause: De, | ||
resume: Fe, | ||
isActive: _e | ||
onBeforeLoop: ne.on, | ||
onLoop: re.on, | ||
onAfterLoop: oe.on, | ||
pause: Ve, | ||
resume: je, | ||
isActive: Ue | ||
}; | ||
} | ||
const je = j(new Se()); | ||
function ae() { | ||
const ke = V(new Te()); | ||
function se() { | ||
return { | ||
scene: je | ||
scene: ke | ||
}; | ||
} | ||
function Ue(e) { | ||
function Ne(e) { | ||
const t = { nodes: {}, materials: {} }; | ||
return e && e.traverse((n) => { | ||
n.name && (t.nodes[n.name] = n), n.material && !t.materials[n.material.name] && (t.materials[n.material.name] = n.material); | ||
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); | ||
}), t; | ||
} | ||
async function Je(e, t, n, a, r) { | ||
const { logError: o } = W(), s = new e(); | ||
r && r(s), n && n(e); | ||
const i = (Array.isArray(t) ? t : [t]).map( | ||
(f) => new Promise((u, m) => { | ||
s.load( | ||
f, | ||
(d) => { | ||
d.scene && Object.assign(d, Ue(d.scene)), u(d); | ||
async function Qe(e, t, r, a, s) { | ||
const { logError: l } = U(), f = new e(); | ||
s && s(f), r && r(e); | ||
const o = (Array.isArray(t) ? t : [t]).map( | ||
(u) => new Promise((n, i) => { | ||
f.load( | ||
u, | ||
(p) => { | ||
p.scene && Object.assign(p, Ne(p.scene)), n(p); | ||
}, | ||
a, | ||
(d) => m(o("[useLoader] - Failed to load resource", d)) | ||
(p) => i(l("[useLoader] - Failed to load resource", p)) | ||
); | ||
}) | ||
); | ||
return V(t) ? await Promise.all(i) : await i[0]; | ||
return R(t) ? await Promise.all(o) : await o[0]; | ||
} | ||
async function qe(e) { | ||
const t = new xe(), n = new Ee(t), a = (r) => new Promise((o, s) => { | ||
n.load( | ||
r, | ||
(c) => o(c), | ||
async function Xe(e) { | ||
const t = new Le(), r = new Re(t), a = (s) => new Promise((l, f) => { | ||
r.load( | ||
s, | ||
(c) => l(c), | ||
() => null, | ||
() => { | ||
s(new Error("[useTextures] - Failed to load texture")); | ||
f(new Error("[useTextures] - Failed to load texture")); | ||
} | ||
); | ||
}); | ||
if (V(e)) { | ||
const r = await Promise.all(e.map((o) => a(o))); | ||
return e.length > 1 ? r : r[0]; | ||
if (R(e)) { | ||
const s = await Promise.all(e.map((l) => a(l))); | ||
return e.length > 1 ? s : s[0]; | ||
} else { | ||
const { map: r, displacementMap: o, normalMap: s, roughnessMap: c, metalnessMap: i, aoMap: f } = e; | ||
const { map: s, displacementMap: l, normalMap: f, roughnessMap: c, metalnessMap: o, aoMap: u } = e; | ||
return { | ||
map: r ? await a(r) : null, | ||
displacementMap: o ? await a(o) : null, | ||
normalMap: s ? await a(s) : null, | ||
map: s ? await a(s) : null, | ||
displacementMap: l ? await a(l) : null, | ||
normalMap: f ? await a(f) : null, | ||
roughnessMap: c ? await a(c) : null, | ||
metalnessMap: i ? await a(i) : null, | ||
aoMap: f ? await a(f) : null | ||
metalnessMap: o ? await a(o) : null, | ||
aoMap: u ? await a(u) : null | ||
}; | ||
} | ||
} | ||
const R = fe({}); | ||
function oe() { | ||
function e(n) { | ||
return R[n]; | ||
const E = he({}); | ||
function ce() { | ||
function e(r) { | ||
return E[r]; | ||
} | ||
function t(n, a) { | ||
R[n] = a; | ||
function t(r, a) { | ||
E[r] = a; | ||
} | ||
return { | ||
state: R, | ||
...me(R), | ||
state: E, | ||
...we(E), | ||
getState: e, | ||
@@ -234,76 +248,76 @@ setState: t | ||
} | ||
const p = j(), z = F(!1); | ||
function Ve(e, t, n) { | ||
const m = V(), z = S(!1); | ||
function We(e, t, r) { | ||
const { | ||
alpha: a = !1, | ||
antialias: r, | ||
depth: o, | ||
logarithmicDepthBuffer: s, | ||
antialias: s, | ||
depth: l, | ||
logarithmicDepthBuffer: f, | ||
failIfMajorPerformanceCaveat: c, | ||
precision: i, | ||
premultipliedAlpha: f, | ||
stencil: u, | ||
shadows: m = !1, | ||
shadowMapType: d = Pe, | ||
physicallyCorrectLights: w = !1, | ||
outputEncoding: C = Le, | ||
toneMapping: x = Te, | ||
toneMappingExposure: L = 1, | ||
context: T = void 0, | ||
powerPreference: y = "default", | ||
preserveDrawingBuffer: l = !1, | ||
clearColor: v = q("#000000"), | ||
windowSize: g = !1 | ||
} = n, { width: h, height: M } = g ? Y() : he(t), { pixelRatio: k } = we(), { pause: se, resume: ie } = re(), ce = D(() => h.value / M.value), N = () => { | ||
!p.value || (p.value.setSize(h.value, M.value), p.value.setPixelRatio(k.value)); | ||
precision: o, | ||
premultipliedAlpha: u, | ||
stencil: n, | ||
shadows: i = !1, | ||
shadowMapType: p = Oe, | ||
physicallyCorrectLights: h = !1, | ||
outputEncoding: g = Ae, | ||
toneMapping: w = Be, | ||
toneMappingExposure: v = 1, | ||
context: O = void 0, | ||
powerPreference: d = "default", | ||
preserveDrawingBuffer: ie = !1, | ||
clearColor: k = K("#000000"), | ||
windowSize: ue = !1 | ||
} = r, { width: A, height: B } = ue ? Y() : Me(t), { pixelRatio: N } = Se(), { pause: le, resume: pe } = ae(), fe = D(() => A.value / B.value), W = () => { | ||
!m.value || (m.value.setSize(A.value, B.value), m.value.setPixelRatio(N.value)); | ||
}, H = () => { | ||
!p.value || (p.value.shadowMap.enabled = S(m), p.value.outputEncoding = S(C), p.value.shadowMap.type = S(d), p.value.physicallyCorrectLights = S(w), p.value.toneMapping = S(x), p.value.toneMappingExposure = S(L), p.value.setClearColor(q(S(v)))); | ||
}, ue = () => { | ||
const G = B(e); | ||
if (p.value || !G) | ||
!m.value || (m.value.shadowMap.enabled = C(i), m.value.outputEncoding = C(g), m.value.shadowMap.type = C(p), m.value.physicallyCorrectLights = C(h), m.value.toneMapping = C(w), m.value.toneMappingExposure = C(v), m.value.setClearColor(K(C(k)))); | ||
}, me = () => { | ||
const G = I(e); | ||
if (m.value || !G) | ||
return; | ||
p.value = new Re({ | ||
m.value = new Ie({ | ||
canvas: G, | ||
alpha: a, | ||
antialias: r, | ||
context: T, | ||
depth: o, | ||
antialias: s, | ||
context: O, | ||
depth: l, | ||
failIfMajorPerformanceCaveat: c, | ||
logarithmicDepthBuffer: s, | ||
powerPreference: y, | ||
precision: i, | ||
stencil: u, | ||
preserveDrawingBuffer: l, | ||
premultipliedAlpha: f | ||
logarithmicDepthBuffer: f, | ||
powerPreference: d, | ||
precision: o, | ||
stencil: n, | ||
preserveDrawingBuffer: ie, | ||
premultipliedAlpha: u | ||
}); | ||
const { setState: pe } = oe(); | ||
pe("renderer", p.value), H(), N(), ie(), z.value = !0; | ||
}, le = () => { | ||
!p.value || (p.value.dispose(), p.value = void 0, z.value = !1, se()); | ||
const { setState: ge } = ce(); | ||
ge("renderer", m.value), H(), W(), pe(), z.value = !0; | ||
}, de = () => { | ||
!m.value || (m.value.dispose(), m.value = void 0, z.value = !1, le()); | ||
}; | ||
return O([h, M, k], N), O( | ||
return x([A, B, N], W), x( | ||
() => [ | ||
m, | ||
d, | ||
C, | ||
i, | ||
p, | ||
g, | ||
h, | ||
w, | ||
x, | ||
L, | ||
v | ||
v, | ||
k | ||
], | ||
H | ||
), O( | ||
), x( | ||
() => [e, t], | ||
() => { | ||
B(e) && B(t) && ue(); | ||
I(e) && I(t) && me(); | ||
}, | ||
{ immediate: !0, deep: !0 } | ||
), { | ||
renderer: p, | ||
renderer: m, | ||
isReady: z, | ||
dispose: le, | ||
aspectRatio: ce | ||
dispose: de, | ||
aspectRatio: fe | ||
}; | ||
} | ||
const We = _({ | ||
const He = _({ | ||
name: "TresCanvas", | ||
@@ -323,8 +337,8 @@ props: { | ||
}, | ||
setup(e, { slots: t, attrs: n }) { | ||
const { logError: a } = W(), r = F(), o = F(), { renderer: s, dispose: c, aspectRatio: i } = Ve(r, o, e), f = j(); | ||
return A("camera", f), A("renderer", s), A("aspect-ratio", i), t.default && !t.default().some((u) => u.type.name === "Scene") && a("TresCanvas must contain a Scene component."), t.default && !t.default().some((u) => { | ||
var m; | ||
return (m = u.type.name) == null ? void 0 : m.includes("Camera"); | ||
}) && a("Scene must contain a Camera component."), de(() => c()), () => { | ||
setup(e, { slots: t, attrs: r }) { | ||
const { logError: a } = U(), s = S(), l = S(), { renderer: f, dispose: c, aspectRatio: o } = We(s, l, e), u = V(); | ||
return P("camera", u), P("renderer", f), P("aspect-ratio", o), t.default && !t.default().some((n) => n.type.name === "Scene") && a("TresCanvas must contain a Scene component."), t.default && !t.default().some((n) => { | ||
var i; | ||
return (i = n.type.name) == null ? void 0 : i.includes("Camera"); | ||
}) && a("Scene must contain a Camera component."), ve(() => c()), () => { | ||
if (t.default) | ||
@@ -334,3 +348,3 @@ return J( | ||
{ | ||
ref: o, | ||
ref: l, | ||
style: { | ||
@@ -340,3 +354,3 @@ position: "relative", | ||
height: "100vh", | ||
...n.style | ||
...r.style | ||
} | ||
@@ -346,3 +360,3 @@ }, | ||
J("canvas", { | ||
ref: r, | ||
ref: s, | ||
style: { width: "100%", height: "100%", position: "absolute", top: 0, left: 0 } | ||
@@ -355,8 +369,8 @@ }), | ||
} | ||
}), ke = _({ | ||
}), Ge = _({ | ||
name: "Scene", | ||
setup(e, { slots: t }) { | ||
const { scene: n } = ae(), a = X("renderer"), { activeCamera: r } = Z(), { onLoop: o } = re(); | ||
return A("local-scene", n), o(() => { | ||
(a == null ? void 0 : a.value) && (r == null ? void 0 : r.value) && (n == null ? void 0 : n.value) && a.value.render(n == null ? void 0 : n.value, r.value); | ||
const { scene: r } = se(), a = X("renderer"), { activeCamera: s } = ee(), { onLoop: l } = ae(); | ||
return P("local-scene", r), l(() => { | ||
(a == null ? void 0 : a.value) && (s == null ? void 0 : s.value) && (r == null ? void 0 : r.value) && a.value.render(r == null ? void 0 : r.value, s.value); | ||
}), () => { | ||
@@ -367,9 +381,11 @@ if (t.default) | ||
} | ||
}), Ke = Symbol("UseTresState"), Qe = { | ||
}), Ye = Symbol("UseTresState"), Ze = { | ||
install(e, t) { | ||
const n = (t == null ? void 0 : t.prefix) || "Tres"; | ||
e.component(`${n}Canvas`, We), e.component(`${n}Scene`, ke); | ||
const { catalogue: a } = be(), { createComponentInstances: r } = ze(n); | ||
r(t != null && t.extends ? { ...a, ...t.extends } : a).forEach(([s, c]) => { | ||
e.component(s, c); | ||
const r = (t == null ? void 0 : t.prefix) || "Tres"; | ||
e.component(`${r}Canvas`, He), e.component(`${r}Scene`, Ge); | ||
const { catalogue: a } = Fe(e, r), { createComponentInstances: s } = te(r); | ||
s(a).forEach(([f, c]) => { | ||
e.component(f, c); | ||
}), Ce(() => { | ||
console.log({ catalogue: a }); | ||
}); | ||
@@ -379,15 +395,15 @@ } | ||
export { | ||
Oe as CameraType, | ||
Ke as UseTresStateSymbol, | ||
Qe as default, | ||
Ue as trasverseObjects, | ||
Z as useCamera, | ||
be as useCatalogue, | ||
ze as useInstanceCreator, | ||
Je as useLoader, | ||
re as useRenderLoop, | ||
Ve as useRenderer, | ||
ae as useScene, | ||
qe as useTexture, | ||
oe as useTres | ||
$e as CameraType, | ||
Ye as UseTresStateSymbol, | ||
Ze as default, | ||
Ne as trasverseObjects, | ||
ee as useCamera, | ||
Fe as useCatalogue, | ||
te as useInstanceCreator, | ||
Qe as useLoader, | ||
ae as useRenderLoop, | ||
We as useRenderer, | ||
se as useScene, | ||
Xe as useTexture, | ||
ce as useTres | ||
}; |
@@ -6,2 +6,3 @@ import { Object3D } from 'three' | ||
export type TresCatalogue = Record<string, any> | ||
export type TresVNodeType = VNodeTypes & { | ||
@@ -13,1 +14,2 @@ name?: string | Array<string> | ||
export type TresVNode = VNode & { children?: Array<VNode>; type: TresVNodeType } | ||
export type TresAttributes = Record<string, any> & { args?: number[] } |
{ | ||
"name": "@tresjs/core", | ||
"description": "Declarative ThreeJS using Vue Components", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"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
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
2305185
735