فهرست منبع

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 NodeKeywords from './NodeKeywords.js';
 import NodeCache from './NodeCache.js';
+import { createNodeMaterialFromType } from '../materials/NodeMaterial.js';
 import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
 
 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 ) {
 
 		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 { step } from '../math/MathNode.js';
 import { cond } from '../math/CondNode.js';
-import MeshBasicNodeMaterial from '../materials/MeshBasicNodeMaterial.js';
 
 import { Color, DepthTexture, NearestFilter } from 'three';
 
@@ -44,7 +43,7 @@ class AnalyticLightNode extends LightingNode {
 
 		if ( shadowNode === null ) {
 
-			if ( depthMaterial === null ) depthMaterial = new MeshBasicNodeMaterial();
+			if ( depthMaterial === null ) depthMaterial = builder.createNodeMaterial( 'MeshBasicNodeMaterial' );
 
 			const shadow = this.light.shadow;
 			const rtt = builder.getRenderTarget( shadow.mapSize.width, shadow.mapSize.height );