forked from GreggJuanEduardoPH/vue-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vgl-rect-area-light.js
45 lines (43 loc) · 1.15 KB
/
vgl-rect-area-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
import { RectAreaLight } from 'three';
import VglLight from './vgl-light';
import { float } from '../types';
/**
* RectAreaLight emits light uniformly across the face a rectangular plane. See
* [THREE.RectAreaLight](https://threejs.org/docs/#api/en/lights/RectAreaLight).
*
* This light type can be used to simulate light sources such as bright windows or strip lighting.
*
* Properties of [VglLight](vgl-light) are also available as mixin.
*/
export default {
mixins: [VglLight],
props: {
/** Width of the light. */
width: { type: float, default: 10 },
/** Height of the light. */
height: { type: float, default: 10 },
},
computed: {
/** The THREE.RectAreaLight instance. */
inst: () => new RectAreaLight(),
},
watch: {
inst: {
handler(inst) {
Object.assign(inst, {
width: parseFloat(this.width),
height: parseFloat(this.height),
});
},
immediate: true,
},
width(width) {
this.inst.width = parseFloat(width);
this.vglObject3d.emit();
},
height(height) {
this.inst.height = parseFloat(height);
this.vglObject3d.emit();
},
},
};