Fix variable shadowing bug in CameraUtils.setCameraParams #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
setCameraParamsfunction inCameraUtils.tscontained a variable shadowing issue that could cause incorrect camera calculations when horizontal field-of-view (FOV) clamping was required.The bug occurred on line 79 where the
focalLengthparameter was being redeclared inside an if block:This shadowing meant that when horizontal FOV needed to be clamped (typically with wide aspect ratios or extreme principal point offsets), the function would use the original
focalLengthparameter value in subsequent calculations instead of the newly computed adjusted value, leading to inconsistent camera state.Solution
adjustedFocalLengthvariable initialized with the originalfocalLengthparameteradjustedFocalLengthinstead of shadowing the parameteradjustedFocalLengthTesting
All existing tests continue to pass, and a new test case specifically verifies correct behavior when horizontal FOV clamping occurs with wide aspect ratios and off-center principal points.
The fix ensures camera calculations remain mathematically consistent when the system needs to adjust focal length due to FOV constraints, preventing potential rendering artifacts or incorrect camera positioning.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/722234/chrome-linux.zip/usr/local/bin/node install.js(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.