Browse Source

NodeMaterial: Fix backward compatibility of scene.environment. (#25698)

sunag 2 năm trước cách đây
mục cha
commit
464e9adc17
1 tập tin đã thay đổi với 22 bổ sung1 xóa
  1. 22 1
      examples/jsm/nodes/materials/NodeMaterial.js

+ 22 - 1
examples/jsm/nodes/materials/NodeMaterial.js

@@ -11,6 +11,7 @@ import { positionLocal } from '../accessors/PositionNode.js';
 import { reference } from '../accessors/ReferenceNode.js';
 import { skinning } from '../accessors/SkinningNode.js';
 import { texture } from '../accessors/TextureNode.js';
+import { cubeTexture } from '../accessors/CubeTextureNode.js';
 import { toneMapping } from '../display/ToneMappingNode.js';
 import { rangeFog } from '../fog/FogRangeNode.js';
 import { densityFog } from '../fog/FogExp2Node.js';
@@ -161,8 +162,28 @@ class NodeMaterial extends ShaderMaterial {
 	constructLights( builder ) {
 
 		let lightsNode = this.lightsNode || builder.lightsNode;
+		let envNode = this.envNode || builder.scene.environmentNode;
+
+		if ( envNode === undefined && builder.scene.environment ) {
+
+			const environment = builder.scene.environment;
+
+			if ( environment.isCubeTexture === true ) {
+
+				envNode = cubeTexture( environment );
+
+			} else if ( environment.isTexture === true ) {
+
+				envNode = texture( environment );
+
+			} else {
+
+				console.error( 'NodeMaterial: Unsupported environment configuration.', environment );
+
+			}
+
+		}
 
-		const envNode = this.envNode || builder.scene.environmentNode;
 		const materialLightsNode = [];
 
 		if ( envNode ) {