Refactor rendering

This commit is contained in:
schmelczerandras 2020-08-18 15:49:15 +02:00
parent edca93fcfe
commit 76282a4cf7
25 changed files with 239 additions and 213 deletions

View file

@ -2,6 +2,7 @@ import { IDrawable } from './i-drawable';
import { IDrawableDescriptor } from './i-drawable-descriptor';
import { settings } from '../settings';
import { Blob } from '../../shapes/types/blob';
import { vec2, mat2d } from 'gl-matrix';
export class DrawableBlob extends Blob implements IDrawable {
public static descriptor: IDrawableDescriptor = {
@ -10,17 +11,37 @@ export class DrawableBlob extends Blob implements IDrawable {
shaderCombinationSteps: settings.shaderCombinations.blobSteps,
};
public serializeToUniforms(uniforms: any): void {
public serializeToUniforms(
uniforms: any,
scale: number,
transform: mat2d
): void {
const uniformName = DrawableBlob.descriptor.uniformName;
if (!uniforms.hasOwnProperty(uniformName)) {
uniforms[uniformName] = [];
}
uniforms[uniformName].push({
headCenter: this.head.center,
torsoCenter: this.torso.center,
leftFootCenter: this.leftFoot.center,
rightFootCenter: this.rightFoot.center,
headCenter: vec2.transformMat2d(
vec2.create(),
this.head.center,
transform
),
torsoCenter: vec2.transformMat2d(
vec2.create(),
this.torso.center,
transform
),
leftFootCenter: vec2.transformMat2d(
vec2.create(),
this.leftFoot.center,
transform
),
rightFootCenter: vec2.transformMat2d(
vec2.create(),
this.rightFoot.center,
transform
),
});
}
}