UNPKG

@polygonjs/polygonjs

Version:

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

24 lines (23 loc) 723 B
"use strict"; export function createPhysicsTriMesh(PhysicsLib2, object) { var _a; const geometry = object.geometry; if (!geometry) { return; } const position = geometry.getAttribute("position"); if (!position) { return; } let indexArray = (_a = geometry.getIndex()) == null ? void 0 : _a.array; if (!indexArray) { const pointsCount = position.array.length / 3; indexArray = new Uint32Array(pointsCount); for (let i = 0; i < pointsCount; i++) { indexArray[i] = i; } } const float32ArrayPosition = new Float32Array(position.array); const uint32ArrayIndex = new Uint32Array(indexArray); return PhysicsLib2.ColliderDesc.trimesh(float32ArrayPosition, uint32ArrayIndex); }