-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLight.js
More file actions
49 lines (43 loc) · 1.46 KB
/
Light.js
File metadata and controls
49 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class SpotLight extends THREE.SpotLight {
constructor(scene, x, y, z, target, shadow = true, color = 0xffffff, intensity = 1) {
super(color);
this.intensity = intensity;
this.distance = 200;
this.angle = 0.5;
this.penumbra = 0.2;
this.decay = 1;
if (shadow) {
this.castShadow = true;
this.shadow = new THREE.LightShadow(new THREE.PerspectiveCamera(80, 1, 1, 2500));
this.shadow.bias = 0.0005;
this.shadow.mapSize.height = 1024;
this.shadow.mapSize.width = 1024;
}
this.target = target;
this.position.set(x, y, z);
scene.add(this);
}
}
class DirectionalLight extends THREE.DirectionalLight {
constructor(scene, x, y, z, target, shadow = true, color = 0xffffff, intensity = 1) {
super(color);
this.intensity = intensity;
if (shadow) {
this.castShadow = true;
this.shadow = new THREE.LightShadow(new THREE.PerspectiveCamera(80, 1, 1, 2500));
this.shadow.bias = 0.0005;
this.shadow.mapSize.height = 1024;
this.shadow.mapSize.width = 1024;
}
this.position.set(x, y, z);
if (target)
this.lookAt = target.position;
scene.add(this);
}
}
class AmbientLight extends THREE.AmbientLight {
constructor(scene, color = 0xffffff, intensity = 1) {
super(color, intensity);
scene.add(this);
}
}