Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Support Custom Renderers #24

Open
CodyJasonBennett opened this issue Jan 20, 2021 · 7 comments
Open

Support Custom Renderers #24

CodyJasonBennett opened this issue Jan 20, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@CodyJasonBennett
Copy link
Contributor

CodyJasonBennett commented Jan 20, 2021

Currently, <three-game> provides a default WebGLRenderer instance, but there are cases where users would opt to use SVGRenderer, CSS2DRenderer, CSS3DRenderer, and WebGL1Renderer.

To support these renderers, we could pick up renderer elements as children of <three-game> and conditionally revert #21 for non-WebGL instances. For instance, react-three-fiber tackles this by only using renderer.setAnimationLoop when xr is enabled.

@RangerMauve
Copy link

Would it make sense to enable this by defining new custom elements? Like <three-svg-game>?

@CodyJasonBennett
Copy link
Contributor Author

CodyJasonBennett commented Jan 21, 2021

I think so, but I like your suggestion of having modified elements for <three-game> rather than child elements that merely modify its behavior. I suppose this would depend on how we deal with custom cameras, etc.

@hmans
Copy link
Owner

hmans commented Jan 21, 2021

I'm tinkering with a few ideas for this. The one that feels best so far revolves around providing the various bits and pieces that are currently hardcoded into the monolithic <three-game> element as separate elements that can be combined as the user needs them, with <three-game> being reduced to just a "starter configuration" of these.

For example, we'd have <three-ticker>, <three-webgl-renderer>, <three-css-renderer>, etc., and you'd either use them directly (if you need the configurability), or through a <three-game>, <three-css-game> etc. template.

One of the downsides of this idea is the potential for namespace collisions. If we introduce a <three-ticker> element, and a future version of Three.js itself exposes a THREE.Ticker, we'll have a collision that needs to be resolved somehow.

At the same time, we've been discussing (on Discord) to establish a separate "extras" package that, similar to react-drei for react-three-fiber, provides elements that implement specific functionality (using code from Three.js' examples), like GLTF loading, Orbit Controls and so on. It's possible that there is a synergy between this and the things discussed above.

@hmans hmans added the enhancement New feature or request label Jan 21, 2021
@hmans hmans added this to the 0.3 milestone Jan 21, 2021
@hmans hmans self-assigned this Jan 29, 2021
@hmans
Copy link
Owner

hmans commented Jan 29, 2021

I'm tackling this now. The goal is to allow the user to create instances of these renderers by using their corresponsing <three-*> tags, eg. <three-css-3d-renderer>, and having them automatically hook up with the <three-game> element. (There is probably no need to use the newly introduced DOM CSS selector referencing here, since there will always only ever be a single renderer -- and projects where even this does not apply for some wild reason will most likely not be static HTML projects.)

@hmans
Copy link
Owner

hmans commented Jan 29, 2021

PR for the first pass on this: #43

hmans added a commit that referenced this issue Jan 30, 2021
@hmans
Copy link
Owner

hmans commented Jan 30, 2021

I've merged #43, which allows customization of renderers that live in the THREE.* namespace. I'm deferring support for CSS/SVG renderers to 0.4.

@hmans hmans modified the milestones: 0.3, 0.4 Jan 30, 2021
@hmans
Copy link
Owner

hmans commented Feb 19, 2021

In the interest of pushing out a 0.4 release soon, I'm moving this to the next milestone.

@hmans hmans modified the milestones: 0.4, 0.5 Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants