TresGroup以及primitive中有 group 的情况下,事件绑定后,不响应的问题

发布于 2024-07-06 17:41:46

//监听点击事件
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)

  }
1 条评论

发布
问题