@1pizzateam/roostr 0.7.0 → 0.8.1
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/dist/roostr.d.ts +275 -212
- package/dist/roostr.js +1449 -1121
- package/package.json +2 -2
package/dist/roostr.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ SOFTWARE.
|
|
|
24
24
|
https://github.com/1pizzateam/RoostR.js
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import { Mat4x3,
|
|
28
|
-
export { Accumulator, Bezier, Box as BoundingBox, Sphere as BoundingSphere, Circ, Frustum, Grid, Mat3, Mat4, Mat4x3, NumArray, Quat, Rand, Ray3 as Ray, Rect, RollingAverage, Plane as SpatialPlane, Time, Trigo, Utils, Vec2, Vec3 } from '@1pizzateam/spock';
|
|
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
29
|
|
|
30
30
|
declare class SceneRenderer {
|
|
31
31
|
context: WebGLRenderingContext;
|
|
@@ -34,6 +34,7 @@ declare class SceneRenderer {
|
|
|
34
34
|
private depthWrite;
|
|
35
35
|
constructor(context: WebGLRenderingContext);
|
|
36
36
|
invalidateState(): void;
|
|
37
|
+
reset(): void;
|
|
37
38
|
defaultSettings(): void;
|
|
38
39
|
enable(capability: string): void;
|
|
39
40
|
disable(capability: string): void;
|
|
@@ -58,6 +59,62 @@ declare class SceneGraph {
|
|
|
58
59
|
getWorldMatrix(): Mat4x3;
|
|
59
60
|
}
|
|
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
|
+
|
|
61
118
|
type TextureSource = HTMLImageElement | HTMLCanvasElement | ImageData | ImageBitmap | Uint8Array;
|
|
62
119
|
interface ITextureOptions {
|
|
63
120
|
wrapS?: number;
|
|
@@ -66,13 +123,12 @@ interface ITextureOptions {
|
|
|
66
123
|
magFilter?: number;
|
|
67
124
|
flipY?: boolean;
|
|
68
125
|
generateMipmaps?: boolean;
|
|
69
|
-
|
|
70
|
-
height?: number;
|
|
126
|
+
size?: Vec2;
|
|
71
127
|
}
|
|
72
128
|
declare const Texture: {
|
|
73
129
|
create(source: TextureSource, context: WebGLRenderingContext, options?: ITextureOptions): WebGLTexture | null;
|
|
74
130
|
load(url: string, context: WebGLRenderingContext, options?: ITextureOptions): Promise<WebGLTexture | null>;
|
|
75
|
-
update(texture: WebGLTexture, source: TextureSource, context: WebGLRenderingContext,
|
|
131
|
+
update(texture: WebGLTexture, source: TextureSource, context: WebGLRenderingContext, offset?: Vec2, size?: Vec2, flipY?: boolean): void;
|
|
76
132
|
};
|
|
77
133
|
|
|
78
134
|
type UniformValue = number | number[] | Float32Array | Int32Array | Vec2 | Vec3 | Quat | Mat3 | Mat4 | Mat4x3;
|
|
@@ -82,8 +138,6 @@ declare class Uniform {
|
|
|
82
138
|
constructor(type: string, value: UniformValue);
|
|
83
139
|
}
|
|
84
140
|
|
|
85
|
-
type Vec3Like = Vec3 | ArrayLike<number>;
|
|
86
|
-
|
|
87
141
|
declare class SubMesh {
|
|
88
142
|
start: number;
|
|
89
143
|
count: number;
|
|
@@ -96,25 +150,33 @@ declare class GLState {
|
|
|
96
150
|
elementBuffer: WebGLBuffer | null;
|
|
97
151
|
attributeMask: number | null;
|
|
98
152
|
maxAttributes: number;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
153
|
+
frameOfProgram: WeakMap<object, number>;
|
|
154
|
+
materialOfProgram: WeakMap<object, object>;
|
|
155
|
+
materialVersionOfProgram: WeakMap<object, number>;
|
|
102
156
|
invalidate(): void;
|
|
157
|
+
reset(): void;
|
|
103
158
|
}
|
|
104
159
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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;
|
|
118
180
|
}
|
|
119
181
|
|
|
120
182
|
interface IGeometry {
|
|
@@ -232,35 +294,31 @@ interface IFlatLights {
|
|
|
232
294
|
[key: string]: any;
|
|
233
295
|
}
|
|
234
296
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
updateUniforms(): boolean;
|
|
254
|
-
private sync;
|
|
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;
|
|
255
315
|
}
|
|
256
316
|
|
|
257
317
|
declare enum eDrawMethod {
|
|
258
318
|
drawElements = "drawElements",
|
|
259
319
|
drawArrays = "drawArrays"
|
|
260
320
|
}
|
|
261
|
-
declare class Mesh implements IMesh {
|
|
262
|
-
boundingBox: Box;
|
|
263
|
-
boundingSphere: Sphere$1;
|
|
321
|
+
declare class Mesh extends Node<Mesh> implements IMesh {
|
|
264
322
|
vertices: number[] | Float32Array | null;
|
|
265
323
|
indices: number[] | Int32Array | Uint16Array | null;
|
|
266
324
|
normals: number[] | Float32Array | null;
|
|
@@ -277,44 +335,17 @@ declare class Mesh implements IMesh {
|
|
|
277
335
|
indexBuffer: WebGLBuffer | null;
|
|
278
336
|
normalBuffer: WebGLBuffer | null;
|
|
279
337
|
texCoordBuffer: WebGLBuffer | null;
|
|
280
|
-
position: Vec3;
|
|
281
|
-
scale: Vec3;
|
|
282
|
-
quaternion: Quat;
|
|
283
|
-
modelMatrix: Mat4x3;
|
|
284
|
-
worldMatrix: Mat4x3;
|
|
285
|
-
normalMatrix: Mat3;
|
|
286
|
-
parent: Mesh | null;
|
|
287
|
-
traversalStamp: number;
|
|
288
338
|
sortKey: number;
|
|
289
|
-
private _rotation;
|
|
290
|
-
private isRotationStale;
|
|
291
|
-
private isTransformDirty;
|
|
292
|
-
private isWorldDirty;
|
|
293
339
|
private ownsTexture;
|
|
294
|
-
private
|
|
295
|
-
private
|
|
296
|
-
|
|
297
|
-
private static readonly scratchView;
|
|
298
|
-
private static readonly scratchVec;
|
|
299
|
-
private static readonly scratchCamera;
|
|
300
|
-
private static readonly scratchDir;
|
|
301
|
-
private static readonly scratchA;
|
|
302
|
-
private static readonly scratchB;
|
|
303
|
-
private static readonly scratchC;
|
|
340
|
+
private textureSource;
|
|
341
|
+
private textureOptions;
|
|
342
|
+
indexType: number;
|
|
304
343
|
private static readonly scratchHit;
|
|
305
|
-
private static readonly scratchWorldHit;
|
|
306
|
-
private static readonly scratchInverse;
|
|
307
|
-
private static readonly scratchRay;
|
|
308
|
-
isBoundsDirty: boolean;
|
|
309
|
-
isNormalMatrixDirty: boolean;
|
|
310
|
-
localBoundingBox: Box;
|
|
311
|
-
localBoundingSphere: Sphere$1;
|
|
312
344
|
active: boolean;
|
|
313
345
|
drawMethod: eDrawMethod;
|
|
314
346
|
programs: IProgram[];
|
|
315
347
|
nbPrograms: number;
|
|
316
348
|
materials: Material[];
|
|
317
|
-
children: Mesh[];
|
|
318
349
|
blendMode: boolean;
|
|
319
350
|
blendOptions: IBlendOptions;
|
|
320
351
|
depthWrite: boolean;
|
|
@@ -324,61 +355,29 @@ declare class Mesh implements IMesh {
|
|
|
324
355
|
setInactive(): void;
|
|
325
356
|
toggleActive(): boolean;
|
|
326
357
|
isActive(): boolean;
|
|
327
|
-
addChild(mesh: Mesh): void;
|
|
328
|
-
removeChild(mesh: Mesh): boolean;
|
|
329
358
|
addProgram(vertexShaderOrProgram: string | WebGLProgram, fragmentShaderOrMaterial?: string | Material, material?: Material): boolean;
|
|
330
359
|
clearPrograms(): void;
|
|
331
360
|
addMaterial(material: Material): boolean;
|
|
332
|
-
markDirty(): void;
|
|
333
|
-
get rotation(): Vec3;
|
|
334
|
-
set rotation(euler: Vec3);
|
|
335
|
-
private rotationChanged;
|
|
336
|
-
setPosition(xOrVec: Vec3Like | number, y?: number, z?: number): this;
|
|
337
|
-
setRotation(xOrVec: Vec3Like | number, y?: number, z?: number): this;
|
|
338
|
-
setScale(xOrVec: Vec3Like | number, y?: number, z?: number): this;
|
|
339
|
-
scaleBy(factorOrVec: Vec3 | number): this;
|
|
340
|
-
setQuaternion(q: Quat): this;
|
|
341
|
-
slerp(targetQuat: Quat, t: number): this;
|
|
342
|
-
rotateX(angle: number): this;
|
|
343
|
-
rotateY(angle: number): this;
|
|
344
|
-
rotateZ(angle: number): this;
|
|
345
|
-
rotateOnAxis(axis: Vec3, angle: number): this;
|
|
346
|
-
translate(xOrVec: Vec3Like | number, y?: number, z?: number): this;
|
|
347
|
-
lookAt(target: Vec3, up?: Vec3): this;
|
|
348
|
-
updateModelMatrix(): boolean;
|
|
349
|
-
computeNormalMatrix(): Mat3;
|
|
350
|
-
getWorldPosition(target?: Vec3): Vec3;
|
|
351
|
-
getWorldDirection(target?: Vec3): Vec3;
|
|
352
|
-
distanceTo(target: Mesh | Vec3): number;
|
|
353
|
-
isInsideBounds(min: Vec3, max: Vec3): boolean;
|
|
354
|
-
computeBounds(): void;
|
|
355
|
-
computeBoundingBox(): Box;
|
|
356
|
-
computeBoundingSphere(): Sphere$1;
|
|
357
361
|
raycast(ray: Ray3, precise?: boolean): {
|
|
358
362
|
distance: number;
|
|
359
363
|
point: Vec3;
|
|
360
364
|
} | null;
|
|
361
|
-
private raycastTriangles;
|
|
362
|
-
private getVertex;
|
|
363
365
|
useBasicMaterial(options?: IMaterialShortcutOptions): this;
|
|
364
366
|
usePhongMaterial(options?: IPhongShortcutOptions): this;
|
|
365
367
|
useNormalMaterial(): this;
|
|
366
368
|
private applyTextureOption;
|
|
367
369
|
private releaseTexture;
|
|
368
|
-
setWorldMatrix(worldMatrix: Mat4x3): void;
|
|
369
370
|
setTexture(img: TextureSource, options?: ITextureOptions): void;
|
|
370
371
|
addCustomUniform(name: string, type: string, value: UniformValue): void;
|
|
371
372
|
setCustomUniform(name: string, value: UniformValue): void;
|
|
372
373
|
private createIndexData;
|
|
373
|
-
private
|
|
374
|
+
private createBuffers;
|
|
375
|
+
restore(): void;
|
|
374
376
|
private createProgram;
|
|
375
|
-
private addProgramAttribute;
|
|
376
|
-
private addProgramUniform;
|
|
377
377
|
activateBlendMode(): void;
|
|
378
378
|
deactivateBlendMode(): void;
|
|
379
379
|
setBlend(source?: string, destination?: string, equation?: string): this;
|
|
380
380
|
setDepthWrite(enabled: boolean): this;
|
|
381
|
-
computeWorldMatrix(graph: SceneGraph): void;
|
|
382
381
|
render(projectionMatrix: Float32Array, viewMatrix: Float32Array, lights: IFlatLights, time: number, blendMode: boolean, cameraPosition?: Vec3, fog?: {
|
|
383
382
|
color: Vec3;
|
|
384
383
|
near: number;
|
|
@@ -389,89 +388,82 @@ declare class Mesh implements IMesh {
|
|
|
389
388
|
near: number;
|
|
390
389
|
far: number;
|
|
391
390
|
} | null, frame?: IFrameInfo): void;
|
|
392
|
-
private static lightTypeValue;
|
|
393
|
-
private static packVec4;
|
|
394
|
-
private uploadFrameUniforms;
|
|
395
391
|
destroy(): void;
|
|
396
|
-
private ucfirst;
|
|
397
392
|
}
|
|
398
393
|
interface IMaterialShortcutOptions {
|
|
399
|
-
color?:
|
|
394
|
+
color?: Vec3;
|
|
400
395
|
texture?: HTMLImageElement | HTMLCanvasElement | WebGLTexture;
|
|
401
396
|
}
|
|
402
397
|
interface IPhongShortcutOptions {
|
|
403
|
-
ambient?:
|
|
404
|
-
diffuse?:
|
|
405
|
-
specular?:
|
|
398
|
+
ambient?: Vec3;
|
|
399
|
+
diffuse?: Vec3;
|
|
400
|
+
specular?: Vec3;
|
|
406
401
|
shininess?: number;
|
|
407
402
|
texture?: HTMLImageElement | HTMLCanvasElement | WebGLTexture;
|
|
408
403
|
}
|
|
409
404
|
|
|
410
405
|
type Light = 'directional' | 'point' | 'spot' | 'ambient';
|
|
411
406
|
|
|
407
|
+
interface IDirectionalLightOptions {
|
|
408
|
+
direction?: Vec3;
|
|
409
|
+
diffuse?: Vec3;
|
|
410
|
+
specular?: Vec3;
|
|
411
|
+
position?: Vec3;
|
|
412
|
+
}
|
|
412
413
|
declare class DirectionalLight {
|
|
413
414
|
position: Vec3;
|
|
414
415
|
diffuse: Vec3;
|
|
415
416
|
specular: Vec3;
|
|
416
417
|
direction: Vec3;
|
|
417
418
|
type: Light;
|
|
418
|
-
constructor(directionOrOptions?: Vec3 |
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
});
|
|
424
|
-
setPosition(xOrVec: Vec3Like | number, y?: number, z?: number): void;
|
|
425
|
-
setDirection(xOrVec: Vec3Like | number, y?: number, z?: number): void;
|
|
426
|
-
setDiffuse(xOrVec: Vec3Like | number, y?: number, z?: number): void;
|
|
427
|
-
setSpecular(xOrVec: Vec3Like | number, y?: number, z?: number): void;
|
|
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;
|
|
428
424
|
}
|
|
429
425
|
|
|
426
|
+
interface IPointLightOptions {
|
|
427
|
+
position?: Vec3;
|
|
428
|
+
diffuse?: Vec3;
|
|
429
|
+
specular?: Vec3;
|
|
430
|
+
constantAttenuation?: number;
|
|
431
|
+
linearAttenuation?: number;
|
|
432
|
+
quadraticAttenuation?: number;
|
|
433
|
+
}
|
|
430
434
|
declare class PointLight extends DirectionalLight {
|
|
431
435
|
constantAttenuation: number;
|
|
432
436
|
linearAttenuation: number;
|
|
433
437
|
quadraticAttenuation: number;
|
|
434
|
-
constructor(positionOrOptions?: Vec3 |
|
|
435
|
-
position?: Vec3 | number[];
|
|
436
|
-
diffuse?: Vec3 | number[];
|
|
437
|
-
specular?: Vec3 | number[];
|
|
438
|
-
constantAttenuation?: number;
|
|
439
|
-
linearAttenuation?: number;
|
|
440
|
-
quadraticAttenuation?: number;
|
|
441
|
-
});
|
|
438
|
+
constructor(positionOrOptions?: Vec3 | IPointLightOptions);
|
|
442
439
|
setConstantAttenuation(value: number): void;
|
|
443
440
|
setLinearAttenuation(value: number): void;
|
|
444
441
|
setQuadraticAttenuation(value: number): void;
|
|
445
442
|
}
|
|
446
443
|
|
|
444
|
+
interface ISpotLightOptions extends IPointLightOptions {
|
|
445
|
+
direction?: Vec3;
|
|
446
|
+
cutoff?: number;
|
|
447
|
+
exponent?: number;
|
|
448
|
+
}
|
|
447
449
|
declare class SpotLight extends PointLight {
|
|
448
450
|
cutoff: number;
|
|
449
451
|
exponent: number;
|
|
450
452
|
direction: Vec3;
|
|
451
|
-
constructor(positionOrOptions?: Vec3 |
|
|
452
|
-
position?: Vec3 | number[];
|
|
453
|
-
direction?: Vec3 | number[];
|
|
454
|
-
diffuse?: Vec3 | number[];
|
|
455
|
-
specular?: Vec3 | number[];
|
|
456
|
-
cutoff?: number;
|
|
457
|
-
exponent?: number;
|
|
458
|
-
constantAttenuation?: number;
|
|
459
|
-
linearAttenuation?: number;
|
|
460
|
-
quadraticAttenuation?: number;
|
|
461
|
-
});
|
|
453
|
+
constructor(positionOrOptions?: Vec3 | ISpotLightOptions);
|
|
462
454
|
setCutoff(value: number): void;
|
|
463
455
|
setExponent(value: number): void;
|
|
464
|
-
setDirection(
|
|
456
|
+
setDirection(direction: Vec3): void;
|
|
465
457
|
}
|
|
466
458
|
|
|
467
459
|
declare class AmbientLight {
|
|
468
460
|
diffuse: Vec3;
|
|
469
461
|
intensity: number;
|
|
470
462
|
type: Light;
|
|
471
|
-
constructor(
|
|
472
|
-
setColor(
|
|
463
|
+
constructor(diffuse?: Vec3, intensity?: number);
|
|
464
|
+
setColor(diffuse: Vec3): this;
|
|
473
465
|
setIntensity(intensity: number): this;
|
|
474
|
-
getColor(): Vec3;
|
|
466
|
+
getColor(target?: Vec3): Vec3;
|
|
475
467
|
get color(): Vec3;
|
|
476
468
|
set color(c: Vec3);
|
|
477
469
|
}
|
|
@@ -479,7 +471,6 @@ declare class AmbientLight {
|
|
|
479
471
|
type AnyLight = DirectionalLight | PointLight | SpotLight | AmbientLight;
|
|
480
472
|
declare const MAX_LIGHTS = 8;
|
|
481
473
|
declare class Lights {
|
|
482
|
-
private static _ambient;
|
|
483
474
|
private warnedOverflow;
|
|
484
475
|
directionals: DirectionalLight[];
|
|
485
476
|
points: PointLight[];
|
|
@@ -493,9 +484,6 @@ declare class Lights {
|
|
|
493
484
|
constructor();
|
|
494
485
|
addLight(light: AnyLight): void;
|
|
495
486
|
removeLight(light: AnyLight): boolean;
|
|
496
|
-
private ClearFlatArrays;
|
|
497
|
-
private ensureBuffers;
|
|
498
|
-
private push;
|
|
499
487
|
flatten(extraAmbient?: Vec3): IFlatLights;
|
|
500
488
|
clear(): void;
|
|
501
489
|
getFlatArray(property: string): (number | string)[] | undefined;
|
|
@@ -521,11 +509,11 @@ declare class Camera {
|
|
|
521
509
|
setViewMatrix(): void;
|
|
522
510
|
setProjectionMatrix(): void;
|
|
523
511
|
private invalidateProjectionView;
|
|
524
|
-
getProjectionViewMatrix():
|
|
512
|
+
getProjectionViewMatrix(): Mat4;
|
|
525
513
|
getInverseProjectionViewMatrix(): Mat4;
|
|
526
|
-
setPosition(
|
|
527
|
-
setTarget(
|
|
528
|
-
setUp(
|
|
514
|
+
setPosition(position: Vec3): void;
|
|
515
|
+
setTarget(target: Vec3): void;
|
|
516
|
+
setUp(up: Vec3): void;
|
|
529
517
|
lookAt(target: Vec3): void;
|
|
530
518
|
getViewDirection(target?: Vec3): Vec3;
|
|
531
519
|
getDistance(): number;
|
|
@@ -534,23 +522,30 @@ declare class Camera {
|
|
|
534
522
|
getProjectionMatrix(): Float32Array;
|
|
535
523
|
getViewMatrixObject(): Mat4x3;
|
|
536
524
|
getProjectionMatrixObject(): Mat4;
|
|
537
|
-
getRay(
|
|
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;
|
|
538
535
|
}
|
|
539
536
|
|
|
540
537
|
interface ISceneOptions {
|
|
541
538
|
canvasId?: string | HTMLCanvasElement;
|
|
542
539
|
context?: WebGLRenderingContext;
|
|
543
540
|
viewport?: {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
};
|
|
549
|
-
clearColor?: Vec3 | number[];
|
|
541
|
+
position?: Vec2;
|
|
542
|
+
size: Vec2;
|
|
543
|
+
} | Vec2;
|
|
544
|
+
clearColor?: Vec3;
|
|
550
545
|
cullFace?: 'BACK' | 'FRONT' | 'NONE';
|
|
551
546
|
frontFace?: 'CCW' | 'CW';
|
|
552
547
|
depthTest?: boolean;
|
|
553
|
-
ambientColor?:
|
|
548
|
+
ambientColor?: Vec3;
|
|
554
549
|
fog?: {
|
|
555
550
|
color: Vec3;
|
|
556
551
|
near: number;
|
|
@@ -572,29 +567,28 @@ declare class Scene {
|
|
|
572
567
|
context: WebGLRenderingContext;
|
|
573
568
|
renderer: SceneRenderer;
|
|
574
569
|
graph: SceneGraph;
|
|
570
|
+
collector: SceneCollector;
|
|
575
571
|
resolution: Vec2;
|
|
576
|
-
private scratchFrustum;
|
|
577
|
-
private scratchVec;
|
|
578
572
|
private frame;
|
|
579
573
|
private frameCounter;
|
|
580
574
|
private traversalStamp;
|
|
581
|
-
private opaqueList;
|
|
582
|
-
private blendedList;
|
|
583
575
|
constructor(contextOrOptions: WebGLRenderingContext | ISceneOptions);
|
|
584
576
|
private static contextFromCanvas;
|
|
585
|
-
setViewport(
|
|
586
|
-
|
|
577
|
+
setViewport(size: Vec2, position?: Vec2): void;
|
|
578
|
+
getSize(target?: Vec2): Vec2;
|
|
579
|
+
setClearColor(color: Vec3, alpha?: number): void;
|
|
580
|
+
setSize(size: Vec2): void;
|
|
587
581
|
clear(color?: boolean, depth?: boolean): void;
|
|
588
582
|
addMesh(mesh: Mesh): void;
|
|
589
583
|
removeMesh(mesh: Mesh): boolean;
|
|
590
584
|
addLight(light: AnyLight): void;
|
|
591
585
|
removeLight(light: AnyLight): boolean;
|
|
592
|
-
setAmbientColor(
|
|
593
|
-
setFog(color:
|
|
594
|
-
setFog(r: number, g: number, b: number, near?: number, far?: number): this;
|
|
586
|
+
setAmbientColor(color: Vec3): this;
|
|
587
|
+
setFog(color: Vec3, near: number, far?: number): this;
|
|
595
588
|
clearFog(): this;
|
|
596
589
|
clearMeshes(): void;
|
|
597
590
|
clearLights(): void;
|
|
591
|
+
restore(): void;
|
|
598
592
|
destroy(destroyMeshes?: boolean): void;
|
|
599
593
|
getLightsProperty(property: string): (number | string)[] | undefined;
|
|
600
594
|
enableBlendMode(equation: string, source: string, destination: string): void;
|
|
@@ -609,14 +603,11 @@ declare class Scene {
|
|
|
609
603
|
private markDescendants;
|
|
610
604
|
private computeWorldMatrices;
|
|
611
605
|
private beginFrame;
|
|
612
|
-
private collect;
|
|
613
|
-
private drawBlended;
|
|
614
606
|
renderBlended(camera: Camera, time?: number, flatLights?: IFlatLights, frustum?: Frustum | null): number;
|
|
615
607
|
}
|
|
616
608
|
|
|
617
609
|
interface IRendererOptions {
|
|
618
|
-
|
|
619
|
-
height?: number;
|
|
610
|
+
size?: Vec2;
|
|
620
611
|
contextAttributes?: WebGLContextAttributes;
|
|
621
612
|
onContextLost?: () => void;
|
|
622
613
|
onContextRestored?: () => void;
|
|
@@ -635,12 +626,13 @@ declare class Renderer {
|
|
|
635
626
|
enable(capability: string): void;
|
|
636
627
|
disable(capability: string): void;
|
|
637
628
|
setCullFace(mode: string): void;
|
|
638
|
-
setViewport(
|
|
639
|
-
setClearColor(
|
|
629
|
+
setViewport(size: Vec2): void;
|
|
630
|
+
setClearColor(color: Vec3, alpha?: number): void;
|
|
640
631
|
clearFrame(): void;
|
|
641
632
|
getContext(): WebGLRenderingContext | null;
|
|
642
633
|
getCanvas(): HTMLCanvasElement | null;
|
|
643
|
-
setSize(
|
|
634
|
+
setSize(size: Vec2): void;
|
|
635
|
+
getSize(target?: Vec2): Vec2;
|
|
644
636
|
private findById;
|
|
645
637
|
}
|
|
646
638
|
|
|
@@ -651,12 +643,13 @@ declare class RenderTarget {
|
|
|
651
643
|
framebuffer: WebGLFramebuffer | null;
|
|
652
644
|
texture: WebGLTexture | null;
|
|
653
645
|
depthBuffer: WebGLRenderbuffer | null;
|
|
654
|
-
constructor(
|
|
646
|
+
constructor(size: Vec2, context: WebGLRenderingContext);
|
|
647
|
+
restore(): void;
|
|
655
648
|
private init;
|
|
656
649
|
bind(): void;
|
|
657
|
-
unbind(
|
|
650
|
+
unbind(viewportSize?: Vec2): void;
|
|
658
651
|
getSize(target?: Vec2): Vec2;
|
|
659
|
-
setSize(
|
|
652
|
+
setSize(size: Vec2): void;
|
|
660
653
|
dispose(): void;
|
|
661
654
|
}
|
|
662
655
|
|
|
@@ -665,10 +658,11 @@ declare class PerspectiveCamera extends Camera {
|
|
|
665
658
|
ratio: number;
|
|
666
659
|
zNear: number;
|
|
667
660
|
zFar: number;
|
|
668
|
-
constructor(fov: number,
|
|
669
|
-
setProjectionMatrix(viewport?: Vec2 |
|
|
661
|
+
constructor(fov: number, nearFar?: Vec2, context?: WebGLRenderingContext | null);
|
|
662
|
+
setProjectionMatrix(viewport?: Vec2 | null): void;
|
|
670
663
|
setFov(fov: number): void;
|
|
671
|
-
setNearFar(
|
|
664
|
+
setNearFar(nearFar: Vec2): void;
|
|
665
|
+
getNearFar(target?: Vec2): Vec2;
|
|
672
666
|
}
|
|
673
667
|
|
|
674
668
|
declare class OrthographicCamera extends Camera {
|
|
@@ -678,9 +672,10 @@ declare class OrthographicCamera extends Camera {
|
|
|
678
672
|
bottom: number;
|
|
679
673
|
near: number;
|
|
680
674
|
far: number;
|
|
681
|
-
constructor(
|
|
675
|
+
constructor(bounds: Rect, nearFar?: Vec2);
|
|
682
676
|
setProjectionMatrix(): void;
|
|
683
|
-
setBounds(
|
|
677
|
+
setBounds(bounds: Rect, nearFar?: Vec2): void;
|
|
678
|
+
getNearFar(target?: Vec2): Vec2;
|
|
684
679
|
}
|
|
685
680
|
|
|
686
681
|
declare class OrbitControls {
|
|
@@ -740,10 +735,10 @@ declare class OrbitControls {
|
|
|
740
735
|
}
|
|
741
736
|
|
|
742
737
|
declare class BasicMesh implements IGeometry {
|
|
743
|
-
vertices: number[] | null;
|
|
744
|
-
indices: number[] | null;
|
|
745
|
-
normals: number[] | null;
|
|
746
|
-
uvs: number[] | null;
|
|
738
|
+
vertices: number[] | Float32Array | null;
|
|
739
|
+
indices: number[] | Int32Array | Uint16Array | null;
|
|
740
|
+
normals: number[] | Float32Array | null;
|
|
741
|
+
uvs: number[] | Float32Array | null;
|
|
747
742
|
subMeshes: SubMesh[];
|
|
748
743
|
itemSize: number;
|
|
749
744
|
primitive: string;
|
|
@@ -756,7 +751,8 @@ declare class Line extends BasicMesh {
|
|
|
756
751
|
subMeshes: SubMesh[];
|
|
757
752
|
itemSize: number;
|
|
758
753
|
primitive: string;
|
|
759
|
-
constructor(vertices
|
|
754
|
+
constructor(vertices?: Vec3[], thickness?: number);
|
|
755
|
+
setPoints(vertices: Vec3[]): this;
|
|
760
756
|
}
|
|
761
757
|
|
|
762
758
|
declare class FullscreenQuad extends BasicMesh {
|
|
@@ -770,7 +766,7 @@ declare class Quad extends BasicMesh {
|
|
|
770
766
|
subMeshes: SubMesh[];
|
|
771
767
|
itemSize: number;
|
|
772
768
|
primitive: string;
|
|
773
|
-
constructor(
|
|
769
|
+
constructor(size?: Vec2 | Rect);
|
|
774
770
|
}
|
|
775
771
|
|
|
776
772
|
interface IQuad {
|
|
@@ -783,17 +779,17 @@ declare class MultiQuad extends BasicMesh {
|
|
|
783
779
|
indices: number[];
|
|
784
780
|
uvs: number[];
|
|
785
781
|
quad: IQuad;
|
|
786
|
-
constructor(
|
|
782
|
+
constructor(size?: Vec2 | Rect);
|
|
787
783
|
createQuads(length: number): void;
|
|
788
784
|
private createIndices;
|
|
789
785
|
}
|
|
790
786
|
|
|
791
787
|
declare class Cube extends BasicMesh {
|
|
792
|
-
constructor(
|
|
788
|
+
constructor(size?: Vec3, flat?: boolean);
|
|
793
789
|
}
|
|
794
790
|
|
|
795
791
|
declare class Sphere extends BasicMesh {
|
|
796
|
-
constructor();
|
|
792
|
+
constructor(scale?: Vec3);
|
|
797
793
|
}
|
|
798
794
|
|
|
799
795
|
declare class Hemisphere extends BasicMesh {
|
|
@@ -801,11 +797,11 @@ declare class Hemisphere extends BasicMesh {
|
|
|
801
797
|
}
|
|
802
798
|
|
|
803
799
|
declare class Plane extends BasicMesh {
|
|
804
|
-
constructor(
|
|
800
|
+
constructor(size?: Vec2, segments?: Vec2, orientation?: 'xy' | 'xz');
|
|
805
801
|
}
|
|
806
802
|
|
|
807
803
|
declare class Cylinder extends BasicMesh {
|
|
808
|
-
constructor(
|
|
804
|
+
constructor(radii?: Vec2, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean);
|
|
809
805
|
}
|
|
810
806
|
|
|
811
807
|
declare class VWing extends BasicMesh {
|
|
@@ -827,9 +823,9 @@ declare class CustomMesh implements IGeometry {
|
|
|
827
823
|
primitives: string[];
|
|
828
824
|
constructor();
|
|
829
825
|
private static toFloat32;
|
|
830
|
-
setVertices(array: Vec3[]
|
|
826
|
+
setVertices(array: Vec3[]): void;
|
|
831
827
|
setIndices(array: Int32Array | number[]): void;
|
|
832
|
-
setNormals(array: Vec3[]
|
|
828
|
+
setNormals(array: Vec3[]): void;
|
|
833
829
|
setUvs(array: Float32Array | number[]): void;
|
|
834
830
|
addSubMeshes(array: Float32Array | Int32Array | number[]): void;
|
|
835
831
|
addSubMesh(start: number, count: number): void;
|
|
@@ -847,12 +843,72 @@ declare class CustomMesh implements IGeometry {
|
|
|
847
843
|
computeVertexNormals(): Float32Array | null;
|
|
848
844
|
}
|
|
849
845
|
|
|
850
|
-
declare
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
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;
|
|
854
899
|
}
|
|
855
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
|
+
|
|
856
912
|
type ShaderType = 'VERTEX_SHADER' | 'FRAGMENT_SHADER';
|
|
857
913
|
declare const Shader: {
|
|
858
914
|
create(context: WebGLRenderingContext, str: string, type: ShaderType): WebGLShader | null;
|
|
@@ -863,16 +919,23 @@ declare const BasicShader: {
|
|
|
863
919
|
fragment: string;
|
|
864
920
|
create(context: WebGLRenderingContext): WebGLProgram | null;
|
|
865
921
|
};
|
|
866
|
-
|
|
922
|
+
|
|
923
|
+
declare const PhongShader: {
|
|
867
924
|
vertex: string;
|
|
868
925
|
fragment: string;
|
|
869
926
|
create(context: WebGLRenderingContext): WebGLProgram | null;
|
|
870
927
|
};
|
|
871
|
-
|
|
928
|
+
|
|
929
|
+
declare const NormalShader: {
|
|
872
930
|
vertex: string;
|
|
873
931
|
fragment: string;
|
|
874
932
|
create(context: WebGLRenderingContext): WebGLProgram | null;
|
|
875
933
|
};
|
|
876
934
|
|
|
877
|
-
|
|
878
|
-
|
|
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 };
|