From c2540a55064098b5c7b145a9e785e370b78c4d23 Mon Sep 17 00:00:00 2001 From: Alvaro Saburido Date: Sat, 29 Jul 2023 13:17:02 +0200 Subject: [PATCH] fix: added controls and extend to state context (#355) --- 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,