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

update camera aspect ratio in Plan View and Cross Section #635

Closed
Algorush opened this issue Jun 14, 2024 · 11 comments
Closed

update camera aspect ratio in Plan View and Cross Section #635

Algorush opened this issue Jun 14, 2024 · 11 comments
Assignees

Comments

@Algorush
Copy link
Collaborator

image

@vincentfretin
Copy link
Collaborator

See my comments 3DStreet/3dstreet-editor#185 (comment)

@Algorush Algorush self-assigned this Jun 14, 2024
@Algorush
Copy link
Collaborator Author

Algorush commented Jun 14, 2024

See my comments 3DStreet/3dstreet-editor#185 (comment)

Thanks, I read the comments but didn't look in detail yet. Yes, the parameters of the Ortho camera are different from the Perspective camera. Perhaps this is causing the problem. I studied ortho and perspective cameras while working with 3dtiles-loader, I'll try to fix this

@vincentfretin
Copy link
Collaborator

Good luck. I spend about 2 hours trying without success.

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in 3DStreet Dev Tracking Jun 23, 2024
@kfarr kfarr moved this from Backlog (Not Ready) to To Do - Soon in 3DStreet Dev Tracking Jun 23, 2024
@vincentfretin
Copy link
Collaborator

Oh I see that EditorControls is also messing around the left bottom right top property of the ortho camera

if (this.isOrthographic) {
// Change FOV for ortho.
let factor = 1;
if (delta.x + delta.y + delta.z < 0) {
factor = -1;
}
delta = distance * scope.zoomSpeed * factor;
object.left -= delta * ratio;
object.bottom -= delta;
object.right += delta * ratio;
object.top += delta;
if (object.left >= -0.0001) {
return;
}
object.updateProjectionMatrix();

I missed that code when I tried to fix the issue.

@vincentfretin
Copy link
Collaborator

controls.setAspectRatio(sceneEl.canvas.width / sceneEl.canvas.height);

probably just need to be executed on resize

@Algorush
Copy link
Collaborator Author

Algorush commented Jul 4, 2024

I made it work. I'll add a PR later. in window resize I first calculate FrustumSize, then add parameters for ortho camera. It works with Plan View in inspector, but not with Cross Section View:

        if (inspector.camera.isOrthographicCamera) {
          const frustumSize = inspector.camera.top - inspector.camera.bottom;
          inspector.camera.left = -frustumSize * aspect / 2;
          inspector.camera.right = frustumSize * aspect / 2;
          inspector.camera.top = frustumSize / 2;
          inspector.camera.bottom = -frustumSize / 2;
        }

so I need to do this work in Cross Section View also

@Algorush
Copy link
Collaborator Author

Algorush commented Jul 5, 2024

I fixed it with Cross Section View too.
I'll try to add this fix in aframe repo in resize event function here: https://github.com/aframevr/aframe/blob/66baa9c8128caf9199e8a773ca4d637a25947d06/src/core/scene/a-scene.js#L577

@Algorush Algorush moved this from To Do - Soon to In progress in 3DStreet Dev Tracking Jul 5, 2024
@Algorush Algorush moved this from In progress to For Review in 3DStreet Dev Tracking Jul 6, 2024
@Algorush
Copy link
Collaborator Author

Algorush commented Jul 6, 2024

Added PR here in 3DStreet. I was unable to clone the aframe repository due to an error during the download, perhaps a problem with my unstable connection in a rural area

@kfarr kfarr assigned vincentfretin and unassigned Algorush Jul 15, 2024
@vincentfretin
Copy link
Collaborator

I'll make changes to your PR.
Also for reference in three.js editor:
https://github.com/mrdoob/three.js/blob/1845f6cd0525b5c73b9da33c40e198c360af29f1/editor/js/Viewport.js#L153-L179

@vincentfretin vincentfretin moved this from For Review to In progress in 3DStreet Dev Tracking Jul 16, 2024
@vincentfretin
Copy link
Collaborator

PR #694 fixes the issue.

@kfarr
Copy link
Collaborator

kfarr commented Jul 17, 2024

closed by #694

@kfarr kfarr closed this as completed Jul 17, 2024
@github-project-automation github-project-automation bot moved this from For Review to Done in 3DStreet Dev Tracking Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants