@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
21 lines (20 loc) • 735 B
JavaScript
;
import { Box3, Vector3 } from "three";
import { updateSelectionState } from "./GroupCommon";
const bbox = new Box3();
const bboxHalfSize = new Vector3();
const entityPosition = new Vector3();
export class GroupByBoundingBoxHelper {
constructor(node) {
this.node = node;
}
evalForEntities(allEntities, selectionStates) {
bboxHalfSize.copy(this.node.pv.boundingBoxSize).multiplyScalar(0.5);
bbox.min.copy(this.node.pv.boundingBoxCenter).sub(bboxHalfSize);
bbox.max.copy(this.node.pv.boundingBoxCenter).add(bboxHalfSize);
for (const entity of allEntities) {
entity.position(entityPosition);
updateSelectionState(selectionStates, entity, bbox.containsPoint(entityPosition));
}
}
}