Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for Custom Renderers #272

Open
4 tasks done
alvarosabu opened this issue May 19, 2023 · 3 comments
Open
4 tasks done

Support for Custom Renderers #272

alvarosabu opened this issue May 19, 2023 · 3 comments
Assignees
Labels
help wanted Extra attention is needed investigation

Comments

@alvarosabu
Copy link
Member

alvarosabu commented May 19, 2023

Description

As of now, https://github.com/Tresjs/tres/blob/main/src/composables/useRenderer/index.ts#L209 supports the default WebGL 2 renderer.

The idea would be to adapt useRenderer so a custom renderer like https://github.com/mrdoob/three.js/blob/dev/examples/jsm/renderers/webgpu/WebGPURenderer.js can be used.

Suggested solution

Check out R3F and NGT support

https://github.com/pmndrs/react-three-fiber/blob/master/packages/fiber/src/core/index.tsx#L108

image

Alternative

No response

Additional context

No response

Validations

@alvarosabu alvarosabu added enhancement help wanted Extra attention is needed labels May 19, 2023
@callumacrae
Copy link
Collaborator

callumacrae commented May 22, 2023

I've been having a look at this. Depending on the level of support we want, this might be tricky. WebGPURenderer might be fine, but Tres seems to assume that the output element will be a canvas, which in the case of SVGRenderer, CSS2DRenderer, stuff like that, the output element is not a canvas.

Looks like to truly support any renderer, we'd have to take the returned domElement and use that instead of providing our own.

Maybe it would be best to support only canvas-based renderers?

(R3F also only support canvas-based renderers)

Here's the interface for SVGRenderer: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/three/examples/jsm/renderers/SVGRenderer.d.ts
And here's an example of usage: https://github.com/mrdoob/three.js/blob/master/examples/svg_lines.html

@callumacrae
Copy link
Collaborator

Another complication - to use a canvas-based renderer, Tres needs to instantiate the renderer (because it has the canvas), but for an example like this, we need access to the renderer itself in the vue component.

I'm giving up for now - if anyone wants to pick it up in the future, here's what I tried so far :) callumacrae@a475a3f

@drcmda
Copy link

drcmda commented Oct 17, 2023

the output element is not a canvas. (R3F also only support canvas-based renderers)

the output doesn't really matter because for various reasons you don't want to output a canvas anyway as the outmost element but a div (or a view on native). the reason for this is you have eco system overlays that rely on being in the same nesting as the canvas element, for instance the addons html or view components.

here's an example of a svg renderer in react https://codesandbox.io/s/zcuqh?file=/src/App.js

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed investigation
Projects
Status: No status
Development

No branches or pull requests

3 participants