Start refactoring
This commit is contained in:
parent
6fc53ee51e
commit
9b47d56d8f
39 changed files with 423 additions and 234 deletions
35
frontend/src/scripts/drawing/lights/circle-light.ts
Normal file
35
frontend/src/scripts/drawing/lights/circle-light.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { ILight } from './i-light';
|
||||
import { vec2, vec3 } from 'gl-matrix';
|
||||
|
||||
export class CircleLight implements ILight {
|
||||
public static uniformName = 'lights';
|
||||
|
||||
constructor(
|
||||
public center: vec2,
|
||||
public radius: number,
|
||||
public color: vec3,
|
||||
public lightness: number
|
||||
) {}
|
||||
|
||||
serializeToUniforms(uniforms: any): void {
|
||||
const listName = CircleLight.uniformName;
|
||||
|
||||
if (!uniforms.hasOwnProperty(listName)) {
|
||||
uniforms[listName] = [];
|
||||
}
|
||||
|
||||
uniforms[listName].push({
|
||||
center: this.center,
|
||||
radius: this.radius,
|
||||
value: this.value,
|
||||
});
|
||||
}
|
||||
|
||||
get value(): vec3 {
|
||||
return vec3.scale(
|
||||
vec3.create(),
|
||||
vec3.normalize(this.color, this.color),
|
||||
this.lightness
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue