-
-
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
NodeMaterial: serialize/deserialize and Material.fromType() #23314
Conversation
Hmm, one problem with this approach is that it makes I was hoping that |
One of the key things about three.js is the fact that it's ~150kb gzipped. Could you do some tests to see how the new |
I think you are referring to Because some others approaches like |
Yes 👍 |
I build here a .min files to reference in
import * as THREE from './three.min.js';
import * as THREE from './three.min.js';
import ColorNode from './jsm/renderers/nodes/inputs/ColorNode.js';
import { nodeFrame } from './jsm/renderers/webgl/nodes/WebGLNodes.js';
import * as THREE from './three.min.js';
import * as Nodes from './jsm/renderers/nodes/Nodes.js';
import { nodeFrame } from './jsm/renderers/webgl/nodes/WebGLNodes.js'; -- |
Nice! Just remembered that we have a script that helps visualizing tree-shaking: #21657 |
Thanks! |
I was thinking of an approach to register classes imported. Like: class NoiseNode extends Node {
...
}
Node.library.add( NoiseNode ); So we can register only the imported classes and preserve this design using |
…3314) * Node serializer (draft) * add Material.fromType() * NodeObjectLoader: serialize/deserialize * update default values * fix analytic light * force refresh material uniforms using .uniformsNeedUpdate * Revert "force refresh material uniforms using .uniformsNeedUpdate" This reverts commit b083fb4. * mrdoob code style * cleanup * cleanup (2) * Update NodeMaterial.js Co-authored-by: mrdoob <[email protected]>
Related issue: #22552
Introduction
This PR add support to serialize
NodeMaterial
in theScene Graph
ofThree.js
.Create
NodeMaterial
base class extended ofShaderNode
.Node.serialize() / Node.deserialize()
This can be used to
serialize
/deserialize
specificNode
fields, these methods can be extended.Node.fromType()
It can be used to create extended
Nodes
and share the sameNodeMaterialLoader
.Loaders
NodeLoader
- only NodesNodeMaterialLoader
- Nodes in MaterialsNodeObjectLoader
- Nodes in Scene GraphSerialization test
webgl_materials_standard_nodes
- serialize objects after load to testCore
Object3D
src/core/Object3D.js
- addnodes
totoJSON()
Material.fromType()
src/loaders/MaterialLoader.js
src/materials/Material.js
src/materials/Materials.js
This contribution is funded by Google via Igalia.