@tresjs/core
Advanced tools
Comparing version 3.2.1-next.3 to 3.2.1-next.4
414
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v3.2.1-next.3 | ||
* version: v3.2.1-next.4 | ||
* (c) 2023 | ||
@@ -8,23 +8,23 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { ref as h, computed as A, watchEffect as D, onUnmounted as N, shallowRef as F, watch as te, reactive as ue, readonly as le, provide as I, inject as ce, createRenderer as fe, defineComponent as U, useSlots as pe, getCurrentInstance as J, onMounted as me, openBlock as ve, createElementBlock as de, normalizeStyle as ge, h as K, Fragment as ye } from "vue"; | ||
import { ref as h, computed as k, watchEffect as D, onUnmounted as N, shallowRef as F, watch as te, reactive as ue, readonly as le, provide as I, inject as ce, createRenderer as fe, defineComponent as U, useSlots as me, getCurrentInstance as J, onMounted as pe, openBlock as ve, createElementBlock as de, normalizeStyle as ge, h as K, Fragment as ye } from "vue"; | ||
import * as we from "three"; | ||
import { PerspectiveCamera as W, OrthographicCamera as Ce, Camera as _e, Clock as Pe, Vector3 as Ee, Color as R, REVISION as Me, SRGBColorSpace as Ae, ACESFilmicToneMapping as be, PCFSoftShadowMap as ke, WebGLRenderer as z, LoadingManager as De, TextureLoader as Oe, Vector2 as xe, Raycaster as he, BufferAttribute as Be, Scene as Le } from "three"; | ||
import { createEventHook as x, useRafFn as Te, toValue as P, unrefElement as Se, useDevicePixelRatio as Re, usePointer as je, useElementBounding as He, useWindowSize as Fe, useElementSize as ze } from "@vueuse/core"; | ||
import { PerspectiveCamera as W, OrthographicCamera as Ce, Camera as _e, Clock as Pe, Vector3 as Ee, Color as R, REVISION as Me, SRGBColorSpace as Ae, ACESFilmicToneMapping as ke, PCFSoftShadowMap as be, WebGLRenderer as z, LoadingManager as De, TextureLoader as xe, Vector2 as Oe, Raycaster as he, BufferAttribute as Be, Scene as Le } from "three"; | ||
import { createEventHook as O, useRafFn as Te, toValue as P, unrefElement as Se, useDevicePixelRatio as Re, usePointer as je, useElementBounding as He, useWindowSize as Fe, useElementSize as ze } from "@vueuse/core"; | ||
const Ge = ({ sizes: e, scene: n }) => { | ||
const t = h([]), r = A( | ||
const t = h([]), r = k( | ||
() => t.value[0] | ||
), a = (s, c = !1) => { | ||
t.value.some(({ uuid: i }) => i === s.uuid) || (c ? f(s) : t.value.push(s)); | ||
}, o = (s) => { | ||
t.value = t.value.filter(({ uuid: c }) => c !== s.uuid); | ||
}, f = (s) => { | ||
const c = s instanceof _e ? s : t.value.find((p) => p.uuid === s); | ||
), a = (i, c = !1) => { | ||
t.value.some(({ uuid: u }) => u === i.uuid) || (c ? f(i) : t.value.push(i)); | ||
}, o = (i) => { | ||
t.value = t.value.filter(({ uuid: c }) => c !== i.uuid); | ||
}, f = (i) => { | ||
const c = i instanceof _e ? i : t.value.find((m) => m.uuid === i); | ||
if (!c) | ||
return; | ||
const i = t.value.filter(({ uuid: p }) => p !== c.uuid); | ||
t.value = [c, ...i]; | ||
const u = t.value.filter(({ uuid: m }) => m !== c.uuid); | ||
t.value = [c, ...u]; | ||
}; | ||
return D(() => { | ||
e.aspectRatio.value && t.value.forEach((s) => { | ||
s instanceof W && (s.aspect = e.aspectRatio.value), (s instanceof W || s instanceof Ce) && s.updateProjectionMatrix(); | ||
e.aspectRatio.value && t.value.forEach((i) => { | ||
i instanceof W && (i.aspect = e.aspectRatio.value), (i instanceof W || i instanceof Ce) && i.updateProjectionMatrix(); | ||
}); | ||
@@ -40,7 +40,7 @@ }), n.userData.tres__registerCamera = a, n.userData.tres__deregisterCamera = o, N(() => { | ||
}; | ||
}, re = x(), ne = x(), V = x(), O = new Pe(); | ||
}, re = O(), ne = O(), V = O(), x = new Pe(); | ||
let j = 0, H = 0; | ||
const { pause: Ie, resume: We, isActive: $e } = Te( | ||
() => { | ||
re.trigger({ delta: j, elapsed: H, clock: O }), ne.trigger({ delta: j, elapsed: H, clock: O }), V.trigger({ delta: j, elapsed: H, clock: O }); | ||
re.trigger({ delta: j, elapsed: H, clock: x }), ne.trigger({ delta: j, elapsed: H, clock: x }), V.trigger({ delta: j, elapsed: H, clock: x }); | ||
}, | ||
@@ -50,3 +50,3 @@ { immediate: !1 } | ||
V.on(() => { | ||
j = O.getDelta(), H = O.getElapsedTime(); | ||
j = x.getDelta(), H = x.getElapsedTime(); | ||
}); | ||
@@ -60,3 +60,3 @@ const ae = () => ({ | ||
isActive: $e | ||
}), mt = !0, X = "[TresJS ▲ ■ ●] "; | ||
}), pt = !0, X = "[TresJS ▲ ■ ●] "; | ||
function B() { | ||
@@ -119,3 +119,3 @@ function e(r, a) { | ||
const a = e.attributes, o = n.attributes; | ||
return a.length !== o.length ? !1 : Array.from(a).every(({ name: f, value: s }) => n.getAttribute(f) === s); | ||
return a.length !== o.length ? !1 : Array.from(a).every(({ name: f, value: i }) => n.getAttribute(f) === i); | ||
} | ||
@@ -145,7 +145,7 @@ if (e === n) | ||
outputColorSpace: Ae, | ||
toneMapping: be, | ||
toneMapping: ke, | ||
toneMappingExposure: 3, | ||
shadowMap: { | ||
enabled: !0, | ||
type: ke | ||
type: be | ||
} | ||
@@ -161,3 +161,3 @@ } | ||
}) { | ||
const f = A(() => ({ | ||
const f = k(() => ({ | ||
alpha: P(t.alpha), | ||
@@ -175,51 +175,51 @@ depth: P(t.depth), | ||
failIfMajorPerformanceCaveat: P(t.failIfMajorPerformanceCaveat) | ||
})), s = F(new z(f.value)); | ||
})), i = F(new z(f.value)); | ||
te(f, () => { | ||
s.value.dispose(), s.value = new z(f.value); | ||
i.value.dispose(), i.value = new z(f.value); | ||
}), D(() => { | ||
s.value.setSize(a.width.value, a.height.value); | ||
i.value.setSize(a.width.value, a.height.value); | ||
}); | ||
const { pixelRatio: c } = Re(); | ||
D(() => { | ||
s.value.setPixelRatio(c.value); | ||
i.value.setPixelRatio(c.value); | ||
}); | ||
const { logError: i } = B(), u = (() => { | ||
const v = new z(), C = { | ||
const { logError: u } = B(), l = (() => { | ||
const d = new z(), w = { | ||
shadowMap: { | ||
enabled: v.shadowMap.enabled, | ||
type: v.shadowMap.type | ||
enabled: d.shadowMap.enabled, | ||
type: d.shadowMap.type | ||
}, | ||
toneMapping: v.toneMapping, | ||
toneMappingExposure: v.toneMappingExposure, | ||
outputColorSpace: v.outputColorSpace | ||
toneMapping: d.toneMapping, | ||
toneMappingExposure: d.toneMappingExposure, | ||
outputColorSpace: d.outputColorSpace | ||
}; | ||
return v.dispose(), C; | ||
return d.dispose(), w; | ||
})(); | ||
D(() => { | ||
const v = P(t.preset); | ||
v && (v in S || i(`Renderer Preset must be one of these: ${Object.keys(S).join(", ")}`), oe(s.value, S[v])); | ||
const C = (b, M) => { | ||
const k = P(b), L = () => { | ||
if (v) | ||
return Q(S[v], M); | ||
const d = P(t.preset); | ||
d && (d in S || u(`Renderer Preset must be one of these: ${Object.keys(S).join(", ")}`), oe(i.value, S[d])); | ||
const w = (_, A) => { | ||
const b = P(_), L = () => { | ||
if (d) | ||
return Q(S[d], A); | ||
}; | ||
if (k !== void 0) | ||
return k; | ||
const d = L(); | ||
return d !== void 0 ? d : Q(u, M); | ||
}, w = (b, M) => Ke(s.value, M, C(b, M)); | ||
w(t.shadows, "shadowMap.enabled"), w(t.toneMapping, "toneMapping"), w(t.shadowMapType, "shadowMap.type"), Ye < 150 && w(!t.useLegacyLights, "physicallyCorrectLights"), w(t.outputColorSpace, "outputColorSpace"), w(t.toneMappingExposure, "toneMappingExposure"); | ||
const _ = C(t.clearColor, "clearColor"); | ||
_ && s.value.setClearColor( | ||
_ ? Ne(_) : new R(0) | ||
if (b !== void 0) | ||
return b; | ||
const g = L(); | ||
return g !== void 0 ? g : Q(l, A); | ||
}, E = (_, A) => Ke(i.value, A, w(_, A)); | ||
E(t.shadows, "shadowMap.enabled"), E(t.toneMapping, "toneMapping"), E(t.shadowMapType, "shadowMap.type"), Ye < 150 && E(!t.useLegacyLights, "physicallyCorrectLights"), E(t.outputColorSpace, "outputColorSpace"), E(t.toneMappingExposure, "toneMappingExposure"); | ||
const C = w(t.clearColor, "clearColor"); | ||
C && i.value.setClearColor( | ||
C ? Ne(C) : new R(0) | ||
// default clear color is not easily/efficiently retrievable from three | ||
); | ||
}); | ||
const { pause: l, resume: g, onLoop: y } = ae(); | ||
const { pause: s, resume: v, onLoop: y } = ae(); | ||
return y(() => { | ||
o.value && !P(r) && s.value.render(e, o.value); | ||
}), g(), N(() => { | ||
l(), s.value.dispose(), s.value.forceContextLoss(); | ||
o.value && !P(r) && i.value.render(e, o.value); | ||
}), v(), N(() => { | ||
s(), i.value.dispose(), i.value.forceContextLoss(); | ||
}), { | ||
renderer: s | ||
renderer: i | ||
}; | ||
@@ -238,10 +238,10 @@ } | ||
const c = (Array.isArray(n) ? n : [n]).map( | ||
(i) => new Promise((p, u) => { | ||
(u) => new Promise((m, l) => { | ||
f.load( | ||
i, | ||
(l) => { | ||
l.scene && Object.assign(l, Ze(l.scene)), p(l); | ||
u, | ||
(s) => { | ||
s.scene && Object.assign(s, Ze(s.scene)), m(s); | ||
}, | ||
r, | ||
(l) => u(o("[useLoader] - Failed to load resource", l)) | ||
(s) => l(o("[useLoader] - Failed to load resource", s)) | ||
); | ||
@@ -253,6 +253,6 @@ }) | ||
async function gt(e) { | ||
const n = new De(), t = new Oe(n), r = (a) => new Promise((o, f) => { | ||
const n = new De(), t = new xe(n), r = (a) => new Promise((o, f) => { | ||
t.load( | ||
a, | ||
(s) => o(s), | ||
(i) => o(i), | ||
() => null, | ||
@@ -272,7 +272,7 @@ () => { | ||
normalMap: f, | ||
roughnessMap: s, | ||
roughnessMap: i, | ||
metalnessMap: c, | ||
aoMap: i, | ||
alphaMap: p, | ||
matcap: u | ||
aoMap: u, | ||
alphaMap: m, | ||
matcap: l | ||
} = e; | ||
@@ -283,7 +283,7 @@ return { | ||
normalMap: f ? await r(f) : null, | ||
roughnessMap: s ? await r(s) : null, | ||
roughnessMap: i ? await r(i) : null, | ||
metalnessMap: c ? await r(c) : null, | ||
aoMap: i ? await r(i) : null, | ||
alphaMap: p ? await r(p) : null, | ||
matcap: u ? await r(u) : null | ||
aoMap: u ? await r(u) : null, | ||
alphaMap: m ? await r(m) : null, | ||
matcap: l ? await r(l) : null | ||
}; | ||
@@ -293,36 +293,36 @@ } | ||
const et = (e, { renderer: n, camera: t, raycaster: r }) => { | ||
const a = A(() => n.value.domElement), { x: o, y: f } = je({ target: a }), { width: s, height: c, top: i, left: p } = He(a), u = ({ x: d, y: E }) => { | ||
const a = k(() => n.value.domElement), { x: o, y: f } = je({ target: a }), { width: i, height: c, top: u, left: m } = He(a), l = ({ x: g, y: M }) => { | ||
if (a.value) | ||
return { | ||
x: (d - p.value) / s.value * 2 - 1, | ||
y: -((E - i.value) / c.value) * 2 + 1 | ||
x: (g - m.value) / i.value * 2 - 1, | ||
y: -((M - u.value) / c.value) * 2 + 1 | ||
}; | ||
}, l = ({ x: d, y: E }) => { | ||
}, s = ({ x: g, y: M }) => { | ||
if (t.value) | ||
return r.value.setFromCamera(new xe(d, E), t.value), r.value.intersectObjects(e.value, !1); | ||
}, g = (d) => { | ||
const E = u({ | ||
x: (d == null ? void 0 : d.clientX) ?? o.value, | ||
y: (d == null ? void 0 : d.clientY) ?? f.value | ||
return r.value.setFromCamera(new Oe(g, M), t.value), r.value.intersectObjects(e.value, !1); | ||
}, v = (g) => { | ||
const M = l({ | ||
x: (g == null ? void 0 : g.clientX) ?? o.value, | ||
y: (g == null ? void 0 : g.clientY) ?? f.value | ||
}); | ||
return E ? l(E) || [] : []; | ||
}, y = A(() => g()), v = x(), C = x(), w = (d, E) => { | ||
d.trigger({ event: E, intersects: g(E) }); | ||
}, _ = (d) => { | ||
w(C, d); | ||
return M ? s(M) || [] : []; | ||
}, y = k(() => v()), d = O(), w = O(), E = (g, M) => { | ||
g.trigger({ event: M, intersects: v(M) }); | ||
}, C = (g) => { | ||
E(w, g); | ||
}; | ||
let b; | ||
const M = (d) => { | ||
var E; | ||
b = (E = g(d)[0]) == null ? void 0 : E.object; | ||
}, k = (d) => { | ||
var E; | ||
d instanceof PointerEvent && b === ((E = g(d)[0]) == null ? void 0 : E.object) && w(v, d); | ||
}, L = (d) => C.trigger({ event: d, intersects: [] }); | ||
return a.value.addEventListener("pointerup", k), a.value.addEventListener("pointerdown", M), a.value.addEventListener("pointermove", _), a.value.addEventListener("pointerleave", L), N(() => { | ||
a != null && a.value && (a.value.removeEventListener("pointerup", k), a.value.removeEventListener("pointerdown", M), a.value.removeEventListener("pointermove", _), a.value.removeEventListener("pointerleave", L)); | ||
let _; | ||
const A = (g) => { | ||
var M; | ||
_ = (M = v(g)[0]) == null ? void 0 : M.object; | ||
}, b = (g) => { | ||
var M; | ||
g instanceof PointerEvent && _ === ((M = v(g)[0]) == null ? void 0 : M.object) && E(d, g); | ||
}, L = (g) => w.trigger({ event: g, intersects: [] }); | ||
return a.value.addEventListener("pointerup", b), a.value.addEventListener("pointerdown", A), a.value.addEventListener("pointermove", C), a.value.addEventListener("pointerleave", L), N(() => { | ||
a != null && a.value && (a.value.removeEventListener("pointerup", b), a.value.removeEventListener("pointerdown", A), a.value.removeEventListener("pointermove", C), a.value.removeEventListener("pointerleave", L)); | ||
}), { | ||
intersects: y, | ||
onClick: (d) => v.on(d).off, | ||
onPointerMove: (d) => C.on(d).off | ||
onClick: (g) => d.on(g).off, | ||
onPointerMove: (g) => w.on(g).off | ||
}; | ||
@@ -334,4 +334,4 @@ }; | ||
let f = null; | ||
return r.traverse((s) => { | ||
s[a] === o && (f = s); | ||
return r.traverse((i) => { | ||
i[a] === o && (f = i); | ||
}), f || e(`Child with ${a} '${o}' not found.`), f; | ||
@@ -353,33 +353,33 @@ } | ||
pointerLeave: /* @__PURE__ */ new Map() | ||
}), r = h(/* @__PURE__ */ new Set()), a = (l) => { | ||
r.value.add(l); | ||
}, o = (l) => { | ||
r.value.delete(l); | ||
}, f = (l) => { | ||
Object.values(t).forEach((g) => g.delete(l)), o(l); | ||
}, s = (l) => { | ||
const { onClick: g, onPointerMove: y, onPointerEnter: v, onPointerLeave: C } = l; | ||
g && t.click.set(l, g), y && t.pointerMove.set(l, y), v && t.pointerEnter.set(l, v), C && t.pointerLeave.set(l, C); | ||
}), r = h(/* @__PURE__ */ new Set()), a = (s) => { | ||
r.value.add(s); | ||
}, o = (s) => { | ||
r.value.delete(s); | ||
}, f = (s) => { | ||
Object.values(t).forEach((v) => v.delete(s)), o(s); | ||
}, i = (s) => { | ||
const { onClick: v, onPointerMove: y, onPointerEnter: d, onPointerLeave: w } = s; | ||
v && t.click.set(s, v), y && t.pointerMove.set(s, y), d && t.pointerEnter.set(s, d), w && t.pointerLeave.set(s, w); | ||
}; | ||
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = f, e.userData.tres__registerBlockingObjectAtPointerEventHandler = a, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
const c = A( | ||
e.userData.tres__registerAtPointerEventHandler = i, e.userData.tres__deregisterAtPointerEventHandler = f, e.userData.tres__registerBlockingObjectAtPointerEventHandler = a, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
const c = k( | ||
() => Je( | ||
[ | ||
...Array.from(r.value), | ||
...Object.values(t).map((l) => Array.from(l.keys())).flat() | ||
...Object.values(t).map((s) => Array.from(s.keys())).flat() | ||
], | ||
({ uuid: l }) => l | ||
({ uuid: s }) => s | ||
) | ||
), { onClick: i, onPointerMove: p } = et(c, n); | ||
i(({ intersects: l, event: g }) => { | ||
), { onClick: u, onPointerMove: m } = et(c, n); | ||
u(({ intersects: s, event: v }) => { | ||
var y; | ||
l.length && ((y = t.click.get(l[0].object)) == null || y(l[0], g)); | ||
s.length && ((y = t.click.get(s[0].object)) == null || y(s[0], v)); | ||
}); | ||
let u; | ||
return p(({ intersects: l, event: g }) => { | ||
var _, b, M, k; | ||
const y = (_ = l == null ? void 0 : l[0]) == null ? void 0 : _.object, { pointerLeave: v, pointerEnter: C, pointerMove: w } = t; | ||
u && u !== y && ((b = v.get(u)) == null || b(u, g)), y && (u !== y && ((M = C.get(y)) == null || M(l[0], g)), (k = w.get(y)) == null || k(l[0], g)), u = y || null; | ||
let l; | ||
return m(({ intersects: s, event: v }) => { | ||
var C, _, A, b; | ||
const y = (C = s == null ? void 0 : s[0]) == null ? void 0 : C.object, { pointerLeave: d, pointerEnter: w, pointerMove: E } = t; | ||
l && l !== y && ((_ = d.get(l)) == null || _(l, v)), y && (l !== y && ((A = w.get(y)) == null || A(s[0], v)), (b = E.get(y)) == null || b(s[0], v)), l = y || null; | ||
}), { | ||
registerObject: s, | ||
registerObject: i, | ||
deregisterObject: f | ||
@@ -395,15 +395,15 @@ }; | ||
}) { | ||
const o = A( | ||
const o = k( | ||
() => P(t) ? Fe() : ze(P(n).parentElement) | ||
), f = A(() => o.value.width.value), s = A(() => o.value.height.value), c = A(() => f.value / s.value), i = { | ||
height: s, | ||
), f = k(() => o.value.width.value), i = k(() => o.value.height.value), c = k(() => f.value / i.value), u = { | ||
height: i, | ||
width: f, | ||
aspectRatio: c | ||
}, p = F(e), { | ||
camera: u, | ||
cameras: l, | ||
registerCamera: g, | ||
}, m = F(e), { | ||
camera: l, | ||
cameras: s, | ||
registerCamera: v, | ||
deregisterCamera: y, | ||
setCameraActive: v | ||
} = Ge({ sizes: i, scene: e }), { renderer: C } = Qe( | ||
setCameraActive: d | ||
} = Ge({ sizes: u, scene: e }), { renderer: w } = Qe( | ||
{ | ||
@@ -413,19 +413,19 @@ scene: e, | ||
options: a, | ||
contextParts: { sizes: i, camera: u }, | ||
contextParts: { sizes: u, camera: l }, | ||
disableRender: r | ||
} | ||
), w = { | ||
sizes: i, | ||
scene: p, | ||
camera: u, | ||
cameras: le(l), | ||
renderer: C, | ||
), E = { | ||
sizes: u, | ||
scene: m, | ||
camera: l, | ||
cameras: le(s), | ||
renderer: w, | ||
raycaster: F(new he()), | ||
controls: h(null), | ||
extend: q, | ||
registerCamera: g, | ||
setCameraActive: v, | ||
registerCamera: v, | ||
setCameraActive: d, | ||
deregisterCamera: y | ||
}; | ||
return I("useTres", w), w; | ||
return I("useTres", E), E; | ||
} | ||
@@ -439,6 +439,6 @@ function nt() { | ||
const wt = nt; | ||
let G = null, m = null; | ||
let G = null, p = null; | ||
const { logError: ee } = B(), at = { | ||
createElement(e, n, t, r) { | ||
var f, s; | ||
var f, i; | ||
if (r || (r = {}), r.args || (r.args = []), e === "template" || qe(e)) | ||
@@ -455,3 +455,3 @@ return null; | ||
} | ||
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 && ((f = r == null ? void 0 : r.material) != null && f.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 && ((f = r == null ? void 0 : r.material) != null && f.isMaterial && (o.userData.tres__materialViaProp = !0), (i = r == null ? void 0 : r.geometry) != null && i.isBufferGeometry && (o.userData.tres__geometryViaProp = !0)), o.userData = { | ||
...o.userData, | ||
@@ -462,18 +462,18 @@ tres__name: a | ||
insert(e, n) { | ||
var t, r, a, o, f, s, c, i, p; | ||
if (n && n.isScene && (m = n), (((t = e == null ? void 0 : e.__vnode) == null ? void 0 : t.type) === "TresGroup" || ((r = e == null ? void 0 : e.__vnode) == null ? void 0 : r.type) === "TresObject3D") && n === null && !((o = (a = e == null ? void 0 : e.__vnode) == null ? void 0 : a.ctx) != null && o.asyncResolved)) { | ||
var t, r, a, o, f, i, c, u, m; | ||
if (n && n.isScene && (p = n), (((t = e == null ? void 0 : e.__vnode) == null ? void 0 : t.type) === "TresGroup" || ((r = e == null ? void 0 : e.__vnode) == null ? void 0 : r.type) === "TresObject3D") && n === null && !((o = (a = e == null ? void 0 : e.__vnode) == null ? void 0 : a.ctx) != null && o.asyncResolved)) { | ||
G = e; | ||
return; | ||
} else | ||
(f = e == null ? void 0 : e.__vnode) != null && f.type.includes("Controls") && n === null && (G = m); | ||
(f = e == null ? void 0 : e.__vnode) != null && f.type.includes("Controls") && n === null && (G = p); | ||
if (n || (n = G), e != null && e.isObject3D) { | ||
if (e != null && e.isCamera) { | ||
if (!(m != null && m.userData.tres__registerCamera)) | ||
if (!(p != null && p.userData.tres__registerCamera)) | ||
throw "could not find tres__registerCamera on scene's userData"; | ||
(c = m == null ? void 0 : (s = m.userData).tres__registerCamera) == null || c.call(s, e); | ||
(c = p == null ? void 0 : (i = p.userData).tres__registerCamera) == null || c.call(i, e); | ||
} | ||
if (e != null && e.onClick || e != null && e.onPointerMove || e != null && e.onPointerEnter || e != null && e.onPointerLeave) { | ||
if (!(m != null && m.userData.tres__registerAtPointerEventHandler)) | ||
if (!(p != null && p.userData.tres__registerAtPointerEventHandler)) | ||
throw "could not find tres__registerAtPointerEventHandler on scene's userData"; | ||
(p = m == null ? void 0 : (i = m.userData).tres__registerAtPointerEventHandler) == null || p.call(i, e); | ||
(m = p == null ? void 0 : (u = p.userData).tres__registerAtPointerEventHandler) == null || m.call(u, e); | ||
} | ||
@@ -487,22 +487,22 @@ } | ||
if (e.isObject3D) { | ||
const r = e, a = (i) => { | ||
var u, l; | ||
const p = i; | ||
i.userData.tres__materialViaProp || (u = p.material) == null || u.dispose(), i.userData.tres__geometryViaProp || (l = p.geometry) == null || l.dispose(); | ||
}, o = m == null ? void 0 : m.userData.tres__deregisterAtPointerEventHandler, f = m == null ? void 0 : m.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (i) => { | ||
var p, u; | ||
const r = e, a = (u) => { | ||
var l, s; | ||
const m = u; | ||
u.userData.tres__materialViaProp || (l = m.material) == null || l.dispose(), u.userData.tres__geometryViaProp || (s = m.geometry) == null || s.dispose(); | ||
}, o = p == null ? void 0 : p.userData.tres__deregisterAtPointerEventHandler, f = p == null ? void 0 : p.userData.tres__deregisterBlockingObjectAtPointerEventHandler, i = (u) => { | ||
var m, l; | ||
if (!f) | ||
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData"; | ||
if ((u = m == null ? void 0 : (p = m.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || u.call(p, i), !o) | ||
if ((l = p == null ? void 0 : (m = p.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || l.call(m, u), !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)); | ||
}, c = (i) => { | ||
const p = m == null ? void 0 : m.userData.tres__deregisterCamera; | ||
if (!p) | ||
(u != null && u.onClick || u != null && u.onPointerMove || u != null && u.onPointerEnter || u != null && u.onPointerLeave) && (o == null || o(u)); | ||
}, c = (u) => { | ||
const m = p == null ? void 0 : p.userData.tres__deregisterCamera; | ||
if (!m) | ||
throw "could not find tres__deregisterCamera on scene's userData"; | ||
i.isCamera && (p == null || p(i)); | ||
u.isCamera && (m == null || m(u)); | ||
}; | ||
r.traverse((i) => { | ||
a(i), c(i), s == null || s(i); | ||
}), a(r), c(r), s == null || s(r); | ||
r.traverse((u) => { | ||
a(u), c(u), i == null || i(u); | ||
}), a(r), c(r), i == null || i(r); | ||
} | ||
@@ -513,20 +513,20 @@ (n = e.removeFromParent) == null || n.call(e), (t = e.dispose) == null || t.call(e); | ||
patchProp(e, n, t, r) { | ||
var a, o, f, s; | ||
var a, o, f, i; | ||
if (e) { | ||
let c = e, i = n; | ||
if (e.isObject3D && i === "blocks-pointer-events") { | ||
r || r === "" ? (o = m == null ? void 0 : (a = m.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(a, e) : (s = m == null ? void 0 : (f = m.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(f, e); | ||
let c = e, u = n; | ||
if (e.isObject3D && u === "blocks-pointer-events") { | ||
r || r === "" ? (o = p == null ? void 0 : (a = p.userData).tres__registerBlockingObjectAtPointerEventHandler) == null || o.call(a, e) : (i = p == null ? void 0 : (f = p.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || i.call(f, e); | ||
return; | ||
} | ||
let p = T(i), u = c == null ? void 0 : c[p]; | ||
if (i === "args") { | ||
const g = e, y = t ?? [], v = r ?? [], C = e.userData.tres__name || e.type; | ||
C && y.length && !Xe(y, v) && (c = Object.assign(g, new $.value[C](...r))); | ||
let m = T(u), l = c == null ? void 0 : c[m]; | ||
if (u === "args") { | ||
const v = e, y = t ?? [], d = r ?? [], w = e.userData.tres__name || e.type; | ||
w && y.length && !Xe(y, d) && (c = Object.assign(v, new $.value[w](...r))); | ||
return; | ||
} | ||
if (c.type === "BufferGeometry") { | ||
if (i === "args") | ||
if (u === "args") | ||
return; | ||
c.setAttribute( | ||
T(i), | ||
T(u), | ||
new Be(...r) | ||
@@ -536,12 +536,12 @@ ); | ||
} | ||
if (i.includes("-") && u === void 0) { | ||
const g = i.split("-"); | ||
u = g.reduce((y, v) => y[T(v)], c), i = g.pop(), p = i.toLowerCase(), u != null && u.set || (c = g.reduce((y, v) => y[T(v)], c)); | ||
if (u.includes("-") && l === void 0) { | ||
const v = u.split("-"); | ||
l = v.reduce((y, d) => y[T(d)], c), u = v.pop(), m = u.toLowerCase(), l != null && l.set || (c = v.reduce((y, d) => y[T(d)], c)); | ||
} | ||
let l = r; | ||
if (l === "" && (l = !0), Z(u)) { | ||
Array.isArray(l) ? e[p](...l) : e[p](l); | ||
let s = r; | ||
if (s === "" && (s = !0), Z(l)) { | ||
Array.isArray(s) ? e[m](...s) : e[m](s); | ||
return; | ||
} | ||
!(u != null && u.set) && !Z(u) ? c[p] = l : u.constructor === l.constructor && (u != null && u.copy) ? u == null || u.copy(l) : Array.isArray(l) ? u.set(...l) : !u.isColor && u.setScalar ? u.setScalar(l) : u.set(l); | ||
!(l != null && l.set) && !Z(l) ? c[m] = s : l.constructor === s.constructor && (l != null && l.copy) ? l == null || l.copy(s) : Array.isArray(s) ? l.set(...s) : !l.isColor && l.setScalar ? l.setScalar(s) : l.set(s); | ||
} | ||
@@ -590,26 +590,28 @@ }, | ||
setup(e) { | ||
var m; | ||
const n = e, { logWarning: t } = B(), r = h(), a = F(new Le()); | ||
ae(); | ||
const o = pe(), f = J(), s = (p) => U({ | ||
const o = me(), f = (m = J()) == null ? void 0 : m.appContext.app, i = (l) => U({ | ||
setup() { | ||
const u = J(); | ||
return u.appContext.app = f.appContext.app, Object.assign(u.provides, u.appContext.provides), I("useTres", p), I("extend", q), () => K(ye, null, o != null && o.default ? o.default() : []); | ||
var v; | ||
const s = (v = J()) == null ? void 0 : v.appContext; | ||
return s && (s.app = f), I("useTres", l), I("extend", q), () => K(ye, null, o != null && o.default ? o.default() : []); | ||
} | ||
}), c = (p) => { | ||
const u = s(p); | ||
ot(K(u), a.value); | ||
}, i = A(() => n.disableRender); | ||
return me(() => { | ||
const p = r, u = rt({ | ||
}), c = (l) => { | ||
const s = i(l); | ||
ot(K(s), a.value); | ||
}, u = k(() => n.disableRender); | ||
return pe(() => { | ||
const l = r, s = rt({ | ||
scene: a.value, | ||
canvas: p, | ||
canvas: l, | ||
windowSize: n.windowSize, | ||
disableRender: i, | ||
disableRender: u, | ||
rendererOptions: n | ||
}); | ||
tt({ scene: a.value, contextParts: u }); | ||
const { registerCamera: l, camera: g, cameras: y, deregisterCamera: v } = u; | ||
c(u); | ||
const C = () => { | ||
const w = new W( | ||
tt({ scene: a.value, contextParts: s }); | ||
const { registerCamera: v, camera: y, cameras: d, deregisterCamera: w } = s; | ||
c(s); | ||
const E = () => { | ||
const C = new W( | ||
45, | ||
@@ -620,5 +622,5 @@ window.innerWidth / window.innerHeight, | ||
); | ||
w.position.set(3, 3, 3), w.lookAt(0, 0, 0), l(w); | ||
C.position.set(3, 3, 3), C.lookAt(0, 0, 0), v(C); | ||
const _ = D(() => { | ||
y.value.length >= 2 && (w.removeFromParent(), v(w), _ == null || _()); | ||
d.value.length >= 2 && (C.removeFromParent(), w(C), _ == null || _()); | ||
}); | ||
@@ -628,4 +630,4 @@ }; | ||
() => n.camera, | ||
(w, _) => { | ||
w ? l(w) : _ && (_.removeFromParent(), v(_)); | ||
(C, _) => { | ||
C ? v(C) : _ && (_.removeFromParent(), w(_)); | ||
}, | ||
@@ -635,6 +637,6 @@ { | ||
} | ||
), g.value || (t( | ||
), y.value || (t( | ||
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene." | ||
), C()); | ||
}), (p, u) => (ve(), de("canvas", { | ||
), E()); | ||
}), (l, s) => (ve(), de("canvas", { | ||
ref_key: "canvas", | ||
@@ -647,3 +649,3 @@ ref: r, | ||
height: "100%", | ||
position: p.windowSize ? "fixed" : "relative", | ||
position: l.windowSize ? "fixed" : "relative", | ||
top: 0, | ||
@@ -676,3 +678,3 @@ left: 0, | ||
q as extend, | ||
mt as isProd, | ||
pt as isProd, | ||
Ne as normalizeColor, | ||
@@ -679,0 +681,0 @@ vt as normalizeVectorFlexibleParam, |
{ | ||
"name": "@tresjs/core", | ||
"type": "module", | ||
"version": "3.2.1-next.3", | ||
"version": "3.2.1-next.4", | ||
"packageManager": "pnpm@8.3.1", | ||
@@ -6,0 +6,0 @@ "description": "Declarative ThreeJS using Vue Components", |
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
380099
5406