Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera issue with version 2.0.3 #429

Closed
dsilvera opened this issue Feb 29, 2024 · 2 comments
Closed

Camera issue with version 2.0.3 #429

dsilvera opened this issue Feb 29, 2024 · 2 comments

Comments

@dsilvera
Copy link

Since updating the library to version 4.3.0, I've noticed that when I background my application and return to it, the camera's position has changed. I can also reproduce it by opening an activity on top and then closing it to return to the SceneView. I didn't encounter any issues like this with previous versions. I haven't made any changes to my code, so I assume the issue stems from the library itself.

I was using version 2.0.2 before. Is there perhaps some additional code required when transitioning to version 4.3.0?

You can see that there's a zoom-out between the two images (before and after putting the app in the background). If I swipe before putting it in the background, I no longer see my model. It seems to zoom out from the point where the model was opened.

Capture d’écran 2024-02-29 à 12 51 46 Capture d’écran 2024-02-29 à 12 51 56
@dsilvera
Copy link
Author

dsilvera commented Mar 1, 2024

I found a temporary solution. The issue lies with the onResized method:

protected open fun onResized(width: Int, height: Int) {
        view.viewport = Viewport(0, 0, width, height)
        cameraNode.updateProjection()
        updateCameraManipulator()
    }

Upon returning from the background, the updateProjection method alters the position of my camera node. To address this, I have overridden the function as follows:

    var resizedWidth:Int? = null
    var resizedHeight:Int? = null
    override fun onResized(width: Int, height: Int) {
        if (this.resizedWidth == width && this.resizedHeight == height) return
        resizedWidth = width
        resizedHeight = height
        view.viewport = Viewport(0, 0, width, height)
        cameraNode.updateProjection()
        updateCameraManipulator()
    }

This modification resolves the issue. If you have a better solution, I'm open to it.

@ThomasGorisse
Copy link
Contributor

Fixed in v2.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants