Skip to content

Commit

Permalink
Added intensity to Light (thus AmbientLight). See #7621.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Nov 21, 2015
1 parent 05ade8f commit 9bec2f0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/lights/AmbientLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @author mrdoob / http://mrdoob.com/
*/

THREE.AmbientLight = function ( color ) {
THREE.AmbientLight = function ( color, intensity ) {

THREE.Light.call( this, color );
THREE.Light.call( this, color, intensity );

this.type = 'AmbientLight';

Expand Down
5 changes: 1 addition & 4 deletions src/lights/DirectionalLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

THREE.DirectionalLight = function ( color, intensity ) {

THREE.Light.call( this, color );
THREE.Light.call( this, color, intensity );

this.type = 'DirectionalLight';

Expand All @@ -14,8 +14,6 @@ THREE.DirectionalLight = function ( color, intensity ) {

this.target = new THREE.Object3D();

this.intensity = ( intensity !== undefined ) ? intensity : 1;

this.shadow = new THREE.LightShadow( new THREE.OrthographicCamera( - 500, 500, 500, - 500, 50, 5000 ) );

};
Expand All @@ -27,7 +25,6 @@ THREE.DirectionalLight.prototype.copy = function ( source ) {

THREE.Light.prototype.copy.call( this, source );

this.intensity = source.intensity;
this.target = source.target.clone();

this.shadow = source.shadow.clone();
Expand Down
4 changes: 1 addition & 3 deletions src/lights/HemisphereLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {

THREE.Light.call( this, skyColor );
THREE.Light.call( this, skyColor, intensity );

this.type = 'HemisphereLight';

Expand All @@ -14,7 +14,6 @@ THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {
this.updateMatrix();

this.groundColor = new THREE.Color( groundColor );
this.intensity = ( intensity !== undefined ) ? intensity : 1;

};

Expand All @@ -26,7 +25,6 @@ THREE.HemisphereLight.prototype.copy = function ( source ) {
THREE.Light.prototype.copy.call( this, source );

this.groundColor.copy( source.groundColor );
this.intensity = source.intensity;

return this;

Expand Down
7 changes: 5 additions & 2 deletions src/lights/Light.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
* @author alteredq / http://alteredqualia.com/
*/

THREE.Light = function ( color ) {
THREE.Light = function ( color, intensity ) {

THREE.Object3D.call( this );

this.type = 'Light';

this.color = new THREE.Color( color );
this.intensity = intensity !== undefined ? intensity : 1;

this.receiveShadow = undefined;

Expand All @@ -23,6 +24,7 @@ THREE.Light.prototype.copy = function ( source ) {
THREE.Object3D.prototype.copy.call( this, source );

this.color.copy( source.color );
this.intensity = source.intensity;

return this;

Expand All @@ -33,9 +35,10 @@ THREE.Light.prototype.toJSON = function ( meta ) {
var data = THREE.Object3D.prototype.toJSON.call( this, meta );

data.object.color = this.color.getHex();
data.object.intensity = this.intensity;

if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();

if ( this.intensity !== undefined ) data.object.intensity = this.intensity;
if ( this.distance !== undefined ) data.object.distance = this.distance;
if ( this.angle !== undefined ) data.object.angle = this.angle;
if ( this.decay !== undefined ) data.object.decay = this.decay;
Expand Down
4 changes: 1 addition & 3 deletions src/lights/PointLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

THREE.PointLight = function ( color, intensity, distance, decay ) {

THREE.Light.call( this, color );
THREE.Light.call( this, color, intensity );

this.type = 'PointLight';

this.intensity = ( intensity !== undefined ) ? intensity : 1;
this.distance = ( distance !== undefined ) ? distance : 0;
this.decay = ( decay !== undefined ) ? decay : 1; // for physically correct lights, should be 2.

Expand All @@ -24,7 +23,6 @@ THREE.PointLight.prototype.copy = function ( source ) {

THREE.Light.prototype.copy.call( this, source );

this.intensity = source.intensity;
this.distance = source.distance;
this.decay = source.decay;

Expand Down
4 changes: 1 addition & 3 deletions src/lights/SpotLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay ) {

THREE.Light.call( this, color );
THREE.Light.call( this, color, intensity );

this.type = 'SpotLight';

Expand All @@ -13,7 +13,6 @@ THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay

this.target = new THREE.Object3D();

this.intensity = ( intensity !== undefined ) ? intensity : 1;
this.distance = ( distance !== undefined ) ? distance : 0;
this.angle = ( angle !== undefined ) ? angle : Math.PI / 3;
this.exponent = ( exponent !== undefined ) ? exponent : 10;
Expand All @@ -30,7 +29,6 @@ THREE.SpotLight.prototype.copy = function ( source ) {

THREE.Light.prototype.copy.call( this, source );

this.intensity = source.intensity;
this.distance = source.distance;
this.angle = source.angle;
this.exponent = source.exponent;
Expand Down
6 changes: 3 additions & 3 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2663,9 +2663,9 @@ THREE.WebGLRenderer = function ( parameters ) {

if ( light instanceof THREE.AmbientLight ) {

r += color.r;
g += color.g;
b += color.b;
r += color.r * intensity;
g += color.g * intensity;
b += color.b * intensity;

} else if ( light instanceof THREE.DirectionalLight ) {

Expand Down

0 comments on commit 9bec2f0

Please sign in to comment.