@tresjs/core
Advanced tools
Comparing version 3.8.1 to 3.9.0
import { TresCamera } from '../types/'; | ||
import { RendererPresetsType } from '../composables/useRenderer/const'; | ||
import { TresContext } from '../composables'; | ||
import { WebGLRendererParameters, ColorSpace, ShadowMapType, ToneMapping } from 'three'; | ||
import { ColorSpace, ShadowMapType, ToneMapping, WebGLRendererParameters } from 'three'; | ||
@@ -32,5 +32,5 @@ export interface TresCanvasProps extends Omit<WebGLRendererParameters, 'canvas'> { | ||
}>, { | ||
context: import("vue").ShallowRef<TresContext | null>; | ||
context: import('vue').ShallowRef<TresContext | null>; | ||
dispose: () => void; | ||
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<TresCanvasProps>, { | ||
}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<TresCanvasProps>, { | ||
alpha: undefined; | ||
@@ -60,5 +60,5 @@ depth: undefined; | ||
}, {}>, Readonly<{ | ||
default(): any; | ||
default: () => any; | ||
}> & { | ||
default(): any; | ||
default: () => any; | ||
}>; | ||
@@ -65,0 +65,0 @@ export default _default; |
import { Loader, Object3D } from 'three'; | ||
export interface TresLoader<T> extends Loader { | ||
load(url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): unknown; | ||
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<T>; | ||
load: (url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void) => unknown; | ||
loadAsync: (url: string, onProgress?: (event: ProgressEvent) => void) => Promise<T>; | ||
} | ||
@@ -7,0 +7,0 @@ export type LoaderProto<T> = new (...args: any) => TresLoader<T extends unknown ? any : T>; |
import { TresContext } from '../useTresContextProvider'; | ||
import { TresScene } from 'src/types'; | ||
import { Intersection, Event, Object3D } from 'three'; | ||
import { Event, Intersection, Object3D } from 'three'; | ||
@@ -5,0 +5,0 @@ type CallbackFn = (intersection: Intersection<Object3D<Event>>, event: PointerEvent) => void; |
import { TresContext } from '../useTresContextProvider'; | ||
import { Ref } from 'vue'; | ||
import { Object3D, Intersection, Object3DEventMap } from 'three'; | ||
import { Intersection, Object3D, Object3DEventMap } from 'three'; | ||
@@ -5,0 +5,0 @@ export type Intersects = Intersection<Object3D<Object3DEventMap>>[]; |
@@ -6,3 +6,3 @@ import { RendererPresetsType } from './const'; | ||
import { MaybeRef } from 'vue'; | ||
import { WebGLRenderer, Scene, ToneMapping, ColorSpace, ShadowMapType, WebGLRendererParameters } from 'three'; | ||
import { WebGLRenderer, ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters } from 'three'; | ||
@@ -74,8 +74,2 @@ type TransformToMaybeRefOrGetter<T> = { | ||
} | ||
/** | ||
* Reactive three.js WebGLRenderer instance | ||
* | ||
* @param canvas | ||
* @param {UseRendererOptions} [options] | ||
*/ | ||
export declare function useRenderer({ scene, canvas, options, disableRender, contextParts: { sizes, camera }, }: { | ||
@@ -82,0 +76,0 @@ canvas: MaybeRef<HTMLCanvasElement>; |
@@ -1,2 +0,2 @@ | ||
import { Scene, Object3D } from 'three'; | ||
import { Object3D, Scene } from 'three'; | ||
@@ -3,0 +3,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { MaybeRefOrGetter, MaybeRef, ComputedRef, Ref } from 'vue'; | ||
import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue'; | ||
@@ -3,0 +3,0 @@ export interface SizesType { |
@@ -1,2 +0,2 @@ | ||
export declare const render: import('vue').RootRenderFunction<import("src").TresObject>; | ||
export declare const render: import('vue').RootRenderFunction<import('..').TresObject>; | ||
declare const _default: { | ||
@@ -3,0 +3,0 @@ extend: (objects: any) => any; |
@@ -0,1 +1,2 @@ | ||
import { vRotate } from './vRotate'; | ||
import { vDistanceTo } from './vDistanceTo'; | ||
@@ -6,2 +7,2 @@ import { vAlwaysLookAt } from './vAlwaysLookAt'; | ||
export { vLog, vLightHelper, vAlwaysLookAt, vDistanceTo }; | ||
export { vLog, vLightHelper, vAlwaysLookAt, vDistanceTo, vRotate }; |
@@ -111,6 +111,6 @@ import { EventProps as PointerEventHandlerEventProps } from '../composables/usePointerEventHandler'; | ||
interface MathRepresentation { | ||
set(...args: number[] | [THREE.ColorRepresentation]): any; | ||
set: (...args: number[] | [THREE.ColorRepresentation]) => any; | ||
} | ||
interface VectorRepresentation extends MathRepresentation { | ||
setScalar(s: number): any; | ||
setScalar: (s: number) => any; | ||
} | ||
@@ -134,7 +134,7 @@ export interface VectorCoordinates { | ||
interface RaycastableRepresentation { | ||
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void; | ||
raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void; | ||
} | ||
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown; | ||
export interface VueProps<P> { | ||
children?: VNode[]; | ||
children?: VNode<P>[]; | ||
ref?: VNodeRef; | ||
@@ -141,0 +141,0 @@ key?: string | number | symbol; |
@@ -1,2 +0,2 @@ | ||
import { MeshBasicMaterial, Vector3, Mesh, Scene, Object3D } from 'three'; | ||
import { MeshBasicMaterial, Vector3, Mesh, Object3D, Scene } from 'three'; | ||
@@ -3,0 +3,0 @@ export declare function toSetMethodName(key: string): string; |
@@ -1,2 +0,2 @@ | ||
import { ColorRepresentation, Vector3, Color } from 'three'; | ||
import { ColorRepresentation, Color, Vector3 } from 'three'; | ||
@@ -3,0 +3,0 @@ export type SizeFlexibleParams = number[] | { |
532
dist/tres.js
/** | ||
* name: @tresjs/core | ||
* version: v3.8.1 | ||
* version: v3.9.0 | ||
* (c) 2024 | ||
@@ -8,10 +8,10 @@ * description: Declarative ThreeJS using Vue Components | ||
*/ | ||
var De = Object.defineProperty; | ||
var Be = (e, r, t) => r in e ? De(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t; | ||
var J = (e, r, t) => (Be(e, typeof r != "symbol" ? r + "" : r, t), t); | ||
import { ref as R, computed as T, watchEffect as D, onUnmounted as G, shallowRef as j, watch as ge, reactive as ve, readonly as q, provide as K, inject as je, createRenderer as He, defineComponent as ne, useSlots as Re, getCurrentInstance as se, onMounted as Ie, openBlock as $e, createElementBlock as Ne, normalizeClass as Ve, unref as ze, normalizeStyle as We, h as ie, Fragment as Ue } from "vue"; | ||
var Oe = Object.defineProperty; | ||
var De = (e, r, t) => r in e ? Oe(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t; | ||
var Q = (e, r, t) => (De(e, typeof r != "symbol" ? r + "" : r, t), t); | ||
import { ref as A, computed as L, watchEffect as B, onUnmounted as U, shallowRef as H, watch as ge, reactive as ve, readonly as Y, provide as K, inject as Be, createRenderer as je, defineComponent as ne, useSlots as He, getCurrentInstance as se, onMounted as Re, openBlock as Ie, createElementBlock as $e, normalizeClass as ze, unref as Ne, normalizeStyle as We, h as ie, Fragment as Ve } from "vue"; | ||
import * as he from "three"; | ||
import { PerspectiveCamera as X, OrthographicCamera as Fe, Camera as Ge, Clock as Je, Vector3 as ye, Color as W, MeshBasicMaterial as we, DoubleSide as Qe, REVISION as Ye, SRGBColorSpace as qe, ACESFilmicToneMapping as Ke, PCFSoftShadowMap as Xe, WebGLRenderer as Q, TextureLoader as Ze, Vector2 as et, Raycaster as tt, BufferAttribute as rt, Scene as ot, Line as nt, BufferGeometry as ae, Float32BufferAttribute as le, LineBasicMaterial as st, Mesh as it, BackSide as at, DirectionalLightHelper as lt, PointLightHelper as ut, SpotLightHelper as ct, HemisphereLightHelper as dt, ArrowHelper as ft } from "three"; | ||
import { createEventHook as H, useRafFn as be, toValue as _, unrefElement as pt, useDevicePixelRatio as mt, usePointer as gt, useElementBounding as vt, useWindowSize as ht, useElementSize as yt, refDebounced as ue, useFps as wt, useMemory as bt } from "@vueuse/core"; | ||
const _t = "@tresjs/core", Et = "module", Ct = "3.8.1", Mt = "pnpm@8.15.6", xt = "Declarative ThreeJS using Vue Components", St = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", Pt = "MIT", kt = [ | ||
import { PerspectiveCamera as X, OrthographicCamera as Fe, Camera as Ue, Clock as Ge, Vector3 as te, Color as W, MeshBasicMaterial as ye, DoubleSide as Qe, REVISION as qe, SRGBColorSpace as Je, ACESFilmicToneMapping as Ye, PCFSoftShadowMap as Ke, WebGLRenderer as q, TextureLoader as Xe, Vector2 as Ze, Raycaster as et, BufferAttribute as tt, Scene as rt, Line as ot, BufferGeometry as ae, Float32BufferAttribute as le, LineBasicMaterial as nt, Mesh as st, BackSide as it, DirectionalLightHelper as at, PointLightHelper as lt, SpotLightHelper as ut, HemisphereLightHelper as ct, ArrowHelper as dt, Quaternion as ft } from "three"; | ||
import { createEventHook as R, useRafFn as we, toValue as E, unrefElement as pt, useDevicePixelRatio as mt, usePointer as gt, useElementBounding as vt, useWindowSize as ht, useElementSize as yt, refDebounced as ue, useFps as wt, useMemory as _t } from "@vueuse/core"; | ||
const bt = "@tresjs/core", Et = "module", Ct = "3.9.0", xt = "pnpm@8.15.6", Mt = "Declarative ThreeJS using Vue Components", St = "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)", kt = "MIT", Pt = [ | ||
"vue", | ||
@@ -25,4 +25,4 @@ "3d", | ||
types: "./dist/index.d.ts", | ||
require: "./dist/tres.umd.cjs", | ||
import: "./dist/tres.js" | ||
import: "./dist/tres.js", | ||
require: "./dist/tres.umd.cjs" | ||
}, | ||
@@ -43,4 +43,4 @@ "./components": { | ||
}, Lt = "./dist/tres.js", Ot = "./dist/tres.js", Dt = "./dist/index.d.ts", Bt = [ | ||
"dist", | ||
"*.d.ts" | ||
"*.d.ts", | ||
"dist" | ||
], jt = { | ||
@@ -57,3 +57,4 @@ access: "public" | ||
coverage: "vitest run --coverage", | ||
lint: "eslint . --ext .js,.jsx,.ts,.tsx,.vue", | ||
lint: "eslint .", | ||
"lint:fix": "eslint . --fix", | ||
"docs:dev": "vitepress dev docs", | ||
@@ -63,3 +64,4 @@ "docs:build": "vitepress build docs", | ||
"docs:preview": "vitepress preview docs", | ||
"docs:contributors": "esno scripts/update-contributors.ts" | ||
"docs:contributors": "esno scripts/update-contributors.ts", | ||
prepare: "node .husky/install.mjs" | ||
}, Rt = { | ||
@@ -76,14 +78,16 @@ three: ">=0.133", | ||
"@tresjs/cientos": "3.8.0", | ||
"@tresjs/eslint-config": "^1.0.0", | ||
"@tresjs/eslint-config-vue": "^0.2.1", | ||
"@types/three": "^0.163.0", | ||
"@typescript-eslint/eslint-plugin": "^7.5.0", | ||
"@typescript-eslint/parser": "^7.5.0", | ||
"@typescript-eslint/eslint-plugin": "^7.7.1", | ||
"@typescript-eslint/parser": "^7.7.1", | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"@vitest/ui": "^1.0.4", | ||
"@vitest/ui": "^1.5.0", | ||
"@vue/test-utils": "^2.4.3", | ||
eslint: "^8.55.0", | ||
"eslint-plugin-vue": "^9.19.2", | ||
eslint: "^9.1.1", | ||
"eslint-plugin-vue": "^9.25.0", | ||
esno: "^4.0.0", | ||
gsap: "^3.12.3", | ||
husky: "^9.0.11", | ||
jsdom: "^24.0.0", | ||
@@ -93,3 +97,3 @@ kolorist: "^1.8.0", | ||
pathe: "^1.1.1", | ||
"release-it": "^17.0.1", | ||
"release-it": "^17.2.0", | ||
"rollup-plugin-analyzer": "^4.0.0", | ||
@@ -99,24 +103,24 @@ "rollup-plugin-copy": "^3.5.0", | ||
three: "^0.163.0", | ||
unocss: "^0.58.0", | ||
unocss: "^0.59.4", | ||
unplugin: "^1.10.1", | ||
"unplugin-vue-components": "^0.26.0", | ||
vite: "^5.2.7", | ||
vite: "^5.2.10", | ||
"vite-plugin-banner": "^0.7.1", | ||
"vite-plugin-dts": "3.8.1", | ||
"vite-plugin-inspect": "^0.8.1", | ||
"vite-plugin-dts": "3.9.0", | ||
"vite-plugin-inspect": "^0.8.4", | ||
"vite-plugin-require-transform": "^1.0.21", | ||
"vite-svg-loader": "^5.1.0", | ||
vitepress: "1.0.2", | ||
vitest: "^1.0.4", | ||
vue: "^3.3.11", | ||
vitepress: "1.1.3", | ||
vitest: "^1.5.0", | ||
vue: "^3.4.24", | ||
"vue-demi": "^0.14.6" | ||
}, Nt = { | ||
name: _t, | ||
}, zt = { | ||
name: bt, | ||
type: Et, | ||
version: Ct, | ||
packageManager: Mt, | ||
description: xt, | ||
packageManager: xt, | ||
description: Mt, | ||
author: St, | ||
license: Pt, | ||
keywords: kt, | ||
license: kt, | ||
keywords: Pt, | ||
sideEffects: Tt, | ||
@@ -133,11 +137,7 @@ exports: At, | ||
devDependencies: $t | ||
}, Vt = ({ sizes: e, scene: r }) => { | ||
const t = R([]), o = T( | ||
}, Nt = ({ sizes: e, scene: r }) => { | ||
const t = A([]), o = L( | ||
() => t.value[0] | ||
), s = (a, l = !1) => { | ||
t.value.some(({ uuid: c }) => c === a.uuid) || (l ? n(a) : t.value.push(a)); | ||
}, i = (a) => { | ||
t.value = t.value.filter(({ uuid: l }) => l !== a.uuid); | ||
}, n = (a) => { | ||
const l = a instanceof Ge ? a : t.value.find((m) => m.uuid === a); | ||
), s = (a) => { | ||
const l = a instanceof Ue ? a : t.value.find((m) => m.uuid === a); | ||
if (!l) | ||
@@ -147,8 +147,12 @@ return; | ||
t.value = [l, ...c]; | ||
}, i = (a, l = !1) => { | ||
t.value.some(({ uuid: c }) => c === a.uuid) || (l ? s(a) : t.value.push(a)); | ||
}, n = (a) => { | ||
t.value = t.value.filter(({ uuid: l }) => l !== a.uuid); | ||
}; | ||
return D(() => { | ||
return B(() => { | ||
e.aspectRatio.value && t.value.forEach((a) => { | ||
a instanceof X && (a.aspect = e.aspectRatio.value), (a instanceof X || a instanceof Fe) && a.updateProjectionMatrix(); | ||
}); | ||
}), r.userData.tres__registerCamera = s, r.userData.tres__deregisterCamera = i, G(() => { | ||
}), r.userData.tres__registerCamera = i, r.userData.tres__deregisterCamera = n, U(() => { | ||
t.value = []; | ||
@@ -158,31 +162,31 @@ }), { | ||
cameras: t, | ||
registerCamera: s, | ||
deregisterCamera: i, | ||
setCameraActive: n | ||
registerCamera: i, | ||
deregisterCamera: n, | ||
setCameraActive: s | ||
}; | ||
}, _e = H(), Ee = H(), te = H(), B = new Je(); | ||
let U = 0, F = 0; | ||
const { pause: zt, resume: Wt, isActive: Ut } = be( | ||
}, _e = R(), be = R(), re = R(), j = new Ge(); | ||
let V = 0, F = 0; | ||
const { pause: Wt, resume: Vt, isActive: Ft } = we( | ||
() => { | ||
_e.trigger({ delta: U, elapsed: F, clock: B }), Ee.trigger({ delta: U, elapsed: F, clock: B }), te.trigger({ delta: U, elapsed: F, clock: B }); | ||
_e.trigger({ delta: V, elapsed: F, clock: j }), be.trigger({ delta: V, elapsed: F, clock: j }), re.trigger({ delta: V, elapsed: F, clock: j }); | ||
}, | ||
{ immediate: !1 } | ||
); | ||
te.on(() => { | ||
U = B.getDelta(), F = B.getElapsedTime(); | ||
re.on(() => { | ||
V = j.getDelta(), F = j.getElapsedTime(); | ||
}); | ||
const re = () => ({ | ||
const G = () => ({ | ||
onBeforeLoop: _e.on, | ||
onLoop: Ee.on, | ||
onAfterLoop: te.on, | ||
pause: zt, | ||
resume: Wt, | ||
isActive: Ut | ||
}), Rr = !0, $ = "[TresJS ▲ ■ ●] "; | ||
function A() { | ||
onLoop: be.on, | ||
onAfterLoop: re.on, | ||
pause: Wt, | ||
resume: Vt, | ||
isActive: Ft | ||
}), Ir = !0, I = "[TresJS ▲ ■ ●] "; | ||
function P() { | ||
function e(...o) { | ||
typeof o[0] == "string" ? o[0] = $ + o[0] : o.unshift($), console.error(...o); | ||
typeof o[0] == "string" ? o[0] = I + o[0] : o.unshift(I), console.error(...o); | ||
} | ||
function r(...o) { | ||
typeof o[0] == "string" ? o[0] = $ + o[0] : o.unshift($), console.warn(...o); | ||
typeof o[0] == "string" ? o[0] = I + o[0] : o.unshift(I), console.warn(...o); | ||
} | ||
@@ -197,6 +201,6 @@ function t(o, s) { | ||
} | ||
function Ir(e) { | ||
return typeof e == "number" ? [e, e, e] : e instanceof ye ? [e.x, e.y, e.z] : e; | ||
function $r(e) { | ||
return typeof e == "number" ? [e, e, e] : e instanceof te ? [e.x, e.y, e.z] : e; | ||
} | ||
function Ft(e) { | ||
function Ut(e) { | ||
return e instanceof W ? e : Array.isArray(e) ? new W(...e) : new W(e); | ||
@@ -207,4 +211,4 @@ } | ||
super(...t); | ||
J(this, "type", "HightlightMesh"); | ||
J(this, "createTime"); | ||
Q(this, "type", "HightlightMesh"); | ||
Q(this, "createTime"); | ||
this.createTime = Date.now(); | ||
@@ -217,14 +221,14 @@ } | ||
} | ||
const Ce = (e, r) => { | ||
const Ee = (e, r) => { | ||
for (const t of Object.keys(r)) | ||
r[t] instanceof Object && Object.assign(r[t], Ce(e[t], r[t])); | ||
r[t] instanceof Object && Object.assign(r[t], Ee(e[t], r[t])); | ||
return Object.assign(e || {}, r), e; | ||
}, Jt = "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", Qt = /* @__PURE__ */ Yt(Jt); | ||
}, Qt = "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", qt = /* @__PURE__ */ Jt(Qt); | ||
function ce(e) { | ||
return e && e.nodeType === 1; | ||
} | ||
function N(e) { | ||
function $(e) { | ||
return e.replace(/-([a-z])/g, (r, t) => t.toUpperCase()); | ||
} | ||
function Yt(e, r) { | ||
function Jt(e, r) { | ||
const t = /* @__PURE__ */ Object.create(null), o = e.split(","); | ||
@@ -235,3 +239,3 @@ for (let s = 0; s < o.length; s++) | ||
} | ||
const qt = (e, r) => { | ||
const Yt = (e, r) => { | ||
const t = /* @__PURE__ */ new Set(), o = []; | ||
@@ -252,3 +256,3 @@ for (const s of e) { | ||
}; | ||
function Me(e, r) { | ||
function Ce(e, r) { | ||
if (ce(e) && ce(r)) { | ||
@@ -266,3 +270,3 @@ const s = e.attributes, i = r.attributes; | ||
for (const s of t) | ||
if (!o.includes(s) || !Me(e[s], r[s])) | ||
if (!o.includes(s) || !Ce(e[s], r[s])) | ||
return !1; | ||
@@ -275,3 +279,3 @@ return !0; | ||
for (let t = 0; t < e.length; t++) | ||
if (!Me(e[t], r[t])) | ||
if (!Ce(e[t], r[t])) | ||
return !1; | ||
@@ -307,3 +311,3 @@ return !0; | ||
function tr(e) { | ||
const r = new we({ | ||
const r = new ye({ | ||
color: 11003607, | ||
@@ -323,14 +327,14 @@ // Highlight color, e.g., yellow | ||
let r = e.value; | ||
return e.value && ((t = e.value) != null && t.isMesh) && (r = e.value.position), Array.isArray(e.value) && (r = new ye(...r)), r; | ||
return e.value && ((t = e.value) != null && t.isMesh) && (r = e.value.position), Array.isArray(e.value) && (r = new te(...r)), r; | ||
} | ||
const rr = Number.parseInt(Ye.replace("dev", "")), V = { | ||
const rr = Number.parseInt(qe.replace("dev", "")), z = { | ||
realistic: { | ||
shadows: !0, | ||
physicallyCorrectLights: !0, | ||
outputColorSpace: qe, | ||
toneMapping: Ke, | ||
outputColorSpace: Je, | ||
toneMapping: Ye, | ||
toneMappingExposure: 3, | ||
shadowMap: { | ||
enabled: !0, | ||
type: Xe | ||
type: Ke | ||
} | ||
@@ -346,27 +350,27 @@ } | ||
}) { | ||
const n = T(() => ({ | ||
alpha: _(t.alpha), | ||
depth: _(t.depth), | ||
const n = L(() => ({ | ||
alpha: E(t.alpha), | ||
depth: E(t.depth), | ||
canvas: pt(r), | ||
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) | ||
})), a = j(new Q(n.value)); | ||
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) | ||
})), a = H(new q(n.value)); | ||
ge(n, () => { | ||
a.value.dispose(), a.value = new Q(n.value); | ||
}), D(() => { | ||
a.value.dispose(), a.value = new q(n.value); | ||
}), B(() => { | ||
a.value.setSize(s.width.value, s.height.value); | ||
}); | ||
const { pixelRatio: l } = mt(); | ||
D(() => { | ||
B(() => { | ||
a.value.setPixelRatio(l.value); | ||
}); | ||
const { logError: c } = A(), d = (() => { | ||
const p = new Q(), y = { | ||
const { logError: c } = P(), d = (() => { | ||
const p = new q(), y = { | ||
shadowMap: { | ||
@@ -382,9 +386,9 @@ enabled: p.shadowMap.enabled, | ||
})(); | ||
D(() => { | ||
const p = _(t.preset); | ||
p && (p in V || c(`Renderer Preset must be one of these: ${Object.keys(V).join(", ")}`), Ce(a.value, V[p])); | ||
const y = (C, M) => { | ||
const w = _(C), S = () => { | ||
B(() => { | ||
const p = E(t.preset); | ||
p && (p in z || c(`Renderer Preset must be one of these: ${Object.keys(z).join(", ")}`), Ee(a.value, z[p])); | ||
const y = (C, x) => { | ||
const w = E(C), S = () => { | ||
if (p) | ||
return de(V[p], M); | ||
return de(z[p], x); | ||
}; | ||
@@ -394,15 +398,15 @@ if (w !== void 0) | ||
const v = S(); | ||
return v !== void 0 ? v : de(d, M); | ||
}, b = (C, M) => Kt(a.value, M, y(C, M)); | ||
return v !== void 0 ? v : de(d, x); | ||
}, b = (C, x) => Kt(a.value, x, y(C, x)); | ||
b(t.shadows, "shadowMap.enabled"), b(t.toneMapping, "toneMapping"), b(t.shadowMapType, "shadowMap.type"), rr < 150 && b(!t.useLegacyLights, "physicallyCorrectLights"), b(t.outputColorSpace, "outputColorSpace"), b(t.toneMappingExposure, "toneMappingExposure"); | ||
const x = y(t.clearColor, "clearColor"); | ||
x && a.value.setClearColor( | ||
x ? Ft(x) : new W(0) | ||
const M = y(t.clearColor, "clearColor"); | ||
M && a.value.setClearColor( | ||
M ? Ut(M) : new W(0) | ||
// default clear color is not easily/efficiently retrievable from three | ||
); | ||
}); | ||
const { pause: u, resume: f, onLoop: h } = re(); | ||
const { pause: u, resume: f, onLoop: h } = G(); | ||
return h(() => { | ||
i.value && !_(o) && a.value.render(e, i.value); | ||
}), f(), G(() => { | ||
i.value && !E(o) && a.value.render(e, i.value); | ||
}), f(), U(() => { | ||
u(), a.value.dispose(), a.value.forceContextLoss(); | ||
@@ -420,4 +424,4 @@ }), { | ||
} | ||
async function $r(e, r, t, o, s) { | ||
const { logError: i } = A(), n = new e(); | ||
async function zr(e, r, t, o, s) { | ||
const { logError: i } = P(), n = new e(); | ||
s && s(n), t && t(n); | ||
@@ -439,3 +443,3 @@ const l = (Array.isArray(r) ? r : [r]).map( | ||
async function Nr(e, r) { | ||
const t = new Ze(r), o = (s) => new Promise((i, n) => { | ||
const t = new Xe(r), o = (s) => new Promise((i, n) => { | ||
t.load( | ||
@@ -477,32 +481,32 @@ s, | ||
const ir = (e, { renderer: r, camera: t, raycaster: o }) => { | ||
const s = T(() => r.value.domElement), { x: i, y: n } = gt({ target: s }), { width: a, height: l, top: c, left: m } = vt(s), d = ({ x: v, y: E }) => { | ||
const s = L(() => r.value.domElement), { x: i, y: n } = gt({ target: s }), { width: a, height: l, top: c, left: m } = vt(s), d = ({ x: v, y: _ }) => { | ||
if (s.value) | ||
return { | ||
x: (v - m.value) / a.value * 2 - 1, | ||
y: -((E - c.value) / l.value) * 2 + 1 | ||
y: -((_ - c.value) / l.value) * 2 + 1 | ||
}; | ||
}, u = ({ x: v, y: E }) => { | ||
}, u = ({ x: v, y: _ }) => { | ||
if (t.value) | ||
return o.value.setFromCamera(new et(v, E), t.value), o.value.intersectObjects(e.value, !1); | ||
return o.value.setFromCamera(new Ze(v, _), t.value), o.value.intersectObjects(e.value, !1); | ||
}, f = (v) => { | ||
const E = d({ | ||
const _ = d({ | ||
x: (v == null ? void 0 : v.clientX) ?? i.value, | ||
y: (v == null ? void 0 : v.clientY) ?? n.value | ||
}); | ||
return E ? u(E) || [] : []; | ||
}, h = T(() => f()), p = H(), y = H(), b = (v, E) => { | ||
v.trigger({ event: E, intersects: f(E) }); | ||
}, x = (v) => { | ||
return _ ? u(_) || [] : []; | ||
}, h = L(() => f()), p = R(), y = R(), b = (v, _) => { | ||
v.trigger({ event: _, intersects: f(_) }); | ||
}, M = (v) => { | ||
b(y, v); | ||
}; | ||
let C; | ||
const M = (v) => { | ||
var E; | ||
C = (E = f(v)[0]) == null ? void 0 : E.object; | ||
const x = (v) => { | ||
var _; | ||
C = (_ = f(v)[0]) == null ? void 0 : _.object; | ||
}, w = (v) => { | ||
var E; | ||
v instanceof PointerEvent && C === ((E = f(v)[0]) == null ? void 0 : E.object) && b(p, v); | ||
var _; | ||
v instanceof PointerEvent && C === ((_ = f(v)[0]) == null ? void 0 : _.object) && b(p, v); | ||
}, S = (v) => y.trigger({ event: v, intersects: [] }); | ||
return s.value.addEventListener("pointerup", w), s.value.addEventListener("pointerdown", M), s.value.addEventListener("pointermove", x), s.value.addEventListener("pointerleave", S), G(() => { | ||
s != null && s.value && (s.value.removeEventListener("pointerup", w), s.value.removeEventListener("pointerdown", M), s.value.removeEventListener("pointermove", x), s.value.removeEventListener("pointerleave", S)); | ||
return s.value.addEventListener("pointerup", w), s.value.addEventListener("pointerdown", x), s.value.addEventListener("pointermove", M), s.value.addEventListener("pointerleave", S), U(() => { | ||
s != null && s.value && (s.value.removeEventListener("pointerup", w), s.value.removeEventListener("pointerdown", x), s.value.removeEventListener("pointermove", M), s.value.removeEventListener("pointerleave", S)); | ||
}), { | ||
@@ -514,4 +518,4 @@ intersects: h, | ||
}; | ||
function Vr() { | ||
const { logWarning: e } = A(); | ||
function Wr() { | ||
const { logWarning: e } = P(); | ||
function r(i, n, a) { | ||
@@ -548,3 +552,3 @@ let l = null; | ||
pointerLeave: /* @__PURE__ */ new Map() | ||
}), o = R(/* @__PURE__ */ new Set()), s = (u) => { | ||
}), o = A(/* @__PURE__ */ new Set()), s = (u) => { | ||
o.value.add(u); | ||
@@ -560,4 +564,4 @@ }, i = (u) => { | ||
e.userData.tres__registerAtPointerEventHandler = a, e.userData.tres__deregisterAtPointerEventHandler = n, e.userData.tres__registerBlockingObjectAtPointerEventHandler = s, e.userData.tres__deregisterBlockingObjectAtPointerEventHandler = i; | ||
const l = T( | ||
() => qt( | ||
const l = L( | ||
() => Yt( | ||
[ | ||
@@ -576,5 +580,5 @@ ...Array.from(o.value), | ||
return m(({ intersects: u, event: f }) => { | ||
var x, C, M, w; | ||
const h = (x = u == null ? void 0 : u[0]) == null ? void 0 : x.object, { pointerLeave: p, pointerEnter: y, pointerMove: b } = t; | ||
d && d !== h && ((C = p.get(d)) == null || C(d, f)), h && (d !== h && ((M = y.get(h)) == null || M(u[0], f)), (w = b.get(h)) == null || w(u[0], f)), d = h || null; | ||
var M, C, x, w; | ||
const h = (M = u == null ? void 0 : u[0]) == null ? void 0 : M.object, { pointerLeave: p, pointerEnter: y, pointerMove: b } = t; | ||
d && d !== h && ((C = p.get(d)) == null || C(d, f)), h && (d !== h && ((x = y.get(h)) == null || x(u[0], f)), (w = b.get(h)) == null || w(u[0], f)), d = h || null; | ||
}), { | ||
@@ -585,3 +589,3 @@ registerObject: a, | ||
}; | ||
function Se(e) { | ||
function Me(e) { | ||
let r = 0; | ||
@@ -598,5 +602,5 @@ return e.traverse((t) => { | ||
} | ||
const Z = R({}), oe = (e) => Object.assign(Z.value, e); | ||
const Z = A({}), oe = (e) => Object.assign(Z.value, e); | ||
function ur(e, r, t = 10) { | ||
const o = _(e) ? ht() : yt(T(() => _(r).parentElement)), s = q(ue(o.width, t)), i = q(ue(o.height, t)), n = T(() => s.value / i.value); | ||
const o = E(e) ? ht() : yt(L(() => E(r).parentElement)), s = Y(ue(o.width, t)), i = Y(ue(o.height, t)), n = L(() => s.value / i.value); | ||
return { | ||
@@ -615,3 +619,3 @@ height: i, | ||
}) { | ||
const i = ur(t, r), n = j(e), { | ||
const i = ur(t, r), n = H(e), { | ||
camera: a, | ||
@@ -622,3 +626,3 @@ cameras: l, | ||
setCameraActive: d | ||
} = Vt({ sizes: i, scene: e }), { renderer: u } = or( | ||
} = Nt({ sizes: i, scene: e }), { renderer: u } = or( | ||
{ | ||
@@ -635,6 +639,6 @@ scene: e, | ||
camera: a, | ||
cameras: q(l), | ||
cameras: Y(l), | ||
renderer: u, | ||
raycaster: j(new tt()), | ||
controls: R(null), | ||
raycaster: H(new et()), | ||
controls: A(null), | ||
perf: { | ||
@@ -658,12 +662,12 @@ maxFrames: 160, | ||
K("useTres", f); | ||
const h = 100, p = wt({ every: h }), { isSupported: y, memory: b } = bt({ interval: h }), x = 160; | ||
const h = 100, p = wt({ every: h }), { isSupported: y, memory: b } = _t({ interval: h }), M = 160; | ||
let C = performance.now(); | ||
const M = ({ timestamp: I }) => { | ||
f.scene.value && (f.perf.memory.allocatedMem = Se(f.scene.value)), I - C >= h && (C = I, f.perf.fps.accumulator.push(p.value), f.perf.fps.accumulator.length > x && f.perf.fps.accumulator.shift(), f.perf.fps.value = p.value, y.value && b.value && (f.perf.memory.accumulator.push(b.value.usedJSHeapSize / 1024 / 1024), f.perf.memory.accumulator.length > x && f.perf.memory.accumulator.shift(), f.perf.memory.currentMem = f.perf.memory.accumulator.reduce((Le, Oe) => Le + Oe, 0) / f.perf.memory.accumulator.length)); | ||
const x = ({ timestamp: _ }) => { | ||
f.scene.value && (f.perf.memory.allocatedMem = Me(f.scene.value)), _ - C >= h && (C = _, f.perf.fps.accumulator.push(p.value), f.perf.fps.accumulator.length > M && f.perf.fps.accumulator.shift(), f.perf.fps.value = p.value, y.value && b.value && (f.perf.memory.accumulator.push(b.value.usedJSHeapSize / 1024 / 1024), f.perf.memory.accumulator.length > M && f.perf.memory.accumulator.shift(), f.perf.memory.currentMem = f.perf.memory.accumulator.reduce((Ae, Le) => Ae + Le, 0) / f.perf.memory.accumulator.length)); | ||
}; | ||
let w = 0; | ||
const S = 1, { pause: v, resume: E } = be(({ delta: I }) => { | ||
window.__TRES__DEVTOOLS__ && (M({ timestamp: performance.now() }), w += I, w >= S && (window.__TRES__DEVTOOLS__.cb(f), w = 0)); | ||
const S = 1, { pause: v } = we(({ delta: _ }) => { | ||
window.__TRES__DEVTOOLS__ && (x({ timestamp: performance.now() }), w += _, w >= S && (window.__TRES__DEVTOOLS__.cb(f), w = 0)); | ||
}, { immediate: !0 }); | ||
return G(() => { | ||
return U(() => { | ||
v(); | ||
@@ -673,3 +677,3 @@ }), f; | ||
function dr() { | ||
const e = je("useTres"); | ||
const e = Be("useTres"); | ||
if (!e) | ||
@@ -679,5 +683,5 @@ throw new Error("useTresContext must be used together with useTresContextProvider"); | ||
} | ||
const zr = dr; | ||
const Vr = dr; | ||
let g = null; | ||
const { logError: pe } = A(), Y = [ | ||
const { logError: pe } = P(), J = [ | ||
"onClick", | ||
@@ -690,3 +694,3 @@ "onPointerMove", | ||
var n, a; | ||
if (o || (o = {}), o.args || (o.args = []), e === "template" || Qt(e)) | ||
if (o || (o = {}), o.args || (o.args = []), e === "template" || qt(e)) | ||
return null; | ||
@@ -714,8 +718,8 @@ let s = e.replace("Tres", ""), i; | ||
if (!(g != null && g.userData.tres__registerCamera)) | ||
throw "could not find tres__registerCamera on scene's userData"; | ||
throw new Error("could not find tres__registerCamera on scene's userData"); | ||
(s = g == null ? void 0 : (o = g.userData).tres__registerCamera) == null || s.call(o, e); | ||
} | ||
if (e && Y.some((a) => e[a])) { | ||
if (e && J.some((a) => e[a])) { | ||
if (!(g != null && g.userData.tres__registerAtPointerEventHandler)) | ||
throw "could not find tres__registerAtPointerEventHandler on scene's userData"; | ||
throw new Error("could not find tres__registerAtPointerEventHandler on scene's userData"); | ||
(n = g == null ? void 0 : (i = g.userData).tres__registerAtPointerEventHandler) == null || n.call(i, e); | ||
@@ -737,10 +741,10 @@ } | ||
if (!n) | ||
throw "could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData"; | ||
throw new Error("could not find tres__deregisterBlockingObjectAtPointerEventHandler on scene's userData"); | ||
if ((d = g == null ? void 0 : (m = g.userData).tres__deregisterBlockingObjectAtPointerEventHandler) == null || d.call(m, c), !i) | ||
throw "could not find tres__deregisterAtPointerEventHandler on scene's userData"; | ||
c && Y.some((u) => c[u]) && (i == null || i(c)); | ||
throw new Error("could not find tres__deregisterAtPointerEventHandler on scene's userData"); | ||
c && J.some((u) => c[u]) && (i == null || i(c)); | ||
}, l = (c) => { | ||
const m = g == null ? void 0 : g.userData.tres__deregisterCamera; | ||
if (!m) | ||
throw "could not find tres__deregisterCamera on scene's userData"; | ||
throw new Error("could not find tres__deregisterCamera on scene's userData"); | ||
c.isCamera && (m == null || m(c)); | ||
@@ -763,3 +767,3 @@ }; | ||
} | ||
let m = N(c), d = l == null ? void 0 : l[m]; | ||
let m = $(c), d = l == null ? void 0 : l[m]; | ||
if (c === "args") { | ||
@@ -774,4 +778,4 @@ const f = e, h = t ?? [], p = o ?? [], y = e.userData.tres__name || e.type; | ||
l.setAttribute( | ||
N(c), | ||
new rt(...o) | ||
$(c), | ||
new tt(...o) | ||
); | ||
@@ -782,7 +786,7 @@ return; | ||
const f = c.split("-"); | ||
d = f.reduce((h, p) => h[N(p)], l), c = f.pop(), m = c.toLowerCase(), d != null && d.set || (l = f.reduce((h, p) => h[N(p)], l)); | ||
d = f.reduce((h, p) => h[$(p)], l), c = f.pop(), m = c.toLowerCase(), d != null && d.set || (l = f.reduce((h, p) => h[$(p)], l)); | ||
} | ||
let u = o; | ||
if (u === "" && (u = !0), fe(d)) { | ||
Y.includes(r) || (Array.isArray(u) ? e[m](...u) : e[m](u)); | ||
J.includes(r) || (Array.isArray(u) ? e[m](...u) : e[m](u)); | ||
return; | ||
@@ -805,15 +809,15 @@ } | ||
insertStaticContent: () => void 0 | ||
}, { render: pr } = He(fr); | ||
}, { render: pr } = je(fr); | ||
oe(he); | ||
function mr() { | ||
return Pe().__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
return Se().__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
} | ||
function Pe() { | ||
function Se() { | ||
return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {}; | ||
} | ||
const gr = typeof Proxy == "function", vr = "devtools-plugin:setup", hr = "plugin:settings:set"; | ||
let L, ee; | ||
let O, ee; | ||
function yr() { | ||
var e; | ||
return L !== void 0 || (typeof window < "u" && window.performance ? (L = !0, ee = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (L = !0, ee = globalThis.perf_hooks.performance) : L = !1), L; | ||
return O !== void 0 || (typeof window < "u" && window.performance ? (O = !0, ee = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (O = !0, ee = globalThis.perf_hooks.performance) : O = !1), O; | ||
} | ||
@@ -823,3 +827,3 @@ function wr() { | ||
} | ||
class br { | ||
class _r { | ||
constructor(r, t) { | ||
@@ -886,8 +890,8 @@ this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = r, this.hook = t; | ||
} | ||
function _r(e, r) { | ||
const t = e, o = Pe(), s = mr(), i = gr && t.enableEarlyProxy; | ||
function br(e, r) { | ||
const t = e, o = Se(), s = mr(), i = gr && t.enableEarlyProxy; | ||
if (s && (o.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !i)) | ||
s.emit(vr, e, r); | ||
else { | ||
const n = i ? new br(t, s) : null; | ||
const n = i ? new _r(t, s) : null; | ||
(o.__VUE_DEVTOOLS_PLUGINS__ = o.__VUE_DEVTOOLS_PLUGINS__ || []).push({ | ||
@@ -916,3 +920,3 @@ pluginDescriptor: t, | ||
}); | ||
const t = Se(e); | ||
const t = Me(e); | ||
return t > 0 && r.tags.push({ | ||
@@ -939,3 +943,2 @@ label: `${lr(t)} KB`, | ||
}), r.tags.push({ | ||
// eslint-disable-next-line max-len | ||
label: `x: ${Math.round(e.position.x)} y: ${Math.round(e.position.y)} z: ${Math.round(e.position.z)}`, | ||
@@ -947,3 +950,3 @@ textColor: 9738662, | ||
}; | ||
function Te(e, r) { | ||
function Pe(e, r) { | ||
e.children.forEach((t) => { | ||
@@ -953,10 +956,10 @@ if (t.type === "HightlightMesh") | ||
const o = ke(t); | ||
r.children.push(o), Te(t, o); | ||
r.children.push(o), Pe(t, o); | ||
}); | ||
} | ||
const Cr = [], O = "tres:inspector", Mr = ve({ | ||
const Cr = [], D = "tres:inspector", xr = ve({ | ||
sceneGraph: null | ||
}); | ||
function xr(e, r) { | ||
_r( | ||
function Mr(e, r) { | ||
br( | ||
{ | ||
@@ -973,6 +976,5 @@ id: "dev.esm.tres", | ||
typeof t.now != "function" && Er( | ||
// eslint-disable-next-line max-len | ||
"You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html." | ||
), t.addInspector({ | ||
id: O, | ||
id: D, | ||
label: "TresJS 🪐", | ||
@@ -982,9 +984,9 @@ icon: "account_tree", | ||
}), setInterval(() => { | ||
t.sendInspectorTree(O); | ||
t.sendInspectorTree(D); | ||
}, 1e3), setInterval(() => { | ||
t.notifyComponentUpdate(); | ||
}, 5e3), t.on.getInspectorTree((i) => { | ||
if (i.inspectorId === O) { | ||
if (i.inspectorId === D) { | ||
const n = ke(r.scene.value); | ||
Te(r.scene.value, n), Mr.sceneGraph = n, i.rootNodes = [n]; | ||
Pe(r.scene.value, n), xr.sceneGraph = n, i.rootNodes = [n]; | ||
} | ||
@@ -994,3 +996,3 @@ }); | ||
t.on.getInspectorState((i) => { | ||
if (i.inspectorId === O) { | ||
if (i.inspectorId === D) { | ||
const [n] = r.scene.value.getObjectsByProperty("uuid", i.nodeId); | ||
@@ -1091,3 +1093,3 @@ if (!n) | ||
}), t.on.editInspectorState((i) => { | ||
i.inspectorId === O && er(r.scene.value, i.nodeId, i.path, i.state.value); | ||
i.inspectorId === D && er(r.scene.value, i.nodeId, i.path, i.state.value); | ||
}); | ||
@@ -1097,3 +1099,3 @@ } | ||
} | ||
const Sr = ["data-scene", "data-tres"], Pr = /* @__PURE__ */ ne({ | ||
const Sr = ["data-scene", "data-tres"], kr = /* @__PURE__ */ ne({ | ||
__name: "TresCanvas", | ||
@@ -1126,18 +1128,18 @@ props: { | ||
var h; | ||
const t = e, { logWarning: o } = A(), s = R(), i = j(new ot()), { resume: n } = re(), a = Re(), l = (h = se()) == null ? void 0 : h.appContext.app, c = (p) => ne({ | ||
const t = e, o = He(), { logWarning: s } = P(), i = A(), n = H(new rt()), { resume: a } = G(), l = (h = se()) == null ? void 0 : h.appContext.app, c = (p) => ne({ | ||
setup() { | ||
var b; | ||
const y = (b = se()) == null ? void 0 : b.appContext; | ||
return y && (y.app = l), K("useTres", p), K("extend", oe), typeof window < "u" && xr(y.app, p), () => ie(Ue, null, a != null && a.default ? a.default() : []); | ||
return y && (y.app = l), K("useTres", p), K("extend", oe), typeof window < "u" && Mr(y.app, p), () => ie(Ve, null, o != null && o.default ? o.default() : []); | ||
} | ||
}), m = (p) => { | ||
const y = c(p); | ||
pr(ie(y), i.value); | ||
pr(ie(y), n.value); | ||
}, d = (p, y = !1) => { | ||
i.value.children = [], y && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), m(p), n(); | ||
}, u = T(() => t.disableRender), f = j(null); | ||
return r({ context: f, dispose: () => d(f.value, !0) }), Ie(() => { | ||
const p = s; | ||
n.value.children = [], y && (p.renderer.value.dispose(), p.renderer.value.renderLists.dispose(), p.renderer.value.forceContextLoss()), m(p), a(); | ||
}, u = L(() => t.disableRender), f = H(null); | ||
return r({ context: f, dispose: () => d(f.value, !0) }), Re(() => { | ||
const p = i; | ||
f.value = cr({ | ||
scene: i.value, | ||
scene: n.value, | ||
canvas: p, | ||
@@ -1147,6 +1149,6 @@ windowSize: t.windowSize, | ||
rendererOptions: t | ||
}), ar({ scene: i.value, contextParts: f.value }); | ||
const { registerCamera: y, camera: b, cameras: x, deregisterCamera: C } = f.value; | ||
}), ar({ scene: n.value, contextParts: f.value }); | ||
const { registerCamera: y, camera: b, cameras: M, deregisterCamera: C } = f.value; | ||
m(f.value); | ||
const M = () => { | ||
const x = () => { | ||
const w = new X( | ||
@@ -1159,4 +1161,4 @@ 45, | ||
w.position.set(3, 3, 3), w.lookAt(0, 0, 0), y(w); | ||
const S = D(() => { | ||
x.value.length >= 2 && (w.removeFromParent(), C(w), S == null || S()); | ||
const S = B(() => { | ||
M.value.length >= 2 && (w.removeFromParent(), C(w), S == null || S()); | ||
}); | ||
@@ -1172,11 +1174,11 @@ }; | ||
} | ||
), b.value || (o( | ||
), b.value || (s( | ||
"No camera found. Creating a default perspective camera. To have full control over a camera, please add one to the scene." | ||
), M()); | ||
}), (p, y) => ($e(), Ne("canvas", { | ||
), x()); | ||
}), (p, y) => (Ie(), $e("canvas", { | ||
ref_key: "canvas", | ||
ref: s, | ||
"data-scene": i.value.uuid, | ||
class: Ve(p.$attrs.class), | ||
"data-tres": `tresjs ${ze(Nt).version}`, | ||
ref: i, | ||
"data-scene": n.value.uuid, | ||
class: ze(p.$attrs.class), | ||
"data-tres": `tresjs ${Ne(zt).version}`, | ||
style: We({ | ||
@@ -1195,3 +1197,3 @@ display: "block", | ||
} | ||
}), kr = [ | ||
}), Pr = [ | ||
"TresCanvas", | ||
@@ -1203,6 +1205,6 @@ "TresLeches", | ||
compilerOptions: { | ||
isCustomElement: (e) => e.startsWith("Tres") && !kr.includes(e) || e === "primitive" | ||
isCustomElement: (e) => e.startsWith("Tres") && !Pr.includes(e) || e === "primitive" | ||
} | ||
} | ||
}, Wr = Tr, Ur = { | ||
}, Fr = Tr, Ur = { | ||
mounted: (e, r) => { | ||
@@ -1216,10 +1218,10 @@ if (r.arg) { | ||
}; | ||
class Ae extends nt { | ||
class Te extends ot { | ||
constructor(r, t) { | ||
const o = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0], s = new ae(); | ||
s.setAttribute("position", new le(o, 3)), s.computeBoundingSphere(); | ||
const i = new st({ fog: !1 }); | ||
const i = new nt({ fog: !1 }); | ||
super(s, i), this.light = r, this.color = t, this.type = "RectAreaLightHelper"; | ||
const n = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0], a = new ae(); | ||
a.setAttribute("position", new le(n, 3)), a.computeBoundingSphere(), this.add(new it(a, new we({ side: at, fog: !1 }))); | ||
a.setAttribute("position", new le(n, 3)), a.computeBoundingSphere(), this.add(new st(a, new ye({ side: it, fog: !1 }))); | ||
} | ||
@@ -1240,11 +1242,11 @@ updateMatrixWorld() { | ||
} | ||
const { logWarning: me } = A(); | ||
let z, k; | ||
const { logWarning: me } = P(); | ||
let N, T; | ||
const Ar = { | ||
DirectionalLight: lt, | ||
PointLight: ut, | ||
SpotLight: ct, | ||
HemisphereLight: dt, | ||
RectAreaLight: Ae | ||
}, Fr = { | ||
DirectionalLight: at, | ||
PointLight: lt, | ||
SpotLight: ut, | ||
HemisphereLight: ct, | ||
RectAreaLight: Te | ||
}, Gr = { | ||
mounted: (e) => { | ||
@@ -1255,6 +1257,6 @@ if (!e.isLight) { | ||
} | ||
z = Ar[e.type], e.parent.add(new z(e, 1, e.color.getHex())); | ||
N = Ar[e.type], e.parent.add(new N(e, 1, e.color.getHex())); | ||
}, | ||
updated: (e) => { | ||
k = e.parent.children.find((r) => r instanceof z), !(k instanceof Ae) && k.update(); | ||
T = e.parent.children.find((r) => r instanceof N), !(T instanceof Te) && T.update(); | ||
}, | ||
@@ -1266,5 +1268,5 @@ unmounted: (e) => { | ||
} | ||
k = e.parent.children.find((r) => r instanceof z), k && k.dispose && k.dispose(), e.parent.remove(k); | ||
T = e.parent.children.find((r) => r instanceof N), T && T.dispose && T.dispose(), e.parent.remove(T); | ||
} | ||
}, { logWarning: Lr } = A(), Gr = { | ||
}, { logWarning: Lr } = P(), Qr = { | ||
updated: (e, r) => { | ||
@@ -1276,3 +1278,3 @@ const t = xe(r); | ||
} | ||
const { onLoop: o } = re(); | ||
const { onLoop: o } = G(); | ||
o(() => { | ||
@@ -1282,3 +1284,5 @@ e.lookAt(t); | ||
} | ||
}, { logWarning: Or } = A(), Jr = { | ||
}, { logWarning: Or } = P(); | ||
let k = null; | ||
const qr = { | ||
updated: (e, r) => { | ||
@@ -1291,5 +1295,5 @@ var s; | ||
} | ||
P && (P.dispose(), e.parent.remove(P)); | ||
k && (k.dispose(), e.parent.remove(k)); | ||
const o = t.clone().sub(e.position); | ||
o.normalize(), P = new ft(o, e.position, e.position.distanceTo(t), 16776960), e.parent.add(P), console.table( | ||
o.normalize(), k = new dt(o, e.position, e.position.distanceTo(t), 16776960), e.parent.add(k), console.table( | ||
[ | ||
@@ -1303,37 +1307,49 @@ ["Distance:", e.position.distanceTo(t)], | ||
unmounted: (e) => { | ||
P == null || P.dispose(), e.parent.remove(P); | ||
k == null || k.dispose(), e.parent.remove(k); | ||
} | ||
}; | ||
let P = null; | ||
const Qr = { | ||
}, { logWarning: Dr } = P(), Jr = { | ||
mounted: (e, r) => { | ||
if (e.isCamera) { | ||
Dr(`Rotate the ${e.type} is not a good idea`); | ||
return; | ||
} | ||
const t = r.value ?? 0.01, o = A(r.modifiers.x || r.arg === "x" ? 1 : 0), s = A(r.modifiers.y || r.arg === "y" ? 1 : 0), i = A(r.modifiers.z || r.arg === "z" ? 1 : 0); | ||
o.value + s.value + i.value === 0 && (o.value = 1, s.value = 1); | ||
const n = new ft().setFromAxisAngle(new te(o.value, s.value, i.value).normalize(), t), { onLoop: a } = G(); | ||
a(() => { | ||
e.applyQuaternion(n); | ||
}); | ||
} | ||
}, Yr = { | ||
install(e) { | ||
e.component("TresCanvas", Pr); | ||
e.component("TresCanvas", kr); | ||
} | ||
}; | ||
export { | ||
Pr as TresCanvas, | ||
kr as TresCanvas, | ||
Z as catalogue, | ||
Qr as default, | ||
Yr as default, | ||
oe as extend, | ||
Rr as isProd, | ||
Ft as normalizeColor, | ||
Ir as normalizeVectorFlexibleParam, | ||
Wr as templateCompilerOptions, | ||
Ir as isProd, | ||
Ut as normalizeColor, | ||
$r as normalizeVectorFlexibleParam, | ||
Fr as templateCompilerOptions, | ||
sr as trasverseObjects, | ||
Vt as useCamera, | ||
$r as useLoader, | ||
A as useLogger, | ||
Nt as useCamera, | ||
zr as useLoader, | ||
P as useLogger, | ||
ar as usePointerEventHandler, | ||
ir as useRaycaster, | ||
re as useRenderLoop, | ||
G as useRenderLoop, | ||
or as useRenderer, | ||
Vr as useSeek, | ||
Wr as useSeek, | ||
Nr as useTexture, | ||
zr as useTres, | ||
Vr as useTres, | ||
dr as useTresContext, | ||
cr as useTresContextProvider, | ||
Gr as vAlwaysLookAt, | ||
Jr as vDistanceTo, | ||
Fr as vLightHelper, | ||
Ur as vLog | ||
Qr as vAlwaysLookAt, | ||
qr as vDistanceTo, | ||
Gr as vLightHelper, | ||
Ur as vLog, | ||
Jr as vRotate | ||
}; |
{ | ||
"name": "@tresjs/core", | ||
"type": "module", | ||
"version": "3.8.1", | ||
"version": "3.9.0", | ||
"packageManager": "pnpm@8.15.6", | ||
@@ -20,4 +20,4 @@ "description": "Declarative ThreeJS using Vue Components", | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/tres.umd.cjs", | ||
"import": "./dist/tres.js" | ||
"import": "./dist/tres.js", | ||
"require": "./dist/tres.umd.cjs" | ||
}, | ||
@@ -42,4 +42,4 @@ "./components": { | ||
"files": [ | ||
"dist", | ||
"*.d.ts" | ||
"*.d.ts", | ||
"dist" | ||
], | ||
@@ -58,3 +58,4 @@ "publishConfig": { | ||
"coverage": "vitest run --coverage", | ||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint . --fix", | ||
"docs:dev": "vitepress dev docs", | ||
@@ -64,3 +65,4 @@ "docs:build": "vitepress build docs", | ||
"docs:preview": "vitepress preview docs", | ||
"docs:contributors": "esno scripts/update-contributors.ts" | ||
"docs:contributors": "esno scripts/update-contributors.ts", | ||
"prepare": "node .husky/install.mjs" | ||
}, | ||
@@ -80,14 +82,16 @@ "peerDependencies": { | ||
"@tresjs/cientos": "3.8.0", | ||
"@tresjs/eslint-config": "^1.0.0", | ||
"@tresjs/eslint-config-vue": "^0.2.1", | ||
"@types/three": "^0.163.0", | ||
"@typescript-eslint/eslint-plugin": "^7.5.0", | ||
"@typescript-eslint/parser": "^7.5.0", | ||
"@typescript-eslint/eslint-plugin": "^7.7.1", | ||
"@typescript-eslint/parser": "^7.7.1", | ||
"@vitejs/plugin-vue": "^5.0.4", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"@vitest/ui": "^1.0.4", | ||
"@vitest/ui": "^1.5.0", | ||
"@vue/test-utils": "^2.4.3", | ||
"eslint": "^8.55.0", | ||
"eslint-plugin-vue": "^9.19.2", | ||
"eslint": "^9.1.1", | ||
"eslint-plugin-vue": "^9.25.0", | ||
"esno": "^4.0.0", | ||
"gsap": "^3.12.3", | ||
"husky": "^9.0.11", | ||
"jsdom": "^24.0.0", | ||
@@ -97,3 +101,3 @@ "kolorist": "^1.8.0", | ||
"pathe": "^1.1.1", | ||
"release-it": "^17.0.1", | ||
"release-it": "^17.2.0", | ||
"rollup-plugin-analyzer": "^4.0.0", | ||
@@ -103,16 +107,16 @@ "rollup-plugin-copy": "^3.5.0", | ||
"three": "^0.163.0", | ||
"unocss": "^0.58.0", | ||
"unocss": "^0.59.4", | ||
"unplugin": "^1.10.1", | ||
"unplugin-vue-components": "^0.26.0", | ||
"vite": "^5.2.7", | ||
"vite": "^5.2.10", | ||
"vite-plugin-banner": "^0.7.1", | ||
"vite-plugin-dts": "3.8.1", | ||
"vite-plugin-inspect": "^0.8.1", | ||
"vite-plugin-dts": "3.9.0", | ||
"vite-plugin-inspect": "^0.8.4", | ||
"vite-plugin-require-transform": "^1.0.21", | ||
"vite-svg-loader": "^5.1.0", | ||
"vitepress": "1.0.2", | ||
"vitest": "^1.0.4", | ||
"vue": "^3.3.11", | ||
"vitepress": "1.1.3", | ||
"vitest": "^1.5.0", | ||
"vue": "^3.4.24", | ||
"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
458884
46
6636
39