Some refactoring
This commit is contained in:
parent
a51c06ae7b
commit
99f47e2961
1 changed files with 72 additions and 113 deletions
28
frontend/src/scripts/graphics/drawables/drawable-tunnel.ts
Normal file
28
frontend/src/scripts/graphics/drawables/drawable-tunnel.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { mat2d, vec2 } from 'gl-matrix';
|
||||
import TunnelShape from '../../shapes/types/tunnel-shape';
|
||||
import { settings } from '../settings';
|
||||
import { IDrawable } from './i-drawable';
|
||||
import { IDrawableDescriptor } from './i-drawable-descriptor';
|
||||
|
||||
export class DrawableTunnel extends TunnelShape implements IDrawable {
|
||||
public static descriptor: IDrawableDescriptor = {
|
||||
uniformName: 'lines',
|
||||
countMacroName: 'lineCount',
|
||||
shaderCombinationSteps: settings.shaderCombinations.lineSteps,
|
||||
empty: new DrawableTunnel(vec2.fromValues(0, 0), vec2.fromValues(0, 0), 0, 0),
|
||||
};
|
||||
|
||||
public serializeToUniforms(uniforms: any, scale: number, transform: mat2d): void {
|
||||
const { uniformName } = DrawableTunnel.descriptor;
|
||||
if (!Object.prototype.hasOwnProperty.call(uniforms, uniformName)) {
|
||||
uniforms[uniformName] = [];
|
||||
}
|
||||
|
||||
uniforms[uniformName].push({
|
||||
from: vec2.transformMat2d(vec2.create(), this.from, transform),
|
||||
toFromDelta: vec2.scale(vec2.create(), this.toFromDelta, scale),
|
||||
fromRadius: this.fromRadius * scale,
|
||||
toRadius: this.toRadius * scale,
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue