//投影获取点击或鼠标移入的模型
var raycaster = new THREE.Raycaster()
var mouse = new THREE.Vector2()
function findIntersectedModule(e, arrMesh) {
var intersected;
//将鼠标点击位置的屏幕坐标转成threejs中的标准坐标,具体解释见代码释义
if (isMobile) {
if (e.changedTouches) {
var touch = e.changedTouches[0]; //touches数组对象获得屏幕上所有的touch,取第一个touch
if (Math.abs(touch.pageX-touchStartX) + Math.abs(touch.pageY-touchStartY) >= 3) {
return undefined;
}
mouse.x = (touch.pageX / window.innerWidth) * 2 - 1;
mouse.y = -(touch.pageY / window.innerHeight) * 2 + 1;
}
if (!isOrientationLandscape()) mouse.rotateAround(new THREE.Vector2(0, 0), 1.57);
} else {
mouse.x = (e.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(e.clientY / window.innerHeight) * 2 + 1;
}
//新建一个三维单位向量 假设z方向就是0.5
//根据照相机,把这个向量转换到视点坐标系
var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5).unproject(camera);
//在视点坐标