-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebGPURenderer: Add Offscreen Support #27520
Conversation
Sorry, I didn't quite understand the relationship between the description and the commit. |
I wanted to add an example for The PR by itself simply adds Worker support. 😁 |
Indeed that was my bad @sunag. Basically injecting a promise outside of the scope of the module breaks web workers. So I refactored: // statics
let _staticAdapter = null;
if ( navigator.gpu !== undefined ) {
_staticAdapter = await navigator.gpu.requestAdapter(); <-- this breaks web workers
} to: // statics
let isAvailable = navigator.gpu !== undefined;
if ( typeof window !== 'undefined' && isAvailable ) {
isAvailable = await navigator.gpu.requestAdapter();
} Using Alternative solution would have been to make |
Thanks for the detailed explanation. :) |
* add offscreen support * refactor statics webgpu * navigator.gpu should be enough for initial check * fix webgl context ktx2loader * use isAvailable in webgpurenderer * cleanup and should fix pupeeter * return promise * feedbacks * remove unecessary async * removed oversight * cleanup ---------
This PR fix the use of the
WebGPURenderer
in a worker context.A small issue is that the WebGPURenderer is intricately tied to direct imports from 'three' making it complex to create an example without changing the configuration of the project.
Web browsers do not currently support the importmap feature in worker contexts. Alternatives would be to update the rollup configuration or use relatives paths. (
Uncaught (in promise) TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".
)I tested on my local with another project on both backends and it works fine.
This contribution is funded by Utsubo