super-three 0.135.0 → 0.136.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.
Files changed (175) hide show
  1. package/build/three.js +527 -332
  2. package/build/three.min.js +1 -1
  3. package/build/three.module.js +752 -370
  4. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  5. package/examples/js/animation/CCDIKSolver.js +0 -1
  6. package/examples/js/animation/MMDPhysics.js +1 -3
  7. package/examples/js/controls/ArcballControls.js +38 -52
  8. package/examples/js/controls/TransformControls.js +24 -1
  9. package/examples/js/curves/CurveExtras.js +0 -2
  10. package/examples/js/effects/AsciiEffect.js +2 -9
  11. package/examples/js/exporters/GLTFExporter.js +1 -1
  12. package/examples/js/geometries/TeapotGeometry.js +0 -1
  13. package/examples/js/interactive/SelectionBox.js +2 -0
  14. package/examples/js/interactive/SelectionHelper.js +22 -7
  15. package/examples/js/lights/RectAreaLightUniformsLib.js +4 -0
  16. package/examples/js/loaders/AMFLoader.js +0 -2
  17. package/examples/js/loaders/ColladaLoader.js +1 -2
  18. package/examples/js/loaders/EXRLoader.js +185 -262
  19. package/examples/js/loaders/FBXLoader.js +3 -4
  20. package/examples/js/loaders/GLTFLoader.js +2 -2
  21. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -8
  22. package/examples/js/loaders/KTX2Loader.js +11 -2
  23. package/examples/js/loaders/KTXLoader.js +1 -1
  24. package/examples/js/loaders/LDrawLoader.js +26 -30
  25. package/examples/js/loaders/LUT3dlLoader.js +2 -0
  26. package/examples/js/loaders/LUTCubeLoader.js +2 -0
  27. package/examples/js/loaders/MMDLoader.js +0 -1
  28. package/examples/js/loaders/NRRDLoader.js +9 -2
  29. package/examples/js/loaders/OBJLoader.js +0 -2
  30. package/examples/js/loaders/PLYLoader.js +1 -1
  31. package/examples/js/loaders/RGBELoader.js +0 -15
  32. package/examples/js/loaders/RGBMLoader.js +55 -5
  33. package/examples/js/loaders/SVGLoader.js +2 -2
  34. package/examples/js/loaders/VOXLoader.js +1 -0
  35. package/examples/js/loaders/VRMLLoader.js +2 -1
  36. package/examples/js/math/ImprovedNoise.js +1 -1
  37. package/examples/js/misc/GPUComputationRenderer.js +3 -1
  38. package/examples/js/objects/Lensflare.js +2 -10
  39. package/examples/js/objects/Reflector.js +7 -0
  40. package/examples/js/objects/Refractor.js +7 -0
  41. package/examples/js/objects/Sky.js +1 -1
  42. package/examples/js/objects/Water.js +2 -2
  43. package/examples/js/objects/Water2.js +4 -7
  44. package/examples/js/postprocessing/GlitchPass.js +3 -1
  45. package/examples/js/postprocessing/SSAOPass.js +1 -0
  46. package/examples/js/shaders/ConvolutionShader.js +0 -1
  47. package/examples/js/shaders/FXAAShader.js +1 -1
  48. package/examples/js/shaders/FilmShader.js +1 -1
  49. package/examples/js/shaders/GammaCorrectionShader.js +1 -1
  50. package/examples/js/shaders/HorizontalBlurShader.js +1 -2
  51. package/examples/js/shaders/SSRShader.js +1 -1
  52. package/examples/js/shaders/SSRrShader.js +1 -1
  53. package/examples/js/shaders/VerticalBlurShader.js +1 -2
  54. package/examples/js/utils/GeometryUtils.js +1 -1
  55. package/examples/js/utils/RoughnessMipmapper.js +18 -29
  56. package/examples/jsm/animation/CCDIKSolver.js +0 -1
  57. package/examples/jsm/animation/MMDPhysics.js +0 -2
  58. package/examples/jsm/controls/ArcballControls.js +27 -56
  59. package/examples/jsm/controls/TransformControls.js +24 -1
  60. package/examples/jsm/curves/CurveExtras.js +0 -2
  61. package/examples/jsm/effects/AsciiEffect.js +2 -9
  62. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  63. package/examples/jsm/geometries/TeapotGeometry.js +0 -1
  64. package/examples/jsm/interactive/SelectionBox.js +1 -0
  65. package/examples/jsm/interactive/SelectionHelper.js +19 -7
  66. package/examples/jsm/libs/flow.module.js +256 -136
  67. package/examples/jsm/lights/RectAreaLightUniformsLib.js +7 -0
  68. package/examples/jsm/loaders/AMFLoader.js +0 -2
  69. package/examples/jsm/loaders/ColladaLoader.js +1 -2
  70. package/examples/jsm/loaders/EXRLoader.js +184 -293
  71. package/examples/jsm/loaders/FBXLoader.js +3 -4
  72. package/examples/jsm/loaders/GLTFLoader.js +2 -2
  73. package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -14
  74. package/examples/jsm/loaders/KTX2Loader.js +13 -4
  75. package/examples/jsm/loaders/KTXLoader.js +1 -1
  76. package/examples/jsm/loaders/LDrawLoader.js +23 -24
  77. package/examples/jsm/loaders/LUT3dlLoader.js +2 -0
  78. package/examples/jsm/loaders/LUTCubeLoader.js +2 -0
  79. package/examples/jsm/loaders/MMDLoader.js +0 -1
  80. package/examples/jsm/loaders/NRRDLoader.js +10 -2
  81. package/examples/jsm/loaders/OBJLoader.js +0 -2
  82. package/examples/jsm/loaders/PLYLoader.js +1 -1
  83. package/examples/jsm/loaders/RGBELoader.js +0 -20
  84. package/examples/jsm/loaders/RGBMLoader.js +61 -7
  85. package/examples/jsm/loaders/SVGLoader.js +2 -2
  86. package/examples/jsm/loaders/TDSLoader.js +30 -9
  87. package/examples/jsm/loaders/VOXLoader.js +1 -0
  88. package/examples/jsm/loaders/VRMLLoader.js +2 -1
  89. package/examples/jsm/math/ImprovedNoise.js +1 -1
  90. package/examples/jsm/misc/GPUComputationRenderer.js +3 -1
  91. package/examples/jsm/node-editor/NodeEditor.js +23 -22
  92. package/examples/jsm/node-editor/examples/rim.json +1 -1
  93. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +48 -9
  94. package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
  95. package/examples/jsm/nodes/core/NodeBuilder.js +2 -2
  96. package/examples/jsm/nodes/materials/nodes/StandardNode.js +1 -0
  97. package/examples/jsm/nodes/math/MathNode.js +12 -0
  98. package/examples/jsm/nodes/misc/BumpMapNode.js +1 -1
  99. package/examples/jsm/nodes/misc/TextureCubeUVNode.js +1 -4
  100. package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -116
  101. package/examples/jsm/objects/Lensflare.js +3 -14
  102. package/examples/jsm/objects/Reflector.js +7 -0
  103. package/examples/jsm/objects/Refractor.js +7 -0
  104. package/examples/jsm/objects/Sky.js +1 -1
  105. package/examples/jsm/objects/Water.js +2 -2
  106. package/examples/jsm/objects/Water2.js +4 -8
  107. package/examples/jsm/postprocessing/GlitchPass.js +3 -1
  108. package/examples/jsm/postprocessing/SAOPass.js +1 -1
  109. package/examples/jsm/postprocessing/SSAOPass.js +1 -0
  110. package/examples/jsm/renderers/nodes/Nodes.js +1 -0
  111. package/examples/jsm/renderers/nodes/ShaderNode.js +7 -6
  112. package/examples/jsm/renderers/nodes/core/InputNode.js +1 -1
  113. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +1 -1
  114. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +26 -31
  115. package/examples/jsm/renderers/nodes/functions/BSDFs.js +2 -2
  116. package/examples/jsm/renderers/nodes/functions/PhysicalMaterialFunctions.js +27 -0
  117. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +1 -1
  118. package/examples/jsm/renderers/nodes/math/MathNode.js +5 -3
  119. package/examples/jsm/renderers/nodes/math/OperatorNode.js +2 -2
  120. package/examples/jsm/renderers/nodes/utils/TimerNode.js +1 -1
  121. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +14 -14
  122. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +7 -6
  123. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +1 -1
  124. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +42 -61
  125. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +2 -2
  126. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +0 -1
  127. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +30 -4
  128. package/examples/jsm/shaders/ConvolutionShader.js +0 -1
  129. package/examples/jsm/shaders/FXAAShader.js +1 -1
  130. package/examples/jsm/shaders/FilmShader.js +1 -1
  131. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  132. package/examples/jsm/shaders/HorizontalBlurShader.js +1 -2
  133. package/examples/jsm/shaders/SSRShader.js +1 -1
  134. package/examples/jsm/shaders/SSRrShader.js +1 -1
  135. package/examples/jsm/shaders/VerticalBlurShader.js +1 -2
  136. package/examples/jsm/utils/GeometryUtils.js +1 -1
  137. package/examples/jsm/utils/RoughnessMipmapper.js +19 -32
  138. package/examples/jsm/utils/WorkerPool.js +11 -11
  139. package/package.json +15 -9
  140. package/src/Three.Legacy.js +12 -0
  141. package/src/Three.js +1 -2
  142. package/src/constants.js +1 -7
  143. package/src/core/Object3D.js +1 -1
  144. package/src/extras/PMREMGenerator.js +19 -110
  145. package/src/extras/core/Interpolations.js +1 -1
  146. package/src/geometries/LatheGeometry.js +70 -47
  147. package/src/helpers/CameraHelper.js +1 -1
  148. package/src/loaders/FileLoader.js +23 -6
  149. package/src/math/Color.js +0 -38
  150. package/src/math/Ray.js +2 -2
  151. package/src/math/Sphere.js +10 -1
  152. package/src/objects/Skeleton.js +1 -0
  153. package/src/renderers/WebGLRenderer.js +23 -16
  154. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +1 -1
  155. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +2 -24
  156. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -47
  157. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +1 -1
  158. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +27 -1
  159. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  160. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +10 -0
  161. package/src/renderers/webgl/WebGLCapabilities.js +0 -2
  162. package/src/renderers/webgl/WebGLMorphtargets.js +1 -0
  163. package/src/renderers/webgl/WebGLProgram.js +2 -19
  164. package/src/renderers/webgl/WebGLPrograms.js +191 -35
  165. package/src/renderers/webgl/WebGLRenderLists.js +4 -14
  166. package/src/renderers/webgl/WebGLShaderCache.js +120 -0
  167. package/src/renderers/webgl/WebGLState.js +45 -0
  168. package/src/renderers/webgl/WebGLTextures.js +195 -26
  169. package/src/renderers/webxr/WebXRManager.js +10 -3
  170. package/src/scenes/Scene.js +1 -1
  171. package/src/textures/DataTexture.js +0 -2
  172. package/src/textures/DataTexture2DArray.js +0 -2
  173. package/src/textures/DataTexture3D.js +0 -2
  174. package/src/textures/FramebufferTexture.js +25 -0
  175. package/src/utils.js +1 -37
package/build/three.js CHANGED
@@ -9,7 +9,7 @@
9
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));
10
10
  }(this, (function (exports) { 'use strict';
11
11
 
12
- const REVISION = '135';
12
+ const REVISION = '136';
13
13
  const MOUSE = {
14
14
  LEFT: 0,
15
15
  MIDDLE: 1,
@@ -113,7 +113,6 @@
113
113
  const RGBAFormat = 1023;
114
114
  const LuminanceFormat = 1024;
115
115
  const LuminanceAlphaFormat = 1025;
116
- const RGBEFormat = RGBAFormat;
117
116
  const DepthFormat = 1026;
118
117
  const DepthStencilFormat = 1027;
119
118
  const RedFormat = 1028;
@@ -178,11 +177,6 @@
178
177
  const TriangleFanDrawMode = 2;
179
178
  const LinearEncoding = 3000;
180
179
  const sRGBEncoding = 3001;
181
- const GammaEncoding = 3007;
182
- const RGBEEncoding = 3002;
183
- const RGBM7Encoding = 3004;
184
- const RGBM16Encoding = 3005;
185
- const RGBDEncoding = 3006;
186
180
  const BasicDepthPacking = 3200;
187
181
  const RGBADepthPacking = 3201;
188
182
  const TangentSpaceNormalMap = 0;
@@ -1106,36 +1100,6 @@
1106
1100
  function createElementNS(name) {
1107
1101
  return document.createElementNS('http://www.w3.org/1999/xhtml', name);
1108
1102
  }
1109
- /**
1110
- * cyrb53 hash for string from: https://stackoverflow.com/a/52171480
1111
- *
1112
- * Public Domain, @bryc - https://stackoverflow.com/users/815680/bryc
1113
- *
1114
- * It is roughly similar to the well-known MurmurHash/xxHash algorithms. It uses a combination
1115
- * of multiplication and Xorshift to generate the hash, but not as thorough. As a result it's
1116
- * faster than either would be in JavaScript and significantly simpler to implement. Keep in
1117
- * mind this is not a secure algorithm, if privacy/security is a concern, this is not for you.
1118
- *
1119
- * @param {string} str
1120
- * @param {number} seed, default 0
1121
- * @returns number
1122
- */
1123
-
1124
-
1125
- function hashString(str, seed = 0) {
1126
- let h1 = 0xdeadbeef ^ seed,
1127
- h2 = 0x41c6ce57 ^ seed;
1128
-
1129
- for (let i = 0, ch; i < str.length; i++) {
1130
- ch = str.charCodeAt(i);
1131
- h1 = Math.imul(h1 ^ ch, 2654435761);
1132
- h2 = Math.imul(h2 ^ ch, 1597334677);
1133
- }
1134
-
1135
- h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
1136
- h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
1137
- return 4294967296 * (2097151 & h2) + (h1 >>> 0);
1138
- }
1139
1103
 
1140
1104
  let _canvas;
1141
1105
 
@@ -3676,7 +3640,11 @@
3676
3640
  // To enclose another sphere into this sphere, we only need to enclose two points:
3677
3641
  // 1) Enclose the farthest point on the other sphere into this sphere.
3678
3642
  // 2) Enclose the opposite point of the farthest point into this sphere.
3679
- _toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius);
3643
+ if (this.center.equals(sphere.center) === true) {
3644
+ _toFarthestPoint.set(0, 0, 1).multiplyScalar(sphere.radius);
3645
+ } else {
3646
+ _toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius);
3647
+ }
3680
3648
 
3681
3649
  this.expandByPoint(_v1$6.copy(sphere.center).add(_toFarthestPoint));
3682
3650
  this.expandByPoint(_v1$6.copy(sphere.center).sub(_toFarthestPoint));
@@ -3768,7 +3736,7 @@
3768
3736
  }
3769
3737
 
3770
3738
  distanceSqToSegment(v0, v1, optionalPointOnRay, optionalPointOnSegment) {
3771
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h
3739
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h
3772
3740
  // It returns the min distance between the ray and the segment
3773
3741
  // defined by v0 and v1
3774
3742
  // It can also set two optional targets :
@@ -3979,7 +3947,7 @@
3979
3947
 
3980
3948
  intersectTriangle(a, b, c, backfaceCulling, target) {
3981
3949
  // Compute the offset origin, edges, and normal.
3982
- // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
3950
+ // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
3983
3951
  _edge1.subVectors(b, a);
3984
3952
 
3985
3953
  _edge2.subVectors(c, a);
@@ -6684,31 +6652,6 @@
6684
6652
  return this;
6685
6653
  }
6686
6654
 
6687
- copyGammaToLinear(color, gammaFactor = 2.0) {
6688
- this.r = Math.pow(color.r, gammaFactor);
6689
- this.g = Math.pow(color.g, gammaFactor);
6690
- this.b = Math.pow(color.b, gammaFactor);
6691
- return this;
6692
- }
6693
-
6694
- copyLinearToGamma(color, gammaFactor = 2.0) {
6695
- const safeInverse = gammaFactor > 0 ? 1.0 / gammaFactor : 1.0;
6696
- this.r = Math.pow(color.r, safeInverse);
6697
- this.g = Math.pow(color.g, safeInverse);
6698
- this.b = Math.pow(color.b, safeInverse);
6699
- return this;
6700
- }
6701
-
6702
- convertGammaToLinear(gammaFactor) {
6703
- this.copyGammaToLinear(this, gammaFactor);
6704
- return this;
6705
- }
6706
-
6707
- convertLinearToGamma(gammaFactor) {
6708
- this.copyLinearToGamma(this, gammaFactor);
6709
- return this;
6710
- }
6711
-
6712
6655
  copySRGBToLinear(color) {
6713
6656
  this.r = SRGBToLinear(color.r);
6714
6657
  this.g = SRGBToLinear(color.g);
@@ -7350,7 +7293,7 @@
7350
7293
 
7351
7294
  } //
7352
7295
 
7353
- let _id = 0;
7296
+ let _id$1 = 0;
7354
7297
 
7355
7298
  const _m1 = /*@__PURE__*/new Matrix4();
7356
7299
 
@@ -7368,7 +7311,7 @@
7368
7311
  constructor() {
7369
7312
  super();
7370
7313
  Object.defineProperty(this, 'id', {
7371
- value: _id++
7314
+ value: _id$1++
7372
7315
  });
7373
7316
  this.uuid = generateUUID();
7374
7317
  this.name = '';
@@ -9721,7 +9664,7 @@
9721
9664
 
9722
9665
  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}";
9723
9666
 
9724
- 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";
9667
+ 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";
9725
9668
 
9726
9669
  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";
9727
9670
 
@@ -9735,7 +9678,7 @@
9735
9678
 
9736
9679
  var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
9737
9680
 
9738
- 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}";
9681
+ 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}";
9739
9682
 
9740
9683
  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";
9741
9684
 
@@ -9755,7 +9698,7 @@
9755
9698
 
9756
9699
  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";
9757
9700
 
9758
- 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}";
9701
+ 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}";
9759
9702
 
9760
9703
  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";
9761
9704
 
@@ -9777,7 +9720,7 @@
9777
9720
 
9778
9721
  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";
9779
9722
 
9780
- 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}";
9723
+ 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}";
9781
9724
 
9782
9725
  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";
9783
9726
 
@@ -9921,7 +9864,7 @@
9921
9864
  const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <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 <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\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 <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <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}";
9922
9865
 
9923
9866
  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}";
9924
- 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 - 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}";
9867
+ 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}";
9925
9868
 
9926
9869
  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}";
9927
9870
  const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <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 <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\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 <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <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}";
@@ -11214,12 +11157,8 @@
11214
11157
 
11215
11158
  return 'lowp';
11216
11159
  }
11217
- /* eslint-disable no-undef */
11218
-
11219
11160
 
11220
11161
  const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext;
11221
- /* eslint-enable no-undef */
11222
-
11223
11162
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
11224
11163
  const maxPrecision = getMaxPrecision(precision);
11225
11164
 
@@ -11562,12 +11501,7 @@
11562
11501
  const MAX_SAMPLES = 20;
11563
11502
  const ENCODINGS = {
11564
11503
  [LinearEncoding]: 0,
11565
- [sRGBEncoding]: 1,
11566
- [RGBEEncoding]: 2,
11567
- [RGBM7Encoding]: 3,
11568
- [RGBM16Encoding]: 4,
11569
- [RGBDEncoding]: 5,
11570
- [GammaEncoding]: 6
11504
+ [sRGBEncoding]: 1
11571
11505
  };
11572
11506
 
11573
11507
  const _flatCamera = /*@__PURE__*/new OrthographicCamera();
@@ -11640,7 +11574,7 @@
11640
11574
  }
11641
11575
  /**
11642
11576
  * Generates a PMREM from an equirectangular texture, which can be either LDR
11643
- * (RGBFormat) or HDR (RGBEFormat). The ideal input image size is 1k (1024 x 512),
11577
+ * or HDR. The ideal input image size is 1k (1024 x 512),
11644
11578
  * as this matches best with the 256 x 256 cubemap output.
11645
11579
  */
11646
11580
 
@@ -11650,7 +11584,7 @@
11650
11584
  }
11651
11585
  /**
11652
11586
  * Generates a PMREM from an cubemap texture, which can be either LDR
11653
- * (RGBFormat) or HDR (RGBEFormat). The ideal input cube size is 256 x 256,
11587
+ * or HDR. The ideal input cube size is 256 x 256,
11654
11588
  * as this matches best with the 256 x 256 cubemap output.
11655
11589
  */
11656
11590
 
