in modules/layers/src/solid-polygon-layer/solid-polygon-layer.js [77:196]
initializeState() {
const {gl, viewport} = this.context;
let {coordinateSystem} = this.props;
if (viewport.isGeospatial && coordinateSystem === COORDINATE_SYSTEM.DEFAULT) {
coordinateSystem = COORDINATE_SYSTEM.LNGLAT;
}
this.setState({
numInstances: 0,
polygonTesselator: new PolygonTesselator({
// Lnglat coordinates are usually projected non-linearly, which affects tesselation results
// Provide a preproject function if the coordinates are in lnglat
preproject: coordinateSystem === COORDINATE_SYSTEM.LNGLAT && viewport.projectFlat,
fp64: this.use64bitPositions(),
IndexType: !gl || hasFeatures(gl, FEATURES.ELEMENT_INDEX_UINT32) ? Uint32Array : Uint16Array
})
});
const attributeManager = this.getAttributeManager();
const noAlloc = true;
attributeManager.remove(['instancePickingColors']);
/* eslint-disable max-len */
attributeManager.add({
indices: {size: 1, isIndexed: true, update: this.calculateIndices, noAlloc},
positions: {
size: 3,
type: GL.DOUBLE,
fp64: this.use64bitPositions(),
transition: ATTRIBUTE_TRANSITION,
accessor: 'getPolygon',
update: this.calculatePositions,
noAlloc,
shaderAttributes: {
positions: {
vertexOffset: 0,
divisor: 0
},
instancePositions: {
vertexOffset: 0,
divisor: 1
},
nextPositions: {
vertexOffset: 1,
divisor: 1
}
}
},
vertexValid: {
size: 1,
divisor: 1,
type: GL.UNSIGNED_BYTE,
update: this.calculateVertexValid,
noAlloc
},
elevations: {
size: 1,
transition: ATTRIBUTE_TRANSITION,
accessor: 'getElevation',
shaderAttributes: {
elevations: {
divisor: 0
},
instanceElevations: {
divisor: 1
}
}
},
fillColors: {
alias: 'colors',
size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
transition: ATTRIBUTE_TRANSITION,
accessor: 'getFillColor',
defaultValue: DEFAULT_COLOR,
shaderAttributes: {
fillColors: {
divisor: 0
},
instanceFillColors: {
divisor: 1
}
}
},
lineColors: {
alias: 'colors',
size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
transition: ATTRIBUTE_TRANSITION,
accessor: 'getLineColor',
defaultValue: DEFAULT_COLOR,
shaderAttributes: {
lineColors: {
divisor: 0
},
instanceLineColors: {
divisor: 1
}
}
},
pickingColors: {
size: 3,
type: GL.UNSIGNED_BYTE,
accessor: (object, {index, target: value}) =>
this.encodePickingColor(object && object.__source ? object.__source.index : index, value),
shaderAttributes: {
pickingColors: {
divisor: 0
},
instancePickingColors: {
divisor: 1
}
}
}
});
/* eslint-enable max-len */
}