gridviz 3.0.26 → 3.0.28

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 +126 -128
  2. package/dist/gridviz.js +8798 -8706
  3. package/dist/gridviz.min.js +1 -1
  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 +544 -544
  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 +78 -77
  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 +224 -214
  28. package/src/layer/GridLayer.js +149 -148
  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/ContourStyle.js +21 -21
  38. package/src/style/DotDensityStyle.js +133 -133
  39. package/src/style/ImageStyle.js +100 -100
  40. package/src/style/IsoFenceStyle.js +217 -217
  41. package/src/style/JoyPlotStyle.js +127 -127
  42. package/src/style/LegoStyle.js +110 -110
  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/ShadingStyle.js +61 -0
  48. package/src/style/ShapeColorSizeStyle.js +147 -147
  49. package/src/style/SideCategoryStyle.js +112 -112
  50. package/src/style/SideStyle.js +212 -212
  51. package/src/style/SquareColorCategoryWebGLStyle.js +107 -107
  52. package/src/style/SquareColorWebGLStyle.js +126 -126
  53. package/src/style/StrokeStyle.js +135 -135
  54. package/src/style/TanakaStyle.js +69 -69
  55. package/src/style/TextStyle.js +110 -110
  56. package/src/style/TimeSeriesStyle.js +222 -222
  57. package/src/utils/WebGLRectangleColoring.js +106 -106
  58. package/src/utils/WebGLSquareColoring.js +118 -118
  59. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  60. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  61. package/src/utils/WebGLSquareColoringKS.js +153 -153
  62. package/src/utils/scale.js +218 -218
  63. package/src/utils/stretching.js +120 -120
  64. package/src/utils/ternary.js +208 -208
  65. package/src/utils/utils.js +58 -58
  66. package/src/utils/webGLUtils.js +72 -72
  67. package/src/utils/zoomUtils.js +142 -142
