提交 9bec2f03 编写于 作者: M Mr.doob

Added intensity to Light (thus AmbientLight). See #7621.

上级 05ade8fe
......@@ -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';
......
......@@ -5,7 +5,7 @@
THREE.DirectionalLight = function ( color, intensity ) {
THREE.Light.call( this, color );
THREE.Light.call( this, color, intensity );
this.type = 'DirectionalLight';
......@@ -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 ) );
};
......@@ -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();
......
......@@ -4,7 +4,7 @@
THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {
THREE.Light.call( this, skyColor );
THREE.Light.call( this, skyColor, intensity );
this.type = 'HemisphereLight';
......@@ -14,7 +14,6 @@ THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {
this.updateMatrix();
this.groundColor = new THREE.Color( groundColor );
this.intensity = ( intensity !== undefined ) ? intensity : 1;
};
......@@ -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;
......
......@@ -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;
......@@ -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;
......@@ -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;
......
......@@ -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.
......@@ -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;
......
......@@ -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';
......@@ -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;
......@@ -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;
......
......@@ -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 ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册