소스 검색

Merge pull request #21319 from Mugen87/dev51

MeshStandardMaterial: Revert class change.
Mr.doob 4 년 전
부모
커밋
b920260287
2개의 변경된 파일134개의 추가작업 그리고 136개의 파일을 삭제
  1. 52 54
      src/materials/MeshPhysicalMaterial.js
  2. 82 82
      src/materials/MeshStandardMaterial.js

+ 52 - 54
src/materials/MeshPhysicalMaterial.js

@@ -22,92 +22,90 @@ import { MathUtils } from '../math/MathUtils.js';
  * }
  */
 
-class MeshPhysicalMaterial extends MeshStandardMaterial {
+function MeshPhysicalMaterial( parameters ) {
 
-	constructor( parameters ) {
+	MeshStandardMaterial.call( this );
 
-		super();
+	this.defines = {
 
-		this.defines = {
+		'STANDARD': '',
+		'PHYSICAL': ''
 
-			'STANDARD': '',
-			'PHYSICAL': ''
+	};
 
-		};
+	this.type = 'MeshPhysicalMaterial';
 
-		this.type = 'MeshPhysicalMaterial';
+	this.clearcoat = 0.0;
+	this.clearcoatMap = null;
+	this.clearcoatRoughness = 0.0;
+	this.clearcoatRoughnessMap = null;
+	this.clearcoatNormalScale = new Vector2( 1, 1 );
+	this.clearcoatNormalMap = null;
 
-		this.clearcoat = 0.0;
-		this.clearcoatMap = null;
-		this.clearcoatRoughness = 0.0;
-		this.clearcoatRoughnessMap = null;
-		this.clearcoatNormalScale = new Vector2( 1, 1 );
-		this.clearcoatNormalMap = null;
+	this.reflectivity = 0.5; // maps to F0 = 0.04
 
-		this.reflectivity = 0.5; // maps to F0 = 0.04
+	Object.defineProperty( this, 'ior', {
+		get: function () {
 
-		Object.defineProperty( this, 'ior', {
-			get: function () {
+			return ( 1 + 0.4 * this.reflectivity ) / ( 1 - 0.4 * this.reflectivity );
 
-				return ( 1 + 0.4 * this.reflectivity ) / ( 1 - 0.4 * this.reflectivity );
+		},
+		set: function ( ior ) {
 
-			},
-			set: function ( ior ) {
+			this.reflectivity = MathUtils.clamp( 2.5 * ( ior - 1 ) / ( ior + 1 ), 0, 1 );
 
-				this.reflectivity = MathUtils.clamp( 2.5 * ( ior - 1 ) / ( ior + 1 ), 0, 1 );
-
-			}
-		} );
-
-
-		this.sheen = null; // null will disable sheen bsdf
+		}
+	} );
 
-		this.transmission = 0.0;
-		this.transmissionMap = null;
+	this.sheen = null; // null will disable sheen bsdf
 
-		this.setValues( parameters );
+	this.transmission = 0.0;
+	this.transmissionMap = null;
 
-	}
+	this.setValues( parameters );
 
-	copy( source ) {
+}
 
-		super.copy( source );
+MeshPhysicalMaterial.prototype = Object.create( MeshStandardMaterial.prototype );
+MeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;
 
-		this.defines = {
+MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
 
-			'STANDARD': '',
-			'PHYSICAL': ''
+MeshPhysicalMaterial.prototype.copy = function ( source ) {
 
-		};
+	MeshStandardMaterial.prototype.copy.call( this, source );
 
-		this.clearcoat = source.clearcoat;
-		this.clearcoatMap = source.clearcoatMap;
-		this.clearcoatRoughness = source.clearcoatRoughness;
-		this.clearcoatRoughnessMap = source.clearcoatRoughnessMap;
-		this.clearcoatNormalMap = source.clearcoatNormalMap;
-		this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
+	this.defines = {
 
-		this.reflectivity = source.reflectivity;
+		'STANDARD': '',
+		'PHYSICAL': ''
 
-		if ( source.sheen ) {
+	};
 
-			this.sheen = ( this.sheen || new Color() ).copy( source.sheen );
+	this.clearcoat = source.clearcoat;
+	this.clearcoatMap = source.clearcoatMap;
+	this.clearcoatRoughness = source.clearcoatRoughness;
+	this.clearcoatRoughnessMap = source.clearcoatRoughnessMap;
+	this.clearcoatNormalMap = source.clearcoatNormalMap;
+	this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
 
-		} else {
+	this.reflectivity = source.reflectivity;
 
-			this.sheen = null;
+	if ( source.sheen ) {
 
-		}
+		this.sheen = ( this.sheen || new Color() ).copy( source.sheen );
 
-		this.transmission = source.transmission;
-		this.transmissionMap = source.transmissionMap;
+	} else {
 
-		return this;
+		this.sheen = null;
 
 	}
 
-}
+	this.transmission = source.transmission;
+	this.transmissionMap = source.transmissionMap;
 
-MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
+	return this;
+
+};
 
 export { MeshPhysicalMaterial };

+ 82 - 82
src/materials/MeshStandardMaterial.js

@@ -55,134 +55,134 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-class MeshStandardMaterial extends Material {
+function MeshStandardMaterial( parameters ) {
 
-	constructor( parameters ) {
+	Material.call( this );
 
-		super();
+	this.defines = { 'STANDARD': '' };
 
-		this.defines = { 'STANDARD': '' };
+	this.type = 'MeshStandardMaterial';
 
-		this.type = 'MeshStandardMaterial';
+	this.color = new Color( 0xffffff ); // diffuse
+	this.roughness = 1.0;
+	this.metalness = 0.0;
 
-		this.color = new Color( 0xffffff ); // diffuse
-		this.roughness = 1.0;
-		this.metalness = 0.0;
+	this.map = null;
 
-		this.map = null;
+	this.lightMap = null;
+	this.lightMapIntensity = 1.0;
 
-		this.lightMap = null;
-		this.lightMapIntensity = 1.0;
+	this.aoMap = null;
+	this.aoMapIntensity = 1.0;
 
-		this.aoMap = null;
-		this.aoMapIntensity = 1.0;
+	this.emissive = new Color( 0x000000 );
+	this.emissiveIntensity = 1.0;
+	this.emissiveMap = null;
 
-		this.emissive = new Color( 0x000000 );
-		this.emissiveIntensity = 1.0;
-		this.emissiveMap = null;
+	this.bumpMap = null;
+	this.bumpScale = 1;
 
-		this.bumpMap = null;
-		this.bumpScale = 1;
+	this.normalMap = null;
+	this.normalMapType = TangentSpaceNormalMap;
+	this.normalScale = new Vector2( 1, 1 );
 
-		this.normalMap = null;
-		this.normalMapType = TangentSpaceNormalMap;
-		this.normalScale = new Vector2( 1, 1 );
+	this.displacementMap = null;
+	this.displacementScale = 1;
+	this.displacementBias = 0;
 
-		this.displacementMap = null;
-		this.displacementScale = 1;
-		this.displacementBias = 0;
+	this.roughnessMap = null;
 
-		this.roughnessMap = null;
+	this.metalnessMap = null;
 
-		this.metalnessMap = null;
+	this.alphaMap = null;
 
-		this.alphaMap = null;
+	this.envMap = null;
+	this.envMapIntensity = 1.0;
 
-		this.envMap = null;
-		this.envMapIntensity = 1.0;
+	this.refractionRatio = 0.98;
 
-		this.refractionRatio = 0.98;
+	this.wireframe = false;
+	this.wireframeLinewidth = 1;
+	this.wireframeLinecap = 'round';
+	this.wireframeLinejoin = 'round';
 
-		this.wireframe = false;
-		this.wireframeLinewidth = 1;
-		this.wireframeLinecap = 'round';
-		this.wireframeLinejoin = 'round';
+	this.skinning = false;
+	this.morphTargets = false;
+	this.morphNormals = false;
 
-		this.skinning = false;
-		this.morphTargets = false;
-		this.morphNormals = false;
+	this.flatShading = false;
 
-		this.flatShading = false;
+	this.vertexTangents = false;
 
-		this.vertexTangents = false;
+	this.setValues( parameters );
 
-		this.setValues( parameters );
+}
 
-	}
+MeshStandardMaterial.prototype = Object.create( Material.prototype );
+MeshStandardMaterial.prototype.constructor = MeshStandardMaterial;
 
-	copy( source ) {
+MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
 
-		super.copy( source );
+MeshStandardMaterial.prototype.copy = function ( source ) {
 
-		this.defines = { 'STANDARD': '' };
+	Material.prototype.copy.call( this, source );
 
-		this.color.copy( source.color );
-		this.roughness = source.roughness;
-		this.metalness = source.metalness;
+	this.defines = { 'STANDARD': '' };
 
-		this.map = source.map;
+	this.color.copy( source.color );
+	this.roughness = source.roughness;
+	this.metalness = source.metalness;
 
-		this.lightMap = source.lightMap;
-		this.lightMapIntensity = source.lightMapIntensity;
+	this.map = source.map;
 
-		this.aoMap = source.aoMap;
-		this.aoMapIntensity = source.aoMapIntensity;
+	this.lightMap = source.lightMap;
+	this.lightMapIntensity = source.lightMapIntensity;
 
-		this.emissive.copy( source.emissive );
-		this.emissiveMap = source.emissiveMap;
-		this.emissiveIntensity = source.emissiveIntensity;
+	this.aoMap = source.aoMap;
+	this.aoMapIntensity = source.aoMapIntensity;
 
-		this.bumpMap = source.bumpMap;
-		this.bumpScale = source.bumpScale;
+	this.emissive.copy( source.emissive );
+	this.emissiveMap = source.emissiveMap;
+	this.emissiveIntensity = source.emissiveIntensity;
 
-		this.normalMap = source.normalMap;
-		this.normalMapType = source.normalMapType;
-		this.normalScale.copy( source.normalScale );
+	this.bumpMap = source.bumpMap;
+	this.bumpScale = source.bumpScale;
 
-		this.displacementMap = source.displacementMap;
-		this.displacementScale = source.displacementScale;
-		this.displacementBias = source.displacementBias;
+	this.normalMap = source.normalMap;
+	this.normalMapType = source.normalMapType;
+	this.normalScale.copy( source.normalScale );
 
-		this.roughnessMap = source.roughnessMap;
+	this.displacementMap = source.displacementMap;
+	this.displacementScale = source.displacementScale;
+	this.displacementBias = source.displacementBias;
 
-		this.metalnessMap = source.metalnessMap;
+	this.roughnessMap = source.roughnessMap;
 
-		this.alphaMap = source.alphaMap;
+	this.metalnessMap = source.metalnessMap;
 
-		this.envMap = source.envMap;
-		this.envMapIntensity = source.envMapIntensity;
+	this.alphaMap = source.alphaMap;
 
-		this.refractionRatio = source.refractionRatio;
+	this.envMap = source.envMap;
+	this.envMapIntensity = source.envMapIntensity;
 
-		this.wireframe = source.wireframe;
-		this.wireframeLinewidth = source.wireframeLinewidth;
-		this.wireframeLinecap = source.wireframeLinecap;
-		this.wireframeLinejoin = source.wireframeLinejoin;
+	this.refractionRatio = source.refractionRatio;
 
-		this.skinning = source.skinning;
-		this.morphTargets = source.morphTargets;
-		this.morphNormals = source.morphNormals;
+	this.wireframe = source.wireframe;
+	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframeLinecap = source.wireframeLinecap;
+	this.wireframeLinejoin = source.wireframeLinejoin;
 
-		this.flatShading = source.flatShading;
+	this.skinning = source.skinning;
+	this.morphTargets = source.morphTargets;
+	this.morphNormals = source.morphNormals;
 
-		this.vertexTangents = source.vertexTangents;
+	this.flatShading = source.flatShading;
 
-		return this;
+	this.vertexTangents = source.vertexTangents;
 
-	}
+	return this;
 
-}
+};
 
-MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
 
 export { MeshStandardMaterial };