@@ -141,7 +141,7 @@ function makePoints(sampleCount, dimensionCount, dimensions, color) {
141141 return points ;
142142}
143143
144- function makeVecAttr ( sampleCount , points , vecIndex ) {
144+ function makeVecAttr ( regl , sampleCount , points , vecIndex ) {
145145
146146 var i , j , k ;
147147 var pointPairs = [ ] ;
@@ -157,18 +157,16 @@ function makeVecAttr(sampleCount, points, vecIndex) {
157157 }
158158 }
159159
160- return pointPairs ;
160+ return regl . buffer ( pointPairs ) ;
161161}
162162
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 ) {
167164
168165 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+ }
172170
173171 return attributes ;
174172}
@@ -206,11 +204,11 @@ module.exports = function(canvasGL, d) {
206204
207205 var panelCount = initialPanels . length ;
208206
209- var points = makePoints ( sampleCount , dimensionCount , initialDims , color ) ;
210- var attributes = makeAttributes ( sampleCount , points ) ;
211-
212207 var regl = d . regl ;
213208
209+ var points = makePoints ( sampleCount , dimensionCount , initialDims , color ) ;
210+ var attributes = makeAttributes ( regl , sampleCount , points ) ;
211+
214212 var mask , maskTexture ;
215213
216214 var paletteTexture = regl . texture ( {
@@ -509,7 +507,8 @@ module.exports = function(canvasGL, d) {
509507 function destroy ( ) {
510508 canvasGL . style [ 'pointer-events' ] = 'none' ;
511509 paletteTexture . destroy ( ) ;
512- maskTexture . destroy ( ) ;
510+ if ( maskTexture ) maskTexture . destroy ( ) ;
511+ for ( var k in attributes ) attributes [ k ] . destroy ( ) ;
513512 }
514513
515514 return {
0 commit comments