@@ -11730,12 +11664,12 @@
11730
11664
  _allocateTargets(texture) {
11731
11665
  // warning: null texture is valid
11732
11666
  const params = {
11733
- magFilter: NearestFilter,
11734
- minFilter: NearestFilter,
11667
+ magFilter: LinearFilter,
11668
+ minFilter: LinearFilter,
11735
11669
  generateMipmaps: false,
11736
- type: UnsignedByteType,
11737
- format: RGBEFormat,
11738
- encoding: _isLDR(texture) ? texture.encoding : RGBEEncoding,
11670
+ type: HalfFloatType,
11671
+ format: RGBAFormat,
11672
+ encoding: LinearEncoding,
11739
11673
  depthBuffer: false
11740
11674
  };
11741
11675
 
@@ -11760,11 +11694,9 @@
11760
11694
  const forwardSign = [1, 1, 1, -1, -1, -1];
11761
11695
  const renderer = this._renderer;
11762
11696
  const originalAutoClear = renderer.autoClear;
11763
- const outputEncoding = renderer.outputEncoding;
11764
11697
  const toneMapping = renderer.toneMapping;
11765
11698
  renderer.getClearColor(_clearColor);
11766
11699
  renderer.toneMapping = NoToneMapping;
11767
- renderer.outputEncoding = LinearEncoding;
11768
11700
  renderer.autoClear = false;
11769
11701
  const backgroundMaterial = new MeshBasicMaterial({
11770
11702
  name: 'PMREM.Background',
@@ -11815,18 +11747,16 @@
11815
11747
  backgroundBox.geometry.dispose();
11816
11748
  backgroundBox.material.dispose();
11817
11749
  renderer.toneMapping = toneMapping;
11818
- renderer.outputEncoding = outputEncoding;
11819
11750
  renderer.autoClear = originalAutoClear;
11820
11751
  scene.background = background;
11821
11752
  }
11822
11753
 
11823
11754
  _setEncoding(uniform, texture) {
11824
- /* if ( this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding ) {
11825
- uniform.value = ENCODINGS[ LinearEncoding ];
11826
- } else {
11827
- uniform.value = ENCODINGS[ texture.encoding ];
11828
- } */
11829
- uniform.value = ENCODINGS[texture.encoding];
11755
+ if (this._renderer.capabilities.isWebGL2 === true && texture.format === RGBAFormat && texture.type === UnsignedByteType && texture.encoding === sRGBEncoding) {
11756
+ uniform.value = ENCODINGS[LinearEncoding];
11757
+ } else {
11758
+ uniform.value = ENCODINGS[texture.encoding];
11759
+ }
11830
11760
  }
11831
11761
 
11832
11762
  _textureToCubeUV(texture, cubeUVRenderTarget) {
@@ -11854,8 +11784,6 @@
11854
11784
 
11855
11785
  this._setEncoding(uniforms['inputEncoding'], texture);
11856
11786
 
11857
- this._setEncoding(uniforms['outputEncoding'], cubeUVRenderTarget.texture);
11858
-
11859
11787
  _setViewport(cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX);
11860
11788
 
11861
11789
  renderer.setRenderTarget(cubeUVRenderTarget);
@@ -11944,11 +11872,6 @@
11944
11872
 
11945
11873
  blurUniforms['dTheta'].value = radiansPerPixel;
11946
11874
  blurUniforms['mipInt'].value = LOD_MAX - lodIn;
11947
-
11948
- this._setEncoding(blurUniforms['inputEncoding'], targetIn.texture);
11949
-
11950
- this._setEncoding(blurUniforms['outputEncoding'], targetIn.texture);
11951
-
11952
11875
  const outputSize = _sizeLods[lodOut];
11953
11876
  const x = 3 * Math.max(0, SIZE_MAX - 2 * outputSize);
11954
11877
  const y = (lodOut === 0 ? 0 : 2 * SIZE_MAX) + 2 * outputSize * (lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0);
@@ -11961,11 +11884,6 @@
11961
11884
 
11962
11885
  }
11963
11886
 
11964
- function _isLDR(texture) {
11965
- if (texture === undefined || texture.type !== UnsignedByteType) return false;
11966
- return texture.encoding === LinearEncoding || texture.encoding === sRGBEncoding || texture.encoding === GammaEncoding;
11967
- }
11968
-
11969
11887
  function _createPlanes() {
11970
11888
  const _lodPlanes = [];
11971
11889
  const _sizeLods = [];
@@ -12071,12 +11989,6 @@
12071
11989
  },
12072
11990
  'poleAxis': {
12073
11991
  value: poleAxis
12074
- },
12075
- 'inputEncoding': {
12076
- value: ENCODINGS[LinearEncoding]
12077
- },
12078
- 'outputEncoding': {
12079
- value: ENCODINGS[LinearEncoding]
12080
11992
  }
12081
11993
  },
12082
11994
  vertexShader: _getCommonVertexShader(),
@@ -12143,8 +12055,6 @@
12143
12055
 
12144
12056
  }
12145
12057
 
12146
- gl_FragColor = linearToOutputTexel( gl_FragColor );
12147
-
12148
12058
  }
12149
12059
  `,
12150
12060
  blending: NoBlending,
@@ -12167,9 +12077,6 @@
12167
12077
  },
12168
12078
  'inputEncoding': {
12169
12079
  value: ENCODINGS[LinearEncoding]
12170
- },
12171
- 'outputEncoding': {
12172
- value: ENCODINGS[LinearEncoding]
12173
12080
  }
12174
12081
  },
12175
12082
  vertexShader: _getCommonVertexShader(),
@@ -12210,8 +12117,6 @@
12210
12117
  vec3 bm = mix( bl, br, f.x );
12211
12118
  gl_FragColor.rgb = mix( tm, bm, f.y );
12212
12119
 
12213
- gl_FragColor = linearToOutputTexel( gl_FragColor );
12214
-
12215
12120
  }
12216
12121
  `,
12217
12122
  blending: NoBlending,
@@ -12230,9 +12135,6 @@
12230
12135
  },
12231
12136
  'inputEncoding': {
12232
12137
  value: ENCODINGS[LinearEncoding]
12233
- },
12234
- 'outputEncoding': {
12235
- value: ENCODINGS[LinearEncoding]
12236
12138
  }
12237
12139
  },
12238
12140
  vertexShader: _getCommonVertexShader(),
@@ -12251,9 +12153,7 @@
12251
12153
 
12252
12154
  void main() {
12253
12155
 
12254
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
12255
- gl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;
12256
- gl_FragColor = linearToOutputTexel( gl_FragColor );
12156
+ gl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) );
12257
12157
 
12258
12158
  }
12259
12159
  `,
@@ -12334,7 +12234,6 @@
12334
12234
  `
12335
12235
 
12336
12236
  uniform int inputEncoding;
12337
- uniform int outputEncoding;
12338
12237
 
12339
12238
  #include <encodings_pars_fragment>
12340
12239
 
@@ -12344,63 +12243,9 @@
12344
12243
 
12345
12244
  return value;
12346
12245
 
12347
- } else if ( inputEncoding == 1 ) {
12348
-
12349
- return sRGBToLinear( value );
12350
-
12351
- } else if ( inputEncoding == 2 ) {
12352
-
12353
- return RGBEToLinear( value );
12354
-
12355
- } else if ( inputEncoding == 3 ) {
12356
-
12357
- return RGBMToLinear( value, 7.0 );
12358
-
12359
- } else if ( inputEncoding == 4 ) {
12360
-
12361
- return RGBMToLinear( value, 16.0 );
12362
-
12363
- } else if ( inputEncoding == 5 ) {
12364
-
12365
- return RGBDToLinear( value, 256.0 );
12366
-
12367
12246
  } else {
12368
12247
 
12369
- return GammaToLinear( value, 2.2 );
12370
-
12371
- }
12372
-
12373
- }
12374
-
12375
- vec4 linearToOutputTexel( vec4 value ) {
12376
-
12377
- if ( outputEncoding == 0 ) {
12378
-
12379
- return value;
12380
-
12381
- } else if ( outputEncoding == 1 ) {
12382
-
12383
- return LinearTosRGB( value );
12384
-
12385
- } else if ( outputEncoding == 2 ) {
12386
-
12387
- return LinearToRGBE( value );
12388
-
12389
- } else if ( outputEncoding == 3 ) {
12390
-
12391
- return LinearToRGBM( value, 7.0 );
12392
-
12393
- } else if ( outputEncoding == 4 ) {
12394
-
12395
- return LinearToRGBM( value, 16.0 );
12396
-
12397
- } else if ( outputEncoding == 5 ) {
12398
-
12399
- return LinearToRGBD( value, 256.0 );
12400
-
12401
- } else {
12402
-
12403
- return LinearToGamma( value, 2.2 );
12248
+ return sRGBToLinear( value );
12404
12249
 
12405
12250
  }
12406
12251
 
@@ -12806,7 +12651,6 @@
12806
12651
  this.generateMipmaps = false;
12807
12652
  this.flipY = false;
12808
12653
  this.unpackAlignment = 1;
12809
- this.needsUpdate = true;
12810
12654
  }
12811
12655
 
12812
12656
  }
@@ -12868,7 +12712,8 @@
12868
12712
  const texture = new DataTexture2DArray(buffer, width, height, numberOfMorphTargets);
12869
12713
  texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower)
12870
12714
 
12871
- texture.type = FloatType; // fill buffer
12715
+ texture.type = FloatType;
12716
+ texture.needsUpdate = true; // fill buffer
12872
12717
 
12873
12718
  const vertexDataStride = numberOfVertexData * 4;
12874
12719
 
@@ -13068,7 +12913,6 @@
13068
12913
  this.generateMipmaps = false;
13069
12914
  this.flipY = false;
13070
12915
  this.unpackAlignment = 1;
13071
- this.needsUpdate = true;
13072
12916
  }
13073
12917
 
13074
12918
  }
@@ -13911,21 +13755,6 @@
13911
13755
  case sRGBEncoding:
13912
13756
  return ['sRGB', '( value )'];
13913
13757
 
13914
- case RGBEEncoding:
13915
- return ['RGBE', '( value )'];
13916
-
13917
- case RGBM7Encoding:
13918
- return ['RGBM', '( value, 7.0 )'];
13919
-
13920
- case RGBM16Encoding:
13921
- return ['RGBM', '( value, 16.0 )'];
13922
-
13923
- case RGBDEncoding:
13924
- return ['RGBD', '( value, 256.0 )'];
13925
-
13926
- case GammaEncoding:
13927
- return ['Gamma', '( value, float( GAMMA_FACTOR ) )'];
13928
-
13929
13758
  default:
13930
13759
  console.warn('THREE.WebGLProgram: Unsupported encoding:', encoding);
13931
13760
  return ['Linear', '( value )'];
@@ -14171,7 +14000,6 @@
14171
14000
  const envMapTypeDefine = generateEnvMapTypeDefine(parameters);
14172
14001
  const envMapModeDefine = generateEnvMapModeDefine(parameters);
14173
14002
  const envMapBlendingDefine = generateEnvMapBlendingDefine(parameters);
14174
- const gammaFactorDefine = renderer.gammaFactor > 0 ? renderer.gammaFactor : 1.0;
14175
14003
  const customExtensions = parameters.isWebGL2 ? '' : generateExtensions(parameters);
14176
14004
  const customDefines = generateDefines(defines);
14177
14005
  const program = gl.createProgram();
@@ -14191,8 +14019,8 @@
14191
14019
  prefixFragment += '\n';
14192
14020
  }
