UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

24 lines (23 loc) 669 B
"use strict"; import { Box3, Vector3 } from "three"; const _position = new Vector3(); const _bbox = new Box3(); export class ByBboxHelper { constructor(node) { this.node = node; } evalForEntities(points) { this._setBbox(_bbox); for (const point of points) { point.position(_position); const inBbox = _bbox.containsPoint(_position); if (inBbox) { this.node.entitySelectionHelper.select(point); } } } _setBbox(target) { target.min.copy(this.node.pv.bboxSize).multiplyScalar(-0.5).add(this.node.pv.bboxCenter); target.max.copy(this.node.pv.bboxSize).multiplyScalar(0.5).add(this.node.pv.bboxCenter); } }