@inweb/viewer-three 27.1.2 → 27.1.4

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.
@@ -251,6 +251,8 @@
251
251
  rulerUnit: "Default",
252
252
  rulerPrecision: 2,
253
253
  cameraMode: "perspective",
254
+ snapshotMimeType: "image/jpeg",
255
+ snapshotQuality: 0.25,
254
256
  };
255
257
  }
256
258
  class Options {
@@ -592,7 +594,7 @@
592
594
  * Copyright 2010-2025 Three.js Authors
593
595
  * SPDX-License-Identifier: MIT
594
596
  */
595
- const REVISION = '180';
597
+ const REVISION = '182';
596
598
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
597
599
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
598
600
  const CullFaceNone = 0;
@@ -707,6 +709,10 @@
707
709
  const RGB_ETC1_Format = 36196;
708
710
  const RGB_ETC2_Format = 37492;
709
711
  const RGBA_ETC2_EAC_Format = 37496;
712
+ const R11_EAC_Format = 37488;
713
+ const SIGNED_R11_EAC_Format = 37489;
714
+ const RG11_EAC_Format = 37490;
715
+ const SIGNED_RG11_EAC_Format = 37491;
710
716
  const RGBA_ASTC_4x4_Format = 37808;
711
717
  const RGBA_ASTC_5x4_Format = 37809;
712
718
  const RGBA_ASTC_5x5_Format = 37810;
@@ -753,6 +759,9 @@
753
759
  const LinearSRGBColorSpace = 'srgb-linear';
754
760
  const LinearTransfer = 'linear';
755
761
  const SRGBTransfer = 'srgb';
762
+ const NoNormalPacking = '';
763
+ const NormalRGPacking = 'rg';
764
+ const NormalGAPacking = 'ga';
756
765
  const ZeroStencilOp = 0;
757
766
  const KeepStencilOp = 7680;
758
767
  const ReplaceStencilOp = 7681;
@@ -806,6 +815,92 @@
806
815
  FIRST: 'first',
807
816
  EITHER: 'either'
808
817
  };
818
+ function arrayNeedsUint32( array ) {
819
+ for ( let i = array.length - 1; i >= 0; -- i ) {
820
+ if ( array[ i ] >= 65535 ) return true;
821
+ }
822
+ return false;
823
+ }
824
+ const TYPED_ARRAYS = {
825
+ Int8Array: Int8Array,
826
+ Uint8Array: Uint8Array,
827
+ Uint8ClampedArray: Uint8ClampedArray,
828
+ Int16Array: Int16Array,
829
+ Uint16Array: Uint16Array,
830
+ Int32Array: Int32Array,
831
+ Uint32Array: Uint32Array,
832
+ Float32Array: Float32Array,
833
+ Float64Array: Float64Array
834
+ };
835
+ function getTypedArray( type, buffer ) {
836
+ return new TYPED_ARRAYS[ type ]( buffer );
837
+ }
838
+ function isTypedArray( array ) {
839
+ return ArrayBuffer.isView( array ) && ! ( array instanceof DataView );
840
+ }
841
+ function createElementNS( name ) {
842
+ return document.createElementNS( 'http://www.w3.org/1999/xhtml', name );
843
+ }
844
+ function createCanvasElement() {
845
+ const canvas = createElementNS( 'canvas' );
846
+ canvas.style.display = 'block';
847
+ return canvas;
848
+ }
849
+ const _cache = {};
850
+ let _setConsoleFunction = null;
851
+ function setConsoleFunction( fn ) {
852
+ _setConsoleFunction = fn;
853
+ }
854
+ function getConsoleFunction() {
855
+ return _setConsoleFunction;
856
+ }
857
+ function log( ...params ) {
858
+ const message = 'THREE.' + params.shift();
859
+ if ( _setConsoleFunction ) {
860
+ _setConsoleFunction( 'log', message, ...params );
861
+ } else {
862
+ console.log( message, ...params );
863
+ }
864
+ }
865
+ function warn( ...params ) {
866
+ const message = 'THREE.' + params.shift();
867
+ if ( _setConsoleFunction ) {
868
+ _setConsoleFunction( 'warn', message, ...params );
869
+ } else {
870
+ console.warn( message, ...params );
871
+ }
872
+ }
873
+ function error( ...params ) {
874
+ const message = 'THREE.' + params.shift();
875
+ if ( _setConsoleFunction ) {
876
+ _setConsoleFunction( 'error', message, ...params );
877
+ } else {
878
+ console.error( message, ...params );
879
+ }
880
+ }
881
+ function warnOnce( ...params ) {
882
+ const message = params.join( ' ' );
883
+ if ( message in _cache ) return;
884
+ _cache[ message ] = true;
885
+ warn( ...params );
886
+ }
887
+ function probeAsync( gl, sync, interval ) {
888
+ return new Promise( function ( resolve, reject ) {
889
+ function probe() {
890
+ switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
891
+ case gl.WAIT_FAILED:
892
+ reject();
893
+ break;
894
+ case gl.TIMEOUT_EXPIRED:
895
+ setTimeout( probe, interval );
896
+ break;
897
+ default:
898
+ resolve();
899
+ }
900
+ }
901
+ setTimeout( probe, interval );
902
+ } );
903
+ }
809
904
  class EventDispatcher {
810
905
  addEventListener( type, listener ) {
811
906
  if ( this._listeners === undefined ) this._listeners = {};
@@ -961,7 +1056,7 @@
961
1056
  q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );
962
1057
  break;
963
1058
  default:
964
- console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
1059
+ warn( 'MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );
965
1060
  }
966
1061
  }
967
1062
  function denormalize( value, array ) {
@@ -1298,18 +1393,18 @@
1298
1393
  y0 = src0[ srcOffset0 + 1 ],
1299
1394
  z0 = src0[ srcOffset0 + 2 ],
1300
1395
  w0 = src0[ srcOffset0 + 3 ];
1301
- const x1 = src1[ srcOffset1 + 0 ],
1396
+ let x1 = src1[ srcOffset1 + 0 ],
1302
1397
  y1 = src1[ srcOffset1 + 1 ],
1303
1398
  z1 = src1[ srcOffset1 + 2 ],
1304
1399
  w1 = src1[ srcOffset1 + 3 ];
1305
- if ( t === 0 ) {
1400
+ if ( t <= 0 ) {
1306
1401
  dst[ dstOffset + 0 ] = x0;
1307
1402
  dst[ dstOffset + 1 ] = y0;
1308
1403
  dst[ dstOffset + 2 ] = z0;
1309
1404
  dst[ dstOffset + 3 ] = w0;
1310
1405
  return;
1311
1406
  }
1312
- if ( t === 1 ) {
1407
+ if ( t >= 1 ) {
1313
1408
  dst[ dstOffset + 0 ] = x1;
1314
1409
  dst[ dstOffset + 1 ] = y1;
1315
1410
  dst[ dstOffset + 2 ] = z1;
@@ -1317,22 +1412,29 @@
1317
1412
  return;
1318
1413
  }
1319
1414
  if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
1415
+ let dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
1416
+ if ( dot < 0 ) {
1417
+ x1 = - x1;
1418
+ y1 = - y1;
1419
+ z1 = - z1;
1420
+ w1 = - w1;
1421
+ dot = - dot;
1422
+ }
1320
1423
  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 ) {
1424
+ if ( dot < 0.9995 ) {
1425
+ const theta = Math.acos( dot );
1426
+ const sin = Math.sin( theta );
1427
+ s = Math.sin( s * theta ) / sin;
1428
+ t = Math.sin( t * theta ) / sin;
1429
+ x0 = x0 * s + x1 * t;
1430
+ y0 = y0 * s + y1 * t;
1431
+ z0 = z0 * s + z1 * t;
1432
+ w0 = w0 * s + w1 * t;
1433
+ } else {
1434
+ x0 = x0 * s + x1 * t;
1435
+ y0 = y0 * s + y1 * t;
1436
+ z0 = z0 * s + z1 * t;
1437
+ w0 = w0 * s + w1 * t;
1336
1438
  const f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
1337
1439
  x0 *= f;
1338
1440
  y0 *= f;
@@ -1455,7 +1557,7 @@
1455
1557
  this._w = c1 * c2 * c3 + s1 * s2 * s3;
1456
1558
  break;
1457
1559
  default:
1458
- console.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order );
1560
+ warn( 'Quaternion: .setFromEuler() encountered an unknown order: ' + order );
1459
1561
  }
1460
1562
  if ( update === true ) this._onChangeCallback();
1461
1563
  return this;
@@ -1592,45 +1694,35 @@
1592
1694
  return this;
1593
1695
  }
1594
1696
  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;
1697
+ if ( t <= 0 ) return this;
1698
+ if ( t >= 1 ) return this.copy( qb );
1699
+ let x = qb._x, y = qb._y, z = qb._z, w = qb._w;
1700
+ let dot = this.dot( qb );
1701
+ if ( dot < 0 ) {
1702
+ x = - x;
1703
+ y = - y;
1704
+ z = - z;
1705
+ w = - w;
1706
+ dot = - dot;
1707
+ }
1708
+ let s = 1 - t;
1709
+ if ( dot < 0.9995 ) {
1710
+ const theta = Math.acos( dot );
1711
+ const sin = Math.sin( theta );
1712
+ s = Math.sin( s * theta ) / sin;
1713
+ t = Math.sin( t * theta ) / sin;
1714
+ this._x = this._x * s + x * t;
1715
+ this._y = this._y * s + y * t;
1716
+ this._z = this._z * s + z * t;
1717
+ this._w = this._w * s + w * t;
1718
+ this._onChangeCallback();
1605
1719
  } 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;
1720
+ this._x = this._x * s + x * t;
1721
+ this._y = this._y * s + y * t;
1722
+ this._z = this._z * s + z * t;
1723
+ this._w = this._w * s + w * t;
1622
1724
  this.normalize();
1623
- return this;
1624
1725
  }
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
1726
  return this;
1635
1727
  }
1636
1728
  slerpQuaternions( qa, qb, t ) {
@@ -2318,57 +2410,6 @@
2318
2410
  }
2319
2411
  }
2320
2412
  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
2413
  const LINEAR_REC709_TO_XYZ = new Matrix3().set(
2373
2414
  0.4123908, 0.3575843, 0.1804808,
2374
2415
  0.2126390, 0.7151687, 0.0721923,
@@ -2438,11 +2479,11 @@
2438
2479
  return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
2439
2480
  },
2440
2481
  fromWorkingColorSpace: function ( color, targetColorSpace ) {
2441
- warnOnce( 'THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().' );
2482
+ warnOnce( 'ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().' );
2442
2483
  return ColorManagement.workingToColorSpace( color, targetColorSpace );
2443
2484
  },
2444
2485
  toWorkingColorSpace: function ( color, sourceColorSpace ) {
2445
- warnOnce( 'THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().' );
2486
+ warnOnce( 'ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().' );
2446
2487
  return ColorManagement.colorSpaceToWorking( color, sourceColorSpace );
2447
2488
  },
2448
2489
  };
@@ -2536,7 +2577,7 @@
2536
2577
  height: image.height
2537
2578
  };
2538
2579
  } else {
2539
- console.warn( 'THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );
2580
+ warn( 'ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );
2540
2581
  return image;
2541
2582
  }
2542
2583
  }
@@ -2555,7 +2596,7 @@
2555
2596
  const data = this.data;
2556
2597
  if ( ( typeof HTMLVideoElement !== 'undefined' ) && ( data instanceof HTMLVideoElement ) ) {
2557
2598
  target.set( data.videoWidth, data.videoHeight, 0 );
2558
- } else if ( data instanceof VideoFrame ) {
2599
+ } else if ( ( typeof VideoFrame !== 'undefined' ) && ( data instanceof VideoFrame ) ) {
2559
2600
  target.set( data.displayHeight, data.displayWidth, 0 );
2560
2601
  } else if ( data !== null ) {
2561
2602
  target.set( data.width, data.height, data.depth || 0 );
@@ -2613,7 +2654,7 @@
2613
2654
  type: image.data.constructor.name
2614
2655
  };
2615
2656
  } else {
2616
- console.warn( 'THREE.Texture: Unable to serialize Texture.' );
2657
+ warn( 'Texture: Unable to serialize Texture.' );
2617
2658
  return {};
2618
2659
  }
2619
2660
  }
@@ -2722,12 +2763,12 @@
2722
2763
  for ( const key in values ) {
2723
2764
  const newValue = values[ key ];
2724
2765
  if ( newValue === undefined ) {
2725
- console.warn( `THREE.Texture.setValues(): parameter '${ key }' has value of undefined.` );
2766
+ warn( `Texture.setValues(): parameter '${ key }' has value of undefined.` );
2726
2767
  continue;
2727
2768
  }
2728
2769
  const currentValue = this[ key ];
2729
2770
  if ( currentValue === undefined ) {
2730
- console.warn( `THREE.Texture.setValues(): property '${ key }' does not exist.` );
2771
+ warn( `Texture.setValues(): property '${ key }' does not exist.` );
2731
2772
  continue;
2732
2773
  }
2733
2774
  if ( ( currentValue && newValue ) && ( currentValue.isVector2 && newValue.isVector2 ) ) {
@@ -3320,7 +3361,9 @@
3320
3361
  this.textures[ i ].image.width = width;
3321
3362
  this.textures[ i ].image.height = height;
3322
3363
  this.textures[ i ].image.depth = depth;
3323
- this.textures[ i ].isArrayTexture = this.textures[ i ].image.depth > 1;
3364
+ if ( this.textures[ i ].isData3DTexture !== true ) {
3365
+ this.textures[ i ].isArrayTexture = this.textures[ i ].image.depth > 1;
3366
+ }
3324
3367
  }
3325
3368
  this.dispose();
3326
3369
  }
@@ -4142,6 +4185,12 @@
4142
4185
  return this;
4143
4186
  }
4144
4187
  extractBasis( xAxis, yAxis, zAxis ) {
4188
+ if ( this.determinant() === 0 ) {
4189
+ xAxis.set( 1, 0, 0 );
4190
+ yAxis.set( 0, 1, 0 );
4191
+ zAxis.set( 0, 0, 1 );
4192
+ return this;
4193
+ }
4145
4194
  xAxis.setFromMatrixColumn( this, 0 );
4146
4195
  yAxis.setFromMatrixColumn( this, 1 );
4147
4196
  zAxis.setFromMatrixColumn( this, 2 );
@@ -4157,6 +4206,9 @@
4157
4206
  return this;
4158
4207
  }
4159
4208
  extractRotation( m ) {
4209
+ if ( m.determinant() === 0 ) {
4210
+ return this.identity();
4211
+ }
4160
4212
  const te = this.elements;
4161
4213
  const me = m.elements;
4162
4214
  const scaleX = 1 / _v1$5.setFromMatrixColumn( m, 0 ).length();
@@ -4339,40 +4391,16 @@
4339
4391
  const n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];
4340
4392
  const n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];
4341
4393
  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
- );
4394
+ const t11 = n23 * n34 - n24 * n33;
4395
+ const t12 = n22 * n34 - n24 * n32;
4396
+ const t13 = n22 * n33 - n23 * n32;
4397
+ const t21 = n21 * n34 - n24 * n31;
4398
+ const t22 = n21 * n33 - n23 * n31;
4399
+ const t23 = n21 * n32 - n22 * n31;
4400
+ return n11 * ( n42 * t11 - n43 * t12 + n44 * t13 ) -
4401
+ n12 * ( n41 * t11 - n43 * t21 + n44 * t22 ) +
4402
+ n13 * ( n41 * t12 - n42 * t21 + n44 * t23 ) -
4403
+ n14 * ( n41 * t13 - n42 * t22 + n43 * t23 );
4376
4404
  }
4377
4405
  transpose() {
4378
4406
  const te = this.elements;
@@ -4553,14 +4581,19 @@
4553
4581
  }
4554
4582
  decompose( position, quaternion, scale ) {
4555
4583
  const te = this.elements;
4584
+ position.x = te[ 12 ];
4585
+ position.y = te[ 13 ];
4586
+ position.z = te[ 14 ];
4587
+ if ( this.determinant() === 0 ) {
4588
+ scale.set( 1, 1, 1 );
4589
+ quaternion.identity();
4590
+ return this;
4591
+ }
4556
4592
  let sx = _v1$5.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
4557
4593
  const sy = _v1$5.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
4558
4594
  const sz = _v1$5.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
4559
4595
  const det = this.determinant();
4560
4596
  if ( det < 0 ) sx = - sx;
4561
- position.x = te[ 12 ];
4562
- position.y = te[ 13 ];
4563
- position.z = te[ 14 ];
4564
4597
  _m1$2.copy( this );
4565
4598
  const invSX = 1 / sx;
4566
4599
  const invSY = 1 / sy;
@@ -4800,7 +4833,7 @@
4800
4833
  }
4801
4834
  break;
4802
4835
  default:
4803
- console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );
4836
+ warn( 'Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );
4804
4837
  }
4805
4838
  this._order = order;
4806
4839
  if ( update === true ) this._onChangeCallback();
@@ -5054,7 +5087,7 @@
5054
5087
  return this;
5055
5088
  }
5056
5089
  if ( object === this ) {
5057
- console.error( 'THREE.Object3D.add: object can\'t be added as a child of itself.', object );
5090
+ error( 'Object3D.add: object can\'t be added as a child of itself.', object );
5058
5091
  return this;
5059
5092
  }
5060
5093
  if ( object && object.isObject3D ) {
@@ -5066,7 +5099,7 @@
5066
5099
  this.dispatchEvent( _childaddedEvent );
5067
5100
  _childaddedEvent.child = null;
5068
5101
  } else {
5069
- console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object );
5102
+ error( 'Object3D.add: object not an instance of THREE.Object3D.', object );
5070
5103
  }
5071
5104
  return this;
5072
5105
  }
@@ -5717,7 +5750,7 @@
5717
5750
  function handleAlpha( string ) {
5718
5751
  if ( string === undefined ) return;
5719
5752
  if ( parseFloat( string ) < 1 ) {
5720
- console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );
5753
+ warn( 'Color: Alpha component of ' + style + ' will be ignored.' );
5721
5754
  }
5722
5755
  }
5723
5756
  let m;
@@ -5760,7 +5793,7 @@
5760
5793
  }
5761
5794
  break;
5762
5795
  default:
5763
- console.warn( 'THREE.Color: Unknown color model ' + style );
5796
+ warn( 'Color: Unknown color model ' + style );
5764
5797
  }
5765
5798
  } else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) {
5766
5799
  const hex = m[ 1 ];
@@ -5775,7 +5808,7 @@
5775
5808
  } else if ( size === 6 ) {
5776
5809
  return this.setHex( parseInt( hex, 16 ), colorSpace );
5777
5810
  } else {
5778
- console.warn( 'THREE.Color: Invalid hex color ' + style );
5811
+ warn( 'Color: Invalid hex color ' + style );
5779
5812
  }
5780
5813
  } else if ( style && style.length > 0 ) {
5781
5814
  return this.setColorName( style, colorSpace );
@@ -5787,7 +5820,7 @@
5787
5820
  if ( hex !== undefined ) {
5788
5821
  this.setHex( hex, colorSpace );
5789
5822
  } else {
5790
- console.warn( 'THREE.Color: Unknown color ' + style );
5823
+ warn( 'Color: Unknown color ' + style );
5791
5824
  }
5792
5825
  return this;
5793
5826
  }
@@ -6047,12 +6080,12 @@
6047
6080
  for ( const key in values ) {
6048
6081
  const newValue = values[ key ];
6049
6082
  if ( newValue === undefined ) {
6050
- console.warn( `THREE.Material: parameter '${ key }' has value of undefined.` );
6083
+ warn( `Material: parameter '${ key }' has value of undefined.` );
6051
6084
  continue;
6052
6085
  }
6053
6086
  const currentValue = this[ key ];
6054
6087
  if ( currentValue === undefined ) {
6055
- console.warn( `THREE.Material: '${ key }' is not a property of THREE.${ this.type }.` );
6088
+ warn( `Material: '${ key }' is not a property of THREE.${ this.type }.` );
6056
6089
  continue;
6057
6090
  }
6058
6091
  if ( currentValue && currentValue.isColor ) {
@@ -6217,6 +6250,7 @@
6217
6250
  if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
6218
6251
  if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
6219
6252
  if ( this.forceSinglePass === true ) data.forceSinglePass = true;
6253
+ if ( this.allowOverride === false ) data.allowOverride = false;
6220
6254
  if ( this.wireframe === true ) data.wireframe = true;
6221
6255
  if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
6222
6256
  if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
@@ -6296,6 +6330,7 @@
6296
6330
  this.alphaToCoverage = source.alphaToCoverage;
6297
6331
  this.premultipliedAlpha = source.premultipliedAlpha;
6298
6332
  this.forceSinglePass = source.forceSinglePass;
6333
+ this.allowOverride = source.allowOverride;
6299
6334
  this.visible = source.visible;
6300
6335
  this.toneMapped = source.toneMapped;
6301
6336
  this.userData = JSON.parse( JSON.stringify( source.userData ) );
@@ -6434,7 +6469,7 @@
6434
6469
  };
6435
6470
  }
6436
6471
  function toHalfFloat( val ) {
6437
- if ( Math.abs( val ) > 65504 ) console.warn( 'THREE.DataUtils.toHalfFloat(): Value out of range.' );
6472
+ if ( Math.abs( val ) > 65504 ) warn( 'DataUtils.toHalfFloat(): Value out of range.' );
6438
6473
  val = clamp( val, -65504, 65504 );
6439
6474
  _tables.floatView[ 0 ] = val;
6440
6475
  const f = _tables.uint32View[ 0 ];
@@ -6798,6 +6833,7 @@
6798
6833
  this.type = 'BufferGeometry';
6799
6834
  this.index = null;
6800
6835
  this.indirect = null;
6836
+ this.indirectOffset = 0;
6801
6837
  this.attributes = {};
6802
6838
  this.morphAttributes = {};
6803
6839
  this.morphTargetsRelative = false;
@@ -6818,8 +6854,9 @@
6818
6854
  }
6819
6855
  return this;
6820
6856
  }
6821
- setIndirect( indirect ) {
6857
+ setIndirect( indirect, indirectOffset = 0 ) {
6822
6858
  this.indirect = indirect;
6859
+ this.indirectOffset = indirectOffset;
6823
6860
  return this;
6824
6861
  }
6825
6862
  getIndirect() {
@@ -6936,7 +6973,7 @@
6936
6973
  positionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );
6937
6974
  }
6938
6975
  if ( points.length > positionAttribute.count ) {
6939
- console.warn( 'THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );
6976
+ warn( 'BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );
6940
6977
  }
6941
6978
  positionAttribute.needsUpdate = true;
6942
6979
  }
@@ -6949,7 +6986,7 @@
6949
6986
  const position = this.attributes.position;
6950
6987
  const morphAttributesPosition = this.morphAttributes.position;
6951
6988
  if ( position && position.isGLBufferAttribute ) {
6952
- console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.', this );
6989
+ error( 'BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.', this );
6953
6990
  this.boundingBox.set(
6954
6991
  new Vector3( - Infinity, - Infinity, - Infinity ),
6955
6992
  new Vector3( + Infinity, + Infinity, + Infinity )
@@ -6977,7 +7014,7 @@
6977
7014
  this.boundingBox.makeEmpty();
6978
7015
  }
6979
7016
  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 );
7017
+ error( 'BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
6981
7018
  }
6982
7019
  }
6983
7020
  computeBoundingSphere() {
@@ -6987,7 +7024,7 @@
6987
7024
  const position = this.attributes.position;
6988
7025
  const morphAttributesPosition = this.morphAttributes.position;
6989
7026
  if ( position && position.isGLBufferAttribute ) {
6990
- console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.', this );
7027
+ error( 'BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.', this );
6991
7028
  this.boundingSphere.set( new Vector3(), Infinity );
6992
7029
  return;
6993
7030
  }
@@ -7031,7 +7068,7 @@
7031
7068
  }
7032
7069
  this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
7033
7070
  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 );
7071
+ error( 'BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this );
7035
7072
  }
7036
7073
  }
7037
7074
  }
@@ -7042,7 +7079,7 @@
7042
7079
  attributes.position === undefined ||
7043
7080
  attributes.normal === undefined ||
7044
7081
  attributes.uv === undefined ) {
7045
- console.error( 'THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' );
7082
+ error( 'BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' );
7046
7083
  return;
7047
7084
  }
7048
7085
  const positionAttribute = attributes.position;
@@ -7212,7 +7249,7 @@
7212
7249
  return new BufferAttribute( array2, itemSize, normalized );
7213
7250
  }
7214
7251
  if ( this.index === null ) {
7215
- console.warn( 'THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' );
7252
+ warn( 'BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' );
7216
7253
  return this;
7217
7254
  }
7218
7255
  const geometry2 = new BufferGeometry();
@@ -7678,7 +7715,7 @@
7678
7715
  property.isVector2 || property.isVector3 || property.isVector4 ||
7679
7716
  property.isTexture || property.isQuaternion ) ) {
7680
7717
  if ( property.isRenderTargetTexture ) {
7681
- console.warn( 'UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().' );
7718
+ warn( 'UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().' );
7682
7719
  dst[ u ][ p ] = null;
7683
7720
  } else {
7684
7721
  dst[ u ][ p ] = property.clone();
@@ -7769,6 +7806,9 @@
7769
7806
  this.clipping = source.clipping;
7770
7807
  this.extensions = Object.assign( {}, source.extensions );
7771
7808
  this.glslVersion = source.glslVersion;
7809
+ this.defaultAttributeValues = Object.assign( {}, source.defaultAttributeValues );
7810
+ this.index0AttributeName = source.index0AttributeName;
7811
+ this.uniformsNeedUpdate = source.uniformsNeedUpdate;
7772
7812
  return this;
7773
7813
  }
7774
7814
  toJSON( meta ) {
@@ -8682,7 +8722,7 @@
8682
8722
  }
8683
8723
  clone( data ) {
8684
8724
  if ( data === undefined ) {
8685
- console.log( 'THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.' );
8725
+ log( 'InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.' );
8686
8726
  const array = [];
8687
8727
  for ( let i = 0; i < this.count; i ++ ) {
8688
8728
  const index = i * this.data.stride + this.offset;
@@ -8703,7 +8743,7 @@
8703
8743
  }
8704
8744
  toJSON( data ) {
8705
8745
  if ( data === undefined ) {
8706
- console.log( 'THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.' );
8746
+ log( 'InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.' );
8707
8747
  const array = [];
8708
8748
  for ( let i = 0; i < this.count; i ++ ) {
8709
8749
  const index = i * this.data.stride + this.offset;
@@ -8797,7 +8837,7 @@
8797
8837
  }
8798
8838
  raycast( raycaster, intersects ) {
8799
8839
  if ( raycaster.camera === null ) {
8800
- console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' );
8840
+ error( 'Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' );
8801
8841
  }
8802
8842
  _worldScale.setFromMatrixScale( this.matrixWorld );
8803
8843
  _viewWorldMatrix.copy( raycaster.camera.matrixWorld );
@@ -9086,7 +9126,7 @@
9086
9126
  } else if ( this.bindMode === DetachedBindMode ) {
9087
9127
  this.bindMatrixInverse.copy( this.bindMatrix ).invert();
9088
9128
  } else {
9089
- console.warn( 'THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode );
9129
+ warn( 'SkinnedMesh: Unrecognized bindMode: ' + this.bindMode );
9090
9130
  }
9091
9131
  }
9092
9132
  applyBoneTransform( index, target ) {
@@ -9132,6 +9172,7 @@
9132
9172
  this.bones = bones.slice( 0 );
9133
9173
  this.boneInverses = boneInverses;
9134
9174
  this.boneMatrices = null;
9175
+ this.previousBoneMatrices = null;
9135
9176
  this.boneTexture = null;
9136
9177
  this.init();
9137
9178
  }
@@ -9143,7 +9184,7 @@
9143
9184
  this.calculateInverses();
9144
9185
  } else {
9145
9186
  if ( bones.length !== boneInverses.length ) {
9146
- console.warn( 'THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.' );
9187
+ warn( 'Skeleton: Number of inverse bone matrices does not match amount of bones.' );
9147
9188
  this.boneInverses = [];
9148
9189
  for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
9149
9190
  this.boneInverses.push( new Matrix4() );
@@ -9231,7 +9272,7 @@
9231
9272
  const uuid = json.bones[ i ];
9232
9273
  let bone = bones[ uuid ];
9233
9274
  if ( bone === undefined ) {
9234
- console.warn( 'THREE.Skeleton: No bone found with UUID:', uuid );
9275
+ warn( 'Skeleton: No bone found with UUID:', uuid );
9235
9276
  bone = new Bone();
9236
9277
  }
9237
9278
  this.bones.push( bone );
@@ -9624,7 +9665,7 @@
9624
9665
  return new this.constructor().copy( this );
9625
9666
  }
9626
9667
  }
9627
- const _projScreenMatrix$2 = new Matrix4();
9668
+ const _projScreenMatrix$1 = new Matrix4();
9628
9669
  const _frustum$1 = new Frustum();
9629
9670
  class FrustumArray {
9630
9671
  constructor() {
@@ -9636,12 +9677,12 @@
9636
9677
  }
9637
9678
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9638
9679
  const camera = cameraArray.cameras[ i ];
9639
- _projScreenMatrix$2.multiplyMatrices(
9680
+ _projScreenMatrix$1.multiplyMatrices(
9640
9681
  camera.projectionMatrix,
9641
9682
  camera.matrixWorldInverse
9642
9683
  );
9643
9684
  _frustum$1.setFromProjectionMatrix(
9644
- _projScreenMatrix$2,
9685
+ _projScreenMatrix$1,
9645
9686
  camera.coordinateSystem,
9646
9687
  camera.reversedDepth
9647
9688
  );
@@ -9657,12 +9698,12 @@
9657
9698
  }
9658
9699
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9659
9700
  const camera = cameraArray.cameras[ i ];
9660
- _projScreenMatrix$2.multiplyMatrices(
9701
+ _projScreenMatrix$1.multiplyMatrices(
9661
9702
  camera.projectionMatrix,
9662
9703
  camera.matrixWorldInverse
9663
9704
  );
9664
9705
  _frustum$1.setFromProjectionMatrix(
9665
- _projScreenMatrix$2,
9706
+ _projScreenMatrix$1,
9666
9707
  camera.coordinateSystem,
9667
9708
  camera.reversedDepth
9668
9709
  );
@@ -9678,12 +9719,12 @@
9678
9719
  }
9679
9720
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9680
9721
  const camera = cameraArray.cameras[ i ];
9681
- _projScreenMatrix$2.multiplyMatrices(
9722
+ _projScreenMatrix$1.multiplyMatrices(
9682
9723
  camera.projectionMatrix,
9683
9724
  camera.matrixWorldInverse
9684
9725
  );
9685
9726
  _frustum$1.setFromProjectionMatrix(
9686
- _projScreenMatrix$2,
9727
+ _projScreenMatrix$1,
9687
9728
  camera.coordinateSystem,
9688
9729
  camera.reversedDepth
9689
9730
  );
@@ -9699,12 +9740,12 @@
9699
9740
  }
9700
9741
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9701
9742
  const camera = cameraArray.cameras[ i ];
9702
- _projScreenMatrix$2.multiplyMatrices(
9743
+ _projScreenMatrix$1.multiplyMatrices(
9703
9744
  camera.projectionMatrix,
9704
9745
  camera.matrixWorldInverse
9705
9746
  );
9706
9747
  _frustum$1.setFromProjectionMatrix(
9707
- _projScreenMatrix$2,
9748
+ _projScreenMatrix$1,
9708
9749
  camera.coordinateSystem,
9709
9750
  camera.reversedDepth
9710
9751
  );
@@ -9720,12 +9761,12 @@
9720
9761
  }
9721
9762
  for ( let i = 0; i < cameraArray.cameras.length; i ++ ) {
9722
9763
  const camera = cameraArray.cameras[ i ];
9723
- _projScreenMatrix$2.multiplyMatrices(
9764
+ _projScreenMatrix$1.multiplyMatrices(
9724
9765
  camera.projectionMatrix,
9725
9766
  camera.matrixWorldInverse
9726
9767
  );
9727
9768
  _frustum$1.setFromProjectionMatrix(
9728
- _projScreenMatrix$2,
9769
+ _projScreenMatrix$1,
9729
9770
  camera.coordinateSystem,
9730
9771
  camera.reversedDepth
9731
9772
  );
@@ -10151,6 +10192,7 @@
10151
10192
  }
10152
10193
  index.array.copyWithin( nextIndexStart, indexStart, indexStart + reservedIndexCount );
10153
10194
  index.addUpdateRange( nextIndexStart, reservedIndexCount );
10195
+ index.needsUpdate = true;
10154
10196
  geometryInfo.indexStart = nextIndexStart;
10155
10197
  }
10156
10198
  nextIndexStart += geometryInfo.reservedIndexCount;
@@ -10163,6 +10205,7 @@
10163
10205
  const { array, itemSize } = attribute;
10164
10206
  array.copyWithin( nextVertexStart * itemSize, vertexStart * itemSize, ( vertexStart + reservedVertexCount ) * itemSize );
10165
10207
  attribute.addUpdateRange( nextVertexStart * itemSize, reservedVertexCount * itemSize );
10208
+ attribute.needsUpdate = true;
10166
10209
  }
10167
10210
  geometryInfo.vertexStart = nextVertexStart;
10168
10211
  }
@@ -10171,6 +10214,7 @@
10171
10214
  this._nextIndexStart = geometry.index ? geometryInfo.indexStart + geometryInfo.reservedIndexCount : 0;
10172
10215
  this._nextVertexStart = geometryInfo.vertexStart + geometryInfo.reservedVertexCount;
10173
10216
  }
10217
+ this._visibilityChanged = true;
10174
10218
  return this;
10175
10219
  }
10176
10220
  getBoundingBoxAt( geometryId, target ) {
@@ -10577,7 +10621,7 @@
10577
10621
  }
10578
10622
  geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
10579
10623
  } else {
10580
- console.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10624
+ warn( 'Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10581
10625
  }
10582
10626
  return this;
10583
10627
  }
@@ -10693,7 +10737,7 @@
10693
10737
  }
10694
10738
  geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );
10695
10739
  } else {
10696
- console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10740
+ warn( 'LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );
10697
10741
  }
10698
10742
  return this;
10699
10743
  }
@@ -10850,6 +10894,7 @@
10850
10894
  dispose() {
10851
10895
  if ( this._requestVideoFrameCallbackId !== 0 ) {
10852
10896
  this.source.data.cancelVideoFrameCallback( this._requestVideoFrameCallbackId );
10897
+ this._requestVideoFrameCallbackId = 0;
10853
10898
  }
10854
10899
  super.dispose();
10855
10900
  }
@@ -10942,6 +10987,22 @@
10942
10987
  return data;
10943
10988
  }
10944
10989
  }
10990
+ class CubeDepthTexture extends DepthTexture {
10991
+ constructor( size, type = UnsignedIntType, mapping = CubeReflectionMapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, format = DepthFormat ) {
10992
+ const image = { width: size, height: size, depth: 1 };
10993
+ const images = [ image, image, image, image, image, image ];
10994
+ super( size, size, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format );
10995
+ this.image = images;
10996
+ this.isCubeDepthTexture = true;
10997
+ this.isCubeTexture = true;
10998
+ }
10999
+ get images() {
11000
+ return this.image;
11001
+ }
11002
+ set images( value ) {
11003
+ this.image = value;
11004
+ }
11005
+ }
10945
11006
  class ExternalTexture extends Texture {
10946
11007
  constructor( sourceTexture = null ) {
10947
11008
  super();
@@ -11411,7 +11472,7 @@
11411
11472
  return this;
11412
11473
  }
11413
11474
  static fromJSON( data ) {
11414
- return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.details );
11475
+ return new PolyhedronGeometry( data.vertices, data.indices, data.radius, data.detail );
11415
11476
  }
11416
11477
  }
11417
11478
  class DodecahedronGeometry extends PolyhedronGeometry {
@@ -11549,7 +11610,7 @@
11549
11610
  this.cacheArcLengths = null;
11550
11611
  }
11551
11612
  getPoint( ) {
11552
- console.warn( 'THREE.Curve: .getPoint() not implemented.' );
11613
+ warn( 'Curve: .getPoint() not implemented.' );
11553
11614
  }
11554
11615
  getPointAt( u, optionalTarget ) {
11555
11616
  const t = this.getUtoTmapping( u );
@@ -12594,10 +12655,10 @@
12594
12655
  let minX, minY, invSize;
12595
12656
  if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
12596
12657
  if (data.length > 80 * dim) {
12597
- minX = Infinity;
12598
- minY = Infinity;
12599
- let maxX = -Infinity;
12600
- let maxY = -Infinity;
12658
+ minX = data[0];
12659
+ minY = data[1];
12660
+ let maxX = minX;
12661
+ let maxY = minY;
12601
12662
  for (let i = dim; i < outerLen; i += dim) {
12602
12663
  const x = data[i];
12603
12664
  const y = data[i + 1];
@@ -13115,7 +13176,8 @@
13115
13176
  extrudePts = extrudePath.getSpacedPoints( steps );
13116
13177
  extrudeByPath = true;
13117
13178
  bevelEnabled = false;
13118
- splineTube = extrudePath.computeFrenetFrames( steps, false );
13179
+ const isClosed = extrudePath.isCatmullRomCurve3 ? extrudePath.closed : false;
13180
+ splineTube = extrudePath.computeFrenetFrames( steps, isClosed );
13119
13181
  binormal = new Vector3();
13120
13182
  normal = new Vector3();
13121
13183
  position2 = new Vector3();
@@ -13173,7 +13235,7 @@
13173
13235
  vertices = vertices.concat( ahole );
13174
13236
  }
13175
13237
  function scalePt2( pt, vec, size ) {
13176
- if ( ! vec ) console.error( 'THREE.ExtrudeGeometry: vec does not exist' );
13238
+ if ( ! vec ) error( 'ExtrudeGeometry: vec does not exist' );
13177
13239
  return pt.clone().addScaledVector( vec, size );
13178
13240
  }
13179
13241
  const vlen = vertices.length;
@@ -14843,6 +14905,8 @@
14843
14905
  this.displacementScale = 1;
14844
14906
  this.displacementBias = 0;
14845
14907
  this.alphaMap = null;
14908
+ this.wireframe = false;
14909
+ this.wireframeLinewidth = 1;
14846
14910
  this.flatShading = false;
14847
14911
  this.fog = true;
14848
14912
  this.setValues( parameters );
@@ -14862,6 +14926,8 @@
14862
14926
  this.displacementScale = source.displacementScale;
14863
14927
  this.displacementBias = source.displacementBias;
14864
14928
  this.alphaMap = source.alphaMap;
14929
+ this.wireframe = source.wireframe;
14930
+ this.wireframeLinewidth = source.wireframeLinewidth;
14865
14931
  this.flatShading = source.flatShading;
14866
14932
  this.fog = source.fog;
14867
14933
  return this;
@@ -14892,9 +14958,6 @@
14892
14958
  }
14893
14959
  return Array.prototype.slice.call( array );
14894
14960
  }
14895
- function isTypedArray( object ) {
14896
- return ArrayBuffer.isView( object ) && ! ( object instanceof DataView );
14897
- }
14898
14961
  function getKeyframeOrder( times ) {
14899
14962
  function compareTime( i, j ) {
14900
14963
  return times[ i ] - times[ j ];
@@ -15350,7 +15413,7 @@
15350
15413
  throw new Error( message );
15351
15414
  }
15352
15415
  }
15353
- console.warn( 'THREE.KeyframeTrack:', message );
15416
+ warn( 'KeyframeTrack:', message );
15354
15417
  return this;
15355
15418
  }
15356
15419
  this.createInterpolant = factoryMethod;
@@ -15414,26 +15477,26 @@
15414
15477
  let valid = true;
15415
15478
  const valueSize = this.getValueSize();
15416
15479
  if ( valueSize - Math.floor( valueSize ) !== 0 ) {
15417
- console.error( 'THREE.KeyframeTrack: Invalid value size in track.', this );
15480
+ error( 'KeyframeTrack: Invalid value size in track.', this );
15418
15481
  valid = false;
15419
15482
  }
15420
15483
  const times = this.times,
15421
15484
  values = this.values,
15422
15485
  nKeys = times.length;
15423
15486
  if ( nKeys === 0 ) {
15424
- console.error( 'THREE.KeyframeTrack: Track is empty.', this );
15487
+ error( 'KeyframeTrack: Track is empty.', this );
15425
15488
  valid = false;
15426
15489
  }
15427
15490
  let prevTime = null;
