UNPKG

1.02 kBJavaScriptView Raw
1import { Matrix4 } from '../math/Matrix4.js';
2import { Vector2 } from '../math/Vector2.js';
3
4/**
5 * @author mrdoob / http://mrdoob.com/
6 */
7
8function LightShadow( camera ) {
9
10 this.camera = camera;
11
12 this.bias = 0;
13 this.radius = 1;
14
15 this.mapSize = new Vector2( 512, 512 );
16
17 this.map = null;
18 this.matrix = new Matrix4();
19
20}
21
22Object.assign( LightShadow.prototype, {
23
24 copy: function ( source ) {
25
26 this.camera = source.camera.clone();
27
28 this.bias = source.bias;
29 this.radius = source.radius;
30
31 this.mapSize.copy( source.mapSize );
32
33 return this;
34
35 },
36
37 clone: function () {
38
39 return new this.constructor().copy( this );
40
41 },
42
43 toJSON: function () {
44
45 var object = {};
46
47 if ( this.bias !== 0 ) object.bias = this.bias;
48 if ( this.radius !== 1 ) object.radius = this.radius;
49 if ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();
50
51 object.camera = this.camera.toJSON( false ).object;
52 delete object.camera.matrix;
53
54 return object;
55
56 }
57
58} );
59
60
61export { LightShadow };