gridviz 3.0.34 → 3.0.36

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 (67) hide show
  1. package/README.md +129 -129
  2. package/dist/gridviz.js +17487 -17471
  3. package/dist/gridviz.min.js +2 -2
  4. package/package.json +73 -73
  5. package/src/button/Button.js +67 -67
  6. package/src/button/FullscreenButton.js +121 -121
  7. package/src/button/ZoomButtons.js +103 -103
  8. package/src/core/Dataset.js +154 -154
  9. package/src/core/Drawable.js +78 -78
  10. package/src/core/GeoCanvas.js +443 -443
  11. package/src/core/Layer.js +23 -23
  12. package/src/core/Legend.js +108 -108
  13. package/src/core/Map.js +568 -552
  14. package/src/core/MultiResolutionDataset.js +93 -93
  15. package/src/core/Style.js +98 -98
  16. package/src/core/Tooltip.js +182 -182
  17. package/src/dataset/COGeo.js +25 -25
  18. package/src/dataset/CSVGrid.js +112 -112
  19. package/src/dataset/GeoTIFF.js +122 -122
  20. package/src/dataset/JSGrid.js +55 -55
  21. package/src/dataset/TiledGrid.js +302 -302
  22. package/src/dataset/worker.js +18 -18
  23. package/src/index.js +79 -79
  24. package/src/layer/BackgroundLayer.js +173 -173
  25. package/src/layer/BackgroundLayerImage.js +81 -81
  26. package/src/layer/BackgroundLayerWMS.js +104 -104
  27. package/src/layer/GeoJSONLayer.js +276 -276
  28. package/src/layer/GridLayer.js +166 -166
  29. package/src/layer/LabelLayer.js +194 -194
  30. package/src/legend/ColorCategoryLegend.js +109 -109
  31. package/src/legend/ColorDiscreteLegend.js +100 -100
  32. package/src/legend/ColorLegend.js +115 -115
  33. package/src/legend/OrientationLegend.js +89 -89
  34. package/src/legend/SizeLegend.js +224 -224
  35. package/src/legend/TernaryLegend.js +302 -302
  36. package/src/style/CompositionStyle.js +291 -291
  37. package/src/style/DotDensityStyle.js +133 -133
  38. package/src/style/ImageStyle.js +100 -100
  39. package/src/style/Interpolator.js +258 -258
  40. package/src/style/IsoFenceStyle.js +217 -217
  41. package/src/style/JoyPlotStyle.js +180 -180
  42. package/src/style/LegoStyle.js +132 -132
  43. package/src/style/MosaicStyle.js +99 -99
  44. package/src/style/NinjaStarStyle.js +102 -102
  45. package/src/style/PillarStyle.js +207 -207
  46. package/src/style/SegmentStyle.js +105 -105
  47. package/src/style/ShadingRayStyle.js +280 -280
  48. package/src/style/ShadingStyle.js +72 -72
  49. package/src/style/ShapeColorSizeStyle.js +147 -147
  50. package/src/style/SideCategoryStyle.js +112 -112
  51. package/src/style/SideStyle.js +217 -217
  52. package/src/style/SideTanakaStyle.js +154 -154
  53. package/src/style/SquareColorCategoryWebGLStyle.js +307 -294
  54. package/src/style/SquareColorWebGLStyle.js +126 -126
  55. package/src/style/StrokeStyle.js +135 -135
  56. package/src/style/TextStyle.js +110 -110
  57. package/src/style/TimeSeriesStyle.js +222 -222
  58. package/src/utils/WebGLRectangleColoring.js +106 -106
  59. package/src/utils/WebGLSquareColoring.js +118 -118
  60. package/src/utils/WebGLSquareColoringAdvanced.js +227 -227
  61. package/src/utils/WebGLSquareColoringKS.js +153 -153
  62. package/src/utils/scale.js +255 -255
  63. package/src/utils/stretching.js +120 -120
  64. package/src/utils/ternary.js +208 -208
  65. package/src/utils/utils.js +125 -125
  66. package/src/utils/webGLUtils.js +73 -73
  67. package/src/utils/zoomUtils.js +142 -142
@@ -1,227 +1,227 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { initShaderProgram, createShader } from './webGLUtils.js'
5
- import { color } from 'd3-color'
6
-
7
- /**
8
- * Everything to easily draw colored squares with webGL.
9
- * All the same size, but different fill color.
10
- * The color interpolation is computed in the fragment shader program, by the GPU, thus it is less flexible but faster.
11
- */
12
- export class WebGLSquareColoringAdvanced {
13
- //see:
14
- //https://webglfundamentals.org/webgl/lessons/fr/webgl-shaders-and-glsl.html#les-uniforms-dans-les-shaders-de-vertex
15
- //https://thebookofshaders.com/glossary/?search=mix
16
- //https://thebookofshaders.com/06/
17
- //https://thebookofshaders.com/glossary/
18
-
19
- /**
20
- *
21
- * @param {*} gl
22
- * @param {Array.<String>} colors
23
- * @param {{fun:string,alpha:number}} stretching
24
- * @param {number} sizePix
25
- * @param {number|undefined} globalOpacity
26
- */
27
- constructor(gl, colors, stretching, sizePix = 10, globalOpacity = undefined) {
28
- /** @type {WebGLRenderingContext} */
29
- this.gl = gl
30
- //gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
31
- //gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
32
- //gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
33
-
34
- /** @type {WebGLShader} */
35
- const vShader = createShader(
36
- gl,
37
- gl.VERTEX_SHADER,
38
- `
39
- attribute vec2 pos;
40
- uniform float sizePix;
41
- uniform mat3 mat;
42
-
43
- attribute float t;
44
- varying float vt;
45
-
46
- void main() {
47
- gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
48
- gl_PointSize = sizePix;
49
- vt = t;
50
- }
51
- `
52
- )
53
-
54
- //prepare fragment shader code
55
- //declare the uniform and other variables
56
- const fshBuff = []
57
- fshBuff.push('precision mediump float;')
58
- fshBuff.push('varying float vt;')
59
- fshBuff.push('uniform float alpha;')
60
- for (let i = 0; i < colors.length; i++) fshBuff.push('uniform vec4 c' + i + ';')
61
- //start the main function
62
- fshBuff.push('void main(void) {')
63
-
64
- // apply the stretching of t
65
- if (stretching) {
66
- if (stretching.fun == 'pow')
67
- //sPow = (t, alpha = 3) => Math.pow(t, alpha);
68
- fshBuff.push(' float t = pow(vt, alpha);')
69
- else if (stretching.fun == 'powInv')
70
- //sPowRev = (t, alpha = 3) => 1 - Math.pow(1 - t, 1 / alpha);
71
- fshBuff.push(' float t = 1.0-pow(1.0-vt, 1.0/alpha);')
72
- else if (stretching.fun == 'exp')
73
- //sExp = (t, alpha = 3) => alpha == 0 ? t : (Math.exp(t * alpha) - 1) / (Math.exp(alpha) - 1);
74
- fshBuff.push(
75
- stretching.alpha == 0
76
- ? `float t = vt;`
77
- : ' float t = (exp(vt * alpha) - 1.0) / (exp(alpha) - 1.0);')
78
- else if (stretching.fun == 'log')
79
- //sExpRev = (t, alpha = 3) => alpha == 0 ? t : 1 - (1 / alpha) * Math.log(Math.exp(alpha) * (1 - t) + t);
80
- fshBuff.push(
81
- stretching.alpha == 0
82
- ? `float t = vt;`
83
- : ' float t = 1.0 - (1.0 / alpha) * log(exp(alpha) * (1.0 - vt) + vt);')
84
- else if (stretching.fun == 'circle') {
85
- if (stretching.alpha == 0)
86
- //if (alpha == 0) return t;
87
- fshBuff.push(' float t = vt;')
88
- else if (stretching.alpha == 1)
89
- // if (alpha == 1) return Math.sqrt(2 * t - t * t);
90
- fshBuff.push(' float t = sqrt(vt * (2.0 - vt));')
91
- else {
92
- //const a = alpha / (1 - alpha);
93
- //return Math.sqrt(1 / (a * a) + t * (2 / a + 2 - t)) - 1 / a;
94
- fshBuff.push(' float a = alpha / (1.0 - alpha);')
95
- fshBuff.push(' float t = sqrt(1.0 / (a * a) + vt * ( 2.0/a + 2.0 - vt )) - 1.0 / a;')
96
- }
97
- } else if (stretching.fun == 'circleInv') {
98
- // 1 - sCircleLow(1 - t, alpha)
99
- if (stretching.alpha == 0)
100
- //if (alpha == 0) return t;
101
- fshBuff.push(' float t = vt;')
102
- else if (stretching.alpha == 1)
103
- // if (alpha == 1) return Math.sqrt(2 * t - t * t);
104
- fshBuff.push(' float t = 1.0 - sqrt((1.0 - vt) * (1.0 + vt));')
105
- else {
106
- //const a = alpha / (1 - alpha);
107
- //return Math.sqrt(1 / (a * a) + (2 * t) / a + 2 * t - t * t) - 1 / a;
108
- fshBuff.push(' float a = alpha / (1.0 - alpha);')
109
- fshBuff.push(' float t = 1.0 - sqrt(1.0 / (a * a) + (1.0-vt) * ( 2.0/a + 1.0 + vt )) + 1.0 / a;')
110
- }
111
- } else {
112
- console.error('Unexpected stretching function code: ' + stretching.fun)
113
- fshBuff.push(' float t = vt;')
114
- }
115
- } else {
116
- fshBuff.push(' float t = vt;')
117
- }
118
-
119
- //choose initial and final colors, and adjust t value
120
- if (colors.length == 1) {
121
- fshBuff.push(' vec4 cI=c0;')
122
- fshBuff.push(' vec4 cF=c0;')
123
- }
124
- else if (colors.length == 2) {
125
- fshBuff.push(' vec4 cI=c0;')
126
- fshBuff.push(' vec4 cF=c1;')
127
- } else {
128
- const nb = colors.length - 1
129
- const nbs = nb + '.0'
130
- fshBuff.push(' vec4 cI;')
131
- fshBuff.push(' vec4 cF;')
132
- fshBuff.push(' if(t<1.0/' + nbs + ') { cI=c0; cF=c1; t=t*' + nbs + '; }')
133
- for (let i = 2; i < nb; i++)
134
- fshBuff.push(
135
- ' else if(t<' +
136
- i +
137
- '.0/' +
138
- nbs +
139
- ') { cI=c' +
140
- (i - 1) +
141
- '; cF=c' +
142
- i +
143
- '; t=' +
144
- nbs +
145
- '*t-' +
146
- (i - 1) +
147
- '.0; }')
148
- fshBuff.push(' else { cI=c' + (nb - 1) + '; cF=c' + nb + '; t=' + nbs + '*t-' + (nb - 1) + '.0; }')
149
- }
150
-
151
- //one single color
152
- if (colors.length == 1) fshBuff.push(' gl_FragColor = vec4(c0[0], c0[1], c0[2], c0[3]);}')
153
- //set interpolated color, between initial and final one
154
- else fshBuff.push(' gl_FragColor = mix(cI, cF, t);}')
155
-
156
- let fshString = fshBuff.join("")
157
- //let fshString = fshBuff.join("\n")
158
- //console.log(fshString)
159
-
160
- /** @type {WebGLShader} */
161
- const fShader = createShader(gl, gl.FRAGMENT_SHADER, fshString)
162
-
163
- /** @type {WebGLProgram} */
164
- this.program = initShaderProgram(gl, vShader, fShader)
165
- gl.useProgram(this.program)
166
-
167
- //set uniforms
168
-
169
- //sizePix
170
- //TODO: bug here. Seems to be limited to some threshold value (around 250).
171
- gl.uniform1f(gl.getUniformLocation(this.program, 'sizePix'), 1.0 * sizePix)
172
-
173
- //stretching alpha factor
174
- gl.uniform1f(gl.getUniformLocation(this.program, 'alpha'), stretching ? 1.0 * stretching.alpha : 0.0)
175
-
176
- //colors
177
- for (let i = 0; i < colors.length; i++) {
178
- const c = color(colors[i])
179
-
180
- let opacity = c.opacity
181
- if (c.opacity == 1 && globalOpacity != undefined) opacity = globalOpacity
182
-
183
- const colData = [+c.r / 255.0, +c.g / 255.0, +c.b / 255.0, +opacity]
184
- //console.log(i, colors[i], c, colData)
185
- gl.uniform4fv(gl.getUniformLocation(this.program, 'c' + i), colData)
186
- }
187
- }
188
-
189
- /** */
190
- draw(verticesBuffer, tBuffer, transfoMat) {
191
- const gl = this.gl
192
- const program = this.program
193
-
194
- //vertice data
195
- gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
196
- gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(verticesBuffer), gl.STATIC_DRAW)
197
- const position = gl.getAttribLocation(program, 'pos')
198
- gl.vertexAttribPointer(
199
- position,
200
- 2, //numComponents
201
- gl.FLOAT, //type
202
- false, //normalise
203
- 0, //stride
204
- 0 //offset
205
- )
206
- gl.enableVertexAttribArray(position)
207
-
208
- //t data
209
- gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
210
- gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(tBuffer), gl.STATIC_DRAW)
211
- const t = gl.getAttribLocation(program, 't')
212
- gl.vertexAttribPointer(t, 1, gl.FLOAT, false, 0, 0)
213
- gl.enableVertexAttribArray(t)
214
-
215
- //transformation
216
- gl.uniformMatrix3fv(gl.getUniformLocation(program, 'mat'), false, new Float32Array(transfoMat))
217
-
218
- // Enable the depth test
219
- //gl.enable(gl.DEPTH_TEST);
220
- // Clear the color buffer bit
221
- gl.clear(gl.COLOR_BUFFER_BIT)
222
- // Set the view port
223
- //gl.viewport(0, 0, cg.w, cg.h);
224
-
225
- gl.drawArrays(gl.POINTS, 0, verticesBuffer.length / 2)
226
- }
227
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { initShaderProgram, createShader } from './webGLUtils.js'
5
+ import { color } from 'd3-color'
6
+
7
+ /**
8
+ * Everything to easily draw colored squares with webGL.
9
+ * All the same size, but different fill color.
10
+ * The color interpolation is computed in the fragment shader program, by the GPU, thus it is less flexible but faster.
11
+ */
12
+ export class WebGLSquareColoringAdvanced {
13
+ //see:
14
+ //https://webglfundamentals.org/webgl/lessons/fr/webgl-shaders-and-glsl.html#les-uniforms-dans-les-shaders-de-vertex
15
+ //https://thebookofshaders.com/glossary/?search=mix
16
+ //https://thebookofshaders.com/06/
17
+ //https://thebookofshaders.com/glossary/
18
+
19
+ /**
20
+ *
21
+ * @param {*} gl
22
+ * @param {Array.<String>} colors
23
+ * @param {{fun:string,alpha:number}} stretching
24
+ * @param {number} sizePix
25
+ * @param {number|undefined} globalOpacity
26
+ */
27
+ constructor(gl, colors, stretching, sizePix = 10, globalOpacity = undefined) {
28
+ /** @type {WebGLRenderingContext} */
29
+ this.gl = gl
30
+ //gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
31
+ //gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
32
+ //gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
33
+
34
+ /** @type {WebGLShader} */
35
+ const vShader = createShader(
36
+ gl,
37
+ gl.VERTEX_SHADER,
38
+ `
39
+ attribute vec2 pos;
40
+ uniform float sizePix;
41
+ uniform mat3 mat;
42
+
43
+ attribute float t;
44
+ varying float vt;
45
+
46
+ void main() {
47
+ gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
48
+ gl_PointSize = sizePix;
49
+ vt = t;
50
+ }
51
+ `
52
+ )
53
+
54
+ //prepare fragment shader code
55
+ //declare the uniform and other variables
56
+ const fshBuff = []
57
+ fshBuff.push('precision mediump float;')
58
+ fshBuff.push('varying float vt;')
59
+ fshBuff.push('uniform float alpha;')
60
+ for (let i = 0; i < colors.length; i++) fshBuff.push('uniform vec4 c' + i + ';')
61
+ //start the main function
62
+ fshBuff.push('void main(void) {')
63
+
64
+ // apply the stretching of t
65
+ if (stretching) {
66
+ if (stretching.fun == 'pow')
67
+ //sPow = (t, alpha = 3) => Math.pow(t, alpha);
68
+ fshBuff.push(' float t = pow(vt, alpha);')
69
+ else if (stretching.fun == 'powInv')
70
+ //sPowRev = (t, alpha = 3) => 1 - Math.pow(1 - t, 1 / alpha);
71
+ fshBuff.push(' float t = 1.0-pow(1.0-vt, 1.0/alpha);')
72
+ else if (stretching.fun == 'exp')
73
+ //sExp = (t, alpha = 3) => alpha == 0 ? t : (Math.exp(t * alpha) - 1) / (Math.exp(alpha) - 1);
74
+ fshBuff.push(
75
+ stretching.alpha == 0
76
+ ? `float t = vt;`
77
+ : ' float t = (exp(vt * alpha) - 1.0) / (exp(alpha) - 1.0);')
78
+ else if (stretching.fun == 'log')
79
+ //sExpRev = (t, alpha = 3) => alpha == 0 ? t : 1 - (1 / alpha) * Math.log(Math.exp(alpha) * (1 - t) + t);
80
+ fshBuff.push(
81
+ stretching.alpha == 0
82
+ ? `float t = vt;`
83
+ : ' float t = 1.0 - (1.0 / alpha) * log(exp(alpha) * (1.0 - vt) + vt);')
84
+ else if (stretching.fun == 'circle') {
85
+ if (stretching.alpha == 0)
86
+ //if (alpha == 0) return t;
87
+ fshBuff.push(' float t = vt;')
88
+ else if (stretching.alpha == 1)
89
+ // if (alpha == 1) return Math.sqrt(2 * t - t * t);
90
+ fshBuff.push(' float t = sqrt(vt * (2.0 - vt));')
91
+ else {
92
+ //const a = alpha / (1 - alpha);
93
+ //return Math.sqrt(1 / (a * a) + t * (2 / a + 2 - t)) - 1 / a;
94
+ fshBuff.push(' float a = alpha / (1.0 - alpha);')
95
+ fshBuff.push(' float t = sqrt(1.0 / (a * a) + vt * ( 2.0/a + 2.0 - vt )) - 1.0 / a;')
96
+ }
97
+ } else if (stretching.fun == 'circleInv') {
98
+ // 1 - sCircleLow(1 - t, alpha)
99
+ if (stretching.alpha == 0)
100
+ //if (alpha == 0) return t;
101
+ fshBuff.push(' float t = vt;')
102
+ else if (stretching.alpha == 1)
103
+ // if (alpha == 1) return Math.sqrt(2 * t - t * t);
104
+ fshBuff.push(' float t = 1.0 - sqrt((1.0 - vt) * (1.0 + vt));')
105
+ else {
106
+ //const a = alpha / (1 - alpha);
107
+ //return Math.sqrt(1 / (a * a) + (2 * t) / a + 2 * t - t * t) - 1 / a;
108
+ fshBuff.push(' float a = alpha / (1.0 - alpha);')
109
+ fshBuff.push(' float t = 1.0 - sqrt(1.0 / (a * a) + (1.0-vt) * ( 2.0/a + 1.0 + vt )) + 1.0 / a;')
110
+ }
111
+ } else {
112
+ console.error('Unexpected stretching function code: ' + stretching.fun)
113
+ fshBuff.push(' float t = vt;')
114
+ }
115
+ } else {
116
+ fshBuff.push(' float t = vt;')
117
+ }
118
+
119
+ //choose initial and final colors, and adjust t value
120
+ if (colors.length == 1) {
121
+ fshBuff.push(' vec4 cI=c0;')
122
+ fshBuff.push(' vec4 cF=c0;')
123
+ }
124
+ else if (colors.length == 2) {
125
+ fshBuff.push(' vec4 cI=c0;')
126
+ fshBuff.push(' vec4 cF=c1;')
127
+ } else {
128
+ const nb = colors.length - 1
129
+ const nbs = nb + '.0'
130
+ fshBuff.push(' vec4 cI;')
131
+ fshBuff.push(' vec4 cF;')
132
+ fshBuff.push(' if(t<1.0/' + nbs + ') { cI=c0; cF=c1; t=t*' + nbs + '; }')
133
+ for (let i = 2; i < nb; i++)
134
+ fshBuff.push(
135
+ ' else if(t<' +
136
+ i +
137
+ '.0/' +
138
+ nbs +
139
+ ') { cI=c' +
140
+ (i - 1) +
141
+ '; cF=c' +
142
+ i +
143
+ '; t=' +
144
+ nbs +
145
+ '*t-' +
146
+ (i - 1) +
147
+ '.0; }')
148
+ fshBuff.push(' else { cI=c' + (nb - 1) + '; cF=c' + nb + '; t=' + nbs + '*t-' + (nb - 1) + '.0; }')
149
+ }
150
+
151
+ //one single color
152
+ if (colors.length == 1) fshBuff.push(' gl_FragColor = vec4(c0[0], c0[1], c0[2], c0[3]);}')
153
+ //set interpolated color, between initial and final one
154
+ else fshBuff.push(' gl_FragColor = mix(cI, cF, t);}')
155
+
156
+ let fshString = fshBuff.join("")
157
+ //let fshString = fshBuff.join("\n")
158
+ //console.log(fshString)
159
+
160
+ /** @type {WebGLShader} */
161
+ const fShader = createShader(gl, gl.FRAGMENT_SHADER, fshString)
162
+
163
+ /** @type {WebGLProgram} */
164
+ this.program = initShaderProgram(gl, vShader, fShader)
165
+ gl.useProgram(this.program)
166
+
167
+ //set uniforms
168
+
169
+ //sizePix
170
+ //TODO: bug here. Seems to be limited to some threshold value (around 250).
171
+ gl.uniform1f(gl.getUniformLocation(this.program, 'sizePix'), 1.0 * sizePix)
172
+
173
+ //stretching alpha factor
174
+ gl.uniform1f(gl.getUniformLocation(this.program, 'alpha'), stretching ? 1.0 * stretching.alpha : 0.0)
175
+
176
+ //colors
177
+ for (let i = 0; i < colors.length; i++) {
178
+ const c = color(colors[i])
179
+
180
+ let opacity = c.opacity
181
+ if (c.opacity == 1 && globalOpacity != undefined) opacity = globalOpacity
182
+
183
+ const colData = [+c.r / 255.0, +c.g / 255.0, +c.b / 255.0, +opacity]
184
+ //console.log(i, colors[i], c, colData)
185
+ gl.uniform4fv(gl.getUniformLocation(this.program, 'c' + i), colData)
186
+ }
187
+ }
188
+
189
+ /** */
190
+ draw(verticesBuffer, tBuffer, transfoMat) {
191
+ const gl = this.gl
192
+ const program = this.program
193
+
194
+ //vertice data
195
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
196
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(verticesBuffer), gl.STATIC_DRAW)
197
+ const position = gl.getAttribLocation(program, 'pos')
198
+ gl.vertexAttribPointer(
199
+ position,
200
+ 2, //numComponents
201
+ gl.FLOAT, //type
202
+ false, //normalise
203
+ 0, //stride
204
+ 0 //offset
205
+ )
206
+ gl.enableVertexAttribArray(position)
207
+
208
+ //t data
209
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
210
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(tBuffer), gl.STATIC_DRAW)
211
+ const t = gl.getAttribLocation(program, 't')
212
+ gl.vertexAttribPointer(t, 1, gl.FLOAT, false, 0, 0)
213
+ gl.enableVertexAttribArray(t)
214
+
215
+ //transformation
216
+ gl.uniformMatrix3fv(gl.getUniformLocation(program, 'mat'), false, new Float32Array(transfoMat))
217
+
218
+ // Enable the depth test
219
+ //gl.enable(gl.DEPTH_TEST);
220
+ // Clear the color buffer bit
221
+ gl.clear(gl.COLOR_BUFFER_BIT)
222
+ // Set the view port
223
+ //gl.viewport(0, 0, cg.w, cg.h);
224
+
225
+ gl.drawArrays(gl.POINTS, 0, verticesBuffer.length / 2)
226
+ }
227
+ }