@tresjs/core
Advanced tools
Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6
export declare const rendererPresets: { | ||
realistic: { | ||
outputEncoding: import("three").TextureEncoding; | ||
toneMapping: import("three").ToneMapping; | ||
outputEncoding: 3001; | ||
toneMapping: 4; | ||
toneMappingExposure: number; | ||
shadowMap: { | ||
enabled: boolean; | ||
type: import("three").ShadowMapType; | ||
type: 2; | ||
}; | ||
@@ -10,0 +10,0 @@ }; |
321
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v2.0.0-alpha.5 | ||
* version: v2.0.0-alpha.6 | ||
* (c) 2023 | ||
@@ -8,14 +8,14 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { ref as M, watchEffect as Ee, toRef as xe, shallowRef as ne, toRefs as ae, computed as re, watch as O, shallowReactive as Pe, createRenderer as Se, defineComponent as Te, onUnmounted as Re, h as S } from "vue"; | ||
import * as oe from "three"; | ||
import { MathUtils as Ae, PerspectiveCamera as F, OrthographicCamera as ke, Clock as ie, Color as I, sRGBEncoding as Oe, ACESFilmicToneMapping as je, PCFSoftShadowMap as Be, PCFShadowMap as _e, LinearEncoding as Y, NoToneMapping as Q, WebGLRenderer as De, LoadingManager as Fe, TextureLoader as Ie, Raycaster as We, Vector2 as ze, Mesh as He, BufferAttribute as $e } from "three"; | ||
import { createEventHook as G, useRafFn as Ge, resolveUnref as c, useWindowSize as Ne, useElementSize as Ue, useDevicePixelRatio as Ve, unrefElement as W, useEventListener as qe, isFunction as Z } from "@vueuse/core"; | ||
const $ = M({ uuid: Ae.generateUUID() }), se = (e) => void Object.assign($.value, e); | ||
var Je = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Je || {}); | ||
const Ke = 45; | ||
import { ref as M, watchEffect as xe, toRef as Pe, shallowRef as re, toRefs as oe, computed as ie, watch as O, shallowReactive as Te, createRenderer as Re, defineComponent as ke, onUnmounted as Ae, h as P } from "vue"; | ||
import * as se from "three"; | ||
import { MathUtils as Oe, PerspectiveCamera as z, OrthographicCamera as je, Clock as ue, Color as D, sRGBEncoding as Be, ACESFilmicToneMapping as We, PCFSoftShadowMap as _e, PCFShadowMap as ze, LinearEncoding as Z, NoToneMapping as ee, WebGLRenderer as De, LoadingManager as Fe, TextureLoader as Ie, Raycaster as He, Vector2 as $e, Mesh as Ge, BufferAttribute as Ne } from "three"; | ||
import { createEventHook as G, useRafFn as Ue, resolveUnref as c, useWindowSize as Ve, useElementSize as qe, useDevicePixelRatio as Ye, unrefElement as F, useEventListener as Je, isFunction as te } from "@vueuse/core"; | ||
const $ = M({ uuid: Oe.generateUUID() }), ce = (e) => void Object.assign($.value, e); | ||
var Ke = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ke || {}); | ||
const Xe = 45; | ||
let y; | ||
function ue() { | ||
function le() { | ||
const { state: e, setState: t, aspectRatio: o } = L(); | ||
function r(a = "Perspective", s) { | ||
var l, p, d; | ||
var f, l, p; | ||
if (a === "Perspective") { | ||
@@ -25,7 +25,7 @@ const { near: m, far: w, fov: v } = s || { | ||
far: 1e3, | ||
fov: Ke | ||
fov: Xe | ||
}; | ||
y = new F(v, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, m, w), (p = e.cameras) == null || p.push(y); | ||
y = new z(v, ((f = e.aspectRatio) == null ? void 0 : f.value) || window.innerWidth / window.innerHeight, m, w), (l = e.cameras) == null || l.push(y); | ||
} else { | ||
const { left: m, right: w, top: v, bottom: g, near: x, far: P } = s || { | ||
const { left: m, right: w, top: v, bottom: g, near: S, far: x } = s || { | ||
left: -100, | ||
@@ -38,3 +38,3 @@ right: 100, | ||
}; | ||
y = new ke(m, w, v, g, x, P), (d = e.cameras) == null || d.push(y); | ||
y = new je(m, w, v, g, S, x), (p = e.cameras) == null || p.push(y); | ||
} | ||
@@ -45,7 +45,7 @@ return e.camera = y, t("camera", e.camera), y; | ||
var a; | ||
e.camera instanceof F && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (a = e.camera) == null || a.updateProjectionMatrix(); | ||
e.camera instanceof z && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (a = e.camera) == null || a.updateProjectionMatrix(); | ||
} | ||
function i(a) { | ||
var s; | ||
(s = e.cameras) == null || s.push(a), a instanceof F && e.aspectRatio && (a.aspect = e.aspectRatio.value), a.updateProjectionMatrix(), t("camera", a); | ||
(s = e.cameras) == null || s.push(a), a instanceof z && e.aspectRatio && (a.aspect = e.aspectRatio.value), a.updateProjectionMatrix(), t("camera", a); | ||
} | ||
@@ -55,6 +55,6 @@ function u() { | ||
} | ||
return Ee(() => { | ||
return xe(() => { | ||
o != null && o.value && n(); | ||
}), { | ||
activeCamera: xe(e, "camera"), | ||
activeCamera: Pe(e, "camera"), | ||
createCamera: r, | ||
@@ -66,7 +66,7 @@ updateCamera: n, | ||
} | ||
const ce = G(), le = G(), N = G(), b = new ie(); | ||
const fe = G(), pe = G(), N = G(), b = new ue(); | ||
let j = 0, B = 0; | ||
const { pause: Xe, resume: Ye, isActive: Qe } = Ge( | ||
const { pause: Qe, resume: Ze, isActive: et } = Ue( | ||
() => { | ||
ce.trigger({ delta: j, elapsed: B, clock: b }), le.trigger({ delta: j, elapsed: B, clock: b }), N.trigger({ delta: j, elapsed: B, clock: b }); | ||
fe.trigger({ delta: j, elapsed: B, clock: b }), pe.trigger({ delta: j, elapsed: B, clock: b }), N.trigger({ delta: j, elapsed: B, clock: b }); | ||
}, | ||
@@ -80,32 +80,32 @@ { immediate: !1 } | ||
return { | ||
onBeforeLoop: ce.on, | ||
onLoop: le.on, | ||
onBeforeLoop: fe.on, | ||
onLoop: pe.on, | ||
onAfterLoop: N.on, | ||
pause: Xe, | ||
resume: Ye, | ||
isActive: Qe | ||
pause: Qe, | ||
resume: Ze, | ||
isActive: et | ||
}; | ||
} | ||
function Ze(e) { | ||
return e instanceof I ? e : Array.isArray(e) ? new I(...e) : new I(e); | ||
function tt(e) { | ||
return e instanceof D ? e : Array.isArray(e) ? new D(...e) : new D(e); | ||
} | ||
const z = { | ||
const I = { | ||
realistic: { | ||
outputEncoding: Oe, | ||
toneMapping: je, | ||
outputEncoding: Be, | ||
toneMapping: We, | ||
toneMappingExposure: 3, | ||
shadowMap: { | ||
enabled: !0, | ||
type: Be | ||
type: _e | ||
} | ||
} | ||
}, fe = (e, t) => { | ||
}, de = (e, t) => { | ||
for (const o of Object.keys(t)) | ||
t[o] instanceof Object && Object.assign(t[o], fe(e[o], t[o])); | ||
t[o] instanceof Object && Object.assign(t[o], de(e[o], t[o])); | ||
return Object.assign(e || {}, t), e; | ||
}, et = "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", tt = /* @__PURE__ */ nt(et); | ||
}, nt = "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", at = /* @__PURE__ */ rt(nt); | ||
function T(e) { | ||
return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase()); | ||
} | ||
function nt(e, t) { | ||
function rt(e, t) { | ||
const o = /* @__PURE__ */ Object.create(null), r = e.split(","); | ||
@@ -116,4 +116,5 @@ for (let n = 0; n < r.length; n++) | ||
} | ||
const f = ne(), H = M(!1); | ||
function at(e, t, o) { | ||
const d = re(), H = M(!1); | ||
function ot(e, t, o) { | ||
var Q; | ||
const { | ||
@@ -126,49 +127,52 @@ alpha: r = !0, | ||
precision: s, | ||
premultipliedAlpha: l, | ||
stencil: p, | ||
shadows: d = !1, | ||
shadowMapType: m = _e, | ||
premultipliedAlpha: f, | ||
stencil: l, | ||
shadows: p = !1, | ||
shadowMapType: m = ze, | ||
physicallyCorrectLights: w = !1, | ||
useLegacyLights: v = !1, | ||
outputEncoding: g = Y, | ||
toneMapping: x = Q, | ||
toneMappingExposure: P = 1, | ||
context: me = void 0, | ||
powerPreference: ve = "default", | ||
preserveDrawingBuffer: ge = !1, | ||
outputEncoding: g = Z, | ||
toneMapping: S = ee, | ||
toneMappingExposure: x = 1, | ||
context: ge = void 0, | ||
powerPreference: we = "default", | ||
preserveDrawingBuffer: he = !1, | ||
clearColor: C, | ||
windowSize: we = !1, | ||
preset: he = void 0 | ||
} = ae(o), { setState: _ } = L(), { width: V, height: q } = c(we) ? Ne() : Ue(t), { logError: ye } = E(), { pixelRatio: J } = Ve(), { pause: Me, resume: Ce } = U(), D = re(() => V.value / q.value), K = () => { | ||
f.value && (f.value.setSize(V.value, q.value), f.value.setPixelRatio(Math.min(J.value, 2))); | ||
windowSize: V = !1, | ||
preset: ye = void 0 | ||
} = oe(o), { setState: W } = L(), { width: q, height: Y } = c(V) ? Ve() : qe(t), { logError: Me, logWarning: Ce } = E(), { pixelRatio: J } = Ye(), { pause: be, resume: Le } = U(), _ = ie(() => q.value / Y.value); | ||
!c(V) && ((Q = t == null ? void 0 : t.value) == null ? void 0 : Q.offsetHeight) === 0 && Ce(`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.`); | ||
const K = () => { | ||
d.value && (d.value.setSize(q.value, Y.value), d.value.setPixelRatio(Math.min(J.value, 2))); | ||
}, X = () => { | ||
if (!f.value) | ||
if (!d.value) | ||
return; | ||
const h = c(he); | ||
const h = c(ye); | ||
if (h) { | ||
h in z || ye("Renderer Preset must be one of these: " + Object.keys(z).join(", ")), fe(f.value, z[h]); | ||
h in I || Me("Renderer Preset must be one of these: " + Object.keys(I).join(", ")), de(d.value, I[h]); | ||
return; | ||
} | ||
f.value.shadowMap.enabled = c(d), f.value.shadowMap.type = c(m), f.value.toneMapping = c(x) || Q, f.value.toneMappingExposure = c(P), f.value.outputEncoding = c(g) || Y, C != null && C.value && f.value.setClearColor(Ze(c(C))), f.value.useLegacyLights = c(v); | ||
}, be = () => { | ||
const h = W(e); | ||
h && (f.value = new De({ | ||
d.value.shadowMap.enabled = c(p), d.value.shadowMap.type = c(m), d.value.toneMapping = c(S) || ee, d.value.toneMappingExposure = c(x), d.value.outputEncoding = c(g) || Z, C != null && C.value && d.value.setClearColor(tt(c(C))), d.value.useLegacyLights = c(v); | ||
}, Ee = () => { | ||
const h = F(e); | ||
h && (d.value = new De({ | ||
canvas: h, | ||
alpha: c(r), | ||
antialias: c(n), | ||
context: c(me), | ||
context: c(ge), | ||
depth: c(i), | ||
failIfMajorPerformanceCaveat: c(a), | ||
logarithmicDepthBuffer: c(u), | ||
powerPreference: c(ve), | ||
powerPreference: c(we), | ||
precision: c(s), | ||
stencil: c(p), | ||
preserveDrawingBuffer: c(ge), | ||
premultipliedAlpha: c(l) | ||
}), _("renderer", f.value), _("clock", new ie()), _("aspectRatio", D), X(), K(), Ce(), H.value = !0); | ||
}, Le = () => { | ||
f.value && (f.value.dispose(), f.value = void 0, H.value = !1, Me()); | ||
stencil: c(l), | ||
preserveDrawingBuffer: c(he), | ||
premultipliedAlpha: c(f) | ||
}), W("renderer", d.value), W("clock", new ue()), W("aspectRatio", _), X(), K(), Le(), H.value = !0); | ||
}, Se = () => { | ||
d.value && (d.value.dispose(), d.value = void 0, H.value = !1, be()); | ||
}; | ||
return O([D, J], K), O( | ||
[d, m, g, v, x, P, C], | ||
return O([_, J], K), O( | ||
[p, m, g, v, S, x, C], | ||
X | ||
@@ -178,14 +182,14 @@ ), O( | ||
() => { | ||
W(e) && W(t) && be(); | ||
F(e) && F(t) && Ee(); | ||
}, | ||
{ immediate: !0, deep: !0 } | ||
), { | ||
renderer: f, | ||
renderer: d, | ||
isReady: H, | ||
dispose: Le, | ||
aspectRatio: D | ||
dispose: Se, | ||
aspectRatio: _ | ||
}; | ||
} | ||
const pe = (e) => !!e && e.constructor === Array; | ||
function rt(e) { | ||
const me = (e) => !!e && e.constructor === Array; | ||
function it(e) { | ||
const t = { nodes: {}, materials: {} }; | ||
@@ -196,20 +200,20 @@ return e && e.traverse((o) => { | ||
} | ||
async function wt(e, t, o, r, n) { | ||
async function yt(e, t, o, r, n) { | ||
const { logError: i } = E(), u = new e(); | ||
n && n(u), o && o(u); | ||
const s = (Array.isArray(t) ? t : [t]).map( | ||
(l) => new Promise((p, d) => { | ||
(f) => new Promise((l, p) => { | ||
u.load( | ||
l, | ||
f, | ||
(m) => { | ||
m.scene && Object.assign(m, rt(m.scene)), p(m); | ||
m.scene && Object.assign(m, it(m.scene)), l(m); | ||
}, | ||
r, | ||
(m) => d(i("[useLoader] - Failed to load resource", m)) | ||
(m) => p(i("[useLoader] - Failed to load resource", m)) | ||
); | ||
}) | ||
); | ||
return pe(t) ? await Promise.all(s) : await s[0]; | ||
return me(t) ? await Promise.all(s) : await s[0]; | ||
} | ||
async function ht(e) { | ||
async function Mt(e) { | ||
const t = new Fe(), o = new Ie(t), r = (n) => new Promise((i, u) => { | ||
@@ -225,7 +229,16 @@ o.load( | ||
}); | ||
if (pe(e)) { | ||
if (me(e)) { | ||
const n = await Promise.all(e.map((i) => r(i))); | ||
return e.length > 1 ? n : n[0]; | ||
} else { | ||
const { map: n, displacementMap: i, normalMap: u, roughnessMap: a, metalnessMap: s, aoMap: l } = e; | ||
const { | ||
map: n, | ||
displacementMap: i, | ||
normalMap: u, | ||
roughnessMap: a, | ||
metalnessMap: s, | ||
aoMap: f, | ||
alphaMap: l, | ||
matcap: p | ||
} = e; | ||
return { | ||
@@ -237,7 +250,9 @@ map: n ? await r(n) : null, | ||
metalnessMap: s ? await r(s) : null, | ||
aoMap: l ? await r(l) : null | ||
aoMap: f ? await r(f) : null, | ||
alphaMap: l ? await r(l) : null, | ||
matcap: p ? await r(p) : null | ||
}; | ||
} | ||
} | ||
const ot = { | ||
const st = { | ||
camera: void 0, | ||
@@ -247,4 +262,4 @@ cameras: [], | ||
renderer: void 0, | ||
aspectRatio: re(() => window.innerWidth / window.innerHeight) | ||
}, R = Pe(ot); | ||
aspectRatio: ie(() => window.innerWidth / window.innerHeight) | ||
}, R = Te(st); | ||
function L() { | ||
@@ -259,3 +274,3 @@ function e(o) { | ||
state: R, | ||
...ae(R), | ||
...oe(R), | ||
getState: e, | ||
@@ -265,21 +280,21 @@ setState: t | ||
} | ||
const ee = ne(new We()), A = M(new ze()), it = M(null); | ||
function de() { | ||
const ne = re(new He()), k = M(new $e()), ut = M(null); | ||
function ve() { | ||
const { setState: e } = L(); | ||
e("raycaster", ee.value), e("pointer", A), e("currentInstance", it); | ||
e("raycaster", ne.value), e("pointer", k), e("currentInstance", ut); | ||
function t(o) { | ||
A.value.x = o.clientX / window.innerWidth * 2 - 1, A.value.y = -(o.clientY / window.innerHeight) * 2 + 1; | ||
k.value.x = o.clientX / window.innerWidth * 2 - 1, k.value.y = -(o.clientY / window.innerHeight) * 2 + 1; | ||
} | ||
return window.addEventListener("pointermove", t), { | ||
raycaster: ee, | ||
pointer: A | ||
raycaster: ne, | ||
pointer: k | ||
}; | ||
} | ||
const yt = !0, te = "[TresJS ▲ ■ ●] "; | ||
const Ct = !0, ae = "[TresJS ▲ ■ ●] "; | ||
function E() { | ||
function e(r, n) { | ||
console.error(`${te} ${r}`, n || ""); | ||
console.error(`${ae} ${r}`, n || ""); | ||
} | ||
function t(r) { | ||
console.warn(`${te} ${r}`); | ||
console.warn(`${ae} ${r}`); | ||
} | ||
@@ -294,3 +309,3 @@ function o(r, n) { | ||
} | ||
function Mt() { | ||
function bt() { | ||
const { logWarning: e } = E(); | ||
@@ -311,4 +326,4 @@ function t(r, n, i) { | ||
} | ||
const { logWarning: st } = E(); | ||
function ut(e) { | ||
const { logWarning: ct } = E(); | ||
function lt(e) { | ||
for (const t in e) | ||
@@ -319,14 +334,14 @@ if (t.indexOf("on") === 0) | ||
} | ||
let k = null; | ||
const ct = { | ||
let A = null; | ||
const ft = { | ||
createElement(e, t, o, r) { | ||
if (e === "template" || tt(e)) | ||
if (e === "template" || at(e)) | ||
return null; | ||
let n; | ||
if (r === null && (r = {}), r != null && r.args ? n = new $.value[e.replace("Tres", "")](...r.args) : n = new $.value[e.replace("Tres", "")](), n.isCamera) { | ||
(!(r != null && r.position) || r != null && r.position.every((u) => u == 0)) && st( | ||
(!(r != null && r.position) || r != null && r.position.every((u) => u == 0)) && ct( | ||
// eslint-disable-next-line max-len | ||
"Camera is positioned at the center of the scene [0,0,0], if this is not intentional try setting a position if your scene seems empty 🤗" | ||
); | ||
const { pushCamera: i } = ue(); | ||
const { pushCamera: i } = le(); | ||
i(n); | ||
@@ -337,3 +352,3 @@ } | ||
insert(e, t, o) { | ||
if (k === null && t.isScene && (k = t), t === null && (t = k), t != null && t.isObject3D && (e != null && e.isObject3D)) { | ||
if (A === null && t.isScene && (A = t), t === null && (t = A), t != null && t.isObject3D && (e != null && e.isObject3D)) { | ||
const a = o ? t.children.indexOf(o) : 0; | ||
@@ -345,10 +360,10 @@ e.parent = t, t.children.splice(a, 0, e), e.dispatchEvent({ type: "added" }); | ||
let n = null, i = null; | ||
const { raycaster: u } = de(); | ||
e && e instanceof He && ut(e) && (r(() => { | ||
var a, s, l; | ||
const { raycaster: u } = ve(); | ||
e && e instanceof Ge && lt(e) && (r(() => { | ||
var a, s, f; | ||
if (t != null && t.children && e && u) { | ||
const p = u.value.intersectObjects(t.children); | ||
p.length > 0 && p[0].object.uuid === e.uuid ? (i = p[0], (n === null || n.object.uuid !== (i == null ? void 0 : i.object.uuid)) && ((a = e.onPointerEnter) == null || a.call(e, i)), (s = e.onPointerMove) == null || s.call(e, i)) : (i = null, n !== null && ((l = e.onPointerLeave) == null || l.call(e, n))), n = i; | ||
const l = u.value.intersectObjects(t.children); | ||
l.length > 0 && l[0].object.uuid === e.uuid ? (i = l[0], (n === null || n.object.uuid !== (i == null ? void 0 : i.object.uuid)) && ((a = e.onPointerEnter) == null || a.call(e, i)), (s = e.onPointerMove) == null || s.call(e, i)) : (i = null, n !== null && ((f = e.onPointerLeave) == null || f.call(e, n))), n = i; | ||
} | ||
}), qe(window, "click", () => { | ||
}), Je(window, "click", () => { | ||
var a; | ||
@@ -369,15 +384,19 @@ i !== null && ((a = e.onClick) == null || a.call(e, i)); | ||
let a = n == null ? void 0 : n[u]; | ||
if (e.parent || (e.parent = k), n.type === "BufferGeometry" && (i = i.split("-").pop(), n.setAttribute( | ||
T(i), | ||
new $e(...r) | ||
)), i.includes("-") && a === void 0) { | ||
const l = i.split("-"); | ||
a = l.reduce((p, d) => p[T(d)], n), i = l.pop(), a != null && a.set || (n = l.reduce((p, d) => p[T(d)], n)); | ||
if (e.parent || (e.parent = A), n.type === "BufferGeometry") { | ||
n.setAttribute( | ||
T(i), | ||
new Ne(...r) | ||
); | ||
return; | ||
} | ||
if (i.includes("-") && a === void 0) { | ||
const f = i.split("-"); | ||
a = f.reduce((l, p) => l[T(p)], n), i = f.pop(), a != null && a.set || (n = f.reduce((l, p) => l[T(p)], n)); | ||
} | ||
let s = r; | ||
if (s === "" && (s = !0), Z(a)) { | ||
if (s === "" && (s = !0), te(a)) { | ||
Array.isArray(s) ? e[u](...s) : e[u](s); | ||
return; | ||
} | ||
!(a != null && a.set) && !Z(a) ? n[u] = s : a.constructor === s.constructor && (a != null && a.copy) ? a == null || a.copy(s) : Array.isArray(s) ? a.set(...s) : !a.isColor && a.setScalar ? a.setScalar(s) : a.set(s); | ||
!(a != null && a.set) && !te(a) ? n[u] = s : a.constructor === s.constructor && (a != null && a.copy) ? a == null || a.copy(s) : Array.isArray(s) ? a.set(...s) : !a.isColor && a.setScalar ? a.setScalar(s) : a.set(s); | ||
} | ||
@@ -397,4 +416,4 @@ }, | ||
insertStaticContent: () => void 0 | ||
}, { createApp: lt } = Se(ct), ft = (e) => { | ||
const t = lt(o); | ||
}, { createApp: pt } = Re(ft), dt = (e) => { | ||
const t = pt(o); | ||
function o() { | ||
@@ -405,4 +424,4 @@ return e && e.default ? e.default() : []; | ||
}; | ||
se(oe); | ||
const { logWarning: pt } = E(), dt = Te({ | ||
ce(se); | ||
const { logWarning: mt } = E(), vt = ke({ | ||
name: "TresCanvas", | ||
@@ -425,12 +444,12 @@ props: [ | ||
setup(e, { slots: t, expose: o }) { | ||
e.physicallyCorrectLights === !0 && pt("physicallyCorrectLights is deprecated, useLegacyLights is now false by default"); | ||
const r = M(), n = M(), i = new oe.Scene(), { setState: u } = L(); | ||
u("scene", i), Re(() => { | ||
e.physicallyCorrectLights === !0 && mt("physicallyCorrectLights is deprecated, useLegacyLights is now false by default"); | ||
const r = M(), n = M(), i = new se.Scene(), { setState: u } = L(); | ||
u("scene", i), Ae(() => { | ||
u("renderer", null); | ||
}); | ||
function a() { | ||
const { renderer: p } = at(n, r, e), { activeCamera: d } = ue(), { onLoop: m } = U(), { raycaster: w, pointer: v } = de(); | ||
const { renderer: l } = ot(n, r, e), { activeCamera: p } = le(), { onLoop: m } = U(), { raycaster: w, pointer: v } = ve(); | ||
m(() => { | ||
var g; | ||
d.value && (w.value.setFromCamera(v.value, d.value), (g = p.value) == null || g.render(i, d.value)); | ||
p.value && (w.value.setFromCamera(v.value, p.value), (g = l.value) == null || g.render(i, p.value)); | ||
}); | ||
@@ -440,9 +459,9 @@ } | ||
let s; | ||
function l() { | ||
s = ft(t), s.provide("useTres", L()), s.provide("extend", se), s.mount(i); | ||
function f() { | ||
s = dt(t), s.provide("useTres", L()), s.provide("extend", ce), s.mount(i); | ||
} | ||
return l(), o({ | ||
return f(), o({ | ||
scene: i | ||
}), () => S( | ||
S( | ||
}), () => P( | ||
P( | ||
"div", | ||
@@ -462,3 +481,3 @@ { | ||
[ | ||
S( | ||
P( | ||
"div", | ||
@@ -472,3 +491,3 @@ { | ||
[ | ||
S("canvas", { | ||
P("canvas", { | ||
ref: n, | ||
@@ -491,24 +510,24 @@ "data-scene": i.uuid, | ||
} | ||
}), Ct = { | ||
}), Lt = { | ||
install(e) { | ||
e.component("TresCanvas", dt); | ||
e.component("TresCanvas", vt); | ||
} | ||
}; | ||
export { | ||
Je as CameraType, | ||
dt as TresCanvas, | ||
Ke as CameraType, | ||
vt as TresCanvas, | ||
$ as catalogue, | ||
Ct as default, | ||
se as extend, | ||
yt as isProd, | ||
rt as trasverseObjects, | ||
ue as useCamera, | ||
wt as useLoader, | ||
Lt as default, | ||
ce as extend, | ||
Ct as isProd, | ||
it as trasverseObjects, | ||
le as useCamera, | ||
yt as useLoader, | ||
E as useLogger, | ||
de as useRaycaster, | ||
ve as useRaycaster, | ||
U as useRenderLoop, | ||
at as useRenderer, | ||
Mt as useSeek, | ||
ht as useTexture, | ||
ot as useRenderer, | ||
bt as useSeek, | ||
Mt as useTexture, | ||
L as useTres | ||
}; |
{ | ||
"name": "@tresjs/core", | ||
"description": "Declarative ThreeJS using Vue Components", | ||
"version": "2.0.0-alpha.5", | ||
"version": "2.0.0-alpha.6", | ||
"type": "module", | ||
@@ -93,3 +93,2 @@ "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", | ||
"vite-plugin-dts": "2.1.0", | ||
"vite-plugin-glsl": "^1.1.2", | ||
"vite-plugin-inspect": "^0.7.16", | ||
@@ -96,0 +95,0 @@ "vite-plugin-require-transform": "^1.0.9", |
@@ -12,4 +12,17 @@ # @tresjs/core ▲ ■ ● | ||
## Setup | ||
## Docs | ||
Checkout the [docs](https://tresjs.org) | ||
## Demos | ||
- [Stackblitz Collection](https://stackblitz.com/@alvarosabu/collections/tresjs) | ||
## Contribution | ||
We are open to contributions, please read the [contributing guide](/CONTRIBUTING.md) to get started. | ||
### Setup | ||
``` | ||
@@ -19,24 +32,38 @@ pnpm install --shamefully-hoist | ||
## Dev | ||
### Playground | ||
To run the small playground without Histoire use | ||
To run the small playground | ||
``` | ||
pnpm run dev | ||
pnpm run playground | ||
``` | ||
## Histoire | ||
### Build lib | ||
All local demos will be inside [Histoire](https://histoire.dev/) stories. | ||
To build the core as library mode just use | ||
``` | ||
pnpm run story:dev | ||
pnpm run build | ||
``` | ||
## Build lib | ||
### Docs | ||
To build the core as library mode just use | ||
To run de docs in dev mode | ||
```bash | ||
pnpm run docs:dev | ||
``` | ||
pnpm run build | ||
To build them | ||
```bash | ||
pnpm run docs:build | ||
``` | ||
## License | ||
[MIT](/LICENSE) | ||
## Sponsors | ||
Be the first to support this project [here](https://github.com/sponsors/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
71822
36
1465
67