Skip to content

Fix annotation hotspot sizing#8463

Merged
slimbuck merged 1 commit intoplaycanvas:mainfrom
slimbuck:anno-dev
Feb 20, 2026
Merged

Fix annotation hotspot sizing#8463
slimbuck merged 1 commit intoplaycanvas:mainfrom
slimbuck:anno-dev

Conversation

@slimbuck
Copy link
Member

Summary

  • Fix annotation hotspot scaling to use view-space depth instead of Euclidean distance, ensuring projection-correct sizing that matches the camera's perspective projection

Details

Annotation hotspot sizing

_updateAnnotationRotationAndScale previously computed the Euclidean distance between the camera and annotation positions to derive world-space hotspot size. This is incorrect because the projection matrix operates in view space — a point off to the side at the same depth would have a larger Euclidean distance but the same projected size. The fix passes the view-space depth (-vec.z from the view matrix transform) directly, producing stable hotspot sizes regardless of screen position.

@slimbuck slimbuck requested review from a team and Copilot February 20, 2026 09:53
@slimbuck slimbuck self-assigned this Feb 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a mathematical error in annotation hotspot sizing by using view-space depth instead of Euclidean distance for scale calculations. The previous implementation incorrectly computed the 3D distance between camera and annotation positions, which caused hotspots to appear at different sizes depending on their screen position, even when at the same depth. The fix correctly uses the view-space Z coordinate (negated to get positive depth) which matches the projection matrix's coordinate system.

Changes:

  • Updated _updateAnnotationRotationAndScale method to accept a viewDepth parameter instead of computing Euclidean distance internally
  • Modified the caller to pass -vec.z (view-space depth) which is already computed via view matrix transformation
  • Added clarifying comment explaining the use of view-space depth over Euclidean distance

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@slimbuck slimbuck merged commit 43f56b8 into playcanvas:main Feb 20, 2026
10 of 12 checks passed
@slimbuck slimbuck deleted the anno-dev branch February 20, 2026 11:10
mvaligursky pushed a commit that referenced this pull request Feb 24, 2026
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.

3 participants