@tresjs/core
Advanced tools
Comparing version 3.3.0 to 3.4.0
151
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v3.3.0 | ||
* version: v3.4.0 | ||
* (c) 2023 | ||
@@ -8,6 +8,6 @@ * 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 I, inject as le, createRenderer as ue, defineComponent as q, useSlots as ce, getCurrentInstance as U, onMounted as fe, openBlock as pe, createElementBlock as me, normalizeStyle as de, h as J, Fragment as ve } from "vue"; | ||
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, mergeProps as de, h as J, Fragment as ve } from "vue"; | ||
import * as ge from "three"; | ||
import { PerspectiveCamera as $, OrthographicCamera as ye, Camera as we, Clock as Ce, Vector3 as Pe, Color as H, REVISION as _e, SRGBColorSpace as he, ACESFilmicToneMapping as Ee, PCFSoftShadowMap as Me, WebGLRenderer as z, LoadingManager as Ae, TextureLoader as ke, Vector2 as De, Raycaster as be, BufferAttribute as xe, Scene as Le } from "three"; | ||
import { createEventHook as L, useRafFn as Be, toValue as h, unrefElement as Oe, useDevicePixelRatio as Te, usePointer as Se, useElementBounding as Re, useWindowSize as He, useElementSize as je } from "@vueuse/core"; | ||
import { PerspectiveCamera as I, OrthographicCamera as ye, Camera as we, Clock as Ce, Vector3 as Pe, Color as H, REVISION as he, SRGBColorSpace as _e, ACESFilmicToneMapping as Ee, PCFSoftShadowMap as Me, WebGLRenderer as z, LoadingManager as Ae, TextureLoader as ke, Vector2 as De, Raycaster as be, BufferAttribute as xe, Scene as Le } from "three"; | ||
import { createEventHook as L, useRafFn as Be, toValue as _, unrefElement as Oe, useDevicePixelRatio as Te, usePointer as Se, useElementBounding as Re, useWindowSize as He, useElementSize as je } from "@vueuse/core"; | ||
const Fe = ({ sizes: e, scene: a }) => { | ||
@@ -29,3 +29,3 @@ const t = B([]), r = A( | ||
e.aspectRatio.value && t.value.forEach((s) => { | ||
s instanceof $ && (s.aspect = e.aspectRatio.value), (s instanceof $ || s instanceof ye) && s.updateProjectionMatrix(); | ||
s instanceof I && (s.aspect = e.aspectRatio.value), (s instanceof I || s instanceof ye) && s.updateProjectionMatrix(); | ||
}); | ||
@@ -43,3 +43,3 @@ }), a.userData.tres__registerCamera = n, a.userData.tres__deregisterCamera = o, W(() => { | ||
let j = 0, F = 0; | ||
const { pause: ze, resume: Ie, isActive: $e } = Be( | ||
const { pause: ze, resume: $e, isActive: Ie } = Be( | ||
() => { | ||
@@ -58,4 +58,4 @@ te.trigger({ delta: j, elapsed: F, clock: b }), re.trigger({ delta: j, elapsed: F, clock: b }), N.trigger({ delta: j, elapsed: F, clock: b }); | ||
pause: ze, | ||
resume: Ie, | ||
isActive: $e | ||
resume: $e, | ||
isActive: Ie | ||
}), mt = !0, K = "[TresJS ▲ ■ ●] "; | ||
@@ -141,7 +141,7 @@ function O() { | ||
} | ||
const Ke = Array.isArray, Xe = Number.parseInt(_e.replace("dev", "")), R = { | ||
const Ke = Array.isArray, Xe = Number.parseInt(he.replace("dev", "")), R = { | ||
realistic: { | ||
shadows: !0, | ||
physicallyCorrectLights: !0, | ||
outputColorSpace: he, | ||
outputColorSpace: _e, | ||
toneMapping: Ee, | ||
@@ -163,14 +163,14 @@ toneMappingExposure: 3, | ||
const c = A(() => ({ | ||
alpha: h(t.alpha), | ||
depth: h(t.depth), | ||
alpha: _(t.alpha), | ||
depth: _(t.depth), | ||
canvas: Oe(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) | ||
context: _(t.context), | ||
stencil: _(t.stencil), | ||
antialias: _(t.antialias) === void 0 ? !0 : _(t.antialias), | ||
precision: _(t.precision), | ||
powerPreference: _(t.powerPreference), | ||
premultipliedAlpha: _(t.premultipliedAlpha), | ||
preserveDrawingBuffer: _(t.preserveDrawingBuffer), | ||
logarithmicDepthBuffer: _(t.logarithmicDepthBuffer), | ||
failIfMajorPerformanceCaveat: _(t.failIfMajorPerformanceCaveat) | ||
})), s = x(new z(c.value)); | ||
@@ -199,6 +199,6 @@ ee(c, () => { | ||
D(() => { | ||
const v = h(t.preset); | ||
const v = _(t.preset); | ||
v && (v in R || l(`Renderer Preset must be one of these: ${Object.keys(R).join(", ")}`), ae(s.value, R[v])); | ||
const w = (P, C) => { | ||
const k = h(P), T = () => { | ||
const k = _(P), T = () => { | ||
if (v) | ||
@@ -211,4 +211,4 @@ return Y(R[v], C); | ||
return y !== void 0 ? y : Y(u, C); | ||
}, _ = (P, C) => Ue(s.value, C, w(P, C)); | ||
_(t.shadows, "shadowMap.enabled"), _(t.toneMapping, "toneMapping"), _(t.shadowMapType, "shadowMap.type"), Xe < 150 && _(!t.useLegacyLights, "physicallyCorrectLights"), _(t.outputColorSpace, "outputColorSpace"), _(t.toneMappingExposure, "toneMappingExposure"); | ||
}, h = (P, C) => Ue(s.value, C, w(P, C)); | ||
h(t.shadows, "shadowMap.enabled"), h(t.toneMapping, "toneMapping"), h(t.shadowMapType, "shadowMap.type"), Xe < 150 && h(!t.useLegacyLights, "physicallyCorrectLights"), h(t.outputColorSpace, "outputColorSpace"), h(t.toneMappingExposure, "toneMappingExposure"); | ||
const M = w(t.clearColor, "clearColor"); | ||
@@ -220,6 +220,6 @@ M && s.value.setClearColor( | ||
}); | ||
const { pause: i, resume: d, onLoop: m } = ne(); | ||
return m(() => { | ||
o.value && !h(r) && s.value.render(e, o.value); | ||
}), d(), W(() => { | ||
const { pause: i, resume: m, onLoop: d } = ne(); | ||
return d(() => { | ||
o.value && !_(r) && s.value.render(e, o.value); | ||
}), m(), W(() => { | ||
i(), s.value.dispose(), s.value.forceContextLoss(); | ||
@@ -301,3 +301,3 @@ }), { | ||
return r.value.setFromCamera(new De(y, E), t.value), r.value.intersectObjects(e.value, !1); | ||
}, d = (y) => { | ||
}, m = (y) => { | ||
const E = u({ | ||
@@ -308,6 +308,6 @@ x: (y == null ? void 0 : y.clientX) ?? o.value, | ||
return E ? i(E) || [] : []; | ||
}, m = A(() => d()), v = L(), w = L(), _ = (y, E) => { | ||
y.trigger({ event: E, intersects: d(E) }); | ||
}, d = A(() => m()), v = L(), w = L(), h = (y, E) => { | ||
y.trigger({ event: E, intersects: m(E) }); | ||
}, M = (y) => { | ||
_(w, y); | ||
h(w, y); | ||
}; | ||
@@ -317,6 +317,6 @@ let P; | ||
var E; | ||
P = (E = d(y)[0]) == null ? void 0 : E.object; | ||
P = (E = m(y)[0]) == null ? void 0 : E.object; | ||
}, k = (y) => { | ||
var E; | ||
y instanceof PointerEvent && P === ((E = d(y)[0]) == null ? void 0 : E.object) && _(v, y); | ||
y instanceof PointerEvent && P === ((E = m(y)[0]) == null ? void 0 : E.object) && h(v, y); | ||
}, T = (y) => w.trigger({ event: y, intersects: [] }); | ||
@@ -326,3 +326,3 @@ return n.value.addEventListener("pointerup", k), n.value.addEventListener("pointerdown", C), n.value.addEventListener("pointermove", M), n.value.addEventListener("pointerleave", T), W(() => { | ||
}), { | ||
intersects: m, | ||
intersects: d, | ||
onClick: (y) => v.on(y).off, | ||
@@ -359,6 +359,6 @@ onPointerMove: (y) => w.on(y).off | ||
}, c = (i) => { | ||
Object.values(t).forEach((d) => d.delete(i)), o(i); | ||
Object.values(t).forEach((m) => m.delete(i)), o(i); | ||
}, s = (i) => { | ||
const { onClick: d, onPointerMove: m, onPointerEnter: v, onPointerLeave: w } = i; | ||
d && t.click.set(i, d), m && t.pointerMove.set(i, m), v && t.pointerEnter.set(i, v), w && t.pointerLeave.set(i, w); | ||
const { onClick: m, onPointerMove: d, onPointerEnter: v, onPointerLeave: w } = i; | ||
m && t.click.set(i, m), d && t.pointerMove.set(i, d), v && t.pointerEnter.set(i, v), w && t.pointerLeave.set(i, w); | ||
}; | ||
@@ -375,11 +375,11 @@ e.userData.tres__registerAtPointerEventHandler = s, e.userData.tres__deregisterAtPointerEventHandler = c, e.userData.tres__registerBlockingObjectAtPointerEventHandler = n, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = o; | ||
), { onClick: l, onPointerMove: p } = et(f, a); | ||
l(({ intersects: i, event: d }) => { | ||
var m; | ||
i.length && ((m = t.click.get(i[0].object)) == null || m(i[0], d)); | ||
l(({ intersects: i, event: m }) => { | ||
var d; | ||
i.length && ((d = t.click.get(i[0].object)) == null || d(i[0], m)); | ||
}); | ||
let u; | ||
return p(({ intersects: i, event: d }) => { | ||
return p(({ intersects: i, event: m }) => { | ||
var M, P, C, k; | ||
const m = (M = i == null ? void 0 : i[0]) == null ? void 0 : M.object, { pointerLeave: v, pointerEnter: w, pointerMove: _ } = t; | ||
u && u !== m && ((P = v.get(u)) == null || P(u, d)), m && (u !== m && ((C = w.get(m)) == null || C(i[0], d)), (k = _.get(m)) == null || k(i[0], d)), u = m || null; | ||
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, m)), d && (u !== d && ((C = w.get(d)) == null || C(i[0], m)), (k = h.get(d)) == null || k(i[0], m)), u = d || null; | ||
}), { | ||
@@ -398,3 +398,3 @@ registerObject: s, | ||
const o = A( | ||
() => h(t) ? He() : je(h(a).parentElement) | ||
() => _(t) ? He() : je(_(a).parentElement) | ||
), c = A(() => o.value.width.value), s = A(() => o.value.height.value), f = A(() => c.value / s.value), l = { | ||
@@ -407,4 +407,4 @@ height: s, | ||
cameras: i, | ||
registerCamera: d, | ||
deregisterCamera: m, | ||
registerCamera: m, | ||
deregisterCamera: d, | ||
setCameraActive: v | ||
@@ -419,3 +419,3 @@ } = Fe({ sizes: l, scene: e }), { renderer: w } = Ye( | ||
} | ||
), _ = { | ||
), h = { | ||
sizes: l, | ||
@@ -429,7 +429,7 @@ scene: p, | ||
extend: V, | ||
registerCamera: d, | ||
registerCamera: m, | ||
setCameraActive: v, | ||
deregisterCamera: m | ||
deregisterCamera: d | ||
}; | ||
return I("useTres", _), _; | ||
return $("useTres", h), h; | ||
} | ||
@@ -519,4 +519,4 @@ function nt() { | ||
if (l === "args") { | ||
const d = e, m = t ?? [], v = r ?? [], w = e.userData.tres__name || e.type; | ||
w && m.length && !Je(m, v) && (f = Object.assign(d, new G.value[w](...r))); | ||
const m = e, d = t ?? [], v = r ?? [], w = e.userData.tres__name || e.type; | ||
w && d.length && !Je(d, v) && (f = Object.assign(m, new G.value[w](...r))); | ||
return; | ||
@@ -534,4 +534,4 @@ } | ||
if (l.includes("-") && u === void 0) { | ||
const d = l.split("-"); | ||
u = d.reduce((m, v) => m[S(v)], f), l = d.pop(), p = l.toLowerCase(), u != null && u.set || (f = d.reduce((m, v) => m[S(v)], f)); | ||
const m = l.split("-"); | ||
u = m.reduce((d, v) => d[S(v)], f), l = m.pop(), p = l.toLowerCase(), u != null && u.set || (f = m.reduce((d, v) => d[S(v)], f)); | ||
} | ||
@@ -590,17 +590,17 @@ let i = r; | ||
ne(); | ||
const c = ce(), s = (i = U()) == null ? void 0 : i.appContext.app, f = (d) => q({ | ||
const c = ce(), s = (i = U()) == null ? void 0 : i.appContext.app, f = (m) => q({ | ||
setup() { | ||
var v; | ||
const m = (v = U()) == null ? void 0 : v.appContext; | ||
return m && (m.app = s), I("useTres", d), I("extend", V), () => J(ve, null, c != null && c.default ? c.default() : []); | ||
const d = (v = U()) == null ? void 0 : v.appContext; | ||
return d && (d.app = s), $("useTres", m), $("extend", V), () => J(ve, null, c != null && c.default ? c.default() : []); | ||
} | ||
}), l = (d) => { | ||
const m = f(d); | ||
ot(J(m), o.value); | ||
}), l = (m) => { | ||
const d = f(m); | ||
ot(J(d), o.value); | ||
}, p = A(() => t.disableRender), u = x(null); | ||
return a({ context: u }), fe(() => { | ||
const d = n; | ||
const m = n; | ||
u.value = rt({ | ||
scene: o.value, | ||
canvas: d, | ||
canvas: m, | ||
windowSize: t.windowSize, | ||
@@ -610,6 +610,6 @@ disableRender: p, | ||
}), tt({ scene: o.value, contextParts: u.value }); | ||
const { registerCamera: m, camera: v, cameras: w, deregisterCamera: _ } = u.value; | ||
const { registerCamera: d, camera: v, cameras: w, deregisterCamera: h } = u.value; | ||
l(u.value); | ||
const M = () => { | ||
const P = new $( | ||
const P = new I( | ||
45, | ||
@@ -620,5 +620,5 @@ window.innerWidth / window.innerHeight, | ||
); | ||
P.position.set(3, 3, 3), P.lookAt(0, 0, 0), m(P); | ||
P.position.set(3, 3, 3), P.lookAt(0, 0, 0), d(P); | ||
const C = D(() => { | ||
w.value.length >= 2 && (P.removeFromParent(), _(P), C == null || C()); | ||
w.value.length >= 2 && (P.removeFromParent(), h(P), C == null || C()); | ||
}); | ||
@@ -629,3 +629,3 @@ }; | ||
(P, C) => { | ||
P && m(P), C && (C.removeFromParent(), _(C)); | ||
P && d(P), C && (C.removeFromParent(), h(C)); | ||
}, | ||
@@ -638,11 +638,12 @@ { | ||
), M()); | ||
}), (d, m) => (pe(), me("canvas", { | ||
}), (m, d) => (pe(), me("canvas", de({ | ||
ref_key: "canvas", | ||
ref: n, | ||
"data-scene": o.value.uuid, | ||
style: de({ | ||
"data-scene": o.value.uuid | ||
}, m.$attrs, { | ||
style: { | ||
display: "block", | ||
width: "100%", | ||
height: "100%", | ||
position: d.windowSize ? "fixed" : "relative", | ||
position: m.windowSize ? "fixed" : "relative", | ||
top: 0, | ||
@@ -652,4 +653,4 @@ left: 0, | ||
touchAction: "none" | ||
}) | ||
}, null, 12, st)); | ||
} | ||
}), null, 16, st)); | ||
} | ||
@@ -656,0 +657,0 @@ }), lt = [ |
{ | ||
"name": "@tresjs/core", | ||
"type": "module", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"packageManager": "pnpm@8.3.1", | ||
@@ -20,3 +20,4 @@ "description": "Declarative ThreeJS using Vue Components", | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/tres.js" | ||
"import": "./dist/tres.js", | ||
"require": "./dist/tres.umd.cjs" | ||
}, | ||
@@ -76,3 +77,3 @@ "./components": { | ||
"@tresjs/cientos": "3.1.0", | ||
"@tresjs/eslint-config-vue": "^0.1.1", | ||
"@tresjs/eslint-config-vue": "^0.2.0", | ||
"@types/three": "^0.155.1", | ||
@@ -79,0 +80,0 @@ "@typescript-eslint/eslint-plugin": "^6.4.1", |
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
381247
5471