-
Notifications
You must be signed in to change notification settings - Fork 73
export get_root #17
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
base: main
Are you sure you want to change the base?
export get_root #17
Conversation
I am working on a library that exposes https://github.com/vanruesc/postprocessing as svelte components. I need access to the root three object, and didn't see any other way to access it.
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/svelte/svelte-cubed/99KuVhfc5qGHPgY9BqBNH2n5ugxt |
Testing this locally, the exported @Rich-Harris Is the purpose of the empty object context key to force a unique context for each three instance? Perhaps requiring an ID at the Canvas level (when multiple instances are detected) would allow context to be constructed using strings based on the canvas ID, making it easier to get to with |
@aewing - The first thing I did was a quick and dirty edit of the svelte-cubed code in node_modules. As you mentioned, I was getting undefined. I would like to understand why. However - once I forked the repo, linked it, made the modification, and then built it, everything started working as expected. |
This would be nice to have. It would also simplify the implementation of the interactivity example in #20, which currently exposes the |
I have figured out a partial workaround to this, for those who don't want to fork the library or wait for something like this to be merged. With some hacking, it's possible to obtain references to the canvas, scene, and camera. I haven't figured out how to find the renderer or controls yet but it's probably doable.
I have created a |
I've just published |
This would be great to have, I'm currently having to bind the |
Hey all, have noticed Rich doing the following to get root
Here's the setup function: svelte-cubed/src/lib/utils/context.js Line 15 in 4f7a3b2
Could we use this? |
Not really, for that we would need for the key to that context to be exported, in this case, the object called |
What do you mean? they both give you export function setup(self) {
const root = getContext(ROOT);
// other stuff
return {
root,
parent,
self
};
}
/** @returns {import('../types/context').RootContext} */
function get_root() {
return getContext(ROOT);
} |
I am working on a library that exposes https://github.com/vanruesc/postprocessing as svelte components. I need access to the root three object, and didn't see any other way to access it.