@inweb/viewer-three 27.1.2 → 27.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -592,7 +592,7 @@
592
592
  * Copyright 2010-2025 Three.js Authors
593
593
  * SPDX-License-Identifier: MIT
594
594
  */
595
- const REVISION = '180';
595
+ const REVISION = '182';
596
596
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
597
597
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
598
598
  const CullFaceNone = 0;
@@ -707,6 +707,10 @@
707
707
  const RGB_ETC1_Format = 36196;
708
708
  const RGB_ETC2_Format = 37492;
709
709
  const RGBA_ETC2_EAC_Format = 37496;
710
+ const R11_EAC_Format = 37488;
711
+ const SIGNED_R11_EAC_Format = 37489;
712
+ const RG11_EAC_Format = 37490;
713
+ const SIGNED_RG11_EAC_Format = 37491;
710
714
  const RGBA_ASTC_4x4_Format = 37808;
711
715
  const RGBA_ASTC_5x4_Format = 37809;
712
716
  const RGBA_ASTC_5x5_Format = 37810;
@@ -753,6 +757,9 @@
753
757
  const LinearSRGBColorSpace = 'srgb-linear';
754
758
  const LinearTransfer = 'linear';
755
759
  const SRGBTransfer = 'srgb';
760
+ const NoNormalPacking = '';
761
+ const NormalRGPacking = 'rg';
762
+ const NormalGAPacking = 'ga';
756
763
  const ZeroStencilOp = 0;
757
764
  const KeepStencilOp = 7680;
758
765
  const ReplaceStencilOp = 7681;
@@ -806,6 +813,92 @@
806
813
  FIRST: 'first',
807
814
  EITHER: 'either'
808
815
  };
816
+ function arrayNeedsUint32( array ) {
817
+ for ( let i = array.length - 1; i >= 0; -- i ) {
818
+ if ( array[ i ] >= 65535 ) return true;
819
+ }
820
+ return false;
821
+ }
822
+ const TYPED_ARRAYS = {
823
+ Int8Array: Int8Array,
824
+ Uint8Array: Uint8Array,
825
+ Uint8ClampedArray: Uint8ClampedArray,
826
+ Int16Array: Int16Array,
827
+ Uint16Array: Uint16Array,
828
+ Int32Array: Int32Array,
829
+ Uint32Array: Uint32Array,
830
+ Float32Array: Float32Array,
831
+ Float64Array: Float64Array
832
+ };
833
+ function getTypedArray( type, buffer ) {
834
+ return new TYPED_ARRAYS[ type ]( buffer );
835
+ }
836
+ function isTypedArray( array ) {
837
+ return ArrayBuffer.isView( array ) && ! ( array instanceof DataView );
838
+ }
839
+ function createElementNS( name ) {
840
+ return document.createElementNS( 'http://www.w3.org/1999/xhtml', name );
841
+ }
842
+ function createCanvasElement() {
843
+ const canvas = createElementNS( 'canvas' );
844
+ canvas.style.display = 'block';
845
+ return canvas;
846
+ }
847
+ const _cache = {};
848
+ let _setConsoleFunction = null;
849
+ function setConsoleFunction( fn ) {
850
+ _setConsoleFunction = fn;
851
+ }
852
+ function getConsoleFunction() {
853
+ return _setConsoleFunction;
854
+ }
855
+ function log( ...params ) {
856
+ const message = 'THREE.' + params.shift();
857
+ if ( _setConsoleFunction ) {
858
+ _setConsoleFunction( 'log', message, ...params );
859
+ } else {
860
+ console.log( message, ...params );
861
+ }
862
+ }
863
+ function warn( ...params ) {
864
+ const message = 'THREE.' + params.shift();
865
+ if ( _setConsoleFunction ) {
866
+ _setConsoleFunction( 'warn', message, ...params );
867
+ } else {
868
+ console.warn( message, ...params );
869
+ }
870
+ }
871
+ function error( ...params ) {
872
+ const message = 'THREE.' + params.shift();
873
+ if ( _setConsoleFunction ) {
874
+ _setConsoleFunction( 'error', message, ...params );
875
+ } else {
876
+ console.error( message, ...params );
877
+ }
878
+ }
879
+ function warnOnce( ...params ) {
880
+ const message = params.join( ' ' );
881
+ if ( message in _cache ) return;
882
+ _cache[ message ] = true;
883
+ warn( ...params );
884
+ }
885
+ function probeAsync( gl, sync, interval ) {
886
+ return new Promise( function ( resolve, reject ) {
887
+ function probe() {
888
+ switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
889
+ case gl.WAIT_FAILED:
890
+ reject();
891
+ break;
892
+ case gl.TIMEOUT_EXPIRED:
893
+ setTimeout( probe, interval );
894
+ break;
895
+ default:
896
+ resolve();
897
+ }
898
+ }
899
+ setTimeout( probe, interval );
900
+ } );
901
+ }
809
902
  class EventDispatcher {
810
903
  addEventListener( type, listener ) {
811
904
  if ( this._listeners === undefined ) this._listeners = {};
@@ -961,7 +1054,7 @@
961
1054
  q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );
962
1055
  break;
963
1056
  default:
964
- console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
1057
+ warn( 'MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
965
1058
  }
966
1059
  }
967
1060
  function denormalize( value, array ) {
@@ -1298,18 +1391,18 @@
1298
1391
  y0 = src0[ srcOffset0 + 1 ],
1299
1392
  z0 = src0[ srcOffset0 + 2 ],
1300
1393
  w0 = src0[ srcOffset0 + 3 ];
1301
- const x1 = src1[ srcOffset1 + 0 ],
1394
+ let x1 = src1[ srcOffset1 + 0 ],
1302
1395
  y1 = src1[ srcOffset1 + 1 ],
1303
1396
  z1 = src1[ srcOffset1 + 2 ],
1304
1397
  w1 = src1[ srcOffset1 + 3 ];
1305
- if ( t === 0 ) {
1398
+ if ( t <= 0 ) {
1306
1399
  dst[ dstOffset + 0 ] = x0;
1307
1400
  dst[ dstOffset + 1 ] = y0;
1308
1401
  dst[ dstOffset + 2 ] = z0;
1309
1402
  dst[ dstOffset + 3 ] = w0;
1310
1403
  return;
1311
1404
  }
1312
- if ( t === 1 ) {
1405
+ if ( t >= 1 ) {
1313
1406
  dst[ dstOffset + 0 ] = x1;
1314
1407
  dst[ dstOffset + 1 ] = y1;
1315
1408
  dst[ dstOffset + 2 ] = z1;
@@ -1317,22 +1410,29 @@
1317
1410
  return;
1318
1411
  }
1319
1412
  if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
1413
+ let dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
1414
+ if ( dot < 0 ) {
1415
+ x1 = - x1;
1416
+ y1 = - y1;
1417
+ z1 = - z1;
1418
+ w1 = - w1;
1419
+ dot = - dot;
1420
+ }
1320
1421
  let s = 1 - t;
1321
- const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
1322
- dir = ( cos >= 0 ? 1 : -1 ),
1323
- sqrSin = 1 - cos * cos;
1324
- if ( sqrSin > Number.EPSILON ) {
1325
- const sin = Math.sqrt( sqrSin ),
1326
- len = Math.atan2( sin, cos * dir );
1327
- s = Math.sin( s * len ) / sin;
1328
- t = Math.sin( t * len ) / sin;
1329
- }
1330
- const tDir = t * dir;
1331
- x0 = x0 * s + x1 * tDir;
1332
- y0 = y0 * s + y1 * tDir;
1333
- z0 = z0 * s + z1 * tDir;
1334
- w0 = w0 * s + w1 * tDir;
1335
- if ( s === 1 - t ) {
1422
+ if ( dot < 0.9995 ) {
1423
+ const theta = Math.acos( dot );
1424
+ const sin = Math.sin( theta );
1425
+ s = Math.sin( s * theta ) / sin;
1426
+ t = Math.sin( t * theta ) / sin;
1427
+ x0 = x0 * s + x1 * t;
1428
+ y0 = y0 * s + y1 * t;
1429
+ z0 = z0 * s + z1 * t;
1430
+ w0 = w0 * s + w1 * t;
1431
+ } else {
1432
+ x0 = x0 * s + x1 * t;
1433
+ y0 = y0 * s + y1 * t;
1434
+ z0 = z0 * s + z1 * t;
1435
+ w0 = w0 * s + w1 * t;
1336
1436
  const f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
1337
1437
  x0 *= f;
1338
1438
  y0 *= f;
@@ -1455,7 +1555,7 @@
1455
1555
  this._w = c1 * c2 * c3 + s1 * s2 * s3;
1456
1556
  break;
1457
1557
  default:
1458
- console.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order );
1558
+ warn( 'Quaternion: .setFromEuler() encountered an unknown order: ' + order );
1459
1559
  }
1460
1560
  if ( update === true ) this._onChangeCallback();
1461
1561
  return this;
@@ -1592,45 +1692,35 @@
1592
1692
  return this;
1593
1693
  }
1594
1694
  slerp( qb, t ) {
1595
- if ( t === 0 ) return this;
1596
- if ( t === 1 ) return this.copy( qb );
1597
- const x = this._x, y = this._y, z = this._z, w = this._w;
1598
- let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
1599
- if ( cosHalfTheta < 0 ) {
1600
- this._w = - qb._w;
1601
- this._x = - qb._x;
1602
- this._y = - qb._y;
1603
- this._z = - qb._z;
1604
- cosHalfTheta = - cosHalfTheta;
1695
+ if ( t <= 0 ) return this;
1696
+ if ( t >= 1 ) return this.copy( qb );
1697
+ let x = qb._x, y = qb._y, z = qb._z, w = qb._w;
1698
+ let dot = this.dot( qb );
1699
+ if ( dot < 0 ) {
1700
+ x = - x;
1701
+ y = - y;
1702
+ z = - z;
1703
+ w = - w;
1704
+ dot = - dot;
1705
+ }
1706
+ let s = 1 - t;
1707
+ if ( dot < 0.9995 ) {
1708
+ const theta = Math.acos( dot );
1709
+ const sin = Math.sin( theta );
1710
+ s = Math.sin( s * theta ) / sin;
1711
+ t = Math.sin( t * theta ) / sin;
1712
+ this._x = this._x * s + x * t;
1713
+ this._y = this._y * s + y * t;
1714
+ this._z = this._z * s + z * t;
1715
+ this._w = this._w * s + w * t;
1716
+ this._onChangeCallback();
1605
1717
  } else {
1606
- this.copy( qb );
1607
- }
1608
- if ( cosHalfTheta >= 1.0 ) {
1609
- this._w = w;
1610
- this._x = x;
1611
- this._y = y;
1612
- this._z = z;
1613
- return this;
1614
- }
1615
- const sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
1616
- if ( sqrSinHalfTheta <= Number.EPSILON ) {
1617
- const s = 1 - t;
1618
- this._w = s * w + t * this._w;
1619
- this._x = s * x + t * this._x;
1620
- this._y = s * y + t * this._y;
1621
- this._z = s * z + t * this._z;
1718
+ this._x = this._x * s + x * t;
1719
+ this._y = this._y * s + y * t;
1720
+ this._z = this._z * s + z * t;
1721
+ this._w = this._w * s + w * t;
1622
1722
  this.normalize();
1623
- return this;
1624
1723
  }
1625
- const sinHalfTheta = Math.sqrt( sqrSinHalfTheta );
1626
- const halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
1627
- const ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
1628
- ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
1629
- this._w = ( w * ratioA + this._w * ratioB );
1630
- this._x = ( x * ratioA + this._x * ratioB );
1631
- this._y = ( y * ratioA + this._y * ratioB );
1632
- this._z = ( z * ratioA + this._z * ratioB );
1633
- this._onChangeCallback();
1634
1724
  return this;
1635
1725
  }
1636
1726
  slerpQuaternions( qa, qb, t ) {
@@ -2318,57 +2408,6 @@
2318
2408
  }
2319
2409
  }
2320
2410
  const _m3 = new Matrix3();
2321
- function arrayNeedsUint32( array ) {
2322
- for ( let i = array.length - 1; i >= 0; -- i ) {
2323
- if ( array[ i ] >= 65535 ) return true;
2324
- }
2325
- return false;
2326
- }
2327
- const TYPED_ARRAYS = {
2328
- Int8Array: Int8Array,
2329
- Uint8Array: Uint8Array,
2330
- Uint8ClampedArray: Uint8ClampedArray,
2331
- Int16Array: Int16Array,
2332
- Uint16Array: Uint16Array,
2333
- Int32Array: Int32Array,
2334
- Uint32Array: Uint32Array,
2335
- Float32Array: Float32Array,
2336
- Float64Array: Float64Array
2337
- };
2338
- function getTypedArray( type, buffer ) {
2339
- return new TYPED_ARRAYS[ type ]( buffer );
2340
- }
2341
- function createElementNS( name ) {
2342
- return document.createElementNS( 'http://www.w3.org/1999/xhtml', name );
2343
- }
2344
- function createCanvasElement() {
2345
- const canvas = createElementNS( 'canvas' );
2346
- canvas.style.display = 'block';
2347
- return canvas;
2348
- }
2349
- const _cache = {};
2350
- function warnOnce( message ) {
2351
- if ( message in _cache ) return;
2352
- _cache[ message ] = true;
2353
- console.warn( message );
2354
- }
2355
- function probeAsync( gl, sync, interval ) {
2356
- return new Promise( function ( resolve, reject ) {
2357
- function probe() {
2358
- switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
2359
- case gl.WAIT_FAILED:
2360
- reject();
2361
- break;
2362
- case gl.TIMEOUT_EXPIRED:
2363
- setTimeout( probe, interval );
2364
- break;
2365
- default:
2366
- resolve();
2367
- }
2368
- }
2369
- setTimeout( probe, interval );
2370
- } );
2371
- }
2372
2411
  const LINEAR_REC709_TO_XYZ = new Matrix3().set(
2373
2412
  0.4123908, 0.3575843, 0.1804808,
2374
2413
  0.2126390, 0.7151687, 0.0721923,
@@ -2438,11 +2477,11 @@
2438
2477
  return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
2439
2478
  },
2440
2479
  fromWorkingColorSpace: function ( color, targetColorSpace ) {
2441
- warnOnce( 'THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().' );
2480
+ warnOnce( 'ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().' );
2442
2481
  return ColorManagement.workingToColorSpace( color, targetColorSpace );
2443
2482
  },
2444
2483
  toWorkingColorSpace: function ( color, sourceColorSpace ) {
2445
- warnOnce( 'THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().' );
2484
+ warnOnce( 'ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().' );
2446
2485
  return ColorManagement.colorSpaceToWorking( color, sourceColorSpace );
2447
2486
  },
2448
2487
  };
@@ -2536,7 +2575,7 @@
2536
2575
  height: image.height
2537
2576
  };
2538
2577
  } else {
2539
- console.warn( 'THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );
2578
+ warn( 'ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );
2540
2579
  return image;
2541
2580
  }
2542
2581
  }
@@ -2555,7 +2594,7 @@
2555
2594
  const data = this.data;
2556
2595
  if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( data instanceof HTMLVideoElement ) ) {
2557
2596
  target.set( data.videoWidth, data.videoHeight, 0 );
2558
- } else if ( data instanceof VideoFrame ) {
2597
+ } else if ( ( typeof VideoFrame !== 'undefined' ) && ( data instanceof VideoFrame ) ) {
2559
2598
  target.set( data.displayHeight, data.displayWidth, 0 );
2560
2599
  } else if ( data !== null ) {
2561
2600
  target.set( data.width, data.height, data.depth || 0 );
@@ -2613,7 +2652,7 @@
2613
2652
  type: image.data.constructor.name
2614
2653
  };
2615
2654
  } else {
2616
- console.warn( 'THREE.Texture: Unable to serialize Texture.' );
2655
+ warn( 'Texture: Unable to serialize Texture.' );
2617
2656
  return {};
2618
2657
  }
2619
2658
  }
@@ -2722,12 +2761,12 @@
2722
2761
  for ( const key in values ) {
2723
2762
  const newValue = values[ key ];
2724
2763
  if ( newValue === undefined ) {
2725
- console.warn( `THREE.Texture.setValues(): parameter '${ key }' has value of undefined.` );
2764
+ warn( `Texture.setValues(): parameter '${ key }' has value of undefined.` );
2726
2765
  continue;
2727
2766
  }
2728
2767
  const currentValue = this[ key ];
2729
2768
  if ( currentValue === undefined ) {
2730
- console.warn( `THREE.Texture.setValues(): property '${ key }' does not exist.` );
2769
+ warn( `Texture.setValues(): property '${ key }' does not exist.` );
2731
2770
  continue;
2732
2771
  }
2733
2772
  if ( ( currentValue && newValue ) && ( currentValue.isVector2 && newValue.isVector2 ) ) {
@@ -3320,7 +3359,9 @@
3320
3359
  this.textures[ i ].image.width = width;
3321
3360
  this.textures[ i ].image.height = height;
3322
3361
  this.textures[ i ].image.depth = depth;
3323
- this.textures[ i ].isArrayTexture = this.textures[ i ].image.depth > 1;
3362
+ if ( this.textures[ i ].isData3DTexture !== true ) {
3363
+ this.textures[ i ].isArrayTexture = this.textures[ i ].image.depth > 1;
3364
+ }
3324
3365
  }
3325
3366
  this.dispose();
3326
3367
  }
@@ -4142,6 +4183,12 @@
4142
4183
  return this;
4143
4184
  }
4144
4185
  extractBasis( xAxis, yAxis, zAxis ) {
4186
+ if ( this.determinant() === 0 ) {
4187
+ xAxis.set( 1, 0, 0 );
4188
+ yAxis.set( 0, 1, 0 );
4189
+ zAxis.set( 0, 0, 1 );
4190
+ return this;
4191
+ }
4145
4192
  xAxis.setFromMatrixColumn( this, 0 );
4146
4193
  yAxis.setFromMatrixColumn( this, 1 );
4147
4194
  zAxis.setFromMatrixColumn( this, 2 );
@@ -4157,6 +4204,9 @@
4157
4204
  return this;
4158
4205
  }
4159
4206
  extractRotation( m ) {
4207
+ if ( m.determinant() === 0 ) {
4208
+ return this.identity();
4209
+ }
4160
4210
  const te = this.elements;
4161
4211
  const me = m.elements;
4162
4212
  const scaleX = 1 / _v1$5.setFromMatrixColumn( m, 0 ).length();
@@ -4339,40 +4389,16 @@
4339
4389
  const n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];
4340
4390
  const n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];
4341
4391
  const n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];
4342
- return (
4343
- n41 * (
4344
- + n14 * n23 * n32
4345
- - n13 * n24 * n32
4346
- - n14 * n22 * n33
4347
- + n12 * n24 * n33
4348
- + n13 * n22 * n34
4349
- - n12 * n23 * n34
4350
- ) +
4351
- n42 * (
4352
- + n11 * n23 * n34
4353
- - n11 * n24 * n33
4354
- + n14 * n21 * n33
4355
- - n13 * n21 * n34
4356
- + n13 * n24 * n31
4357
- - n14 * n23 * n31
4358
- ) +
4359
- n43 * (
4360
- + n11 * n24 * n32
4361
- - n11 * n22 * n34
4362
- - n14 * n21 * n32
4363
- + n12 * n21 * n34
4364
- + n14 * n22 * n31
4365
- - n12 * n24 * n31
4366
- ) +
4367
- n44 * (
4368
- - n13 * n22 * n31
4369
- - n11 * n23 * n32
4370
- + n11 * n22 * n33
4371
- + n13 * n21 * n32
4372
- - n12 * n21 * n33
4373
- + n12 * n23 * n31
4374
- )
4375
- );
4392
+ const t11 = n23 * n34 - n24 * n33;
4393
+ const t12 = n22 * n34 - n24 * n32;
4394
+ const t13 = n22 * n33 - n23 * n32;
4395
+ const t21 = n21 * n34 - n24 * n31;
4396
+ const t22 = n21 * n33 - n23 * n31;
4397
+ const t23 = n21 * n32 - n22 * n31;
4398
+ return n11 * ( n42 * t11 - n43 * t12 + n44 * t13 ) -
4399
+ n12 * ( n41 * t11 - n43 * t21 + n44 * t22 ) +
4400
+ n13 * ( n41 * t12 - n42 * t21 + n44 * t23 ) -
4401
+ n14 * ( n41 * t13 - n42 * t22 + n43 * t23 );
4376
4402
  }
4377
4403
  transpose() {
4378
4404
  const te = this.elements;
@@ -4553,14 +4579,19 @@
4553
4579
  }
4554
4580
  decompose( position, quaternion, scale ) {
4555
4581
  const te = this.elements;
4582
+ position.x = te[ 12 ];
4583
+ position.y = te[ 13 ];
4584
+ position.z = te[ 14 ];
4585
+ if ( this.determinant() === 0 ) {
4586
+ scale.set( 1, 1, 1 );
4587
+ quaternion.identity();
4588
+ return this;
4589
+ }
4556
4590
  let sx = _v1$5.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
4557
4591
  const sy = _v1$5.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
4558
4592
  const sz = _v1$5.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
4559
4593
  const det = this.determinant();
4560
4594
  if ( det < 0 ) sx = - sx;
4561
- position.x = te[ 12 ];
4562
- position.y = te[ 13 ];
4563
- position.z = te[ 14 ];
4564
4595
  _m1$2.copy( this );
4565
4596
  const invSX = 1 / sx;
4566
4597
  const invSY = 1 / sy;
@@ -4800,7 +4831,7 @@
4800
4831
  }
4801
4832
  break;
4802
4833
  default:
4803
- console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );
4834
+ warn( 'Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );
4804
4835
  }
4805
4836
  this._order = order;
4806
4837
  if ( update === true ) this._onChangeCallback();
@@ -5054,7 +5085,7 @@
5054
5085
  return this;
5055
5086
  }
5056
5087
  if ( object === this ) {
5057
- console.error( 'THREE.Object3D.add: object can\'t be added as a child of itself.', object );
5088
+ error( 'Object3D.add: object can\'t be added as a child of itself.', object );
5058
5089
  return this;
5059
5090
  }
5060
5091
  if ( object && object.isObject3D ) {
@@ -5066,7 +5097,7 @@
5066
5097
  this.dispatchEvent( _childaddedEvent );
5067
5098
  _childaddedEvent.child = null;
5068
5099
  } else {
5069
- console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object );
5100
+ error( 'Object3D.add: object not an instance of THREE.Object3D.', object );
5070
5101
  }
5071
5102
  return this;
5072
5103
  }
@@ -5717,7 +5748,7 @@
5717
5748
  function handleAlpha( string ) {
5718
5749
  if ( string === undefined ) return;
5719
5750
  if ( parseFloat( string ) < 1 ) {
5720
- console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );
5751
+ warn( 'Color: Alpha component of ' + style + ' will be ignored.' );
5721
5752
  }
5722
5753
  }
5723
5754
  let m;
@@ -5760,7 +5791,7 @@
5760
5791
  }
5761
5792
  break;
5762
5793
  default:
5763
- console.warn( 'THREE.Color: Unknown color model ' + style );
5794
+ warn( 'Color: Unknown color model ' + style );
5764
5795
  }
5765
5796
  } else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) {
5766
5797
  const hex = m[ 1 ];
@@ -5775,7 +5806,7 @@
5775
5806
  } else if ( size === 6 ) {
5776
5807
  return this.setHex( parseInt( hex, 16 ), colorSpace );
5777
5808
  } else {
5778
- console.warn( 'THREE.Color: Invalid hex color ' + style );
5809
+ warn( 'Color: Invalid hex color ' + style );
5779
5810
  }
5780
5811
  } else if ( style && style.length > 0 ) {
5781
5812
  return this.setColorName( style, colorSpace );
@@ -5787,7 +5818,7 @@
5787
5818
  if ( hex !== undefined ) {
5788
5819
  this.setHex( hex, colorSpace );
5789
5820
  } else {
5790
- console.warn( 'THREE.Color: Unknown color ' + style );
5821
+ warn( 'Color: Unknown color ' + style );
5791
5822
  }
5792
5823
  return this;
5793
5824
  }
@@ -6047,12 +6078,12 @@
6047
6078
  for ( const key in values ) {
6048
6079
  const newValue = values[ key ];
6049
6080
  if ( newValue === undefined ) {
6050
- console.warn( `THREE.Material: parameter '${ key }' has value of undefined.` );
6081
+ warn( `Material: parameter '${ key }' has value of undefined.` );
6051
6082
  continue;
6052
6083
  }
6053
6084
  const currentValue = this[ key ];
6054
6085
  if ( currentValue === undefined ) {
6055
- console.warn( `THREE.Material: '${ key }' is not a property of THREE.${ this.type }.` );
6086
+ warn( `Material: '${ key }' is not a property of THREE.${ this.type }.` );
6056
6087
  continue;
6057
6088
  }
6058
6089
  if ( currentValue && currentValue.isColor ) {
@@ -6217,6 +6248,7 @@
6217
6248
  if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
6218
6249
  if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
6219
6250
  if ( this.forceSinglePass === true ) data.forceSinglePass = true;
6251
+ if ( this.allowOverride === false ) data.allowOverride = false;
6220
6252
  if ( this.wireframe === true ) data.wireframe = true;
6221
6253
  if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
6222
6254
  if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
@@ -6296,6 +6328,7 @@
6296
6328
  this.alphaToCoverage = source.alphaToCoverage;
6297
6329
  this.premultipliedAlpha = source.premultipliedAlpha;
6298
6330
  this.forceSinglePass = source.forceSinglePass;
6331
+ this.allowOverride = source.allowOverride;
6299
6332
  this.visible = source.visible;
6300
6333
  this.toneMapped = source.toneMapped;
6301
6334
  this.userData = JSON.parse( JSON.stringify( source.userData ) );
@@ -6434,7 +6467,7 @@
6434
6467
  };
6435
6468
  }
6436
6469
  function toHalfFloat( val ) {
6437
- if ( Math.abs( val ) > 65504 ) console.warn( 'THREE.DataUtils.toHalfFloat(): Value out of range.' );
6470
+ if ( Math.abs( val ) > 65504 ) warn( 'DataUtils.toHalfFloat(): Value out of range.' );
6438
6471
  val = clamp( val, -65504, 65504 );
6439
6472
  _tables.floatView[ 0 ] = val;
6440
6473
  const f = _tables.uint32View[ 0 ];
@@ -6798,6 +6831,7 @@
6798
6831
  this.type = 'BufferGeometry';
6799
6832
  this.index = null;
6800
6833
  this.indirect = null;
6834
+ this.indirectOffset = 0;
6801
6835
  this.attributes = {};
6802
6836
  this.morphAttributes = {};
6803
6837
  this.morphTargetsRelative = false;
@@ -6818,8 +6852,9 @@
6818
6852
  }
6819
6853
  return this;
6820
6854
  }
6821
- setIndirect( indirect ) {
6855
+ setIndirect( indirect, indirectOffset = 0 ) {
6822
6856
  this.indirect = indirect;
6857
+ this.indirectOffset = indirectOffset;
6823
6858
  return this;
6824
6859
  }
6825
6860
  getIndirect() {
@@ -6936,7 +6971,7 @@
6936
6971
  positionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );
6937
6972
  }
6938
6973
  if ( points.length > positionAttribute.count ) {
6939
- console.warn( 'THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );
6974
+ warn( 'BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );
6940
6975
  }
6941
6976
  positionAttribute.needsUpdate = true;
6942
6977
  }
@@ -6949,7 +6984,7 @@
6949
6984
  const position = this.attributes.position;
6950
6985
  const morphAttributesPosition = this.morphAttributes.position;
6951
6986
  if ( position && position.isGLBufferAttribute ) {
6952
- console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.', this );
6987
+ error( 'BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.', this );
6953
6988
  this.boundingBox.set(
6954
6989
  new Vector3( - Infinity, - Infinity, - Infinity ),
6955
6990
  new Vector3( + Infinity, + Infinity, + Infinity )
@@ -6977,7 +7012,7 @@
6977
7012
  this.boundingBox.makeEmpty();
6978
7013
  }
6979
7014
  if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
6980
- console.error( 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
7015
+ error( 'BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
6981
7016
  }
6982
7017
  }
6983
7018
  computeBoundingSphere() {
@@ -6987,7 +7022,7 @@
6987
7022
  const position = this.attributes.position;
6988
7023
  const morphAttributesPosition = this.morphAttributes.position;
6989
7024
  if ( position && position.isGLBufferAttribute ) {
6990
- console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.', this );
7025
+ error( 'BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.', this );
6991
7026
  this.boundingSphere.set( new Vector3(), Infinity );
6992
7027
  return;
6993
7028
  }
@@ -7031,7 +7066,7 @@
7031
7066
  }
7032
7067
  this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
7033
7068
  if ( isNaN( this.boundingSphere.radius ) ) {
7034
- console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
7069
+ error( 'BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
7035
7070
  }
7036
7071
  }
7037
7072
  }
@@ -7042,7 +7077,7 @@
7042
7077
  attributes.position === undefined ||
7043
7078
  attributes.normal === undefined ||
7044
7079
  attributes.uv === undefined ) {
7045
- console.error( 'THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' );
7080
+ error( 'BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' );
7046
7081
  return;
7047
7082
  }
7048
7083
  const positionAttribute = attributes.position;
@@ -7212,7 +7247,7 @@
7212
7247
  return new BufferAttribute( array2, itemSize, normalized );
7213
7248
  }
7214
7249
  if ( this.index === null ) {
7215
- console.warn( 'THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' );
7250
+ warn( 'BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' );
7216
7251
  return this;
7217
7252
  }
7218
7253
  const geometry2 = new BufferGeometry();
@@ -7678,7 +7713,7 @@
7678
7713
  property.isVector2 || property.isVector3 || property.isVector4 ||
7679
7714
  property.isTexture || property.isQuaternion ) ) {
7680
7715
  if ( property.isRenderTargetTexture ) {
7681
- console.warn( 'UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().' );
7716
+ warn( 'UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().' );
7682
7717
  dst[ u ][ p ] = null;
7683
7718
  } else {
7684
7719
  dst[ u ][ p ] = property.clone();
@@ -7769,6 +7804,9 @@
7769
7804
  this.clipping = source.clipping;
7770
7805
  this.extensions = Object.assign( {}, source.extensions );
7771
7806
  this.glslVersion = source.glslVersion;
7807
+ this.defaultAttributeValues = Object.assign( {}, source.defaultAttributeValues );
7808
+ this.index0AttributeName = source.index0AttributeName;
7809
+ this.uniformsNeedUpdate = source.uniformsNeedUpdate;
7772
7810
  return this;
7773
7811
  }
7774
7812
  toJSON( meta ) {
@@ -8682,7 +8720,7 @@
8682
8720
  }
8683
8721
  clone( data ) {
8684
8722
  if ( data === undefined ) {
8685
- console.log( 'THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.' );
8723
+ log( 'InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.' );
8686
8724
  const array = [];
8687
8725
  for ( let i = 0; i < this.count; i ++ ) {
8688
8726
  const index = i * this.data.stride + this.offset;
@@ -8703,7 +8741,7 @@
8703
8741
  }
8704
8742
  toJSON( data ) {
8705
8743
  if ( data === undefined ) {
8706
- console.log( 'THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.' );
8744
+ log( 'InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.' );
8707
8745
  const array = [];
8708
8746
  for ( let i = 0; i < this.count; i ++ ) {
8709
8747
  const index = i * this.data.stride + this.offset;
@@ -8797,7 +8835,7 @@
8797
8835
  }
8798
8836
  raycast( raycaster, intersects ) {
8799
8837
  if ( raycaster.camera === null ) {
8800
- console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' );
8838
+ error( 'Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' );
8801
8839
  }
8802
8840
  _worldScale.setFromMatrixScale( this.matrixWorld );
8803
8841
  _viewWorldMatrix.copy( raycaster.camera.matrixWorld );
@@ -9086,7 +9124,7 @@
9086
9124
  } else if ( this.bindMode === DetachedBindMode ) {
9087
9125
  this.bindMatrixInverse.copy( this.bindMatrix ).invert();
9088
9126
  } else {
9089
- console.warn( 'THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode );
9127
+ warn( 'SkinnedMesh: Unrecognized bindMode: ' + this.bindMode );
9090
9128
  }
9091
9129
  }
9092
9130
  applyBoneTransform( index, target ) {
@@ -9132,6 +9170,7 @@
9132
9170
  this.bones = bones.slice( 0 );
9133
9171
  this.boneInverses = boneInverses;
9134
9172
  this.boneMatrices = null;
9173
+ this.previousBoneMatrices = null;
9135
9174
  this.boneTexture = null;
9136
9175
  this.init();
9137
9176
  }
@@ -9143,7 +9182,7 @@
9143
9182
  this.calculateInverses();
9144
9183
  } else {
9145
9184
  if ( bones.length !== boneInverses.length ) {
9146
- console.warn( 'THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.' );
9185
+ warn( 'Skeleton: Number of inverse bone matrices does not match amount of bones.' );
9147
9186
  this.boneInverses = [];
9148
9187
  for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
9149
9188
  this.boneInverses.push( new Matrix4() );
@@ -9231,7 +9270,7 @@
9231
9270
  const uuid = json.bones[ i ];
9232
9271
  let bone = bones[ uuid ];
9233
9272
  if ( bone === undefined ) {
9234
- console.warn( 'THREE.Skeleton: No bone found with UUID:', uuid );
9273
+ warn( 'Skeleton: No bone found with UUID:', uuid );
9235
9274
  bone = new Bone();
9236
9275
  }
9237
9276
  this.bones.push( bone );
@@ -9624,7 +9663,7 @@
9624
9663
  return new this.constructor().copy( this );
9625
9664
  }
9626
9665
  }
9627
- const _projScreenMatrix$2 = new Matrix4();
9666
+ const _projScreenMatrix$1 = new Matrix4();
9628
9667
  const _frustum$1 = new Frustum();
9629
9668
  class FrustumArray {
9630
9669
  constructor() {
@@ -9636,12 +9675,12 @@
9636
9675
  }
9637
9676
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9638
9677
  const camera = cameraArray.cameras[ i ];
9639
- _projScreenMatrix$2.multiplyMatrices(
9678
+ _projScreenMatrix$1.multiplyMatrices(
9640
9679
  camera.projectionMatrix,
9641
9680
  camera.matrixWorldInverse
9642
9681
  );
9643
9682
  _frustum$1.setFromProjectionMatrix(
9644
- _projScreenMatrix$2,
9683
+ _projScreenMatrix$1,
9645
9684
  camera.coordinateSystem,
9646
9685
  camera.reversedDepth
9647
9686
  );
@@ -9657,12 +9696,12 @@
9657
9696
  }
9658
9697
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9659
9698
  const camera = cameraArray.cameras[ i ];
9660
- _projScreenMatrix$2.multiplyMatrices(
9699
+ _projScreenMatrix$1.multiplyMatrices(
9661
9700
  camera.projectionMatrix,
9662
9701
  camera.matrixWorldInverse
9663
9702
  );
9664
9703
  _frustum$1.setFromProjectionMatrix(
9665
- _projScreenMatrix$2,
9704
+ _projScreenMatrix$1,
9666
9705
  camera.coordinateSystem,
9667
9706
  camera.reversedDepth
9668
9707
  );
@@ -9678,12 +9717,12 @@
9678
9717
  }
9679
9718
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9680
9719
  const camera = cameraArray.cameras[ i ];
9681
- _projScreenMatrix$2.multiplyMatrices(
9720
+ _projScreenMatrix$1.multiplyMatrices(
9682
9721
  camera.projectionMatrix,
9683
9722
  camera.matrixWorldInverse
9684
9723
  );
9685
9724
  _frustum$1.setFromProjectionMatrix(
9686
- _projScreenMatrix$2,
9725
+ _projScreenMatrix$1,
9687
9726
  camera.coordinateSystem,
9688
9727
  camera.reversedDepth
9689
9728
  );
@@ -9699,12 +9738,12 @@
9699
9738
  }
9700
9739
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9701
9740
  const camera = cameraArray.cameras[ i ];
9702
- _projScreenMatrix$2.multiplyMatrices(
9741
+ _projScreenMatrix$1.multiplyMatrices(
9703
9742
  camera.projectionMatrix,
9704
9743
  camera.matrixWorldInverse
9705
9744
  );
9706
9745
  _frustum$1.setFromProjectionMatrix(
9707
- _projScreenMatrix$2,
9746
+ _projScreenMatrix$1,
9708
9747
  camera.coordinateSystem,
9709
9748
  camera.reversedDepth
9710
9749
  );
@@ -9720,12 +9759,12 @@
9720
9759
  }
9721
9760
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9722
9761
  const camera = cameraArray.cameras[ i ];
9723
- _projScreenMatrix$2.multiplyMatrices(
9762
+ _projScreenMatrix$1.multiplyMatrices(
9724
9763
  camera.projectionMatrix,
9725
9764
  camera.matrixWorldInverse
9726
9765
  );
9727
9766
  _frustum$1.setFromProjectionMatrix(
9728
- _projScreenMatrix$2,
9767
+ _projScreenMatrix$1,
9729
9768
  camera.coordinateSystem,
9730
9769
  camera.reversedDepth
9731
9770
  );
@@ -10151,6 +10190,7 @@
10151
10190
  }
10152
10191
  index.array.copyWithin( nextIndexStart, indexStart, indexStart + reservedIndexCount );
10153
10192
  index.addUpdateRange( nextIndexStart, reservedIndexCount );
10193
+ index.needsUpdate = true;
10154
10194
  geometryInfo.indexStart = nextIndexStart;
10155
10195
  }
10156
10196
  nextIndexStart += geometryInfo.reservedIndexCount;
@@ -10163,6 +10203,7 @@
10163
10203
  const { array, itemSize } = attribute;
10164
10204
  array.copyWithin( nextVertexStart * itemSize, vertexStart * itemSize, ( vertexStart + reservedVertexCount ) * itemSize );
10165
10205
  attribute.addUpdateRange( nextVertexStart * itemSize, reservedVertexCount * itemSize );
10206
+ attribute.needsUpdate = true;
10166
10207
  }
10167
10208
  geometryInfo.vertexStart = nextVertexStart;
10168
10209
  }
@@ -10171,6 +10212,7 @@
10171
10212
  this._nextIndexStart = geometry.index ? geometryInfo.indexStart + geometryInfo.reservedIndexCount : 0;
10172
10213
  this._nextVertexStart = geometryInfo.vertexStart + geometryInfo.reservedVertexCount;
10173
10214
  }
10215
+ this._visibilityChanged = true;
10174
10216
  return this;
10175
10217
  }
10176
10218
  getBoundingBoxAt( geometryId, target ) {
@@ -10577,7 +10619,7 @@
10577
10619
  }
10578
10620
  geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
10579
10621
  } else {
10580
- console.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10622
+ warn( 'Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10581
10623
  }
10582
10624
  return this;
10583
10625
  }
@@ -10693,7 +10735,7 @@
10693
10735
  }
10694
10736
  geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
10695
10737
  } else {
10696
- console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10738
+ warn( 'LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10697
10739
  }
10698
10740
  return this;
10699
10741
  }
@@ -10850,6 +10892,7 @@
10850
10892
  dispose() {
10851
10893
  if ( this._requestVideoFrameCallbackId !== 0 ) {
10852
10894
  this.source.data.cancelVideoFrameCallback( this._requestVideoFrameCallbackId );
10895
+ this._requestVideoFrameCallbackId = 0;
10853
10896
  }
10854
10897
  super.dispose();
10855
10898
  }
@@ -10942,6 +10985,22 @@
10942
10985
  return data;
10943
10986
  }
10944
10987
  }
10988
+ class CubeDepthTexture extends DepthTexture {
10989
+ constructor( size, type = UnsignedIntType, mapping = CubeReflectionMapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, format = DepthFormat ) {
10990
+ const image = { width: size, height: size, depth: 1 };
10991
+ const images = [ image, image, image, image, image, image ];
10992
+ super( size, size, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format );
10993
+ this.image = images;
10994
+ this.isCubeDepthTexture = true;
10995
+ this.isCubeTexture = true;
10996
+ }
10997
+ get images() {
10998
+ return this.image;
10999
+ }
11000
+ set images( value ) {
11001
+ this.image = value;
11002
+ }
11003
+ }
10945
11004
  class ExternalTexture extends Texture {
10946
11005
  constructor( sourceTexture = null ) {
10947
11006
  super();
@@ -11411,7 +11470,7 @@
11411
11470
  return this;
11412
11471
  }
11413
11472
  static fromJSON( data ) {
11414
- return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.details );
11473
+ return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.detail );
11415
11474
  }
11416
11475
  }
11417
11476
  class DodecahedronGeometry extends PolyhedronGeometry {
@@ -11549,7 +11608,7 @@
11549
11608
  this.cacheArcLengths = null;
11550
11609
  }
11551
11610
  getPoint( ) {
11552
- console.warn( 'THREE.Curve: .getPoint() not implemented.' );
11611
+ warn( 'Curve: .getPoint() not implemented.' );
11553
11612
  }
11554
11613
  getPointAt( u, optionalTarget ) {
11555
11614
  const t = this.getUtoTmapping( u );
@@ -12594,10 +12653,10 @@
12594
12653
  let minX, minY, invSize;
12595
12654
  if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
12596
12655
  if (data.length > 80 * dim) {
12597
- minX = Infinity;
12598
- minY = Infinity;
12599
- let maxX = -Infinity;
12600
- let maxY = -Infinity;
12656
+ minX = data[0];
12657
+ minY = data[1];
12658
+ let maxX = minX;
12659
+ let maxY = minY;
12601
12660
  for (let i = dim; i < outerLen; i += dim) {
12602
12661
  const x = data[i];
12603
12662
  const y = data[i + 1];
@@ -13115,7 +13174,8 @@
13115
13174
  extrudePts = extrudePath.getSpacedPoints( steps );
13116
13175
  extrudeByPath = true;
13117
13176
  bevelEnabled = false;
13118
- splineTube = extrudePath.computeFrenetFrames( steps, false );
13177
+ const isClosed = extrudePath.isCatmullRomCurve3 ? extrudePath.closed : false;
13178
+ splineTube = extrudePath.computeFrenetFrames( steps, isClosed );
13119
13179
  binormal = new Vector3();
13120
13180
  normal = new Vector3();
13121
13181
  position2 = new Vector3();
@@ -13173,7 +13233,7 @@
13173
13233
  vertices = vertices.concat( ahole );
13174
13234
  }
13175
13235
  function scalePt2( pt, vec, size ) {
13176
- if ( ! vec ) console.error( 'THREE.ExtrudeGeometry: vec does not exist' );
13236
+ if ( ! vec ) error( 'ExtrudeGeometry: vec does not exist' );
13177
13237
  return pt.clone().addScaledVector( vec, size );
13178
13238
  }
13179
13239
  const vlen = vertices.length;
@@ -14843,6 +14903,8 @@
14843
14903
  this.displacementScale = 1;
14844
14904
  this.displacementBias = 0;
14845
14905
  this.alphaMap = null;
14906
+ this.wireframe = false;
14907
+ this.wireframeLinewidth = 1;
14846
14908
  this.flatShading = false;
14847
14909
  this.fog = true;
14848
14910
  this.setValues( parameters );
@@ -14862,6 +14924,8 @@
14862
14924
  this.displacementScale = source.displacementScale;
14863
14925
  this.displacementBias = source.displacementBias;
14864
14926
  this.alphaMap = source.alphaMap;
14927
+ this.wireframe = source.wireframe;
14928
+ this.wireframeLinewidth = source.wireframeLinewidth;
14865
14929
  this.flatShading = source.flatShading;
14866
14930
  this.fog = source.fog;
14867
14931
  return this;
@@ -14892,9 +14956,6 @@
14892
14956
  }
14893
14957
  return Array.prototype.slice.call( array );
14894
14958
  }
14895
- function isTypedArray( object ) {
14896
- return ArrayBuffer.isView( object ) && ! ( object instanceof DataView );
14897
- }
14898
14959
  function getKeyframeOrder( times ) {
14899
14960
  function compareTime( i, j ) {
14900
14961
  return times[ i ] - times[ j ];
@@ -15350,7 +15411,7 @@
15350
15411
  throw new Error( message );
15351
15412
  }
15352
15413
  }
15353
- console.warn( 'THREE.KeyframeTrack:', message );
15414
+ warn( 'KeyframeTrack:', message );
15354
15415
  return this;
15355
15416
  }
15356
15417
  this.createInterpolant = factoryMethod;
@@ -15414,26 +15475,26 @@
15414
15475
  let valid = true;
15415
15476
  const valueSize = this.getValueSize();
15416
15477
  if ( valueSize - Math.floor( valueSize ) !== 0 ) {
15417
- console.error( 'THREE.KeyframeTrack: Invalid value size in track.', this );
15478
+ error( 'KeyframeTrack: Invalid value size in track.', this );
15418
15479
  valid = false;
15419
15480
  }
15420
15481
  const times = this.times,
15421
15482
  values = this.values,
15422
15483
  nKeys = times.length;
15423
15484
  if ( nKeys === 0 ) {
15424
- console.error( 'THREE.KeyframeTrack: Track is empty.', this );
15485
+ error( 'KeyframeTrack: Track is empty.', this );
15425
15486
  valid = false;
15426
15487
  }
15427
15488
  let prevTime = null;
15428
15489
  for ( let i = 0; i !== nKeys; i ++ ) {
15429
15490
  const currTime = times[ i ];
15430
15491
  if ( typeof currTime === 'number' && isNaN( currTime ) ) {
15431
- console.error( 'THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime );
15492
+ error( 'KeyframeTrack: Time is not a valid number.', this, i, currTime );
15432
15493
  valid = false;
15433
15494
  break;
15434
15495
  }
15435
15496
  if ( prevTime !== null && prevTime > currTime ) {
15436
- console.error( 'THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime );
15497
+ error( 'KeyframeTrack: Out of order keys.', this, i, currTime, prevTime );
15437
15498
  valid = false;
15438
15499
  break;
15439
15500
  }
@@ -15444,7 +15505,7 @@
15444
15505
  for ( let i = 0, n = values.length; i !== n; ++ i ) {
15445
15506
  const value = values[ i ];
15446
15507
  if ( isNaN( value ) ) {
15447
- console.error( 'THREE.KeyframeTrack: Value is not a valid number.', this, i, value );
15508
+ error( 'KeyframeTrack: Value is not a valid number.', this, i, value );
15448
15509
  valid = false;
15449
15510
  break;
15450
15511
  }
@@ -15687,9 +15748,9 @@
15687
15748
  return clips;
15688
15749
  }
15689
15750
  static parseAnimation( animation, bones ) {
15690
- console.warn( 'THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185' );
15751
+ warn( 'AnimationClip: parseAnimation() is deprecated and will be removed with r185' );
15691
15752
  if ( ! animation ) {
15692
- console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' );
15753
+ error( 'AnimationClip: No animation in JSONLoader data.' );
15693
15754
  return null;
15694
15755
  }
15695
15756
  const addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) {
@@ -15865,7 +15926,7 @@
15865
15926
  this.onLoad = onLoad;
15866
15927
  this.onProgress = onProgress;
15867
15928
  this.onError = onError;
15868
- this.abortController = new AbortController();
15929
+ this._abortController = null;
15869
15930
  this.itemStart = function ( url ) {
15870
15931
  itemsTotal ++;
15871
15932
  if ( isLoading === false ) {
@@ -15926,10 +15987,16 @@
15926
15987
  };
15927
15988
  this.abort = function () {
15928
15989
  this.abortController.abort();
15929
- this.abortController = new AbortController();
15990
+ this._abortController = null;
15930
15991
  return this;
15931
15992
  };
15932
15993
  }
15994
+ get abortController() {
15995
+ if ( ! this._abortController ) {
15996
+ this._abortController = new AbortController();
15997
+ }
15998
+ return this._abortController;
15999
+ }
15933
16000
  }
15934
16001
  const DefaultLoadingManager = new LoadingManager();
15935
16002
  class Loader {
@@ -16026,7 +16093,7 @@
16026
16093
  .then( response => {
16027
16094
  if ( response.status === 200 || response.status === 0 ) {
16028
16095
  if ( response.status === 0 ) {
16029
- console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
16096
+ warn( 'FileLoader: HTTP Status 0 received.' );
16030
16097
  }
16031
16098
  if ( typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined ) {
16032
16099
  return response;
@@ -16149,7 +16216,7 @@
16149
16216
  if ( onError ) {
16150
16217
  onError( e );
16151
16218
  } else {
16152
- console.error( e );
16219
+ error( e );
16153
16220
  }
16154
16221
  scope.manager.itemError( url );
16155
16222
  }
@@ -16346,7 +16413,7 @@
16346
16413
  if ( onError !== undefined ) {
16347
16414
  onError( error );
16348
16415
  } else {
16349
- console.error( error );
16416
+ error( error );
16350
16417
  return;
16351
16418
  }
16352
16419
  }
@@ -16418,6 +16485,7 @@
16418
16485
  this.intensity = intensity;
16419
16486
  }
16420
16487
  dispose() {
16488
+ this.dispatchEvent( { type: 'dispose' } );
16421
16489
  }
16422
16490
  copy( source, recursive ) {
16423
16491
  super.copy( source, recursive );
@@ -16429,13 +16497,6 @@
16429
16497
  const data = super.toJSON( meta );
16430
16498
  data.object.color = this.color.getHex();
16431
16499
  data.object.intensity = this.intensity;
16432
- if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();
16433
- if ( this.distance !== undefined ) data.object.distance = this.distance;
16434
- if ( this.angle !== undefined ) data.object.angle = this.angle;
16435
- if ( this.decay !== undefined ) data.object.decay = this.decay;
16436
- if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
16437
- if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
16438
- if ( this.target !== undefined ) data.object.target = this.target.uuid;
16439
16500
  return data;
16440
16501
  }
16441
16502
  }
@@ -16453,8 +16514,13 @@
16453
16514
  this.groundColor.copy( source.groundColor );
16454
16515
  return this;
16455
16516
  }
16517
+ toJSON( meta ) {
16518
+ const data = super.toJSON( meta );
16519
+ data.object.groundColor = this.groundColor.getHex();
16520
+ return data;
16521
+ }
16456
16522
  }
16457
- const _projScreenMatrix$1 = new Matrix4();
16523
+ const _projScreenMatrix$2 = new Matrix4();
16458
16524
  const _lightPositionWorld$1 = new Vector3();
16459
16525
  const _lookTarget$1 = new Vector3();
16460
16526
  class LightShadow {
@@ -16493,8 +16559,8 @@
16493
16559
  _lookTarget$1.setFromMatrixPosition( light.target.matrixWorld );
16494
16560
  shadowCamera.lookAt( _lookTarget$1 );
16495
16561
  shadowCamera.updateMatrixWorld();
16496
- _projScreenMatrix$1.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
16497
- this._frustum.setFromProjectionMatrix( _projScreenMatrix$1, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
16562
+ _projScreenMatrix$2.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
16563
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix$2, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
16498
16564
  if ( shadowCamera.reversedDepth ) {
16499
16565
  shadowMatrix.set(
16500
16566
  0.5, 0.0, 0.0, 0.5,
@@ -16510,7 +16576,7 @@
16510
16576
  0.0, 0.0, 0.0, 1.0
16511
16577
  );
16512
16578
  }
16513
- shadowMatrix.multiply( _projScreenMatrix$1 );
16579
+ shadowMatrix.multiply( _projScreenMatrix$2 );
16514
16580
  }
16515
16581
  getViewport( viewportIndex ) {
16516
16582
  return this._viewports[ viewportIndex ];
@@ -16601,6 +16667,7 @@
16601
16667
  this.intensity = power / Math.PI;
16602
16668
  }
16603
16669
  dispose() {
16670
+ super.dispose();
16604
16671
  this.shadow.dispose();
16605
16672
  }
16606
16673
  copy( source, recursive ) {
@@ -16610,54 +16677,26 @@
16610
16677
  this.penumbra = source.penumbra;
16611
16678
  this.decay = source.decay;
16612
16679
  this.target = source.target.clone();
16680
+ this.map = source.map;
16613
16681
  this.shadow = source.shadow.clone();
16614
16682
  return this;
16615
16683
  }
16684
+ toJSON( meta ) {
16685
+ const data = super.toJSON( meta );
16686
+ data.object.distance = this.distance;
16687
+ data.object.angle = this.angle;
16688
+ data.object.decay = this.decay;
16689
+ data.object.penumbra = this.penumbra;
16690
+ data.object.target = this.target.uuid;
16691
+ if ( this.map && this.map.isTexture ) data.object.map = this.map.toJSON( meta ).uuid;
16692
+ data.object.shadow = this.shadow.toJSON();
16693
+ return data;
16694
+ }
16616
16695
  }
16617
- const _projScreenMatrix = new Matrix4();
16618
- const _lightPositionWorld = new Vector3();
16619
- const _lookTarget = new Vector3();
16620
16696
  class PointLightShadow extends LightShadow {
16621
16697
  constructor() {
16622
16698
  super( new PerspectiveCamera( 90, 1, 0.5, 500 ) );
16623
16699
  this.isPointLightShadow = true;
16624
- this._frameExtents = new Vector2( 4, 2 );
16625
- this._viewportCount = 6;
16626
- this._viewports = [
16627
- new Vector4( 2, 1, 1, 1 ),
16628
- new Vector4( 0, 1, 1, 1 ),
16629
- new Vector4( 3, 1, 1, 1 ),
16630
- new Vector4( 1, 1, 1, 1 ),
16631
- new Vector4( 3, 0, 1, 1 ),
16632
- new Vector4( 1, 0, 1, 1 )
16633
- ];
16634
- this._cubeDirections = [
16635
- new Vector3( 1, 0, 0 ), new Vector3( -1, 0, 0 ), new Vector3( 0, 0, 1 ),
16636
- new Vector3( 0, 0, -1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, -1, 0 )
16637
- ];
16638
- this._cubeUps = [
16639
- new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ),
16640
- new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, -1 )
16641
- ];
16642
- }
16643
- updateMatrices( light, viewportIndex = 0 ) {
16644
- const camera = this.camera;
16645
- const shadowMatrix = this.matrix;
16646
- const far = light.distance || camera.far;
16647
- if ( far !== camera.far ) {
16648
- camera.far = far;
16649
- camera.updateProjectionMatrix();
16650
- }
16651
- _lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
16652
- camera.position.copy( _lightPositionWorld );
16653
- _lookTarget.copy( camera.position );
16654
- _lookTarget.add( this._cubeDirections[ viewportIndex ] );
16655
- camera.up.copy( this._cubeUps[ viewportIndex ] );
16656
- camera.lookAt( _lookTarget );
16657
- camera.updateMatrixWorld();
16658
- shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
16659
- _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
16660
- this._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
16661
16700
  }
16662
16701
  }
16663
16702
  class PointLight extends Light {
@@ -16676,6 +16715,7 @@
16676
16715
  this.intensity = power / ( 4 * Math.PI );
16677
16716
  }
16678
16717
  dispose() {
16718
+ super.dispose();
16679
16719
  this.shadow.dispose();
16680
16720
  }
16681
16721
  copy( source, recursive ) {
@@ -16685,6 +16725,13 @@
16685
16725
  this.shadow = source.shadow.clone();
16686
16726
  return this;
16687
16727
  }
16728
+ toJSON( meta ) {
16729
+ const data = super.toJSON( meta );
16730
+ data.object.distance = this.distance;
16731
+ data.object.decay = this.decay;
16732
+ data.object.shadow = this.shadow.toJSON();
16733
+ return data;
16734
+ }
16688
16735
  }
16689
16736
  class OrthographicCamera extends Camera {
16690
16737
  constructor( left = -1, right = 1, top = 1, bottom = -1, near = 0.1, far = 2000 ) {
@@ -16790,6 +16837,7 @@
16790
16837
  this.shadow = new DirectionalLightShadow();
16791
16838
  }
16792
16839
  dispose() {
16840
+ super.dispose();
16793
16841
  this.shadow.dispose();
16794
16842
  }
16795
16843
  copy( source ) {
@@ -16798,6 +16846,12 @@
16798
16846
  this.shadow = source.shadow.clone();
16799
16847
  return this;
16800
16848
  }
16849
+ toJSON( meta ) {
16850
+ const data = super.toJSON( meta );
16851
+ data.object.shadow = this.shadow.toJSON();
16852
+ data.object.target = this.target.uuid;
16853
+ return data;
16854
+ }
16801
16855
  }
16802
16856
  class AmbientLight extends Light {
16803
16857
  constructor( color, intensity ) {
@@ -16957,11 +17011,6 @@
16957
17011
  this.sh.copy( source.sh );
16958
17012
  return this;
16959
17013
  }
16960
- fromJSON( json ) {
16961
- this.intensity = json.intensity;
16962
- this.sh.fromArray( json.sh );
16963
- return this;
16964
- }
16965
17014
  toJSON( meta ) {
16966
17015
  const data = super.toJSON( meta );
16967
17016
  data.object.sh = this.sh.toArray();
@@ -16986,7 +17035,7 @@
16986
17035
  if ( onError ) {
16987
17036
  onError( e );
16988
17037
  } else {
16989
- console.error( e );
17038
+ error( e );
16990
17039
  }
16991
17040
  scope.manager.itemError( url );
16992
17041
  }
@@ -16996,7 +17045,7 @@
16996
17045
  const textures = this.textures;
16997
17046
  function getTexture( name ) {
16998
17047
  if ( textures[ name ] === undefined ) {
16999
- console.warn( 'THREE.MaterialLoader: Undefined texture', name );
17048
+ warn( 'MaterialLoader: Undefined texture', name );
17000
17049
  }
17001
17050
  return textures[ name ];
17002
17051
  }
@@ -17072,6 +17121,7 @@
17072
17121
  if ( json.alphaToCoverage !== undefined ) material.alphaToCoverage = json.alphaToCoverage;
17073
17122
  if ( json.premultipliedAlpha !== undefined ) material.premultipliedAlpha = json.premultipliedAlpha;
17074
17123
  if ( json.forceSinglePass !== undefined ) material.forceSinglePass = json.forceSinglePass;
17124
+ if ( json.allowOverride !== undefined ) material.allowOverride = json.allowOverride;
17075
17125
  if ( json.visible !== undefined ) material.visible = json.visible;
17076
17126
  if ( json.toneMapped !== undefined ) material.toneMapped = json.toneMapped;
17077
17127
  if ( json.userData !== undefined ) material.userData = json.userData;
@@ -17257,7 +17307,7 @@
17257
17307
  if ( onError ) {
17258
17308
  onError( e );
17259
17309
  } else {
17260
- console.error( e );
17310
+ error( e );
17261
17311
  }
17262
17312
  scope.manager.itemError( url );
17263
17313
  }
@@ -17366,13 +17416,13 @@
17366
17416
  json = JSON.parse( text );
17367
17417
  } catch ( error ) {
17368
17418
  if ( onError !== undefined ) onError( error );
17369
- console.error( 'THREE:ObjectLoader: Can\'t parse ' + url + '.', error.message );
17419
+ error( 'ObjectLoader: Can\'t parse ' + url + '.', error.message );
17370
17420
  return;
17371
17421
  }
17372
17422
  const metadata = json.metadata;
17373
17423
  if ( metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry' ) {
17374
17424
  if ( onError !== undefined ) onError( new Error( 'THREE.ObjectLoader: Can\'t load ' + url ) );
17375
- console.error( 'THREE.ObjectLoader: Can\'t load ' + url );
17425
+ error( 'ObjectLoader: Can\'t load ' + url );
17376
17426
  return;
17377
17427
  }
17378
17428
  scope.parse( json, onLoad );
@@ -17472,7 +17522,7 @@
17472
17522
  if ( data.type in Geometries ) {
17473
17523
  geometry = Geometries[ data.type ].fromJSON( data, shapes );
17474
17524
  } else {
17475
- console.warn( `THREE.ObjectLoader: Unsupported geometry type "${ data.type }"` );
17525
+ warn( `ObjectLoader: Unsupported geometry type "${ data.type }"` );
17476
17526
  }
17477
17527
  }
17478
17528
  geometry.uuid = data.uuid;
@@ -17621,7 +17671,7 @@
17621
17671
  parseTextures( json, images ) {
17622
17672
  function parseConstant( value, type ) {
17623
17673
  if ( typeof value === 'number' ) return value;
17624
- console.warn( 'THREE.ObjectLoader.parseTexture: Constant should be in numeric form.', value );
17674
+ warn( 'ObjectLoader.parseTexture: Constant should be in numeric form.', value );
17625
17675
  return type[ value ];
17626
17676
  }
17627
17677
  const textures = {};
@@ -17629,10 +17679,10 @@
17629
17679
  for ( let i = 0, l = json.length; i < l; i ++ ) {
17630
17680
  const data = json[ i ];
17631
17681
  if ( data.image === undefined ) {
17632
- console.warn( 'THREE.ObjectLoader: No "image" specified for', data.uuid );
17682
+ warn( 'ObjectLoader: No "image" specified for', data.uuid );
17633
17683
  }
17634
17684
  if ( images[ data.image ] === undefined ) {
17635
- console.warn( 'THREE.ObjectLoader: Undefined image', data.image );
17685
+ warn( 'ObjectLoader: Undefined image', data.image );
17636
17686
  }
17637
17687
  const source = images[ data.image ];
17638
17688
  const image = source.data;
@@ -17683,7 +17733,7 @@
17683
17733
  let object;
17684
17734
  function getGeometry( name ) {
17685
17735
  if ( geometries[ name ] === undefined ) {
17686
- console.warn( 'THREE.ObjectLoader: Undefined geometry', name );
17736
+ warn( 'ObjectLoader: Undefined geometry', name );
17687
17737
  }
17688
17738
  return geometries[ name ];
17689
17739
  }
@@ -17694,20 +17744,20 @@
17694
17744
  for ( let i = 0, l = name.length; i < l; i ++ ) {
17695
17745
  const uuid = name[ i ];
17696
17746
  if ( materials[ uuid ] === undefined ) {
17697
- console.warn( 'THREE.ObjectLoader: Undefined material', uuid );
17747
+ warn( 'ObjectLoader: Undefined material', uuid );
17698
17748
  }
17699
17749
  array.push( materials[ uuid ] );
17700
17750
  }
17701
17751
  return array;
17702
17752
  }
17703
17753
  if ( materials[ name ] === undefined ) {
17704
- console.warn( 'THREE.ObjectLoader: Undefined material', name );
17754
+ warn( 'ObjectLoader: Undefined material', name );
17705
17755
  }
17706
17756
  return materials[ name ];
17707
17757
  }
17708
17758
  function getTexture( uuid ) {
17709
17759
  if ( textures[ uuid ] === undefined ) {
17710
- console.warn( 'THREE.ObjectLoader: Undefined texture', uuid );
17760
+ warn( 'ObjectLoader: Undefined texture', uuid );
17711
17761
  }
17712
17762
  return textures[ uuid ];
17713
17763
  }
@@ -17775,7 +17825,8 @@
17775
17825
  object = new HemisphereLight( data.color, data.groundColor, data.intensity );
17776
17826
  break;
17777
17827
  case 'LightProbe':
17778
- object = new LightProbe().fromJSON( data );
17828
+ const sh = new SphericalHarmonics3().fromArray( data.sh );
17829
+ object = new LightProbe( sh, data.intensity );
17779
17830
  break;
17780
17831
  case 'SkinnedMesh':
17781
17832
  geometry = getGeometry( data.geometry );
@@ -17934,7 +17985,7 @@
17934
17985
  if ( child.isSkinnedMesh === true && child.skeleton !== undefined ) {
17935
17986
  const skeleton = skeletons[ child.skeleton ];
17936
17987
  if ( skeleton === undefined ) {
17937
- console.warn( 'THREE.ObjectLoader: No skeleton found with UUID:', child.skeleton );
17988
+ warn( 'ObjectLoader: No skeleton found with UUID:', child.skeleton );
17938
17989
  } else {
17939
17990
  child.bind( skeleton, child.bindMatrix );
17940
17991
  }
@@ -17982,10 +18033,10 @@
17982
18033
  super( manager );
17983
18034
  this.isImageBitmapLoader = true;
17984
18035
  if ( typeof createImageBitmap === 'undefined' ) {
17985
- console.warn( 'THREE.ImageBitmapLoader: createImageBitmap() not supported.' );
18036
+ warn( 'ImageBitmapLoader: createImageBitmap() not supported.' );
17986
18037
  }
17987
18038
  if ( typeof fetch === 'undefined' ) {
17988
- console.warn( 'THREE.ImageBitmapLoader: fetch() not supported.' );
18039
+ warn( 'ImageBitmapLoader: fetch() not supported.' );
17989
18040
  }
17990
18041
  this.options = { premultiplyAlpha: 'none' };
17991
18042
  this._abortController = new AbortController();
@@ -18089,7 +18140,7 @@
18089
18140
  if ( onError ) {
18090
18141
  onError( e );
18091
18142
  } else {
18092
- console.error( e );
18143
+ error( e );
18093
18144
  }
18094
18145
  scope.manager.itemError( url );
18095
18146
  }
@@ -18332,11 +18383,11 @@
18332
18383
  }
18333
18384
  play( delay = 0 ) {
18334
18385
  if ( this.isPlaying === true ) {
18335
- console.warn( 'THREE.Audio: Audio is already playing.' );
18386
+ warn( 'Audio: Audio is already playing.' );
18336
18387
  return;
18337
18388
  }
18338
18389
  if ( this.hasPlaybackControl === false ) {
18339
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18390
+ warn( 'Audio: this Audio has no playback control.' );
18340
18391
  return;
18341
18392
  }
18342
18393
  this._startedAt = this.context.currentTime + delay;
@@ -18355,7 +18406,7 @@
18355
18406
  }
