Make descriptor access faster
This commit is contained in:
parent
7a7273c2be
commit
4f726ddac2
6 changed files with 54 additions and 65 deletions
|
|
@ -2,9 +2,8 @@ import { mat2d, vec2 } from 'gl-matrix';
|
|||
import { DrawableDescriptor } from './drawable-descriptor';
|
||||
|
||||
export abstract class Drawable {
|
||||
static get descriptor(): DrawableDescriptor {
|
||||
throw new Error('This getter should be overriden');
|
||||
}
|
||||
// This should be overriden by inherited classes
|
||||
public static readonly descriptor: DrawableDescriptor;
|
||||
|
||||
public abstract distance(target: vec2): number;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@ import { Drawable } from '../drawable';
|
|||
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||
|
||||
export class CircleLight extends Drawable {
|
||||
public static get descriptor(): DrawableDescriptor {
|
||||
return {
|
||||
public static readonly descriptor: DrawableDescriptor = {
|
||||
uniformName: 'circleLights',
|
||||
uniformCountMacroName: 'CIRCLE_LIGHT_COUNT',
|
||||
shaderCombinationSteps: [0, 1, 2, 4],
|
||||
empty: new CircleLight(vec2.fromValues(0, 0), vec3.fromValues(0, 0, 0), 0),
|
||||
};
|
||||
}
|
||||
|
||||
constructor(public center: vec2, public color: vec3, public intensity: number) {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ import { Drawable } from '../drawable';
|
|||
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||
|
||||
export class Flashlight extends Drawable {
|
||||
public static get descriptor(): DrawableDescriptor {
|
||||
return {
|
||||
public static readonly descriptor: DrawableDescriptor = {
|
||||
uniformName: 'flashlights',
|
||||
uniformCountMacroName: 'FLASHLIGHT_COUNT',
|
||||
shaderCombinationSteps: [0, 1, 2, 4],
|
||||
|
|
@ -15,7 +14,6 @@ export class Flashlight extends Drawable {
|
|||
0
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
public constructor(
|
||||
public center: vec2,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ import { Drawable } from '../drawable';
|
|||
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||
|
||||
export class Circle extends Drawable {
|
||||
public static get descriptor(): DrawableDescriptor {
|
||||
return {
|
||||
public static descriptor: DrawableDescriptor = {
|
||||
sdf: {
|
||||
shader: `
|
||||
uniform struct {
|
||||
|
|
@ -32,7 +31,6 @@ export class Circle extends Drawable {
|
|||
shaderCombinationSteps: [0, 1, 2, 3, 16, 32],
|
||||
empty: new Circle(vec2.fromValues(0, 0), 0),
|
||||
};
|
||||
}
|
||||
|
||||
constructor(public center: vec2, public radius: number) {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ import { Drawable } from '../drawable';
|
|||
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||
|
||||
export class InvertedTunnel extends Drawable {
|
||||
public static get descriptor(): DrawableDescriptor {
|
||||
return {
|
||||
public static descriptor: DrawableDescriptor = {
|
||||
sdf: {
|
||||
shader: `
|
||||
uniform struct InvertedTunnel {
|
||||
|
|
@ -51,7 +50,6 @@ export class InvertedTunnel extends Drawable {
|
|||
shaderCombinationSteps: [0, 1, 4, 16, 32],
|
||||
empty: new InvertedTunnel(vec2.fromValues(0, 0), vec2.fromValues(0, 0), 0, 0),
|
||||
};
|
||||
}
|
||||
|
||||
constructor(
|
||||
public readonly from: vec2,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ import { Drawable } from '../drawable';
|
|||
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||
|
||||
export class Tunnel extends Drawable {
|
||||
public static get descriptor(): DrawableDescriptor {
|
||||
return {
|
||||
public static descriptor: DrawableDescriptor = {
|
||||
sdf: {
|
||||
shader: `
|
||||
uniform struct Tunnel {
|
||||
|
|
@ -56,7 +55,6 @@ export class Tunnel extends Drawable {
|
|||
0
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
constructor(
|
||||
public readonly from: vec2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue