|
@@ -28,7 +28,7 @@ class Node extends EventDispatcher {
|
|
|
|
|
|
get type() {
|
|
get type() {
|
|
|
|
|
|
- return this.constructor.name;
|
|
|
|
|
|
+ return this.constructor.type;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -134,7 +134,7 @@ class Node extends EventDispatcher {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- construct( builder ) {
|
|
|
|
|
|
+ setup( builder ) {
|
|
|
|
|
|
const nodeProperties = builder.getNodeProperties( this );
|
|
const nodeProperties = builder.getNodeProperties( this );
|
|
|
|
|
|
@@ -149,6 +149,14 @@ class Node extends EventDispatcher {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ construct( builder ) { // @deprecated, r157
|
|
|
|
+
|
|
|
|
+ console.warn( 'THREE.Node: construct() is deprecated. Use setup() instead.' );
|
|
|
|
+
|
|
|
|
+ return this.setup( builder );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
analyze( builder ) {
|
|
analyze( builder ) {
|
|
|
|
|
|
const nodeData = builder.getDataFromNode( this );
|
|
const nodeData = builder.getDataFromNode( this );
|
|
@@ -212,7 +220,7 @@ class Node extends EventDispatcher {
|
|
builder.addChain( this );
|
|
builder.addChain( this );
|
|
|
|
|
|
/* Build stages expected results:
|
|
/* Build stages expected results:
|
|
- - "construct" -> Node
|
|
|
|
|
|
+ - "setup" -> Node
|
|
- "analyze" -> null
|
|
- "analyze" -> null
|
|
- "generate" -> String
|
|
- "generate" -> String
|
|
*/
|
|
*/
|
|
@@ -220,18 +228,18 @@ class Node extends EventDispatcher {
|
|
|
|
|
|
const buildStage = builder.getBuildStage();
|
|
const buildStage = builder.getBuildStage();
|
|
|
|
|
|
- if ( buildStage === 'construct' ) {
|
|
|
|
|
|
+ if ( buildStage === 'setup' ) {
|
|
|
|
|
|
const properties = builder.getNodeProperties( this );
|
|
const properties = builder.getNodeProperties( this );
|
|
|
|
|
|
if ( properties.initialized !== true || builder.context.tempRead === false ) {
|
|
if ( properties.initialized !== true || builder.context.tempRead === false ) {
|
|
|
|
|
|
- const stackNodesBeforeConstruct = builder.stack.nodes.length;
|
|
|
|
|
|
+ const stackNodesBeforeSetup = builder.stack.nodes.length;
|
|
|
|
|
|
properties.initialized = true;
|
|
properties.initialized = true;
|
|
- properties.outputNode = this.construct( builder );
|
|
|
|
|
|
+ properties.outputNode = this.setup( builder );
|
|
|
|
|
|
- if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeConstruct ) {
|
|
|
|
|
|
+ if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
|
|
|
|
|
|
properties.outputNode = builder.stack;
|
|
properties.outputNode = builder.stack;
|
|
|
|
|
|
@@ -454,12 +462,13 @@ class Node extends EventDispatcher {
|
|
|
|
|
|
export default Node;
|
|
export default Node;
|
|
|
|
|
|
-export function addNodeClass( nodeClass ) {
|
|
|
|
|
|
+export function addNodeClass( type, nodeClass ) {
|
|
|
|
|
|
- if ( typeof nodeClass !== 'function' || ! nodeClass.name ) throw new Error( `Node class ${ nodeClass.name } is not a class` );
|
|
|
|
- if ( NodeClasses.has( nodeClass.name ) ) throw new Error( `Redefinition of node class ${ nodeClass.name }` );
|
|
|
|
|
|
+ if ( typeof nodeClass !== 'function' || ! type ) throw new Error( `Node class ${ type } is not a class` );
|
|
|
|
+ if ( NodeClasses.has( type ) ) throw new Error( `Redefinition of node class ${ type }` );
|
|
|
|
|
|
- NodeClasses.set( nodeClass.name, nodeClass );
|
|
|
|
|
|
+ NodeClasses.set( type, nodeClass );
|
|
|
|
+ nodeClass.type = type;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|