super-three 0.162.0 → 0.164.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 (187) hide show
  1. package/build/three.cjs +847 -1226
  2. package/build/three.module.js +846 -1225
  3. package/build/three.module.min.js +2 -2
  4. package/examples/jsm/animation/CCDIKSolver.js +4 -2
  5. package/examples/jsm/controls/TransformControls.js +3 -3
  6. package/examples/jsm/exporters/GLTFExporter.js +66 -5
  7. package/examples/jsm/exporters/USDZExporter.js +22 -1
  8. package/examples/jsm/geometries/TextGeometry.js +10 -2
  9. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  10. package/examples/jsm/libs/draco/README.md +2 -2
  11. package/examples/jsm/libs/fflate.module.js +694 -496
  12. package/examples/jsm/lines/LineMaterial.js +0 -2
  13. package/examples/jsm/loaders/3MFLoader.js +2 -0
  14. package/examples/jsm/loaders/EXRLoader.js +351 -97
  15. package/examples/jsm/loaders/FBXLoader.js +1 -1
  16. package/examples/jsm/loaders/GLTFLoader.js +59 -0
  17. package/examples/jsm/loaders/KTX2Loader.js +3 -10
  18. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  19. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  20. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  21. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  22. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  23. package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
  24. package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
  25. package/examples/jsm/math/Octree.js +26 -20
  26. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  27. package/examples/jsm/nodes/Nodes.js +10 -4
  28. package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
  29. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  30. package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
  31. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  32. package/examples/jsm/nodes/accessors/MaterialNode.js +107 -3
  33. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
  35. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  36. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  38. package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
  39. package/examples/jsm/nodes/accessors/TextureNode.js +51 -10
  40. package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
  41. package/examples/jsm/nodes/code/FunctionNode.js +0 -8
  42. package/examples/jsm/nodes/core/Node.js +63 -4
  43. package/examples/jsm/nodes/core/NodeBuilder.js +26 -25
  44. package/examples/jsm/nodes/core/NodeFrame.js +10 -10
  45. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  46. package/examples/jsm/nodes/core/OutputStructNode.js +2 -1
  47. package/examples/jsm/nodes/core/PropertyNode.js +10 -0
  48. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  49. package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
  50. package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
  51. package/examples/jsm/nodes/display/PassNode.js +17 -1
  52. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  53. package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
  54. package/examples/jsm/nodes/display/ViewportNode.js +4 -2
  55. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  56. package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
  57. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  58. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  59. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  60. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
  61. package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  62. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
  63. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  64. package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
  65. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +164 -10
  66. package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
  67. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +19 -5
  68. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
  69. package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -70
  70. package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
  71. package/examples/jsm/nodes/lighting/LightsNode.js +11 -1
  72. package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
  73. package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
  74. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +10 -6
  75. package/examples/jsm/nodes/materials/Materials.js +1 -0
  76. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
  77. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  78. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +76 -5
  79. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
  80. package/examples/jsm/nodes/materials/NodeMaterial.js +55 -43
  81. package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
  82. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  83. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  84. package/examples/jsm/nodes/shadernode/ShaderNode.js +3 -9
  85. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  86. package/examples/jsm/objects/QuadMesh.js +7 -23
  87. package/examples/jsm/physics/JoltPhysics.js +281 -0
  88. package/examples/jsm/physics/RapierPhysics.js +4 -4
  89. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  90. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  91. package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
  92. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  93. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  94. package/examples/jsm/renderers/common/Animation.js +3 -0
  95. package/examples/jsm/renderers/common/Background.js +8 -8
  96. package/examples/jsm/renderers/common/ClippingContext.js +1 -1
  97. package/examples/jsm/renderers/common/Info.js +11 -19
  98. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  99. package/examples/jsm/renderers/common/RenderContext.js +1 -1
  100. package/examples/jsm/renderers/common/RenderList.js +1 -1
  101. package/examples/jsm/renderers/common/RenderObject.js +47 -5
  102. package/examples/jsm/renderers/common/RenderObjects.js +1 -1
  103. package/examples/jsm/renderers/common/Renderer.js +153 -21
  104. package/examples/jsm/renderers/common/Textures.js +1 -1
  105. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +773 -0
  106. package/examples/jsm/renderers/common/nodes/Nodes.js +34 -63
  107. package/examples/jsm/renderers/webgl/WebGLBackend.js +146 -36
  108. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +145 -0
  109. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +9 -3
  110. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
  111. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  112. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +64 -7
  113. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +6 -23
  114. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +77 -60
  115. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -4
  116. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +29 -1
  117. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  118. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
  119. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  120. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  121. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  122. package/examples/jsm/utils/SceneUtils.js +60 -1
  123. package/examples/jsm/utils/TextureUtils.js +1 -1
  124. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  125. package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
  126. package/package.json +1 -1
  127. package/src/Three.js +0 -1
  128. package/src/animation/AnimationClip.js +1 -1
  129. package/src/constants.js +3 -3
  130. package/src/core/Object3D.js +10 -7
  131. package/src/core/RenderTarget.js +8 -0
  132. package/src/extras/PMREMGenerator.js +21 -11
  133. package/src/loaders/FileLoader.js +1 -1
  134. package/src/loaders/MaterialLoader.js +1 -0
  135. package/src/loaders/ObjectLoader.js +2 -0
  136. package/src/materials/Material.js +2 -0
  137. package/src/materials/MeshPhysicalMaterial.js +20 -0
  138. package/src/materials/ShaderMaterial.js +0 -4
  139. package/src/math/Spherical.js +4 -5
  140. package/src/objects/BatchedMesh.js +27 -3
  141. package/src/objects/InstancedMesh.js +10 -0
  142. package/src/objects/Line.js +66 -43
  143. package/src/renderers/WebGLRenderer.js +130 -158
  144. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
  145. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
  146. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  147. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  148. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  149. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  150. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  151. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
  152. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  153. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
  154. package/src/renderers/shaders/ShaderChunk.js +0 -2
  155. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
  156. package/src/renderers/shaders/ShaderLib.js +2 -1
  157. package/src/renderers/shaders/UniformsUtils.js +10 -1
  158. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  159. package/src/renderers/webgl/WebGLBackground.js +18 -3
  160. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  161. package/src/renderers/webgl/WebGLBufferRenderer.js +35 -21
  162. package/src/renderers/webgl/WebGLCapabilities.js +35 -13
  163. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  164. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  165. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +35 -21
  166. package/src/renderers/webgl/WebGLLights.js +6 -32
  167. package/src/renderers/webgl/WebGLMaterials.js +8 -3
  168. package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
  169. package/src/renderers/webgl/WebGLProgram.js +21 -52
  170. package/src/renderers/webgl/WebGLPrograms.js +24 -31
  171. package/src/renderers/webgl/WebGLRenderStates.js +13 -7
  172. package/src/renderers/webgl/WebGLShadowMap.js +25 -25
  173. package/src/renderers/webgl/WebGLState.js +15 -59
  174. package/src/renderers/webgl/WebGLTextures.js +138 -292
  175. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  176. package/src/renderers/webgl/WebGLUtils.js +9 -78
  177. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  178. package/src/renderers/webxr/WebXRManager.js +4 -6
  179. package/src/scenes/Scene.js +7 -1
  180. package/src/textures/Texture.js +11 -1
  181. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  182. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -320
  183. package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
  184. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -794
  185. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
  186. package/src/renderers/WebGL1Renderer.js +0 -7
  187. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2010-2023 Three.js Authors
3
+ * Copyright 2010-2024 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- const REVISION = '162';
6
+ const REVISION = '164';
7
7
 
8
8
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
9
9
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -96,7 +96,9 @@ const HalfFloatType = 1016;
96
96
  const UnsignedShort4444Type = 1017;
97
97
  const UnsignedShort5551Type = 1018;
98
98
  const UnsignedInt248Type = 1020;
99
+ const UnsignedInt5999Type = 35902;
99
100
  const AlphaFormat = 1021;
101
+ const RGBFormat = 1022;
100
102
  const RGBAFormat = 1023;
101
103
  const LuminanceFormat = 1024;
102
104
  const LuminanceAlphaFormat = 1025;
@@ -212,8 +214,6 @@ const StreamCopyUsage = 35042;
212
214
  const GLSL1 = '100';
213
215
  const GLSL3 = '300 es';
214
216
 
215
- const _SRGBAFormat = 1035; // fallback for WebGL 1
216
-
217
217
  const WebGLCoordinateSystem = 2000;
218
218
  const WebGPUCoordinateSystem = 2001;
219
219
 
@@ -2001,7 +2001,7 @@ class Texture extends EventDispatcher {
2001
2001
  this.onUpdate = null;
2002
2002
 
2003
2003
  this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not
2004
- this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
2004
+ this.pmremVersion = 0; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
2005
2005
 
2006
2006
  }
2007
2007
 
@@ -2232,6 +2232,16 @@ class Texture extends EventDispatcher {
2232
2232
 
2233
2233
  }
2234
2234
 
2235
+ set needsPMREMUpdate( value ) {
2236
+
2237
+ if ( value === true ) {
2238
+
2239
+ this.pmremVersion ++;
2240
+
2241
+ }
2242
+
2243
+ }
2244
+
2235
2245
  }
2236
2246
 
2237
2247
  Texture.DEFAULT_IMAGE = null;
