in packages/miew/src/gfx/FrameInfo.js [147:204]
parseBinaryData(arrayBuffer) {
const dataView = new DataView(arrayBuffer);
let offset = 0;
const atomsCount = dataView.getUint32(offset, true);
offset += 4;
const framesCount = dataView.getUint32(offset, true);
this._framesCount = framesCount;
this._framesRange.end = this._framesRange.end > 0
? Math.min(this._framesRange.end, framesCount - 1) : framesCount - 1;
offset += 4;
this._atomsCount = atomsCount;
const maxSize = 1024 * 1024; // 1 MB
this._framesRequestLength = Math.ceil(maxSize / (atomsCount * 8));
const chunkedFramesCount = this._framesRange.end - this._framesRange.start + 1;
if (atomsCount !== this._complex._atoms.length
|| arrayBuffer.byteLength !== cDataOffset + chunkedFramesCount * atomsCount * 8) {
throw new Error();
}
const complex = this._complex;
let timeStep = dataView.getUint32(offset, true);
let iName = 0;
while (timeStep > 1000 && iName < cSecNames.length - 1) {
timeStep /= 1000;
++iName;
}
this._timeStep = `${timeStep.toString()} ${cSecNames[iName]}`;
offset += 4;
const secondary = [];
const posData = new Float32Array(chunkedFramesCount * atomsCount * 3);
let coordIdx = 0;
const secondaryArr = new Int8Array(atomsCount);
for (let j = 0; j < chunkedFramesCount; ++j) {
for (let i = 0; i < atomsCount; ++i) {
const hiWord = dataView.getUint32(offset, true);
offset += 4;
const loWord = dataView.getUint32(offset, true);
offset += 4;
const str = (loWord & cStrMask) >>> cStrShift;
const x = fromUInt20ToInt20(((loWord & cFirstMask) >>> cFirstShift) >> 0);
const y = fromUInt20ToInt20((((loWord & cSecMask1) << cSecShift1)
| ((hiWord & cSecMask2) >>> cSecShift2)) >> 0);
const z = fromUInt20ToInt20((hiWord & cThirdMask) >> 0);
secondaryArr[i] = 0;
if (str > 0 && str < 4) {
secondaryArr[i] = cHelixIdx;
} else if (str === 4) {
secondaryArr[i] = cSheetIdx;
}
posData[coordIdx++] = x / 100;
posData[coordIdx++] = y / 100;
posData[coordIdx++] = z / 100;
}
secondary.push(_createSecondary(secondaryArr, complex));
}
this._secondaryData = secondary;
this._data = posData;
}