@1pizzateam/roostr 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +35 -2
- package/dist/roostr.d.ts +941 -0
- package/dist/roostr.js +3650 -0
- package/package.json +65 -4
package/dist/roostr.d.ts
ADDED
|
@@ -0,0 +1,941 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2015 Ludovic CLUBER
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
23
|
+
|
|
24
|
+
https://github.com/1pizzateam/RoostR.js
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { Mat4x3, Vec3, Quat, Mat3, Box, Sphere as Sphere$1, Vec2, Mat4, Ray3, Frustum, Rect } from '@1pizzateam/spock';
|
|
28
|
+
export { Accumulator, Bezier, Box as BoundingBox, Sphere as BoundingSphere, Circ, Frustum, Grid, Mat3, Mat4, Mat4x3, NumArray, Quat, Rand, Ray3 as Ray, Ray2, Rect, RollingAverage, Plane as SpatialPlane, Time, Trigo, Utils, Vec2, Vec3 } from '@1pizzateam/spock';
|
|
29
|
+
|
|
30
|
+
declare class SceneRenderer {
|
|
31
|
+
context: WebGLRenderingContext;
|
|
32
|
+
private blendKey;
|
|
33
|
+
private blendEnabled;
|
|
34
|
+
private depthWrite;
|
|
35
|
+
constructor(context: WebGLRenderingContext);
|
|
36
|
+
invalidateState(): void;
|
|
37
|
+
reset(): void;
|
|
38
|
+
defaultSettings(): void;
|
|
39
|
+
enable(capability: string): void;
|
|
40
|
+
disable(capability: string): void;
|
|
41
|
+
setDepthFunc(mode: string): void;
|
|
42
|
+
setBlendFunction(sourceFactor: string, destinationFactor: string): void;
|
|
43
|
+
setBlendEquation(mode: string): void;
|
|
44
|
+
enableDepthTest(): void;
|
|
45
|
+
disableDepthTest(): void;
|
|
46
|
+
enableBlendMode(equation: string, source: string, destination: string): void;
|
|
47
|
+
disableBlendMode(): void;
|
|
48
|
+
setDepthWrite(enabled: boolean): void;
|
|
49
|
+
getParameter(parameterName: GLenum): GLenum | Float32Array | GLint | WebGLBuffer | GLboolean | Array<GLboolean> | GLfloat | WebGLFramebuffer | Int32Array | GLuint | WebGLTexture;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare class SceneGraph {
|
|
53
|
+
model: Array<Mat4x3>;
|
|
54
|
+
nbModel: number;
|
|
55
|
+
modelStackTop: number;
|
|
56
|
+
constructor();
|
|
57
|
+
pushModelMatrix(modelMatrix: Mat4x3): void;
|
|
58
|
+
popModelMatrix(): void;
|
|
59
|
+
getWorldMatrix(): Mat4x3;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare class Node<T extends Node<T> = any> {
|
|
63
|
+
position: Vec3;
|
|
64
|
+
scale: Vec3;
|
|
65
|
+
quaternion: Quat;
|
|
66
|
+
modelMatrix: Mat4x3;
|
|
67
|
+
worldMatrix: Mat4x3;
|
|
68
|
+
normalMatrix: Mat3;
|
|
69
|
+
boundingBox: Box;
|
|
70
|
+
boundingSphere: Sphere$1;
|
|
71
|
+
localBoundingBox: Box;
|
|
72
|
+
localBoundingSphere: Sphere$1;
|
|
73
|
+
parent: T | null;
|
|
74
|
+
children: T[];
|
|
75
|
+
traversalStamp: number;
|
|
76
|
+
isBoundsDirty: boolean;
|
|
77
|
+
isNormalMatrixDirty: boolean;
|
|
78
|
+
isWorldDirty: boolean;
|
|
79
|
+
private _rotation;
|
|
80
|
+
private isRotationStale;
|
|
81
|
+
private isTransformDirty;
|
|
82
|
+
private static readonly UP;
|
|
83
|
+
private static readonly scratchQuat;
|
|
84
|
+
private static readonly scratchVec;
|
|
85
|
+
constructor();
|
|
86
|
+
addChild(node: T): void;
|
|
87
|
+
removeChild(node: T): boolean;
|
|
88
|
+
markDirty(): void;
|
|
89
|
+
get rotation(): Vec3;
|
|
90
|
+
set rotation(euler: Vec3);
|
|
91
|
+
private rotationChanged;
|
|
92
|
+
setPosition(position: Vec3): this;
|
|
93
|
+
setRotation(rotation: Vec3): this;
|
|
94
|
+
setScale(scale: Vec3): this;
|
|
95
|
+
scaleBy(factor: Vec3): this;
|
|
96
|
+
setQuaternion(q: Quat): this;
|
|
97
|
+
slerp(targetQuat: Quat, t: number): this;
|
|
98
|
+
rotateX(angle: number): this;
|
|
99
|
+
rotateY(angle: number): this;
|
|
100
|
+
rotateZ(angle: number): this;
|
|
101
|
+
rotateOnAxis(axis: Vec3, angle: number): this;
|
|
102
|
+
translate(translation: Vec3): this;
|
|
103
|
+
lookAt(target: Vec3, up?: Vec3): this;
|
|
104
|
+
updateModelMatrix(): boolean;
|
|
105
|
+
computeNormalMatrix(): Mat3;
|
|
106
|
+
getWorldPosition(target?: Vec3): Vec3;
|
|
107
|
+
getWorldDirection(target?: Vec3): Vec3;
|
|
108
|
+
distanceTo(target: Node | Vec3): number;
|
|
109
|
+
isInsideBounds(box: Box): boolean;
|
|
110
|
+
setLocalBounds(box: Box): this;
|
|
111
|
+
computeBounds(): void;
|
|
112
|
+
computeBoundingBox(): Box;
|
|
113
|
+
computeBoundingSphere(): Sphere$1;
|
|
114
|
+
setWorldMatrix(worldMatrix: Mat4x3): void;
|
|
115
|
+
computeWorldMatrix(graph: SceneGraph): void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type TextureSource = HTMLImageElement | HTMLCanvasElement | ImageData | ImageBitmap | Uint8Array;
|
|
119
|
+
interface ITextureOptions {
|
|
120
|
+
wrapS?: number;
|
|
121
|
+
wrapT?: number;
|
|
122
|
+
minFilter?: number;
|
|
123
|
+
magFilter?: number;
|
|
124
|
+
flipY?: boolean;
|
|
125
|
+
generateMipmaps?: boolean;
|
|
126
|
+
size?: Vec2;
|
|
127
|
+
}
|
|
128
|
+
declare const Texture: {
|
|
129
|
+
create(source: TextureSource, context: WebGLRenderingContext, options?: ITextureOptions): WebGLTexture | null;
|
|
130
|
+
load(url: string, context: WebGLRenderingContext, options?: ITextureOptions): Promise<WebGLTexture | null>;
|
|
131
|
+
update(texture: WebGLTexture, source: TextureSource, context: WebGLRenderingContext, offset?: Vec2, size?: Vec2, flipY?: boolean): void;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
type UniformValue = number | number[] | Float32Array | Int32Array | Vec2 | Vec3 | Quat | Mat3 | Mat4 | Mat4x3;
|
|
135
|
+
declare class Uniform {
|
|
136
|
+
type: string;
|
|
137
|
+
value: UniformValue;
|
|
138
|
+
constructor(type: string, value: UniformValue);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare class SubMesh {
|
|
142
|
+
start: number;
|
|
143
|
+
count: number;
|
|
144
|
+
constructor(start: number, count: number);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare class GLState {
|
|
148
|
+
program: WebGLProgram | null;
|
|
149
|
+
arrayBuffer: WebGLBuffer | null;
|
|
150
|
+
elementBuffer: WebGLBuffer | null;
|
|
151
|
+
attributeMask: number | null;
|
|
152
|
+
maxAttributes: number;
|
|
153
|
+
frameOfProgram: WeakMap<object, number>;
|
|
154
|
+
materialOfProgram: WeakMap<object, object>;
|
|
155
|
+
materialVersionOfProgram: WeakMap<object, number>;
|
|
156
|
+
invalidate(): void;
|
|
157
|
+
reset(): void;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface IMaterialOptions {
|
|
161
|
+
ambient?: Vec3;
|
|
162
|
+
diffuse?: Vec3;
|
|
163
|
+
specular?: Vec3;
|
|
164
|
+
shininess?: number;
|
|
165
|
+
}
|
|
166
|
+
declare class Material {
|
|
167
|
+
ambient: Vec3;
|
|
168
|
+
diffuse: Vec3;
|
|
169
|
+
specular: Vec3;
|
|
170
|
+
shininess: number;
|
|
171
|
+
uniforms: IMaterialUniforms;
|
|
172
|
+
version: number;
|
|
173
|
+
constructor(options?: IMaterialOptions);
|
|
174
|
+
setAmbient(ambient: Vec3): void;
|
|
175
|
+
setDiffuse(diffuse: Vec3): void;
|
|
176
|
+
setSpecular(specular: Vec3): void;
|
|
177
|
+
setShininess(shininess: number): void;
|
|
178
|
+
updateUniforms(): boolean;
|
|
179
|
+
private sync;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface IGeometry {
|
|
183
|
+
vertices: number[] | Float32Array | null;
|
|
184
|
+
indices: number[] | Int32Array | Uint16Array | null;
|
|
185
|
+
normals: number[] | Float32Array | null;
|
|
186
|
+
subMeshes: SubMesh[];
|
|
187
|
+
itemSize: number | null;
|
|
188
|
+
primitive: string | null;
|
|
189
|
+
uvs?: number[] | Float32Array | null;
|
|
190
|
+
nbSubMeshes?: number;
|
|
191
|
+
quad?: {
|
|
192
|
+
vertices: number[] | null;
|
|
193
|
+
indices: number[] | null;
|
|
194
|
+
uvs?: number[] | null;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
interface IMesh extends IGeometry {
|
|
198
|
+
customUniforms?: ICustomUniforms;
|
|
199
|
+
context?: WebGLRenderingContext;
|
|
200
|
+
renderer?: MeshRenderer;
|
|
201
|
+
WebGLTexture?: WebGLTexture | null;
|
|
202
|
+
vertexBuffer?: WebGLBuffer | null;
|
|
203
|
+
indexBuffer?: WebGLBuffer | null;
|
|
204
|
+
normalBuffer?: WebGLBuffer | null;
|
|
205
|
+
texCoordBuffer?: WebGLBuffer | null;
|
|
206
|
+
position?: Vec3;
|
|
207
|
+
rotation?: Vec3;
|
|
208
|
+
scale?: Vec3;
|
|
209
|
+
quaternion?: Quat;
|
|
210
|
+
modelMatrix?: Mat4x3;
|
|
211
|
+
worldMatrix?: Mat4x3;
|
|
212
|
+
normalMatrix?: Mat3;
|
|
213
|
+
active?: boolean;
|
|
214
|
+
drawMethod?: eDrawMethod;
|
|
215
|
+
programs?: IProgram[];
|
|
216
|
+
nbPrograms?: number;
|
|
217
|
+
materials?: Material[];
|
|
218
|
+
children?: IMesh[];
|
|
219
|
+
blendMode?: boolean;
|
|
220
|
+
zOrder?: number;
|
|
221
|
+
}
|
|
222
|
+
interface IFrameInfo {
|
|
223
|
+
id: number;
|
|
224
|
+
resolution?: Vec2;
|
|
225
|
+
}
|
|
226
|
+
interface IBlendOptions {
|
|
227
|
+
equation: string;
|
|
228
|
+
source: string;
|
|
229
|
+
destination: string;
|
|
230
|
+
}
|
|
231
|
+
interface ICustomUniforms {
|
|
232
|
+
[key: string]: Uniform;
|
|
233
|
+
}
|
|
234
|
+
interface IMaterialUniforms {
|
|
235
|
+
materialAmbient: Uniform;
|
|
236
|
+
materialDiffuse: Uniform;
|
|
237
|
+
materialSpecular: Uniform;
|
|
238
|
+
materialShininess: Uniform;
|
|
239
|
+
}
|
|
240
|
+
interface IProgram extends WebGLProgram {
|
|
241
|
+
vertexNormal: GLint;
|
|
242
|
+
vertexPosition: GLint;
|
|
243
|
+
textureCoord: GLint;
|
|
244
|
+
sampler: WebGLUniformLocation | null;
|
|
245
|
+
modelMatrix: WebGLUniformLocation | null;
|
|
246
|
+
normalMatrix?: WebGLUniformLocation | null;
|
|
247
|
+
projectionMatrix: WebGLUniformLocation | null;
|
|
248
|
+
viewMatrix: WebGLUniformLocation | null;
|
|
249
|
+
time: WebGLUniformLocation | null;
|
|
250
|
+
screenResolution: WebGLUniformLocation | null;
|
|
251
|
+
lightPosition?: WebGLUniformLocation | null;
|
|
252
|
+
lightDiffuse?: WebGLUniformLocation | null;
|
|
253
|
+
lightSpecular?: WebGLUniformLocation | null;
|
|
254
|
+
lightDirection?: WebGLUniformLocation | null;
|
|
255
|
+
lightAttenuation?: WebGLUniformLocation | null;
|
|
256
|
+
lightCutoff?: WebGLUniformLocation | null;
|
|
257
|
+
lightExponent?: WebGLUniformLocation | null;
|
|
258
|
+
lightType?: WebGLUniformLocation | null;
|
|
259
|
+
lightPositionType?: WebGLUniformLocation | null;
|
|
260
|
+
lightDiffuseCutoff?: WebGLUniformLocation | null;
|
|
261
|
+
lightSpecularExponent?: WebGLUniformLocation | null;
|
|
262
|
+
nbLights?: WebGLUniformLocation | null;
|
|
263
|
+
ambientLight?: WebGLUniformLocation | null;
|
|
264
|
+
ambientColor?: WebGLUniformLocation | null;
|
|
265
|
+
fogColor?: WebGLUniformLocation | null;
|
|
266
|
+
fogNear?: WebGLUniformLocation | null;
|
|
267
|
+
fogFar?: WebGLUniformLocation | null;
|
|
268
|
+
[key: string]: any;
|
|
269
|
+
}
|
|
270
|
+
interface IFlatLights {
|
|
271
|
+
position: number[];
|
|
272
|
+
diffuse: number[];
|
|
273
|
+
specular: number[];
|
|
274
|
+
constantAttenuation: number[];
|
|
275
|
+
linearAttenuation: number[];
|
|
276
|
+
quadraticAttenuation: number[];
|
|
277
|
+
cutoff: number[];
|
|
278
|
+
exponent: number[];
|
|
279
|
+
direction: number[];
|
|
280
|
+
type: (string | number)[];
|
|
281
|
+
ambient?: number[];
|
|
282
|
+
floatPosition?: Float32Array;
|
|
283
|
+
floatDiffuse?: Float32Array;
|
|
284
|
+
floatSpecular?: Float32Array;
|
|
285
|
+
floatDirection?: Float32Array;
|
|
286
|
+
floatAttenuation?: Float32Array;
|
|
287
|
+
floatCutoff?: Float32Array;
|
|
288
|
+
floatExponent?: Float32Array;
|
|
289
|
+
floatType?: Float32Array;
|
|
290
|
+
floatAmbient?: Float32Array;
|
|
291
|
+
packedPosition?: Float32Array;
|
|
292
|
+
packedDiffuse?: Float32Array;
|
|
293
|
+
packedSpecular?: Float32Array;
|
|
294
|
+
[key: string]: any;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
declare class MeshRenderer {
|
|
298
|
+
context: WebGLRenderingContext;
|
|
299
|
+
state: GLState;
|
|
300
|
+
constructor(context: WebGLRenderingContext);
|
|
301
|
+
defaultSettings(): void;
|
|
302
|
+
createBuffer(target: string, size: ArrayBuffer | ArrayBufferView | null, drawMethod: string): WebGLBuffer | null;
|
|
303
|
+
useProgram(program: WebGLProgram): void;
|
|
304
|
+
bindBuffer(target: string, buffer: WebGLBuffer | null): void;
|
|
305
|
+
deleteBuffer(buffer: WebGLBuffer): void;
|
|
306
|
+
setAttributeMask(mask: number): void;
|
|
307
|
+
vertexAttribPointer(index: number, size: number, type: string, normalized: boolean, stride: number, offset: number): void;
|
|
308
|
+
drawElements(primitive: string | number, subMesh: SubMesh, indexType?: number): void;
|
|
309
|
+
drawArrays(primitive: string | number, subMesh: SubMesh): void;
|
|
310
|
+
drawMesh(mesh: Mesh, projectionMatrix: Float32Array, viewMatrix: Float32Array, lights: IFlatLights, time: number, cameraPosition?: Vec3, fog?: {
|
|
311
|
+
color: Vec3;
|
|
312
|
+
near: number;
|
|
313
|
+
far: number;
|
|
314
|
+
} | null, frame?: IFrameInfo): void;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
declare enum eDrawMethod {
|
|
318
|
+
drawElements = "drawElements",
|
|
319
|
+
drawArrays = "drawArrays"
|
|
320
|
+
}
|
|
321
|
+
declare class Mesh extends Node<Mesh> implements IMesh {
|
|
322
|
+
vertices: number[] | Float32Array | null;
|
|
323
|
+
indices: number[] | Int32Array | Uint16Array | null;
|
|
324
|
+
normals: number[] | Float32Array | null;
|
|
325
|
+
uvs: number[] | Float32Array | null;
|
|
326
|
+
itemSize: number | null;
|
|
327
|
+
subMeshes: SubMesh[];
|
|
328
|
+
nbSubMeshes: number;
|
|
329
|
+
primitive: string | null;
|
|
330
|
+
customUniforms: ICustomUniforms;
|
|
331
|
+
context: WebGLRenderingContext;
|
|
332
|
+
renderer: MeshRenderer;
|
|
333
|
+
WebGLTexture: WebGLTexture | null;
|
|
334
|
+
vertexBuffer: WebGLBuffer | null;
|
|
335
|
+
indexBuffer: WebGLBuffer | null;
|
|
336
|
+
normalBuffer: WebGLBuffer | null;
|
|
337
|
+
texCoordBuffer: WebGLBuffer | null;
|
|
338
|
+
sortKey: number;
|
|
339
|
+
private ownsTexture;
|
|
340
|
+
private textureSource;
|
|
341
|
+
private textureOptions;
|
|
342
|
+
indexType: number;
|
|
343
|
+
private static readonly scratchHit;
|
|
344
|
+
active: boolean;
|
|
345
|
+
drawMethod: eDrawMethod;
|
|
346
|
+
programs: IProgram[];
|
|
347
|
+
nbPrograms: number;
|
|
348
|
+
materials: Material[];
|
|
349
|
+
blendMode: boolean;
|
|
350
|
+
blendOptions: IBlendOptions;
|
|
351
|
+
depthWrite: boolean;
|
|
352
|
+
zOrder: number;
|
|
353
|
+
constructor(meshOrContext: IMesh | WebGLRenderingContext, contextOrMesh: WebGLRenderingContext | IMesh);
|
|
354
|
+
setActive(): void;
|
|
355
|
+
setInactive(): void;
|
|
356
|
+
toggleActive(): boolean;
|
|
357
|
+
isActive(): boolean;
|
|
358
|
+
addProgram(vertexShaderOrProgram: string | WebGLProgram, fragmentShaderOrMaterial?: string | Material, material?: Material): boolean;
|
|
359
|
+
clearPrograms(): void;
|
|
360
|
+
addMaterial(material: Material): boolean;
|
|
361
|
+
raycast(ray: Ray3, precise?: boolean): {
|
|
362
|
+
distance: number;
|
|
363
|
+
point: Vec3;
|
|
364
|
+
} | null;
|
|
365
|
+
useBasicMaterial(options?: IMaterialShortcutOptions): this;
|
|
366
|
+
usePhongMaterial(options?: IPhongShortcutOptions): this;
|
|
367
|
+
useNormalMaterial(): this;
|
|
368
|
+
private applyTextureOption;
|
|
369
|
+
private releaseTexture;
|
|
370
|
+
setTexture(img: TextureSource, options?: ITextureOptions): void;
|
|
371
|
+
addCustomUniform(name: string, type: string, value: UniformValue): void;
|
|
372
|
+
setCustomUniform(name: string, value: UniformValue): void;
|
|
373
|
+
private createIndexData;
|
|
374
|
+
private createBuffers;
|
|
375
|
+
restore(): void;
|
|
376
|
+
private createProgram;
|
|
377
|
+
activateBlendMode(): void;
|
|
378
|
+
deactivateBlendMode(): void;
|
|
379
|
+
setBlend(source?: string, destination?: string, equation?: string): this;
|
|
380
|
+
setDepthWrite(enabled: boolean): this;
|
|
381
|
+
render(projectionMatrix: Float32Array, viewMatrix: Float32Array, lights: IFlatLights, time: number, blendMode: boolean, cameraPosition?: Vec3, fog?: {
|
|
382
|
+
color: Vec3;
|
|
383
|
+
near: number;
|
|
384
|
+
far: number;
|
|
385
|
+
} | null, frame?: IFrameInfo): void;
|
|
386
|
+
renderSelf(projectionMatrix: Float32Array, viewMatrix: Float32Array, lights: IFlatLights, time: number, blendMode: boolean, cameraPosition?: Vec3, fog?: {
|
|
387
|
+
color: Vec3;
|
|
388
|
+
near: number;
|
|
389
|
+
far: number;
|
|
390
|
+
} | null, frame?: IFrameInfo): void;
|
|
391
|
+
destroy(): void;
|
|
392
|
+
}
|
|
393
|
+
interface IMaterialShortcutOptions {
|
|
394
|
+
color?: Vec3;
|
|
395
|
+
texture?: HTMLImageElement | HTMLCanvasElement | WebGLTexture;
|
|
396
|
+
}
|
|
397
|
+
interface IPhongShortcutOptions {
|
|
398
|
+
ambient?: Vec3;
|
|
399
|
+
diffuse?: Vec3;
|
|
400
|
+
specular?: Vec3;
|
|
401
|
+
shininess?: number;
|
|
402
|
+
texture?: HTMLImageElement | HTMLCanvasElement | WebGLTexture;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
type Light = 'directional' | 'point' | 'spot' | 'ambient';
|
|
406
|
+
|
|
407
|
+
interface IDirectionalLightOptions {
|
|
408
|
+
direction?: Vec3;
|
|
409
|
+
diffuse?: Vec3;
|
|
410
|
+
specular?: Vec3;
|
|
411
|
+
position?: Vec3;
|
|
412
|
+
}
|
|
413
|
+
declare class DirectionalLight {
|
|
414
|
+
position: Vec3;
|
|
415
|
+
diffuse: Vec3;
|
|
416
|
+
specular: Vec3;
|
|
417
|
+
direction: Vec3;
|
|
418
|
+
type: Light;
|
|
419
|
+
constructor(directionOrOptions?: Vec3 | IDirectionalLightOptions);
|
|
420
|
+
setPosition(position: Vec3): void;
|
|
421
|
+
setDirection(direction: Vec3): void;
|
|
422
|
+
setDiffuse(diffuse: Vec3): void;
|
|
423
|
+
setSpecular(specular: Vec3): void;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
interface IPointLightOptions {
|
|
427
|
+
position?: Vec3;
|
|
428
|
+
diffuse?: Vec3;
|
|
429
|
+
specular?: Vec3;
|
|
430
|
+
constantAttenuation?: number;
|
|
431
|
+
linearAttenuation?: number;
|
|
432
|
+
quadraticAttenuation?: number;
|
|
433
|
+
}
|
|
434
|
+
declare class PointLight extends DirectionalLight {
|
|
435
|
+
constantAttenuation: number;
|
|
436
|
+
linearAttenuation: number;
|
|
437
|
+
quadraticAttenuation: number;
|
|
438
|
+
constructor(positionOrOptions?: Vec3 | IPointLightOptions);
|
|
439
|
+
setConstantAttenuation(value: number): void;
|
|
440
|
+
setLinearAttenuation(value: number): void;
|
|
441
|
+
setQuadraticAttenuation(value: number): void;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
interface ISpotLightOptions extends IPointLightOptions {
|
|
445
|
+
direction?: Vec3;
|
|
446
|
+
cutoff?: number;
|
|
447
|
+
exponent?: number;
|
|
448
|
+
}
|
|
449
|
+
declare class SpotLight extends PointLight {
|
|
450
|
+
cutoff: number;
|
|
451
|
+
exponent: number;
|
|
452
|
+
direction: Vec3;
|
|
453
|
+
constructor(positionOrOptions?: Vec3 | ISpotLightOptions);
|
|
454
|
+
setCutoff(value: number): void;
|
|
455
|
+
setExponent(value: number): void;
|
|
456
|
+
setDirection(direction: Vec3): void;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
declare class AmbientLight {
|
|
460
|
+
diffuse: Vec3;
|
|
461
|
+
intensity: number;
|
|
462
|
+
type: Light;
|
|
463
|
+
constructor(diffuse?: Vec3, intensity?: number);
|
|
464
|
+
setColor(diffuse: Vec3): this;
|
|
465
|
+
setIntensity(intensity: number): this;
|
|
466
|
+
getColor(target?: Vec3): Vec3;
|
|
467
|
+
get color(): Vec3;
|
|
468
|
+
set color(c: Vec3);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
type AnyLight = DirectionalLight | PointLight | SpotLight | AmbientLight;
|
|
472
|
+
declare const MAX_LIGHTS = 8;
|
|
473
|
+
declare class Lights {
|
|
474
|
+
private warnedOverflow;
|
|
475
|
+
directionals: DirectionalLight[];
|
|
476
|
+
points: PointLight[];
|
|
477
|
+
spots: SpotLight[];
|
|
478
|
+
ambients: AmbientLight[];
|
|
479
|
+
nbDirectionals: number;
|
|
480
|
+
nbPoints: number;
|
|
481
|
+
nbSpots: number;
|
|
482
|
+
nbAmbients: number;
|
|
483
|
+
flatArrays: IFlatLights;
|
|
484
|
+
constructor();
|
|
485
|
+
addLight(light: AnyLight): void;
|
|
486
|
+
removeLight(light: AnyLight): boolean;
|
|
487
|
+
flatten(extraAmbient?: Vec3): IFlatLights;
|
|
488
|
+
clear(): void;
|
|
489
|
+
getFlatArray(property: string): (number | string)[] | undefined;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
declare class Camera {
|
|
493
|
+
viewMatrix: Mat4x3;
|
|
494
|
+
projectionMatrix: Mat4;
|
|
495
|
+
position: Vec3;
|
|
496
|
+
target: Vec3;
|
|
497
|
+
up: Vec3;
|
|
498
|
+
protected cachedViewMatrix: Float32Array;
|
|
499
|
+
protected cachedProjectionMatrix: Float32Array;
|
|
500
|
+
private projectionViewMatrix;
|
|
501
|
+
private inverseProjectionViewMatrix;
|
|
502
|
+
private isProjectionViewDirty;
|
|
503
|
+
private isInverseDirty;
|
|
504
|
+
private static _scratchNear;
|
|
505
|
+
private static _scratchFar;
|
|
506
|
+
private static _scratchDir;
|
|
507
|
+
private static _scratchNdc;
|
|
508
|
+
constructor(position: Vec3, target: Vec3, up: Vec3);
|
|
509
|
+
setViewMatrix(): void;
|
|
510
|
+
setProjectionMatrix(): void;
|
|
511
|
+
private invalidateProjectionView;
|
|
512
|
+
getProjectionViewMatrix(): Float32Array;
|
|
513
|
+
getInverseProjectionViewMatrix(): Mat4;
|
|
514
|
+
setPosition(position: Vec3): void;
|
|
515
|
+
setTarget(target: Vec3): void;
|
|
516
|
+
setUp(up: Vec3): void;
|
|
517
|
+
lookAt(target: Vec3): void;
|
|
518
|
+
getViewDirection(target?: Vec3): Vec3;
|
|
519
|
+
getDistance(): number;
|
|
520
|
+
dolly(amount: number): void;
|
|
521
|
+
getViewMatrix(): Float32Array;
|
|
522
|
+
getProjectionMatrix(): Float32Array;
|
|
523
|
+
getViewMatrixObject(): Mat4x3;
|
|
524
|
+
getProjectionMatrixObject(): Mat4;
|
|
525
|
+
getRay(ndc: Vec2, targetRay?: Ray3): Ray3;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
declare class SceneCollector {
|
|
529
|
+
opaqueList: Mesh[];
|
|
530
|
+
blendedList: Mesh[];
|
|
531
|
+
scratchFrustum: Frustum;
|
|
532
|
+
private scratchVec;
|
|
533
|
+
collect(meshes: Mesh[], camera: Camera, frustum: Frustum | null, opaque: boolean, blended: boolean, stamp: number): void;
|
|
534
|
+
drawBlended(scene: Scene, camera: Camera, time: number, flatLights: IFlatLights, frame: IFrameInfo): number;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
interface ISceneOptions {
|
|
538
|
+
canvasId?: string | HTMLCanvasElement;
|
|
539
|
+
context?: WebGLRenderingContext;
|
|
540
|
+
viewport?: {
|
|
541
|
+
position?: Vec2;
|
|
542
|
+
size: Vec2;
|
|
543
|
+
} | Vec2;
|
|
544
|
+
clearColor?: Vec3;
|
|
545
|
+
cullFace?: 'BACK' | 'FRONT' | 'NONE';
|
|
546
|
+
frontFace?: 'CCW' | 'CW';
|
|
547
|
+
depthTest?: boolean;
|
|
548
|
+
ambientColor?: Vec3;
|
|
549
|
+
fog?: {
|
|
550
|
+
color: Vec3;
|
|
551
|
+
near: number;
|
|
552
|
+
far: number;
|
|
553
|
+
} | null;
|
|
554
|
+
enableFrustumCulling?: boolean;
|
|
555
|
+
}
|
|
556
|
+
declare class Scene {
|
|
557
|
+
meshes: Mesh[];
|
|
558
|
+
nbMeshes: number;
|
|
559
|
+
lights: Lights;
|
|
560
|
+
ambientColor: Vec3;
|
|
561
|
+
fog: {
|
|
562
|
+
color: Vec3;
|
|
563
|
+
near: number;
|
|
564
|
+
far: number;
|
|
565
|
+
} | null;
|
|
566
|
+
enableFrustumCulling: boolean;
|
|
567
|
+
context: WebGLRenderingContext;
|
|
568
|
+
renderer: SceneRenderer;
|
|
569
|
+
graph: SceneGraph;
|
|
570
|
+
collector: SceneCollector;
|
|
571
|
+
resolution: Vec2;
|
|
572
|
+
private frame;
|
|
573
|
+
private frameCounter;
|
|
574
|
+
private traversalStamp;
|
|
575
|
+
constructor(contextOrOptions: WebGLRenderingContext | ISceneOptions);
|
|
576
|
+
private static contextFromCanvas;
|
|
577
|
+
setViewport(size: Vec2, position?: Vec2): void;
|
|
578
|
+
getSize(target?: Vec2): Vec2;
|
|
579
|
+
setClearColor(color: Vec3, alpha?: number): void;
|
|
580
|
+
setSize(size: Vec2): void;
|
|
581
|
+
clear(color?: boolean, depth?: boolean): void;
|
|
582
|
+
addMesh(mesh: Mesh): void;
|
|
583
|
+
removeMesh(mesh: Mesh): boolean;
|
|
584
|
+
addLight(light: AnyLight): void;
|
|
585
|
+
removeLight(light: AnyLight): boolean;
|
|
586
|
+
setAmbientColor(color: Vec3): this;
|
|
587
|
+
setFog(color: Vec3, near: number, far?: number): this;
|
|
588
|
+
clearFog(): this;
|
|
589
|
+
clearMeshes(): void;
|
|
590
|
+
clearLights(): void;
|
|
591
|
+
restore(): void;
|
|
592
|
+
destroy(destroyMeshes?: boolean): void;
|
|
593
|
+
getLightsProperty(property: string): (number | string)[] | undefined;
|
|
594
|
+
enableBlendMode(equation: string, source: string, destination: string): void;
|
|
595
|
+
disableBlendMode(): void;
|
|
596
|
+
getRendererBlendMode(): GLenum | Float32Array | GLint | WebGLBuffer | GLboolean | GLboolean[] | GLfloat | WebGLFramebuffer | Int32Array | GLuint | WebGLTexture;
|
|
597
|
+
raycast(ray: Ray3, precise?: boolean): {
|
|
598
|
+
mesh: Mesh;
|
|
599
|
+
distance: number;
|
|
600
|
+
point: Vec3;
|
|
601
|
+
}[];
|
|
602
|
+
render(camera: Camera, time?: number): number;
|
|
603
|
+
private markDescendants;
|
|
604
|
+
private computeWorldMatrices;
|
|
605
|
+
private beginFrame;
|
|
606
|
+
renderBlended(camera: Camera, time?: number, flatLights?: IFlatLights, frustum?: Frustum | null): number;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
interface IRendererOptions {
|
|
610
|
+
size?: Vec2;
|
|
611
|
+
contextAttributes?: WebGLContextAttributes;
|
|
612
|
+
onContextLost?: () => void;
|
|
613
|
+
onContextRestored?: () => void;
|
|
614
|
+
}
|
|
615
|
+
declare class Renderer {
|
|
616
|
+
canvas: HTMLCanvasElement | null;
|
|
617
|
+
context: WebGLRenderingContext | null;
|
|
618
|
+
isContextLost: boolean;
|
|
619
|
+
private options;
|
|
620
|
+
private onContextLostBound;
|
|
621
|
+
private onContextRestoredBound;
|
|
622
|
+
constructor(canvasID: string | HTMLCanvasElement, options?: IRendererOptions);
|
|
623
|
+
dispose(): void;
|
|
624
|
+
defaultSettings(): void;
|
|
625
|
+
setFrontFace(mode: string): void;
|
|
626
|
+
enable(capability: string): void;
|
|
627
|
+
disable(capability: string): void;
|
|
628
|
+
setCullFace(mode: string): void;
|
|
629
|
+
setViewport(size: Vec2): void;
|
|
630
|
+
setClearColor(color: Vec3, alpha?: number): void;
|
|
631
|
+
clearFrame(): void;
|
|
632
|
+
getContext(): WebGLRenderingContext | null;
|
|
633
|
+
getCanvas(): HTMLCanvasElement | null;
|
|
634
|
+
setSize(size: Vec2): void;
|
|
635
|
+
getSize(target?: Vec2): Vec2;
|
|
636
|
+
private findById;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
declare class RenderTarget {
|
|
640
|
+
width: number;
|
|
641
|
+
height: number;
|
|
642
|
+
context: WebGLRenderingContext;
|
|
643
|
+
framebuffer: WebGLFramebuffer | null;
|
|
644
|
+
texture: WebGLTexture | null;
|
|
645
|
+
depthBuffer: WebGLRenderbuffer | null;
|
|
646
|
+
constructor(size: Vec2, context: WebGLRenderingContext);
|
|
647
|
+
restore(): void;
|
|
648
|
+
private init;
|
|
649
|
+
bind(): void;
|
|
650
|
+
unbind(viewportSize?: Vec2): void;
|
|
651
|
+
getSize(target?: Vec2): Vec2;
|
|
652
|
+
setSize(size: Vec2): void;
|
|
653
|
+
dispose(): void;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
declare class PerspectiveCamera extends Camera {
|
|
657
|
+
fov: number;
|
|
658
|
+
ratio: number;
|
|
659
|
+
zNear: number;
|
|
660
|
+
zFar: number;
|
|
661
|
+
constructor(fov: number, nearFar?: Vec2, context?: WebGLRenderingContext | null);
|
|
662
|
+
setProjectionMatrix(viewport?: Vec2 | null): void;
|
|
663
|
+
setFov(fov: number): void;
|
|
664
|
+
setNearFar(nearFar: Vec2): void;
|
|
665
|
+
getNearFar(target?: Vec2): Vec2;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
declare class OrthographicCamera extends Camera {
|
|
669
|
+
left: number;
|
|
670
|
+
right: number;
|
|
671
|
+
top: number;
|
|
672
|
+
bottom: number;
|
|
673
|
+
near: number;
|
|
674
|
+
far: number;
|
|
675
|
+
constructor(bounds: Rect, nearFar?: Vec2);
|
|
676
|
+
setProjectionMatrix(): void;
|
|
677
|
+
setBounds(bounds: Rect, nearFar?: Vec2): void;
|
|
678
|
+
getNearFar(target?: Vec2): Vec2;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
declare class OrbitControls {
|
|
682
|
+
camera: Camera;
|
|
683
|
+
domElement: HTMLElement;
|
|
684
|
+
distance: number;
|
|
685
|
+
targetDistance: number;
|
|
686
|
+
azimuth: number;
|
|
687
|
+
targetAzimuth: number;
|
|
688
|
+
elevation: number;
|
|
689
|
+
targetElevation: number;
|
|
690
|
+
minDistance: number;
|
|
691
|
+
maxDistance: number;
|
|
692
|
+
minElevation: number;
|
|
693
|
+
maxElevation: number;
|
|
694
|
+
rotateSpeed: number;
|
|
695
|
+
zoomSpeed: number;
|
|
696
|
+
panSpeed: number;
|
|
697
|
+
enableDamping: boolean;
|
|
698
|
+
dampingFactor: number;
|
|
699
|
+
private isDragging;
|
|
700
|
+
private dragMode;
|
|
701
|
+
private previousMouseX;
|
|
702
|
+
private previousMouseY;
|
|
703
|
+
private touchStartDistance;
|
|
704
|
+
private activePointerId;
|
|
705
|
+
private appliedPose;
|
|
706
|
+
private appliedTarget;
|
|
707
|
+
private onPointerDownBound;
|
|
708
|
+
private onPointerMoveBound;
|
|
709
|
+
private onPointerUpBound;
|
|
710
|
+
private onWheelBound;
|
|
711
|
+
private onContextMenuBound;
|
|
712
|
+
private onTouchStartBound;
|
|
713
|
+
private onTouchMoveBound;
|
|
714
|
+
private onTouchEndBound;
|
|
715
|
+
constructor(camera: Camera, domElement: HTMLElement);
|
|
716
|
+
private attach;
|
|
717
|
+
dispose(): void;
|
|
718
|
+
private onPointerDown;
|
|
719
|
+
private onPointerMove;
|
|
720
|
+
private onPointerUp;
|
|
721
|
+
private onWheel;
|
|
722
|
+
private onTouchStart;
|
|
723
|
+
private onTouchMove;
|
|
724
|
+
private onTouchEnd;
|
|
725
|
+
private static _touchA;
|
|
726
|
+
private static _touchB;
|
|
727
|
+
private static touchDistance;
|
|
728
|
+
private static _scratchForward;
|
|
729
|
+
private static _scratchRight;
|
|
730
|
+
private static _scratchUp;
|
|
731
|
+
private static _scratchPan;
|
|
732
|
+
private static _scratchSpherical;
|
|
733
|
+
private pan;
|
|
734
|
+
update(deltaTime?: number): void;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
declare class BasicMesh implements IGeometry {
|
|
738
|
+
vertices: number[] | Float32Array | null;
|
|
739
|
+
indices: number[] | Int32Array | Uint16Array | null;
|
|
740
|
+
normals: number[] | Float32Array | null;
|
|
741
|
+
uvs: number[] | Float32Array | null;
|
|
742
|
+
subMeshes: SubMesh[];
|
|
743
|
+
itemSize: number;
|
|
744
|
+
primitive: string;
|
|
745
|
+
constructor();
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
declare class Line extends BasicMesh {
|
|
749
|
+
vertices: number[];
|
|
750
|
+
thickness: number;
|
|
751
|
+
subMeshes: SubMesh[];
|
|
752
|
+
itemSize: number;
|
|
753
|
+
primitive: string;
|
|
754
|
+
constructor(vertices?: Vec3[], thickness?: number);
|
|
755
|
+
setPoints(vertices: Vec3[]): this;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
declare class FullscreenQuad extends BasicMesh {
|
|
759
|
+
uvs: number[];
|
|
760
|
+
constructor();
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
declare class Quad extends BasicMesh {
|
|
764
|
+
vertices: number[];
|
|
765
|
+
uvs: number[];
|
|
766
|
+
subMeshes: SubMesh[];
|
|
767
|
+
itemSize: number;
|
|
768
|
+
primitive: string;
|
|
769
|
+
constructor(size?: Vec2 | Rect);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
interface IQuad {
|
|
773
|
+
vertices: Float32Array;
|
|
774
|
+
indices: Int32Array;
|
|
775
|
+
uvs: Float32Array;
|
|
776
|
+
}
|
|
777
|
+
declare class MultiQuad extends BasicMesh {
|
|
778
|
+
vertices: number[];
|
|
779
|
+
indices: number[];
|
|
780
|
+
uvs: number[];
|
|
781
|
+
quad: IQuad;
|
|
782
|
+
constructor(size?: Vec2 | Rect);
|
|
783
|
+
createQuads(length: number): void;
|
|
784
|
+
private createIndices;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
declare class Cube extends BasicMesh {
|
|
788
|
+
constructor(size?: Vec3, flat?: boolean);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
declare class Sphere extends BasicMesh {
|
|
792
|
+
constructor(scale?: Vec3);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
declare class Hemisphere extends BasicMesh {
|
|
796
|
+
constructor();
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
declare class Plane extends BasicMesh {
|
|
800
|
+
constructor(size?: Vec2, segments?: Vec2, orientation?: 'xy' | 'xz');
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
declare class Cylinder extends BasicMesh {
|
|
804
|
+
constructor(radii?: Vec2, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
declare class VWing extends BasicMesh {
|
|
808
|
+
constructor();
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
declare class Cannon extends BasicMesh {
|
|
812
|
+
constructor();
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
declare class CustomMesh implements IGeometry {
|
|
816
|
+
vertices: Float32Array | null;
|
|
817
|
+
indices: Int32Array | null;
|
|
818
|
+
normals: Float32Array | null;
|
|
819
|
+
uvs: Float32Array | null;
|
|
820
|
+
subMeshes: SubMesh[];
|
|
821
|
+
itemSize: number;
|
|
822
|
+
primitive: string;
|
|
823
|
+
primitives: string[];
|
|
824
|
+
constructor();
|
|
825
|
+
private static toFloat32;
|
|
826
|
+
setVertices(array: Vec3[]): void;
|
|
827
|
+
setIndices(array: Int32Array | number[]): void;
|
|
828
|
+
setNormals(array: Vec3[]): void;
|
|
829
|
+
setUvs(array: Float32Array | number[]): void;
|
|
830
|
+
addSubMeshes(array: Float32Array | Int32Array | number[]): void;
|
|
831
|
+
addSubMesh(start: number, count: number): void;
|
|
832
|
+
setItemSize(itemSize: number): void;
|
|
833
|
+
setPrimitive(primitive: string): boolean;
|
|
834
|
+
private static _vA;
|
|
835
|
+
private static _vB;
|
|
836
|
+
private static _vC;
|
|
837
|
+
private static _e1;
|
|
838
|
+
private static _e2;
|
|
839
|
+
private static _n;
|
|
840
|
+
private static _sum;
|
|
841
|
+
private static readonly UP;
|
|
842
|
+
private static accumulate;
|
|
843
|
+
computeVertexNormals(): Float32Array | null;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
declare const SpriteShader: {
|
|
847
|
+
vertex: string;
|
|
848
|
+
fragment: string;
|
|
849
|
+
create(context: WebGLRenderingContext): WebGLProgram | null;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
type SpriteBillboard = 'none' | 'spherical' | 'cylindrical';
|
|
853
|
+
type SpriteAnchor = 'center' | 'bottom';
|
|
854
|
+
interface ISpriteOptions {
|
|
855
|
+
size?: Vec2;
|
|
856
|
+
texture?: TextureSource;
|
|
857
|
+
textureOptions?: ITextureOptions;
|
|
858
|
+
frames?: number;
|
|
859
|
+
anchor?: SpriteAnchor;
|
|
860
|
+
billboard?: SpriteBillboard;
|
|
861
|
+
alphaCutoff?: number;
|
|
862
|
+
material?: Material;
|
|
863
|
+
depthBias?: number;
|
|
864
|
+
fragment?: string;
|
|
865
|
+
}
|
|
866
|
+
declare class Sprite extends Mesh {
|
|
867
|
+
readonly width: number;
|
|
868
|
+
readonly height: number;
|
|
869
|
+
frames: number;
|
|
870
|
+
readonly anchor: SpriteAnchor;
|
|
871
|
+
billboard: SpriteBillboard;
|
|
872
|
+
private currentFrame;
|
|
873
|
+
private alphaCutoff;
|
|
874
|
+
private depthBias;
|
|
875
|
+
private static readonly scratchSpriteMin;
|
|
876
|
+
private static readonly scratchSpriteMax;
|
|
877
|
+
private static readonly scratchSpriteBox;
|
|
878
|
+
private static readonly scratchSpriteHit;
|
|
879
|
+
constructor(context: WebGLRenderingContext, options: ISpriteOptions);
|
|
880
|
+
private updateLocalBounds;
|
|
881
|
+
setFrame(frame: number): this;
|
|
882
|
+
getFrame(): number;
|
|
883
|
+
setFrames(frames: number): this;
|
|
884
|
+
getFrames(): number;
|
|
885
|
+
setBillboard(billboard: SpriteBillboard): this;
|
|
886
|
+
getBillboard(): SpriteBillboard;
|
|
887
|
+
setAlphaCutoff(cutoff: number): this;
|
|
888
|
+
getAlphaCutoff(): number;
|
|
889
|
+
setDepthBias(depthBias: number): this;
|
|
890
|
+
getDepthBias(): number;
|
|
891
|
+
getWidth(): number;
|
|
892
|
+
getHeight(): number;
|
|
893
|
+
getSize(target?: Vec2): Vec2;
|
|
894
|
+
getAnchor(): SpriteAnchor;
|
|
895
|
+
raycast(ray: Ray3, precise?: boolean): {
|
|
896
|
+
distance: number;
|
|
897
|
+
point: Vec3;
|
|
898
|
+
} | null;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
declare const Program: {
|
|
902
|
+
create(context: WebGLRenderingContext, vertexShader: string, fragmentShader: string): WebGLProgram | null;
|
|
903
|
+
acquire(context: WebGLRenderingContext, vertexShader: string, fragmentShader: string): WebGLProgram | null;
|
|
904
|
+
release(context: WebGLRenderingContext, program: WebGLProgram): void;
|
|
905
|
+
sources(program: WebGLProgram): {
|
|
906
|
+
vertex: string;
|
|
907
|
+
fragment: string;
|
|
908
|
+
} | null;
|
|
909
|
+
reset(context: WebGLRenderingContext): void;
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
type ShaderType = 'VERTEX_SHADER' | 'FRAGMENT_SHADER';
|
|
913
|
+
declare const Shader: {
|
|
914
|
+
create(context: WebGLRenderingContext, str: string, type: ShaderType): WebGLShader | null;
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
declare const BasicShader: {
|
|
918
|
+
vertex: string;
|
|
919
|
+
fragment: string;
|
|
920
|
+
create(context: WebGLRenderingContext): WebGLProgram | null;
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
declare const PhongShader: {
|
|
924
|
+
vertex: string;
|
|
925
|
+
fragment: string;
|
|
926
|
+
create(context: WebGLRenderingContext): WebGLProgram | null;
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
declare const NormalShader: {
|
|
930
|
+
vertex: string;
|
|
931
|
+
fragment: string;
|
|
932
|
+
create(context: WebGLRenderingContext): WebGLProgram | null;
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
type Vec3Like = Vec3 | ArrayLike<number>;
|
|
936
|
+
type Vec2Like = Vec2 | ArrayLike<number>;
|
|
937
|
+
declare function assignVec3(target: Vec3, xOrVec: Vec3Like | number, y?: number, z?: number): Vec3;
|
|
938
|
+
declare function assignVec2(target: Vec2, xOrVec: Vec2Like | number, y?: number): Vec2;
|
|
939
|
+
|
|
940
|
+
export { AmbientLight, BasicMesh, BasicShader, Camera, Cannon, Cube, CustomMesh, Cylinder, DirectionalLight, FullscreenQuad, Hemisphere, Lights, Line, MAX_LIGHTS, Material, Mesh, MultiQuad, Node, NormalShader, OrbitControls, OrthographicCamera, PerspectiveCamera, PhongShader, Plane, PointLight, Program, Quad, RenderTarget, Renderer, Scene, Shader, Sphere, SpotLight, Sprite, SpriteShader, SubMesh, Texture, Uniform, VWing, assignVec2, assignVec3, eDrawMethod };
|
|
941
|
+
export type { AnyLight, ICustomUniforms, IFlatLights, IFrameInfo, IGeometry, IMaterialOptions, IMaterialUniforms, IMesh, IProgram, IRendererOptions, ISceneOptions, ISpriteOptions, ITextureOptions, SpriteAnchor, SpriteBillboard, TextureSource, UniformValue, Vec2Like, Vec3Like };
|