14193
14021
  } else {
14194
- prefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', '#define GAMMA_FACTOR ' + gammaFactorDefine, '#define MAX_BONES ' + parameters.maxBones, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', ' attribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', ' attribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', ' attribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', ' attribute vec4 color;', '#elif defined( USE_COLOR )', ' attribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', ' attribute vec3 morphTarget0;', ' attribute vec3 morphTarget1;', ' attribute vec3 morphTarget2;', ' attribute vec3 morphTarget3;', ' #ifdef USE_MORPHNORMALS', ' attribute vec3 morphNormal0;', ' attribute vec3 morphNormal1;', ' attribute vec3 morphNormal2;', ' attribute vec3 morphNormal3;', ' #else', ' attribute vec3 morphTarget4;', ' attribute vec3 morphTarget5;', ' attribute vec3 morphTarget6;', ' attribute vec3 morphTarget7;', ' #endif', '#endif', '#ifdef USE_SKINNING', ' attribute vec4 skinIndex;', ' attribute vec4 skinWeight;', '#endif', '\n'].filter(filterEmptyLine).join('\n');
14195
- prefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, '#define GAMMA_FACTOR ' + gammaFactorDefine, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoat ? '#define USE_CLEARCOAT' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.alphaTest ? '#define USE_ALPHATEST' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below
14022
+ prefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', '#define MAX_BONES ' + parameters.maxBones, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', ' attribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', ' attribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', ' attribute vec4 tangent;', '#endif', '#if defined( USE_COLOR_ALPHA )', ' attribute vec4 color;', '#elif defined( USE_COLOR )', ' attribute vec3 color;', '#endif', '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', ' attribute vec3 morphTarget0;', ' attribute vec3 morphTarget1;', ' attribute vec3 morphTarget2;', ' attribute vec3 morphTarget3;', ' #ifdef USE_MORPHNORMALS', ' attribute vec3 morphNormal0;', ' attribute vec3 morphNormal1;', ' attribute vec3 morphNormal2;', ' attribute vec3 morphNormal3;', ' #else', ' attribute vec3 morphTarget4;', ' attribute vec3 morphTarget5;', ' attribute vec3 morphTarget6;', ' attribute vec3 morphTarget7;', ' #endif', '#endif', '#ifdef USE_SKINNING', ' attribute vec4 skinIndex;', ' attribute vec4 skinWeight;', '#endif', '\n'].filter(filterEmptyLine).join('\n');
14023
+ prefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoat ? '#define USE_CLEARCOAT' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.alphaTest ? '#define USE_ALPHATEST' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', parameters.transmission ? '#define USE_TRANSMISSION' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below
14196
14024
  parameters.toneMapping !== NoToneMapping ? getToneMappingFunction('toneMapping', parameters.toneMapping) : '', parameters.dithering ? '#define DITHERING' : '', parameters.format === RGBFormat ? '#define OPAQUE' : '', ShaderChunk['encodings_pars_fragment'], // this code is required here because it is used by the various encoding/decoding function defined below
14197
14025
  parameters.map ? getTexelDecodingFunction('mapTexelToLinear', parameters.mapEncoding) : '', parameters.matcap ? getTexelDecodingFunction('matcapTexelToLinear', parameters.matcapEncoding) : '', parameters.envMap ? getTexelDecodingFunction('envMapTexelToLinear', parameters.envMapEncoding) : '', parameters.emissiveMap ? getTexelDecodingFunction('emissiveMapTexelToLinear', parameters.emissiveMapEncoding) : '', parameters.specularColorMap ? getTexelDecodingFunction('specularColorMapTexelToLinear', parameters.specularColorMapEncoding) : '', parameters.sheenColorMap ? getTexelDecodingFunction('sheenColorMapTexelToLinear', parameters.sheenColorMapEncoding) : '', parameters.lightMap ? getTexelDecodingFunction('lightMapTexelToLinear', parameters.lightMapEncoding) : '', getTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\n'].filter(filterEmptyLine).join('\n');
14198
14026
  }
@@ -14210,7 +14038,7 @@
14210
14038
  // GLSL 3.0 conversion for built-in materials and ShaderMaterial
14211
14039
  versionString = '#version 300 es\n';
14212
14040
  prefixVertex = ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join('\n') + '\n' + prefixVertex;
14213
- prefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#define gl_FragColor pc_fragColor', '#define gl_FragDepthEXT gl_FragDepth', '#define texture2D texture', '#define textureCube texture', '#define texture2DProj textureProj', '#define texture2DLodEXT textureLod', '#define texture2DProjLodEXT textureProjLod', '#define textureCubeLodEXT textureLod', '#define texture2DGradEXT textureGrad', '#define texture2DProjGradEXT textureProjGrad', '#define textureCubeGradEXT textureGrad'].join('\n') + '\n' + prefixFragment;
14041
+ prefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#define gl_FragColor pc_fragColor', '#define gl_FragDepthEXT gl_FragDepth', '#define texture2D texture', '#define textureCube texture', '#define texture2DProj textureProj', '#define texture2DLodEXT textureLod', '#define texture2DProjLodEXT textureProjLod', '#define textureCubeLodEXT textureLod', '#define texture2DGradEXT textureGrad', '#define texture2DProjGradEXT textureProjGrad', '#define textureCubeGradEXT textureGrad'].join('\n') + '\n' + prefixFragment;
14214
14042
  }
14215
14043
 
14216
14044
  const vertexGlsl = versionString + prefixVertex + vertexShader;
@@ -14311,7 +14139,98 @@
14311
14139
  return this;
14312
14140
  }
14313
14141
 
14142
+ let _id = 0;
14143
+
14144
+ class WebGLShaderCache {
14145
+ constructor() {
14146
+ this.shaderCache = new Map();
14147
+ this.materialCache = new Map();
14148
+ }
14149
+
14150
+ update(material) {
14151
+ const vertexShader = material.vertexShader;
14152
+ const fragmentShader = material.fragmentShader;
14153
+
14154
+ const vertexShaderStage = this._getShaderStage(vertexShader);
14155
+
14156
+ const fragmentShaderStage = this._getShaderStage(fragmentShader);
14157
+
14158
+ const materialShaders = this._getShaderCacheForMaterial(material);
14159
+
14160
+ if (materialShaders.has(vertexShaderStage) === false) {
14161
+ materialShaders.add(vertexShaderStage);
14162
+ vertexShaderStage.usedTimes++;
14163
+ }
14164
+
14165
+ if (materialShaders.has(fragmentShaderStage) === false) {
14166
+ materialShaders.add(fragmentShaderStage);
14167
+ fragmentShaderStage.usedTimes++;
14168
+ }
14169
+
14170
+ return this;
14171
+ }
14172
+
14173
+ remove(material) {
14174
+ const materialShaders = this.materialCache.get(material);
14175
+
14176
+ for (const shaderStage of materialShaders) {
14177
+ shaderStage.usedTimes--;
14178
+ if (shaderStage.usedTimes === 0) this.shaderCache.delete(shaderStage);
14179
+ }
14180
+
14181
+ this.materialCache.delete(material);
14182
+ return this;
14183
+ }
14184
+
14185
+ getVertexShaderID(material) {
14186
+ return this._getShaderStage(material.vertexShader).id;
14187
+ }
14188
+
14189
+ getFragmentShaderID(material) {
14190
+ return this._getShaderStage(material.fragmentShader).id;
14191
+ }
14192
+
14193
+ dispose() {
14194
+ this.shaderCache.clear();
14195
+ this.materialCache.clear();
14196
+ }
14197
+
14198
+ _getShaderCacheForMaterial(material) {
14199
+ const cache = this.materialCache;
14200
+
14201
+ if (cache.has(material) === false) {
14202
+ cache.set(material, new Set());
14203
+ }
14204
+
14205
+ return cache.get(material);
14206
+ }
14207
+
14208
+ _getShaderStage(code) {
14209
+ const cache = this.shaderCache;
14210
+
14211
+ if (cache.has(code) === false) {
14212
+ const stage = new WebGLShaderStage();
14213
+ cache.set(code, stage);
14214
+ }
14215
+
14216
+ return cache.get(code);
14217
+ }
14218
+
14219
+ }
14220
+
14221
+ class WebGLShaderStage {
14222
+ constructor() {
14223
+ this.id = _id++;
14224
+ this.usedTimes = 0;
14225
+ }
14226
+
14227
+ }
14228
+
14314
14229
  function WebGLPrograms(renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping) {
14230
+ const _programLayers = new Layers();
14231
+
14232
+ const _customShaders = new WebGLShaderCache();
14233
+
14315
14234
  const programs = [];
14316
14235
  const isWebGL2 = capabilities.isWebGL2;
14317
14236
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
@@ -14336,7 +14255,6 @@
14336
14255
  ShadowMaterial: 'shadow',
14337
14256
  SpriteMaterial: 'sprite'
14338
14257
  };
14339
- const parameterNames = ['precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoat', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap',, 'roughnessMap', 'metalnessMap', 'gradientMap', 'alphaMap', 'alphaTest', 'combine', 'vertexColors', 'vertexAlphas', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'morphTargetsCount', 'premultipliedAlpha', 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'format', 'specularIntensityMap', 'specularColorMap', 'specularColorMapEncoding', 'transmission', 'transmissionMap', 'thicknessMap', 'sheen', 'sheenColorMap', 'sheenColorMapEncoding', 'sheenRoughnessMap'];
14340
14258
 
14341
14259
  function getMaxBones(object) {
14342
14260
  const skeleton = object.skeleton;
@@ -14375,10 +14293,10 @@
14375
14293
  } else {
14376
14294
  encoding = LinearEncoding;
14377
14295
  }
14378
- /* if ( isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding ) {
14379
- encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
14380
- } */
14381
14296
 
14297
+ if (isWebGL2 && map && map.isTexture && map.format === RGBAFormat && map.type === UnsignedByteType && map.encoding === sRGBEncoding) {
14298
+ encoding = LinearEncoding; // disable inline decode for sRGB textures in WebGL 2
14299
+ }
14382
14300
 
14383
14301
  return encoding;
14384
14302
  }
@@ -14401,6 +14319,7 @@
14401
14319
  }
14402
14320
 
14403
14321
  let vertexShader, fragmentShader;
14322
+ let customVertexShaderID, customFragmentShaderID;
14404
14323
 
14405
14324
  if (shaderID) {
14406
14325
  const shader = ShaderLib[shaderID];
@@ -14409,6 +14328,11 @@
14409
14328
  } else {
14410
14329
  vertexShader = material.vertexShader;
14411
14330
  fragmentShader = material.fragmentShader;
14331
+
14332
+ _customShaders.update(material);
14333
+
14334
+ customVertexShaderID = _customShaders.getVertexShaderID(material);
14335
+ customFragmentShaderID = _customShaders.getFragmentShaderID(material);
14412
14336
  }
14413
14337
 
