UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

27 lines (20 loc) 761 B
import { computeBufferAttributeHash } from "./computeBufferAttributeHash.js"; import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js"; /** * * @param {THREE.BufferGeometry} geometry * @returns {number} */ export function computeGeometryHash(geometry) { let hash = 0; const attributes = geometry.attributes; for (const attributesKey in attributes) { hash = hash * 31 + computeStringHash(attributesKey); } hash ^= computeBufferAttributeHash(geometry.getIndex()); const position_attribute = geometry.getAttribute('position'); if (position_attribute !== undefined) { hash ^= computeBufferAttributeHash(position_attribute); } return hash; }