1 | import { Color } from '../math/Color.js';
|
2 | import { Vector3 } from '../math/Vector3.js';
|
3 | import { LightProbe } from './LightProbe.js';
|
4 |
|
5 | class HemisphereLightProbe extends LightProbe {
|
6 |
|
7 | constructor( skyColor, groundColor, intensity = 1 ) {
|
8 |
|
9 | super( undefined, intensity );
|
10 |
|
11 | const color1 = new Color().set( skyColor );
|
12 | const color2 = new Color().set( groundColor );
|
13 |
|
14 | const sky = new Vector3( color1.r, color1.g, color1.b );
|
15 | const ground = new Vector3( color2.r, color2.g, color2.b );
|
16 |
|
17 |
|
18 | const c0 = Math.sqrt( Math.PI );
|
19 | const c1 = c0 * Math.sqrt( 0.75 );
|
20 |
|
21 | this.sh.coefficients[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 );
|
22 | this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 );
|
23 |
|
24 | }
|
25 |
|
26 | }
|
27 |
|
28 | HemisphereLightProbe.prototype.isHemisphereLightProbe = true;
|
29 |
|
30 | export { HemisphereLightProbe };
|