//监听点击事件
window.addEventListener('click', (event) => {
const raycaster = new THREE.Raycaster()
const mouse = new THREE.Vector2()
mouse.x = (event.clientX / window.innerWidth) * 2 - 1
mouse.y = - (event.clientY / window.innerHeight) * 2 + 1
console.log("========raycaster", raycaster)
console.log("========camera", camera)
raycaster.setFromCamera(mouse, camera.value);
var intersects = raycaster.intersectObjects(model.children, true);
// //当intersects.length > 0说明碰点击到物体(可能为多个重合的物体),获取最近的物体名称进行判断
if (intersects.length > 0) {
const mesh = console.log(intersects[0].object)
}
非常nice,感谢为社区做的贡献!