Browse Source

fix(src/materials): Convert to ES6.

linbingquan 4 years ago
parent
commit
5c852a2816

+ 23 - 22
src/materials/LineBasicMaterial.js

@@ -12,44 +12,45 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function LineBasicMaterial( parameters ) {
+class LineBasicMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'LineBasicMaterial';
+		super();
 
-	this.color = new Color( 0xffffff );
+		Object.defineProperty( this, 'isLineBasicMaterial', { value: true } );
 
-	this.linewidth = 1;
-	this.linecap = 'round';
-	this.linejoin = 'round';
+		this.type = 'LineBasicMaterial';
 
-	this.morphTargets = false;
+		this.color = new Color( 0xffffff );
 
-	this.setValues( parameters );
+		this.linewidth = 1;
+		this.linecap = 'round';
+		this.linejoin = 'round';
 
-}
+		this.morphTargets = false;
+
+		this.setValues( parameters );
 
-LineBasicMaterial.prototype = Object.create( Material.prototype );
-LineBasicMaterial.prototype.constructor = LineBasicMaterial;
+	}
 
-LineBasicMaterial.prototype.isLineBasicMaterial = true;
 
-LineBasicMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		Material.prototype.copy.call( this, source );
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	this.linewidth = source.linewidth;
-	this.linecap = source.linecap;
-	this.linejoin = source.linejoin;
+		this.linewidth = source.linewidth;
+		this.linecap = source.linecap;
+		this.linejoin = source.linejoin;
 
-	this.morphTargets = source.morphTargets;
+		this.morphTargets = source.morphTargets;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { LineBasicMaterial };

+ 18 - 18
src/materials/LineDashedMaterial.js

@@ -13,36 +13,36 @@ import { LineBasicMaterial } from './LineBasicMaterial.js';
  * }
  */
 
-function LineDashedMaterial( parameters ) {
+class LineDashedMaterial extends LineBasicMaterial {
 
-	LineBasicMaterial.call( this );
+	constructor( parameters ) {
 
-	this.type = 'LineDashedMaterial';
+		super();
 
-	this.scale = 1;
-	this.dashSize = 3;
-	this.gapSize = 1;
+		Object.defineProperty( this, 'isLineDashedMaterial', { value: true } );
 
-	this.setValues( parameters );
+		this.type = 'LineDashedMaterial';
 
-}
+		this.scale = 1;
+		this.dashSize = 3;
+		this.gapSize = 1;
 
-LineDashedMaterial.prototype = Object.create( LineBasicMaterial.prototype );
-LineDashedMaterial.prototype.constructor = LineDashedMaterial;
+		this.setValues( parameters );
 
-LineDashedMaterial.prototype.isLineDashedMaterial = true;
+	}
 
-LineDashedMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	LineBasicMaterial.prototype.copy.call( this, source );
+		super.copy( source );
 
-	this.scale = source.scale;
-	this.dashSize = source.dashSize;
-	this.gapSize = source.gapSize;
+		this.scale = source.scale;
+		this.dashSize = source.dashSize;
+		this.gapSize = source.gapSize;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { LineDashedMaterial };

+ 67 - 71
src/materials/Material.js

@@ -4,88 +4,94 @@ import { MathUtils } from '../math/MathUtils.js';
 
 let materialId = 0;
 
-function Material() {
+class Material extends EventDispatcher {
 
-	Object.defineProperty( this, 'id', { value: materialId ++ } );
+	constructor() {
 
-	this.uuid = MathUtils.generateUUID();
+		super();
 
-	this.name = '';
-	this.type = 'Material';
+		Object.defineProperty( this, 'id', { value: materialId ++ } );
+		Object.defineProperty( this, 'isMaterial', { value: true } );
 
-	this.fog = true;
+		this.uuid = MathUtils.generateUUID();
 
-	this.blending = NormalBlending;
-	this.side = FrontSide;
-	this.vertexColors = false;
+		this.name = '';
+		this.type = 'Material';
 
-	this.opacity = 1;
-	this.transparent = false;
+		this.fog = true;
 
-	this.blendSrc = SrcAlphaFactor;
-	this.blendDst = OneMinusSrcAlphaFactor;
-	this.blendEquation = AddEquation;
-	this.blendSrcAlpha = null;
-	this.blendDstAlpha = null;
-	this.blendEquationAlpha = null;
+		this.blending = NormalBlending;
+		this.side = FrontSide;
+		this.flatShading = false;
+		this.vertexColors = false;
 
-	this.depthFunc = LessEqualDepth;
-	this.depthTest = true;
-	this.depthWrite = true;
+		this.opacity = 1;
+		this.transparent = false;
 
-	this.stencilWriteMask = 0xff;
-	this.stencilFunc = AlwaysStencilFunc;
-	this.stencilRef = 0;
-	this.stencilFuncMask = 0xff;
-	this.stencilFail = KeepStencilOp;
-	this.stencilZFail = KeepStencilOp;
-	this.stencilZPass = KeepStencilOp;
-	this.stencilWrite = false;
+		this.blendSrc = SrcAlphaFactor;
+		this.blendDst = OneMinusSrcAlphaFactor;
+		this.blendEquation = AddEquation;
+		this.blendSrcAlpha = null;
+		this.blendDstAlpha = null;
+		this.blendEquationAlpha = null;
 
-	this.clippingPlanes = null;
-	this.clipIntersection = false;
-	this.clipShadows = false;
+		this.depthFunc = LessEqualDepth;
+		this.depthTest = true;
+		this.depthWrite = true;
 
-	this.shadowSide = null;
+		this.stencilWriteMask = 0xff;
+		this.stencilFunc = AlwaysStencilFunc;
+		this.stencilRef = 0;
+		this.stencilFuncMask = 0xff;
+		this.stencilFail = KeepStencilOp;
+		this.stencilZFail = KeepStencilOp;
+		this.stencilZPass = KeepStencilOp;
+		this.stencilWrite = false;
 
-	this.colorWrite = true;
+		this.clippingPlanes = null;
+		this.clipIntersection = false;
+		this.clipShadows = false;
 
-	this.precision = null; // override the renderer's default precision for this material
+		this.shadowSide = null;
 
-	this.polygonOffset = false;
-	this.polygonOffsetFactor = 0;
-	this.polygonOffsetUnits = 0;
+		this.colorWrite = true;
 
-	this.dithering = false;
+		this.precision = null; // override the renderer's default precision for this material
 
-	this.alphaTest = 0;
-	this.premultipliedAlpha = false;
+		this.polygonOffset = false;
+		this.polygonOffsetFactor = 0;
+		this.polygonOffsetUnits = 0;
 
-	this.visible = true;
+		this.dithering = false;
 
-	this.toneMapped = true;
+		this.alphaTest = 0;
+		this.premultipliedAlpha = false;
 
-	this.userData = {};
+		this.visible = true;
 
-	this.version = 0;
+		this.toneMapped = true;
 
-}
+		this.userData = {};
+
+		this.version = 0;
 
-Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
+	}
 
-	constructor: Material,
+	set needsUpdate( value ) {
+
+		if ( value === true ) this.version ++;
 
-	isMaterial: true,
+	}
 
-	onBeforeCompile: function ( /* shaderobject, renderer */ ) {},
+	onBeforeCompile( /* shaderobject, renderer */ ) {}
 
-	customProgramCacheKey: function () {
+	customProgramCacheKey() {
 
 		return this.onBeforeCompile.toString();
 
-	},
+	}
 
-	setValues: function ( values ) {
+	setValues( values ) {
 
 		if ( values === undefined ) return;
 
@@ -134,9 +140,9 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		}
 
-	},
+	}
 
-	toJSON: function ( meta ) {
+	toJSON( meta ) {
 
 		const isRoot = ( meta === undefined || typeof meta === 'string' );
 
@@ -347,15 +353,15 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		return data;
 
-	},
+	}
 
-	clone: function () {
+	clone() {
 
 		return new this.constructor().copy( this );
 
-	},
+	}
 
-	copy: function ( source ) {
+	copy( source ) {
 
 		this.name = source.name;
 
@@ -431,24 +437,14 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		return this;
 
-	},
-
-	dispose: function () {
-
-		this.dispatchEvent( { type: 'dispose' } );
-
 	}
 
-} );
-
-Object.defineProperty( Material.prototype, 'needsUpdate', {
+	dispose() {
 
-	set: function ( value ) {
-
-		if ( value === true ) this.version ++;
+		this.dispatchEvent( { type: 'dispose' } );
 
 	}
 
-} );
+}
 
 export { Material };