@@ -1,133 +1,133 @@
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
- * Color based on categories.
11
- */
12
- export class WebGLSquareColoringCatAdvanced {
13
- /**
14
- * @param {Array.<string>} colors
15
- */
16
- constructor(colors) {
17
- /**
18
- * @type {Array.<string>} */
19
- this.colors = colors
20
-
21
- /** Vector shader program
22
- * @type {string} */
23
- this.vshString = `
24
- attribute vec2 pos;
25
- uniform float sizePix;
26
- uniform mat3 mat;
27
-
28
- attribute float i;
29
- varying float vi;
30
-
31
- void main() {
32
- gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
33
- gl_PointSize = sizePix;
34
- vi = i;
35
- }
36
- `
37
-
38
- //prepare fragment shader code
39
- //declare the uniform and other variables
40
- const out = []
41
- out.push('precision mediump float;\nvarying float vi;\n')
42
- //add color uniforms
43
- out.push('uniform vec4')
44
- for (let i = 0; i < colors.length; i++) {
45
- if (i > 0) out.push(',')
46
- out.push(' c' + i)
47
- }
48
- out.push(';\n')
49
- //start the main function
50
- out.push('void main(void) {\n')
51
- //choose color i
52
- for (let i = 0; i < colors.length; i++) {
53
- if (i > 0) out.push('else ')
54
- out.push('if(vi==')
55
- out.push(i)
56
- out.push('.0) gl_FragColor = vec4(c')
57
- out.push(i)
58
- out.push('[0], c')
59
- out.push(i)
60
- out.push('[1], c')
61
- out.push(i)
62
- out.push('[2], c')
63
- out.push(i)
64
- out.push('[3]);\n')
65
- }
66
- out.push('else gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}')
67
- /** Fragment shader program
68
- * @type {string} */
69
- this.fshString = out.join('')
70
- }
71
-
72
- /** */
73
- draw(gl, verticesBuffer, iBuffer, transfoMat, sizePix = 10) {
74
- /** @type {WebGLShader} */
75
- const vShader = createShader(gl, gl.VERTEX_SHADER, this.vshString)
76
-
77
- /** @type {WebGLShader} */
78
- const fShader = createShader(gl, gl.FRAGMENT_SHADER, this.fshString)
79
-
80
- /** @type {WebGLProgram} */
81
- const program = initShaderProgram(gl, vShader, fShader)
82
- gl.useProgram(program)
83
-
84
- //set uniforms
85
-
86
- //sizePix
87
- gl.uniform1f(gl.getUniformLocation(program, 'sizePix'), 1.0 * sizePix)
88
-
89
- //colors
90
- for (let i = 0; i < this.colors.length; i++) {
91
- const c = color(this.colors[i])
92
- gl.uniform4fv(gl.getUniformLocation(program, 'c' + i), [
93
- +c.r / 255.0,
94
- +c.g / 255.0,
95
- +c.b / 255.0,
96
- +c.opacity,
97
- ])
98
- }
99
-
100
- //vertice data
101
- gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
102
- gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(verticesBuffer), gl.STATIC_DRAW)
103
- const position = gl.getAttribLocation(program, 'pos')
104
- gl.vertexAttribPointer(
105
- position,
106
- 2, //numComponents
107
- gl.FLOAT, //type
108
- false, //normalise
109
- 0, //stride
110
- 0 //offset
111
- )
112
- gl.enableVertexAttribArray(position)
113
-
114
- //i data
115
- gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
116
- gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(iBuffer), gl.STATIC_DRAW)
117
- const i = gl.getAttribLocation(program, 'i')
118
- gl.vertexAttribPointer(i, 1, gl.FLOAT, false, 0, 0)
119
- gl.enableVertexAttribArray(i)
120
-
121
- //transformation
122
- gl.uniformMatrix3fv(gl.getUniformLocation(program, 'mat'), false, new Float32Array(transfoMat))
123
-
124
- // Enable the depth test
125
- //gl.enable(gl.DEPTH_TEST);
126
- // Clear the color buffer bit
127
- gl.clear(gl.COLOR_BUFFER_BIT)
128
- // Set the view port
129
- //gl.viewport(0, 0, cg.w, cg.h);
130
-
131
- gl.drawArrays(gl.POINTS, 0, verticesBuffer.length / 2)
132
- }
133
- }
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
+ * Color based on categories.
11
+ */
12
+ export class WebGLSquareColoringCatAdvanced {
13
+ /**
14
+ * @param {Array.<string>} colors
15
+ */
16
+ constructor(colors) {
17
+ /**
18
+ * @type {Array.<string>} */
19
+ this.colors = colors
20
+
21
+ /** Vector shader program
22
+ * @type {string} */
23
+ this.vshString = `
24
+ attribute vec2 pos;
25
+ uniform float sizePix;
26
+ uniform mat3 mat;
27
+
28
+ attribute float i;
29
+ varying float vi;
30
+
31
+ void main() {
32
+ gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
33
+ gl_PointSize = sizePix;
34
+ vi = i;
35
+ }
36
+ `
37
+
38
+ //prepare fragment shader code
39
+ //declare the uniform and other variables
40
+ const out = []
41
+ out.push('precision mediump float;\nvarying float vi;\n')
42
+ //add color uniforms
43
+ out.push('uniform vec4')
44
+ for (let i = 0; i < colors.length; i++) {
45
+ if (i > 0) out.push(',')
46
+ out.push(' c' + i)
47
+ }
48
+ out.push(';\n')
49
+ //start the main function
50
+ out.push('void main(void) {\n')
51
+ //choose color i
52
+ for (let i = 0; i < colors.length; i++) {
53
+ if (i > 0) out.push('else ')
54
+ out.push('if(vi==')
55
+ out.push(i)
56
+ out.push('.0) gl_FragColor = vec4(c')
57
+ out.push(i)
58
+ out.push('[0], c')
59
+ out.push(i)
60
+ out.push('[1], c')
61
+ out.push(i)
62
+ out.push('[2], c')
63
+ out.push(i)
64
+ out.push('[3]);\n')
65
+ }
66
+ out.push('else gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}')
67
+ /** Fragment shader program
68
+ * @type {string} */
69
+ this.fshString = out.join('')
70
+ }
71
+
72
+ /** */
73
+ draw(gl, verticesBuffer, iBuffer, transfoMat, sizePix = 10) {
74
+ /** @type {WebGLShader} */
75
+ const vShader = createShader(gl, gl.VERTEX_SHADER, this.vshString)
76
+
77
+ /** @type {WebGLShader} */
78
+ const fShader = createShader(gl, gl.FRAGMENT_SHADER, this.fshString)
79
+
80
+ /** @type {WebGLProgram} */
81
+ const program = initShaderProgram(gl, vShader, fShader)
82
+ gl.useProgram(program)
83
+
84
+ //set uniforms
85
+
86
+ //sizePix
87
+ gl.uniform1f(gl.getUniformLocation(program, 'sizePix'), 1.0 * sizePix)
88
+
89
+ //colors
90
+ for (let i = 0; i < this.colors.length; i++) {
91
+ const c = color(this.colors[i])
92
+ gl.uniform4fv(gl.getUniformLocation(program, 'c' + i), [
93
+ +c.r / 255.0,
94
+ +c.g / 255.0,
95
+ +c.b / 255.0,
96
+ +c.opacity,
97
+ ])
98
+ }
99
+
100
+ //vertice data
101
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
102
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(verticesBuffer), gl.STATIC_DRAW)
103
+ const position = gl.getAttribLocation(program, 'pos')
104
+ gl.vertexAttribPointer(
105
+ position,
106
+ 2, //numComponents
107
+ gl.FLOAT, //type
108
+ false, //normalise
109
+ 0, //stride
110
+ 0 //offset
111
+ )
112
+ gl.enableVertexAttribArray(position)
113
+
114
+ //i data
115
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
116
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(iBuffer), gl.STATIC_DRAW)
117
+ const i = gl.getAttribLocation(program, 'i')
118
+ gl.vertexAttribPointer(i, 1, gl.FLOAT, false, 0, 0)
119
+ gl.enableVertexAttribArray(i)
120
+
121
+ //transformation
122
+ gl.uniformMatrix3fv(gl.getUniformLocation(program, 'mat'), false, new Float32Array(transfoMat))
123
+
124
+ // Enable the depth test
125
+ //gl.enable(gl.DEPTH_TEST);
126
+ // Clear the color buffer bit
127
+ gl.clear(gl.COLOR_BUFFER_BIT)
128
+ // Set the view port
129
+ //gl.viewport(0, 0, cg.w, cg.h);
130
+
131
+ gl.drawArrays(gl.POINTS, 0, verticesBuffer.length / 2)
132
+ }
133
+ }
@@ -1,153 +1,153 @@
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 WebGLSquareColoringKS {
13
- //see:
14
- //https://webglfundamentals.org/
15
- //https://webglfundamentals.org/webgl/lessons/fr/webgl-shaders-and-glsl.html#les-uniforms-dans-les-shaders-de-vertex
16
- //https://thebookofshaders.com/glossary/?search=mix
17
- //https://thebookofshaders.com/06/
18
- //https://thebookofshaders.com/glossary/
19
-
20
- /**
21
- *
22
- * @param {*} gl
23
- * @param {Array.<String>} colors
24
- * @param {{fun:string,alpha:number}} stretching
25
- * @param {number} sizePix
26
- */
27
- constructor(gl, colors, stretching, sizePix = 10) {
28
- /** @type {WebGLRenderingContext} */
29
- this.gl = gl
30
-
31
- /** @type {WebGLShader} */
32
- const vShader = createShader(
33
- gl,
34
- gl.VERTEX_SHADER,
35
- `
36
- attribute vec2 pos;
37
- uniform float sizePix;
38
- uniform vec3 data[2];
39
- uniform mat3 mat;
40
-
41
- varying float vt;
42
-
43
- void main() {
44
-
45
- //one vertex for each screen pixels
46
- //list of data as uniform
47
- //compute smoothed t here from uniforms
48
-
49
- //compute cell screen position
50
- gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
51
-
52
- //set pixel size - same for all
53
- gl_PointSize = sizePix;
54
-
55
- //pass the pixel value to the fragment as varying
56
- vt = data[2];
57
- }
58
- `
59
- )
60
-
61
- //prepare fragment shader code
62
- //declare the uniform and other variables
63
- let fshString = `
64
- precision mediump float;
65
- varying float vt;
66
- uniform float alpha;
67
- uniform vec4 c0;
68
- uniform vec4 c1;
69
- uniform vec4 c2;
70
- uniform vec4 c3;
71
- uniform vec4 c4;
72
- void main(void) {
73
- if(vt == 0.0) return;
74
- float t = 1.0 - (1.0 / alpha) * log(exp(alpha) * (1.0 - vt) + vt);
75
- vec4 cI;
76
- vec4 cF;
77
- if(t<1.0/4.0) { cI=c0; cF=c1; t=t*4.0; }
78
- else if(t<2.0/4.0) { cI=c1; cF=c2; t=4.0*t-1.0; }
79
- else if(t<3.0/4.0) { cI=c2; cF=c3; t=4.0*t-2.0; }
80
- else { cI=c3; cF=c4; t=4.0*t-3.0; }
81
- gl_FragColor = mix(cI, cF, t);
82
- }`
83
-
84
- /** @type {WebGLShader} */
85
- const fShader = createShader(gl, gl.FRAGMENT_SHADER, fshString)
86
-
87
- /** @type {WebGLProgram} */
88
- this.program = initShaderProgram(gl, vShader, fShader)
89
- gl.useProgram(this.program)
90
-
91
- //set uniforms
92
-
93
- //sizePix
94
- gl.uniform1f(gl.getUniformLocation(this.program, 'sizePix'), 1.0 * sizePix)
95
-
96
- //stretching alpha factor
97
- gl.uniform1f(gl.getUniformLocation(this.program, 'alpha'), stretching ? 1.0 * stretching.alpha : 0.0)
98
-
99
- //colors
100
- for (let i = 0; i < colors.length; i++) {
101
- const c = color(colors[i])
102
- gl.uniform4fv(gl.getUniformLocation(this.program, 'c' + i), [
103
- +c.r / 255.0,
104
- +c.g / 255.0,
105
- +c.b / 255.0,
106
- +c.opacity,
107
- ])
108
- }
109
- }
110
-
111
- /** */
112
- draw(verticesBuffer, data, transfoMat) {
113
- const gl = this.gl
114
- const program = this.program
115
-
116
- //vertice data
117
- gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
118
- gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(verticesBuffer), gl.STATIC_DRAW)
119
- const position = gl.getAttribLocation(program, 'pos')
120
- gl.vertexAttribPointer(
121
- position,
122
- 2, //numComponents
123
- gl.FLOAT, //type
124
- false, //normalise
125
- 0, //stride
126
- 0 //offset
127
- )
128
- gl.enableVertexAttribArray(position)
129
-
130
- //t data
131
- /*gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
132
- gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(tBuffer), gl.STATIC_DRAW);
133
- const t = gl.getAttribLocation(program, "t");
134
- gl.vertexAttribPointer(t, 1, gl.FLOAT, false, 0, 0);
135
- gl.enableVertexAttribArray(t);*/
136
-
137
- //data
138
- //gl.uniformMatrix3fv(gl.getUniformLocation(program, "mat"), false, new Float32Array(transfoMat));
139
- gl.uniform3fv(gl.getUniformLocation(program, 'data'), 2, new Float32Array(data))
140
-
141
- //transformation
142
- gl.uniformMatrix3fv(gl.getUniformLocation(program, 'mat'), false, new Float32Array(transfoMat))
143
-
144
- // Enable the depth test
145
- //gl.enable(gl.DEPTH_TEST);
146
- // Clear the color buffer bit
147
- gl.clear(gl.COLOR_BUFFER_BIT)
148
- // Set the view port
149
- //gl.viewport(0, 0, cg.w, cg.h);
150
-
151
- gl.drawArrays(gl.POINTS, 0, verticesBuffer.length / 2)
152
- }
153
- }
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 WebGLSquareColoringKS {
13
+ //see:
14
+ //https://webglfundamentals.org/
15
+ //https://webglfundamentals.org/webgl/lessons/fr/webgl-shaders-and-glsl.html#les-uniforms-dans-les-shaders-de-vertex
16
+ //https://thebookofshaders.com/glossary/?search=mix
17
+ //https://thebookofshaders.com/06/
18
+ //https://thebookofshaders.com/glossary/
19
+
20
+ /**
21
+ *
22
+ * @param {*} gl
23
+ * @param {Array.<String>} colors
24
+ * @param {{fun:string,alpha:number}} stretching
25
+ * @param {number} sizePix
26
+ */
27
+ constructor(gl, colors, stretching, sizePix = 10) {
28
+ /** @type {WebGLRenderingContext} */
29
+ this.gl = gl
30
+
31
+ /** @type {WebGLShader} */
32
+ const vShader = createShader(
33
+ gl,
34
+ gl.VERTEX_SHADER,
35
+ `
36
+ attribute vec2 pos;
37
+ uniform float sizePix;
38
+ uniform vec3 data[2];
39
+ uniform mat3 mat;
40
+
41
+ varying float vt;
42
+
43
+ void main() {
44
+
45
+ //one vertex for each screen pixels
46
+ //list of data as uniform
47
+ //compute smoothed t here from uniforms
48
+
49
+ //compute cell screen position
50
+ gl_Position = vec4(mat * vec3(pos, 1.0), 1.0);
51
+
52
+ //set pixel size - same for all
53
+ gl_PointSize = sizePix;
54
+
55
+ //pass the pixel value to the fragment as varying
56
+ vt = data[2];
57
+ }
58
+ `
59
+ )
60
+
61
+ //prepare fragment shader code
62
+ //declare the uniform and other variables
63
+ let fshString = `
64
+ precision mediump float;
65
+ varying float vt;
66
+ uniform float alpha;
67
+ uniform vec4 c0;
68
+ uniform vec4 c1;
69
+ uniform vec4 c2;
70
+ uniform vec4 c3;
71
+ uniform vec4 c4;
72
+ void main(void) {
73
+ if(vt == 0.0) return;
74
+ float t = 1.0 - (1.0 / alpha) * log(exp(alpha) * (1.0 - vt) + vt);
75
+ vec4 cI;
76
+ vec4 cF;
77
+ if(t<1.0/4.0) { cI=c0; cF=c1; t=t*4.0; }
78
+ else if(t<2.0/4.0) { cI=c1; cF=c2; t=4.0*t-1.0; }
79
+ else if(t<3.0/4.0) { cI=c2; cF=c3; t=4.0*t-2.0; }
80
+ else { cI=c3; cF=c4; t=4.0*t-3.0; }
81
+ gl_FragColor = mix(cI, cF, t);
82
+ }`
83
+
84
+ /** @type {WebGLShader} */
85
+ const fShader = createShader(gl, gl.FRAGMENT_SHADER, fshString)
86
+
87
+ /** @type {WebGLProgram} */
88
+ this.program = initShaderProgram(gl, vShader, fShader)
89
+ gl.useProgram(this.program)
90
+
91
+ //set uniforms
92
+
93
+ //sizePix
94
+ gl.uniform1f(gl.getUniformLocation(this.program, 'sizePix'), 1.0 * sizePix)
95
+
96
+ //stretching alpha factor
97
+ gl.uniform1f(gl.getUniformLocation(this.program, 'alpha'), stretching ? 1.0 * stretching.alpha : 0.0)
98
+
99
+ //colors
100
+ for (let i = 0; i < colors.length; i++) {
101
+ const c = color(colors[i])
102
+ gl.uniform4fv(gl.getUniformLocation(this.program, 'c' + i), [
103
+ +c.r / 255.0,
104
+ +c.g / 255.0,
105
+ +c.b / 255.0,
106
+ +c.opacity,
107
+ ])
108
+ }
109
+ }
110
+
111
+ /** */
112
+ draw(verticesBuffer, data, transfoMat) {
113
+ const gl = this.gl
114
+ const program = this.program
115
+
116
+ //vertice data
117
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer())
118
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(verticesBuffer), gl.STATIC_DRAW)
119
+ const position = gl.getAttribLocation(program, 'pos')
120
+ gl.vertexAttribPointer(
121
+ position,
122
+ 2, //numComponents
123
+ gl.FLOAT, //type
124
+ false, //normalise
125
+ 0, //stride
126
+ 0 //offset
127
+ )
128
+ gl.enableVertexAttribArray(position)
129
+
130
+ //t data
131
+ /*gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
132
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(tBuffer), gl.STATIC_DRAW);
133
+ const t = gl.getAttribLocation(program, "t");
134
+ gl.vertexAttribPointer(t, 1, gl.FLOAT, false, 0, 0);
135
+ gl.enableVertexAttribArray(t);*/
136
+
137
+ //data
138
+ //gl.uniformMatrix3fv(gl.getUniformLocation(program, "mat"), false, new Float32Array(transfoMat));
139
+ gl.uniform3fv(gl.getUniformLocation(program, 'data'), 2, new Float32Array(data))
140
+
141
+ //transformation
142
+ gl.uniformMatrix3fv(gl.getUniformLocation(program, 'mat'), false, new Float32Array(transfoMat))
143
+
144
+ // Enable the depth test
145
+ //gl.enable(gl.DEPTH_TEST);
146
+ // Clear the color buffer bit
147
+ gl.clear(gl.COLOR_BUFFER_BIT)
148
+ // Set the view port
149
+ //gl.viewport(0, 0, cg.w, cg.h);
150
+
151
+ gl.drawArrays(gl.POINTS, 0, verticesBuffer.length / 2)
152
+ }
153
+ }