Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpriteNodeMaterial: size attenuation support orthographic camera #29517

Merged

Conversation

RenaudRohlinger
Copy link
Collaborator

@RenaudRohlinger RenaudRohlinger commented Sep 28, 2024

Description

Adjusted sprite scaling for orthographic cameras when sizeAttenuation is false by adding:

const orthoScale = float(2.0).div(cameraProjectionMatrix.element(1).element(1));
scale = scale.mul(orthoScale.mul(2));

We calculate orthoScale as 2.0 / cameraProjectionMatrix[1][1] to obtain the camera's vertical size, and then multiply by 2 to adjust for the normalized device coordinate (NDC) space ranging from -1 to 1. This ensures sprites scale correctly in orthographic projections, maintaining consistent sizes on the screen regardless of the camera's zoom level.

This contribution is funded by Segments.AI & Utsubo

@RenaudRohlinger RenaudRohlinger added this to the r170 milestone Sep 28, 2024
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 687.15
170.18
687.15
170.18
+0 B
+0 B
WebGPU 805.82
216.97
805.89
216.99
+69 B
+24 B
WebGPU Nodes 805.33
216.83
805.39
216.85
+69 B
+24 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 462.85
111.79
462.85
111.79
+0 B
+0 B
WebGPU 535.59
144.55
535.66
144.58
+69 B
+26 B
WebGPU Nodes 491.75
134.31
491.75
134.31
+0 B
+0 B

@RenaudRohlinger RenaudRohlinger merged commit efb7510 into mrdoob:dev Sep 30, 2024
12 checks passed
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.

2 participants