Skip to content

Commit

Permalink
explicitly create AttributeManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed May 12, 2024
1 parent 134a139 commit c354c6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
LayerContext,
UpdateParameters,
CompositeLayerProps,
Attribute
Attribute,
AttributeManager
} from '@deck.gl/core';
import {Aggregator} from './aggregator';

Expand All @@ -28,7 +29,7 @@ export default abstract class AggregationLayer<
cpuAggregator: CPUAggregator | null;
};

/** Allow this layer to have an AttributeManager and participates in the draw cycle */
/** Allow this layer to participates in the draw cycle */
get isDrawable() {
return true;
}
Expand Down Expand Up @@ -89,6 +90,14 @@ export default abstract class AggregationLayer<
return this.state.gpuAggregator || this.state.cpuAggregator;
}

// override CompositeLayer._getAttributeManager to create AttributeManager instance
_getAttributeManager() {
return new AttributeManager(this.context.device, {
id: this.props.id,
stats: this.context.stats
});
}

// Override CompositeLayer._postUpdate to update attributes and the CPUAggregator
protected _postUpdate(updateParams: UpdateParameters<this>, forceUpdate: boolean) {
this._updateAttributes();
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/lib/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ export default abstract class Layer<PropsT extends {} = {}> extends Component<

debug(TRACE_INITIALIZE, this);

const attributeManager = this.isDrawable ? this._getAttributeManager() : null;
const attributeManager = this._getAttributeManager();

if (attributeManager) {
// All instanced layers get instancePickingColors attribute by default
Expand Down

0 comments on commit c354c6e

Please sign in to comment.