Setting the file. One moment.
Lights · Frost Sequence Camera Orbit · heygen-com/hyperframes · Skills Docs
ContentsBack to the top of the page Three Mesh BVH LICENSE
(opens in a new tab)
source/src/scene/ Lights.ts
TypeScript · 103 lines · 3 KB
.
HemisphereLight
(
0xffffff
,
0x000000
,
0.2
);
8 rim = new THREE . SpotLight ( 0xffffff , 1 , 0 , Math. PI / 3 , 1 , 0 );
9 accentCool = new THREE . DirectionalLight ( 0xc7ddff , 0.35 );
10 accentWarm = new THREE . DirectionalLight ( 0xffdfc4 , 0.22 );
11 group = new THREE . Group ();
12 private mapSize = 0 ;
13 private settingsVersion = - 1 ;
14
15 constructor () {
16 this .key.castShadow = true ;
17 this .key.shadow.camera.left = - 5.5 ;
18 this .key.shadow.camera.right = 5.5 ;
19 this .key.shadow.camera.top = 5.5 ;
20 this .key.shadow.camera.bottom = - 5.5 ;
21 this .key.shadow.camera.near = 2 ;
22 this .key.shadow.camera.far = 30 ;
23 this .key.target.position. set ( 0 , 0 , 0 );
24 this .rim.target.position. set ( 0 , 0 , 0 );
25 this .group. add (
26 this .key,
27 this .key.target,
28 this .fill,
29 this .rim,
30 this .rim.target,
31 this .accentCool,
32 this .accentCool.target,
33 this .accentWarm,
34 this .accentWarm.target,
35 );
36 }
37
38 update ( t : number , hoverAmount : number ) {
39 const L = D .lighting;
40 const swayA = Math. sin ((t * 2 * Math. PI ) / Math. max ( 1 , L .sway.period)) * L .sway.amplitude;
41 const swayB =
42 Math. sin (((t * 2 * Math. PI ) / Math. max ( 1 , L .sway.period)) * 0.61 + 0.8 ) * L .sway.amplitude;
43 const el = THREE .MathUtils. degToRad ( L .key.elevation + swayB * 40 );
44 const az = THREE .MathUtils. degToRad ( L .key.azimuth + swayA * 60 );
45 const dist = 12 ;
46 this .key.position. set (
47 Math. cos (el) * Math. sin (az) * dist,
48 Math. sin (el) * dist,
49 Math. cos (el) * Math. cos (az) * dist,
50 );
51 this .key.intensity = L .key.intensity * ( 1 + L .key.hoverBoost * hoverAmount);
52 const rel = THREE .MathUtils. degToRad ( L .rimElevation);
53 const raz = THREE .MathUtils. degToRad ( L .rimAzimuth ?? 180 );
54 this .rim.position. set (
55 Math. cos (rel) * Math. sin (raz) * 10 ,
56 Math. sin (rel) * 10 ,
57 Math. cos (rel) * Math. cos (raz) * 10 ,
58 );
59 for ( const [ light , cfg ] of [
60 [ this .accentCool, L .accentCool],
61 [ this .accentWarm, L .accentWarm],
62 ] as const ) {
63 if ( ! cfg) continue ;
64 const e = THREE .MathUtils. degToRad (cfg.elevation),
65 a = THREE .MathUtils. degToRad (cfg.azimuth);
66 light.position. set (
67 Math. cos (e) * Math. sin (a) * 12 ,
68 Math. sin (e) * 12 ,
69 Math. cos (e) * Math. cos (a) * 12 ,
70 );
71 light.color. set (cfg.color);
72 light.intensity = cfg.intensity;
73 }
74 if ( D .version !== this .settingsVersion) {
75 this .settingsVersion = D .version;
76 this .key.color. set ( L .key.color);
77 this .fill.intensity = L .fill;
78 this .fill.color. set ( L .fillColor);
79 this .fill.groundColor. set ( L .fillGroundColor);
80 this .rim.color. set ( L .rimColor);
81 this .rim.intensity = L .rim * 40 ;
82 this .rim.angle = THREE .MathUtils. degToRad ( L .rimAngle ?? 65 );
83 this .rim.penumbra = 1 ;
84 this .rim.decay = 1.2 ;
85 this .rim.distance = 60 ;
86 const sh = this .key.shadow;
87 sh.radius = L .shadow.softness;
88 sh.blurSamples = Math. round ( L .shadow.samples);
89 sh.bias = L .shadow.bias;
90 sh.intensity = L .shadow.intensity;
91 const ms = parseInt ( L .shadow.mapSize, 10 );
92 if (ms !== this .mapSize) {
93 this .mapSize = ms;
94 sh.mapSize. set (ms, ms);
95 if (sh.map) {
96 sh.map. dispose ();
97 (sh as any ).map = null ;
98 }
99 sh.needsUpdate = true ;
100 }
101 }
102 }
103 }