Fix lights
This commit is contained in:
parent
13843f87a8
commit
e44be0c5ee
17 changed files with 179 additions and 117 deletions
26
src/drawables/lights/light-drawable.ts
Normal file
26
src/drawables/lights/light-drawable.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { mat2d, vec2, vec3 } from 'gl-matrix';
|
||||
import { Drawable } from '../../main';
|
||||
|
||||
export class LightDrawable extends Drawable {
|
||||
protected lightnessRatio = 1;
|
||||
|
||||
constructor(public center: vec2, public color: vec3, public intensity: number) {
|
||||
super();
|
||||
}
|
||||
|
||||
public setLightnessRatio(ratio: number) {
|
||||
this.lightnessRatio = ratio;
|
||||
}
|
||||
|
||||
public minDistance(target: vec2): number {
|
||||
return vec2.dist(this.center, target);
|
||||
}
|
||||
|
||||
protected getObjectToSerialize(transform2d: mat2d, transform1d: number): any {
|
||||
return {
|
||||
center: vec2.transformMat2d(vec2.create(), this.center, transform2d),
|
||||
color: this.color,
|
||||
intensity: this.intensity * this.lightnessRatio,
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue