We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

elie520

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: Inaccurate raycast on camera rotation? #40670
    elie520
    Participant

    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

    in reply to: Verge3D: get screen coordinate from 3D coordinates? #40138
    elie520
    Participant

    Thanks 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 the app.camera

    in reply to: Unwanted behaviour with registerOnHover and for loop #40079
    elie520
    Participant

    I 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')});
    }
    in reply to: Add an EventListener to a blender object #39574
    elie520
    Participant

    This 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 :)

    in reply to: HTML element in verge 3d #39535
    elie520
    Participant

    yes, 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!

Viewing 5 posts - 1 through 5 (of 5 total)