+ 48 - 48
src/materials/MeshBasicMaterial.js

@@ -34,82 +34,82 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function MeshBasicMaterial( parameters ) {
+class MeshBasicMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'MeshBasicMaterial';
+		super();
 
-	this.color = new Color( 0xffffff ); // emissive
+		Object.defineProperty( this, 'isMeshBasicMaterial', { value: true } );
 
-	this.map = null;
+		this.type = 'MeshBasicMaterial';
 
-	this.lightMap = null;
-	this.lightMapIntensity = 1.0;
+		this.color = new Color( 0xffffff ); // emissive
 
-	this.aoMap = null;
-	this.aoMapIntensity = 1.0;
+		this.map = null;
 
-	this.specularMap = null;
+		this.lightMap = null;
+		this.lightMapIntensity = 1.0;
 
-	this.alphaMap = null;
+		this.aoMap = null;
+		this.aoMapIntensity = 1.0;
 
-	this.envMap = null;
-	this.combine = MultiplyOperation;
-	this.reflectivity = 1;
-	this.refractionRatio = 0.98;
+		this.specularMap = null;
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
-	this.wireframeLinecap = 'round';
-	this.wireframeLinejoin = 'round';
+		this.alphaMap = null;
 
-	this.skinning = false;
-	this.morphTargets = false;
+		this.envMap = null;
+		this.combine = MultiplyOperation;
+		this.reflectivity = 1;
+		this.refractionRatio = 0.98;
 
-	this.setValues( parameters );
+		this.wireframe = false;
+		this.wireframeLinewidth = 1;
+		this.wireframeLinecap = 'round';
+		this.wireframeLinejoin = 'round';
 
-}
+		this.skinning = false;
+		this.morphTargets = false;
 
-MeshBasicMaterial.prototype = Object.create( Material.prototype );
-MeshBasicMaterial.prototype.constructor = MeshBasicMaterial;
+		this.setValues( parameters );
 
-MeshBasicMaterial.prototype.isMeshBasicMaterial = true;
+	}
 
-MeshBasicMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		super.copy( source );
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.lightMap = source.lightMap;
-	this.lightMapIntensity = source.lightMapIntensity;
+		this.lightMap = source.lightMap;
+		this.lightMapIntensity = source.lightMapIntensity;
 
-	this.aoMap = source.aoMap;
-	this.aoMapIntensity = source.aoMapIntensity;
+		this.aoMap = source.aoMap;
+		this.aoMapIntensity = source.aoMapIntensity;
 
-	this.specularMap = source.specularMap;
+		this.specularMap = source.specularMap;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.envMap = source.envMap;
-	this.combine = source.combine;
-	this.reflectivity = source.reflectivity;
-	this.refractionRatio = source.refractionRatio;
+		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;
+		this.wireframe = source.wireframe;
+		this.wireframeLinewidth = source.wireframeLinewidth;
+		this.wireframeLinecap = source.wireframeLinecap;
+		this.wireframeLinejoin = source.wireframeLinejoin;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshBasicMaterial };

+ 33 - 33
src/materials/MeshDepthMaterial.js

@@ -19,62 +19,62 @@ import { BasicDepthPacking } from '../constants.js';
  * }
  */
 
-function MeshDepthMaterial( parameters ) {
+class MeshDepthMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'MeshDepthMaterial';
+		super();
 
-	this.depthPacking = BasicDepthPacking;
+		Object.defineProperty( this, 'isMeshDepthMaterial', { value: true } );
 
-	this.skinning = false;
-	this.morphTargets = false;
+		this.type = 'MeshDepthMaterial';
 
-	this.map = null;
+		this.depthPacking = BasicDepthPacking;
 
-	this.alphaMap = null;
+		this.skinning = false;
+		this.morphTargets = false;
 
-	this.displacementMap = null;
-	this.displacementScale = 1;
-	this.displacementBias = 0;
+		this.map = null;
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+		this.alphaMap = null;
 
-	this.fog = false;
+		this.displacementMap = null;
+		this.displacementScale = 1;
+		this.displacementBias = 0;
 
-	this.setValues( parameters );
+		this.wireframe = false;
+		this.wireframeLinewidth = 1;
 
-}
+		this.fog = false;
 
