-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.d.ts
298 lines (258 loc) · 7.89 KB
/
index.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
declare module "3d-core-raub" {
type EventEmitter = import('node:events').EventEmitter;
type Img = typeof import('image-raub');
type TThree = typeof import('three');
type TScene = import('three').Scene;
type TRenderer = import('three').WebGLRenderer;
type TCamera = import('three').Camera;
type TWebgl = typeof import('webgl-raub');
type TImage = typeof import('image-raub');
type TGlfw = typeof import('glfw-raub');
type TDocumentOpts = import('glfw-raub').TDocumentOpts;
type Document = import('glfw-raub').Document;
type Window = import('glfw-raub').Window;
type TUnknownObject = Readonly<{ [id: string]: unknown }>;
class WebVRManager {
readonly enabled: boolean;
constructor();
isPresenting(): boolean;
dispose(): void;
setAnimationLoop(): void;
getCamera(): TUnknownObject;
submitFrame(): void;
}
type TLocation = Readonly<{
href: string,
ancestorOrigins: TUnknownObject,
origin: string,
protocol: string,
host: string,
hostname: string,
port: string,
pathname: string,
search: string,
hash: string,
}>;
type TNavigator = Readonly<{
appCodeName: string,
appName: string,
appVersion: string,
bluetooth: TUnknownObject,
clipboard: TUnknownObject,
connection: {
onchange: unknown,
effectiveType: string,
rtt: number,
downlink: number,
saveData: boolean,
},
cookieEnabled: boolean,
credentials: TUnknownObject,
deviceMemory: number,
doNotTrack: unknown,
geolocation: TUnknownObject,
hardwareConcurrency: number,
keyboard: TUnknownObject,
language: string,
languages: string[],
locks: TUnknownObject,
maxTouchPoints: number,
mediaCapabilities: TUnknownObject,
mediaDevices: { ondevicechange: unknown },
mimeTypes: { length: number },
onLine: boolean,
permissions: TUnknownObject,
platform: string,
plugins: { length: number },
presentation: { defaultRequest: unknown, receiver: unknown },
product: string,
productSub: string,
serviceWorker: {
ready: Promise<boolean>,
controller: unknown,
oncontrollerchange: unknown,
onmessage: unknown
},
storage: TUnknownObject,
usb: {
onconnect: unknown,
ondisconnect: unknown,
},
userAgent: string,
vendor: string,
vendorSub: string,
webkitPersistentStorage: TUnknownObject,
webkitTemporaryStorage: TUnknownObject,
}>;
type TScreenOpts = Readonly<{
three?: TThree,
THREE?: TThree,
gl?: TWebgl,
doc?: Document,
document?: Document,
Image?: TImage,
title?: string,
camera?: TCamera,
scene?: TScene,
renderer?: TRenderer,
fov?: number,
near?: number,
far?: number,
z?: number,
}>;
export class Screen implements EventEmitter {
constructor(opts?: TScreenOpts);
readonly context: TWebgl;
readonly three: TThree;
readonly renderer: TRenderer;
readonly scene: TScene;
readonly camera: TCamera;
readonly document: Document;
readonly canvas: Document;
readonly width: number;
readonly height: number;
readonly w: number;
readonly h: number;
readonly size: TThree['Vector2'];
title: string;
icon: Document['icon'];
fov: number;
mode: Document['mode'];
draw(): void;
snapshot(name?: string): void;
// ------ implements EventEmitter
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(eventName: string | symbol): Function[];
rawListeners(eventName: string | symbol): Function[];
emit(eventName: string | symbol, ...args: any[]): boolean;
listenerCount(eventName: string | symbol, listener?: Function): number;
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
eventNames(): Array<string | symbol>;
}
type TCore3D = {
/**
* Almost the same as `Image` in a browser. Also `document.createElement('img')`
* does the same thing as `new Image()`. For more info see
* [image-raub](https://github.com/node-3d/image-raub#image-for-nodejs).
*/
Image: Img,
/**
* This constructor spawns a new platform window **with a web-document like interface**.
* For more info see [glfw-raub](https://github.com/node-3d/glfw-raub#class-document).
*/
Document: TGlfw['Document'],
/**
* This constructor spawns a new OS window.
* For more info see [glfw-raub](https://github.com/node-3d/glfw-raub#class-window).
*/
Window: TGlfw['Window'],
/**
* A WebGL context instance. This is **almost** the same as real WebGL stuff.
* For more info see [webgl-raub](https://github.com/node-3d/webgl-raub#webgl-for-nodejs).
*/
gl: TWebgl,
/**
* Low level GLFW interface.
* For more info see glfw-raub](https://github.com/node-3d/glfw-raub#glfw-for-nodejs)
*/
glfw: TGlfw,
/**
* The default instance of Document - created automatically when `init()` is called.
*/
doc: Document,
/**
* @alias doc
*/
canvas: Document,
/**
* @alias doc
*/
document: Document,
/**
* @alias doc
*/
window: Document,
/**
* The default frame-loop helper, calls `requestAnimationFrame` automatically.
*/
loop: (cb: () => void) => void,
/**
* Swaps GL buffers and calls the `cb` callback on next frame.
* @alias doc.requestAnimationFrame
*/
requestAnimationFrame: (cb: (dateNow: number) => void) => number,
Screen: typeof Screen,
};
type TPluginDecl = string | ((core3d: TCore3D) => void) | Readonly<{ name: string, opts: TUnknownObject }>;
type TInitOpts = TDocumentOpts & Readonly<{
/**
* Use GLES 3.2 profile instead of default.
*
* In this mode, shader augmentation is disabled, as the context becomes compatible
* with WebGL API set (as GLES intended). Some things, such as
* `texture.colorSpace = three.SRGBColorSpace;` work better or even exclusively
* in this mode.
*/
isGles3?: boolean,
/**
* EXPERIMENTAL. Defines WebGL2 context, so three.js uses WebGL2 pathways.
*
* At this point, most of the stuff stops working in this mode. Some additional
* shader tweaks or API exports may be required to fully support running web
* libs in WebGL2 mode.
*
* Note: for non-web libs this has no effect, since it only affects common "isWebGL2" checks.
*/
isWebGL2?: boolean,
/**
* Is default window visible?
*
* For "headless" mode, use `false`. The window will be created in GLFW hidden mode
* (this is how headless GL works anyway). The default value is `true` - visible window.
*/
isVisible?: boolean,
/**
* An override for WebGL implementation.
*/
webgl?: TWebgl,
/**
* An override for Image implementation.
*/
Image?: Img,
/**
* An override for GLFW implementation.
*/
glfw?: TGlfw,
/**
* An override for the `location` object.
*/
location?: TLocation,
/**
* An override for the `navigator` object.
*/
navigator?: TNavigator,
/**
* An override for the `WebVRManager` object.
*/
WebVRManager?: WebVRManager,
}>;
/**
* Initialize Node3D. Creates the first window/document and sets up the global environment.
* This function can be called repeatedly, but will ignore further calls.
* The return value is cached and will be returned immediately for repeating calls.
*/
export const init: (opts?: TInitOpts) => TCore3D;
/**
* Teaches `three.FileLoader.load` to work with Node `fs`. Additionally implements
* `three.Texture.fromId` static method to create THREE textures from known GL resource IDs.
*/
export const addThreeHelpers: (three: TThree, gl: TWebgl) => void;
}