Forum Replies Created
-
AuthorPosts
-
elie520Participant
Thank you for your answer!
As soon as I have some time I’ll look into your idea, and eventually share the cleaned code if I still need help. In any case, I’ll get back to you.Cheers
elie520ParticipantThanks for your answer!
I ended up solving my problem with
v3Copy.project(getObjectByName("__DEFAULT_CAMERA__"))
which is essentially the same I guess, except for performance issues. So I’ll use directly theapp.camera
elie520ParticipantI could solve my problem using
_pGlob.hoveredObject
in the following way:for (var a = 0 ; a < objs.length ; a++) { registerOnHover(objs[a],false,function(){outline(_pGlob.hoveredObject, 'ENABLE')},function(){outline(_pGlob.hoveredObject,'DISABLE')}); }
elie520ParticipantThis is PERFECT thanks a lot!!
For future reference, here’s a working example:
function clickedBlenderObject(event) { // returns the clicked object if any, null otherwise let mouse = new v3d.Vector2(); mouse.x = (event.clientX / window.innerWidth) * 2 - 1; mouse.y = - (event.clientY / window.innerHeight) * 2 + 1; let raycaster = new v3d.Raycaster() raycaster.setFromCamera(mouse, app.camera); let intersected = raycaster.intersectObjects(app.scene.children) return intersected.length?intersected[0].object:null } function myFunction(event) { let clicked_object = clickedBlenderObject(event) if (clicked_object) { //do whatever you want with your clicked_object and the event } } window.addEventListener('click', myFunction);
Of course, much more can be done since the raycasting encapsulates much more infos.
Once more, thank you GlifTek :)
elie520Participantyes, it’s possible thanks to unique IDs that can be assigned to each annotation.
Could you please tell us how? I found the uuid of my objects in the array app.scene.children, but I don’t know how to go from there to grasping the HTMLElement corresponding to each element.
Thanks!
-
AuthorPosts