UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

37 lines (32 loc) 986 B
/** * * @param {BinaryBuffer} buffer * @param {AABB3} box * @param {number} x0 * @param {number} y0 * @param {number} z0 * @param {number} x1 * @param {number} y1 * @param {number} z1 */ export function deserializeAABB3Quantized16Uint(buffer, box, x0, y0, z0, x1, y1, z1) { //compute value ranges const xD = x1 - x0; const yD = y1 - y0; const zD = z1 - z0; //read values const _x0 = buffer.readUint16(); const _y0 = buffer.readUint16(); const _z0 = buffer.readUint16(); const _x1 = buffer.readUint16(); const _y1 = buffer.readUint16(); const _z1 = buffer.readUint16(); //quantize all values const qx0 = (_x0 / 65535) * xD + x0; const qy0 = (_y0 / 65535) * yD + y0; const qz0 = (_z0 / 65535) * zD + z0; const qx1 = (_x1 / 65535) * xD + x0; const qy1 = (_y1 / 65535) * yD + y0; const qz1 = (_z1 / 65535) * zD + z0; box.setBounds(qx0, qy0, qz0, qx1, qy1, qz1); }