fix(hero): aim the hero camera at the crystal so it renders centred in the canvas - #61
Merged
Merged
Conversation
…n the canvas R3F treats the Canvas `camera` prop as construction-only and never calls lookAt, so the custom-positioned hero camera faced world -Z instead of the crystal — leaving it off-centre (low) in its plate even after the earlier geometry.center() fix. Added onCreated camera.lookAt(0,0,0) so the optical axis runs through the crystal's centroid (already at the origin), and removed the now-redundant drei <Center> wrapper (which offsets by the axis-aligned bbox and is imperfect around a rotating child). Browser-verified with pixel analysis: crystal centroid within ~0.3% of plate centre, stays centred through rotation, static+centred under reduced motion, both themes + mobile OK, no console errors. Build clean.
|
🚀 Preview deployed to: https://d105e10a.gemmology-dev.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
cameraprop as construction-only and never callslookAt, so the custom-positioned hero camera faced world -Z instead of the crystal, leaving it off-centre (low) in its plate even after the earliergeometry.center()fix.onCreated={({ camera }) => camera.lookAt(0, 0, 0)}so the optical axis runs through the crystal's centroid (already at the origin).<Center>wrapper, which offsets by the axis-aligned bbox and is imperfect around a rotating child.Test plan