// 引入图标
const textureLoader = new THREE.TextureLoader();
const map = textureLoader.load("/icon/location.png");
let material = new THREE.SpriteMaterial({map:map})
let mesh = new THREE.Sprite(material)
mesh.position.set(0,1.5,0)
mesh.userData = {id:1} // 自定义属性
scene.add(mesh)
// 创建射线监听点击的物体
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();
window.addEventListener("dblclick",(event)=>{
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -((event.clientY / window.innerHeight) * 2 - 1);
raycaster.setFromCamera(mouse,camera);
let result = raycaster.intersectObject(mesh)
console.log(result)
})
暂无评论