Browse Source

DirectionalLight: Convert to ES6 class

Mr.doob 4 years ago
parent
commit
ab1ed6c0f6
1 changed files with 13 additions and 17 deletions
  1. 13 17
      src/lights/DirectionalLight.js

+ 13 - 17
src/lights/DirectionalLight.js

@@ -2,40 +2,36 @@ import { Light } from './Light.js';
 import { DirectionalLightShadow } from './DirectionalLightShadow.js';
 import { Object3D } from '../core/Object3D.js';
 
-function DirectionalLight( color, intensity ) {
+class DirectionalLight extends Light {
 
-	Light.call( this, color, intensity );
+	constructor( color, intensity ) {
 
-	this.type = 'DirectionalLight';
+		super( color, intensity );
 
-	this.position.copy( Object3D.DefaultUp );
-	this.updateMatrix();
+		Object.defineProperty( this, 'isDirectionalLight', { value: true } );
 
-	this.target = new Object3D();
+		this.type = 'DirectionalLight';
 
-	this.shadow = new DirectionalLightShadow();
+		this.position.copy( Object3D.DefaultUp );
+		this.updateMatrix();
 
-}
-
-DirectionalLight.prototype = Object.assign( Object.create( Light.prototype ), {
+		this.target = new Object3D();
 
-	constructor: DirectionalLight,
+		this.shadow = new DirectionalLightShadow();
 
-	isDirectionalLight: true,
+	}
 
-	copy: function ( source ) {
+	copy( source ) {
 
-		Light.prototype.copy.call( this, source );
+		super.copy( source );
 
 		this.target = source.target.clone();
-
 		this.shadow = source.shadow.clone();
 
 		return this;
 
 	}
 
-} );
-
+}
 
 export { DirectionalLight };