UNPKG

three-mesh-bvh

Version:

A BVH implementation to speed up raycasting against three.js meshes.

46 lines (28 loc) 729 B
class _BufferStack { constructor() { this.float32Array = null; this.uint16Array = null; this.uint32Array = null; const stack = []; let prevBuffer = null; this.setBuffer = buffer => { if ( prevBuffer ) { stack.push( prevBuffer ); } prevBuffer = buffer; this.float32Array = new Float32Array( buffer ); this.uint16Array = new Uint16Array( buffer ); this.uint32Array = new Uint32Array( buffer ); }; this.clearBuffer = () => { prevBuffer = null; this.float32Array = null; this.uint16Array = null; this.uint32Array = null; if ( stack.length !== 0 ) { this.setBuffer( stack.pop() ); } }; } } export const BufferStack = /* @__PURE__ */ new _BufferStack();