polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
16 lines (14 loc) • 458 B
text/typescript
import {BufferGeometry} from 'three/src/core/BufferGeometry';
import { ArrayUtils } from '../../ArrayUtils';
const POSITION = 'position';
export class CoreGeometryIndexBuilder {
static create_index_if_none(geometry: BufferGeometry) {
if (!geometry.index) {
const position = geometry.getAttribute(POSITION);
if (position) {
const position_array = position.array;
geometry.setIndex(ArrayUtils.range(position_array.length / 3));
}
}
}
}