@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
24 lines (17 loc) • 593 B
JavaScript
import { computeHashFloat } from "../../primitives/numbers/computeHashFloat.js";
/**
*
* @param {number[]|Float32Array|Float64Array} values
*/
export function computeHashFloatArray(values) {
const dataLength = values.length;
let hash = dataLength;
for (let i = 0; i < dataLength; i++) {
const singleValue = values[i];
//scale value to integer range
const integerValue = computeHashFloat(singleValue);
hash = ((hash << 5) - hash) + integerValue;
hash |= 0; // Convert to 32bit integer
}
return hash;
}