@@ -2911,6 +2921,8 @@ class RenderTarget extends EventDispatcher {
2911
2921
  minFilter: LinearFilter,
2912
2922
  depthBuffer: true,
2913
2923
  stencilBuffer: false,
2924
+ resolveDepthBuffer: true,
2925
+ resolveStencilBuffer: true,
2914
2926
  depthTexture: null,
2915
2927
  samples: 0,
2916
2928
  count: 1
@@ -2935,6 +2947,9 @@ class RenderTarget extends EventDispatcher {
2935
2947
  this.depthBuffer = options.depthBuffer;
2936
2948
  this.stencilBuffer = options.stencilBuffer;
2937
2949
 
2950
+ this.resolveDepthBuffer = options.resolveDepthBuffer;
2951
+ this.resolveStencilBuffer = options.resolveStencilBuffer;
2952
+
2938
2953
  this.depthTexture = options.depthTexture;
2939
2954
 
2940
2955
  this.samples = options.samples;
@@ -3012,6 +3027,9 @@ class RenderTarget extends EventDispatcher {
3012
3027
  this.depthBuffer = source.depthBuffer;
3013
3028
  this.stencilBuffer = source.stencilBuffer;
3014
3029
 
3030
+ this.resolveDepthBuffer = source.resolveDepthBuffer;
3031
+ this.resolveStencilBuffer = source.resolveStencilBuffer;
3032
+
3015
3033
  if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
3016
3034
 
3017
3035
  this.samples = source.samples;
@@ -7400,12 +7418,7 @@ class Object3D extends EventDispatcher {
7400
7418
 
7401
7419
  if ( object && object.isObject3D ) {
7402
7420
 
7403
- if ( object.parent !== null ) {
7404
-
7405
- object.parent.remove( object );
7406
-
7407
- }
7408
-
7421
+ object.removeFromParent();
7409
7422
  object.parent = this;
7410
7423
  this.children.push( object );
7411
7424
 
@@ -7498,10 +7511,18 @@ class Object3D extends EventDispatcher {
7498
7511
 
7499
7512
  object.applyMatrix4( _m1$3 );
7500
7513
 
7501
- this.add( object );
7514
+ object.removeFromParent();
7515
+ object.parent = this;
7516
+ this.children.push( object );
7502
7517
 
7503
7518
  object.updateWorldMatrix( false, true );
7504
7519
 
7520
+ object.dispatchEvent( _addedEvent );
7521
+
7522
+ _childaddedEvent.child = object;
7523
+ this.dispatchEvent( _childaddedEvent );
7524
+ _childaddedEvent.child = null;
7525
+
7505
7526
  return this;
7506
7527
 
7507
7528
  }
@@ -9224,6 +9245,8 @@ class Material extends EventDispatcher {
9224
9245
 
9225
9246
  }
9226
9247
 
9248
+ if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
9249
+
9227
9250
  if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
9228
9251
  if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
9229
9252
  if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
@@ -11772,7 +11795,7 @@ class Mesh extends Object3D {
11772
11795
 
11773
11796
  }
11774
11797
 
11775
- function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
11798
+ function checkIntersection$1( object, material, raycaster, ray, pA, pB, pC, point ) {
11776
11799
 
11777
11800
  let intersect;
11778
11801
 
@@ -11809,7 +11832,7 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
11809
11832
  object.getVertexPosition( b, _vB$1 );
11810
11833
  object.getVertexPosition( c, _vC$1 );
11811
11834
 
11812
- const intersection = checkIntersection( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
11835
+ const intersection = checkIntersection$1( object, material, raycaster, ray, _vA$1, _vB$1, _vC$1, _intersectionPoint );
11813
11836
 
11814
11837
  if ( intersection ) {
11815
11838
 
@@ -12128,13 +12151,22 @@ function cloneUniformsGroups( src ) {
12128
12151
 
12129
12152
  function getUnlitUniformColorSpace( renderer ) {
12130
12153
 
12131
- if ( renderer.getRenderTarget() === null ) {
12154
+ const currentRenderTarget = renderer.getRenderTarget();
12155
+
12156
+ if ( currentRenderTarget === null ) {
12132
12157
 
12133
12158
  // https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
12134
12159
  return renderer.outputColorSpace;
12135
12160
 
12136
12161
  }
12137
12162
 
12163
+ // https://github.com/mrdoob/three.js/issues/27868
12164
+ if ( currentRenderTarget.isXRRenderTarget === true ) {
12165
+
12166
+ return currentRenderTarget.texture.colorSpace;
12167
+
12168
+ }
12169
+
12138
12170
  return ColorManagement.workingColorSpace;
12139
12171
 
12140
12172
  }
@@ -12176,10 +12208,6 @@ class ShaderMaterial extends Material {
12176
12208
  this.forceSinglePass = true;
12177
12209
 
12178
12210
  this.extensions = {
12179
- derivatives: false, // set to use derivatives
12180
- fragDepth: false, // set to use fragment depth values
12181
- drawBuffers: false, // set to use draw buffers
12182
- shaderTextureLOD: false, // set to use shader texture LOD
12183
12211
  clipCullDistance: false, // set to use vertex shader clipping
12184
12212
  multiDraw: false // set to use vertex shader multi_draw / enable gl_DrawID
12185
12213
  };
@@ -13420,9 +13448,7 @@ function WebGLAnimation() {
13420
13448
 
13421
13449
  }
13422
13450
 
13423
- function WebGLAttributes( gl, capabilities ) {
13424
-
13425
- const isWebGL2 = capabilities.isWebGL2;
13451
+ function WebGLAttributes( gl ) {
13426
13452
 
13427
13453
  const buffers = new WeakMap();
13428
13454
 
@@ -13449,15 +13475,7 @@ function WebGLAttributes( gl, capabilities ) {
13449
13475
 
13450
13476
  if ( attribute.isFloat16BufferAttribute ) {
13451
13477
 
13452
- if ( isWebGL2 ) {
13453
-
13454
- type = gl.HALF_FLOAT;
13455
-
13456
- } else {
13457
-
13458
- throw new Error( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
13459
-
13460
- }
13478
+ type = gl.HALF_FLOAT;
13461
13479
 
13462
13480
  } else {
13463
13481
 
@@ -13525,17 +13543,9 @@ function WebGLAttributes( gl, capabilities ) {
13525
13543
  for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
13526
13544
 
13527
13545
  const range = updateRanges[ i ];
13528
- if ( isWebGL2 ) {
13529
-
13530
- gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13531
- array, range.start, range.count );
13532
-
13533
- } else {
13534
-
13535
- gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13536
- array.subarray( range.start, range.start + range.count ) );
13537
13546
 
13538
- }
13547
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13548
+ array, range.start, range.count );
13539
13549
 
13540
13550
  }
13541
13551
 
@@ -13546,17 +13556,8 @@ function WebGLAttributes( gl, capabilities ) {
13546
13556
  // @deprecated, r159
13547
13557
  if ( updateRange.count !== - 1 ) {
13548
13558
 
13549
- if ( isWebGL2 ) {
13550
-
13551
- gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
13552
- array, updateRange.offset, updateRange.count );
13553
-
13554
- } else {
13555
-
13556
- gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
13557
- array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );
13558
-
13559
- }
13559
+ gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
13560
+ array, updateRange.offset, updateRange.count );
13560
13561
 
13561
13562
  updateRange.count = - 1; // reset range
13562
13563
 
@@ -13825,8 +13826,6 @@ var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying flo
13825
13826
 
13826
13827
  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\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}";
13827
13828
 
13828
- var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif";
13829
-
13830
13829
  var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
13831
13830
 
13832
13831
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
@@ -13845,9 +13844,9 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor
13845
13844
 
13846
13845
  var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong";
13847
13846
 
13848
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
13847
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
13849
13848
 
13850
- 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_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
13849
+ var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
13851
13850
 
13852
13851
  var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
13853
13852
 
@@ -13855,13 +13854,13 @@ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGH
13855
13854
 
13856
13855
  var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
13857
13856
 
13858
- var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
13857
+ var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
13859
13858
 
13860
- var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
13859
+ var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
13861
13860
 
13862
- var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif";
13861
+ var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
13863
13862
 
13864
- var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif";
13863
+ var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif";
13865
13864
 
13866
13865
  var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
13867
13866
 
@@ -13921,7 +13920,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
13921
13920
 
13922
13921
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
13923
13922
 
13924
- var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif";
13923
+ var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n#endif";
13925
13924
 
13926
13925
  var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif";
13927
13926
 
@@ -13943,11 +13942,11 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
13943
13942
 
13944
13943
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
13945
13944
 
13946
- var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tfloat startCompression = 0.8 - 0.04;\n\tfloat desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min(color.r, min(color.g, color.b));\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max(color.r, max(color.g, color.b));\n\tif (peak < startCompression) return color;\n\tfloat d = 1. - startCompression;\n\tfloat newPeak = 1. - d * d / (peak + d - startCompression);\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n\treturn mix(color, vec3(1, 1, 1), g);\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
13945
+ var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
13947
13946
 
13948
- var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
13947
+ var transmission_fragment = "#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif";
13949
13948
 
13950
- var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif";
13949
+ var transmission_pars_fragment = "#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif";
13951
13950
 
13952
13951
  var uv_pars_fragment = "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif";
13953
13952
 
@@ -14007,7 +14006,7 @@ const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;
14007
14006
 
14008
14007
  const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}";
14009
14008
 
14010
- const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
14009
+ const fragment$5 = "#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
14011
14010
 
14012
14011
  const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
14013
14012
 
@@ -14069,7 +14068,6 @@ const ShaderChunk = {
14069
14068
  fog_fragment: fog_fragment,
14070
14069
  fog_pars_fragment: fog_pars_fragment,
14071
14070
  gradientmap_pars_fragment: gradientmap_pars_fragment,
14072
- lightmap_fragment: lightmap_fragment,
14073
14071
  lightmap_pars_fragment: lightmap_pars_fragment,
14074
14072
  lights_lambert_fragment: lights_lambert_fragment,
14075
14073
  lights_lambert_pars_fragment: lights_lambert_pars_fragment,
@@ -14484,7 +14482,7 @@ const ShaderLib = {
14484
14482
  emissive: { value: /*@__PURE__*/ new Color( 0x000000 ) },
14485
14483
  roughness: { value: 1.0 },
14486
14484
  metalness: { value: 0.0 },
14487
- envMapIntensity: { value: 1 } // temporary
14485
+ envMapIntensity: { value: 1 }
14488
14486
  }
14489
14487
  ] ),
14490
14488
 
@@ -14705,6 +14703,7 @@ ShaderLib.physical = {
14705
14703
  clearcoatRoughness: { value: 0 },
14706
14704
  clearcoatRoughnessMap: { value: null },
14707
14705
  clearcoatRoughnessMapTransform: { value: /*@__PURE__*/ new Matrix3() },
14706
+ dispersion: { value: 0 },
14708
14707
  iridescence: { value: 0 },
14709
14708
  iridescenceMap: { value: null },
14710
14709
  iridescenceMapTransform: { value: /*@__PURE__*/ new Matrix3() },
@@ -14763,9 +14762,8 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14763
14762
  let currentBackgroundVersion = 0;
14764
14763
  let currentTonemapping = null;
14765
14764
 
14766
- function render( renderList, scene ) {
14765
+ function getBackground( scene ) {
14767
14766
 
14768
- let forceClear = false;
14769
14767
  let background = scene.isScene === true ? scene.background : null;
14770
14768
 
14771
14769
  if ( background && background.isTexture ) {
@@ -14775,6 +14773,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14775
14773
 
14776
14774
  }
14777
14775
 
14776
+ return background;
14777
+
14778
+ }
14779
+
14780
+ function render( scene ) {
14781
+
14782
+ let forceClear = false;
14783
+ const background = getBackground( scene );
14784
+
14778
14785
  if ( background === null ) {
14779
14786
 
14780
14787
  setClear( clearColor, clearAlpha );
@@ -14804,6 +14811,12 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14804
14811
 
14805
14812
  }
14806
14813
 
14814
+ }
14815
+
14816
+ function addToRenderList( renderList, scene ) {
14817
+
14818
+ const background = getBackground( scene );
14819
+
14807
14820
  if ( background && ( background.isCubeTexture || background.mapping === CubeUVReflectionMapping ) ) {
14808
14821
 
14809
14822
  if ( boxMesh === undefined ) {
@@ -14984,19 +14997,17 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14984
14997
  setClear( clearColor, clearAlpha );
14985
14998
 
14986
14999
  },
14987
- render: render
15000
+ render: render,
15001
+ addToRenderList: addToRenderList
14988
15002
 
14989
15003
  };
14990
15004
 
14991
15005
  }
14992
15006
 
14993
- function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15007
+ function WebGLBindingStates( gl, attributes ) {
14994
15008
 
14995
15009
  const maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );
14996
15010
 
14997
- const extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );
14998
- const vaoAvailable = capabilities.isWebGL2 || extension !== null;
14999
-
15000
15011
  const bindingStates = {};
15001
15012
 
15002
15013
  const defaultState = createBindingState( null );
@@ -15007,38 +15018,18 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15007
15018
 
15008
15019
  let updateBuffers = false;
15009
15020
 
15010
- if ( vaoAvailable ) {
15021
+ const state = getBindingState( geometry, program, material );
15011
15022
 
15012
- const state = getBindingState( geometry, program, material );
15023
+ if ( currentState !== state ) {
15013
15024
 
15014
- if ( currentState !== state ) {
15025
+ currentState = state;
15026
+ bindVertexArrayObject( currentState.object );
15015
15027
 
15016
- currentState = state;
15017
- bindVertexArrayObject( currentState.object );
15018
-
15019
- }
15020
-
15021
- updateBuffers = needsUpdate( object, geometry, program, index );
15022
-
15023
- if ( updateBuffers ) saveCache( object, geometry, program, index );
15024
-
15025
- } else {
15026
-
15027
- const wireframe = ( material.wireframe === true );
15028
-
15029
- if ( currentState.geometry !== geometry.id ||
15030
- currentState.program !== program.id ||
15031
- currentState.wireframe !== wireframe ) {
15032
-
15033
- currentState.geometry = geometry.id;
15034
- currentState.program = program.id;
15035
- currentState.wireframe = wireframe;
15036
-
15037
- updateBuffers = true;
15028
+ }
15038
15029
 
15039
- }
15030
+ updateBuffers = needsUpdate( object, geometry, program, index );
15040
15031
 
15041
- }
15032
+ if ( updateBuffers ) saveCache( object, geometry, program, index );
15042
15033
 
15043
15034
  if ( index !== null ) {
15044
15035
 
@@ -15064,25 +15055,19 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15064
15055
 
15065
15056
  function createVertexArrayObject() {
15066
15057
 
15067
- if ( capabilities.isWebGL2 ) return gl.createVertexArray();
15068
-
15069
- return extension.createVertexArrayOES();
15058
+ return gl.createVertexArray();
15070
15059
 
15071
15060
  }
15072
15061
 
15073
15062
  function bindVertexArrayObject( vao ) {
15074
15063
 
15075
- if ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao );
15076
-
15077
- return extension.bindVertexArrayOES( vao );
15064
+ return gl.bindVertexArray( vao );
15078
15065
 
15079
15066
  }
15080
15067
 
15081
15068
  function deleteVertexArrayObject( vao ) {
15082
15069
 
15083
- if ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao );
15084
-
15085
- return extension.deleteVertexArrayOES( vao );
15070
+ return gl.deleteVertexArray( vao );
15086
15071
 
15087
15072
  }
15088
15073
 
@@ -15280,9 +15265,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15280
15265
 
15281
15266
  if ( attributeDivisors[ attribute ] !== meshPerAttribute ) {
15282
15267
 
15283
- const extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );
15284
-
15285
- extension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );
15268
+ gl.vertexAttribDivisor( attribute, meshPerAttribute );
15286
15269
  attributeDivisors[ attribute ] = meshPerAttribute;
15287
15270
 
15288
15271
  }
@@ -15323,12 +15306,6 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15323
15306
 
15324
15307
  function setupVertexAttributes( object, material, program, geometry ) {
15325
15308
 
15326
- if ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {
15327
-
15328
- if ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;
15329
-
15330
- }
15331
-
15332
15309
  initAttributes();
15333
15310
 
15334
15311
  const geometryAttributes = geometry.attributes;
@@ -15367,9 +15344,9 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15367
15344
  const type = attribute.type;
15368
15345
  const bytesPerElement = attribute.bytesPerElement;
15369
15346
 
15370
- // check for integer attributes (WebGL 2 only)
15347
+ // check for integer attributes
15371
15348
 
15372
- const integer = ( capabilities.isWebGL2 === true && ( type === gl.INT || type === gl.UNSIGNED_INT || geometryAttribute.gpuType === IntType ) );
15349
+ const integer = ( type === gl.INT || type === gl.UNSIGNED_INT || geometryAttribute.gpuType === IntType );
15373
15350
 
15374
15351
  if ( geometryAttribute.isInterleavedBufferAttribute ) {
15375
15352
 
@@ -15617,9 +15594,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15617
15594
 
15618
15595
  }
15619
15596
 
15620
- function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15621
-
15622
- const isWebGL2 = capabilities.isWebGL2;
15597
+ function WebGLBufferRenderer( gl, extensions, info ) {
15623
15598
 
15624
15599
  let mode;
15625
15600
 
@@ -15641,49 +15616,60 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15641
15616
 
15642
15617
  if ( primcount === 0 ) return;
15643
15618
 
15644
- let extension, methodName;
15619
+ gl.drawArraysInstanced( mode, start, count, primcount );
15645
15620
 
15646
- if ( isWebGL2 ) {
15621
+ info.update( count, mode, primcount );
15647
15622
 
15648
- extension = gl;
15649
- methodName = 'drawArraysInstanced';
15623
+ }
15650
15624
 
15651
- } else {
15625
+ function renderMultiDraw( starts, counts, drawCount ) {
15652
15626
 
15653
- extension = extensions.get( 'ANGLE_instanced_arrays' );
15654
- methodName = 'drawArraysInstancedANGLE';
15627
+ if ( drawCount === 0 ) return;
15655
15628
 
15656
- if ( extension === null ) {
15629
+ const extension = extensions.get( 'WEBGL_multi_draw' );
15657
15630
 
15658
- console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
15659
- return;
15631
+ if ( extension === null ) {
15632
+
15633
+ for ( let i = 0; i < drawCount; i ++ ) {
15634
+
15635
+ this.render( starts[ i ], counts[ i ] );
15660
15636
 
15661
15637
  }
15662
15638
 
15663
- }
15639
+ } else {
15664
15640
 
15665
- extension[ methodName ]( mode, start, count, primcount );
15641
+ extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15666
15642
 
15667
- info.update( count, mode, primcount );
15643
+ let elementCount = 0;
15644
+ for ( let i = 0; i < drawCount; i ++ ) {
15645
+
15646
+ elementCount += counts[ i ];
15647
+
15648
+ }
15649
+
15650
+ info.update( elementCount, mode, 1 );
15651
+
15652
+ }
15668
15653
 
15669
15654
  }
15670
15655
 
15671
- function renderMultiDraw( starts, counts, drawCount ) {
15656
+ function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
15672
15657
 
15673
15658
  if ( drawCount === 0 ) return;
15674
15659
 
15675
15660
  const extension = extensions.get( 'WEBGL_multi_draw' );
15661
+
15676
15662
  if ( extension === null ) {
15677
15663
 
15678
- for ( let i = 0; i < drawCount; i ++ ) {
15664
+ for ( let i = 0; i < starts.length; i ++ ) {
15679
15665
 
15680
- this.render( starts[ i ], counts[ i ] );
15666
+ renderInstances( starts[ i ], counts[ i ], primcount[ i ] );
15681
15667
 
15682
15668
  }
15683
15669
 
15684
15670
  } else {
15685
15671
 
15686
- extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15672
+ extension.multiDrawArraysInstancedWEBGL( mode, starts, 0, counts, 0, primcount, 0, drawCount );
15687
15673
 
15688
15674
  let elementCount = 0;
15689
15675
  for ( let i = 0; i < drawCount; i ++ ) {
@@ -15692,7 +15678,11 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15692
15678
 
15693
15679
  }
15694
15680
 
15695
- info.update( elementCount, mode, 1 );
15681
+ for ( let i = 0; i < primcount.length; i ++ ) {
15682
+
15683
+ info.update( elementCount, mode, primcount[ i ] );
15684
+
15685
+ }
15696
15686
 
15697
15687
  }
15698
15688
 
@@ -15704,10 +15694,11 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15704
15694
  this.render = render;
15705
15695
  this.renderInstances = renderInstances;
15706
15696
  this.renderMultiDraw = renderMultiDraw;
15697
+ this.renderMultiDrawInstances = renderMultiDrawInstances;
15707
15698
 
15708
15699
  }
15709
15700
 
15710
- function WebGLCapabilities( gl, extensions, parameters ) {
15701
+ function WebGLCapabilities( gl, extensions, parameters, utils ) {
15711
15702
 
15712
15703
  let maxAnisotropy;
15713
15704
 
@@ -15731,6 +15722,33 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15731
15722
 
15732
15723
  }
15733
15724
 
15725
+ function textureFormatReadable( textureFormat ) {
15726
+
15727
+ if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
15728
+
15729
+ return false;
15730
+
15731
+ }
15732
+
15733
+ return true;
15734
+
15735
+ }
15736
+
15737
+ function textureTypeReadable( textureType ) {
15738
+
15739
+ const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );
15740
+
15741
+ if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
15742
+ textureType !== FloatType && ! halfFloatSupportedByExt ) {
15743
+
15744
+ return false;
15745
+
15746
+ }
15747
+
15748
+ return true;
15749
+
15750
+ }
15751
+
15734
15752
  function getMaxPrecision( precision ) {
15735
15753
 
15736
15754
  if ( precision === 'highp' ) {
@@ -15761,8 +15779,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15761
15779
 
15762
15780
  }
15763
15781
 
15764
- const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
15765
-
15766
15782
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
15767
15783
  const maxPrecision = getMaxPrecision( precision );
15768
15784
 
@@ -15773,8 +15789,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15773
15789
 
15774
15790
  }
15775
15791
 
15776
- const drawBuffers = isWebGL2 || extensions.has( 'WEBGL_draw_buffers' );
15777
-
15778
15792
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
15779
15793
 
15780
15794
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
@@ -15788,20 +15802,19 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15788
15802
  const maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );
15789
15803
 
15790
15804
  const vertexTextures = maxVertexTextures > 0;
15791
- const floatFragmentTextures = isWebGL2 || extensions.has( 'OES_texture_float' );
15792
- const floatVertexTextures = vertexTextures && floatFragmentTextures;
15793
15805
 
15794
- const maxSamples = isWebGL2 ? gl.getParameter( gl.MAX_SAMPLES ) : 0;
15806
+ const maxSamples = gl.getParameter( gl.MAX_SAMPLES );
15795
15807
 
15796
15808
  return {
15797
15809
 
15798
- isWebGL2: isWebGL2,
15799
-
15800
- drawBuffers: drawBuffers,
15810
+ isWebGL2: true, // keeping this for backwards compatibility
15801
15811
 
15802
15812
  getMaxAnisotropy: getMaxAnisotropy,
15803
15813
  getMaxPrecision: getMaxPrecision,
15804
15814
 
15815
+ textureFormatReadable: textureFormatReadable,
15816
+ textureTypeReadable: textureTypeReadable,
15817
+
15805
15818
  precision: precision,
15806
15819
  logarithmicDepthBuffer: logarithmicDepthBuffer,
15807
15820
 
@@ -15816,8 +15829,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15816
15829
  maxFragmentUniforms: maxFragmentUniforms,
15817
15830
 
15818
15831
  vertexTextures: vertexTextures,
15819
- floatFragmentTextures: floatFragmentTextures,
15820
- floatVertexTextures: floatVertexTextures,
15821
15832
 
15822
15833
  maxSamples: maxSamples
15823
15834
 
@@ -16236,6 +16247,7 @@ const _clearColor = /*@__PURE__*/ new Color();
16236
16247
  let _oldTarget = null;
16237
16248
  let _oldActiveCubeFace = 0;
16238
16249
  let _oldActiveMipmapLevel = 0;
16250
+ let _oldXrEnabled = false;
16239
16251
 
16240
16252
  // Golden Ratio
16241
16253
  const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
@@ -16244,16 +16256,16 @@ const INV_PHI = 1 / PHI;
16244
16256
  // Vertices of a dodecahedron (except the opposites, which represent the
16245
16257
  // same axis), used as axis directions evenly spread on a sphere.
16246
16258
  const _axisDirections = [
16247
- /*@__PURE__*/ new Vector3( 1, 1, 1 ),
16248
- /*@__PURE__*/ new Vector3( - 1, 1, 1 ),
16249
- /*@__PURE__*/ new Vector3( 1, 1, - 1 ),
16250
- /*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
16251
- /*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
16252
- /*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
16253
- /*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
16254
- /*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
16259
+ /*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ),
16255
16260
  /*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ),
16256
- /*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ) ];
16261
+ /*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
16262
+ /*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
16263
+ /*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
16264
+ /*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
16265
+ /*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
16266
+ /*@__PURE__*/ new Vector3( 1, 1, - 1 ),
16267
+ /*@__PURE__*/ new Vector3( - 1, 1, 1 ),
16268
+ /*@__PURE__*/ new Vector3( 1, 1, 1 ) ];
16257
16269
 
16258
16270
  /**
16259
16271
  * This class generates a Prefiltered, Mipmapped Radiance Environment Map
@@ -16303,6 +16315,9 @@ class PMREMGenerator {
16303
16315
  _oldTarget = this._renderer.getRenderTarget();
16304
16316
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
16305
16317
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
16318
+ _oldXrEnabled = this._renderer.xr.enabled;
16319
+
16320
+ this._renderer.xr.enabled = false;
16306
16321
 
16307
16322
  this._setSize( 256 );
16308
16323
 
@@ -16418,6 +16433,8 @@ class PMREMGenerator {
16418
16433
  _cleanup( outputTarget ) {
16419
16434
 
16420
16435
  this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
16436
+ this._renderer.xr.enabled = _oldXrEnabled;
16437
+
16421
16438
  outputTarget.scissorTest = false;
16422
16439
  _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
16423
16440
 
@@ -16438,6 +16455,9 @@ class PMREMGenerator {
16438
16455
  _oldTarget = this._renderer.getRenderTarget();
16439
16456
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
16440
16457
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
16458
+ _oldXrEnabled = this._renderer.xr.enabled;
16459
+
16460
+ this._renderer.xr.enabled = false;
16441
16461
 
16442
16462
  const cubeUVRenderTarget = renderTarget || this._allocateTargets();
16443
16463
  this._textureToCubeUV( texture, cubeUVRenderTarget );
@@ -16631,12 +16651,13 @@ class PMREMGenerator {
16631
16651
  const renderer = this._renderer;
16632
16652
  const autoClear = renderer.autoClear;
16633
16653
  renderer.autoClear = false;
16654
+ const n = this._lodPlanes.length;
16634
16655
 
16635
- for ( let i = 1; i < this._lodPlanes.length; i ++ ) {
16656
+ for ( let i = 1; i < n; i ++ ) {
16636
16657
 
16637
16658
  const sigma = Math.sqrt( this._sigmas[ i ] * this._sigmas[ i ] - this._sigmas[ i - 1 ] * this._sigmas[ i - 1 ] );
16638
16659
 
16639
- const poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ];
16660
+ const poleAxis = _axisDirections[ ( n - i - 1 ) % _axisDirections.length ];
16640
16661
 
16641
16662
  this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis );
16642
16663
 
@@ -17120,24 +17141,26 @@ function WebGLCubeUVMaps( renderer ) {
17120
17141
 
17121
17142
  if ( isEquirectMap || isCubeMap ) {
17122
17143
 
17123
- if ( texture.isRenderTargetTexture && texture.needsPMREMUpdate === true ) {
17144
+ let renderTarget = cubeUVmaps.get( texture );
17124
17145
 
17125
- texture.needsPMREMUpdate = false;
17146
+ const currentPMREMVersion = renderTarget !== undefined ? renderTarget.texture.pmremVersion : 0;
17126
17147
 
17127
- let renderTarget = cubeUVmaps.get( texture );
17148
+ if ( texture.isRenderTargetTexture && texture.pmremVersion !== currentPMREMVersion ) {
17128
17149
 
17129
17150
  if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
17130
17151
 
17131
17152
  renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture, renderTarget ) : pmremGenerator.fromCubemap( texture, renderTarget );
17153
+ renderTarget.texture.pmremVersion = texture.pmremVersion;
17154
+
17132
17155
  cubeUVmaps.set( texture, renderTarget );
17133
17156
 
17134
17157
  return renderTarget.texture;
17135
17158
 
17136
17159
  } else {
17137
17160
 
17138
- if ( cubeUVmaps.has( texture ) ) {
17161
+ if ( renderTarget !== undefined ) {
17139
17162
 
17140
- return cubeUVmaps.get( texture ).texture;
17163
+ return renderTarget.texture;
17141
17164
 
17142
17165
  } else {
17143
17166
 
@@ -17147,7 +17170,9 @@ function WebGLCubeUVMaps( renderer ) {
17147
17170
 
17148
17171
  if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
17149
17172
 
17150
- const renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture );
17173
+ renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture );
17174
+ renderTarget.texture.pmremVersion = texture.pmremVersion;
17175
+
17151
17176
  cubeUVmaps.set( texture, renderTarget );
17152
17177
 
17153
17178
  texture.addEventListener( 'dispose', onTextureDispose );
@@ -17278,29 +17303,14 @@ function WebGLExtensions( gl ) {
17278
17303
 
17279
17304
  },
17280
17305
 
17281
- init: function ( capabilities ) {
17282
-
17283
- if ( capabilities.isWebGL2 ) {
17284
-
17285
- getExtension( 'EXT_color_buffer_float' );
17286
- getExtension( 'WEBGL_clip_cull_distance' );
17287
-
17288
- } else {
17289
-
17290
- getExtension( 'WEBGL_depth_texture' );
17291
- getExtension( 'OES_texture_float' );
17292
- getExtension( 'OES_texture_half_float' );
17293
- getExtension( 'OES_texture_half_float_linear' );
17294
- getExtension( 'OES_standard_derivatives' );
17295
- getExtension( 'OES_element_index_uint' );
17296
- getExtension( 'OES_vertex_array_object' );
17297
- getExtension( 'ANGLE_instanced_arrays' );
17298
-
17299
- }
17306
+ init: function () {
17300
17307
 
17308
+ getExtension( 'EXT_color_buffer_float' );
17309
+ getExtension( 'WEBGL_clip_cull_distance' );
17301
17310
  getExtension( 'OES_texture_float_linear' );
17302
17311
  getExtension( 'EXT_color_buffer_half_float' );
17303
17312
  getExtension( 'WEBGL_multisampled_render_to_texture' );
17313
+ getExtension( 'WEBGL_render_shared_exponent' );
17304
17314
 
17305
17315
  },
17306
17316
 
@@ -17528,9 +17538,7 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
17528
17538
 
17529
17539
  }
17530
17540
 
17531
- function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17532
-
17533
- const isWebGL2 = capabilities.isWebGL2;
17541
+ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
17534
17542
 
17535
17543
  let mode;
17536
17544
 
@@ -17561,49 +17569,60 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17561
17569
 
17562
17570
  if ( primcount === 0 ) return;
17563
17571
 
17564
- let extension, methodName;
17572
+ gl.drawElementsInstanced( mode, count, type, start * bytesPerElement, primcount );
17565
17573
 
17566
- if ( isWebGL2 ) {
17574
+ info.update( count, mode, primcount );
17567
17575
 
17568
- extension = gl;
17569
- methodName = 'drawElementsInstanced';
17576
+ }
17570
17577
 
17571
- } else {
17578
+ function renderMultiDraw( starts, counts, drawCount ) {
17572
17579
 
17573
- extension = extensions.get( 'ANGLE_instanced_arrays' );
17574
- methodName = 'drawElementsInstancedANGLE';
17580
+ if ( drawCount === 0 ) return;
17575
17581
 
17576
- if ( extension === null ) {
17582
+ const extension = extensions.get( 'WEBGL_multi_draw' );
17577
17583
 
17578
- console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
17579
- return;
17584
+ if ( extension === null ) {
17585
+
17586
+ for ( let i = 0; i < drawCount; i ++ ) {
17587
+
17588
+ this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17580
17589
 
17581
17590
  }
17582
17591
 
17583
- }
17592
+ } else {
17584
17593
 
17585
- extension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );
17594
+ extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17586
17595
 
17587
- info.update( count, mode, primcount );
17596
+ let elementCount = 0;
17597
+ for ( let i = 0; i < drawCount; i ++ ) {
17598
+
17599
+ elementCount += counts[ i ];
17600
+
17601
+ }
17602
+
17603
+ info.update( elementCount, mode, 1 );
17604
+
17605
+ }
17588
17606
 
17589
17607
  }
17590
17608
 
17591
- function renderMultiDraw( starts, counts, drawCount ) {
17609
+ function renderMultiDrawInstances( starts, counts, drawCount, primcount ) {
17592
17610
 
17593
17611
  if ( drawCount === 0 ) return;
17594
17612
 
17595
17613
  const extension = extensions.get( 'WEBGL_multi_draw' );
17614
+
17596
17615
  if ( extension === null ) {
17597
17616
 
17598
- for ( let i = 0; i < drawCount; i ++ ) {
17617
+ for ( let i = 0; i < starts.length; i ++ ) {
17599
17618
 
17600
- this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17619
+ renderInstances( starts[ i ] / bytesPerElement, counts[ i ], primcount[ i ] );
17601
17620
 
17602
17621
  }
17603
17622
 
17604
17623
  } else {
17605
17624
 
17606
- extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17625
+ extension.multiDrawElementsInstancedWEBGL( mode, counts, 0, type, starts, 0, primcount, 0, drawCount );
17607
17626
 
17608
17627
  let elementCount = 0;
17609
17628
  for ( let i = 0; i < drawCount; i ++ ) {
@@ -17612,7 +17631,11 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17612
17631
 
17613
17632
  }
17614
17633
 
17615
- info.update( elementCount, mode, 1 );
17634
+ for ( let i = 0; i < primcount.length; i ++ ) {
17635
+
17636
+ info.update( elementCount, mode, primcount[ i ] );
17637
+
17638
+ }
17616
17639
 
17617
17640
  }
17618
17641
 
@@ -17625,6 +17648,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17625
17648
  this.render = render;
17626
17649
  this.renderInstances = renderInstances;
17627
17650
  this.renderMultiDraw = renderMultiDraw;
17651
+ this.renderMultiDrawInstances = renderMultiDrawInstances;
17628
17652
 
17629
17653
  }
17630
17654
 
@@ -17697,296 +17721,158 @@ function WebGLInfo( gl ) {
17697
17721
 
17698
17722
  }
17699
17723
 
17700
- function numericalSort( a, b ) {
17701
-
17702
- return a[ 0 ] - b[ 0 ];
17703
-
17704
- }
17705
-
17706
- function absNumericalSort( a, b ) {
17707
-
17708
- return Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );
17709
-
17710
- }
17711
-
17712
17724
  function WebGLMorphtargets( gl, capabilities, textures ) {
17713
17725
 
17714
- const influencesList = {};
17715
- const morphInfluences = new Float32Array( 8 );
17716
17726
  const morphTextures = new WeakMap();
17717
17727
  const morph = new Vector4();
17718
17728
 
17719
- const workInfluences = [];
17720
-
17721
- for ( let i = 0; i < 8; i ++ ) {
17722
-
17723
- workInfluences[ i ] = [ i, 0 ];
17724
-
17725
- }
17726
-
17727
17729
  function update( object, geometry, program ) {
17728
17730
 
17729
17731
  const objectInfluences = object.morphTargetInfluences;
17730
17732
 
17731
- if ( capabilities.isWebGL2 === true ) {
17732
-
17733
- // instead of using attributes, the WebGL 2 code path encodes morph targets
17734
- // into an array of data textures. Each layer represents a single morph target.
17735
-
17736
- const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
17737
- const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
17738
-
17739
- let entry = morphTextures.get( geometry );
17740
-
17741
- if ( entry === undefined || entry.count !== morphTargetsCount ) {
17742
-
17743
- if ( entry !== undefined ) entry.texture.dispose();
17744
-
17745
- const hasMorphPosition = geometry.morphAttributes.position !== undefined;
17746
- const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
17747
- const hasMorphColors = geometry.morphAttributes.color !== undefined;
17748
-
17749
- const morphTargets = geometry.morphAttributes.position || [];
17750
- const morphNormals = geometry.morphAttributes.normal || [];
17751
- const morphColors = geometry.morphAttributes.color || [];
17752
-
17753
- let vertexDataCount = 0;
17733
+ // instead of using attributes, the WebGL 2 code path encodes morph targets
17734
+ // into an array of data textures. Each layer represents a single morph target.
17754
17735
 
17755
- if ( hasMorphPosition === true ) vertexDataCount = 1;
17756
- if ( hasMorphNormals === true ) vertexDataCount = 2;
17757
- if ( hasMorphColors === true ) vertexDataCount = 3;
17736
+ const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
17737
+ const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
17758
17738
 
17759
- let width = geometry.attributes.position.count * vertexDataCount;
17760
- let height = 1;
17739
+ let entry = morphTextures.get( geometry );
17761
17740
 
17762
- if ( width > capabilities.maxTextureSize ) {
17741
+ if ( entry === undefined || entry.count !== morphTargetsCount ) {
17763
17742
 
17764
- height = Math.ceil( width / capabilities.maxTextureSize );
17765
- width = capabilities.maxTextureSize;
17743
+ if ( entry !== undefined ) entry.texture.dispose();
17766
17744
 
17767
- }
17745
+ const hasMorphPosition = geometry.morphAttributes.position !== undefined;
17746
+ const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
17747
+ const hasMorphColors = geometry.morphAttributes.color !== undefined;
17768
17748
 
17769
- const buffer = new Float32Array( width * height * 4 * morphTargetsCount );
17770
-
17771
- const texture = new DataArrayTexture( buffer, width, height, morphTargetsCount );
17772
- texture.type = FloatType;
17773
- texture.needsUpdate = true;
17749
+ const morphTargets = geometry.morphAttributes.position || [];
17750
+ const morphNormals = geometry.morphAttributes.normal || [];
17751
+ const morphColors = geometry.morphAttributes.color || [];
17774
17752
 
17775
- // fill buffer
17753
+ let vertexDataCount = 0;
17776
17754
 
17777
- const vertexDataStride = vertexDataCount * 4;
17755
+ if ( hasMorphPosition === true ) vertexDataCount = 1;
17756
+ if ( hasMorphNormals === true ) vertexDataCount = 2;
17757
+ if ( hasMorphColors === true ) vertexDataCount = 3;
17778
17758
 
17779
- for ( let i = 0; i < morphTargetsCount; i ++ ) {
17759
+ let width = geometry.attributes.position.count * vertexDataCount;
17760
+ let height = 1;
17780
17761
 
17781
- const morphTarget = morphTargets[ i ];
17782
- const morphNormal = morphNormals[ i ];
17783
- const morphColor = morphColors[ i ];
17762
+ if ( width > capabilities.maxTextureSize ) {
17784
17763
 
17785
- const offset = width * height * 4 * i;
17764
+ height = Math.ceil( width / capabilities.maxTextureSize );
17765
+ width = capabilities.maxTextureSize;
17786
17766
 
17787
- for ( let j = 0; j < morphTarget.count; j ++ ) {
17767
+ }
17788
17768
 
17789
- const stride = j * vertexDataStride;
17769
+ const buffer = new Float32Array( width * height * 4 * morphTargetsCount );
17790
17770
 
17791
- if ( hasMorphPosition === true ) {
17771
+ const texture = new DataArrayTexture( buffer, width, height, morphTargetsCount );
17772
+ texture.type = FloatType;
17773
+ texture.needsUpdate = true;
17792
17774
 
17793
- morph.fromBufferAttribute( morphTarget, j );
17775
+ // fill buffer
17794
17776
 
17795
- buffer[ offset + stride + 0 ] = morph.x;
17796
- buffer[ offset + stride + 1 ] = morph.y;
17797
- buffer[ offset + stride + 2 ] = morph.z;
17798
- buffer[ offset + stride + 3 ] = 0;
17777
+ const vertexDataStride = vertexDataCount * 4;
17799
17778
 
17800
- }
17779
+ for ( let i = 0; i < morphTargetsCount; i ++ ) {
17801
17780
 
17802
- if ( hasMorphNormals === true ) {
17781
+ const morphTarget = morphTargets[ i ];
17782
+ const morphNormal = morphNormals[ i ];
17783
+ const morphColor = morphColors[ i ];
17803
17784
 
17804
- morph.fromBufferAttribute( morphNormal, j );
17785
+ const offset = width * height * 4 * i;
17805
17786
 
17806
- buffer[ offset + stride + 4 ] = morph.x;
17807
- buffer[ offset + stride + 5 ] = morph.y;
17808
- buffer[ offset + stride + 6 ] = morph.z;
17809
- buffer[ offset + stride + 7 ] = 0;
17787
+ for ( let j = 0; j < morphTarget.count; j ++ ) {
17810
17788
 
17811
- }
17789
+ const stride = j * vertexDataStride;
17812
17790
 
17813
- if ( hasMorphColors === true ) {
17791
+ if ( hasMorphPosition === true ) {
17814
17792
 
17815
- morph.fromBufferAttribute( morphColor, j );
17793
+ morph.fromBufferAttribute( morphTarget, j );
17816
17794
 
17817
- buffer[ offset + stride + 8 ] = morph.x;
17818
- buffer[ offset + stride + 9 ] = morph.y;
17819
- buffer[ offset + stride + 10 ] = morph.z;
17820
- buffer[ offset + stride + 11 ] = ( morphColor.itemSize === 4 ) ? morph.w : 1;
17821
-
17822
- }
17795
+ buffer[ offset + stride + 0 ] = morph.x;
17796
+ buffer[ offset + stride + 1 ] = morph.y;
17797
+ buffer[ offset + stride + 2 ] = morph.z;
17798
+ buffer[ offset + stride + 3 ] = 0;
17823
17799
 
17824
17800
  }
17825
17801
 
17826
- }
17827
-
17828
- entry = {
17829
- count: morphTargetsCount,
17830
- texture: texture,
17831
- size: new Vector2( width, height )
17832
- };
17833
-
17834
- morphTextures.set( geometry, entry );
17835
-
17836
- function disposeTexture() {
17837
-
17838
- texture.dispose();
17802
+ if ( hasMorphNormals === true ) {
17839
17803
 
17840
- morphTextures.delete( geometry );
17804
+ morph.fromBufferAttribute( morphNormal, j );
17841
17805
 
17842
- geometry.removeEventListener( 'dispose', disposeTexture );
17806
+ buffer[ offset + stride + 4 ] = morph.x;
17807
+ buffer[ offset + stride + 5 ] = morph.y;
17808
+ buffer[ offset + stride + 6 ] = morph.z;
17809
+ buffer[ offset + stride + 7 ] = 0;
17843
17810
 
17844
- }
17845
-
17846
- geometry.addEventListener( 'dispose', disposeTexture );
17847
-
17848
- }
17849
-
17850
- //
17851
- if ( object.isInstancedMesh === true && object.morphTexture !== null ) {
17852
-
17853
- program.getUniforms().setValue( gl, 'morphTexture', object.morphTexture, textures );
17811
+ }
17854
17812
 
17855
- } else {
17813
+ if ( hasMorphColors === true ) {
17856
17814
 
17857
- let morphInfluencesSum = 0;
17815
+ morph.fromBufferAttribute( morphColor, j );
17858
17816
 
17859
- for ( let i = 0; i < objectInfluences.length; i ++ ) {
17817
+ buffer[ offset + stride + 8 ] = morph.x;
17818
+ buffer[ offset + stride + 9 ] = morph.y;
17819
+ buffer[ offset + stride + 10 ] = morph.z;
17820
+ buffer[ offset + stride + 11 ] = ( morphColor.itemSize === 4 ) ? morph.w : 1;
17860
17821
 
17861
- morphInfluencesSum += objectInfluences[ i ];
17822
+ }
17862
17823
 
17863
17824
  }
17864
17825
 
17865
- const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
17866
-
17867
-
17868
- program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
17869
- program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
17870
-
17871
17826
  }
17872
17827
 
17873
- program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures );
17874
- program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size );
17875
-
17876
- } else {
17877
-
17878
- // When object doesn't have morph target influences defined, we treat it as a 0-length array
17879
- // This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences
17880
-
17881
- const length = objectInfluences === undefined ? 0 : objectInfluences.length;
17882
-
17883
- let influences = influencesList[ geometry.id ];
17884
-
17885
- if ( influences === undefined || influences.length !== length ) {
17886
-
17887
- // initialise list
17888
-
17889
- influences = [];
17890
-
17891
- for ( let i = 0; i < length; i ++ ) {
17892
-
17893
- influences[ i ] = [ i, 0 ];
17894
-
17895
- }
17896
-
17897
- influencesList[ geometry.id ] = influences;
17828
+ entry = {
17829
+ count: morphTargetsCount,
17830
+ texture: texture,
17831
+ size: new Vector2( width, height )
17832
+ };
17898
17833
 
17899
- }
17834
+ morphTextures.set( geometry, entry );
17900
17835
 
17901
- // Collect influences
17836
+ function disposeTexture() {
17902
17837
 
17903
- for ( let i = 0; i < length; i ++ ) {
17838
+ texture.dispose();
17904
17839
 
17905
- const influence = influences[ i ];
17840
+ morphTextures.delete( geometry );
17906
17841
 
17907
- influence[ 0 ] = i;
17908
- influence[ 1 ] = objectInfluences[ i ];
17842
+ geometry.removeEventListener( 'dispose', disposeTexture );
17909
17843
 
17910
17844
  }
17911
17845
 
17912
- influences.sort( absNumericalSort );
17913
-
17914
- for ( let i = 0; i < 8; i ++ ) {
17915
-
17916
- if ( i < length && influences[ i ][ 1 ] ) {
17917
-
17918
- workInfluences[ i ][ 0 ] = influences[ i ][ 0 ];
17919
- workInfluences[ i ][ 1 ] = influences[ i ][ 1 ];
17920
-
17921
- } else {
17922
-
17923
- workInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;
17924
- workInfluences[ i ][ 1 ] = 0;
17846
+ geometry.addEventListener( 'dispose', disposeTexture );
17925
17847
 
17926
- }
17848
+ }
17927
17849
 
17928
- }
17850
+ //
17851
+ if ( object.isInstancedMesh === true && object.morphTexture !== null ) {
17929
17852
 
17930
- workInfluences.sort( numericalSort );
17853
+ program.getUniforms().setValue( gl, 'morphTexture', object.morphTexture, textures );
17931
17854
 
17932
- const morphTargets = geometry.morphAttributes.position;
17933
- const morphNormals = geometry.morphAttributes.normal;
17855
+ } else {
17934
17856
 
17935
17857
  let morphInfluencesSum = 0;
17936
17858
 
17937
- for ( let i = 0; i < 8; i ++ ) {
17938
-
17939
- const influence = workInfluences[ i ];
17940
- const index = influence[ 0 ];
17941
- const value = influence[ 1 ];
17942
-
17943
- if ( index !== Number.MAX_SAFE_INTEGER && value ) {
17944
-
17945
- if ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {
17946
-
17947
- geometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );
17948
-
17949
- }
17950
-
17951
- if ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {
17952
-
17953
- geometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );
17954
-
17955
- }
17956
-
17957
- morphInfluences[ i ] = value;
17958
- morphInfluencesSum += value;
17959
-
17960
- } else {
17859
+ for ( let i = 0; i < objectInfluences.length; i ++ ) {
17961
17860
 
17962
- if ( morphTargets && geometry.hasAttribute( 'morphTarget' + i ) === true ) {
17963
-
17964
- geometry.deleteAttribute( 'morphTarget' + i );
17965
-
17966
- }
17967
-
17968
- if ( morphNormals && geometry.hasAttribute( 'morphNormal' + i ) === true ) {
17969
-
17970
- geometry.deleteAttribute( 'morphNormal' + i );
17971
-
17972
- }
17973
-
17974
- morphInfluences[ i ] = 0;
17975
-
17976
- }
17861
+ morphInfluencesSum += objectInfluences[ i ];
17977
17862
 
17978
17863
  }
17979
17864
 
17980
- // GLSL shader uses formula baseinfluence * base + sum(target * influence)
17981
- // This allows us to switch between absolute morphs and relative morphs without changing shader code
17982
- // When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)
17983
17865
  const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
17984
17866
 
17867
+
17985
17868
  program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
17986
- program.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );
17869
+ program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
17987
17870
 
17988
17871
  }
17989
17872
 
17873
+ program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures );
17874
+ program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size );
17875
+
17990
17876
  }
17991
17877
 
17992
17878
  return {
@@ -19536,19 +19422,6 @@ function getToneMappingFunction( functionName, toneMapping ) {
19536
19422
 
19537
19423
  }
19538
19424
 
19539
- function generateExtensions( parameters ) {
19540
-
19541
- const chunks = [
19542
- ( parameters.extensionDerivatives || !! parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.normalMapTangentSpace || parameters.clearcoatNormalMap || parameters.flatShading || parameters.alphaToCoverage || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',
19543
- ( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',
19544
- ( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',
19545
- ( parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''
19546
- ];
19547
-
19548
- return chunks.filter( filterEmptyLine ).join( '\n' );
19549
-
19550
- }
19551
-
19552
19425
  function generateVertexExtensions( parameters ) {
19553
19426
 
19554
19427
  const chunks = [
@@ -19651,11 +19524,7 @@ function resolveIncludes( string ) {
19651
19524
 
19652
19525
  }
19653
19526
 
19654
- const shaderChunkMap = new Map( [
19655
- [ 'encodings_fragment', 'colorspace_fragment' ], // @deprecated, r154
19656
- [ 'encodings_pars_fragment', 'colorspace_pars_fragment' ], // @deprecated, r154
19657
- [ 'output_fragment', 'opaque_fragment' ], // @deprecated, r154
19658
- ] );
19527
+ const shaderChunkMap = new Map();
19659
19528
 
19660
19529
  function includeReplacer( match, include ) {
19661
19530
 
@@ -19716,27 +19585,21 @@ function generatePrecision( parameters ) {
19716
19585
  precision ${parameters.precision} int;
19717
19586
  precision ${parameters.precision} sampler2D;
19718
19587
  precision ${parameters.precision} samplerCube;
19588
+ precision ${parameters.precision} sampler3D;
19589
+ precision ${parameters.precision} sampler2DArray;
19590
+ precision ${parameters.precision} sampler2DShadow;
19591
+ precision ${parameters.precision} samplerCubeShadow;
19592
+ precision ${parameters.precision} sampler2DArrayShadow;
19593
+ precision ${parameters.precision} isampler2D;
19594
+ precision ${parameters.precision} isampler3D;
19595
+ precision ${parameters.precision} isamplerCube;
19596
+ precision ${parameters.precision} isampler2DArray;
19597
+ precision ${parameters.precision} usampler2D;
19598
+ precision ${parameters.precision} usampler3D;
19599
+ precision ${parameters.precision} usamplerCube;
19600
+ precision ${parameters.precision} usampler2DArray;
19719
19601
  `;
19720
19602
 
19721
- if ( parameters.isWebGL2 ) {
19722
-
19723
- precisionstring += `precision ${parameters.precision} sampler3D;
19724
- precision ${parameters.precision} sampler2DArray;
19725
- precision ${parameters.precision} sampler2DShadow;
19726
- precision ${parameters.precision} samplerCubeShadow;
19727
- precision ${parameters.precision} sampler2DArrayShadow;
19728
- precision ${parameters.precision} isampler2D;
19729
- precision ${parameters.precision} isampler3D;
19730
- precision ${parameters.precision} isamplerCube;
19731
- precision ${parameters.precision} isampler2DArray;
19732
- precision ${parameters.precision} usampler2D;
19733
- precision ${parameters.precision} usampler3D;
19734
- precision ${parameters.precision} usamplerCube;
19735
- precision ${parameters.precision} usampler2DArray;
19736
- `;
19737
-
19738
- }
19739
-
19740
19603
  if ( parameters.precision === 'highp' ) {
19741
19604
 
19742
19605
  precisionstring += '\n#define HIGH_PRECISION';
@@ -19885,8 +19748,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19885
19748
  const envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );
19886
19749
  const envMapCubeUVSize = generateCubeUVSize( parameters );
19887
19750
 
19888
- const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
19889
-
19890
19751
  const customVertexExtensions = generateVertexExtensions( parameters );
19891
19752
 
19892
19753
  const customDefines = generateDefines( defines );
@@ -19917,8 +19778,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19917
19778
 
19918
19779
  prefixFragment = [
19919
19780
 
19920
- customExtensions,
19921
-
19922
19781
  '#define SHADER_TYPE ' + parameters.shaderType,
19923
19782
  '#define SHADER_NAME ' + parameters.shaderName,
19924
19783
 
@@ -20040,10 +19899,10 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20040
19899
 
20041
19900
  parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
20042
19901
  parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
20043
- ( parameters.morphColors && parameters.isWebGL2 ) ? '#define USE_MORPHCOLORS' : '',
20044
- ( parameters.morphTargetsCount > 0 && parameters.isWebGL2 ) ? '#define MORPHTARGETS_TEXTURE' : '',
20045
- ( parameters.morphTargetsCount > 0 && parameters.isWebGL2 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
20046
- ( parameters.morphTargetsCount > 0 && parameters.isWebGL2 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
19902
+ ( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
19903
+ ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
19904
+ ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
19905
+ ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
20047
19906
  parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
20048
19907
  parameters.flipSided ? '#define FLIP_SIDED' : '',
20049
19908
 
@@ -20057,7 +19916,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20057
19916
  parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
20058
19917
 
20059
19918
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
20060
- ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
20061
19919
 
20062
19920
  'uniform mat4 modelMatrix;',
20063
19921
  'uniform mat4 modelViewMatrix;',
@@ -20161,8 +20019,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20161
20019
 
20162
20020
  prefixFragment = [
20163
20021
 
20164
- customExtensions,
20165
-
20166
20022
  generatePrecision( parameters ),
20167
20023
 
20168
20024
  '#define SHADER_TYPE ' + parameters.shaderType,
@@ -20199,6 +20055,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20199
20055
  parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
20200
20056
  parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
20201
20057
 
20058
+ parameters.dispersion ? '#define USE_DISPERSION' : '',
20059
+
20202
20060
  parameters.iridescence ? '#define USE_IRIDESCENCE' : '',
20203
20061
  parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
20204
20062
  parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
@@ -20250,7 +20108,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20250
20108
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
20251
20109
 
20252
20110
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
20253
- ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
20254
20111
 
20255
20112
  'uniform mat4 viewMatrix;',
20256
20113
  'uniform vec3 cameraPosition;',
@@ -20285,7 +20142,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20285
20142
  vertexShader = unrollLoops( vertexShader );
20286
20143
  fragmentShader = unrollLoops( fragmentShader );
20287
20144
 
20288
- if ( parameters.isWebGL2 && parameters.isRawShaderMaterial !== true ) {
20145
+ if ( parameters.isRawShaderMaterial !== true ) {
20289
20146
 
20290
20147
  // GLSL 3.0 conversion for built-in materials and ShaderMaterial
20291
20148
 
@@ -20293,14 +20150,12 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20293
20150
 
20294
20151
  prefixVertex = [
20295
20152
  customVertexExtensions,
20296
- 'precision mediump sampler2DArray;',
20297
20153
  '#define attribute in',
20298
20154
  '#define varying out',
20299
20155
  '#define texture2D texture'
20300
20156
  ].join( '\n' ) + '\n' + prefixVertex;
20301
20157
 
20302
20158
  prefixFragment = [
20303
- 'precision mediump sampler2DArray;',
20304
20159
  '#define varying in',
20305
20160
  ( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
20306
20161
  ( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
@@ -20691,7 +20546,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20691
20546
  const _activeChannels = new Set();
20692
20547
  const programs = [];
20693
20548
 
20694
- const IS_WEBGL2 = capabilities.isWebGL2;
20695
20549
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
20696
20550
  const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
20697
20551
 
@@ -20808,6 +20662,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20808
20662
 
20809
20663
  const HAS_ANISOTROPY = material.anisotropy > 0;
20810
20664
  const HAS_CLEARCOAT = material.clearcoat > 0;
20665
+ const HAS_DISPERSION = material.dispersion > 0;
20811
20666
  const HAS_IRIDESCENCE = material.iridescence > 0;
20812
20667
  const HAS_SHEEN = material.sheen > 0;
20813
20668
  const HAS_TRANSMISSION = material.transmission > 0;
@@ -20855,8 +20710,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20855
20710
 
20856
20711
  const parameters = {
20857
20712
 
20858
- isWebGL2: IS_WEBGL2,
20859
-
20860
20713
  shaderID: shaderID,
20861
20714
  shaderType: material.type,
20862
20715
  shaderName: material.name,
@@ -20909,6 +20762,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20909
20762
  clearcoatNormalMap: HAS_CLEARCOAT_NORMALMAP,
20910
20763
  clearcoatRoughnessMap: HAS_CLEARCOAT_ROUGHNESSMAP,
20911
20764
 
20765
+ dispersion: HAS_DISPERSION,
20766
+
20912
20767
  iridescence: HAS_IRIDESCENCE,
20913
20768
  iridescenceMap: HAS_IRIDESCENCEMAP,
20914
20769
  iridescenceThicknessMap: HAS_IRIDESCENCE_THICKNESSMAP,
@@ -21031,16 +20886,9 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21031
20886
 
21032
20887
  index0AttributeName: material.index0AttributeName,
21033
20888
 
21034
- extensionDerivatives: HAS_EXTENSIONS && material.extensions.derivatives === true,
21035
- extensionFragDepth: HAS_EXTENSIONS && material.extensions.fragDepth === true,
21036
- extensionDrawBuffers: HAS_EXTENSIONS && material.extensions.drawBuffers === true,
21037
- extensionShaderTextureLOD: HAS_EXTENSIONS && material.extensions.shaderTextureLOD === true,
21038
20889
  extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
21039
20890
  extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
21040
20891
 
21041
- rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
21042
- rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
21043
- rendererExtensionShaderTextureLod: IS_WEBGL2 || extensions.has( 'EXT_shader_texture_lod' ),
21044
20892
  rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
21045
20893
 
21046
20894
  customProgramCacheKey: material.customProgramCacheKey()
@@ -21156,47 +21004,47 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21156
21004
 
21157
21005
  _programLayers.disableAll();
21158
21006
 
21159
- if ( parameters.isWebGL2 )
21160
- _programLayers.enable( 0 );
21161
21007
  if ( parameters.supportsVertexTextures )
21162
- _programLayers.enable( 1 );
21008
+ _programLayers.enable( 0 );
21163
21009
  if ( parameters.instancing )
21164
- _programLayers.enable( 2 );
21010
+ _programLayers.enable( 1 );
21165
21011
  if ( parameters.instancingColor )
21166
- _programLayers.enable( 3 );
21012
+ _programLayers.enable( 2 );
21167
21013
  if ( parameters.instancingMorph )
21168
- _programLayers.enable( 4 );
21014
+ _programLayers.enable( 3 );
21169
21015
  if ( parameters.matcap )
21170
- _programLayers.enable( 5 );
21016
+ _programLayers.enable( 4 );
21171
21017
  if ( parameters.envMap )
21172
- _programLayers.enable( 6 );
21018
+ _programLayers.enable( 5 );
21173
21019
  if ( parameters.normalMapObjectSpace )
21174
- _programLayers.enable( 7 );
21020
+ _programLayers.enable( 6 );
21175
21021
  if ( parameters.normalMapTangentSpace )
21176
- _programLayers.enable( 8 );
21022
+ _programLayers.enable( 7 );
21177
21023
  if ( parameters.clearcoat )
21178
- _programLayers.enable( 9 );
21024
+ _programLayers.enable( 8 );
21179
21025
  if ( parameters.iridescence )
21180
- _programLayers.enable( 10 );
21026
+ _programLayers.enable( 9 );
21181
21027
  if ( parameters.alphaTest )
21182
- _programLayers.enable( 11 );
21028
+ _programLayers.enable( 10 );
21183
21029
  if ( parameters.vertexColors )
21184
- _programLayers.enable( 12 );
21030
+ _programLayers.enable( 11 );
21185
21031
  if ( parameters.vertexAlphas )
21186
- _programLayers.enable( 13 );
21032
+ _programLayers.enable( 12 );
21187
21033
  if ( parameters.vertexUv1s )
21188
- _programLayers.enable( 14 );
21034
+ _programLayers.enable( 13 );
21189
21035
  if ( parameters.vertexUv2s )
21190
- _programLayers.enable( 15 );
21036
+ _programLayers.enable( 14 );
21191
21037
  if ( parameters.vertexUv3s )
21192
- _programLayers.enable( 16 );
21038
+ _programLayers.enable( 15 );
21193
21039
  if ( parameters.vertexTangents )
21194
- _programLayers.enable( 17 );
21040
+ _programLayers.enable( 16 );
21195
21041
  if ( parameters.anisotropy )
21196
- _programLayers.enable( 18 );
21042
+ _programLayers.enable( 17 );
21197
21043
  if ( parameters.alphaHash )
21198
- _programLayers.enable( 19 );
21044
+ _programLayers.enable( 18 );
21199
21045
  if ( parameters.batching )
21046
+ _programLayers.enable( 19 );
21047
+ if ( parameters.dispersion )
21200
21048
  _programLayers.enable( 20 );
21201
21049
 
21202
21050
  array.push( _programLayers.mask );
@@ -21772,7 +21620,7 @@ function shadowCastingAndTexturingLightsFirst( lightA, lightB ) {
21772
21620
 
21773
21621
  }
21774
21622
 
21775
- function WebGLLights( extensions, capabilities ) {
21623
+ function WebGLLights( extensions ) {
21776
21624
 
21777
21625
  const cache = new UniformsCache();
21778
21626
 
@@ -22021,41 +21869,15 @@ function WebGLLights( extensions, capabilities ) {
22021
21869
 
22022
21870
  if ( rectAreaLength > 0 ) {
22023
21871
 
22024
- if ( capabilities.isWebGL2 ) {
21872
+ if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
22025
21873
 
22026
- // WebGL 2
22027
-
22028
- if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
22029
-
22030
- state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
22031
- state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
22032
-
22033
- } else {
22034
-
22035
- state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
22036
- state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
22037
-
22038
- }
21874
+ state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
21875
+ state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
22039
21876
 
22040
21877
  } else {
22041
21878
 
22042
- // WebGL 1
22043
-
22044
- if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
22045
-
22046
- state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
22047
- state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
22048
-
22049
- } else if ( extensions.has( 'OES_texture_half_float_linear' ) === true ) {
22050
-
22051
- state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
22052
- state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
22053
-
22054
- } else {
22055
-
22056
- console.error( 'THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.' );
22057
-
22058
- }
21879
+ state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
21880
+ state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
22059
21881
 
22060
21882
  }
22061
21883
 
@@ -22208,14 +22030,16 @@ function WebGLLights( extensions, capabilities ) {
22208
22030
 
22209
22031
  }
22210
22032
 
22211
- function WebGLRenderState( extensions, capabilities ) {
22033
+ function WebGLRenderState( extensions ) {
22212
22034
 
22213
- const lights = new WebGLLights( extensions, capabilities );
22035
+ const lights = new WebGLLights( extensions );
22214
22036
 
22215
22037
  const lightsArray = [];
22216
22038
  const shadowsArray = [];
22217
22039
 
22218
- function init() {
22040
+ function init( camera ) {
22041
+
22042
+ state.camera = camera;
22219
22043
 
22220
22044
  lightsArray.length = 0;
22221
22045
  shadowsArray.length = 0;
@@ -22250,7 +22074,11 @@ function WebGLRenderState( extensions, capabilities ) {
22250
22074
  lightsArray: lightsArray,
22251
22075
  shadowsArray: shadowsArray,
22252
22076
 
22253
- lights: lights
22077
+ camera: null,
22078
+
22079
+ lights: lights,
22080
+
22081
+ transmissionRenderTarget: {}
22254
22082
  };
22255
22083
 
22256
22084
  return {
@@ -22265,7 +22093,7 @@ function WebGLRenderState( extensions, capabilities ) {
22265
22093
 
22266
22094
  }
22267
22095
 
22268
- function WebGLRenderStates( extensions, capabilities ) {
22096
+ function WebGLRenderStates( extensions ) {
22269
22097
 
22270
22098
  let renderStates = new WeakMap();
22271
22099
 
@@ -22276,14 +22104,14 @@ function WebGLRenderStates( extensions, capabilities ) {
22276
22104
 
22277
22105
  if ( renderStateArray === undefined ) {
22278
22106
 
22279
- renderState = new WebGLRenderState( extensions, capabilities );
22107
+ renderState = new WebGLRenderState( extensions );
22280
22108
  renderStates.set( scene, [ renderState ] );
22281
22109
 
22282
22110
  } else {
22283
22111
 
22284
22112
  if ( renderCallDepth >= renderStateArray.length ) {
22285
22113
 
22286
- renderState = new WebGLRenderState( extensions, capabilities );
22114
+ renderState = new WebGLRenderState( extensions );
22287
22115
  renderStateArray.push( renderState );
22288
22116
 
22289
22117
  } else {
@@ -22405,7 +22233,7 @@ const vertex = "void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";
22405
22233
 
22406
22234
  const fragment = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";
22407
22235
 
22408
- function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22236
+ function WebGLShadowMap( renderer, objects, capabilities ) {
22409
22237
 
22410
22238
  let _frustum = new Frustum();
22411
22239
 
@@ -22419,7 +22247,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22419
22247
 
22420
22248
  _materialCache = {},
22421
22249
 
22422
- _maxTextureSize = _capabilities.maxTextureSize;
22250
+ _maxTextureSize = capabilities.maxTextureSize;
22423
22251
 
22424
22252
  const shadowSide = { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, [ DoubleSide ]: DoubleSide };
22425
22253
 
@@ -22469,11 +22297,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22469
22297
 
22470
22298
  if ( lights.length === 0 ) return;
22471
22299
 
22472
- const currentRenderTarget = _renderer.getRenderTarget();
22473
- const activeCubeFace = _renderer.getActiveCubeFace();
22474
- const activeMipmapLevel = _renderer.getActiveMipmapLevel();
22300
+ const currentRenderTarget = renderer.getRenderTarget();
22301
+ const activeCubeFace = renderer.getActiveCubeFace();
22302
+ const activeMipmapLevel = renderer.getActiveMipmapLevel();
22475
22303
 
22476
- const _state = _renderer.state;
22304
+ const _state = renderer.state;
22477
22305
 
22478
22306
  // Set GL state for depth map.
22479
22307
  _state.setBlending( NoBlending );
@@ -22547,8 +22375,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22547
22375
 
22548
22376
  }
22549
22377
 
22550
- _renderer.setRenderTarget( shadow.map );
22551
- _renderer.clear();
22378
+ renderer.setRenderTarget( shadow.map );
22379
+ renderer.clear();
22552
22380
 
22553
22381
  const viewportCount = shadow.getViewportCount();
22554
22382
 
@@ -22589,13 +22417,13 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22589
22417
 
22590
22418
  scope.needsUpdate = false;
22591
22419
 
22592
- _renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );
22420
+ renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );
22593
22421
 
22594
22422
  };
22595
22423
 
22596
22424
  function VSMPass( shadow, camera ) {
22597
22425
 
22598
- const geometry = _objects.update( fullScreenMesh );
22426
+ const geometry = objects.update( fullScreenMesh );
22599
22427
 
22600
22428
  if ( shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples ) {
22601
22429
 
@@ -22618,18 +22446,18 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22618
22446
  shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;
22619
22447
  shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;
22620
22448
  shadowMaterialVertical.uniforms.radius.value = shadow.radius;
22621
- _renderer.setRenderTarget( shadow.mapPass );
22622
- _renderer.clear();
22623
- _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );
22449
+ renderer.setRenderTarget( shadow.mapPass );
22450
+ renderer.clear();
22451
+ renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );
22624
22452
 
22625
22453
  // horizontal pass
22626
22454
 
22627
22455
  shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;
22628
22456
  shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;
22629
22457
  shadowMaterialHorizontal.uniforms.radius.value = shadow.radius;
22630
- _renderer.setRenderTarget( shadow.map );
22631
- _renderer.clear();
22632
- _renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null );
22458
+ renderer.setRenderTarget( shadow.map );
22459
+ renderer.clear();
22460
+ renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null );
22633
22461
 
22634
22462
  }
22635
22463
 
@@ -22647,7 +22475,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22647
22475
 
22648
22476
  result = ( light.isPointLight === true ) ? _distanceMaterial : _depthMaterial;
22649
22477
 
22650
- if ( ( _renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
22478
+ if ( ( renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
22651
22479
  ( material.displacementMap && material.displacementScale !== 0 ) ||
22652
22480
  ( material.alphaMap && material.alphaTest > 0 ) ||
22653
22481
  ( material.map && material.alphaTest > 0 ) ) {
@@ -22712,7 +22540,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22712
22540
 
22713
22541
  if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {
22714
22542
 
22715
- const materialProperties = _renderer.properties.get( result );
22543
+ const materialProperties = renderer.properties.get( result );
22716
22544
  materialProperties.light = light;
22717
22545
 
22718
22546
  }
@@ -22733,7 +22561,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22733
22561
 
22734
22562
  object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
22735
22563
 
22736
- const geometry = _objects.update( object );
22564
+ const geometry = objects.update( object );
22737
22565
  const material = object.material;
22738
22566
 
22739
22567
  if ( Array.isArray( material ) ) {
@@ -22749,11 +22577,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22749
22577
 
22750
22578
  const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
22751
22579
 
22752
- object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22580
+ object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22753
22581
 
22754
- _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
22582
+ renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
22755
22583
 
22756
- object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22584
+ object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22757
22585
 
22758
22586
  }
22759
22587
 
@@ -22763,11 +22591,11 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22763
22591
 
22764
22592
  const depthMaterial = getDepthMaterial( object, material, light, type );
22765
22593
 
22766
- object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22594
+ object.onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22767
22595
 
22768
- _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
22596
+ renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
22769
22597
 
22770
- object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22598
+ object.onAfterShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22771
22599
 
22772
22600
  }
22773
22601
 
@@ -22813,9 +22641,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22813
22641
 
22814
22642
  }
22815
22643
 
22816
- function WebGLState( gl, extensions, capabilities ) {
22817
-
22818
- const isWebGL2 = capabilities.isWebGL2;
22644
+ function WebGLState( gl ) {
22819
22645
 
22820
22646
  function ColorBuffer() {
22821
22647
 
@@ -23187,7 +23013,7 @@ function WebGLState( gl, extensions, capabilities ) {
23187
23013
 
23188
23014
  for ( let i = 0; i < count; i ++ ) {
23189
23015
 
23190
- if ( isWebGL2 && ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) ) {
23016
+ if ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) {
23191
23017
 
23192
23018
  gl.texImage3D( target, 0, gl.RGBA, 1, 1, dimensions, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
23193
23019
 
@@ -23206,13 +23032,8 @@ function WebGLState( gl, extensions, capabilities ) {
23206
23032
  const emptyTextures = {};
23207
23033
  emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
23208
23034
  emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
23209
-
23210
- if ( isWebGL2 ) {
23211
-
23212
- emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
23213
- emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
23214
-
23215
- }
23035
+ emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
23036
+ emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
23216
23037
 
23217
23038
  // init
23218
23039
 
@@ -23261,21 +23082,17 @@ function WebGLState( gl, extensions, capabilities ) {
23261
23082
 
23262
23083
  currentBoundFramebuffers[ target ] = framebuffer;
23263
23084
 
23264
- if ( isWebGL2 ) {
23085
+ // gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
23265
23086
 
23266
- // gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
23087
+ if ( target === gl.DRAW_FRAMEBUFFER ) {
23267
23088
 
23268
- if ( target === gl.DRAW_FRAMEBUFFER ) {
23089
+ currentBoundFramebuffers[ gl.FRAMEBUFFER ] = framebuffer;
23269
23090
 
23270
- currentBoundFramebuffers[ gl.FRAMEBUFFER ] = framebuffer;
23271
-
23272
- }
23273
-
23274
- if ( target === gl.FRAMEBUFFER ) {
23091
+ }
23275
23092
 
23276
- currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] = framebuffer;
23093
+ if ( target === gl.FRAMEBUFFER ) {
23277
23094
 
23278
- }
23095
+ currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] = framebuffer;
23279
23096
 
23280
23097
  }
23281
23098
 
@@ -23334,23 +23151,10 @@ function WebGLState( gl, extensions, capabilities ) {
23334
23151
 
23335
23152
  if ( needsUpdate ) {
23336
23153
 
23337
- if ( capabilities.isWebGL2 ) {
23338
-
23339
- gl.drawBuffers( drawBuffers );
23340
-
23341
- } else if ( extensions.has( 'WEBGL_draw_buffers' ) === true ) {
23342
-
23343
- extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
23344
-
23345
- } else {
23346
-
23347
- throw new Error( 'THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension' );
23348
-
23349
- }
23154
+ gl.drawBuffers( drawBuffers );
23350
23155
 
23351
23156
  }
23352
23157
 
23353
-
23354
23158
  }
23355
23159
 
23356
23160
  function useProgram( program ) {
@@ -23375,23 +23179,8 @@ function WebGLState( gl, extensions, capabilities ) {
23375
23179
  [ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT
23376
23180
  };
23377
23181
 
23378
- if ( isWebGL2 ) {
23379
-
23380
- equationToGL[ MinEquation ] = gl.MIN;
23381
- equationToGL[ MaxEquation ] = gl.MAX;
23382
-
23383
- } else {
23384
-
23385
- const extension = extensions.get( 'EXT_blend_minmax' );
23386
-
23387
- if ( extension !== null ) {
23388
-
23389
- equationToGL[ MinEquation ] = extension.MIN_EXT;
23390
- equationToGL[ MaxEquation ] = extension.MAX_EXT;
23391
-
23392
- }
23393
-
23394
- }
23182
+ equationToGL[ MinEquation ] = gl.MIN;
23183
+ equationToGL[ MaxEquation ] = gl.MAX;
23395
23184
 
23396
23185
  const factorToGL = {
23397
23186
  [ ZeroFactor ]: gl.ZERO,
@@ -24015,13 +23804,8 @@ function WebGLState( gl, extensions, capabilities ) {
24015
23804
  gl.activeTexture( gl.TEXTURE0 );
24016
23805
 
24017
23806
  gl.bindFramebuffer( gl.FRAMEBUFFER, null );
24018
-
24019
- if ( isWebGL2 === true ) {
24020
-
24021
- gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
24022
- gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
24023
-
24024
- }
23807
+ gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
23808
+ gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
24025
23809
 
24026
23810
  gl.useProgram( null );
24027
23811
 
@@ -24128,7 +23912,6 @@ function WebGLState( gl, extensions, capabilities ) {
24128
23912
 
24129
23913
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
24130
23914
 
24131
- const isWebGL2 = capabilities.isWebGL2;
24132
23915
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
24133
23916
  const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
24134
23917
  const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
@@ -24170,7 +23953,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24170
23953
 
24171
23954
  }
24172
23955
 
24173
- function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {
23956
+ function resizeImage( image, needsNewCanvas, maxSize ) {
24174
23957
 
24175
23958
  let scale = 1;
24176
23959
 
@@ -24186,7 +23969,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24186
23969
 
24187
23970
  // only perform resize if necessary
24188
23971
 
24189
- if ( scale < 1 || needsPowerOfTwo === true ) {
23972
+ if ( scale < 1 ) {
24190
23973
 
24191
23974
  // only perform resize for certain image types
24192
23975
 
@@ -24195,10 +23978,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24195
23978
  ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
24196
23979
  ( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
24197
23980
 
24198
- const floor = needsPowerOfTwo ? floorPowerOfTwo : Math.floor;
24199
-
24200
- const width = floor( scale * dimensions.width );
24201
- const height = floor( scale * dimensions.height );
23981
+ const width = Math.floor( scale * dimensions.width );
23982
+ const height = Math.floor( scale * dimensions.height );
24202
23983
 
24203
23984
  if ( _canvas === undefined ) _canvas = createCanvas( width, height );
24204
23985
 
@@ -24234,27 +24015,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24234
24015
 
24235
24016
  }
24236
24017
 
24237
- function isPowerOfTwo$1( image ) {
24238
-
24239
- const dimensions = getDimensions( image );
24240
-
24241
- return isPowerOfTwo( dimensions.width ) && isPowerOfTwo( dimensions.height );
24242
-
24243
- }
24244
-
24245
- function textureNeedsPowerOfTwo( texture ) {
24246
-
24247
- if ( isWebGL2 ) return false;
24018
+ function textureNeedsGenerateMipmaps( texture ) {
24248
24019
 
24249
- return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||
24250
- ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
24251
-
24252
- }
24253
-
24254
- function textureNeedsGenerateMipmaps( texture, supportsMips ) {
24255
-
24256
- return texture.generateMipmaps && supportsMips &&
24257
- texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
24020
+ return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
24258
24021
 
24259
24022
  }
24260
24023
 
@@ -24266,8 +24029,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24266
24029
 
24267
24030
  function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
24268
24031
 
24269
- if ( isWebGL2 === false ) return glFormat;
24270
-
24271
24032
  if ( internalFormatName !== null ) {
24272
24033
 
24273
24034
  if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
@@ -24316,6 +24077,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24316
24077
 
24317
24078
  }
24318
24079
 
24080
+ if ( glFormat === _gl.RGB ) {
24081
+
24082
+ if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
24083
+
24084
+ }
24085
+
24319
24086
  if ( glFormat === _gl.RGBA ) {
24320
24087
 
24321
24088
  const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
@@ -24340,9 +24107,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24340
24107
 
24341
24108
  }
24342
24109
 
24343
- function getMipLevels( texture, image, supportsMips ) {
24110
+ function getMipLevels( texture, image ) {
24344
24111
 
24345
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
24112
+ if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
24346
24113
 
24347
24114
  return Math.log2( Math.max( image.width, image.height ) ) + 1;
24348
24115
 
@@ -24366,20 +24133,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24366
24133
 
24367
24134
  }
24368
24135
 
24369
- // Fallback filters for non-power-of-2 textures
24370
-
24371
- function filterFallback( f ) {
24372
-
24373
- if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
24374
-
24375
- return _gl.NEAREST;
24376
-
24377
- }
24378
-
24379
- return _gl.LINEAR;
24380
-
24381
- }
24382
-
24383
24136
  //
24384
24137
 
24385
24138
  function onTextureDispose( event ) {
@@ -24697,7 +24450,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24697
24450
  [ NotEqualCompare ]: _gl.NOTEQUAL
24698
24451
  };
24699
24452
 
24700
- function setTextureParameters( textureType, texture, supportsMips ) {
24453
+ function setTextureParameters( textureType, texture ) {
24701
24454
 
24702
24455
  if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
24703
24456
  ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
@@ -24707,48 +24460,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24707
24460
 
24708
24461
  }
24709
24462
 
24710
- if ( supportsMips ) {
24711
-
24712
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
24713
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
24714
-
24715
- if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
24463
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
24464
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
24716
24465
 
24717
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
24466
+ if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
24718
24467
 
24719
- }
24720
-
24721
- _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
24722
- _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
24723
-
24724
- } else {
24725
-
24726
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
24727
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
24728
-
24729
- if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
24730
-
24731
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );
24732
-
24733
- }
24734
-
24735
- if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {
24736
-
24737
- console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
24738
-
24739
- }
24740
-
24741
- _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
24742
- _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
24743
-
24744
- if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {
24745
-
24746
- console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );
24747
-
24748
- }
24468
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
24749
24469
 
24750
24470
  }
24751
24471
 
24472
+ _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
24473
+ _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
24474
+
24752
24475
  if ( texture.compareFunction ) {
24753
24476
 
24754
24477
  _gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
@@ -24760,8 +24483,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24760
24483
 
24761
24484
  if ( texture.magFilter === NearestFilter ) return;
24762
24485
  if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
24763
- if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
24764
- if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
24486
+ if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
24765
24487
 
24766
24488
  if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
24767
24489
 
@@ -24919,97 +24641,41 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24919
24641
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
24920
24642
  _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24921
24643
 
24922
- const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false;
24923
- let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
24644
+ let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
24924
24645
  image = verifyColorSpace( texture, image );
24925
24646
 
24926
- const supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
24927
- glFormat = utils.convert( texture.format, texture.colorSpace );
24647
+ const glFormat = utils.convert( texture.format, texture.colorSpace );
24928
24648
 
24929
- let glType = utils.convert( texture.type ),
24930
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
24649
+ const glType = utils.convert( texture.type );
24650
+ let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
24931
24651
 
24932
- setTextureParameters( textureType, texture, supportsMips );
24652
+ setTextureParameters( textureType, texture );
24933
24653
 
24934
24654
  let mipmap;
24935
24655
  const mipmaps = texture.mipmaps;
24936
24656
 
24937
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
24657
+ const useTexStorage = ( texture.isVideoTexture !== true );
24938
24658
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
24939
24659
  const dataReady = source.dataReady;
24940
- const levels = getMipLevels( texture, image, supportsMips );
24660
+ const levels = getMipLevels( texture, image );
24941
24661
 
24942
24662
  if ( texture.isDepthTexture ) {
24943
24663
 
24944
24664
  // populate depth texture with dummy data
24945
24665
 
24946
- glInternalFormat = _gl.DEPTH_COMPONENT;
24947
-
24948
- if ( isWebGL2 ) {
24949
-
24950
- if ( texture.type === FloatType ) {
24951
-
24952
- glInternalFormat = _gl.DEPTH_COMPONENT32F;
24953
-
24954
- } else if ( texture.type === UnsignedIntType ) {
24955
-
24956
- glInternalFormat = _gl.DEPTH_COMPONENT24;
24957
-
24958
- } else if ( texture.type === UnsignedInt248Type ) {
24959
-
24960
- glInternalFormat = _gl.DEPTH24_STENCIL8;
24961
-
24962
- } else {
24963
-
24964
- glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
24965
-
24966
- }
24967
-
24968
- } else {
24969
-
24970
- if ( texture.type === FloatType ) {
24971
-
24972
- console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
24973
-
24974
- }
24975
-
24976
- }
24977
-
24978
- // validation checks for WebGL 1
24979
-
24980
- if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
24981
-
24982
- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
24983
- // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
24984
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
24985
- if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
24986
-
24987
- console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
24988
-
24989
- texture.type = UnsignedIntType;
24990
- glType = utils.convert( texture.type );
24991
-
24992
- }
24993
-
24994
- }
24666
+ glInternalFormat = _gl.DEPTH_COMPONENT16;
24995
24667
 
24996
- if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
24668
+ if ( texture.type === FloatType ) {
24997
24669
 
24998
- // Depth stencil textures need the DEPTH_STENCIL internal format
24999
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
25000
- glInternalFormat = _gl.DEPTH_STENCIL;
24670
+ glInternalFormat = _gl.DEPTH_COMPONENT32F;
25001
24671
 
25002
- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
25003
- // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
25004
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
25005
- if ( texture.type !== UnsignedInt248Type ) {
24672
+ } else if ( texture.type === UnsignedIntType ) {
25006
24673
 
25007
- console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
24674
+ glInternalFormat = _gl.DEPTH_COMPONENT24;
25008
24675
 
25009
- texture.type = UnsignedInt248Type;
25010
- glType = utils.convert( texture.type );
24676
+ } else if ( texture.type === UnsignedInt248Type ) {
25011
24677
 
25012
- }
24678
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
25013
24679
 
25014
24680
  }
25015
24681
 
@@ -25035,7 +24701,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25035
24701
  // if there are no manual mipmaps
25036
24702
  // set 0 level mipmap and then use GL to generate other mipmap levels
25037
24703
 
25038
- if ( mipmaps.length > 0 && supportsMips ) {
24704
+ if ( mipmaps.length > 0 ) {
25039
24705
 
25040
24706
  if ( useTexStorage && allocateMemory ) {
25041
24707
 
@@ -25282,7 +24948,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25282
24948
  // if there are no manual mipmaps
25283
24949
  // set 0 level mipmap and then use GL to generate other mipmap levels
25284
24950
 
25285
- if ( mipmaps.length > 0 && supportsMips ) {
24951
+ if ( mipmaps.length > 0 ) {
25286
24952
 
25287
24953
  if ( useTexStorage && allocateMemory ) {
25288
24954
 
@@ -25342,7 +25008,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25342
25008
 
25343
25009
  }
25344
25010
 
25345
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25011
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
25346
25012
 
25347
25013
  generateMipmap( textureType );
25348
25014
 
@@ -25392,7 +25058,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25392
25058
 
25393
25059
  if ( ! isCompressed && ! isDataTexture ) {
25394
25060
 
25395
- cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
25061
+ cubeImage[ i ] = resizeImage( texture.image[ i ], true, capabilities.maxCubemapSize );
25396
25062
 
25397
25063
  } else {
25398
25064
 
@@ -25405,17 +25071,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25405
25071
  }
25406
25072
 
25407
25073
  const image = cubeImage[ 0 ],
25408
- supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
25409
25074
  glFormat = utils.convert( texture.format, texture.colorSpace ),
25410
25075
  glType = utils.convert( texture.type ),
25411
25076
  glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
25412
25077
 
25413
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
25078
+ const useTexStorage = ( texture.isVideoTexture !== true );
25414
25079
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
25415
25080
  const dataReady = source.dataReady;
25416
- let levels = getMipLevels( texture, image, supportsMips );
25081
+ let levels = getMipLevels( texture, image );
25417
25082
 
25418
- setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
25083
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
25419
25084
 
25420
25085
  let mipmaps;
25421
25086
 
@@ -25580,7 +25245,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25580
25245
 
25581
25246
  }
25582
25247
 
25583
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25248
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
25584
25249
 
25585
25250
  // We assume images for cube map have the same size.
25586
25251
  generateMipmap( _gl.TEXTURE_CUBE_MAP );
@@ -25722,7 +25387,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25722
25387
 
25723
25388
  } else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
25724
25389
 
25725
- let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
25390
+ let glInternalFormat = _gl.DEPTH_COMPONENT24;
25726
25391
 
25727
25392
  if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
25728
25393
 
@@ -26001,7 +25666,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26001
25666
 
26002
25667
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
26003
25668
  const isMultipleRenderTargets = ( textures.length > 1 );
26004
- const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
26005
25669
 
26006
25670
  if ( ! isMultipleRenderTargets ) {
26007
25671
 
@@ -26024,7 +25688,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26024
25688
 
26025
25689
  for ( let i = 0; i < 6; i ++ ) {
26026
25690
 
26027
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25691
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26028
25692
 
26029
25693
  renderTargetProperties.__webglFramebuffer[ i ] = [];
26030
25694
 
@@ -26044,7 +25708,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26044
25708
 
26045
25709
  } else {
26046
25710
 
26047
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25711
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26048
25712
 
26049
25713
  renderTargetProperties.__webglFramebuffer = [];
26050
25714
 
@@ -26062,31 +25726,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26062
25726
 
26063
25727
  if ( isMultipleRenderTargets ) {
26064
25728
 
26065
- if ( capabilities.drawBuffers ) {
26066
-
26067
- for ( let i = 0, il = textures.length; i < il; i ++ ) {
26068
-
26069
- const attachmentProperties = properties.get( textures[ i ] );
25729
+ for ( let i = 0, il = textures.length; i < il; i ++ ) {
26070
25730
 
26071
- if ( attachmentProperties.__webglTexture === undefined ) {
25731
+ const attachmentProperties = properties.get( textures[ i ] );
26072
25732
 
26073
- attachmentProperties.__webglTexture = _gl.createTexture();
25733
+ if ( attachmentProperties.__webglTexture === undefined ) {
26074
25734
 
26075
- info.memory.textures ++;
25735
+ attachmentProperties.__webglTexture = _gl.createTexture();
26076
25736
 
26077
- }
25737
+ info.memory.textures ++;
26078
25738
 
26079
25739
  }
26080
25740
 
26081
- } else {
26082
-
26083
- console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
26084
-
26085
25741
  }
26086
25742
 
26087
25743
  }
26088
25744
 
26089
- if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
25745
+ if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
26090
25746
 
26091
25747
  renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
26092
25748
  renderTargetProperties.__webglColorRenderbuffer = [];
@@ -26130,11 +25786,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26130
25786
  if ( isCube ) {
26131
25787
 
26132
25788
  state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
26133
- setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
25789
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
26134
25790
 
26135
25791
  for ( let i = 0; i < 6; i ++ ) {
26136
25792
 
26137
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25793
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26138
25794
 
26139
25795
  for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
26140
25796
 
@@ -26150,7 +25806,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26150
25806
 
26151
25807
  }
26152
25808
 
26153
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25809
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
26154
25810
 
26155
25811
  generateMipmap( _gl.TEXTURE_CUBE_MAP );
26156
25812
 
@@ -26166,10 +25822,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26166
25822
  const attachmentProperties = properties.get( attachment );
26167
25823
 
26168
25824
  state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
26169
- setTextureParameters( _gl.TEXTURE_2D, attachment, supportsMips );
25825
+ setTextureParameters( _gl.TEXTURE_2D, attachment );
26170
25826
  setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
26171
25827
 
26172
- if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) {
25828
+ if ( textureNeedsGenerateMipmaps( attachment ) ) {
26173
25829
 
26174
25830
  generateMipmap( _gl.TEXTURE_2D );
26175
25831
 
@@ -26185,15 +25841,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26185
25841
 
26186
25842
  if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
26187
25843
 
26188
- if ( isWebGL2 ) {
26189
-
26190
- glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
26191
-
26192
- } else {
26193
-
26194
- console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
26195
-
26196
- }
25844
+ glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
26197
25845
 
26198
25846
  }
26199
25847
 
@@ -26204,9 +25852,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26204
25852
  }
26205
25853
 
26206
25854
  state.bindTexture( glTextureType, textureProperties.__webglTexture );
26207
- setTextureParameters( glTextureType, texture, supportsMips );
25855
+ setTextureParameters( glTextureType, texture );
26208
25856
 
26209
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25857
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26210
25858
 
26211
25859
  for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
26212
25860
 
@@ -26220,7 +25868,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26220
25868
 
26221
25869
  }
26222
25870
 
26223
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25871
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
26224
25872
 
26225
25873
  generateMipmap( glTextureType );
26226
25874
 
@@ -26242,15 +25890,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26242
25890
 
26243
25891
  function updateRenderTargetMipmap( renderTarget ) {
26244
25892
 
26245
- const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
26246
-
26247
25893
  const textures = renderTarget.textures;
26248
25894
 
26249
25895
  for ( let i = 0, il = textures.length; i < il; i ++ ) {
26250
25896
 
26251
25897
  const texture = textures[ i ];
26252
25898
 
26253
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25899
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
26254
25900
 
26255
25901
  const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
26256
25902
  const webglTexture = properties.get( texture ).__webglTexture;
@@ -26265,109 +25911,120 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26265
25911
 
26266
25912
  }
26267
25913
 
25914
+ const invalidationArrayRead = [];
25915
+ const invalidationArrayDraw = [];
25916
+
26268
25917
  function updateMultisampleRenderTarget( renderTarget ) {
26269
25918
 
26270
- if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
25919
+ if ( renderTarget.samples > 0 ) {
26271
25920
 
26272
- const textures = renderTarget.textures;
26273
- const width = renderTarget.width;
26274
- const height = renderTarget.height;
26275
- let mask = _gl.COLOR_BUFFER_BIT;
26276
- const invalidationArray = [];
26277
- const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
26278
- const renderTargetProperties = properties.get( renderTarget );
26279
- const isMultipleRenderTargets = ( textures.length > 1 );
25921
+ if ( useMultisampledRTT( renderTarget ) === false ) {
26280
25922
 
26281
- // If MRT we need to remove FBO attachments
26282
- if ( isMultipleRenderTargets ) {
25923
+ const textures = renderTarget.textures;
25924
+ const width = renderTarget.width;
25925
+ const height = renderTarget.height;
25926
+ let mask = _gl.COLOR_BUFFER_BIT;
25927
+ const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
25928
+ const renderTargetProperties = properties.get( renderTarget );
25929
+ const isMultipleRenderTargets = ( textures.length > 1 );
26283
25930
 
26284
- for ( let i = 0; i < textures.length; i ++ ) {
25931
+ // If MRT we need to remove FBO attachments
25932
+ if ( isMultipleRenderTargets ) {
25933
+
25934
+ for ( let i = 0; i < textures.length; i ++ ) {
26285
25935
 
26286
- state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
26287
- _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
25936
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
25937
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, null );
26288
25938
 
26289
- state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
26290
- _gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
25939
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
25940
+ _gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, null, 0 );
25941
+
25942
+ }
26291
25943
 
26292
25944
  }
26293
25945
 
26294
- }
25946
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
25947
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
26295
25948
 
26296
- state.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
26297
- state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
25949
+ for ( let i = 0; i < textures.length; i ++ ) {
26298
25950
 
26299
- for ( let i = 0; i < textures.length; i ++ ) {
25951
+ if ( renderTarget.resolveDepthBuffer ) {
26300
25952
 
26301
- invalidationArray.push( _gl.COLOR_ATTACHMENT0 + i );
25953
+ if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
26302
25954
 
26303
- if ( renderTarget.depthBuffer ) {
25955
+ // resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
26304
25956
 
26305
- invalidationArray.push( depthStyle );
25957
+ if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
26306
25958
 
26307
- }
25959
+ }
26308
25960
 
26309
- const ignoreDepthValues = ( renderTargetProperties.__ignoreDepthValues !== undefined ) ? renderTargetProperties.__ignoreDepthValues : false;
25961
+ if ( isMultipleRenderTargets ) {
26310
25962
 
26311
- if ( ignoreDepthValues === false ) {
25963
+ _gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
26312
25964
 
26313
- if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
26314
- if ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
25965
+ const webglTexture = properties.get( textures[ i ] ).__webglTexture;
25966
+ _gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
26315
25967
 
26316
- }
25968
+ }
26317
25969
 
26318
- if ( isMultipleRenderTargets ) {
25970
+ _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
26319
25971
 
26320
- _gl.framebufferRenderbuffer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
25972
+ if ( supportsInvalidateFramebuffer === true ) {
26321
25973
 
26322
- }
25974
+ invalidationArrayRead.length = 0;
25975
+ invalidationArrayDraw.length = 0;
26323
25976
 
26324
- if ( ignoreDepthValues === true ) {
25977
+ invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );
26325
25978
 
26326
- _gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, [ depthStyle ] );
26327
- _gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
25979
+ if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {
26328
25980
 
26329
- }
25981
+ invalidationArrayRead.push( depthStyle );
25982
+ invalidationArrayDraw.push( depthStyle );
26330
25983
 
26331
- if ( isMultipleRenderTargets ) {
25984
+ _gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, invalidationArrayDraw );
25985
+
25986
+ }
26332
25987
 
26333
- const webglTexture = properties.get( textures[ i ] ).__webglTexture;
26334
- _gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, webglTexture, 0 );
25988
+ _gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArrayRead );
25989
+
25990
+ }
26335
25991
 
26336
25992
  }
26337
25993
 
26338
- _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );
25994
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
25995
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
26339
25996
 
26340
- if ( supportsInvalidateFramebuffer ) {
25997
+ // If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
25998
+ if ( isMultipleRenderTargets ) {
26341
25999
 
26342
- _gl.invalidateFramebuffer( _gl.READ_FRAMEBUFFER, invalidationArray );
26000
+ for ( let i = 0; i < textures.length; i ++ ) {
26343
26001
 
26344
- }
26002
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
26003
+ _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
26345
26004
 
26005
+ const webglTexture = properties.get( textures[ i ] ).__webglTexture;
26346
26006
 
26347
- }
26007
+ state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
26008
+ _gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
26348
26009
 
26349
- state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
26350
- state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
26010
+ }
26351
26011
 
26352
- // If MRT since pre-blit we removed the FBO we need to reconstruct the attachments
26353
- if ( isMultipleRenderTargets ) {
26012
+ }
26354
26013
 
26355
- for ( let i = 0; i < textures.length; i ++ ) {
26014
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
26356
26015
 
26357
- state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
26358
- _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[ i ] );
26016
+ } else {
26017
+
26018
+ if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {
26359
26019
 
26360
- const webglTexture = properties.get( textures[ i ] ).__webglTexture;
26020
+ const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
26361
26021
 
26362
- state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
26363
- _gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, webglTexture, 0 );
26022
+ _gl.invalidateFramebuffer( _gl.DRAW_FRAMEBUFFER, [ depthStyle ] );
26364
26023
 
26365
26024
  }
26366
26025
 
26367
26026
  }
26368
26027
 
26369
- state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );
26370
-
26371
26028
  }
26372
26029
 
26373
26030
  }
@@ -26382,7 +26039,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26382
26039
 
26383
26040
  const renderTargetProperties = properties.get( renderTarget );
26384
26041
 
26385
- return isWebGL2 && renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
26042
+ return renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
26386
26043
 
26387
26044
  }
26388
26045
 
@@ -26407,7 +26064,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26407
26064
  const format = texture.format;
26408
26065
  const type = texture.type;
26409
26066
 
26410
- if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
26067
+ if ( texture.isCompressedTexture === true || texture.isVideoTexture === true ) return image;
26411
26068
 
26412
26069
  if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
26413
26070
 
@@ -26415,36 +26072,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26415
26072
 
26416
26073
  if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
26417
26074
 
26418
- if ( isWebGL2 === false ) {
26075
+ // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
26419
26076
 
26420
- // in WebGL 1, try to use EXT_sRGB extension and unsized formats
26077
+ if ( format !== RGBAFormat || type !== UnsignedByteType ) {
26421
26078
 
26422
- if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) {
26423
-
26424
- texture.format = _SRGBAFormat;
26425
-
26426
- // it's not possible to generate mips in WebGL 1 with this extension
26427
-
26428
- texture.minFilter = LinearFilter;
26429
- texture.generateMipmaps = false;
26430
-
26431
- } else {
26432
-
26433
- // slow fallback (CPU decode)
26434
-
26435
- image = ImageUtils.sRGBToLinear( image );
26436
-
26437
- }
26438
-
26439
- } else {
26440
-
26441
- // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
26442
-
26443
- if ( format !== RGBAFormat || type !== UnsignedByteType ) {
26444
-
26445
- console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
26446
-
26447
- }
26079
+ console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
26448
26080
 
26449
26081
  }
26450
26082
 
@@ -26508,9 +26140,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26508
26140
 
26509
26141
  }
26510
26142
 
26511
- function WebGLUtils( gl, extensions, capabilities ) {
26512
-
26513
- const isWebGL2 = capabilities.isWebGL2;
26143
+ function WebGLUtils( gl, extensions ) {
26514
26144
 
26515
26145
  function convert( p, colorSpace = NoColorSpace ) {
26516
26146
 
@@ -26521,6 +26151,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
26521
26151
  if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
26522
26152
  if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
26523
26153
  if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
26154
+ if ( p === UnsignedInt5999Type ) return gl.UNSIGNED_INT_5_9_9_9_REV;
26524
26155
 
26525
26156
  if ( p === ByteType ) return gl.BYTE;
26526
26157
  if ( p === ShortType ) return gl.SHORT;
@@ -26528,50 +26159,16 @@ function WebGLUtils( gl, extensions, capabilities ) {
26528
26159
  if ( p === IntType ) return gl.INT;
26529
26160
  if ( p === UnsignedIntType ) return gl.UNSIGNED_INT;
26530
26161
  if ( p === FloatType ) return gl.FLOAT;
26531
-
26532
- if ( p === HalfFloatType ) {
26533
-
26534
- if ( isWebGL2 ) return gl.HALF_FLOAT;
26535
-
26536
- extension = extensions.get( 'OES_texture_half_float' );
26537
-
26538
- if ( extension !== null ) {
26539
-
26540
- return extension.HALF_FLOAT_OES;
26541
-
26542
- } else {
26543
-
26544
- return null;
26545
-
26546
- }
26547
-
26548
- }
26162
+ if ( p === HalfFloatType ) return gl.HALF_FLOAT;
26549
26163
 
26550
26164
  if ( p === AlphaFormat ) return gl.ALPHA;
26165
+ if ( p === RGBFormat ) return gl.RGB;
26551
26166
  if ( p === RGBAFormat ) return gl.RGBA;
26552
26167
  if ( p === LuminanceFormat ) return gl.LUMINANCE;
26553
26168
  if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
26554
26169
  if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
26555
26170
  if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
26556
26171
 
26557
- // WebGL 1 sRGB fallback
26558
-
26559
- if ( p === _SRGBAFormat ) {
26560
-
26561
- extension = extensions.get( 'EXT_sRGB' );
26562
-
26563
- if ( extension !== null ) {
26564
-
26565
- return extension.SRGB_ALPHA_EXT;
26566
-
26567
- } else {
26568
-
26569
- return null;
26570
-
26571
- }
26572
-
26573
- }
26574
-
26575
26172
  // WebGL2 formats.
26576
26173
 
26577
26174
  if ( p === RedFormat ) return gl.RED;
@@ -26643,33 +26240,15 @@ function WebGLUtils( gl, extensions, capabilities ) {
26643
26240
 
26644
26241
  }
26645
26242
 
26646
- // ETC1
26647
-
26648
- if ( p === RGB_ETC1_Format ) {
26243
+ // ETC
26649
26244
 
26650
- extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
26651
-
26652
- if ( extension !== null ) {
26653
-
26654
- return extension.COMPRESSED_RGB_ETC1_WEBGL;
26655
-
26656
- } else {
26657
-
26658
- return null;
26659
-
26660
- }
26661
-
26662
- }
26663
-
26664
- // ETC2
26665
-
26666
- if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
26245
+ if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
26667
26246
 
26668
26247
  extension = extensions.get( 'WEBGL_compressed_texture_etc' );
26669
26248
 
26670
26249
  if ( extension !== null ) {
26671
26250
 
26672
- if ( p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
26251
+ if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
26673
26252
  if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
26674
26253
 
26675
26254
  } else {
@@ -26758,23 +26337,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
26758
26337
 
26759
26338
  //
26760
26339
 
26761
- if ( p === UnsignedInt248Type ) {
26762
-
26763
- if ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;
26764
-
26765
- extension = extensions.get( 'WEBGL_depth_texture' );
26766
-
26767
- if ( extension !== null ) {
26768
-
26769
- return extension.UNSIGNED_INT_24_8_WEBGL;
26770
-
26771
- } else {
26772
-
26773
- return null;
26774
-
26775
- }
26776
-
26777
- }
26340
+ if ( p === UnsignedInt248Type ) return gl.UNSIGNED_INT_24_8;
26778
26341
 
26779
26342
  // if "p" can't be resolved, assume the user defines a WebGL constant as a string (fallback/workaround for packed RGB formats)
26780
26343
 
@@ -27750,11 +27313,11 @@ void main() {
27750
27313
 
27751
27314
  if ( coord.x >= 1.0 ) {
27752
27315
 
27753
- gl_FragDepthEXT = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
27316
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
27754
27317
 
27755
27318
  } else {
27756
27319
 
27757
- gl_FragDepthEXT = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
27320
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
27758
27321
 
27759
27322
  }
27760
27323
 
@@ -27802,7 +27365,6 @@ class WebXRDepthSensing {
27802
27365
 
27803
27366
  const viewport = cameraXR.cameras[ 0 ].viewport;
27804
27367
  const material = new ShaderMaterial( {
27805
- extensions: { fragDepth: true },
27806
27368
  vertexShader: _occlusion_vertex,
27807
27369
  fragmentShader: _occlusion_fragment,
27808
27370
  uniforms: {
@@ -28108,10 +27670,10 @@ class WebXRManager extends EventDispatcher {
28108
27670
  currentPixelRatio = renderer.getPixelRatio();
28109
27671
  renderer.getSize( currentSize );
28110
27672
 
28111
- if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) {
27673
+ if ( session.renderState.layers === undefined ) {
28112
27674
 
28113
27675
  const layerInit = {
28114
- antialias: ( session.renderState.layers === undefined ) ? attributes.antialias : true,
27676
+ antialias: attributes.antialias,
28115
27677
  alpha: true,
28116
27678
  depth: attributes.depth,
28117
27679
  stencil: attributes.stencil,
@@ -28179,7 +27741,8 @@ class WebXRManager extends EventDispatcher {
28179
27741
  depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
28180
27742
  stencilBuffer: attributes.stencil,
28181
27743
  colorSpace: renderer.outputColorSpace,
28182
- samples: attributes.antialias ? 4 : 0
27744
+ samples: attributes.antialias ? 4 : 0,
27745
+ resolveDepthBuffer: ( glProjLayer.ignoreDepthValues === false )
28183
27746
  };
28184
27747
 
28185
27748
  if ( scope.isMultiview ) {
@@ -28199,9 +27762,6 @@ class WebXRManager extends EventDispatcher {
28199
27762
 
28200
27763
  }
28201
27764
 
28202
- const renderTargetProperties = renderer.properties.get( newRenderTarget );
28203
- renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;
28204
-
28205
27765
  }
28206
27766
 
28207
27767
  newRenderTarget.isXRRenderTarget = true; // TODO Remove this when possible, see #23278
@@ -29090,11 +28650,10 @@ function WebGLMaterials( renderer, properties ) {
29090
28650
 
29091
28651
  }
29092
28652
 
29093
- const envMap = properties.get( material ).envMap;
29094
-
29095
- if ( envMap ) {
28653
+ if ( material.envMap ) {
29096
28654
 
29097
28655
  //uniforms.envMap.value = material.envMap; // part of uniforms common
28656
+
29098
28657
  uniforms.envMapIntensity.value = material.envMapIntensity;
29099
28658
 
29100
28659
  }
@@ -29168,6 +28727,12 @@ function WebGLMaterials( renderer, properties ) {
29168
28727
 
29169
28728
  }
29170
28729
 
28730
+ if ( material.dispersion > 0 ) {
28731
+
28732
+ uniforms.dispersion.value = material.dispersion;
28733
+
28734
+ }
28735
+
29171
28736
  if ( material.iridescence > 0 ) {
29172
28737
 
29173
28738
  uniforms.iridescence.value = material.iridescence;
@@ -29290,7 +28855,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
29290
28855
  let updateList = {};
29291
28856
  let allocatedBindingPoints = [];
29292
28857
 
29293
- const maxBindingPoints = ( capabilities.isWebGL2 ) ? gl.getParameter( gl.MAX_UNIFORM_BUFFER_BINDINGS ) : 0; // binding points are global whereas block indices are per shader program
28858
+ const maxBindingPoints = gl.getParameter( gl.MAX_UNIFORM_BUFFER_BINDINGS ); // binding points are global whereas block indices are per shader program
29294
28859
 
29295
28860
  function bind( uniformsGroup, program ) {
29296
28861
 
@@ -29682,7 +29247,7 @@ class WebGLRenderer {
29682
29247
  canvas = createCanvasElement(),
29683
29248
  context = null,
29684
29249
  depth = true,
29685
- stencil = true,
29250
+ stencil = false,
29686
29251
  alpha = false,
29687
29252
  antialias = false,
29688
29253
  premultipliedAlpha = true,
@@ -29698,6 +29263,12 @@ class WebGLRenderer {
29698
29263
 
29699
29264
  if ( context !== null ) {
29700
29265
 
29266
+ if ( typeof WebGLRenderingContext !== 'undefined' && context instanceof WebGLRenderingContext ) {
29267
+
29268
+ throw new Error( 'THREE.WebGLRenderer: WebGL 1 is not supported since r163.' );
29269
+
29270
+ }
29271
+
29701
29272
  _alpha = context.getContextAttributes().alpha;
29702
29273
 
29703
29274
  } else {
@@ -29810,15 +29381,10 @@ class WebGLRenderer {
29810
29381
  let _clippingEnabled = false;
29811
29382
  let _localClippingEnabled = false;
29812
29383
 
29813
- // transmission
29814
-
29815
- let _transmissionRenderTarget = null;
29816
-
29817
29384
  // camera matrices cache
29818
29385
 
29819
29386
  const _projScreenMatrix = new Matrix4();
29820
29387
 
29821
- const _vector2 = new Vector2();
29822
29388
  const _vector3 = new Vector3();
29823
29389
 
29824
29390
  const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
@@ -29833,17 +29399,9 @@ class WebGLRenderer {
29833
29399
 
29834
29400
  let _gl = context;
29835
29401
 
29836
- function getContext( contextNames, contextAttributes ) {
29837
-
29838
- for ( let i = 0; i < contextNames.length; i ++ ) {
29402
+ function getContext( contextName, contextAttributes ) {
29839
29403
 
29840
- const contextName = contextNames[ i ];
29841
- const context = canvas.getContext( contextName, contextAttributes );
29842
- if ( context !== null ) return context;
29843
-
29844
- }
29845
-
29846
- return null;
29404
+ return canvas.getContext( contextName, contextAttributes );
29847
29405
 
29848
29406
  }
29849
29407
 
@@ -29870,19 +29428,13 @@ class WebGLRenderer {
29870
29428
 
29871
29429
  if ( _gl === null ) {
29872
29430
 
29873
- const contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];
29431
+ const contextName = 'webgl2';
29874
29432
 
29875
- if ( _this.isWebGL1Renderer === true ) {
29876
-
29877
- contextNames.shift();
29878
-
29879
- }
29880
-
29881
- _gl = getContext( contextNames, contextAttributes );
29433
+ _gl = getContext( contextName, contextAttributes );
29882
29434
 
29883
29435
  if ( _gl === null ) {
29884
29436
 
29885
- if ( getContext( contextNames ) ) {
29437
+ if ( getContext( contextName ) ) {
29886
29438
 
29887
29439
  throw new Error( 'Error creating WebGL context with your selected attributes.' );
29888
29440
 
@@ -29896,24 +29448,6 @@ class WebGLRenderer {
29896
29448
 
29897
29449
  }
29898
29450
 
29899
- if ( typeof WebGLRenderingContext !== 'undefined' && _gl instanceof WebGLRenderingContext ) { // @deprecated, r153
29900
-
29901
- console.warn( 'THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.' );
29902
-
29903
- }
29904
-
29905
- // Some experimental-webgl implementations do not have getShaderPrecisionFormat
29906
-
29907
- if ( _gl.getShaderPrecisionFormat === undefined ) {
29908
-
29909
- _gl.getShaderPrecisionFormat = function () {
29910
-
29911
- return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
29912
-
29913
- };
29914
-
29915
- }
29916
-
29917
29451
  } catch ( error ) {
29918
29452
 
29919
29453
  console.error( 'THREE.WebGLRenderer: ' + error.message );
@@ -29933,22 +29467,21 @@ class WebGLRenderer {
29933
29467
  function initGLContext() {
29934
29468
 
29935
29469
  extensions = new WebGLExtensions( _gl );
29470
+ extensions.init();
29936
29471
 
29937
- capabilities = new WebGLCapabilities( _gl, extensions, parameters );
29938
-
29939
- extensions.init( capabilities );
29472
+ utils = new WebGLUtils( _gl, extensions );
29940
29473
 
29941
- utils = new WebGLUtils( _gl, extensions, capabilities );
29474
+ capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
29942
29475
 
29943
- state = new WebGLState( _gl, extensions, capabilities );
29476
+ state = new WebGLState( _gl );
29944
29477
 
29945
29478
  info = new WebGLInfo( _gl );
29946
29479
  properties = new WebGLProperties();
29947
29480
  textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
29948
29481
  cubemaps = new WebGLCubeMaps( _this );
29949
29482
  cubeuvmaps = new WebGLCubeUVMaps( _this );
29950
- attributes = new WebGLAttributes( _gl, capabilities );
29951
- bindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );
29483
+ attributes = new WebGLAttributes( _gl );
29484
+ bindingStates = new WebGLBindingStates( _gl, attributes );
29952
29485
  geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
29953
29486
  objects = new WebGLObjects( _gl, geometries, attributes, info );
29954
29487
  morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
@@ -29956,14 +29489,14 @@ class WebGLRenderer {
29956
29489
  programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
29957
29490
  materials = new WebGLMaterials( _this, properties );
29958
29491
  renderLists = new WebGLRenderLists();
29959
- renderStates = new WebGLRenderStates( extensions, capabilities );
29492
+ renderStates = new WebGLRenderStates( extensions );
29960
29493
  background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
29961
29494
  multiview = new WebGLMultiview( _this, extensions, _gl );
29962
29495
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
29963
29496
  uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
29964
29497
 
29965
- bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );
29966
- indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );
29498
+ bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info );
29499
+ indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info );
29967
29500
 
29968
29501
  info.programs = programCache.programs;
29969
29502
 
@@ -30295,13 +29828,6 @@ class WebGLRenderer {
30295
29828
  xr.removeEventListener( 'sessionstart', onXRSessionStart );
30296
29829
  xr.removeEventListener( 'sessionend', onXRSessionEnd );
30297
29830
 
30298
- if ( _transmissionRenderTarget ) {
30299
-
30300
- _transmissionRenderTarget.dispose();
30301
- _transmissionRenderTarget = null;
30302
-
30303
- }
30304
-
30305
29831
  animation.stop();
30306
29832
 
30307
29833
  };
@@ -30512,7 +30038,15 @@ class WebGLRenderer {
30512
30038
 
30513
30039
  if ( object.isBatchedMesh ) {
30514
30040
 
30515
- renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30041
+ if ( object._multiDrawInstances !== null ) {
30042
+
30043
+ renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
30044
+
30045
+ } else {
30046
+
30047
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30048
+
30049
+ }
30516
30050
 
30517
30051
  } else if ( object.isInstancedMesh ) {
30518
30052
 
@@ -30562,7 +30096,7 @@ class WebGLRenderer {
30562
30096
  if ( targetScene === null ) targetScene = scene;
30563
30097
 
30564
30098
  currentRenderState = renderStates.get( targetScene );
30565
- currentRenderState.init();
30099
+ currentRenderState.init( camera );
30566
30100
 
30567
30101
  renderStateStack.push( currentRenderState );
30568
30102
 
@@ -30779,7 +30313,7 @@ class WebGLRenderer {
30779
30313
  if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
30780
30314
 
30781
30315
  currentRenderState = renderStates.get( scene, renderStateStack.length );
30782
- currentRenderState.init();
30316
+ currentRenderState.init( camera );
30783
30317
 
30784
30318
  renderStateStack.push( currentRenderState );
30785
30319
 
@@ -30804,6 +30338,13 @@ class WebGLRenderer {
30804
30338
 
30805
30339
  }
30806
30340
 
30341
+ const renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
30342
+ if ( renderBackground ) {
30343
+
30344
+ background.addToRenderList( currentRenderList, scene );
30345
+
30346
+ }
30347
+
30807
30348
  //
30808
30349
 
30809
30350
  this.info.render.frame ++;
@@ -30820,20 +30361,30 @@ class WebGLRenderer {
30820
30361
 
30821
30362
  if ( this.info.autoReset === true ) this.info.reset();
30822
30363
 
30364
+ // render scene
30823
30365
 
30824
- //
30366
+ const opaqueObjects = currentRenderList.opaque;
30367
+ const transmissiveObjects = currentRenderList.transmissive;
30825
30368
 
30826
- if ( xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false ) {
30369
+ currentRenderState.setupLights( _this._useLegacyLights );
30827
30370
 
30828
- background.render( currentRenderList, scene );
30371
+ if ( camera.isArrayCamera ) {
30829
30372
 
30830
- }
30373
+ const cameras = camera.cameras;
30831
30374
 
30832
- // render scene
30375
+ if ( transmissiveObjects.length > 0 ) {
30833
30376
 
30834
- currentRenderState.setupLights( _this._useLegacyLights );
30377
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30835
30378
 
30836
- if ( camera.isArrayCamera ) {
30379
+ const camera2 = cameras[ i ];
30380
+
30381
+ renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
30382
+
30383
+ }
30384
+
30385
+ }
30386
+
30387
+ if ( renderBackground ) background.render( scene );
30837
30388
 
30838
30389
  if ( xr.enabled && xr.isMultiview ) {
30839
30390
 
@@ -30843,8 +30394,6 @@ class WebGLRenderer {
30843
30394
 
30844
30395
  } else {
30845
30396
 
30846
- const cameras = camera.cameras;
30847
-
30848
30397
  for ( let i = 0, l = cameras.length; i < l; i ++ ) {
30849
30398
 
30850
30399
  const camera2 = cameras[ i ];
@@ -30857,6 +30406,10 @@ class WebGLRenderer {
30857
30406
 
30858
30407
  } else {
30859
30408
 
30409
+ if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
30410
+
30411
+ if ( renderBackground ) background.render( scene );
30412
+
30860
30413
  renderScene( currentRenderList, scene, camera );
30861
30414
 
30862
30415
  }
@@ -30898,6 +30451,8 @@ class WebGLRenderer {
30898
30451
 
30899
30452
  currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
30900
30453
 
30454
+ if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );
30455
+
30901
30456
  } else {
30902
30457
 
30903
30458
  currentRenderState = null;
@@ -31042,8 +30597,6 @@ class WebGLRenderer {
31042
30597
 
31043
30598
  if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
31044
30599
 
31045
- if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
31046
-
31047
30600
  if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
31048
30601
 
31049
30602
  if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
@@ -31070,15 +30623,16 @@ class WebGLRenderer {
31070
30623
 
31071
30624
  }
31072
30625
 
31073
- const isWebGL2 = capabilities.isWebGL2;
30626
+ if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
31074
30627
 
31075
- if ( _transmissionRenderTarget === null ) {
31076
-
31077
- _transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
30628
+ currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
31078
30629
  generateMipmaps: true,
31079
- type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
30630
+ type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
31080
30631
  minFilter: LinearMipmapLinearFilter,
31081
- samples: ( isWebGL2 ) ? 4 : 0
30632
+ samples: 4,
30633
+ stencilBuffer: stencil,
30634
+ resolveDepthBuffer: false,
30635
+ resolveStencilBuffer: false
31082
30636
  } );
31083
30637
 
31084
30638
  // debug
@@ -31093,22 +30647,15 @@ class WebGLRenderer {
31093
30647
 
31094
30648
  }
31095
30649
 
31096
- _this.getDrawingBufferSize( _vector2 );
31097
-
31098
- if ( isWebGL2 ) {
30650
+ const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget[ camera.id ];
31099
30651
 
31100
- _transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
31101
-
31102
- } else {
31103
-
31104
- _transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
31105
-
31106
- }
30652
+ const activeViewport = camera.viewport || _currentViewport;
30653
+ transmissionRenderTarget.setSize( activeViewport.z, activeViewport.w );
31107
30654
 
31108
30655
  //
31109
30656
 
31110
30657
  const currentRenderTarget = _this.getRenderTarget();
31111
- _this.setRenderTarget( _transmissionRenderTarget );
30658
+ _this.setRenderTarget( transmissionRenderTarget );
31112
30659
 
31113
30660
  _this.getClearColor( _currentClearColor );
31114
30661
  _currentClearAlpha = _this.getClearAlpha();
@@ -31121,44 +30668,57 @@ class WebGLRenderer {
31121
30668
  const currentToneMapping = _this.toneMapping;
31122
30669
  _this.toneMapping = NoToneMapping;
31123
30670
 
30671
+ // Remove viewport from camera to avoid nested render calls resetting viewport to it (e.g Reflector).
30672
+ // Transmission render pass requires viewport to match the transmissionRenderTarget.
30673
+ const currentCameraViewport = camera.viewport;
30674
+ if ( camera.viewport !== undefined ) camera.viewport = undefined;
30675
+
30676
+ currentRenderState.setupLightsView( camera );
30677
+
30678
+ if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
30679
+
31124
30680
  renderObjects( opaqueObjects, scene, camera );
31125
30681
 
31126
- textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
31127
- textures.updateRenderTargetMipmap( _transmissionRenderTarget );
30682
+ textures.updateMultisampleRenderTarget( transmissionRenderTarget );
30683
+ textures.updateRenderTargetMipmap( transmissionRenderTarget );
31128
30684
 
31129
- let renderTargetNeedsUpdate = false;
30685
+ if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === false ) { // see #28131
31130
30686
 
31131
- for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
30687
+ let renderTargetNeedsUpdate = false;
31132
30688
 
31133
- const renderItem = transmissiveObjects[ i ];
30689
+ for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
31134
30690
 
31135
- const object = renderItem.object;
31136
- const geometry = renderItem.geometry;
31137
- const material = renderItem.material;
31138
- const group = renderItem.group;
30691
+ const renderItem = transmissiveObjects[ i ];
31139
30692
 
31140
- if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
30693
+ const object = renderItem.object;
30694
+ const geometry = renderItem.geometry;
30695
+ const material = renderItem.material;
30696
+ const group = renderItem.group;
31141
30697
 
31142
- const currentSide = material.side;
30698
+ if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
31143
30699
 
31144
- material.side = BackSide;
31145
- material.needsUpdate = true;
30700
+ const currentSide = material.side;
31146
30701
 
31147
- renderObject( object, scene, camera, geometry, material, group );
30702
+ material.side = BackSide;
30703
+ material.needsUpdate = true;
31148
30704
 
31149
- material.side = currentSide;
31150
- material.needsUpdate = true;
30705
+ renderObject( object, scene, camera, geometry, material, group );
31151
30706
 
31152
- renderTargetNeedsUpdate = true;
30707
+ material.side = currentSide;
30708
+ material.needsUpdate = true;
30709
+
30710
+ renderTargetNeedsUpdate = true;
30711
+
30712
+ }
31153
30713
 
31154
30714
  }
31155
30715
 
31156
- }
30716
+ if ( renderTargetNeedsUpdate === true ) {
31157
30717
 
31158
- if ( renderTargetNeedsUpdate === true ) {
30718
+ textures.updateMultisampleRenderTarget( transmissionRenderTarget );
30719
+ textures.updateRenderTargetMipmap( transmissionRenderTarget );
31159
30720
 
31160
- textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
31161
- textures.updateRenderTargetMipmap( _transmissionRenderTarget );
30721
+ }
31162
30722
 
31163
30723
  }
31164
30724
 
@@ -31166,6 +30726,8 @@ class WebGLRenderer {
31166
30726
 
31167
30727
  _this.setClearColor( _currentClearColor, _currentClearAlpha );
31168
30728
 
30729
+ if ( currentCameraViewport !== undefined ) camera.viewport = currentCameraViewport;
30730
+
31169
30731
  _this.toneMapping = currentToneMapping;
31170
30732
 
31171
30733
  }
@@ -31518,7 +31080,7 @@ class WebGLRenderer {
31518
31080
 
31519
31081
  needsProgramChange = true;
31520
31082
 
31521
- } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
31083
+ } else if ( materialProperties.morphTargetsCount !== morphTargetsCount ) {
31522
31084
 
31523
31085
  needsProgramChange = true;
31524
31086
 
@@ -31640,17 +31202,9 @@ class WebGLRenderer {
31640
31202
 
31641
31203
  if ( skeleton ) {
31642
31204
 
31643
- if ( capabilities.floatVertexTextures ) {
31644
-
31645
- if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
31205
+ if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
31646
31206
 
31647
- p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
31648
-
31649
- } else {
31650
-
31651
- console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' );
31652
-
31653
- }
31207
+ p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
31654
31208
 
31655
31209
  }
31656
31210
 
@@ -31665,7 +31219,7 @@ class WebGLRenderer {
31665
31219
 
31666
31220
  const morphAttributes = geometry.morphAttributes;
31667
31221
 
31668
- if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
31222
+ if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined ) ) {
31669
31223
 
31670
31224
  morphtargets.update( object, geometry, program );
31671
31225
 
@@ -31688,6 +31242,12 @@ class WebGLRenderer {
31688
31242
 
31689
31243
  }
31690
31244
 
31245
+ if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
31246
+
31247
+ m_uniforms.envMapIntensity.value = scene.environmentIntensity;
31248
+
31249
+ }
31250
+
31691
31251
  if ( refreshMaterial ) {
31692
31252
 
31693
31253
  p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
@@ -31715,7 +31275,7 @@ class WebGLRenderer {
31715
31275
 
31716
31276
  }
31717
31277
 
31718
- materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget );
31278
+ materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
31719
31279
 
31720
31280
  WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
31721
31281
 
@@ -31757,18 +31317,10 @@ class WebGLRenderer {
31757
31317
 
31758
31318
  for ( let i = 0, l = groups.length; i < l; i ++ ) {
31759
31319
 
31760
- if ( capabilities.isWebGL2 ) {
31761
-
31762
- const group = groups[ i ];
31763
-
31764
- uniformsGroups.update( group, program );
31765
- uniformsGroups.bind( group, program );
31766
-
31767
- } else {
31768
-
31769
- console.warn( 'THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.' );
31320
+ const group = groups[ i ];
31770
31321
 
31771
- }
31322
+ uniformsGroups.update( group, program );
31323
+ uniformsGroups.bind( group, program );
31772
31324
 
31773
31325
  }
31774
31326
 
@@ -31937,7 +31489,7 @@ class WebGLRenderer {
31937
31489
 
31938
31490
  isCube = true;
31939
31491
 
31940
- } else if ( ( capabilities.isWebGL2 && renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
31492
+ } else if ( ( renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
31941
31493
 
31942
31494
  framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
31943
31495
 
@@ -31969,7 +31521,7 @@ class WebGLRenderer {
31969
31521
 
31970
31522
  const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
31971
31523
 
31972
- if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
31524
+ if ( framebufferBound && useDefaultFramebuffer ) {
31973
31525
 
31974
31526
  state.drawBuffers( renderTarget, framebuffer );
31975
31527
 
@@ -32023,18 +31575,14 @@ class WebGLRenderer {
32023
31575
  const textureFormat = texture.format;
32024
31576
  const textureType = texture.type;
32025
31577
 
32026
- if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
31578
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
32027
31579
 
32028
31580
  console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
32029
31581
  return;
32030
31582
 
32031
31583
  }
32032
31584
 
32033
- const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) );
32034
-
32035
- if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
32036
- ! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
32037
- ! halfFloatSupportedByExt ) {
31585
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
32038
31586
 
32039
31587
  console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
32040
31588
  return;
@@ -32118,16 +31666,9 @@ class WebGLRenderer {
32118
31666
 
32119
31667
  this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
32120
31668
 
32121
- if ( _this.isWebGL1Renderer ) {
32122
-
32123
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' );
32124
- return;
32125
-
32126
- }
32127
-
32128
- const width = Math.round( sourceBox.max.x - sourceBox.min.x );
32129
- const height = Math.round( sourceBox.max.y - sourceBox.min.y );
32130
- const depth = sourceBox.max.z - sourceBox.min.z + 1;
31669
+ const width = sourceBox.max.x - sourceBox.min.x;
31670
+ const height = sourceBox.max.y - sourceBox.min.y;
31671
+ const depth = sourceBox.max.z - sourceBox.min.z;
32131
31672
  const glFormat = utils.convert( dstTexture.format );
32132
31673
  const glType = utils.convert( dstTexture.type );
32133
31674
  let glTarget;
@@ -32279,10 +31820,6 @@ class WebGLRenderer {
32279
31820
 
32280
31821
  }
32281
31822
 
32282
- class WebGL1Renderer extends WebGLRenderer {}
32283
-
32284
- WebGL1Renderer.prototype.isWebGL1Renderer = true;
32285
-
32286
31823
  class FogExp2 {
32287
31824
 
32288
31825
  constructor( color, density = 0.00025 ) {
@@ -32367,6 +31904,8 @@ class Scene extends Object3D {
32367
31904
  this.backgroundBlurriness = 0;
32368
31905
  this.backgroundIntensity = 1;
32369
31906
  this.backgroundRotation = new Euler();
31907
+
31908
+ this.environmentIntensity = 1;
32370
31909
  this.environmentRotation = new Euler();
32371
31910
 
32372
31911
  this.overrideMaterial = null;
@@ -32390,6 +31929,8 @@ class Scene extends Object3D {
32390
31929
  this.backgroundBlurriness = source.backgroundBlurriness;
32391
31930
  this.backgroundIntensity = source.backgroundIntensity;
32392
31931
  this.backgroundRotation.copy( source.backgroundRotation );
31932
+
31933
+ this.environmentIntensity = source.environmentIntensity;
32393
31934
  this.environmentRotation.copy( source.environmentRotation );
32394
31935
 
32395
31936
  if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
@@ -32405,10 +31946,12 @@ class Scene extends Object3D {
32405
31946
  const data = super.toJSON( meta );
32406
31947
 
32407
31948
  if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
31949
+
32408
31950
  if ( this.backgroundBlurriness > 0 ) data.object.backgroundBlurriness = this.backgroundBlurriness;
32409
31951
  if ( this.backgroundIntensity !== 1 ) data.object.backgroundIntensity = this.backgroundIntensity;
32410
-
32411
31952
  data.object.backgroundRotation = this.backgroundRotation.toArray();
31953
+
31954
+ if ( this.environmentIntensity !== 1 ) data.object.environmentIntensity = this.environmentIntensity;
32412
31955
  data.object.environmentRotation = this.environmentRotation.toArray();
32413
31956
 
32414
31957
  return data;
@@ -34037,6 +33580,7 @@ class InstancedMesh extends Mesh {
34037
33580
 
34038
33581
  this.instanceMatrix.copy( source.instanceMatrix );
34039
33582
 
33583
+ if ( source.morphTexture !== null ) this.morphTexture = source.morphTexture.clone();
34040
33584
  if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone();
34041
33585
 
34042
33586
  this.count = source.count;
@@ -34188,6 +33732,15 @@ class InstancedMesh extends Mesh {
34188
33732
 
34189
33733
  this.dispatchEvent( { type: 'dispose' } );
34190
33734
 
33735
+ if ( this.morphTexture !== null ) {
33736
+
33737
+ this.morphTexture.dispose();
33738
+ this.morphTexture = null;
33739
+
33740
+ }
33741
+
33742
+ return this;
33743
+
34191
33744
  }
34192
33745
 
34193
33746
  }
@@ -34334,6 +33887,7 @@ class BatchedMesh extends Mesh {
34334
33887
  this._multiDrawCounts = new Int32Array( maxGeometryCount );
34335
33888
  this._multiDrawStarts = new Int32Array( maxGeometryCount );
34336
33889
  this._multiDrawCount = 0;
33890
+ this._multiDrawInstances = null;
34337
33891
  this._visibilityChanged = true;
34338
33892
 
34339
33893
  // Local matrix per geometry by using data texture
@@ -34377,8 +33931,7 @@ class BatchedMesh extends Mesh {
34377
33931
  const { array, itemSize, normalized } = srcAttribute;
34378
33932
 
34379
33933
  const dstArray = new array.constructor( maxVertexCount * itemSize );
34380
- const dstAttribute = new srcAttribute.constructor( dstArray, itemSize, normalized );
34381
- dstAttribute.setUsage( srcAttribute.usage );
33934
+ const dstAttribute = new BufferAttribute( dstArray, itemSize, normalized );
34382
33935
 
34383
33936
  geometry.setAttribute( attributeName, dstAttribute );
34384
33937
 
@@ -34405,7 +33958,7 @@ class BatchedMesh extends Mesh {
34405
33958
 
34406
33959
  }
34407
33960
 
34408
- // Make sure the geometry is compatible with the existing combined geometry atributes
33961
+ // Make sure the geometry is compatible with the existing combined geometry attributes
34409
33962
  _validateGeometry( geometry ) {
34410
33963
 
34411
33964
  // check that the geometry doesn't have a version of our reserved id attribute
@@ -34696,6 +34249,7 @@ class BatchedMesh extends Mesh {
34696
34249
  }
34697
34250
 
34698
34251
  dstAttribute.needsUpdate = true;
34252
+ dstAttribute.addUpdateRange( vertexStart * itemSize, vertexCount * itemSize );
34699
34253
 
34700
34254
  }
34701
34255
 
@@ -34719,6 +34273,7 @@ class BatchedMesh extends Mesh {
34719
34273
  }
34720
34274
 
34721
34275
  dstIndex.needsUpdate = true;
34276
+ dstIndex.addUpdateRange( indexStart, reservedRange.indexCount );
34722
34277
 
34723
34278
  }
34724
34279
 
@@ -34774,6 +34329,28 @@ class BatchedMesh extends Mesh {
34774
34329
 
34775
34330
  }
34776
34331
 
34332
+ getInstanceCountAt( id ) {
34333
+
34334
+ if ( this._multiDrawInstances === null ) return null;
34335
+
34336
+ return this._multiDrawInstances[ id ];
34337
+
34338
+ }
34339
+
34340
+ setInstanceCountAt( id, instanceCount ) {
34341
+
34342
+ if ( this._multiDrawInstances === null ) {
34343
+
34344
+ this._multiDrawInstances = new Int32Array( this._maxGeometryCount ).fill( 1 );
34345
+
34346
+ }
34347
+
34348
+ this._multiDrawInstances[ id ] = instanceCount;
34349
+
34350
+ return id;
34351
+
34352
+ }
34353
+
34777
34354
  // get bounding box and compute it if it doesn't exist
34778
34355
  getBoundingBoxAt( id, target ) {
34779
34356
 
@@ -35243,12 +34820,16 @@ class LineBasicMaterial extends Material {
35243
34820
 
35244
34821
  }
35245
34822
 
35246
- const _start$1 = /*@__PURE__*/ new Vector3();
35247
- const _end$1 = /*@__PURE__*/ new Vector3();
34823
+ const _vStart = /*@__PURE__*/ new Vector3();
34824
+ const _vEnd = /*@__PURE__*/ new Vector3();
34825
+
35248
34826
  const _inverseMatrix$1 = /*@__PURE__*/ new Matrix4();
35249
34827
  const _ray$1 = /*@__PURE__*/ new Ray();
35250
34828
  const _sphere$1 = /*@__PURE__*/ new Sphere();
35251
34829
 
34830
+ const _intersectPointOnRay = /*@__PURE__*/ new Vector3();
34831
+ const _intersectPointOnSegment = /*@__PURE__*/ new Vector3();
34832
+
35252
34833
  class Line extends Object3D {
35253
34834
 
35254
34835
  constructor( geometry = new BufferGeometry(), material = new LineBasicMaterial() ) {
@@ -35290,11 +34871,11 @@ class Line extends Object3D {
35290
34871
 
35291
34872
  for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
35292
34873
 
35293
- _start$1.fromBufferAttribute( positionAttribute, i - 1 );
35294
- _end$1.fromBufferAttribute( positionAttribute, i );
34874
+ _vStart.fromBufferAttribute( positionAttribute, i - 1 );
34875
+ _vEnd.fromBufferAttribute( positionAttribute, i );
35295
34876
 
35296
34877
  lineDistances[ i ] = lineDistances[ i - 1 ];
35297
- lineDistances[ i ] += _start$1.distanceTo( _end$1 );
34878
+ lineDistances[ i ] += _vStart.distanceTo( _vEnd );
35298
34879
 
35299
34880
  }
35300
34881
 
@@ -35335,10 +34916,6 @@ class Line extends Object3D {
35335
34916
  const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
35336
34917
  const localThresholdSq = localThreshold * localThreshold;
35337
34918
 
35338
- const vStart = new Vector3();
35339
- const vEnd = new Vector3();
35340
- const interSegment = new Vector3();
35341
- const interRay = new Vector3();
35342
34919
  const step = this.isLineSegments ? 2 : 1;
35343
34920
 
35344
34921
  const index = geometry.index;
@@ -35355,31 +34932,28 @@ class Line extends Object3D {
35355
34932
  const a = index.getX( i );
35356
34933
  const b = index.getX( i + 1 );
35357
34934
 
35358
- vStart.fromBufferAttribute( positionAttribute, a );
35359
- vEnd.fromBufferAttribute( positionAttribute, b );
34935
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
35360
34936
 
35361
- const distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
34937
+ if ( intersect ) {
35362
34938
 
35363
- if ( distSq > localThresholdSq ) continue;
34939
+ intersects.push( intersect );
35364
34940
 
35365
- interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
34941
+ }
35366
34942
 
35367
- const distance = raycaster.ray.origin.distanceTo( interRay );
34943
+ }
35368
34944
 
35369
- if ( distance < raycaster.near || distance > raycaster.far ) continue;
34945
+ if ( this.isLineLoop ) {
35370
34946
 
35371
- intersects.push( {
34947
+ const a = index.getX( end - 1 );
34948
+ const b = index.getX( start );
35372
34949
 
35373
- distance: distance,
35374
- // What do we want? intersection point on the ray or on the segment??
35375
- // point: raycaster.ray.at( distance ),
35376
- point: interSegment.clone().applyMatrix4( this.matrixWorld ),
35377
- index: i,
35378
- face: null,
35379
- faceIndex: null,
35380
- object: this
34950
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, a, b );
35381
34951
 
35382
- } );
34952
+ if ( intersect ) {
34953
+
34954
+ intersects.push( intersect );
34955
+
34956
+ }
35383
34957
 
35384
34958
  }
35385
34959
 
@@ -35390,31 +34964,25 @@ class Line extends Object3D {
35390
34964
 
35391
34965
  for ( let i = start, l = end - 1; i < l; i += step ) {
35392
34966
 
35393
- vStart.fromBufferAttribute( positionAttribute, i );
35394
- vEnd.fromBufferAttribute( positionAttribute, i + 1 );
34967
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, i, i + 1 );
34968
+
34969
+ if ( intersect ) {
35395
34970
 
35396
- const distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
34971
+ intersects.push( intersect );
35397
34972
 
35398
- if ( distSq > localThresholdSq ) continue;
34973
+ }
35399
34974
 
35400
- interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
34975
+ }
35401
34976
 
35402
- const distance = raycaster.ray.origin.distanceTo( interRay );
34977
+ if ( this.isLineLoop ) {
35403
34978
 
35404
- if ( distance < raycaster.near || distance > raycaster.far ) continue;
34979
+ const intersect = checkIntersection( this, raycaster, _ray$1, localThresholdSq, end - 1, start );
35405
34980
 
35406
- intersects.push( {
34981
+ if ( intersect ) {
35407
34982
 
35408
- distance: distance,
35409
- // What do we want? intersection point on the ray or on the segment??
35410
- // point: raycaster.ray.at( distance ),
35411
- point: interSegment.clone().applyMatrix4( this.matrixWorld ),
35412
- index: i,
35413
- face: null,
35414
- faceIndex: null,
35415
- object: this
34983
+ intersects.push( intersect );
35416
34984
 
35417
- } );
34985
+ }
35418
34986
 
35419
34987
  }
35420
34988
 
@@ -35455,6 +35023,38 @@ class Line extends Object3D {
35455
35023
 
35456
35024
  }
35457
35025
 
35026
+ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
35027
+
35028
+ const positionAttribute = object.geometry.attributes.position;
35029
+
35030
+ _vStart.fromBufferAttribute( positionAttribute, a );
35031
+ _vEnd.fromBufferAttribute( positionAttribute, b );
35032
+
35033
+ const distSq = ray.distanceSqToSegment( _vStart, _vEnd, _intersectPointOnRay, _intersectPointOnSegment );
35034
+
35035
+ if ( distSq > thresholdSq ) return;
35036
+
35037
+ _intersectPointOnRay.applyMatrix4( object.matrixWorld ); // Move back to world space for distance calculation
35038
+
35039
+ const distance = raycaster.ray.origin.distanceTo( _intersectPointOnRay );
35040
+
35041
+ if ( distance < raycaster.near || distance > raycaster.far ) return;
35042
+
35043
+ return {
35044
+
35045
+ distance: distance,
35046
+ // What do we want? intersection point on the ray or on the segment??
35047
+ // point: raycaster.ray.at( distance ),
35048
+ point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
35049
+ index: a,
35050
+ face: null,
35051
+ faceIndex: null,
35052
+ object: object
35053
+
35054
+ };
35055
+
35056
+ }
35057
+
35458
35058
  const _start = /*@__PURE__*/ new Vector3();
35459
35059
  const _end = /*@__PURE__*/ new Vector3();
35460
35060
 
@@ -42092,6 +41692,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
42092
41692
 
42093
41693
  this._anisotropy = 0;
42094
41694
  this._clearcoat = 0;
41695
+ this._dispersion = 0;
42095
41696
  this._iridescence = 0;
42096
41697
  this._sheen = 0.0;
42097
41698
  this._transmission = 0;
@@ -42154,6 +41755,24 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
42154
41755
 
42155
41756
  }
42156
41757
 
41758
+ get dispersion() {
41759
+
41760
+ return this._dispersion;
41761
+
41762
+ }
41763
+
41764
+ set dispersion( value ) {
41765
+
41766
+ if ( this._dispersion > 0 !== value > 0 ) {
41767
+
41768
+ this.version ++;
41769
+
41770
+ }
41771
+
41772
+ this._dispersion = value;
41773
+
41774
+ }
41775
+
42157
41776
  get sheen() {
42158
41777
 
42159
41778
  return this._sheen;
@@ -42212,6 +41831,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
42212
41831
  this.clearcoatNormalMap = source.clearcoatNormalMap;
42213
41832
  this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
42214
41833
 
41834
+ this.dispersion = source.dispersion;
42215
41835
  this.ior = source.ior;
42216
41836
 
42217
41837
  this.iridescence = source.iridescence;
@@ -44065,7 +43685,7 @@ VectorKeyframeTrack.prototype.ValueTypeName = 'vector';
44065
43685
 
44066
43686
  class AnimationClip {
44067
43687
 
44068
- constructor( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) {
43688
+ constructor( name = '', duration = - 1, tracks = [], blendMode = NormalAnimationBlendMode ) {
44069
43689
 
44070
43690
  this.name = name;
44071
43691
  this.tracks = tracks;
@@ -44885,7 +44505,7 @@ class FileLoader extends Loader {
44885
44505
 
44886
44506
  // Nginx needs X-File-Size check
44887
44507
  // https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
44888
- const contentLength = response.headers.get( 'Content-Length' ) || response.headers.get( 'X-File-Size' );
44508
+ const contentLength = response.headers.get( 'X-File-Size' ) || response.headers.get( 'Content-Length' );
44889
44509
  const total = contentLength ? parseInt( contentLength ) : 0;
44890
44510
  const lengthComputable = total !== 0;
44891
44511
  let loaded = 0;
@@ -46486,6 +46106,7 @@ class MaterialLoader extends Loader {
46486
46106
  if ( json.shininess !== undefined ) material.shininess = json.shininess;
46487
46107
  if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat;
46488
46108
  if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness;
46109
+ if ( json.dispersion !== undefined ) material.dispersion = json.dispersion;
46489
46110
  if ( json.iridescence !== undefined ) material.iridescence = json.iridescence;
46490
46111
  if ( json.iridescenceIOR !== undefined ) material.iridescenceIOR = json.iridescenceIOR;
46491
46112
  if ( json.iridescenceThicknessRange !== undefined ) material.iridescenceThicknessRange = json.iridescenceThicknessRange;
@@ -47818,6 +47439,8 @@ class ObjectLoader extends Loader {
47818
47439
  if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
47819
47440
  if ( data.backgroundIntensity !== undefined ) object.backgroundIntensity = data.backgroundIntensity;
47820
47441
  if ( data.backgroundRotation !== undefined ) object.backgroundRotation.fromArray( data.backgroundRotation );
47442
+
47443
+ if ( data.environmentIntensity !== undefined ) object.environmentIntensity = data.environmentIntensity;
47821
47444
  if ( data.environmentRotation !== undefined ) object.environmentRotation.fromArray( data.environmentRotation );
47822
47445
 
47823
47446
  break;
@@ -52449,11 +52072,9 @@ function intersect( object, raycaster, intersects, recursive ) {
52449
52072
  /**
52450
52073
  * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
52451
52074
  *
52452
- * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up.
52453
- * The azimuthal angle (theta) is measured from the positive z-axis.
52075
+ * phi (the polar angle) is measured from the positive y-axis. The positive y-axis is up.
52076
+ * theta (the azimuthal angle) is measured from the positive z-axis.
52454
52077
  */
52455
-
52456
-
52457
52078
  class Spherical {
52458
52079
 
52459
52080
  constructor( radius = 1, phi = 0, theta = 0 ) {
@@ -54463,4 +54084,4 @@ if ( typeof window !== 'undefined' ) {
54463
54084
 
54464
54085
  }
54465
54086
 
54466
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL1Renderer, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, _SRGBAFormat, createCanvasElement };
54087
+ export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };