@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
22 lines (17 loc) • 485 B
JavaScript
/**
*
* @param {THREE.BufferGeometry} geometry
* @returns {number}
*/
export function compute_geometry_polycount(geometry) {
const index = geometry.getIndex();
if (index !== null) {
return index.count / 3;
}
const position_attribute = geometry.getAttribute('position');
if (position_attribute !== undefined) {
return position_attribute.count / 3;
}
// no valid way to discern polycount, assume 0
return 0;
}