📄 NodeMaterialLoader.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 4 |
🧱 Classes | 1 |
📦 Imports | 1 |
📊 Variables & Constants | 4 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 src/loaders/nodes/NodeMaterialLoader.js
📦 Imports¶
Name | Source |
---|---|
MaterialLoader |
../../loaders/MaterialLoader.js |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
nodes |
{ [x: string]: Node.constructor; } |
let/var | this.nodes |
✗ |
inputNodes |
any |
let/var | json.inputNodes |
✗ |
uuid |
any |
let/var | inputNodes[ property ] |
✗ |
materialClass |
NodeMaterial.constructor |
let/var | this.nodeMaterials[ type ] |
✗ |
Functions¶
NodeMaterialLoader.parse(json: any): NodeMaterial
¶
JSDoc:
/**
* Parses the node material from the given JSON.
*
* @param {Object} json - The JSON definition
* @return {NodeMaterial}. The parsed material.
*/
Parameters:
json
any
Returns: NodeMaterial
Calls:
super.parse
Code
NodeMaterialLoader.setNodes(value: { [x: string]: Node.constructor; }): NodeLoader
¶
JSDoc:
/**
* Defines the dictionary of node types.
*
* @param {Object<string,Node.constructor>} value - The node library defined as `<classname,class>`.
* @return {NodeLoader} A reference to this loader.
*/
Parameters:
value
{ [x: string]: Node.constructor; }
Returns: NodeLoader
NodeMaterialLoader.setNodeMaterials(value: { [x: string]: NodeMaterial.constructor; }): NodeLoader
¶
JSDoc:
/**
* Defines the dictionary of node material types.
*
* @param {Object<string,NodeMaterial.constructor>} value - The node material library defined as `<classname,class>`.
* @return {NodeLoader} A reference to this loader.
*/
Parameters:
value
{ [x: string]: NodeMaterial.constructor; }
Returns: NodeLoader
NodeMaterialLoader.createMaterialFromType(type: string): Node
¶
JSDoc:
/**
* Creates a node material from the given type.
*
* @param {string} type - The node material type.
* @return {Node} The created node material instance.
*/
Parameters:
type
string
Returns: Node
Calls:
super.createMaterialFromType
Code
Classes¶
NodeMaterialLoader
¶
Class Code
class NodeMaterialLoader extends MaterialLoader {
/**
* Constructs a new node material loader.
*
* @param {LoadingManager} [manager] - A reference to a loading manager.
*/
constructor( manager ) {
super( manager );
/**
* Represents a dictionary of node types.
*
* @type {Object<string,Node.constructor>}
*/
this.nodes = {};
/**
* Represents a dictionary of node material types.
*
* @type {Object<string,NodeMaterial.constructor>}
*/
this.nodeMaterials = {};
}
/**
* Parses the node material from the given JSON.
*
* @param {Object} json - The JSON definition
* @return {NodeMaterial}. The parsed material.
*/
parse( json ) {
const material = super.parse( json );
const nodes = this.nodes;
const inputNodes = json.inputNodes;
for ( const property in inputNodes ) {
const uuid = inputNodes[ property ];
material[ property ] = nodes[ uuid ];
}
return material;
}
/**
* Defines the dictionary of node types.
*
* @param {Object<string,Node.constructor>} value - The node library defined as `<classname,class>`.
* @return {NodeLoader} A reference to this loader.
*/
setNodes( value ) {
this.nodes = value;
return this;
}
/**
* Defines the dictionary of node material types.
*
* @param {Object<string,NodeMaterial.constructor>} value - The node material library defined as `<classname,class>`.
* @return {NodeLoader} A reference to this loader.
*/
setNodeMaterials( value ) {
this.nodeMaterials = value;
return this;
}
/**
* Creates a node material from the given type.
*
* @param {string} type - The node material type.
* @return {Node} The created node material instance.
*/
createMaterialFromType( type ) {
const materialClass = this.nodeMaterials[ type ];
if ( materialClass !== undefined ) {
return new materialClass();
}
return super.createMaterialFromType( type );
}
}