diff --git a/docs/api/tres-canvas.md b/docs/api/tres-canvas.md index 78e8a6b4c..a53f093e2 100644 --- a/docs/api/tres-canvas.md +++ b/docs/api/tres-canvas.md @@ -92,6 +92,7 @@ renderer.shadowMap.type = PCFSoftShadowMap | **toneMappingExposure** | Exposure level of tone mapping. | `1` | | **useLegacyLights** | Whether to use the legacy lighting mode or not | `true` | | **windowSize** | Whether to use the window size as the canvas size or the parent element. | `false` | +| **disableProvideBridge** | Disable the provide/inject bridge between Vue context and TresCanvas. | `false` | ### Defaults diff --git a/playground/vue/src/pages/issues/732/SubComponentWithInject.vue b/playground/vue/src/pages/issues/732/SubComponentWithInject.vue index d8951a67c..c4b05136f 100644 --- a/playground/vue/src/pages/issues/732/SubComponentWithInject.vue +++ b/playground/vue/src/pages/issues/732/SubComponentWithInject.vue @@ -5,9 +5,9 @@ const awiwi = inject('awiwi') const bululu = inject('bululu') const vRoute = inject('v-route') // eslint-disable-next-line no-console -watchEffect(() => console.log('tres:awiwi', awiwi.a)) +watchEffect(() => console.log('tres:awiwi', awiwi?.a)) // eslint-disable-next-line no-console -watchEffect(() => console.log('tres:bululu', bululu.value)) +watchEffect(() => console.log('tres:bululu', bululu?.value)) // eslint-disable-next-line no-console watchEffect(() => console.log('tres:v-route', vRoute)) // eslint-disable-next-line no-console diff --git a/playground/vue/src/pages/issues/732/SubVueComponentWithInject.vue b/playground/vue/src/pages/issues/732/SubVueComponentWithInject.vue index 824b8c151..6be0ab21f 100644 --- a/playground/vue/src/pages/issues/732/SubVueComponentWithInject.vue +++ b/playground/vue/src/pages/issues/732/SubVueComponentWithInject.vue @@ -4,9 +4,9 @@ import { inject, watchEffect } from 'vue' const awiwi = inject('awiwi') const bululu = inject('bululu') // eslint-disable-next-line no-console -watchEffect(() => console.log('vue:awiwi', awiwi.a)) +watchEffect(() => console.log('vue:awiwi', awiwi?.a)) // eslint-disable-next-line no-console -watchEffect(() => console.log('vue:bululu', bululu.value)) +watchEffect(() => console.log('vue:bululu', bululu?.value)) // eslint-disable-next-line no-console watchEffect(() => console.log('vue:v-route', inject('v-route'))) // eslint-disable-next-line no-console diff --git a/src/components/TresCanvas.vue b/src/components/TresCanvas.vue index 912e66fa7..99064a6b6 100644 --- a/src/components/TresCanvas.vue +++ b/src/components/TresCanvas.vue @@ -54,6 +54,9 @@ export interface TresCanvasProps camera?: TresCamera preset?: RendererPresetsType windowSize?: boolean + + // Misc opt-out flags + disableProvideBridge?: boolean } const props = withDefaults(defineProps(), { @@ -68,6 +71,7 @@ const props = withDefaults(defineProps(), { logarithmicDepthBuffer: undefined, failIfMajorPerformanceCaveat: undefined, renderMode: 'always', + disableProvideBridge: false, }) // Define emits for Pointer events, pass `emit` into useTresEventManager so we can emit events off of TresCanvas @@ -130,7 +134,7 @@ const createInternalComponent = (context: TresContext, empty = false) => } // Start the recursion from the initial instance - if (instance?.parent) { + if (instance?.parent && !props.disableProvideBridge) { mergeProvides(instance.parent) Object.entries(provides)