@@ -255,9 +255,18 @@ export default class Attribute extends DataColumn<AttributeOptions, AttributeInt
255
255
// Use generic value
256
256
// Returns true if successful
257
257
setConstantValue ( value ?: NumericArray ) : boolean {
258
- // TODO(ibgreen): WebGPU does not support constant values
258
+ // TODO(ibgreen): WebGPU does not support constant values,
259
+ // they will be emulated as buffers instead for now.
259
260
const isWebGPU = this . device . type === 'webgpu' ;
260
261
if ( isWebGPU || value === undefined || typeof value === 'function' ) {
262
+ if ( isWebGPU && typeof value !== 'function' ) {
263
+ const normalisedValue = this . _normalizeValue ( value , [ ] , 0 ) ;
264
+ // ensure we trigger an update for the attribute's emulated buffer
265
+ // where webgl would perform the update here
266
+ if ( ! this . _areValuesEqual ( normalisedValue , this . value ) ) {
267
+ this . setNeedsUpdate ( 'WebGPU constant updated' ) ;
268
+ }
269
+ }
261
270
return false ;
262
271
}
263
272
@@ -435,8 +444,8 @@ export default class Attribute extends DataColumn<AttributeOptions, AttributeInt
435
444
// @ts -ignore
436
445
( typeof accessor === 'function' ? accessor : props [ accessor ] ) ;
437
446
// TODO(ibgreen) WebGPU needs buffers, generate an accessor function from a constant
438
- if ( typeof accessorFunc !== 'function' ) {
439
- accessorFunc = ( ) => accessorFunc ;
447
+ if ( typeof accessorFunc !== 'function' && typeof accessor === 'string' ) {
448
+ accessorFunc = ( ) => props [ accessor ] ;
440
449
}
441
450
assert ( typeof accessorFunc === 'function' , `accessor "${ accessor } " is not a function` ) ;
442
451
0 commit comments