-
-
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
WebGPURenderer: Build - three.webgpu.js
#28650
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Seems that an update in |
Could we also use this PR to move the It feels a bit odd to point to the addons such as The import map would then look like this: {
"imports": {
"three": "../build/three.webgpu.js",
"three/debug": "./webgpu/renderers/webgpu/Three.js",
"three/addons/": "./jsm/"
}
} |
It wouldn't be TBH, I did not have the impression so far that import paths containing
Um, I'm not sure I agree. What would be exactly easier? |
It's a matter of best practice and trying to organize the repository more effectively. Why should the new Renderer and Node System be under the "examples/jsm" folder? It feels like anything that is not the WebGLRenderer is placed under examples/jsm by default. I just feel that this PR will bring some fresh air to the repository and maybe we could take that opportunity to reorganize a bit! 😄 |
Um, why not moving The directory size of |
Indeed, even better! 👍 |
"three/addons/": "./jsm/", | ||
"three/nodes": "./jsm/nodes/Nodes.js" | ||
"three": "../build/three.webgpu.js", | ||
"three/debug": "../src/Three.WebGPU.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug
does not appear to be needed. Should we have an example in which it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I purposely put it in sandbox
because I thought it could convey the idea of debug
since I can't make simple comments in the JSON, maybe there is a more suitable way to do this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your choice... I'd vote to merge this PR ASAP if @Mugen87 approves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me think about the naming for all this for a couple of days 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced three/nodes
to three/webgpu
in package. I imagined that developers could use three alias in vite like:
// vite.config.js
import { defineConfig } from 'vite';
export default defineConfig({
resolve: {
alias: {
'three': 'three/webgpu'
}
}
});
For documentation purpose here is the correct way to use the new build: // vite.config.js
import { defineConfig } from 'vite';
export default defineConfig({
resolve: {
alias: {
'three/examples/jsm': 'three/examples/jsm',
'three/addons': 'three/examples/jsm',
'three/tsl': 'three/webgpu',
'three': 'three/webgpu',
}
}
}); The order is important otherwise /cc @sunag |
import WebGPU / NodeMaterial stuff from `three/webgpu` See: mrdoob/three.js#28650 Three.js r167 is not released yet! I tested the behavior by using `yarn link` on `three` and `@types/three` importmaps for Three.js in webgpu examples are temporarily replaced to node_modules, please change them back before merging Some codes inside MToonNodeMaterial emit type errors because of recent @types/three changes I'm asking Methuselar96 why the change is made See: three-types/three-ts-types#1023 (comment)
Related issue: #28328, #28328 (comment)
Description
TSL
I did some tests to include TSL in the build, the first attempt was
THREE.TSL
and useconst { .. } =
to import, which works well but is incompatible withtree shaking
, the second attempt was to preservethree/tls
but that would prevent having a single build file for everything. I think that since TSL will be part of the agnostic rendering system, it seems correct for it to be an essential central part of the file, just like other materials are.To import a TSL, just use:
For class creation this is more familiar:
Renderer
Using the Renderer has become simpler too with
THREE.
:PMREMGenerator
Previously it was necessary to reimport PMREMGenerator from a new path for webgpu, now it is possible to use the original
THREE.PMREMGenerator
syntax.RectAreaLightTexturesLib
I created a base LTC for use on WebGPU, WebGLRenderer also relies on this same class.
QuadMesh, PostProcessing
QuadMesh and PostProcessing can be used with THREE.QuadMesh and THREE.PostProcessing.
Lines2
We have a separate
jsm/lines/webgpu
class now to handle just TSL, previously we had a lot of GLSL mixed in between the class extensions.Imports
If you want to edit the files without having to recompile them, you can use the imports above.
Next steps
This simplifies the process for creating the
tree shaking
that will come with the next PR. Do you just need to update fromthree.webgpu.js
tothree.webgpu.nodes.js
orthree.nodes.js
?