@tresjs/core
Advanced tools
Comparing version 3.4.1 to 3.5.0
@@ -10,2 +10,4 @@ /** | ||
seekByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D | null; | ||
seekAll: (parent: THREE.Scene | THREE.Object3D, property: string, value: string) => THREE.Object3D[]; | ||
seekAllByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D[]; | ||
} | ||
@@ -12,0 +14,0 @@ /** |
299
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v3.4.1 | ||
* version: v3.5.0 | ||
* (c) 2023 | ||
@@ -8,19 +8,19 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
import { ref as B, computed as A, watchEffect as D, onUnmounted as W, shallowRef as x, watch as ee, reactive as se, readonly as ie, provide as $, 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 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 * 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 z, LoadingManager as ke, TextureLoader as De, Vector2 as be, Raycaster as xe, BufferAttribute as Le, Scene as Be } from "three"; | ||
import { createEventHook as L, 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"; | ||
const ze = ({ sizes: e, scene: a }) => { | ||
const t = B([]), r = A( | ||
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"; | ||
const $e = ({ sizes: e, scene: a }) => { | ||
const t = L([]), r = A( | ||
() => t.value[0] | ||
), n = (s, f = !1) => { | ||
t.value.some(({ uuid: l }) => l === s.uuid) || (f ? c(s) : t.value.push(s)); | ||
t.value.some(({ uuid: i }) => i === s.uuid) || (f ? u(s) : t.value.push(s)); | ||
}, o = (s) => { | ||
t.value = t.value.filter(({ uuid: f }) => f !== s.uuid); | ||
}, c = (s) => { | ||
}, u = (s) => { | ||
const f = s instanceof Ce ? s : t.value.find((m) => m.uuid === s); | ||
if (!f) | ||
return; | ||
const l = t.value.filter(({ uuid: m }) => m !== f.uuid); | ||
t.value = [f, ...l]; | ||
const i = t.value.filter(({ uuid: m }) => m !== f.uuid); | ||
t.value = [f, ...i]; | ||
}; | ||
@@ -31,3 +31,3 @@ return D(() => { | ||
}); | ||
}), a.userData.tres__registerCamera = n, a.userData.tres__deregisterCamera = o, W(() => { | ||
}), a.userData.tres__registerCamera = n, a.userData.tres__deregisterCamera = o, N(() => { | ||
t.value = []; | ||
@@ -39,13 +39,13 @@ }), { | ||
deregisterCamera: o, | ||
setCameraActive: c | ||
setCameraActive: u | ||
}; | ||
}, te = L(), re = L(), N = L(), b = new Pe(); | ||
}, te = B(), re = B(), W = B(), b = new Pe(); | ||
let j = 0, F = 0; | ||
const { pause: $e, resume: Ie, isActive: Ge } = Oe( | ||
const { pause: ze, resume: Ie, isActive: Ge } = Oe( | ||
() => { | ||
te.trigger({ delta: j, elapsed: F, clock: b }), re.trigger({ delta: j, elapsed: F, clock: b }), N.trigger({ delta: j, elapsed: F, clock: b }); | ||
te.trigger({ delta: j, elapsed: F, clock: b }), re.trigger({ delta: j, elapsed: F, clock: b }), W.trigger({ delta: j, elapsed: F, clock: b }); | ||
}, | ||
{ immediate: !1 } | ||
); | ||
N.on(() => { | ||
W.on(() => { | ||
j = b.getDelta(), F = b.getElapsedTime(); | ||
@@ -56,4 +56,4 @@ }); | ||
onLoop: re.on, | ||
onAfterLoop: N.on, | ||
pause: $e, | ||
onAfterLoop: W.on, | ||
pause: ze, | ||
resume: Ie, | ||
@@ -80,3 +80,3 @@ isActive: Ge | ||
} | ||
function We(e) { | ||
function Ne(e) { | ||
return e instanceof H ? e : Array.isArray(e) ? new H(...e) : new H(e); | ||
@@ -88,3 +88,3 @@ } | ||
return Object.assign(e || {}, a), e; | ||
}, Ne = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", Ve = /* @__PURE__ */ qe(Ne); | ||
}, We = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", Ve = /* @__PURE__ */ qe(We); | ||
function X(e) { | ||
@@ -116,3 +116,3 @@ return e && e.nodeType === 1; | ||
const r = Array.isArray(a) ? a : a.match(/([^[.\]])+/g); | ||
r && r.reduce((n, o, c) => (n[o] === void 0 && (n[o] = {}), c === r.length - 1 && (n[o] = t), n[o]), e); | ||
r && r.reduce((n, o, u) => (n[o] === void 0 && (n[o] = {}), u === r.length - 1 && (n[o] = t), n[o]), e); | ||
}; | ||
@@ -122,3 +122,3 @@ function oe(e, a) { | ||
const n = e.attributes, o = a.attributes; | ||
return n.length !== o.length ? !1 : Array.from(n).every(({ name: c, value: s }) => a.getAttribute(c) === s); | ||
return n.length !== o.length ? !1 : Array.from(n).every(({ name: u, value: s }) => a.getAttribute(u) === s); | ||
} | ||
@@ -165,3 +165,3 @@ if (e === a) | ||
}) { | ||
const c = A(() => ({ | ||
const u = A(() => ({ | ||
alpha: E(t.alpha), | ||
@@ -179,5 +179,5 @@ depth: E(t.depth), | ||
failIfMajorPerformanceCaveat: E(t.failIfMajorPerformanceCaveat) | ||
})), s = x(new z(c.value)); | ||
ee(c, () => { | ||
s.value.dispose(), s.value = new z(c.value); | ||
})), s = x(new $(u.value)); | ||
ee(u, () => { | ||
s.value.dispose(), s.value = new $(u.value); | ||
}), D(() => { | ||
@@ -190,4 +190,4 @@ s.value.setSize(n.width.value, n.height.value); | ||
}); | ||
const { logError: l } = O(), u = (() => { | ||
const v = new z(), w = { | ||
const { logError: i } = O(), c = (() => { | ||
const v = new $(), w = { | ||
shadowMap: { | ||
@@ -205,3 +205,3 @@ enabled: v.shadowMap.enabled, | ||
const v = E(t.preset); | ||
v && (v in R || l(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), ae(s.value, R[v])); | ||
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) => { | ||
@@ -215,3 +215,3 @@ const k = E(P), T = () => { | ||
const y = T(); | ||
return y !== void 0 ? y : Y(u, C); | ||
return y !== void 0 ? y : Y(c, C); | ||
}, h = (P, C) => Je(s.value, C, w(P, C)); | ||
@@ -221,11 +221,11 @@ 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"); | ||
M && s.value.setClearColor( | ||
M ? We(M) : new H(0) | ||
M ? Ne(M) : new H(0) | ||
// default clear color is not easily/efficiently retrievable from three | ||
); | ||
}); | ||
const { pause: i, resume: p, onLoop: d } = ne(); | ||
const { pause: l, resume: p, onLoop: d } = ne(); | ||
return d(() => { | ||
o.value && !E(r) && s.value.render(e, o.value); | ||
}), p(), W(() => { | ||
i(), s.value.dispose(), s.value.forceContextLoss(); | ||
}), p(), N(() => { | ||
l(), s.value.dispose(), s.value.forceContextLoss(); | ||
}), { | ||
@@ -243,13 +243,13 @@ renderer: s | ||
async function gt(e, a, t, r, n) { | ||
const { logError: o } = O(), c = new e(); | ||
n && n(c), t && t(c); | ||
const { logError: o } = O(), u = new e(); | ||
n && n(u), t && t(u); | ||
const f = (Array.isArray(a) ? a : [a]).map( | ||
(l) => new Promise((m, u) => { | ||
c.load( | ||
l, | ||
(i) => { | ||
i.scene && Object.assign(i, et(i.scene)), m(i); | ||
(i) => new Promise((m, c) => { | ||
u.load( | ||
i, | ||
(l) => { | ||
l.scene && Object.assign(l, et(l.scene)), m(l); | ||
}, | ||
r, | ||
(i) => u(o("[useLoader] - Failed to load resource", i)) | ||
(l) => c(o("[useLoader] - Failed to load resource", l)) | ||
); | ||
@@ -261,3 +261,3 @@ }) | ||
async function yt(e) { | ||
const a = new ke(), t = new De(a), r = (n) => new Promise((o, c) => { | ||
const a = new ke(), t = new De(a), r = (n) => new Promise((o, u) => { | ||
t.load( | ||
@@ -268,3 +268,3 @@ n, | ||
() => { | ||
c(new Error("[useTextures] - Failed to load texture")); | ||
u(new Error("[useTextures] - Failed to load texture")); | ||
} | ||
@@ -280,8 +280,8 @@ ); | ||
displacementMap: o, | ||
normalMap: c, | ||
normalMap: u, | ||
roughnessMap: s, | ||
metalnessMap: f, | ||
aoMap: l, | ||
aoMap: i, | ||
alphaMap: m, | ||
matcap: u | ||
matcap: c | ||
} = e; | ||
@@ -291,8 +291,8 @@ return { | ||
displacementMap: o ? await r(o) : null, | ||
normalMap: c ? await r(c) : null, | ||
normalMap: u ? await r(u) : null, | ||
roughnessMap: s ? await r(s) : null, | ||
metalnessMap: f ? await r(f) : null, | ||
aoMap: l ? await r(l) : null, | ||
aoMap: i ? await r(i) : null, | ||
alphaMap: m ? await r(m) : null, | ||
matcap: u ? await r(u) : null | ||
matcap: c ? await r(c) : null | ||
}; | ||
@@ -302,18 +302,18 @@ } | ||
const tt = (e, { renderer: a, camera: t, raycaster: r }) => { | ||
const n = A(() => a.value.domElement), { x: o, y: c } = Re({ target: n }), { width: s, height: f, top: l, left: m } = He(n), u = ({ x: y, y: _ }) => { | ||
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: _ }) => { | ||
if (n.value) | ||
return { | ||
x: (y - m.value) / s.value * 2 - 1, | ||
y: -((_ - l.value) / f.value) * 2 + 1 | ||
y: -((_ - i.value) / f.value) * 2 + 1 | ||
}; | ||
}, i = ({ x: y, y: _ }) => { | ||
}, l = ({ x: y, y: _ }) => { | ||
if (t.value) | ||
return r.value.setFromCamera(new be(y, _), t.value), r.value.intersectObjects(e.value, !1); | ||
}, p = (y) => { | ||
const _ = u({ | ||
const _ = c({ | ||
x: (y == null ? void 0 : y.clientX) ?? o.value, | ||
y: (y == null ? void 0 : y.clientY) ?? c.value | ||
y: (y == null ? void 0 : y.clientY) ?? u.value | ||
}); | ||
return _ ? i(_) || [] : []; | ||
}, d = A(() => p()), v = L(), w = L(), h = (y, _) => { | ||
return _ ? l(_) || [] : []; | ||
}, d = A(() => p()), v = B(), w = B(), h = (y, _) => { | ||
y.trigger({ event: _, intersects: p(_) }); | ||
@@ -331,3 +331,3 @@ }, M = (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), W(() => { | ||
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)); | ||
@@ -342,14 +342,25 @@ }), { | ||
const { logWarning: e } = O(); | ||
function a(r, n, o) { | ||
let c = null; | ||
return r.traverse((s) => { | ||
s[n] === o && (c = s); | ||
}), c || e(`Child with ${n} '${o}' not found.`), c; | ||
function a(o, u, s) { | ||
let f = null; | ||
return o.traverse((i) => { | ||
i[u] === s && (f = i); | ||
}), f || e(`Child with ${u} '${s}' not found.`), f; | ||
} | ||
function t(r, n) { | ||
return a(r, "name", n); | ||
function t(o, u, s) { | ||
const f = []; | ||
return o.traverse((i) => { | ||
i[u].includes(s) && f.push(i); | ||
}), f.length || e(`Children with ${u} '${s}' not found.`), f; | ||
} | ||
function r(o, u) { | ||
return a(o, "name", u); | ||
} | ||
function n(o, u) { | ||
return t(o, "name", u); | ||
} | ||
return { | ||
seek: a, | ||
seekByName: t | ||
seekByName: r, | ||
seekAll: t, | ||
seekAllByName: n | ||
}; | ||
@@ -363,13 +374,13 @@ } | ||
pointerLeave: /* @__PURE__ */ new Map() | ||
}), r = B(/* @__PURE__ */ new Set()), n = (i) => { | ||
r.value.add(i); | ||
}, o = (i) => { | ||
r.value.delete(i); | ||
}, c = (i) => { | ||
Object.values(t).forEach((p) => p.delete(i)), o(i); | ||
}, s = (i) => { | ||
const { onClick: p, onPointerMove: d, onPointerEnter: v, onPointerLeave: w } = i; | ||
p && t.click.set(i, p), d && t.pointerMove.set(i, d), v && t.pointerEnter.set(i, v), w && t.pointerLeave.set(i, w); | ||
}), r = L(/* @__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); | ||
}, 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); | ||
}; | ||
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = c, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = u, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
const f = A( | ||
@@ -379,21 +390,21 @@ () => Ue( | ||
...Array.from(r.value), | ||
...Object.values(t).map((i) => Array.from(i.keys())).flat() | ||
...Object.values(t).map((l) => Array.from(l.keys())).flat() | ||
], | ||
({ uuid: i }) => i | ||
({ uuid: l }) => l | ||
) | ||
), { onClick: l, onPointerMove: m } = tt(f, a); | ||
l(({ intersects: i, event: p }) => { | ||
), { onClick: i, onPointerMove: m } = tt(f, a); | ||
i(({ intersects: l, event: p }) => { | ||
var d; | ||
i.length && ((d = t.click.get(i[0].object)) == null || d(i[0], p)); | ||
l.length && ((d = t.click.get(l[0].object)) == null || d(l[0], p)); | ||
}); | ||
let u; | ||
return m(({ intersects: i, event: p }) => { | ||
let c; | ||
return m(({ intersects: l, event: p }) => { | ||
var M, P, C, k; | ||
const d = (M = i == null ? void 0 : i[0]) == null ? void 0 : M.object, { pointerLeave: v, pointerEnter: w, pointerMove: h } = t; | ||
u && u !== d && ((P = v.get(u)) == null || P(u, p)), d && (u !== d && ((C = w.get(d)) == null || C(i[0], p)), (k = h.get(d)) == null || k(i[0], p)), u = d || null; | ||
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; | ||
}), { | ||
registerObject: s, | ||
deregisterObject: c | ||
deregisterObject: u | ||
}; | ||
}, G = B({}), V = (e) => Object.assign(G.value, e); | ||
}, G = L({}), V = (e) => Object.assign(G.value, e); | ||
function nt({ | ||
@@ -408,13 +419,13 @@ scene: e, | ||
() => E(t) ? je() : Fe(E(a).parentElement) | ||
), c = A(() => o.value.width.value), s = A(() => o.value.height.value), f = A(() => c.value / s.value), l = { | ||
), u = A(() => o.value.width.value), s = A(() => o.value.height.value), f = A(() => u.value / s.value), i = { | ||
height: s, | ||
width: c, | ||
width: u, | ||
aspectRatio: f | ||
}, m = x(e), { | ||
camera: u, | ||
cameras: i, | ||
camera: c, | ||
cameras: l, | ||
registerCamera: p, | ||
deregisterCamera: d, | ||
setCameraActive: v | ||
} = ze({ sizes: l, scene: e }), { renderer: w } = Qe( | ||
} = $e({ sizes: i, scene: e }), { renderer: w } = Qe( | ||
{ | ||
@@ -424,13 +435,13 @@ scene: e, | ||
options: n, | ||
contextParts: { sizes: l, camera: u }, | ||
contextParts: { sizes: i, camera: c }, | ||
disableRender: r | ||
} | ||
), h = { | ||
sizes: l, | ||
sizes: i, | ||
scene: m, | ||
camera: u, | ||
cameras: ie(i), | ||
camera: c, | ||
cameras: ie(l), | ||
renderer: w, | ||
raycaster: x(new xe()), | ||
controls: B(null), | ||
controls: L(null), | ||
extend: V, | ||
@@ -441,3 +452,3 @@ registerCamera: p, | ||
}; | ||
return $("useTres", h), h; | ||
return z("useTres", h), h; | ||
} | ||
@@ -454,3 +465,3 @@ function at() { | ||
createElement(e, a, t, r) { | ||
var c, s; | ||
var u, s; | ||
if (r || (r = {}), r.args || (r.args = []), e === "template" || Ve(e)) | ||
@@ -467,3 +478,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 && ((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 = { | ||
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 = { | ||
...o.userData, | ||
@@ -474,3 +485,3 @@ tres__name: n | ||
insert(e, a) { | ||
var r, n, o, c; | ||
var r, n, o, u; | ||
a && a.isScene && (g = a); | ||
@@ -487,3 +498,3 @@ const t = a || g; | ||
throw "could not find tres__registerAtPointerEventHandler on scene's userData"; | ||
(c = g == null ? void 0 : (o = g.userData).tres__registerAtPointerEventHandler) == null || c.call(o, e); | ||
(u = g == null ? void 0 : (o = g.userData).tres__registerAtPointerEventHandler) == null || u.call(o, e); | ||
} | ||
@@ -497,21 +508,21 @@ } | ||
if (e.isObject3D) { | ||
const r = e, n = (l) => { | ||
var u, i; | ||
const m = l; | ||
l.userData.tres__materialViaProp || (u = m.material) == null || u.dispose(), l.userData.tres__geometryViaProp || (i = m.geometry) == null || i.dispose(); | ||
}, o = g == null ? void 0 : g.userData.tres__deregisterAtPointerEventHandler, c = g == null ? void 0 : g.userData.tres__deregisterBlockingObjectAtPointerEventHandler, s = (l) => { | ||
var m, u; | ||
if (!c) | ||
const r = e, n = (i) => { | ||
var c, 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) | ||
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData"; | ||
if ((u = g == null ? void 0 : (m = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || u.call(m, l), !o) | ||
if ((c = g == null ? void 0 : (m = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || c.call(m, i), !o) | ||
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData"; | ||
(l != null && l.onClick || l != null && l.onPointerMove || l != null && l.onPointerEnter || l != null && l.onPointerLeave) && (o == null || o(l)); | ||
}, f = (l) => { | ||
(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; | ||
if (!m) | ||
throw "could not find tres__deregisterCamera on scene's userData"; | ||
l.isCamera && (m == null || m(l)); | ||
i.isCamera && (m == null || m(i)); | ||
}; | ||
r.traverse((l) => { | ||
n(l), f(l), s == null || s(l); | ||
r.traverse((i) => { | ||
n(i), f(i), s == null || s(i); | ||
}), n(r), f(r), s == null || s(r); | ||
@@ -523,11 +534,11 @@ } | ||
patchProp(e, a, t, r) { | ||
var n, o, c, s; | ||
var n, o, u, s; | ||
if (e) { | ||
let f = e, l = a; | ||
if (e.isObject3D && l === "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 : (c = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || s.call(c, e); | ||
let f = 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); | ||
return; | ||
} | ||
let m = S(l), u = f == null ? void 0 : f[m]; | ||
if (l === "args") { | ||
let m = S(i), c = f == null ? void 0 : f[m]; | ||
if (i === "args") { | ||
const p = e, d = t ?? [], v = r ?? [], w = e.userData.tres__name || e.type; | ||
@@ -538,20 +549,20 @@ w && d.length && !Ke(d, v) && (f = Object.assign(p, new G.value[w](...r))); | ||
if (f.type === "BufferGeometry") { | ||
if (l === "args") | ||
if (i === "args") | ||
return; | ||
f.setAttribute( | ||
S(l), | ||
new Le(...r) | ||
S(i), | ||
new Be(...r) | ||
); | ||
return; | ||
} | ||
if (l.includes("-") && u === void 0) { | ||
const p = l.split("-"); | ||
u = p.reduce((d, v) => d[S(v)], f), l = p.pop(), m = l.toLowerCase(), u != null && u.set || (f = p.reduce((d, v) => d[S(v)], f)); | ||
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)); | ||
} | ||
let i = r; | ||
if (i === "" && (i = !0), Q(u)) { | ||
Array.isArray(i) ? e[m](...i) : e[m](i); | ||
let l = r; | ||
if (l === "" && (l = !0), Q(c)) { | ||
Array.isArray(l) ? e[m](...l) : e[m](l); | ||
return; | ||
} | ||
!(u != null && u.set) && !Q(u) ? f[m] = i : u.constructor === i.constructor && (u != null && u.copy) ? u == null || u.copy(i) : Array.isArray(i) ? u.set(...i) : !u.isColor && u.setScalar ? u.setScalar(i) : u.set(i); | ||
!(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); | ||
} | ||
@@ -600,18 +611,18 @@ }, | ||
setup(e, { expose: a }) { | ||
var i; | ||
const t = e, { logWarning: r } = O(), n = B(), o = x(new Be()); | ||
var l; | ||
const t = e, { logWarning: r } = O(), n = L(), o = x(new Le()); | ||
ne(); | ||
const c = ce(), s = (i = U()) == null ? void 0 : i.appContext.app, f = (p) => q({ | ||
const u = ce(), s = (l = U()) == null ? void 0 : l.appContext.app, f = (p) => q({ | ||
setup() { | ||
var v; | ||
const d = (v = U()) == null ? void 0 : v.appContext; | ||
return d && (d.app = s), $("useTres", p), $("extend", V), () => J(ge, null, c != null && c.default ? c.default() : []); | ||
return d && (d.app = s), z("useTres", p), z("extend", V), () => J(ge, null, u != null && u.default ? u.default() : []); | ||
} | ||
}), l = (p) => { | ||
}), i = (p) => { | ||
const d = f(p); | ||
st(J(d), o.value); | ||
}, m = A(() => t.disableRender), u = x(null); | ||
return a({ context: u }), fe(() => { | ||
}, m = A(() => t.disableRender), c = x(null); | ||
return a({ context: c }), fe(() => { | ||
const p = n; | ||
u.value = nt({ | ||
c.value = nt({ | ||
scene: o.value, | ||
@@ -622,5 +633,5 @@ canvas: p, | ||
rendererOptions: t | ||
}), rt({ scene: o.value, contextParts: u.value }); | ||
const { registerCamera: d, camera: v, cameras: w, deregisterCamera: h } = u.value; | ||
l(u.value); | ||
}), rt({ scene: o.value, contextParts: c.value }); | ||
const { registerCamera: d, camera: v, cameras: w, deregisterCamera: h } = c.value; | ||
i(c.value); | ||
const M = () => { | ||
@@ -688,7 +699,7 @@ const P = new I( | ||
dt as isProd, | ||
We as normalizeColor, | ||
Ne as normalizeColor, | ||
vt as normalizeVectorFlexibleParam, | ||
Pt as templateCompilerOptions, | ||
et as trasverseObjects, | ||
ze as useCamera, | ||
$e as useCamera, | ||
gt as useLoader, | ||
@@ -695,0 +706,0 @@ O as useLogger, |
@@ -1,2 +0,2 @@ | ||
import type { DefineComponent, Ref, VNode } from 'vue'; | ||
import type { DefineComponent, VNode, VNodeRef } from 'vue'; | ||
import type * as THREE from 'three'; | ||
@@ -137,4 +137,4 @@ import type { EventProps as PointerEventHandlerEventProps } from '../composables/usePointerEventHandler'; | ||
children?: VNode[]; | ||
ref?: string | null | Ref<P>; | ||
key?: string; | ||
ref?: VNodeRef; | ||
key?: string | number | symbol; | ||
} | ||
@@ -141,0 +141,0 @@ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<WithMathProps<P>, VueProps<P> & EventProps<P>>>; |
{ | ||
"name": "@tresjs/core", | ||
"type": "module", | ||
"version": "3.4.1", | ||
"version": "3.5.0", | ||
"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
382043
5485