-MeshDepthMaterial.prototype = Object.create( Material.prototype );
-MeshDepthMaterial.prototype.constructor = MeshDepthMaterial;
+		this.setValues( parameters );
 
-MeshDepthMaterial.prototype.isMeshDepthMaterial = true;
+	}
 
-MeshDepthMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		Material.prototype.copy.call( this, source );
 
-	this.depthPacking = source.depthPacking;
+		this.depthPacking = source.depthPacking;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.displacementMap = source.displacementMap;
-	this.displacementScale = source.displacementScale;
-	this.displacementBias = source.displacementBias;
+		this.displacementMap = source.displacementMap;
+		this.displacementScale = source.displacementScale;
+		this.displacementBias = source.displacementBias;
 
-	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+		this.wireframe = source.wireframe;
+		this.wireframeLinewidth = source.wireframeLinewidth;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshDepthMaterial };

+ 33 - 33
src/materials/MeshDistanceMaterial.js

@@ -22,60 +22,60 @@ import { Vector3 } from '../math/Vector3.js';
  * }
  */
 
-function MeshDistanceMaterial( parameters ) {
+class MeshDistanceMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'MeshDistanceMaterial';
+		super();
 
-	this.referencePosition = new Vector3();
-	this.nearDistance = 1;
-	this.farDistance = 1000;
+		Object.defineProperty( this, 'isMeshDistanceMaterial', { value: true } );
 
-	this.skinning = false;
-	this.morphTargets = false;
+		this.type = 'MeshDistanceMaterial';
 
-	this.map = null;
+		this.referencePosition = new Vector3();
+		this.nearDistance = 1;
+		this.farDistance = 1000;
 
-	this.alphaMap = null;
+		this.skinning = false;
+		this.morphTargets = false;
 
-	this.displacementMap = null;
-	this.displacementScale = 1;
-	this.displacementBias = 0;
+		this.map = null;
 
-	this.fog = false;
+		this.alphaMap = null;
 
-	this.setValues( parameters );
+		this.displacementMap = null;
+		this.displacementScale = 1;
+		this.displacementBias = 0;
 
-}
+		this.fog = false;
 
-MeshDistanceMaterial.prototype = Object.create( Material.prototype );
-MeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;
+		this.setValues( parameters );
 
-MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
+	}
 
-MeshDistanceMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		super.clone( source );
 
-	this.referencePosition.copy( source.referencePosition );
-	this.nearDistance = source.nearDistance;
-	this.farDistance = source.farDistance;
+		this.referencePosition.copy( source.referencePosition );
+		this.nearDistance = source.nearDistance;
+		this.farDistance = source.farDistance;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.displacementMap = source.displacementMap;
-	this.displacementScale = source.displacementScale;
-	this.displacementBias = source.displacementBias;
+		this.displacementMap = source.displacementMap;
+		this.displacementScale = source.displacementScale;
+		this.displacementBias = source.displacementBias;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshDistanceMaterial };

+ 56 - 56
src/materials/MeshLambertMaterial.js

@@ -37,92 +37,92 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function MeshLambertMaterial( parameters ) {
+class MeshLambertMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'MeshLambertMaterial';
+		super();
 
-	this.color = new Color( 0xffffff ); // diffuse
+		Object.defineProperty( this, 'isMeshLambertMaterial', { value: true } );
 
-	this.map = null;
+		this.type = 'MeshLambertMaterial';
 
-	this.lightMap = null;
-	this.lightMapIntensity = 1.0;
+		this.color = new Color( 0xffffff ); // diffuse
 
-	this.aoMap = null;
-	this.aoMapIntensity = 1.0;
+		this.map = null;
 
-	this.emissive = new Color( 0x000000 );
-	this.emissiveIntensity = 1.0;
-	this.emissiveMap = null;
+		this.lightMap = null;
+		this.lightMapIntensity = 1.0;
 
-	this.specularMap = null;
+		this.aoMap = null;
+		this.aoMapIntensity = 1.0;
 
-	this.alphaMap = null;
+		this.emissive = new Color( 0x000000 );
+		this.emissiveIntensity = 1.0;
+		this.emissiveMap = null;
 
-	this.envMap = null;
-	this.combine = MultiplyOperation;
-	this.reflectivity = 1;
-	this.refractionRatio = 0.98;
+		this.specularMap = null;
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
-	this.wireframeLinecap = 'round';
-	this.wireframeLinejoin = 'round';
+		this.alphaMap = null;
 
-	this.skinning = false;
-	this.morphTargets = false;
-	this.morphNormals = false;
+		this.envMap = null;
+		this.combine = MultiplyOperation;
+		this.reflectivity = 1;
+		this.refractionRatio = 0.98;
 
-	this.setValues( parameters );
+		this.wireframe = false;
+		this.wireframeLinewidth = 1;
+		this.wireframeLinecap = 'round';
+		this.wireframeLinejoin = 'round';
 
-}
+		this.skinning = false;
+		this.morphTargets = false;
+		this.morphNormals = false;
 
-MeshLambertMaterial.prototype = Object.create( Material.prototype );
-MeshLambertMaterial.prototype.constructor = MeshLambertMaterial;
+		this.setValues( parameters );
 
-MeshLambertMaterial.prototype.isMeshLambertMaterial = true;
+	}
 
-MeshLambertMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		Material.prototype.copy.call( this, source );
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.lightMap = source.lightMap;
-	this.lightMapIntensity = source.lightMapIntensity;
+		this.lightMap = source.lightMap;
+		this.lightMapIntensity = source.lightMapIntensity;
 
-	this.aoMap = source.aoMap;
-	this.aoMapIntensity = source.aoMapIntensity;
+		this.aoMap = source.aoMap;
+		this.aoMapIntensity = source.aoMapIntensity;
 
-	this.emissive.copy( source.emissive );
-	this.emissiveMap = source.emissiveMap;
-	this.emissiveIntensity = source.emissiveIntensity;
+		this.emissive.copy( source.emissive );
+		this.emissiveMap = source.emissiveMap;
+		this.emissiveIntensity = source.emissiveIntensity;
 
