react-globe.gl 2.19.0 → 2.20.0

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.
@@ -1,4 +1,4 @@
1
- // Version 2.19.0 react-globe.gl - https://github.com/vasturiano/react-globe.gl
1
+ // Version 2.20.0 react-globe.gl - https://github.com/vasturiano/react-globe.gl
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['react'], factory) :
@@ -308,7 +308,7 @@
308
308
  * Copyright 2010-2021 Three.js Authors
309
309
  * SPDX-License-Identifier: MIT
310
310
  */
311
- const REVISION = '134';
311
+ const REVISION = '136';
312
312
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
313
313
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
314
314
  const CullFaceNone = 0;
@@ -394,7 +394,6 @@
394
394
  const RGBAFormat = 1023;
395
395
  const LuminanceFormat = 1024;
396
396
  const LuminanceAlphaFormat = 1025;
397
- const RGBEFormat = RGBAFormat;
398
397
  const DepthFormat = 1026;
399
398
  const DepthStencilFormat = 1027;
400
399
  const RedFormat = 1028;
@@ -460,12 +459,6 @@
460
459
  const TriangleFanDrawMode = 2;
461
460
  const LinearEncoding = 3000;
462
461
  const sRGBEncoding = 3001;
463
- const GammaEncoding = 3007;
464
- const RGBEEncoding = 3002;
465
- const LogLuvEncoding = 3003;
466
- const RGBM7Encoding = 3004;
467
- const RGBM16Encoding = 3005;
468
- const RGBDEncoding = 3006;
469
462
  const BasicDepthPacking = 3200;
470
463
  const RGBADepthPacking = 3201;
471
464
  const TangentSpaceNormalMap = 0;
@@ -562,13 +555,6 @@
562
555
 
563
556
  }
564
557
 
565
- let _seed = 1234567;
566
-
567
- const DEG2RAD = Math.PI / 180;
568
- const RAD2DEG = 180 / Math.PI;
569
-
570
- //
571
-
572
558
  const _lut = [];
573
559
 
574
560
  for ( let i = 0; i < 256; i ++ ) {
@@ -577,18 +563,14 @@
577
563
 
578
564
  }
579
565
 
580
- const hasRandomUUID = typeof crypto !== 'undefined' && 'randomUUID' in crypto;
581
-
582
- function generateUUID() {
583
-
584
- if ( hasRandomUUID ) {
566
+ let _seed = 1234567;
585
567
 
586
- return crypto.randomUUID().toUpperCase();
587
568
 
588
- }
569
+ const DEG2RAD = Math.PI / 180;
570
+ const RAD2DEG = 180 / Math.PI;
589
571
 
590
- // TODO Remove this code when crypto.randomUUID() is available everywhere
591
- // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
572
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
573
+ function generateUUID() {
592
574
 
593
575
  const d0 = Math.random() * 0xffffffff | 0;
594
576
  const d1 = Math.random() * 0xffffffff | 0;
@@ -1673,42 +1655,6 @@
1673
1655
 
1674
1656
  }
1675
1657
 
1676
- /**
1677
- * cyrb53 hash for string from: https://stackoverflow.com/a/52171480
1678
- *
1679
- * Public Domain, @bryc - https://stackoverflow.com/users/815680/bryc
1680
- *
1681
- * It is roughly similar to the well-known MurmurHash/xxHash algorithms. It uses a combination
1682
- * of multiplication and Xorshift to generate the hash, but not as thorough. As a result it's
1683
- * faster than either would be in JavaScript and significantly simpler to implement. Keep in
1684
- * mind this is not a secure algorithm, if privacy/security is a concern, this is not for you.
1685
- *
1686
- * @param {string} str
1687
- * @param {number} seed, default 0
1688
- * @returns number
1689
- */
1690
- function hashString( str, seed = 0 ) {
1691
-
1692
- let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
1693
-
1694
- for ( let i = 0, ch; i < str.length; i ++ ) {
1695
-
1696
- ch = str.charCodeAt( i );
1697
-
1698
- h1 = Math.imul( h1 ^ ch, 2654435761 );
1699
-
1700
- h2 = Math.imul( h2 ^ ch, 1597334677 );
1701
-
1702
- }
1703
-
1704
- h1 = Math.imul( h1 ^ ( h1 >>> 16 ), 2246822507 ) ^ Math.imul( h2 ^ ( h2 >>> 13 ), 3266489909 );
1705
-
1706
- h2 = Math.imul( h2 ^ ( h2 >>> 16 ), 2246822507 ) ^ Math.imul( h1 ^ ( h1 >>> 13 ), 3266489909 );
1707
-
1708
- return 4294967296 * ( 2097151 & h2 ) + ( h1 >>> 0 );
1709
-
1710
- }
1711
-
1712
1658
  let _canvas;
1713
1659
 
1714
1660
  class ImageUtils {
@@ -2975,12 +2921,16 @@
2975
2921
 
2976
2922
  class WebGLMultisampleRenderTarget extends WebGLRenderTarget {
2977
2923
 
2978
- constructor( width, height, options ) {
2924
+ constructor( width, height, options = {} ) {
2979
2925
 
2980
2926
  super( width, height, options );
2981
2927
 
2982
2928
  this.samples = 4;
2983
2929
 
2930
+ this.ignoreDepthForMultisampleCopy = options.ignoreDepth !== undefined ? options.ignoreDepth : true;
2931
+ this.useRenderToTexture = ( options.useRenderToTexture !== undefined ) ? options.useRenderToTexture : false;
2932
+ this.useRenderbuffer = this.useRenderToTexture === false;
2933
+
2984
2934
  }
2985
2935
 
2986
2936
  copy( source ) {
@@ -2988,6 +2938,8 @@
2988
2938
  super.copy.call( this, source );
2989
2939
 
2990
2940
  this.samples = source.samples;
2941
+ this.useRenderToTexture = source.useRenderToTexture;
2942
+ this.useRenderbuffer = source.useRenderbuffer;
2991
2943
 
2992
2944
  return this;
2993
2945
 
@@ -5131,7 +5083,16 @@
5131
5083
  // 1) Enclose the farthest point on the other sphere into this sphere.
5132
5084
  // 2) Enclose the opposite point of the farthest point into this sphere.
5133
5085
 
5134
- _toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius );
5086
+ if ( this.center.equals( sphere.center ) === true ) {
5087
+
5088
+ _toFarthestPoint.set( 0, 0, 1 ).multiplyScalar( sphere.radius );
5089
+
5090
+
5091
+ } else {
5092
+
5093
+ _toFarthestPoint.subVectors( sphere.center, this.center ).normalize().multiplyScalar( sphere.radius );
5094
+
5095
+ }
5135
5096
 
5136
5097
  this.expandByPoint( _v1$6.copy( sphere.center ).add( _toFarthestPoint ) );
5137
5098
  this.expandByPoint( _v1$6.copy( sphere.center ).sub( _toFarthestPoint ) );
@@ -5254,7 +5215,7 @@
5254
5215
 
5255
5216
  distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {
5256
5217
 
5257
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h
5218
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h
5258
5219
  // It returns the min distance between the ray and the segment
5259
5220
  // defined by v0 and v1
5260
5221
  // It can also set two optional targets :
@@ -5553,7 +5514,7 @@
5553
5514
 
5554
5515
  // Compute the offset origin, edges, and normal.
5555
5516
 
5556
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
5517
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
5557
5518
 
5558
5519
  _edge1.subVectors( b, a );
5559
5520
  _edge2.subVectors( c, a );
@@ -6855,7 +6816,7 @@
6855
6816
 
6856
6817
  set( channel ) {
6857
6818
 
6858
- this.mask = 1 << channel | 0;
6819
+ this.mask = ( 1 << channel | 0 ) >>> 0;
6859
6820
 
6860
6821
  }
6861
6822
 
@@ -6895,6 +6856,12 @@
6895
6856
 
6896
6857
  }
6897
6858
 
6859
+ isEnabled( channel ) {
6860
+
6861
+ return ( this.mask & ( 1 << channel | 0 ) ) !== 0;
6862
+
6863
+ }
6864
+
6898
6865
  }
6899
6866
 
6900
6867
  let _object3DId = 0;
@@ -7295,6 +7262,8 @@
7295
7262
 
7296
7263
  // adds object as a child of this, while maintaining the object's world transform
7297
7264
 
7265
+ // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)
7266
+
7298
7267
  this.updateWorldMatrix( true, false );
7299
7268
 
7300
7269
  _m1$1.copy( this.matrixWorld ).invert();
@@ -7388,7 +7357,7 @@
7388
7357
 
7389
7358
  }
7390
7359
 
7391
- raycast() {}
7360
+ raycast( /* raycaster, intersects */ ) {}
7392
7361
 
7393
7362
  traverse( callback ) {
7394
7363
 
@@ -8889,44 +8858,6 @@
8889
8858
 
8890
8859
  }
8891
8860
 
8892
- copyGammaToLinear( color, gammaFactor = 2.0 ) {
8893
-
8894
- this.r = Math.pow( color.r, gammaFactor );
8895
- this.g = Math.pow( color.g, gammaFactor );
8896
- this.b = Math.pow( color.b, gammaFactor );
8897
-
8898
- return this;
8899
-
8900
- }
8901
-
8902
- copyLinearToGamma( color, gammaFactor = 2.0 ) {
8903
-
8904
- const safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;
8905
-
8906
- this.r = Math.pow( color.r, safeInverse );
8907
- this.g = Math.pow( color.g, safeInverse );
8908
- this.b = Math.pow( color.b, safeInverse );
8909
-
8910
- return this;
8911
-
8912
- }
8913
-
8914
- convertGammaToLinear( gammaFactor ) {
8915
-
8916
- this.copyGammaToLinear( this, gammaFactor );
8917
-
8918
- return this;
8919
-
8920
- }
8921
-
8922
- convertLinearToGamma( gammaFactor ) {
8923
-
8924
- this.copyLinearToGamma( this, gammaFactor );
8925
-
8926
- return this;
8927
-
8928
- }
8929
-
8930
8861
  copySRGBToLinear( color ) {
8931
8862
 
8932
8863
  this.r = SRGBToLinear( color.r );
@@ -9738,7 +9669,7 @@
9738
9669
 
9739
9670
  }
9740
9671
 
9741
- let _id = 0;
9672
+ let _id$1 = 0;
9742
9673
 
9743
9674
  const _m1 = /*@__PURE__*/ new Matrix4();
9744
9675
  const _obj = /*@__PURE__*/ new Object3D();
@@ -9753,7 +9684,7 @@
9753
9684
 
9754
9685
  super();
9755
9686
 
9756
- Object.defineProperty( this, 'id', { value: _id ++ } );
9687
+ Object.defineProperty( this, 'id', { value: _id$1 ++ } );
9757
9688
 
9758
9689
  this.uuid = generateUUID();
9759
9690
 
@@ -12979,7 +12910,7 @@
12979
12910
 
12980
12911
  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; }\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 color ) { return dot( color, vec3( 0.3333 ) ); }\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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\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}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\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}";
12981
12912
 
12982
- var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.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\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\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\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + 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 ), m0, cubeUV_maxMipLevel );\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";
12913
+ var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.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\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\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\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + 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 ), m0, cubeUV_maxMipLevel );\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";
12983
12914
 
12984
12915
  var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
12985
12916
 
@@ -12993,11 +12924,11 @@
12993
12924
 
12994
12925
  var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
12995
12926
 
12996
- var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( 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 LinearTosRGB( 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}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}";
12927
+ var encodings_pars_fragment = "vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBToLinear( 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 LinearTosRGB( 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}";
12997
12928
 
12998
12929
  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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\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";
12999
12930
 
13000
- var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\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";
12931
+ var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\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";
13001
12932
 
13002
12933
  var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\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";
13003
12934
 
@@ -13013,7 +12944,7 @@
13013
12944
 
13014
12945
  var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";
13015
12946
 
13016
- var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}";
12947
+ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}";
13017
12948
 
13018
12949
  var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
13019
12950
 
@@ -13035,7 +12966,7 @@
13035
12966
 
13036
12967
  var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\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\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\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( ( ior - 1.0 ) / ( 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, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif";
13037
12968
 
13038
- var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\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_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\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}\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\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}";
12969
+ var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\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_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\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}\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\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\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}";
13039
12970
 
13040
12971
  var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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\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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, 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, geometry, 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\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\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 ], geometry.normal );\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";
13041
12972
 
@@ -13191,7 +13122,7 @@
13191
13122
 
13192
13123
  const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_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 <uv2_vertex>\n\t#include <color_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}";
13193
13124
 
13194
- const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define 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 SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\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 <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\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 <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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 <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_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13125
+ const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define 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 SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\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 <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\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 <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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 <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 + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
13195
13126
 
13196
13127
  const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_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 <uv2_vertex>\n\t#include <color_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}";
13197
13128
 
@@ -13379,8 +13310,7 @@
13379
13310
  flipEnvMap: { value: - 1 },
13380
13311
  reflectivity: { value: 1.0 }, // basic, lambert, phong
13381
13312
  ior: { value: 1.5 }, // standard, physical
13382
- refractionRatio: { value: 0.98 },
13383
- maxMipLevel: { value: 0 }
13313
+ refractionRatio: { value: 0.98 }
13384
13314
 
13385
13315
  },
13386
13316
 
@@ -14795,10 +14725,8 @@
14795
14725
 
14796
14726
  }
14797
14727
 
14798
- /* eslint-disable no-undef */
14799
14728
  const isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) ||
14800
14729
  ( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext );
14801
- /* eslint-enable no-undef */
14802
14730
 
14803
14731
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
14804
14732
  const maxPrecision = getMaxPrecision( precision );
@@ -15288,12 +15216,7 @@
15288
15216
 
15289
15217
  const ENCODINGS = {
15290
15218
  [ LinearEncoding ]: 0,
15291
- [ sRGBEncoding ]: 1,
15292
- [ RGBEEncoding ]: 2,
15293
- [ RGBM7Encoding ]: 3,
15294
- [ RGBM16Encoding ]: 4,
15295
- [ RGBDEncoding ]: 5,
15296
- [ GammaEncoding ]: 6
15219
+ [ sRGBEncoding ]: 1
15297
15220
  };
15298
15221
 
15299
15222
  const _flatCamera = /*@__PURE__*/ new OrthographicCamera();
@@ -15377,7 +15300,7 @@
15377
15300
 
15378
15301
  /**
15379
15302
  * Generates a PMREM from an equirectangular texture, which can be either LDR
15380
- * (RGBFormat) or HDR (RGBEFormat). The ideal input image size is 1k (1024 x 512),
15303
+ * or HDR. The ideal input image size is 1k (1024 x 512),
15381
15304
  * as this matches best with the 256 x 256 cubemap output.
15382
15305
  */
