更新时间:2023-01-23 23:26:52
而不是检查2d画布,你可以检查3d点是否为平截头体。
Instead of check 2d canvas, you can check a 3d point is in frustum or not.
camera.updateMatrix();
camera.updateMatrixWorld();
var frustum = new THREE.Frustum();
frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse));
// Your 3d point to check
var pos = new THREE.Vector3(x, y, z);
if (frustum.containsPoint(pos)) {
// Do something with the position...
}