WebGPURenderer: Make canvas optional - #34525
Draft
donmccurdy wants to merge 3 commits into
Draft
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❌ 2 example(s) failed (full artifacts).
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.






Draft for discussion. I don't expect this can merge as a whole, but I'm hoping at least some parts of it might be OK.
In the past, if you wanted to use three.js without a browser, you'd need to use
headless-gl, and a bunch of polyfills to replace browser and DOM APIs. More recentlyheadless-glbecoming a dead end: it doesn't support WebGL 2, which three.js has now required for several years. In theory, we could be better off today, with eithernode-webgpuor Deno's WebGPU API.I tried with
node-webgpu, starting with a simple background color (no textures or network requests!) and ran into some small problems. Several of these look like they might be good things to fix regardless of Node.js usage, based on the "TODO: Unify CanvasTarget and OutputRenderTarget" comment already in the code?Is it reasonable to think that if we're using WebGPU, and the user provides both
deviceandoutputRenderTarget, the canvas could become optional? That would allow running a script like this in Node.js, for example:With the changes proposed in this PR, the script above runs and reads back pixels from the GPU.