15383
15306
  fromEquirectangular( equirectangular ) {
@@ -15388,7 +15311,7 @@
15388
15311
 
15389
15312
  /**
15390
15313
  * Generates a PMREM from an cubemap texture, which can be either LDR
15391
- * (RGBFormat) or HDR (RGBEFormat). The ideal input cube size is 256 x 256,
15314
+ * or HDR. The ideal input cube size is 256 x 256,
15392
15315
  * as this matches best with the 256 x 256 cubemap output.
15393
15316
  */
15394
15317
  fromCubemap( cubemap ) {
@@ -15473,12 +15396,12 @@
15473
15396
  _allocateTargets( texture ) { // warning: null texture is valid
15474
15397
 
15475
15398
  const params = {
15476
- magFilter: NearestFilter,
15477
- minFilter: NearestFilter,
15399
+ magFilter: LinearFilter,
15400
+ minFilter: LinearFilter,
15478
15401
  generateMipmaps: false,
15479
- type: UnsignedByteType,
15480
- format: RGBEFormat,
15481
- encoding: _isLDR( texture ) ? texture.encoding : RGBEEncoding,
15402
+ type: HalfFloatType,
15403
+ format: RGBAFormat,
15404
+ encoding: LinearEncoding,
15482
15405
  depthBuffer: false
15483
15406
  };
15484
15407
 
@@ -15506,12 +15429,10 @@
15506
15429
  const renderer = this._renderer;
15507
15430
 
15508
15431
  const originalAutoClear = renderer.autoClear;
15509
- const outputEncoding = renderer.outputEncoding;
15510
15432
  const toneMapping = renderer.toneMapping;
15511
15433
  renderer.getClearColor( _clearColor );
15512
15434
 
15513
15435
  renderer.toneMapping = NoToneMapping;
15514
- renderer.outputEncoding = LinearEncoding;
15515
15436
  renderer.autoClear = false;
15516
15437
 
15517
15438
  const backgroundMaterial = new MeshBasicMaterial( {
@@ -15581,7 +15502,6 @@
15581
15502
  backgroundBox.material.dispose();
15582
15503
 
15583
15504
  renderer.toneMapping = toneMapping;
15584
- renderer.outputEncoding = outputEncoding;
15585
15505
  renderer.autoClear = originalAutoClear;
15586
15506
  scene.background = background;
15587
15507
 
@@ -15639,7 +15559,6 @@
15639
15559
  }
15640
15560
 
15641
15561
  this._setEncoding( uniforms[ 'inputEncoding' ], texture );
15642
- this._setEncoding( uniforms[ 'outputEncoding' ], cubeUVRenderTarget.texture );
15643
15562
 
15644
15563
  _setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX );
15645
15564
 
@@ -15771,9 +15690,6 @@
15771
15690
  blurUniforms[ 'dTheta' ].value = radiansPerPixel;
15772
15691
  blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn;
15773
15692
 
15774
- this._setEncoding( blurUniforms[ 'inputEncoding' ], targetIn.texture );
15775
- this._setEncoding( blurUniforms[ 'outputEncoding' ], targetIn.texture );
15776
-
15777
15693
  const outputSize = _sizeLods[ lodOut ];
15778
15694
  const x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize );
15779
15695
  const y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 );
@@ -15786,14 +15702,6 @@
15786
15702
 
15787
15703
  }
15788
15704
 
15789
- function _isLDR( texture ) {
15790
-
15791
- if ( texture === undefined || texture.type !== UnsignedByteType ) return false;
15792
-
15793
- return texture.encoding === LinearEncoding || texture.encoding === sRGBEncoding || texture.encoding === GammaEncoding;
15794
-
15795
- }
15796
-
15797
15705
  function _createPlanes() {
15798
15706
 
15799
15707
  const _lodPlanes = [];
@@ -15906,9 +15814,7 @@
15906
15814
  'latitudinal': { value: false },
15907
15815
  'dTheta': { value: 0 },
15908
15816
  'mipInt': { value: 0 },
15909
- 'poleAxis': { value: poleAxis },
15910
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] },
15911
- 'outputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15817
+ 'poleAxis': { value: poleAxis }
15912
15818
  },
15913
15819
 
15914
15820
  vertexShader: _getCommonVertexShader(),
@@ -15974,8 +15880,6 @@
15974
15880
 
15975
15881
  }
15976
15882
 
15977
- gl_FragColor = linearToOutputTexel( gl_FragColor );
15978
-
15979
15883
  }
15980
15884
  `,
15981
15885
 
@@ -15999,8 +15903,7 @@
15999
15903
  uniforms: {
16000
15904
  'envMap': { value: null },
16001
15905
  'texelSize': { value: texelSize },
16002
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] },
16003
- 'outputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15906
+ 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] }
16004
15907
  },
16005
15908
 
16006
15909
  vertexShader: _getCommonVertexShader(),
@@ -16040,8 +15943,6 @@
16040
15943
  vec3 bm = mix( bl, br, f.x );
16041
15944
  gl_FragColor.rgb = mix( tm, bm, f.y );
16042
15945
 
16043
- gl_FragColor = linearToOutputTexel( gl_FragColor );
16044
-
16045
15946
  }
16046
15947
  `,
16047
15948
 
@@ -16063,8 +15964,7 @@
16063
15964
 
16064
15965
  uniforms: {
16065
15966
  'envMap': { value: null },
16066
- 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] },
16067
- 'outputEncoding': { value: ENCODINGS[ LinearEncoding ] }
15967
+ 'inputEncoding': { value: ENCODINGS[ LinearEncoding ] }
16068
15968
  },
16069
15969
 
16070
15970
  vertexShader: _getCommonVertexShader(),
@@ -16082,9 +15982,7 @@
16082
15982
 
16083
15983
  void main() {
16084
15984
 
16085
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
16086
- gl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;
16087
- gl_FragColor = linearToOutputTexel( gl_FragColor );
15985
+ gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) );
16088
15986
 
16089
15987
  }
16090
15988
  `,
@@ -16167,7 +16065,6 @@
16167
16065
  return /* glsl */`
16168
16066
 
16169
16067
  uniform int inputEncoding;
16170
- uniform int outputEncoding;
16171
16068
 
16172
16069
  #include <encodings_pars_fragment>
16173
16070
 
@@ -16177,63 +16074,9 @@
16177
16074
 
16178
16075
  return value;
16179
16076
 
16180
- } else if ( inputEncoding == 1 ) {
16181
-
16182
- return sRGBToLinear( value );
16183
-
16184
- } else if ( inputEncoding == 2 ) {
16185
-
16186
- return RGBEToLinear( value );
16187
-
16188
- } else if ( inputEncoding == 3 ) {
16189
-
16190
- return RGBMToLinear( value, 7.0 );
16191
-
16192
- } else if ( inputEncoding == 4 ) {
16193
-
16194
- return RGBMToLinear( value, 16.0 );
16195
-
16196
- } else if ( inputEncoding == 5 ) {
16197
-
16198
- return RGBDToLinear( value, 256.0 );
16199
-
16200
- } else {
16201
-
16202
- return GammaToLinear( value, 2.2 );
16203
-
16204
- }
16205
-
16206
- }
16207
-
16208
- vec4 linearToOutputTexel( vec4 value ) {
16209
-
16210
- if ( outputEncoding == 0 ) {
16211
-
16212
- return value;
16213
-
16214
- } else if ( outputEncoding == 1 ) {
16215
-
16216
- return LinearTosRGB( value );
16217
-
16218
- } else if ( outputEncoding == 2 ) {
16219
-
16220
- return LinearToRGBE( value );
16221
-
16222
- } else if ( outputEncoding == 3 ) {
16223
-
16224
- return LinearToRGBM( value, 7.0 );
16225
-
16226
- } else if ( outputEncoding == 4 ) {
16227
-
16228
- return LinearToRGBM( value, 16.0 );
16229
-
16230
- } else if ( outputEncoding == 5 ) {
16231
-
16232
- return LinearToRGBD( value, 256.0 );
16233
-
16234
16077
  } else {
16235
16078
 
16236
- return LinearToGamma( value, 2.2 );
16079
+ return sRGBToLinear( value );
16237
16080
 
16238
16081
  }
16239
16082
 
@@ -16433,6 +16276,7 @@
16433
16276
 
16434
16277
  getExtension( 'OES_texture_float_linear' );
16435
16278
  getExtension( 'EXT_color_buffer_half_float' );
16279
+ getExtension( 'WEBGL_multisampled_render_to_texture' );
16436
16280
 
16437
16281
  },
16438
16282
 
@@ -16800,8 +16644,6 @@
16800
16644
  this.flipY = false;
16801
16645
  this.unpackAlignment = 1;
16802
16646
 
16803
- this.needsUpdate = true;
16804
-
16805
16647
  }
16806
16648
 
16807
16649
  }
@@ -16889,6 +16731,7 @@
16889
16731
  const texture = new DataTexture2DArray( buffer, width, height, numberOfMorphTargets );
16890
16732
  texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower)
16891
16733
  texture.type = FloatType;
16734
+ texture.needsUpdate = true;
16892
16735
 
16893
16736
  // fill buffer
16894
16737
 
@@ -17179,8 +17022,6 @@
17179
17022
  this.flipY = false;
17180
17023
  this.unpackAlignment = 1;
17181
17024
 
17182
- this.needsUpdate = true;
17183
-
17184
17025
  }
17185
17026
 
17186
17027
  }
@@ -17874,7 +17715,7 @@
17874
17715
  }
17875
17716
 
17876
17717
 
17877
- // Array of textures (2D / Cube)
17718
+ // Array of textures (2D / 3D / Cube / 2DArray)
17878
17719
 
17879
17720
  function setValueT1Array( gl, v, textures ) {
17880
17721
 
@@ -17892,6 +17733,22 @@
17892
17733
 
17893
17734
  }
17894
17735
 
17736
+ function setValueT3DArray( gl, v, textures ) {
17737
+
17738
+ const n = v.length;
17739
+
17740
+ const units = allocTexUnits( textures, n );
17741
+
17742
+ gl.uniform1iv( this.addr, units );
17743
+
17744
+ for ( let i = 0; i !== n; ++ i ) {
17745
+
17746
+ textures.setTexture3D( v[ i ] || emptyTexture3d, units[ i ] );
17747
+
17748
+ }
17749
+
17750
+ }
17751
+
17895
17752
  function setValueT6Array( gl, v, textures ) {
17896
17753
 
17897
17754
  const n = v.length;
@@ -17908,6 +17765,23 @@
17908
17765
 
17909
17766
  }
17910
17767
 
17768
+ function setValueT2DArrayArray( gl, v, textures ) {
17769
+
17770
+ const n = v.length;
17771
+
17772
+ const units = allocTexUnits( textures, n );
17773
+
17774
+ gl.uniform1iv( this.addr, units );
17775
+
17776
+ for ( let i = 0; i !== n; ++ i ) {
17777
+
17778
+ textures.setTexture2DArray( v[ i ] || emptyTexture2dArray, units[ i ] );
17779
+
17780
+ }
17781
+
17782
+ }
17783
+
17784
+
17911
17785
  // Helper to pick the right setter for a pure (bottom-level) array
17912
17786
 
17913
17787
  function getPureArraySetter( type ) {
@@ -17940,12 +17814,23 @@
17940
17814
  case 0x8b62: // SAMPLER_2D_SHADOW
17941
17815
  return setValueT1Array;
17942
17816
 
17817
+ case 0x8b5f: // SAMPLER_3D
17818
+ case 0x8dcb: // INT_SAMPLER_3D
17819
+ case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D
17820
+ return setValueT3DArray;
17821
+
17943
17822
  case 0x8b60: // SAMPLER_CUBE
17944
17823
  case 0x8dcc: // INT_SAMPLER_CUBE
17945
17824
  case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE
17946
17825
  case 0x8dc5: // SAMPLER_CUBE_SHADOW
17947
17826
  return setValueT6Array;
17948
17827
 
17828
+ case 0x8dc1: // SAMPLER_2D_ARRAY
17829
+ case 0x8dcf: // INT_SAMPLER_2D_ARRAY
17830
+ case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY
17831
+ case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW
17832
+ return setValueT2DArrayArray;
17833
+
17949
17834
  }
17950
17835
 
17951
17836
  }
@@ -18191,18 +18076,6 @@
18191
18076
  return [ 'Linear', '( value )' ];
18192
18077
  case sRGBEncoding:
18193
18078
  return [ 'sRGB', '( value )' ];
18194
- case RGBEEncoding:
18195
- return [ 'RGBE', '( value )' ];
18196
- case RGBM7Encoding:
18197
- return [ 'RGBM', '( value, 7.0 )' ];
18198
- case RGBM16Encoding:
18199
- return [ 'RGBM', '( value, 16.0 )' ];
18200
- case RGBDEncoding:
18201
- return [ 'RGBD', '( value, 256.0 )' ];
18202
- case GammaEncoding:
18203
- return [ 'Gamma', '( value, float( GAMMA_FACTOR ) )' ];
18204
- case LogLuvEncoding:
18205
- return [ 'LogLuv', '( value )' ];
18206
18079
  default:
18207
18080
  console.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding );
18208
18081
  return [ 'Linear', '( value )' ];
@@ -18563,9 +18436,6 @@
18563
18436
  const envMapModeDefine = generateEnvMapModeDefine( parameters );
18564
18437
  const envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );
18565
18438
 
18566
-
18567
- const gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0;
18568
-
18569
18439
  const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
18570
18440
 
18571
18441
  const customDefines = generateDefines( defines );
@@ -18617,8 +18487,6 @@
18617
18487
 
18618
18488
  parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',
18619
18489
 
18620
- '#define GAMMA_FACTOR ' + gammaFactorDefine,
18621
-
18622
18490
  '#define MAX_BONES ' + parameters.maxBones,
18623
18491
  ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',
18624
18492
  ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',
@@ -18767,8 +18635,6 @@
18767
18635
 
18768
18636
  customDefines,
18769
18637
 
18770
- '#define GAMMA_FACTOR ' + gammaFactorDefine,
18771
-
18772
18638
  ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',
18773
18639
  ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',
18774
18640
 
@@ -18888,7 +18754,7 @@
18888
18754
 
