Conversation
EditorControls.focus used target.localToWorld to place the camera, which multiplied the world-space bbox-derived offset by the target's world scale. Focusing a model scaled by N ended up N times too far. Decompose matrixWorld instead and rotate the offset by the target's world rotation only. Preserves the focus-camera-pose override and the catalog baseRotation behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code Review: Fix editor focus for scaled targetsOverviewThis PR fixes a camera focus bug in This is a well-scoped, surgical fix with a clear rationale. Code QualityPositives:
Minor observations:
CorrectnessThe math is sound:
One subtle design question worth considering: for the The mutation of Potential Issues
SummaryThis is a clean, well-reasoned backport from aframe-inspector. The fix is mathematically correct, follows Three.js idioms, and the scope is appropriately narrow. The Verdict: Approve with minor nit. Nice work @vincentfretin! |
EditorControls.focus used target.localToWorld to place the camera, which multiplied the world-space bbox-derived offset by the target's world scale. Focusing a model scaled by N ended up N times too far. Decompose matrixWorld instead and rotate the offset by the target's world rotation only. Preserves the focus-camera-pose override and the catalog baseRotation behaviour.
This is a backport of aframevr/aframe-inspector#854 but you don't seem to use scale on any entity currently, so you probably never saw that issue, but you may in the future if the user drag and drop a glb and scale the entity.