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.

use camera-controls with App or camera lookAt

Home Forums Programming use camera-controls with App or camera lookAt

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #49178
    koby
    Participant

    I would like to be able to focus on an object when double clicking on it.
    It seems that a nice option is to use something like https://github.com/yomotsu/camera-controls

    I wonder how I can integrate it with the App object.
    I’ve also tried camera.lookAt() but for some reasons it’s not working.
    Otherwise if you have another idea on achieving this you are welcome ;)

    #49196

    hi,

    you can use the puzzles look at or tween camera or zoom camera to object
    https://www.soft8soft.com/docs/manual/en/puzzles/Camera.html#look_at

    if you need to do this with code, you can check out the visual_logic.js file generated by these puzzles.

    Chief 3D Verger | LinkedIn | Twitter

    #49241
    koby
    Participant

    Thanks a lot, I got something close to what I’m looking after but on some elements the mouse clicks doesn’t catch intersects.

    I’m trying to reproduce a double click => focus like Sketchfab player but the following code misses for instance (particularly the left) hands of the farmer within your demo but catches the ‘ground’:

        const onDoubleClick = ((event) => {
            let containerOffset = offset(app.container)
            pointer.x = ((event.clientX - containerOffset.left) / (app.container.clientWidth)) * 2 - 1;
            pointer.y = - ((event.clientY- containerOffset.top ) / (app.container.clientHeight)) * 2 + 1;
            raycaster.setFromCamera(pointer, app.camera);
    // don't intersect anything on the left hand of the farmer demo
            const intersects = raycaster.intersectObjects(app.scene.children, true) 
    
    

    Any idea on the matter?

    Many thanks

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.