14414
14338
  const currentRenderTarget = renderer.getRenderTarget();
@@ -14421,6 +14345,8 @@
14421
14345
  vertexShader: vertexShader,
14422
14346
  fragmentShader: fragmentShader,
14423
14347
  defines: material.defines,
14348
+ customVertexShaderID: customVertexShaderID,
14349
+ customFragmentShaderID: customFragmentShaderID,
14424
14350
  isRawShaderMaterial: material.isRawShaderMaterial === true,
14425
14351
  glslVersion: material.glslVersion,
14426
14352
  precision: precision,
@@ -14470,7 +14396,7 @@
14470
14396
  vertexTangents: !!material.normalMap && !!object.geometry && !!object.geometry.attributes.tangent,
14471
14397
  vertexColors: material.vertexColors,
14472
14398
  vertexAlphas: material.vertexColors === true && !!object.geometry && !!object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4,
14473
- 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,
14399
+ 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,
14474
14400
  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,
14475
14401
  fog: !!fog,
14476
14402
  useFog: material.fog,
@@ -14523,8 +14449,8 @@
14523
14449
  if (parameters.shaderID) {
14524
14450
  array.push(parameters.shaderID);
14525
14451
  } else {
14526
- array.push(hashString(parameters.fragmentShader));
14527
- array.push(hashString(parameters.vertexShader));
14452
+ array.push(parameters.customVertexShaderID);
14453
+ array.push(parameters.customFragmentShaderID);
14528
14454
  }
14529
14455
 
14530
14456
  if (parameters.defines !== undefined) {
@@ -14535,18 +14461,111 @@
14535
14461
  }
14536
14462
 
14537
14463
  if (parameters.isRawShaderMaterial === false) {
14538
- for (let i = 0; i < parameterNames.length; i++) {
14539
- array.push(parameters[parameterNames[i]]);
14540
- }
14541
-
14464
+ getProgramCacheKeyParameters(array, parameters);
14465
+ getProgramCacheKeyBooleans(array, parameters);
14542
14466
  array.push(renderer.outputEncoding);
14543
- array.push(renderer.gammaFactor);
14544
14467
  }
14545
14468
 
14546
14469
  array.push(parameters.customProgramCacheKey);
14547
14470
  return array.join();
14548
14471
  }
14549
14472
 
14473
+ function getProgramCacheKeyParameters(array, parameters) {
14474
+ array.push(parameters.precision);
14475
+ array.push(parameters.outputEncoding);
14476
+ array.push(parameters.mapEncoding);
14477
+ array.push(parameters.matcapEncoding);
14478
+ array.push(parameters.envMapMode);
14479
+ array.push(parameters.envMapEncoding);
14480
+ array.push(parameters.lightMapEncoding);
14481
+ array.push(parameters.emissiveMapEncoding);
14482
+ array.push(parameters.combine);
14483
+ array.push(parameters.vertexUvs);
14484
+ array.push(parameters.fogExp2);
14485
+ array.push(parameters.sizeAttenuation);
14486
+ array.push(parameters.maxBones);
14487
+ array.push(parameters.morphTargetsCount);
14488
+ array.push(parameters.numDirLights);
14489
+ array.push(parameters.numPointLights);
14490
+ array.push(parameters.numSpotLights);
14491
+ array.push(parameters.numHemiLights);
14492
+ array.push(parameters.numRectAreaLights);
14493
+ array.push(parameters.numDirLightShadows);
14494
+ array.push(parameters.numPointLightShadows);
14495
+ array.push(parameters.numSpotLightShadows);
14496
+ array.push(parameters.shadowMapType);
14497
+ array.push(parameters.toneMapping);
14498
+ array.push(parameters.numClippingPlanes);
14499
+ array.push(parameters.numClipIntersection);
14500
+ array.push(parameters.format);
14501
+ array.push(parameters.specularColorMapEncoding);
14502
+ array.push(parameters.sheenColorMapEncoding);
14503
+ }
14504
+
14505
+ function getProgramCacheKeyBooleans(array, parameters) {
14506
+ _programLayers.disableAll();
14507
+
14508
+ if (parameters.isWebGL2) _programLayers.enable(0);
14509
+ if (parameters.supportsVertexTextures) _programLayers.enable(1);
14510
+ if (parameters.instancing) _programLayers.enable(2);
14511
+ if (parameters.instancingColor) _programLayers.enable(3);
14512
+ if (parameters.map) _programLayers.enable(4);
14513
+ if (parameters.matcap) _programLayers.enable(5);
14514
+ if (parameters.envMap) _programLayers.enable(6);
14515
+ if (parameters.envMapCubeUV) _programLayers.enable(7);
14516
+ if (parameters.lightMap) _programLayers.enable(8);
14517
+ if (parameters.aoMap) _programLayers.enable(9);
14518
+ if (parameters.emissiveMap) _programLayers.enable(10);
14519
+ if (parameters.bumpMap) _programLayers.enable(11);
14520
+ if (parameters.normalMap) _programLayers.enable(12);
14521
+ if (parameters.objectSpaceNormalMap) _programLayers.enable(13);
14522
+ if (parameters.tangentSpaceNormalMap) _programLayers.enable(14);
14523
+ if (parameters.clearcoat) _programLayers.enable(15);
14524
+ if (parameters.clearcoatMap) _programLayers.enable(16);
14525
+ if (parameters.clearcoatRoughnessMap) _programLayers.enable(17);
14526
+ if (parameters.clearcoatNormalMap) _programLayers.enable(18);
14527
+ if (parameters.displacementMap) _programLayers.enable(19);
14528
+ if (parameters.specularMap) _programLayers.enable(20);
14529
+ if (parameters.roughnessMap) _programLayers.enable(21);
14530
+ if (parameters.metalnessMap) _programLayers.enable(22);
14531
+ if (parameters.gradientMap) _programLayers.enable(23);
14532
+ if (parameters.alphaMap) _programLayers.enable(24);
14533
+ if (parameters.alphaTest) _programLayers.enable(25);
14534
+ if (parameters.vertexColors) _programLayers.enable(26);
14535
+ if (parameters.vertexAlphas) _programLayers.enable(27);
14536
+ if (parameters.vertexUvs) _programLayers.enable(28);
14537
+ if (parameters.vertexTangents) _programLayers.enable(29);
14538
+ if (parameters.uvsVertexOnly) _programLayers.enable(30);
14539
+ if (parameters.fog) _programLayers.enable(31);
14540
+ array.push(_programLayers.mask);
14541
+
14542
+ _programLayers.disableAll();
14543
+
14544
+ if (parameters.useFog) _programLayers.enable(0);
14545
+ if (parameters.flatShading) _programLayers.enable(1);
14546
+ if (parameters.logarithmicDepthBuffer) _programLayers.enable(2);
14547
+ if (parameters.skinning) _programLayers.enable(3);
14548
+ if (parameters.useVertexTexture) _programLayers.enable(4);
14549
+ if (parameters.morphTargets) _programLayers.enable(5);
14550
+ if (parameters.morphNormals) _programLayers.enable(6);
14551
+ if (parameters.premultipliedAlpha) _programLayers.enable(7);
14552
+ if (parameters.shadowMapEnabled) _programLayers.enable(8);
14553
+ if (parameters.physicallyCorrectLights) _programLayers.enable(9);
14554
+ if (parameters.doubleSided) _programLayers.enable(10);
14555
+ if (parameters.flipSided) _programLayers.enable(11);
14556
+ if (parameters.depthPacking) _programLayers.enable(12);
14557
+ if (parameters.dithering) _programLayers.enable(13);
14558
+ if (parameters.specularIntensityMap) _programLayers.enable(14);
14559
+ if (parameters.specularColorMap) _programLayers.enable(15);
14560
+ if (parameters.transmission) _programLayers.enable(16);
14561
+ if (parameters.transmissionMap) _programLayers.enable(17);
14562
+ if (parameters.thicknessMap) _programLayers.enable(18);
14563
+ if (parameters.sheen) _programLayers.enable(19);
14564
+ if (parameters.sheenColorMap) _programLayers.enable(20);
14565
+ if (parameters.sheenRoughnessMap) _programLayers.enable(21);
14566
+ array.push(_programLayers.mask);
14567
+ }
14568
+
14550
14569
  function getUniforms(material) {
14551
14570
  const shaderID = shaderIDs[material.type];
14552
14571
  let uniforms;
@@ -14593,14 +14612,24 @@
14593
14612
  }
14594
14613
  }
14595
14614
 
14615
+ function releaseShaderCache(material) {
14616
+ _customShaders.remove(material);
14617
+ }
14618
+
14619
+ function dispose() {
14620
+ _customShaders.dispose();
14621
+ }
14622
+
14596
14623
  return {
14597
14624
  getParameters: getParameters,
14598
14625
  getProgramCacheKey: getProgramCacheKey,
14599
14626
  getUniforms: getUniforms,
14600
14627
  acquireProgram: acquireProgram,
14601
14628
  releaseProgram: releaseProgram,
14629
+ releaseShaderCache: releaseShaderCache,
14602
14630
  // Exposed for resource monitoring & error feedback via renderer.info:
14603
- programs: programs
14631
+ programs: programs,
14632
+ dispose: dispose
14604
14633
  };
14605
14634
  }
14606
14635
 
@@ -14643,8 +14672,6 @@
14643
14672
  return a.groupOrder - b.groupOrder;
14644
14673
  } else if (a.renderOrder !== b.renderOrder) {
14645
14674
  return a.renderOrder - b.renderOrder;
14646
- } else if (a.program !== b.program) {
14647
- return a.program.id - b.program.id;
14648
14675
  } else if (a.material.id !== b.material.id) {
14649
14676
  return a.material.id - b.material.id;
14650
14677
  } else if (a.z !== b.z) {
@@ -14666,15 +14693,12 @@
14666
14693
  }
14667
14694
  }
14668
14695
 
14669
- function WebGLRenderList(properties) {
14696
+ function WebGLRenderList() {
14670
14697
  const renderItems = [];
14671
14698
  let renderItemsIndex = 0;
14672
14699
  const opaque = [];
14673
14700
  const transmissive = [];
14674
14701
  const transparent = [];
14675
- const defaultProgram = {
14676
- id: -1
14677
- };
14678
14702
 
14679
14703
  function init() {
14680
14704
  renderItemsIndex = 0;
@@ -14685,7 +14709,6 @@
14685
14709
 
14686
14710
  function getNextRenderItem(object, geometry, material, groupOrder, z, group) {
14687
14711
  let renderItem = renderItems[renderItemsIndex];
14688
- const materialProperties = properties.get(material);
14689
14712
 
14690
14713
  if (renderItem === undefined) {
14691
14714
  renderItem = {
@@ -14693,7 +14716,6 @@
14693
14716
  object: object,
14694
14717
  geometry: geometry,
14695
14718
  material: material,
14696
- program: materialProperties.program || defaultProgram,
14697
14719
  groupOrder: groupOrder,
14698
14720
  renderOrder: object.renderOrder,
14699
14721
  z: z,
@@ -14705,7 +14727,6 @@
14705
14727
  renderItem.object = object;
14706
14728
  renderItem.geometry = geometry;
14707
14729
  renderItem.material = material;
14708
- renderItem.program = materialProperties.program || defaultProgram;
14709
14730
  renderItem.groupOrder = groupOrder;
14710
14731
  renderItem.renderOrder = object.renderOrder;
14711
14732
  renderItem.z = z;
@@ -14755,7 +14776,6 @@
14755
14776
  renderItem.object = null;
14756
14777
  renderItem.geometry = null;
14757
14778
  renderItem.material = null;
14758
- renderItem.program = null;
14759
14779
  renderItem.group = null;
14760
14780
  }
14761
14781
  }
@@ -14772,18 +14792,18 @@
14772
14792
  };
14773
14793
  }
14774
14794
 
14775
- function WebGLRenderLists(properties) {
14795
+ function WebGLRenderLists() {
14776
14796
  let lists = new WeakMap();
14777
14797
 
14778
14798
  function get(scene, renderCallDepth) {
14779
14799
  let list;
14780
14800
 
14781
14801
  if (lists.has(scene) === false) {
14782
- list = new WebGLRenderList(properties);
14802
+ list = new WebGLRenderList();
14783
14803
  lists.set(scene, [list]);
14784
14804
  } else {
14785
14805
  if (renderCallDepth >= lists.get(scene).length) {
14786
- list = new WebGLRenderList(properties);
14806
+ list = new WebGLRenderList();
14787
14807
  lists.get(scene).push(list);
14788
14808
  } else {
14789
14809
  list = lists.get(scene)[renderCallDepth];
@@ -16244,6 +16264,22 @@
16244
16264
  }
16245
16265
  }
16246
16266
 
16267
+ function texSubImage3D() {
16268
+ try {
16269
+ gl.texSubImage3D.apply(gl, arguments);
16270
+ } catch (error) {
16271
+ console.error('THREE.WebGLState:', error);
16272
+ }
16273
+ }
16274
+
16275
+ function compressedTexSubImage2D() {
16276
+ try {
16277
+ gl.compressedTexSubImage2D.apply(gl, arguments);
16278
+ } catch (error) {
16279
+ console.error('THREE.WebGLState:', error);
16280
+ }
16281
+ }
16282
+
16247
16283
  function texStorage2D() {
16248
16284
  try {
16249
16285
  gl.texStorage2D.apply(gl, arguments);
@@ -16252,6 +16288,14 @@
16252
16288
  }
16253
16289
  }
16254
16290
 
16291
+ function texStorage3D() {
16292
+ try {
16293
+ gl.texStorage3D.apply(gl, arguments);
16294
+ } catch (error) {
16295
+ console.error('THREE.WebGLState:', error);
16296
+ }
16297
+ }
16298
+
16255
16299
  function texImage2D() {
16256
16300
  try {
16257
16301
  gl.texImage2D.apply(gl, arguments);
@@ -16371,7 +16415,10 @@
16371
16415
  texImage2D: texImage2D,
16372
16416
  texImage3D: texImage3D,
16373
16417
  texStorage2D: texStorage2D,
16418
+ texStorage3D: texStorage3D,
16374
16419
  texSubImage2D: texSubImage2D,
16420
+ texSubImage3D: texSubImage3D,
16421
+ compressedTexSubImage2D: compressedTexSubImage2D,
16375
16422
  scissor: scissor,
16376
16423
  viewport: viewport,
16377
16424
  reset: reset
@@ -16458,9 +16505,7 @@
16458
16505
  _gl.generateMipmap(target);
16459
16506
  }
16460
16507
 
16461
- function getInternalFormat(internalFormatName, glFormat, glType
16462
- /*, encoding*/
16463
- ) {
16508
+ function getInternalFormat(internalFormatName, glFormat, glType, encoding) {
16464
16509
  if (isWebGL2 === false) return glFormat;
16465
16510
 
16466
16511
  if (internalFormatName !== null) {
@@ -16484,9 +16529,8 @@
16484
16529
 
16485
16530
  if (glFormat === _gl.RGBA) {
16486
16531
  if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
16487
- if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F; //if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = ( encoding === sRGBEncoding ) ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
16488
-
16489
- if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RGBA8;
16532
+ if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
16533
+ if (glType === _gl.UNSIGNED_BYTE) internalFormat = encoding === sRGBEncoding ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
16490
16534
  }
16491
16535
 
16492
16536
  if (internalFormat === _gl.R16F || internalFormat === _gl.R32F || internalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F) {
@@ -16497,12 +16541,13 @@
16497
16541
  }
16498
16542
 
16499
16543
  function getMipLevels(texture, image, supportsMips) {
16500
- if (textureNeedsGenerateMipmaps(texture, supportsMips) === true) {
16501
- // generated mipmaps via gl.generateMipmap()
16544
+ if (textureNeedsGenerateMipmaps(texture, supportsMips) === true || texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) {
16502
16545
  return Math.log2(Math.max(image.width, image.height)) + 1;
16503
- } else if (texture.mipmaps.length > 0) {
16546
+ } else if (texture.mipmaps !== undefined && texture.mipmaps.length > 0) {
16504
16547
  // user-defined mipmaps
16505
16548
  return texture.mipmaps.length;
16549
+ } else if (texture.isCompressedTexture && Array.isArray(texture.image)) {
16550
+ return image.mipmaps.length;
16506
16551
  } else {
16507
16552
  // texture without mipmaps (only base level)
16508
16553
  return 1;
@@ -16769,6 +16814,9 @@
16769
16814
  setTextureParameters(textureType, texture, supportsMips);
16770
16815
  let mipmap;
16771
16816
  const mipmaps = texture.mipmaps;
16817
+ const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
16818
+ const allocateMemory = textureProperties.__version === undefined;
16819
+ const levels = getMipLevels(texture, image, supportsMips);
16772
16820
 
16773
16821
  if (texture.isDepthTexture) {
16774
16822
  // populate depth texture with dummy data
@@ -16817,48 +16865,99 @@
16817
16865
  } //
16818
16866
 
16819
16867
 
16820
- state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
16868
+ if (useTexStorage && allocateMemory) {
16869
+ state.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height);
16870
+ } else {
16871
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
16872
+ }
16821
16873
  } else if (texture.isDataTexture) {
16822
16874
  // use manually created mipmaps if available
16823
16875
  // if there are no manual mipmaps
16824
16876
  // set 0 level mipmap and then use GL to generate other mipmap levels
16825
16877
  if (mipmaps.length > 0 && supportsMips) {
16878
+ if (useTexStorage && allocateMemory) {
16879
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
16880
+ }
16881
+
16826
16882
  for (let i = 0, il = mipmaps.length; i < il; i++) {
16827
16883
  mipmap = mipmaps[i];
16828
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16884
+
16885
+ if (useTexStorage) {
16886
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
16887
+ } else {
16888
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16889
+ }
16829
16890
  }
16830
16891
 
16831
16892
  texture.generateMipmaps = false;
16832
16893
  } else {
16833
- state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
16894
+ if (useTexStorage) {
16895
+ if (allocateMemory) {
16896
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
16897
+ }
16898
+
16899
+ state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data);
16900
+ } else {
16901
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);
16902
+ }
16834
16903
  }
16835
16904
  } else if (texture.isCompressedTexture) {
16905
+ if (useTexStorage && allocateMemory) {
16906
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
16907
+ }
16908
+
16836
16909
  for (let i = 0, il = mipmaps.length; i < il; i++) {
16837
16910
  mipmap = mipmaps[i];
16838
16911
 
16839
16912
  if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
16840
16913
  if (glFormat !== null) {
16841
- state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
16914
+ if (useTexStorage) {
16915
+ state.compressedTexSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
16916
+ } else {
16917
+ state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
16918
+ }
16842
16919
  } else {
16843
16920
  console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
16844
16921
  }
16845
16922
  } else {
16846
- state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16923
+ if (useTexStorage) {
16924
+ state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
16925
+ } else {
16926
+ state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
16927
+ }
16847
16928
  }
16848
16929
  }
16849
16930
  } else if (texture.isDataTexture2DArray) {
16850
- state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16931
+ if (useTexStorage) {
16932
+ if (allocateMemory) {
16933
+ state.texStorage3D(_gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth);
16934
+ }
16935
+
16936
+ state.texSubImage3D(_gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);
16937
+ } else {
16938
+ state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16939
+ }
16851
16940
  } else if (texture.isDataTexture3D) {
16852
- state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16941
+ if (useTexStorage) {
16942
+ if (allocateMemory) {
16943
+ state.texStorage3D(_gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth);
16944
+ }
16945
+
16946
+ state.texSubImage3D(_gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data);
16947
+ } else {
16948
+ state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);
16949
+ }
16950
+ } else if (texture.isFramebufferTexture) {
16951
+ if (useTexStorage && allocateMemory) {
16952
+ state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height);
16953
+ } else {
16954
+ state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);
16955
+ }
16853
16956
  } else {
16854
16957
  // regular Texture (image, video, canvas)
16855
16958
  // use manually created mipmaps if available
16856
16959
  // if there are no manual mipmaps
16857
16960
  // set 0 level mipmap and then use GL to generate other mipmap levels
16858
- const levels = getMipLevels(texture, image, supportsMips);
16859
- const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
16860
- const allocateMemory = textureProperties.__version === undefined;
16861
-
16862
16961
  if (mipmaps.length > 0 && supportsMips) {
16863
16962
  if (useTexStorage && allocateMemory) {
16864
16963
  state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height);
@@ -16927,10 +17026,17 @@
16927
17026
  glFormat = utils.convert(texture.format),
16928
17027
  glType = utils.convert(texture.type),
16929
17028
  glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding);
17029
+ const useTexStorage = isWebGL2 && texture.isVideoTexture !== true;
17030
+ const allocateMemory = textureProperties.__version === undefined;
17031
+ let levels = getMipLevels(texture, image, supportsMips);
16930
17032
  setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips);
16931
17033
  let mipmaps;
16932
17034
 
16933
17035
  if (isCompressed) {
17036
+ if (useTexStorage && allocateMemory) {
17037
+ state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, image.width, image.height);
17038
+ }
17039
+
16934
17040
  for (let i = 0; i < 6; i++) {
16935
17041
  mipmaps = cubeImage[i].mipmaps;
16936
17042
 
@@ -16939,33 +17045,67 @@
16939
17045
 
16940
17046
  if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
16941
17047
  if (glFormat !== null) {
16942
- state.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
17048
+ if (useTexStorage) {
17049
+ state.compressedTexSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data);
17050
+ } else {
17051
+ state.compressedTexImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
17052
+ }
16943
17053
  } else {
16944
17054
  console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');
16945
17055
  }
16946
17056
  } else {
16947
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
17057
+ if (useTexStorage) {
17058
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data);
17059
+ } else {
17060
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
17061
+ }
16948
17062
  }
16949
17063
  }
16950
17064
  }
16951
17065
  } else {
16952
17066
  mipmaps = texture.mipmaps;
16953
17067
 
17068
+ if (useTexStorage && allocateMemory) {
17069
+ // TODO: Uniformly handle mipmap definitions
17070
+ // Normal textures and compressed cube textures define base level + mips with their mipmap array
17071
+ // Uncompressed cube textures use their mipmap array only for mips (no base level)
17072
+ if (mipmaps.length > 0) levels++;
17073
+ state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[0].width, cubeImage[0].height);
17074
+ }
17075
+
16954
17076
  for (let i = 0; i < 6; i++) {
16955
17077
  if (isDataTexture) {
16956
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);
17078
+ if (useTexStorage) {
17079
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, cubeImage[i].width, cubeImage[i].height, glFormat, glType, cubeImage[i].data);
17080
+ } else {
17081
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[i].width, cubeImage[i].height, 0, glFormat, glType, cubeImage[i].data);
17082
+ }
16957
17083
 
16958
17084
  for (let j = 0; j < mipmaps.length; j++) {
16959
17085
  const mipmap = mipmaps[j];
16960
17086
  const mipmapImage = mipmap.image[i].image;
16961
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
17087
+
17088
+ if (useTexStorage) {
17089
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, mipmapImage.width, mipmapImage.height, glFormat, glType, mipmapImage.data);
17090
+ } else {
17091
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
17092
+ }
16962
17093
  }
16963
17094
  } else {
16964
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]);
17095
+ if (useTexStorage) {
17096
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[i]);
17097
+ } else {
17098
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]);
17099
+ }
16965
17100
 
16966
17101
  for (let j = 0; j < mipmaps.length; j++) {
16967
17102
  const mipmap = mipmaps[j];
16968
- state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]);
17103
+
17104
+ if (useTexStorage) {
17105
+ state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[i]);
17106
+ } else {
17107
+ state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]);
17108
+ }
16969
17109
  }
16970
17110
  }
16971
17111
  }
@@ -18340,7 +18480,11 @@
18340
18480
  session.updateRenderState({
18341
18481
  baseLayer: glBaseLayer
18342
18482
  });
18343
- newRenderTarget = new WebGLRenderTarget(glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight);
18483
+ newRenderTarget = new WebGLRenderTarget(glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, {
18484
+ format: RGBAFormat,
18485
+ type: UnsignedByteType,
18486
+ encoding: renderer.outputEncoding
18487
+ });
18344
18488
  } else {
18345
18489
  isMultisample = attributes.antialias;
18346
18490
  let depthFormat = null;
@@ -18348,7 +18492,7 @@
18348
18492
  let glDepthFormat = null;
18349
18493
 
18350
18494
  if (attributes.depth) {
18351
- glDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT16;
18495
+ glDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
18352
18496
  depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat;
18353
18497
  depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType;
18354
18498
  }
@@ -18371,7 +18515,8 @@
18371
18515
  depthTexture: new DepthTexture(glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat),
18372
18516
  stencilBuffer: attributes.stencil,
18373
18517
  ignoreDepth: glProjLayer.ignoreDepthValues,
18374
- useRenderToTexture: hasMultisampledRenderToTexture
18518
+ useRenderToTexture: hasMultisampledRenderToTexture,
18519
+ encoding: renderer.outputEncoding
18375
18520
  });
18376
18521
  } else {
18377
18522
  newRenderTarget = new WebGLRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, {
@@ -18379,13 +18524,14 @@
18379
18524
  type: UnsignedByteType,
18380
18525
  depthTexture: new DepthTexture(glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat),
18381
18526
  stencilBuffer: attributes.stencil,
18382
- ignoreDepth: glProjLayer.ignoreDepthValues
18527
+ ignoreDepth: glProjLayer.ignoreDepthValues,
18528
+ encoding: renderer.outputEncoding
18383
18529
  });
18384
18530
  }
18385
18531
  } // Set foveation to maximum.
18386
18532
 
18387
18533
 
18388
- this.setFoveation(0);
18534
+ this.setFoveation(1.0);
18389
18535
  referenceSpace = await session.requestReferenceSpace(referenceSpaceType);
18390
18536
  animation.setContext(session);
18391
18537
  animation.start();
@@ -19250,8 +19396,6 @@
19250
19396
  this.clippingPlanes = [];
19251
19397
  this.localClippingEnabled = false; // physically based shading
19252
19398
 
19253
- this.gammaFactor = 2.0; // for backwards compatibility
19254
-
19255
19399
  this.outputEncoding = LinearEncoding; // physical lights
19256
19400
 
19257
19401
  this.physicallyCorrectLights = false; // tone mapping
@@ -19407,7 +19551,7 @@
19407
19551
  clipping = new WebGLClipping(properties);
19408
19552
  programCache = new WebGLPrograms(_this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping);
19409
19553
  materials = new WebGLMaterials(properties);
19410
- renderLists = new WebGLRenderLists(properties);
19554
+ renderLists = new WebGLRenderLists();
19411
19555
  renderStates = new WebGLRenderStates(extensions, capabilities);
19412
19556
  background = new WebGLBackground(_this, cubemaps, state, objects, _premultipliedAlpha);
19413
19557
  shadowMap = new WebGLShadowMap(_this, objects, capabilities);
@@ -19590,6 +19734,7 @@
19590
19734
  cubeuvmaps.dispose();
19591
19735
  objects.dispose();
19592
19736
  bindingStates.dispose();
19737
+ programCache.dispose();
19593
19738
  xr.dispose();
19594
19739
  xr.removeEventListener('sessionstart', onXRSessionStart);
19595
19740
  xr.removeEventListener('sessionend', onXRSessionEnd);
@@ -19645,6 +19790,10 @@
19645
19790
  programs.forEach(function (program) {
19646
19791
  programCache.releaseProgram(program);
19647
19792
  });
19793
+
19794
+ if (material.isShaderMaterial) {
19795
+ programCache.releaseShaderCache(material);
19796
+ }
19648
19797
  }
19649
19798
  } // Buffer rendering
19650
19799
 
@@ -20141,6 +20290,7 @@
20141
20290
  materialProperties.numIntersection = parameters.numClipIntersection;
20142
20291
  materialProperties.vertexAlphas = parameters.vertexAlphas;
20143
20292
  materialProperties.vertexTangents = parameters.vertexTangents;
20293
+ materialProperties.toneMapping = parameters.toneMapping;
20144
20294
  }
20145
20295
 
20146
20296
  function setProgram(camera, scene, geometry, material, object) {
@@ -20156,6 +20306,7 @@
20156
20306
  const morphTargets = !!geometry.morphAttributes.position;
20157
20307
  const morphNormals = !!geometry.morphAttributes.normal;
20158
20308
  const morphTargetsCount = !!geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0;
20309
+ const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
20159
20310
  const materialProperties = properties.get(material);
20160
20311
  const lights = currentRenderState.state.lights;
20161
20312
 
@@ -20199,6 +20350,8 @@
20199
20350
  needsProgramChange = true;
20200
20351
  } else if (materialProperties.morphNormals !== morphNormals) {
20201
20352
  needsProgramChange = true;
20353
+ } else if (materialProperties.toneMapping !== toneMapping) {
20354
+ needsProgramChange = true;
20202
20355
  } else if (capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount) {
20203
20356
  needsProgramChange = true;
20204
20357
  }
@@ -20574,21 +20727,17 @@
20574
20727
  };
20575
20728
 
20576
20729
  this.copyFramebufferToTexture = function (position, texture, level = 0) {
20730
+ if (texture.isFramebufferTexture !== true) {
20731
+ console.error('THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.');
20732
+ return;
20733
+ }
20734
+
20577
20735
  const levelScale = Math.pow(2, -level);
20578
20736
  const width = Math.floor(texture.image.width * levelScale);
20579
20737
  const height = Math.floor(texture.image.height * levelScale);
20580
- let glFormat = utils.convert(texture.format);
20581
-
20582
- if (capabilities.isWebGL2) {
20583
- // Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=1120100
20584
- // Not needed in Chrome 93+
20585
- if (glFormat === _gl.RGB) glFormat = _gl.RGB8;
20586
- if (glFormat === _gl.RGBA) glFormat = _gl.RGBA8;
20587
- }
20588
-
20589
20738
  textures.setTexture2D(texture, 0);
20590
20739
 
20591
- _gl.copyTexImage2D(_gl.TEXTURE_2D, level, glFormat, position.x, position.y, width, height, 0);
20740
+ _gl.copyTexSubImage2D(_gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height);
20592
20741
 
20593
20742
  state.unbindTexture();
20594
20743
  };
@@ -20717,8 +20866,7 @@
20717
20866
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
20718
20867
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
20719
20868
  detail: this
20720
- })); // eslint-disable-line no-undef
20721
-
20869
+ }));
20722
20870
  }
20723
20871
  }
20724
20872
 
@@ -20789,8 +20937,7 @@
20789
20937
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
20790
20938
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {
20791
20939
  detail: this
20792
- })); // eslint-disable-line no-undef
20793
-
20940
+ }));
20794
20941
  }
20795
20942
  }
20796
20943
 
@@ -21555,7 +21702,6 @@
21555
21702
  this.generateMipmaps = false;
21556
21703
  this.flipY = false;
21557
21704
  this.unpackAlignment = 1;
21558
- this.needsUpdate = true;
21559
21705
  }
21560
21706
 
21561
21707
  }
@@ -21679,6 +21825,7 @@
21679
21825
  boneMatrices.set(this.boneMatrices); // copy current values
21680
21826
 
21681
21827
  const boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType);
21828
+ boneTexture.needsUpdate = true;
21682
21829
  this.boneMatrices = boneMatrices;
21683
21830
  this.boneTexture = boneTexture;
21684
21831
  this.boneTextureSize = size;
@@ -22343,6 +22490,23 @@
22343
22490
 
22344
22491
  VideoTexture.prototype.isVideoTexture = true;
22345
22492
 
