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