|
@@ -1,9 +1,9 @@
|
|
import type { Camera } from 'three'
|
|
import type { Camera } from 'three'
|
|
-import type { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue'
|
|
|
|
|
|
+import type { ComputedRef, DeepReadonly, MaybeRefOrGetter, Ref, ShallowRef } from 'vue'
|
|
import type { RendererLoop } from '../../core/loop'
|
|
import type { RendererLoop } from '../../core/loop'
|
|
import type { EmitEventFn, Renderer, TresControl, TresScene } from '../../types'
|
|
import type { EmitEventFn, Renderer, TresControl, TresScene } from '../../types'
|
|
import { Raycaster } from 'three'
|
|
import { Raycaster } from 'three'
|
|
-import { computed, inject, onUnmounted, provide, readonly, ref, shallowRef, toValue } from 'vue'
|
|
|
|
|
|
+import { computed, inject, onUnmounted, provide, readonly, ref, shallowRef } from 'vue'
|
|
import { extend } from '../../core/catalogue'
|
|
import { extend } from '../../core/catalogue'
|
|
import { createRenderLoop } from '../../core/loop'
|
|
import { createRenderLoop } from '../../core/loop'
|
|
import { type Events, useEventsOptions as withEventsProps } from '../../utils/createEvents'
|
|
import { type Events, useEventsOptions as withEventsProps } from '../../utils/createEvents'
|
|
@@ -47,6 +47,7 @@ export interface PerformanceState {
|
|
}
|
|
}
|
|
|
|
|
|
export interface TresContext {
|
|
export interface TresContext {
|
|
|
|
+ canvas: ShallowRef<HTMLCanvasElement>
|
|
events: Events
|
|
events: Events
|
|
scene: ShallowRef<TresScene>
|
|
scene: ShallowRef<TresScene>
|
|
sizes: SizesType
|
|
sizes: SizesType
|
|
@@ -87,11 +88,10 @@ export async function useTresContextProvider({
|
|
emit,
|
|
emit,
|
|
}: {
|
|
}: {
|
|
scene: TresScene
|
|
scene: TresScene
|
|
- canvas: MaybeRef<HTMLCanvasElement>
|
|
|
|
|
|
+ canvas: ShallowRef<HTMLCanvasElement>
|
|
windowSize: MaybeRefOrGetter<boolean>
|
|
windowSize: MaybeRefOrGetter<boolean>
|
|
props: TresCanvasProps
|
|
props: TresCanvasProps
|
|
emit: EmitEventFn
|
|
emit: EmitEventFn
|
|
-
|
|
|
|
}): Promise<TresContext> {
|
|
}): Promise<TresContext> {
|
|
const localScene = shallowRef<TresScene>(scene)
|
|
const localScene = shallowRef<TresScene>(scene)
|
|
const sizes = useSizes(windowSize, canvas)
|
|
const sizes = useSizes(windowSize, canvas)
|
|
@@ -158,11 +158,12 @@ export async function useTresContextProvider({
|
|
loop: createRenderLoop(),
|
|
loop: createRenderLoop(),
|
|
props,
|
|
props,
|
|
emit,
|
|
emit,
|
|
|
|
+ canvas,
|
|
}
|
|
}
|
|
|
|
|
|
provide('useTres', ctx)
|
|
provide('useTres', ctx)
|
|
|
|
|
|
- const r = (await withRendererProps(ctx as TresContext, { canvas: toValue(canvas) }))
|
|
|
|
|
|
+ const r = (await withRendererProps(ctx as TresContext))
|
|
ctx.renderer = r.renderer
|
|
ctx.renderer = r.renderer
|
|
ctx.events = withEventsProps(ctx as TresContext).events
|
|
ctx.events = withEventsProps(ctx as TresContext).events
|
|
|
|
|