From eecf608ad1bfb7d4cbe64cf275a356a8dd383b73 Mon Sep 17 00:00:00 2001 From: Alvaro Saburido Date: Thu, 1 Aug 2024 08:41:20 +0200 Subject: [PATCH] fix: typescript issues (#794) * fix: added TresControl type anf dixed minor type issues * fix: export VectorFlexibleParams types --- src/composables/useTresContextProvider/index.ts | 6 +++--- src/devtools/plugin.ts | 2 +- src/index.ts | 2 ++ src/types/index.ts | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/composables/useTresContextProvider/index.ts b/src/composables/useTresContextProvider/index.ts index 10308b228..9c5e5ef0e 100644 --- a/src/composables/useTresContextProvider/index.ts +++ b/src/composables/useTresContextProvider/index.ts @@ -1,6 +1,6 @@ import { useFps, useMemory, useRafFn } from '@vueuse/core' import { computed, inject, onUnmounted, provide, readonly, ref, shallowRef } from 'vue' -import type { Camera, EventDispatcher, WebGLRenderer } from 'three' +import type { Camera, WebGLRenderer } from 'three' import { Raycaster } from 'three' import type { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue' import { calculateMemoryUsage } from '../../utils/perf' @@ -8,7 +8,7 @@ import { useCamera } from '../useCamera' import type { UseRendererOptions } from '../useRenderer' import { useRenderer } from '../useRenderer' import { extend } from '../../core/catalogue' -import type { EmitEventFn, TresObject, TresScene } from '../../types' +import type { EmitEventFn, TresControl, TresObject, TresScene } from '../../types' import { type TresEventManager, useTresEventManager } from '../useTresEventManager' import useSizes, { type SizesType } from '../useSizes' @@ -54,7 +54,7 @@ export interface TresContext { extend: (objects: any) => void camera: ComputedRef cameras: DeepReadonly> - controls: Ref<(EventDispatcher & { enabled: boolean }) | null> + controls: TresControl | null renderer: ShallowRef raycaster: ShallowRef perf: PerformanceState diff --git a/src/devtools/plugin.ts b/src/devtools/plugin.ts index dc87653a6..be034f72c 100644 --- a/src/devtools/plugin.ts +++ b/src/devtools/plugin.ts @@ -177,7 +177,7 @@ export function registerTresDevtools(app: DevtoolsApp, tres: TresContext) { object: Object.entries(instance) .map(([key, value]) => { if (key === 'children') { - return { key, value: value.filter(child => child.type !== 'HightlightMesh') } + return { key, value: value.filter((child: { type: string }) => child.type !== 'HightlightMesh') } } return { key, value, editable: true } }) diff --git a/src/index.ts b/src/index.ts index 9f24e7bd7..e508b67a0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,3 +34,5 @@ export { templateCompilerOptions, dispose, } + +export type { VectorFlexibleParams } from './utils/normalize' diff --git a/src/types/index.ts b/src/types/index.ts index 5df7ed9d4..332cfd999 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -186,6 +186,7 @@ export type TresColorArray = typeof THREE.Color | [color: THREE.ColorRepresentat export type TresLayers = THREE.Layers | Parameters[0] export type TresQuaternion = THREE.Quaternion | Parameters export type TresEuler = THREE.Euler +export type TresControl = THREE.EventDispatcher & { enabled: boolean } type WithMathProps

= { [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType : P[K] }