This repository has been archived by the owner on Jul 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathDirectionalLightDescriptor.js
86 lines (70 loc) · 2.08 KB
/
DirectionalLightDescriptor.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import * as THREE from 'three';
import PropTypes from 'prop-types';
import LightDescriptorBase from './LightDescriptorBase';
class DirectionalLightDescriptor extends LightDescriptorBase {
static defaultShadowCameraLeft = -5;
static defaultShadowCameraRight = 5;
static defaultShadowCameraTop = 5;
static defaultShadowCameraBottom = -5;
constructor(react3Instance) {
super(react3Instance);
this.hasProp('intensity', {
type: PropTypes.number,
simple: true,
default: 1,
});
this.hasProp('shadowCameraLeft', {
type: PropTypes.number,
updateInitial: true,
update(threeObject, value, hasProp) {
if (hasProp) {
threeObject.shadow.camera.left = value;
}
},
default: DirectionalLightDescriptor.defaultShadowCameraLeft,
});
this.hasProp('shadowCameraBottom', {
type: PropTypes.number,
updateInitial: true,
update(threeObject, value, hasProp) {
if (hasProp) {
threeObject.shadow.camera.bottom = value;
}
},
default: DirectionalLightDescriptor.defaultShadowCameraBottom,
});
this.hasProp('shadowCameraRight', {
type: PropTypes.number,
updateInitial: true,
update(threeObject, value, hasProp) {
if (hasProp) {
threeObject.shadow.camera.right = value;
}
},
default: DirectionalLightDescriptor.defaultShadowCameraRight,
});
this.hasProp('shadowCameraTop', {
type: PropTypes.number,
updateInitial: true,
update(threeObject, value, hasProp) {
if (hasProp) {
threeObject.shadow.camera.top = value;
}
},
default: DirectionalLightDescriptor.defaultShadowCameraTop,
});
this.hasColor();
this.hasDirection();
}
construct(props) {
const color = props.color;
const intensity = props.intensity;
const result = new THREE.DirectionalLight(color, intensity);
result.position.set(0, 0, 0);
return result;
}
unmount(threeObject) {
super.unmount(threeObject);
}
}
module.exports = DirectionalLightDescriptor;