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

CubeCamera: Orient cameras right-side-up. #24921

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

WestLangley
Copy link
Collaborator

Fixes #3702, based on this suggestion.

CubeCamera currently sets its cameras "upside down", by setting a negative up-axis prior to calling camera.lookAt().

const cameraPX = new PerspectiveCamera( fov, aspect, near, far );
cameraPX.layers = this.layers;
cameraPX.up.set( 0, - 1, 0 );
cameraPX.lookAt( 1, 0, 0 );

Doing so results in a mirroring of the rendered output in both the x-axis and y-axis.

This mirroring is required to accommodate the WebGL texture cube handedness and texture-origin conventions.

However, the same mirroring effect can be achieved by setting a negative fov.

The advantage of applying a negative fov instead of rotating the camera is that sprites rendered by a CubeCamera will now render right-side-up.

Sprites which have rotation of zero always render right-side-up in camera space.

//

Note: There will always be artifacts when a sprite straddles an edge of the top or bottom cube face. This is unavoidable.

@WestLangley WestLangley added this to the r147 milestone Nov 7, 2022
@Mugen87 Mugen87 changed the title CubeCamera: Orient cameras right-side-up CubeCamera: Orient cameras right-side-up. Nov 8, 2022
@Mugen87 Mugen87 merged commit bd6fcd5 into mrdoob:dev Nov 8, 2022
@WestLangley WestLangley deleted the dev-cube_camera branch November 8, 2022 17:03
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

Successfully merging this pull request may close these issues.

Sprites are flipped upside-down in envMap taken by CubeCamera
2 participants