Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added controls and extend to state context #355

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/composables/useTresContextProvider/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -12,6 +13,8 @@ export type TresContext = {
cameras: DeepReadonly<Ref<Camera[]>>;
renderer: ShallowRef<WebGLRenderer>
raycaster: ShallowRef<Raycaster>
controls: Ref<(EventDispatcher & { enabled: boolean }) | null>
extend: (objects: any) => void
addCamera: (camera: Camera) => void;
removeCamera: (camera: Camera) => void
setCameraActive: (cameraOrUuid: Camera | string) => void;
Expand Down Expand Up @@ -75,6 +78,8 @@ export function useTresContextProvider({
cameras: readonly(cameras),
renderer,
raycaster: shallowRef(new Raycaster()),
controls: ref(null),
extend,
addCamera,
removeCamera,
setCameraActive,
Expand Down
Loading