-	this.specularMap = source.specularMap;
+		this.specularMap = source.specularMap;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.envMap = source.envMap;
-	this.combine = source.combine;
-	this.reflectivity = source.reflectivity;
-	this.refractionRatio = source.refractionRatio;
+		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;
+		this.wireframe = source.wireframe;
+		this.wireframeLinewidth = source.wireframeLinewidth;
+		this.wireframeLinecap = source.wireframeLinecap;
+		this.wireframeLinejoin = source.wireframeLinejoin;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
-	this.morphNormals = source.morphNormals;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
+		this.morphNormals = source.morphNormals;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshLambertMaterial };

+ 47 - 46
src/materials/MeshMatcapMaterial.js

@@ -33,82 +33,83 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function MeshMatcapMaterial( parameters ) {
+class MeshMatcapMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.defines = { 'MATCAP': '' };
+		super();
 
-	this.type = 'MeshMatcapMaterial';
+		Object.defineProperty( this, 'isMeshMatcapMaterial', { value: true } );
 
-	this.color = new Color( 0xffffff ); // diffuse
+		this.defines = { 'MATCAP': '' };
 
-	this.matcap = null;
+		this.type = 'MeshMatcapMaterial';
 
-	this.map = null;
+		this.color = new Color( 0xffffff ); // diffuse
 
-	this.bumpMap = null;
-	this.bumpScale = 1;
+		this.matcap = null;
 
-	this.normalMap = null;
-	this.normalMapType = TangentSpaceNormalMap;
-	this.normalScale = new Vector2( 1, 1 );
+		this.map = null;
 
-	this.displacementMap = null;
-	this.displacementScale = 1;
-	this.displacementBias = 0;
+		this.bumpMap = null;
+		this.bumpScale = 1;
 
-	this.alphaMap = null;
+		this.normalMap = null;
+		this.normalMapType = TangentSpaceNormalMap;
+		this.normalScale = new Vector2( 1, 1 );
 
-	this.skinning = false;
-	this.morphTargets = false;
-	this.morphNormals = false;
+		this.displacementMap = null;
+		this.displacementScale = 1;
+		this.displacementBias = 0;
 
-	this.flatShading = false;
+		this.alphaMap = null;
 
-	this.setValues( parameters );
+		this.skinning = false;
+		this.morphTargets = false;
+		this.morphNormals = false;
 
-}
+		this.flatShading = false;
+
+		this.setValues( parameters );
 
-MeshMatcapMaterial.prototype = Object.create( Material.prototype );
-MeshMatcapMaterial.prototype.constructor = MeshMatcapMaterial;
+	}
 
-MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;
 
-MeshMatcapMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		super.clone( source );
 
-	this.defines = { 'MATCAP': '' };
+		this.defines = { 'MATCAP': '' };
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	this.matcap = source.matcap;
+		this.matcap = source.matcap;
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.bumpMap = source.bumpMap;
-	this.bumpScale = source.bumpScale;
+		this.bumpMap = source.bumpMap;
+		this.bumpScale = source.bumpScale;
 
-	this.normalMap = source.normalMap;
-	this.normalMapType = source.normalMapType;
-	this.normalScale.copy( source.normalScale );
+		this.normalMap = source.normalMap;
+		this.normalMapType = source.normalMapType;
+		this.normalScale.copy( source.normalScale );
 
-	this.displacementMap = source.displacementMap;
-	this.displacementScale = source.displacementScale;
-	this.displacementBias = source.displacementBias;
+		this.displacementMap = source.displacementMap;
+		this.displacementScale = source.displacementScale;
+		this.displacementBias = source.displacementBias;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
-	this.morphNormals = source.morphNormals;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
+		this.morphNormals = source.morphNormals;
 
-	this.flatShading = source.flatShading;
+		this.flatShading = source.flatShading;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshMatcapMaterial };

+ 41 - 41
src/materials/MeshNormalMaterial.js

@@ -28,70 +28,70 @@ import { Vector2 } from '../math/Vector2.js';
  * }
  */
 
-function MeshNormalMaterial( parameters ) {
+class MeshNormalMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'MeshNormalMaterial';
+		super();
 
-	this.bumpMap = null;
-	this.bumpScale = 1;
+		Object.defineProperty( this, 'isMeshNormalMaterial', { value: true } );
 
-	this.normalMap = null;
-	this.normalMapType = TangentSpaceNormalMap;
-	this.normalScale = new Vector2( 1, 1 );
+		this.type = 'MeshNormalMaterial';
 
-	this.displacementMap = null;
-	this.displacementScale = 1;
-	this.displacementBias = 0;
+		this.bumpMap = null;
+		this.bumpScale = 1;
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+		this.normalMap = null;
+		this.normalMapType = TangentSpaceNormalMap;
+		this.normalScale = new Vector2( 1, 1 );
 
-	this.fog = false;
+		this.displacementMap = null;
+		this.displacementScale = 1;
+		this.displacementBias = 0;
 
-	this.skinning = false;
-	this.morphTargets = false;
-	this.morphNormals = false;
+		this.wireframe = false;
+		this.wireframeLinewidth = 1;
 
-	this.flatShading = false;
+		this.fog = false;
 
-	this.setValues( parameters );
+		this.skinning = false;
+		this.morphTargets = false;
+		this.morphNormals = false;
 
-}
+		this.flatShading = false;
 
-MeshNormalMaterial.prototype = Object.create( Material.prototype );
-MeshNormalMaterial.prototype.constructor = MeshNormalMaterial;
+		this.setValues( parameters );
 
-MeshNormalMaterial.prototype.isMeshNormalMaterial = true;
+	}
 
-MeshNormalMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		super.clone( source );
 
-	this.bumpMap = source.bumpMap;
-	this.bumpScale = source.bumpScale;
+		this.bumpMap = source.bumpMap;
+		this.bumpScale = source.bumpScale;
 
-	this.normalMap = source.normalMap;
-	this.normalMapType = source.normalMapType;
-	this.normalScale.copy( source.normalScale );
+		this.normalMap = source.normalMap;
+		this.normalMapType = source.normalMapType;
+		this.normalScale.copy( source.normalScale );
 
-	this.displacementMap = source.displacementMap;
-	this.displacementScale = source.displacementScale;
-	this.displacementBias = source.displacementBias;
+		this.displacementMap = source.displacementMap;
+		this.displacementScale = source.displacementScale;
+		this.displacementBias = source.displacementBias;
 
