MeshBVH.intersectsBox 是 three-bvh-mesh 库中 MeshBVH 类的一个方法,用于检测网格在边框中是否有交集。
MeshBVH.intersectsBox( box )
box: THREE.Box3 类型的边框,即需要检测的边框。true 表示有交集,返回布尔值 false 表示无交集。import { MeshBVH } from 'three-bvh-mesh';
import * as THREE from 'three';
const geometry = new THREE.BoxGeometry( 1, 1, 1 );
const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
const mesh = new THREE.Mesh( geometry, material );
const box = new THREE.Box3( new THREE.Vector3( -5, -5, -5 ), new THREE.Vector3( 5, 5, 5 ) );
console.log( MeshBVH.intersectsBox( box ) ); // true
MeshBVH.intersectsBox 方法必须在网格构建完毕后调用。
参数 box 必须为非空的 THREE.Box3 类型。
当返回值为 true 时,不一定表示网格与边框完全重合,而可能仅仅存在交集。
在逐帧渲染中,调用 MeshBVH.intersectsBox 方法的性能较低,建议对该方法调用次数进行优化。