Answer the review: one reference viewport, one lookup for the card
Two of the three comments were worth taking. The star field and the rings drawn over it each carried their own copy of the reference viewport and field of view the angular sizes are figured against. They agree today, and nothing would have told anyone when they stopped: a ring would just sit a little wide of its star at some window sizes. One module now holds the three constants and says what they are for. The leader line to the object card looked the card's panel up by selector on every frame it was drawn. The host element is stable and the panel inside it only changes when a different body is selected, so the lookup is derived once per change instead of sixty times a second. Left alone: replacing `positions.set([x, y, z], i * 3)` with an index-by-index loop to avoid a temporary array per host. It runs once, over six hundred and thirty-four stars, at bootstrap, and the version with the temporary reads better than the version without. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016jxMkwA2rbicdGxHosecYi
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* How a size in pixels becomes a size the scene can draw.
|
||||
*
|
||||
* Sprites in this view are sized angularly rather than in world units, so a star holds the same
|
||||
* share of the screen however far away it is and whatever the window is doing. Pixels are what
|
||||
* the figures are chosen in, though — "a star is between one and a half and six pixels across"
|
||||
* is a statement someone can check by looking — so the two are related through a reference
|
||||
* viewport and field of view, and the pixel figures are exact only at that height.
|
||||
*
|
||||
* Shared rather than restated per renderer: the star field and the rings drawn over it have to
|
||||
* agree, or a ring sits a little wide of the star it belongs to at some window sizes and not at
|
||||
* others.
|
||||
*/
|
||||
|
||||
export const REFERENCE_VIEWPORT_HEIGHT_PX = 900;
|
||||
export const REFERENCE_FOV_DEGREES = 55;
|
||||
|
||||
/** Multiply a size in reference pixels by this to get the angular size the material wants. */
|
||||
export const PIXELS_TO_ANGULAR_SIZE = (2 * Math.tan((REFERENCE_FOV_DEGREES * Math.PI) / 180 / 2)) / REFERENCE_VIEWPORT_HEIGHT_PX;
|
||||
Reference in New Issue
Block a user