18889
18755
  prefixFragment = [
18890
18756
  '#define varying in',
18891
- ( parameters.glslVersion === GLSL3 ) ? '' : 'out highp vec4 pc_fragColor;',
18757
+ ( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
18892
18758
  ( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
18893
18759
  '#define gl_FragDepthEXT gl_FragDepth',
18894
18760
  '#define texture2D texture',
@@ -19060,8 +18926,129 @@
19060
18926
 
19061
18927
  }
19062
18928
 
18929
+ let _id = 0;
18930
+
18931
+ class WebGLShaderCache {
18932
+
18933
+ constructor() {
18934
+
18935
+ this.shaderCache = new Map();
18936
+ this.materialCache = new Map();
18937
+
18938
+ }
18939
+
18940
+ update( material ) {
18941
+
18942
+ const vertexShader = material.vertexShader;
18943
+ const fragmentShader = material.fragmentShader;
18944
+
18945
+ const vertexShaderStage = this._getShaderStage( vertexShader );
18946
+ const fragmentShaderStage = this._getShaderStage( fragmentShader );
18947
+
18948
+ const materialShaders = this._getShaderCacheForMaterial( material );
18949
+
18950
+ if ( materialShaders.has( vertexShaderStage ) === false ) {
18951
+
18952
+ materialShaders.add( vertexShaderStage );
18953
+ vertexShaderStage.usedTimes ++;
18954
+
18955
+ }
18956
+
18957
+ if ( materialShaders.has( fragmentShaderStage ) === false ) {
18958
+
18959
+ materialShaders.add( fragmentShaderStage );
18960
+ fragmentShaderStage.usedTimes ++;
18961
+
18962
+ }
18963
+
18964
+ return this;
18965
+
18966
+ }
18967
+
18968
+ remove( material ) {
18969
+
18970
+ const materialShaders = this.materialCache.get( material );
18971
+
18972
+ for ( const shaderStage of materialShaders ) {
18973
+
18974
+ shaderStage.usedTimes --;
18975
+
18976
+ if ( shaderStage.usedTimes === 0 ) this.shaderCache.delete( shaderStage );
18977
+
18978
+ }
18979
+
18980
+ this.materialCache.delete( material );
18981
+
18982
+ return this;
18983
+
18984
+ }
18985
+
18986
+ getVertexShaderID( material ) {
18987
+
18988
+ return this._getShaderStage( material.vertexShader ).id;
18989
+
18990
+ }
18991
+
18992
+ getFragmentShaderID( material ) {
18993
+
18994
+ return this._getShaderStage( material.fragmentShader ).id;
18995
+
18996
+ }
18997
+
18998
+ dispose() {
18999
+
19000
+ this.shaderCache.clear();
19001
+ this.materialCache.clear();
19002
+
19003
+ }
19004
+
19005
+ _getShaderCacheForMaterial( material ) {
19006
+
19007
+ const cache = this.materialCache;
19008
+
19009
+ if ( cache.has( material ) === false ) {
19010
+
19011
+ cache.set( material, new Set() );
19012
+
19013
+ }
19014
+
19015
+ return cache.get( material );
19016
+
19017
+ }
19018
+
19019
+ _getShaderStage( code ) {
19020
+
19021
+ const cache = this.shaderCache;
19022
+
19023
+ if ( cache.has( code ) === false ) {
19024
+
19025
+ const stage = new WebGLShaderStage();
19026
+ cache.set( code, stage );
19027
+
19028
+ }
19029
+
19030
+ return cache.get( code );
19031
+
19032
+ }
19033
+
19034
+ }
19035
+
19036
+ class WebGLShaderStage {
19037
+
19038
+ constructor() {
19039
+
19040
+ this.id = _id ++;
19041
+
19042
+ this.usedTimes = 0;
19043
+
19044
+ }
19045
+
19046
+ }
19047
+
19063
19048
  function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping ) {
19064
19049
 
19050
+ const _programLayers = new Layers();
19051
+ const _customShaders = new WebGLShaderCache();
19065
19052
  const programs = [];
19066
19053
 
19067
19054
  const isWebGL2 = capabilities.isWebGL2;
@@ -19069,7 +19056,6 @@
19069
19056
  const floatVertexTextures = capabilities.floatVertexTextures;
19070
19057
  const maxVertexUniforms = capabilities.maxVertexUniforms;
19071
19058
  const vertexTextures = capabilities.vertexTextures;
19072
-
19073
19059
  let precision = capabilities.precision;
19074
19060
 
19075
19061
  const shaderIDs = {
@@ -19090,25 +19076,6 @@
19090
19076
  SpriteMaterial: 'sprite'
19091
19077
  };
19092
19078
 
19093
- const parameterNames = [
19094
- 'precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor',
19095
- 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV',
19096
- 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap',
19097
- 'objectSpaceNormalMap', 'tangentSpaceNormalMap',
19098
- 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap',
19099
- 'displacementMap', 'specularMap', , 'roughnessMap', 'metalnessMap', 'gradientMap',
19100
- 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2',
19101
- 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning',
19102
- 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha',
19103
- 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights',
19104
- 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows',
19105
- 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights',
19106
- 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format',
19107
- 'specularIntensityMap', 'specularColorMap', 'specularColorMapEncoding',
19108
- 'transmission', 'transmissionMap', 'thicknessMap',
19109
- 'sheen', 'sheenColorMap', 'sheenColorMapEncoding', 'sheenRoughnessMap'
19110
- ];
19111
-
19112
19079
  function getMaxBones( object ) {
19113
19080
 
19114
19081
  const skeleton = object.skeleton;
@@ -19201,6 +19168,7 @@
19201
19168
  }
19202
19169
 
19203
19170
  let vertexShader, fragmentShader;
19171
+ let customVertexShaderID, customFragmentShaderID;
19204
19172
 
19205
19173
  if ( shaderID ) {
19206
19174
 
@@ -19214,6 +19182,11 @@
19214
19182
  vertexShader = material.vertexShader;
19215
19183
  fragmentShader = material.fragmentShader;
19216
19184
 
19185
+ _customShaders.update( material );
19186
+
19187
+ customVertexShaderID = _customShaders.getVertexShaderID( material );
19188
+ customFragmentShaderID = _customShaders.getFragmentShaderID( material );
19189
+
19217
19190
  }
19218
19191
 
19219
19192
  const currentRenderTarget = renderer.getRenderTarget();
@@ -19232,6 +19205,9 @@
19232
19205
  fragmentShader: fragmentShader,
19233
19206
  defines: material.defines,
19234
19207
 
19208
+ customVertexShaderID: customVertexShaderID,
19209
+ customFragmentShaderID: customFragmentShaderID,
19210
+
19235
19211
  isRawShaderMaterial: material.isRawShaderMaterial === true,
19236
19212
  glslVersion: material.glslVersion,
19237
19213
 
@@ -19292,8 +19268,8 @@
19292
19268
  vertexTangents: ( !! material.normalMap && !! object.geometry && !! object.geometry.attributes.tangent ),
19293
19269
  vertexColors: material.vertexColors,
19294
19270
  vertexAlphas: material.vertexColors === true && !! object.geometry && !! object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4,
19295
- vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || !! material.sheenColorMap || material.sheenRoughnessMap,
19296
- uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || material.transmission > 0 || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || !! material.sheen > 0 || !! material.sheenColorMap || !! material.sheenRoughnessMap ) && !! material.displacementMap,
19271
+ vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || !! material.sheenColorMap || !! material.sheenRoughnessMap,
19272
+ uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || material.transmission > 0 || !! material.transmissionMap || !! material.thicknessMap || !! material.specularIntensityMap || !! material.specularColorMap || material.sheen > 0 || !! material.sheenColorMap || !! material.sheenRoughnessMap ) && !! material.displacementMap,
19297
19273
 
19298
19274
  fog: !! fog,
19299
19275
  useFog: material.fog,
@@ -19370,8 +19346,8 @@
19370
19346
 
19371
19347
  } else {
19372
19348
 
19373
- array.push( hashString( parameters.fragmentShader ) );
19374
- array.push( hashString( parameters.vertexShader ) );
19349
+ array.push( parameters.customVertexShaderID );
19350
+ array.push( parameters.customFragmentShaderID );
19375
19351
 
19376
19352
  }
19377
19353
 
@@ -19388,14 +19364,9 @@
19388
19364
 
19389
19365
  if ( parameters.isRawShaderMaterial === false ) {
19390
19366
 
19391
- for ( let i = 0; i < parameterNames.length; i ++ ) {
19392
-
19393
- array.push( parameters[ parameterNames[ i ] ] );
19394
-
19395
- }
19396
-
19367
+ getProgramCacheKeyParameters( array, parameters );
19368
+ getProgramCacheKeyBooleans( array, parameters );
19397
19369
  array.push( renderer.outputEncoding );
19398
- array.push( renderer.gammaFactor );
19399
19370
 
19400
19371
  }
19401
19372
 
@@ -19405,6 +19376,161 @@
19405
19376
 
19406
19377
  }
19407
19378
 
19379
+ function getProgramCacheKeyParameters( array, parameters ) {
19380
+
19381
+ array.push( parameters.precision );
19382
+ array.push( parameters.outputEncoding );
19383
+ array.push( parameters.mapEncoding );
19384
+ array.push( parameters.matcapEncoding );
19385
+ array.push( parameters.envMapMode );
19386
+ array.push( parameters.envMapEncoding );
19387
+ array.push( parameters.lightMapEncoding );
19388
+ array.push( parameters.emissiveMapEncoding );
19389
+ array.push( parameters.combine );
19390
+ array.push( parameters.vertexUvs );
19391
+ array.push( parameters.fogExp2 );
19392
+ array.push( parameters.sizeAttenuation );
19393
+ array.push( parameters.maxBones );
19394
+ array.push( parameters.morphTargetsCount );
19395
+ array.push( parameters.numDirLights );
19396
+ array.push( parameters.numPointLights );
19397
+ array.push( parameters.numSpotLights );
19398
+ array.push( parameters.numHemiLights );
19399
+ array.push( parameters.numRectAreaLights );
19400
+ array.push( parameters.numDirLightShadows );
19401
+ array.push( parameters.numPointLightShadows );
19402
+ array.push( parameters.numSpotLightShadows );
19403
+ array.push( parameters.shadowMapType );
19404
+ array.push( parameters.toneMapping );
19405
+ array.push( parameters.numClippingPlanes );
19406
+ array.push( parameters.numClipIntersection );
19407
+ array.push( parameters.format );
19408
+ array.push( parameters.specularColorMapEncoding );
19409
+ array.push( parameters.sheenColorMapEncoding );
19410
+
19411
+ }
19412
+
19413
+ function getProgramCacheKeyBooleans( array, parameters ) {
19414
+
19415
+ _programLayers.disableAll();
19416
+
19417
+ if ( parameters.isWebGL2 )
19418
+ _programLayers.enable( 0 );
19419
+ if ( parameters.supportsVertexTextures )
19420
+ _programLayers.enable( 1 );
19421
+ if ( parameters.instancing )
19422
+ _programLayers.enable( 2 );
19423
+ if ( parameters.instancingColor )
19424
+ _programLayers.enable( 3 );
19425
+ if ( parameters.map )
19426
+ _programLayers.enable( 4 );
19427
+ if ( parameters.matcap )
19428
+ _programLayers.enable( 5 );
19429
+ if ( parameters.envMap )
19430
+ _programLayers.enable( 6 );
19431
+ if ( parameters.envMapCubeUV )
19432
+ _programLayers.enable( 7 );
19433
+ if ( parameters.lightMap )
19434
+ _programLayers.enable( 8 );
19435
+ if ( parameters.aoMap )
19436
+ _programLayers.enable( 9 );
19437
+ if ( parameters.emissiveMap )
19438
+ _programLayers.enable( 10 );
19439
+ if ( parameters.bumpMap )
19440
+ _programLayers.enable( 11 );
19441
+ if ( parameters.normalMap )
19442
+ _programLayers.enable( 12 );
19443
+ if ( parameters.objectSpaceNormalMap )
19444
+ _programLayers.enable( 13 );
19445
+ if ( parameters.tangentSpaceNormalMap )
19446
+ _programLayers.enable( 14 );
19447
+ if ( parameters.clearcoat )
19448
+ _programLayers.enable( 15 );
19449
+ if ( parameters.clearcoatMap )
19450
+ _programLayers.enable( 16 );
19451
+ if ( parameters.clearcoatRoughnessMap )
19452
+ _programLayers.enable( 17 );
19453
+ if ( parameters.clearcoatNormalMap )
19454
+ _programLayers.enable( 18 );
19455
+ if ( parameters.displacementMap )
19456
+ _programLayers.enable( 19 );
19457
+ if ( parameters.specularMap )
19458
+ _programLayers.enable( 20 );
19459
+ if ( parameters.roughnessMap )
19460
+ _programLayers.enable( 21 );
19461
+ if ( parameters.metalnessMap )
19462
+ _programLayers.enable( 22 );
19463
+ if ( parameters.gradientMap )
19464
+ _programLayers.enable( 23 );
19465
+ if ( parameters.alphaMap )
19466
+ _programLayers.enable( 24 );
19467
+ if ( parameters.alphaTest )
19468
+ _programLayers.enable( 25 );
19469
+ if ( parameters.vertexColors )
19470
+ _programLayers.enable( 26 );
19471
+ if ( parameters.vertexAlphas )
19472
+ _programLayers.enable( 27 );
19473
+ if ( parameters.vertexUvs )
19474
+ _programLayers.enable( 28 );
19475
+ if ( parameters.vertexTangents )
19476
+ _programLayers.enable( 29 );
19477
+ if ( parameters.uvsVertexOnly )
19478
+ _programLayers.enable( 30 );
19479
+ if ( parameters.fog )
19480
+ _programLayers.enable( 31 );
19481
+
19482
+ array.push( _programLayers.mask );
19483
+ _programLayers.disableAll();
19484
+
19485
+ if ( parameters.useFog )
19486
+ _programLayers.enable( 0 );
19487
+ if ( parameters.flatShading )
19488
+ _programLayers.enable( 1 );
19489
+ if ( parameters.logarithmicDepthBuffer )
19490
+ _programLayers.enable( 2 );
19491
+ if ( parameters.skinning )
19492
+ _programLayers.enable( 3 );
19493
+ if ( parameters.useVertexTexture )
19494
+ _programLayers.enable( 4 );
19495
+ if ( parameters.morphTargets )
19496
+ _programLayers.enable( 5 );
19497
+ if ( parameters.morphNormals )
19498
+ _programLayers.enable( 6 );
19499
+ if ( parameters.premultipliedAlpha )
19500
+ _programLayers.enable( 7 );
19501
+ if ( parameters.shadowMapEnabled )
19502
+ _programLayers.enable( 8 );
19503
+ if ( parameters.physicallyCorrectLights )
19504
+ _programLayers.enable( 9 );
19505
+ if ( parameters.doubleSided )
19506
+ _programLayers.enable( 10 );
19507
+ if ( parameters.flipSided )
19508
+ _programLayers.enable( 11 );
19509
+ if ( parameters.depthPacking )
19510
+ _programLayers.enable( 12 );
19511
+ if ( parameters.dithering )
19512
+ _programLayers.enable( 13 );
19513
+ if ( parameters.specularIntensityMap )
19514
+ _programLayers.enable( 14 );
19515
+ if ( parameters.specularColorMap )
19516
+ _programLayers.enable( 15 );
19517
+ if ( parameters.transmission )
19518
+ _programLayers.enable( 16 );
19519
+ if ( parameters.transmissionMap )
19520
+ _programLayers.enable( 17 );
19521
+ if ( parameters.thicknessMap )
19522
+ _programLayers.enable( 18 );
19523
+ if ( parameters.sheen )
19524
+ _programLayers.enable( 19 );
19525
+ if ( parameters.sheenColorMap )
19526
+ _programLayers.enable( 20 );
19527
+ if ( parameters.sheenRoughnessMap )
19528
+ _programLayers.enable( 21 );
19529
+
19530
+ array.push( _programLayers.mask );
19531
+
19532
+ }
19533
+
19408
19534
  function getUniforms( material ) {
19409
19535
 
19410
19536
  const shaderID = shaderIDs[ material.type ];
@@ -19472,14 +19598,28 @@
19472
19598
 
19473
19599
  }
19474
19600
 
19601
+ function releaseShaderCache( material ) {
19602
+
19603
+ _customShaders.remove( material );
19604
+
19605
+ }
19606
+
19607
+ function dispose() {
19608
+
19609
+ _customShaders.dispose();
19610
+
19611
+ }
19612
+
19475
19613
  return {
19476
19614
  getParameters: getParameters,
19477
19615
  getProgramCacheKey: getProgramCacheKey,
19478
19616
  getUniforms: getUniforms,
19479
19617
  acquireProgram: acquireProgram,
19480
19618
  releaseProgram: releaseProgram,
19619
+ releaseShaderCache: releaseShaderCache,
19481
19620
  // Exposed for resource monitoring & error feedback via renderer.info:
19482
- programs: programs
19621
+ programs: programs,
19622
+ dispose: dispose
19483
19623
  };
19484
19624
 
19485
19625
  }
@@ -19540,10 +19680,6 @@
19540
19680
 
19541
19681
  return a.renderOrder - b.renderOrder;
19542
19682
 
