threejs自由绘制线条或矩形的思路

(1)创建平面

let normal = new THREE.Vector3(0, 0, 1);
let planeGround = new THREE.Plane(normal, 0);

(2)获得交点坐标

//创建raycaster等必要的元素
...
let intersects = this.raycaster.ray.intersectPlane(planeGround);
let x = intersects.x, y = intersects.y;

(3)相同方式获得第二个交点坐标,即可绘制线条或者矩形

你可能感兴趣的:(javascript)