-	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+		this.wireframe = source.wireframe;
+		this.wireframeLinewidth = source.wireframeLinewidth;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
-	this.morphNormals = source.morphNormals;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
+		this.morphNormals = source.morphNormals;
 
-	this.flatShading = source.flatShading;
+		this.flatShading = source.flatShading;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshNormalMaterial };

+ 78 - 78
src/materials/MeshPhongMaterial.js

@@ -53,122 +53,122 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function MeshPhongMaterial( parameters ) {
+class MeshPhongMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'MeshPhongMaterial';
+		super();
 
-	this.color = new Color( 0xffffff ); // diffuse
-	this.specular = new Color( 0x111111 );
-	this.shininess = 30;
+		Object.defineProperty( this, 'isMeshPhongMaterial', { value: true } );
 
-	this.map = null;
+		this.type = 'MeshPhongMaterial';
 
-	this.lightMap = null;
-	this.lightMapIntensity = 1.0;
+		this.color = new Color( 0xffffff ); // diffuse
+		this.specular = new Color( 0x111111 );
+		this.shininess = 30;
 
-	this.aoMap = null;
-	this.aoMapIntensity = 1.0;
+		this.map = null;
 
-	this.emissive = new Color( 0x000000 );
-	this.emissiveIntensity = 1.0;
-	this.emissiveMap = null;
+		this.lightMap = null;
+		this.lightMapIntensity = 1.0;
 
-	this.bumpMap = null;
-	this.bumpScale = 1;
+		this.aoMap = null;
+		this.aoMapIntensity = 1.0;
 
-	this.normalMap = null;
-	this.normalMapType = TangentSpaceNormalMap;
-	this.normalScale = new Vector2( 1, 1 );
+		this.emissive = new Color( 0x000000 );
+		this.emissiveIntensity = 1.0;
+		this.emissiveMap = null;
 
-	this.displacementMap = null;
-	this.displacementScale = 1;
-	this.displacementBias = 0;
+		this.bumpMap = null;
+		this.bumpScale = 1;
 
-	this.specularMap = null;
+		this.normalMap = null;
+		this.normalMapType = TangentSpaceNormalMap;
+		this.normalScale = new Vector2( 1, 1 );
 
-	this.alphaMap = null;
+		this.displacementMap = null;
+		this.displacementScale = 1;
+		this.displacementBias = 0;
 
-	this.envMap = null;
-	this.combine = MultiplyOperation;
-	this.reflectivity = 1;
-	this.refractionRatio = 0.98;
+		this.specularMap = null;
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
-	this.wireframeLinecap = 'round';
-	this.wireframeLinejoin = 'round';
+		this.alphaMap = null;
 
-	this.skinning = false;
-	this.morphTargets = false;
-	this.morphNormals = false;
+		this.envMap = null;
+		this.combine = MultiplyOperation;
+		this.reflectivity = 1;
+		this.refractionRatio = 0.98;
 
-	this.flatShading = false;
+		this.wireframe = false;
+		this.wireframeLinewidth = 1;
+		this.wireframeLinecap = 'round';
+		this.wireframeLinejoin = 'round';
 
-	this.setValues( parameters );
+		this.skinning = false;
+		this.morphTargets = false;
+		this.morphNormals = false;
 
-}
+		this.flatShading = false;
 
-MeshPhongMaterial.prototype = Object.create( Material.prototype );
-MeshPhongMaterial.prototype.constructor = MeshPhongMaterial;
+		this.setValues( parameters );
 
-MeshPhongMaterial.prototype.isMeshPhongMaterial = true;
+	}
 
-MeshPhongMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		Material.prototype.copy.call( this, source );
 
-	this.color.copy( source.color );
-	this.specular.copy( source.specular );
-	this.shininess = source.shininess;
+		this.color.copy( source.color );
+		this.specular.copy( source.specular );
+		this.shininess = source.shininess;
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.lightMap = source.lightMap;
-	this.lightMapIntensity = source.lightMapIntensity;
+		this.lightMap = source.lightMap;
+		this.lightMapIntensity = source.lightMapIntensity;
 
-	this.aoMap = source.aoMap;
-	this.aoMapIntensity = source.aoMapIntensity;
+		this.aoMap = source.aoMap;
+		this.aoMapIntensity = source.aoMapIntensity;
 
-	this.emissive.copy( source.emissive );
-	this.emissiveMap = source.emissiveMap;
-	this.emissiveIntensity = source.emissiveIntensity;
+		this.emissive.copy( source.emissive );
+		this.emissiveMap = source.emissiveMap;
+		this.emissiveIntensity = source.emissiveIntensity;
 
-	this.bumpMap = source.bumpMap;
-	this.bumpScale = source.bumpScale;
+		this.bumpMap = source.bumpMap;
+		this.bumpScale = source.bumpScale;
 
-	this.normalMap = source.normalMap;
-	this.normalMapType = source.normalMapType;
-	this.normalScale.copy( source.normalScale );
+		this.normalMap = source.normalMap;
+		this.normalMapType = source.normalMapType;
+		this.normalScale.copy( source.normalScale );
 
-	this.displacementMap = source.displacementMap;
-	this.displacementScale = source.displacementScale;
-	this.displacementBias = source.displacementBias;
+		this.displacementMap = source.displacementMap;
+		this.displacementScale = source.displacementScale;
+		this.displacementBias = source.displacementBias;
 
-	this.specularMap = source.specularMap;
+		this.specularMap = source.specularMap;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.envMap = source.envMap;
-	this.combine = source.combine;
-	this.reflectivity = source.reflectivity;
-	this.refractionRatio = source.refractionRatio;
+		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;
+		this.wireframe = source.wireframe;
+		this.wireframeLinewidth = source.wireframeLinewidth;
+		this.wireframeLinecap = source.wireframeLinecap;
+		this.wireframeLinejoin = source.wireframeLinejoin;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
-	this.morphNormals = source.morphNormals;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
+		this.morphNormals = source.morphNormals;
 
-	this.flatShading = source.flatShading;
+		this.flatShading = source.flatShading;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshPhongMaterial };

+ 54 - 52
src/materials/MeshPhysicalMaterial.js

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

+ 82 - 82
src/materials/MeshStandardMaterial.js

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

+ 65 - 65
src/materials/MeshToonMaterial.js

