Skip to content

glTF Exporter: Fix light direction calculation #16721

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alexchuber
Copy link
Contributor

The previous light direction calculation didn't account for when the Babylon light direction matched glTF's. This would result NaN values in RotationAxisToRef, as the rotation axis would be (0,0,0), and its length (0) used as a divisor.

I noticed we already have a function to do what we need for the light direction calculation-- FromUnitVectorsToRef-- so I've replaced the whole thing with that. Much simpler.

(Bonus: I also noticed that the lights in our glTF light export test don't use glTF falloff, so I've earmarked that change in this PR.)

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 5, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 5, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 5, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 5, 2025

Comment on lines +113 to +114
const direction = TmpVectors.Vector3[0];
babylonNode.direction.normalizeToRef(direction);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change this? It's more concise with the original.

@sebavan sebavan enabled auto-merge (squash) June 5, 2025 23:13
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.

4 participants