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';
|
import { DrawableDescriptor } from './drawable-descriptor';
|
||||||
|
|
||||||
export abstract class Drawable {
|
export abstract class Drawable {
|
||||||
static get descriptor(): DrawableDescriptor {
|
// This should be overriden by inherited classes
|
||||||
throw new Error('This getter should be overriden');
|
public static readonly descriptor: DrawableDescriptor;
|
||||||
}
|
|
||||||
|
|
||||||
public abstract distance(target: vec2): number;
|
public abstract distance(target: vec2): number;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,12 @@ import { Drawable } from '../drawable';
|
||||||
import { DrawableDescriptor } from '../drawable-descriptor';
|
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||||
|
|
||||||
export class CircleLight extends Drawable {
|
export class CircleLight extends Drawable {
|
||||||
public static get descriptor(): DrawableDescriptor {
|
public static readonly descriptor: DrawableDescriptor = {
|
||||||
return {
|
|
||||||
uniformName: 'circleLights',
|
uniformName: 'circleLights',
|
||||||
uniformCountMacroName: 'CIRCLE_LIGHT_COUNT',
|
uniformCountMacroName: 'CIRCLE_LIGHT_COUNT',
|
||||||
shaderCombinationSteps: [0, 1, 2, 4],
|
shaderCombinationSteps: [0, 1, 2, 4],
|
||||||
empty: new CircleLight(vec2.fromValues(0, 0), vec3.fromValues(0, 0, 0), 0),
|
empty: new CircleLight(vec2.fromValues(0, 0), vec3.fromValues(0, 0, 0), 0),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
constructor(public center: vec2, public color: vec3, public intensity: number) {
|
constructor(public center: vec2, public color: vec3, public intensity: number) {
|
||||||
super();
|
super();
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ import { Drawable } from '../drawable';
|
||||||
import { DrawableDescriptor } from '../drawable-descriptor';
|
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||||
|
|
||||||
export class Flashlight extends Drawable {
|
export class Flashlight extends Drawable {
|
||||||
public static get descriptor(): DrawableDescriptor {
|
public static readonly descriptor: DrawableDescriptor = {
|
||||||
return {
|
|
||||||
uniformName: 'flashlights',
|
uniformName: 'flashlights',
|
||||||
uniformCountMacroName: 'FLASHLIGHT_COUNT',
|
uniformCountMacroName: 'FLASHLIGHT_COUNT',
|
||||||
shaderCombinationSteps: [0, 1, 2, 4],
|
shaderCombinationSteps: [0, 1, 2, 4],
|
||||||
|
|
@ -15,7 +14,6 @@ export class Flashlight extends Drawable {
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
public center: vec2,
|
public center: vec2,
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ import { Drawable } from '../drawable';
|
||||||
import { DrawableDescriptor } from '../drawable-descriptor';
|
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||||
|
|
||||||
export class Circle extends Drawable {
|
export class Circle extends Drawable {
|
||||||
public static get descriptor(): DrawableDescriptor {
|
public static descriptor: DrawableDescriptor = {
|
||||||
return {
|
|
||||||
sdf: {
|
sdf: {
|
||||||
shader: `
|
shader: `
|
||||||
uniform struct {
|
uniform struct {
|
||||||
|
|
@ -32,7 +31,6 @@ export class Circle extends Drawable {
|
||||||
shaderCombinationSteps: [0, 1, 2, 3, 16, 32],
|
shaderCombinationSteps: [0, 1, 2, 3, 16, 32],
|
||||||
empty: new Circle(vec2.fromValues(0, 0), 0),
|
empty: new Circle(vec2.fromValues(0, 0), 0),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
constructor(public center: vec2, public radius: number) {
|
constructor(public center: vec2, public radius: number) {
|
||||||
super();
|
super();
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import { Drawable } from '../drawable';
|
||||||
import { DrawableDescriptor } from '../drawable-descriptor';
|
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||||
|
|
||||||
export class InvertedTunnel extends Drawable {
|
export class InvertedTunnel extends Drawable {
|
||||||
public static get descriptor(): DrawableDescriptor {
|
public static descriptor: DrawableDescriptor = {
|
||||||
return {
|
|
||||||
sdf: {
|
sdf: {
|
||||||
shader: `
|
shader: `
|
||||||
uniform struct InvertedTunnel {
|
uniform struct InvertedTunnel {
|
||||||
|
|
@ -51,7 +50,6 @@ export class InvertedTunnel extends Drawable {
|
||||||
shaderCombinationSteps: [0, 1, 4, 16, 32],
|
shaderCombinationSteps: [0, 1, 4, 16, 32],
|
||||||
empty: new InvertedTunnel(vec2.fromValues(0, 0), vec2.fromValues(0, 0), 0, 0),
|
empty: new InvertedTunnel(vec2.fromValues(0, 0), vec2.fromValues(0, 0), 0, 0),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public readonly from: vec2,
|
public readonly from: vec2,
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import { Drawable } from '../drawable';
|
||||||
import { DrawableDescriptor } from '../drawable-descriptor';
|
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||||
|
|
||||||
export class Tunnel extends Drawable {
|
export class Tunnel extends Drawable {
|
||||||
public static get descriptor(): DrawableDescriptor {
|
public static descriptor: DrawableDescriptor = {
|
||||||
return {
|
|
||||||
sdf: {
|
sdf: {
|
||||||
shader: `
|
shader: `
|
||||||
uniform struct Tunnel {
|
uniform struct Tunnel {
|
||||||
|
|
@ -56,7 +55,6 @@ export class Tunnel extends Drawable {
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public readonly from: vec2,
|
public readonly from: vec2,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue