Skip to content
Merged
4 changes: 2 additions & 2 deletions modules/core/src/lib/attribute/attribute-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class AttributeManager {
} else if (
typeof accessorName === 'string' &&
!buffers[accessorName] &&
attribute.setConstantValue(props[accessorName])
attribute.setConstantValue(props[accessorName], context)
) {
// Step 3: try set constant value from props
// Note: if buffers[accessorName] is supplied, ignore props[accessorName]
Expand Down Expand Up @@ -380,7 +380,7 @@ export default class AttributeManager {
// The attribute is flagged as constant outside of an update cycle
// Skip allocation and updater call
// @ts-ignore value can be set to an array by user but always cast to typed array during attribute update
attribute.setConstantValue(attribute.value);
attribute.setConstantValue(attribute.value, context);
return;
}

Expand Down
5 changes: 3 additions & 2 deletions modules/core/src/lib/attribute/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export default class Attribute extends DataColumn<AttributeOptions, AttributeInt

// Use generic value
// Returns true if successful
setConstantValue(value?: NumericArray): boolean {
setConstantValue(value?: any, context?: any): boolean {
// TODO(ibgreen): WebGPU does not support constant values,
// they will be emulated as buffers instead for now.
const isWebGPU = this.device.type === 'webgpu';
Expand All @@ -270,7 +270,8 @@ export default class Attribute extends DataColumn<AttributeOptions, AttributeInt
return false;
}

const hasChanged = this.setData({constant: true, value});
const objectValue = this.settings.transform ? this.settings.transform.call(context, value) : value;
const hasChanged = this.setData({constant:true, value: objectValue});

if (hasChanged) {
this.setNeedsRedraw();
Expand Down