@luma.gl/constants 9.0.0-alpha.3 → 9.0.0-alpha.30

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.
@@ -0,0 +1,336 @@
1
+ // luma.gl, MIT license
2
+
3
+ import {GL} from './constants-enum';
4
+
5
+ /* eslint-disable camelcase */ // TODO is this needed?
6
+
7
+ /** TypeScript type covering all typed arrays */
8
+ export type TypedArray =
9
+ | Int8Array
10
+ | Uint8Array
11
+ | Int16Array
12
+ | Uint16Array
13
+ | Int32Array
14
+ | Uint32Array
15
+ | Uint8ClampedArray
16
+ | Float32Array
17
+ | Float64Array;
18
+
19
+ /** type covering all typed arrays and classic arrays consisting of numbers */
20
+ export type NumberArray = number[] | TypedArray;
21
+
22
+ /** We don't know the type of Framebuffer at this stage */
23
+ type Framebuffer = unknown;
24
+
25
+ /** Rendering primitives. Constants passed to drawElements() or drawArrays() to specify what kind of primitive to render. */
26
+ export type GLPrimitiveTopology =
27
+ | GL.POINTS
28
+ | GL.LINES
29
+ | GL.LINE_STRIP
30
+ | GL.LINE_LOOP
31
+ | GL.TRIANGLES
32
+ | GL.TRIANGLE_STRIP
33
+ | GL.TRIANGLE_FAN;
34
+
35
+ /** Rendering primitives. Constants passed to transform feedback . */
36
+ export type GLPrimitive = GL.POINTS | GL.LINES | GL.TRIANGLES;
37
+
38
+ /** Data Type */
39
+ export type GLDataType =
40
+ | GL.FLOAT
41
+ | GL.UNSIGNED_SHORT
42
+ | GL.UNSIGNED_INT
43
+ | GL.UNSIGNED_BYTE
44
+ | GL.BYTE
45
+ | GL.SHORT
46
+ | GL.INT;
47
+
48
+ /** Pixel Type */
49
+ export type GLPixelType =
50
+ | GL.UNSIGNED_BYTE
51
+ | GL.UNSIGNED_SHORT_5_6_5
52
+ | GL.UNSIGNED_SHORT_4_4_4_4
53
+ | GL.UNSIGNED_SHORT_5_5_5_1;
54
+
55
+ /** Uniform Type */
56
+ export type GLUniformType = GLSamplerType | GLCompositeType;
57
+
58
+ /** Sampler uniform type */
59
+ export type GLSamplerType =
60
+ | GL.SAMPLER_2D
61
+ | GL.SAMPLER_CUBE
62
+ | GL.SAMPLER_3D
63
+ | GL.SAMPLER_2D_SHADOW
64
+ | GL.SAMPLER_2D_ARRAY
65
+ | GL.SAMPLER_2D_ARRAY_SHADOW
66
+ | GL.SAMPLER_CUBE_SHADOW
67
+ | GL.INT_SAMPLER_2D
68
+ | GL.INT_SAMPLER_3D
69
+ | GL.INT_SAMPLER_CUBE
70
+ | GL.INT_SAMPLER_2D_ARRAY
71
+ | GL.UNSIGNED_INT_SAMPLER_2D
72
+ | GL.UNSIGNED_INT_SAMPLER_3D
73
+ | GL.UNSIGNED_INT_SAMPLER_CUBE
74
+ | GL.UNSIGNED_INT_SAMPLER_2D_ARRAY;
75
+
76
+ /** Composite types table */
77
+ export type GLCompositeType =
78
+ | GL.FLOAT
79
+ | GL.FLOAT_VEC2
80
+ | GL.FLOAT_VEC3
81
+ | GL.FLOAT_VEC4
82
+ | GL.INT
83
+ | GL.INT_VEC2
84
+ | GL.INT_VEC3
85
+ | GL.INT_VEC4
86
+ | GL.UNSIGNED_INT
87
+ | GL.UNSIGNED_INT_VEC2
88
+ | GL.UNSIGNED_INT_VEC3
89
+ | GL.UNSIGNED_INT_VEC4
90
+ | GL.BOOL
91
+ | GL.BOOL_VEC2
92
+ | GL.BOOL_VEC3
93
+ | GL.BOOL_VEC4
94
+ | GL.FLOAT_MAT2
95
+ | GL.FLOAT_MAT2x3
96
+ | GL.FLOAT_MAT2x4
97
+ | GL.FLOAT_MAT3x2
98
+ | GL.FLOAT_MAT3
99
+ | GL.FLOAT_MAT3x4
100
+ | GL.FLOAT_MAT4x2
101
+ | GL.FLOAT_MAT4x3
102
+ | GL.FLOAT_MAT4;
103
+
104
+ /**
105
+ * Depth or stencil tests
106
+ * Constants passed to WebGLRenderingContext.depthFunc() or WebGLRenderingContext.stencilFunc().
107
+ */
108
+ export type GLFunction =
109
+ | GL.NEVER
110
+ | GL.LESS
111
+ | GL.EQUAL
112
+ | GL.LEQUAL
113
+ | GL.GREATER
114
+ | GL.NOTEQUAL
115
+ | GL.GEQUAL
116
+ | GL.ALWAYS;
117
+
118
+ export type GLBlendEquation =
119
+ | GL.FUNC_ADD
120
+ | GL.FUNC_SUBTRACT
121
+ | GL.FUNC_REVERSE_SUBTRACT
122
+ | GL.MIN_EXT
123
+ | GL.MAX_EXT;
124
+
125
+ export type GLBlendFunction =
126
+ | GL.ZERO
127
+ | GL.ONE
128
+ | GL.SRC_COLOR
129
+ | GL.ONE_MINUS_SRC_COLOR
130
+ | GL.DST_COLOR
131
+ | GL.ONE_MINUS_DST_COLOR
132
+ | GL.SRC_ALPHA
133
+ | GL.ONE_MINUS_SRC_ALPHA
134
+ | GL.DST_ALPHA
135
+ | GL.ONE_MINUS_DST_ALPHA
136
+ | GL.CONSTANT_COLOR
137
+ | GL.ONE_MINUS_CONSTANT_COLOR
138
+ | GL.CONSTANT_ALPHA
139
+ | GL.ONE_MINUS_CONSTANT_ALPHA
140
+ | GL.SRC_ALPHA_SATURATE;
141
+
142
+ /**
143
+ * Stencil actions
144
+ * Constants passed to WebGLRenderingContext.stencilOp().
145
+ */
146
+ export type GLStencilOp =
147
+ | GL.KEEP
148
+ | GL.ZERO
149
+ | GL.REPLACE
150
+ | GL.INCR
151
+ | GL.INCR_WRAP
152
+ | GL.DECR
153
+ | GL.DECR_WRAP
154
+ | GL.INVERT;
155
+
156
+ /** Parameters for textures and samplers */
157
+ export type GLSamplerParameters = {
158
+ /** Sets the wrap parameter for texture coordinate to either GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT, or GL_REPEAT. */
159
+ [GL.TEXTURE_WRAP_S]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
160
+ /** Sets the wrap parameter for texture coordinate to either GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT, or GL_REPEAT. */
161
+ [GL.TEXTURE_WRAP_T]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
162
+ /** Sets the wrap parameter for texture coordinate to either GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT, or GL_REPEAT. */
163
+ [GL.TEXTURE_WRAP_R]?: GL.CLAMP_TO_EDGE | GL.REPEAT | GL.MIRRORED_REPEAT;
164
+
165
+ /** The texture magnification function is used when the pixel being textured maps to an area less than or equal to one texture element. It sets the texture magnification function to either GL_NEAREST or GL_LINEAR (see below). GL_NEAREST is generally faster than GL_LINEAR, but it can produce textured images with sharper edges because the transition between texture elements is not as smooth. Default: GL_LINEAR. */
166
+ [GL.TEXTURE_MAG_FILTER]?: GL.NEAREST | GL.LINEAR;
167
+ /** The texture minifying function is used whenever the pixel being textured maps to an area greater than one texture element. There are six defined minifying functions. Two of them use the nearest one or nearest four texture elements to compute the texture value. The other four use mipmaps. Default: GL_NEAREST_MIPMAP_LINEAR */
168
+ [GL.TEXTURE_MIN_FILTER]?:
169
+ | GL.NEAREST
170
+ | GL.LINEAR
171
+ | GL.NEAREST_MIPMAP_NEAREST
172
+ | GL.NEAREST_MIPMAP_LINEAR
173
+ | GL.LINEAR_MIPMAP_NEAREST
174
+ | GL.LINEAR_MIPMAP_LINEAR;
175
+ /* A GLfloat indicating the minimum level-of-detail mipmap. */
176
+ [GL.TEXTURE_MIN_LOD]?: number;
177
+ /* A GLfloat indicating the minimum level-of-detail mipmap. */
178
+ [GL.TEXTURE_MAX_LOD]?: number;
179
+ /** Texture parameter TEXTURE_COMPARE_FUNC specifies the depth texture comparison function */
180
+ [GL.TEXTURE_COMPARE_FUNC]?: number; // COMPARE_FUNC);
181
+ /** Texture parameter TEXTURE_COMPARE_MODE specifies the depth texture comparison operands. */
182
+ [GL.TEXTURE_COMPARE_MODE]?: GL.COMPARE_REF_TO_TEXTURE;
183
+ /** Max anisotropy level */
184
+ [GL.TEXTURE_MAX_ANISOTROPY_EXT]?: number;
185
+ };
186
+
187
+ /**
188
+ * All global WebGL parameters
189
+ */
190
+ export type GLValueParameters = {
191
+ [GL.BLEND]?: boolean;
192
+ [GL.BLEND_COLOR]?: [number, number, number, number] | NumberArray;
193
+ [GL.BLEND_EQUATION_RGB]?: GLBlendEquation;
194
+ [GL.BLEND_EQUATION_ALPHA]?: GLBlendEquation;
195
+ [GL.BLEND_SRC_RGB]?: GLBlendFunction;
196
+ [GL.BLEND_DST_RGB]?: GLBlendFunction;
197
+ [GL.BLEND_SRC_ALPHA]?: GLBlendFunction;
198
+ [GL.BLEND_DST_ALPHA]?: GLBlendFunction;
199
+ [GL.COLOR_CLEAR_VALUE]?: [number, number, number, number] | NumberArray;
200
+ [GL.COLOR_WRITEMASK]?: [boolean, boolean, boolean, boolean] | boolean[];
201
+ [GL.CULL_FACE]?: boolean;
202
+ [GL.CULL_FACE_MODE]?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;
203
+ [GL.DEPTH_TEST]?: boolean;
204
+ [GL.DEPTH_CLEAR_VALUE]?: number;
205
+ [GL.DEPTH_FUNC]?: GLFunction;
206
+ [GL.DEPTH_RANGE]?: [number, number] | NumberArray;
207
+ [GL.DEPTH_WRITEMASK]?: boolean;
208
+ [GL.DITHER]?: boolean;
209
+ [GL.FRAGMENT_SHADER_DERIVATIVE_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;
210
+ [GL.CURRENT_PROGRAM]?: WebGLProgram | null;
211
+ [GL.FRAMEBUFFER_BINDING]?: WebGLFramebuffer | null;
212
+ [GL.RENDERBUFFER_BINDING]?: WebGLRenderbuffer | null;
213
+ [GL.TRANSFORM_FEEDBACK_BINDING]?: WebGLTransformFeedback | null;
214
+ [GL.VERTEX_ARRAY_BINDING]?: WebGLVertexArrayObject | null;
215
+ [GL.ARRAY_BUFFER_BINDING]?: WebGLBuffer | null;
216
+ [GL.COPY_READ_BUFFER_BINDING]?: WebGLBuffer | null;
217
+ [GL.COPY_WRITE_BUFFER_BINDING]?: WebGLBuffer | null;
218
+ [GL.PIXEL_PACK_BUFFER_BINDING]?: WebGLBuffer | null;
219
+ [GL.PIXEL_UNPACK_BUFFER_BINDING]?: WebGLBuffer | null;
220
+ [GL.TEXTURE_BINDING_2D]?: WebGLTexture | null;
221
+ [GL.TEXTURE_BINDING_2D_ARRAY]?: WebGLTexture | null;
222
+ [GL.TEXTURE_BINDING_3D]?: WebGLTexture | null;
223
+ [GL.TEXTURE_BINDING_CUBE_MAP]?: WebGLTexture | null;
224
+ [GL.FRONT_FACE]?: GL.CW | GL.CCW;
225
+ [GL.GENERATE_MIPMAP_HINT]?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;
226
+ [GL.LINE_WIDTH]?: number;
227
+ [GL.POLYGON_OFFSET_FILL]?: boolean;
228
+ [GL.POLYGON_OFFSET_FACTOR]?: number;
229
+ [GL.POLYGON_OFFSET_UNITS]?: number;
230
+ [GL.SAMPLE_ALPHA_TO_COVERAGE]?: boolean;
231
+ [GL.SAMPLE_COVERAGE]?: boolean;
232
+ [GL.RASTERIZER_DISCARD]?: boolean;
233
+ [GL.SAMPLE_COVERAGE_VALUE]?: number;
234
+ [GL.SAMPLE_COVERAGE_INVERT]?: boolean;
235
+ [GL.SCISSOR_TEST]?: boolean;
236
+ [GL.SCISSOR_BOX]?: [number, number, number, number] | NumberArray;
237
+ [GL.STENCIL_TEST]?: boolean;
238
+ [GL.STENCIL_CLEAR_VALUE]?: number;
239
+ [GL.STENCIL_WRITEMASK]?: number;
240
+ [GL.STENCIL_BACK_WRITEMASK]?: number;
241
+ [GL.STENCIL_FUNC]?: GLFunction;
242
+ [GL.STENCIL_REF]?: number;
243
+ [GL.STENCIL_VALUE_MASK]?: number;
244
+ [GL.STENCIL_BACK_FUNC]?: GLFunction;
245
+ [GL.STENCIL_BACK_REF]?: number;
246
+ [GL.STENCIL_BACK_VALUE_MASK]?: number;
247
+ [GL.STENCIL_FAIL]?: GLStencilOp;
248
+ [GL.STENCIL_PASS_DEPTH_FAIL]?: GLStencilOp;
249
+ [GL.STENCIL_PASS_DEPTH_PASS]?: GLStencilOp;
250
+ [GL.STENCIL_BACK_FAIL]?: GLStencilOp;
251
+ [GL.STENCIL_BACK_PASS_DEPTH_FAIL]?: GLStencilOp;
252
+ [GL.STENCIL_BACK_PASS_DEPTH_PASS]?: GLStencilOp;
253
+ [GL.VIEWPORT]?: [number, number, number, number] | NumberArray;
254
+
255
+ // WEBGL1 PIXEL PACK/UNPACK MODES
256
+ [GL.PACK_ALIGNMENT]?: number;
257
+ [GL.UNPACK_ALIGNMENT]?: number;
258
+ [GL.UNPACK_FLIP_Y_WEBGL]?: boolean;
259
+ [GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?: boolean;
260
+ [GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]?: GL.NONE | GL.BROWSER_DEFAULT_WEBGL;
261
+
262
+ // WEBGL2 PIXEL PACK/UNPACK MODES
263
+ // RASTERIZER_DISCARD ...
264
+ [GL.PACK_ROW_LENGTH]?: number;
265
+ [GL.PACK_SKIP_PIXELS]?: number;
266
+ [GL.PACK_SKIP_ROWS]?: number;
267
+ [GL.READ_FRAMEBUFFER_BINDING]?: Framebuffer | null;
268
+ [GL.UNPACK_ROW_LENGTH]?: number;
269
+ [GL.UNPACK_IMAGE_HEIGHT]?: number;
270
+ [GL.UNPACK_SKIP_PIXELS]?: number;
271
+ [GL.UNPACK_SKIP_ROWS]?: number;
272
+ [GL.UNPACK_SKIP_IMAGES]?: number;
273
+ };
274
+
275
+ /**
276
+ * Function style WebGL parameters used by luma.gl
277
+ * @todo Should perhaps be defined in webgl module
278
+ */
279
+ export type GLFunctionParameters = {
280
+ // Function-style setters
281
+ framebuffer?: Framebuffer | null;
282
+ blend?: boolean;
283
+ blendColor?: [number, number, number, number] | NumberArray;
284
+ blendEquation?: GLBlendEquation | [GLBlendEquation, GLBlendEquation];
285
+ /* defines which function is used for blending pixel arithmetic. Defaults to one and zero */
286
+ blendFunc?:
287
+ | [GLBlendFunction, GLBlendFunction]
288
+ | [GLBlendFunction, GLBlendFunction, GLBlendFunction, GLBlendFunction];
289
+
290
+ clearColor?: [number, number, number, number] | NumberArray;
291
+ clearDepth?: number;
292
+ clearStencil?: number;
293
+
294
+ colorMask?: [boolean, boolean, boolean, boolean] | boolean[];
295
+
296
+ cull?: boolean;
297
+ cullFace?: GL.FRONT | GL.BACK | GL.FRONT_AND_BACK;
298
+
299
+ depthTest?: boolean;
300
+ depthFunc?: GLFunction;
301
+ /** Specifies whether writing into the depth buffer is enabled. Default true, i.e. writing is enabled. */
302
+ depthMask?: boolean;
303
+ depthRange?: [number, number] | NumberArray;
304
+
305
+ dither?: boolean;
306
+
307
+ derivativeHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;
308
+
309
+ frontFace?: GL.CW | GL.CCW;
310
+
311
+ mipmapHint?: GL.FASTEST | GL.NICEST | GL.DONT_CARE;
312
+
313
+ lineWidth?: number;
314
+
315
+ polygonOffsetFill?: boolean;
316
+ polygonOffset?: [number, number];
317
+
318
+ sampleCoverage?: [number, boolean];
319
+
320
+ scissorTest?: boolean;
321
+ scissor?: [number, number, number, number] | NumberArray;
322
+
323
+ stencilTest?: boolean;
324
+ /** Bit mask to enable or disable writing of individual bits in the stencil planes. By default, the mask is all 1. */
325
+ stencilMask?: number | [number, number];
326
+ stencilFunc?:
327
+ | [GLFunction, number, number]
328
+ | [GLFunction, number, number, GLFunction, number, number];
329
+ stencilOp?:
330
+ | [GLStencilOp, GLStencilOp, GLStencilOp]
331
+ | [GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp, GLStencilOp];
332
+ viewport?: [number, number, number, number] | NumberArray;
333
+ };
334
+
335
+ /** WebGL style parameters object (with both GL constants and function style fields) */
336
+ export type GLParameters = GLValueParameters & GLFunctionParameters;