UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

36 lines (26 loc) 1.15 kB
import { AABB3 } from "../../geom/3d/aabb/AABB3.js"; /** * Prints the whole hierarchy into the console. * * Utility tool, primarily intended for debugging. * * WARNING: can crash the browser as hierarchies can have thousands of nodes * @param {BVH} bvh * @param {number} [node] where to start, defaults to root * @param {string} [prefix] Initial prefix for the node */ export function ebvh_print_to_console(bvh, node = bvh.root, prefix = '') { const is_leaf = bvh.node_is_leaf(node); const aabb = new AABB3(); bvh.node_get_aabb(node, aabb); let s_bounds = `Bounds: [ x0=${aabb.x0}, x1=${aabb.x1}, y0=${aabb.y0}, y1=${aabb.y1}, z0=${aabb.z0}, z1=${aabb.z1} ]`; if (is_leaf) { console.log(prefix + `LeafNode/${node} UserData: ${bvh.node_get_user_data(node)}, ${s_bounds}`) } else { console.groupCollapsed(prefix + `BinaryNode/${node}`); console.log(s_bounds); ebvh_print_to_console(bvh, bvh.node_get_child1(node), 'child1 -> '); ebvh_print_to_console(bvh, bvh.node_get_child2(node), 'child2 -> '); console.groupEnd(); } }