@tresjs/core
Advanced tools
Comparing version 3.6.0-next.0 to 3.6.0
@@ -33,2 +33,3 @@ import type { WebGLRendererParameters, ColorSpace, ShadowMapType, ToneMapping } from 'three'; | ||
context: Ref<TresContext | null> | import("vue").ShallowRef<TresContext | null>; | ||
dispose: () => void; | ||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<TresCanvasProps>, { | ||
@@ -35,0 +36,0 @@ alpha: undefined; |
428
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v3.6.0-next.0 | ||
* version: v3.6.0 | ||
* (c) 2023 | ||
@@ -8,19 +8,19 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { ref as S, computed as k, watchEffect as D, onUnmounted as $, shallowRef as L, watch as re, reactive as pe, readonly as ve, provide as V, inject as de, createRenderer as ge, defineComponent as q, useSlots as ye, getCurrentInstance as J, onMounted as we, openBlock as Ee, createElementBlock as _e, normalizeClass as Ce, normalizeStyle as Me, h as K, Fragment as he } from "vue"; | ||
import { ref as B, computed as b, watchEffect as D, onUnmounted as $, shallowRef as L, watch as re, reactive as pe, readonly as de, provide as V, inject as ve, createRenderer as ge, defineComponent as q, useSlots as ye, getCurrentInstance as J, onMounted as we, openBlock as Ee, createElementBlock as Ce, normalizeClass as _e, normalizeStyle as Me, h as K, Fragment as he } from "vue"; | ||
import * as Pe from "three"; | ||
import { PerspectiveCamera as G, OrthographicCamera as Ae, Camera as ke, Clock as be, Vector3 as De, Color as F, REVISION as Te, SRGBColorSpace as Le, ACESFilmicToneMapping as xe, PCFSoftShadowMap as Se, WebGLRenderer as I, LoadingManager as Be, TextureLoader as Oe, Vector2 as Re, Raycaster as He, BufferAttribute as Fe, Scene as je } from "three"; | ||
import { createEventHook as x, useRafFn as ne, toValue as h, unrefElement as ze, useDevicePixelRatio as $e, usePointer as Ne, useElementBounding as Ie, useWindowSize as Ve, useElementSize as Ge, useFps as We, useMemory as Ue } from "@vueuse/core"; | ||
import { PerspectiveCamera as G, OrthographicCamera as Ae, Camera as ke, Clock as be, Vector3 as De, Color as F, REVISION as Te, SRGBColorSpace as Le, ACESFilmicToneMapping as Se, PCFSoftShadowMap as Be, WebGLRenderer as I, LoadingManager as xe, TextureLoader as Oe, Vector2 as Re, Raycaster as He, BufferAttribute as Fe, Scene as je } from "three"; | ||
import { createEventHook as S, useRafFn as ne, toValue as M, unrefElement as ze, useDevicePixelRatio as $e, usePointer as Ne, useElementBounding as Ie, useWindowSize as Ve, useElementSize as Ge, useFps as We, useMemory as Ue } from "@vueuse/core"; | ||
const Ye = ({ sizes: e, scene: a }) => { | ||
const t = S([]), r = k( | ||
const t = B([]), r = b( | ||
() => t.value[0] | ||
), n = (s, c = !1) => { | ||
t.value.some(({ uuid: i }) => i === s.uuid) || (c ? l(s) : t.value.push(s)); | ||
), n = (s, l = !1) => { | ||
t.value.some(({ uuid: i }) => i === s.uuid) || (l ? c(s) : t.value.push(s)); | ||
}, o = (s) => { | ||
t.value = t.value.filter(({ uuid: c }) => c !== s.uuid); | ||
}, l = (s) => { | ||
const c = s instanceof ke ? s : t.value.find((p) => p.uuid === s); | ||
if (!c) | ||
t.value = t.value.filter(({ uuid: l }) => l !== s.uuid); | ||
}, c = (s) => { | ||
const l = s instanceof ke ? s : t.value.find((p) => p.uuid === s); | ||
if (!l) | ||
return; | ||
const i = t.value.filter(({ uuid: p }) => p !== c.uuid); | ||
t.value = [c, ...i]; | ||
const i = t.value.filter(({ uuid: p }) => p !== l.uuid); | ||
t.value = [l, ...i]; | ||
}; | ||
@@ -38,5 +38,5 @@ return D(() => { | ||
deregisterCamera: o, | ||
setCameraActive: l | ||
setCameraActive: c | ||
}; | ||
}, ae = x(), oe = x(), U = x(), T = new be(); | ||
}, ae = S(), oe = S(), U = S(), T = new be(); | ||
let j = 0, z = 0; | ||
@@ -60,3 +60,3 @@ const { pause: qe, resume: Je, isActive: Ke } = ne( | ||
}), Pt = !0, X = "[TresJS ▲ ■ ●] "; | ||
function B() { | ||
function x() { | ||
function e(r, n) { | ||
@@ -113,3 +113,3 @@ console.error(`${X} ${r}`, n || ""); | ||
const r = Array.isArray(a) ? a : a.match(/([^[.\]])+/g); | ||
r && r.reduce((n, o, l) => (n[o] === void 0 && (n[o] = {}), l === r.length - 1 && (n[o] = t), n[o]), e); | ||
r && r.reduce((n, o, c) => (n[o] === void 0 && (n[o] = {}), c === r.length - 1 && (n[o] = t), n[o]), e); | ||
}; | ||
@@ -119,3 +119,3 @@ function ue(e, a) { | ||
const n = e.attributes, o = a.attributes; | ||
return n.length !== o.length ? !1 : Array.from(n).every(({ name: l, value: s }) => a.getAttribute(l) === s); | ||
return n.length !== o.length ? !1 : Array.from(n).every(({ name: c, value: s }) => a.getAttribute(c) === s); | ||
} | ||
@@ -147,7 +147,7 @@ if (e === a) | ||
outputColorSpace: Le, | ||
toneMapping: xe, | ||
toneMapping: Se, | ||
toneMappingExposure: 3, | ||
shadowMap: { | ||
enabled: !0, | ||
type: Se | ||
type: Be | ||
} | ||
@@ -163,61 +163,61 @@ } | ||
}) { | ||
const l = k(() => ({ | ||
alpha: h(t.alpha), | ||
depth: h(t.depth), | ||
const c = b(() => ({ | ||
alpha: M(t.alpha), | ||
depth: M(t.depth), | ||
canvas: ze(a), | ||
context: h(t.context), | ||
stencil: h(t.stencil), | ||
antialias: h(t.antialias) === void 0 ? !0 : h(t.antialias), | ||
precision: h(t.precision), | ||
powerPreference: h(t.powerPreference), | ||
premultipliedAlpha: h(t.premultipliedAlpha), | ||
preserveDrawingBuffer: h(t.preserveDrawingBuffer), | ||
logarithmicDepthBuffer: h(t.logarithmicDepthBuffer), | ||
failIfMajorPerformanceCaveat: h(t.failIfMajorPerformanceCaveat) | ||
})), s = L(new I(l.value)); | ||
re(l, () => { | ||
s.value.dispose(), s.value = new I(l.value); | ||
context: M(t.context), | ||
stencil: M(t.stencil), | ||
antialias: M(t.antialias) === void 0 ? !0 : M(t.antialias), | ||
precision: M(t.precision), | ||
powerPreference: M(t.powerPreference), | ||
premultipliedAlpha: M(t.premultipliedAlpha), | ||
preserveDrawingBuffer: M(t.preserveDrawingBuffer), | ||
logarithmicDepthBuffer: M(t.logarithmicDepthBuffer), | ||
failIfMajorPerformanceCaveat: M(t.failIfMajorPerformanceCaveat) | ||
})), s = L(new I(c.value)); | ||
re(c, () => { | ||
s.value.dispose(), s.value = new I(c.value); | ||
}), D(() => { | ||
s.value.setSize(n.width.value, n.height.value); | ||
}); | ||
const { pixelRatio: c } = $e(); | ||
const { pixelRatio: l } = $e(); | ||
D(() => { | ||
s.value.setPixelRatio(c.value); | ||
s.value.setPixelRatio(l.value); | ||
}); | ||
const { logError: i } = B(), f = (() => { | ||
const d = new I(), C = { | ||
const { logError: i } = x(), f = (() => { | ||
const m = new I(), w = { | ||
shadowMap: { | ||
enabled: d.shadowMap.enabled, | ||
type: d.shadowMap.type | ||
enabled: m.shadowMap.enabled, | ||
type: m.shadowMap.type | ||
}, | ||
toneMapping: d.toneMapping, | ||
toneMappingExposure: d.toneMappingExposure, | ||
outputColorSpace: d.outputColorSpace | ||
toneMapping: m.toneMapping, | ||
toneMappingExposure: m.toneMappingExposure, | ||
outputColorSpace: m.outputColorSpace | ||
}; | ||
return d.dispose(), C; | ||
return m.dispose(), w; | ||
})(); | ||
D(() => { | ||
const d = h(t.preset); | ||
d && (d in H || i(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), ie(s.value, H[d])); | ||
const C = (E, _) => { | ||
const A = h(E), b = () => { | ||
if (d) | ||
return Z(H[d], _); | ||
const m = M(t.preset); | ||
m && (m in H || i(`Renderer Preset must be one of these: ${Object.keys(H).join(", ")}`), ie(s.value, H[m])); | ||
const w = (P, A) => { | ||
const C = M(P), k = () => { | ||
if (m) | ||
return Z(H[m], A); | ||
}; | ||
if (A !== void 0) | ||
return A; | ||
const g = b(); | ||
return g !== void 0 ? g : Z(f, _); | ||
}, w = (E, _) => rt(s.value, _, C(E, _)); | ||
w(t.shadows, "shadowMap.enabled"), w(t.toneMapping, "toneMapping"), w(t.shadowMapType, "shadowMap.type"), ot < 150 && w(!t.useLegacyLights, "physicallyCorrectLights"), w(t.outputColorSpace, "outputColorSpace"), w(t.toneMappingExposure, "toneMappingExposure"); | ||
const P = C(t.clearColor, "clearColor"); | ||
P && s.value.setClearColor( | ||
P ? Xe(P) : new F(0) | ||
if (C !== void 0) | ||
return C; | ||
const g = k(); | ||
return g !== void 0 ? g : Z(f, A); | ||
}, d = (P, A) => rt(s.value, A, w(P, A)); | ||
d(t.shadows, "shadowMap.enabled"), d(t.toneMapping, "toneMapping"), d(t.shadowMapType, "shadowMap.type"), ot < 150 && d(!t.useLegacyLights, "physicallyCorrectLights"), d(t.outputColorSpace, "outputColorSpace"), d(t.toneMappingExposure, "toneMappingExposure"); | ||
const h = w(t.clearColor, "clearColor"); | ||
h && s.value.setClearColor( | ||
h ? Xe(h) : new F(0) | ||
// default clear color is not easily/efficiently retrievable from three | ||
); | ||
}); | ||
const { pause: u, resume: m, onLoop: v } = se(); | ||
return v(() => { | ||
o.value && !h(r) && s.value.render(e, o.value); | ||
}), m(), $(() => { | ||
const { pause: u, resume: v, onLoop: E } = se(); | ||
return E(() => { | ||
o.value && !M(r) && s.value.render(e, o.value); | ||
}), v(), $(() => { | ||
u(), s.value.dispose(), s.value.forceContextLoss(); | ||
@@ -236,7 +236,7 @@ }), { | ||
async function kt(e, a, t, r, n) { | ||
const { logError: o } = B(), l = new e(); | ||
n && n(l), t && t(l); | ||
const c = (Array.isArray(a) ? a : [a]).map( | ||
const { logError: o } = x(), c = new e(); | ||
n && n(c), t && t(c); | ||
const l = (Array.isArray(a) ? a : [a]).map( | ||
(i) => new Promise((p, f) => { | ||
l.load( | ||
c.load( | ||
i, | ||
@@ -251,6 +251,6 @@ (u) => { | ||
); | ||
return it(a) ? await Promise.all(c) : await c[0]; | ||
return it(a) ? await Promise.all(l) : await l[0]; | ||
} | ||
async function bt(e) { | ||
const a = new Be(), t = new Oe(a), r = (n) => new Promise((o, l) => { | ||
const a = new xe(), t = new Oe(a), r = (n) => new Promise((o, c) => { | ||
t.load( | ||
@@ -261,3 +261,3 @@ n, | ||
() => { | ||
l(new Error("[useTextures] - Failed to load texture")); | ||
c(new Error("[useTextures] - Failed to load texture")); | ||
} | ||
@@ -273,5 +273,5 @@ ); | ||
displacementMap: o, | ||
normalMap: l, | ||
normalMap: c, | ||
roughnessMap: s, | ||
metalnessMap: c, | ||
metalnessMap: l, | ||
aoMap: i, | ||
@@ -284,5 +284,5 @@ alphaMap: p, | ||
displacementMap: o ? await r(o) : null, | ||
normalMap: l ? await r(l) : null, | ||
normalMap: c ? await r(c) : null, | ||
roughnessMap: s ? await r(s) : null, | ||
metalnessMap: c ? await r(c) : null, | ||
metalnessMap: l ? await r(l) : null, | ||
aoMap: i ? await r(i) : null, | ||
@@ -295,57 +295,57 @@ alphaMap: p ? await r(p) : null, | ||
const lt = (e, { renderer: a, camera: t, raycaster: r }) => { | ||
const n = k(() => a.value.domElement), { x: o, y: l } = Ne({ target: n }), { width: s, height: c, top: i, left: p } = Ie(n), f = ({ x: g, y: M }) => { | ||
const n = b(() => a.value.domElement), { x: o, y: c } = Ne({ target: n }), { width: s, height: l, top: i, left: p } = Ie(n), f = ({ x: g, y: _ }) => { | ||
if (n.value) | ||
return { | ||
x: (g - p.value) / s.value * 2 - 1, | ||
y: -((M - i.value) / c.value) * 2 + 1 | ||
y: -((_ - i.value) / l.value) * 2 + 1 | ||
}; | ||
}, u = ({ x: g, y: M }) => { | ||
}, u = ({ x: g, y: _ }) => { | ||
if (t.value) | ||
return r.value.setFromCamera(new Re(g, M), t.value), r.value.intersectObjects(e.value, !1); | ||
}, m = (g) => { | ||
const M = f({ | ||
return r.value.setFromCamera(new Re(g, _), t.value), r.value.intersectObjects(e.value, !1); | ||
}, v = (g) => { | ||
const _ = f({ | ||
x: (g == null ? void 0 : g.clientX) ?? o.value, | ||
y: (g == null ? void 0 : g.clientY) ?? l.value | ||
y: (g == null ? void 0 : g.clientY) ?? c.value | ||
}); | ||
return M ? u(M) || [] : []; | ||
}, v = k(() => m()), d = x(), C = x(), w = (g, M) => { | ||
g.trigger({ event: M, intersects: m(M) }); | ||
}, P = (g) => { | ||
w(C, g); | ||
return _ ? u(_) || [] : []; | ||
}, E = b(() => v()), m = S(), w = S(), d = (g, _) => { | ||
g.trigger({ event: _, intersects: v(_) }); | ||
}, h = (g) => { | ||
d(w, g); | ||
}; | ||
let E; | ||
const _ = (g) => { | ||
var M; | ||
E = (M = m(g)[0]) == null ? void 0 : M.object; | ||
}, A = (g) => { | ||
var M; | ||
g instanceof PointerEvent && E === ((M = m(g)[0]) == null ? void 0 : M.object) && w(d, g); | ||
}, b = (g) => C.trigger({ event: g, intersects: [] }); | ||
return n.value.addEventListener("pointerup", A), n.value.addEventListener("pointerdown", _), n.value.addEventListener("pointermove", P), n.value.addEventListener("pointerleave", b), $(() => { | ||
n != null && n.value && (n.value.removeEventListener("pointerup", A), n.value.removeEventListener("pointerdown", _), n.value.removeEventListener("pointermove", P), n.value.removeEventListener("pointerleave", b)); | ||
let P; | ||
const A = (g) => { | ||
var _; | ||
P = (_ = v(g)[0]) == null ? void 0 : _.object; | ||
}, C = (g) => { | ||
var _; | ||
g instanceof PointerEvent && P === ((_ = v(g)[0]) == null ? void 0 : _.object) && d(m, g); | ||
}, k = (g) => w.trigger({ event: g, intersects: [] }); | ||
return n.value.addEventListener("pointerup", C), n.value.addEventListener("pointerdown", A), n.value.addEventListener("pointermove", h), n.value.addEventListener("pointerleave", k), $(() => { | ||
n != null && n.value && (n.value.removeEventListener("pointerup", C), n.value.removeEventListener("pointerdown", A), n.value.removeEventListener("pointermove", h), n.value.removeEventListener("pointerleave", k)); | ||
}), { | ||
intersects: v, | ||
onClick: (g) => d.on(g).off, | ||
onPointerMove: (g) => C.on(g).off | ||
intersects: E, | ||
onClick: (g) => m.on(g).off, | ||
onPointerMove: (g) => w.on(g).off | ||
}; | ||
}; | ||
function Dt() { | ||
const { logWarning: e } = B(); | ||
function a(o, l, s) { | ||
let c = null; | ||
const { logWarning: e } = x(); | ||
function a(o, c, s) { | ||
let l = null; | ||
return o.traverse((i) => { | ||
i[l] === s && (c = i); | ||
}), c || e(`Child with ${l} '${s}' not found.`), c; | ||
i[c] === s && (l = i); | ||
}), l || e(`Child with ${c} '${s}' not found.`), l; | ||
} | ||
function t(o, l, s) { | ||
const c = []; | ||
function t(o, c, s) { | ||
const l = []; | ||
return o.traverse((i) => { | ||
i[l].includes(s) && c.push(i); | ||
}), c.length || e(`Children with ${l} '${s}' not found.`), c; | ||
i[c].includes(s) && l.push(i); | ||
}), l.length || e(`Children with ${c} '${s}' not found.`), l; | ||
} | ||
function r(o, l) { | ||
return a(o, "name", l); | ||
function r(o, c) { | ||
return a(o, "name", c); | ||
} | ||
function n(o, l) { | ||
return t(o, "name", l); | ||
function n(o, c) { | ||
return t(o, "name", c); | ||
} | ||
@@ -365,14 +365,14 @@ return { | ||
pointerLeave: /* @__PURE__ */ new Map() | ||
}), r = S(/* @__PURE__ */ new Set()), n = (u) => { | ||
}), r = B(/* @__PURE__ */ new Set()), n = (u) => { | ||
r.value.add(u); | ||
}, o = (u) => { | ||
r.value.delete(u); | ||
}, l = (u) => { | ||
Object.values(t).forEach((m) => m.delete(u)), o(u); | ||
}, c = (u) => { | ||
Object.values(t).forEach((v) => v.delete(u)), o(u); | ||
}, s = (u) => { | ||
const { onClick: m, onPointerMove: v, onPointerEnter: d, onPointerLeave: C } = u; | ||
m && t.click.set(u, m), v && t.pointerMove.set(u, v), d && t.pointerEnter.set(u, d), C && t.pointerLeave.set(u, C); | ||
const { onClick: v, onPointerMove: E, onPointerEnter: m, onPointerLeave: w } = u; | ||
v && t.click.set(u, v), E && t.pointerMove.set(u, E), m && t.pointerEnter.set(u, m), w && t.pointerLeave.set(u, w); | ||
}; | ||
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = l, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
const c = k( | ||
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = c, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
const l = b( | ||
() => tt( | ||
@@ -385,15 +385,15 @@ [ | ||
) | ||
), { onClick: i, onPointerMove: p } = lt(c, a); | ||
i(({ intersects: u, event: m }) => { | ||
var v; | ||
u.length && ((v = t.click.get(u[0].object)) == null || v(u[0], m)); | ||
), { onClick: i, onPointerMove: p } = lt(l, a); | ||
i(({ intersects: u, event: v }) => { | ||
var E; | ||
u.length && ((E = t.click.get(u[0].object)) == null || E(u[0], v)); | ||
}); | ||
let f; | ||
return p(({ intersects: u, event: m }) => { | ||
var P, E, _, A; | ||
const v = (P = u == null ? void 0 : u[0]) == null ? void 0 : P.object, { pointerLeave: d, pointerEnter: C, pointerMove: w } = t; | ||
f && f !== v && ((E = d.get(f)) == null || E(f, m)), v && (f !== v && ((_ = C.get(v)) == null || _(u[0], m)), (A = w.get(v)) == null || A(u[0], m)), f = v || null; | ||
return p(({ intersects: u, event: v }) => { | ||
var h, P, A, C; | ||
const E = (h = u == null ? void 0 : u[0]) == null ? void 0 : h.object, { pointerLeave: m, pointerEnter: w, pointerMove: d } = t; | ||
f && f !== E && ((P = m.get(f)) == null || P(f, v)), E && (f !== E && ((A = w.get(E)) == null || A(u[0], v)), (C = d.get(E)) == null || C(u[0], v)), f = E || null; | ||
}), { | ||
registerObject: s, | ||
deregisterObject: l | ||
deregisterObject: c | ||
}; | ||
@@ -405,8 +405,8 @@ }; | ||
if (t.isMesh && t.geometry) { | ||
const r = t.geometry, n = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, l = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, s = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, c = n + o + l + s; | ||
a += c; | ||
const r = t.geometry, n = r.attributes.position.count * 3 * Float32Array.BYTES_PER_ELEMENT, o = r.index ? r.index.count * Uint32Array.BYTES_PER_ELEMENT : 0, c = r.attributes.normal ? r.attributes.normal.count * 3 * Float32Array.BYTES_PER_ELEMENT : 0, s = r.attributes.uv ? r.attributes.uv.count * 2 * Float32Array.BYTES_PER_ELEMENT : 0, l = n + o + c + s; | ||
a += l; | ||
} | ||
}), a; | ||
} | ||
const W = S({}), Y = (e) => Object.assign(W.value, e); | ||
const W = B({}), Y = (e) => Object.assign(W.value, e); | ||
function mt({ | ||
@@ -419,15 +419,15 @@ scene: e, | ||
}) { | ||
const o = k( | ||
() => h(t) ? Ve() : Ge(h(a).parentElement) | ||
), l = k(() => o.value.width.value), s = k(() => o.value.height.value), c = k(() => l.value / s.value), i = { | ||
const o = b( | ||
() => M(t) ? Ve() : Ge(M(a).parentElement) | ||
), c = b(() => o.value.width.value), s = b(() => o.value.height.value), l = b(() => c.value / s.value), i = { | ||
height: s, | ||
width: l, | ||
aspectRatio: c | ||
width: c, | ||
aspectRatio: l | ||
}, p = L(e), { | ||
camera: f, | ||
cameras: u, | ||
registerCamera: m, | ||
deregisterCamera: v, | ||
setCameraActive: d | ||
} = Ye({ sizes: i, scene: e }), { renderer: C } = st( | ||
registerCamera: v, | ||
deregisterCamera: E, | ||
setCameraActive: m | ||
} = Ye({ sizes: i, scene: e }), { renderer: w } = st( | ||
{ | ||
@@ -440,10 +440,10 @@ scene: e, | ||
} | ||
), w = { | ||
), d = { | ||
sizes: i, | ||
scene: p, | ||
camera: f, | ||
cameras: ve(u), | ||
renderer: C, | ||
cameras: de(u), | ||
renderer: w, | ||
raycaster: L(new He()), | ||
controls: S(null), | ||
controls: B(null), | ||
perf: { | ||
@@ -462,22 +462,22 @@ maxFrames: 160, | ||
extend: Y, | ||
registerCamera: m, | ||
setCameraActive: d, | ||
deregisterCamera: v | ||
registerCamera: v, | ||
setCameraActive: m, | ||
deregisterCamera: E | ||
}; | ||
V("useTres", w); | ||
const P = 100, E = We({ every: P }), { isSupported: _, memory: A } = Ue({ interval: P }), b = 160; | ||
V("useTres", d); | ||
const h = 100, P = We({ every: h }), { isSupported: A, memory: C } = Ue({ interval: h }), k = 160; | ||
let g = performance.now(); | ||
const M = ({ timestamp: O }) => { | ||
w.scene.value && (w.perf.memory.allocatedMem = ft(w.scene.value)), O - g >= P && (g = O, w.perf.fps.accumulator.push(E.value), w.perf.fps.accumulator.length > b && w.perf.fps.accumulator.shift(), w.perf.fps.value = E.value, _.value && A.value && (w.perf.memory.accumulator.push(A.value.usedJSHeapSize / 1024 / 1024), w.perf.memory.accumulator.length > b && w.perf.memory.accumulator.shift(), w.perf.memory.currentMem = w.perf.memory.accumulator.reduce((fe, me) => fe + me, 0) / w.perf.memory.accumulator.length)); | ||
const _ = ({ timestamp: O }) => { | ||
d.scene.value && (d.perf.memory.allocatedMem = ft(d.scene.value)), O - g >= h && (g = O, d.perf.fps.accumulator.push(P.value), d.perf.fps.accumulator.length > k && d.perf.fps.accumulator.shift(), d.perf.fps.value = P.value, A.value && C.value && (d.perf.memory.accumulator.push(C.value.usedJSHeapSize / 1024 / 1024), d.perf.memory.accumulator.length > k && d.perf.memory.accumulator.shift(), d.perf.memory.currentMem = d.perf.memory.accumulator.reduce((fe, me) => fe + me, 0) / d.perf.memory.accumulator.length)); | ||
}; | ||
let N = 0; | ||
const le = 1, { pause: ce, resume: _t } = ne(({ delta: O }) => { | ||
window.__TRES__DEVTOOLS__ && (M({ timestamp: performance.now() }), N += O, N >= le && (window.__TRES__DEVTOOLS__.cb(w), N = 0)); | ||
const le = 1, { pause: ce, resume: Ct } = ne(({ delta: O }) => { | ||
window.__TRES__DEVTOOLS__ && (_({ timestamp: performance.now() }), N += O, N >= le && (window.__TRES__DEVTOOLS__.cb(d), N = 0)); | ||
}, { immediate: !0 }); | ||
return $(() => { | ||
ce(); | ||
}), w; | ||
}), d; | ||
} | ||
function pt() { | ||
const e = de("useTres"); | ||
const e = ve("useTres"); | ||
if (!e) | ||
@@ -489,5 +489,5 @@ throw new Error("useTresContext must be used together with useTresContextProvider"); | ||
let y = null; | ||
const { logError: te } = B(), vt = { | ||
const { logError: te } = x(), dt = { | ||
createElement(e, a, t, r) { | ||
var l, s; | ||
var c, s; | ||
if (r || (r = {}), r.args || (r.args = []), e === "template" || Ze(e)) | ||
@@ -498,9 +498,9 @@ return null; | ||
(r == null ? void 0 : r.object) === void 0 && te("Tres primitives need a prop 'object'"); | ||
const c = r.object; | ||
n = c.type, o = Object.assign(c, { type: n, attach: r.attach, primitive: !0 }); | ||
const l = r.object; | ||
n = l.type, o = Object.assign(l, { type: n, attach: r.attach, primitive: !0 }); | ||
} else { | ||
const c = W.value[n]; | ||
c || te(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new c(...r.args); | ||
const l = W.value[n]; | ||
l || te(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new l(...r.args); | ||
} | ||
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((l = r == null ? void 0 : r.material) != null && l.isMaterial && (o.userData.tres__materialViaProp = !0), (s = r == null ? void 0 : r.geometry) != null && s.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = { | ||
return o.isCamera && (r != null && r.position || o.position.set(3, 3, 3), r != null && r.lookAt || o.lookAt(0, 0, 0)), (r == null ? void 0 : r.attach) === void 0 && (o.isMaterial ? o.attach = "material" : o.isBufferGeometry && (o.attach = "geometry")), o.isObject3D && ((c = r == null ? void 0 : r.material) != null && c.isMaterial && (o.userData.tres__materialViaProp = !0), (s = r == null ? void 0 : r.geometry) != null && s.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = { | ||
...o.userData, | ||
@@ -511,3 +511,3 @@ tres__name: n | ||
insert(e, a) { | ||
var r, n, o, l; | ||
var r, n, o, c; | ||
a && a.isScene && (y = a); | ||
@@ -524,3 +524,3 @@ const t = a || y; | ||
throw "could not find tres__registerAtPointerEventHandler on scene's userData"; | ||
(l = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || l.call(o, e); | ||
(c = y == null ? void 0 : (o = y.userData).tres__registerAtPointerEventHandler) == null || c.call(o, e); | ||
} | ||
@@ -537,6 +537,6 @@ } | ||
const p = i; | ||
i.userData.tres__materialViaProp || (f = p.material) == null || f.dispose(), i.userData.tres__geometryViaProp || (u = p.geometry) == null || u.dispose(); | ||
}, o = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, l = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => { | ||
i.userData.tres__materialViaProp || ((f = p.material) == null || f.dispose(), p.material = void 0), i.userData.tres__geometryViaProp || ((u = p.geometry) == null || u.dispose(), p.geometry = void 0); | ||
}, o = y == null ? void 0 : y.userData.tres__deregisterAtPointerEventHandler, c = y == null ? void 0 : y.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => { | ||
var p, f; | ||
if (!l) | ||
if (!c) | ||
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData"; | ||
@@ -546,3 +546,3 @@ if ((f = y == null ? void 0 : (p = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(p, i), !o) | ||
(i != null && i.onClick || i != null && i.onPointerMove || i != null && i.onPointerEnter || i != null && i.onPointerLeave) && (o == null || o(i)); | ||
}, c = (i) => { | ||
}, l = (i) => { | ||
const p = y == null ? void 0 : y.userData.tres__deregisterCamera; | ||
@@ -553,27 +553,27 @@ if (!p) | ||
}; | ||
r.traverse((i) => { | ||
n(i), c(i), s == null || s(i); | ||
}), n(r), c(r), s == null || s(r); | ||
(a = e.removeFromParent) == null || a.call(e), r.traverse((i) => { | ||
n(i), l(i), s == null || s(i); | ||
}), n(r), l(r), s == null || s(r); | ||
} | ||
(a = e.removeFromParent) == null || a.call(e), (t = e.dispose) == null || t.call(e); | ||
(t = e.dispose) == null || t.call(e); | ||
} | ||
}, | ||
patchProp(e, a, t, r) { | ||
var n, o, l, s; | ||
var n, o, c, s; | ||
if (e) { | ||
let c = e, i = a; | ||
let l = e, i = a; | ||
if (e.isObject3D && i === "blocks-pointer-events") { | ||
r || r === "" ? (o = y == null ? void 0 : (n = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = y == null ? void 0 : (l = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(l, e); | ||
r || r === "" ? (o = y == null ? void 0 : (n = y.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = y == null ? void 0 : (c = y.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(c, e); | ||
return; | ||
} | ||
let p = R(i), f = c == null ? void 0 : c[p]; | ||
let p = R(i), f = l == null ? void 0 : l[p]; | ||
if (i === "args") { | ||
const m = e, v = t ?? [], d = r ?? [], C = e.userData.tres__name || e.type; | ||
C && v.length && !nt(v, d) && (c = Object.assign(m, new W.value[C](...r))); | ||
const v = e, E = t ?? [], m = r ?? [], w = e.userData.tres__name || e.type; | ||
w && E.length && !nt(E, m) && (l = Object.assign(v, new W.value[w](...r))); | ||
return; | ||
} | ||
if (c.type === "BufferGeometry") { | ||
if (l.type === "BufferGeometry") { | ||
if (i === "args") | ||
return; | ||
c.setAttribute( | ||
l.setAttribute( | ||
R(i), | ||
@@ -585,4 +585,4 @@ new Fe(...r) | ||
if (i.includes("-") && f === void 0) { | ||
const m = i.split("-"); | ||
f = m.reduce((v, d) => v[R(d)], c), i = m.pop(), p = i.toLowerCase(), f != null && f.set || (c = m.reduce((v, d) => v[R(d)], c)); | ||
const v = i.split("-"); | ||
f = v.reduce((E, m) => E[R(m)], l), i = v.pop(), p = i.toLowerCase(), f != null && f.set || (l = v.reduce((E, m) => E[R(m)], l)); | ||
} | ||
@@ -594,3 +594,3 @@ let u = r; | ||
} | ||
!(f != null && f.set) && !ee(f) ? c[p] = u : f.constructor === u.constructor && (f != null && f.copy) ? f == null || f.copy(u) : Array.isArray(u) ? f.set(...u) : !f.isColor && f.setScalar ? f.setScalar(u) : f.set(u); | ||
!(f != null && f.set) && !ee(f) ? l[p] = u : f.constructor === u.constructor && (f != null && f.copy) ? f == null || f.copy(u) : Array.isArray(u) ? f.set(...u) : !f.isColor && f.setScalar ? f.setScalar(u) : f.set(u); | ||
} | ||
@@ -610,3 +610,3 @@ }, | ||
insertStaticContent: () => void 0 | ||
}, { render: dt } = ge(vt); | ||
}, { render: vt } = ge(dt); | ||
Y(Pe); | ||
@@ -640,28 +640,28 @@ const gt = ["data-scene"], yt = /* @__PURE__ */ q({ | ||
setup(e, { expose: a }) { | ||
var u; | ||
const t = e, { logWarning: r } = B(), n = S(), o = L(new je()); | ||
se(); | ||
const l = ye(), s = (u = J()) == null ? void 0 : u.appContext.app, c = (m) => q({ | ||
var E; | ||
const t = e, { logWarning: r } = x(), n = B(), o = L(new je()), { resume: c } = se(), s = ye(), l = (E = J()) == null ? void 0 : E.appContext.app, i = (m) => q({ | ||
setup() { | ||
var d; | ||
const v = (d = J()) == null ? void 0 : d.appContext; | ||
return v && (v.app = s), V("useTres", m), V("extend", Y), () => K(he, null, l != null && l.default ? l.default() : []); | ||
const w = (d = J()) == null ? void 0 : d.appContext; | ||
return w && (w.app = l), V("useTres", m), V("extend", Y), () => K(he, null, s != null && s.default ? s.default() : []); | ||
} | ||
}), i = (m) => { | ||
const v = c(m); | ||
dt(K(v), o.value); | ||
}, p = k(() => t.disableRender), f = L(null); | ||
return a({ context: f }), we(() => { | ||
}), p = (m) => { | ||
const w = i(m); | ||
vt(K(w), o.value); | ||
}, f = (m, w = !1) => { | ||
o.value.children = [], w && (m.renderer.value.dispose(), m.renderer.value.renderLists.dispose(), m.renderer.value.forceContextLoss()), p(m), c(); | ||
}, u = b(() => t.disableRender), v = L(null); | ||
return a({ context: v, dispose: () => f(v.value, !0) }), we(() => { | ||
const m = n; | ||
f.value = mt({ | ||
v.value = mt({ | ||
scene: o.value, | ||
canvas: m, | ||
windowSize: t.windowSize, | ||
disableRender: p, | ||
disableRender: u, | ||
rendererOptions: t | ||
}), ct({ scene: o.value, contextParts: f.value }); | ||
const { registerCamera: v, camera: d, cameras: C, deregisterCamera: w } = f.value; | ||
i(f.value); | ||
const P = () => { | ||
const E = new G( | ||
}), ct({ scene: o.value, contextParts: v.value }); | ||
const { registerCamera: w, camera: d, cameras: h, deregisterCamera: P } = v.value; | ||
p(v.value); | ||
const A = () => { | ||
const C = new G( | ||
45, | ||
@@ -672,5 +672,5 @@ window.innerWidth / window.innerHeight, | ||
); | ||
E.position.set(3, 3, 3), E.lookAt(0, 0, 0), v(E); | ||
const _ = D(() => { | ||
C.value.length >= 2 && (E.removeFromParent(), w(E), _ == null || _()); | ||
C.position.set(3, 3, 3), C.lookAt(0, 0, 0), w(C); | ||
const k = D(() => { | ||
h.value.length >= 2 && (C.removeFromParent(), P(C), k == null || k()); | ||
}); | ||
@@ -680,4 +680,4 @@ }; | ||
() => t.camera, | ||
(E, _) => { | ||
E && v(E), _ && (_.removeFromParent(), w(_)); | ||
(C, k) => { | ||
C && w(C), k && (k.removeFromParent(), P(k)); | ||
}, | ||
@@ -689,8 +689,8 @@ { | ||
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene." | ||
), P()); | ||
}), (m, v) => (Ee(), _e("canvas", { | ||
), A()); | ||
}), (m, w) => (Ee(), Ce("canvas", { | ||
ref_key: "canvas", | ||
ref: n, | ||
"data-scene": o.value.uuid, | ||
class: Ce(m.$attrs.class), | ||
class: _e(m.$attrs.class), | ||
style: Me({ | ||
@@ -719,3 +719,3 @@ display: "block", | ||
} | ||
}, Lt = Et, xt = { | ||
}, Lt = Et, St = { | ||
install(e) { | ||
@@ -728,3 +728,3 @@ e.component("TresCanvas", yt); | ||
W as catalogue, | ||
xt as default, | ||
St as default, | ||
Y as extend, | ||
@@ -738,3 +738,3 @@ Pt as isProd, | ||
kt as useLoader, | ||
B as useLogger, | ||
x as useLogger, | ||
ct as usePointerEventHandler, | ||
@@ -741,0 +741,0 @@ lt as useRaycaster, |
{ | ||
"name": "@tresjs/core", | ||
"type": "module", | ||
"version": "3.6.0-next.0", | ||
"version": "3.6.0", | ||
"packageManager": "pnpm@8.10.2", | ||
@@ -69,3 +69,3 @@ "description": "Declarative ThreeJS using Vue Components", | ||
"@alvarosabu/utils": "^3.1.1", | ||
"@vueuse/core": "^10.5.0" | ||
"@vueuse/core": "^10.7.0" | ||
}, | ||
@@ -77,36 +77,36 @@ "devDependencies": { | ||
"@tresjs/eslint-config-vue": "^0.2.1", | ||
"@types/three": "^0.158.3", | ||
"@typescript-eslint/eslint-plugin": "^6.13.0", | ||
"@typescript-eslint/parser": "^6.13.0", | ||
"@vitejs/plugin-vue": "^4.5.0", | ||
"@types/three": "^0.159.0", | ||
"@typescript-eslint/eslint-plugin": "^6.14.0", | ||
"@typescript-eslint/parser": "^6.14.0", | ||
"@vitejs/plugin-vue": "^4.5.2", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"@vitest/ui": "^0.34.6", | ||
"@vue/test-utils": "^2.4.2", | ||
"eslint": "^8.54.0", | ||
"eslint-plugin-vue": "^9.18.1", | ||
"@vitest/ui": "^1.0.4", | ||
"@vue/test-utils": "^2.4.3", | ||
"eslint": "^8.55.0", | ||
"eslint-plugin-vue": "^9.19.2", | ||
"esno": "^4.0.0", | ||
"gsap": "^3.12.2", | ||
"jsdom": "^23.0.0", | ||
"gsap": "^3.12.3", | ||
"jsdom": "^23.0.1", | ||
"kolorist": "^1.8.0", | ||
"ohmyfetch": "^0.4.21", | ||
"pathe": "^1.1.1", | ||
"release-it": "^17.0.0", | ||
"release-it": "^17.0.1", | ||
"rollup-plugin-analyzer": "^4.0.0", | ||
"rollup-plugin-copy": "^3.5.0", | ||
"rollup-plugin-visualizer": "^5.9.3", | ||
"three": "^0.158.0", | ||
"unocss": "^0.57.7", | ||
"rollup-plugin-visualizer": "^5.11.0", | ||
"three": "^0.159.0", | ||
"unocss": "^0.58.0", | ||
"unplugin": "^1.5.1", | ||
"unplugin-vue-components": "^0.25.2", | ||
"vite": "^5.0.2", | ||
"unplugin-vue-components": "^0.26.0", | ||
"vite": "^5.0.8", | ||
"vite-plugin-banner": "^0.7.1", | ||
"vite-plugin-dts": "3.6.3", | ||
"vite-plugin-inspect": "^0.8.0", | ||
"vite-plugin-dts": "3.6.4", | ||
"vite-plugin-inspect": "^0.8.1", | ||
"vite-plugin-require-transform": "^1.0.21", | ||
"vite-svg-loader": "^5.1.0", | ||
"vitepress": "1.0.0-rc.31", | ||
"vitest": "^0.34.6", | ||
"vue": "^3.3.9", | ||
"vitest": "^1.0.4", | ||
"vue": "^3.3.11", | ||
"vue-demi": "^0.14.6" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
419304
5886
2
Updated@vueuse/core@^10.7.0