-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathInput.d.ts
97 lines (97 loc) · 3.09 KB
/
Input.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import Texture2D from 'nanogl/texture-2d';
import Chunk from './Chunk';
import Swizzle from './Swizzle';
import ChunksSlots from './ChunksSlots';
import Program from 'nanogl/program';
import { Hash } from './Hash';
import TexCoord from './TexCoord';
export declare enum ShaderType {
FRAGMENT = 1,
VERTEX = 2,
ALL = 3
}
declare type InputSize = 1 | 2 | 3 | 4;
declare enum ParamType {
SAMPLER = 0,
UNIFORM = 1,
ATTRIBUTE = 2,
CONSTANT = 3
}
export interface IInputParam {
readonly ptype: ParamType;
name: string;
size: InputSize;
token: string;
_input: Input | null;
}
declare type InputParam = Sampler | Uniform | Attribute | Constant;
export declare class Sampler extends Chunk implements IInputParam {
readonly ptype: ParamType.SAMPLER;
name: string;
size: InputSize;
token: string;
_input: Input | null;
_tex: Texture2D | null;
texCoords: TexCoord | string;
_varying: string;
constructor(name: string, texCoords: TexCoord | string);
set(t: Texture2D): void;
_genCode(slots: ChunksSlots): void;
setup(prg: Program): void;
}
export declare class Uniform extends Chunk implements IInputParam {
readonly ptype: ParamType.UNIFORM;
name: string;
size: InputSize;
token: string;
_input: Input | null;
_value: Float32Array;
constructor(name: string, size: InputSize);
set(...args: number[]): void;
_genCode(slots: ChunksSlots): void;
setup(prg: Program): void;
}
export declare class Attribute extends Chunk implements IInputParam {
readonly ptype: ParamType.ATTRIBUTE;
name: string;
size: InputSize;
token: string;
_input: Input | null;
constructor(name: string, size: InputSize);
_genCode(slots: ChunksSlots): void;
}
export declare class Constant extends Chunk implements IInputParam {
readonly ptype: ParamType.CONSTANT;
name: string;
size: InputSize;
token: string;
_input: Input | null;
value: ArrayLike<number> | number;
_hash: Hash;
constructor(value: ArrayLike<number> | number);
_genCode(slots: ChunksSlots): void;
_stringifyValue(): string;
}
export default class Input extends Chunk {
static readonly Sampler: typeof Sampler;
static readonly Uniform: typeof Uniform;
static readonly Attribute: typeof Attribute;
static readonly Constant: typeof Constant;
static readonly FRAGMENT: ShaderType;
static readonly VERTEX: ShaderType;
static readonly ALL: ShaderType;
readonly name: string;
readonly size: InputSize;
readonly shader: ShaderType;
comps: Swizzle;
param: InputParam | null;
constructor(name: string, size: InputSize, shader?: ShaderType);
attach(param: InputParam, comps?: Swizzle): void;
detach(): void;
attachSampler(name: string, texCoords: string | TexCoord, comps?: Swizzle): Sampler;
attachUniform(name: string, size?: InputSize, comps?: Swizzle): Uniform;
attachAttribute(name: string, size?: InputSize, comps?: Swizzle): Attribute;
attachConstant(value: ArrayLike<number> | number, comps?: Swizzle): Constant;
_genCode(slots: ChunksSlots): void;
}
export {};