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

fixed NaN cameraOrbit #4041

Merged
merged 1 commit into from
Jan 10, 2023
Merged

fixed NaN cameraOrbit #4041

merged 1 commit into from
Jan 10, 2023

Conversation

elalish
Copy link
Collaborator

@elalish elalish commented Jan 10, 2023

There are two fixes here, one for the actual problem, and a second to act as a backstop against similar problems. Both were verified to independently fix the issue via the included test.

I also verified that no matter what nonsense you put into camera-orbit or cameraOrbit, it will never produce NaN, it instead falls back to the default initial values.

@elalish elalish self-assigned this Jan 10, 2023
@@ -508,7 +512,7 @@ export class SmoothControls extends EventDispatcher {
}

private pixelLengthToSphericalAngle(pixelLength: number): number {
return 2 * Math.PI * pixelLength / this.element.clientHeight;
return 2 * Math.PI * pixelLength / this.scene.height;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why clientHeight was used here; scene.height is correct as this is the one that is assured to never be < 1.

Copy link
Collaborator

@samaneh-kazemi samaneh-kazemi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix.

@elalish elalish merged commit f5d02dd into master Jan 10, 2023
@elalish elalish deleted the cameraNaN branch January 10, 2023 21:39
elalish added a commit that referenced this pull request Jan 10, 2023
JL-Vidinoti pushed a commit to vidinoti/model-viewer that referenced this pull request Apr 22, 2024
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.

None yet

2 participants