@@ -103,10 +103,10 @@ test('Attribute#allocate', t => {
103
103
t . ok ( attribute . allocate ( 4 ) , 'allocate successful' ) ;
104
104
t . is ( attribute . value , allocatedValue , 'reused the same typed array' ) ;
105
105
106
- attribute . setConstantValue ( [ 1 , 1 ] ) ;
106
+ attribute . setConstantValue ( this , [ 1 , 1 ] ) ;
107
107
t . deepEquals ( attribute . value , [ 1 , 1 ] , 'value overwritten by external constant' ) ;
108
108
109
- attribute . setConstantValue ( undefined ) ;
109
+ attribute . setConstantValue ( this , undefined ) ;
110
110
t . ok ( attribute . allocate ( 4 ) , 'allocate successful' ) ;
111
111
t . is ( attribute . value , allocatedValue , 'reused the same typed array' ) ;
112
112
@@ -136,14 +136,14 @@ test('Attribute#setConstantValue', t => {
136
136
t . ok ( attribute . getValue ( ) . positions instanceof Buffer , 'attribute is using packed buffer' ) ;
137
137
attribute . needsRedraw ( { clearChangedFlags : true } ) ;
138
138
139
- attribute . setConstantValue ( [ 0 , 0 , 0 ] ) ;
139
+ attribute . setConstantValue ( this , [ 0 , 0 , 0 ] ) ;
140
140
t . deepEqual ( attribute . getValue ( ) . positions , [ 0 , 0 , 0 ] , 'attribute set to constant value' ) ;
141
141
t . ok ( attribute . needsRedraw ( { clearChangedFlags : true } ) , 'attribute marked needs redraw' ) ;
142
142
143
- attribute . setConstantValue ( [ 0 , 0 , 0 ] ) ;
143
+ attribute . setConstantValue ( this , [ 0 , 0 , 0 ] ) ;
144
144
t . notOk ( attribute . needsRedraw ( { clearChangedFlags : true } ) , 'attribute should not need redraw' ) ;
145
145
146
- attribute . setConstantValue ( [ 0 , 0 , 1 ] ) ;
146
+ attribute . setConstantValue ( this , [ 0 , 0 , 1 ] ) ;
147
147
t . deepEqual ( attribute . getValue ( ) . positions , [ 0 , 0 , 1 ] , 'attribute set to constant value' ) ;
148
148
t . ok ( attribute . needsRedraw ( { clearChangedFlags : true } ) , 'attribute marked needs redraw' ) ;
149
149
@@ -156,7 +156,7 @@ test('Attribute#setConstantValue', t => {
156
156
accessor : 'getColor'
157
157
} ) ;
158
158
159
- attribute . setConstantValue ( [ 255 , 255 , 0 ] ) ;
159
+ attribute . setConstantValue ( this , [ 255 , 255 , 0 ] ) ;
160
160
t . deepEqual ( attribute . getValue ( ) . colors , [ 1 , 1 , 0 ] , 'constant value is normalized' ) ;
161
161
162
162
t . end ( ) ;
@@ -277,7 +277,8 @@ test('Attribute#updateBuffer', t => {
277
277
{ id : 'E' , value : 0 , color : undefined }
278
278
] ,
279
279
getColor : d => d . color ,
280
- getValue : d => d . value
280
+ getValue : d => d . value ,
281
+ getValueConstant : [ 20 ]
281
282
} ;
282
283
283
284
const TEST_PARAMS = [
@@ -341,6 +342,18 @@ test('Attribute#updateBuffer', t => {
341
342
standard : [ 20 , 40 , 14 , 0 ] ,
342
343
'variable size' : [ 20 , 20 , 40 , 14 , 14 , 14 , 14 , 0 , 0 , 0 ]
343
344
} ,
345
+ {
346
+ title : 'constant accessor with transform' ,
347
+ attribute : new Attribute ( device , {
348
+ id : 'values' ,
349
+ type : 'float32' ,
350
+ size : 1 ,
351
+ accessor : 'getValueConstant' ,
352
+ transform : x => x * 2
353
+ } ) ,
354
+ standard : [ 40 , 40 , 40 , 40 ] ,
355
+ 'variable size' : [ 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 , 40 ]
356
+ } ,
344
357
{
345
358
title : 'custom accessor' ,
346
359
attribute : new Attribute ( device , {
@@ -1114,7 +1127,7 @@ test('Attribute#updateBuffer', t => {
1114
1127
t . is ( bounds , attribute . getBounds ( ) , 'bounds is cached' ) ;
1115
1128
1116
1129
attribute . setNeedsUpdate ( ) ;
1117
- attribute . setConstantValue ( [ - 1 , 0 , 1 ] ) ;
1130
+ attribute . setConstantValue ( this , [ - 1 , 0 , 1 ] ) ;
1118
1131
1119
1132
bounds = attribute . getBounds ( ) ;
1120
1133
t . deepEqual (
0 commit comments