浏览代码

Nodes: Fix circular dependency (#26163)

sunag 2 年之前
父节点
当前提交
129635bdb5
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 7 0
      examples/jsm/nodes/core/NodeBuilder.js
  2. 1 2
      examples/jsm/nodes/lighting/AnalyticLightNode.js

+ 7 - 0
examples/jsm/nodes/core/NodeBuilder.js

@@ -5,6 +5,7 @@ import NodeVar from './NodeVar.js';
 import NodeCode from './NodeCode.js';
 import NodeCode from './NodeCode.js';
 import NodeKeywords from './NodeKeywords.js';
 import NodeKeywords from './NodeKeywords.js';
 import NodeCache from './NodeCache.js';
 import NodeCache from './NodeCache.js';
+import { createNodeMaterialFromType } from '../materials/NodeMaterial.js';
 import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
 import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
 
 
 import { REVISION, NoColorSpace, LinearEncoding, sRGBEncoding, SRGBColorSpace, Color, Vector2, Vector3, Vector4, Float16BufferAttribute } from 'three';
 import { REVISION, NoColorSpace, LinearEncoding, sRGBEncoding, SRGBColorSpace, Color, Vector2, Vector3, Vector4, Float16BufferAttribute } from 'three';
@@ -921,6 +922,12 @@ class NodeBuilder {
 
 
 	}
 	}
 
 
+	createNodeMaterial( type ) {
+
+		return createNodeMaterialFromType( type );
+
+	}
+
 	format( snippet, fromType, toType ) {
 	format( snippet, fromType, toType ) {
 
 
 		fromType = this.getVectorType( fromType );
 		fromType = this.getVectorType( fromType );

+ 1 - 2
examples/jsm/nodes/lighting/AnalyticLightNode.js

@@ -8,7 +8,6 @@ import { texture } from '../accessors/TextureNode.js';
 import { positionWorld } from '../accessors/PositionNode.js';
 import { positionWorld } from '../accessors/PositionNode.js';
 //import { step } from '../math/MathNode.js';
 //import { step } from '../math/MathNode.js';
 import { cond } from '../math/CondNode.js';
 import { cond } from '../math/CondNode.js';
-import MeshBasicNodeMaterial from '../materials/MeshBasicNodeMaterial.js';
 
 
 import { Color, DepthTexture, NearestFilter } from 'three';
 import { Color, DepthTexture, NearestFilter } from 'three';
 
 
@@ -44,7 +43,7 @@ class AnalyticLightNode extends LightingNode {
 
 
 		if ( shadowNode === null ) {
 		if ( shadowNode === null ) {
 
 
-			if ( depthMaterial === null ) depthMaterial = new MeshBasicNodeMaterial();
+			if ( depthMaterial === null ) depthMaterial = builder.createNodeMaterial( 'MeshBasicNodeMaterial' );
 
 
 			const shadow = this.light.shadow;
 			const shadow = this.light.shadow;
 			const rtt = builder.getRenderTarget( shadow.mapSize.width, shadow.mapSize.height );
 			const rtt = builder.getRenderTarget( shadow.mapSize.width, shadow.mapSize.height );