18356
18407
  pause() {
18357
18408
  if ( this.hasPlaybackControl === false ) {
18358
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18409
+ warn( 'Audio: this Audio has no playback control.' );
18359
18410
  return;
18360
18411
  }
18361
18412
  if ( this.isPlaying === true ) {
@@ -18371,7 +18422,7 @@
18371
18422
  }
18372
18423
  stop( delay = 0 ) {
18373
18424
  if ( this.hasPlaybackControl === false ) {
18374
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18425
+ warn( 'Audio: this Audio has no playback control.' );
18375
18426
  return;
18376
18427
  }
18377
18428
  this._progress = 0;
@@ -18443,7 +18494,7 @@
18443
18494
  }
18444
18495
  setPlaybackRate( value ) {
18445
18496
  if ( this.hasPlaybackControl === false ) {
18446
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18497
+ warn( 'Audio: this Audio has no playback control.' );
18447
18498
  return;
18448
18499
  }
18449
18500
  this.playbackRate = value;
@@ -18461,14 +18512,14 @@
18461
18512
  }
18462
18513
  getLoop() {
18463
18514
  if ( this.hasPlaybackControl === false ) {
18464
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18515
+ warn( 'Audio: this Audio has no playback control.' );
18465
18516
  return false;
18466
18517
  }
18467
18518
  return this.loop;
18468
18519
  }
18469
18520
  setLoop( value ) {
18470
18521
  if ( this.hasPlaybackControl === false ) {
18471
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18522
+ warn( 'Audio: this Audio has no playback control.' );
18472
18523
  return;
18473
18524
  }
18474
18525
  this.loop = value;
@@ -18495,7 +18546,7 @@
18495
18546
  copy( source, recursive ) {
18496
18547
  super.copy( source, recursive );
18497
18548
  if ( source.sourceType !== 'buffer' ) {
18498
- console.warn( 'THREE.Audio: Audio source type cannot be copied.' );
18549
+ warn( 'Audio: Audio source type cannot be copied.' );
18499
18550
  return this;
18500
18551
  }
18501
18552
  this.autoplay = source.autoplay;
@@ -18979,7 +19030,7 @@
18979
19030
  this.getValue = this._getValue_unavailable;
18980
19031
  this.setValue = this._setValue_unavailable;
18981
19032
  if ( ! targetObject ) {
18982
- console.warn( 'THREE.PropertyBinding: No target node found for track: ' + this.path + '.' );
19033
+ warn( 'PropertyBinding: No target node found for track: ' + this.path + '.' );
18983
19034
  return;
18984
19035
  }
18985
19036
  if ( objectName ) {
@@ -18987,18 +19038,18 @@
18987
19038
  switch ( objectName ) {
18988
19039
  case 'materials':
18989
19040
  if ( ! targetObject.material ) {
18990
- console.error( 'THREE.PropertyBinding: Can not bind to material as node does not have a material.', this );
19041
+ error( 'PropertyBinding: Can not bind to material as node does not have a material.', this );
18991
19042
  return;
18992
19043
  }
18993
19044
  if ( ! targetObject.material.materials ) {
18994
- console.error( 'THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this );
19045
+ error( 'PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this );
18995
19046
  return;
18996
19047
  }
18997
19048
  targetObject = targetObject.material.materials;
18998
19049
  break;
18999
19050
  case 'bones':
19000
19051
  if ( ! targetObject.skeleton ) {
19001
- console.error( 'THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this );
19052
+ error( 'PropertyBinding: Can not bind to bones as node does not have a skeleton.', this );
19002
19053
  return;
19003
19054
  }
19004
19055
  targetObject = targetObject.skeleton.bones;
@@ -19015,25 +19066,25 @@
19015
19066
  break;
19016
19067
  }
19017
19068
  if ( ! targetObject.material ) {
19018
- console.error( 'THREE.PropertyBinding: Can not bind to material as node does not have a material.', this );
19069
+ error( 'PropertyBinding: Can not bind to material as node does not have a material.', this );
19019
19070
  return;
19020
19071
  }
19021
19072
  if ( ! targetObject.material.map ) {
19022
- console.error( 'THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.', this );
19073
+ error( 'PropertyBinding: Can not bind to material.map as node.material does not have a map.', this );
19023
19074
  return;
19024
19075
  }
19025
19076
  targetObject = targetObject.material.map;
19026
19077
  break;
19027
19078
  default:
19028
19079
  if ( targetObject[ objectName ] === undefined ) {
19029
- console.error( 'THREE.PropertyBinding: Can not bind to objectName of node undefined.', this );
19080
+ error( 'PropertyBinding: Can not bind to objectName of node undefined.', this );
19030
19081
  return;
19031
19082
  }
19032
19083
  targetObject = targetObject[ objectName ];
19033
19084
  }
19034
19085
  if ( objectIndex !== undefined ) {
19035
19086
  if ( targetObject[ objectIndex ] === undefined ) {
19036
- console.error( 'THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject );
19087
+ error( 'PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject );
19037
19088
  return;
19038
19089
  }
19039
19090
  targetObject = targetObject[ objectIndex ];
@@ -19042,7 +19093,7 @@
19042
19093
  const nodeProperty = targetObject[ propertyName ];
19043
19094
  if ( nodeProperty === undefined ) {
19044
19095
  const nodeName = parsedPath.nodeName;
19045
- console.error( 'THREE.PropertyBinding: Trying to update property for track: ' + nodeName +
19096
+ error( 'PropertyBinding: Trying to update property for track: ' + nodeName +
19046
19097
  '.' + propertyName + ' but it wasn\'t found.', targetObject );
19047
19098
  return;
19048
19099
  }
@@ -19057,11 +19108,11 @@
19057
19108
  if ( propertyIndex !== undefined ) {
19058
19109
  if ( propertyName === 'morphTargetInfluences' ) {
19059
19110
  if ( ! targetObject.geometry ) {
19060
- console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this );
19111
+ error( 'PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this );
19061
19112
  return;
19062
19113
  }
19063
19114
  if ( ! targetObject.geometry.morphAttributes ) {
19064
- console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this );
19115
+ error( 'PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this );
19065
19116
  return;
19066
19117
  }
19067
19118
  if ( targetObject.morphTargetDictionary[ propertyIndex ] !== undefined ) {
@@ -19196,7 +19247,7 @@
19196
19247
  bindingsForPath[ firstActiveIndex ] = binding;
19197
19248
  }
19198
19249
  } else if ( objects[ index ] !== knownObject ) {
19199
- console.error( 'THREE.AnimationObjectGroup: Different objects with the same UUID ' +
19250
+ error( 'AnimationObjectGroup: Different objects with the same UUID ' +
19200
19251
  'detected. Clean the caches or recreate your infrastructure when reloading scenes.' );
19201
19252
  }
19202
19253
  }
@@ -20225,7 +20276,7 @@
20225
20276
  this.ray.direction.set( 0, 0, -1 ).transformDirection( camera.matrixWorld );
20226
20277
  this.camera = camera;
20227
20278
  } else {
20228
- console.error( 'THREE.Raycaster: Unsupported camera type: ' + camera.type );
20279
+ error( 'Raycaster: Unsupported camera type: ' + camera.type );
20229
20280
  }
20230
20281
  }
20231
20282
  setFromXRController( controller ) {
@@ -21495,7 +21546,7 @@
21495
21546
  }
21496
21547
  connect( element ) {
21497
21548
  if ( element === undefined ) {
21498
- console.warn( 'THREE.Controls: connect() now requires an element.' );
21549
+ warn( 'Controls: connect() now requires an element.' );
21499
21550
  return;
21500
21551
  }
21501
21552
  if ( this.domElement !== null ) this.disconnect();
@@ -21575,8 +21626,12 @@
21575
21626
  return ( Math.max( width, 8 ) * Math.max( height, 8 ) ) / 2;
21576
21627
  case RGB_ETC1_Format:
21577
21628
  case RGB_ETC2_Format:
21629
+ case R11_EAC_Format:
21630
+ case SIGNED_R11_EAC_Format:
21578
21631
  return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
21579
21632
  case RGBA_ETC2_EAC_Format:
21633
+ case RG11_EAC_Format:
21634
+ case SIGNED_RG11_EAC_Format:
21580
21635
  return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
21581
21636
  case RGBA_ASTC_4x4_Format:
21582
21637
  return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
@@ -21664,7 +21719,7 @@
21664
21719
  }
21665
21720
  if ( typeof window !== 'undefined' ) {
21666
21721
  if ( window.__THREE__ ) {
21667
- console.warn( 'WARNING: Multiple instances of Three.js being imported.' );
21722
+ warn( 'WARNING: Multiple instances of Three.js being imported.' );
21668
21723
  } else {
21669
21724
  window.__THREE__ = REVISION;
21670
21725
  }
@@ -21845,7 +21900,7 @@
21845
21900
  var color_pars_fragment = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif";
21846
21901
  var color_pars_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif";
21847
21902
  var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif";
21848
- var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
21903
+ var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
21849
21904
  var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
21850
21905
  var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
21851
21906
  var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif";
@@ -21855,7 +21910,7 @@
21855
21910
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
21856
21911
  var colorspace_pars_fragment = "vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
21857
21912
  var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
21858
- var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
21913
+ var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n#endif";
21859
21914
  var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
21860
21915
  var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif";
21861
21916
  var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif";
@@ -21868,14 +21923,14 @@
21868
21923
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
21869
21924
  var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert";
21870
21925
  var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
21871
- var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
21926
+ var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
21872
21927
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
21873
21928
  var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon";
21874
21929
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
21875
21930
  var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong";
21876
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
21877
- var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
21878
- var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
21931
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
21932
+ var lights_physical_pars_fragment = "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn v;\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColorBlended;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
21933
+ var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
21879
21934
  var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif";
21880
21935
  var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
21881
21936
  var logdepthbuf_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
@@ -21911,10 +21966,10 @@
21911
21966
  var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif";
21912
21967
  var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif";
21913
21968
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
21914
- var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow( sampler2D shadow, vec2 uv, float compare ) {\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare, distribution.x );\n\t\t#endif\n\t\tif ( hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif";
21969
+ var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadow = step( depth, dp );\n\t\t\t#else\n\t\t\t\tshadow = step( dp, depth );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\n#endif";
21915
21970
  var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
21916
21971
  var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif";
21917
- var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}";
21972
+ var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}";
21918
21973
  var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
21919
21974
  var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif";
21920
21975
  var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";
@@ -21923,7 +21978,7 @@
21923
21978
  var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";
21924
21979
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
21925
21980
  var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
21926
- var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
21981
+ var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
21927
21982
  var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif";
21928
21983
  var uv_pars_fragment = "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif";
21929
21984
  var uv_pars_vertex = "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif";
@@ -21938,7 +21993,7 @@
21938
21993
  const vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}";
21939
21994
  const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}";
21940
21995
  const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
21941
- const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}";
21996
+ const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}";
21942
21997
  const vertex$c = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}";
21943
21998
  const fragment$c = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
21944
21999
  const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
@@ -21946,21 +22001,21 @@
21946
22001
  const vertex$a = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}";
21947
22002
  const fragment$a = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
21948
22003
  const vertex$9 = "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
21949
- const fragment$9 = "#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
22004
+ const fragment$9 = "#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
21950
22005
  const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}";
21951
22006
  const fragment$8 = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
21952
22007
  const vertex$7 = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}";
21953
- const fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}";
22008
+ const fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}";
21954
22009
  const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
21955
- const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
22010
+ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
21956
22011
  const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}";
21957
- const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
22012
+ const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n \t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
21958
22013
  const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
21959
- const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
22014
+ const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
21960
22015
  const vertex$3 = "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}";
21961
22016
  const fragment$3 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}";
21962
22017
  const vertex$2 = "#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
21963
- const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
22018
+ const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
21964
22019
  const vertex$1 = "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
21965
22020
  const fragment$1 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
21966
22021
  const ShaderChunk = {
@@ -22079,8 +22134,8 @@
22079
22134
  cube_frag: fragment$f,
22080
22135
  depth_vert: vertex$e,
22081
22136
  depth_frag: fragment$e,
22082
- distanceRGBA_vert: vertex$d,
22083
- distanceRGBA_frag: fragment$d,
22137
+ distance_vert: vertex$d,
22138
+ distance_frag: fragment$d,
22084
22139
  equirect_vert: vertex$c,
22085
22140
  equirect_frag: fragment$c,
22086
22141
  linedashed_vert: vertex$b,
@@ -22127,6 +22182,7 @@
22127
22182
  reflectivity: { value: 1.0 },
22128
22183
  ior: { value: 1.5 },
22129
22184
  refractionRatio: { value: 0.98 },
22185
+ dfgLUT: { value: null }
22130
22186
  },
22131
22187
  aomap: {
22132
22188
  aoMap: { value: null },
@@ -22462,7 +22518,7 @@
22462
22518
  vertexShader: ShaderChunk.equirect_vert,
22463
22519
  fragmentShader: ShaderChunk.equirect_frag
22464
22520
  },
22465
- distanceRGBA: {
22521
+ distance: {
22466
22522
  uniforms: mergeUniforms( [
22467
22523
  UniformsLib.common,
22468
22524
  UniformsLib.displacementmap,
@@ -22472,8 +22528,8 @@
22472
22528
  farDistance: { value: 1000 }
22473
22529
  }
22474
22530
  ] ),
22475
- vertexShader: ShaderChunk.distanceRGBA_vert,
22476
- fragmentShader: ShaderChunk.distanceRGBA_frag
22531
+ vertexShader: ShaderChunk.distance_vert,
22532
+ fragmentShader: ShaderChunk.distance_frag
22477
22533
  },
22478
22534
  shadow: {
22479
22535
  uniforms: mergeUniforms( [
@@ -23132,7 +23188,7 @@
23132
23188
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
23133
23189
  const maxPrecision = getMaxPrecision( precision );
23134
23190
  if ( maxPrecision !== precision ) {
23135
- console.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );
23191
+ warn( 'WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );
23136
23192
  precision = maxPrecision;
23137
23193
  }
23138
23194
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
@@ -23145,8 +23201,8 @@
23145
23201
  const maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );
23146
23202
  const maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );
23147
23203
  const maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );
23148
- const vertexTextures = maxVertexTextures > 0;
23149
23204
  const maxSamples = gl.getParameter( gl.MAX_SAMPLES );
23205
+ const samples = gl.getParameter( gl.SAMPLES );
23150
23206
  return {
23151
23207
  isWebGL2: true,
23152
23208
  getMaxAnisotropy: getMaxAnisotropy,
@@ -23164,8 +23220,8 @@
23164
23220
  maxVertexUniforms: maxVertexUniforms,
23165
23221
  maxVaryings: maxVaryings,
23166
23222
  maxFragmentUniforms: maxFragmentUniforms,
23167
- vertexTextures: vertexTextures,
23168
- maxSamples: maxSamples
23223
+ maxSamples: maxSamples,
23224
+ samples: samples
23169
23225
  };
23170
23226
  }
23171
23227
  function WebGLClipping( properties ) {
@@ -23312,25 +23368,13 @@
23312
23368
  const LOD_MIN = 4;
23313
23369
  const EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ];
23314
23370
  const MAX_SAMPLES = 20;
23371
+ const GGX_SAMPLES = 256;
23315
23372
  const _flatCamera = new OrthographicCamera();
23316
23373
  const _clearColor = new Color();
23317
23374
  let _oldTarget = null;
23318
23375
  let _oldActiveCubeFace = 0;
23319
23376
  let _oldActiveMipmapLevel = 0;
23320
23377
  let _oldXrEnabled = false;
23321
- const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
23322
- const INV_PHI = 1 / PHI;
23323
- const _axisDirections = [
23324
- new Vector3( - PHI, INV_PHI, 0 ),
23325
- new Vector3( PHI, INV_PHI, 0 ),
23326
- new Vector3( - INV_PHI, 0, PHI ),
23327
- new Vector3( INV_PHI, 0, PHI ),
23328
- new Vector3( 0, PHI, - INV_PHI ),
23329
- new Vector3( 0, PHI, INV_PHI ),
23330
- new Vector3( -1, 1, -1 ),
23331
- new Vector3( 1, 1, -1 ),
23332
- new Vector3( -1, 1, 1 ),
23333
- new Vector3( 1, 1, 1 ) ];
23334
23378
  const _origin = new Vector3();
23335
23379
  class PMREMGenerator {
23336
23380
  constructor( renderer ) {
@@ -23338,13 +23382,14 @@
23338
23382
  this._pingPongRenderTarget = null;
23339
23383
  this._lodMax = 0;
23340
23384
  this._cubeSize = 0;
23341
- this._lodPlanes = [];
23342
23385
  this._sizeLods = [];
23343
23386
  this._sigmas = [];
23344
- this._blurMaterial = null;
23387
+ this._lodMeshes = [];
23388
+ this._backgroundBox = null;
23345
23389
  this._cubemapMaterial = null;
23346
23390
  this._equirectMaterial = null;
23347
- this._compileMaterial( this._blurMaterial );
23391
+ this._blurMaterial = null;
23392
+ this._ggxMaterial = null;
23348
23393
  }
23349
23394
  fromScene( scene, sigma = 0, near = 0.1, far = 100, options = {} ) {
23350
23395
  const {
@@ -23389,6 +23434,10 @@
23389
23434
  this._dispose();
23390
23435
  if ( this._cubemapMaterial !== null ) this._cubemapMaterial.dispose();
23391
23436
  if ( this._equirectMaterial !== null ) this._equirectMaterial.dispose();
23437
+ if ( this._backgroundBox !== null ) {
23438
+ this._backgroundBox.geometry.dispose();
23439
+ this._backgroundBox.material.dispose();
23440
+ }
23392
23441
  }
23393
23442
  _setSize( cubeSize ) {
23394
23443
  this._lodMax = Math.floor( Math.log2( cubeSize ) );
@@ -23396,9 +23445,10 @@
23396
23445
  }
23397
23446
  _dispose() {
23398
23447
  if ( this._blurMaterial !== null ) this._blurMaterial.dispose();
23448
+ if ( this._ggxMaterial !== null ) this._ggxMaterial.dispose();
23399
23449
  if ( this._pingPongRenderTarget !== null ) this._pingPongRenderTarget.dispose();
23400
- for ( let i = 0; i < this._lodPlanes.length; i ++ ) {
23401
- this._lodPlanes[ i ].dispose();
23450
+ for ( let i = 0; i < this._lodMeshes.length; i ++ ) {
23451
+ this._lodMeshes[ i ].geometry.dispose();
23402
23452
  }
23403
23453
  }
23404
23454
  _cleanup( outputTarget ) {
@@ -23443,14 +23493,15 @@
23443
23493
  }
23444
23494
  this._pingPongRenderTarget = _createRenderTarget( width, height, params );
23445
23495
  const { _lodMax } = this;
23446
- ( { sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = _createPlanes( _lodMax ) );
23496
+ ( { lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas } = _createPlanes( _lodMax ) );
23447
23497
  this._blurMaterial = _getBlurShader( _lodMax, width, height );
23498
+ this._ggxMaterial = _getGGXShader( _lodMax, width, height );
23448
23499
  }
23449
23500
  return cubeUVRenderTarget;
23450
23501
  }
23451
23502
  _compileMaterial( material ) {
23452
- const tmpMesh = new Mesh( this._lodPlanes[ 0 ], material );
23453
- this._renderer.compile( tmpMesh, _flatCamera );
23503
+ const mesh = new Mesh( new BufferGeometry(), material );
23504
+ this._renderer.compile( mesh, _flatCamera );
23454
23505
  }
23455
23506
  _sceneToCubeUV( scene, near, far, cubeUVRenderTarget, position ) {
23456
23507
  const fov = 90;
@@ -23470,13 +23521,19 @@
23470
23521
  renderer.clearDepth();
23471
23522
  renderer.setRenderTarget( null );
23472
23523
  }
23473
- const backgroundMaterial = new MeshBasicMaterial( {
23474
- name: 'PMREM.Background',
23475
- side: BackSide,
23476
- depthWrite: false,
23477
- depthTest: false,
23478
- } );
23479
- const backgroundBox = new Mesh( new BoxGeometry(), backgroundMaterial );
23524
+ if ( this._backgroundBox === null ) {
23525
+ this._backgroundBox = new Mesh(
23526
+ new BoxGeometry(),
23527
+ new MeshBasicMaterial( {
23528
+ name: 'PMREM.Background',
23529
+ side: BackSide,
23530
+ depthWrite: false,
23531
+ depthTest: false,
23532
+ } )
23533
+ );
23534
+ }
23535
+ const backgroundBox = this._backgroundBox;
23536
+ const backgroundMaterial = backgroundBox.material;
23480
23537
  let useSolidColor = false;
23481
23538
  const background = scene.background;
23482
23539
  if ( background ) {
@@ -23512,8 +23569,6 @@
23512
23569
  }
23513
23570
  renderer.render( scene, cubeCamera );
23514
23571
  }
23515
- backgroundBox.geometry.dispose();
23516
- backgroundBox.material.dispose();
23517
23572
  renderer.toneMapping = toneMapping;
23518
23573
  renderer.autoClear = originalAutoClear;
23519
23574
  scene.background = background;
@@ -23532,7 +23587,8 @@
23532
23587
  }
23533
23588
  }
23534
23589
  const material = isCubeTexture ? this._cubemapMaterial : this._equirectMaterial;
23535
- const mesh = new Mesh( this._lodPlanes[ 0 ], material );
23590
+ const mesh = this._lodMeshes[ 0 ];
23591
+ mesh.material = material;
23536
23592
  const uniforms = material.uniforms;
23537
23593
  uniforms[ 'envMap' ].value = texture;
23538
23594
  const size = this._cubeSize;
@@ -23544,14 +23600,41 @@
23544
23600
  const renderer = this._renderer;
23545
23601
  const autoClear = renderer.autoClear;
23546
23602
  renderer.autoClear = false;
23547
- const n = this._lodPlanes.length;
23603
+ const n = this._lodMeshes.length;
23548
23604
  for ( let i = 1; i < n; i ++ ) {
23549
- const sigma = Math.sqrt( this._sigmas[ i ] * this._sigmas[ i ] - this._sigmas[ i - 1 ] * this._sigmas[ i - 1 ] );
23550
- const poleAxis = _axisDirections[ ( n - i - 1 ) % _axisDirections.length ];
23551
- this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis );
23605
+ this._applyGGXFilter( cubeUVRenderTarget, i - 1, i );
23552
23606
  }
23553
23607
  renderer.autoClear = autoClear;
23554
23608
  }