19543
- } else if ( a.program !== b.program ) {
19544
-
19545
- return a.program.id - b.program.id;
19546
-
19547
19683
  } else if ( a.material.id !== b.material.id ) {
19548
19684
 
19549
19685
  return a.material.id - b.material.id;
@@ -19583,7 +19719,7 @@
19583
19719
  }
19584
19720
 
19585
19721
 
19586
- function WebGLRenderList( properties ) {
19722
+ function WebGLRenderList() {
19587
19723
 
19588
19724
  const renderItems = [];
19589
19725
  let renderItemsIndex = 0;
@@ -19592,8 +19728,6 @@
19592
19728
  const transmissive = [];
19593
19729
  const transparent = [];
19594
19730
 
19595
- const defaultProgram = { id: - 1 };
19596
-
19597
19731
  function init() {
19598
19732
 
19599
19733
  renderItemsIndex = 0;
@@ -19607,7 +19741,6 @@
19607
19741
  function getNextRenderItem( object, geometry, material, groupOrder, z, group ) {
19608
19742
 
19609
19743
  let renderItem = renderItems[ renderItemsIndex ];
19610
- const materialProperties = properties.get( material );
19611
19744
 
19612
19745
  if ( renderItem === undefined ) {
19613
19746
 
@@ -19616,7 +19749,6 @@
19616
19749
  object: object,
19617
19750
  geometry: geometry,
19618
19751
  material: material,
19619
- program: materialProperties.program || defaultProgram,
19620
19752
  groupOrder: groupOrder,
19621
19753
  renderOrder: object.renderOrder,
19622
19754
  z: z,
@@ -19631,7 +19763,6 @@
19631
19763
  renderItem.object = object;
19632
19764
  renderItem.geometry = geometry;
19633
19765
  renderItem.material = material;
19634
- renderItem.program = materialProperties.program || defaultProgram;
19635
19766
  renderItem.groupOrder = groupOrder;
19636
19767
  renderItem.renderOrder = object.renderOrder;
19637
19768
  renderItem.z = z;
@@ -19707,7 +19838,6 @@
19707
19838
  renderItem.object = null;
19708
19839
  renderItem.geometry = null;
19709
19840
  renderItem.material = null;
19710
- renderItem.program = null;
19711
19841
  renderItem.group = null;
19712
19842
 
19713
19843
  }
@@ -19730,7 +19860,7 @@
19730
19860
 
19731
19861
  }
19732
19862
 
19733
- function WebGLRenderLists( properties ) {
19863
+ function WebGLRenderLists() {
19734
19864
 
19735
19865
  let lists = new WeakMap();
19736
19866
 
@@ -19740,14 +19870,14 @@
19740
19870
 
19741
19871
  if ( lists.has( scene ) === false ) {
19742
19872
 
19743
- list = new WebGLRenderList( properties );
19873
+ list = new WebGLRenderList();
19744
19874
  lists.set( scene, [ list ] );
19745
19875
 
19746
19876
  } else {
19747
19877
 
19748
19878
  if ( renderCallDepth >= lists.get( scene ).length ) {
19749
19879
 
19750
- list = new WebGLRenderList( properties );
19880
+ list = new WebGLRenderList();
19751
19881
  lists.get( scene ).push( list );
19752
19882
 
19753
19883
  } else {
@@ -21242,7 +21372,6 @@
21242
21372
 
21243
21373
  let enabledCapabilities = {};
21244
21374
 
21245
- let xrFramebuffer = null;
21246
21375
  let currentBoundFramebuffers = {};
21247
21376
 
21248
21377
  let currentProgram = null;
@@ -21354,22 +21483,8 @@
21354
21483
 
21355
21484
  }
21356
21485
 
21357
- function bindXRFramebuffer( framebuffer ) {
21358
-
21359
- if ( framebuffer !== xrFramebuffer ) {
21360
-
21361
- gl.bindFramebuffer( 36160, framebuffer );
21362
-
21363
- xrFramebuffer = framebuffer;
21364
-
21365
- }
21366
-
21367
- }
21368
-
21369
21486
  function bindFramebuffer( target, framebuffer ) {
21370
21487
 
21371
- if ( framebuffer === null && xrFramebuffer !== null ) framebuffer = xrFramebuffer; // use active XR framebuffer if available
21372
-
21373
21488
  if ( currentBoundFramebuffers[ target ] !== framebuffer ) {
21374
21489
 
21375
21490
  gl.bindFramebuffer( target, framebuffer );
@@ -21805,6 +21920,76 @@
21805
21920
 
21806
21921
  }
21807
21922
 
21923
+ function texSubImage2D() {
21924
+
21925
+ try {
21926
+
21927
+ gl.texSubImage2D.apply( gl, arguments );
21928
+
21929
+ } catch ( error ) {
21930
+
21931
+ console.error( 'THREE.WebGLState:', error );
21932
+
21933
+ }
21934
+
21935
+ }
21936
+
21937
+ function texSubImage3D() {
21938
+
21939
+ try {
21940
+
21941
+ gl.texSubImage3D.apply( gl, arguments );
21942
+
21943
+ } catch ( error ) {
21944
+
21945
+ console.error( 'THREE.WebGLState:', error );
21946
+
21947
+ }
21948
+
21949
+ }
21950
+
21951
+ function compressedTexSubImage2D() {
21952
+
21953
+ try {
21954
+
21955
+ gl.compressedTexSubImage2D.apply( gl, arguments );
21956
+
21957
+ } catch ( error ) {
21958
+
21959
+ console.error( 'THREE.WebGLState:', error );
21960
+
21961
+ }
21962
+
21963
+ }
21964
+
21965
+ function texStorage2D() {
21966
+
21967
+ try {
21968
+
21969
+ gl.texStorage2D.apply( gl, arguments );
21970
+
21971
+ } catch ( error ) {
21972
+
21973
+ console.error( 'THREE.WebGLState:', error );
21974
+
21975
+ }
21976
+
21977
+ }
21978
+
21979
+ function texStorage3D() {
21980
+
21981
+ try {
21982
+
21983
+ gl.texStorage3D.apply( gl, arguments );
21984
+
21985
+ } catch ( error ) {
21986
+
21987
+ console.error( 'THREE.WebGLState:', error );
21988
+
21989
+ }
21990
+
21991
+ }
21992
+
21808
21993
  function texImage2D() {
21809
21994
 
21810
21995
  try {
@@ -21917,7 +22102,6 @@
21917
22102
  currentTextureSlot = null;
21918
22103
  currentBoundTextures = {};
21919
22104
 
21920
- xrFramebuffer = null;
21921
22105
  currentBoundFramebuffers = {};
21922
22106
 
21923
22107
  currentProgram = null;
@@ -21961,7 +22145,6 @@
21961
22145
  disable: disable,
21962
22146
 
21963
22147
  bindFramebuffer: bindFramebuffer,
21964
- bindXRFramebuffer: bindXRFramebuffer,
21965
22148
 
21966
22149
  useProgram: useProgram,
21967
22150
 
@@ -21983,6 +22166,12 @@
21983
22166
  texImage2D: texImage2D,
21984
22167
  texImage3D: texImage3D,
21985
22168
 
22169
+ texStorage2D: texStorage2D,
22170
+ texStorage3D: texStorage3D,
22171
+ texSubImage2D: texSubImage2D,
22172
+ texSubImage3D: texSubImage3D,
22173
+ compressedTexSubImage2D: compressedTexSubImage2D,
22174
+
21986
22175
  scissor: scissor,
21987
22176
  viewport: viewport,
21988
22177
 
@@ -21999,6 +22188,8 @@
21999
22188
  const maxCubemapSize = capabilities.maxCubemapSize;
22000
22189
  const maxTextureSize = capabilities.maxTextureSize;
22001
22190
  const maxSamples = capabilities.maxSamples;
22191
+ const hasMultisampledRenderToTexture = extensions.has( 'WEBGL_multisampled_render_to_texture' );
22192
+ const MultisampledRenderToTextureExtension = hasMultisampledRenderToTexture ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : undefined;
22002
22193
 
22003
22194
  const _videoTextures = new WeakMap();
22004
22195
  let _canvas;
@@ -22112,14 +22303,10 @@
22112
22303
 
22113
22304
  }
22114
22305
 
22115
- function generateMipmap( target, texture, width, height, depth = 1 ) {
22306
+ function generateMipmap( target ) {
22116
22307
 
22117
22308
  _gl.generateMipmap( target );
22118
22309
 
22119
- const textureProperties = properties.get( texture );
22120
-
22121
- textureProperties.__maxMipLevel = Math.log2( Math.max( width, height, depth ) );
22122
-
22123
22310
  }
22124
22311
 
22125
22312
  function getInternalFormat( internalFormatName, glFormat, glType, encoding ) {
@@ -22171,6 +22358,32 @@
22171
22358
 
22172
22359
  }
22173
22360
 
22361
+ function getMipLevels( texture, image, supportsMips ) {
22362
+
22363
+ if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
22364
+
22365
+ return Math.log2( Math.max( image.width, image.height ) ) + 1;
22366
+
22367
+ } else if ( texture.mipmaps !== undefined && texture.mipmaps.length > 0 ) {
22368
+
22369
+ // user-defined mipmaps
22370
+
22371
+ return texture.mipmaps.length;
22372
+
22373
+ } else if ( texture.isCompressedTexture && Array.isArray( texture.image ) ) {
22374
+
22375
+ return image.mipmaps.length;
22376
+
22377
+ } else {
22378
+
22379
+ // texture without mipmaps (only base level)
22380
+
22381
+ return 1;
22382
+
22383
+ }
22384
+
22385
+ }
22386
+
22174
22387
  // Fallback filters for non-power-of-2 textures
22175
22388
 
22176
22389
  function filterFallback( f ) {
@@ -22529,6 +22742,10 @@
22529
22742
  let mipmap;
22530
22743
  const mipmaps = texture.mipmaps;
22531
22744
 
22745
+ const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
22746
+ const allocateMemory = ( textureProperties.__version === undefined );
22747
+ const levels = getMipLevels( texture, image, supportsMips );
22748
+
22532
22749
  if ( texture.isDepthTexture ) {
22533
22750
 
22534
22751
  // populate depth texture with dummy data
@@ -22605,7 +22822,15 @@
22605
22822
 
22606
22823
  //
22607
22824
 
22608
- state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
22825
+ if ( useTexStorage && allocateMemory ) {
22826
+
22827
+ state.texStorage2D( 3553, 1, glInternalFormat, image.width, image.height );
22828
+
22829
+ } else {
22830
+
22831
+ state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
22832
+
22833
+ }
22609
22834
 
22610
22835
  } else if ( texture.isDataTexture ) {
22611
22836
 
@@ -22615,25 +22840,58 @@
22615
22840
 
22616
22841
  if ( mipmaps.length > 0 && supportsMips ) {
22617
22842
 
22843
+ if ( useTexStorage && allocateMemory ) {
22844
+
22845
+ state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
22846
+
22847
+ }
22848
+
22618
22849
  for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
22619
22850
 
22620
22851
  mipmap = mipmaps[ i ];
22621
- state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22852
+
22853
+ if ( useTexStorage ) {
22854
+
22855
+ state.texSubImage2D( 3553, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
22856
+
22857
+ } else {
22858
+
22859
+ state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22860
+
22861
+ }
22622
22862
 
22623
22863
  }
22624
22864
 
22625
22865
  texture.generateMipmaps = false;
22626
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22627
22866
 
22628
22867
  } else {
22629
22868
 
22630
- state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
22631
- textureProperties.__maxMipLevel = 0;
22869
+ if ( useTexStorage ) {
22870
+
22871
+ if ( allocateMemory ) {
22872
+
22873
+ state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
22874
+
22875
+ }
22876
+
22877
+ state.texSubImage2D( 3553, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
22878
+
22879
+ } else {
22880
+
22881
+ state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
22882
+
22883
+ }
22632
22884
 
22633
22885
  }
22634
22886
 
22635
22887
  } else if ( texture.isCompressedTexture ) {
22636
22888
 
22889
+ if ( useTexStorage && allocateMemory ) {
22890
+
22891
+ state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
22892
+
22893
+ }
22894
+
22637
22895
  for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
22638
22896
 
22639
22897
  mipmap = mipmaps[ i ];
@@ -22642,7 +22900,15 @@
22642
22900
 
22643
22901
  if ( glFormat !== null ) {
22644
22902
 
22645
- state.compressedTexImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
22903
+ if ( useTexStorage ) {
22904
+
22905
+ state.compressedTexSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
22906
+
22907
+ } else {
22908
+
22909
+ state.compressedTexImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
22910
+
22911
+ }
22646
22912
 
22647
22913
  } else {
22648
22914
 
@@ -22652,23 +22918,67 @@
22652
22918
 
22653
22919
  } else {
22654
22920
 
22655
- state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22921
+ if ( useTexStorage ) {
22922
+
22923
+ state.texSubImage2D( 3553, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
22924
+
22925
+ } else {
22926
+
22927
+ state.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
22928
+
22929
+ }
22656
22930
 
22657
22931
  }
22658
22932
 
22659
22933
  }
22660
22934
 
22661
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22662
-
22663
22935
  } else if ( texture.isDataTexture2DArray ) {
22664
22936
 
22665
- state.texImage3D( 35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22666
- textureProperties.__maxMipLevel = 0;
22937
+ if ( useTexStorage ) {
22938
+
22939
+ if ( allocateMemory ) {
22940
+
22941
+ state.texStorage3D( 35866, levels, glInternalFormat, image.width, image.height, image.depth );
22942
+
22943
+ }
22944
+
22945
+ state.texSubImage3D( 35866, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
22946
+
22947
+ } else {
22948
+
22949
+ state.texImage3D( 35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22950
+
22951
+ }
22667
22952
 
22668
22953
  } else if ( texture.isDataTexture3D ) {
22669
22954
 
22670
- state.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22671
- textureProperties.__maxMipLevel = 0;
22955
+ if ( useTexStorage ) {
22956
+
22957
+ if ( allocateMemory ) {
22958
+
22959
+ state.texStorage3D( 32879, levels, glInternalFormat, image.width, image.height, image.depth );
22960
+
22961
+ }
22962
+
22963
+ state.texSubImage3D( 32879, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
22964
+
22965
+ } else {
22966
+
22967
+ state.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
22968
+
22969
+ }
22970
+
22971
+ } else if ( texture.isFramebufferTexture ) {
22972
+
22973
+ if ( useTexStorage && allocateMemory ) {
22974
+
22975
+ state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
22976
+
22977
+ } else {
22978
+
22979
+ state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
22980
+
22981
+ }
22672
22982
 
22673
22983
  } else {
22674
22984
 
@@ -22680,20 +22990,47 @@
22680
22990
 
22681
22991
  if ( mipmaps.length > 0 && supportsMips ) {
22682
22992
 
22993
+ if ( useTexStorage && allocateMemory ) {
22994
+
22995
+ state.texStorage2D( 3553, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
22996
+
22997
+ }
22998
+
22683
22999
  for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
22684
23000
 
22685
23001
  mipmap = mipmaps[ i ];
22686
- state.texImage2D( 3553, i, glInternalFormat, glFormat, glType, mipmap );
23002
+
23003
+ if ( useTexStorage ) {
23004
+
23005
+ state.texSubImage2D( 3553, i, 0, 0, glFormat, glType, mipmap );
23006
+
23007
+ } else {
23008
+
23009
+ state.texImage2D( 3553, i, glInternalFormat, glFormat, glType, mipmap );
23010
+
23011
+ }
22687
23012
 
22688
23013
  }
22689
23014
 
22690
23015
  texture.generateMipmaps = false;
22691
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22692
23016
 
22693
23017
  } else {
22694
23018
 
22695
- state.texImage2D( 3553, 0, glInternalFormat, glFormat, glType, image );
22696
- textureProperties.__maxMipLevel = 0;
23019
+ if ( useTexStorage ) {
23020
+
23021
+ if ( allocateMemory ) {
23022
+
23023
+ state.texStorage2D( 3553, levels, glInternalFormat, image.width, image.height );
23024
+
23025
+ }
23026
+
23027
+ state.texSubImage2D( 3553, 0, 0, 0, glFormat, glType, image );
23028
+
23029
+ } else {
23030
+
23031
+ state.texImage2D( 3553, 0, glInternalFormat, glFormat, glType, image );
23032
+
23033
+ }
22697
23034
 
22698
23035
  }
22699
23036
 
@@ -22701,7 +23038,7 @@
22701
23038
 
22702
23039
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
22703
23040
 
22704
- generateMipmap( textureType, texture, image.width, image.height );
23041
+ generateMipmap( textureType );
22705
23042
 
22706
23043
  }
22707
23044
 
@@ -22750,12 +23087,22 @@
22750
23087
  glType = utils.convert( texture.type ),
22751
23088
  glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
22752
23089
 
23090
+ const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
23091
+ const allocateMemory = ( textureProperties.__version === undefined );
23092
+ let levels = getMipLevels( texture, image, supportsMips );
23093
+
22753
23094
  setTextureParameters( 34067, texture, supportsMips );
22754
23095
 
22755
23096
  let mipmaps;
22756
23097
 
22757
23098
  if ( isCompressed ) {
22758
23099
 
23100
+ if ( useTexStorage && allocateMemory ) {
23101
+
23102
+ state.texStorage2D( 34067, levels, glInternalFormat, image.width, image.height );
23103
+
23104
+ }
23105
+
22759
23106
  for ( let i = 0; i < 6; i ++ ) {
22760
23107
 
22761
23108
  mipmaps = cubeImage[ i ].mipmaps;
@@ -22768,7 +23115,15 @@
22768
23115
 
22769
23116
  if ( glFormat !== null ) {
22770
23117
 
22771
- state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
23118
+ if ( useTexStorage ) {
23119
+
23120
+ state.compressedTexSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
23121
+
23122
+ } else {
23123
+
23124
+ state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
23125
+
23126
+ }
22772
23127
 
22773
23128
  } else {
22774
23129
 
@@ -22778,7 +23133,15 @@
22778
23133
 
22779
23134
  } else {
22780
23135
 
22781
- state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
23136
+ if ( useTexStorage ) {
23137
+
23138
+ state.texSubImage2D( 34069 + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
23139
+
23140
+ } else {
23141
+
23142
+ state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
23143
+
23144
+ }
22782
23145
 
22783
23146
  }
22784
23147
 
@@ -22786,36 +23149,78 @@
22786
23149
 
22787
23150
  }
22788
23151
 
22789
- textureProperties.__maxMipLevel = mipmaps.length - 1;
22790
-
22791
23152
  } else {
22792
23153
 
22793
23154
  mipmaps = texture.mipmaps;
22794
23155
 
23156
+ if ( useTexStorage && allocateMemory ) {
23157
+
23158
+ // TODO: Uniformly handle mipmap definitions
23159
+ // Normal textures and compressed cube textures define base level + mips with their mipmap array
23160
+ // Uncompressed cube textures use their mipmap array only for mips (no base level)
23161
+
23162
+ if ( mipmaps.length > 0 ) levels ++;
23163
+
23164
+ state.texStorage2D( 34067, levels, glInternalFormat, cubeImage[ 0 ].width, cubeImage[ 0 ].height );
23165
+
23166
+ }
23167
+
22795
23168
  for ( let i = 0; i < 6; i ++ ) {
22796
23169
 
22797
23170
  if ( isDataTexture ) {
22798
23171
 
22799
- state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
23172
+ if ( useTexStorage ) {
23173
+
23174
+ state.texSubImage2D( 34069 + i, 0, 0, 0, cubeImage[ i ].width, cubeImage[ i ].height, glFormat, glType, cubeImage[ i ].data );
23175
+
23176
+ } else {
23177
+
23178
+ state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
23179
+
23180
+ }
22800
23181
 
22801
23182
  for ( let j = 0; j < mipmaps.length; j ++ ) {
22802
23183
 
22803
23184
  const mipmap = mipmaps[ j ];
22804
23185
  const mipmapImage = mipmap.image[ i ].image;
22805
23186
 
22806
- state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
23187
+ if ( useTexStorage ) {
23188
+
23189
+ state.texSubImage2D( 34069 + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data );
23190
+
23191
+ } else {
23192
+
23193
+ state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
23194
+
23195
+ }
22807
23196
 
22808
23197
  }
22809
23198
 
22810
23199
  } else {
22811
23200
 
22812
- state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
23201
+ if ( useTexStorage ) {
23202
+
23203
+ state.texSubImage2D( 34069 + i, 0, 0, 0, glFormat, glType, cubeImage[ i ] );
23204
+
23205
+ } else {
23206
+
23207
+ state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
23208
+
23209
+ }
22813
23210
 
22814
23211
  for ( let j = 0; j < mipmaps.length; j ++ ) {
22815
23212
 
22816
23213
  const mipmap = mipmaps[ j ];
22817
23214
 
22818
- state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
23215
+ if ( useTexStorage ) {
23216
+
23217
+ state.texSubImage2D( 34069 + i, j + 1, 0, 0, glFormat, glType, mipmap.image[ i ] );
23218
+
23219
+ } else {
23220
+
23221
+ state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
23222
+
23223
+ }
22819
23224
 
22820
23225
  }
22821
23226
 
@@ -22823,14 +23228,12 @@
22823
23228
 
22824
23229
  }
22825
23230
 
22826
- textureProperties.__maxMipLevel = mipmaps.length;
22827
-
22828
23231
  }
22829
23232
 
22830
23233
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
22831
23234
 
22832
23235
  // We assume images for cube map have the same size.
22833
- generateMipmap( 34067, texture, image.width, image.height );
23236
+ generateMipmap( 34067 );
22834
23237
 
22835
23238
  }
22836
23239
 
@@ -22848,23 +23251,38 @@
22848
23251
  const glFormat = utils.convert( texture.format );
22849
23252
  const glType = utils.convert( texture.type );
22850
23253
  const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
23254
+ const renderTargetProperties = properties.get( renderTarget );
22851
23255
 
22852
- if ( textureTarget === 32879 || textureTarget === 35866 ) {
23256
+ if ( ! renderTargetProperties.__hasExternalTextures ) {
22853
23257
 
22854
- state.texImage3D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null );
23258
+ if ( textureTarget === 32879 || textureTarget === 35866 ) {
22855
23259
 
22856
- } else {
23260
+ state.texImage3D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null );
23261
+
23262
+ } else {
22857
23263
 
22858
- state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
23264
+ state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
23265
+
23266
+ }
22859
23267
 
22860
23268
  }
22861
23269
 
22862
23270
  state.bindFramebuffer( 36160, framebuffer );
22863
- _gl.framebufferTexture2D( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
23271
+ if ( renderTarget.useRenderToTexture ) {
23272
+
23273
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
23274
+
23275
+ } else {
23276
+
23277
+ _gl.framebufferTexture2D( 36160, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
23278
+
23279
+ }
23280
+
22864
23281
  state.bindFramebuffer( 36160, null );
22865
23282
 
22866
23283
  }
22867
23284
 
23285
+
22868
23286
  // Setup storage for internal depth/stencil buffers and bind to correct framebuffer
22869
23287
  function setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {
22870
23288
 
@@ -22874,7 +23292,7 @@
22874
23292
 
22875
23293
  let glInternalFormat = 33189;
22876
23294
 
22877
- if ( isMultisample ) {
23295
+ if ( isMultisample || renderTarget.useRenderToTexture ) {
22878
23296
 
22879
23297
  const depthTexture = renderTarget.depthTexture;
22880
23298
 
@@ -22894,7 +23312,15 @@
22894
23312
 
22895
23313
  const samples = getRenderTargetSamples( renderTarget );
22896
23314
 
22897
- _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23315
+ if ( renderTarget.useRenderToTexture ) {
23316
+
23317
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23318
+
23319
+ } else {
23320
+
23321
+ _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23322
+
23323
+ }
22898
23324
 
22899
23325
  } else {
22900
23326
 
@@ -22906,12 +23332,16 @@
22906
23332
 
22907
23333
  } else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
22908
23334
 
22909
- if ( isMultisample ) {
23335
+ const samples = getRenderTargetSamples( renderTarget );
22910
23336
 
22911
- const samples = getRenderTargetSamples( renderTarget );
23337
+ if ( isMultisample && renderTarget.useRenderbuffer ) {
22912
23338
 
22913
23339
  _gl.renderbufferStorageMultisample( 36161, samples, 35056, renderTarget.width, renderTarget.height );
22914
23340
 
23341
+ } else if ( renderTarget.useRenderToTexture ) {
23342
+
23343
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, 35056, renderTarget.width, renderTarget.height );
23344
+
22915
23345
  } else {
22916
23346
 
22917
23347
  _gl.renderbufferStorage( 36161, 34041, renderTarget.width, renderTarget.height );
@@ -22929,13 +23359,16 @@
22929
23359
  const glFormat = utils.convert( texture.format );
22930
23360
  const glType = utils.convert( texture.type );
22931
23361
  const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.encoding );
23362
+ const samples = getRenderTargetSamples( renderTarget );
22932
23363
 
22933
- if ( isMultisample ) {
22934
-
22935
- const samples = getRenderTargetSamples( renderTarget );
23364
+ if ( isMultisample && renderTarget.useRenderbuffer ) {
22936
23365
 
22937
23366
  _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
22938
23367
 
23368
+ } else if ( renderTarget.useRenderToTexture ) {
23369
+
23370
+ MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height );
23371
+
22939
23372
  } else {
22940
23373
 
22941
23374
  _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height );
@@ -22976,14 +23409,31 @@
22976
23409
  setTexture2D( renderTarget.depthTexture, 0 );
22977
23410
 
22978
23411
  const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
23412
+ const samples = getRenderTargetSamples( renderTarget );
22979
23413
 
22980
23414
  if ( renderTarget.depthTexture.format === DepthFormat ) {
22981
23415
 
22982
- _gl.framebufferTexture2D( 36160, 36096, 3553, webglDepthTexture, 0 );
23416
+ if ( renderTarget.useRenderToTexture ) {
23417
+
23418
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 36096, 3553, webglDepthTexture, 0, samples );
23419
+
23420
+ } else {
23421
+
23422
+ _gl.framebufferTexture2D( 36160, 36096, 3553, webglDepthTexture, 0 );
23423
+
23424
+ }
22983
23425
 
22984
23426
  } else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
22985
23427
 
22986
- _gl.framebufferTexture2D( 36160, 33306, 3553, webglDepthTexture, 0 );
23428
+ if ( renderTarget.useRenderToTexture ) {
23429
+
23430
+ MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( 36160, 33306, 3553, webglDepthTexture, 0, samples );
23431
+
23432
+ } else {
23433
+
23434
+ _gl.framebufferTexture2D( 36160, 33306, 3553, webglDepthTexture, 0 );
23435
+
23436
+ }
22987
23437
 
22988
23438
  } else {
22989
23439
 
@@ -22997,10 +23447,9 @@
22997
23447
  function setupDepthRenderbuffer( renderTarget ) {
22998
23448
 
22999
23449
  const renderTargetProperties = properties.get( renderTarget );
23000
-
23001
23450
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
23002
23451
 
23003
- if ( renderTarget.depthTexture ) {
23452
+ if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
23004
23453
 
23005
23454
  if ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );
23006
23455
 
@@ -23034,6 +23483,25 @@
23034
23483
 
23035
23484
  }
23036
23485
 
23486
+ // rebind framebuffer with external textures
23487
+ function rebindTextures( renderTarget, colorTexture, depthTexture ) {
23488
+
23489
+ const renderTargetProperties = properties.get( renderTarget );
23490
+
23491
+ if ( colorTexture !== undefined ) {
23492
+
23493
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, 36064, 3553 );
23494
+
23495
+ }
23496
+
23497
+ if ( depthTexture !== undefined ) {
23498
+
23499
+ setupDepthRenderbuffer( renderTarget );
23500
+
23501
+ }
23502
+
23503
+ }
23504
+
23037
23505
  // Set up GL resources for the render target
23038
23506
  function setupRenderTarget( renderTarget ) {
23039
23507
 
@@ -23046,7 +23514,12 @@
23046
23514
 
23047
23515
  if ( renderTarget.isWebGLMultipleRenderTargets !== true ) {
23048
23516
 
23049
- textureProperties.__webglTexture = _gl.createTexture();
23517
+ if ( textureProperties.__webglTexture === undefined ) {
23518
+
23519
+ textureProperties.__webglTexture = _gl.createTexture();
23520
+
23521
+ }
23522
+
23050
23523
  textureProperties.__version = texture.version;
23051
23524
  info.memory.textures ++;
23052
23525
 
@@ -23054,7 +23527,6 @@
23054
23527
 
23055
23528
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
23056
23529
  const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
23057
- const isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );
23058
23530
  const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray;
23059
23531
  const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
23060
23532
 
@@ -23110,7 +23582,7 @@
23110
23582
 
23111
23583
  }
23112
23584
 
23113
- } else if ( isMultisample ) {
23585
+ } else if ( renderTarget.useRenderbuffer ) {
23114
23586
 
23115
23587
  if ( isWebGL2 ) {
23116
23588
 
@@ -23164,7 +23636,7 @@
23164
23636
 
23165
23637
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
23166
23638
 
23167
- generateMipmap( 34067, texture, renderTarget.width, renderTarget.height );
23639
+ generateMipmap( 34067 );
23168
23640
 
23169
23641
  }
23170
23642
 
@@ -23185,7 +23657,7 @@
23185
23657
 
23186
23658
  if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) {
23187
23659
 
23188
- generateMipmap( 3553, attachment, renderTarget.width, renderTarget.height );
23660
+ generateMipmap( 3553 );
23189
23661
 
23190
23662
  }
23191
23663
 
@@ -23220,7 +23692,7 @@
23220
23692
 
23221
23693
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
23222
23694
 
23223
- generateMipmap( glTextureType, texture, renderTarget.width, renderTarget.height, renderTarget.depth );
23695
+ generateMipmap( glTextureType );
23224
23696
 
23225
23697
  }
23226
23698
 
@@ -23254,7 +23726,7 @@
23254
23726
  const webglTexture = properties.get( texture ).__webglTexture;
23255
23727
 
23256
23728
  state.bindTexture( target, webglTexture );
23257
- generateMipmap( target, texture, renderTarget.width, renderTarget.height );
23729
+ generateMipmap( target );
23258
23730
  state.unbindTexture();
23259
23731
 
23260
23732
  }
@@ -23265,23 +23737,43 @@
23265
23737
 
23266
23738
  function updateMultisampleRenderTarget( renderTarget ) {
23267
23739
 
23268
- if ( renderTarget.isWebGLMultisampleRenderTarget ) {
23740
+ if ( renderTarget.useRenderbuffer ) {
23269
23741
 
23270
23742
  if ( isWebGL2 ) {
23271
23743
 
23272
23744
  const width = renderTarget.width;
23273
23745
  const height = renderTarget.height;
23274
23746
  let mask = 16384;
23747
+ const invalidationArray = [ 36064 ];
23748
+ const depthStyle = renderTarget.stencilBuffer ? 33306 : 36096;
23749
+
23750
+ if ( renderTarget.depthBuffer ) {
23751
+
23752
+ invalidationArray.push( depthStyle );
23753
+
23754
+ }
23755
+
23756
+ if ( ! renderTarget.ignoreDepthForMultisampleCopy ) {
23275
23757
 
23276
- if ( renderTarget.depthBuffer ) mask |= 256;
23277
- if ( renderTarget.stencilBuffer ) mask |= 1024;
23758
+ if ( renderTarget.depthBuffer ) mask |= 256;
23759
+ if ( renderTarget.stencilBuffer ) mask |= 1024;
23760
+
23761
+ }
23278
23762
 
23279
23763
  const renderTargetProperties = properties.get( renderTarget );
23280
23764
 
23281
23765
  state.bindFramebuffer( 36008, renderTargetProperties.__webglMultisampledFramebuffer );
23282
23766
  state.bindFramebuffer( 36009, renderTargetProperties.__webglFramebuffer );
23283
23767
 
23768
+ if ( renderTarget.ignoreDepthForMultisampleCopy ) {
23769
+
23770
+ _gl.invalidateFramebuffer( 36008, [ depthStyle ] );
23771
+ _gl.invalidateFramebuffer( 36009, [ depthStyle ] );
23772
+
23773
+ }
23774
+
23284
23775
  _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, 9728 );
23776
+ _gl.invalidateFramebuffer( 36008, invalidationArray );
23285
23777
 
23286
23778
  state.bindFramebuffer( 36008, null );
23287
23779
  state.bindFramebuffer( 36009, renderTargetProperties.__webglMultisampledFramebuffer );
@@ -23298,7 +23790,7 @@
23298
23790
 
23299
23791
  function getRenderTargetSamples( renderTarget ) {
23300
23792
 
23301
- return ( isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?
23793
+ return ( isWebGL2 && ( renderTarget.useRenderbuffer || renderTarget.useRenderToTexture ) ) ?
23302
23794
  Math.min( maxSamples, renderTarget.samples ) : 0;
23303
23795
 
23304
23796
  }
@@ -23371,9 +23863,12 @@
23371
23863
  this.setTexture2DArray = setTexture2DArray;
23372
23864
  this.setTexture3D = setTexture3D;
23373
23865
  this.setTextureCube = setTextureCube;
23866
+ this.rebindTextures = rebindTextures;
23374
23867
  this.setupRenderTarget = setupRenderTarget;
23375
23868
  this.updateRenderTargetMipmap = updateRenderTargetMipmap;
23376
23869
  this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
23870
+ this.setupDepthRenderbuffer = setupDepthRenderbuffer;
23871
+ this.setupFrameBufferTexture = setupFrameBufferTexture;
23377
23872
 
23378
23873
  this.safeSetTexture2D = safeSetTexture2D;
23379
23874
  this.safeSetTextureCube = safeSetTextureCube;
@@ -23895,6 +24390,38 @@
23895
24390
 
23896
24391
  }
23897
24392
 
24393
+ class DepthTexture extends Texture {
24394
+
24395
+ constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
24396
+
24397
+ format = format !== undefined ? format : DepthFormat;
24398
+
24399
+ if ( format !== DepthFormat && format !== DepthStencilFormat ) {
24400
+
24401
+ throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
24402
+
24403
+ }
24404
+
24405
+ if ( type === undefined && format === DepthFormat ) type = UnsignedShortType;
24406
+ if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
24407
+
24408
+ super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
24409
+
24410
+ this.image = { width: width, height: height };
24411
+
24412
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
24413
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
24414
+
24415
+ this.flipY = false;
24416
+ this.generateMipmaps = false;
24417
+
24418
+ }
24419
+
24420
+
24421
+ }
24422
+
24423
+ DepthTexture.prototype.isDepthTexture = true;
24424
+
23898
24425
  class WebXRManager extends EventDispatcher {
23899
24426
 
23900
24427
  constructor( renderer, gl ) {
@@ -23902,26 +24429,23 @@
23902
24429
  super();
23903
24430
 
23904
24431
  const scope = this;
23905
- const state = renderer.state;
23906
24432
 
23907
24433
  let session = null;
23908
24434
  let framebufferScaleFactor = 1.0;
23909
24435
 
23910
24436
  let referenceSpace = null;
23911
24437
  let referenceSpaceType = 'local-floor';
24438
+ const hasMultisampledRenderToTexture = renderer.extensions.has( 'WEBGL_multisampled_render_to_texture' );
23912
24439
 
23913
24440
  let pose = null;
23914
24441
  let glBinding = null;
23915
- let glFramebuffer = null;
23916
24442
  let glProjLayer = null;
23917
24443
  let glBaseLayer = null;
23918
24444
  let isMultisample = false;
23919
- let glMultisampledFramebuffer = null;
23920
- let glColorRenderbuffer = null;
23921
- let glDepthRenderbuffer = null;
23922
24445
  let xrFrame = null;
23923
- let depthStyle = null;
23924
- let clearStyle = null;
24446
+ const attributes = gl.getContextAttributes();
24447
+ let initialRenderTarget = null;
24448
+ let newRenderTarget = null;
23925
24449
 
23926
24450
  const controllers = [];
23927
24451
  const inputSourcesMap = new Map();
@@ -24026,21 +24550,13 @@
24026
24550
 
24027
24551
  // restore framebuffer/rendering state
24028
24552
 
24029
- state.bindXRFramebuffer( null );
24030
- renderer.setRenderTarget( renderer.getRenderTarget() );
24031
-
24032
- if ( glFramebuffer ) gl.deleteFramebuffer( glFramebuffer );
24033
- if ( glMultisampledFramebuffer ) gl.deleteFramebuffer( glMultisampledFramebuffer );
24034
- if ( glColorRenderbuffer ) gl.deleteRenderbuffer( glColorRenderbuffer );
24035
- if ( glDepthRenderbuffer ) gl.deleteRenderbuffer( glDepthRenderbuffer );
24036
- glFramebuffer = null;
24037
- glMultisampledFramebuffer = null;
24038
- glColorRenderbuffer = null;
24039
- glDepthRenderbuffer = null;
24553
+ renderer.setRenderTarget( initialRenderTarget );
24554
+
24040
24555
  glBaseLayer = null;
24041
24556
  glProjLayer = null;
24042
24557
  glBinding = null;
24043
24558
  session = null;
24559
+ newRenderTarget = null;
24044
24560
 
24045
24561
  //
24046
24562
 
@@ -24112,6 +24628,8 @@
24112
24628
 
24113
24629
  if ( session !== null ) {
24114
24630
 
24631
+ initialRenderTarget = renderer.getRenderTarget();
24632
+
24115
24633
  session.addEventListener( 'select', onSessionEvent );
24116
24634
  session.addEventListener( 'selectstart', onSessionEvent );
24117
24635
  session.addEventListener( 'selectend', onSessionEvent );
@@ -24121,18 +24639,16 @@
24121
24639
  session.addEventListener( 'end', onSessionEnd );
24122
24640
  session.addEventListener( 'inputsourceschange', onInputSourcesChange );
24123
24641
 
24124
- const attributes = gl.getContextAttributes();
24125
-
24126
24642
  if ( attributes.xrCompatible !== true ) {
24127
24643
 
24128
24644
  await gl.makeXRCompatible();
24129
24645
 
24130
24646
  }
24131
24647
 
24132
- if ( session.renderState.layers === undefined ) {
24648
+ if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) {
24133
24649
 
24134
24650
  const layerInit = {
24135
- antialias: attributes.antialias,
24651
+ antialias: ( session.renderState.layers === undefined ) ? attributes.antialias : true,
24136
24652
  alpha: attributes.alpha,
24137
24653
  depth: attributes.depth,
24138
24654
  stencil: attributes.stencil,
@@ -24143,43 +24659,34 @@
24143
24659
 
24144
24660
  session.updateRenderState( { baseLayer: glBaseLayer } );
24145
24661
 
24146
- } else if ( gl instanceof WebGLRenderingContext ) {
24147
-
24148
- // Use old style webgl layer because we can't use MSAA
24149
- // WebGL2 support.
24150
-
24151
- const layerInit = {
24152
- antialias: true,
24153
- alpha: attributes.alpha,
24154
- depth: attributes.depth,
24155
- stencil: attributes.stencil,
24156
- framebufferScaleFactor: framebufferScaleFactor
24157
- };
24158
-
24159
- glBaseLayer = new XRWebGLLayer( session, gl, layerInit );
24160
-
24161
- session.updateRenderState( { layers: [ glBaseLayer ] } );
24662
+ newRenderTarget = new WebGLRenderTarget(
24663
+ glBaseLayer.framebufferWidth,
24664
+ glBaseLayer.framebufferHeight,
24665
+ {
24666
+ format: RGBAFormat,
24667
+ type: UnsignedByteType,
24668
+ encoding: renderer.outputEncoding
24669
+ }
24670
+ );
24162
24671
 
24163
24672
  } else {
24164
24673
 
24165
24674
  isMultisample = attributes.antialias;
24166
24675
  let depthFormat = null;
24167
-
24676
+ let depthType = null;
24677
+ let glDepthFormat = null;
24168
24678
 
24169
24679
  if ( attributes.depth ) {
24170
24680
 
24171
- clearStyle = 256;
24172
-
24173
- if ( attributes.stencil ) clearStyle |= 1024;
24174
-
24175
- depthStyle = attributes.stencil ? 33306 : 36096;
24176
- depthFormat = attributes.stencil ? 35056 : 33190;
24681
+ glDepthFormat = attributes.stencil ? 35056 : 33190;
24682
+ depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat;
24683
+ depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType;
24177
24684
 
24178
24685
  }
24179
24686
 
24180
24687
  const projectionlayerInit = {
24181
- colorFormat: attributes.alpha ? 32856 : 32849,
24182
- depthFormat: depthFormat,
24688
+ colorFormat: ( attributes.alpha || isMultisample ) ? 32856 : 32849,
24689
+ depthFormat: glDepthFormat,
24183
24690
  scaleFactor: framebufferScaleFactor
24184
24691
  };
24185
24692
 
@@ -24187,41 +24694,44 @@
24187
24694
 
24188
24695
  glProjLayer = glBinding.createProjectionLayer( projectionlayerInit );
24189
24696
 
24190
- glFramebuffer = gl.createFramebuffer();
24191
-
24192
24697
  session.updateRenderState( { layers: [ glProjLayer ] } );
24193
24698
 
24194
24699
  if ( isMultisample ) {
24195
24700
 
24196
- glMultisampledFramebuffer = gl.createFramebuffer();
24197
- glColorRenderbuffer = gl.createRenderbuffer();
24198
- gl.bindRenderbuffer( 36161, glColorRenderbuffer );
24199
- gl.renderbufferStorageMultisample(
24200
- 36161,
24201
- 4,
24202
- 32856,
24701
+ newRenderTarget = new WebGLMultisampleRenderTarget(
24203
24702
  glProjLayer.textureWidth,
24204
- glProjLayer.textureHeight );
24205
- state.bindFramebuffer( 36160, glMultisampledFramebuffer );
24206
- gl.framebufferRenderbuffer( 36160, 36064, 36161, glColorRenderbuffer );
24207
- gl.bindRenderbuffer( 36161, null );
24208
-
24209
- if ( depthFormat !== null ) {
24210
-
24211
- glDepthRenderbuffer = gl.createRenderbuffer();
24212
- gl.bindRenderbuffer( 36161, glDepthRenderbuffer );
24213
- gl.renderbufferStorageMultisample( 36161, 4, depthFormat, glProjLayer.textureWidth, glProjLayer.textureHeight );
24214
- gl.framebufferRenderbuffer( 36160, depthStyle, 36161, glDepthRenderbuffer );
24215
- gl.bindRenderbuffer( 36161, null );
24703
+ glProjLayer.textureHeight,
24704
+ {
24705
+ format: RGBAFormat,
24706
+ type: UnsignedByteType,
24707
+ depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
24708
+ stencilBuffer: attributes.stencil,
24709
+ ignoreDepth: glProjLayer.ignoreDepthValues,
24710
+ useRenderToTexture: hasMultisampledRenderToTexture,
24711
+ encoding: renderer.outputEncoding
24712
+ } );
24216
24713
 
24217
- }
24714
+ } else {
24218
24715
 
24219
- state.bindFramebuffer( 36160, null );
24716
+ newRenderTarget = new WebGLRenderTarget(
24717
+ glProjLayer.textureWidth,
24718
+ glProjLayer.textureHeight,
24719
+ {
24720
+ format: attributes.alpha ? RGBAFormat : RGBFormat,
24721
+ type: UnsignedByteType,
24722
+ depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
24723
+ stencilBuffer: attributes.stencil,
24724
+ ignoreDepth: glProjLayer.ignoreDepthValues,
24725
+ encoding: renderer.outputEncoding
24726
+ } );
24220
24727
 
24221
24728
  }
24222
24729
 
24223
24730
  }
24224
24731
 
24732
+ // Set foveation to maximum.
24733
+ this.setFoveation( 1.0 );
24734
+
24225
24735
  referenceSpace = await session.requestReferenceSpace( referenceSpaceType );
24226
24736
 
24227
24737
  animation.setContext( session );
@@ -24480,7 +24990,8 @@
24480
24990
 
24481
24991
  if ( glBaseLayer !== null ) {
24482
24992
 
24483
- state.bindXRFramebuffer( glBaseLayer.framebuffer );
24993
+ renderer.setRenderTargetFramebuffer( newRenderTarget, glBaseLayer.framebuffer );
24994
+ renderer.setRenderTarget( newRenderTarget );
24484
24995
 
24485
24996
  }
24486
24997
 
@@ -24491,7 +25002,6 @@
24491
25002
  if ( views.length !== cameraVR.cameras.length ) {
24492
25003
 
24493
25004
  cameraVR.cameras.length = 0;
24494
-
24495
25005
  cameraVRNeedsUpdate = true;
24496
25006
 
24497
25007
  }
@@ -24509,19 +25019,20 @@
24509
25019
  } else {
24510
25020
 
24511
25021
  const glSubImage = glBinding.getViewSubImage( glProjLayer, view );
25022
+ viewport = glSubImage.viewport;
24512
25023
 
24513
- state.bindXRFramebuffer( glFramebuffer );
25024
+ // For side-by-side projection, we only produce a single texture for both eyes.
25025
+ if ( i === 0 ) {
24514
25026
 
24515
- if ( glSubImage.depthStencilTexture !== undefined ) {
25027
+ renderer.setRenderTargetTextures(
25028
+ newRenderTarget,
25029
+ glSubImage.colorTexture,
25030
+ glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture );
24516
25031
 
24517
- gl.framebufferTexture2D( 36160, depthStyle, 3553, glSubImage.depthStencilTexture, 0 );
25032
+ renderer.setRenderTarget( newRenderTarget );
24518
25033
 
24519
25034
  }
24520
25035
 
24521
- gl.framebufferTexture2D( 36160, 36064, 3553, glSubImage.colorTexture, 0 );
24522
-
24523
- viewport = glSubImage.viewport;
24524
-
24525
25036
  }
24526
25037
 
24527
25038
  const camera = cameras[ i ];
@@ -24544,14 +25055,6 @@
24544
25055
 
24545
25056
  }
24546
25057
 
24547
- if ( isMultisample ) {
24548
-
24549
- state.bindXRFramebuffer( glMultisampledFramebuffer );
24550
-
24551
- if ( clearStyle !== null ) gl.clear( clearStyle );
24552
-
24553
- }
24554
-
24555
25058
  }
24556
25059
 
24557
25060
  //
@@ -24569,26 +25072,6 @@
24569
25072
 
24570
25073
  if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );
24571
25074
 
24572
- if ( isMultisample ) {
24573
-
24574
- const width = glProjLayer.textureWidth;
24575
- const height = glProjLayer.textureHeight;
24576
-
24577
- state.bindFramebuffer( 36008, glMultisampledFramebuffer );
24578
- state.bindFramebuffer( 36009, glFramebuffer );
24579
- // Invalidate the depth here to avoid flush of the depth data to main memory.
24580
- gl.invalidateFramebuffer( 36008, [ depthStyle ] );
24581
- gl.invalidateFramebuffer( 36009, [ depthStyle ] );
24582
- gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, 16384, 9728 );
24583
- // Invalidate the MSAA buffer because it's not needed anymore.
24584
- gl.invalidateFramebuffer( 36008, [ 36064 ] );
24585
- state.bindFramebuffer( 36008, null );
24586
- state.bindFramebuffer( 36009, null );
24587
-
24588
- state.bindFramebuffer( 36160, glMultisampledFramebuffer );
24589
-
24590
- }
24591
-
24592
25075
  xrFrame = null;
24593
25076
 
24594
25077
  }
@@ -24766,14 +25249,6 @@
24766
25249
  uniforms.ior.value = material.ior;
24767
25250
  uniforms.refractionRatio.value = material.refractionRatio;
24768
25251
 
24769
- const maxMipLevel = properties.get( envMap ).__maxMipLevel;
24770
-
24771
- if ( maxMipLevel !== undefined ) {
24772
-
24773
- uniforms.maxMipLevel.value = maxMipLevel;
24774
-
24775
- }
24776
-
24777
25252
  }
24778
25253
 
24779
25254
  if ( material.lightMap ) {
@@ -25469,7 +25944,6 @@
25469
25944
 
25470
25945
  // physically based shading
25471
25946
 
25472
- this.gammaFactor = 2.0; // for backwards compatibility
25473
25947
  this.outputEncoding = LinearEncoding;
25474
25948
 
25475
25949
  // physical lights
@@ -25575,8 +26049,10 @@
25575
26049
  failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat
25576
26050
  };
25577
26051
 
25578
- // event listeners must be registered before WebGL context is created, see #12753
26052
+ // OffscreenCanvas does not have setAttribute, see #22811
26053
+ if ( 'setAttribute' in _canvas ) _canvas.setAttribute( 'data-engine', `three.js r${REVISION}` );
25579
26054
 
26055
+ // event listeners must be registered before WebGL context is created, see #12753
25580
26056
  _canvas.addEventListener( 'webglcontextlost', onContextLost, false );
25581
26057
  _canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
25582
26058
 
@@ -25662,7 +26138,7 @@
25662
26138
  clipping = new WebGLClipping( properties );
25663
26139
  programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
25664
26140
  materials = new WebGLMaterials( properties );
25665
- renderLists = new WebGLRenderLists( properties );
26141
+ renderLists = new WebGLRenderLists();
25666
26142
  renderStates = new WebGLRenderStates( extensions, capabilities );
25667
26143
  background = new WebGLBackground( _this, cubemaps, state, objects, _premultipliedAlpha );
25668
26144
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
@@ -25930,6 +26406,7 @@
25930
26406
  cubeuvmaps.dispose();
25931
26407
  objects.dispose();
25932
26408
  bindingStates.dispose();
26409
+ programCache.dispose();
25933
26410
 
25934
26411
  xr.dispose();
25935
26412
 
@@ -26014,6 +26491,12 @@
26014
26491
 
26015
26492
  } );
26016
26493
 
26494
+ if ( material.isShaderMaterial ) {
26495
+
26496
+ programCache.releaseShaderCache( material );
26497
+
26498
+ }
26499
+
26017
26500
  }
26018
26501
 
26019
26502
  }
@@ -26552,7 +27035,8 @@
26552
27035
  minFilter: LinearMipmapLinearFilter,
26553
27036
  magFilter: NearestFilter,
26554
27037
  wrapS: ClampToEdgeWrapping,
26555
- wrapT: ClampToEdgeWrapping
27038
+ wrapT: ClampToEdgeWrapping,
27039
+ useRenderToTexture: extensions.has( 'WEBGL_multisampled_render_to_texture' )
26556
27040
  } );
26557
27041
 
26558
27042
  }
@@ -26759,6 +27243,7 @@
26759
27243
  materialProperties.numIntersection = parameters.numClipIntersection;
26760
27244
  materialProperties.vertexAlphas = parameters.vertexAlphas;
26761
27245
  materialProperties.vertexTangents = parameters.vertexTangents;
27246
+ materialProperties.toneMapping = parameters.toneMapping;
26762
27247
 
26763
27248
  }
26764
27249
 
@@ -26777,6 +27262,7 @@
26777
27262
  const morphTargets = !! geometry.morphAttributes.position;
26778
27263
  const morphNormals = !! geometry.morphAttributes.normal;
26779
27264
  const morphTargetsCount = !! geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
27265
+ const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
26780
27266
 
26781
27267
  const materialProperties = properties.get( material );
26782
27268
  const lights = currentRenderState.state.lights;
@@ -26858,6 +27344,10 @@
26858
27344
 
26859
27345
  needsProgramChange = true;
26860
27346
 
27347
+ } else if ( materialProperties.toneMapping !== toneMapping ) {
27348
+
27349
+ needsProgramChange = true;
27350
+
26861
27351
  } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
26862
27352
 
26863
27353
  needsProgramChange = true;
@@ -27118,15 +27608,71 @@
27118
27608
 
27119
27609
  };
27120
27610
 
27611
+ this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
27612
+
27613
+ properties.get( renderTarget.texture ).__webglTexture = colorTexture;
27614
+ properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture;
27615
+
27616
+ const renderTargetProperties = properties.get( renderTarget );
27617
+ renderTargetProperties.__hasExternalTextures = true;
27618
+
27619
+ if ( renderTargetProperties.__hasExternalTextures ) {
27620
+
27621
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
27622
+
27623
+ if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
27624
+
27625
+ // The multisample_render_to_texture extension doesn't work properly if there
27626
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
27627
+ if ( renderTarget.useRenderToTexture ) {
27628
+
27629
+ console.warn( 'render-to-texture extension was disabled because an external texture was provided' );
27630
+ renderTarget.useRenderToTexture = false;
27631
+ renderTarget.useRenderbuffer = true;
27632
+
27633
+ }
27634
+
27635
+ }
27636
+
27637
+ }
27638
+
27639
+ };
27640
+
27641
+ this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) {
27642
+
27643
+ const renderTargetProperties = properties.get( renderTarget );
27644
+ renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
27645
+ renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
27646
+
27647
+ };
27648
+
27121
27649
  this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
