Skip to content

Commit

Permalink
feat: opt-out flag for disabling provide bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Sep 27, 2024
1 parent 2a4e37c commit 7f3196d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/api/tres-canvas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/components/TresCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export interface TresCanvasProps
camera?: TresCamera
preset?: RendererPresetsType
windowSize?: boolean
// Misc opt-out flags
disableProvideBridge?: boolean
}
const props = withDefaults(defineProps<TresCanvasProps>(), {
Expand All @@ -68,6 +71,7 @@ const props = withDefaults(defineProps<TresCanvasProps>(), {
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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7f3196d

Please sign in to comment.