Refactor rendering

This commit is contained in:
schmelczerandras 2020-08-18 15:49:15 +02:00
commit 76282a4cf7

View file

@ -1,4 +1,4 @@
import { vec2, vec3 } from 'gl-matrix';
import { vec2, vec3, mat2d } from 'gl-matrix';
import { GameObject } from '../../../objects/game-object';
import { settings } from '../../settings';
import { IDrawableDescriptor } from '../i-drawable-descriptor';
@ -12,7 +12,6 @@ export class CircleLight implements ILight {
};
constructor(
public readonly owner: GameObject,
public center: vec2,
public radius: number,
public color: vec3,
@ -23,7 +22,11 @@ export class CircleLight implements ILight {
return 0;
}
public serializeToUniforms(uniforms: any): void {
public serializeToUniforms(
uniforms: any,
scale: number,
transform: mat2d
): void {
const uniformName = CircleLight.descriptor.uniformName;
if (!uniforms.hasOwnProperty(uniformName)) {
@ -31,8 +34,8 @@ export class CircleLight implements ILight {
}
uniforms[uniformName].push({
center: this.center,
radius: this.radius,
center: vec2.transformMat2d(vec2.create(), this.center, transform),
radius: this.radius * scale,
value: this.value,
});
}