@lightningjs/renderer 0.9.1 → 0.9.3

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.
Files changed (97) hide show
  1. package/dist/exports/index.d.ts +3 -0
  2. package/dist/{src/core/text-rendering/renderers/SdfTextRenderer/internal/findNearestMultiple.js → exports/index.js} +4 -11
  3. package/dist/exports/index.js.map +1 -0
  4. package/dist/src/common/IAnimationController.d.ts +58 -1
  5. package/dist/src/common/IAnimationController.js +0 -18
  6. package/dist/src/common/IAnimationController.js.map +1 -1
  7. package/dist/src/core/CoreNode.js +40 -0
  8. package/dist/src/core/CoreNode.js.map +1 -1
  9. package/dist/src/core/CoreTextureManager.d.ts +35 -0
  10. package/dist/src/core/CoreTextureManager.js +1 -1
  11. package/dist/src/core/CoreTextureManager.js.map +1 -1
  12. package/dist/src/core/TextureList.js +34 -0
  13. package/dist/src/core/TextureList.js.map +1 -0
  14. package/dist/src/core/animations/CoreAnimation.d.ts +2 -2
  15. package/dist/src/core/animations/CoreAnimation.js +33 -10
  16. package/dist/src/core/animations/CoreAnimation.js.map +1 -1
  17. package/dist/src/core/animations/CoreAnimationController.d.ts +8 -12
  18. package/dist/src/core/animations/CoreAnimationController.js +42 -46
  19. package/dist/src/core/animations/CoreAnimationController.js.map +1 -1
  20. package/dist/src/core/lib/ImageWorker.d.ts +0 -1
  21. package/dist/src/core/lib/ImageWorker.js +8 -10
  22. package/dist/src/core/lib/ImageWorker.js.map +1 -1
  23. package/dist/src/core/lib/utils.d.ts +1 -0
  24. package/dist/src/core/lib/utils.js +20 -0
  25. package/dist/src/core/lib/utils.js.map +1 -1
  26. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +25 -0
  27. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
  28. package/dist/src/core/renderers/webgl/newShader/effectsMock.d.ts +1 -0
  29. package/dist/src/core/renderers/webgl/newShader/effectsMock.js +36 -0
  30. package/dist/src/core/renderers/webgl/newShader/effectsMock.js.map +1 -0
  31. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +2 -1
  32. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js.map +1 -1
  33. package/dist/src/core/textures/ImageTexture.d.ts +5 -1
  34. package/dist/src/core/textures/ImageTexture.js +20 -9
  35. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  36. package/dist/src/core/utils.js +1 -6
  37. package/dist/src/core/utils.js.map +1 -1
  38. package/dist/src/main-api/INode.d.ts +1 -1
  39. package/dist/src/main-api/Renderer.d.ts +314 -0
  40. package/dist/src/main-api/Renderer.js +387 -0
  41. package/dist/src/main-api/Renderer.js.map +1 -0
  42. package/dist/src/main-api/utils.d.ts +2 -0
  43. package/dist/src/main-api/utils.js +34 -0
  44. package/dist/src/main-api/utils.js.map +1 -0
  45. package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.d.ts +8 -4
  46. package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js +53 -24
  47. package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js.map +1 -1
  48. package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +6 -0
  49. package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +1 -1
  50. package/dist/src/render-drivers/utils.js +6 -1
  51. package/dist/src/render-drivers/utils.js.map +1 -1
  52. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  53. package/{dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/roundUpToMultiple.js → exports/index.ts} +4 -14
  54. package/package.json +1 -1
  55. package/src/common/IAnimationController.ts +60 -1
  56. package/src/core/CoreNode.ts +45 -0
  57. package/src/core/CoreTextureManager.ts +40 -1
  58. package/src/core/animations/CoreAnimation.ts +35 -11
  59. package/src/core/animations/CoreAnimationController.ts +48 -53
  60. package/src/core/lib/ImageWorker.ts +10 -13
  61. package/src/core/lib/utils.ts +25 -0
  62. package/src/core/renderers/webgl/WebGlCoreRenderer.ts +27 -0
  63. package/src/core/renderers/webgl/shaders/effects/BorderEffect.ts +2 -1
  64. package/src/core/textures/ImageTexture.ts +26 -9
  65. package/src/core/utils.ts +1 -7
  66. package/src/main-api/INode.ts +1 -1
  67. package/src/render-drivers/threadx/ThreadXMainAnimationController.ts +63 -27
  68. package/src/render-drivers/threadx/worker/ThreadXRendererNode.ts +6 -0
  69. package/src/render-drivers/utils.ts +6 -1
  70. package/dist/src/core/lib/WebGlContext.d.ts +0 -414
  71. package/dist/src/core/lib/WebGlContext.js +0 -640
  72. package/dist/src/core/lib/WebGlContext.js.map +0 -1
  73. package/dist/src/core/scene/Scene.d.ts +0 -59
  74. package/dist/src/core/scene/Scene.js +0 -106
  75. package/dist/src/core/scene/Scene.js.map +0 -1
  76. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/findNearestMultiple.d.ts +0 -8
  77. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/findNearestMultiple.js.map +0 -1
  78. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/SdfBufferHelper.d.ts +0 -19
  79. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/SdfBufferHelper.js +0 -84
  80. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/SdfBufferHelper.js.map +0 -1
  81. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutLine.d.ts +0 -8
  82. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutLine.js +0 -40
  83. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutLine.js.map +0 -1
  84. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutText2.d.ts +0 -2
  85. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutText2.js +0 -41
  86. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/layoutText2.js.map +0 -1
  87. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/utils.d.ts +0 -1
  88. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/utils.js +0 -4
  89. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2/utils.js.map +0 -1
  90. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2.js +0 -2
  91. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText2.js.map +0 -1
  92. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.d.ts +0 -20
  93. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js +0 -55
  94. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js.map +0 -1
  95. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/roundUpToMultiple.d.ts +0 -9
  96. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/roundUpToMultiple.js.map +0 -1
  97. /package/dist/src/core/{text-rendering/renderers/SdfTextRenderer/internal/layoutText2.d.ts → TextureList.d.ts} +0 -0
package/src/core/utils.ts CHANGED
@@ -177,7 +177,7 @@ const parseCubicBezier = (str: string) => {
177
177
  export const getTimingFunction = (
178
178
  str: string,
179
179
  ): ((time: number) => number | undefined) => {
180
- if (str === '') {
180
+ if (str === 'linear') {
181
181
  return defaultTiming;
182
182
  }
183
183
 
@@ -185,12 +185,6 @@ export const getTimingFunction = (
185
185
  return timingMapping[str] || defaultTiming;
186
186
  }
187
187
 
188
- if (str === 'linear') {
189
- return (time: number) => {
190
- return time;
191
- };
192
- }
193
-
194
188
  if (str === 'step-start') {
195
189
  return () => {
196
190
  return 1;
@@ -443,7 +443,7 @@ export interface INodeWritableProps {
443
443
  * The data stored can only be of type string, number or boolean.
444
444
  */
445
445
  export type CustomDataMap = {
446
- [key: string]: string | number | boolean;
446
+ [key: string]: string | number | boolean | undefined;
447
447
  };
448
448
 
449
449
  export type INodeAnimatableProps = {
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  /* eslint-disable @typescript-eslint/unbound-method */
21
+ import { EventEmitter } from '../../common/EventEmitter.js';
21
22
  import type {
22
23
  AnimationControllerState,
23
24
  IAnimationController,
@@ -25,37 +26,48 @@ import type {
25
26
  import { assertTruthy } from '../../utils.js';
26
27
  import type { ThreadXMainNode } from './ThreadXMainNode.js';
27
28
 
28
- export class ThreadXMainAnimationController implements IAnimationController {
29
- stoppedPromise: Promise<void> | null = null;
29
+ export class ThreadXMainAnimationController
30
+ extends EventEmitter
31
+ implements IAnimationController
32
+ {
33
+ stoppedPromise: Promise<void>;
30
34
  /**
31
35
  * If this is null, then the animation is in a finished / stopped state.
32
36
  */
33
37
  stoppedResolve: (() => void) | null = null;
38
+ state: AnimationControllerState;
34
39
 
35
40
  constructor(private node: ThreadXMainNode, private id: number) {
36
- this.onAnimationFinished = this.onAnimationFinished.bind(this);
41
+ super();
37
42
  this.state = 'stopped';
38
- }
39
43
 
40
- state: AnimationControllerState;
44
+ // Initial stopped promise is resolved (since the animation is stopped)
45
+ this.stoppedPromise = Promise.resolve();
46
+
47
+ // Bind event handlers
48
+ this.onAnimating = this.onAnimating.bind(this);
49
+ this.onFinished = this.onFinished.bind(this);
50
+ }
41
51
 
42
52
  start(): IAnimationController {
43
- if (this.stoppedResolve === null) {
53
+ if (this.state !== 'running') {
44
54
  this.makeStoppedPromise();
45
- this.node.on('animationFinished', this.onAnimationFinished);
55
+ this.sendStart();
56
+ this.state = 'running';
46
57
  }
47
- this.state = 'running';
48
- this.node.emit('startAnimation', { id: this.id });
49
58
  return this;
50
59
  }
51
60
 
52
61
  stop(): IAnimationController {
53
- this.node.emit('stopAnimation', { id: this.id });
54
- this.node.off('animationFinished', this.onAnimationFinished);
55
- if (this.stoppedResolve !== null) {
56
- this.stoppedResolve();
57
- this.stoppedResolve = null;
62
+ if (this.state === 'stopped') {
63
+ return this;
58
64
  }
65
+ this.sendStop();
66
+ // if (this.stoppedResolve !== null) {
67
+ // this.stoppedResolve();
68
+ // this.stoppedResolve = null;
69
+ // this.emit('stopped', this);
70
+ // }
59
71
  this.state = 'stopped';
60
72
  return this;
61
73
  }
@@ -71,29 +83,53 @@ export class ThreadXMainAnimationController implements IAnimationController {
71
83
  }
72
84
 
73
85
  waitUntilStopped(): Promise<void> {
74
- this.makeStoppedPromise();
75
- const promise = this.stoppedPromise;
76
- assertTruthy(promise);
77
- return promise;
86
+ return this.stoppedPromise;
87
+ }
88
+
89
+ private sendStart(): void {
90
+ // Hook up event listeners
91
+ this.node.on('animationFinished', this.onFinished);
92
+ this.node.on('animationAnimating', this.onAnimating);
93
+ // Then register the animation
94
+ this.node.emit('startAnimation', { id: this.id });
95
+ }
96
+
97
+ private sendStop(): void {
98
+ // First unregister the animation
99
+ this.node.emit('stopAnimation', { id: this.id });
100
+ // Then unhook event listeners
101
+ this.node.off('animationFinished', this.onFinished);
102
+ this.node.off('animationAnimating', this.onAnimating);
78
103
  }
79
104
 
80
- private onAnimationFinished(
105
+ private makeStoppedPromise(): void {
106
+ if (this.stoppedResolve === null) {
107
+ this.stoppedPromise = new Promise((resolve) => {
108
+ this.stoppedResolve = resolve;
109
+ });
110
+ }
111
+ }
112
+
113
+ private onFinished(
81
114
  target: ThreadXMainNode,
82
- { id, loop }: { id: number; loop: boolean },
115
+ { id }: { id: number; loop: boolean },
83
116
  ) {
84
117
  if (id === this.id) {
85
- this.node.off('animationFinished', this.onAnimationFinished);
86
- this.stoppedResolve?.();
118
+ assertTruthy(this.stoppedResolve);
119
+ this.node.off('animationFinished', this.onFinished);
120
+ this.node.off('animationAnimating', this.onAnimating);
121
+
122
+ // resolve promise
123
+ this.stoppedResolve();
87
124
  this.stoppedResolve = null;
125
+ this.emit('stopped', this);
88
126
  this.state = 'stopped';
89
127
  }
90
128
  }
91
129
 
92
- private makeStoppedPromise(): void {
93
- if (this.stoppedResolve === null) {
94
- this.stoppedPromise = new Promise((resolve) => {
95
- this.stoppedResolve = resolve;
96
- });
130
+ private onAnimating(target: ThreadXMainNode, { id }: { id: number }) {
131
+ if (id === this.id) {
132
+ this.emit('animating', this);
97
133
  }
98
134
  }
99
135
  }
@@ -84,6 +84,12 @@ export class ThreadXRendererNode extends SharedNode {
84
84
  props as Partial<INodeAnimatableProps>,
85
85
  settings as Partial<AnimationSettings>,
86
86
  );
87
+ animation.on('animating', () => {
88
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
89
+ this.emit('animationAnimating', {
90
+ id: id as number,
91
+ });
92
+ });
87
93
  animation.on('finished', () => {
88
94
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
89
95
  this.emit('animationFinished', {
@@ -58,7 +58,12 @@ export async function loadCoreExtension(
58
58
  }
59
59
 
60
60
  export function santizeCustomDataMap(d: CustomDataMap): CustomDataMap {
61
- const validTypes = { boolean: true, string: true, number: true, undefined: true };
61
+ const validTypes = {
62
+ boolean: true,
63
+ string: true,
64
+ number: true,
65
+ undefined: true,
66
+ };
62
67
 
63
68
  const keys = Object.keys(d);
64
69
  for (let i = 0; i < keys.length; i++) {
@@ -1,414 +0,0 @@
1
- export declare class WebGlContext {
2
- private gl;
3
- private activeTextureUnit;
4
- private texture2dUnits;
5
- private texture2dParams;
6
- private scissorEnabled;
7
- private scissorX;
8
- private scissorY;
9
- private scissorWidth;
10
- private scissorHeight;
11
- private blendEnabled;
12
- private blendSrcRgb;
13
- private blendDstRgb;
14
- private blendSrcAlpha;
15
- private blendDstAlpha;
16
- private boundArrayBuffer;
17
- private boundElementArrayBuffer;
18
- private curProgram;
19
- private programUniforms;
20
- constructor(gl: WebGLRenderingContext | WebGL2RenderingContext);
21
- /**
22
- * ```
23
- * gl.activeTexture(textureUnit + gl.TEXTURE0);
24
- * ```
25
- *
26
- * @remarks
27
- * **WebGL Difference**: `textureUnit` is based from 0, not `gl.TEXTURE0`.
28
- *
29
- * @param textureUnit
30
- */
31
- activeTexture(textureUnit: number): void;
32
- /**
33
- * ```
34
- * gl.bindTexture(gl.TEXTURE_2D, texture);
35
- * ```
36
- * @remarks
37
- * **WebGL Difference**: Bind target is always `gl.TEXTURE_2D`
38
- *
39
- * @param texture
40
- */
41
- bindTexture(texture: WebGLTexture | null): void;
42
- private _getActiveTexture;
43
- /**
44
- * ```
45
- * gl.texParameteri(gl.TEXTURE_2D, pname, param)
46
- * ```
47
- * @remarks
48
- * **WebGL Difference**: Bind target is always `gl.TEXTURE_2D`
49
- *
50
- * @param pname
51
- * @param param
52
- * @returns
53
- */
54
- texParameteri(pname: number, param: number): void;
55
- /**
56
- * ```
57
- * gl.texImage2D(
58
- * gl.TEXTURE_2D,
59
- * level,
60
- * internalFormat,
61
- * width,
62
- * height,
63
- * border,
64
- * format,
65
- * type,
66
- * pixels,
67
- * );
68
- * ```
69
- * @remarks
70
- * **WebGL Difference**: Bind target is always `gl.TEXTURE_2D`
71
- *
72
- * @param level
73
- * @param internalFormat
74
- * @param width
75
- * @param height
76
- * @param border
77
- * @param format
78
- * @param type
79
- * @param pixels
80
- */
81
- texImage2D(level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView | null): void;
82
- texImage2D(level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource): void;
83
- /**
84
- * ```
85
- * gl.pixelStorei(pname, param);
86
- * ```
87
- *
88
- * @param pname
89
- * @param param
90
- */
91
- pixelStorei(pname: GLenum, param: GLint | GLboolean): void;
92
- /**
93
- * ```
94
- * gl.generateMipmap(gl.TEXTURE_2D);
95
- * ```
96
- *
97
- * @remarks
98
- * **WebGL Difference**: Bind target is always `gl.TEXTURE_2D`
99
- */
100
- generateMipmap(): void;
101
- /**
102
- * ```
103
- * gl.createTexture();
104
- * ```
105
- *
106
- * @returns
107
- */
108
- createTexture(): WebGLTexture | null;
109
- /**
110
- * ```
111
- * gl.deleteTexture(texture);
112
- * ```
113
- *
114
- * @param texture
115
- */
116
- deleteTexture(texture: WebGLTexture | null): void;
117
- /**
118
- * ```
119
- * gl.viewport(x, y, width, height);
120
- * ```
121
- */
122
- viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void;
123
- /**
124
- * ```
125
- * gl.clearColor(red, green, blue, alpha);
126
- * ```
127
- *
128
- * @param red
129
- * @param green
130
- * @param blue
131
- * @param alpha
132
- */
133
- clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf): void;
134
- /**
135
- * ```
136
- * gl["enable"|"disable"](gl.SCISSOR_TEST);
137
- * ```
138
- * @param enable
139
- */
140
- scissorTest(enable: boolean): void;
141
- /**
142
- * ```
143
- * gl.scissor(x, y, width, height);
144
- * ```
145
- *
146
- * @param x
147
- * @param y
148
- * @param width
149
- * @param height
150
- */
151
- scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei): void;
152
- /**
153
- * ```
154
- * gl["enable"|"disable"](gl.BLEND);
155
- * ```
156
- *
157
- * @param blend
158
- * @returns
159
- */
160
- setBlend(blend: boolean): void;
161
- /**
162
- * ```
163
- * gl.blendFunc(src, dst);
164
- * ```
165
- *
166
- * @param src
167
- * @param dst
168
- */
169
- blendFunc(src: GLenum, dst: GLenum): void;
170
- /**
171
- * ```
172
- * createBuffer();
173
- * ```
174
- *
175
- * @returns
176
- */
177
- createBuffer(): WebGLBuffer | null;
178
- /**
179
- * ```
180
- * gl.clear(gl.COLOR_BUFFER_BIT);
181
- * ```
182
- *
183
- * @remarks
184
- * **WebGL Difference**: Clear mask is always `gl.COLOR_BUFFER_BIT`
185
- */
186
- clear(): void;
187
- /**
188
- * ```
189
- * gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
190
- * gl.bufferData(gl.ARRAY_BUFFER, data, usage);
191
- * ```
192
- *
193
- * @remarks
194
- * **WebGL Combo**: `gl.bindBuffer` and `gl.bufferData` are combined into one function.
195
- *
196
- * @param buffer
197
- * @param data
198
- * @param usage
199
- */
200
- arrayBufferData(buffer: WebGLBuffer | null, data: ArrayBufferView, usage: GLenum): void;
201
- /**
202
- * ```
203
- * gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer);
204
- * gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, data, usage);
205
- * ```
206
- * @remarks
207
- * **WebGL Combo**: `gl.bindBuffer` and `gl.bufferData` are combined into one function.
208
- *
209
- * @param buffer
210
- * @param data
211
- * @param usage
212
- */
213
- elementArrayBufferData(buffer: WebGLBuffer | null, data: ArrayBufferView, usage: GLenum): void;
214
- /**
215
- * ```
216
- * gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
217
- * gl.vertexAttribPointer(index, size, type, normalized, stride, offset);
218
- * ```
219
- *
220
- * @remarks
221
- * **WebGL Combo**: `gl.bindBuffer` and `gl.vertexAttribPointer` are combined into one function.
222
- *
223
- * @param buffer
224
- * @param index
225
- * @param size
226
- * @param type
227
- * @param normalized
228
- * @param stride
229
- * @param offset
230
- */
231
- vertexAttribPointer(buffer: WebGLBuffer, index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr): void;
232
- /**
233
- * ```
234
- * gl.useProgram(program);
235
- * ```
236
- *
237
- * @param program
238
- * @returns
239
- */
240
- useProgram(program: WebGLProgram | null): void;
241
- setUniform<T extends keyof UniformMethodMap>(type: T, location: WebGLUniformLocation, ...args: UniformMethodMap[T]): void;
242
- /**
243
- * ```
244
- * gl.getParameter(pname);
245
- * ```
246
- *
247
- * @param pname
248
- * @returns
249
- */
250
- getParameter(pname: GLenum): any;
251
- /**
252
- * ```
253
- * gl.drawElements(mode, count, type, offset);
254
- * ```
255
- *
256
- * @param mode
257
- * @param count
258
- * @param type
259
- * @param offset
260
- */
261
- drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr): void;
262
- /**
263
- * ```
264
- * gl.drawArrays(mode, first, count);
265
- * ```
266
- *
267
- * @param name
268
- * @returns
269
- */
270
- getExtension(name: string): any;
271
- /**
272
- * ```
273
- * gl.createVertexArray();
274
- * ```
275
- *
276
- * @returns
277
- */
278
- createVertexArray(): WebGLVertexArrayObject | null;
279
- /**
280
- * ```
281
- * gl.bindVertexArray(vertexArray);
282
- * ```
283
- *
284
- * @param vertexArray
285
- */
286
- bindVertexArray(vertexArray: WebGLVertexArrayObject | null): void;
287
- /**
288
- * ```
289
- * gl.getAttribLocation(program, name);
290
- * ```
291
- *
292
- * @param program
293
- * @param name
294
- * @returns
295
- */
296
- getAttribLocation(program: WebGLProgram, name: string): number;
297
- /**
298
- * ```
299
- * gl.getUniformLocation(program, name);
300
- * ```
301
- *
302
- * @param program
303
- * @param name
304
- * @returns
305
- */
306
- getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation | null;
307
- /**
308
- * ```
309
- * gl.enableVertexAttribArray(index);
310
- * ```
311
- *
312
- * @param index
313
- */
314
- enableVertexAttribArray(index: number): void;
315
- /**
316
- * ```
317
- * gl.disableVertexAttribArray(index);
318
- * ```
319
- *
320
- * @param index
321
- */
322
- disableVertexAttribArray(index: number): void;
323
- /**
324
- * ```
325
- * gl.createShader(type);
326
- * ```
327
- *
328
- * @param type
329
- * @returns
330
- */
331
- createShader(type: number): WebGLShader | null;
332
- /**
333
- * ```
334
- * gl.compileShader(shader);
335
- * ```
336
- *
337
- * @param shader
338
- * @returns
339
- */
340
- compileShader(shader: WebGLShader): void;
341
- /**
342
- * ```
343
- * gl.attachShader(program, shader);
344
- * ```
345
- *
346
- * @param program
347
- * @param shader
348
- */
349
- attachShader(program: WebGLProgram, shader: WebGLShader): void;
350
- /**
351
- * ```
352
- * gl.linkProgram(program);
353
- * ```
354
- *
355
- * @param program
356
- */
357
- linkProgram(program: WebGLProgram): void;
358
- /**
359
- * ```
360
- * gl.deleteProgram(shader);
361
- * ```
362
- *
363
- * @param shader
364
- */
365
- deleteProgram(shader: WebGLProgram): void;
366
- /**
367
- * ```
368
- * gl.getShaderParameter(shader, pname);
369
- * ```
370
- *
371
- * @param shader
372
- * @param pname
373
- */
374
- getShaderParameter(shader: WebGLShader, pname: GLenum): any;
375
- /**
376
- * ```
377
- * gl.getShaderInfoLog(shader);
378
- * ```
379
- *
380
- * @param shader
381
- */
382
- getShaderInfoLog(shader: WebGLShader): string | null;
383
- /**
384
- * ```
385
- * gl.createProgram();
386
- * ```
387
- *
388
- * @returns
389
- */
390
- createProgram(): WebGLProgram | null;
391
- /**
392
- * ```
393
- * gl.getProgramParameter(program, pname);
394
- * ```
395
- *
396
- * @param program
397
- * @param pname
398
- * @returns
399
- */
400
- getProgramParameter(program: WebGLProgram, pname: GLenum): any;
401
- }
402
- type IsUniformMethod<MethodName, MethodType> = MethodName extends `uniform${string}` ? MethodType extends (location: WebGLUniformLocation | null, ...args: any[]) => void ? true : false : false;
403
- export type UniformMethodMap = {
404
- [Key in keyof WebGLRenderingContext as IsUniformMethod<Key, WebGLRenderingContext[Key]> extends true ? Key : never]: WebGLRenderingContext[Key] extends (location: WebGLUniformLocation | null, ...args: infer T) => void ? T : never;
405
- };
406
- /**
407
- *
408
- *
409
- * @param a
410
- * @param b
411
- * @returns
412
- */
413
- export declare function compareArrays<T>(a: T[], b: T[]): boolean;
414
- export {};