27122
27650
 
27123
27651
  _currentRenderTarget = renderTarget;
27124
27652
  _currentActiveCubeFace = activeCubeFace;
27125
27653
  _currentActiveMipmapLevel = activeMipmapLevel;
27654
+ let useDefaultFramebuffer = true;
27655
+
27656
+ if ( renderTarget ) {
27657
+
27658
+ const renderTargetProperties = properties.get( renderTarget );
27659
+
27660
+ if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
27126
27661
 
27127
- if ( renderTarget && properties.get( renderTarget ).__webglFramebuffer === undefined ) {
27662
+ // We need to make sure to rebind the framebuffer.
27663
+ state.bindFramebuffer( 36160, null );
27664
+ useDefaultFramebuffer = false;
27128
27665
 
27129
- textures.setupRenderTarget( renderTarget );
27666
+ } else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
27667
+
27668
+ textures.setupRenderTarget( renderTarget );
27669
+
27670
+ } else if ( renderTargetProperties.__hasExternalTextures ) {
27671
+
27672
+ // Color and depth texture must be rebound in order for the swapchain to update.
27673
+ textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
27674
+
27675
+ }
27130
27676
 
27131
27677
  }
27132
27678
 
@@ -27151,7 +27697,7 @@
27151
27697
  framebuffer = __webglFramebuffer[ activeCubeFace ];
