@@ -165,13 +165,13 @@ function Scatter (regl, options) {
165
165
} : { constant : [ Math . round ( prop . borderSize * 255 / maxSize ) ] } ,
166
166
colorId : ( ctx , prop ) => prop . color . length ? {
167
167
buffer : colorBuffer ,
168
- stride : 4 ,
168
+ stride : 8 ,
169
169
offset : 0
170
170
} : { constant : [ prop . color ] } ,
171
171
borderColorId : ( ctx , prop ) => prop . borderColor . length ? {
172
172
buffer : colorBuffer ,
173
- stride : 4 ,
174
- offset : 2
173
+ stride : 8 ,
174
+ offset : 4
175
175
} : { constant : [ prop . borderColor ] }
176
176
} ,
177
177
@@ -443,7 +443,9 @@ function Scatter (regl, options) {
443
443
scatter2d . groups = groups = options . map ( ( options , i ) => {
444
444
let group = groups [ i ]
445
445
446
- if ( ! options ) return group
446
+ if ( options === undefined ) return group
447
+
448
+ if ( options === null ) options = { positions : null }
447
449
else if ( typeof options === 'function' ) options = { after : options }
448
450
else if ( typeof options [ 0 ] === 'number' ) options = { positions : options }
449
451
@@ -461,6 +463,9 @@ function Scatter (regl, options) {
461
463
viewport : 'viewport viewBox' ,
462
464
opacity : 'opacity alpha'
463
465
} )
466
+
467
+ if ( options . positions === null ) options . positions = [ ]
468
+
464
469
if ( ! group ) {
465
470
groups [ i ] = group = {
466
471
id : i ,
@@ -702,22 +707,31 @@ function Scatter (regl, options) {
702
707
}
703
708
704
709
if ( color ) {
705
- let colorData = new Uint16Array ( len * 2 )
710
+ let colorData = new Uint16Array ( len * 4 )
706
711
707
712
groups . forEach ( ( group , i ) => {
708
713
if ( ! group ) return
709
714
let { count, offset, color, borderColor} = group
710
715
if ( ! count ) return
711
716
712
717
if ( color . length || borderColor . length ) {
713
- let colorIds = new Uint16Array ( count * 2 )
718
+ let colorIds = new Uint16Array ( count * 4 )
714
719
for ( let i = 0 ; i < count ; i ++ ) {
715
- colorIds [ i * 2 ] = color [ i ] == null ? color : color [ i ]
716
- colorIds [ i * 2 + 1 ] = borderColor [ i ] == null ? borderColor : borderColor [ i ]
720
+ if ( color [ i ] != null ) {
721
+ colorIds [ i * 4 ] = color [ i ] % maxColors
722
+ colorIds [ i * 4 + 1 ] = Math . floor ( color [ i ] / maxColors )
723
+ }
724
+ if ( borderColor [ i ] != null ) {
725
+ colorIds [ i * 4 + 2 ] = borderColor [ i ] % maxColors
726
+ colorIds [ i * 4 + 3 ] = Math . floor ( borderColor [ i ] / maxColors )
727
+ }
717
728
}
718
- colorData . set ( colorIds , offset * 2 )
729
+
730
+ colorData . set ( colorIds , offset * 4 )
719
731
}
720
732
} )
733
+
734
+
721
735
colorBuffer ( colorData )
722
736
}
723
737
}
0 commit comments