22493
+ class FramebufferTexture extends Texture {
22494
+ constructor(width, height, format) {
22495
+ super({
22496
+ width,
22497
+ height
22498
+ });
22499
+ this.format = format;
22500
+ this.magFilter = NearestFilter;
22501
+ this.minFilter = NearestFilter;
22502
+ this.generateMipmaps = false;
22503
+ this.needsUpdate = true;
22504
+ }
22505
+
22506
+ }
22507
+
22508
+ FramebufferTexture.prototype.isFramebufferTexture = true;
22509
+
22346
22510
  class CompressedTexture extends Texture {
22347
22511
  constructor(mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {
22348
22512
  super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
@@ -23541,7 +23705,7 @@
23541
23705
 
23542
23706
  /**
23543
23707
  * Bezier Curves formulas obtained from
23544
- * http://en.wikipedia.org/wiki/Bézier_curve
23708
+ * https://en.wikipedia.org/wiki/B%C3%A9zier_curve
23545
23709
  */
23546
23710
  function CatmullRom(t, p0, p1, p2, p3) {
23547
23711
  const v0 = (p2 - p0) * 0.5;
@@ -25526,11 +25690,55 @@
25526
25690
 
25527
25691
  const indices = [];
25528
25692
  const vertices = [];
25529
- const uvs = []; // helper variables
25693
+ const uvs = [];
25694
+ const initNormals = [];
25695
+ const normals = []; // helper variables
25530
25696
 
25531
25697
  const inverseSegments = 1.0 / segments;
25532
25698
  const vertex = new Vector3();
25533
- const uv = new Vector2(); // generate vertices and uvs
25699
+ const uv = new Vector2();
25700
+ const normal = new Vector3();
25701
+ const curNormal = new Vector3();
25702
+ const prevNormal = new Vector3();
25703
+ let dx = 0;
25704
+ let dy = 0; // pre-compute normals for initial "meridian"
25705
+
25706
+ for (let j = 0; j <= points.length - 1; j++) {
25707
+ switch (j) {
25708
+ case 0:
25709
+ // special handling for 1st vertex on path
25710
+ dx = points[j + 1].x - points[j].x;
25711
+ dy = points[j + 1].y - points[j].y;
25712
+ normal.x = dy * 1.0;
25713
+ normal.y = -dx;
25714
+ normal.z = dy * 0.0;
25715
+ prevNormal.copy(normal);
25716
+ normal.normalize();
25717
+ initNormals.push(normal.x, normal.y, normal.z);
25718
+ break;
25719
+
25720
+ case points.length - 1:
25721
+ // special handling for last Vertex on path
25722
+ initNormals.push(prevNormal.x, prevNormal.y, prevNormal.z);
25723
+ break;
25724
+
25725
+ default:
25726
+ // default handling for all vertices in between
25727
+ dx = points[j + 1].x - points[j].x;
25728
+ dy = points[j + 1].y - points[j].y;
25729
+ normal.x = dy * 1.0;
25730
+ normal.y = -dx;
25731
+ normal.z = dy * 0.0;
25732
+ curNormal.copy(normal);
25733
+ normal.x += prevNormal.x;
25734
+ normal.y += prevNormal.y;
25735
+ normal.z += prevNormal.z;
25736
+ normal.normalize();
25737
+ initNormals.push(normal.x, normal.y, normal.z);
25738
+ prevNormal.copy(curNormal);
25739
+ }
25740
+ } // generate vertices, uvs and normals
25741
+
25534
25742
 
25535
25743
  for (let i = 0; i <= segments; i++) {
25536
25744
  const phi = phiStart + i * inverseSegments * phiLength;
@@ -25546,7 +25754,12 @@
25546
25754
 
25547
25755
  uv.x = i / segments;
25548
25756
  uv.y = j / (points.length - 1);
25549
- uvs.push(uv.x, uv.y);
25757
+ uvs.push(uv.x, uv.y); // normal
25758
+
25759
+ const x = initNormals[3 * j + 0] * sin;
25760
+ const y = initNormals[3 * j + 1];
25761
+ const z = initNormals[3 * j + 0] * cos;
25762
+ normals.push(x, y, z);
25550
25763
  }
25551
25764
  } // indices
25552
25765
 
@@ -25567,36 +25780,8 @@
25567
25780
 
25568
25781
  this.setIndex(indices);
25569
25782
  this.setAttribute('position', new Float32BufferAttribute(vertices, 3));
25570
- this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // generate normals
25571
-
25572
- this.computeVertexNormals(); // if the geometry is closed, we need to average the normals along the seam.
25573
- // because the corresponding vertices are identical (but still have different UVs).
25574
-
25575
- if (phiLength === Math.PI * 2) {
25576
- const normals = this.attributes.normal.array;
25577
- const n1 = new Vector3();
25578
- const n2 = new Vector3();
25579
- const n = new Vector3(); // this is the buffer offset for the last line of vertices
25580
-
25581
- const base = segments * points.length * 3;
25582
-
25583
- for (let i = 0, j = 0; i < points.length; i++, j += 3) {
25584
- // select the normal of the vertex in the first line
25585
- n1.x = normals[j + 0];
25586
- n1.y = normals[j + 1];
25587
- n1.z = normals[j + 2]; // select the normal of the vertex in the last line
25588
-
25589
- n2.x = normals[base + j + 0];
25590
- n2.y = normals[base + j + 1];
25591
- n2.z = normals[base + j + 2]; // average normals
25592
-
25593
- n.addVectors(n1, n2).normalize(); // assign the new values to both normals
25594
-
25595
- normals[j + 0] = normals[base + j + 0] = n.x;
25596
- normals[j + 1] = normals[base + j + 1] = n.y;
25597
- normals[j + 2] = normals[base + j + 2] = n.z;
25598
- }
25599
- }
25783
+ this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));
25784
+ this.setAttribute('normal', new Float32BufferAttribute(normals, 3));
25600
25785
  }
25601
25786
 
25602
25787
  static fromJSON(data) {
@@ -28622,6 +28807,10 @@
28622
28807
  console.warn('THREE.FileLoader: HTTP Status 0 received.');
28623
28808
  }
28624
28809
 
28810
+ if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) {
28811
+ return response;
28812
+ }
28813
+
28625
28814
  const callbacks = loading[url];
28626
28815
  const reader = response.body.getReader();
28627
28816
  const contentLength = response.headers.get('Content-Length');
@@ -28629,7 +28818,7 @@
28629
28818
  const lengthComputable = total !== 0;
28630
28819
  let loaded = 0; // periodically read data into the new stream tracking while download progress
28631
28820
 
28632
- return new ReadableStream({
28821
+ const stream = new ReadableStream({
28633
28822
  start(controller) {
28634
28823
  readData();
28635
28824
 
@@ -28661,12 +28850,11 @@
28661
28850
  }
28662
28851
 
28663
28852
  });
28853
+ return new Response(stream);
28664
28854
  } else {
28665
28855
  throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`);
28666
28856
  }
28667
- }).then(stream => {
28668
- const response = new Response(stream);
28669
-
28857
+ }).then(response => {
28670
28858
  switch (this.responseType) {
28671
28859
  case 'arraybuffer':
28672
28860
  return response.arrayBuffer();
@@ -28697,11 +28885,16 @@
28697
28885
  const callback = callbacks[i];
28698
28886
  if (callback.onLoad) callback.onLoad(data);
28699
28887
  }
28700
-
28701
- this.manager.itemEnd(url);
28702
28888
  }).catch(err => {
28703
28889
  // Abort errors and other errors are handled the same
28704
28890
  const callbacks = loading[url];
28891
+
28892
+ if (callbacks === undefined) {
28893
+ // When onLoad was called and url was deleted in `loading`
28894
+ this.manager.itemError(url);
28895
+ throw err;
28896
+ }
28897
+
28705
28898
  delete loading[url];
28706
28899
 
28707
28900
  for (let i = 0, il = callbacks.length; i < il; i++) {
@@ -28710,6 +28903,7 @@
28710
28903
  }
28711
28904
 
28712
28905
  this.manager.itemError(url);
28906
+ }).finally(() => {
28713
28907
  this.manager.itemEnd(url);
28714
28908
  });
28715
28909
  this.manager.itemStart(url);
@@ -34479,7 +34673,7 @@
34479
34673
  * - shows frustum, line of sight and up of the camera
34480
34674
  * - suitable for fast updates
34481
34675
  * - based on frustum visualization in lightgl.js shadowmap example
34482
- * http://evanw.github.com/lightgl.js/tests/shadowmap.html
34676
+ * https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html
34483
34677
  */
34484
34678
 
34485
34679
 
@@ -36181,6 +36375,15 @@
36181
36375
  set: function () {
36182
36376
  console.warn('THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.');
36183
36377
  }
36378
+ },
36379
+ gammaFactor: {
36380
+ get: function () {
36381
+ console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');
36382
+ return 2;
36383
+ },
36384
+ set: function () {
36385
+ console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.');
36386
+ }
36184
36387
  }
36185
36388
  });
36186
36389
  Object.defineProperties(WebGLShadowMap.prototype, {
@@ -36418,14 +36621,11 @@
36418
36621
  }
36419
36622
 
36420
36623
  if (typeof __THREE_DEVTOOLS__ !== 'undefined') {
36421
- /* eslint-disable no-undef */
36422
36624
  __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', {
36423
36625
  detail: {
36424
36626
  revision: REVISION
36425
36627
  }
36426
36628
  }));
36427
- /* eslint-enable no-undef */
36428
-
36429
36629
  }
36430
36630
 
36431
36631
  if (typeof window !== 'undefined') {
@@ -36563,12 +36763,12 @@
36563
36763
  exports.FogExp2 = FogExp2;
36564
36764
  exports.Font = Font;
36565
36765
  exports.FontLoader = FontLoader;
36766
+ exports.FramebufferTexture = FramebufferTexture;
36566
36767
  exports.FrontSide = FrontSide;
36567
36768
  exports.Frustum = Frustum;
36568
36769
  exports.GLBufferAttribute = GLBufferAttribute;
36569
36770
  exports.GLSL1 = GLSL1;
36570
36771
  exports.GLSL3 = GLSL3;
36571
- exports.GammaEncoding = GammaEncoding;
36572
36772
  exports.GreaterDepth = GreaterDepth;
36573
36773
  exports.GreaterEqualDepth = GreaterEqualDepth;
36574
36774
  exports.GreaterEqualStencilFunc = GreaterEqualStencilFunc;
@@ -36753,13 +36953,8 @@
36753
36953
  exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;
36754
36954
  exports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;
36755
36955
  exports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;
36756
- exports.RGBDEncoding = RGBDEncoding;
36757
- exports.RGBEEncoding = RGBEEncoding;
36758
- exports.RGBEFormat = RGBEFormat;
36759
36956
  exports.RGBFormat = RGBFormat;
36760
36957
  exports.RGBIntegerFormat = RGBIntegerFormat;
36761
- exports.RGBM16Encoding = RGBM16Encoding;
36762
- exports.RGBM7Encoding = RGBM7Encoding;
36763
36958
  exports.RGB_ETC1_Format = RGB_ETC1_Format;
36764
36959
  exports.RGB_ETC2_Format = RGB_ETC2_Format;
36765
36960
  exports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;