-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Improve compatibility of three/webgpu with nextjs #29916
Comments
Do you mind explaining in more detail what parts of |
I am testing it here: |
@RenaudRohlinger This is the line in question:
Could this section be rewritten like so? // GPUShaderStage is not defined in browsers not supporting WebGPU
const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
const wrapNames = {
[ RepeatWrapping ]: 'repeat',
[ ClampToEdgeWrapping ]: 'clamp',
[ MirroredRepeatWrapping ]: 'mirror'
};
const gpuShaderStageLib = {
'vertex': GPUShaderStage.VERTEX,
'fragment': GPUShaderStage.FRAGMENT,
'compute': GPUShaderStage.COMPUTE
}; |
I believe so, also I'm surprised nextjs got the issue, I'm using the WebGPURenderer in OffScreen Canvas actively. |
It needs more broadly approaching for all "self." or "navigator." code around code of webgpu parts |
@whatisor cloning this repo and running |
@donmccurdy using dynamic import in that project is not a good way, just work around to overcome it. |
@whatisor WebGPU does not exist in Node.js, and cannot be used for server-side rendering (SSR). three.js renderers cannot operate in a Node.js environment, so I'm not sure a performance comparison is meaningful. Maybe we can avoid top-level await, and fix issues that would prevent importing three.js in a Node.js environment, but I don't think putting |
@donmccurdy Server will not handle any 3D resource, it compiles app script at compile time with best Lint support and prerender html only at runtime. I am sure we can do it well as webglrenderer. This is not a big issue, just avoid "global scope" in code. |
Description
As default, 1 threejs project working on nextjs, which wants to upgrade to WebGPU, needs dynamic import for three/webgpu component.
This has some limitation during development.
Solution
We should be able to avoid all client code style as "self." in global scope.
Alternatives
NA
Additional context
No response
The text was updated successfully, but these errors were encountered: