Comments (4)
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 outside
the TresJS renderer thus still having access to the same context and there for the provided value.
The second time you inject the context has changed and the dependency injection does not have any value registered for the key test
.
Notice if you inject a value in SecondTresjs.vue
and add a child like ThirdTresjs.vue
the provided value is correctly injected like in this Example.
Take the explanation with a grain of salt as i'm not 100% sure about the specfics.
from tres.
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
from tres.
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
outside
the TresJS renderer thus still having access to the same context and there for the provided value. The second time you inject the context has changed and the dependency injection does not have any value registered for the keytest
.Notice if you inject a value in
SecondTresjs.vue
and add a child likeThirdTresjs.vue
the provided value is correctly injected like in this Example.Take the explanation with a grain of salt as i'm not 100% sure about the specfics.
thanks for the solution and the explanation, even though i cannot understand why you cannot have more than one context
from tres.
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 (context: TresContext,additionalContext)
to the function called inside mountCustomRenderer
that pass custom provided variables.
It can be an array given to a new props on the canvas (additional-context=['key-one','key-two']
) ; this way inside mountCustomRender
we can inject these variables, pass them to createInternalComponent()
and from here provided again white the same name.
from tres.
Related Issues (20)
- LocalClippingEnabled HOT 1
- `useLoop` callback state missing controls HOT 1
- Render mode policies
- camera-position bug since version 3.8 HOT 3
- Add userData to vue devtools component inspector
- Invalid watch source error when declaring a CatmullRomCurve3 HOT 1
- position type is incorrect
- The Lifecycle Hooks is out of order after v3.9.0 HOT 6
- `<primitive> :object` breaking references to THREE objects HOT 1
- Physics support integration! HOT 3
- Toggle v-if on a Tres component declared in a separate SFC makes it detach from its parent HOT 9
- V4 drops fps HOT 2
- v4.0.1 The `onPointerLeave` function is not activating. HOT 8
- Manual rendering (edge case): canvases loaded into new tabs are initially blank
- Cannot read properties of undefined (reading 'dispose') - GridHelper HOT 1
- `Camera` wrapped by `TresGroup` cannot be used properly after `version 4.0` HOT 2
- `Event` is not triggered in `TresGroup` HOT 1
- intersect only objects with events registered HOT 3
- No more outlines since V4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tres.