forked from GreggJuanEduardoPH/vue-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vgl-point-light.js
48 lines (46 loc) · 1.36 KB
/
vgl-point-light.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
import { PointLight } from 'three';
import VglLight from './vgl-light';
import { float } from '../types';
/**
* A light that gets emitted from a single point in all directions, corresponding [THREE.PointLight](https://threejs.org/docs/index.html#api/lights/PointLight). A common use case for this is to replicate the light emitted from a bare lightbulb. This light can cast shadows.
*
* Properties of [VglLight](vgl-light) are also available as mixin.
*/
export default {
mixins: [VglLight],
props: {
/**
* The distance from the light where the intensity is 0.
* When set to 0, then the light never stops.
*/
distance: { type: float, default: 0 },
/**
* The amount the light dims along the distance of the light.
* For physically correct lighting, set this to 2.
*/
decay: { type: float, default: 1 },
},
computed: {
/** The THREE.PointLight instance. */
inst: () => new PointLight(),
},
watch: {
inst: {
handler(inst) {
Object.assign(inst, {
distance: parseFloat(this.distance),
decay: parseFloat(this.decay),
});
},
immediate: true,
},
distance(distance) {
this.inst.distance = parseFloat(distance);
this.vglObject3d.emit();
},
decay(decay) {
this.inst.decay = parseFloat(decay);
this.vglObject3d.emit();
},
},
};