UNPKG

awv3

Version:
25 lines (22 loc) 762 B
import * as THREE from 'three'; export default class InfinitePlane extends THREE.Object3D { constructor() { super(); this.type = 'InfinitePlane'; this.plane = new THREE.Plane(); } raycast(raycaster, intersects) { const inverseMatrix = new THREE.Matrix4().getInverse(this.matrixWorld); const ray = raycaster.ray.clone().applyMatrix4(inverseMatrix); const distance = ray.distanceToPlane(this.plane); if (distance === null || distance < raycaster.near || distance > raycaster.far) return; intersects.push({ distance, distanceToRay: 0, point: ray.at(distance), index: 0, face: null, object: this }); } }