|
1 | 1 | declare module "3d-core-raub" { |
| 2 | + type EventEmitter = import('node:events').EventEmitter; |
2 | 3 | type Img = typeof import('image-raub'); |
3 | 4 | type TThree = typeof import('three'); |
| 5 | + type TScene = import('three').Scene; |
| 6 | + type TRenderer = import('three').WebGLRenderer; |
| 7 | + type TCamera = import('three').Camera; |
4 | 8 | type TWebgl = typeof import('webgl-raub'); |
| 9 | + type TImage = typeof import('image-raub'); |
5 | 10 | type TGlfw = typeof import('glfw-raub'); |
6 | 11 | type TDocumentOpts = import('glfw-raub').TDocumentOpts; |
7 | 12 | type Document = import('glfw-raub').Document; |
@@ -87,7 +92,69 @@ declare module "3d-core-raub" { |
87 | 92 | webkitTemporaryStorage: TUnknownObject, |
88 | 93 | }>; |
89 | 94 |
|
90 | | - type TLoop = (cb: (i: number) => void) => void; |
| 95 | + type TScreenOpts = Readonly<{ |
| 96 | + three?: TThree, |
| 97 | + THREE?: TThree, |
| 98 | + gl?: TWebgl, |
| 99 | + doc?: Document, |
| 100 | + document?: Document, |
| 101 | + Image?: TImage, |
| 102 | + title?: string, |
| 103 | + camera?: TCamera, |
| 104 | + scene?: TScene, |
| 105 | + renderer?: TRenderer, |
| 106 | + fov?: number, |
| 107 | + near?: number, |
| 108 | + far?: number, |
| 109 | + z?: number, |
| 110 | + }>; |
| 111 | + |
| 112 | + export class Screen implements EventEmitter { |
| 113 | + constructor(opts?: TScreenOpts); |
| 114 | + |
| 115 | + readonly context: TWebgl; |
| 116 | + readonly three: TThree; |
| 117 | + readonly renderer: TRenderer; |
| 118 | + readonly scene: TScene; |
| 119 | + readonly camera: TCamera; |
| 120 | + |
| 121 | + readonly document: Document; |
| 122 | + readonly canvas: Document; |
| 123 | + |
| 124 | + readonly width: number; |
| 125 | + readonly height: number; |
| 126 | + readonly w: number; |
| 127 | + readonly h: number; |
| 128 | + readonly size: TThree['Vector2']; |
| 129 | + |
| 130 | + title: string; |
| 131 | + icon: Document['icon']; |
| 132 | + fov: number; |
| 133 | + mode: Document['mode']; |
| 134 | + |
| 135 | + draw(): void; |
| 136 | + snapshot(name?: string): void; |
| 137 | + |
| 138 | + |
| 139 | + // ------ implements EventEmitter |
| 140 | + |
| 141 | + addListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| 142 | + on(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| 143 | + once(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| 144 | + removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| 145 | + off(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| 146 | + removeAllListeners(event?: string | symbol): this; |
| 147 | + setMaxListeners(n: number): this; |
| 148 | + getMaxListeners(): number; |
| 149 | + listeners(eventName: string | symbol): Function[]; |
| 150 | + rawListeners(eventName: string | symbol): Function[]; |
| 151 | + emit(eventName: string | symbol, ...args: any[]): boolean; |
| 152 | + listenerCount(eventName: string | symbol, listener?: Function): number; |
| 153 | + prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| 154 | + prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| 155 | + eventNames(): Array<string | symbol>; |
| 156 | + } |
| 157 | + |
91 | 158 |
|
92 | 159 | type TCore3D = { |
93 | 160 | /** |
@@ -142,13 +209,15 @@ declare module "3d-core-raub" { |
142 | 209 | /** |
143 | 210 | * The default frame-loop helper, calls `requestAnimationFrame` automatically. |
144 | 211 | */ |
145 | | - loop: TLoop, |
| 212 | + loop: (cb: () => void) => void, |
146 | 213 |
|
147 | 214 | /** |
148 | 215 | * Swaps GL buffers and calls the `cb` callback on next frame. |
149 | 216 | * @alias doc.requestAnimationFrame |
150 | 217 | */ |
151 | 218 | requestAnimationFrame: (cb: (dateNow: number) => void) => number, |
| 219 | + |
| 220 | + Screen: typeof Screen, |
152 | 221 | }; |
153 | 222 |
|
154 | 223 | type TPluginDecl = string | ((core3d: TCore3D) => void) | Readonly<{ name: string, opts: TUnknownObject }>; |
|
0 commit comments