speedscope/regl.d.ts

56 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-11-23 06:19:10 +03:00
declare module "regl" {
interface ReglProp {}
type ReglPrimitiveValue =
boolean |
number |
number[] |
number[][] |
ReglProp
type ReglValue<P> = ReglPrimitiveValue | {(context: any, props: P, batchId: number): ReglPrimitiveValue}
2017-11-23 12:25:25 +03:00
export type vec2 = [number, number]
export type vec3 = [number, number, number]
export type mat3 = [number, number, number, number, number, number, number, number, number]
2017-11-23 06:19:10 +03:00
interface ReglCommandParameters<P> {
/** Source code of vertex shader */
vert: string
/** Source code of fragment shader */
frag: string
attributes: {[attributeName: string]: ReglValue<P>}
uniforms: {[uniformName: string]: ReglValue<P>}
/** Number of vertices to draw */
count: number
/** */
primitive?: 'points' | 'lines' | 'line strip' | 'triangles' | 'triangle strip' | 'triangle fan'
/** Offset of primitives to draw */
offset?: number
}
2017-11-23 12:25:25 +03:00
export interface ReglCommand<P> {
2017-11-23 06:19:10 +03:00
(p: P): void
}
export interface ReglCommandConstructor {
<P>(params: ReglCommandParameters<P>): ReglCommand<P>
}
function ReglConstructor(): ReglCommandConstructor
function ReglConstructor(ctx: WebGLRenderingContext): ReglCommandConstructor
function ReglConstructor(canvas: HTMLCanvasElement): ReglCommandConstructor
namespace ReglConstructor {
function prop(name: string): ReglProp
}
export default ReglConstructor
}