@@ -42,104 +42,104 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function MeshToonMaterial( parameters ) {
+class MeshToonMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.defines = { 'TOON': '' };
+		super();
 
-	this.type = 'MeshToonMaterial';
+		Object.defineProperty( this, 'isMeshToonMaterial', { value: true } );
 
-	this.color = new Color( 0xffffff );
+		this.defines = { 'TOON': '' };
 
-	this.map = null;
-	this.gradientMap = null;
+		this.type = 'MeshToonMaterial';
 
-	this.lightMap = null;
-	this.lightMapIntensity = 1.0;
+		this.color = new Color( 0xffffff );
 
-	this.aoMap = null;
-	this.aoMapIntensity = 1.0;
+		this.map = null;
+		this.gradientMap = null;
 
-	this.emissive = new Color( 0x000000 );
-	this.emissiveIntensity = 1.0;
-	this.emissiveMap = null;
+		this.lightMap = null;
+		this.lightMapIntensity = 1.0;
 
-	this.bumpMap = null;
-	this.bumpScale = 1;
+		this.aoMap = null;
+		this.aoMapIntensity = 1.0;
 
-	this.normalMap = null;
-	this.normalMapType = TangentSpaceNormalMap;
-	this.normalScale = new Vector2( 1, 1 );
+		this.emissive = new Color( 0x000000 );
+		this.emissiveIntensity = 1.0;
+		this.emissiveMap = null;
 
-	this.displacementMap = null;
-	this.displacementScale = 1;
-	this.displacementBias = 0;
+		this.bumpMap = null;
+		this.bumpScale = 1;
 
-	this.alphaMap = null;
+		this.normalMap = null;
+		this.normalMapType = TangentSpaceNormalMap;
+		this.normalScale = new Vector2( 1, 1 );
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
-	this.wireframeLinecap = 'round';
-	this.wireframeLinejoin = 'round';
+		this.displacementMap = null;
+		this.displacementScale = 1;
+		this.displacementBias = 0;
 
-	this.skinning = false;
-	this.morphTargets = false;
-	this.morphNormals = false;
+		this.alphaMap = null;
 
-	this.setValues( parameters );
+		this.wireframe = false;
+		this.wireframeLinewidth = 1;
+		this.wireframeLinecap = 'round';
+		this.wireframeLinejoin = 'round';
 
-}
+		this.skinning = false;
+		this.morphTargets = false;
+		this.morphNormals = false;
 
-MeshToonMaterial.prototype = Object.create( Material.prototype );
-MeshToonMaterial.prototype.constructor = MeshToonMaterial;
+		this.setValues( parameters );
 
-MeshToonMaterial.prototype.isMeshToonMaterial = true;
+	}
 
-MeshToonMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		super.clone( source );
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	this.map = source.map;
-	this.gradientMap = source.gradientMap;
+		this.map = source.map;
+		this.gradientMap = source.gradientMap;
 
-	this.lightMap = source.lightMap;
-	this.lightMapIntensity = source.lightMapIntensity;
+		this.lightMap = source.lightMap;
+		this.lightMapIntensity = source.lightMapIntensity;
 
-	this.aoMap = source.aoMap;
-	this.aoMapIntensity = source.aoMapIntensity;
+		this.aoMap = source.aoMap;
+		this.aoMapIntensity = source.aoMapIntensity;
 
-	this.emissive.copy( source.emissive );
-	this.emissiveMap = source.emissiveMap;
-	this.emissiveIntensity = source.emissiveIntensity;
+		this.emissive.copy( source.emissive );
+		this.emissiveMap = source.emissiveMap;
+		this.emissiveIntensity = source.emissiveIntensity;
 
-	this.bumpMap = source.bumpMap;
-	this.bumpScale = source.bumpScale;
+		this.bumpMap = source.bumpMap;
+		this.bumpScale = source.bumpScale;
 
-	this.normalMap = source.normalMap;
-	this.normalMapType = source.normalMapType;
-	this.normalScale.copy( source.normalScale );
+		this.normalMap = source.normalMap;
+		this.normalMapType = source.normalMapType;
+		this.normalScale.copy( source.normalScale );
 
-	this.displacementMap = source.displacementMap;
-	this.displacementScale = source.displacementScale;
-	this.displacementBias = source.displacementBias;
+		this.displacementMap = source.displacementMap;
+		this.displacementScale = source.displacementScale;
+		this.displacementBias = source.displacementBias;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
-	this.wireframeLinecap = source.wireframeLinecap;
-	this.wireframeLinejoin = source.wireframeLinejoin;
+		this.wireframe = source.wireframe;
+		this.wireframeLinewidth = source.wireframeLinewidth;
+		this.wireframeLinecap = source.wireframeLinecap;
+		this.wireframeLinejoin = source.wireframeLinejoin;
 
-	this.skinning = source.skinning;
-	this.morphTargets = source.morphTargets;
-	this.morphNormals = source.morphNormals;
+		this.skinning = source.skinning;
+		this.morphTargets = source.morphTargets;
+		this.morphNormals = source.morphNormals;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { MeshToonMaterial };

+ 24 - 24
src/materials/PointsMaterial.js

@@ -15,50 +15,50 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function PointsMaterial( parameters ) {
+class PointsMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'PointsMaterial';
+		super();
 
-	this.color = new Color( 0xffffff );
+		Object.defineProperty( this, 'isPointsMaterial', { value: true } );
 
-	this.map = null;
+		this.type = 'PointsMaterial';
 
-	this.alphaMap = null;
+		this.color = new Color( 0xffffff );
 
-	this.size = 1;
-	this.sizeAttenuation = true;
+		this.map = null;
 
-	this.morphTargets = false;
+		this.alphaMap = null;
 
-	this.setValues( parameters );
+		this.size = 1;
+		this.sizeAttenuation = true;
 
-}
+		this.morphTargets = false;
 
-PointsMaterial.prototype = Object.create( Material.prototype );
-PointsMaterial.prototype.constructor = PointsMaterial;
+		this.setValues( parameters );
 
-PointsMaterial.prototype.isPointsMaterial = true;
+	}
 
-PointsMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		super.clone( source );
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.size = source.size;
-	this.sizeAttenuation = source.sizeAttenuation;
+		this.size = source.size;
+		this.sizeAttenuation = source.sizeAttenuation;
 
