From 3570e16598dbb6e1485f4992d905542c4d40e3ab Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Sat, 29 Jul 2023 12:54:43 +0200 Subject: [PATCH] fix: added controls and extend to state context --- src/composables/useTresContextProvider/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/composables/useTresContextProvider/index.ts b/src/composables/useTresContextProvider/index.ts index 72b24ddb5..f4befef8e 100644 --- a/src/composables/useTresContextProvider/index.ts +++ b/src/composables/useTresContextProvider/index.ts @@ -1,8 +1,9 @@ import { toValue, useElementSize, useWindowSize } from '@vueuse/core'; -import { inject, provide, readonly, shallowRef, computed } from 'vue'; +import { inject, provide, readonly, shallowRef, computed, ref } from 'vue'; import { useCamera } from '../useCamera'; -import { Camera, Raycaster, Scene, WebGLRenderer } from 'three'; +import { Camera, EventDispatcher, Raycaster, Scene, WebGLRenderer } from 'three'; import { UseRendererOptions, useRenderer } from '../useRenderer'; +import { extend } from '../../core/catalogue'; import type { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue'; @@ -12,6 +13,8 @@ export type TresContext = { cameras: DeepReadonly>; renderer: ShallowRef raycaster: ShallowRef + controls: Ref<(EventDispatcher & { enabled: boolean }) | null> + extend: (objects: any) => void addCamera: (camera: Camera) => void; removeCamera: (camera: Camera) => void setCameraActive: (cameraOrUuid: Camera | string) => void; @@ -75,6 +78,8 @@ export function useTresContextProvider({ cameras: readonly(cameras), renderer, raycaster: shallowRef(new Raycaster()), + controls: ref(null), + extend, addCamera, removeCamera, setCameraActive,