UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

30 lines (22 loc) 744 B
import { bvh32_set_leaf_from_triangle } from "./bvh32_set_leaf_from_triangle.js"; /** * * @param {BinaryUint32BVH} bvh * @param {Float32Array} vertices */ export function bvh32_from_unindexed_geometry(bvh, vertices) { const triangle_count = vertices.length / 9; bvh.setLeafCount(triangle_count); bvh.initialize_structure(); for (let i = 0; i < triangle_count; i++) { const index3 = i * 3; // generate triangle vertex indices const iA = index3; const iB = index3 + 1; const iC = index3 + 2; bvh32_set_leaf_from_triangle(bvh, i, vertices, iA, iB, iC); } // finalize build // bvh.sort_morton(MATRIX_4_IDENTITY); bvh.build(); }