Thanks a lot for your answer, but I am in a npm project, using typescript.
I got to import WebGPURenderer but I juste donât know how.
Nothing of all I tried works âŚ
For example :
import WebGPURenderer from âthree/examples/jsm/renderers/webgpu/WebGPURenderer.jsâ;
is what I often see but it does not work.
How can it be that I cannot even start a threejs project using webGPU âŚ
WebGPU is all experimental and it does not appear to be in the official documentation either.
As a wild guess, your npm installation might just be defaulting to using three.module.js and not really observing the three.webgpu.js. I donât really deal with npm so I wouldnât really know.
We could ask @Attila_Schroeder if he might have had some experience with WebGPU on npm.
I think since r167.1 WebGPU has become an integral part of three.js, because since r167.1 there is three.webgpu.js in the build folder. The entire node system has also been migrated from examples to src, which was necessary in order to be able to build three.webgpu.js.
But I donât work with TS at all and so unfortunately I canât help if itâs a TS-specific problem.
@Tyl,
Since r167, which you also use, the WebGPURenderer is no longer in examples/jsm
So if you try to integrate the WebGPURenderer from there, it wonât work. r167 was a big leap. If you install three.js with npm like me and your three.js r167 is in the node_modules folder, then you need three.webgpu.js instead of three.module.js.
Then you can initialize the WebGPURenderer like GithubDragonFly showed.
My Ocean2 repo is one with node_modules. So I used npm to install three.js for that too. I recently updated this to r167.1. Maybe this will help you for your npm project, because in your case three.js will then be in the node_modules folder
The repo can be executed directly in visual studio code right after the download. Maybe this will help you.
If you need the logarithmicDetphBuffer, there are a few things to consider because WebGPU works differently than WebGL. Here a link to a codePen if you want to use the logarithmicDetphBuffer with custom shaders
I need typescript because I use also Angular, and I have too my former project in WebGL in which I can reuse most of my typescript code.
I assume I just have to wait that the devs fix this bug in threejs ⌠(or tell me how to deal with it)
You canât add //@ts-ignore above your import it doesnât have to impact angular in any way. TS is also not related to threejs in any official way, there are volunteers maintaining types in a separate project.
r167 thanks! Some examples of WebGPU were blank last year. A fallback did not load. Now they work (with Chrome 121 Android 12). Some make my phone hot.
Many thanks for your help.
Your template works, and I could make mine almost work too (I still have some pb with Angular now)
I had to modify a line in tsconfig.json to make work : "moduleResolution": "node",
became "moduleResolution": "bundler",