Replies: 2 comments 4 replies
|
Thanks for opening the discussion @jakobhock . Personally, I'd like to be able to allow users to swap renderers eventually, but there are a number of changes that would need to happen in order to allow that. We're a really small team working on the core and at the moment and other issues are taking priority. But that could change if there is feedback from the community indicating a strong desire to swap renderers. Feel free to open a feature request on Tres or discuss on the Discord. (For Tres, Github discussions are sometimes overlooked. Those other avenues might give a better idea of how much community interest there is.) |
|
Hello, I have also encountered this problem and I am very excited to see your solution here. However, I am not sure how the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motivation
TresJS is currently missing a clean way to integrate the CSS2DRenderer into the scene. The standard way to use the CSS2DRenderer currently would to do something like the following:
The
CustomCSS2DRendererwould provide the renderer to the tree and the user would have to inject in into every place they would want to create a label as. Additional there is no nice way to handle the UI part as HTML elements are not allowed in aTresCanvas. This is an unmaintainable way of handling the 2D part of a 3D scene.Proposal
To address these difficulties, i propose tres could provide a
TresCSS2DRenderercomponent that would handle the rendering of the 2D part of the scene. With the registration of said component the user would be able to use a newTresLabelcomponent inside meshes to create 2D labels in the scene.TresLabelis a wrapper around theCSS2DObjectclass from Threejs and supports props to control the underlying object. TheTresLabelprovides aslotfor the user to define the content of the label with standard HTML and CSS. TheMeshto which theTresLabelis assigned to would be provided in the template as aslotpropto enable the user to access it's information in the label. The proposed API would look like the following:Changes
For this proposal to be implemented the following changes would have to be made:
TresCSS2DRenderercomponent to the core package.CSS2DRendereron creation of the scene if aTresCSS2DRendereris present in the tree.TresLabelcomponent if aTresCSS2DRendereris present in the tree.Meshof aTresMeshas aslotpropin theTresLabelcomponent.Benefits
TresLabelcomponent in everyTresMeshwithout having to inject the renderer into the tree.Conclusion
Support for 2D elements in a 3D scene is a necessary feature for TresJS to be a complete 3D framework. The proposed API would provide a clean and maintainable way to integrate 2D elements into the scene. The user would be able to use standard HTML and CSS to style the labels and would not have to fiddle around with rendering labels in a javascript native way.
As this is my first proposal/contribution to TresJS i would be happy to hear your feedback on the proposal and be able to discuss it with you.
All reactions