@@ -15,11 +15,11 @@ import {
15
15
} from './constants.js' ;
16
16
import { ShadowRenderer } from './renderer/shadow-renderer.js' ;
17
17
18
- var spotCenter = new Vec3 ( ) ;
19
- var spotEndPoint = new Vec3 ( ) ;
20
- var tmpVec = new Vec3 ( ) ;
18
+ const spotCenter = new Vec3 ( ) ;
19
+ const spotEndPoint = new Vec3 ( ) ;
20
+ const tmpVec = new Vec3 ( ) ;
21
21
22
- var chanId = { r : 0 , g : 1 , b : 2 , a : 3 } ;
22
+ const chanId = { r : 0 , g : 1 , b : 2 , a : 3 } ;
23
23
24
24
// viewport in shadows map for cascades for directional light
25
25
const directionalCascades = [
@@ -129,7 +129,7 @@ class Light {
129
129
130
130
// Cache of light property data in a format more friendly for shader uniforms
131
131
this . _finalColor = new Float32Array ( [ 0.8 , 0.8 , 0.8 ] ) ;
132
- var c = Math . pow ( this . _finalColor [ 0 ] , 2.2 ) ;
132
+ const c = Math . pow ( this . _finalColor [ 0 ] , 2.2 ) ;
133
133
this . _linearFinalColor = new Float32Array ( [ c , c , c ] ) ;
134
134
135
135
this . _position = new Vec3 ( 0 , 0 , 0 ) ;
@@ -213,7 +213,7 @@ class Light {
213
213
* @returns {Light } A cloned Light.
214
214
*/
215
215
clone ( ) {
216
- var clone = new Light ( this . device ) ;
216
+ const clone = new Light ( this . device ) ;
217
217
218
218
// Clone Light properties
219
219
clone . type = this . _type ;
@@ -292,10 +292,10 @@ class Light {
292
292
293
293
getBoundingSphere ( sphere ) {
294
294
if ( this . _type === LIGHTTYPE_SPOT ) {
295
- var range = this . attenuationEnd ;
296
- var angle = this . _outerConeAngle ;
297
- var f = Math . cos ( angle * math . DEG_TO_RAD ) ;
298
- var node = this . _node ;
295
+ const range = this . attenuationEnd ;
296
+ const angle = this . _outerConeAngle ;
297
+ const f = Math . cos ( angle * math . DEG_TO_RAD ) ;
298
+ const node = this . _node ;
299
299
300
300
spotCenter . copy ( node . up ) ;
301
301
spotCenter . mulScalar ( - range * 0.5 * f ) ;
@@ -319,11 +319,11 @@ class Light {
319
319
320
320
getBoundingBox ( box ) {
321
321
if ( this . _type === LIGHTTYPE_SPOT ) {
322
- var range = this . attenuationEnd ;
323
- var angle = this . _outerConeAngle ;
324
- var node = this . _node ;
322
+ const range = this . attenuationEnd ;
323
+ const angle = this . _outerConeAngle ;
324
+ const node = this . _node ;
325
325
326
- var scl = Math . abs ( Math . sin ( angle * math . DEG_TO_RAD ) * range ) ;
326
+ const scl = Math . abs ( Math . sin ( angle * math . DEG_TO_RAD ) * range ) ;
327
327
328
328
box . center . set ( 0 , - range * 0.5 , 0 ) ;
329
329
box . halfExtents . set ( scl , range * 0.5 , scl ) ;
@@ -337,15 +337,15 @@ class Light {
337
337
}
338
338
339
339
_updateFinalColor ( ) {
340
- var color = this . _color ;
341
- var r = color . r ;
342
- var g = color . g ;
343
- var b = color . b ;
340
+ const color = this . _color ;
341
+ const r = color . r ;
342
+ const g = color . g ;
343
+ const b = color . b ;
344
344
345
- var i = this . _intensity ;
345
+ const i = this . _intensity ;
346
346
347
- var finalColor = this . _finalColor ;
348
- var linearFinalColor = this . _linearFinalColor ;
347
+ const finalColor = this . _finalColor ;
348
+ const linearFinalColor = this . _linearFinalColor ;
349
349
350
350
finalColor [ 0 ] = r * i ;
351
351
finalColor [ 1 ] = g * i ;
@@ -362,19 +362,12 @@ class Light {
362
362
}
363
363
364
364
setColor ( ) {
365
- var r , g , b ;
366
365
if ( arguments . length === 1 ) {
367
- r = arguments [ 0 ] . r ;
368
- g = arguments [ 0 ] . g ;
369
- b = arguments [ 0 ] . b ;
366
+ this . _color . set ( arguments [ 0 ] . r , arguments [ 0 ] . g , arguments [ 0 ] . b ) ;
370
367
} else if ( arguments . length === 3 ) {
371
- r = arguments [ 0 ] ;
372
- g = arguments [ 1 ] ;
373
- b = arguments [ 2 ] ;
368
+ this . _color . set ( arguments [ 0 ] , arguments [ 1 ] , arguments [ 2 ] ) ;
374
369
}
375
370
376
- this . _color . set ( r , g , b ) ;
377
-
378
371
this . _updateFinalColor ( ) ;
379
372
}
380
373
@@ -407,7 +400,7 @@ class Light {
407
400
// 12 : cookie transform
408
401
// 10 - 11 : light source shape
409
402
// 8 - 9 : light num cascades
410
- var key =
403
+ let key =
411
404
( this . _type << 29 ) |
412
405
( ( this . _castShadows ? 1 : 0 ) << 28 ) |
413
406
( this . _shadowType << 25 ) |
@@ -446,7 +439,7 @@ class Light {
446
439
this . _destroyShadowMap ( ) ;
447
440
this . updateKey ( ) ;
448
441
449
- var stype = this . _shadowType ;
442
+ const stype = this . _shadowType ;
450
443
this . _shadowType = null ;
451
444
this . shadowType = stype ; // refresh shadow type; switching from direct/spot to omni and back may change it
452
445
}
@@ -463,7 +456,7 @@ class Light {
463
456
this . _destroyShadowMap ( ) ;
464
457
this . updateKey ( ) ;
465
458
466
- var stype = this . _shadowType ;
459
+ const stype = this . _shadowType ;
467
460
this . _shadowType = null ;
468
461
this . shadowType = stype ; // refresh shadow type; switching shape and back may change it
469
462
}
@@ -476,7 +469,7 @@ class Light {
476
469
if ( this . _shadowType === value )
477
470
return ;
478
471
479
- var device = this . device ;
472
+ const device = this . device ;
480
473
481
474
if ( this . _type === LIGHTTYPE_OMNI )
482
475
value = SHADOW_PCF3 ; // VSM or HW PCF for omni lights is not supported yet
@@ -652,9 +645,9 @@ class Light {
652
645
return ;
653
646
654
647
if ( value . length < 3 ) {
655
- var chr = value . charAt ( value . length - 1 ) ;
656
- var addLen = 3 - value . length ;
657
- for ( var i = 0 ; i < addLen ; i ++ )
648
+ const chr = value . charAt ( value . length - 1 ) ;
649
+ const addLen = 3 - value . length ;
650
+ for ( let i = 0 ; i < addLen ; i ++ )
658
651
value += chr ;
659
652
}
660
653
this . _cookieChannel = value ;
@@ -686,7 +679,7 @@ class Light {
686
679
if ( this . _cookieOffset === value )
687
680
return ;
688
681
689
- var xformNew = ! ! ( this . _cookieTransformSet || value ) ;
682
+ const xformNew = ! ! ( this . _cookieTransformSet || value ) ;
690
683
if ( xformNew && ! value && this . _cookieOffset ) {
691
684
this . _cookieOffset . set ( 0 , 0 ) ;
692
685
} else {
0 commit comments