UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

31 lines (20 loc) 761 B
import { BufferAttribute, BufferGeometry } from "three"; /** * * @param {AABB3} aabb * @returns {THREE.BufferGeometry} */ function aabb3_to_buffer_geometry(aabb) { const bounds_geometry = new BufferGeometry(); const vertices_array = new Float32Array(24); aabb.getCorners(vertices_array); const vertices_attribute = new BufferAttribute(vertices_array, 3, false); bounds_geometry.setAttribute('position', vertices_attribute); const indices_array = new Uint8Array([ 0, 1, 5, 5, 4, 0, // bottom 2, 3, 7, 7, 6, 2 //top ]); const indices_attribute = new BufferAttribute(indices_array, 1, false); bounds_geometry.setIndex(indices_attribute); return bounds_geometry; }