-	this.morphTargets = source.morphTargets;
+		this.morphTargets = source.morphTargets;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { PointsMaterial };

+ 7 - 7
src/materials/RawShaderMaterial.js

@@ -1,17 +1,17 @@
 import { ShaderMaterial } from './ShaderMaterial.js';
 
-function RawShaderMaterial( parameters ) {
+class RawShaderMaterial extends ShaderMaterial {
 
-	ShaderMaterial.call( this, parameters );
+	constructor( parameters ) {
 
-	this.type = 'RawShaderMaterial';
+		super( parameters );
 
-}
+		Object.defineProperty( this, 'isRawShaderMaterial', { value: true } );
 
-RawShaderMaterial.prototype = Object.create( ShaderMaterial.prototype );
-RawShaderMaterial.prototype.constructor = RawShaderMaterial;
+		this.type = 'RawShaderMaterial';
 
-RawShaderMaterial.prototype.isRawShaderMaterial = true;
+	}
 
+}
 
 export { RawShaderMaterial };

+ 122 - 118
src/materials/ShaderMaterial.js

@@ -23,191 +23,195 @@ import default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.
  * }
  */
 
-function ShaderMaterial( parameters ) {
+class ShaderMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'ShaderMaterial';
+		super();
 
-	this.defines = {};
-	this.uniforms = {};
+		Object.defineProperty( this, 'isShaderMaterial', { value: true } );
 
-	this.vertexShader = default_vertex;
-	this.fragmentShader = default_fragment;
+		this.type = 'ShaderMaterial';
 
-	this.linewidth = 1;
+		this.defines = {};
+		this.uniforms = {};
 
-	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+		this.vertexShader = default_vertex;
+		this.fragmentShader = default_fragment;
 
-	this.fog = false; // set to use scene fog
-	this.lights = false; // set to use scene lights
-	this.clipping = false; // set to use user-defined clipping planes
+		this.linewidth = 1;
 
-	this.skinning = false; // set to use skinning attribute streams
-	this.morphTargets = false; // set to use morph targets
-	this.morphNormals = false; // set to use morph normals
+		this.wireframe = false;
+		this.wireframeLinewidth = 1;
 
-	this.extensions = {
-		derivatives: false, // set to use derivatives
-		fragDepth: false, // set to use fragment depth values
-		drawBuffers: false, // set to use draw buffers
-		shaderTextureLOD: false // set to use shader texture LOD
-	};
+		this.fog = false; // set to use scene fog
+		this.lights = false; // set to use scene lights
+		this.clipping = false; // set to use user-defined clipping planes
 
-	// When rendered geometry doesn't include these attributes but the material does,
-	// use these default values in WebGL. This avoids errors when buffer data is missing.
-	this.defaultAttributeValues = {
-		'color': [ 1, 1, 1 ],
-		'uv': [ 0, 0 ],
-		'uv2': [ 0, 0 ]
-	};
+		this.skinning = false; // set to use skinning attribute streams
+		this.morphTargets = false; // set to use morph targets
+		this.morphNormals = false; // set to use morph normals
 
-	this.index0AttributeName = undefined;
-	this.uniformsNeedUpdate = false;
+		this.extensions = {
+			derivatives: false, // set to use derivatives
+			fragDepth: false, // set to use fragment depth values
+			drawBuffers: false, // set to use draw buffers
+			shaderTextureLOD: false // set to use shader texture LOD
+		};
 
-	this.glslVersion = null;
+		// When rendered geometry doesn't include these attributes but the material does,
+		// use these default values in WebGL. This avoids errors when buffer data is missing.
+		this.defaultAttributeValues = {
+			'color': [ 1, 1, 1 ],
+			'uv': [ 0, 0 ],
+			'uv2': [ 0, 0 ]
+		};
 
-	if ( parameters !== undefined ) {
+		this.index0AttributeName = undefined;
+		this.uniformsNeedUpdate = false;
 
-		if ( parameters.attributes !== undefined ) {
+		this.glslVersion = null;
 
-			console.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );
+		if ( parameters !== undefined ) {
 
-		}
+			if ( parameters !== undefined ) {
 
-		this.setValues( parameters );
+				if ( parameters.attributes !== undefined ) {
 
-	}
+					console.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );
 
-}
+				}
 
-ShaderMaterial.prototype = Object.create( Material.prototype );
-ShaderMaterial.prototype.constructor = ShaderMaterial;
+				this.setValues( parameters );
 
-ShaderMaterial.prototype.isShaderMaterial = true;
+			}
 
-ShaderMaterial.prototype.copy = function ( source ) {
+		}
 
-	Material.prototype.copy.call( this, source );
+	}
 
-	this.fragmentShader = source.fragmentShader;
-	this.vertexShader = source.vertexShader;
+	copy( source ) {
 
-	this.uniforms = cloneUniforms( source.uniforms );
+		Material.prototype.copy.call( this, source );
 
-	this.defines = Object.assign( {}, source.defines );
+		this.fragmentShader = source.fragmentShader;
+		this.vertexShader = source.vertexShader;
 
-	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+		this.uniforms = cloneUniforms( source.uniforms );
 
-	this.lights = source.lights;
-	this.clipping = source.clipping;
+		this.defines = Object.assign( {}, source.defines );
 
-	this.skinning = source.skinning;
+		this.wireframe = source.wireframe;
+		this.wireframeLinewidth = source.wireframeLinewidth;
 
-	this.morphTargets = source.morphTargets;
-	this.morphNormals = source.morphNormals;
+		this.lights = source.lights;
+		this.clipping = source.clipping;
 
-	this.extensions = Object.assign( {}, source.extensions );
+		this.skinning = source.skinning;
 
-	this.glslVersion = source.glslVersion;
+		this.morphTargets = source.morphTargets;
+		this.morphNormals = source.morphNormals;
 
-	return this;
+		this.extensions = Object.assign( {}, source.extensions );
 
-};
+		this.glslVersion = source.glslVersion;
 
-ShaderMaterial.prototype.toJSON = function ( meta ) {
+		return this;
 
-	const data = Material.prototype.toJSON.call( this, meta );
+	}
 
-	data.glslVersion = this.glslVersion;
-	data.uniforms = {};
+	toJSON( meta ) {
 
-	for ( const name in this.uniforms ) {
+		const data = super.toJSON( meta );
 
-		const uniform = this.uniforms[ name ];
-		const value = uniform.value;
+		data.glslVersion = this.glslVersion;
+		data.uniforms = {};
 
-		if ( value && value.isTexture ) {
+		for ( const name in this.uniforms ) {
 
-			data.uniforms[ name ] = {
-				type: 't',
-				value: value.toJSON( meta ).uuid
-			};
+			const uniform = this.uniforms[ name ];
+			const value = uniform.value;
 
-		} else if ( value && value.isColor ) {
+			if ( value && value.isTexture ) {
 
-			data.uniforms[ name ] = {
-				type: 'c',
-				value: value.getHex()
-			};
+				data.uniforms[ name ] = {
+					type: 't',
+					value: value.toJSON( meta ).uuid
+				};
 
-		} else if ( value && value.isVector2 ) {
+			} else if ( value && value.isColor ) {
 
-			data.uniforms[ name ] = {
-				type: 'v2',
-				value: value.toArray()
-			};
+				data.uniforms[ name ] = {
+					type: 'c',
+					value: value.getHex()
+				};
 
-		} else if ( value && value.isVector3 ) {
+			} else if ( value && value.isVector2 ) {
 
-			data.uniforms[ name ] = {
-				type: 'v3',
-				value: value.toArray()
-			};
+				data.uniforms[ name ] = {
+					type: 'v2',
+					value: value.toArray()
+				};
 
-		} else if ( value && value.isVector4 ) {
+			} else if ( value && value.isVector3 ) {
 
-			data.uniforms[ name ] = {
-				type: 'v4',
-				value: value.toArray()
-			};
+				data.uniforms[ name ] = {
+					type: 'v3',
+					value: value.toArray()
+				};
 
-		} else if ( value && value.isMatrix3 ) {
+			} else if ( value && value.isVector4 ) {
 
-			data.uniforms[ name ] = {
-				type: 'm3',
-				value: value.toArray()
-			};
+				data.uniforms[ name ] = {
+					type: 'v4',
+					value: value.toArray()
+				};
 
-		} else if ( value && value.isMatrix4 ) {
+			} else if ( value && value.isMatrix3 ) {
 
-			data.uniforms[ name ] = {
-				type: 'm4',
-				value: value.toArray()
-			};
+				data.uniforms[ name ] = {
+					type: 'm3',
+					value: value.toArray()
+				};
 
-		} else {
+			} else if ( value && value.isMatrix4 ) {
 
-			data.uniforms[ name ] = {
-				value: value
-			};
+				data.uniforms[ name ] = {
+					type: 'm4',
+					value: value.toArray()
+				};
 
-			// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far
+			} else {
 
-		}
+				data.uniforms[ name ] = {
+					value: value
+				};
 
-	}
+				// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far
 
-	if ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;
+			}
 
-	data.vertexShader = this.vertexShader;
-	data.fragmentShader = this.fragmentShader;
+		}
 
-	const extensions = {};
+		if ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;
 
-	for ( const key in this.extensions ) {
+		data.vertexShader = this.vertexShader;
+		data.fragmentShader = this.fragmentShader;
 
-		if ( this.extensions[ key ] === true ) extensions[ key ] = true;
+		const extensions = {};
 
-	}
+		for ( const key in this.extensions ) {
 
-	if ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;
+			if ( this.extensions[ key ] === true ) extensions[ key ] = true;
+
+		}
 
-	return data;
+		if ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;
 
-};
+		return data;
 
+	}
+
+}
 
 export { ShaderMaterial };

+ 15 - 15
src/materials/ShadowMaterial.js

@@ -7,33 +7,33 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function ShadowMaterial( parameters ) {
+class ShadowMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'ShadowMaterial';
+		super();
 
-	this.color = new Color( 0x000000 );
-	this.transparent = true;
+		Object.defineProperty( this, 'isShadowMaterial', { value: true } );
 
-	this.setValues( parameters );
+		this.type = 'ShadowMaterial';
 
-}
+		this.color = new Color( 0x000000 );
+		this.transparent = true;
 
-ShadowMaterial.prototype = Object.create( Material.prototype );
-ShadowMaterial.prototype.constructor = ShadowMaterial;
+		this.setValues( parameters );
 
-ShadowMaterial.prototype.isShadowMaterial = true;
+	}
 
-ShadowMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		super.copy( source );
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { ShadowMaterial };

+ 24 - 23
src/materials/SpriteMaterial.js

@@ -11,49 +11,50 @@ import { Color } from '../math/Color.js';
  * }
  */
 
-function SpriteMaterial( parameters ) {
+class SpriteMaterial extends Material {
 
-	Material.call( this );
+	constructor( parameters ) {
 
-	this.type = 'SpriteMaterial';
+		super();
 
-	this.color = new Color( 0xffffff );
+		Object.defineProperty( this, 'isSpriteMaterial', { value: true } );
 
-	this.map = null;
+		this.type = 'SpriteMaterial';
 
-	this.alphaMap = null;
+		this.color = new Color( 0xffffff );
 
-	this.rotation = 0;
+		this.map = null;
 
-	this.sizeAttenuation = true;
+		this.alphaMap = null;
 
-	this.transparent = true;
+		this.rotation = 0;
 
-	this.setValues( parameters );
+		this.sizeAttenuation = true;
 
-}
+		this.transparent = true;
+
+		this.setValues( parameters );
 
-SpriteMaterial.prototype = Object.create( Material.prototype );
-SpriteMaterial.prototype.constructor = SpriteMaterial;
-SpriteMaterial.prototype.isSpriteMaterial = true;
+	}
 
-SpriteMaterial.prototype.copy = function ( source ) {
+	copy( source ) {
 
-	Material.prototype.copy.call( this, source );
+		Material.prototype.copy.call( this, source );
 
-	this.color.copy( source.color );
+		this.color.copy( source.color );
 
-	this.map = source.map;
+		this.map = source.map;
 
-	this.alphaMap = source.alphaMap;
+		this.alphaMap = source.alphaMap;
 
-	this.rotation = source.rotation;
+		this.rotation = source.rotation;
 
-	this.sizeAttenuation = source.sizeAttenuation;
+		this.sizeAttenuation = source.sizeAttenuation;
 
-	return this;
+		return this;
 
-};
+	}
 
+}
 
 export { SpriteMaterial };