@@ -141,7 +141,7 @@ function makePoints(sampleCount, dimensionCount, dimensions, color) {
141
141
return points ;
142
142
}
143
143
144
- function makeVecAttr ( sampleCount , points , vecIndex ) {
144
+ function makeVecAttr ( regl , sampleCount , points , vecIndex ) {
145
145
146
146
var i , j , k ;
147
147
var pointPairs = [ ] ;
@@ -157,18 +157,16 @@ function makeVecAttr(sampleCount, points, vecIndex) {
157
157
}
158
158
}
159
159
160
- return pointPairs ;
160
+ return regl . buffer ( pointPairs ) ;
161
161
}
162
162
163
- function makeAttributes ( sampleCount , points ) {
164
-
165
- var vecIndices = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ] ;
166
- var vectors = vecIndices . map ( function ( vecIndex ) { return makeVecAttr ( sampleCount , points , vecIndex ) ; } ) ;
163
+ function makeAttributes ( regl , sampleCount , points ) {
167
164
168
165
var attributes = { } ;
169
- vectors . forEach ( function ( v , vecIndex ) {
170
- attributes [ 'p' + vecIndex . toString ( 16 ) ] = v ;
171
- } ) ;
166
+
167
+ for ( var i = 0 ; i < 16 ; i ++ ) {
168
+ attributes [ 'p' + i . toString ( 16 ) ] = makeVecAttr ( regl , sampleCount , points , i ) ;
169
+ }
172
170
173
171
return attributes ;
174
172
}
@@ -206,11 +204,11 @@ module.exports = function(canvasGL, d) {
206
204
207
205
var panelCount = initialPanels . length ;
208
206
209
- var points = makePoints ( sampleCount , dimensionCount , initialDims , color ) ;
210
- var attributes = makeAttributes ( sampleCount , points ) ;
211
-
212
207
var regl = d . regl ;
213
208
209
+ var points = makePoints ( sampleCount , dimensionCount , initialDims , color ) ;
210
+ var attributes = makeAttributes ( regl , sampleCount , points ) ;
211
+
214
212
var mask , maskTexture ;
215
213
216
214
var paletteTexture = regl . texture ( {
@@ -509,7 +507,8 @@ module.exports = function(canvasGL, d) {
509
507
function destroy ( ) {
510
508
canvasGL . style [ 'pointer-events' ] = 'none' ;
511
509
paletteTexture . destroy ( ) ;
512
- maskTexture . destroy ( ) ;
510
+ if ( maskTexture ) maskTexture . destroy ( ) ;
511
+ for ( var k in attributes ) attributes [ k ] . destroy ( ) ;
513
512
}
514
513
515
514
return {
0 commit comments