Skip to content

Commit

Permalink
Move getShaderAttributes to AttributeManager
Browse files Browse the repository at this point in the history
  • Loading branch information
1chandu committed Nov 5, 2019
1 parent 105d0af commit 35163e3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 1 addition & 3 deletions modules/aggregation-layers/src/aggregation-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export default class AggregationLayer extends CompositeLayer {
}

getAttributes() {
const attributes = this.getAttributeManager().getAttributes();
// call Layer method to get shader attributes
return this._getShaderAttributes(attributes);
return this.getAttributeManager().getShaderAttributes();
}

getModuleSettings() {
Expand Down
14 changes: 14 additions & 0 deletions modules/core/src/lib/attribute-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ export default class AttributeManager {
return changedAttributes;
}

// Returns shader attributes
getShaderAttributes(attributes, excludeAttributes = {}) {
if (!attributes) {
attributes = this.getAttributes();
}
const shaderAttributes = {};
for (const attributeName in attributes) {
if (!excludeAttributes[attributeName]) {
Object.assign(shaderAttributes, attributes[attributeName].getShaderAttributes());
}
}
return shaderAttributes;
}

// PROTECTED METHODS - Only to be used by collaborating classes, not by apps

// Returns object containing all accessors as keys, with non-null values
Expand Down
16 changes: 5 additions & 11 deletions modules/core/src/lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,13 @@ export default class Layer extends Component {
value.set(pickingColorCache.subarray(startRow * size, endRow * size), startRow * size);
}

_getShaderAttributes(attributes, excludeAttributes = {}) {
const shaderAttributes = {};
for (const attributeName in attributes) {
if (!excludeAttributes[attributeName]) {
Object.assign(shaderAttributes, attributes[attributeName].getShaderAttributes());
}
}
return shaderAttributes;
}

_setModelAttributes(model, changedAttributes) {
const attributeManager = this.getAttributeManager();
const excludeAttributes = model.userData.excludeAttributes || {};
const shaderAttributes = this._getShaderAttributes(changedAttributes, excludeAttributes);
const shaderAttributes = attributeManager.getShaderAttributes(
changedAttributes,
excludeAttributes
);

model.setAttributes(shaderAttributes);
}
Expand Down

0 comments on commit 35163e3

Please sign in to comment.