Skip to content

Commit

Permalink
fix: proxy app context
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Sep 11, 2023
1 parent 924407e commit 128e3a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/TresCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { render } from '../core/renderer'
import type { RendererPresetsType } from '../composables/useRenderer/const'
import type { TresCamera, TresObject } from '../types/'
import { getCurrentInstance } from 'vue'
import { App } from 'vue'
export interface TresCanvasProps
extends Omit<WebGLRendererParameters, 'canvas'> {
Expand Down Expand Up @@ -81,9 +83,13 @@ const slots = defineSlots<{
default(): any
}>()
const vueApp = getCurrentInstance()?.appContext.app
const createInternalComponent = (context: TresContext) =>
defineComponent({
setup() {
const ctx = getCurrentInstance()?.appContext
if(ctx) ctx.app = vueApp as App
provide('useTres', context)
provide('extend', extend)
return () => h(Fragment, null, slots?.default ? slots.default() : [])
Expand Down

0 comments on commit 128e3a5

Please sign in to comment.