-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
feat: pass all provides down to custom renderer #806
feat: pass all provides down to custom renderer #806
Conversation
✅ Deploy Preview for tresjs-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @alvarosabu ,
I grabbed the latest revision. provide
from outside the <TresCanvas>
doesn't seem to work on components within the <TresCanvas>
– I tried adding an inject
in SubComponentWithInject.vue
.
I could be wrong though. I didn't find a demo that showed how this is meant to be used, so I wrote a quick one, but maybe it's not how this is intended to be used. (I only found a demo that's intended to show that providing useTres
doesn't break things)
Hi @andretchen0 yeah no worries I was just trying stuff, will set this PR to draft. I did manage to make it work with I'm currently clueless how to make it work, I opened a help request here in vue discord https://discord.com/channels/325477692906536972/1283405486175031418 |
If we want to be explicit about <!-- ProvideBridge.vue -->
<script setup lang="ts">
import { provide } from 'vue'
interface Props {
keysValues: Record<string, any>
}
const props = withDefaults(defineProps<Props>(), {
keysValues: () => ({})
})
for (const [key, value] of Object.entries(props.keysValues)) {
provide(key, value)
}
</script>
<template>
<TresGroup>
<slot></slot>
</TresGroup>
</template> <TresCanvas>
<TresPerspectiveCamera />
<OrbitControls />
<ProvideBridge :keys-values="{ foo: inject('foo') }">
<Box /> <!-- Box can inject "foo" in its script setup -->
</ProvideBridge>
</TresCanvas> |
… of github.com:Tresjs/tres into feature/732-pass-vue-providers-down-to-custom-renderer
Closes #537
Closes #732
This PR adds an opt-out bridge to pass down Vue parent
provides
down to the Tres components viaTresCanvas
with a flag to disable itenableProvideBridge
How to test
pnpm run dev
You should see console logs with prefixes like
tres
from the child tres component with the injects andvue
for the vue child components, both should show a value different from undefined.If you pass the
:enable-provide-bridge="false"
and refresh, thetres
consoles should be undefined.