|
42 | 42 | rayleigh: 3, |
43 | 43 | mieCoefficient: 0.005, |
44 | 44 | mieDirectionalG: 0.7, |
45 | | - inclination: 0.02, // elevation / inclination |
46 | | - azimuth: 0, // Facing front |
| 45 | + elevation: 2, |
| 46 | + azimuth: 180, |
47 | 47 | exposure: renderer.toneMappingExposure |
48 | 48 | }; |
49 | 49 |
|
50 | 50 | function guiChanged() { |
51 | 51 |
|
52 | 52 | const uniforms = sky.material.uniforms; |
53 | | - uniforms[ "turbidity" ].value = effectController.turbidity; |
54 | | - uniforms[ "rayleigh" ].value = effectController.rayleigh; |
55 | | - uniforms[ "mieCoefficient" ].value = effectController.mieCoefficient; |
56 | | - uniforms[ "mieDirectionalG" ].value = effectController.mieDirectionalG; |
| 53 | + uniforms[ 'turbidity' ].value = effectController.turbidity; |
| 54 | + uniforms[ 'rayleigh' ].value = effectController.rayleigh; |
| 55 | + uniforms[ 'mieCoefficient' ].value = effectController.mieCoefficient; |
| 56 | + uniforms[ 'mieDirectionalG' ].value = effectController.mieDirectionalG; |
57 | 57 |
|
58 | | - const theta = 0.5 * Math.PI * ( 1 - effectController.inclination ); |
59 | | - const phi = 2 * Math.PI * ( effectController.azimuth - 0.5 ); |
| 58 | + const phi = THREE.MathUtils.degToRad( 90 - effectController.elevation ); |
| 59 | + const theta = THREE.MathUtils.degToRad( effectController.azimuth ); |
60 | 60 |
|
61 | | - sun.x = Math.sin( theta ) * Math.sin( phi ); |
62 | | - sun.y = Math.cos( theta ); |
63 | | - sun.z = Math.sin( theta ) * Math.cos( phi ); |
| 61 | + sun.setFromSphericalCoords( 1, phi, theta ); |
64 | 62 |
|
65 | | - uniforms[ "sunPosition" ].value.copy( sun ); |
| 63 | + uniforms[ 'sunPosition' ].value.copy( sun ); |
66 | 64 |
|
67 | 65 | renderer.toneMappingExposure = effectController.exposure; |
68 | 66 | renderer.render( scene, camera ); |
|
71 | 69 |
|
72 | 70 | const gui = new GUI(); |
73 | 71 |
|
74 | | - gui.add( effectController, "turbidity", 0.0, 20.0, 0.1 ).onChange( guiChanged ); |
75 | | - gui.add( effectController, "rayleigh", 0.0, 4, 0.001 ).onChange( guiChanged ); |
76 | | - gui.add( effectController, "mieCoefficient", 0.0, 0.1, 0.001 ).onChange( guiChanged ); |
77 | | - gui.add( effectController, "mieDirectionalG", 0.0, 1, 0.001 ).onChange( guiChanged ); |
78 | | - gui.add( effectController, "inclination", -1, 1, 0.0001 ).onChange( guiChanged ); |
79 | | - gui.add( effectController, "azimuth", 0, 1, 0.0001 ).onChange( guiChanged ); |
80 | | - gui.add( effectController, "exposure", 0, 1, 0.0001 ).onChange( guiChanged ); |
| 72 | + gui.add( effectController, 'turbidity', 0.0, 20.0, 0.1 ).onChange( guiChanged ); |
| 73 | + gui.add( effectController, 'rayleigh', 0.0, 4, 0.001 ).onChange( guiChanged ); |
| 74 | + gui.add( effectController, 'mieCoefficient', 0.0, 0.1, 0.001 ).onChange( guiChanged ); |
| 75 | + gui.add( effectController, 'mieDirectionalG', 0.0, 1, 0.001 ).onChange( guiChanged ); |
| 76 | + gui.add( effectController, 'elevation', 0, 90, 0.1 ).onChange( guiChanged ); |
| 77 | + gui.add( effectController, 'azimuth', - 180, 180, 0.1 ).onChange( guiChanged ); |
| 78 | + gui.add( effectController, 'exposure', 0, 1, 0.0001 ).onChange( guiChanged ); |
81 | 79 |
|
82 | 80 | guiChanged(); |
83 | 81 |
|
|
0 commit comments