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.

Responsive Camera Switching

Home Forums Puzzles Responsive Camera Switching

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #44244
    timmeh
    Participant

    Hi, first- absolutely love the software. Puzzles are a total joy to work with!

    I’m switching between cameras with a window.parent resize event listener that checks if the innerWidth is less than 768, which is working great. The problem comes when I try to do the same thing with this statement for initial load:

    if (window.parent.innerWidth < 768) {
        app.camera = cameraMobile;
    }

    This does change the camera, but it is stretched vertically. Resizing the window at all fixes it- fitting the scene back into place how it should be, so I think it has something to do with how the scene size is recalculated when the v3d-container resizes. Any idea how I can fix this?

    Both cameras are orthographic (blender); the initial camera is at 76.9 orthographic scale and the mobile camera is at 58 scale.

    #44319

    Hi,

    you can try the following:

    v3d.apps[0].onResize()

    EDIT:

    actually you should do it this way:

    if (window.parent.innerWidth < 768) {
        app.setCamera(cameraMobile);
    }

    it does resizing automatically.

    Chief 3D Verger | LinkedIn | Twitter

    #44381
    timmeh
    Participant

    That worked beautifully- thanks Yuri!

    #51369

    Hi Yuri. In which .js file should I add this code?

    if (window.parent.innerWidth < 768) {
    app.setCamera(cameraMobile);
    }

    #51480
    yogyog
    Participant

    Not exactly what you asked for but I find it works well to set the rendersize to something square in your 3D program, that way is your on a landscape screen it will extend the viewing area sideways, and if your in a portrait screen it will extend the field of view vertically.

    #51481
    yogyog
    Participant

    Sorry This post was meant to be on another thread.

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