Browse Source

MeshToonMaterial extends MeshPhongMaterial

Takahiro 8 years ago
parent
commit
d2c39ff497
2 changed files with 9 additions and 98 deletions
  1. 5 94
      src/materials/MeshToonMaterial.js
  2. 4 4
      src/renderers/WebGLRenderer.js

+ 5 - 94
src/materials/MeshToonMaterial.js

@@ -1,7 +1,4 @@
-import { Material } from './Material';
-import { MultiplyOperation } from '../constants';
-import { Vector2 } from '../math/Vector2';
-import { Color } from '../math/Color';
+import { MeshPhongMaterial } from './MeshPhongMaterial';
 
 /**
  * @author takahirox / http://github.com/takahirox
@@ -56,112 +53,26 @@ import { Color } from '../math/Color';
 
 function MeshToonMaterial( parameters ) {
 
-	Material.call( this );
+	MeshPhongMaterial.call( this );
 
 	this.type = 'MeshToonMaterial';
 
-	this.color = new Color( 0xffffff ); // diffuse
-	this.specular = new Color( 0x111111 );
-	this.shininess = 30;
-
-	this.map = null;
-
-	this.lightMap = null;
-	this.lightMapIntensity = 1.0;
-
-	this.aoMap = null;
-	this.aoMapIntensity = 1.0;
-
-	this.emissive = new Color( 0x000000 );
-	this.emissiveIntensity = 1.0;
-	this.emissiveMap = null;
-
-	this.bumpMap = null;
-	this.bumpScale = 1;
-
-	this.normalMap = null;
-	this.normalScale = new Vector2( 1, 1 );
-
-	this.displacementMap = null;
-	this.displacementScale = 1;
-	this.displacementBias = 0;
-
-	this.specularMap = null;
-
-	this.alphaMap = null;
-
-	this.envMap = null;
-	this.combine = MultiplyOperation;
-	this.reflectivity = 1;
-	this.refractionRatio = 0.98;
-
 	this.gradientMap = null;
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
-	this.wireframeLinecap = 'round';
-	this.wireframeLinejoin = 'round';
-
-	this.skinning = false;
-	this.morphTargets = false;
-	this.morphNormals = false;
-
 	this.setValues( parameters );
 
 }
 
-MeshToonMaterial.prototype = Object.create( Material.prototype );
+MeshToonMaterial.prototype = Object.create( MeshPhongMaterial.prototype );
 MeshToonMaterial.prototype.constructor = MeshToonMaterial;
 
 MeshToonMaterial.prototype.isMeshToonMaterial = true;
 
 MeshToonMaterial.prototype.copy = function ( source ) {
 
-	Material.prototype.copy.call( this, source );
-
-	this.color.copy( source.color );
-	this.specular.copy( source.specular );
-	this.shininess = source.shininess;
-
-	this.map = source.map;
-
-	this.lightMap = source.lightMap;
-	this.lightMapIntensity = source.lightMapIntensity;
-
-	this.aoMap = source.aoMap;
-	this.aoMapIntensity = source.aoMapIntensity;
-
-	this.emissive.copy( source.emissive );
-	this.emissiveMap = source.emissiveMap;
-	this.emissiveIntensity = source.emissiveIntensity;
-
-	this.bumpMap = source.bumpMap;
-	this.bumpScale = source.bumpScale;
-
-	this.normalMap = source.normalMap;
-	this.normalScale.copy( source.normalScale );
-
-	this.displacementMap = source.displacementMap;
-	this.displacementScale = source.displacementScale;
-	this.displacementBias = source.displacementBias;
-
-	this.specularMap = source.specularMap;
-
-	this.alphaMap = source.alphaMap;
-
-	this.envMap = source.envMap;
-	this.combine = source.combine;
-	this.reflectivity = source.reflectivity;
-	this.refractionRatio = source.refractionRatio;
-
-	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
-	this.wireframeLinecap = source.wireframeLinecap;
-	this.wireframeLinejoin = source.wireframeLinejoin;
+	MeshPhongMaterial.prototype.copy.call( this, source );
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
-	this.morphNormals = source.morphNormals;
+	this.gradientMap = source.gradientMap;
 
 	return this;
 

+ 4 - 4
src/renderers/WebGLRenderer.js

@@ -1892,14 +1892,14 @@ function WebGLRenderer( parameters ) {
 
 				refreshUniformsLambert( m_uniforms, material );
 
-			} else if ( material.isMeshPhongMaterial ) {
-
-				refreshUniformsPhong( m_uniforms, material );
-
 			} else if ( material.isMeshToonMaterial ) {
 
 				refreshUniformsToon( m_uniforms, material );
 
+			} else if ( material.isMeshPhongMaterial ) {
+
+				refreshUniformsPhong( m_uniforms, material );
+
 			} else if ( material.isMeshPhysicalMaterial ) {
 
 				refreshUniformsPhysical( m_uniforms, material );