From 1cc367c8d8bcbedf8fbfd202f53bd063f2c47e78 Mon Sep 17 00:00:00 2001 From: giagitom Date: Sun, 15 Feb 2026 01:09:42 +0100 Subject: [PATCH] Fix head rotation for clip-space billboard offset --- src/mol-gl/shader/text.vert.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mol-gl/shader/text.vert.ts b/src/mol-gl/shader/text.vert.ts index 2b2b95de5..b2895b341 100644 --- a/src/mol-gl/shader/text.vert.ts +++ b/src/mol-gl/shader/text.vert.ts @@ -103,12 +103,13 @@ void main(void){ cornerOffset.y += offsetY; if (uHasHeadRotation) { - cornerOffset = (uInvHeadRotation * vec4(cornerOffset, 0.0, 0.0)).xy; + vec3 rotatedOffset = (uInvHeadRotation * vec4(cornerOffset, 0.0, 0.0)).xyz; + clip += uProjection * vec4(rotatedOffset, 0.0); + } else { + // apply offset in clip space to avoid perspective distortion on the quad + clip.xy += vec2(uProjection[0][0], uProjection[1][1]) * cornerOffset; } - // apply offset in clip space to avoid perspective distortion on the quad - clip.xy += vec2(uProjection[0][0], uProjection[1][1]) * cornerOffset; - gl_Position = clip; vViewPosition = -mvCenter.xyz;