in modules/core/src/lib/attribute/data-column.js [58:112]
constructor(gl, opts) {
this.gl = gl;
this.id = opts.id;
this.size = opts.size;
const logicalType = opts.logicalType || opts.type;
const doublePrecision = logicalType === GL.DOUBLE;
let {defaultValue} = opts;
defaultValue = Number.isFinite(defaultValue)
? [defaultValue]
: defaultValue || new Array(this.size).fill(0);
opts.defaultValue = defaultValue;
let bufferType = logicalType;
if (doublePrecision) {
bufferType = GL.FLOAT;
} else if (!bufferType && opts.isIndexed) {
bufferType =
gl && hasFeature(gl, FEATURES.ELEMENT_INDEX_UINT32) ? GL.UNSIGNED_INT : GL.UNSIGNED_SHORT;
} else if (!bufferType) {
bufferType = GL.FLOAT;
}
opts.logicalType = logicalType;
opts.type = bufferType;
// This is the attribute type defined by the layer
// If an external buffer is provided, this.type may be overwritten
// But we always want to use defaultType for allocation
let defaultType = glArrayFromType(logicalType || bufferType || GL.FLOAT);
this.shaderAttributes = {};
this.doublePrecision = doublePrecision;
// `fp64: false` tells a double-precision attribute to allocate Float32Arrays
// by default when using auto-packing. This is more efficient in use cases where
// high precision is unnecessary, but the `64Low` attribute is still required
// by the shader.
if (doublePrecision && opts.fp64 === false) {
defaultType = Float32Array;
}
opts.bytesPerElement = defaultType.BYTES_PER_ELEMENT;
this.defaultType = defaultType;
this.value = null;
this.settings = opts;
this.state = {
externalBuffer: null,
bufferAccessor: opts,
allocatedValue: null,
constant: false
};
this._buffer = null;
this.setData(opts);
}