@luma.gl/constants 9.0.0-alpha.4 → 9.0.0-alpha.40

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