UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

38 lines (28 loc) 823 B
import { aabb3_array_intersects_sphere_array } from "../../../geom/3d/aabb/aabb3_array_intersects_sphere_array.js"; import { BVHQuery } from "./BVHQuery.js"; const scratch_aabb = []; export class BVHQueryIntersectsSphere extends BVHQuery { /** * * @type {number[]} */ sphere = []; /** * * @param {number[]|ArrayLike<number>} sphere * @returns {BVHQueryIntersectsRay} */ static from(sphere) { const r = new BVHQueryIntersectsSphere(); r.sphere = sphere; return r; } evaluate(node, tree) { tree.node_get_aabb(node, scratch_aabb); // test node against the ray return aabb3_array_intersects_sphere_array( scratch_aabb, this.sphere ); } }