forked from pissang/claygl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Renderer.d.ts
141 lines (96 loc) · 4.74 KB
/
Renderer.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
///<reference path="Camera.d.ts" />
///<reference path="Scene.d.ts" />
///<reference path="Mesh.d.ts" />
///<reference path="Geometry.d.ts" />
///<reference path="Material.d.ts" />
///<reference path="Shader.d.ts" />
///<reference path="Node.d.ts" />
///<reference path="Texture.d.ts" />
///<reference path="FrameBuffer.d.ts" />
///<reference path="math/Vector2.d.ts" />
declare module qtek {
interface IRendererOption {
canvas?: HTMLCanvasElement;
width?: number;
height?: number;
devicePixelRatio?: number;
color?: number[];
alhpa?: boolean;
depth?: boolean;
stencil?: boolean;
antialias?: boolean;
premultipliedAlpha?: boolean;
preserveDrawingBuffer?: boolean;
}
interface IRenderInfo {
faceNumber: number;
vertexNumber: number;
drawCallNumber: number;
meshNumber: number;
}
interface IViewport {
x: number;
y: number;
width: number;
height: number;
}
export class Renderer {
constructor(option?: IRendererOption);
canvas: HTMLCanvasElement;
devicePixelRatio: number;
color: any;
clear: number;
alhpa: boolean;
depth: boolean;
stencil: boolean;
antialias: boolean;
premultipliedAlpha: boolean;
preserveDrawingBuffer: boolean;
throwShaderError: boolean;
gl: WebGLRenderingContext;
viewport: IViewport;
render(scene: Scene, camera: Camera, notUpdateScene?: boolean, preZ?: boolean) : IRenderInfo;
renderQueue(queue: Renderable[], camera: Camera, globalMaterial?: Material, preZ?: boolean): IRenderInfo;
getWidth(): number;
getHeight(): number;
getDevicePixelRatio(): number;
getViewportAspect(): number;
resize(width: number, height: number): void;
setDevicePixelRatio(devicePixelRatio: number): void;
setViewport(x: number, y: number, width: number, height: number): void;
setViewport(viewport: IViewport): void;
saveViewport(): void;
restoreViewport(): void;
saveClear(): void;
restoreClear(): void;
disposeShader(shader: Shader): void;
disposeGeometry(geometry: Geometry): void;
disposeTexture(texture: Texture): void;
disposeNode(node: Node): void;
disposeScene(scene: Scene): void;
disposeFrameBuffer(frameBuffer: FrameBuffer): void;
dispose(): void;
screenToNdc(x: number, y: number, out?: math.Vector2): math.Vector2;
// Events
on(name: 'beforerender', handler: (renderer?: Renderer, scene?: Scene, camera?: Camera) => void, context?: any): void;
on(name: 'beforerender:opaque', handler: (renderer?: Renderer, queue?: Renderable[]) => void, context?: any): void;
on(name: 'beforerender:transparent', handler: (renderer?: Renderer, queue?: Renderable[]) => void, context?: any): void;
on(name: 'afterrender:opaque', handler: (renderer?: Renderer, queue?: Renderable[], renderInfo?: IRenderInfo) => void, context?: any): void;
on(name: 'afterrender:transparent', handler: (renderer?: Renderer, queue?: Renderable[], renderInfo?: IRenderInfo) => void, context?: any): void;
on(name: 'afterrender', handler: (renderer?: Renderer, scene?: Scene, camera?: Camera, renderInfo?: IRenderInfo) => void, context?: any): void;
on(name: string, handler: Function, context?: any): void;
before(name: 'render', handler: (renderer?: Renderer, scene?: Scene, camera?: Camera) => void, context?: any): void;
before(name: 'render:opaque', handler: (renderer?: Renderer, queue?: Renderable[]) => void, context?: any): void;
before(name: 'render:transparent', handler: (renderer?: Renderer, queue?: Renderable[]) => void, context?: any): void;
after(name: 'render:opaque', handler: (renderer?: Renderer, queue?: Renderable[], renderInfo?: IRenderInfo) => void, context?: any): void;
after(name: 'render:transparent', handler: (renderer?: Renderer, queue?: Renderable[], renderInfo?: IRenderInfo) => void, context?: any): void;
after(name: 'render', handler: (renderer?: Renderer, scene?: Scene, camera?: Camera, renderInfo?: IRenderInfo) => void, context?: any): void;
before(name: string, handler: Function, context?: any): void;
after(name: string, handler: Function, context?: any): void;
static opaqueSortFunc(a: Renderable, b: Renderable): boolean;
static transparentSortFunc(a: Renderable, b: Renderable): boolean;
static COLOR_BUFFER_BIT: number;
static DEPTH_BUFFER_BIT: number;
static STENCIL_BUFFER_BIT: number;
}
}