Skip to content

Commit a051c7c

Browse files
committed
Add Screen to d.ts
1 parent 6f009e0 commit a051c7c

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

index.d.ts

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
declare module "3d-core-raub" {
2+
type EventEmitter = import('node:events').EventEmitter;
23
type Img = typeof import('image-raub');
34
type TThree = typeof import('three');
5+
type TScene = import('three').Scene;
6+
type TRenderer = import('three').WebGLRenderer;
7+
type TCamera = import('three').Camera;
48
type TWebgl = typeof import('webgl-raub');
9+
type TImage = typeof import('image-raub');
510
type TGlfw = typeof import('glfw-raub');
611
type TDocumentOpts = import('glfw-raub').TDocumentOpts;
712
type Document = import('glfw-raub').Document;
@@ -87,7 +92,69 @@ declare module "3d-core-raub" {
8792
webkitTemporaryStorage: TUnknownObject,
8893
}>;
8994

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+
91158

92159
type TCore3D = {
93160
/**
@@ -142,13 +209,15 @@ declare module "3d-core-raub" {
142209
/**
143210
* The default frame-loop helper, calls `requestAnimationFrame` automatically.
144211
*/
145-
loop: TLoop,
212+
loop: (cb: () => void) => void,
146213

147214
/**
148215
* Swaps GL buffers and calls the `cb` callback on next frame.
149216
* @alias doc.requestAnimationFrame
150217
*/
151218
requestAnimationFrame: (cb: (dateNow: number) => void) => number,
219+
220+
Screen: typeof Screen,
152221
};
153222

154223
type TPluginDecl = string | ((core3d: TCore3D) => void) | Readonly<{ name: string, opts: TUnknownObject }>;

0 commit comments

Comments
 (0)