UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

16 lines (14 loc) 463 B
import {BufferAttribute, BufferGeometry} from 'three'; import {rangeWithEnd} from '../../ArrayUtils'; const POSITION = 'position'; export class CoreGeometryIndexBuilder { static createIndexIfNone(geometry: BufferGeometry) { if (!geometry.index) { const position = geometry.getAttribute(POSITION) as BufferAttribute; if (position) { const position_array = position.array; geometry.setIndex(rangeWithEnd(position_array.length / 3)); } } } }