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

Vector3: correct the randomDirection() method #27725

Merged
merged 1 commit into from
Feb 11, 2024

Conversation

WestLangley
Copy link
Collaborator

Follow-on to #22494

three.js uses a 'y-up' convention. The current implementation was copied from a source using a 'z-up' convention. This PR fixes that oversight.

Note: the prior code did generate uniform samples, in spite of the oversight.

@WestLangley WestLangley added this to the r162 milestone Feb 10, 2024
Copy link

github-actions bot commented Feb 10, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
676.1 kB (168.2 kB) 676.1 kB (168.2 kB) -4 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
457.2 kB (111 kB) 457.1 kB (111 kB) -4 B
@WestLangley
Copy link
Collaborator Author

The screenshots I generate are not correct for some reason.

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 11, 2024

I'll merge and try it on my end.

@Mugen87 Mugen87 merged commit 7f85579 into mrdoob:dev Feb 11, 2024
20 of 22 checks passed
@WestLangley WestLangley deleted the dev-vector_random_direction branch February 12, 2024 17:50
@LeviPesin
Copy link
Contributor

LeviPesin commented Feb 13, 2024

I believe there is no difference in the behaviour of the previous and new code -- they both generate a uniform sample on the sphere, it wouldn't depend on using z-up or y-up (it is uniformly distributed in any case -- a rotation of uniform distribution is still the same uniform distribution).
The difference in the screenshots happens only because of changing the order of Math.random() calls.
@Mugen87 @WestLangley

@WestLangley
Copy link
Collaborator Author

Here is the screenshot of webgl_raycaster_bvh.jpg generated on my iMac:

image

npm run make-screenshot webgl_raycaster_bvh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants