Created
October 29, 2021 11:51
-
-
Save LeonBaudouin/b18018da7706c6ab812e058005487980 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const randomVectorInCone = (theta: number, target: THREE.Vector3) => { | |
const z = remap(Math.random(), [0, 1], [Math.cos(theta), 1]) | |
const phi = remap(Math.random(), [0, 1], [0, 2 * Math.PI]) | |
target.set( | |
Math.sqrt(1 - z * z) * Math.cos(phi), | |
Math.sqrt(1 - z * z) * Math.sin(phi), | |
z | |
) | |
target.normalize() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment