Hello i am using this code for creating annotations, i believe it is the same approach from three.js main examples.
https://raw.githubusercontent.com/Sean-Bradley/Three.js-TypeScript-Boilerplate/annotations/src/client/client.ts
I am trying to change some things, right now i want when the user clicks on a sprite then the sprite should change the image or even color (right now the sprite is generated with a texture if you see in the .ts) Also i want the sprite to change when the mouseover.
I only managed to do onclick by adding :
const v = new THREE.Vector2()
function onClick(event: MouseEvent) {
v.set(
(event.clientX / renderer.domElement.clientWidth) * 2 - 1,
-(event.clientY / renderer.domElement.clientHeight) * 2 + 1
)
raycaster.setFromCamera(v, camera)
const intersects = raycaster.intersectObjects(annotationMarkers, true)
if (intersects.length > 0) { if (intersects[0].object.userData && intersects[0].object.userData.id) {
gotoAnnotation(annotations[intersects[0].object.userData.id])
//i added THIS intersects[0].object.scale.set(0.1,0.1,0.1)
}
}}
This will change a little bit the sprite button (it will scale it) but when you click on another sprite it would not revert back to old scale.
I do understand that i will have to play with raycasting and intersects but i am not able to find a proper workaround.