@tresjs/core
Advanced tools
Comparing version 3.5.1 to 3.5.2
@@ -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; |
454
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v3.5.1 | ||
* version: v3.5.2 | ||
* (c) 2023 | ||
@@ -8,21 +8,21 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { ref as L, computed as A, watchEffect as D, onUnmounted as N, shallowRef as x, watch as ee, reactive as se, readonly as ie, provide as z, inject as le, createRenderer as ue, defineComponent as q, useSlots as ce, getCurrentInstance as U, onMounted as fe, openBlock as pe, createElementBlock as me, normalizeClass as de, normalizeStyle as ve, h as J, Fragment as ge } from "vue"; | ||
import { ref as O, computed as D, watchEffect as b, onUnmounted as N, shallowRef as B, watch as ee, reactive as se, readonly as ie, provide as z, inject as le, createRenderer as ue, defineComponent as q, useSlots as ce, getCurrentInstance as U, onMounted as fe, openBlock as pe, createElementBlock as me, normalizeClass as de, normalizeStyle as ve, h as J, Fragment as ge } from "vue"; | ||
import * as ye from "three"; | ||
import { PerspectiveCamera as I, OrthographicCamera as we, Camera as Ce, Clock as Pe, Vector3 as he, Color as H, REVISION as Ee, SRGBColorSpace as _e, ACESFilmicToneMapping as Me, PCFSoftShadowMap as Ae, WebGLRenderer as $, LoadingManager as ke, TextureLoader as De, Vector2 as be, Raycaster as xe, BufferAttribute as Be, Scene as Le } from "three"; | ||
import { createEventHook as B, useRafFn as Oe, toValue as E, unrefElement as Te, useDevicePixelRatio as Se, usePointer as Re, useElementBounding as He, useWindowSize as je, useElementSize as Fe } from "@vueuse/core"; | ||
import { PerspectiveCamera as I, OrthographicCamera as we, Camera as Ce, Clock as Pe, Vector3 as he, Color as H, REVISION as Ee, SRGBColorSpace as _e, ACESFilmicToneMapping as Me, PCFSoftShadowMap as Ae, WebGLRenderer as $, LoadingManager as ke, TextureLoader as De, Vector2 as be, Raycaster as Le, BufferAttribute as Be, Scene as xe } from "three"; | ||
import { createEventHook as x, useRafFn as Oe, toValue as h, unrefElement as Te, useDevicePixelRatio as Se, usePointer as Re, useElementBounding as He, useWindowSize as je, useElementSize as Fe } from "@vueuse/core"; | ||
const $e = ({ sizes: e, scene: a }) => { | ||
const t = L([]), r = A( | ||
const t = O([]), r = D( | ||
() => t.value[0] | ||
), n = (s, f = !1) => { | ||
t.value.some(({ uuid: i }) => i === s.uuid) || (f ? u(s) : t.value.push(s)); | ||
), n = (s, u = !1) => { | ||
t.value.some(({ uuid: i }) => i === s.uuid) || (u ? c(s) : t.value.push(s)); | ||
}, o = (s) => { | ||
t.value = t.value.filter(({ uuid: f }) => f !== s.uuid); | ||
}, u = (s) => { | ||
const f = s instanceof Ce ? s : t.value.find((m) => m.uuid === s); | ||
if (!f) | ||
t.value = t.value.filter(({ uuid: u }) => u !== s.uuid); | ||
}, c = (s) => { | ||
const u = s instanceof Ce ? s : t.value.find((m) => m.uuid === s); | ||
if (!u) | ||
return; | ||
const i = t.value.filter(({ uuid: m }) => m !== f.uuid); | ||
t.value = [f, ...i]; | ||
const i = t.value.filter(({ uuid: m }) => m !== u.uuid); | ||
t.value = [u, ...i]; | ||
}; | ||
return D(() => { | ||
return b(() => { | ||
e.aspectRatio.value && t.value.forEach((s) => { | ||
@@ -38,9 +38,9 @@ s instanceof I && (s.aspect = e.aspectRatio.value), (s instanceof I || s instanceof we) && s.updateProjectionMatrix(); | ||
deregisterCamera: o, | ||
setCameraActive: u | ||
setCameraActive: c | ||
}; | ||
}, te = B(), re = B(), W = B(), b = new Pe(); | ||
}, te = x(), re = x(), W = x(), L = new Pe(); | ||
let j = 0, F = 0; | ||
const { pause: ze, resume: Ie, isActive: Ge } = Oe( | ||
() => { | ||
te.trigger({ delta: j, elapsed: F, clock: b }), re.trigger({ delta: j, elapsed: F, clock: b }), W.trigger({ delta: j, elapsed: F, clock: b }); | ||
te.trigger({ delta: j, elapsed: F, clock: L }), re.trigger({ delta: j, elapsed: F, clock: L }), W.trigger({ delta: j, elapsed: F, clock: L }); | ||
}, | ||
@@ -50,3 +50,3 @@ { immediate: !1 } | ||
W.on(() => { | ||
j = b.getDelta(), F = b.getElapsedTime(); | ||
j = L.getDelta(), F = L.getElapsedTime(); | ||
}); | ||
@@ -61,3 +61,3 @@ const ne = () => ({ | ||
}), dt = !0, K = "[TresJS ▲ ■ ●] "; | ||
function O() { | ||
function T() { | ||
function e(r, n) { | ||
@@ -114,3 +114,3 @@ console.error(`${K} ${r}`, n || ""); | ||
const r = Array.isArray(a) ? a : a.match(/([^[.\]])+/g); | ||
r && r.reduce((n, o, u) => (n[o] === void 0 && (n[o] = {}), u === 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); | ||
}; | ||
@@ -120,3 +120,3 @@ function oe(e, a) { | ||
const n = e.attributes, o = a.attributes; | ||
return n.length !== o.length ? !1 : Array.from(n).every(({ name: u, value: s }) => a.getAttribute(u) === s); | ||
return n.length !== o.length ? !1 : Array.from(n).every(({ name: c, value: s }) => a.getAttribute(c) === s); | ||
} | ||
@@ -163,61 +163,61 @@ if (e === a) | ||
}) { | ||
const u = A(() => ({ | ||
alpha: E(t.alpha), | ||
depth: E(t.depth), | ||
const c = D(() => ({ | ||
alpha: h(t.alpha), | ||
depth: h(t.depth), | ||
canvas: Te(a), | ||
context: E(t.context), | ||
stencil: E(t.stencil), | ||
antialias: E(t.antialias) === void 0 ? !0 : E(t.antialias), | ||
precision: E(t.precision), | ||
powerPreference: E(t.powerPreference), | ||
premultipliedAlpha: E(t.premultipliedAlpha), | ||
preserveDrawingBuffer: E(t.preserveDrawingBuffer), | ||
logarithmicDepthBuffer: E(t.logarithmicDepthBuffer), | ||
failIfMajorPerformanceCaveat: E(t.failIfMajorPerformanceCaveat) | ||
})), s = x(new $(u.value)); | ||
ee(u, () => { | ||
s.value.dispose(), s.value = new $(u.value); | ||
}), D(() => { | ||
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 = B(new $(c.value)); | ||
ee(c, () => { | ||
s.value.dispose(), s.value = new $(c.value); | ||
}), b(() => { | ||
s.value.setSize(n.width.value, n.height.value); | ||
}); | ||
const { pixelRatio: f } = Se(); | ||
D(() => { | ||
s.value.setPixelRatio(f.value); | ||
const { pixelRatio: u } = Se(); | ||
b(() => { | ||
s.value.setPixelRatio(u.value); | ||
}); | ||
const { logError: i } = O(), c = (() => { | ||
const v = new $(), w = { | ||
const { logError: i } = T(), f = (() => { | ||
const p = new $(), g = { | ||
shadowMap: { | ||
enabled: v.shadowMap.enabled, | ||
type: v.shadowMap.type | ||
enabled: p.shadowMap.enabled, | ||
type: p.shadowMap.type | ||
}, | ||
toneMapping: v.toneMapping, | ||
toneMappingExposure: v.toneMappingExposure, | ||
outputColorSpace: v.outputColorSpace | ||
toneMapping: p.toneMapping, | ||
toneMappingExposure: p.toneMappingExposure, | ||
outputColorSpace: p.outputColorSpace | ||
}; | ||
return v.dispose(), w; | ||
return p.dispose(), g; | ||
})(); | ||
D(() => { | ||
const v = E(t.preset); | ||
v && (v in R || i(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), ae(s.value, R[v])); | ||
const w = (P, C) => { | ||
const k = E(P), T = () => { | ||
if (v) | ||
return Y(R[v], C); | ||
b(() => { | ||
const p = h(t.preset); | ||
p && (p in R || i(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), ae(s.value, R[p])); | ||
const g = (M, _) => { | ||
const P = h(M), A = () => { | ||
if (p) | ||
return Y(R[p], _); | ||
}; | ||
if (k !== void 0) | ||
return k; | ||
const y = T(); | ||
return y !== void 0 ? y : Y(c, C); | ||
}, h = (P, C) => Je(s.value, C, w(P, C)); | ||
h(t.shadows, "shadowMap.enabled"), h(t.toneMapping, "toneMapping"), h(t.shadowMapType, "shadowMap.type"), Ye < 150 && h(!t.useLegacyLights, "physicallyCorrectLights"), h(t.outputColorSpace, "outputColorSpace"), h(t.toneMappingExposure, "toneMappingExposure"); | ||
const M = w(t.clearColor, "clearColor"); | ||
M && s.value.setClearColor( | ||
M ? Ne(M) : new H(0) | ||
if (P !== void 0) | ||
return P; | ||
const y = A(); | ||
return y !== void 0 ? y : Y(f, _); | ||
}, C = (M, _) => Je(s.value, _, g(M, _)); | ||
C(t.shadows, "shadowMap.enabled"), C(t.toneMapping, "toneMapping"), C(t.shadowMapType, "shadowMap.type"), Ye < 150 && C(!t.useLegacyLights, "physicallyCorrectLights"), C(t.outputColorSpace, "outputColorSpace"), C(t.toneMappingExposure, "toneMappingExposure"); | ||
const k = g(t.clearColor, "clearColor"); | ||
k && s.value.setClearColor( | ||
k ? Ne(k) : new H(0) | ||
// default clear color is not easily/efficiently retrievable from three | ||
); | ||
}); | ||
const { pause: l, resume: p, onLoop: d } = ne(); | ||
return d(() => { | ||
o.value && !E(r) && s.value.render(e, o.value); | ||
}), p(), N(() => { | ||
const { pause: l, resume: d, onLoop: w } = ne(); | ||
return w(() => { | ||
o.value && !h(r) && s.value.render(e, o.value); | ||
}), d(), N(() => { | ||
l(), s.value.dispose(), s.value.forceContextLoss(); | ||
@@ -236,7 +236,7 @@ }), { | ||
async function gt(e, a, t, r, n) { | ||
const { logError: o } = O(), u = new e(); | ||
n && n(u), t && t(u); | ||
const f = (Array.isArray(a) ? a : [a]).map( | ||
(i) => new Promise((m, c) => { | ||
u.load( | ||
const { logError: o } = T(), c = new e(); | ||
n && n(c), t && t(c); | ||
const u = (Array.isArray(a) ? a : [a]).map( | ||
(i) => new Promise((m, f) => { | ||
c.load( | ||
i, | ||
@@ -247,10 +247,10 @@ (l) => { | ||
r, | ||
(l) => c(o("[useLoader] - Failed to load resource", l)) | ||
(l) => f(o("[useLoader] - Failed to load resource", l)) | ||
); | ||
}) | ||
); | ||
return Ze(a) ? await Promise.all(f) : await f[0]; | ||
return Ze(a) ? await Promise.all(u) : await u[0]; | ||
} | ||
async function yt(e) { | ||
const a = new ke(), t = new De(a), r = (n) => new Promise((o, u) => { | ||
const a = new ke(), t = new De(a), r = (n) => new Promise((o, c) => { | ||
t.load( | ||
@@ -261,3 +261,3 @@ n, | ||
() => { | ||
u(new Error("[useTextures] - Failed to load texture")); | ||
c(new Error("[useTextures] - Failed to load texture")); | ||
} | ||
@@ -273,8 +273,8 @@ ); | ||
displacementMap: o, | ||
normalMap: u, | ||
normalMap: c, | ||
roughnessMap: s, | ||
metalnessMap: f, | ||
metalnessMap: u, | ||
aoMap: i, | ||
alphaMap: m, | ||
matcap: c | ||
matcap: f | ||
} = e; | ||
@@ -284,8 +284,8 @@ return { | ||
displacementMap: o ? await r(o) : null, | ||
normalMap: u ? await r(u) : null, | ||
normalMap: c ? await r(c) : null, | ||
roughnessMap: s ? await r(s) : null, | ||
metalnessMap: f ? await r(f) : null, | ||
metalnessMap: u ? await r(u) : null, | ||
aoMap: i ? await r(i) : null, | ||
alphaMap: m ? await r(m) : null, | ||
matcap: c ? await r(c) : null | ||
matcap: f ? await r(f) : null | ||
}; | ||
@@ -295,57 +295,57 @@ } | ||
const tt = (e, { renderer: a, camera: t, raycaster: r }) => { | ||
const n = A(() => a.value.domElement), { x: o, y: u } = Re({ target: n }), { width: s, height: f, top: i, left: m } = He(n), c = ({ x: y, y: _ }) => { | ||
const n = D(() => a.value.domElement), { x: o, y: c } = Re({ target: n }), { width: s, height: u, top: i, left: m } = He(n), f = ({ x: y, y: E }) => { | ||
if (n.value) | ||
return { | ||
x: (y - m.value) / s.value * 2 - 1, | ||
y: -((_ - i.value) / f.value) * 2 + 1 | ||
y: -((E - i.value) / u.value) * 2 + 1 | ||
}; | ||
}, l = ({ x: y, y: _ }) => { | ||
}, l = ({ x: y, y: E }) => { | ||
if (t.value) | ||
return r.value.setFromCamera(new be(y, _), t.value), r.value.intersectObjects(e.value, !1); | ||
}, p = (y) => { | ||
const _ = c({ | ||
return r.value.setFromCamera(new be(y, E), t.value), r.value.intersectObjects(e.value, !1); | ||
}, d = (y) => { | ||
const E = f({ | ||
x: (y == null ? void 0 : y.clientX) ?? o.value, | ||
y: (y == null ? void 0 : y.clientY) ?? u.value | ||
y: (y == null ? void 0 : y.clientY) ?? c.value | ||
}); | ||
return _ ? l(_) || [] : []; | ||
}, d = A(() => p()), v = B(), w = B(), h = (y, _) => { | ||
y.trigger({ event: _, intersects: p(_) }); | ||
}, M = (y) => { | ||
h(w, y); | ||
return E ? l(E) || [] : []; | ||
}, w = D(() => d()), p = x(), g = x(), C = (y, E) => { | ||
y.trigger({ event: E, intersects: d(E) }); | ||
}, k = (y) => { | ||
C(g, y); | ||
}; | ||
let P; | ||
const C = (y) => { | ||
var _; | ||
P = (_ = p(y)[0]) == null ? void 0 : _.object; | ||
}, k = (y) => { | ||
var _; | ||
y instanceof PointerEvent && P === ((_ = p(y)[0]) == null ? void 0 : _.object) && h(v, y); | ||
}, T = (y) => w.trigger({ event: y, intersects: [] }); | ||
return n.value.addEventListener("pointerup", k), n.value.addEventListener("pointerdown", C), n.value.addEventListener("pointermove", M), n.value.addEventListener("pointerleave", T), N(() => { | ||
n != null && n.value && (n.value.removeEventListener("pointerup", k), n.value.removeEventListener("pointerdown", C), n.value.removeEventListener("pointermove", M), n.value.removeEventListener("pointerleave", T)); | ||
let M; | ||
const _ = (y) => { | ||
var E; | ||
M = (E = d(y)[0]) == null ? void 0 : E.object; | ||
}, P = (y) => { | ||
var E; | ||
y instanceof PointerEvent && M === ((E = d(y)[0]) == null ? void 0 : E.object) && C(p, y); | ||
}, A = (y) => g.trigger({ event: y, intersects: [] }); | ||
return n.value.addEventListener("pointerup", P), n.value.addEventListener("pointerdown", _), n.value.addEventListener("pointermove", k), n.value.addEventListener("pointerleave", A), N(() => { | ||
n != null && n.value && (n.value.removeEventListener("pointerup", P), n.value.removeEventListener("pointerdown", _), n.value.removeEventListener("pointermove", k), n.value.removeEventListener("pointerleave", A)); | ||
}), { | ||
intersects: d, | ||
onClick: (y) => v.on(y).off, | ||
onPointerMove: (y) => w.on(y).off | ||
intersects: w, | ||
onClick: (y) => p.on(y).off, | ||
onPointerMove: (y) => g.on(y).off | ||
}; | ||
}; | ||
function wt() { | ||
const { logWarning: e } = O(); | ||
function a(o, u, s) { | ||
let f = null; | ||
const { logWarning: e } = T(); | ||
function a(o, c, s) { | ||
let u = null; | ||
return o.traverse((i) => { | ||
i[u] === s && (f = i); | ||
}), f || e(`Child with ${u} '${s}' not found.`), f; | ||
i[c] === s && (u = i); | ||
}), u || e(`Child with ${c} '${s}' not found.`), u; | ||
} | ||
function t(o, u, s) { | ||
const f = []; | ||
function t(o, c, s) { | ||
const u = []; | ||
return o.traverse((i) => { | ||
i[u].includes(s) && f.push(i); | ||
}), f.length || e(`Children with ${u} '${s}' not found.`), f; | ||
i[c].includes(s) && u.push(i); | ||
}), u.length || e(`Children with ${c} '${s}' not found.`), u; | ||
} | ||
function r(o, u) { | ||
return a(o, "name", u); | ||
function r(o, c) { | ||
return a(o, "name", c); | ||
} | ||
function n(o, u) { | ||
return t(o, "name", u); | ||
function n(o, c) { | ||
return t(o, "name", c); | ||
} | ||
@@ -365,14 +365,14 @@ return { | ||
pointerLeave: /* @__PURE__ */ new Map() | ||
}), r = L(/* @__PURE__ */ new Set()), n = (l) => { | ||
}), r = O(/* @__PURE__ */ new Set()), n = (l) => { | ||
r.value.add(l); | ||
}, o = (l) => { | ||
r.value.delete(l); | ||
}, u = (l) => { | ||
Object.values(t).forEach((p) => p.delete(l)), o(l); | ||
}, c = (l) => { | ||
Object.values(t).forEach((d) => d.delete(l)), o(l); | ||
}, s = (l) => { | ||
const { onClick: p, onPointerMove: d, onPointerEnter: v, onPointerLeave: w } = l; | ||
p && t.click.set(l, p), d && t.pointerMove.set(l, d), v && t.pointerEnter.set(l, v), w && t.pointerLeave.set(l, w); | ||
const { onClick: d, onPointerMove: w, onPointerEnter: p, onPointerLeave: g } = l; | ||
d && t.click.set(l, d), w && t.pointerMove.set(l, w), p && t.pointerEnter.set(l, p), g && t.pointerLeave.set(l, g); | ||
}; | ||
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
const f = A( | ||
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = c, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
const u = D( | ||
() => Ue( | ||
@@ -385,17 +385,17 @@ [ | ||
) | ||
), { onClick: i, onPointerMove: m } = tt(f, a); | ||
i(({ intersects: l, event: p }) => { | ||
var d; | ||
l.length && ((d = t.click.get(l[0].object)) == null || d(l[0], p)); | ||
), { onClick: i, onPointerMove: m } = tt(u, a); | ||
i(({ intersects: l, event: d }) => { | ||
var w; | ||
l.length && ((w = t.click.get(l[0].object)) == null || w(l[0], d)); | ||
}); | ||
let c; | ||
return m(({ intersects: l, event: p }) => { | ||
var M, P, C, k; | ||
const d = (M = l == null ? void 0 : l[0]) == null ? void 0 : M.object, { pointerLeave: v, pointerEnter: w, pointerMove: h } = t; | ||
c && c !== d && ((P = v.get(c)) == null || P(c, p)), d && (c !== d && ((C = w.get(d)) == null || C(l[0], p)), (k = h.get(d)) == null || k(l[0], p)), c = d || null; | ||
let f; | ||
return m(({ intersects: l, event: d }) => { | ||
var k, M, _, P; | ||
const w = (k = l == null ? void 0 : l[0]) == null ? void 0 : k.object, { pointerLeave: p, pointerEnter: g, pointerMove: C } = t; | ||
f && f !== w && ((M = p.get(f)) == null || M(f, d)), w && (f !== w && ((_ = g.get(w)) == null || _(l[0], d)), (P = C.get(w)) == null || P(l[0], d)), f = w || null; | ||
}), { | ||
registerObject: s, | ||
deregisterObject: u | ||
deregisterObject: c | ||
}; | ||
}, G = L({}), V = (e) => Object.assign(G.value, e); | ||
}, G = O({}), V = (e) => Object.assign(G.value, e); | ||
function nt({ | ||
@@ -408,15 +408,15 @@ scene: e, | ||
}) { | ||
const o = A( | ||
() => E(t) ? je() : Fe(E(a).parentElement) | ||
), u = A(() => o.value.width.value), s = A(() => o.value.height.value), f = A(() => u.value / s.value), i = { | ||
const o = D( | ||
() => h(t) ? je() : Fe(h(a).parentElement) | ||
), c = D(() => o.value.width.value), s = D(() => o.value.height.value), u = D(() => c.value / s.value), i = { | ||
height: s, | ||
width: u, | ||
aspectRatio: f | ||
}, m = x(e), { | ||
camera: c, | ||
width: c, | ||
aspectRatio: u | ||
}, m = B(e), { | ||
camera: f, | ||
cameras: l, | ||
registerCamera: p, | ||
deregisterCamera: d, | ||
setCameraActive: v | ||
} = $e({ sizes: i, scene: e }), { renderer: w } = Qe( | ||
registerCamera: d, | ||
deregisterCamera: w, | ||
setCameraActive: p | ||
} = $e({ sizes: i, scene: e }), { renderer: g } = Qe( | ||
{ | ||
@@ -426,19 +426,19 @@ scene: e, | ||
options: n, | ||
contextParts: { sizes: i, camera: c }, | ||
contextParts: { sizes: i, camera: f }, | ||
disableRender: r | ||
} | ||
), h = { | ||
), C = { | ||
sizes: i, | ||
scene: m, | ||
camera: c, | ||
camera: f, | ||
cameras: ie(l), | ||
renderer: w, | ||
raycaster: x(new xe()), | ||
controls: L(null), | ||
renderer: g, | ||
raycaster: B(new Le()), | ||
controls: O(null), | ||
extend: V, | ||
registerCamera: p, | ||
setCameraActive: v, | ||
deregisterCamera: d | ||
registerCamera: d, | ||
setCameraActive: p, | ||
deregisterCamera: w | ||
}; | ||
return z("useTres", h), h; | ||
return z("useTres", C), C; | ||
} | ||
@@ -452,6 +452,6 @@ function at() { | ||
const Ct = at; | ||
let g = null; | ||
const { logError: Z } = O(), ot = { | ||
let v = null; | ||
const { logError: Z } = T(), ot = { | ||
createElement(e, a, t, r) { | ||
var u, s; | ||
var c, s; | ||
if (r || (r = {}), r.args || (r.args = []), e === "template" || Ve(e)) | ||
@@ -462,9 +462,9 @@ return null; | ||
(r == null ? void 0 : r.object) === void 0 && Z("Tres primitives need a prop 'object'"); | ||
const f = r.object; | ||
n = f.type, o = Object.assign(f, { type: n, attach: r.attach, primitive: !0 }); | ||
const u = r.object; | ||
n = u.type, o = Object.assign(u, { type: n, attach: r.attach, primitive: !0 }); | ||
} else { | ||
const f = G.value[n]; | ||
f || Z(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new f(...r.args); | ||
const u = G.value[n]; | ||
u || Z(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), o = new u(...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 && ((u = r == null ? void 0 : r.material) != null && u.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, | ||
@@ -475,15 +475,15 @@ tres__name: n | ||
insert(e, a) { | ||
var r, n, o, u; | ||
a && a.isScene && (g = a); | ||
const t = a || g; | ||
var r, n, o, c; | ||
a && a.isScene && (v = a); | ||
const t = a || v; | ||
if (e != null && e.isObject3D) { | ||
if (e != null && e.isCamera) { | ||
if (!(g != null && g.userData.tres__registerCamera)) | ||
if (!(v != null && v.userData.tres__registerCamera)) | ||
throw "could not find tres__registerCamera on scene's userData"; | ||
(n = g == null ? void 0 : (r = g.userData).tres__registerCamera) == null || n.call(r, e); | ||
(n = v == null ? void 0 : (r = v.userData).tres__registerCamera) == null || n.call(r, e); | ||
} | ||
if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) { | ||
if (!(g != null && g.userData.tres__registerAtPointerEventHandler)) | ||
if (!(v != null && v.userData.tres__registerAtPointerEventHandler)) | ||
throw "could not find tres__registerAtPointerEventHandler on scene's userData"; | ||
(u = g == null ? void 0 : (o = g.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e); | ||
(c = v == null ? void 0 : (o = v.userData).tres__registerAtPointerEventHandler) == null || c.call(o, e); | ||
} | ||
@@ -498,14 +498,14 @@ } | ||
const r = e, n = (i) => { | ||
var c, l; | ||
var f, l; | ||
const m = i; | ||
i.userData.tres__materialViaProp || (c = m.material) == null || c.dispose(), i.userData.tres__geometryViaProp || (l = m.geometry) == null || l.dispose(); | ||
}, o = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, u = g == null ? void 0 : g.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => { | ||
var m, c; | ||
if (!u) | ||
i.userData.tres__materialViaProp || ((f = m.material) == null || f.dispose(), m.material = void 0), i.userData.tres__geometryViaProp || ((l = m.geometry) == null || l.dispose(), m.geometry = void 0); | ||
}, o = v == null ? void 0 : v.userData.tres__deregisterAtPointerEventHandler, c = v == null ? void 0 : v.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => { | ||
var m, f; | ||
if (!c) | ||
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData"; | ||
if ((c = g == null ? void 0 : (m = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || c.call(m, i), !o) | ||
if ((f = v == null ? void 0 : (m = v.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || f.call(m, i), !o) | ||
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData"; | ||
(i != null && i.onClick || i != null && i.onPointerMove || i != null && i.onPointerEnter || i != null && i.onPointerLeave) && (o == null || o(i)); | ||
}, f = (i) => { | ||
const m = g == null ? void 0 : g.userData.tres__deregisterCamera; | ||
}, u = (i) => { | ||
const m = v == null ? void 0 : v.userData.tres__deregisterCamera; | ||
if (!m) | ||
@@ -515,27 +515,27 @@ throw "could not find tres__deregisterCamera on scene's userData"; | ||
}; | ||
r.traverse((i) => { | ||
n(i), f(i), s == null || s(i); | ||
}), n(r), f(r), s == null || s(r); | ||
(a = e.removeFromParent) == null || a.call(e), r.traverse((i) => { | ||
n(i), u(i), s == null || s(i); | ||
}), n(r), u(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, u, s; | ||
var n, o, c, s; | ||
if (e) { | ||
let f = e, i = a; | ||
let u = e, i = a; | ||
if (e.isObject3D && i === "blocks-pointer-events") { | ||
r || r === "" ? (o = g == null ? void 0 : (n = g.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = g == null ? void 0 : (u = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(u, e); | ||
r || r === "" ? (o = v == null ? void 0 : (n = v.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(n, e) : (s = v == null ? void 0 : (c = v.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(c, e); | ||
return; | ||
} | ||
let m = S(i), c = f == null ? void 0 : f[m]; | ||
let m = S(i), f = u == null ? void 0 : u[m]; | ||
if (i === "args") { | ||
const p = e, d = t ?? [], v = r ?? [], w = e.userData.tres__name || e.type; | ||
w && d.length && !Ke(d, v) && (f = Object.assign(p, new G.value[w](...r))); | ||
const d = e, w = t ?? [], p = r ?? [], g = e.userData.tres__name || e.type; | ||
g && w.length && !Ke(w, p) && (u = Object.assign(d, new G.value[g](...r))); | ||
return; | ||
} | ||
if (f.type === "BufferGeometry") { | ||
if (u.type === "BufferGeometry") { | ||
if (i === "args") | ||
return; | ||
f.setAttribute( | ||
u.setAttribute( | ||
S(i), | ||
@@ -546,12 +546,12 @@ new Be(...r) | ||
} | ||
if (i.includes("-") && c === void 0) { | ||
const p = i.split("-"); | ||
c = p.reduce((d, v) => d[S(v)], f), i = p.pop(), m = i.toLowerCase(), c != null && c.set || (f = p.reduce((d, v) => d[S(v)], f)); | ||
if (i.includes("-") && f === void 0) { | ||
const d = i.split("-"); | ||
f = d.reduce((w, p) => w[S(p)], u), i = d.pop(), m = i.toLowerCase(), f != null && f.set || (u = d.reduce((w, p) => w[S(p)], u)); | ||
} | ||
let l = r; | ||
if (l === "" && (l = !0), Q(c)) { | ||
if (l === "" && (l = !0), Q(f)) { | ||
Array.isArray(l) ? e[m](...l) : e[m](l); | ||
return; | ||
} | ||
!(c != null && c.set) && !Q(c) ? f[m] = l : c.constructor === l.constructor && (c != null && c.copy) ? c == null || c.copy(l) : Array.isArray(l) ? c.set(...l) : !c.isColor && c.setScalar ? c.setScalar(l) : c.set(l); | ||
!(f != null && f.set) && !Q(f) ? u[m] = l : f.constructor === l.constructor && (f != null && f.copy) ? f == null || f.copy(l) : Array.isArray(l) ? f.set(...l) : !f.isColor && f.setScalar ? f.setScalar(l) : f.set(l); | ||
} | ||
@@ -600,27 +600,27 @@ }, | ||
setup(e, { expose: a }) { | ||
var l; | ||
const t = e, { logWarning: r } = O(), n = L(), o = x(new Le()); | ||
ne(); | ||
const u = ce(), s = (l = U()) == null ? void 0 : l.appContext.app, f = (p) => q({ | ||
var w; | ||
const t = e, { logWarning: r } = T(), n = O(), o = B(new xe()), { resume: c } = ne(), s = ce(), u = (w = U()) == null ? void 0 : w.appContext.app, i = (p) => q({ | ||
setup() { | ||
var v; | ||
const d = (v = U()) == null ? void 0 : v.appContext; | ||
return d && (d.app = s), z("useTres", p), z("extend", V), () => J(ge, null, u != null && u.default ? u.default() : []); | ||
var C; | ||
const g = (C = U()) == null ? void 0 : C.appContext; | ||
return g && (g.app = u), z("useTres", p), z("extend", V), () => J(ge, null, s != null && s.default ? s.default() : []); | ||
} | ||
}), i = (p) => { | ||
const d = f(p); | ||
st(J(d), o.value); | ||
}, m = A(() => t.disableRender), c = x(null); | ||
return a({ context: c }), fe(() => { | ||
}), m = (p) => { | ||
const g = i(p); | ||
st(J(g), o.value); | ||
}, f = (p, g = !1) => { | ||
o.value.children = [], g && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), m(p), c(); | ||
}, l = D(() => t.disableRender), d = B(null); | ||
return a({ context: d, dispose: () => f(d.value, !0) }), fe(() => { | ||
const p = n; | ||
c.value = nt({ | ||
d.value = nt({ | ||
scene: o.value, | ||
canvas: p, | ||
windowSize: t.windowSize, | ||
disableRender: m, | ||
disableRender: l, | ||
rendererOptions: t | ||
}), rt({ scene: o.value, contextParts: c.value }); | ||
const { registerCamera: d, camera: v, cameras: w, deregisterCamera: h } = c.value; | ||
i(c.value); | ||
const M = () => { | ||
}), rt({ scene: o.value, contextParts: d.value }); | ||
const { registerCamera: g, camera: C, cameras: k, deregisterCamera: M } = d.value; | ||
m(d.value); | ||
const _ = () => { | ||
const P = new I( | ||
@@ -632,5 +632,5 @@ 45, | ||
); | ||
P.position.set(3, 3, 3), P.lookAt(0, 0, 0), d(P); | ||
const C = D(() => { | ||
w.value.length >= 2 && (P.removeFromParent(), h(P), C == null || C()); | ||
P.position.set(3, 3, 3), P.lookAt(0, 0, 0), g(P); | ||
const A = b(() => { | ||
k.value.length >= 2 && (P.removeFromParent(), M(P), A == null || A()); | ||
}); | ||
@@ -640,4 +640,4 @@ }; | ||
() => t.camera, | ||
(P, C) => { | ||
P && d(P), C && (C.removeFromParent(), h(C)); | ||
(P, A) => { | ||
P && g(P), A && (A.removeFromParent(), M(A)); | ||
}, | ||
@@ -647,6 +647,6 @@ { | ||
} | ||
), v.value || (r( | ||
), C.value || (r( | ||
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene." | ||
), M()); | ||
}), (p, d) => (pe(), me("canvas", { | ||
), _()); | ||
}), (p, g) => (pe(), me("canvas", { | ||
ref_key: "canvas", | ||
@@ -696,3 +696,3 @@ ref: n, | ||
gt as useLoader, | ||
O as useLogger, | ||
T as useLogger, | ||
rt as usePointerEventHandler, | ||
@@ -699,0 +699,0 @@ tt as useRaycaster, |
{ | ||
"name": "@tresjs/core", | ||
"type": "module", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"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
415689
5827
Updated@vueuse/core@^10.7.0