@tresjs/core
Advanced tools
Comparing version 2.0.0-beta.1 to 2.0.0-beta.2
import { RendererOptions } from 'vue'; | ||
import { TresObject } from '../types'; | ||
export declare const isOn: (key: string) => boolean; | ||
export declare const nodeOps: RendererOptions<TresObject, TresObject>; |
447
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v2.0.0-beta.1 | ||
* version: v2.0.0-beta.2 | ||
* (c) 2023 | ||
@@ -8,23 +8,23 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { ref as M, watchEffect as oe, toRef as ke, shallowRef as ie, toRefs as se, computed as ce, watch as z, shallowReactive as ue, provide as Ae, inject as Oe, createRenderer as je, defineComponent as fe, onMounted as _e, onUnmounted as Be, h as L } from "vue"; | ||
import * as le from "three"; | ||
import { MathUtils as De, PerspectiveCamera as O, OrthographicCamera as ze, Clock as de, Color as W, sRGBEncoding as We, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ie, PCFShadowMap as He, LinearEncoding as ee, NoToneMapping as te, WebGLRenderer as Ue, LoadingManager as $e, TextureLoader as Ge, Raycaster as Ne, Vector2 as Ve, Mesh as qe, BufferAttribute as Ye } from "three"; | ||
import { createEventHook as $, useRafFn as Ke, resolveUnref as f, useWindowSize as Xe, useElementSize as Je, useDevicePixelRatio as Qe, unrefElement as F, useEventListener as Ze, isFunction as ne } from "@vueuse/core"; | ||
const H = M({ uuid: De.generateUUID() }), pe = (e) => void Object.assign(H.value, e); | ||
var et = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(et || {}); | ||
const tt = 45; | ||
let x; | ||
function U() { | ||
const { state: e, setState: t, aspectRatio: r } = S(); | ||
import { ref as S, watchEffect as ie, toRef as Pe, shallowRef as se, toRefs as ce, computed as ue, watch as H, shallowReactive as le, provide as Re, inject as ke, onUnmounted as fe, createRenderer as Ae, defineComponent as de, onMounted as Oe, h as P } from "vue"; | ||
import * as pe from "three"; | ||
import { MathUtils as je, PerspectiveCamera as B, OrthographicCamera as _e, Clock as me, Color as U, sRGBEncoding as ze, ACESFilmicToneMapping as Be, PCFSoftShadowMap as De, PCFShadowMap as We, LinearEncoding as ne, NoToneMapping as ae, WebGLRenderer as Fe, LoadingManager as Ie, TextureLoader as He, Raycaster as Ue, Vector2 as $e, BufferAttribute as Ge } from "three"; | ||
import { createEventHook as V, useRafFn as Ne, resolveUnref as u, useWindowSize as qe, useElementSize as Ve, useDevicePixelRatio as Ye, unrefElement as $, isFunction as re, useEventListener as Ke } from "@vueuse/core"; | ||
const N = S({ uuid: je.generateUUID() }), ve = (e) => void Object.assign(N.value, e); | ||
var Xe = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Xe || {}); | ||
const Je = 45; | ||
let L; | ||
function q() { | ||
const { state: e, setState: t, aspectRatio: r } = k(); | ||
function a(o = "Perspective", c) { | ||
var u, l, p; | ||
var l, v, d; | ||
if (o === "Perspective") { | ||
const { near: d, far: w, fov: v } = c || { | ||
const { near: f, far: M, fov: h } = c || { | ||
near: 0.1, | ||
far: 1e3, | ||
fov: tt | ||
fov: Je | ||
}; | ||
x = new O(v, ((u = e.aspectRatio) == null ? void 0 : u.value) || window.innerWidth / window.innerHeight, d, w), (l = e.cameras) == null || l.push(x); | ||
L = new B(h, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, f, M), (v = e.cameras) == null || v.push(L); | ||
} else { | ||
const { left: d, right: w, top: v, bottom: b, near: g, far: P } = c || { | ||
const { left: f, right: M, top: h, bottom: C, near: g, far: p } = c || { | ||
left: -100, | ||
@@ -37,13 +37,13 @@ right: 100, | ||
}; | ||
x = new ze(d, w, v, b, g, P), (p = e.cameras) == null || p.push(x); | ||
L = new _e(f, M, h, C, g, p), (d = e.cameras) == null || d.push(L); | ||
} | ||
return e.camera = x, t("camera", e.camera), x; | ||
return e.camera = L, t("camera", e.camera), L; | ||
} | ||
function n() { | ||
var o; | ||
e.camera instanceof O && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (o = e.camera) == null || o.updateProjectionMatrix(); | ||
e.camera instanceof B && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (o = e.camera) == null || o.updateProjectionMatrix(); | ||
} | ||
function i(o) { | ||
var c; | ||
(c = e.cameras) == null || c.push(o), o instanceof O && e.aspectRatio && (o.aspect = e.aspectRatio.value), o.updateProjectionMatrix(), t("camera", o); | ||
(c = e.cameras) == null || c.push(o), o instanceof B && e.aspectRatio && (o.aspect = e.aspectRatio.value), o.updateProjectionMatrix(), t("camera", o); | ||
} | ||
@@ -53,6 +53,6 @@ function s() { | ||
} | ||
return oe(() => { | ||
return ie(() => { | ||
r != null && r.value && n(); | ||
}), { | ||
activeCamera: ke(e, "camera"), | ||
activeCamera: Pe(e, "camera"), | ||
createCamera: a, | ||
@@ -64,45 +64,45 @@ updateCamera: n, | ||
} | ||
const me = $(), ve = $(), G = $(), E = new de(); | ||
let j = 0, _ = 0; | ||
const { pause: nt, resume: at, isActive: rt } = Ke( | ||
const he = V(), ge = V(), Y = V(), R = new me(); | ||
let D = 0, W = 0; | ||
const { pause: Qe, resume: Ze, isActive: et } = Ne( | ||
() => { | ||
me.trigger({ delta: j, elapsed: _, clock: E }), ve.trigger({ delta: j, elapsed: _, clock: E }), G.trigger({ delta: j, elapsed: _, clock: E }); | ||
he.trigger({ delta: D, elapsed: W, clock: R }), ge.trigger({ delta: D, elapsed: W, clock: R }), Y.trigger({ delta: D, elapsed: W, clock: R }); | ||
}, | ||
{ immediate: !1 } | ||
); | ||
G.on(() => { | ||
j = E.getDelta(), _ = E.getElapsedTime(); | ||
Y.on(() => { | ||
D = R.getDelta(), W = R.getElapsedTime(); | ||
}); | ||
function N() { | ||
function we() { | ||
return { | ||
onBeforeLoop: me.on, | ||
onLoop: ve.on, | ||
onAfterLoop: G.on, | ||
pause: nt, | ||
resume: at, | ||
isActive: rt | ||
onBeforeLoop: he.on, | ||
onLoop: ge.on, | ||
onAfterLoop: Y.on, | ||
pause: Qe, | ||
resume: Ze, | ||
isActive: et | ||
}; | ||
} | ||
function ot(e) { | ||
return e instanceof W ? e : Array.isArray(e) ? new W(...e) : new W(e); | ||
function tt(e) { | ||
return e instanceof U ? e : Array.isArray(e) ? new U(...e) : new U(e); | ||
} | ||
const I = { | ||
const G = { | ||
realistic: { | ||
outputEncoding: We, | ||
toneMapping: Fe, | ||
outputEncoding: ze, | ||
toneMapping: Be, | ||
toneMappingExposure: 3, | ||
shadowMap: { | ||
enabled: !0, | ||
type: Ie | ||
type: De | ||
} | ||
} | ||
}, ge = (e, t) => { | ||
}, be = (e, t) => { | ||
for (const r of Object.keys(t)) | ||
t[r] instanceof Object && Object.assign(t[r], ge(e[r], t[r])); | ||
t[r] instanceof Object && Object.assign(t[r], be(e[r], t[r])); | ||
return Object.assign(e || {}, t), e; | ||
}, it = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", st = /* @__PURE__ */ ct(it); | ||
function R(e) { | ||
}, 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 _(e) { | ||
return e.replace(/-([a-z])/g, (t, r) => r.toUpperCase()); | ||
} | ||
function ct(e, t) { | ||
function rt(e, t) { | ||
const r = /* @__PURE__ */ Object.create(null), a = e.split(","); | ||
@@ -113,5 +113,5 @@ for (let n = 0; n < a.length; n++) | ||
} | ||
function ut(e) { | ||
var Q, Z; | ||
const t = ie(), r = M(!1), { | ||
function ot(e) { | ||
var ee, te; | ||
const t = se(), r = S(!1), { | ||
alpha: a = !0, | ||
@@ -123,57 +123,57 @@ antialias: n = !0, | ||
precision: c, | ||
premultipliedAlpha: u, | ||
stencil: l, | ||
shadows: p = !1, | ||
shadowMapType: d = He, | ||
physicallyCorrectLights: w = !1, | ||
useLegacyLights: v = !1, | ||
outputEncoding: b = ee, | ||
toneMapping: g = te, | ||
toneMappingExposure: P = 1, | ||
context: ye = void 0, | ||
powerPreference: xe = "default", | ||
preserveDrawingBuffer: Me = !1, | ||
clearColor: C, | ||
windowSize: V = !1, | ||
preset: Ce = void 0 | ||
} = se(e), { state: h, setState: B } = S(), { width: q, height: Y } = f(V) ? Xe() : Je(h.container), { logError: Le, logWarning: Ee } = T(), { pixelRatio: K } = Qe(), { pause: Se, resume: Te } = N(), D = ce(() => q.value / Y.value); | ||
!f(V) && ((Z = (Q = h.container) == null ? void 0 : Q.value) == null ? void 0 : Z.offsetHeight) === 0 && Ee(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS. | ||
premultipliedAlpha: l, | ||
stencil: v, | ||
shadows: d = !1, | ||
shadowMapType: f = We, | ||
physicallyCorrectLights: M = !1, | ||
useLegacyLights: h = !1, | ||
outputEncoding: C = ne, | ||
toneMapping: g = ae, | ||
toneMappingExposure: p = 1, | ||
context: b = void 0, | ||
powerPreference: y = "default", | ||
preserveDrawingBuffer: O = !1, | ||
clearColor: w, | ||
windowSize: T = !1, | ||
preset: j = void 0 | ||
} = ce(e), { state: x, setState: F } = k(), { width: K, height: X } = u(T) ? qe() : Ve(x.container), { logError: Me, logWarning: Ce } = A(), { pixelRatio: J } = Ye(), { pause: Ee, resume: Le } = we(), I = ue(() => K.value / X.value); | ||
!u(T) && ((te = (ee = x.container) == null ? void 0 : ee.value) == null ? void 0 : te.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 X = () => { | ||
t.value && (t.value.setSize(q.value, Y.value), t.value.setPixelRatio(Math.min(K.value, 2))); | ||
}, J = () => { | ||
const Q = () => { | ||
t.value && (t.value.setSize(K.value, X.value), t.value.setPixelRatio(Math.min(J.value, 2))); | ||
}, Z = () => { | ||
if (!t.value) | ||
return; | ||
const y = f(Ce); | ||
if (y) { | ||
y in I || Le("Renderer Preset must be one of these: " + Object.keys(I).join(", ")), ge(t.value, I[y]); | ||
const E = u(j); | ||
if (E) { | ||
E in G || Me("Renderer Preset must be one of these: " + Object.keys(G).join(", ")), be(t.value, G[E]); | ||
return; | ||
} | ||
t.value.shadowMap.enabled = f(p), t.value.shadowMap.type = f(d), t.value.toneMapping = f(g) || te, t.value.toneMappingExposure = f(P), t.value.outputEncoding = f(b) || ee, C != null && C.value && t.value.setClearColor(ot(f(C))), t.value.useLegacyLights = f(v); | ||
}, Pe = () => { | ||
const y = F(h.canvas); | ||
y && (t.value = new Ue({ | ||
canvas: y, | ||
alpha: f(a), | ||
antialias: f(n), | ||
context: f(ye), | ||
depth: f(i), | ||
failIfMajorPerformanceCaveat: f(o), | ||
logarithmicDepthBuffer: f(s), | ||
powerPreference: f(xe), | ||
precision: f(c), | ||
stencil: f(l), | ||
preserveDrawingBuffer: f(Me), | ||
premultipliedAlpha: f(u) | ||
}), B("renderer", t.value), B("clock", new de()), B("aspectRatio", D), J(), X(), Te(), r.value = !0); | ||
}, Re = () => { | ||
t.value && (t.value.dispose(), t.value = void 0, r.value = !1, Se()); | ||
t.value.shadowMap.enabled = u(d), t.value.shadowMap.type = u(f), t.value.toneMapping = u(g) || ae, t.value.toneMappingExposure = u(p), t.value.outputEncoding = u(C) || ne, w != null && w.value && t.value.setClearColor(tt(u(w))), t.value.useLegacyLights = u(h); | ||
}, Se = () => { | ||
const E = $(x.canvas); | ||
E && (t.value = new Fe({ | ||
canvas: E, | ||
alpha: u(a), | ||
antialias: u(n), | ||
context: u(b), | ||
depth: u(i), | ||
failIfMajorPerformanceCaveat: u(o), | ||
logarithmicDepthBuffer: u(s), | ||
powerPreference: u(y), | ||
precision: u(c), | ||
stencil: u(v), | ||
preserveDrawingBuffer: u(O), | ||
premultipliedAlpha: u(l) | ||
}), F("renderer", t.value), F("clock", new me()), F("aspectRatio", I), Z(), Q(), Le(), r.value = !0); | ||
}, Te = () => { | ||
t.value && (t.value.dispose(), t.value = void 0, r.value = !1, Ee()); | ||
}; | ||
return z([D, K], X), z( | ||
[p, d, b, v, g, P, C], | ||
J | ||
), z( | ||
() => [h.canvas, h.container], | ||
return H([I, J], Q), H( | ||
[d, f, C, h, g, p, w], | ||
Z | ||
), H( | ||
() => [x.canvas, x.container], | ||
() => { | ||
F(h.canvas) && F(h.container) && Pe(); | ||
$(x.canvas) && $(x.container) && Se(); | ||
}, | ||
@@ -184,8 +184,8 @@ { immediate: !0, deep: !0 } | ||
isReady: r, | ||
dispose: Re, | ||
aspectRatio: D | ||
dispose: Te, | ||
aspectRatio: I | ||
}; | ||
} | ||
const he = (e) => !!e && e.constructor === Array; | ||
function ft(e) { | ||
const ye = (e) => !!e && e.constructor === Array; | ||
function it(e) { | ||
const t = { nodes: {}, materials: {} }; | ||
@@ -196,21 +196,21 @@ return e && e.traverse((r) => { | ||
} | ||
async function Et(e, t, r, a, n) { | ||
const { logError: i } = T(), s = new e(); | ||
async function Mt(e, t, r, a, n) { | ||
const { logError: i } = A(), s = new e(); | ||
n && n(s), r && r(s); | ||
const c = (Array.isArray(t) ? t : [t]).map( | ||
(u) => new Promise((l, p) => { | ||
(l) => new Promise((v, d) => { | ||
s.load( | ||
u, | ||
(d) => { | ||
d.scene && Object.assign(d, ft(d.scene)), l(d); | ||
l, | ||
(f) => { | ||
f.scene && Object.assign(f, it(f.scene)), v(f); | ||
}, | ||
a, | ||
(d) => p(i("[useLoader] - Failed to load resource", d)) | ||
(f) => d(i("[useLoader] - Failed to load resource", f)) | ||
); | ||
}) | ||
); | ||
return he(t) ? await Promise.all(c) : await c[0]; | ||
return ye(t) ? await Promise.all(c) : await c[0]; | ||
} | ||
async function St(e) { | ||
const t = new $e(), r = new Ge(t), a = (n) => new Promise((i, s) => { | ||
async function Ct(e) { | ||
const t = new Ie(), r = new He(t), a = (n) => new Promise((i, s) => { | ||
r.load( | ||
@@ -225,3 +225,3 @@ n, | ||
}); | ||
if (he(e)) { | ||
if (ye(e)) { | ||
const n = await Promise.all(e.map((i) => a(i))); | ||
@@ -236,5 +236,5 @@ return e.length > 1 ? n : n[0]; | ||
metalnessMap: c, | ||
aoMap: u, | ||
alphaMap: l, | ||
matcap: p | ||
aoMap: l, | ||
alphaMap: v, | ||
matcap: d | ||
} = e; | ||
@@ -247,5 +247,5 @@ return { | ||
metalnessMap: c ? await a(c) : null, | ||
aoMap: u ? await a(u) : null, | ||
alphaMap: l ? await a(l) : null, | ||
matcap: p ? await a(p) : null | ||
aoMap: l ? await a(l) : null, | ||
alphaMap: v ? await a(v) : null, | ||
matcap: d ? await a(d) : null | ||
}; | ||
@@ -255,10 +255,10 @@ } | ||
const m = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"]; | ||
function lt() { | ||
function st() { | ||
const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, r = Math.random() * 4294967295 | 0, a = Math.random() * 4294967295 | 0; | ||
return (m[e & 255] + m[e >> 8 & 255] + m[e >> 16 & 255] + m[e >> 24 & 255] + "-" + m[t & 255] + m[t >> 8 & 255] + "-" + m[t >> 16 & 15 | 64] + m[t >> 24 & 255] + "-" + m[r & 63 | 128] + m[r >> 8 & 255] + "-" + m[r >> 16 & 255] + m[r >> 24 & 255] + m[a & 255] + m[a >> 8 & 255] + m[a >> 16 & 255] + m[a >> 24 & 255]).toLowerCase(); | ||
} | ||
const we = Symbol(); | ||
function dt() { | ||
const e = ue({ | ||
uuid: lt(), | ||
const xe = Symbol(); | ||
function ct() { | ||
const e = le({ | ||
uuid: st(), | ||
camera: void 0, | ||
@@ -268,3 +268,3 @@ cameras: [], | ||
renderer: void 0, | ||
aspectRatio: ce(() => window.innerWidth / window.innerHeight) | ||
aspectRatio: ue(() => window.innerWidth / window.innerHeight) | ||
}); | ||
@@ -279,10 +279,10 @@ function t(n) { | ||
state: e, | ||
...se(e), | ||
...ce(e), | ||
getState: t, | ||
setState: r | ||
}; | ||
return Ae(we, a), a; | ||
return Re(xe, a), a; | ||
} | ||
const S = () => Oe(we, { | ||
state: ue({ | ||
const k = () => ke(xe, { | ||
state: le({ | ||
camera: void 0, | ||
@@ -293,21 +293,25 @@ cameras: [], | ||
}) | ||
}), ae = ie(new Ne()), k = M(new Ve()), pt = M(null); | ||
function be() { | ||
const { setState: e } = S(); | ||
e("raycaster", ae.value), e("pointer", k), e("currentInstance", pt); | ||
function t(r) { | ||
k.value.x = r.clientX / window.innerWidth * 2 - 1, k.value.y = -(r.clientY / window.innerHeight) * 2 + 1; | ||
}); | ||
function ut() { | ||
var s; | ||
const e = se(new Ue()), t = S(new $e()), r = S(null), { setState: a, state: n } = k(); | ||
a("raycaster", e.value), a("pointer", t), a("currentInstance", r); | ||
function i(o) { | ||
t.value.x = o.clientX / window.innerWidth * 2 - 1, t.value.y = -(o.clientY / window.innerHeight) * 2 + 1; | ||
} | ||
return window.addEventListener("pointermove", t), { | ||
raycaster: ae, | ||
pointer: k | ||
return (s = n == null ? void 0 : n.renderer) == null || s.domElement.addEventListener("pointermove", i), fe(() => { | ||
var o; | ||
(o = n == null ? void 0 : n.renderer) == null || o.domElement.removeEventListener("pointermove", i); | ||
}), { | ||
raycaster: e, | ||
pointer: t | ||
}; | ||
} | ||
const Tt = !0, re = "[TresJS ▲ ■ ●] "; | ||
function T() { | ||
const Et = !0, oe = "[TresJS ▲ ■ ●] "; | ||
function A() { | ||
function e(a, n) { | ||
console.error(`${re} ${a}`, n || ""); | ||
console.error(`${oe} ${a}`, n || ""); | ||
} | ||
function t(a) { | ||
console.warn(`${re} ${a}`); | ||
console.warn(`${oe} ${a}`); | ||
} | ||
@@ -322,4 +326,4 @@ function r(a, n) { | ||
} | ||
function Pt() { | ||
const { logWarning: e } = T(); | ||
function Lt() { | ||
const { logWarning: e } = A(); | ||
function t(a, n, i) { | ||
@@ -339,46 +343,25 @@ let s = null; | ||
} | ||
const { logWarning: mt } = T(); | ||
function vt(e) { | ||
for (const t in e) | ||
if (t.indexOf("on") === 0) | ||
return !0; | ||
return !1; | ||
} | ||
let A = null; | ||
const gt = { | ||
const { logWarning: lt } = A(), ft = /^on[^a-z]/, dt = (e) => ft.test(e); | ||
let z = null; | ||
const pt = { | ||
createElement(e, t, r, a) { | ||
if (e === "template" || st(e)) | ||
if (e === "template" || at(e)) | ||
return null; | ||
let n; | ||
if (a === null && (a = {}), a != null && a.args ? n = new H.value[e.replace("Tres", "")](...a.args) : n = new H.value[e.replace("Tres", "")](), n.isCamera) { | ||
(!(a != null && a.position) || a != null && a.position.every((s) => s == 0)) && mt( | ||
if (a === null && (a = {}), a != null && a.args ? n = new N.value[e.replace("Tres", "")](...a.args) : n = new N.value[e.replace("Tres", "")](), n.isCamera) { | ||
(!(a != null && a.position) || a != null && a.position.every((s) => s == 0)) && lt( | ||
// 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 } = U(); | ||
const { pushCamera: i } = q(); | ||
i(n); | ||
} | ||
return (a == null ? void 0 : a.attach) === void 0 && (n.isMaterial ? n.attach = "material" : n.isBufferGeometry && (n.attach = "geometry")), n; | ||
return (a == null ? void 0 : a.attach) === void 0 && (n.isMaterial ? n.attach = "material" : n.isBufferGeometry && (n.attach = "geometry")), n.events = {}, n; | ||
}, | ||
insert(e, t, r) { | ||
if (A === null && t.isScene && (A = t), t === null && (t = A), t != null && t.isObject3D && (e != null && e.isObject3D)) { | ||
const s = r ? t.children.indexOf(r) : 0; | ||
e.parent = t, t.children.splice(s, 0, e), e.dispatchEvent({ type: "added" }); | ||
if (z === null && t.isScene && (z = t), t === null && (t = z), t != null && t.isObject3D && (e != null && e.isObject3D)) { | ||
const a = r ? t.children.indexOf(r) : 0; | ||
e.parent = t, t.children.splice(a, 0, e), e.dispatchEvent({ type: "added" }); | ||
} else | ||
typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e)); | ||
const { onLoop: a } = N(); | ||
let n = null, i = null; | ||
if (e && e instanceof qe && vt(e)) { | ||
const { raycaster: s } = be(); | ||
a(() => { | ||
var o, c, u; | ||
if (t != null && t.children && e && s) { | ||
const l = s.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)) && ((o = e.onPointerEnter) == null || o.call(e, i)), (c = e.onPointerMove) == null || c.call(e, i)) : (i = null, n !== null && ((u = e.onPointerLeave) == null || u.call(e, n))), n = i; | ||
} | ||
}), Ze(window, "click", () => { | ||
var o; | ||
i !== null && ((o = e.onClick) == null || o.call(e, i)); | ||
}); | ||
} | ||
}, | ||
@@ -394,8 +377,8 @@ remove(e) { | ||
let n = e, i = t; | ||
const s = R(i); | ||
const s = _(i); | ||
let o = n == null ? void 0 : n[s]; | ||
if (e.parent || (e.parent = A), n.type === "BufferGeometry") { | ||
if (e.parent || (e.parent = z), n.type === "BufferGeometry") { | ||
n.setAttribute( | ||
R(i), | ||
new Ye(...a) | ||
_(i), | ||
new Ge(...a) | ||
); | ||
@@ -405,11 +388,12 @@ return; | ||
if (i.includes("-") && o === void 0) { | ||
const u = i.split("-"); | ||
o = u.reduce((l, p) => l[R(p)], n), i = u.pop(), o != null && o.set || (n = u.reduce((l, p) => l[R(p)], n)); | ||
const l = i.split("-"); | ||
o = l.reduce((v, d) => v[_(d)], n), i = l.pop(), o != null && o.set || (n = l.reduce((v, d) => v[_(d)], n)); | ||
} | ||
dt(i) && (e.events[i] = a); | ||
let c = a; | ||
if (c === "" && (c = !0), ne(o)) { | ||
if (c === "" && (c = !0), re(o)) { | ||
Array.isArray(c) ? e[s](...c) : e[s](c); | ||
return; | ||
} | ||
!(o != null && o.set) && !ne(o) ? n[s] = c : o.constructor === c.constructor && (o != null && o.copy) ? o == null || o.copy(c) : Array.isArray(c) ? o.set(...c) : !o.isColor && o.setScalar ? o.setScalar(c) : o.set(c); | ||
!(o != null && o.set) && !re(o) ? n[s] = c : o.constructor === c.constructor && (o != null && o.copy) ? o == null || o.copy(c) : Array.isArray(c) ? o.set(...c) : !o.isColor && o.setScalar ? o.setScalar(c) : o.set(c); | ||
} | ||
@@ -429,4 +413,4 @@ }, | ||
insertStaticContent: () => void 0 | ||
}, { createApp: ht } = je(gt), wt = (e) => { | ||
const t = ht(r); | ||
}, { createApp: mt } = Ae(pt), vt = (e) => { | ||
const t = mt(r); | ||
function r() { | ||
@@ -437,4 +421,4 @@ return e && e.default ? e.default() : []; | ||
}; | ||
pe(le); | ||
const { logWarning: bt } = T(), yt = fe({ | ||
ve(pe); | ||
const { logWarning: ht } = A(), gt = de({ | ||
name: "TresScene", | ||
@@ -457,28 +441,35 @@ props: [ | ||
setup(e, { slots: t, expose: r }) { | ||
e.physicallyCorrectLights === !0 && bt("physicallyCorrectLights is deprecated, useLegacyLights is now false by default"); | ||
const a = M(), n = M(), i = new le.Scene(), { setState: s } = S(); | ||
e.physicallyCorrectLights === !0 && ht("physicallyCorrectLights is deprecated, useLegacyLights is now false by default"); | ||
const a = S(), n = S(), i = new pe.Scene(), { setState: s } = k(); | ||
s("scene", i), s("canvas", n), s("container", a); | ||
const { pushCamera: o } = U(); | ||
o(new O()), _e(() => { | ||
const { pushCamera: o } = q(); | ||
o(new B()), Oe(() => { | ||
c(); | ||
}), Be(() => { | ||
}), fe(() => { | ||
s("renderer", null); | ||
}); | ||
function c() { | ||
const { renderer: p } = ut(e), { activeCamera: d } = U(), { onLoop: w } = N(), { raycaster: v, pointer: b } = be(); | ||
oe(() => { | ||
d.value && v.value.setFromCamera(b.value, d.value); | ||
}), w(() => { | ||
var g; | ||
d.value && ((g = p.value) == null || g.render(i, d.value)); | ||
const { renderer: d } = ot(e), { activeCamera: f } = q(), { onLoop: M } = we(), { raycaster: h, pointer: C } = ut(); | ||
let g = null, p = null; | ||
ie(() => { | ||
f.value && h.value.setFromCamera(C.value, f.value); | ||
}), M(() => { | ||
var b, y, O, w, T; | ||
if (f.value && ((b = d.value) == null || b.render(i, f.value)), h.value) { | ||
const j = h.value.intersectObjects(i.children); | ||
j.length > 0 ? (p = j[0], g === null && ((O = (y = p.object.events).onPointerEnter) == null || O.call(y, p))) : g !== null && ((T = p == null ? void 0 : (w = p.object.events).onPointerLeave) == null || T.call(w, g), p = null), g = p; | ||
} | ||
}), Ke(n.value, "click", () => { | ||
var b, y; | ||
p !== null && ((y = (b = p.object.events).onClick) == null || y.call(b, p)); | ||
}); | ||
} | ||
let u; | ||
function l() { | ||
u = wt(t), u.provide("useTres", S()), u.provide("extend", pe), u.mount(i); | ||
let l; | ||
function v() { | ||
l = vt(t), l.provide("useTres", k()), l.provide("extend", ve), l.mount(i); | ||
} | ||
return l(), r({ | ||
return v(), r({ | ||
scene: i | ||
}), () => L( | ||
L( | ||
}), () => P( | ||
P( | ||
"div", | ||
@@ -498,3 +489,3 @@ { | ||
[ | ||
L( | ||
P( | ||
"div", | ||
@@ -508,3 +499,3 @@ { | ||
[ | ||
L("canvas", { | ||
P("canvas", { | ||
ref: n, | ||
@@ -527,3 +518,3 @@ "data-scene": i.uuid, | ||
} | ||
}), xt = fe({ | ||
}), wt = de({ | ||
name: "TresCanvas", | ||
@@ -546,28 +537,28 @@ props: [ | ||
setup(e, { slots: t, expose: r }) { | ||
const a = dt(); | ||
return r(a), () => L(yt, e, t); | ||
const a = ct(); | ||
return r(a), () => P(gt, e, t); | ||
} | ||
}), Rt = { | ||
}), St = { | ||
install(e) { | ||
e.component("TresCanvas", xt); | ||
e.component("TresCanvas", wt); | ||
} | ||
}; | ||
export { | ||
et as CameraType, | ||
xt as TresCanvas, | ||
H as catalogue, | ||
Rt as default, | ||
pe as extend, | ||
Tt as isProd, | ||
ft as trasverseObjects, | ||
U as useCamera, | ||
Et as useLoader, | ||
T as useLogger, | ||
be as useRaycaster, | ||
N as useRenderLoop, | ||
ut as useRenderer, | ||
Pt as useSeek, | ||
St as useTexture, | ||
S as useTres, | ||
dt as useTresProvider | ||
Xe as CameraType, | ||
wt as TresCanvas, | ||
N as catalogue, | ||
St as default, | ||
ve as extend, | ||
Et as isProd, | ||
it as trasverseObjects, | ||
q as useCamera, | ||
Mt as useLoader, | ||
A as useLogger, | ||
ut as useRaycaster, | ||
we as useRenderLoop, | ||
ot as useRenderer, | ||
Lt as useSeek, | ||
Ct as useTexture, | ||
k as useTres, | ||
ct as useTresProvider | ||
}; |
{ | ||
"name": "@tresjs/core", | ||
"description": "Declarative ThreeJS using Vue Components", | ||
"version": "2.0.0-beta.1", | ||
"version": "2.0.0-beta.2", | ||
"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
79020
1543