Pārlūkot izejas kodu

WebGLRenderer: Simplified shaderID code. See #5762.

Mr.doob 10 gadi atpakaļ
vecāks
revīzija
0057db3e6b
1 mainītis faili ar 12 papildinājumiem un 35 dzēšanām
  1. 12 35
      src/renderers/WebGLRenderer.js

+ 12 - 35
src/renderers/WebGLRenderer.js

@@ -4052,45 +4052,22 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	// Materials
 	// Materials
 
 
+	var shaderIDs = {
+		MeshDepthMaterial: 'depth',
+		MeshNormalMaterial: 'normal',
+		MeshBasicMaterial: 'basic',
+		MeshLambertMaterial: 'lambert',
+		MeshPhongMaterial: 'phong',
+		LineBasicMaterial: 'basic',
+		LineDashedMaterial: 'dashed',
+		PointCloudMaterial: 'particle_basic'
+	};
+
 	function initMaterial( material, lights, fog, object ) {
 	function initMaterial( material, lights, fog, object ) {
 
 
 		material.addEventListener( 'dispose', onMaterialDispose );
 		material.addEventListener( 'dispose', onMaterialDispose );
 
 
-		var shaderID;
-
-		if ( material instanceof THREE.MeshDepthMaterial ) {
-
-			shaderID = 'depth';
-
-		} else if ( material instanceof THREE.MeshNormalMaterial ) {
-
-			shaderID = 'normal';
-
-		} else if ( material instanceof THREE.MeshBasicMaterial ) {
-
-			shaderID = 'basic';
-
-		} else if ( material instanceof THREE.MeshLambertMaterial ) {
-
-			shaderID = 'lambert';
-
-		} else if ( material instanceof THREE.MeshPhongMaterial ) {
-
-			shaderID = 'phong';
-
-		} else if ( material instanceof THREE.LineBasicMaterial ) {
-
-			shaderID = 'basic';
-
-		} else if ( material instanceof THREE.LineDashedMaterial ) {
-
-			shaderID = 'dashed';
-
-		} else if ( material instanceof THREE.PointCloudMaterial ) {
-
-			shaderID = 'particle_basic';
-
-		}
+		var shaderID = shaderIDs[ material.type ];
 
 
 		if ( shaderID ) {
 		if ( shaderID ) {