@tresjs/core
Advanced tools
Comparing version 2.0.0-beta.13 to 2.0.0-rc.0
@@ -1,2 +0,2 @@ | ||
import { MaybeComputedRef } from '@vueuse/core'; | ||
import { MaybeRefOrGetter } from '@vueuse/core'; | ||
import { WebGLRendererParameters, WebGLRenderer, ShadowMapType } from 'three'; | ||
@@ -12,3 +12,3 @@ import type { TextureEncoding, ToneMapping } from 'three'; | ||
*/ | ||
shadows?: MaybeComputedRef<boolean>; | ||
shadows?: MaybeRefOrGetter<boolean>; | ||
/** | ||
@@ -21,3 +21,3 @@ * Set the shadow map type | ||
*/ | ||
shadowMapType?: MaybeComputedRef<ShadowMapType>; | ||
shadowMapType?: MaybeRefOrGetter<ShadowMapType>; | ||
/** | ||
@@ -30,10 +30,10 @@ * Whether to use physically correct lighting mode. | ||
*/ | ||
physicallyCorrectLights?: MaybeComputedRef<boolean>; | ||
physicallyCorrectLights?: MaybeRefOrGetter<boolean>; | ||
/** | ||
* Whether to use legacy lighting mode. | ||
* | ||
* @type {MaybeComputedRef<boolean>} | ||
* @type {MaybeRefOrGetter<boolean>} | ||
* @memberof UseRendererOptions | ||
*/ | ||
useLegacyLights?: MaybeComputedRef<boolean>; | ||
useLegacyLights?: MaybeRefOrGetter<boolean>; | ||
/** | ||
@@ -45,3 +45,3 @@ * Defines the output encoding of the renderer. | ||
*/ | ||
outputEncoding?: MaybeComputedRef<TextureEncoding>; | ||
outputEncoding?: MaybeRefOrGetter<TextureEncoding>; | ||
/** | ||
@@ -53,3 +53,3 @@ * Defines the tone mapping used by the renderer. | ||
*/ | ||
toneMapping?: MaybeComputedRef<ToneMapping>; | ||
toneMapping?: MaybeRefOrGetter<ToneMapping>; | ||
/** | ||
@@ -60,3 +60,3 @@ * Defines the tone mapping exposure used by the renderer. | ||
*/ | ||
toneMappingExposure?: MaybeComputedRef<number>; | ||
toneMappingExposure?: MaybeRefOrGetter<number>; | ||
/** | ||
@@ -86,4 +86,4 @@ * The context used by the renderer. | ||
*/ | ||
clearColor?: MaybeComputedRef<TresColor>; | ||
windowSize?: MaybeComputedRef<boolean | string>; | ||
clearColor?: MaybeRefOrGetter<TresColor>; | ||
windowSize?: MaybeRefOrGetter<boolean | string>; | ||
preset?: RendererPresetsType; | ||
@@ -90,0 +90,0 @@ } |
295
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v2.0.0-beta.13 | ||
* version: v2.0.0-rc.0 | ||
* (c) 2023 | ||
@@ -8,23 +8,23 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { ref as R, watchEffect as le, toRef as Se, shallowRef as de, toRefs as me, computed as pe, watch as V, shallowReactive as ve, provide as Oe, inject as ke, onUnmounted as ge, createRenderer as je, defineComponent as he, onMounted as De, h as D } from "vue"; | ||
import { ref as R, watchEffect as le, toRef as _e, shallowRef as de, toRefs as me, computed as pe, watch as F, shallowReactive as ve, provide as Se, inject as Oe, onUnmounted as ge, createRenderer as ke, defineComponent as he, onMounted as je, h as k } from "vue"; | ||
import * as we from "three"; | ||
import { MathUtils as Ie, PerspectiveCamera as $, OrthographicCamera as Be, Clock as be, Color as N, sRGBEncoding as ze, ACESFilmicToneMapping as Fe, PCFSoftShadowMap as Ge, PCFShadowMap as Ve, LinearEncoding as ne, NoToneMapping as re, WebGLRenderer as Ue, LoadingManager as We, TextureLoader as He, Raycaster as Ye, Vector2 as $e, BufferAttribute as Ne } from "three"; | ||
import { createEventHook as J, useRafFn as qe, resolveUnref as l, useWindowSize as Ke, useElementSize as Je, useDevicePixelRatio as Xe, unrefElement as q, isFunction as oe, useEventListener as Qe } from "@vueuse/core"; | ||
const ye = R({ uuid: Ie.generateUUID() }), Me = (e) => void Object.assign(ye.value, e); | ||
var Ze = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ze || {}); | ||
const et = 45; | ||
let S; | ||
import { MathUtils as De, PerspectiveCamera as $, OrthographicCamera as Ie, Clock as be, Color as N, sRGBEncoding as Be, ACESFilmicToneMapping as ze, PCFSoftShadowMap as Ge, PCFShadowMap as Ve, LinearEncoding as ne, NoToneMapping as re, WebGLRenderer as Fe, LoadingManager as We, TextureLoader as He, Raycaster as Ue, Vector2 as Ye, BufferAttribute as $e } from "three"; | ||
import { createEventHook as J, useRafFn as Ne, toValue as l, useWindowSize as qe, useElementSize as Ke, useDevicePixelRatio as Je, unrefElement as q, useEventListener as Xe } from "@vueuse/core"; | ||
const ye = R({ uuid: De.generateUUID() }), Me = (e) => void Object.assign(ye.value, e); | ||
var Qe = /* @__PURE__ */ ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Qe || {}); | ||
const Ze = 45; | ||
let _; | ||
function xe() { | ||
const { state: e, setState: t, aspectRatio: o } = O(); | ||
const { state: e, setState: t, aspectRatio: o } = S(); | ||
function a(i = "Perspective", s) { | ||
var u, f, d; | ||
var u, f, m; | ||
if (i === "Perspective") { | ||
const { near: p, far: b, fov: x } = s || { | ||
const { near: v, far: h, fov: M } = s || { | ||
near: 0.1, | ||
far: 1e3, | ||
fov: et | ||
fov: Ze | ||
}; | ||
S = new $(x, ((u = e.aspectRatio) == null ? void 0 : u.value) || window.innerWidth / window.innerHeight, p, b), (f = e.cameras) == null || f.push(S); | ||
_ = new $(M, ((u = e.aspectRatio) == null ? void 0 : u.value) || window.innerWidth / window.innerHeight, v, h), (f = e.cameras) == null || f.push(_); | ||
} else { | ||
const { left: p, right: b, top: x, bottom: g, near: P, far: E } = s || { | ||
const { left: v, right: h, top: M, bottom: w, near: P, far: x } = s || { | ||
left: -100, | ||
@@ -37,5 +37,5 @@ right: 100, | ||
}; | ||
S = new Be(p, b, x, g, P, E), (d = e.cameras) == null || d.push(S); | ||
_ = new Ie(v, h, M, w, P, x), (m = e.cameras) == null || m.push(_); | ||
} | ||
return e.camera = S, t("camera", e.camera), S; | ||
return e.camera = _, t("camera", e.camera), _; | ||
} | ||
@@ -56,3 +56,3 @@ function n() { | ||
}), { | ||
activeCamera: Se(e, "camera"), | ||
activeCamera: _e(e, "camera"), | ||
createCamera: a, | ||
@@ -64,7 +64,7 @@ updateCamera: n, | ||
} | ||
const Ee = J(), Ce = J(), X = J(), I = new be(); | ||
let U = 0, W = 0; | ||
const { pause: tt, resume: at, isActive: nt } = qe( | ||
const Ee = J(), Ce = J(), X = J(), j = new be(); | ||
let W = 0, H = 0; | ||
const { pause: et, resume: tt, isActive: at } = Ne( | ||
() => { | ||
Ee.trigger({ delta: U, elapsed: W, clock: I }), Ce.trigger({ delta: U, elapsed: W, clock: I }), X.trigger({ delta: U, elapsed: W, clock: I }); | ||
Ee.trigger({ delta: W, elapsed: H, clock: j }), Ce.trigger({ delta: W, elapsed: H, clock: j }), X.trigger({ delta: W, elapsed: H, clock: j }); | ||
}, | ||
@@ -74,3 +74,3 @@ { immediate: !1 } | ||
X.on(() => { | ||
U = I.getDelta(), W = I.getElapsedTime(); | ||
W = j.getDelta(), H = j.getElapsedTime(); | ||
}); | ||
@@ -82,8 +82,8 @@ function Re() { | ||
onAfterLoop: X.on, | ||
pause: tt, | ||
resume: at, | ||
isActive: nt | ||
pause: et, | ||
resume: tt, | ||
isActive: at | ||
}; | ||
} | ||
function rt(e) { | ||
function nt(e) { | ||
return e instanceof N ? e : Array.isArray(e) ? new N(...e) : new N(e); | ||
@@ -93,4 +93,4 @@ } | ||
realistic: { | ||
outputEncoding: ze, | ||
toneMapping: Fe, | ||
outputEncoding: Be, | ||
toneMapping: ze, | ||
toneMappingExposure: 3, | ||
@@ -106,7 +106,7 @@ shadowMap: { | ||
return Object.assign(e || {}, t), e; | ||
}, ot = "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", it = /* @__PURE__ */ st(ot); | ||
function G(e) { | ||
}, rt = "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", ot = /* @__PURE__ */ it(rt); | ||
function V(e) { | ||
return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase()); | ||
} | ||
function st(e, t) { | ||
function it(e, t) { | ||
const o = /* @__PURE__ */ Object.create(null), a = e.split(","); | ||
@@ -117,3 +117,3 @@ for (let n = 0; n < a.length; n++) | ||
} | ||
function ct(e) { | ||
function st(e) { | ||
var te, ae; | ||
@@ -129,55 +129,54 @@ const t = de(), o = R(!1), { | ||
stencil: f, | ||
shadows: d = !1, | ||
shadowMapType: p = Ve, | ||
physicallyCorrectLights: b = !1, | ||
useLegacyLights: x = !1, | ||
outputEncoding: g = ne, | ||
toneMapping: P = re, | ||
toneMappingExposure: E = 1, | ||
context: H = void 0, | ||
powerPreference: L = "default", | ||
preserveDrawingBuffer: v = !1, | ||
clearColor: w, | ||
windowSize: h = !1, | ||
preset: M = void 0 | ||
} = me(e), { state: y, setState: T } = O(), { width: C, height: k } = l(h) == !0 || l(h) === "" || l(h) === "true" ? Ke() : Je(y.container), { logError: z, logWarning: A } = B(), { pixelRatio: j } = Xe(), { pause: F, resume: Te } = Re(), Y = pe(() => C.value / k.value); | ||
!l(h) && ((ae = (te = y.container) == null ? void 0 : te.value) == null ? void 0 : ae.offsetHeight) === 0 && A(`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. | ||
shadows: m = !1, | ||
shadowMapType: v = Ve, | ||
useLegacyLights: h = !1, | ||
outputEncoding: M = ne, | ||
toneMapping: w = re, | ||
toneMappingExposure: P = 1, | ||
context: x = void 0, | ||
powerPreference: U = "default", | ||
preserveDrawingBuffer: T = !1, | ||
clearColor: d, | ||
windowSize: b = !1, | ||
preset: y = void 0 | ||
} = me(e), { state: g, setState: L } = S(), { width: O, height: E } = l(b) == !0 || l(b) === "" || l(b) === "true" ? qe() : Ke(g.container), { logError: I, logWarning: B } = D(), { pixelRatio: C } = Je(), { pause: z, resume: G } = Re(), Y = pe(() => O.value / E.value); | ||
!l(b) && ((ae = (te = g.container) == null ? void 0 : te.value) == null ? void 0 : ae.offsetHeight) === 0 && B(`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 Z = () => { | ||
t.value && (t.value.setSize(C.value, k.value), t.value.setPixelRatio(Math.min(j.value, 2))); | ||
t.value && (t.value.setSize(O.value, E.value), t.value.setPixelRatio(Math.min(C.value, 2))); | ||
}, ee = () => { | ||
if (!t.value) | ||
return; | ||
const _ = l(M); | ||
if (_) { | ||
_ in K || z("Renderer Preset must be one of these: " + Object.keys(K).join(", ")), Pe(t.value, K[_]); | ||
const A = l(y); | ||
if (A) { | ||
A in K || I("Renderer Preset must be one of these: " + Object.keys(K).join(", ")), Pe(t.value, K[A]); | ||
return; | ||
} | ||
t.value.shadowMap.enabled = l(d), t.value.shadowMap.type = l(p), t.value.toneMapping = l(P) || re, t.value.toneMappingExposure = l(E), t.value.outputEncoding = l(g) || ne, w != null && w.value && t.value.setClearColor(rt(l(w))), t.value.useLegacyLights = l(x); | ||
}, Ae = () => { | ||
const _ = q(y.canvas); | ||
_ && (t.value = new Ue({ | ||
canvas: _, | ||
t.value.shadowMap.enabled = l(m), t.value.shadowMap.type = l(v), t.value.toneMapping = l(w) || re, t.value.toneMappingExposure = l(P), t.value.outputEncoding = l(M) || ne, d != null && d.value && t.value.setClearColor(nt(l(d))), t.value.useLegacyLights = l(h); | ||
}, Le = () => { | ||
const A = q(g.canvas); | ||
A && (t.value = new Fe({ | ||
canvas: A, | ||
alpha: l(a), | ||
antialias: l(n), | ||
context: l(H), | ||
context: l(x), | ||
depth: l(r), | ||
failIfMajorPerformanceCaveat: l(i), | ||
logarithmicDepthBuffer: l(c), | ||
powerPreference: l(L), | ||
powerPreference: l(U), | ||
precision: l(s), | ||
stencil: l(f), | ||
preserveDrawingBuffer: l(v), | ||
preserveDrawingBuffer: l(T), | ||
premultipliedAlpha: l(u) | ||
}), T("renderer", t.value), T("clock", new be()), T("aspectRatio", Y), ee(), Z(), Te(), o.value = !0); | ||
}, _e = () => { | ||
t.value && (t.value.dispose(), t.value = void 0, o.value = !1, F()); | ||
}), L("renderer", t.value), L("clock", new be()), L("aspectRatio", Y), ee(), Z(), G(), o.value = !0); | ||
}, Ae = () => { | ||
t.value && (t.value.dispose(), t.value = void 0, o.value = !1, z()); | ||
}; | ||
return V([Y, j], Z), V( | ||
[d, p, g, x, P, E, w], | ||
return F([Y, C], Z), F( | ||
[m, v, M, h, w, P, d], | ||
ee | ||
), V( | ||
() => [y.canvas, y.container], | ||
), F( | ||
() => [g.canvas, g.container], | ||
() => { | ||
q(y.canvas) && q(y.container) && Ae(); | ||
q(g.canvas) && q(g.container) && Le(); | ||
}, | ||
@@ -188,8 +187,8 @@ { immediate: !0, deep: !0 } | ||
isReady: o, | ||
dispose: _e, | ||
dispose: Ae, | ||
aspectRatio: Y | ||
}; | ||
} | ||
const ut = (e) => typeof e == "string", Le = (e) => !!e && e.constructor === Array; | ||
function ft(e) { | ||
const oe = (e) => typeof e == "function", ct = (e) => typeof e == "string", Te = (e) => !!e && e.constructor === Array; | ||
function ut(e) { | ||
const t = { nodes: {}, materials: {} }; | ||
@@ -200,20 +199,20 @@ return e && e.traverse((o) => { | ||
} | ||
async function Ct(e, t, o, a, n) { | ||
const { logError: r } = B(), c = new e(); | ||
async function Et(e, t, o, a, n) { | ||
const { logError: r } = D(), c = new e(); | ||
n && n(c), o && o(c); | ||
const s = (Array.isArray(t) ? t : [t]).map( | ||
(u) => new Promise((f, d) => { | ||
(u) => new Promise((f, m) => { | ||
c.load( | ||
u, | ||
(p) => { | ||
p.scene && Object.assign(p, ft(p.scene)), f(p); | ||
(v) => { | ||
v.scene && Object.assign(v, ut(v.scene)), f(v); | ||
}, | ||
a, | ||
(p) => d(r("[useLoader] - Failed to load resource", p)) | ||
(v) => m(r("[useLoader] - Failed to load resource", v)) | ||
); | ||
}) | ||
); | ||
return Le(t) ? await Promise.all(s) : await s[0]; | ||
return Te(t) ? await Promise.all(s) : await s[0]; | ||
} | ||
async function Rt(e) { | ||
async function Ct(e) { | ||
const t = new We(), o = new He(t), a = (n) => new Promise((r, c) => { | ||
@@ -229,3 +228,3 @@ o.load( | ||
}); | ||
if (Le(e)) { | ||
if (Te(e)) { | ||
const n = await Promise.all(e.map((r) => a(r))); | ||
@@ -242,3 +241,3 @@ return e.length > 1 ? n : n[0]; | ||
alphaMap: f, | ||
matcap: d | ||
matcap: m | ||
} = e; | ||
@@ -253,15 +252,15 @@ return { | ||
alphaMap: f ? await a(f) : null, | ||
matcap: d ? await a(d) : null | ||
matcap: m ? await a(m) : null | ||
}; | ||
} | ||
} | ||
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() { | ||
const p = ["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 ft() { | ||
const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, o = 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[o & 63 | 128] + m[o >> 8 & 255] + "-" + m[o >> 16 & 255] + m[o >> 24 & 255] + m[a & 255] + m[a >> 8 & 255] + m[a >> 16 & 255] + m[a >> 24 & 255]).toLowerCase(); | ||
return (p[e & 255] + p[e >> 8 & 255] + p[e >> 16 & 255] + p[e >> 24 & 255] + "-" + p[t & 255] + p[t >> 8 & 255] + "-" + p[t >> 16 & 15 | 64] + p[t >> 24 & 255] + "-" + p[o & 63 | 128] + p[o >> 8 & 255] + "-" + p[o >> 16 & 255] + p[o >> 24 & 255] + p[a & 255] + p[a >> 8 & 255] + p[a >> 16 & 255] + p[a >> 24 & 255]).toLowerCase(); | ||
} | ||
const Q = Symbol(); | ||
function dt() { | ||
function lt() { | ||
const e = ve({ | ||
uuid: lt(), | ||
uuid: ft(), | ||
camera: void 0, | ||
@@ -285,5 +284,5 @@ cameras: [], | ||
}; | ||
return Oe(Q, a), a; | ||
return Se(Q, a), a; | ||
} | ||
const O = () => ke(Q, { | ||
const S = () => Oe(Q, { | ||
state: ve({ | ||
@@ -296,5 +295,5 @@ camera: void 0, | ||
}); | ||
function mt() { | ||
function dt() { | ||
var c; | ||
const e = de(new Ye()), t = R(new $e()), o = R(null), { setState: a, state: n } = O(); | ||
const e = de(new Ue()), t = R(new Ye()), o = R(null), { setState: a, state: n } = S(); | ||
a("raycaster", e.value), a("pointer", t), a("currentInstance", o); | ||
@@ -312,4 +311,4 @@ function r(i) { | ||
} | ||
const Pt = !0, ie = "[TresJS ▲ ■ ●] "; | ||
function B() { | ||
const Rt = !0, ie = "[TresJS ▲ ■ ●] "; | ||
function D() { | ||
function e(a, n) { | ||
@@ -329,4 +328,4 @@ console.error(`${ie} ${a}`, n || ""); | ||
} | ||
function Lt() { | ||
const { logWarning: e } = B(); | ||
function Pt() { | ||
const { logWarning: e } = D(); | ||
function t(a, n, r) { | ||
@@ -346,3 +345,3 @@ let c = null; | ||
} | ||
const pt = /^on[^a-z]/, vt = (e) => pt.test(e); | ||
const mt = /^on[^a-z]/, pt = (e) => mt.test(e); | ||
let se = null; | ||
@@ -352,6 +351,6 @@ const ce = { | ||
MATERIAL_VIA_PROP: "tres__materialViaProp" | ||
}, { logError: ue } = B(), gt = { | ||
}, { logError: ue } = D(), vt = { | ||
createElement(e, t, o, a) { | ||
var s, u; | ||
if (a || (a = {}), a.args || (a.args = []), e === "template" || it(e)) | ||
if (a || (a = {}), a.args || (a.args = []), e === "template" || ot(e)) | ||
return null; | ||
@@ -400,3 +399,3 @@ let n = e.replace("Tres", ""), r; | ||
if (e) { | ||
let n = e, r = t, c = G(r), i = n == null ? void 0 : n[c]; | ||
let n = e, r = t, c = V(r), i = n == null ? void 0 : n[c]; | ||
if (n.type === "BufferGeometry") { | ||
@@ -406,4 +405,4 @@ if (r === "args") | ||
n.setAttribute( | ||
G(r), | ||
new Ne(...a) | ||
V(r), | ||
new $e(...a) | ||
); | ||
@@ -414,5 +413,5 @@ return; | ||
const u = r.split("-"); | ||
i = u.reduce((f, d) => f[G(d)], n), r = u.pop(), c = r.toLowerCase(), i != null && i.set || (n = u.reduce((f, d) => f[G(d)], n)); | ||
i = u.reduce((f, m) => f[V(m)], n), r = u.pop(), c = r.toLowerCase(), i != null && i.set || (n = u.reduce((f, m) => f[V(m)], n)); | ||
} | ||
vt(r) && (e.events[r] = a); | ||
pt(r) && (e.events[r] = a); | ||
let s = a; | ||
@@ -438,4 +437,4 @@ if (s === "" && (s = !0), oe(i)) { | ||
insertStaticContent: () => void 0 | ||
}, { createApp: ht } = je(gt), wt = (e) => { | ||
const t = ht(o); | ||
}, { createApp: gt } = ke(vt), ht = (e) => { | ||
const t = gt(o); | ||
function o() { | ||
@@ -447,3 +446,3 @@ return e && e.default ? e.default() : []; | ||
Me(we); | ||
const { logWarning: fe } = B(), bt = he({ | ||
const { logWarning: fe } = D(), wt = he({ | ||
name: "TresScene", | ||
@@ -469,42 +468,42 @@ props: [ | ||
e.physicallyCorrectLights === !0 && fe("physicallyCorrectLights is deprecated, useLegacyLights is now false by default"); | ||
const a = R(), n = R(), r = new we.Scene(), { setState: c } = O(); | ||
const a = R(), n = R(), r = new we.Scene(), { setState: c } = S(); | ||
c("scene", r), c("canvas", n), c("container", a); | ||
const i = R(), s = t && t.default && t.default(); | ||
(s == null ? void 0 : s.length) > 0 && (i.value = s.some((g) => ut(g.type) && g.type.includes("Camera")) || e.camera, i.value || fe("No camera found in the scene, please add one!")), De(() => { | ||
p(); | ||
s && (s == null ? void 0 : s.length) > 0 && (i.value = s.some((w) => ct(w.type) && w.type.includes("Camera")) || e.camera, i.value || fe("No camera found in the scene, please add one!")), je(() => { | ||
v(); | ||
}), ge(() => { | ||
c("renderer", null); | ||
}); | ||
const { activeCamera: u, pushCamera: f, clearCameras: d } = xe(); | ||
function p() { | ||
const { renderer: g } = ct(e); | ||
const { activeCamera: u, pushCamera: f, clearCameras: m } = xe(); | ||
function v() { | ||
const { renderer: w } = st(e); | ||
e.camera && f(e.camera); | ||
const { onLoop: P } = Re(), { raycaster: E, pointer: H } = mt(); | ||
let L = null, v = null; | ||
const { onLoop: P } = Re(), { raycaster: x, pointer: U } = dt(); | ||
let T = null, d = null; | ||
le(() => { | ||
u.value && E.value.setFromCamera(H.value, u.value); | ||
u.value && x.value.setFromCamera(U.value, u.value); | ||
}), P(() => { | ||
var w, h, M, y, T, C, k, z, A, j; | ||
if (u.value && e.disableRender !== !0 && e.disableRender !== "" && ((w = g.value) == null || w.render(r, u.value)), E.value) { | ||
const F = E.value.intersectObjects(r.children); | ||
F.length > 0 ? (v = F[0], L === null && ((y = (M = (h = v.object) == null ? void 0 : h.events) == null ? void 0 : M.onPointerEnter) == null || y.call(M, v)), (k = (C = (T = v.object) == null ? void 0 : T.events) == null ? void 0 : C.onPointerMove) == null || k.call(C, v)) : L !== null && ((j = (A = (z = v == null ? void 0 : v.object) == null ? void 0 : z.events) == null ? void 0 : A.onPointerLeave) == null || j.call(A, L), v = null), L = v; | ||
var b, y, g, L, O, E, I, B, C, z; | ||
if (u.value && e.disableRender !== !0 && e.disableRender !== "" && ((b = w.value) == null || b.render(r, u.value)), x.value) { | ||
const G = x.value.intersectObjects(r.children); | ||
G.length > 0 ? (d = G[0], T === null && ((L = (g = (y = d.object) == null ? void 0 : y.events) == null ? void 0 : g.onPointerEnter) == null || L.call(g, d)), (I = (E = (O = d.object) == null ? void 0 : O.events) == null ? void 0 : E.onPointerMove) == null || I.call(E, d)) : T !== null && ((z = (C = (B = d == null ? void 0 : d.object) == null ? void 0 : B.events) == null ? void 0 : C.onPointerLeave) == null || z.call(C, T), d = null), T = d; | ||
} | ||
}), Qe(n.value, "click", () => { | ||
var w, h, M; | ||
v !== null && ((M = (h = (w = v.object) == null ? void 0 : w.events) == null ? void 0 : h.onClick) == null || M.call(h, v)); | ||
}), Xe(n.value, "click", () => { | ||
var b, y, g; | ||
d !== null && ((g = (y = (b = d.object) == null ? void 0 : b.events) == null ? void 0 : y.onClick) == null || g.call(y, d)); | ||
}); | ||
} | ||
let b; | ||
function x() { | ||
b = wt(t), b.provide("useTres", O()), b.provide(Q, O()), b.provide("extend", Me), b.mount(r); | ||
let h; | ||
function M() { | ||
h = ht(t), h.provide("useTres", S()), h.provide(Q, S()), h.provide("extend", Me), h.mount(r); | ||
} | ||
return x(), o({ | ||
return M(), o({ | ||
scene: r | ||
}), V( | ||
}), F( | ||
() => e.camera, | ||
(g) => { | ||
g && (d(), f(g)); | ||
(w) => { | ||
w && (m(), f(w)); | ||
} | ||
), () => D( | ||
D( | ||
), () => k( | ||
k( | ||
"div", | ||
@@ -524,3 +523,3 @@ { | ||
[ | ||
D( | ||
k( | ||
"div", | ||
@@ -534,3 +533,3 @@ { | ||
[ | ||
D("canvas", { | ||
k("canvas", { | ||
ref: n, | ||
@@ -553,3 +552,3 @@ "data-scene": r.uuid, | ||
} | ||
}), yt = he({ | ||
}), bt = he({ | ||
name: "TresCanvas", | ||
@@ -574,29 +573,29 @@ props: [ | ||
setup(e, { slots: t, expose: o }) { | ||
const a = dt(); | ||
return o(a), () => D(bt, e, t); | ||
const a = lt(); | ||
return o(a), () => k(wt, e, t); | ||
} | ||
}), Tt = { | ||
install(e) { | ||
e.component("TresCanvas", yt); | ||
e.component("TresCanvas", bt); | ||
} | ||
}; | ||
export { | ||
Ze as CameraType, | ||
Qe as CameraType, | ||
Q as TRES_CONTEXT_KEY, | ||
yt as TresCanvas, | ||
bt as TresCanvas, | ||
ye as catalogue, | ||
Tt as default, | ||
Me as extend, | ||
Pt as isProd, | ||
ft as trasverseObjects, | ||
Rt as isProd, | ||
ut as trasverseObjects, | ||
xe as useCamera, | ||
Ct as useLoader, | ||
B as useLogger, | ||
mt as useRaycaster, | ||
Et as useLoader, | ||
D as useLogger, | ||
dt as useRaycaster, | ||
Re as useRenderLoop, | ||
ct as useRenderer, | ||
Lt as useSeek, | ||
Rt as useTexture, | ||
O as useTres, | ||
dt as useTresProvider | ||
st as useRenderer, | ||
Pt as useSeek, | ||
Ct as useTexture, | ||
S as useTres, | ||
lt as useTresProvider | ||
}; |
@@ -58,3 +58,5 @@ import './tres-components'; | ||
export interface TresEvent extends Intersection<Object3D<Event>> { | ||
object: Object3D; | ||
object: Object3D & { | ||
events?: Record<string, any>; | ||
}; | ||
distance: number; | ||
@@ -64,2 +66,3 @@ faceIndex?: number | undefined; | ||
uv?: Vector2; | ||
events?: Record<string, any>; | ||
} |
{ | ||
"name": "@tresjs/core", | ||
"description": "Declarative ThreeJS using Vue Components", | ||
"version": "2.0.0-beta.13", | ||
"version": "2.0.0-rc.0", | ||
"type": "module", | ||
@@ -61,3 +61,3 @@ "packageManager": "pnpm@8.3.1", | ||
"@alvarosabu/utils": "^2.3.0", | ||
"@vueuse/core": "^9.13.0" | ||
"@vueuse/core": "^10.1.2" | ||
}, | ||
@@ -69,35 +69,35 @@ "devDependencies": { | ||
"@stackblitz/sdk": "^1.9.0", | ||
"@tresjs/cientos": "2.0.0-beta.4", | ||
"@tresjs/cientos": "2.0.0-beta.6", | ||
"@tresjs/core": "2.0.0-beta.11", | ||
"@types/three": "latest", | ||
"@typescript-eslint/eslint-plugin": "^5.58.0", | ||
"@typescript-eslint/parser": "^5.58.0", | ||
"@vitejs/plugin-vue": "^4.1.0", | ||
"@types/three": "^0.151.0", | ||
"@typescript-eslint/eslint-plugin": "^5.59.2", | ||
"@typescript-eslint/parser": "^5.59.2", | ||
"@vitejs/plugin-vue": "^4.2.1", | ||
"@vitest/coverage-c8": "^0.30.1", | ||
"@vitest/ui": "^0.30.0", | ||
"@vitest/ui": "^0.30.1", | ||
"@vue/test-utils": "^2.3.2", | ||
"eslint": "^8.38.0", | ||
"eslint": "^8.39.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-vue": "^9.11.0", | ||
"gsap": "^3.11.5", | ||
"happy-dom": "^9.6.1", | ||
"jsdom": "^21.1.1", | ||
"kolorist": "^1.7.0", | ||
"happy-dom": "^9.10.7", | ||
"jsdom": "^22.0.0", | ||
"kolorist": "^1.8.0", | ||
"pathe": "^1.1.0", | ||
"prettier": "^2.8.7", | ||
"release-it": "^15.10.1", | ||
"prettier": "^2.8.8", | ||
"release-it": "^15.10.3", | ||
"rollup-plugin-analyzer": "^4.0.0", | ||
"rollup-plugin-copy": "^3.4.0", | ||
"rollup-plugin-visualizer": "^5.9.0", | ||
"three": "^0.151.0", | ||
"unocss": "^0.51.4", | ||
"three": "^0.152.2", | ||
"unocss": "^0.51.8", | ||
"unplugin": "^1.3.1", | ||
"unplugin-vue-components": "^0.24.1", | ||
"vite": "^4.2.1", | ||
"vite": "^4.3.4", | ||
"vite-plugin-banner": "^0.7.0", | ||
"vite-plugin-dts": "2.3.0", | ||
"vite-plugin-inspect": "^0.7.22", | ||
"vite-plugin-inspect": "^0.7.24", | ||
"vite-plugin-require-transform": "^1.0.12", | ||
"vite-svg-loader": "^4.0.0", | ||
"vitepress": "1.0.0-alpha.65", | ||
"vitepress": "1.0.0-alpha.75", | ||
"vitest": "^0.30.1", | ||
@@ -104,0 +104,0 @@ "vue-demi": "^0.14.0" |
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
1592
83246
+ Added@types/web-bluetooth@0.0.20(transitive)
+ Added@vueuse/core@10.11.1(transitive)
+ Added@vueuse/metadata@10.11.1(transitive)
+ Added@vueuse/shared@10.11.1(transitive)
- Removed@types/web-bluetooth@0.0.16(transitive)
- Removed@vueuse/core@9.13.0(transitive)
- Removed@vueuse/metadata@9.13.0(transitive)
- Removed@vueuse/shared@9.13.0(transitive)
Updated@vueuse/core@^10.1.2