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
Consider supporting DOM elements inside <Canvas>
#753
Comments
Another use-case for this would be tweakpane libraries. ActualWhenever I want to tweak the value of a component, I have to register the tweaker outside of the scene. (App.svelte) e.g. https://threlte.xyz/docs/examples/geometry/random-placement#basic-random has examples where the tweakpane usage could be simplified ExpectedI'd like it if I could simply register a tweakpane anywhere inside a
If I want to tweak the
This would involve adding and removing around 3 lines of code, instead of messing with a store, or hooking up props. |
There is some progress regarding the usage of svelte-tweakpane-ui in our documentation, which improves the ease of setting up interactive variables. There are also promising solutions like triplex and the already integrated theatre.js for interactive variables/code. However, I am not fully understanding this issue. Currently, only I am curious about the purpose of mixing DOM elements with threlte components. Is it related to tweakpane functionality or is there another reason behind it? |
My particular use-case is having inline 3D rendered graphics, that use a shared canvas throughout the lifecycle of the app. Mayhap the live version of the aforementioned project might be clearer. |
excellent.
Oh, do you mean like the |
Some API like that would be ideal! Right now i’m rawdogging coordinate calculations all over the app. I’m a bit concerned that nested views may hinder SSR, but once again, react folks get it right. |
+1 for a component like Although my use case doesn't look nearly as cool, I am facing a similar issue to @sxxov with my little app https://text-to-cad.zoo.dev (repo here), where I'm trying to be kind to users by not loading all their CAD models at once in the list view. I'm only showing a couple canvasses at once thanks to an IntersectionObserver, but I'm still getting hit with I think a global |
That'd be lovely @franknoirot ! @grischaerbe already help me with converting the component a while ago but it's taken me some time to get around to merging it in. Happy for you to take it the last mile if you're up for it. There are some small things regarding the target dom's CSS props Here's a link to the component if you're ready to get started |
Excellent, that's so great that you've already done so much of the component conversion, thanks! So is FunBit aiming to be the Svelte equivalent to drei? I'm gonna solve my work problem along a different avenue real quick and then take a crack at it. |
Little bit off topic but not at all. Funbit is just making quaternus assets easier to muck around with |
Thank you for the project!
Explanation
Currently, the
<slot />
inside<Canvas>
puts all children into the DOM<canvas>
's children. Whilst this, makes sense to some degree, it really is kind of pointless, as all DOM elements just become fallbacks for browsers who don't support<canvas>
(IE8??).I'm working on a project that mixes DOM elements alongside threlte components, all under a global canvas. I've needed to resort to plenty o' hacks, including manual scroll restoration, stubbing files containing
@threlte/*
imports for SSR, & remounting the entire tree into a sibling portal on hydration.Having support for such a mixed use-case would be great, as it means a jankless SSR-ed DOM, & threlte would just be loaded during hydration. More precisely, making the
'threlte'
& other'threlte-*'
contexts available, in a stubbed way during SSR through an isometricuseThrelte()
, or introducing a new sub-package like@threlte/core/iso
that makes client-side-only hooks return nullable values during SSR to shift the stubbing responsibility to the consumer. Then,<T>
components could become passthrough noops & complete the circle.Example
Source
Expected Result
Actual Result
The text was updated successfully, but these errors were encountered: