Fix lights

This commit is contained in:
schmelczerandras 2020-09-20 19:23:22 +02:00
parent 13843f87a8
commit e44be0c5ee
17 changed files with 179 additions and 117 deletions

View 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,
};
}
}