23609
+ _applyGGXFilter( cubeUVRenderTarget, lodIn, lodOut ) {
23610
+ const renderer = this._renderer;
23611
+ const pingPongRenderTarget = this._pingPongRenderTarget;
23612
+ const ggxMaterial = this._ggxMaterial;
23613
+ const ggxMesh = this._lodMeshes[ lodOut ];
23614
+ ggxMesh.material = ggxMaterial;
23615
+ const ggxUniforms = ggxMaterial.uniforms;
23616
+ const targetRoughness = lodOut / ( this._lodMeshes.length - 1 );
23617
+ const sourceRoughness = lodIn / ( this._lodMeshes.length - 1 );
23618
+ const incrementalRoughness = Math.sqrt( targetRoughness * targetRoughness - sourceRoughness * sourceRoughness );
23619
+ const blurStrength = 0.0 + targetRoughness * 1.25;
23620
+ const adjustedRoughness = incrementalRoughness * blurStrength;
23621
+ const { _lodMax } = this;
23622
+ const outputSize = this._sizeLods[ lodOut ];
23623
+ const x = 3 * outputSize * ( lodOut > _lodMax - LOD_MIN ? lodOut - _lodMax + LOD_MIN : 0 );
23624
+ const y = 4 * ( this._cubeSize - outputSize );
23625
+ ggxUniforms[ 'envMap' ].value = cubeUVRenderTarget.texture;
23626
+ ggxUniforms[ 'roughness' ].value = adjustedRoughness;
23627
+ ggxUniforms[ 'mipInt' ].value = _lodMax - lodIn;
23628
+ _setViewport( pingPongRenderTarget, x, y, 3 * outputSize, 2 * outputSize );
23629
+ renderer.setRenderTarget( pingPongRenderTarget );
23630
+ renderer.render( ggxMesh, _flatCamera );
23631
+ ggxUniforms[ 'envMap' ].value = pingPongRenderTarget.texture;
23632
+ ggxUniforms[ 'roughness' ].value = 0.0;
23633
+ ggxUniforms[ 'mipInt' ].value = _lodMax - lodOut;
23634
+ _setViewport( cubeUVRenderTarget, x, y, 3 * outputSize, 2 * outputSize );
23635
+ renderer.setRenderTarget( cubeUVRenderTarget );
23636
+ renderer.render( ggxMesh, _flatCamera );
23637
+ }
23555
23638
  _blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) {
23556
23639
  const pingPongRenderTarget = this._pingPongRenderTarget;
23557
23640
  this._halfBlur(
@@ -23575,18 +23658,19 @@
23575
23658
  const renderer = this._renderer;
23576
23659
  const blurMaterial = this._blurMaterial;
23577
23660
  if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) {
23578
- console.error(
23661
+ error(
23579
23662
  'blur direction must be either latitudinal or longitudinal!' );
23580
23663
  }
23581
23664
  const STANDARD_DEVIATIONS = 3;
23582
- const blurMesh = new Mesh( this._lodPlanes[ lodOut ], blurMaterial );
23665
+ const blurMesh = this._lodMeshes[ lodOut ];
23666
+ blurMesh.material = blurMaterial;
23583
23667
  const blurUniforms = blurMaterial.uniforms;
23584
23668
  const pixels = this._sizeLods[ lodIn ] - 1;
23585
23669
  const radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 );
23586
23670
  const sigmaPixels = sigmaRadians / radiansPerPixel;
23587
23671
  const samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES;
23588
23672
  if ( samples > MAX_SAMPLES ) {
23589
- console.warn( `sigmaRadians, ${
23673
+ warn( `sigmaRadians, ${
23590
23674
  sigmaRadians}, is too large and will clip, as it requested ${
23591
23675
  samples} samples when the maximum is set to ${MAX_SAMPLES}` );
23592
23676
  }
@@ -23624,9 +23708,9 @@
23624
23708
  }
23625
23709
  }
23626
23710
  function _createPlanes( lodMax ) {
23627
- const lodPlanes = [];
23628
23711
  const sizeLods = [];
23629
23712
  const sigmas = [];
23713
+ const lodMeshes = [];
23630
23714
  let lod = lodMax;
23631
23715
  const totalLods = lodMax - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
23632
23716
  for ( let i = 0; i < totalLods; i ++ ) {
@@ -23671,12 +23755,12 @@
23671
23755
  planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) );
23672
23756
  planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) );
23673
23757
  planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) );
23674
- lodPlanes.push( planes );
23758
+ lodMeshes.push( new Mesh( planes, null ) );
23675
23759
  if ( lod > LOD_MIN ) {
23676
23760
  lod --;
23677
23761
  }
23678
23762
  }
23679
- return { lodPlanes, sizeLods, sigmas };
23763
+ return { lodMeshes, sizeLods, sigmas };
23680
23764
  }
23681
23765
  function _createRenderTarget( width, height, params ) {
23682
23766
  const cubeUVRenderTarget = new WebGLRenderTarget( width, height, params );
@@ -23689,6 +23773,136 @@
23689
23773
  target.viewport.set( x, y, width, height );
23690
23774
  target.scissor.set( x, y, width, height );
23691
23775
  }
23776
+ function _getGGXShader( lodMax, width, height ) {
23777
+ const shaderMaterial = new ShaderMaterial( {
23778
+ name: 'PMREMGGXConvolution',
23779
+ defines: {
23780
+ 'GGX_SAMPLES': GGX_SAMPLES,
23781
+ 'CUBEUV_TEXEL_WIDTH': 1.0 / width,
23782
+ 'CUBEUV_TEXEL_HEIGHT': 1.0 / height,
23783
+ 'CUBEUV_MAX_MIP': `${lodMax}.0`,
23784
+ },
23785
+ uniforms: {
23786
+ 'envMap': { value: null },
23787
+ 'roughness': { value: 0.0 },
23788
+ 'mipInt': { value: 0 }
23789
+ },
23790
+ vertexShader: _getCommonVertexShader(),
23791
+ fragmentShader: `
23792
+
23793
+ precision highp float;
23794
+ precision highp int;
23795
+
23796
+ varying vec3 vOutputDirection;
23797
+
23798
+ uniform sampler2D envMap;
23799
+ uniform float roughness;
23800
+ uniform float mipInt;
23801
+
23802
+ #define ENVMAP_TYPE_CUBE_UV
23803
+ #include <cube_uv_reflection_fragment>
23804
+
23805
+ #define PI 3.14159265359
23806
+
23807
+ // Van der Corput radical inverse
23808
+ float radicalInverse_VdC(uint bits) {
23809
+ bits = (bits << 16u) | (bits >> 16u);
23810
+ bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
23811
+ bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
23812
+ bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
23813
+ bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
23814
+ return float(bits) * 2.3283064365386963e-10; // / 0x100000000
23815
+ }
23816
+
23817
+ // Hammersley sequence
23818
+ vec2 hammersley(uint i, uint N) {
23819
+ return vec2(float(i) / float(N), radicalInverse_VdC(i));
23820
+ }
23821
+
23822
+ // GGX VNDF importance sampling (Eric Heitz 2018)
23823
+ // "Sampling the GGX Distribution of Visible Normals"
23824
+ // https://jcgt.org/published/0007/04/01/
23825
+ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
23826
+ float alpha = roughness * roughness;
23827
+
23828
+ // Section 3.2: Transform view direction to hemisphere configuration
23829
+ vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
23830
+
23831
+ // Section 4.1: Orthonormal basis
23832
+ float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
23833
+ vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
23834
+ vec3 T2 = cross(Vh, T1);
23835
+
23836
+ // Section 4.2: Parameterization of projected area
23837
+ float r = sqrt(Xi.x);
23838
+ float phi = 2.0 * PI * Xi.y;
23839
+ float t1 = r * cos(phi);
23840
+ float t2 = r * sin(phi);
23841
+ float s = 0.5 * (1.0 + Vh.z);
23842
+ t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
23843
+
23844
+ // Section 4.3: Reprojection onto hemisphere
23845
+ vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
23846
+
23847
+ // Section 3.4: Transform back to ellipsoid configuration
23848
+ return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
23849
+ }
23850
+
23851
+ void main() {
23852
+ vec3 N = normalize(vOutputDirection);
23853
+ vec3 V = N; // Assume view direction equals normal for pre-filtering
23854
+
23855
+ vec3 prefilteredColor = vec3(0.0);
23856
+ float totalWeight = 0.0;
23857
+
23858
+ // For very low roughness, just sample the environment directly
23859
+ if (roughness < 0.001) {
23860
+ gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
23861
+ return;
23862
+ }
23863
+
23864
+ // Tangent space basis for VNDF sampling
23865
+ vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
23866
+ vec3 tangent = normalize(cross(up, N));
23867
+ vec3 bitangent = cross(N, tangent);
23868
+
23869
+ for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
23870
+ vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
23871
+
23872
+ // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
23873
+ vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
23874
+
23875
+ // Transform H back to world space
23876
+ vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
23877
+ vec3 L = normalize(2.0 * dot(V, H) * H - V);
23878
+
23879
+ float NdotL = max(dot(N, L), 0.0);
23880
+
23881
+ if(NdotL > 0.0) {
23882
+ // Sample environment at fixed mip level
23883
+ // VNDF importance sampling handles the distribution filtering
23884
+ vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
23885
+
23886
+ // Weight by NdotL for the split-sum approximation
23887
+ // VNDF PDF naturally accounts for the visible microfacet distribution
23888
+ prefilteredColor += sampleColor * NdotL;
23889
+ totalWeight += NdotL;
23890
+ }
23891
+ }
23892
+
23893
+ if (totalWeight > 0.0) {
23894
+ prefilteredColor = prefilteredColor / totalWeight;
23895
+ }
23896
+
23897
+ gl_FragColor = vec4(prefilteredColor, 1.0);
23898
+ }
23899
+ `,
23900
+ blending: NoBlending,
23901
+ depthTest: false,
23902
+ depthWrite: false
23903
+ } );
23904
+ return shaderMaterial;
23905
+ }
23692
23906
  function _getBlurShader( lodMax, width, height ) {
23693
23907
  const weights = new Float32Array( MAX_SAMPLES );
23694
23908
  const poleAxis = new Vector3( 0, 1, 0 );
@@ -23970,23 +24184,7 @@
23970
24184
  if ( extensions[ name ] !== undefined ) {
23971
24185
  return extensions[ name ];
23972
24186
  }
23973
- let extension;
23974
- switch ( name ) {
23975
- case 'WEBGL_depth_texture':
23976
- extension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' );
23977
- break;
23978
- case 'EXT_texture_filter_anisotropic':
23979
- extension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' );
23980
- break;
23981
- case 'WEBGL_compressed_texture_s3tc':
23982
- extension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' );
23983
- break;
23984
- case 'WEBGL_compressed_texture_pvrtc':
23985
- extension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
23986
- break;
23987
- default:
23988
- extension = gl.getExtension( name );
23989
- }
24187
+ const extension = gl.getExtension( name );
23990
24188
  extensions[ name ] = extension;
23991
24189
  return extension;
23992
24190
  }
@@ -24005,7 +24203,7 @@
24005
24203
  get: function ( name ) {
24006
24204
  const extension = getExtension( name );
24007
24205
  if ( extension === null ) {
24008
- warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
24206
+ warnOnce( 'WebGLRenderer: ' + name + ' extension not supported.' );
24009
24207
  }
24010
24208
  return extension;
24011
24209
  }
@@ -24183,7 +24381,7 @@
24183
24381
  render.points += instanceCount * count;
24184
24382
  break;
24185
24383
  default:
24186
- console.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );
24384
+ error( 'WebGLInfo: Unknown draw mode:', mode );
24187
24385
  break;
24188
24386
  }
24189
24387
  }
@@ -24339,6 +24537,172 @@
24339
24537
  dispose: dispose
24340
24538
  };
24341
24539
  }
24540
+ const toneMappingMap = {
24541
+ [ LinearToneMapping ]: 'LINEAR_TONE_MAPPING',
24542
+ [ ReinhardToneMapping ]: 'REINHARD_TONE_MAPPING',
24543
+ [ CineonToneMapping ]: 'CINEON_TONE_MAPPING',
24544
+ [ ACESFilmicToneMapping ]: 'ACES_FILMIC_TONE_MAPPING',
24545
+ [ AgXToneMapping ]: 'AGX_TONE_MAPPING',
24546
+ [ NeutralToneMapping ]: 'NEUTRAL_TONE_MAPPING',
24547
+ [ CustomToneMapping ]: 'CUSTOM_TONE_MAPPING'
24548
+ };
24549
+ function WebGLOutput( type, width, height, depth, stencil ) {
24550
+ const targetA = new WebGLRenderTarget( width, height, {
24551
+ type: type,
24552
+ depthBuffer: depth,
24553
+ stencilBuffer: stencil
24554
+ } );
24555
+ const targetB = new WebGLRenderTarget( width, height, {
24556
+ type: HalfFloatType,
24557
+ depthBuffer: false,
24558
+ stencilBuffer: false
24559
+ } );
24560
+ const geometry = new BufferGeometry();
24561
+ geometry.setAttribute( 'position', new Float32BufferAttribute( [ -1, 3, 0, -1, -1, 0, 3, -1, 0 ], 3 ) );
24562
+ geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
24563
+ const material = new RawShaderMaterial( {
24564
+ uniforms: {
24565
+ tDiffuse: { value: null }
24566
+ },
24567
+ vertexShader: `
24568
+ precision highp float;
24569
+
24570
+ uniform mat4 modelViewMatrix;
24571
+ uniform mat4 projectionMatrix;
24572
+
24573
+ attribute vec3 position;
24574
+ attribute vec2 uv;
24575
+
24576
+ varying vec2 vUv;
24577
+
24578
+ void main() {
24579
+ vUv = uv;
24580
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
24581
+ }`,
24582
+ fragmentShader: `
24583
+ precision highp float;
24584
+
24585
+ uniform sampler2D tDiffuse;
24586
+
24587
+ varying vec2 vUv;
24588
+
24589
+ #include <tonemapping_pars_fragment>
24590
+ #include <colorspace_pars_fragment>
24591
+
24592
+ void main() {
24593
+ gl_FragColor = texture2D( tDiffuse, vUv );
24594
+
24595
+ #ifdef LINEAR_TONE_MAPPING
24596
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
24597
+ #elif defined( REINHARD_TONE_MAPPING )
24598
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
24599
+ #elif defined( CINEON_TONE_MAPPING )
24600
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
24601
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
24602
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
24603
+ #elif defined( AGX_TONE_MAPPING )
24604
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
24605
+ #elif defined( NEUTRAL_TONE_MAPPING )
24606
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
24607
+ #elif defined( CUSTOM_TONE_MAPPING )
24608
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
24609
+ #endif
24610
+
24611
+ #ifdef SRGB_TRANSFER
24612
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
24613
+ #endif
24614
+ }`,
24615
+ depthTest: false,
24616
+ depthWrite: false
24617
+ } );
24618
+ const mesh = new Mesh( geometry, material );
24619
+ const camera = new OrthographicCamera( -1, 1, 1, -1, 0, 1 );
24620
+ let _outputColorSpace = null;
24621
+ let _outputToneMapping = null;
24622
+ let _isCompositing = false;
24623
+ let _savedToneMapping;
24624
+ let _savedRenderTarget = null;
24625
+ let _effects = [];
24626
+ let _hasRenderPass = false;
24627
+ this.setSize = function ( width, height ) {
24628
+ targetA.setSize( width, height );
24629
+ targetB.setSize( width, height );
24630
+ for ( let i = 0; i < _effects.length; i ++ ) {
24631
+ const effect = _effects[ i ];
24632
+ if ( effect.setSize ) effect.setSize( width, height );
24633
+ }
24634
+ };
24635
+ this.setEffects = function ( effects ) {
24636
+ _effects = effects;
24637
+ _hasRenderPass = _effects.length > 0 && _effects[ 0 ].isRenderPass === true;
24638
+ const width = targetA.width;
24639
+ const height = targetA.height;
24640
+ for ( let i = 0; i < _effects.length; i ++ ) {
24641
+ const effect = _effects[ i ];
24642
+ if ( effect.setSize ) effect.setSize( width, height );
24643
+ }
24644
+ };
24645
+ this.begin = function ( renderer, renderTarget ) {
24646
+ if ( _isCompositing ) return false;
24647
+ if ( renderer.toneMapping === NoToneMapping && _effects.length === 0 ) return false;
24648
+ _savedRenderTarget = renderTarget;
24649
+ if ( renderTarget !== null ) {
24650
+ const width = renderTarget.width;
24651
+ const height = renderTarget.height;
24652
+ if ( targetA.width !== width || targetA.height !== height ) {
24653
+ this.setSize( width, height );
24654
+ }
24655
+ }
24656
+ if ( _hasRenderPass === false ) {
24657
+ renderer.setRenderTarget( targetA );
24658
+ }
24659
+ _savedToneMapping = renderer.toneMapping;
24660
+ renderer.toneMapping = NoToneMapping;
24661
+ return true;
24662
+ };
24663
+ this.hasRenderPass = function () {
24664
+ return _hasRenderPass;
24665
+ };
24666
+ this.end = function ( renderer, deltaTime ) {
24667
+ renderer.toneMapping = _savedToneMapping;
24668
+ _isCompositing = true;
24669
+ let readBuffer = targetA;
24670
+ let writeBuffer = targetB;
24671
+ for ( let i = 0; i < _effects.length; i ++ ) {
24672
+ const effect = _effects[ i ];
24673
+ if ( effect.enabled === false ) continue;
24674
+ effect.render( renderer, writeBuffer, readBuffer, deltaTime );
24675
+ if ( effect.needsSwap !== false ) {
24676
+ const temp = readBuffer;
24677
+ readBuffer = writeBuffer;
24678
+ writeBuffer = temp;
24679
+ }
24680
+ }
24681
+ if ( _outputColorSpace !== renderer.outputColorSpace || _outputToneMapping !== renderer.toneMapping ) {
24682
+ _outputColorSpace = renderer.outputColorSpace;
24683
+ _outputToneMapping = renderer.toneMapping;
24684
+ material.defines = {};
24685
+ if ( ColorManagement.getTransfer( _outputColorSpace ) === SRGBTransfer ) material.defines.SRGB_TRANSFER = '';
24686
+ const toneMapping = toneMappingMap[ _outputToneMapping ];
24687
+ if ( toneMapping ) material.defines[ toneMapping ] = '';
24688
+ material.needsUpdate = true;
24689
+ }
24690
+ material.uniforms.tDiffuse.value = readBuffer.texture;
24691
+ renderer.setRenderTarget( _savedRenderTarget );
24692
+ renderer.render( mesh, camera );
24693
+ _savedRenderTarget = null;
24694
+ _isCompositing = false;
24695
+ };
24696
+ this.isCompositing = function () {
24697
+ return _isCompositing;
24698
+ };
24699
+ this.dispose = function () {
24700
+ targetA.dispose();
24701
+ targetB.dispose();
24702
+ geometry.dispose();
24703
+ material.dispose();
24704
+ };
24705
+ }
24342
24706
  const emptyTexture = new Texture();
24343
24707
  const emptyShadowTexture = new DepthTexture( 1, 1 );
24344
24708
  const emptyArrayTexture = new DataArrayTexture();
@@ -24601,7 +24965,7 @@
24601
24965
  }
24602
24966
  let emptyTexture2D;
24603
24967
  if ( this.type === gl.SAMPLER_2D_SHADOW ) {
24604
- emptyShadowTexture.compareFunction = LessEqualCompare;
24968
+ emptyShadowTexture.compareFunction = textures.isReversedDepthBuffer() ? GreaterEqualCompare : LessEqualCompare;
24605
24969
  emptyTexture2D = emptyShadowTexture;
24606
24970
  } else {
24607
24971
  emptyTexture2D = emptyTexture;
@@ -24733,8 +25097,14 @@
24733
25097
  gl.uniform1iv( this.addr, units );
24734
25098
  copyArray( cache, units );
24735
25099
  }
25100
+ let emptyTexture2D;
25101
+ if ( this.type === gl.SAMPLER_2D_SHADOW ) {
25102
+ emptyTexture2D = emptyShadowTexture;
25103
+ } else {
25104
+ emptyTexture2D = emptyTexture;
25105
+ }
24736
25106
  for ( let i = 0; i !== n; ++ i ) {
24737
- textures.setTexture2D( v[ i ] || emptyTexture, units[ i ] );
25107
+ textures.setTexture2D( v[ i ] || emptyTexture2D, units[ i ] );
24738
25108
  }
24739
25109
  }
24740
25110
  function setValueT3DArray( gl, v, textures ) {
@@ -24887,6 +25257,18 @@
24887
25257
  addr = gl.getUniformLocation( program, info.name );
24888
25258
  parseUniform( info, addr, this );
24889
25259
  }
25260
+ const shadowSamplers = [];
25261
+ const otherUniforms = [];
25262
+ for ( const u of this.seq ) {
25263
+ if ( u.type === gl.SAMPLER_2D_SHADOW || u.type === gl.SAMPLER_CUBE_SHADOW || u.type === gl.SAMPLER_2D_ARRAY_SHADOW ) {
25264
+ shadowSamplers.push( u );
25265
+ } else {
25266
+ otherUniforms.push( u );
25267
+ }
25268
+ }
25269
+ if ( shadowSamplers.length > 0 ) {
25270
+ this.seq = shadowSamplers.concat( otherUniforms );
25271
+ }
24890
25272
  }
24891
25273
  setValue( gl, name, value, textures ) {
24892
25274
  const u = this.map[ name ];
@@ -24943,7 +25325,7 @@
24943
25325
  case SRGBTransfer:
24944
25326
  return [ encodingMatrix, 'sRGBTransferOETF' ];
24945
25327
  default:
24946
- console.warn( 'THREE.WebGLProgram: Unsupported color space: ', colorSpace );
25328
+ warn( 'WebGLProgram: Unsupported color space: ', colorSpace );
24947
25329
  return [ encodingMatrix, 'LinearTransferOETF' ];
24948
25330
  }
24949
25331
  }
@@ -24968,33 +25350,20 @@
24968
25350
  '}',
24969
25351
  ].join( '\n' );
24970
25352
  }
25353
+ const toneMappingFunctions = {
25354
+ [ LinearToneMapping ]: 'Linear',
25355
+ [ ReinhardToneMapping ]: 'Reinhard',
25356
+ [ CineonToneMapping ]: 'Cineon',
25357
+ [ ACESFilmicToneMapping ]: 'ACESFilmic',
25358
+ [ AgXToneMapping ]: 'AgX',
25359
+ [ NeutralToneMapping ]: 'Neutral',
25360
+ [ CustomToneMapping ]: 'Custom'
25361
+ };
24971
25362
  function getToneMappingFunction( functionName, toneMapping ) {
24972
- let toneMappingName;
24973
- switch ( toneMapping ) {
24974
- case LinearToneMapping:
24975
- toneMappingName = 'Linear';
24976
- break;
24977
- case ReinhardToneMapping:
24978
- toneMappingName = 'Reinhard';
24979
- break;
24980
- case CineonToneMapping:
24981
- toneMappingName = 'Cineon';
24982
- break;
24983
- case ACESFilmicToneMapping:
24984
- toneMappingName = 'ACESFilmic';
24985
- break;
24986
- case AgXToneMapping:
24987
- toneMappingName = 'AgX';
24988
- break;
24989
- case NeutralToneMapping:
24990
- toneMappingName = 'Neutral';
24991
- break;
24992
- case CustomToneMapping:
24993
- toneMappingName = 'Custom';
24994
- break;
24995
- default:
24996
- console.warn( 'THREE.WebGLProgram: Unsupported toneMapping:', toneMapping );
24997
- toneMappingName = 'Linear';
25363
+ const toneMappingName = toneMappingFunctions[ toneMapping ];
25364
+ if ( toneMappingName === undefined ) {
25365
+ warn( 'WebGLProgram: Unsupported toneMapping:', toneMapping );
25366
+ return 'vec3 ' + functionName + '( vec3 color ) { return LinearToneMapping( color ); }';
24998
25367
  }
24999
25368
  return 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';
25000
25369
  }
@@ -25079,7 +25448,7 @@
25079
25448
  const newInclude = shaderChunkMap.get( include );
25080
25449
  if ( newInclude !== undefined ) {
25081
25450
  string = ShaderChunk[ newInclude ];
25082
- console.warn( 'THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', include, newInclude );
25451
+ warn( 'WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', include, newInclude );
25083
25452
  } else {
25084
25453
  throw new Error( 'Can not resolve #include <' + include + '>' );
25085
25454
  }
@@ -25127,59 +25496,37 @@
25127
25496
  }
25128
25497
  return precisionstring;
25129
25498
  }
25499
+ const shadowMapTypeDefines = {
25500
+ [ PCFShadowMap ]: 'SHADOWMAP_TYPE_PCF',
25501
+ [ VSMShadowMap ]: 'SHADOWMAP_TYPE_VSM'
25502
+ };
25130
25503
  function generateShadowMapTypeDefine( parameters ) {
25131
- let shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';
25132
- if ( parameters.shadowMapType === PCFShadowMap ) {
25133
- shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';
25134
- } else if ( parameters.shadowMapType === PCFSoftShadowMap ) {
25135
- shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';
25136
- } else if ( parameters.shadowMapType === VSMShadowMap ) {
25137
- shadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM';
25138
- }
25139
- return shadowMapTypeDefine;
25504
+ return shadowMapTypeDefines[ parameters.shadowMapType ] || 'SHADOWMAP_TYPE_BASIC';
25140
25505
  }
25506
+ const envMapTypeDefines = {
25507
+ [ CubeReflectionMapping ]: 'ENVMAP_TYPE_CUBE',
25508
+ [ CubeRefractionMapping ]: 'ENVMAP_TYPE_CUBE',
25509
+ [ CubeUVReflectionMapping ]: 'ENVMAP_TYPE_CUBE_UV'
25510
+ };
25141
25511
  function generateEnvMapTypeDefine( parameters ) {
25142
- let envMapTypeDefine = 'ENVMAP_TYPE_CUBE';
25143
- if ( parameters.envMap ) {
25144
- switch ( parameters.envMapMode ) {
25145
- case CubeReflectionMapping:
25146
- case CubeRefractionMapping:
25147
- envMapTypeDefine = 'ENVMAP_TYPE_CUBE';
25148
- break;
25149
- case CubeUVReflectionMapping:
25150
- envMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';
25151
- break;
25152
- }
25153
- }
25154
- return envMapTypeDefine;
25512
+ if ( parameters.envMap === false ) return 'ENVMAP_TYPE_CUBE';
25513
+ return envMapTypeDefines[ parameters.envMapMode ] || 'ENVMAP_TYPE_CUBE';
25155
25514
  }
25515
+ const envMapModeDefines = {
25516
+ [ CubeRefractionMapping ]: 'ENVMAP_MODE_REFRACTION'
25517
+ };
25156
25518
  function generateEnvMapModeDefine( parameters ) {
25157
- let envMapModeDefine = 'ENVMAP_MODE_REFLECTION';
25158
- if ( parameters.envMap ) {
25159
- switch ( parameters.envMapMode ) {
25160
- case CubeRefractionMapping:
25161
- envMapModeDefine = 'ENVMAP_MODE_REFRACTION';
25162
- break;
25163
- }
25164
- }
25165
- return envMapModeDefine;
25519
+ if ( parameters.envMap === false ) return 'ENVMAP_MODE_REFLECTION';
25520
+ return envMapModeDefines[ parameters.envMapMode ] || 'ENVMAP_MODE_REFLECTION';
25166
25521
  }
25522
+ const envMapBlendingDefines = {
25523
+ [ MultiplyOperation ]: 'ENVMAP_BLENDING_MULTIPLY',
25524
+ [ MixOperation ]: 'ENVMAP_BLENDING_MIX',
25525
+ [ AddOperation ]: 'ENVMAP_BLENDING_ADD'
25526
+ };
25167
25527
  function generateEnvMapBlendingDefine( parameters ) {
25168
- let envMapBlendingDefine = 'ENVMAP_BLENDING_NONE';
25169
- if ( parameters.envMap ) {
25170
- switch ( parameters.combine ) {
25171
- case MultiplyOperation:
25172
- envMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';
25173
- break;
25174
- case MixOperation:
25175
- envMapBlendingDefine = 'ENVMAP_BLENDING_MIX';
25176
- break;
25177
- case AddOperation:
25178
- envMapBlendingDefine = 'ENVMAP_BLENDING_ADD';
25179
- break;
25180
- }
25181
- }
25182
- return envMapBlendingDefine;
25528
+ if ( parameters.envMap === false ) return 'ENVMAP_BLENDING_NONE';
25529
+ return envMapBlendingDefines[ parameters.combine ] || 'ENVMAP_BLENDING_NONE';
25183
25530
  }
25184
25531
  function generateCubeUVSize( parameters ) {
25185
25532
  const imageHeight = parameters.envMapCubeUVHeight;
@@ -25495,7 +25842,7 @@
25495
25842
  } else {
25496
25843
  const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );
25497
25844
  const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
25498
- console.error(
25845
+ error(
25499
25846
  'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
25500
25847
  'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
25501
25848
  'Material Name: ' + self.name + '\n' +
@@ -25506,7 +25853,7 @@
25506
25853
  );
25507
25854
  }
25508
25855
  } else if ( programLog !== '' ) {
25509
- console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog );
25856
+ warn( 'WebGLProgram: Program Info Log:', programLog );
25510
25857
  } else if ( vertexLog === '' || fragmentLog === '' ) {
25511
25858
  haveDiagnostics = false;
25512
25859
  }
@@ -25638,12 +25985,12 @@
25638
25985
  const _customShaders = new WebGLShaderCache();
25639
25986
  const _activeChannels = new Set();
25640
25987
  const programs = [];
25988
+ const programsMap = new Map();
25641
25989
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
25642
- const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
25643
25990
  let precision = capabilities.precision;
25644
25991
  const shaderIDs = {
25645
25992
  MeshDepthMaterial: 'depth',
25646
- MeshDistanceMaterial: 'distanceRGBA',
25993
+ MeshDistanceMaterial: 'distance',
25647
25994
  MeshNormalMaterial: 'normal',
25648
25995
  MeshBasicMaterial: 'basic',
25649
25996
  MeshLambertMaterial: 'lambert',
@@ -25673,7 +26020,7 @@
25673
26020
  if ( material.precision !== null ) {
25674
26021
  precision = capabilities.getMaxPrecision( material.precision );
25675
26022
  if ( precision !== material.precision ) {
25676
- console.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );
26023
+ warn( 'WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );
25677
26024
  }
25678
26025
  }
25679
26026
  const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
@@ -25757,7 +26104,6 @@
25757
26104
  instancing: IS_INSTANCEDMESH,
25758
26105
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
25759
26106
  instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
25760
- supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
25761
26107
  outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
25762
26108
  alphaToCoverage: !! material.alphaToCoverage,
25763
26109
  map: HAS_MAP,
@@ -25769,7 +26115,7 @@
25769
26115
  lightMap: HAS_LIGHTMAP,
25770
26116
  bumpMap: HAS_BUMPMAP,
25771
26117
  normalMap: HAS_NORMALMAP,
25772
- displacementMap: SUPPORTS_VERTEX_TEXTURES && HAS_DISPLACEMENTMAP,
26118
+ displacementMap: HAS_DISPLACEMENTMAP,
25773
26119
  emissiveMap: HAS_EMISSIVEMAP,
25774
26120
  normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
25775
26121
  normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
@@ -25950,52 +26296,50 @@
25950
26296
  }
25951
26297
  function getProgramCacheKeyBooleans( array, parameters ) {
25952
26298
  _programLayers.disableAll();
25953
- if ( parameters.supportsVertexTextures )
25954
- _programLayers.enable( 0 );
25955
26299
  if ( parameters.instancing )
25956
- _programLayers.enable( 1 );
26300
+ _programLayers.enable( 0 );
25957
26301
  if ( parameters.instancingColor )
25958
- _programLayers.enable( 2 );
26302
+ _programLayers.enable( 1 );
25959
26303
  if ( parameters.instancingMorph )
25960
- _programLayers.enable( 3 );
26304
+ _programLayers.enable( 2 );
25961
26305
  if ( parameters.matcap )
25962
- _programLayers.enable( 4 );
26306
+ _programLayers.enable( 3 );
25963
26307
  if ( parameters.envMap )
25964
- _programLayers.enable( 5 );
26308
+ _programLayers.enable( 4 );
25965
26309
  if ( parameters.normalMapObjectSpace )
25966
- _programLayers.enable( 6 );
26310
+ _programLayers.enable( 5 );
25967
26311
  if ( parameters.normalMapTangentSpace )
25968
- _programLayers.enable( 7 );
26312
+ _programLayers.enable( 6 );
25969
26313
  if ( parameters.clearcoat )
25970
- _programLayers.enable( 8 );
26314
+ _programLayers.enable( 7 );
25971
26315
  if ( parameters.iridescence )
25972
- _programLayers.enable( 9 );
26316
+ _programLayers.enable( 8 );
25973
26317
  if ( parameters.alphaTest )
25974
- _programLayers.enable( 10 );
26318
+ _programLayers.enable( 9 );
25975
26319
  if ( parameters.vertexColors )
25976
- _programLayers.enable( 11 );
26320
+ _programLayers.enable( 10 );
25977
26321
  if ( parameters.vertexAlphas )
25978
- _programLayers.enable( 12 );
26322
+ _programLayers.enable( 11 );
25979
26323
  if ( parameters.vertexUv1s )
25980
- _programLayers.enable( 13 );
26324
+ _programLayers.enable( 12 );
25981
26325
  if ( parameters.vertexUv2s )
25982
- _programLayers.enable( 14 );
26326
+ _programLayers.enable( 13 );
25983
26327
  if ( parameters.vertexUv3s )
25984
- _programLayers.enable( 15 );
26328
+ _programLayers.enable( 14 );
25985
26329
  if ( parameters.vertexTangents )
25986
- _programLayers.enable( 16 );
26330
+ _programLayers.enable( 15 );
25987
26331
  if ( parameters.anisotropy )
25988
- _programLayers.enable( 17 );
26332
+ _programLayers.enable( 16 );
25989
26333
  if ( parameters.alphaHash )
25990
- _programLayers.enable( 18 );
26334
+ _programLayers.enable( 17 );
25991
26335
  if ( parameters.batching )
25992
- _programLayers.enable( 19 );
26336
+ _programLayers.enable( 18 );
25993
26337
  if ( parameters.dispersion )
25994
- _programLayers.enable( 20 );
26338
+ _programLayers.enable( 19 );
25995
26339
  if ( parameters.batchingColor )
25996
- _programLayers.enable( 21 );
26340
+ _programLayers.enable( 20 );
25997
26341
  if ( parameters.gradientMap )
25998
- _programLayers.enable( 22 );
26342
+ _programLayers.enable( 21 );
25999
26343
  array.push( _programLayers.mask );
26000
26344
  _programLayers.disableAll();
26001
26345
  if ( parameters.fog )
@@ -26056,18 +26400,13 @@
26056
26400
  return uniforms;
26057
26401
  }
26058
26402
  function acquireProgram( parameters, cacheKey ) {
26059
- let program;
26060
- for ( let p = 0, pl = programs.length; p < pl; p ++ ) {
26061
- const preexistingProgram = programs[ p ];
26062
- if ( preexistingProgram.cacheKey === cacheKey ) {
26063
- program = preexistingProgram;
26064
- ++ program.usedTimes;
26065
- break;
26066
- }
26067
- }
26068
- if ( program === undefined ) {
26403
+ let program = programsMap.get( cacheKey );
26404
+ if ( program !== undefined ) {
26405
+ ++ program.usedTimes;
26406
+ } else {
26069
26407
  program = new WebGLProgram( renderer, cacheKey, parameters, bindingStates );
26070
26408
  programs.push( program );
26409
+ programsMap.set( cacheKey, program );
26071
26410
  }
26072
26411
  return program;
26073
26412
  }
@@ -26076,6 +26415,7 @@
26076
26415
  const i = programs.indexOf( program );
26077
26416
  programs[ i ] = programs[ programs.length - 1 ];
26078
26417
  programs.pop();
26418
+ programsMap.delete( program.cacheKey );
26079
26419
  program.destroy();
26080
26420
  }
26081
26421
  }
@@ -26428,7 +26768,14 @@
26428
26768
  const color = light.color;
26429
26769
  const intensity = light.intensity;
26430
26770
  const distance = light.distance;
26431
- const shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null;
26771
+ let shadowMap = null;
26772
+ if ( light.shadow && light.shadow.map ) {
26773
+ if ( light.shadow.map.texture.format === RGFormat ) {
26774
+ shadowMap = light.shadow.map.texture;
26775
+ } else {
26776
+ shadowMap = light.shadow.map.depthTexture || light.shadow.map.texture;
26777
+ }
26778
+ }
26432
26779
  if ( light.isAmbientLight ) {
26433
26780
  r += color.r * intensity;
26434
26781
  g += color.g * intensity;
@@ -26696,13 +27043,24 @@
26696
27043
  };
26697
27044
  }
26698
27045
  const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
26699
- const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
27046
+ const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}";
27047
+ const _cubeDirections = [
27048
+ new Vector3( 1, 0, 0 ), new Vector3( -1, 0, 0 ), new Vector3( 0, 1, 0 ),
27049
+ new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, -1 )
27050
+ ];
27051
+ const _cubeUps = [
27052
+ new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ),
27053
+ new Vector3( 0, 0, -1 ), new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 )
27054
+ ];
27055
+ const _projScreenMatrix = new Matrix4();
27056
+ const _lightPositionWorld = new Vector3();
27057
+ const _lookTarget = new Vector3();
26700
27058
  function WebGLShadowMap( renderer, objects, capabilities ) {
26701
27059
  let _frustum = new Frustum();
26702
27060
  const _shadowMapSize = new Vector2(),
26703
27061
  _viewportSize = new Vector2(),
26704
27062
  _viewport = new Vector4(),
26705
- _depthMaterial = new MeshDepthMaterial( { depthPacking: RGBADepthPacking } ),
27063
+ _depthMaterial = new MeshDepthMaterial(),
26706
27064
  _distanceMaterial = new MeshDistanceMaterial(),
26707
27065
  _materialCache = {},
26708
27066
  _maxTextureSize = capabilities.maxTextureSize;
@@ -26740,6 +27098,10 @@
26740
27098
  if ( scope.enabled === false ) return;
26741
27099
  if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;
26742
27100
  if ( lights.length === 0 ) return;
27101
+ if ( lights.type === PCFSoftShadowMap ) {
27102
+ warn( 'WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.' );
27103
+ lights.type = PCFShadowMap;
27104
+ }
26743
27105
  const currentRenderTarget = renderer.getRenderTarget();
26744
27106
  const activeCubeFace = renderer.getActiveCubeFace();
26745
27107
  const activeMipmapLevel = renderer.getActiveMipmapLevel();
@@ -26752,13 +27114,23 @@
26752
27114
  }
26753
27115
  _state.buffers.depth.setTest( true );
26754
27116
  _state.setScissorTest( false );
26755
- const toVSM = ( _previousType !== VSMShadowMap && this.type === VSMShadowMap );
26756
- const fromVSM = ( _previousType === VSMShadowMap && this.type !== VSMShadowMap );
27117
+ const typeChanged = _previousType !== this.type;
27118
+ if ( typeChanged ) {
27119
+ scene.traverse( function ( object ) {
27120
+ if ( object.material ) {
27121
+ if ( Array.isArray( object.material ) ) {
27122
+ object.material.forEach( mat => mat.needsUpdate = true );
27123
+ } else {
27124
+ object.material.needsUpdate = true;
27125
+ }
27126
+ }
27127
+ } );
27128
+ }
26757
27129
  for ( let i = 0, il = lights.length; i < il; i ++ ) {
26758
27130
  const light = lights[ i ];
26759
27131
  const shadow = light.shadow;
26760
27132
  if ( shadow === undefined ) {
26761
- console.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' );
27133
+ warn( 'WebGLShadowMap:', light, 'has no shadow.' );
26762
27134
  continue;
26763
27135
  }
26764
27136
  if ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue;
@@ -26778,28 +27150,96 @@
26778
27150
  shadow.mapSize.y = _viewportSize.y;
26779
27151
  }
26780
27152
  }
26781
- if ( shadow.map === null || toVSM === true || fromVSM === true ) {
26782
- const pars = ( this.type !== VSMShadowMap ) ? { minFilter: NearestFilter, magFilter: NearestFilter } : {};
27153
+ if ( shadow.map === null || typeChanged === true ) {
26783
27154
  if ( shadow.map !== null ) {
27155
+ if ( shadow.map.depthTexture !== null ) {
27156
+ shadow.map.depthTexture.dispose();
27157
+ shadow.map.depthTexture = null;
27158
+ }
26784
27159
  shadow.map.dispose();
26785
27160
  }
26786
- shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );
26787
- shadow.map.texture.name = light.name + '.shadowMap';
27161
+ if ( this.type === VSMShadowMap ) {
27162
+ if ( light.isPointLight ) {
27163
+ warn( 'WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.' );
27164
+ continue;
27165
+ }
27166
+ shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, {
27167
+ format: RGFormat,
27168
+ type: HalfFloatType,
27169
+ minFilter: LinearFilter,
27170
+ magFilter: LinearFilter,
27171
+ generateMipmaps: false
27172
+ } );
27173
+ shadow.map.texture.name = light.name + '.shadowMap';
27174
+ shadow.map.depthTexture = new DepthTexture( _shadowMapSize.x, _shadowMapSize.y, FloatType );
27175
+ shadow.map.depthTexture.name = light.name + '.shadowMapDepth';
27176
+ shadow.map.depthTexture.format = DepthFormat;
27177
+ shadow.map.depthTexture.compareFunction = null;
27178
+ shadow.map.depthTexture.minFilter = NearestFilter;
27179
+ shadow.map.depthTexture.magFilter = NearestFilter;
27180
+ } else {
27181
+ if ( light.isPointLight ) {
27182
+ shadow.map = new WebGLCubeRenderTarget( _shadowMapSize.x );
27183
+ shadow.map.depthTexture = new CubeDepthTexture( _shadowMapSize.x, UnsignedIntType );
27184
+ } else {
27185
+ shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y );
27186
+ shadow.map.depthTexture = new DepthTexture( _shadowMapSize.x, _shadowMapSize.y, UnsignedIntType );
27187
+ }
27188
+ shadow.map.depthTexture.name = light.name + '.shadowMap';
27189
+ shadow.map.depthTexture.format = DepthFormat;
27190
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
27191
+ if ( this.type === PCFShadowMap ) {
27192
+ shadow.map.depthTexture.compareFunction = reversedDepthBuffer ? GreaterEqualCompare : LessEqualCompare;
27193
+ shadow.map.depthTexture.minFilter = LinearFilter;
27194
+ shadow.map.depthTexture.magFilter = LinearFilter;
27195
+ } else {
27196
+ shadow.map.depthTexture.compareFunction = null;
27197
+ shadow.map.depthTexture.minFilter = NearestFilter;
27198
+ shadow.map.depthTexture.magFilter = NearestFilter;
27199
+ }
27200
+ }
26788
27201
  shadow.camera.updateProjectionMatrix();
26789
27202
  }
26790
- renderer.setRenderTarget( shadow.map );
26791
- renderer.clear();
26792
- const viewportCount = shadow.getViewportCount();
26793
- for ( let vp = 0; vp < viewportCount; vp ++ ) {
26794
- const viewport = shadow.getViewport( vp );
26795
- _viewport.set(
26796
- _viewportSize.x * viewport.x,
26797
- _viewportSize.y * viewport.y,
26798
- _viewportSize.x * viewport.z,
26799
- _viewportSize.y * viewport.w
26800
- );
26801
- _state.viewport( _viewport );
26802
- shadow.updateMatrices( light, vp );
27203
+ const faceCount = shadow.map.isWebGLCubeRenderTarget ? 6 : 1;
27204
+ for ( let face = 0; face < faceCount; face ++ ) {
27205
+ if ( shadow.map.isWebGLCubeRenderTarget ) {
27206
+ renderer.setRenderTarget( shadow.map, face );
27207
+ renderer.clear();
27208
+ } else {
27209
+ if ( face === 0 ) {
27210
+ renderer.setRenderTarget( shadow.map );
27211
+ renderer.clear();
27212
+ }
27213
+ const viewport = shadow.getViewport( face );
27214
+ _viewport.set(
27215
+ _viewportSize.x * viewport.x,
27216
+ _viewportSize.y * viewport.y,
27217
+ _viewportSize.x * viewport.z,
27218
+ _viewportSize.y * viewport.w
27219
+ );
27220
+ _state.viewport( _viewport );
27221
+ }
27222
+ if ( light.isPointLight ) {
27223
+ const camera = shadow.camera;
27224
+ const shadowMatrix = shadow.matrix;
27225
+ const far = light.distance || camera.far;
27226
+ if ( far !== camera.far ) {
27227
+ camera.far = far;
27228
+ camera.updateProjectionMatrix();
27229
+ }
27230
+ _lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
27231
+ camera.position.copy( _lightPositionWorld );
27232
+ _lookTarget.copy( camera.position );
27233
+ _lookTarget.add( _cubeDirections[ face ] );
27234
+ camera.up.copy( _cubeUps[ face ] );
27235
+ camera.lookAt( _lookTarget );
27236
+ camera.updateMatrixWorld();
27237
+ shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
27238
+ _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
27239
+ shadow._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
27240
+ } else {
27241
+ shadow.updateMatrices( light );
27242
+ }
26803
27243
  _frustum = shadow.getFrustum();
26804
27244
  renderObject( scene, camera, shadow.camera, light, this.type );
26805
27245
  }
@@ -26821,9 +27261,12 @@
26821
27261
  shadowMaterialHorizontal.needsUpdate = true;
26822
27262
  }
26823
27263
  if ( shadow.mapPass === null ) {
26824
- shadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y );
27264
+ shadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, {
27265
+ format: RGFormat,
27266
+ type: HalfFloatType
27267
+ } );
26825
27268
  }
26826
- shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
27269
+ shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.depthTexture;
26827
27270
  shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
26828
27271
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
26829
27272
  renderer.setRenderTarget( shadow.mapPass );
@@ -27328,7 +27771,7 @@
27328
27771
  gl.blendFuncSeparate( gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
27329
27772
  break;
27330
27773
  default:
27331
- console.error( 'THREE.WebGLState: Invalid blending: ', blending );
27774
+ error( 'WebGLState: Invalid blending: ', blending );
27332
27775
  break;
27333
27776
  }
27334
27777
  } else {
@@ -27340,13 +27783,13 @@
27340
27783
  gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE );
27341
27784
  break;
27342
27785
  case SubtractiveBlending:
27343
- console.error( 'THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true' );
27786
+ error( 'WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true' );
27344
27787
  break;
27345
27788
  case MultiplyBlending:
27346
- console.error( 'THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true' );
27789
+ error( 'WebGLState: MultiplyBlending requires material.premultipliedAlpha = true' );
27347
27790
  break;
27348
27791
  default:
27349
- console.error( 'THREE.WebGLState: Invalid blending: ', blending );
27792
+ error( 'WebGLState: Invalid blending: ', blending );
27350
27793
  break;
27351
27794
  }
27352
27795
  }
@@ -27503,71 +27946,71 @@
27503
27946
  function compressedTexImage2D() {
27504
27947
  try {
27505
27948
  gl.compressedTexImage2D( ...arguments );
27506
- } catch ( error ) {
27507
- console.error( 'THREE.WebGLState:', error );
27949
+ } catch ( e ) {
27950
+ error( 'WebGLState:', e );
27508
27951
  }
27509
27952
  }
27510
27953
  function compressedTexImage3D() {
27511
27954
  try {
27512
27955
  gl.compressedTexImage3D( ...arguments );
27513
- } catch ( error ) {
27514
- console.error( 'THREE.WebGLState:', error );
27956
+ } catch ( e ) {
27957
+ error( 'WebGLState:', e );
27515
27958
  }
27516
27959
  }
27517
27960
  function texSubImage2D() {
27518
27961
  try {
27519
27962
  gl.texSubImage2D( ...arguments );
27520
- } catch ( error ) {
27521
- console.error( 'THREE.WebGLState:', error );
27963
+ } catch ( e ) {
27964
+ error( 'WebGLState:', e );
27522
27965
  }
27523
27966
  }
27524
27967
  function texSubImage3D() {
27525
27968
  try {
27526
27969
  gl.texSubImage3D( ...arguments );
27527
- } catch ( error ) {
27528
- console.error( 'THREE.WebGLState:', error );
27970
+ } catch ( e ) {
27971
+ error( 'WebGLState:', e );
27529
27972
  }
27530
27973
  }
27531
27974
  function compressedTexSubImage2D() {
27532
27975
  try {
27533
27976
  gl.compressedTexSubImage2D( ...arguments );
27534
- } catch ( error ) {
27535
- console.error( 'THREE.WebGLState:', error );
27977
+ } catch ( e ) {
27978
+ error( 'WebGLState:', e );
27536
27979
  }
27537
27980
  }
27538
27981
  function compressedTexSubImage3D() {
27539
27982
  try {
27540
27983
  gl.compressedTexSubImage3D( ...arguments );
27541
- } catch ( error ) {
27542
- console.error( 'THREE.WebGLState:', error );
27984
+ } catch ( e ) {
27985
+ error( 'WebGLState:', e );
27543
27986
  }
27544
27987
  }
27545
27988
  function texStorage2D() {
27546
27989
  try {
27547
27990
  gl.texStorage2D( ...arguments );
27548
- } catch ( error ) {
27549
- console.error( 'THREE.WebGLState:', error );
27991
+ } catch ( e ) {
27992
+ error( 'WebGLState:', e );
27550
27993
  }
27551
27994
  }
27552
27995
  function texStorage3D() {
27553
27996
  try {
27554
27997
  gl.texStorage3D( ...arguments );
27555
- } catch ( error ) {
27556
- console.error( 'THREE.WebGLState:', error );
27998
+ } catch ( e ) {
27999
+ error( 'WebGLState:', e );
27557
28000
  }
27558
28001
  }
27559
28002
  function texImage2D() {
27560
28003
  try {
27561
28004
  gl.texImage2D( ...arguments );
27562
- } catch ( error ) {
27563
- console.error( 'THREE.WebGLState:', error );
28005
+ } catch ( e ) {
28006
+ error( 'WebGLState:', e );
27564
28007
  }
27565
28008
  }
27566
28009
  function texImage3D() {
27567
28010
  try {
27568
28011
  gl.texImage3D( ...arguments );
27569
- } catch ( error ) {
27570
- console.error( 'THREE.WebGLState:', error );
28012
+ } catch ( e ) {
28013
+ error( 'WebGLState:', e );
27571
28014
  }
27572
28015
  }
27573
28016
  function scissor( scissor ) {
@@ -27738,11 +28181,11 @@
27738
28181
  canvas.height = height;
27739
28182
  const context = canvas.getContext( '2d' );
27740
28183
  context.drawImage( image, 0, 0, width, height );
27741
- console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + dimensions.width + 'x' + dimensions.height + ') to (' + width + 'x' + height + ').' );
28184
+ warn( 'WebGLRenderer: Texture has been resized from (' + dimensions.width + 'x' + dimensions.height + ') to (' + width + 'x' + height + ').' );
27742
28185
  return canvas;
27743
28186
  } else {
27744
28187
  if ( 'data' in image ) {
27745
- console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + dimensions.width + 'x' + dimensions.height + ').' );
28188
+ warn( 'WebGLRenderer: Image in DataTexture is too big (' + dimensions.width + 'x' + dimensions.height + ').' );
27746
28189
  }
27747
28190
  return image;
27748
28191
  }
@@ -27764,7 +28207,7 @@
27764
28207
  function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
27765
28208
  if ( internalFormatName !== null ) {
27766
28209
  if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
27767
- console.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' );
28210
+ warn( 'WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' );
27768
28211
  }
27769
28212
  let internalFormat = glFormat;
27770
28213
  if ( glFormat === _gl.RED ) {
@@ -27837,7 +28280,7 @@
27837
28280
  glInternalFormat = _gl.DEPTH32F_STENCIL8;
27838
28281
  } else if ( depthType === UnsignedShortType ) {
27839
28282
  glInternalFormat = _gl.DEPTH24_STENCIL8;
27840
- console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
28283
+ warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
27841
28284
  }
27842
28285
  } else {
27843
28286
  if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
@@ -27947,7 +28390,7 @@
27947
28390
  function allocateTextureUnit() {
27948
28391
  const textureUnit = textureUnits;
27949
28392
  if ( textureUnit >= capabilities.maxTextures ) {
27950
- console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
28393
+ warn( 'WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
27951
28394
  }
27952
28395
  textureUnits += 1;
27953
28396
  return textureUnit;
@@ -27976,9 +28419,9 @@
27976
28419
  if ( texture.isRenderTargetTexture === false && texture.isExternalTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
27977
28420
  const image = texture.image;
27978
28421
  if ( image === null ) {
27979
- console.warn( 'THREE.WebGLRenderer: Texture marked for update but no image data found.' );
28422
+ warn( 'WebGLRenderer: Texture marked for update but no image data found.' );
27980
28423
  } else if ( image.complete === false ) {
27981
- console.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );
28424
+ warn( 'WebGLRenderer: Texture marked for update but image is incomplete' );
27982
28425
  } else {
27983
28426
  uploadTexture( textureProperties, texture, slot );
27984
28427
  return;
@@ -27993,6 +28436,8 @@
27993
28436
  if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
27994
28437
  uploadTexture( textureProperties, texture, slot );
27995
28438
  return;
28439
+ } else if ( texture.isExternalTexture ) {
28440
+ textureProperties.__webglTexture = texture.sourceTexture ? texture.sourceTexture : null;
27996
28441
  }
27997
28442
  state.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
27998
28443
  }
@@ -28006,7 +28451,7 @@
28006
28451
  }
28007
28452
  function setTextureCube( texture, slot ) {
28008
28453
  const textureProperties = properties.get( texture );
28009
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
28454
+ if ( texture.isCubeDepthTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
28010
28455
  uploadCubeTexture( textureProperties, texture, slot );
28011
28456
  return;
28012
28457
  }
@@ -28039,7 +28484,7 @@
28039
28484
  if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
28040
28485
  ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
28041
28486
  texture.minFilter === LinearFilter || texture.minFilter === LinearMipmapNearestFilter || texture.minFilter === NearestMipmapLinearFilter || texture.minFilter === LinearMipmapLinearFilter ) ) {
28042
- console.warn( 'THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.' );
28487
+ warn( 'WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.' );
28043
28488
  }
28044
28489
  _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
28045
28490
  _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
@@ -28247,7 +28692,7 @@
28247
28692
  state.compressedTexImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, mipmap.data, 0, 0 );
28248
28693
  }
28249
28694
  } else {
28250
- console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28695
+ warn( 'WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28251
28696
  }
28252
28697
  } else {
28253
28698
  if ( useTexStorage ) {
@@ -28275,7 +28720,7 @@
28275
28720
  state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
28276
28721
  }
28277
28722
  } else {
28278
- console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28723
+ warn( 'WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28279
28724
  }
28280
28725
  } else {
28281
28726
  if ( useTexStorage ) {
@@ -28428,7 +28873,7 @@
28428
28873
  state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
28429
28874
  }
28430
28875
  } else {
28431
- console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );
28876
+ warn( 'WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );
28432
28877
  }
28433
28878
  } else {
28434
28879
  if ( useTexStorage ) {
@@ -28521,19 +28966,17 @@
28521
28966
  }
28522
28967
  state.bindFramebuffer( _gl.FRAMEBUFFER, null );
28523
28968
  }
28524
- function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
28969
+ function setupRenderBufferStorage( renderbuffer, renderTarget, useMultisample ) {
28525
28970
  _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
28526
28971
  if ( renderTarget.depthBuffer ) {
28527
28972
  const depthTexture = renderTarget.depthTexture;
28528
28973
  const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
28529
28974
  const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
28530
28975
  const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
28531
- const samples = getRenderTargetSamples( renderTarget );
28532
- const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
28533
- if ( isUseMultisampledRTT ) {
28534
- multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
28535
- } else if ( isMultisample ) {
28536
- _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
28976
+ if ( useMultisampledRTT( renderTarget ) ) {
28977
+ multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28978
+ } else if ( useMultisample ) {
28979
+ _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28537
28980
  } else {
28538
28981
  _gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
28539
28982
  }
@@ -28545,11 +28988,10 @@
28545
28988
  const glFormat = utils.convert( texture.format, texture.colorSpace );
28546
28989
  const glType = utils.convert( texture.type );
28547
28990
  const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
28548
- const samples = getRenderTargetSamples( renderTarget );
28549
- if ( isMultisample && useMultisampledRTT( renderTarget ) === false ) {
28550
- _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
28551
- } else if ( useMultisampledRTT( renderTarget ) ) {
28552
- multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
28991
+ if ( useMultisampledRTT( renderTarget ) ) {
28992
+ multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28993
+ } else if ( useMultisample ) {
28994
+ _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28553
28995
  } else {
28554
28996
  _gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
28555
28997
  }
@@ -28557,9 +28999,8 @@
28557
28999
  }
28558
29000
  _gl.bindRenderbuffer( _gl.RENDERBUFFER, null );
28559
29001
  }
28560
- function setupDepthTexture( framebuffer, renderTarget ) {
28561
- const isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget );
28562
- if ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );
29002
+ function setupDepthTexture( framebuffer, renderTarget, cubeFace ) {
29003
+ const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
28563
29004
  state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
28564
29005
  if ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {
28565
29006
  throw new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );
@@ -28573,20 +29014,45 @@
28573
29014
  renderTarget.depthTexture.image.height = renderTarget.height;
28574
29015
  renderTarget.depthTexture.needsUpdate = true;
28575
29016
  }
28576
- setTexture2D( renderTarget.depthTexture, 0 );
29017
+ if ( isCube ) {
29018
+ if ( textureProperties.__webglInit === undefined ) {
29019
+ textureProperties.__webglInit = true;
29020
+ renderTarget.depthTexture.addEventListener( 'dispose', onTextureDispose );
29021
+ }
29022
+ if ( textureProperties.__webglTexture === undefined ) {
29023
+ textureProperties.__webglTexture = _gl.createTexture();
29024
+ state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
29025
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.depthTexture );
29026
+ const glFormat = utils.convert( renderTarget.depthTexture.format );
29027
+ const glType = utils.convert( renderTarget.depthTexture.type );
29028
+ let glInternalFormat;
29029
+ if ( renderTarget.depthTexture.format === DepthFormat ) {
29030
+ glInternalFormat = _gl.DEPTH_COMPONENT24;
29031
+ } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
29032
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
29033
+ }
29034
+ for ( let i = 0; i < 6; i ++ ) {
29035
+ _gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
29036
+ }
29037
+ }
29038
+ } else {
29039
+ setTexture2D( renderTarget.depthTexture, 0 );
29040
+ }
28577
29041
  const webglDepthTexture = textureProperties.__webglTexture;
28578
29042
  const samples = getRenderTargetSamples( renderTarget );
29043
+ const glTextureType = isCube ? _gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace : _gl.TEXTURE_2D;
29044
+ const glAttachmentType = renderTarget.depthTexture.format === DepthStencilFormat ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
28579
29045
  if ( renderTarget.depthTexture.format === DepthFormat ) {
28580
29046
  if ( useMultisampledRTT( renderTarget ) ) {
28581
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
29047
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
28582
29048
  } else {
28583
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
29049
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
28584
29050
  }
28585
29051
  } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
28586
29052
  if ( useMultisampledRTT( renderTarget ) ) {
28587
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
29053
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
28588
29054
  } else {
28589
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
29055
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
28590
29056
  }
28591
29057
  } else {
28592
29058
  throw new Error( 'Unknown depthTexture format' );
@@ -28612,12 +29078,17 @@
28612
29078
  renderTargetProperties.__boundDepthTexture = depthTexture;
28613
29079
  }
28614
29080
  if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
28615
- if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
28616
- const mipmaps = renderTarget.texture.mipmaps;
28617
- if ( mipmaps && mipmaps.length > 0 ) {
28618
- setupDepthTexture( renderTargetProperties.__webglFramebuffer[ 0 ], renderTarget );
29081
+ if ( isCube ) {
29082
+ for ( let i = 0; i < 6; i ++ ) {
29083
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, i );
29084
+ }
28619
29085
  } else {
28620
- setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );
29086
+ const mipmaps = renderTarget.texture.mipmaps;
29087
+ if ( mipmaps && mipmaps.length > 0 ) {
29088
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer[ 0 ], renderTarget, 0 );
29089
+ } else {
29090
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget, 0 );
29091
+ }
28621
29092
  }
28622
29093
  } else {
28623
29094
  if ( isCube ) {
@@ -28891,10 +29362,10 @@
28891
29362
  if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
28892
29363
  if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
28893
29364
  if ( format !== RGBAFormat || type !== UnsignedByteType ) {
28894
- console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
29365
+ warn( 'WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
28895
29366
  }
28896
29367
  } else {
28897
- console.error( 'THREE.WebGLTextures: Unsupported texture color space:', colorSpace );
29368
+ error( 'WebGLTextures: Unsupported texture color space:', colorSpace );
28898
29369
  }
28899
29370
  }
28900
29371
  return image;
@@ -28925,6 +29396,9 @@
28925
29396
  this.setupDepthRenderbuffer = setupDepthRenderbuffer;
28926
29397
  this.setupFrameBufferTexture = setupFrameBufferTexture;
28927
29398
  this.useMultisampledRTT = useMultisampledRTT;
29399
+ this.isReversedDepthBuffer = function () {
29400
+ return state.buffers.depth.getReversed();
29401
+ };
28928
29402
  }
28929
29403
  function WebGLUtils( gl, extensions ) {
28930
29404
  function convert( p, colorSpace = NoColorSpace ) {
@@ -28986,11 +29460,15 @@
28986
29460
  return null;
28987
29461
  }
28988
29462
  }
28989
- if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
29463
+ if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format || p === R11_EAC_Format || p === SIGNED_R11_EAC_Format || p === RG11_EAC_Format || p === SIGNED_RG11_EAC_Format ) {
28990
29464
  extension = extensions.get( 'WEBGL_compressed_texture_etc' );
28991
29465
  if ( extension !== null ) {
28992
29466
  if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
28993
29467
  if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
29468
+ if ( p === R11_EAC_Format ) return extension.COMPRESSED_R11_EAC;
29469
+ if ( p === SIGNED_R11_EAC_Format ) return extension.COMPRESSED_SIGNED_R11_EAC;
29470
+ if ( p === RG11_EAC_Format ) return extension.COMPRESSED_RG11_EAC;
29471
+ if ( p === SIGNED_RG11_EAC_Format ) return extension.COMPRESSED_SIGNED_RG11_EAC;
28994
29472
  } else {
28995
29473
  return null;
28996
29474
  }
@@ -29222,13 +29700,13 @@ void main() {
29222
29700
  this.setFramebufferScaleFactor = function ( value ) {
29223
29701
  framebufferScaleFactor = value;
29224
29702
  if ( scope.isPresenting === true ) {
29225
- console.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' );
29703
+ warn( 'WebXRManager: Cannot change framebuffer scale while presenting.' );
29226
29704
  }
29227
29705
  };
29228
29706
  this.setReferenceSpaceType = function ( value ) {
29229
29707
  referenceSpaceType = value;
29230
29708
  if ( scope.isPresenting === true ) {
29231
- console.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' );
29709
+ warn( 'WebXRManager: Cannot change reference space type while presenting.' );
29232
29710
  }
29233
29711
  };
29234
29712
  this.getReferenceSpace = function () {
@@ -29955,7 +30433,7 @@ void main() {
29955
30433
  return i;
29956
30434
  }
29957
30435
  }
29958
- console.error( 'THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.' );
30436
+ error( 'WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.' );
29959
30437
  return 0;
29960
30438
  }
29961
30439
  function updateBufferData( uniformsGroup ) {
@@ -30082,9 +30560,9 @@ void main() {
30082
30560
  info.boundary = 64;
30083
30561
  info.storage = 64;
30084
30562
  } else if ( value.isTexture ) {
30085
- console.warn( 'THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.' );
30563
+ warn( 'WebGLRenderer: Texture samplers can not be part of an uniforms group.' );
30086
30564
  } else {
30087
- console.warn( 'THREE.WebGLRenderer: Unsupported uniform value type.', value );
30565
+ warn( 'WebGLRenderer: Unsupported uniform value type.', value );
30088
30566
  }
30089
30567
  return info;
30090
30568
  }
@@ -30111,6 +30589,38 @@ void main() {
30111
30589
  dispose: dispose
30112
30590
  };
30113
30591
  }
30592
+ const DATA = new Uint16Array( [
30593
+ 0x30b5, 0x3ad1, 0x314c, 0x3a4d, 0x33d2, 0x391c, 0x35ef, 0x3828, 0x37f3, 0x36a6, 0x38d1, 0x3539, 0x3979, 0x3410, 0x39f8, 0x3252, 0x3a53, 0x30f0, 0x3a94, 0x2fc9, 0x3abf, 0x2e35, 0x3ada, 0x2d05, 0x3ae8, 0x2c1f, 0x3aed, 0x2ae0, 0x3aea, 0x29d1, 0x3ae1, 0x28ff,
30594
+ 0x3638, 0x38e4, 0x364a, 0x38ce, 0x3699, 0x385e, 0x374e, 0x372c, 0x3839, 0x35a4, 0x38dc, 0x3462, 0x396e, 0x32c4, 0x39de, 0x3134, 0x3a2b, 0x3003, 0x3a59, 0x2e3a, 0x3a6d, 0x2ce1, 0x3a6e, 0x2bba, 0x3a5f, 0x2a33, 0x3a49, 0x290a, 0x3a2d, 0x2826, 0x3a0a, 0x26e8,
30595
+ 0x3894, 0x36d7, 0x3897, 0x36c9, 0x38a3, 0x3675, 0x38bc, 0x35ac, 0x38ee, 0x349c, 0x393e, 0x3332, 0x3997, 0x3186, 0x39e2, 0x3038, 0x3a13, 0x2e75, 0x3a29, 0x2cf5, 0x3a2d, 0x2bac, 0x3a21, 0x29ff, 0x3a04, 0x28bc, 0x39dc, 0x2790, 0x39ad, 0x261a, 0x3978, 0x24fa,
30596
+ 0x39ac, 0x34a8, 0x39ac, 0x34a3, 0x39ae, 0x3480, 0x39ae, 0x3423, 0x39b1, 0x330e, 0x39c2, 0x31a9, 0x39e0, 0x3063, 0x39fc, 0x2eb5, 0x3a0c, 0x2d1d, 0x3a14, 0x2bcf, 0x3a07, 0x29ff, 0x39e9, 0x28a3, 0x39be, 0x273c, 0x3989, 0x25b3, 0x394a, 0x2488, 0x3907, 0x2345,
30597
+ 0x3a77, 0x3223, 0x3a76, 0x321f, 0x3a73, 0x3204, 0x3a6a, 0x31b3, 0x3a58, 0x3114, 0x3a45, 0x303b, 0x3a34, 0x2eb6, 0x3a26, 0x2d31, 0x3a1e, 0x2bef, 0x3a0b, 0x2a0d, 0x39ec, 0x28a1, 0x39c0, 0x271b, 0x3987, 0x2580, 0x3944, 0x2449, 0x38fa, 0x22bd, 0x38ac, 0x2155,
30598
+ 0x3b07, 0x2fca, 0x3b06, 0x2fca, 0x3b00, 0x2fb8, 0x3af4, 0x2f7c, 0x3adb, 0x2eea, 0x3ab4, 0x2e00, 0x3a85, 0x2cec, 0x3a5e, 0x2bc5, 0x3a36, 0x2a00, 0x3a0d, 0x2899, 0x39dc, 0x2707, 0x39a0, 0x2562, 0x395a, 0x2424, 0x390b, 0x2268, 0x38b7, 0x20fd, 0x385f, 0x1fd1,
30599
+ 0x3b69, 0x2cb9, 0x3b68, 0x2cbb, 0x3b62, 0x2cbb, 0x3b56, 0x2cae, 0x3b3b, 0x2c78, 0x3b0d, 0x2c0a, 0x3acf, 0x2ae3, 0x3a92, 0x2998, 0x3a54, 0x2867, 0x3a17, 0x26d0, 0x39d3, 0x253c, 0x3989, 0x2402, 0x3935, 0x2226, 0x38dc, 0x20bd, 0x387d, 0x1f54, 0x381d, 0x1db3,
30600
+ 0x3ba9, 0x296b, 0x3ba8, 0x296f, 0x3ba3, 0x297b, 0x3b98, 0x2987, 0x3b7f, 0x2976, 0x3b4e, 0x2927, 0x3b0e, 0x2895, 0x3ac2, 0x27b7, 0x3a73, 0x263b, 0x3a23, 0x24e7, 0x39d0, 0x239b, 0x3976, 0x21d9, 0x3917, 0x207e, 0x38b2, 0x1ee7, 0x384b, 0x1d53, 0x37c7, 0x1c1e,
30601
+ 0x3bd2, 0x25cb, 0x3bd1, 0x25d3, 0x3bcd, 0x25f0, 0x3bc2, 0x261f, 0x3bad, 0x2645, 0x3b7d, 0x262d, 0x3b3e, 0x25c4, 0x3aec, 0x250f, 0x3a93, 0x243a, 0x3a32, 0x22ce, 0x39d0, 0x215b, 0x3969, 0x202a, 0x38fe, 0x1e6e, 0x388f, 0x1cf1, 0x381f, 0x1b9b, 0x3762, 0x19dd,
30602
+ 0x3be9, 0x21ab, 0x3be9, 0x21b7, 0x3be5, 0x21e5, 0x3bdd, 0x2241, 0x3bc9, 0x22a7, 0x3ba0, 0x22ec, 0x3b62, 0x22cd, 0x3b0f, 0x2247, 0x3aae, 0x2175, 0x3a44, 0x2088, 0x39d4, 0x1f49, 0x3960, 0x1dbe, 0x38e9, 0x1c77, 0x3870, 0x1ae8, 0x37f1, 0x1953, 0x3708, 0x181b,
30603
+ 0x3bf6, 0x1cea, 0x3bf6, 0x1cfb, 0x3bf3, 0x1d38, 0x3bec, 0x1dbd, 0x3bda, 0x1e7c, 0x3bb7, 0x1f25, 0x3b7d, 0x1f79, 0x3b2c, 0x1f4c, 0x3ac6, 0x1ea6, 0x3a55, 0x1dbb, 0x39da, 0x1cbd, 0x395a, 0x1b9d, 0x38d8, 0x1a00, 0x3855, 0x18ac, 0x37ab, 0x173c, 0x36b7, 0x1598,
30604
+ 0x3bfc, 0x1736, 0x3bfc, 0x1759, 0x3bf9, 0x17e7, 0x3bf4, 0x1896, 0x3be4, 0x1997, 0x3bc6, 0x1aa8, 0x3b91, 0x1b84, 0x3b43, 0x1bd2, 0x3ade, 0x1b8a, 0x3a65, 0x1acd, 0x39e2, 0x19d3, 0x3957, 0x18cd, 0x38ca, 0x17b3, 0x383e, 0x1613, 0x376d, 0x14bf, 0x366f, 0x135e,
30605
+ 0x3bff, 0x101b, 0x3bff, 0x1039, 0x3bfc, 0x10c8, 0x3bf9, 0x1226, 0x3bea, 0x1428, 0x3bcf, 0x1584, 0x3b9f, 0x16c5, 0x3b54, 0x179a, 0x3af0, 0x17ce, 0x3a76, 0x1771, 0x39ea, 0x16a4, 0x3956, 0x15a7, 0x38bf, 0x14a7, 0x3829, 0x1379, 0x3735, 0x11ea, 0x362d, 0x10a1,
30606
+ 0x3c00, 0x061b, 0x3c00, 0x066a, 0x3bfe, 0x081c, 0x3bfa, 0x0a4c, 0x3bed, 0x0d16, 0x3bd5, 0x0fb3, 0x3ba9, 0x114d, 0x3b63, 0x127c, 0x3b01, 0x132f, 0x3a85, 0x1344, 0x39f4, 0x12d2, 0x3957, 0x120d, 0x38b5, 0x1122, 0x3817, 0x103c, 0x3703, 0x0ed3, 0x35f0, 0x0d6d,
30607
+ 0x3c00, 0x007a, 0x3c00, 0x0089, 0x3bfe, 0x011d, 0x3bfb, 0x027c, 0x3bf0, 0x04fa, 0x3bda, 0x0881, 0x3bb1, 0x0acd, 0x3b6f, 0x0c97, 0x3b10, 0x0d7b, 0x3a93, 0x0df1, 0x39fe, 0x0def, 0x3959, 0x0d8a, 0x38af, 0x0ce9, 0x3808, 0x0c31, 0x36d5, 0x0af0, 0x35b9, 0x09a3,
30608
+ 0x3c00, 0x0000, 0x3c00, 0x0001, 0x3bff, 0x0015, 0x3bfb, 0x0059, 0x3bf2, 0x00fd, 0x3bdd, 0x01df, 0x3bb7, 0x031c, 0x3b79, 0x047c, 0x3b1d, 0x05d4, 0x3aa0, 0x06d5, 0x3a08, 0x075a, 0x395d, 0x075e, 0x38aa, 0x06f7, 0x37f4, 0x0648, 0x36ac, 0x0576, 0x3586, 0x049f
30609
+ ] );
30610
+ let lut = null;
30611
+ function getDFGLUT() {
30612
+ if ( lut === null ) {
30613
+ lut = new DataTexture( DATA, 16, 16, RGFormat, HalfFloatType );
30614
+ lut.name = 'DFG_LUT';
30615
+ lut.minFilter = LinearFilter;
30616
+ lut.magFilter = LinearFilter;
30617
+ lut.wrapS = ClampToEdgeWrapping;
30618
+ lut.wrapT = ClampToEdgeWrapping;
30619
+ lut.generateMipmaps = false;
30620
+ lut.needsUpdate = true;
30621
+ }
30622
+ return lut;
30623
+ }
30114
30624
  class WebGLRenderer {
30115
30625
  constructor( parameters = {} ) {
30116
30626
  const {
@@ -30125,6 +30635,7 @@ void main() {
30125
30635
  powerPreference = 'default',
30126
30636
  failIfMajorPerformanceCaveat = false,
30127
30637
  reversedDepthBuffer = false,
30638
+ outputBufferType = UnsignedByteType,
30128
30639
  } = parameters;
30129
30640
  this.isWebGLRenderer = true;
30130
30641
  let _alpha;
@@ -30136,12 +30647,27 @@ void main() {
30136
30647
  } else {
30137
30648
  _alpha = alpha;
30138
30649
  }
30650
+ const _outputBufferType = outputBufferType;
30651
+ const INTEGER_FORMATS = new Set( [
30652
+ RGBAIntegerFormat,
30653
+ RGIntegerFormat,
30654
+ RedIntegerFormat
30655
+ ] );
30656
+ const UNSIGNED_TYPES = new Set( [
30657
+ UnsignedByteType,
30658
+ UnsignedIntType,
30659
+ UnsignedShortType,
30660
+ UnsignedInt248Type,
30661
+ UnsignedShort4444Type,
30662
+ UnsignedShort5551Type
30663
+ ] );
30139
30664
  const uintClearColor = new Uint32Array( 4 );
30140
30665
  const intClearColor = new Int32Array( 4 );
30141
30666
  let currentRenderList = null;
30142
30667
  let currentRenderState = null;
30143
30668
  const renderListStack = [];
30144
30669
  const renderStateStack = [];
30670
+ let output = null;
30145
30671
  this.domElement = canvas;
30146
30672
  this.debug = {
30147
30673
  checkShaderErrors: true,
@@ -30219,9 +30745,9 @@ void main() {
30219
30745
  }
30220
30746
  }
30221
30747
  }
30222
- } catch ( error ) {
30223
- console.error( 'THREE.WebGLRenderer: ' + error.message );
30224
- throw error;
30748
+ } catch ( e ) {
30749
+ error( 'WebGLRenderer: ' + e.message );
30750
+ throw e;
30225
30751
  }
30226
30752
  let extensions, capabilities, state, info;
30227
30753
  let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
@@ -30267,6 +30793,9 @@ void main() {
30267
30793
  _this.info = info;
30268
30794
  }
30269
30795
  initGLContext();
30796
+ if ( _outputBufferType !== UnsignedByteType ) {
30797
+ output = new WebGLOutput( _outputBufferType, canvas.width, canvas.height, depth, stencil );
30798
+ }
30270
30799
  const xr = new WebXRManager( _this, _gl );
30271
30800
  this.xr = xr;
30272
30801
  this.getContext = function () {
@@ -30296,7 +30825,7 @@ void main() {
30296
30825
  };
30297
30826
  this.setSize = function ( width, height, updateStyle = true ) {
30298
30827
  if ( xr.isPresenting ) {
30299
- console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' );
30828
+ warn( 'WebGLRenderer: Can\'t change size while VR device is presenting.' );
30300
30829
  return;
30301
30830
  }
30302
30831
  _width = width;
@@ -30307,6 +30836,9 @@ void main() {
30307
30836
  canvas.style.width = width + 'px';
30308
30837
  canvas.style.height = height + 'px';
30309
30838
  }
30839
+ if ( output !== null ) {
30840
+ output.setSize( canvas.width, canvas.height );
30841
+ }
30310
30842
  this.setViewport( 0, 0, width, height );
30311
30843
  };
30312
30844
  this.getDrawingBufferSize = function ( target ) {
@@ -30320,6 +30852,21 @@ void main() {
30320
30852
  canvas.height = Math.floor( height * pixelRatio );
30321
30853
  this.setViewport( 0, 0, width, height );
30322
30854
  };
30855
+ this.setEffects = function ( effects ) {
30856
+ if ( _outputBufferType === UnsignedByteType ) {
30857
+ console.error( 'THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.' );
30858
+ return;
30859
+ }
30860
+ if ( effects ) {
30861
+ for ( let i = 0; i < effects.length; i ++ ) {
30862
+ if ( effects[ i ].isOutputPass === true ) {
30863
+ console.warn( 'THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.' );
30864
+ break;
30865
+ }
30866
+ }
30867
+ }
30868
+ output.setEffects( effects || [] );
30869
+ };
30323
30870
  this.getCurrentViewport = function ( target ) {
30324
30871
  return target.copy( _currentViewport );
30325
30872
  };
@@ -30375,18 +30922,11 @@ void main() {
30375
30922
  let isIntegerFormat = false;
30376
30923
  if ( _currentRenderTarget !== null ) {
30377
30924
  const targetFormat = _currentRenderTarget.texture.format;
30378
- isIntegerFormat = targetFormat === RGBAIntegerFormat ||
30379
- targetFormat === RGIntegerFormat ||
30380
- targetFormat === RedIntegerFormat;
30925
+ isIntegerFormat = INTEGER_FORMATS.has( targetFormat );
30381
30926
  }
30382
30927
  if ( isIntegerFormat ) {
30383
30928
  const targetType = _currentRenderTarget.texture.type;
30384
- const isUnsignedType = targetType === UnsignedByteType ||
30385
- targetType === UnsignedIntType ||
30386
- targetType === UnsignedShortType ||
30387
- targetType === UnsignedInt248Type ||
30388
- targetType === UnsignedShort4444Type ||
30389
- targetType === UnsignedShort5551Type;
30929
+ const isUnsignedType = UNSIGNED_TYPES.has( targetType );
30390
30930
  const clearColor = background.getClearColor();
30391
30931
  const a = background.getClearAlpha();
30392
30932
  const r = clearColor.r;
@@ -30448,11 +30988,11 @@ void main() {
30448
30988
  };
30449
30989
  function onContextLost( event ) {
30450
30990
  event.preventDefault();
30451
- console.log( 'THREE.WebGLRenderer: Context Lost.' );
30991
+ log( 'WebGLRenderer: Context Lost.' );
30452
30992
  _isContextLost = true;
30453
30993
  }
30454
30994
  function onContextRestore( ) {
30455
- console.log( 'THREE.WebGLRenderer: Context Restored.' );
30995
+ log( 'WebGLRenderer: Context Restored.' );
30456
30996
  _isContextLost = false;
30457
30997
  const infoAutoReset = info.autoReset;
30458
30998
  const shadowMapEnabled = shadowMap.enabled;
@@ -30467,7 +31007,7 @@ void main() {
30467
31007
  shadowMap.type = shadowMapType;
30468
31008
  }
30469
31009
  function onContextCreationError( event ) {
30470
- console.error( 'THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
31010
+ error( 'WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
30471
31011
  }
30472
31012
  function onMaterialDispose( event ) {
30473
31013
  const material = event.target;
@@ -30551,7 +31091,7 @@ void main() {
30551
31091
  }
30552
31092
  if ( object.isBatchedMesh ) {
30553
31093
  if ( object._multiDrawInstances !== null ) {
30554
- warnOnce( 'THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
31094
+ warnOnce( 'WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
30555
31095
  renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
30556
31096
  } else {
30557
31097
  if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
@@ -30683,13 +31223,15 @@ void main() {
30683
31223
  xr.addEventListener( 'sessionend', onXRSessionEnd );
30684
31224
  this.render = function ( scene, camera ) {
30685
31225
  if ( camera !== undefined && camera.isCamera !== true ) {
30686
- console.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
31226
+ error( 'WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
30687
31227
  return;
30688
31228
  }
30689
31229
  if ( _isContextLost === true ) return;
31230
+ const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
31231
+ const useOutput = output !== null && ( _currentRenderTarget === null || isXRPresenting ) && output.begin( _this, _currentRenderTarget );
30690
31232
  if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
30691
31233
  if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
30692
- if ( xr.enabled === true && xr.isPresenting === true ) {
31234
+ if ( xr.enabled === true && xr.isPresenting === true && ( output === null || output.isCompositing() === false ) ) {
30693
31235
  if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
30694
31236
  camera = xr.getCamera();
30695
31237
  }
@@ -30725,31 +31267,37 @@ void main() {
30725
31267
  shadowMap.render( shadowsArray, scene, camera );
30726
31268
  if ( _clippingEnabled === true ) clipping.endShadows();
30727
31269
  if ( this.info.autoReset === true ) this.info.reset();
30728
- const opaqueObjects = currentRenderList.opaque;
30729
- const transmissiveObjects = currentRenderList.transmissive;
30730
- currentRenderState.setupLights();
30731
- if ( camera.isArrayCamera ) {
30732
- const cameras = camera.cameras;
30733
- if ( transmissiveObjects.length > 0 ) {
31270
+ const skipSceneRender = useOutput && output.hasRenderPass();
31271
+ if ( skipSceneRender === false ) {
31272
+ const opaqueObjects = currentRenderList.opaque;
31273
+ const transmissiveObjects = currentRenderList.transmissive;
31274
+ currentRenderState.setupLights();
31275
+ if ( camera.isArrayCamera ) {
31276
+ const cameras = camera.cameras;
31277
+ if ( transmissiveObjects.length > 0 ) {
31278
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
31279
+ const camera2 = cameras[ i ];
31280
+ renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
31281
+ }
31282
+ }
31283
+ if ( _renderBackground ) background.render( scene );
30734
31284
  for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30735
31285
  const camera2 = cameras[ i ];
30736
- renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
31286
+ renderScene( currentRenderList, scene, camera2, camera2.viewport );
30737
31287
  }
31288
+ } else {
31289
+ if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
31290
+ if ( _renderBackground ) background.render( scene );
31291
+ renderScene( currentRenderList, scene, camera );
30738
31292
  }
30739
- if ( _renderBackground ) background.render( scene );
30740
- for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30741
- const camera2 = cameras[ i ];
30742
- renderScene( currentRenderList, scene, camera2, camera2.viewport );
30743
- }
30744
- } else {
30745
- if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
30746
- if ( _renderBackground ) background.render( scene );
30747
- renderScene( currentRenderList, scene, camera );
30748
31293
  }
30749
31294
  if ( _currentRenderTarget !== null && _currentActiveMipmapLevel === 0 ) {
30750
31295
  textures.updateMultisampleRenderTarget( _currentRenderTarget );
30751
31296
  textures.updateRenderTargetMipmap( _currentRenderTarget );
30752
31297
  }
31298
+ if ( useOutput ) {
31299
+ output.end( _this );
31300
+ }
30753
31301
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
30754
31302
  bindingStates.resetDefaultState();
30755
31303
  _currentMaterialId = -1;
@@ -30830,9 +31378,7 @@ void main() {
30830
31378
  }
30831
31379
  }
30832
31380
  function renderScene( currentRenderList, scene, camera, viewport ) {
30833
- const opaqueObjects = currentRenderList.opaque;
30834
- const transmissiveObjects = currentRenderList.transmissive;
30835
- const transparentObjects = currentRenderList.transparent;
31381
+ const { opaque: opaqueObjects, transmissive: transmissiveObjects, transparent: transparentObjects } = currentRenderList;
30836
31382
  currentRenderState.setupLightsView( camera );
30837
31383
  if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
30838
31384
  if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
@@ -30850,11 +31396,12 @@ void main() {
30850
31396
  return;
30851
31397
  }
30852
31398
  if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
31399
+ const hasHalfFloatSupport = extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' );
30853
31400
  currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
30854
31401
  generateMipmaps: true,
30855
- type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
31402
+ type: hasHalfFloatSupport ? HalfFloatType : UnsignedByteType,
30856
31403
  minFilter: LinearMipmapLinearFilter,
30857
- samples: 4,
31404
+ samples: capabilities.samples,
30858
31405
  stencilBuffer: stencil,
30859
31406
  resolveDepthBuffer: false,
30860
31407
  resolveStencilBuffer: false,
@@ -30886,10 +31433,7 @@ void main() {
30886
31433
  let renderTargetNeedsUpdate = false;
30887
31434
  for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
30888
31435
  const renderItem = transmissiveObjects[ i ];
30889
- const object = renderItem.object;
30890
- const geometry = renderItem.geometry;
30891
- const material = renderItem.material;
30892
- const group = renderItem.group;
31436
+ const { object, geometry, material, group } = renderItem;
30893
31437
  if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
30894
31438
  const currentSide = material.side;
30895
31439
  material.side = BackSide;
@@ -30914,9 +31458,7 @@ void main() {
30914
31458
  const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
30915
31459
  for ( let i = 0, l = renderList.length; i < l; i ++ ) {
30916
31460
  const renderItem = renderList[ i ];
30917
- const object = renderItem.object;
30918
- const geometry = renderItem.geometry;
30919
- const group = renderItem.group;
31461
+ const { object, geometry, group } = renderItem;
30920
31462
  let material = renderItem.material;
30921
31463
  if ( material.allowOverride === true && overrideMaterial !== null ) {
30922
31464
  material = overrideMaterial;
@@ -31168,6 +31710,17 @@ void main() {
31168
31710
  refreshLights = true;
31169
31711
  }
31170
31712
  }
31713
+ if ( materialProperties.needsLights ) {
31714
+ if ( lights.state.directionalShadowMap.length > 0 ) {
31715
+ p_uniforms.setValue( _gl, 'directionalShadowMap', lights.state.directionalShadowMap, textures );
31716
+ }
31717
+ if ( lights.state.spotShadowMap.length > 0 ) {
31718
+ p_uniforms.setValue( _gl, 'spotShadowMap', lights.state.spotShadowMap, textures );
31719
+ }
31720
+ if ( lights.state.pointShadowMap.length > 0 ) {
31721
+ p_uniforms.setValue( _gl, 'pointShadowMap', lights.state.pointShadowMap, textures );
31722
+ }
31723
+ }
31171
31724
  if ( object.isSkinnedMesh ) {
31172
31725
  p_uniforms.setOptional( _gl, object, 'bindMatrix' );
31173
31726
  p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );
@@ -31202,6 +31755,9 @@ void main() {
31202
31755
  if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
31203
31756
  m_uniforms.envMapIntensity.value = scene.environmentIntensity;
31204
31757
  }
31758
+ if ( m_uniforms.dfgLUT !== undefined ) {
31759
+ m_uniforms.dfgLUT.value = getDFGLUT();
31760
+ }
31205
31761
  if ( refreshMaterial ) {
31206
31762
  p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
31207
31763
  if ( materialProperties.needsLights ) {
@@ -31279,15 +31835,21 @@ void main() {
31279
31835
  _currentRenderTarget = renderTarget;
31280
31836
  _currentActiveCubeFace = activeCubeFace;
31281
31837
  _currentActiveMipmapLevel = activeMipmapLevel;
31282
- let useDefaultFramebuffer = true;
31283
31838
  let framebuffer = null;
31284
31839
  let isCube = false;
31285
31840
  let isRenderTarget3D = false;
31286
31841
  if ( renderTarget ) {
31287
31842
  const renderTargetProperties = properties.get( renderTarget );
31288
31843
  if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
31289
- state.bindFramebuffer( _gl.FRAMEBUFFER, null );
31290
- useDefaultFramebuffer = false;
31844
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
31845
+ _currentViewport.copy( renderTarget.viewport );
31846
+ _currentScissor.copy( renderTarget.scissor );
31847
+ _currentScissorTest = renderTarget.scissorTest;
31848
+ state.viewport( _currentViewport );
31849
+ state.scissor( _currentScissor );
31850
+ state.setScissorTest( _currentScissorTest );
31851
+ _currentMaterialId = -1;
31852
+ return;
31291
31853
  } else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
31292
31854
  textures.setupRenderTarget( renderTarget );
31293
31855
  } else if ( renderTargetProperties.__hasExternalTextures ) {
@@ -31338,7 +31900,7 @@ void main() {
31338
31900
  framebuffer = _scratchFrameBuffer;
31339
31901
  }
31340
31902
  const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
31341
- if ( framebufferBound && useDefaultFramebuffer ) {
31903
+ if ( framebufferBound ) {
31342
31904
  state.drawBuffers( renderTarget, framebuffer );
31343
31905
  }
31344
31906
  state.viewport( _currentViewport );
@@ -31361,7 +31923,7 @@ void main() {
31361
31923
  };
31362
31924
  this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
31363
31925
  if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
31364
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
31926
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
31365
31927
  return;
31366
31928
  }
31367
31929
  let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
@@ -31375,11 +31937,11 @@ void main() {
31375
31937
  const textureFormat = texture.format;
31376
31938
  const textureType = texture.type;
31377
31939
  if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
31378
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
31940
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
31379
31941
  return;
31380
31942
  }
31381
31943
  if ( ! capabilities.textureTypeReadable( textureType ) ) {
31382
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
31944
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
31383
31945
  return;
31384
31946
  }
31385
31947
  if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
@@ -31695,6 +32257,7 @@ void main() {
31695
32257
  ConstantColorFactor: ConstantColorFactor,
31696
32258
  Controls: Controls,
31697
32259
  CubeCamera: CubeCamera,
32260
+ CubeDepthTexture: CubeDepthTexture,
31698
32261
  CubeReflectionMapping: CubeReflectionMapping,
31699
32262
  CubeRefractionMapping: CubeRefractionMapping,
31700
32263
  CubeTexture: CubeTexture,
@@ -31864,9 +32427,12 @@ void main() {
31864
32427
  NeverStencilFunc: NeverStencilFunc,
31865
32428
  NoBlending: NoBlending,
31866
32429
  NoColorSpace: NoColorSpace,
32430
+ NoNormalPacking: NoNormalPacking,
31867
32431
  NoToneMapping: NoToneMapping,
31868
32432
  NormalAnimationBlendMode: NormalAnimationBlendMode,
31869
32433
  NormalBlending: NormalBlending,
32434
+ NormalGAPacking: NormalGAPacking,
32435
+ NormalRGPacking: NormalRGPacking,
31870
32436
  NotEqualCompare: NotEqualCompare,
31871
32437
  NotEqualDepth: NotEqualDepth,
31872
32438
  NotEqualStencilFunc: NotEqualStencilFunc,
@@ -31905,9 +32471,11 @@ void main() {
31905
32471
  Quaternion: Quaternion,
31906
32472
  QuaternionKeyframeTrack: QuaternionKeyframeTrack,
31907
32473
  QuaternionLinearInterpolant: QuaternionLinearInterpolant,
32474
+ R11_EAC_Format: R11_EAC_Format,
31908
32475
  RED_GREEN_RGTC2_Format: RED_GREEN_RGTC2_Format,
31909
32476
  RED_RGTC1_Format: RED_RGTC1_Format,
31910
32477
  REVISION: REVISION,
32478
+ RG11_EAC_Format: RG11_EAC_Format,
31911
32479
  RGBADepthPacking: RGBADepthPacking,
31912
32480
  RGBAFormat: RGBAFormat,
31913
32481
  RGBAIntegerFormat: RGBAIntegerFormat,
@@ -31958,8 +32526,10 @@ void main() {
31958
32526
  ReplaceStencilOp: ReplaceStencilOp,
31959
32527
  ReverseSubtractEquation: ReverseSubtractEquation,
31960
32528
  RingGeometry: RingGeometry,
32529
+ SIGNED_R11_EAC_Format: SIGNED_R11_EAC_Format,
31961
32530
  SIGNED_RED_GREEN_RGTC2_Format: SIGNED_RED_GREEN_RGTC2_Format,
31962
32531
  SIGNED_RED_RGTC1_Format: SIGNED_RED_RGTC1_Format,
32532
+ SIGNED_RG11_EAC_Format: SIGNED_RG11_EAC_Format,
31963
32533
  SRGBColorSpace: SRGBColorSpace,
31964
32534
  SRGBTransfer: SRGBTransfer,
31965
32535
  Scene: Scene,
@@ -32052,7 +32622,13 @@ void main() {
32052
32622
  ZeroFactor: ZeroFactor,
32053
32623
  ZeroSlopeEnding: ZeroSlopeEnding,
32054
32624
  ZeroStencilOp: ZeroStencilOp,
32055
- createCanvasElement: createCanvasElement
32625
+ createCanvasElement: createCanvasElement,
32626
+ error: error,
32627
+ getConsoleFunction: getConsoleFunction,
32628
+ log: log,
32629
+ setConsoleFunction: setConsoleFunction,
32630
+ warn: warn,
32631
+ warnOnce: warnOnce
32056
32632
  });
32057
32633
 
32058
32634
  const _raycaster = new Raycaster();
@@ -38894,16 +39470,14 @@ void main() {
38894
39470
  const transformedBox = node.geometryExtents.clone();
38895
39471
  const structureRoot = node.structure ? this.structureRoots.get(node.structure.id) : null;
38896
39472
  if (node.group) {
38897
- const matrices = [];
38898
- let currentGroup = node.group;
38899
- while (currentGroup && currentGroup !== structureRoot) {
38900
- if (currentGroup.matrix && currentGroup.matrixAutoUpdate === false) {
38901
- matrices.unshift(currentGroup.matrix);
38902
- }
38903
- currentGroup = currentGroup.parent;
39473
+ const relativeMatrix = new Matrix4();
39474
+ let currentObject = node.group;
39475
+ while (currentObject && currentObject !== structureRoot) {
39476
+ relativeMatrix.premultiply(currentObject.matrix);
39477
+ currentObject = currentObject.parent;
38904
39478
  }
38905
- for (const matrix of matrices) {
38906
- transformedBox.applyMatrix4(matrix);
39479
+ if (!relativeMatrix.equals(new Matrix4())) {
39480
+ transformedBox.applyMatrix4(relativeMatrix);
38907
39481
  }
38908
39482
  }
38909
39483
  if (structureRoot && structureRoot.matrix) {
@@ -39356,6 +39930,15 @@ void main() {
39356
39930
  let currentVertexOffset = 0;
39357
39931
  for (const mesh of group.objects) {
39358
39932
  const geometry = mesh.geometry.clone();
39933
+ const relativeMatrix = new Matrix4();
39934
+ let currentObject = mesh;
39935
+ while (currentObject && currentObject !== rootGroup) {
39936
+ relativeMatrix.premultiply(currentObject.matrix);
39937
+ currentObject = currentObject.parent;
39938
+ }
39939
+ if (!relativeMatrix.equals(new Matrix4())) {
39940
+ geometry.applyMatrix4(relativeMatrix);
39941
+ }
39359
39942
  const handle = mesh.userData.handle;
39360
39943
  if (!this.objectIdToIndex.has(handle)) {
39361
39944
  this.objectIdToIndex.set(handle, this.maxObjectId++);
@@ -39450,7 +40033,16 @@ void main() {
39450
40033
  let isEdge = false;
39451
40034
  group.objects.forEach((line) => {
39452
40035
  isEdge = line.userData.isEdge;
39453
- const geometry = line.geometry;
40036
+ const geometry = line.geometry.clone();
40037
+ const relativeMatrix = new Matrix4();
40038
+ let currentObject = line;
40039
+ while (currentObject && currentObject !== rootGroup) {
40040
+ relativeMatrix.premultiply(currentObject.matrix);
40041
+ currentObject = currentObject.parent;
40042
+ }
40043
+ if (!relativeMatrix.equals(new Matrix4())) {
40044
+ geometry.applyMatrix4(relativeMatrix);
40045
+ }
39454
40046
  const positionAttr = geometry.attributes.position;
39455
40047
  const vertexCount = positionAttr.count;
39456
40048
  const handle = line.userData.handle;
@@ -39473,6 +40065,7 @@ void main() {
39473
40065
  indices.push(vertexOffset + i, vertexOffset + i + 1);
39474
40066
  }
39475
40067
  vertexOffset += vertexCount;
40068
+ geometry.dispose();
39476
40069
  });
39477
40070
  const geometry = new BufferGeometry();
39478
40071
  geometry.setAttribute("position", new BufferAttribute(positions, 3));
@@ -39544,6 +40137,15 @@ void main() {
39544
40137
  for (const line of group.objects) {
39545
40138
  isEdge = line.userData.isEdge;
39546
40139
  const geometry = line.geometry.clone();
40140
+ const relativeMatrix = new Matrix4();
40141
+ let currentObject = line;
40142
+ while (currentObject && currentObject !== rootGroup) {
40143
+ relativeMatrix.premultiply(currentObject.matrix);
40144
+ currentObject = currentObject.parent;
40145
+ }
40146
+ if (!relativeMatrix.equals(new Matrix4())) {
40147
+ geometry.applyMatrix4(relativeMatrix);
40148
+ }
39547
40149
  const handle = line.userData.handle;
39548
40150
  if (!this.objectIdToIndex.has(handle)) {
39549
40151
  this.objectIdToIndex.set(handle, this.maxObjectId++);
@@ -39629,6 +40231,15 @@ void main() {
39629
40231
  const handles = new Set();
39630
40232
  for (const points of group.objects) {
39631
40233
  const geometry = points.geometry.clone();
40234
+ const relativeMatrix = new Matrix4();
40235
+ let currentObject = points;
40236
+ while (currentObject && currentObject !== rootGroup) {
40237
+ relativeMatrix.premultiply(currentObject.matrix);
40238
+ currentObject = currentObject.parent;
40239
+ }
40240
+ if (!relativeMatrix.equals(new Matrix4())) {
40241
+ geometry.applyMatrix4(relativeMatrix);
40242
+ }
39632
40243
  geometries.push(geometry);
39633
40244
  optimizedObjects.push(points);
39634
40245
  handles.add(points.userData.handle);
@@ -41941,6 +42552,7 @@ void main() {
41941
42552
  this.clear = true;
41942
42553
  this.clearDepth = false;
41943
42554
  this.needsSwap = false;
42555
+ this.isRenderPass = true;
41944
42556
  this._oldClearColor = new Color();
41945
42557
  }
41946
42558
  render( renderer, writeBuffer, readBuffer ) {
@@ -43059,6 +43671,7 @@ void main() {
43059
43671
  class OutputPass extends Pass {
43060
43672
  constructor() {
43061
43673
  super();
43674
+ this.isOutputPass = true;
43062
43675
  this.uniforms = UniformsUtils.clone( OutputShader.uniforms );
43063
43676
  this.material = new RawShaderMaterial( {
43064
43677
  name: OutputShader.name,