-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Impossible to inject
variable in canvas child component
#732
Comments
I think the problem lies with the custom Tresjs renderer. I think it loses the previous context from the default renderer. The first time you inject it's actually Notice if you inject a value in Take the explanation with a grain of salt as i'm not 100% sure about the specfics. |
Fwiw, if anyone would like to look into this, here's a slightly more minimal reproduction with some notes and a minimal on-screen test: https://stackblitz.com/edit/vitejs-vite-5q8vs7?file=src%2FApp.vue |
thanks for the solution and the explanation, even though i cannot understand why you cannot have more than one context |
think the problem is in this function const createInternalComponent = (context: TresContext) =>
defineComponent({
setup() {
const ctx = getCurrentInstance()?.appContext;
if (ctx) {
ctx.app = instance as App;
}
provide("useTres", context);
provide("extend", extend);
if (typeof window !== "undefined") {
registerTresDevtools(ctx?.app, context);
}
return () => h(Fragment, null, slots?.default ? slots.default() : []);
},
}); It could be possible to add an additional params |
Hi, Does anyone have a final answer on how to deal with injected values in a Tree Scene ? Of course I can pass my variable through props but it can be really annoying. Thanks :) |
Hi @EvanSchleret we are currently discussing it internally, I personally see value in it. Let's see if it is feasible. |
Describe the bug
I'm trying to
inject
a variable inside a component in aTresCanvas
, but it's alwaysundefined
.In the example i log the variable provided by the first component but in the
SecondTresjs
component, the variable isundefined
Am i doing something wrong? I cannot find anything in the docs about the context.
Reproduction
https://stackblitz.com/edit/vitejs-vite-gtrfxh?file=src%2Fcomponents%2FFirstTresjs.vue
Steps to reproduce
No response
System Info
No response
Used Package Manager
npm
Code of Conduct
The text was updated successfully, but these errors were encountered: