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
/
PointLightDescriptor.js
72 lines (59 loc) · 1.54 KB
/
PointLightDescriptor.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
import * as THREE from 'three';
import PropTypes from 'prop-types';
import LightDescriptorBase from './LightDescriptorBase';
class PointLightDescriptor extends LightDescriptorBase {
static defaultShadowCameraFov = 90;
static defaultShadowCameraAspect = 1;
constructor(react3Instance) {
super(react3Instance);
this.hasColor();
[
'intensity',
'decay',
].forEach((propName) => {
this.hasProp(propName, {
type: PropTypes.number,
simple: true,
default: 1,
});
});
this.hasProp('distance', {
type: PropTypes.number,
simple: true,
default: 0,
});
this.hasProp('shadowCameraFov', {
type: PropTypes.number,
updateInitial: true,
update(threeObject, value, hasProp) {
if (hasProp) {
threeObject.shadow.camera.fov = value;
}
},
default: PointLightDescriptor.defaultShadowCameraFov,
});
this.hasProp('shadowCameraAspect', {
type: PropTypes.number,
updateInitial: true,
update(threeObject, value, hasProp) {
if (hasProp) {
threeObject.shadow.camera.aspect = value;
}
},
default: PointLightDescriptor.defaultShadowCameraAspect,
});
this.removeProp('lookAt');
this.removeProp('rotation');
this.removeProp('quaternion');
}
construct(props) {
const {
color,
intensity,
distance,
decay,
} = props;
return new THREE.PointLight(color, intensity, distance, decay);
}
}
module.exports = PointLightDescriptor;