Repository navigation
WebGPURenderer: Replace "addLight" with "lightNode" reference - #34622
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
🖼️ E2E screenshot tests✅ All examples render correctly again (run). |
88e00e9 to
ce83523
Compare
|
|
||
| renderer = new THREE.WebGPURenderer( { antialias: true } ); | ||
| renderer.library.addLight( SunLightNode, SunLight ); | ||
| SunLight.registerNode( SunLightNode ); |
There was a problem hiding this comment.
I guess we're not doing this directly in SunLight to avoid bloating SunLight with node code when it's being used by the WebGLRenderer?
There was a problem hiding this comment.
I guess we're not doing this directly in SunLight to avoid bloating SunLight with node code when it's being used by the WebGLRenderer?
Yeah that's right. And tree shaking can't work for the built-in light nodes at the moment because it's using static functions in module scope / prototype modification. Unfortunately I don't know of a great way to address this without doing something like adding dedicate exports for WebGPURenderer-versions of lights. Eventually when WebGLRenderer is dropped (or at least priority is shifted away from supporting an optimal version of it) these kinds of concessions for the renderer can be addressed more easily.
Another option is to lean a bit harder into node support for WebGLRenderer.
Fix #34561
Related to #34218
Somewhat related to #34611, which moved area lights because it's not tree-shakeable at the moment.
Description
This will allow users to use class inheritance without breaking light rendering. And eventually this should allow for tree shaking the lights and light nodes in WebGPURenderer to reduce file sizes when the nodes can be assigned in-place in the light constructors. But that will require some some discussions around WebGLRenderer since it would mean importing all associated nodes with every light unless there are some other ideas for the short term.