27152
27698
  isCube = true;
27153
27699
 
27154
- } else if ( renderTarget.isWebGLMultisampleRenderTarget ) {
27700
+ } else if ( renderTarget.useRenderbuffer ) {
27155
27701
 
27156
27702
  framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
27157
27703
 
@@ -27175,7 +27721,7 @@
27175
27721
 
27176
27722
  const framebufferBound = state.bindFramebuffer( 36160, framebuffer );
27177
27723
 
27178
- if ( framebufferBound && capabilities.drawBuffers ) {
27724
+ if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
27179
27725
 
27180
27726
  let needsUpdate = false;
27181
27727
 
@@ -27338,25 +27884,20 @@
27338
27884
 
27339
27885
  this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
27340
27886
 
27341
- const levelScale = Math.pow( 2, - level );
27342
- const width = Math.floor( texture.image.width * levelScale );
27343
- const height = Math.floor( texture.image.height * levelScale );
27344
-
27345
- let glFormat = utils.convert( texture.format );
27346
-
27347
- if ( capabilities.isWebGL2 ) {
27348
-
27349
- // Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=1120100
27350
- // Not needed in Chrome 93+
27887
+ if ( texture.isFramebufferTexture !== true ) {
27351
27888
 
27352
- if ( glFormat === 6407 ) glFormat = 32849;
27353
- if ( glFormat === 6408 ) glFormat = 32856;
27889
+ console.error( 'THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.' );
27890
+ return;
27354
27891
 
27355
27892
  }
27356
27893
 
27894
+ const levelScale = Math.pow( 2, - level );
27895
+ const width = Math.floor( texture.image.width * levelScale );
27896
+ const height = Math.floor( texture.image.height * levelScale );
27897
+
27357
27898
  textures.setTexture2D( texture, 0 );
27358
27899
 
27359
- _gl.copyTexImage2D( 3553, level, glFormat, position.x, position.y, width, height, 0 );
27900
+ _gl.copyTexSubImage2D( 3553, level, 0, 0, position.x, position.y, width, height );
27360
27901
 
27361
27902
  state.unbindTexture();
27362
27903
 
@@ -27506,7 +28047,7 @@
27506
28047
 
27507
28048
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
27508
28049
 
27509
- __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef
28050
+ __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
27510
28051
 
27511
28052
  }
27512
28053
 
@@ -27536,7 +28077,7 @@
27536
28077
 
27537
28078
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
27538
28079
 
27539
- __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef
28080
+ __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
27540
28081
 
27541
28082
  }
27542
28083
 
@@ -28400,8 +28941,6 @@
28400
28941
  this.flipY = false;
28401
28942
  this.unpackAlignment = 1;
28402
28943
 
28403
- this.needsUpdate = true;
28404
-
28405
28944
  }
28406
28945
 
28407
28946
  }
@@ -29224,6 +29763,27 @@
29224
29763
 
29225
29764
  VideoTexture.prototype.isVideoTexture = true;
29226
29765
 
29766
+ class FramebufferTexture extends Texture {
29767
+
29768
+ constructor( width, height, format ) {
29769
+
29770
+ super( { width, height } );
29771
+
29772
+ this.format = format;
29773
+
29774
+ this.magFilter = NearestFilter;
29775
+ this.minFilter = NearestFilter;
29776
+
29777
+ this.generateMipmaps = false;
29778
+
29779
+ this.needsUpdate = true;
29780
+
29781
+ }
29782
+
29783
+ }
29784
+
29785
+ FramebufferTexture.prototype.isFramebufferTexture = true;
29786
+
29227
29787
  class CompressedTexture extends Texture {
29228
29788
 
29229
29789
  constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
@@ -29263,38 +29823,6 @@
29263
29823
 
29264
29824
  CanvasTexture.prototype.isCanvasTexture = true;
29265
29825
 
29266
- class DepthTexture extends Texture {
29267
-
29268
- constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
29269
-
29270
- format = format !== undefined ? format : DepthFormat;
29271
-
29272
- if ( format !== DepthFormat && format !== DepthStencilFormat ) {
29273
-
29274
- throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
29275
-
29276
- }
29277
-
29278
- if ( type === undefined && format === DepthFormat ) type = UnsignedShortType;
29279
- if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
29280
-
29281
- super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
29282
-
29283
- this.image = { width: width, height: height };
29284
-
29285
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
29286
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
29287
-
29288
- this.flipY = false;
29289
- this.generateMipmaps = false;
29290
-
29291
- }
29292
-
29293
-
29294
- }
29295
-
29296
- DepthTexture.prototype.isDepthTexture = true;
29297
-
29298
29826
  class CircleGeometry extends BufferGeometry {
29299
29827
 
29300
29828
  constructor( radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2 ) {
@@ -30478,7 +31006,7 @@
30478
31006
 
30479
31007
  /**
30480
31008
  * Bezier Curves formulas obtained from
30481
- * http://en.wikipedia.org/wiki/Bézier_curve
31009
+ * https://en.wikipedia.org/wiki/B%C3%A9zier_curve
30482
31010
  */
30483
31011
 
30484
31012
  function CatmullRom( t, p0, p1, p2, p3 ) {
@@ -34197,7 +34725,7 @@
34197
34725
 
34198
34726
  this.transmissionMap = null;
34199
34727
 
34200
- this.thickness = 0.01;
34728
+ this.thickness = 0;
34201
34729
  this.thicknessMap = null;
34202
34730
  this.attenuationDistance = 0.0;
34203
34731
  this.attenuationColor = new Color$2( 1, 1, 1 );
@@ -37071,6 +37599,12 @@
37071
37599
 
37072
37600
  }
37073
37601
 
37602
+ if ( typeof ReadableStream === 'undefined' || response.body.getReader === undefined ) {
37603
+
37604
+ return response;
37605
+
37606
+ }
37607
+
37074
37608
  const callbacks = loading[ url ];
37075
37609
  const reader = response.body.getReader();
37076
37610
  const contentLength = response.headers.get( 'Content-Length' );
@@ -37079,7 +37613,7 @@
37079
37613
  let loaded = 0;
37080
37614
 
37081
37615
  // periodically read data into the new stream tracking while download progress
37082
- return new ReadableStream( {
37616
+ const stream = new ReadableStream( {
37083
37617
  start( controller ) {
37084
37618
 
37085
37619
  readData();
@@ -37117,6 +37651,8 @@
37117
37651
 
37118
37652
  } );
37119
37653
 
37654
+ return new Response( stream );
37655
+
37120
37656
  } else {
37121
37657
 
37122
37658
  throw Error( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}` );
@@ -37124,9 +37660,7 @@
37124
37660
  }
37125
37661
 
37126
37662
  } )
37127
- .then( stream => {
37128
-
37129
- const response = new Response( stream );
37663
+ .then( response => {
37130
37664
 
37131
37665
  switch ( this.responseType ) {
37132
37666
 
@@ -37175,14 +37709,21 @@
37175
37709
 
37176
37710
  }
37177
37711
 
37178
- this.manager.itemEnd( url );
37179
-
37180
37712
  } )
37181
37713
  .catch( err => {
37182
37714
 
37183
37715
  // Abort errors and other errors are handled the same
37184
37716
 
37185
37717
  const callbacks = loading[ url ];
37718
+
37719
+ if ( callbacks === undefined ) {
37720
+
37721
+ // When onLoad was called and url was deleted in `loading`
37722
+ this.manager.itemError( url );
37723
+ throw err;
37724
+
37725
+ }
37726
+
37186
37727
  delete loading[ url ];
37187
37728
 
37188
37729
  for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
@@ -37193,6 +37734,10 @@
37193
37734
  }
37194
37735
 
37195
37736
  this.manager.itemError( url );
37737
+
37738
+ } )
37739
+ .finally( () => {
37740
+
37196
37741
  this.manager.itemEnd( url );
37197
37742
 
37198
37743
  } );
@@ -43596,7 +44141,19 @@
43596
44141
 
43597
44142
  }
43598
44143
  },
44144
+ gammaFactor: {
44145
+ get: function () {
44146
+
44147
+ console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' );
44148
+ return 2;
43599
44149
 
44150
+ },
44151
+ set: function () {
44152
+
44153
+ console.warn( 'THREE.WebGLRenderer: .gammaFactor has been removed.' );
44154
+
44155
+ }
44156
+ }
43600
44157
  } );
43601
44158
 
43602
44159
  Object.defineProperties( WebGLShadowMap.prototype, {
@@ -43868,11 +44425,9 @@
43868
44425
 
43869
44426
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
43870
44427
 
43871
- /* eslint-disable no-undef */
43872
44428
  __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {
43873
44429
  revision: REVISION,
43874
44430
  } } ) );
43875
- /* eslint-enable no-undef */
43876
44431
 
43877
44432
  }
43878
44433
 
@@ -43975,7 +44530,7 @@
43975
44530
  }
43976
44531
 
43977
44532
  function _iterableToArrayLimit$6(arr, i) {
43978
- var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
44533
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
43979
44534
 
43980
44535
  if (_i == null) return;
43981
44536
  var _arr = [];
@@ -46625,6 +47180,8 @@
46625
47180
  function _possibleConstructorReturn$2(self, call) {
46626
47181
  if (call && (typeof call === "object" || typeof call === "function")) {
46627
47182
  return call;
47183
+ } else if (call !== void 0) {
47184
+ throw new TypeError("Derived constructors may only return object or undefined");
46628
47185
  }
46629
47186
 
46630
47187
  return _assertThisInitialized$3(self);
@@ -46930,8 +47487,8 @@
46930
47487
  holes = _earcut$flatten2.holes;
46931
47488
 
46932
47489
  var firstHoleIdx = holes[0] || Infinity;
46933
- var outerVertices = vertices.slice(0, firstHoleIdx);
46934
- var holeVertices = vertices.slice(firstHoleIdx);
47490
+ var outerVertices = vertices.slice(0, firstHoleIdx * 3);
47491
+ var holeVertices = vertices.slice(firstHoleIdx * 3);
46935
47492
  var holesIdx = new Set(holes);
46936
47493
  var numPoints = Math.round(vertices.length / 3);
46937
47494
  var outerIndices = [],
@@ -72059,8 +72616,8 @@
72059
72616
  : {
72060
72617
  DoubleSide: DoubleSide,
72061
72618
  Group: Group$1,
72062
- Line: Line,
72063
72619
  LineBasicMaterial: LineBasicMaterial,
72620
+ LineSegments: LineSegments,
72064
72621
  Mesh: Mesh,
72065
72622
  MeshBasicMaterial: MeshBasicMaterial
72066
72623
  };
@@ -72168,7 +72725,7 @@
72168
72725
  obj.__defaultCapMaterial // cap material
72169
72726
  ])); // polygon stroke
72170
72727
 
72171
- obj.add(new THREE$8.Line(undefined, new THREE$8.LineBasicMaterial()));
72728
+ obj.add(new THREE$8.LineSegments(undefined, new THREE$8.LineBasicMaterial()));
72172
72729
  obj.__globeObjType = 'polygon'; // Add object type
72173
72730
 
72174
72731
  return obj;
@@ -75324,30 +75881,20 @@
75324
75881
 
75325
75882
  function onPointerUp( event ) {
75326
75883
 
75327
- if ( scope.enabled === false ) return;
75884
+ removePointer( event );
75328
75885
 
75329
- if ( event.pointerType === 'touch' ) {
75886
+ if ( pointers.length === 0 ) {
75330
75887
 
75331
- onTouchEnd();
75888
+ scope.domElement.releasePointerCapture( event.pointerId );
75332
75889
 
75333
- } else {
75890
+ scope.domElement.removeEventListener( 'pointermove', onPointerMove );
75891
+ scope.domElement.removeEventListener( 'pointerup', onPointerUp );
75334
75892
 
75335
- onMouseUp();
75893
+ }
75336
75894
 
75337
- }
75338
-
75339
- removePointer( event );
75340
-
75341
- //
75342
-
75343
- if ( pointers.length === 0 ) {
75344
-
75345
- scope.domElement.releasePointerCapture( event.pointerId );
75346
-
75347
- scope.domElement.removeEventListener( 'pointermove', onPointerMove );
75348
- scope.domElement.removeEventListener( 'pointerup', onPointerUp );
75895
+ scope.dispatchEvent( _endEvent );
75349
75896
 
75350
- }
75897
+ state = STATE.NONE;
75351
75898
 
75352
75899
  }
75353
75900
 
@@ -75488,14 +76035,6 @@
75488
76035
 
75489
76036
  }
75490
76037
 
75491
- function onMouseUp( event ) {
75492
-
75493
- scope.dispatchEvent( _endEvent );
75494
-
75495
- state = STATE.NONE;
75496
-
75497
- }
75498
-
75499
76038
  function onMouseWheel( event ) {
75500
76039
 
75501
76040
  if ( scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE ) return;
@@ -75656,14 +76195,6 @@
75656
76195
 
75657
76196
  }
75658
76197
 
75659
- function onTouchEnd( event ) {
75660
-
75661
- scope.dispatchEvent( _endEvent );
75662
-
75663
- state = STATE.NONE;
75664
-
75665
- }
75666
-
75667
76198
  function onContextMenu( event ) {
75668
76199
 
75669
76200
  if ( scope.enabled === false ) return;
@@ -78054,14 +78585,9 @@
78054
78585
 
78055
78586
  if (Object.getOwnPropertySymbols) {
78056
78587
  var symbols = Object.getOwnPropertySymbols(object);
78057
-
78058
- if (enumerableOnly) {
78059
- symbols = symbols.filter(function (sym) {
78060
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
78061
- });
78062
- }
78063
-
78064
- keys.push.apply(keys, symbols);
78588
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
78589
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
78590
+ })), keys.push.apply(keys, symbols);
78065
78591
  }
78066
78592
 
78067
78593
  return keys;
@@ -78069,19 +78595,12 @@
78069
78595
 
78070
78596
  function _objectSpread2(target) {
78071
78597
  for (var i = 1; i < arguments.length; i++) {
78072
- var source = arguments[i] != null ? arguments[i] : {};
78073
-
78074
- if (i % 2) {
78075
- ownKeys(Object(source), true).forEach(function (key) {
78076
- _defineProperty(target, key, source[key]);
78077
- });
78078
- } else if (Object.getOwnPropertyDescriptors) {
78079
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
78080
- } else {
78081
- ownKeys(Object(source)).forEach(function (key) {
78082
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78083
- });
78084
- }
78598
+ var source = null != arguments[i] ? arguments[i] : {};
78599
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
78600
+ _defineProperty(target, key, source[key]);
78601
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
78602
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78603
+ });
78085
78604
  }
78086
78605
 
78087
78606
  return target;
@@ -78686,10 +79205,9 @@
78686
79205
  var objType = globeObj.__globeObjType;
78687
79206
 
78688
79207
  if (globeObj && objFns.hasOwnProperty(objType) && objFns[objType]) {
78689
- var args = [ev];
79208
+ var args = [ev]; // include click coords
78690
79209
 
78691
79210
  if (objType === 'globe') {
78692
- // include click coords in { lat, lng }
78693
79211
  var _this$toGeoCoords = _this.toGeoCoords(point),
78694
79212
  lat = _this$toGeoCoords.lat,
78695
79213
  lng = _this$toGeoCoords.lng;
@@ -78698,6 +79216,8 @@
78698
79216
  lat: lat,
78699
79217
  lng: lng
78700
79218
  });
79219
+ } else {
79220
+ args.push(_this.toGeoCoords(point));
78701
79221
  }
78702
79222
 
78703
79223
  dataAccessors.hasOwnProperty(objType) && args.unshift(dataAccessors[objType](globeObj.__data));
@@ -78723,10 +79243,9 @@
78723
79243
  var objType = globeObj.__globeObjType;
78724
79244
 
78725
79245
  if (globeObj && objFns.hasOwnProperty(objType) && objFns[objType]) {
78726
- var args = [ev];
79246
+ var args = [ev]; // include click coords
78727
79247
 
78728
79248
  if (objType === 'globe') {
78729
- // include click coords in { lat, lng }
78730
79249
  var _this$toGeoCoords2 = _this.toGeoCoords(point),
78731
79250
  lat = _this$toGeoCoords2.lat,
78732
79251
  lng = _this$toGeoCoords2.lng;
@@ -78735,6 +79254,8 @@
78735
79254
  lat: lat,
78736
79255
  lng: lng
78737
79256
  });
79257
+ } else {
79258
+ args.push(_this.toGeoCoords(point));
78738
79259
  }
78739
79260
 
78740
79261
  dataAccessors.hasOwnProperty(objType) && args.unshift(dataAccessors[objType](globeObj.__data));
@@ -79036,6 +79557,8 @@
79036
79557
 
79037
79558
  var ReactPropTypesSecret_1 = ReactPropTypesSecret$2;
79038
79559
 
79560
+ var has$2 = Function.call.bind(Object.prototype.hasOwnProperty);
79561
+
79039
79562
  /**
79040
79563
  * Copyright (c) 2013-present, Facebook, Inc.
79041
79564
  *
@@ -79048,7 +79571,7 @@
79048
79571
  {
79049
79572
  var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
79050
79573
  var loggedTypeFailures = {};
79051
- var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
79574
+ var has$1 = has$2;
79052
79575
 
79053
79576
  printWarning$1 = function(text) {
79054
79577
  var message = 'Warning: ' + text;
@@ -79060,7 +79583,7 @@
79060
79583
  // This error was thrown as a convenience so that you can use this stack
79061
79584
  // to find the callsite that caused this warning to fire.
79062
79585
  throw new Error(message);
79063
- } catch (x) {}
79586
+ } catch (x) { /**/ }
79064
79587
  };
79065
79588
  }
79066
79589
 
@@ -79089,7 +79612,8 @@
79089
79612
  if (typeof typeSpecs[typeSpecName] !== 'function') {
79090
79613
  var err = Error(
79091
79614
  (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
79092
- 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
79615
+ 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
79616
+ 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
79093
79617
  );
79094
79618
  err.name = 'Invariant Violation';
79095
79619
  throw err;
@@ -79148,9 +79672,9 @@
79148
79672
  var assign = objectAssign;
79149
79673
 
79150
79674
  var ReactPropTypesSecret = ReactPropTypesSecret_1;
79675
+ var has = has$2;
79151
79676
  var checkPropTypes = checkPropTypes_1;
79152
79677
 
79153
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
79154
79678
  var printWarning = function() {};
79155
79679
 
79156
79680
  {
@@ -79251,6 +79775,7 @@
79251
79775
  // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
79252
79776
  var ReactPropTypes = {
79253
79777
  array: createPrimitiveTypeChecker('array'),
79778
+ bigint: createPrimitiveTypeChecker('bigint'),
79254
79779
  bool: createPrimitiveTypeChecker('boolean'),
79255
79780
  func: createPrimitiveTypeChecker('function'),
79256
79781
  number: createPrimitiveTypeChecker('number'),
@@ -79296,8 +79821,9 @@
79296
79821
  * is prohibitively expensive if they are created too often, such as what
79297
79822
  * happens in oneOfType() for any type before the one that matched.
79298
79823
  */
79299
- function PropTypeError(message) {
79824
+ function PropTypeError(message, data) {
79300
79825
  this.message = message;
79826
+ this.data = data && typeof data === 'object' ? data: {};
79301
79827
  this.stack = '';
79302
79828
  }
79303
79829
  // Make `instanceof Error` still work for returned errors.
@@ -79332,7 +79858,7 @@
79332
79858
  ) {
79333
79859
  printWarning(
79334
79860
  'You are manually calling a React.PropTypes validation ' +
79335
- 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
79861
+ 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
79336
79862
  'and will throw in the standalone `prop-types` package. ' +
79337
79863
  'You may be seeing this warning due to a third-party PropTypes ' +
79338
79864
  'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
@@ -79371,7 +79897,10 @@
79371
79897
  // 'of type `object`'.
79372
79898
  var preciseType = getPreciseType(propValue);
79373
79899
 
79374
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
79900
+ return new PropTypeError(
79901
+ 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
79902
+ {expectedType: expectedType}
79903
+ );
79375
79904
  }
79376
79905
  return null;
79377
79906
  }
@@ -79515,14 +80044,19 @@
79515
80044
  }
79516
80045
 
79517
80046
  function validate(props, propName, componentName, location, propFullName) {
80047
+ var expectedTypes = [];
79518
80048
  for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
79519
80049
  var checker = arrayOfTypeCheckers[i];
79520
- if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
80050
+ var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
80051
+ if (checkerResult == null) {
79521
80052
  return null;
79522
80053
  }
80054
+ if (checkerResult.data.hasOwnProperty('expectedType')) {
80055
+ expectedTypes.push(checkerResult.data.expectedType);
80056
+ }
79523
80057
  }
79524
-
79525
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
80058
+ var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
80059
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
79526
80060
  }
79527
80061
  return createChainableTypeChecker(validate);
79528
80062
  }
@@ -79537,6 +80071,13 @@
79537
80071
  return createChainableTypeChecker(validate);
79538
80072
  }
79539
80073
 
80074
+ function invalidValidatorError(componentName, location, propFullName, key, type) {
80075
+ return new PropTypeError(
80076
+ (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
80077
+ 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
80078
+ );
80079
+ }
80080
+
79540
80081
  function createShapeTypeChecker(shapeTypes) {
79541
80082
  function validate(props, propName, componentName, location, propFullName) {
79542
80083
  var propValue = props[propName];
@@ -79546,8 +80087,8 @@
79546
80087
  }
79547
80088
  for (var key in shapeTypes) {
79548
80089
  var checker = shapeTypes[key];
79549
- if (!checker) {
79550
- continue;
80090
+ if (typeof checker !== 'function') {
80091
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
79551
80092
  }
79552
80093
  var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
79553
80094
  if (error) {
@@ -79566,16 +80107,18 @@
79566
80107
  if (propType !== 'object') {
79567
80108
  return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
79568
80109
  }
79569
- // We need to check all keys in case some are required but missing from
79570
- // props.
80110
+ // We need to check all keys in case some are required but missing from props.
79571
80111
  var allKeys = assign({}, props[propName], shapeTypes);
79572
80112
  for (var key in allKeys) {
79573
80113
  var checker = shapeTypes[key];
80114
+ if (has(shapeTypes, key) && typeof checker !== 'function') {
80115
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
80116
+ }
79574
80117
  if (!checker) {
79575
80118
  return new PropTypeError(
79576
80119
  'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
79577
80120
  '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
79578
- '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
80121
+ '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
79579
80122
  );
79580
80123
  }
79581
80124
  var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);