15428
15491
  for ( let i = 0; i !== nKeys; i ++ ) {
15429
15492
  const currTime = times[ i ];
15430
15493
  if ( typeof currTime === 'number' && isNaN( currTime ) ) {
15431
- console.error( 'THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime );
15494
+ error( 'KeyframeTrack: Time is not a valid number.', this, i, currTime );
15432
15495
  valid = false;
15433
15496
  break;
15434
15497
  }
15435
15498
  if ( prevTime !== null && prevTime > currTime ) {
15436
- console.error( 'THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime );
15499
+ error( 'KeyframeTrack: Out of order keys.', this, i, currTime, prevTime );
15437
15500
  valid = false;
15438
15501
  break;
15439
15502
  }
@@ -15444,7 +15507,7 @@
15444
15507
  for ( let i = 0, n = values.length; i !== n; ++ i ) {
15445
15508
  const value = values[ i ];
15446
15509
  if ( isNaN( value ) ) {
15447
- console.error( 'THREE.KeyframeTrack: Value is not a valid number.', this, i, value );
15510
+ error( 'KeyframeTrack: Value is not a valid number.', this, i, value );
15448
15511
  valid = false;
15449
15512
  break;
15450
15513
  }
@@ -15687,9 +15750,9 @@
15687
15750
  return clips;
15688
15751
  }
15689
15752
  static parseAnimation( animation, bones ) {
15690
- console.warn( 'THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185' );
15753
+ warn( 'AnimationClip: parseAnimation() is deprecated and will be removed with r185' );
15691
15754
  if ( ! animation ) {
15692
- console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' );
15755
+ error( 'AnimationClip: No animation in JSONLoader data.' );
15693
15756
  return null;
15694
15757
  }
15695
15758
  const addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) {
@@ -15865,7 +15928,7 @@
15865
15928
  this.onLoad = onLoad;
15866
15929
  this.onProgress = onProgress;
15867
15930
  this.onError = onError;
15868
- this.abortController = new AbortController();
15931
+ this._abortController = null;
15869
15932
  this.itemStart = function ( url ) {
15870
15933
  itemsTotal ++;
15871
15934
  if ( isLoading === false ) {
@@ -15926,10 +15989,16 @@
15926
15989
  };
15927
15990
  this.abort = function () {
15928
15991
  this.abortController.abort();
15929
- this.abortController = new AbortController();
15992
+ this._abortController = null;
15930
15993
  return this;
15931
15994
  };
15932
15995
  }
15996
+ get abortController() {
15997
+ if ( ! this._abortController ) {
15998
+ this._abortController = new AbortController();
15999
+ }
16000
+ return this._abortController;
16001
+ }
15933
16002
  }
15934
16003
  const DefaultLoadingManager = new LoadingManager();
15935
16004
  class Loader {
@@ -16026,7 +16095,7 @@
16026
16095
  .then( response => {
16027
16096
  if ( response.status === 200 || response.status === 0 ) {
16028
16097
  if ( response.status === 0 ) {
16029
- console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
16098
+ warn( 'FileLoader: HTTP Status 0 received.' );
16030
16099
  }
16031
16100
  if ( typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined ) {
16032
16101
  return response;
@@ -16149,7 +16218,7 @@
16149
16218
  if ( onError ) {
16150
16219
  onError( e );
16151
16220
  } else {
16152
- console.error( e );
16221
+ error( e );
16153
16222
  }
16154
16223
  scope.manager.itemError( url );
16155
16224
  }
@@ -16346,7 +16415,7 @@
16346
16415
  if ( onError !== undefined ) {
16347
16416
  onError( error );
16348
16417
  } else {
16349
- console.error( error );
16418
+ error( error );
16350
16419
  return;
16351
16420
  }
16352
16421
  }
@@ -16418,6 +16487,7 @@
16418
16487
  this.intensity = intensity;
16419
16488
  }
16420
16489
  dispose() {
16490
+ this.dispatchEvent( { type: 'dispose' } );
16421
16491
  }
16422
16492
  copy( source, recursive ) {
16423
16493
  super.copy( source, recursive );
@@ -16429,13 +16499,6 @@
16429
16499
  const data = super.toJSON( meta );
16430
16500
  data.object.color = this.color.getHex();
16431
16501
  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
16502
  return data;
16440
16503
  }
16441
16504
  }
@@ -16453,8 +16516,13 @@
16453
16516
  this.groundColor.copy( source.groundColor );
16454
16517
  return this;
16455
16518
  }
16519
+ toJSON( meta ) {
16520
+ const data = super.toJSON( meta );
16521
+ data.object.groundColor = this.groundColor.getHex();
16522
+ return data;
16523
+ }
16456
16524
  }
16457
- const _projScreenMatrix$1 = new Matrix4();
16525
+ const _projScreenMatrix$2 = new Matrix4();
16458
16526
  const _lightPositionWorld$1 = new Vector3();
16459
16527
  const _lookTarget$1 = new Vector3();
16460
16528
  class LightShadow {
@@ -16493,8 +16561,8 @@
16493
16561
  _lookTarget$1.setFromMatrixPosition( light.target.matrixWorld );
16494
16562
  shadowCamera.lookAt( _lookTarget$1 );
16495
16563
  shadowCamera.updateMatrixWorld();
16496
- _projScreenMatrix$1.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
16497
- this._frustum.setFromProjectionMatrix( _projScreenMatrix$1, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
16564
+ _projScreenMatrix$2.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
16565
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix$2, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
16498
16566
  if ( shadowCamera.reversedDepth ) {
16499
16567
  shadowMatrix.set(
16500
16568
  0.5, 0.0, 0.0, 0.5,
@@ -16510,7 +16578,7 @@
16510
16578
  0.0, 0.0, 0.0, 1.0
16511
16579
  );
16512
16580
  }
16513
- shadowMatrix.multiply( _projScreenMatrix$1 );
16581
+ shadowMatrix.multiply( _projScreenMatrix$2 );
16514
16582
  }
16515
16583
  getViewport( viewportIndex ) {
16516
16584
  return this._viewports[ viewportIndex ];
@@ -16601,6 +16669,7 @@
16601
16669
  this.intensity = power / Math.PI;
16602
16670
  }
16603
16671
  dispose() {
16672
+ super.dispose();
16604
16673
  this.shadow.dispose();
16605
16674
  }
16606
16675
  copy( source, recursive ) {
@@ -16610,54 +16679,26 @@
16610
16679
  this.penumbra = source.penumbra;
16611
16680
  this.decay = source.decay;
16612
16681
  this.target = source.target.clone();
16682
+ this.map = source.map;
16613
16683
  this.shadow = source.shadow.clone();
16614
16684
  return this;
16615
16685
  }
16686
+ toJSON( meta ) {
16687
+ const data = super.toJSON( meta );
16688
+ data.object.distance = this.distance;
16689
+ data.object.angle = this.angle;
16690
+ data.object.decay = this.decay;
16691
+ data.object.penumbra = this.penumbra;
16692
+ data.object.target = this.target.uuid;
16693
+ if ( this.map && this.map.isTexture ) data.object.map = this.map.toJSON( meta ).uuid;
16694
+ data.object.shadow = this.shadow.toJSON();
16695
+ return data;
16696
+ }
16616
16697
  }
16617
- const _projScreenMatrix = new Matrix4();
16618
- const _lightPositionWorld = new Vector3();
16619
- const _lookTarget = new Vector3();
16620
16698
  class PointLightShadow extends LightShadow {
16621
16699
  constructor() {
16622
16700
  super( new PerspectiveCamera( 90, 1, 0.5, 500 ) );
16623
16701
  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
16702
  }
16662
16703
  }
16663
16704
  class PointLight extends Light {
@@ -16676,6 +16717,7 @@
16676
16717
  this.intensity = power / ( 4 * Math.PI );
16677
16718
  }
16678
16719
  dispose() {
16720
+ super.dispose();
16679
16721
  this.shadow.dispose();
16680
16722
  }
16681
16723
  copy( source, recursive ) {
@@ -16685,6 +16727,13 @@
16685
16727
  this.shadow = source.shadow.clone();
16686
16728
  return this;
16687
16729
  }
16730
+ toJSON( meta ) {
16731
+ const data = super.toJSON( meta );
16732
+ data.object.distance = this.distance;
16733
+ data.object.decay = this.decay;
16734
+ data.object.shadow = this.shadow.toJSON();
16735
+ return data;
16736
+ }
16688
16737
  }
16689
16738
  class OrthographicCamera extends Camera {
16690
16739
  constructor( left = -1, right = 1, top = 1, bottom = -1, near = 0.1, far = 2000 ) {
@@ -16790,6 +16839,7 @@
16790
16839
  this.shadow = new DirectionalLightShadow();
16791
16840
  }
16792
16841
  dispose() {
16842
+ super.dispose();
16793
16843
  this.shadow.dispose();
16794
16844
  }
16795
16845
  copy( source ) {
@@ -16798,6 +16848,12 @@
16798
16848
  this.shadow = source.shadow.clone();
16799
16849
  return this;
16800
16850
  }
16851
+ toJSON( meta ) {
16852
+ const data = super.toJSON( meta );
16853
+ data.object.shadow = this.shadow.toJSON();
16854
+ data.object.target = this.target.uuid;
16855
+ return data;
16856
+ }
16801
16857
  }
16802
16858
  class AmbientLight extends Light {
16803
16859
  constructor( color, intensity ) {
@@ -16957,11 +17013,6 @@
16957
17013
  this.sh.copy( source.sh );
16958
17014
  return this;
16959
17015
  }
16960
- fromJSON( json ) {
16961
- this.intensity = json.intensity;
16962
- this.sh.fromArray( json.sh );
16963
- return this;
16964
- }
16965
17016
  toJSON( meta ) {
16966
17017
  const data = super.toJSON( meta );
16967
17018
  data.object.sh = this.sh.toArray();
@@ -16986,7 +17037,7 @@
16986
17037
  if ( onError ) {
16987
17038
  onError( e );
16988
17039
  } else {
16989
- console.error( e );
17040
+ error( e );
16990
17041
  }
16991
17042
  scope.manager.itemError( url );
16992
17043
  }
@@ -16996,7 +17047,7 @@
16996
17047
  const textures = this.textures;
16997
17048
  function getTexture( name ) {
16998
17049
  if ( textures[ name ] === undefined ) {
16999
- console.warn( 'THREE.MaterialLoader: Undefined texture', name );
17050
+ warn( 'MaterialLoader: Undefined texture', name );
17000
17051
  }
17001
17052
  return textures[ name ];
17002
17053
  }
@@ -17072,6 +17123,7 @@
17072
17123
  if ( json.alphaToCoverage !== undefined ) material.alphaToCoverage = json.alphaToCoverage;
17073
17124
  if ( json.premultipliedAlpha !== undefined ) material.premultipliedAlpha = json.premultipliedAlpha;
17074
17125
  if ( json.forceSinglePass !== undefined ) material.forceSinglePass = json.forceSinglePass;
17126
+ if ( json.allowOverride !== undefined ) material.allowOverride = json.allowOverride;
17075
17127
  if ( json.visible !== undefined ) material.visible = json.visible;
17076
17128
  if ( json.toneMapped !== undefined ) material.toneMapped = json.toneMapped;
17077
17129
  if ( json.userData !== undefined ) material.userData = json.userData;
@@ -17257,7 +17309,7 @@
17257
17309
  if ( onError ) {
17258
17310
  onError( e );
17259
17311
  } else {
17260
- console.error( e );
17312
+ error( e );
17261
17313
  }
17262
17314
  scope.manager.itemError( url );
17263
17315
  }
@@ -17366,13 +17418,13 @@
17366
17418
  json = JSON.parse( text );
17367
17419
  } catch ( error ) {
17368
17420
  if ( onError !== undefined ) onError( error );
17369
- console.error( 'THREE:ObjectLoader: Can\'t parse ' + url + '.', error.message );
17421
+ error( 'ObjectLoader: Can\'t parse ' + url + '.', error.message );
17370
17422
  return;
17371
17423
  }
17372
17424
  const metadata = json.metadata;
17373
17425
  if ( metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry' ) {
17374
17426
  if ( onError !== undefined ) onError( new Error( 'THREE.ObjectLoader: Can\'t load ' + url ) );
17375
- console.error( 'THREE.ObjectLoader: Can\'t load ' + url );
17427
+ error( 'ObjectLoader: Can\'t load ' + url );
17376
17428
  return;
17377
17429
  }
17378
17430
  scope.parse( json, onLoad );
@@ -17472,7 +17524,7 @@
17472
17524
  if ( data.type in Geometries ) {
17473
17525
  geometry = Geometries[ data.type ].fromJSON( data, shapes );
17474
17526
  } else {
17475
- console.warn( `THREE.ObjectLoader: Unsupported geometry type "${ data.type }"` );
17527
+ warn( `ObjectLoader: Unsupported geometry type "${ data.type }"` );
17476
17528
  }
17477
17529
  }
17478
17530
  geometry.uuid = data.uuid;
@@ -17621,7 +17673,7 @@
17621
17673
  parseTextures( json, images ) {
17622
17674
  function parseConstant( value, type ) {
17623
17675
  if ( typeof value === 'number' ) return value;
17624
- console.warn( 'THREE.ObjectLoader.parseTexture: Constant should be in numeric form.', value );
17676
+ warn( 'ObjectLoader.parseTexture: Constant should be in numeric form.', value );
17625
17677
  return type[ value ];
17626
17678
  }
17627
17679
  const textures = {};
@@ -17629,10 +17681,10 @@
17629
17681
  for ( let i = 0, l = json.length; i < l; i ++ ) {
17630
17682
  const data = json[ i ];
17631
17683
  if ( data.image === undefined ) {
17632
- console.warn( 'THREE.ObjectLoader: No "image" specified for', data.uuid );
17684
+ warn( 'ObjectLoader: No "image" specified for', data.uuid );
17633
17685
  }
17634
17686
  if ( images[ data.image ] === undefined ) {
17635
- console.warn( 'THREE.ObjectLoader: Undefined image', data.image );
17687
+ warn( 'ObjectLoader: Undefined image', data.image );
17636
17688
  }
17637
17689
  const source = images[ data.image ];
17638
17690
  const image = source.data;
@@ -17683,7 +17735,7 @@
17683
17735
  let object;
17684
17736
  function getGeometry( name ) {
17685
17737
  if ( geometries[ name ] === undefined ) {
17686
- console.warn( 'THREE.ObjectLoader: Undefined geometry', name );
17738
+ warn( 'ObjectLoader: Undefined geometry', name );
17687
17739
  }
17688
17740
  return geometries[ name ];
17689
17741
  }
@@ -17694,20 +17746,20 @@
17694
17746
  for ( let i = 0, l = name.length; i < l; i ++ ) {
17695
17747
  const uuid = name[ i ];
17696
17748
  if ( materials[ uuid ] === undefined ) {
17697
- console.warn( 'THREE.ObjectLoader: Undefined material', uuid );
17749
+ warn( 'ObjectLoader: Undefined material', uuid );
17698
17750
  }
17699
17751
  array.push( materials[ uuid ] );
17700
17752
  }
17701
17753
  return array;
17702
17754
  }
17703
17755
  if ( materials[ name ] === undefined ) {
17704
- console.warn( 'THREE.ObjectLoader: Undefined material', name );
17756
+ warn( 'ObjectLoader: Undefined material', name );
17705
17757
  }
17706
17758
  return materials[ name ];
17707
17759
  }
17708
17760
  function getTexture( uuid ) {
17709
17761
  if ( textures[ uuid ] === undefined ) {
17710
- console.warn( 'THREE.ObjectLoader: Undefined texture', uuid );
17762
+ warn( 'ObjectLoader: Undefined texture', uuid );
17711
17763
  }
17712
17764
  return textures[ uuid ];
17713
17765
  }
@@ -17775,7 +17827,8 @@
17775
17827
  object = new HemisphereLight( data.color, data.groundColor, data.intensity );
17776
17828
  break;
17777
17829
  case 'LightProbe':
17778
- object = new LightProbe().fromJSON( data );
17830
+ const sh = new SphericalHarmonics3().fromArray( data.sh );
17831
+ object = new LightProbe( sh, data.intensity );
17779
17832
  break;
17780
17833
  case 'SkinnedMesh':
17781
17834
  geometry = getGeometry( data.geometry );
@@ -17934,7 +17987,7 @@
17934
17987
  if ( child.isSkinnedMesh === true && child.skeleton !== undefined ) {
17935
17988
  const skeleton = skeletons[ child.skeleton ];
17936
17989
  if ( skeleton === undefined ) {
17937
- console.warn( 'THREE.ObjectLoader: No skeleton found with UUID:', child.skeleton );
17990
+ warn( 'ObjectLoader: No skeleton found with UUID:', child.skeleton );
17938
17991
  } else {
17939
17992
  child.bind( skeleton, child.bindMatrix );
17940
17993
  }
@@ -17982,10 +18035,10 @@
17982
18035
  super( manager );
17983
18036
  this.isImageBitmapLoader = true;
17984
18037
  if ( typeof createImageBitmap === 'undefined' ) {
17985
- console.warn( 'THREE.ImageBitmapLoader: createImageBitmap() not supported.' );
18038
+ warn( 'ImageBitmapLoader: createImageBitmap() not supported.' );
17986
18039
  }
17987
18040
  if ( typeof fetch === 'undefined' ) {
17988
- console.warn( 'THREE.ImageBitmapLoader: fetch() not supported.' );
18041
+ warn( 'ImageBitmapLoader: fetch() not supported.' );
17989
18042
  }
17990
18043
  this.options = { premultiplyAlpha: 'none' };
17991
18044
  this._abortController = new AbortController();
@@ -18089,7 +18142,7 @@
18089
18142
  if ( onError ) {
18090
18143
  onError( e );
18091
18144
  } else {
18092
- console.error( e );
18145
+ error( e );
18093
18146
  }
18094
18147
  scope.manager.itemError( url );
18095
18148
  }
@@ -18332,11 +18385,11 @@
18332
18385
  }
18333
18386
  play( delay = 0 ) {
18334
18387
  if ( this.isPlaying === true ) {
18335
- console.warn( 'THREE.Audio: Audio is already playing.' );
18388
+ warn( 'Audio: Audio is already playing.' );
18336
18389
  return;
18337
18390
  }
18338
18391
  if ( this.hasPlaybackControl === false ) {
18339
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18392
+ warn( 'Audio: this Audio has no playback control.' );
18340
18393
  return;
18341
18394
  }
18342
18395
  this._startedAt = this.context.currentTime + delay;
@@ -18355,7 +18408,7 @@
18355
18408
  }
18356
18409
  pause() {
18357
18410
  if ( this.hasPlaybackControl === false ) {
18358
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18411
+ warn( 'Audio: this Audio has no playback control.' );
18359
18412
  return;
18360
18413
  }
18361
18414
  if ( this.isPlaying === true ) {
@@ -18371,7 +18424,7 @@
18371
18424
  }
18372
18425
  stop( delay = 0 ) {
18373
18426
  if ( this.hasPlaybackControl === false ) {
18374
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18427
+ warn( 'Audio: this Audio has no playback control.' );
18375
18428
  return;
18376
18429
  }
18377
18430
  this._progress = 0;
@@ -18443,7 +18496,7 @@
18443
18496
  }
18444
18497
  setPlaybackRate( value ) {
18445
18498
  if ( this.hasPlaybackControl === false ) {
18446
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18499
+ warn( 'Audio: this Audio has no playback control.' );
18447
18500
  return;
18448
18501
  }
18449
18502
  this.playbackRate = value;
@@ -18461,14 +18514,14 @@
18461
18514
  }
18462
18515
  getLoop() {
18463
18516
  if ( this.hasPlaybackControl === false ) {
18464
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18517
+ warn( 'Audio: this Audio has no playback control.' );
18465
18518
  return false;
18466
18519
  }
18467
18520
  return this.loop;
18468
18521
  }
18469
18522
  setLoop( value ) {
18470
18523
  if ( this.hasPlaybackControl === false ) {
18471
- console.warn( 'THREE.Audio: this Audio has no playback control.' );
18524
+ warn( 'Audio: this Audio has no playback control.' );
18472
18525
  return;
18473
18526
  }
18474
18527
  this.loop = value;
@@ -18495,7 +18548,7 @@
18495
18548
  copy( source, recursive ) {
18496
18549
  super.copy( source, recursive );
18497
18550
  if ( source.sourceType !== 'buffer' ) {
18498
- console.warn( 'THREE.Audio: Audio source type cannot be copied.' );
18551
+ warn( 'Audio: Audio source type cannot be copied.' );
18499
18552
  return this;
18500
18553
  }
18501
18554
  this.autoplay = source.autoplay;
@@ -18979,7 +19032,7 @@
18979
19032
  this.getValue = this._getValue_unavailable;
18980
19033
  this.setValue = this._setValue_unavailable;
18981
19034
  if ( ! targetObject ) {
18982
- console.warn( 'THREE.PropertyBinding: No target node found for track: ' + this.path + '.' );
19035
+ warn( 'PropertyBinding: No target node found for track: ' + this.path + '.' );
18983
19036
  return;
18984
19037
  }
18985
19038
  if ( objectName ) {
@@ -18987,18 +19040,18 @@
18987
19040
  switch ( objectName ) {
18988
19041
  case 'materials':
18989
19042
  if ( ! targetObject.material ) {
18990
- console.error( 'THREE.PropertyBinding: Can not bind to material as node does not have a material.', this );
19043
+ error( 'PropertyBinding: Can not bind to material as node does not have a material.', this );
18991
19044
  return;
18992
19045
  }
18993
19046
  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 );
19047
+ error( 'PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this );
18995
19048
  return;
18996
19049
  }
18997
19050
  targetObject = targetObject.material.materials;
18998
19051
  break;
18999
19052
  case 'bones':
19000
19053
  if ( ! targetObject.skeleton ) {
19001
- console.error( 'THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this );
19054
+ error( 'PropertyBinding: Can not bind to bones as node does not have a skeleton.', this );
19002
19055
  return;
19003
19056
  }
19004
19057
  targetObject = targetObject.skeleton.bones;
@@ -19015,25 +19068,25 @@
19015
19068
  break;
19016
19069
  }
19017
19070
  if ( ! targetObject.material ) {
19018
- console.error( 'THREE.PropertyBinding: Can not bind to material as node does not have a material.', this );
19071
+ error( 'PropertyBinding: Can not bind to material as node does not have a material.', this );
19019
19072
  return;
19020
19073
  }
19021
19074
  if ( ! targetObject.material.map ) {
19022
- console.error( 'THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.', this );
19075
+ error( 'PropertyBinding: Can not bind to material.map as node.material does not have a map.', this );
19023
19076
  return;
19024
19077
  }
19025
19078
  targetObject = targetObject.material.map;
19026
19079
  break;
19027
19080
  default:
19028
19081
  if ( targetObject[ objectName ] === undefined ) {
19029
- console.error( 'THREE.PropertyBinding: Can not bind to objectName of node undefined.', this );
19082
+ error( 'PropertyBinding: Can not bind to objectName of node undefined.', this );
19030
19083
  return;
19031
19084
  }
19032
19085
  targetObject = targetObject[ objectName ];
19033
19086
  }
19034
19087
  if ( objectIndex !== undefined ) {
19035
19088
  if ( targetObject[ objectIndex ] === undefined ) {
19036
- console.error( 'THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject );
19089
+ error( 'PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject );
19037
19090
  return;
19038
19091
  }
19039
19092
  targetObject = targetObject[ objectIndex ];
@@ -19042,7 +19095,7 @@
19042
19095
  const nodeProperty = targetObject[ propertyName ];
19043
19096
  if ( nodeProperty === undefined ) {
19044
19097
  const nodeName = parsedPath.nodeName;
19045
- console.error( 'THREE.PropertyBinding: Trying to update property for track: ' + nodeName +
19098
+ error( 'PropertyBinding: Trying to update property for track: ' + nodeName +
19046
19099
  '.' + propertyName + ' but it wasn\'t found.', targetObject );
19047
19100
  return;
19048
19101
  }
@@ -19057,11 +19110,11 @@
19057
19110
  if ( propertyIndex !== undefined ) {
19058
19111
  if ( propertyName === 'morphTargetInfluences' ) {
19059
19112
  if ( ! targetObject.geometry ) {
19060
- console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this );
19113
+ error( 'PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this );
19061
19114
  return;
19062
19115
  }
19063
19116
  if ( ! targetObject.geometry.morphAttributes ) {
19064
- console.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this );
19117
+ error( 'PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this );
19065
19118
  return;
19066
19119
  }
19067
19120
  if ( targetObject.morphTargetDictionary[ propertyIndex ] !== undefined ) {
@@ -19196,7 +19249,7 @@
19196
19249
  bindingsForPath[ firstActiveIndex ] = binding;
19197
19250
  }
19198
19251
  } else if ( objects[ index ] !== knownObject ) {
19199
- console.error( 'THREE.AnimationObjectGroup: Different objects with the same UUID ' +
19252
+ error( 'AnimationObjectGroup: Different objects with the same UUID ' +
19200
19253
  'detected. Clean the caches or recreate your infrastructure when reloading scenes.' );
19201
19254
  }
19202
19255
  }
@@ -20225,7 +20278,7 @@
20225
20278
  this.ray.direction.set( 0, 0, -1 ).transformDirection( camera.matrixWorld );
20226
20279
  this.camera = camera;
20227
20280
  } else {
20228
- console.error( 'THREE.Raycaster: Unsupported camera type: ' + camera.type );
20281
+ error( 'Raycaster: Unsupported camera type: ' + camera.type );
20229
20282
  }
20230
20283
  }
20231
20284
  setFromXRController( controller ) {
@@ -21495,7 +21548,7 @@
21495
21548
  }
21496
21549
  connect( element ) {
21497
21550
  if ( element === undefined ) {
21498
- console.warn( 'THREE.Controls: connect() now requires an element.' );
21551
+ warn( 'Controls: connect() now requires an element.' );
21499
21552
  return;
21500
21553
  }
21501
21554
  if ( this.domElement !== null ) this.disconnect();
@@ -21575,8 +21628,12 @@
21575
21628
  return ( Math.max( width, 8 ) * Math.max( height, 8 ) ) / 2;
21576
21629
  case RGB_ETC1_Format:
21577
21630
  case RGB_ETC2_Format:
21631
+ case R11_EAC_Format:
21632
+ case SIGNED_R11_EAC_Format:
21578
21633
  return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 8;
21579
21634
  case RGBA_ETC2_EAC_Format:
21635
+ case RG11_EAC_Format:
21636
+ case SIGNED_RG11_EAC_Format:
21580
21637
  return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
21581
21638
  case RGBA_ASTC_4x4_Format:
21582
21639
  return Math.floor( ( width + 3 ) / 4 ) * Math.floor( ( height + 3 ) / 4 ) * 16;
@@ -21664,7 +21721,7 @@
21664
21721
  }
21665
21722
  if ( typeof window !== 'undefined' ) {
21666
21723
  if ( window.__THREE__ ) {
21667
- console.warn( 'WARNING: Multiple instances of Three.js being imported.' );
21724
+ warn( 'WARNING: Multiple instances of Three.js being imported.' );
21668
21725
  } else {
21669
21726
  window.__THREE__ = REVISION;
21670
21727
  }
@@ -21845,7 +21902,7 @@
21845
21902
  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
21903
  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
21904
  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";
21905
+ 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
21906
  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
21907
  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
21908
  var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif";
@@ -21855,7 +21912,7 @@
21855
21912
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
21856
21913
  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
21914
  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";
21915
+ 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
21916
  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
21917
  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
21918
  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 +21925,14 @@
21868
21925
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
21869
21926
  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
21927
  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";
21928
+ 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
21929
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
21873
21930
  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
21931
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
21875
21932
  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";
21933
+ 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";
21934
+ 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}";
21935
+ 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
21936
  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
21937
  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
21938
  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 +21968,10 @@
21911
21968
  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
21969
  var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif";
21913
21970
  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";
21971
+ 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
21972
  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
21973
  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}";
21974
+ 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
21975
  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
21976
  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
21977
  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 +21980,7 @@
21923
21980
  var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";
21924
21981
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
21925
21982
  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";
21983
+ 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
21984
  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
21985
  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
21986
  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 +21995,7 @@
21938
21995
  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
21996
  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
21997
  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}";
21998
+ 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
21999
  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
22000
  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
22001
  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 +22003,21 @@
21946
22003
  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
22004
  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
22005
  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}";
22006
+ 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
22007
  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
22008
  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
22009
  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}";
22010
+ 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
22011
  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}";
22012
+ 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
22013
  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}";
22014
+ 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
22015
  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}";
22016
+ 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
22017
  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
22018
  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
22019
  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}";
22020
+ 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
22021
  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
22022
  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
22023
  const ShaderChunk = {
@@ -22079,8 +22136,8 @@
22079
22136
  cube_frag: fragment$f,
22080
22137
  depth_vert: vertex$e,
22081
22138
  depth_frag: fragment$e,
22082
- distanceRGBA_vert: vertex$d,
22083
- distanceRGBA_frag: fragment$d,
22139
+ distance_vert: vertex$d,
22140
+ distance_frag: fragment$d,
22084
22141
  equirect_vert: vertex$c,
22085
22142
  equirect_frag: fragment$c,
22086
22143
  linedashed_vert: vertex$b,
@@ -22127,6 +22184,7 @@
22127
22184
  reflectivity: { value: 1.0 },
22128
22185
  ior: { value: 1.5 },
22129
22186
  refractionRatio: { value: 0.98 },
22187
+ dfgLUT: { value: null }
22130
22188
  },
22131
22189
  aomap: {
22132
22190
  aoMap: { value: null },
@@ -22462,7 +22520,7 @@
22462
22520
  vertexShader: ShaderChunk.equirect_vert,
22463
22521
  fragmentShader: ShaderChunk.equirect_frag
22464
22522
  },
22465
- distanceRGBA: {
22523
+ distance: {
22466
22524
  uniforms: mergeUniforms( [
22467
22525
  UniformsLib.common,
22468
22526
  UniformsLib.displacementmap,
@@ -22472,8 +22530,8 @@
22472
22530
  farDistance: { value: 1000 }
22473
22531
  }
22474
22532
  ] ),
22475
- vertexShader: ShaderChunk.distanceRGBA_vert,
22476
- fragmentShader: ShaderChunk.distanceRGBA_frag
22533
+ vertexShader: ShaderChunk.distance_vert,
22534
+ fragmentShader: ShaderChunk.distance_frag
22477
22535
  },
22478
22536
  shadow: {
22479
22537
  uniforms: mergeUniforms( [
@@ -23132,7 +23190,7 @@
23132
23190
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
23133
23191
  const maxPrecision = getMaxPrecision( precision );
23134
23192
  if ( maxPrecision !== precision ) {
23135
- console.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );
23193
+ warn( 'WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );
23136
23194
  precision = maxPrecision;
23137
23195
  }
23138
23196
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
@@ -23145,8 +23203,8 @@
23145
23203
  const maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );
23146
23204
  const maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );
23147
23205
  const maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );
23148
- const vertexTextures = maxVertexTextures > 0;
23149
23206
  const maxSamples = gl.getParameter( gl.MAX_SAMPLES );
23207
+ const samples = gl.getParameter( gl.SAMPLES );
23150
23208
  return {
23151
23209
  isWebGL2: true,
23152
23210
  getMaxAnisotropy: getMaxAnisotropy,
@@ -23164,8 +23222,8 @@
23164
23222
  maxVertexUniforms: maxVertexUniforms,
23165
23223
  maxVaryings: maxVaryings,
23166
23224
  maxFragmentUniforms: maxFragmentUniforms,
23167
- vertexTextures: vertexTextures,
23168
- maxSamples: maxSamples
23225
+ maxSamples: maxSamples,
23226
+ samples: samples
23169
23227
  };
23170
23228
  }
23171
23229
  function WebGLClipping( properties ) {
@@ -23312,25 +23370,13 @@
23312
23370
  const LOD_MIN = 4;
23313
23371
  const EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ];
23314
23372
  const MAX_SAMPLES = 20;
23373
+ const GGX_SAMPLES = 256;
23315
23374
  const _flatCamera = new OrthographicCamera();
23316
23375
  const _clearColor = new Color();
23317
23376
  let _oldTarget = null;
23318
23377
  let _oldActiveCubeFace = 0;
23319
23378
  let _oldActiveMipmapLevel = 0;
23320
23379
  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
23380
  const _origin = new Vector3();
23335
23381
  class PMREMGenerator {
23336
23382
  constructor( renderer ) {
@@ -23338,13 +23384,14 @@
23338
23384
  this._pingPongRenderTarget = null;
23339
23385
  this._lodMax = 0;
23340
23386
  this._cubeSize = 0;
23341
- this._lodPlanes = [];
23342
23387
  this._sizeLods = [];
23343
23388
  this._sigmas = [];
23344
- this._blurMaterial = null;
23389
+ this._lodMeshes = [];
23390
+ this._backgroundBox = null;
23345
23391
  this._cubemapMaterial = null;
23346
23392
  this._equirectMaterial = null;
23347
- this._compileMaterial( this._blurMaterial );
23393
+ this._blurMaterial = null;
23394
+ this._ggxMaterial = null;
23348
23395
  }
23349
23396
  fromScene( scene, sigma = 0, near = 0.1, far = 100, options = {} ) {
23350
23397
  const {
@@ -23389,6 +23436,10 @@
23389
23436
  this._dispose();
23390
23437
  if ( this._cubemapMaterial !== null ) this._cubemapMaterial.dispose();
23391
23438
  if ( this._equirectMaterial !== null ) this._equirectMaterial.dispose();
23439
+ if ( this._backgroundBox !== null ) {
23440
+ this._backgroundBox.geometry.dispose();
23441
+ this._backgroundBox.material.dispose();
23442
+ }
23392
23443
  }
23393
23444
  _setSize( cubeSize ) {
23394
23445
  this._lodMax = Math.floor( Math.log2( cubeSize ) );
@@ -23396,9 +23447,10 @@
23396
23447
  }
23397
23448
  _dispose() {
23398
23449
  if ( this._blurMaterial !== null ) this._blurMaterial.dispose();
23450
+ if ( this._ggxMaterial !== null ) this._ggxMaterial.dispose();
23399
23451
  if ( this._pingPongRenderTarget !== null ) this._pingPongRenderTarget.dispose();
23400
- for ( let i = 0; i < this._lodPlanes.length; i ++ ) {
23401
- this._lodPlanes[ i ].dispose();
23452
+ for ( let i = 0; i < this._lodMeshes.length; i ++ ) {
23453
+ this._lodMeshes[ i ].geometry.dispose();
23402
23454
  }
23403
23455
  }
23404
23456
  _cleanup( outputTarget ) {
@@ -23443,14 +23495,15 @@
23443
23495
  }
23444
23496
  this._pingPongRenderTarget = _createRenderTarget( width, height, params );
23445
23497
  const { _lodMax } = this;
23446
- ( { sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = _createPlanes( _lodMax ) );
23498
+ ( { lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas } = _createPlanes( _lodMax ) );
23447
23499
  this._blurMaterial = _getBlurShader( _lodMax, width, height );
23500
+ this._ggxMaterial = _getGGXShader( _lodMax, width, height );
23448
23501
  }
23449
23502
  return cubeUVRenderTarget;
23450
23503
  }
23451
23504
  _compileMaterial( material ) {
23452
- const tmpMesh = new Mesh( this._lodPlanes[ 0 ], material );
23453
- this._renderer.compile( tmpMesh, _flatCamera );
23505
+ const mesh = new Mesh( new BufferGeometry(), material );
23506
+ this._renderer.compile( mesh, _flatCamera );
23454
23507
  }
23455
23508
  _sceneToCubeUV( scene, near, far, cubeUVRenderTarget, position ) {
23456
23509
  const fov = 90;
@@ -23470,13 +23523,19 @@
23470
23523
  renderer.clearDepth();
23471
23524
  renderer.setRenderTarget( null );
23472
23525
  }
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 );
23526
+ if ( this._backgroundBox === null ) {
23527
+ this._backgroundBox = new Mesh(
23528
+ new BoxGeometry(),
23529
+ new MeshBasicMaterial( {
23530
+ name: 'PMREM.Background',
23531
+ side: BackSide,
23532
+ depthWrite: false,
23533
+ depthTest: false,
23534
+ } )
23535
+ );
23536
+ }
23537
+ const backgroundBox = this._backgroundBox;
23538
+ const backgroundMaterial = backgroundBox.material;
23480
23539
  let useSolidColor = false;
23481
23540
  const background = scene.background;
23482
23541
  if ( background ) {
@@ -23512,8 +23571,6 @@
23512
23571
  }
23513
23572
  renderer.render( scene, cubeCamera );
23514
23573
  }
23515
- backgroundBox.geometry.dispose();
23516
- backgroundBox.material.dispose();
23517
23574
  renderer.toneMapping = toneMapping;
23518
23575
  renderer.autoClear = originalAutoClear;
23519
23576
  scene.background = background;
@@ -23532,7 +23589,8 @@
23532
23589
  }
23533
23590
  }
23534
23591
  const material = isCubeTexture ? this._cubemapMaterial : this._equirectMaterial;
23535
- const mesh = new Mesh( this._lodPlanes[ 0 ], material );
23592
+ const mesh = this._lodMeshes[ 0 ];
23593
+ mesh.material = material;
23536
23594
  const uniforms = material.uniforms;
23537
23595
  uniforms[ 'envMap' ].value = texture;
23538
23596
  const size = this._cubeSize;
@@ -23544,14 +23602,41 @@
23544
23602
  const renderer = this._renderer;
23545
23603
  const autoClear = renderer.autoClear;
23546
23604
  renderer.autoClear = false;
23547
- const n = this._lodPlanes.length;
23605
+ const n = this._lodMeshes.length;
23548
23606
  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 );
23607
+ this._applyGGXFilter( cubeUVRenderTarget, i - 1, i );
23552
23608
  }
23553
23609
  renderer.autoClear = autoClear;
23554
23610
  }
23611
+ _applyGGXFilter( cubeUVRenderTarget, lodIn, lodOut ) {
23612
+ const renderer = this._renderer;
23613
+ const pingPongRenderTarget = this._pingPongRenderTarget;
23614
+ const ggxMaterial = this._ggxMaterial;
23615
+ const ggxMesh = this._lodMeshes[ lodOut ];
23616
+ ggxMesh.material = ggxMaterial;
23617
+ const ggxUniforms = ggxMaterial.uniforms;
23618
+ const targetRoughness = lodOut / ( this._lodMeshes.length - 1 );
23619
+ const sourceRoughness = lodIn / ( this._lodMeshes.length - 1 );
23620
+ const incrementalRoughness = Math.sqrt( targetRoughness * targetRoughness - sourceRoughness * sourceRoughness );
23621
+ const blurStrength = 0.0 + targetRoughness * 1.25;
23622
+ const adjustedRoughness = incrementalRoughness * blurStrength;
23623
+ const { _lodMax } = this;
23624
+ const outputSize = this._sizeLods[ lodOut ];
23625
+ const x = 3 * outputSize * ( lodOut > _lodMax - LOD_MIN ? lodOut - _lodMax + LOD_MIN : 0 );
23626
+ const y = 4 * ( this._cubeSize - outputSize );
23627
+ ggxUniforms[ 'envMap' ].value = cubeUVRenderTarget.texture;
23628
+ ggxUniforms[ 'roughness' ].value = adjustedRoughness;
23629
+ ggxUniforms[ 'mipInt' ].value = _lodMax - lodIn;
23630
+ _setViewport( pingPongRenderTarget, x, y, 3 * outputSize, 2 * outputSize );
23631
+ renderer.setRenderTarget( pingPongRenderTarget );
23632
+ renderer.render( ggxMesh, _flatCamera );
23633
+ ggxUniforms[ 'envMap' ].value = pingPongRenderTarget.texture;
23634
+ ggxUniforms[ 'roughness' ].value = 0.0;
23635
+ ggxUniforms[ 'mipInt' ].value = _lodMax - lodOut;
23636
+ _setViewport( cubeUVRenderTarget, x, y, 3 * outputSize, 2 * outputSize );
23637
+ renderer.setRenderTarget( cubeUVRenderTarget );
23638
+ renderer.render( ggxMesh, _flatCamera );
23639
+ }
23555
23640
  _blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) {
23556
23641
  const pingPongRenderTarget = this._pingPongRenderTarget;
23557
23642
  this._halfBlur(
@@ -23575,18 +23660,19 @@
23575
23660
  const renderer = this._renderer;
23576
23661
  const blurMaterial = this._blurMaterial;
23577
23662
  if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) {
23578
- console.error(
23663
+ error(
23579
23664
  'blur direction must be either latitudinal or longitudinal!' );
23580
23665
  }
23581
23666
  const STANDARD_DEVIATIONS = 3;
23582
- const blurMesh = new Mesh( this._lodPlanes[ lodOut ], blurMaterial );
23667
+ const blurMesh = this._lodMeshes[ lodOut ];
23668
+ blurMesh.material = blurMaterial;
23583
23669
  const blurUniforms = blurMaterial.uniforms;
23584
23670
  const pixels = this._sizeLods[ lodIn ] - 1;
23585
23671
  const radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 );
23586
23672
  const sigmaPixels = sigmaRadians / radiansPerPixel;
23587
23673
  const samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES;
23588
23674
  if ( samples > MAX_SAMPLES ) {
23589
- console.warn( `sigmaRadians, ${
23675
+ warn( `sigmaRadians, ${
23590
23676
  sigmaRadians}, is too large and will clip, as it requested ${
23591
23677
  samples} samples when the maximum is set to ${MAX_SAMPLES}` );
23592
23678
  }
@@ -23624,9 +23710,9 @@
23624
23710
  }
23625
23711
  }
23626
23712
  function _createPlanes( lodMax ) {
23627
- const lodPlanes = [];
23628
23713
  const sizeLods = [];
23629
23714
  const sigmas = [];
23715
+ const lodMeshes = [];
23630
23716
  let lod = lodMax;
23631
23717
  const totalLods = lodMax - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
23632
23718
  for ( let i = 0; i < totalLods; i ++ ) {
@@ -23671,12 +23757,12 @@
23671
23757
  planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) );
23672
23758
  planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) );
23673
23759
  planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) );
23674
- lodPlanes.push( planes );
23760
+ lodMeshes.push( new Mesh( planes, null ) );
23675
23761
  if ( lod > LOD_MIN ) {
23676
23762
  lod --;
23677
23763
  }
23678
23764
  }
23679
- return { lodPlanes, sizeLods, sigmas };
23765
+ return { lodMeshes, sizeLods, sigmas };
23680
23766
  }
23681
23767
  function _createRenderTarget( width, height, params ) {
23682
23768
  const cubeUVRenderTarget = new WebGLRenderTarget( width, height, params );
@@ -23689,6 +23775,136 @@
23689
23775
  target.viewport.set( x, y, width, height );
23690
23776
  target.scissor.set( x, y, width, height );
23691
23777
  }
23778
+ function _getGGXShader( lodMax, width, height ) {
23779
+ const shaderMaterial = new ShaderMaterial( {
23780
+ name: 'PMREMGGXConvolution',
23781
+ defines: {
23782
+ 'GGX_SAMPLES': GGX_SAMPLES,
23783
+ 'CUBEUV_TEXEL_WIDTH': 1.0 / width,
23784
+ 'CUBEUV_TEXEL_HEIGHT': 1.0 / height,
23785
+ 'CUBEUV_MAX_MIP': `${lodMax}.0`,
23786
+ },
23787
+ uniforms: {
23788
+ 'envMap': { value: null },
23789
+ 'roughness': { value: 0.0 },
23790
+ 'mipInt': { value: 0 }
23791
+ },
23792
+ vertexShader: _getCommonVertexShader(),
23793
+ fragmentShader: `
23794
+
23795
+ precision highp float;
23796
+ precision highp int;
23797
+
23798
+ varying vec3 vOutputDirection;
23799
+
23800
+ uniform sampler2D envMap;
23801
+ uniform float roughness;
23802
+ uniform float mipInt;
23803
+
23804
+ #define ENVMAP_TYPE_CUBE_UV
23805
+ #include <cube_uv_reflection_fragment>
23806
+
23807
+ #define PI 3.14159265359
23808
+
23809
+ // Van der Corput radical inverse
23810
+ float radicalInverse_VdC(uint bits) {
23811
+ bits = (bits << 16u) | (bits >> 16u);
23812
+ bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
23813
+ bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
23814
+ bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
23815
+ bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
23816
+ return float(bits) * 2.3283064365386963e-10; // / 0x100000000
23817
+ }
23818
+
23819
+ // Hammersley sequence
23820
+ vec2 hammersley(uint i, uint N) {
23821
+ return vec2(float(i) / float(N), radicalInverse_VdC(i));
23822
+ }
23823
+
23824
+ // GGX VNDF importance sampling (Eric Heitz 2018)
23825
+ // "Sampling the GGX Distribution of Visible Normals"
23826
+ // https://jcgt.org/published/0007/04/01/
23827
+ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
23828
+ float alpha = roughness * roughness;
23829
+
23830
+ // Section 3.2: Transform view direction to hemisphere configuration
23831
+ vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
23832
+
23833
+ // Section 4.1: Orthonormal basis
23834
+ float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
23835
+ vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
23836
+ vec3 T2 = cross(Vh, T1);
23837
+
23838
+ // Section 4.2: Parameterization of projected area
23839
+ float r = sqrt(Xi.x);
23840
+ float phi = 2.0 * PI * Xi.y;
23841
+ float t1 = r * cos(phi);
23842
+ float t2 = r * sin(phi);
23843
+ float s = 0.5 * (1.0 + Vh.z);
23844
+ t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
23845
+
23846
+ // Section 4.3: Reprojection onto hemisphere
23847
+ vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
23848
+
23849
+ // Section 3.4: Transform back to ellipsoid configuration
23850
+ return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
23851
+ }
23852
+
23853
+ void main() {
23854
+ vec3 N = normalize(vOutputDirection);
23855
+ vec3 V = N; // Assume view direction equals normal for pre-filtering
23856
+
23857
+ vec3 prefilteredColor = vec3(0.0);
23858
+ float totalWeight = 0.0;
23859
+
23860
+ // For very low roughness, just sample the environment directly
23861
+ if (roughness < 0.001) {
23862
+ gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
23863
+ return;
23864
+ }
23865
+
23866
+ // Tangent space basis for VNDF sampling
23867
+ vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
23868
+ vec3 tangent = normalize(cross(up, N));
23869
+ vec3 bitangent = cross(N, tangent);
23870
+
23871
+ for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
23872
+ vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
23873
+
23874
+ // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
23875
+ vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
23876
+
23877
+ // Transform H back to world space
23878
+ vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
23879
+ vec3 L = normalize(2.0 * dot(V, H) * H - V);
23880
+
23881
+ float NdotL = max(dot(N, L), 0.0);
23882
+
23883
+ if(NdotL > 0.0) {
23884
+ // Sample environment at fixed mip level
23885
+ // VNDF importance sampling handles the distribution filtering
23886
+ vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
23887
+
23888
+ // Weight by NdotL for the split-sum approximation
23889
+ // VNDF PDF naturally accounts for the visible microfacet distribution
23890
+ prefilteredColor += sampleColor * NdotL;
23891
+ totalWeight += NdotL;
23892
+ }
23893
+ }
23894
+
23895
+ if (totalWeight > 0.0) {
23896
+ prefilteredColor = prefilteredColor / totalWeight;
23897
+ }
23898
+
23899
+ gl_FragColor = vec4(prefilteredColor, 1.0);
23900
+ }
23901
+ `,
23902
+ blending: NoBlending,
23903
+ depthTest: false,
23904
+ depthWrite: false
23905
+ } );
23906
+ return shaderMaterial;
23907
+ }
23692
23908
  function _getBlurShader( lodMax, width, height ) {
23693
23909
  const weights = new Float32Array( MAX_SAMPLES );
23694
23910
  const poleAxis = new Vector3( 0, 1, 0 );
@@ -23970,23 +24186,7 @@
23970
24186
  if ( extensions[ name ] !== undefined ) {
23971
24187
  return extensions[ name ];
23972
24188
  }
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
- }
24189
+ const extension = gl.getExtension( name );
23990
24190
  extensions[ name ] = extension;
23991
24191
  return extension;
23992
24192
  }
@@ -24005,7 +24205,7 @@
24005
24205
  get: function ( name ) {
24006
24206
  const extension = getExtension( name );
24007
24207
  if ( extension === null ) {
24008
- warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
24208
+ warnOnce( 'WebGLRenderer: ' + name + ' extension not supported.' );
24009
24209
  }
24010
24210
  return extension;
24011
24211
  }
@@ -24183,7 +24383,7 @@
24183
24383
  render.points += instanceCount * count;
24184
24384
  break;
24185
24385
  default:
24186
- console.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );
24386
+ error( 'WebGLInfo: Unknown draw mode:', mode );
24187
24387
  break;
24188
24388
  }
24189
24389
  }
@@ -24339,6 +24539,172 @@
24339
24539
  dispose: dispose
24340
24540
  };
24341
24541
  }
24542
+ const toneMappingMap = {
24543
+ [ LinearToneMapping ]: 'LINEAR_TONE_MAPPING',
24544
+ [ ReinhardToneMapping ]: 'REINHARD_TONE_MAPPING',
24545
+ [ CineonToneMapping ]: 'CINEON_TONE_MAPPING',
24546
+ [ ACESFilmicToneMapping ]: 'ACES_FILMIC_TONE_MAPPING',
24547
+ [ AgXToneMapping ]: 'AGX_TONE_MAPPING',
24548
+ [ NeutralToneMapping ]: 'NEUTRAL_TONE_MAPPING',
24549
+ [ CustomToneMapping ]: 'CUSTOM_TONE_MAPPING'
24550
+ };
24551
+ function WebGLOutput( type, width, height, depth, stencil ) {
24552
+ const targetA = new WebGLRenderTarget( width, height, {
24553
+ type: type,
24554
+ depthBuffer: depth,
24555
+ stencilBuffer: stencil
24556
+ } );
24557
+ const targetB = new WebGLRenderTarget( width, height, {
24558
+ type: HalfFloatType,
24559
+ depthBuffer: false,
24560
+ stencilBuffer: false
24561
+ } );
24562
+ const geometry = new BufferGeometry();
24563
+ geometry.setAttribute( 'position', new Float32BufferAttribute( [ -1, 3, 0, -1, -1, 0, 3, -1, 0 ], 3 ) );
24564
+ geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );
24565
+ const material = new RawShaderMaterial( {
24566
+ uniforms: {
24567
+ tDiffuse: { value: null }
24568
+ },
24569
+ vertexShader: `
24570
+ precision highp float;
24571
+
24572
+ uniform mat4 modelViewMatrix;
24573
+ uniform mat4 projectionMatrix;
24574
+
24575
+ attribute vec3 position;
24576
+ attribute vec2 uv;
24577
+
24578
+ varying vec2 vUv;
24579
+
24580
+ void main() {
24581
+ vUv = uv;
24582
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
24583
+ }`,
24584
+ fragmentShader: `
24585
+ precision highp float;
24586
+
24587
+ uniform sampler2D tDiffuse;
24588
+
24589
+ varying vec2 vUv;
24590
+
24591
+ #include <tonemapping_pars_fragment>
24592
+ #include <colorspace_pars_fragment>
24593
+
24594
+ void main() {
24595
+ gl_FragColor = texture2D( tDiffuse, vUv );
24596
+
24597
+ #ifdef LINEAR_TONE_MAPPING
24598
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
24599
+ #elif defined( REINHARD_TONE_MAPPING )
24600
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
24601
+ #elif defined( CINEON_TONE_MAPPING )
24602
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
24603
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
24604
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
24605
+ #elif defined( AGX_TONE_MAPPING )
24606
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
24607
+ #elif defined( NEUTRAL_TONE_MAPPING )
24608
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
24609
+ #elif defined( CUSTOM_TONE_MAPPING )
24610
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
24611
+ #endif
24612
+
24613
+ #ifdef SRGB_TRANSFER
24614
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
24615
+ #endif
24616
+ }`,
24617
+ depthTest: false,
24618
+ depthWrite: false
24619
+ } );
24620
+ const mesh = new Mesh( geometry, material );
24621
+ const camera = new OrthographicCamera( -1, 1, 1, -1, 0, 1 );
24622
+ let _outputColorSpace = null;
24623
+ let _outputToneMapping = null;
24624
+ let _isCompositing = false;
24625
+ let _savedToneMapping;
24626
+ let _savedRenderTarget = null;
24627
+ let _effects = [];
24628
+ let _hasRenderPass = false;
24629
+ this.setSize = function ( width, height ) {
24630
+ targetA.setSize( width, height );
24631
+ targetB.setSize( width, height );
24632
+ for ( let i = 0; i < _effects.length; i ++ ) {
24633
+ const effect = _effects[ i ];
24634
+ if ( effect.setSize ) effect.setSize( width, height );
24635
+ }
24636
+ };
24637
+ this.setEffects = function ( effects ) {
24638
+ _effects = effects;
24639
+ _hasRenderPass = _effects.length > 0 && _effects[ 0 ].isRenderPass === true;
24640
+ const width = targetA.width;
24641
+ const height = targetA.height;
24642
+ for ( let i = 0; i < _effects.length; i ++ ) {
24643
+ const effect = _effects[ i ];
24644
+ if ( effect.setSize ) effect.setSize( width, height );
24645
+ }
24646
+ };
24647
+ this.begin = function ( renderer, renderTarget ) {
24648
+ if ( _isCompositing ) return false;
24649
+ if ( renderer.toneMapping === NoToneMapping && _effects.length === 0 ) return false;
24650
+ _savedRenderTarget = renderTarget;
24651
+ if ( renderTarget !== null ) {
24652
+ const width = renderTarget.width;
24653
+ const height = renderTarget.height;
24654
+ if ( targetA.width !== width || targetA.height !== height ) {
24655
+ this.setSize( width, height );
24656
+ }
24657
+ }
24658
+ if ( _hasRenderPass === false ) {
24659
+ renderer.setRenderTarget( targetA );
24660
+ }
24661
+ _savedToneMapping = renderer.toneMapping;
24662
+ renderer.toneMapping = NoToneMapping;
24663
+ return true;
24664
+ };
24665
+ this.hasRenderPass = function () {
24666
+ return _hasRenderPass;
24667
+ };
24668
+ this.end = function ( renderer, deltaTime ) {
24669
+ renderer.toneMapping = _savedToneMapping;
24670
+ _isCompositing = true;
24671
+ let readBuffer = targetA;
24672
+ let writeBuffer = targetB;
24673
+ for ( let i = 0; i < _effects.length; i ++ ) {
24674
+ const effect = _effects[ i ];
24675
+ if ( effect.enabled === false ) continue;
24676
+ effect.render( renderer, writeBuffer, readBuffer, deltaTime );
24677
+ if ( effect.needsSwap !== false ) {
24678
+ const temp = readBuffer;
24679
+ readBuffer = writeBuffer;
24680
+ writeBuffer = temp;
24681
+ }
24682
+ }
24683
+ if ( _outputColorSpace !== renderer.outputColorSpace || _outputToneMapping !== renderer.toneMapping ) {
24684
+ _outputColorSpace = renderer.outputColorSpace;
24685
+ _outputToneMapping = renderer.toneMapping;
24686
+ material.defines = {};
24687
+ if ( ColorManagement.getTransfer( _outputColorSpace ) === SRGBTransfer ) material.defines.SRGB_TRANSFER = '';
24688
+ const toneMapping = toneMappingMap[ _outputToneMapping ];
24689
+ if ( toneMapping ) material.defines[ toneMapping ] = '';
24690
+ material.needsUpdate = true;
24691
+ }
24692
+ material.uniforms.tDiffuse.value = readBuffer.texture;
24693
+ renderer.setRenderTarget( _savedRenderTarget );
24694
+ renderer.render( mesh, camera );
24695
+ _savedRenderTarget = null;
24696
+ _isCompositing = false;
24697
+ };
24698
+ this.isCompositing = function () {
24699
+ return _isCompositing;
24700
+ };
24701
+ this.dispose = function () {
24702
+ targetA.dispose();
24703
+ targetB.dispose();
24704
+ geometry.dispose();
24705
+ material.dispose();
24706
+ };
24707
+ }
24342
24708
  const emptyTexture = new Texture();
24343
24709
  const emptyShadowTexture = new DepthTexture( 1, 1 );
24344
24710
  const emptyArrayTexture = new DataArrayTexture();
@@ -24601,7 +24967,7 @@
24601
24967
  }
24602
24968
  let emptyTexture2D;
24603
24969
  if ( this.type === gl.SAMPLER_2D_SHADOW ) {
24604
- emptyShadowTexture.compareFunction = LessEqualCompare;
24970
+ emptyShadowTexture.compareFunction = textures.isReversedDepthBuffer() ? GreaterEqualCompare : LessEqualCompare;
24605
24971
  emptyTexture2D = emptyShadowTexture;
24606
24972
  } else {
24607
24973
  emptyTexture2D = emptyTexture;
@@ -24733,8 +25099,14 @@
24733
25099
  gl.uniform1iv( this.addr, units );
24734
25100
  copyArray( cache, units );
24735
25101
  }
25102
+ let emptyTexture2D;
25103
+ if ( this.type === gl.SAMPLER_2D_SHADOW ) {
25104
+ emptyTexture2D = emptyShadowTexture;
25105
+ } else {
25106
+ emptyTexture2D = emptyTexture;
25107
+ }
24736
25108
  for ( let i = 0; i !== n; ++ i ) {
24737
- textures.setTexture2D( v[ i ] || emptyTexture, units[ i ] );
25109
+ textures.setTexture2D( v[ i ] || emptyTexture2D, units[ i ] );
24738
25110
  }
24739
25111
  }
24740
25112
  function setValueT3DArray( gl, v, textures ) {
@@ -24887,6 +25259,18 @@
24887
25259
  addr = gl.getUniformLocation( program, info.name );
24888
25260
  parseUniform( info, addr, this );
24889
25261
  }
25262
+ const shadowSamplers = [];
25263
+ const otherUniforms = [];
25264
+ for ( const u of this.seq ) {
25265
+ if ( u.type === gl.SAMPLER_2D_SHADOW || u.type === gl.SAMPLER_CUBE_SHADOW || u.type === gl.SAMPLER_2D_ARRAY_SHADOW ) {
25266
+ shadowSamplers.push( u );
25267
+ } else {
25268
+ otherUniforms.push( u );
25269
+ }
25270
+ }
25271
+ if ( shadowSamplers.length > 0 ) {
25272
+ this.seq = shadowSamplers.concat( otherUniforms );
25273
+ }
24890
25274
  }
24891
25275
  setValue( gl, name, value, textures ) {
24892
25276
  const u = this.map[ name ];
@@ -24943,7 +25327,7 @@
24943
25327
  case SRGBTransfer:
24944
25328
  return [ encodingMatrix, 'sRGBTransferOETF' ];
24945
25329
  default:
24946
- console.warn( 'THREE.WebGLProgram: Unsupported color space: ', colorSpace );
25330
+ warn( 'WebGLProgram: Unsupported color space: ', colorSpace );
24947
25331
  return [ encodingMatrix, 'LinearTransferOETF' ];
24948
25332
  }
24949
25333
  }
@@ -24968,33 +25352,20 @@
24968
25352
  '}',
24969
25353
  ].join( '\n' );
24970
25354
  }
25355
+ const toneMappingFunctions = {
25356
+ [ LinearToneMapping ]: 'Linear',
25357
+ [ ReinhardToneMapping ]: 'Reinhard',
25358
+ [ CineonToneMapping ]: 'Cineon',
25359
+ [ ACESFilmicToneMapping ]: 'ACESFilmic',
25360
+ [ AgXToneMapping ]: 'AgX',
25361
+ [ NeutralToneMapping ]: 'Neutral',
25362
+ [ CustomToneMapping ]: 'Custom'
25363
+ };
24971
25364
  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';
25365
+ const toneMappingName = toneMappingFunctions[ toneMapping ];
25366
+ if ( toneMappingName === undefined ) {
25367
+ warn( 'WebGLProgram: Unsupported toneMapping:', toneMapping );
25368
+ return 'vec3 ' + functionName + '( vec3 color ) { return LinearToneMapping( color ); }';
24998
25369
  }
24999
25370
  return 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';
25000
25371
  }
@@ -25079,7 +25450,7 @@
25079
25450
  const newInclude = shaderChunkMap.get( include );
25080
25451
  if ( newInclude !== undefined ) {
25081
25452
  string = ShaderChunk[ newInclude ];
25082
- console.warn( 'THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', include, newInclude );
25453
+ warn( 'WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', include, newInclude );
25083
25454
  } else {
25084
25455
  throw new Error( 'Can not resolve #include <' + include + '>' );
25085
25456
  }
@@ -25127,59 +25498,37 @@
25127
25498
  }
25128
25499
  return precisionstring;
25129
25500
  }
25501
+ const shadowMapTypeDefines = {
25502
+ [ PCFShadowMap ]: 'SHADOWMAP_TYPE_PCF',
25503
+ [ VSMShadowMap ]: 'SHADOWMAP_TYPE_VSM'
25504
+ };
25130
25505
  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;
25506
+ return shadowMapTypeDefines[ parameters.shadowMapType ] || 'SHADOWMAP_TYPE_BASIC';
25140
25507
  }
25508
+ const envMapTypeDefines = {
25509
+ [ CubeReflectionMapping ]: 'ENVMAP_TYPE_CUBE',
25510
+ [ CubeRefractionMapping ]: 'ENVMAP_TYPE_CUBE',
25511
+ [ CubeUVReflectionMapping ]: 'ENVMAP_TYPE_CUBE_UV'
25512
+ };
25141
25513
  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;
25514
+ if ( parameters.envMap === false ) return 'ENVMAP_TYPE_CUBE';
25515
+ return envMapTypeDefines[ parameters.envMapMode ] || 'ENVMAP_TYPE_CUBE';
25155
25516
  }
25517
+ const envMapModeDefines = {
25518
+ [ CubeRefractionMapping ]: 'ENVMAP_MODE_REFRACTION'
25519
+ };
25156
25520
  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;
25521
+ if ( parameters.envMap === false ) return 'ENVMAP_MODE_REFLECTION';
25522
+ return envMapModeDefines[ parameters.envMapMode ] || 'ENVMAP_MODE_REFLECTION';
25166
25523
  }
25524
+ const envMapBlendingDefines = {
25525
+ [ MultiplyOperation ]: 'ENVMAP_BLENDING_MULTIPLY',
25526
+ [ MixOperation ]: 'ENVMAP_BLENDING_MIX',
25527
+ [ AddOperation ]: 'ENVMAP_BLENDING_ADD'
25528
+ };
25167
25529
  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;
25530
+ if ( parameters.envMap === false ) return 'ENVMAP_BLENDING_NONE';
25531
+ return envMapBlendingDefines[ parameters.combine ] || 'ENVMAP_BLENDING_NONE';
25183
25532
  }
25184
25533
  function generateCubeUVSize( parameters ) {
25185
25534
  const imageHeight = parameters.envMapCubeUVHeight;
@@ -25495,7 +25844,7 @@
25495
25844
  } else {
25496
25845
  const vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );
25497
25846
  const fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );
25498
- console.error(
25847
+ error(
25499
25848
  'THREE.WebGLProgram: Shader Error ' + gl.getError() + ' - ' +
25500
25849
  'VALIDATE_STATUS ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ) + '\n\n' +
25501
25850
  'Material Name: ' + self.name + '\n' +
@@ -25506,7 +25855,7 @@
25506
25855
  );
25507
25856
  }
25508
25857
  } else if ( programLog !== '' ) {
25509
- console.warn( 'THREE.WebGLProgram: Program Info Log:', programLog );
25858
+ warn( 'WebGLProgram: Program Info Log:', programLog );
25510
25859
  } else if ( vertexLog === '' || fragmentLog === '' ) {
25511
25860
  haveDiagnostics = false;
25512
25861
  }
@@ -25638,12 +25987,12 @@
25638
25987
  const _customShaders = new WebGLShaderCache();
25639
25988
  const _activeChannels = new Set();
25640
25989
  const programs = [];
25990
+ const programsMap = new Map();
25641
25991
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
25642
- const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
25643
25992
  let precision = capabilities.precision;
25644
25993
  const shaderIDs = {
25645
25994
  MeshDepthMaterial: 'depth',
25646
- MeshDistanceMaterial: 'distanceRGBA',
25995
+ MeshDistanceMaterial: 'distance',
25647
25996
  MeshNormalMaterial: 'normal',
25648
25997
  MeshBasicMaterial: 'basic',
25649
25998
  MeshLambertMaterial: 'lambert',
@@ -25673,7 +26022,7 @@
25673
26022
  if ( material.precision !== null ) {
25674
26023
  precision = capabilities.getMaxPrecision( material.precision );
25675
26024
  if ( precision !== material.precision ) {
25676
- console.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );
26025
+ warn( 'WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );
25677
26026
  }
25678
26027
  }
25679
26028
  const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
@@ -25757,7 +26106,6 @@
25757
26106
  instancing: IS_INSTANCEDMESH,
25758
26107
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
25759
26108
  instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
25760
- supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
25761
26109
  outputColorSpace: ( currentRenderTarget === null ) ? renderer.outputColorSpace : ( currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace ),
25762
26110
  alphaToCoverage: !! material.alphaToCoverage,
25763
26111
  map: HAS_MAP,
@@ -25769,7 +26117,7 @@
25769
26117
  lightMap: HAS_LIGHTMAP,
25770
26118
  bumpMap: HAS_BUMPMAP,
25771
26119
  normalMap: HAS_NORMALMAP,
25772
- displacementMap: SUPPORTS_VERTEX_TEXTURES && HAS_DISPLACEMENTMAP,
26120
+ displacementMap: HAS_DISPLACEMENTMAP,
25773
26121
  emissiveMap: HAS_EMISSIVEMAP,
25774
26122
  normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
25775
26123
  normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
@@ -25950,52 +26298,50 @@
25950
26298
  }
25951
26299
  function getProgramCacheKeyBooleans( array, parameters ) {
25952
26300
  _programLayers.disableAll();
25953
- if ( parameters.supportsVertexTextures )
25954
- _programLayers.enable( 0 );
25955
26301
  if ( parameters.instancing )
25956
- _programLayers.enable( 1 );
26302
+ _programLayers.enable( 0 );
25957
26303
  if ( parameters.instancingColor )
25958
- _programLayers.enable( 2 );
26304
+ _programLayers.enable( 1 );
25959
26305
  if ( parameters.instancingMorph )
25960
- _programLayers.enable( 3 );
26306
+ _programLayers.enable( 2 );
25961
26307
  if ( parameters.matcap )
25962
- _programLayers.enable( 4 );
26308
+ _programLayers.enable( 3 );
25963
26309
  if ( parameters.envMap )
25964
- _programLayers.enable( 5 );
26310
+ _programLayers.enable( 4 );
25965
26311
  if ( parameters.normalMapObjectSpace )
25966
- _programLayers.enable( 6 );
26312
+ _programLayers.enable( 5 );
25967
26313
  if ( parameters.normalMapTangentSpace )
25968
- _programLayers.enable( 7 );
26314
+ _programLayers.enable( 6 );
25969
26315
  if ( parameters.clearcoat )
25970
- _programLayers.enable( 8 );
26316
+ _programLayers.enable( 7 );
25971
26317
  if ( parameters.iridescence )
25972
- _programLayers.enable( 9 );
26318
+ _programLayers.enable( 8 );
25973
26319
  if ( parameters.alphaTest )
25974
- _programLayers.enable( 10 );
26320
+ _programLayers.enable( 9 );
25975
26321
  if ( parameters.vertexColors )
25976
- _programLayers.enable( 11 );
26322
+ _programLayers.enable( 10 );
25977
26323
  if ( parameters.vertexAlphas )
25978
- _programLayers.enable( 12 );
26324
+ _programLayers.enable( 11 );
25979
26325
  if ( parameters.vertexUv1s )
25980
- _programLayers.enable( 13 );
26326
+ _programLayers.enable( 12 );
25981
26327
  if ( parameters.vertexUv2s )
25982
- _programLayers.enable( 14 );
26328
+ _programLayers.enable( 13 );
25983
26329
  if ( parameters.vertexUv3s )
25984
- _programLayers.enable( 15 );
26330
+ _programLayers.enable( 14 );
25985
26331
  if ( parameters.vertexTangents )
25986
- _programLayers.enable( 16 );
26332
+ _programLayers.enable( 15 );
25987
26333
  if ( parameters.anisotropy )
25988
- _programLayers.enable( 17 );
26334
+ _programLayers.enable( 16 );
25989
26335
  if ( parameters.alphaHash )
25990
- _programLayers.enable( 18 );
26336
+ _programLayers.enable( 17 );
25991
26337
  if ( parameters.batching )
25992
- _programLayers.enable( 19 );
26338
+ _programLayers.enable( 18 );
25993
26339
  if ( parameters.dispersion )
25994
- _programLayers.enable( 20 );
26340
+ _programLayers.enable( 19 );
25995
26341
  if ( parameters.batchingColor )
25996
- _programLayers.enable( 21 );
26342
+ _programLayers.enable( 20 );
25997
26343
  if ( parameters.gradientMap )
25998
- _programLayers.enable( 22 );
26344
+ _programLayers.enable( 21 );
25999
26345
  array.push( _programLayers.mask );
26000
26346
  _programLayers.disableAll();
26001
26347
  if ( parameters.fog )
@@ -26056,18 +26402,13 @@
26056
26402
  return uniforms;
26057
26403
  }
26058
26404
  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 ) {
26405
+ let program = programsMap.get( cacheKey );
26406
+ if ( program !== undefined ) {
26407
+ ++ program.usedTimes;
26408
+ } else {
26069
26409
  program = new WebGLProgram( renderer, cacheKey, parameters, bindingStates );
26070
26410
  programs.push( program );
26411
+ programsMap.set( cacheKey, program );
26071
26412
  }
26072
26413
  return program;
26073
26414
  }
@@ -26076,6 +26417,7 @@
26076
26417
  const i = programs.indexOf( program );
26077
26418
  programs[ i ] = programs[ programs.length - 1 ];
26078
26419
  programs.pop();
26420
+ programsMap.delete( program.cacheKey );
26079
26421
  program.destroy();
26080
26422
  }
26081
26423
  }
@@ -26428,7 +26770,14 @@
26428
26770
  const color = light.color;
26429
26771
  const intensity = light.intensity;
26430
26772
  const distance = light.distance;
26431
- const shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null;
26773
+ let shadowMap = null;
26774
+ if ( light.shadow && light.shadow.map ) {
26775
+ if ( light.shadow.map.texture.format === RGFormat ) {
26776
+ shadowMap = light.shadow.map.texture;
26777
+ } else {
26778
+ shadowMap = light.shadow.map.depthTexture || light.shadow.map.texture;
26779
+ }
26780
+ }
26432
26781
  if ( light.isAmbientLight ) {
26433
26782
  r += color.r * intensity;
26434
26783
  g += color.g * intensity;
@@ -26696,13 +27045,24 @@
26696
27045
  };
26697
27046
  }
26698
27047
  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}";
27048
+ 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}";
27049
+ const _cubeDirections = [
27050
+ new Vector3( 1, 0, 0 ), new Vector3( -1, 0, 0 ), new Vector3( 0, 1, 0 ),
27051
+ new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, -1 )
27052
+ ];
27053
+ const _cubeUps = [
27054
+ new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 ), new Vector3( 0, 0, 1 ),
27055
+ new Vector3( 0, 0, -1 ), new Vector3( 0, -1, 0 ), new Vector3( 0, -1, 0 )
27056
+ ];
27057
+ const _projScreenMatrix = new Matrix4();
27058
+ const _lightPositionWorld = new Vector3();
27059
+ const _lookTarget = new Vector3();
26700
27060
  function WebGLShadowMap( renderer, objects, capabilities ) {
26701
27061
  let _frustum = new Frustum();
26702
27062
  const _shadowMapSize = new Vector2(),
26703
27063
  _viewportSize = new Vector2(),
26704
27064
  _viewport = new Vector4(),
26705
- _depthMaterial = new MeshDepthMaterial( { depthPacking: RGBADepthPacking } ),
27065
+ _depthMaterial = new MeshDepthMaterial(),
26706
27066
  _distanceMaterial = new MeshDistanceMaterial(),
26707
27067
  _materialCache = {},
26708
27068
  _maxTextureSize = capabilities.maxTextureSize;
@@ -26740,6 +27100,10 @@
26740
27100
  if ( scope.enabled === false ) return;
26741
27101
  if ( scope.autoUpdate === false && scope.needsUpdate === false ) return;
26742
27102
  if ( lights.length === 0 ) return;
27103
+ if ( lights.type === PCFSoftShadowMap ) {
27104
+ warn( 'WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.' );
27105
+ lights.type = PCFShadowMap;
27106
+ }
26743
27107
  const currentRenderTarget = renderer.getRenderTarget();
26744
27108
  const activeCubeFace = renderer.getActiveCubeFace();
26745
27109
  const activeMipmapLevel = renderer.getActiveMipmapLevel();
@@ -26752,13 +27116,23 @@
26752
27116
  }
26753
27117
  _state.buffers.depth.setTest( true );
26754
27118
  _state.setScissorTest( false );
26755
- const toVSM = ( _previousType !== VSMShadowMap && this.type === VSMShadowMap );
26756
- const fromVSM = ( _previousType === VSMShadowMap && this.type !== VSMShadowMap );
27119
+ const typeChanged = _previousType !== this.type;
27120
+ if ( typeChanged ) {
27121
+ scene.traverse( function ( object ) {
27122
+ if ( object.material ) {
27123
+ if ( Array.isArray( object.material ) ) {
27124
+ object.material.forEach( mat => mat.needsUpdate = true );
27125
+ } else {
27126
+ object.material.needsUpdate = true;
27127
+ }
27128
+ }
27129
+ } );
27130
+ }
26757
27131
  for ( let i = 0, il = lights.length; i < il; i ++ ) {
26758
27132
  const light = lights[ i ];
26759
27133
  const shadow = light.shadow;
26760
27134
  if ( shadow === undefined ) {
26761
- console.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' );
27135
+ warn( 'WebGLShadowMap:', light, 'has no shadow.' );
26762
27136
  continue;
26763
27137
  }
26764
27138
  if ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue;
@@ -26778,28 +27152,96 @@
26778
27152
  shadow.mapSize.y = _viewportSize.y;
26779
27153
  }
26780
27154
  }
26781
- if ( shadow.map === null || toVSM === true || fromVSM === true ) {
26782
- const pars = ( this.type !== VSMShadowMap ) ? { minFilter: NearestFilter, magFilter: NearestFilter } : {};
27155
+ if ( shadow.map === null || typeChanged === true ) {
26783
27156
  if ( shadow.map !== null ) {
27157
+ if ( shadow.map.depthTexture !== null ) {
27158
+ shadow.map.depthTexture.dispose();
27159
+ shadow.map.depthTexture = null;
27160
+ }
26784
27161
  shadow.map.dispose();
26785
27162
  }
26786
- shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );
26787
- shadow.map.texture.name = light.name + '.shadowMap';
27163
+ if ( this.type === VSMShadowMap ) {
27164
+ if ( light.isPointLight ) {
27165
+ warn( 'WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.' );
27166
+ continue;
27167
+ }
27168
+ shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, {
27169
+ format: RGFormat,
27170
+ type: HalfFloatType,
27171
+ minFilter: LinearFilter,
27172
+ magFilter: LinearFilter,
27173
+ generateMipmaps: false
27174
+ } );
27175
+ shadow.map.texture.name = light.name + '.shadowMap';
27176
+ shadow.map.depthTexture = new DepthTexture( _shadowMapSize.x, _shadowMapSize.y, FloatType );
27177
+ shadow.map.depthTexture.name = light.name + '.shadowMapDepth';
27178
+ shadow.map.depthTexture.format = DepthFormat;
27179
+ shadow.map.depthTexture.compareFunction = null;
27180
+ shadow.map.depthTexture.minFilter = NearestFilter;
27181
+ shadow.map.depthTexture.magFilter = NearestFilter;
27182
+ } else {
27183
+ if ( light.isPointLight ) {
27184
+ shadow.map = new WebGLCubeRenderTarget( _shadowMapSize.x );
27185
+ shadow.map.depthTexture = new CubeDepthTexture( _shadowMapSize.x, UnsignedIntType );
27186
+ } else {
27187
+ shadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y );
27188
+ shadow.map.depthTexture = new DepthTexture( _shadowMapSize.x, _shadowMapSize.y, UnsignedIntType );
27189
+ }
27190
+ shadow.map.depthTexture.name = light.name + '.shadowMap';
27191
+ shadow.map.depthTexture.format = DepthFormat;
27192
+ const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
27193
+ if ( this.type === PCFShadowMap ) {
27194
+ shadow.map.depthTexture.compareFunction = reversedDepthBuffer ? GreaterEqualCompare : LessEqualCompare;
27195
+ shadow.map.depthTexture.minFilter = LinearFilter;
27196
+ shadow.map.depthTexture.magFilter = LinearFilter;
27197
+ } else {
27198
+ shadow.map.depthTexture.compareFunction = null;
27199
+ shadow.map.depthTexture.minFilter = NearestFilter;
27200
+ shadow.map.depthTexture.magFilter = NearestFilter;
27201
+ }
27202
+ }
26788
27203
  shadow.camera.updateProjectionMatrix();
26789
27204
  }
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 );
27205
+ const faceCount = shadow.map.isWebGLCubeRenderTarget ? 6 : 1;
27206
+ for ( let face = 0; face < faceCount; face ++ ) {
27207
+ if ( shadow.map.isWebGLCubeRenderTarget ) {
27208
+ renderer.setRenderTarget( shadow.map, face );
27209
+ renderer.clear();
27210
+ } else {
27211
+ if ( face === 0 ) {
27212
+ renderer.setRenderTarget( shadow.map );
27213
+ renderer.clear();
27214
+ }
27215
+ const viewport = shadow.getViewport( face );
27216
+ _viewport.set(
27217
+ _viewportSize.x * viewport.x,
27218
+ _viewportSize.y * viewport.y,
27219
+ _viewportSize.x * viewport.z,
27220
+ _viewportSize.y * viewport.w
27221
+ );
27222
+ _state.viewport( _viewport );
27223
+ }
27224
+ if ( light.isPointLight ) {
27225
+ const camera = shadow.camera;
27226
+ const shadowMatrix = shadow.matrix;
27227
+ const far = light.distance || camera.far;
27228
+ if ( far !== camera.far ) {
27229
+ camera.far = far;
27230
+ camera.updateProjectionMatrix();
27231
+ }
27232
+ _lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
27233
+ camera.position.copy( _lightPositionWorld );
27234
+ _lookTarget.copy( camera.position );
27235
+ _lookTarget.add( _cubeDirections[ face ] );
27236
+ camera.up.copy( _cubeUps[ face ] );
27237
+ camera.lookAt( _lookTarget );
27238
+ camera.updateMatrixWorld();
27239
+ shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
27240
+ _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
27241
+ shadow._frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
27242
+ } else {
27243
+ shadow.updateMatrices( light );
27244
+ }
26803
27245
  _frustum = shadow.getFrustum();
26804
27246
  renderObject( scene, camera, shadow.camera, light, this.type );
26805
27247
  }
@@ -26821,9 +27263,12 @@
26821
27263
  shadowMaterialHorizontal.needsUpdate = true;
26822
27264
  }
26823
27265
  if ( shadow.mapPass === null ) {
26824
- shadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y );
27266
+ shadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, {
27267
+ format: RGFormat,
27268
+ type: HalfFloatType
27269
+ } );
26825
27270
  }
26826
- shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
27271
+ shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.depthTexture;
26827
27272
  shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
26828
27273
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
26829
27274
  renderer.setRenderTarget( shadow.mapPass );
@@ -27328,7 +27773,7 @@
27328
27773
  gl.blendFuncSeparate( gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
27329
27774
  break;
27330
27775
  default:
27331
- console.error( 'THREE.WebGLState: Invalid blending: ', blending );
27776
+ error( 'WebGLState: Invalid blending: ', blending );
27332
27777
  break;
27333
27778
  }
27334
27779
  } else {
@@ -27340,13 +27785,13 @@
27340
27785
  gl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE );
27341
27786
  break;
27342
27787
  case SubtractiveBlending:
27343
- console.error( 'THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true' );
27788
+ error( 'WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true' );
27344
27789
  break;
27345
27790
  case MultiplyBlending:
27346
- console.error( 'THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true' );
27791
+ error( 'WebGLState: MultiplyBlending requires material.premultipliedAlpha = true' );
27347
27792
  break;
27348
27793
  default:
27349
- console.error( 'THREE.WebGLState: Invalid blending: ', blending );
27794
+ error( 'WebGLState: Invalid blending: ', blending );
27350
27795
  break;
27351
27796
  }
27352
27797
  }
@@ -27503,71 +27948,71 @@
27503
27948
  function compressedTexImage2D() {
27504
27949
  try {
27505
27950
  gl.compressedTexImage2D( ...arguments );
27506
- } catch ( error ) {
27507
- console.error( 'THREE.WebGLState:', error );
27951
+ } catch ( e ) {
27952
+ error( 'WebGLState:', e );
27508
27953
  }
27509
27954
  }
27510
27955
  function compressedTexImage3D() {
27511
27956
  try {
27512
27957
  gl.compressedTexImage3D( ...arguments );
27513
- } catch ( error ) {
27514
- console.error( 'THREE.WebGLState:', error );
27958
+ } catch ( e ) {
27959
+ error( 'WebGLState:', e );
27515
27960
  }
27516
27961
  }
27517
27962
  function texSubImage2D() {
27518
27963
  try {
27519
27964
  gl.texSubImage2D( ...arguments );
27520
- } catch ( error ) {
27521
- console.error( 'THREE.WebGLState:', error );
27965
+ } catch ( e ) {
27966
+ error( 'WebGLState:', e );
27522
27967
  }
27523
27968
  }
27524
27969
  function texSubImage3D() {
27525
27970
  try {
27526
27971
  gl.texSubImage3D( ...arguments );
27527
- } catch ( error ) {
27528
- console.error( 'THREE.WebGLState:', error );
27972
+ } catch ( e ) {
27973
+ error( 'WebGLState:', e );
27529
27974
  }
27530
27975
  }
27531
27976
  function compressedTexSubImage2D() {
27532
27977
  try {
27533
27978
  gl.compressedTexSubImage2D( ...arguments );
27534
- } catch ( error ) {
27535
- console.error( 'THREE.WebGLState:', error );
27979
+ } catch ( e ) {
27980
+ error( 'WebGLState:', e );
27536
27981
  }
27537
27982
  }
27538
27983
  function compressedTexSubImage3D() {
27539
27984
  try {
27540
27985
  gl.compressedTexSubImage3D( ...arguments );
27541
- } catch ( error ) {
27542
- console.error( 'THREE.WebGLState:', error );
27986
+ } catch ( e ) {
27987
+ error( 'WebGLState:', e );
27543
27988
  }
27544
27989
  }
27545
27990
  function texStorage2D() {
27546
27991
  try {
27547
27992
  gl.texStorage2D( ...arguments );
27548
- } catch ( error ) {
27549
- console.error( 'THREE.WebGLState:', error );
27993
+ } catch ( e ) {
27994
+ error( 'WebGLState:', e );
27550
27995
  }
27551
27996
  }
27552
27997
  function texStorage3D() {
27553
27998
  try {
27554
27999
  gl.texStorage3D( ...arguments );
27555
- } catch ( error ) {
27556
- console.error( 'THREE.WebGLState:', error );
28000
+ } catch ( e ) {
28001
+ error( 'WebGLState:', e );
27557
28002
  }
27558
28003
  }
27559
28004
  function texImage2D() {
27560
28005
  try {
27561
28006
  gl.texImage2D( ...arguments );
27562
- } catch ( error ) {
27563
- console.error( 'THREE.WebGLState:', error );
28007
+ } catch ( e ) {
28008
+ error( 'WebGLState:', e );
27564
28009
  }
27565
28010
  }
27566
28011
  function texImage3D() {
27567
28012
  try {
27568
28013
  gl.texImage3D( ...arguments );
27569
- } catch ( error ) {
27570
- console.error( 'THREE.WebGLState:', error );
28014
+ } catch ( e ) {
28015
+ error( 'WebGLState:', e );
27571
28016
  }
27572
28017
  }
27573
28018
  function scissor( scissor ) {
@@ -27738,11 +28183,11 @@
27738
28183
  canvas.height = height;
27739
28184
  const context = canvas.getContext( '2d' );
27740
28185
  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 + ').' );
28186
+ warn( 'WebGLRenderer: Texture has been resized from (' + dimensions.width + 'x' + dimensions.height + ') to (' + width + 'x' + height + ').' );
27742
28187
  return canvas;
27743
28188
  } else {
27744
28189
  if ( 'data' in image ) {
27745
- console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + dimensions.width + 'x' + dimensions.height + ').' );
28190
+ warn( 'WebGLRenderer: Image in DataTexture is too big (' + dimensions.width + 'x' + dimensions.height + ').' );
27746
28191
  }
27747
28192
  return image;
27748
28193
  }
@@ -27764,7 +28209,7 @@
27764
28209
  function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
27765
28210
  if ( internalFormatName !== null ) {
27766
28211
  if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
27767
- console.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' );
28212
+ warn( 'WebGLRenderer: Attempt to use non-existing WebGL internal format \'' + internalFormatName + '\'' );
27768
28213
  }
27769
28214
  let internalFormat = glFormat;
27770
28215
  if ( glFormat === _gl.RED ) {
@@ -27837,7 +28282,7 @@
27837
28282
  glInternalFormat = _gl.DEPTH32F_STENCIL8;
27838
28283
  } else if ( depthType === UnsignedShortType ) {
27839
28284
  glInternalFormat = _gl.DEPTH24_STENCIL8;
27840
- console.warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
28285
+ warn( 'DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.' );
27841
28286
  }
27842
28287
  } else {
27843
28288
  if ( depthType === null || depthType === UnsignedIntType || depthType === UnsignedInt248Type ) {
@@ -27947,7 +28392,7 @@
27947
28392
  function allocateTextureUnit() {
27948
28393
  const textureUnit = textureUnits;
27949
28394
  if ( textureUnit >= capabilities.maxTextures ) {
27950
- console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
28395
+ warn( 'WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
27951
28396
  }
27952
28397
  textureUnits += 1;
27953
28398
  return textureUnit;
@@ -27976,9 +28421,9 @@
27976
28421
  if ( texture.isRenderTargetTexture === false && texture.isExternalTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
27977
28422
  const image = texture.image;
27978
28423
  if ( image === null ) {
27979
- console.warn( 'THREE.WebGLRenderer: Texture marked for update but no image data found.' );
28424
+ warn( 'WebGLRenderer: Texture marked for update but no image data found.' );
27980
28425
  } else if ( image.complete === false ) {
27981
- console.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );
28426
+ warn( 'WebGLRenderer: Texture marked for update but image is incomplete' );
27982
28427
  } else {
27983
28428
  uploadTexture( textureProperties, texture, slot );
27984
28429
  return;
@@ -27993,6 +28438,8 @@
27993
28438
  if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
27994
28439
  uploadTexture( textureProperties, texture, slot );
27995
28440
  return;
28441
+ } else if ( texture.isExternalTexture ) {
28442
+ textureProperties.__webglTexture = texture.sourceTexture ? texture.sourceTexture : null;
27996
28443
  }
27997
28444
  state.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
27998
28445
  }
@@ -28006,7 +28453,7 @@
28006
28453
  }
28007
28454
  function setTextureCube( texture, slot ) {
28008
28455
  const textureProperties = properties.get( texture );
28009
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
28456
+ if ( texture.isCubeDepthTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
28010
28457
  uploadCubeTexture( textureProperties, texture, slot );
28011
28458
  return;
28012
28459
  }
@@ -28039,7 +28486,7 @@
28039
28486
  if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
28040
28487
  ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
28041
28488
  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.' );
28489
+ warn( 'WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.' );
28043
28490
  }
28044
28491
  _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
28045
28492
  _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
@@ -28247,7 +28694,7 @@
28247
28694
  state.compressedTexImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, mipmap.data, 0, 0 );
28248
28695
  }
28249
28696
  } else {
28250
- console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28697
+ warn( 'WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28251
28698
  }
28252
28699
  } else {
28253
28700
  if ( useTexStorage ) {
@@ -28275,7 +28722,7 @@
28275
28722
  state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
28276
28723
  }
28277
28724
  } else {
28278
- console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28725
+ warn( 'WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
28279
28726
  }
28280
28727
  } else {
28281
28728
  if ( useTexStorage ) {
@@ -28428,7 +28875,7 @@
28428
28875
  state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
28429
28876
  }
28430
28877
  } else {
28431
- console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );
28878
+ warn( 'WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );
28432
28879
  }
28433
28880
  } else {
28434
28881
  if ( useTexStorage ) {
@@ -28521,19 +28968,17 @@
28521
28968
  }
28522
28969
  state.bindFramebuffer( _gl.FRAMEBUFFER, null );
28523
28970
  }
28524
- function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
28971
+ function setupRenderBufferStorage( renderbuffer, renderTarget, useMultisample ) {
28525
28972
  _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
28526
28973
  if ( renderTarget.depthBuffer ) {
28527
28974
  const depthTexture = renderTarget.depthTexture;
28528
28975
  const depthType = depthTexture && depthTexture.isDepthTexture ? depthTexture.type : null;
28529
28976
  const glInternalFormat = getInternalDepthFormat( renderTarget.stencilBuffer, depthType );
28530
28977
  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 );
28978
+ if ( useMultisampledRTT( renderTarget ) ) {
28979
+ multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28980
+ } else if ( useMultisample ) {
28981
+ _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28537
28982
  } else {
28538
28983
  _gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
28539
28984
  }
@@ -28545,11 +28990,10 @@
28545
28990
  const glFormat = utils.convert( texture.format, texture.colorSpace );
28546
28991
  const glType = utils.convert( texture.type );
28547
28992
  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 );
28993
+ if ( useMultisampledRTT( renderTarget ) ) {
28994
+ multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28995
+ } else if ( useMultisample ) {
28996
+ _gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
28553
28997
  } else {
28554
28998
  _gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
28555
28999
  }
@@ -28557,9 +29001,8 @@
28557
29001
  }
28558
29002
  _gl.bindRenderbuffer( _gl.RENDERBUFFER, null );
28559
29003
  }
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' );
29004
+ function setupDepthTexture( framebuffer, renderTarget, cubeFace ) {
29005
+ const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
28563
29006
  state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
28564
29007
  if ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {
28565
29008
  throw new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );
@@ -28573,20 +29016,45 @@
28573
29016
  renderTarget.depthTexture.image.height = renderTarget.height;
28574
29017
  renderTarget.depthTexture.needsUpdate = true;
28575
29018
  }
28576
- setTexture2D( renderTarget.depthTexture, 0 );
29019
+ if ( isCube ) {
29020
+ if ( textureProperties.__webglInit === undefined ) {
29021
+ textureProperties.__webglInit = true;
29022
+ renderTarget.depthTexture.addEventListener( 'dispose', onTextureDispose );
29023
+ }
29024
+ if ( textureProperties.__webglTexture === undefined ) {
29025
+ textureProperties.__webglTexture = _gl.createTexture();
29026
+ state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
29027
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.depthTexture );
29028
+ const glFormat = utils.convert( renderTarget.depthTexture.format );
29029
+ const glType = utils.convert( renderTarget.depthTexture.type );
29030
+ let glInternalFormat;
29031
+ if ( renderTarget.depthTexture.format === DepthFormat ) {
29032
+ glInternalFormat = _gl.DEPTH_COMPONENT24;
29033
+ } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
29034
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
29035
+ }
29036
+ for ( let i = 0; i < 6; i ++ ) {
29037
+ _gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
29038
+ }
29039
+ }
29040
+ } else {
29041
+ setTexture2D( renderTarget.depthTexture, 0 );
29042
+ }
28577
29043
  const webglDepthTexture = textureProperties.__webglTexture;
28578
29044
  const samples = getRenderTargetSamples( renderTarget );
29045
+ const glTextureType = isCube ? _gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace : _gl.TEXTURE_2D;
29046
+ const glAttachmentType = renderTarget.depthTexture.format === DepthStencilFormat ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
28579
29047
  if ( renderTarget.depthTexture.format === DepthFormat ) {
28580
29048
  if ( useMultisampledRTT( renderTarget ) ) {
28581
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
29049
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
28582
29050
  } else {
28583
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
29051
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
28584
29052
  }
28585
29053
  } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
28586
29054
  if ( useMultisampledRTT( renderTarget ) ) {
28587
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0, samples );
29055
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
28588
29056
  } else {
28589
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );
29057
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
28590
29058
  }
28591
29059
  } else {
28592
29060
  throw new Error( 'Unknown depthTexture format' );
@@ -28612,12 +29080,17 @@
28612
29080
  renderTargetProperties.__boundDepthTexture = depthTexture;
28613
29081
  }
28614
29082
  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 );
29083
+ if ( isCube ) {
29084
+ for ( let i = 0; i < 6; i ++ ) {
29085
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, i );
29086
+ }
28619
29087
  } else {
28620
- setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );
29088
+ const mipmaps = renderTarget.texture.mipmaps;
29089
+ if ( mipmaps && mipmaps.length > 0 ) {
29090
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer[ 0 ], renderTarget, 0 );
29091
+ } else {
29092
+ setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget, 0 );
29093
+ }
28621
29094
  }
28622
29095
  } else {
28623
29096
  if ( isCube ) {
@@ -28891,10 +29364,10 @@
28891
29364
  if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
28892
29365
  if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
28893
29366
  if ( format !== RGBAFormat || type !== UnsignedByteType ) {
28894
- console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
29367
+ warn( 'WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
28895
29368
  }
28896
29369
  } else {
28897
- console.error( 'THREE.WebGLTextures: Unsupported texture color space:', colorSpace );
29370
+ error( 'WebGLTextures: Unsupported texture color space:', colorSpace );
28898
29371
  }
28899
29372
  }
28900
29373
  return image;
@@ -28925,6 +29398,9 @@
28925
29398
  this.setupDepthRenderbuffer = setupDepthRenderbuffer;
28926
29399
  this.setupFrameBufferTexture = setupFrameBufferTexture;
28927
29400
  this.useMultisampledRTT = useMultisampledRTT;
29401
+ this.isReversedDepthBuffer = function () {
29402
+ return state.buffers.depth.getReversed();
29403
+ };
28928
29404
  }
28929
29405
  function WebGLUtils( gl, extensions ) {
28930
29406
  function convert( p, colorSpace = NoColorSpace ) {
@@ -28986,11 +29462,15 @@
28986
29462
  return null;
28987
29463
  }
28988
29464
  }
28989
- if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
29465
+ 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
29466
  extension = extensions.get( 'WEBGL_compressed_texture_etc' );
28991
29467
  if ( extension !== null ) {
28992
29468
  if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
28993
29469
  if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
29470
+ if ( p === R11_EAC_Format ) return extension.COMPRESSED_R11_EAC;
29471
+ if ( p === SIGNED_R11_EAC_Format ) return extension.COMPRESSED_SIGNED_R11_EAC;
29472
+ if ( p === RG11_EAC_Format ) return extension.COMPRESSED_RG11_EAC;
29473
+ if ( p === SIGNED_RG11_EAC_Format ) return extension.COMPRESSED_SIGNED_RG11_EAC;
28994
29474
  } else {
28995
29475
  return null;
28996
29476
  }
@@ -29222,13 +29702,13 @@ void main() {
29222
29702
  this.setFramebufferScaleFactor = function ( value ) {
29223
29703
  framebufferScaleFactor = value;
29224
29704
  if ( scope.isPresenting === true ) {
29225
- console.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' );
29705
+ warn( 'WebXRManager: Cannot change framebuffer scale while presenting.' );
29226
29706
  }
29227
29707
  };
29228
29708
  this.setReferenceSpaceType = function ( value ) {
29229
29709
  referenceSpaceType = value;
29230
29710
  if ( scope.isPresenting === true ) {
29231
- console.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' );
29711
+ warn( 'WebXRManager: Cannot change reference space type while presenting.' );
29232
29712
  }
29233
29713
  };
29234
29714
  this.getReferenceSpace = function () {
@@ -29955,7 +30435,7 @@ void main() {
29955
30435
  return i;
29956
30436
  }
29957
30437
  }
29958
- console.error( 'THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.' );
30438
+ error( 'WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.' );
29959
30439
  return 0;
29960
30440
  }
29961
30441
  function updateBufferData( uniformsGroup ) {
@@ -30082,9 +30562,9 @@ void main() {
30082
30562
  info.boundary = 64;
30083
30563
  info.storage = 64;
30084
30564
  } else if ( value.isTexture ) {
30085
- console.warn( 'THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.' );
30565
+ warn( 'WebGLRenderer: Texture samplers can not be part of an uniforms group.' );
30086
30566
  } else {
30087
- console.warn( 'THREE.WebGLRenderer: Unsupported uniform value type.', value );
30567
+ warn( 'WebGLRenderer: Unsupported uniform value type.', value );
30088
30568
  }
30089
30569
  return info;
30090
30570
  }
@@ -30111,6 +30591,38 @@ void main() {
30111
30591
  dispose: dispose
30112
30592
  };
30113
30593
  }
30594
+ const DATA = new Uint16Array( [
30595
+ 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,
30596
+ 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,
30597
+ 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,
30598
+ 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,
30599
+ 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,
30600
+ 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,
30601
+ 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,
30602
+ 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,
30603
+ 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,
30604
+ 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,
30605
+ 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,
30606
+ 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,
30607
+ 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,
30608
+ 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,
30609
+ 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,
30610
+ 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
30611
+ ] );
30612
+ let lut = null;
30613
+ function getDFGLUT() {
30614
+ if ( lut === null ) {
30615
+ lut = new DataTexture( DATA, 16, 16, RGFormat, HalfFloatType );
30616
+ lut.name = 'DFG_LUT';
30617
+ lut.minFilter = LinearFilter;
30618
+ lut.magFilter = LinearFilter;
30619
+ lut.wrapS = ClampToEdgeWrapping;
30620
+ lut.wrapT = ClampToEdgeWrapping;
30621
+ lut.generateMipmaps = false;
30622
+ lut.needsUpdate = true;
30623
+ }
30624
+ return lut;
30625
+ }
30114
30626
  class WebGLRenderer {
30115
30627
  constructor( parameters = {} ) {
30116
30628
  const {
@@ -30125,6 +30637,7 @@ void main() {
30125
30637
  powerPreference = 'default',
30126
30638
  failIfMajorPerformanceCaveat = false,
30127
30639
  reversedDepthBuffer = false,
30640
+ outputBufferType = UnsignedByteType,
30128
30641
  } = parameters;
30129
30642
  this.isWebGLRenderer = true;
30130
30643
  let _alpha;
@@ -30136,12 +30649,27 @@ void main() {
30136
30649
  } else {
30137
30650
  _alpha = alpha;
30138
30651
  }
30652
+ const _outputBufferType = outputBufferType;
30653
+ const INTEGER_FORMATS = new Set( [
30654
+ RGBAIntegerFormat,
30655
+ RGIntegerFormat,
30656
+ RedIntegerFormat
30657
+ ] );
30658
+ const UNSIGNED_TYPES = new Set( [
30659
+ UnsignedByteType,
30660
+ UnsignedIntType,
30661
+ UnsignedShortType,
30662
+ UnsignedInt248Type,
30663
+ UnsignedShort4444Type,
30664
+ UnsignedShort5551Type
30665
+ ] );
30139
30666
  const uintClearColor = new Uint32Array( 4 );
30140
30667
  const intClearColor = new Int32Array( 4 );
30141
30668
  let currentRenderList = null;
30142
30669
  let currentRenderState = null;
30143
30670
  const renderListStack = [];
30144
30671
  const renderStateStack = [];
30672
+ let output = null;
30145
30673
  this.domElement = canvas;
30146
30674
  this.debug = {
30147
30675
  checkShaderErrors: true,
@@ -30219,9 +30747,9 @@ void main() {
30219
30747
  }
30220
30748
  }
30221
30749
  }
30222
- } catch ( error ) {
30223
- console.error( 'THREE.WebGLRenderer: ' + error.message );
30224
- throw error;
30750
+ } catch ( e ) {
30751
+ error( 'WebGLRenderer: ' + e.message );
30752
+ throw e;
30225
30753
  }
30226
30754
  let extensions, capabilities, state, info;
30227
30755
  let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
@@ -30267,6 +30795,9 @@ void main() {
30267
30795
  _this.info = info;
30268
30796
  }
30269
30797
  initGLContext();
30798
+ if ( _outputBufferType !== UnsignedByteType ) {
30799
+ output = new WebGLOutput( _outputBufferType, canvas.width, canvas.height, depth, stencil );
30800
+ }
30270
30801
  const xr = new WebXRManager( _this, _gl );
30271
30802
  this.xr = xr;
30272
30803
  this.getContext = function () {
@@ -30296,7 +30827,7 @@ void main() {
30296
30827
  };
30297
30828
  this.setSize = function ( width, height, updateStyle = true ) {
30298
30829
  if ( xr.isPresenting ) {
30299
- console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' );
30830
+ warn( 'WebGLRenderer: Can\'t change size while VR device is presenting.' );
30300
30831
  return;
30301
30832
  }
30302
30833
  _width = width;
@@ -30307,6 +30838,9 @@ void main() {
30307
30838
  canvas.style.width = width + 'px';
30308
30839
  canvas.style.height = height + 'px';
30309
30840
  }
30841
+ if ( output !== null ) {
30842
+ output.setSize( canvas.width, canvas.height );
30843
+ }
30310
30844
  this.setViewport( 0, 0, width, height );
30311
30845
  };
30312
30846
  this.getDrawingBufferSize = function ( target ) {
@@ -30320,6 +30854,21 @@ void main() {
30320
30854
  canvas.height = Math.floor( height * pixelRatio );
30321
30855
  this.setViewport( 0, 0, width, height );
30322
30856
  };
30857
+ this.setEffects = function ( effects ) {
30858
+ if ( _outputBufferType === UnsignedByteType ) {
30859
+ console.error( 'THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.' );
30860
+ return;
30861
+ }
30862
+ if ( effects ) {
30863
+ for ( let i = 0; i < effects.length; i ++ ) {
30864
+ if ( effects[ i ].isOutputPass === true ) {
30865
+ console.warn( 'THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.' );
30866
+ break;
30867
+ }
30868
+ }
30869
+ }
30870
+ output.setEffects( effects || [] );
30871
+ };
30323
30872
  this.getCurrentViewport = function ( target ) {
30324
30873
  return target.copy( _currentViewport );
30325
30874
  };
@@ -30375,18 +30924,11 @@ void main() {
30375
30924
  let isIntegerFormat = false;
30376
30925
  if ( _currentRenderTarget !== null ) {
30377
30926
  const targetFormat = _currentRenderTarget.texture.format;
30378
- isIntegerFormat = targetFormat === RGBAIntegerFormat ||
30379
- targetFormat === RGIntegerFormat ||
30380
- targetFormat === RedIntegerFormat;
30927
+ isIntegerFormat = INTEGER_FORMATS.has( targetFormat );
30381
30928
  }
30382
30929
  if ( isIntegerFormat ) {
30383
30930
  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;
30931
+ const isUnsignedType = UNSIGNED_TYPES.has( targetType );
30390
30932
  const clearColor = background.getClearColor();
30391
30933
  const a = background.getClearAlpha();
30392
30934
  const r = clearColor.r;
@@ -30448,11 +30990,11 @@ void main() {
30448
30990
  };
30449
30991
  function onContextLost( event ) {
30450
30992
  event.preventDefault();
30451
- console.log( 'THREE.WebGLRenderer: Context Lost.' );
30993
+ log( 'WebGLRenderer: Context Lost.' );
30452
30994
  _isContextLost = true;
30453
30995
  }
30454
30996
  function onContextRestore( ) {
30455
- console.log( 'THREE.WebGLRenderer: Context Restored.' );
30997
+ log( 'WebGLRenderer: Context Restored.' );
30456
30998
  _isContextLost = false;
30457
30999
  const infoAutoReset = info.autoReset;
30458
31000
  const shadowMapEnabled = shadowMap.enabled;
@@ -30467,7 +31009,7 @@ void main() {
30467
31009
  shadowMap.type = shadowMapType;
30468
31010
  }
30469
31011
  function onContextCreationError( event ) {
30470
- console.error( 'THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
31012
+ error( 'WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
30471
31013
  }
30472
31014
  function onMaterialDispose( event ) {
30473
31015
  const material = event.target;
@@ -30551,7 +31093,7 @@ void main() {
30551
31093
  }
30552
31094
  if ( object.isBatchedMesh ) {
30553
31095
  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.' );
31096
+ warnOnce( 'WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
30555
31097
  renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
30556
31098
  } else {
30557
31099
  if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
@@ -30683,13 +31225,15 @@ void main() {
30683
31225
  xr.addEventListener( 'sessionend', onXRSessionEnd );
30684
31226
  this.render = function ( scene, camera ) {
30685
31227
  if ( camera !== undefined && camera.isCamera !== true ) {
30686
- console.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
31228
+ error( 'WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
30687
31229
  return;
30688
31230
  }
30689
31231
  if ( _isContextLost === true ) return;
31232
+ const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
31233
+ const useOutput = output !== null && ( _currentRenderTarget === null || isXRPresenting ) && output.begin( _this, _currentRenderTarget );
30690
31234
  if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
30691
31235
  if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
30692
- if ( xr.enabled === true && xr.isPresenting === true ) {
31236
+ if ( xr.enabled === true && xr.isPresenting === true && ( output === null || output.isCompositing() === false ) ) {
30693
31237
  if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
30694
31238
  camera = xr.getCamera();
30695
31239
  }
@@ -30725,31 +31269,37 @@ void main() {
30725
31269
  shadowMap.render( shadowsArray, scene, camera );
30726
31270
  if ( _clippingEnabled === true ) clipping.endShadows();
30727
31271
  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 ) {
31272
+ const skipSceneRender = useOutput && output.hasRenderPass();
31273
+ if ( skipSceneRender === false ) {
31274
+ const opaqueObjects = currentRenderList.opaque;
31275
+ const transmissiveObjects = currentRenderList.transmissive;
31276
+ currentRenderState.setupLights();
31277
+ if ( camera.isArrayCamera ) {
31278
+ const cameras = camera.cameras;
31279
+ if ( transmissiveObjects.length > 0 ) {
31280
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
31281
+ const camera2 = cameras[ i ];
31282
+ renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
31283
+ }
31284
+ }
31285
+ if ( _renderBackground ) background.render( scene );
30734
31286
  for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30735
31287
  const camera2 = cameras[ i ];
30736
- renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
31288
+ renderScene( currentRenderList, scene, camera2, camera2.viewport );
30737
31289
  }
31290
+ } else {
31291
+ if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
31292
+ if ( _renderBackground ) background.render( scene );
31293
+ renderScene( currentRenderList, scene, camera );
30738
31294
  }
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
31295
  }
30749
31296
  if ( _currentRenderTarget !== null && _currentActiveMipmapLevel === 0 ) {
30750
31297
  textures.updateMultisampleRenderTarget( _currentRenderTarget );
30751
31298
  textures.updateRenderTargetMipmap( _currentRenderTarget );
30752
31299
  }
31300
+ if ( useOutput ) {
31301
+ output.end( _this );
31302
+ }
30753
31303
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
30754
31304
  bindingStates.resetDefaultState();
30755
31305
  _currentMaterialId = -1;
@@ -30830,9 +31380,7 @@ void main() {
30830
31380
  }
30831
31381
  }
30832
31382
  function renderScene( currentRenderList, scene, camera, viewport ) {
30833
- const opaqueObjects = currentRenderList.opaque;
30834
- const transmissiveObjects = currentRenderList.transmissive;
30835
- const transparentObjects = currentRenderList.transparent;
31383
+ const { opaque: opaqueObjects, transmissive: transmissiveObjects, transparent: transparentObjects } = currentRenderList;
30836
31384
  currentRenderState.setupLightsView( camera );
30837
31385
  if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
30838
31386
  if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
@@ -30850,11 +31398,12 @@ void main() {
30850
31398
  return;
30851
31399
  }
30852
31400
  if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
31401
+ const hasHalfFloatSupport = extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' );
30853
31402
  currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
30854
31403
  generateMipmaps: true,
30855
- type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
31404
+ type: hasHalfFloatSupport ? HalfFloatType : UnsignedByteType,
30856
31405
  minFilter: LinearMipmapLinearFilter,
30857
- samples: 4,
31406
+ samples: capabilities.samples,
30858
31407
  stencilBuffer: stencil,
30859
31408
  resolveDepthBuffer: false,
30860
31409
  resolveStencilBuffer: false,
@@ -30886,10 +31435,7 @@ void main() {
30886
31435
  let renderTargetNeedsUpdate = false;
30887
31436
  for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
30888
31437
  const renderItem = transmissiveObjects[ i ];
30889
- const object = renderItem.object;
30890
- const geometry = renderItem.geometry;
30891
- const material = renderItem.material;
30892
- const group = renderItem.group;
31438
+ const { object, geometry, material, group } = renderItem;
30893
31439
  if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
30894
31440
  const currentSide = material.side;
30895
31441
  material.side = BackSide;
@@ -30914,9 +31460,7 @@ void main() {
30914
31460
  const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
30915
31461
  for ( let i = 0, l = renderList.length; i < l; i ++ ) {
30916
31462
  const renderItem = renderList[ i ];
30917
- const object = renderItem.object;
30918
- const geometry = renderItem.geometry;
30919
- const group = renderItem.group;
31463
+ const { object, geometry, group } = renderItem;
30920
31464
  let material = renderItem.material;
30921
31465
  if ( material.allowOverride === true && overrideMaterial !== null ) {
30922
31466
  material = overrideMaterial;
@@ -31168,6 +31712,17 @@ void main() {
31168
31712
  refreshLights = true;
31169
31713
  }
31170
31714
  }
31715
+ if ( materialProperties.needsLights ) {
31716
+ if ( lights.state.directionalShadowMap.length > 0 ) {
31717
+ p_uniforms.setValue( _gl, 'directionalShadowMap', lights.state.directionalShadowMap, textures );
31718
+ }
31719
+ if ( lights.state.spotShadowMap.length > 0 ) {
31720
+ p_uniforms.setValue( _gl, 'spotShadowMap', lights.state.spotShadowMap, textures );
31721
+ }
31722
+ if ( lights.state.pointShadowMap.length > 0 ) {
31723
+ p_uniforms.setValue( _gl, 'pointShadowMap', lights.state.pointShadowMap, textures );
31724
+ }
31725
+ }
31171
31726
  if ( object.isSkinnedMesh ) {
31172
31727
  p_uniforms.setOptional( _gl, object, 'bindMatrix' );
31173
31728
  p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );
@@ -31202,6 +31757,9 @@ void main() {
31202
31757
  if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
31203
31758
  m_uniforms.envMapIntensity.value = scene.environmentIntensity;
31204
31759
  }
31760
+ if ( m_uniforms.dfgLUT !== undefined ) {
31761
+ m_uniforms.dfgLUT.value = getDFGLUT();
31762
+ }
31205
31763
  if ( refreshMaterial ) {
31206
31764
  p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
31207
31765
  if ( materialProperties.needsLights ) {
@@ -31279,15 +31837,21 @@ void main() {
31279
31837
  _currentRenderTarget = renderTarget;
31280
31838
  _currentActiveCubeFace = activeCubeFace;
31281
31839
  _currentActiveMipmapLevel = activeMipmapLevel;
31282
- let useDefaultFramebuffer = true;
31283
31840
  let framebuffer = null;
31284
31841
  let isCube = false;
31285
31842
  let isRenderTarget3D = false;
31286
31843
  if ( renderTarget ) {
31287
31844
  const renderTargetProperties = properties.get( renderTarget );
31288
31845
  if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
31289
- state.bindFramebuffer( _gl.FRAMEBUFFER, null );
31290
- useDefaultFramebuffer = false;
31846
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
31847
+ _currentViewport.copy( renderTarget.viewport );
31848
+ _currentScissor.copy( renderTarget.scissor );
31849
+ _currentScissorTest = renderTarget.scissorTest;
31850
+ state.viewport( _currentViewport );
31851
+ state.scissor( _currentScissor );
31852
+ state.setScissorTest( _currentScissorTest );
31853
+ _currentMaterialId = -1;
31854
+ return;
31291
31855
  } else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
31292
31856
  textures.setupRenderTarget( renderTarget );
31293
31857
  } else if ( renderTargetProperties.__hasExternalTextures ) {
@@ -31338,7 +31902,7 @@ void main() {
31338
31902
  framebuffer = _scratchFrameBuffer;
31339
31903
  }
31340
31904
  const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
31341
- if ( framebufferBound && useDefaultFramebuffer ) {
31905
+ if ( framebufferBound ) {
31342
31906
  state.drawBuffers( renderTarget, framebuffer );
31343
31907
  }
31344
31908
  state.viewport( _currentViewport );
@@ -31361,7 +31925,7 @@ void main() {
31361
31925
  };
31362
31926
  this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
31363
31927
  if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
31364
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
31928
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
31365
31929
  return;
31366
31930
  }
31367
31931
  let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
@@ -31375,11 +31939,11 @@ void main() {
31375
31939
  const textureFormat = texture.format;
31376
31940
  const textureType = texture.type;
31377
31941
  if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
31378
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
31942
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
31379
31943
  return;
31380
31944
  }
31381
31945
  if ( ! capabilities.textureTypeReadable( textureType ) ) {
31382
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
31946
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
31383
31947
  return;
31384
31948
  }
31385
31949
  if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
@@ -31695,6 +32259,7 @@ void main() {
31695
32259
  ConstantColorFactor: ConstantColorFactor,
31696
32260
  Controls: Controls,
31697
32261
  CubeCamera: CubeCamera,
32262
+ CubeDepthTexture: CubeDepthTexture,
31698
32263
  CubeReflectionMapping: CubeReflectionMapping,
31699
32264
  CubeRefractionMapping: CubeRefractionMapping,
31700
32265
  CubeTexture: CubeTexture,
@@ -31864,9 +32429,12 @@ void main() {
31864
32429
  NeverStencilFunc: NeverStencilFunc,
31865
32430
  NoBlending: NoBlending,
31866
32431
  NoColorSpace: NoColorSpace,
32432
+ NoNormalPacking: NoNormalPacking,
31867
32433
  NoToneMapping: NoToneMapping,
31868
32434
  NormalAnimationBlendMode: NormalAnimationBlendMode,
31869
32435
  NormalBlending: NormalBlending,
32436
+ NormalGAPacking: NormalGAPacking,
32437
+ NormalRGPacking: NormalRGPacking,
31870
32438
  NotEqualCompare: NotEqualCompare,
31871
32439
  NotEqualDepth: NotEqualDepth,
31872
32440
  NotEqualStencilFunc: NotEqualStencilFunc,
@@ -31905,9 +32473,11 @@ void main() {
31905
32473
  Quaternion: Quaternion,
31906
32474
  QuaternionKeyframeTrack: QuaternionKeyframeTrack,
31907
32475
  QuaternionLinearInterpolant: QuaternionLinearInterpolant,
32476
+ R11_EAC_Format: R11_EAC_Format,
31908
32477
  RED_GREEN_RGTC2_Format: RED_GREEN_RGTC2_Format,
31909
32478
  RED_RGTC1_Format: RED_RGTC1_Format,
31910
32479
  REVISION: REVISION,
32480
+ RG11_EAC_Format: RG11_EAC_Format,
31911
32481
  RGBADepthPacking: RGBADepthPacking,
31912
32482
  RGBAFormat: RGBAFormat,
31913
32483
  RGBAIntegerFormat: RGBAIntegerFormat,
@@ -31958,8 +32528,10 @@ void main() {
31958
32528
  ReplaceStencilOp: ReplaceStencilOp,
31959
32529
  ReverseSubtractEquation: ReverseSubtractEquation,
31960
32530
  RingGeometry: RingGeometry,
32531
+ SIGNED_R11_EAC_Format: SIGNED_R11_EAC_Format,
31961
32532
  SIGNED_RED_GREEN_RGTC2_Format: SIGNED_RED_GREEN_RGTC2_Format,
31962
32533
  SIGNED_RED_RGTC1_Format: SIGNED_RED_RGTC1_Format,
32534
+ SIGNED_RG11_EAC_Format: SIGNED_RG11_EAC_Format,
31963
32535
  SRGBColorSpace: SRGBColorSpace,
31964
32536
  SRGBTransfer: SRGBTransfer,
31965
32537
  Scene: Scene,
@@ -32052,7 +32624,13 @@ void main() {
32052
32624
  ZeroFactor: ZeroFactor,
32053
32625
  ZeroSlopeEnding: ZeroSlopeEnding,
32054
32626
  ZeroStencilOp: ZeroStencilOp,
32055
- createCanvasElement: createCanvasElement
32627
+ createCanvasElement: createCanvasElement,
32628
+ error: error,
32629
+ getConsoleFunction: getConsoleFunction,
32630
+ log: log,
32631
+ setConsoleFunction: setConsoleFunction,
32632
+ warn: warn,
32633
+ warnOnce: warnOnce
32056
32634
  });
32057
32635
 
32058
32636
  const _raycaster = new Raycaster();
@@ -35220,9 +35798,15 @@ void main() {
35220
35798
  viewer.clearSlices();
35221
35799
  }
35222
35800
 
35223
- function createPreview(viewer, type = "image/jpeg", quality = 0.25) {
35801
+ function getSnapshot(viewer, type, quality) {
35802
+ var _a, _b;
35224
35803
  viewer.update(true);
35225
- return viewer.canvas.toDataURL(type, quality);
35804
+ const mimeType = (_a = type !== null && type !== void 0 ? type : viewer.options.snapshotMimeType) !== null && _a !== void 0 ? _a : "image/jpeg";
35805
+ const imageQuality = (_b = quality !== null && quality !== void 0 ? quality : viewer.options.snapshotQuality) !== null && _b !== void 0 ? _b : 0.25;
35806
+ if (viewer.markup) {
35807
+ return viewer.markup.getSnapshot(mimeType, imageQuality);
35808
+ }
35809
+ return viewer.canvas.toDataURL(mimeType, imageQuality);
35226
35810
  }
35227
35811
 
35228
35812
  function explode(viewer, index = 0) {
@@ -35431,7 +36015,7 @@ void main() {
35431
36015
  commands.registerCommand("clearSelected", clearSelected);
35432
36016
  commands.registerCommand("clearSlices", clearSlices);
35433
36017
  commands.registerCommand("collect", collect);
35434
- commands.registerCommand("createPreview", createPreview);
36018
+ commands.registerCommand("getSnapshot", getSnapshot);
35435
36019
  commands.registerCommand("explode", explode);
35436
36020
  commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
35437
36021
  commands.registerCommand("getModels", getModels);
@@ -35463,6 +36047,7 @@ void main() {
35463
36047
  commands.registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"));
35464
36048
  commands.registerCommandAlias("clearMarkup", "clearOverlay");
35465
36049
  commands.registerCommandAlias("clearSelected", "unselect");
36050
+ commands.registerCommandAlias("getSnapshot", "createPreview");
35466
36051
  commands.registerCommandAlias("zoomToExtents", "zoomExtents");
35467
36052
  commands.registerCommandAlias("top", "k3DViewTop");
35468
36053
  commands.registerCommandAlias("bottom", "k3DViewBottom");
@@ -38894,16 +39479,14 @@ void main() {
38894
39479
  const transformedBox = node.geometryExtents.clone();
38895
39480
  const structureRoot = node.structure ? this.structureRoots.get(node.structure.id) : null;
38896
39481
  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;
39482
+ const relativeMatrix = new Matrix4();
39483
+ let currentObject = node.group;
39484
+ while (currentObject && currentObject !== structureRoot) {
39485
+ relativeMatrix.premultiply(currentObject.matrix);
39486
+ currentObject = currentObject.parent;
38904
39487
  }
38905
- for (const matrix of matrices) {
38906
- transformedBox.applyMatrix4(matrix);
39488
+ if (!relativeMatrix.equals(new Matrix4())) {
39489
+ transformedBox.applyMatrix4(relativeMatrix);
38907
39490
  }
38908
39491
  }
38909
39492
  if (structureRoot && structureRoot.matrix) {
@@ -39356,6 +39939,15 @@ void main() {
39356
39939
  let currentVertexOffset = 0;
39357
39940
  for (const mesh of group.objects) {
39358
39941
  const geometry = mesh.geometry.clone();
39942
+ const relativeMatrix = new Matrix4();
39943
+ let currentObject = mesh;
39944
+ while (currentObject && currentObject !== rootGroup) {
39945
+ relativeMatrix.premultiply(currentObject.matrix);
39946
+ currentObject = currentObject.parent;
39947
+ }
39948
+ if (!relativeMatrix.equals(new Matrix4())) {
39949
+ geometry.applyMatrix4(relativeMatrix);
39950
+ }
39359
39951
  const handle = mesh.userData.handle;
39360
39952
  if (!this.objectIdToIndex.has(handle)) {
39361
39953
  this.objectIdToIndex.set(handle, this.maxObjectId++);
@@ -39450,7 +40042,16 @@ void main() {
39450
40042
  let isEdge = false;
39451
40043
  group.objects.forEach((line) => {
39452
40044
  isEdge = line.userData.isEdge;
39453
- const geometry = line.geometry;
40045
+ const geometry = line.geometry.clone();
40046
+ const relativeMatrix = new Matrix4();
40047
+ let currentObject = line;
40048
+ while (currentObject && currentObject !== rootGroup) {
40049
+ relativeMatrix.premultiply(currentObject.matrix);
40050
+ currentObject = currentObject.parent;
40051
+ }
40052
+ if (!relativeMatrix.equals(new Matrix4())) {
40053
+ geometry.applyMatrix4(relativeMatrix);
40054
+ }
39454
40055
  const positionAttr = geometry.attributes.position;
39455
40056
  const vertexCount = positionAttr.count;
39456
40057
  const handle = line.userData.handle;
@@ -39473,6 +40074,7 @@ void main() {
39473
40074
  indices.push(vertexOffset + i, vertexOffset + i + 1);
39474
40075
  }
39475
40076
  vertexOffset += vertexCount;
40077
+ geometry.dispose();
39476
40078
  });
39477
40079
  const geometry = new BufferGeometry();
39478
40080
  geometry.setAttribute("position", new BufferAttribute(positions, 3));
@@ -39544,6 +40146,15 @@ void main() {
39544
40146
  for (const line of group.objects) {
39545
40147
  isEdge = line.userData.isEdge;
39546
40148
  const geometry = line.geometry.clone();
40149
+ const relativeMatrix = new Matrix4();
40150
+ let currentObject = line;
40151
+ while (currentObject && currentObject !== rootGroup) {
40152
+ relativeMatrix.premultiply(currentObject.matrix);
40153
+ currentObject = currentObject.parent;
40154
+ }
40155
+ if (!relativeMatrix.equals(new Matrix4())) {
40156
+ geometry.applyMatrix4(relativeMatrix);
40157
+ }
39547
40158
  const handle = line.userData.handle;
39548
40159
  if (!this.objectIdToIndex.has(handle)) {
39549
40160
  this.objectIdToIndex.set(handle, this.maxObjectId++);
@@ -39629,6 +40240,15 @@ void main() {
39629
40240
  const handles = new Set();
39630
40241
  for (const points of group.objects) {
39631
40242
  const geometry = points.geometry.clone();
40243
+ const relativeMatrix = new Matrix4();
40244
+ let currentObject = points;
40245
+ while (currentObject && currentObject !== rootGroup) {
40246
+ relativeMatrix.premultiply(currentObject.matrix);
40247
+ currentObject = currentObject.parent;
40248
+ }
40249
+ if (!relativeMatrix.equals(new Matrix4())) {
40250
+ geometry.applyMatrix4(relativeMatrix);
40251
+ }
39632
40252
  geometries.push(geometry);
39633
40253
  optimizedObjects.push(points);
39634
40254
  handles.add(points.userData.handle);
@@ -41941,6 +42561,7 @@ void main() {
41941
42561
  this.clear = true;
41942
42562
  this.clearDepth = false;
41943
42563
  this.needsSwap = false;
42564
+ this.isRenderPass = true;
41944
42565
  this._oldClearColor = new Color();
41945
42566
  }
41946
42567
  render( renderer, writeBuffer, readBuffer ) {
@@ -43059,6 +43680,7 @@ void main() {
43059
43680
  class OutputPass extends Pass {
43060
43681
  constructor() {
43061
43682
  super();
43683
+ this.isOutputPass = true;
43062
43684
  this.uniforms = UniformsUtils.clone( OutputShader.uniforms );
43063
43685
  this.material = new RawShaderMaterial( {
43064
43686
  name: OutputShader.name,
@@ -55978,10 +56600,22 @@ js: import "konva/skia-backend";
55978
56600
  viewpoint.ellipses = this.getMarkupEllipses();
55979
56601
  viewpoint.images = this.getMarkupImages();
55980
56602
  viewpoint.rectangles = this.getMarkupRectangles();
55981
- viewpoint.snapshot = { data: this.combineMarkupWithDrawing() };
55982
56603
  viewpoint.custom_fields.markup_color = this.getMarkupColor();
55983
56604
  return viewpoint;
55984
56605
  }
56606
+ getSnapshot(type = "image/jpeg", quality = 0.25) {
56607
+ this.clearSelected();
56608
+ const tempCanvas = document.createElement("canvas");
56609
+ if (this._konvaStage) {
56610
+ tempCanvas.width = this._konvaStage.width();
56611
+ tempCanvas.height = this._konvaStage.height();
56612
+ const ctx = tempCanvas.getContext("2d");
56613
+ if (this._container instanceof HTMLCanvasElement)
56614
+ ctx.drawImage(this._container, 0, 0);
56615
+ ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
56616
+ }
56617
+ return tempCanvas.toDataURL(type, quality);
56618
+ }
55985
56619
  enableEditMode(mode) {
55986
56620
  if (!mode || !MarkupMode2Konva[mode]) {
55987
56621
  this.clearSelected();
@@ -56418,19 +57052,6 @@ js: import "konva/skia-backend";
56418
57052
  });
56419
57053
  return clouds;
56420
57054
  }
56421
- combineMarkupWithDrawing() {
56422
- this.clearSelected();
56423
- const tempCanvas = document.createElement("canvas");
56424
- if (this._konvaStage) {
56425
- tempCanvas.width = this._konvaStage.width();
56426
- tempCanvas.height = this._konvaStage.height();
56427
- const ctx = tempCanvas.getContext("2d");
56428
- if (this._container instanceof HTMLCanvasElement)
56429
- ctx.drawImage(this._container, 0, 0);
56430
- ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
56431
- }
56432
- return tempCanvas.toDataURL("image/jpeg", 0.25);
56433
- }
56434
57055
  addLine(linePoints, color, type, width, id) {
56435
57056
  if (!linePoints || linePoints.length === 0)
56436
57057
  return;
@@ -57152,12 +57773,16 @@ js: import "konva/skia-backend";
57152
57773
  viewpoint.clipping_planes = getClippingPlanes();
57153
57774
  viewpoint.selection = getSelection();
57154
57775
  viewpoint.description = new Date().toDateString();
57776
+ viewpoint.snapshot = { data: this.getSnapshot() };
57155
57777
  this._markup.getViewpoint(viewpoint);
57156
57778
  viewpoint.custom_fields.camera_target = getPoint3dFromVector3(this.target);
57157
57779
  viewpoint.custom_fields.selection2 = getSelection2();
57158
57780
  this.emitEvent({ type: "createviewpoint", data: viewpoint });
57159
57781
  return viewpoint;
57160
57782
  }
57783
+ getSnapshot(type, quality) {
57784
+ return this.executeCommand("getSnapshot", type, quality);
57785
+ }
57161
57786
  screenToWorld(position) {
57162
57787
  if (!this.renderer)
57163
57788
  return { x: position.x, y: position.y, z: 0 };