Refactor rendering
This commit is contained in:
parent
9b47d56d8f
commit
c892ca2d01
38 changed files with 511 additions and 429 deletions
36
frontend/src/scripts/drawing/drawables/lights/point-light.ts
Normal file
36
frontend/src/scripts/drawing/drawables/lights/point-light.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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
|
||||
) {}
|
||||
distance(target: vec2): number {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
minimumDistance(target: vec2): number {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
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