super-three 0.161.0 → 0.163.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 (206) hide show
  1. package/build/three.cjs +822 -1332
  2. package/build/three.module.js +820 -1328
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/DragControls.js +91 -30
  5. package/examples/jsm/controls/OrbitControls.js +32 -6
  6. package/examples/jsm/controls/TransformControls.js +9 -9
  7. package/examples/jsm/exporters/GLTFExporter.js +30 -3
  8. package/examples/jsm/exporters/USDZExporter.js +15 -0
  9. package/examples/jsm/geometries/TextGeometry.js +10 -2
  10. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  11. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  12. package/examples/jsm/libs/fflate.module.js +694 -496
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  14. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  15. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  16. package/examples/jsm/libs/tween.module.js +32 -14
  17. package/examples/jsm/lines/LineMaterial.js +0 -2
  18. package/examples/jsm/loaders/3DMLoader.js +13 -21
  19. package/examples/jsm/loaders/3MFLoader.js +2 -0
  20. package/examples/jsm/loaders/EXRLoader.js +89 -19
  21. package/examples/jsm/loaders/FBXLoader.js +1 -1
  22. package/examples/jsm/loaders/GLTFLoader.js +6 -0
  23. package/examples/jsm/loaders/KTX2Loader.js +2 -6
  24. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  25. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  26. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  27. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  28. package/examples/jsm/loaders/VOXLoader.js +9 -2
  29. package/examples/jsm/loaders/VRMLLoader.js +6 -2
  30. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  31. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  32. package/examples/jsm/nodes/Nodes.js +15 -8
  33. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  34. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  35. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  36. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  37. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  38. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  39. package/examples/jsm/nodes/accessors/MorphNode.js +20 -10
  40. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  41. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  42. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
  45. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  46. package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
  47. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  48. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  49. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  50. package/examples/jsm/nodes/core/Node.js +67 -6
  51. package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
  52. package/examples/jsm/nodes/core/NodeFrame.js +8 -8
  53. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  54. package/examples/jsm/nodes/core/TempNode.js +1 -1
  55. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  56. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  57. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  58. package/examples/jsm/nodes/display/PassNode.js +17 -1
  59. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  60. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  61. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  62. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  63. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  64. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  65. package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
  66. package/examples/jsm/nodes/materials/NodeMaterial.js +70 -17
  67. package/examples/jsm/nodes/math/CondNode.js +42 -7
  68. package/examples/jsm/nodes/math/MathNode.js +20 -0
  69. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  70. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  71. package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
  72. package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
  73. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  74. package/examples/jsm/nodes/utils/LoopNode.js +2 -0
  75. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  76. package/examples/jsm/objects/QuadMesh.js +7 -23
  77. package/examples/jsm/physics/RapierPhysics.js +4 -4
  78. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  79. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  80. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  81. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  82. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  83. package/examples/jsm/renderers/common/Animation.js +3 -0
  84. package/examples/jsm/renderers/common/Background.js +3 -3
  85. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  86. package/examples/jsm/renderers/common/Info.js +11 -19
  87. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  88. package/examples/jsm/renderers/common/RenderContext.js +3 -1
  89. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  90. package/examples/jsm/renderers/common/RenderObject.js +46 -3
  91. package/examples/jsm/renderers/common/RenderObjects.js +2 -0
  92. package/examples/jsm/renderers/common/Renderer.js +113 -39
  93. package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
  94. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  95. package/examples/jsm/renderers/common/Textures.js +3 -13
  96. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  97. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
  98. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  99. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  100. package/examples/jsm/renderers/common/nodes/Nodes.js +6 -18
  101. package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
  102. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
  103. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
  104. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
  105. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  106. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
  107. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
  108. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
  109. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
  110. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +67 -37
  111. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
  112. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
  113. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  114. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
  115. package/examples/jsm/shaders/OutputShader.js +4 -0
  116. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  117. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  118. package/examples/jsm/utils/TextureUtils.js +1 -1
  119. package/examples/jsm/webxr/VRButton.js +13 -5
  120. package/examples/jsm/webxr/XRButton.js +0 -1
  121. package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
  122. package/package.json +4 -3
  123. package/src/Three.Legacy.js +20 -0
  124. package/src/Three.js +0 -2
  125. package/src/animation/AnimationClip.js +1 -1
  126. package/src/constants.js +4 -7
  127. package/src/core/BufferAttribute.js +0 -11
  128. package/src/core/BufferGeometry.js +23 -29
  129. package/src/core/Object3D.js +21 -7
  130. package/src/core/Raycaster.js +18 -4
  131. package/src/core/RenderTarget.js +44 -21
  132. package/src/extras/PMREMGenerator.js +11 -0
  133. package/src/extras/curves/EllipseCurve.js +2 -2
  134. package/src/helpers/SpotLightHelper.js +18 -1
  135. package/src/loaders/DataTextureLoader.js +0 -4
  136. package/src/loaders/MaterialLoader.js +1 -0
  137. package/src/loaders/ObjectLoader.js +4 -1
  138. package/src/materials/Material.js +2 -1
  139. package/src/materials/MeshBasicMaterial.js +3 -0
  140. package/src/materials/MeshLambertMaterial.js +3 -0
  141. package/src/materials/MeshPhongMaterial.js +3 -0
  142. package/src/materials/MeshStandardMaterial.js +3 -0
  143. package/src/materials/ShaderMaterial.js +0 -4
  144. package/src/math/Quaternion.js +13 -12
  145. package/src/math/Spherical.js +4 -5
  146. package/src/math/Vector3.js +7 -7
  147. package/src/objects/BatchedMesh.js +4 -3
  148. package/src/objects/InstancedMesh.js +63 -0
  149. package/src/objects/Mesh.js +0 -1
  150. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  151. package/src/renderers/WebGLRenderer.js +70 -136
  152. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  153. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  154. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  155. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  156. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  157. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  158. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  159. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  160. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  161. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  162. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  163. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
  164. package/src/renderers/shaders/ShaderChunk.js +2 -0
  165. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  166. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  167. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  168. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
  169. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
  170. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
  171. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
  172. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
  173. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
  174. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  175. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
  176. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
  177. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  178. package/src/renderers/shaders/ShaderLib.js +3 -2
  179. package/src/renderers/shaders/UniformsLib.js +1 -0
  180. package/src/renderers/shaders/UniformsUtils.js +10 -1
  181. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  182. package/src/renderers/webgl/WebGLBackground.js +18 -0
  183. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  184. package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
  185. package/src/renderers/webgl/WebGLCapabilities.js +2 -12
  186. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  187. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  188. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
  189. package/src/renderers/webgl/WebGLLights.js +6 -32
  190. package/src/renderers/webgl/WebGLMaterials.js +26 -4
  191. package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
  192. package/src/renderers/webgl/WebGLProgram.js +30 -48
  193. package/src/renderers/webgl/WebGLPrograms.js +5 -14
  194. package/src/renderers/webgl/WebGLRenderStates.js +8 -6
  195. package/src/renderers/webgl/WebGLState.js +21 -75
  196. package/src/renderers/webgl/WebGLTextures.js +143 -275
  197. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  198. package/src/renderers/webgl/WebGLUtils.js +6 -57
  199. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  200. package/src/renderers/webxr/WebXRManager.js +2 -2
  201. package/src/scenes/Scene.js +14 -0
  202. package/src/textures/Texture.js +6 -24
  203. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  204. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  205. package/src/renderers/WebGL1Renderer.js +0 -7
  206. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
package/build/three.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const REVISION = '161';
8
+ const REVISION = '163';
9
9
 
10
10
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
11
11
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -64,6 +64,7 @@ const CineonToneMapping = 3;
64
64
  const ACESFilmicToneMapping = 4;
65
65
  const CustomToneMapping = 5;
66
66
  const AgXToneMapping = 6;
67
+ const NeutralToneMapping = 7;
67
68
  const AttachedBindMode = 'attached';
68
69
  const DetachedBindMode = 'detached';
69
70
 
@@ -97,7 +98,9 @@ const HalfFloatType = 1016;
97
98
  const UnsignedShort4444Type = 1017;
98
99
  const UnsignedShort5551Type = 1018;
99
100
  const UnsignedInt248Type = 1020;
101
+ const UnsignedInt5999Type = 35902;
100
102
  const AlphaFormat = 1021;
103
+ const RGBFormat = 1022;
101
104
  const RGBAFormat = 1023;
102
105
  const LuminanceFormat = 1024;
103
106
  const LuminanceAlphaFormat = 1025;
@@ -155,10 +158,6 @@ const AdditiveAnimationBlendMode = 2501;
155
158
  const TrianglesDrawMode = 0;
156
159
  const TriangleStripDrawMode = 1;
157
160
  const TriangleFanDrawMode = 2;
158
- /** @deprecated Use LinearSRGBColorSpace or NoColorSpace in three.js r152+. */
159
- const LinearEncoding = 3000;
160
- /** @deprecated Use SRGBColorSpace in three.js r152+. */
161
- const sRGBEncoding = 3001;
162
161
  const BasicDepthPacking = 3200;
163
162
  const RGBADepthPacking = 3201;
164
163
  const TangentSpaceNormalMap = 0;
@@ -217,8 +216,6 @@ const StreamCopyUsage = 35042;
217
216
  const GLSL1 = '100';
218
217
  const GLSL3 = '300 es';
219
218
 
220
- const _SRGBAFormat = 1035; // fallback for WebGL 1
221
-
222
219
  const WebGLCoordinateSystem = 2000;
223
220
  const WebGPUCoordinateSystem = 2001;
224
221
 
@@ -1998,17 +1995,7 @@ class Texture extends EventDispatcher {
1998
1995
  this.flipY = true;
1999
1996
  this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
2000
1997
 
2001
- if ( typeof colorSpace === 'string' ) {
2002
-
2003
- this.colorSpace = colorSpace;
2004
-
2005
- } else { // @deprecated, r152
2006
-
2007
- warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
2008
- this.colorSpace = colorSpace === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
2009
-
2010
- }
2011
-
1998
+ this.colorSpace = colorSpace;
2012
1999
 
2013
2000
  this.userData = {};
2014
2001
 
@@ -2016,7 +2003,7 @@ class Texture extends EventDispatcher {
2016
2003
  this.onUpdate = null;
2017
2004
 
2018
2005
  this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not
2019
- this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
2006
+ this.pmremVersion = 0; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
2020
2007
 
2021
2008
  }
2022
2009
 
@@ -2247,17 +2234,13 @@ class Texture extends EventDispatcher {
2247
2234
 
2248
2235
  }
2249
2236
 
2250
- get encoding() { // @deprecated, r152
2237
+ set needsPMREMUpdate( value ) {
2251
2238
 
2252
- warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
2253
- return this.colorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
2254
-
2255
- }
2239
+ if ( value === true ) {
2256
2240
 
2257
- set encoding( encoding ) { // @deprecated, r152
2241
+ this.pmremVersion ++;
2258
2242
 
2259
- warnOnce( 'THREE.Texture: Property .encoding has been replaced by .colorSpace.' );
2260
- this.colorSpace = encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
2243
+ }
2261
2244
 
2262
2245
  }
2263
2246
 
@@ -2934,14 +2917,6 @@ class RenderTarget extends EventDispatcher {
2934
2917
 
2935
2918
  const image = { width: width, height: height, depth: 1 };
2936
2919
 
2937
- if ( options.encoding !== undefined ) {
2938
-
2939
- // @deprecated, r152
2940
- warnOnce( 'THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace.' );
2941
- options.colorSpace = options.encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
2942
-
2943
- }
2944
-
2945
2920
  options = Object.assign( {
2946
2921
  generateMipmaps: false,
2947
2922
  internalFormat: null,
@@ -2949,15 +2924,25 @@ class RenderTarget extends EventDispatcher {
2949
2924
  depthBuffer: true,
2950
2925
  stencilBuffer: false,
2951
2926
  depthTexture: null,
2952
- samples: 0
2927
+ samples: 0,
2928
+ count: 1
2953
2929
  }, options );
2954
2930
 
2955
- this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
2956
- this.texture.isRenderTargetTexture = true;
2931
+ const texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
2932
+
2933
+ texture.flipY = false;
2934
+ texture.generateMipmaps = options.generateMipmaps;
2935
+ texture.internalFormat = options.internalFormat;
2957
2936
 
2958
- this.texture.flipY = false;
2959
- this.texture.generateMipmaps = options.generateMipmaps;
2960
- this.texture.internalFormat = options.internalFormat;
2937
+ this.textures = [];
2938
+
2939
+ const count = options.count;
2940
+ for ( let i = 0; i < count; i ++ ) {
2941
+
2942
+ this.textures[ i ] = texture.clone();
2943
+ this.textures[ i ].isRenderTargetTexture = true;
2944
+
2945
+ }
2961
2946
 
2962
2947
  this.depthBuffer = options.depthBuffer;
2963
2948
  this.stencilBuffer = options.stencilBuffer;
@@ -2968,6 +2953,18 @@ class RenderTarget extends EventDispatcher {
2968
2953
 
2969
2954
  }
2970
2955
 
2956
+ get texture() {
2957
+
2958
+ return this.textures[ 0 ];
2959
+
2960
+ }
2961
+
2962
+ set texture( value ) {
2963
+
2964
+ this.textures[ 0 ] = value;
2965
+
2966
+ }
2967
+
2971
2968
  setSize( width, height, depth = 1 ) {
2972
2969
 
2973
2970
  if ( this.width !== width || this.height !== height || this.depth !== depth ) {
@@ -2976,9 +2973,13 @@ class RenderTarget extends EventDispatcher {
2976
2973
  this.height = height;
2977
2974
  this.depth = depth;
2978
2975
 
2979
- this.texture.image.width = width;
2980
- this.texture.image.height = height;
2981
- this.texture.image.depth = depth;
2976
+ for ( let i = 0, il = this.textures.length; i < il; i ++ ) {
2977
+
2978
+ this.textures[ i ].image.width = width;
2979
+ this.textures[ i ].image.height = height;
2980
+ this.textures[ i ].image.depth = depth;
2981
+
2982
+ }
2982
2983
 
2983
2984
  this.dispose();
2984
2985
 
@@ -3006,8 +3007,14 @@ class RenderTarget extends EventDispatcher {
3006
3007
 
3007
3008
  this.viewport.copy( source.viewport );
3008
3009
 
3009
- this.texture = source.texture.clone();
3010
- this.texture.isRenderTargetTexture = true;
3010
+ this.textures.length = 0;
3011
+
3012
+ for ( let i = 0, il = source.textures.length; i < il; i ++ ) {
3013
+
3014
+ this.textures[ i ] = source.textures[ i ].clone();
3015
+ this.textures[ i ].isRenderTargetTexture = true;
3016
+
3017
+ }
3011
3018
 
3012
3019
  // ensure image object is not shared, see #20328
3013
3020
 
@@ -3135,85 +3142,6 @@ class WebGL3DRenderTarget extends WebGLRenderTarget {
3135
3142
 
3136
3143
  }
3137
3144
 
3138
- class WebGLMultipleRenderTargets extends WebGLRenderTarget {
3139
-
3140
- constructor( width = 1, height = 1, count = 1, options = {} ) {
3141
-
3142
- super( width, height, options );
3143
-
3144
- this.isWebGLMultipleRenderTargets = true;
3145
-
3146
- const texture = this.texture;
3147
-
3148
- this.texture = [];
3149
-
3150
- for ( let i = 0; i < count; i ++ ) {
3151
-
3152
- this.texture[ i ] = texture.clone();
3153
- this.texture[ i ].isRenderTargetTexture = true;
3154
-
3155
- }
3156
-
3157
- }
3158
-
3159
- setSize( width, height, depth = 1 ) {
3160
-
3161
- if ( this.width !== width || this.height !== height || this.depth !== depth ) {
3162
-
3163
- this.width = width;
3164
- this.height = height;
3165
- this.depth = depth;
3166
-
3167
- for ( let i = 0, il = this.texture.length; i < il; i ++ ) {
3168
-
3169
- this.texture[ i ].image.width = width;
3170
- this.texture[ i ].image.height = height;
3171
- this.texture[ i ].image.depth = depth;
3172
-
3173
- }
3174
-
3175
- this.dispose();
3176
-
3177
- }
3178
-
3179
- this.viewport.set( 0, 0, width, height );
3180
- this.scissor.set( 0, 0, width, height );
3181
-
3182
- }
3183
-
3184
- copy( source ) {
3185
-
3186
- this.dispose();
3187
-
3188
- this.width = source.width;
3189
- this.height = source.height;
3190
- this.depth = source.depth;
3191
-
3192
- this.scissor.copy( source.scissor );
3193
- this.scissorTest = source.scissorTest;
3194
-
3195
- this.viewport.copy( source.viewport );
3196
-
3197
- this.depthBuffer = source.depthBuffer;
3198
- this.stencilBuffer = source.stencilBuffer;
3199
-
3200
- if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
3201
-
3202
- this.texture.length = 0;
3203
-
3204
- for ( let i = 0, il = source.texture.length; i < il; i ++ ) {
3205
-
3206
- this.texture[ i ] = source.texture[ i ].clone();
3207
- this.texture[ i ].isRenderTargetTexture = true;
3208
-
3209
- }
3210
-
3211
- return this;
3212
-
3213
- }
3214
-
3215
- }
3216
-
3217
3145
  class Quaternion {
3218
3146
 
3219
3147
  constructor( x = 0, y = 0, z = 0, w = 1 ) {
@@ -3805,23 +3733,24 @@ class Quaternion {
3805
3733
 
3806
3734
  random() {
3807
3735
 
3808
- // Derived from http://planning.cs.uiuc.edu/node198.html
3809
- // Note, this source uses w, x, y, z ordering,
3810
- // so we swap the order below.
3736
+ // sets this quaternion to a uniform random unit quaternnion
3811
3737
 
3812
- const u1 = Math.random();
3813
- const sqrt1u1 = Math.sqrt( 1 - u1 );
3814
- const sqrtu1 = Math.sqrt( u1 );
3738
+ // Ken Shoemake
3739
+ // Uniform random rotations
3740
+ // D. Kirk, editor, Graphics Gems III, pages 124-132. Academic Press, New York, 1992.
3815
3741
 
3816
- const u2 = 2 * Math.PI * Math.random();
3742
+ const theta1 = 2 * Math.PI * Math.random();
3743
+ const theta2 = 2 * Math.PI * Math.random();
3817
3744
 
3818
- const u3 = 2 * Math.PI * Math.random();
3745
+ const x0 = Math.random();
3746
+ const r1 = Math.sqrt( 1 - x0 );
3747
+ const r2 = Math.sqrt( x0 );
3819
3748
 
3820
3749
  return this.set(
3821
- sqrt1u1 * Math.cos( u2 ),
3822
- sqrtu1 * Math.sin( u3 ),
3823
- sqrtu1 * Math.cos( u3 ),
3824
- sqrt1u1 * Math.sin( u2 ),
3750
+ r1 * Math.sin( theta1 ),
3751
+ r1 * Math.cos( theta1 ),
3752
+ r2 * Math.sin( theta2 ),
3753
+ r2 * Math.cos( theta2 ),
3825
3754
  );
3826
3755
 
3827
3756
  }
@@ -4589,15 +4518,15 @@ class Vector3 {
4589
4518
 
4590
4519
  randomDirection() {
4591
4520
 
4592
- // Derived from https://mathworld.wolfram.com/SpherePointPicking.html
4521
+ // https://mathworld.wolfram.com/SpherePointPicking.html
4593
4522
 
4594
- const u = ( Math.random() - 0.5 ) * 2;
4595
- const t = Math.random() * Math.PI * 2;
4596
- const f = Math.sqrt( 1 - u ** 2 );
4523
+ const theta = Math.random() * Math.PI * 2;
4524
+ const u = Math.random() * 2 - 1;
4525
+ const c = Math.sqrt( 1 - u * u );
4597
4526
 
4598
- this.x = f * Math.cos( t );
4599
- this.y = f * Math.sin( t );
4600
- this.z = u;
4527
+ this.x = c * Math.cos( theta );
4528
+ this.y = u;
4529
+ this.z = c * Math.sin( theta );
4601
4530
 
4602
4531
  return this;
4603
4532
 
@@ -6623,25 +6552,25 @@ class Matrix4 {
6623
6552
  position.z = te[ 14 ];
6624
6553
 
6625
6554
  // scale the rotation part
6626
- _m1$2.copy( this );
6555
+ _m1$4.copy( this );
6627
6556
 
6628
6557
  const invSX = 1 / sx;
6629
6558
  const invSY = 1 / sy;
6630
6559
  const invSZ = 1 / sz;
6631
6560
 
6632
- _m1$2.elements[ 0 ] *= invSX;
6633
- _m1$2.elements[ 1 ] *= invSX;
6634
- _m1$2.elements[ 2 ] *= invSX;
6561
+ _m1$4.elements[ 0 ] *= invSX;
6562
+ _m1$4.elements[ 1 ] *= invSX;
6563
+ _m1$4.elements[ 2 ] *= invSX;
6635
6564
 
6636
- _m1$2.elements[ 4 ] *= invSY;
6637
- _m1$2.elements[ 5 ] *= invSY;
6638
- _m1$2.elements[ 6 ] *= invSY;
6565
+ _m1$4.elements[ 4 ] *= invSY;
6566
+ _m1$4.elements[ 5 ] *= invSY;
6567
+ _m1$4.elements[ 6 ] *= invSY;
6639
6568
 
6640
- _m1$2.elements[ 8 ] *= invSZ;
6641
- _m1$2.elements[ 9 ] *= invSZ;
6642
- _m1$2.elements[ 10 ] *= invSZ;
6569
+ _m1$4.elements[ 8 ] *= invSZ;
6570
+ _m1$4.elements[ 9 ] *= invSZ;
6571
+ _m1$4.elements[ 10 ] *= invSZ;
6643
6572
 
6644
- quaternion.setFromRotationMatrix( _m1$2 );
6573
+ quaternion.setFromRotationMatrix( _m1$4 );
6645
6574
 
6646
6575
  scale.x = sx;
6647
6576
  scale.y = sy;
@@ -6782,14 +6711,14 @@ class Matrix4 {
6782
6711
  }
6783
6712
 
6784
6713
  const _v1$5 = /*@__PURE__*/ new Vector3();
6785
- const _m1$2 = /*@__PURE__*/ new Matrix4();
6714
+ const _m1$4 = /*@__PURE__*/ new Matrix4();
6786
6715
  const _zero = /*@__PURE__*/ new Vector3( 0, 0, 0 );
6787
6716
  const _one = /*@__PURE__*/ new Vector3( 1, 1, 1 );
6788
6717
  const _x = /*@__PURE__*/ new Vector3();
6789
6718
  const _y = /*@__PURE__*/ new Vector3();
6790
6719
  const _z = /*@__PURE__*/ new Vector3();
6791
6720
 
6792
- const _matrix$1 = /*@__PURE__*/ new Matrix4();
6721
+ const _matrix$2 = /*@__PURE__*/ new Matrix4();
6793
6722
  const _quaternion$3 = /*@__PURE__*/ new Quaternion();
6794
6723
 
6795
6724
  class Euler {
@@ -7024,9 +6953,9 @@ class Euler {
7024
6953
 
7025
6954
  setFromQuaternion( q, order, update ) {
7026
6955
 
7027
- _matrix$1.makeRotationFromQuaternion( q );
6956
+ _matrix$2.makeRotationFromQuaternion( q );
7028
6957
 
7029
- return this.setFromRotationMatrix( _matrix$1, order, update );
6958
+ return this.setFromRotationMatrix( _matrix$2, order, update );
7030
6959
 
7031
6960
  }
7032
6961
 
@@ -7161,7 +7090,7 @@ let _object3DId = 0;
7161
7090
 
7162
7091
  const _v1$4 = /*@__PURE__*/ new Vector3();
7163
7092
  const _q1 = /*@__PURE__*/ new Quaternion();
7164
- const _m1$1 = /*@__PURE__*/ new Matrix4();
7093
+ const _m1$3 = /*@__PURE__*/ new Matrix4();
7165
7094
  const _target = /*@__PURE__*/ new Vector3();
7166
7095
 
7167
7096
  const _position$3 = /*@__PURE__*/ new Vector3();
@@ -7175,6 +7104,9 @@ const _zAxis = /*@__PURE__*/ new Vector3( 0, 0, 1 );
7175
7104
  const _addedEvent = { type: 'added' };
7176
7105
  const _removedEvent = { type: 'removed' };
7177
7106
 
7107
+ const _childaddedEvent = { type: 'childadded', child: null };
7108
+ const _childremovedEvent = { type: 'childremoved', child: null };
7109
+
7178
7110
  class Object3D extends EventDispatcher {
7179
7111
 
7180
7112
  constructor() {
@@ -7411,7 +7343,7 @@ class Object3D extends EventDispatcher {
7411
7343
 
7412
7344
  this.updateWorldMatrix( true, false );
7413
7345
 
7414
- return vector.applyMatrix4( _m1$1.copy( this.matrixWorld ).invert() );
7346
+ return vector.applyMatrix4( _m1$3.copy( this.matrixWorld ).invert() );
7415
7347
 
7416
7348
  }
7417
7349
 
@@ -7437,20 +7369,20 @@ class Object3D extends EventDispatcher {
7437
7369
 
7438
7370
  if ( this.isCamera || this.isLight ) {
7439
7371
 
7440
- _m1$1.lookAt( _position$3, _target, this.up );
7372
+ _m1$3.lookAt( _position$3, _target, this.up );
7441
7373
 
7442
7374
  } else {
7443
7375
 
7444
- _m1$1.lookAt( _target, _position$3, this.up );
7376
+ _m1$3.lookAt( _target, _position$3, this.up );
7445
7377
 
7446
7378
  }
7447
7379
 
7448
- this.quaternion.setFromRotationMatrix( _m1$1 );
7380
+ this.quaternion.setFromRotationMatrix( _m1$3 );
7449
7381
 
7450
7382
  if ( parent ) {
7451
7383
 
7452
- _m1$1.extractRotation( parent.matrixWorld );
7453
- _q1.setFromRotationMatrix( _m1$1 );
7384
+ _m1$3.extractRotation( parent.matrixWorld );
7385
+ _q1.setFromRotationMatrix( _m1$3 );
7454
7386
  this.quaternion.premultiply( _q1.invert() );
7455
7387
 
7456
7388
  }
@@ -7480,17 +7412,16 @@ class Object3D extends EventDispatcher {
7480
7412
 
7481
7413
  if ( object && object.isObject3D ) {
7482
7414
 
7483
- if ( object.parent !== null ) {
7484
-
7485
- object.parent.remove( object );
7486
-
7487
- }
7488
-
7415
+ object.removeFromParent();
7489
7416
  object.parent = this;
7490
7417
  this.children.push( object );
7491
7418
 
7492
7419
  object.dispatchEvent( _addedEvent );
7493
7420
 
7421
+ _childaddedEvent.child = object;
7422
+ this.dispatchEvent( _childaddedEvent );
7423
+ _childaddedEvent.child = null;
7424
+
7494
7425
  } else {
7495
7426
 
7496
7427
  console.error( 'THREE.Object3D.add: object not an instance of THREE.Object3D.', object );
@@ -7524,6 +7455,10 @@ class Object3D extends EventDispatcher {
7524
7455
 
7525
7456
  object.dispatchEvent( _removedEvent );
7526
7457
 
7458
+ _childremovedEvent.child = object;
7459
+ this.dispatchEvent( _childremovedEvent );
7460
+ _childremovedEvent.child = null;
7461
+
7527
7462
  }
7528
7463
 
7529
7464
  return this;
@@ -7558,22 +7493,30 @@ class Object3D extends EventDispatcher {
7558
7493
 
7559
7494
  this.updateWorldMatrix( true, false );
7560
7495
 
7561
- _m1$1.copy( this.matrixWorld ).invert();
7496
+ _m1$3.copy( this.matrixWorld ).invert();
7562
7497
 
7563
7498
  if ( object.parent !== null ) {
7564
7499
 
7565
7500
  object.parent.updateWorldMatrix( true, false );
7566
7501
 
7567
- _m1$1.multiply( object.parent.matrixWorld );
7502
+ _m1$3.multiply( object.parent.matrixWorld );
7568
7503
 
7569
7504
  }
7570
7505
 
7571
- object.applyMatrix4( _m1$1 );
7506
+ object.applyMatrix4( _m1$3 );
7572
7507
 
7573
- this.add( object );
7508
+ object.removeFromParent();
7509
+ object.parent = this;
7510
+ this.children.push( object );
7574
7511
 
7575
7512
  object.updateWorldMatrix( false, true );
7576
7513
 
7514
+ object.dispatchEvent( _addedEvent );
7515
+
7516
+ _childaddedEvent.child = object;
7517
+ this.dispatchEvent( _childaddedEvent );
7518
+ _childaddedEvent.child = null;
7519
+
7577
7520
  return this;
7578
7521
 
7579
7522
  }
@@ -9268,7 +9211,7 @@ class Material extends EventDispatcher {
9268
9211
  if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
9269
9212
  if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
9270
9213
  if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
9271
- if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
9214
+ if ( this.emissiveIntensity !== undefined && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
9272
9215
 
9273
9216
  if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
9274
9217
  if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
@@ -9378,6 +9321,7 @@ class Material extends EventDispatcher {
9378
9321
 
9379
9322
  }
9380
9323
 
9324
+ if ( this.envMapRotation !== undefined ) data.envMapRotation = this.envMapRotation.toArray();
9381
9325
  if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;
9382
9326
  if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity;
9383
9327
  if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio;
@@ -9622,6 +9566,7 @@ class MeshBasicMaterial extends Material {
9622
9566
  this.alphaMap = null;
9623
9567
 
9624
9568
  this.envMap = null;
9569
+ this.envMapRotation = new Euler();
9625
9570
  this.combine = MultiplyOperation;
9626
9571
  this.reflectivity = 1;
9627
9572
  this.refractionRatio = 0.98;
@@ -9656,6 +9601,7 @@ class MeshBasicMaterial extends Material {
9656
9601
  this.alphaMap = source.alphaMap;
9657
9602
 
9658
9603
  this.envMap = source.envMap;
9604
+ this.envMapRotation.copy( source.envMapRotation );
9659
9605
  this.combine = source.combine;
9660
9606
  this.reflectivity = source.reflectivity;
9661
9607
  this.refractionRatio = source.refractionRatio;
@@ -10460,19 +10406,9 @@ class Float32BufferAttribute extends BufferAttribute {
10460
10406
 
10461
10407
  }
10462
10408
 
10463
- class Float64BufferAttribute extends BufferAttribute {
10464
-
10465
- constructor( array, itemSize, normalized ) {
10466
-
10467
- super( new Float64Array( array ), itemSize, normalized );
10468
-
10469
- }
10470
-
10471
- }
10472
-
10473
10409
  let _id$2 = 0;
10474
10410
 
10475
- const _m1 = /*@__PURE__*/ new Matrix4();
10411
+ const _m1$2 = /*@__PURE__*/ new Matrix4();
10476
10412
  const _obj = /*@__PURE__*/ new Object3D();
10477
10413
  const _offset = /*@__PURE__*/ new Vector3();
10478
10414
  const _box$2 = /*@__PURE__*/ new Box3();
@@ -10638,9 +10574,9 @@ class BufferGeometry extends EventDispatcher {
10638
10574
 
10639
10575
  applyQuaternion( q ) {
10640
10576
 
10641
- _m1.makeRotationFromQuaternion( q );
10577
+ _m1$2.makeRotationFromQuaternion( q );
10642
10578
 
10643
- this.applyMatrix4( _m1 );
10579
+ this.applyMatrix4( _m1$2 );
10644
10580
 
10645
10581
  return this;
10646
10582
 
@@ -10650,9 +10586,9 @@ class BufferGeometry extends EventDispatcher {
10650
10586
 
10651
10587
  // rotate geometry around world x-axis
10652
10588
 
10653
- _m1.makeRotationX( angle );
10589
+ _m1$2.makeRotationX( angle );
10654
10590
 
10655
- this.applyMatrix4( _m1 );
10591
+ this.applyMatrix4( _m1$2 );
10656
10592
 
10657
10593
  return this;
10658
10594
 
@@ -10662,9 +10598,9 @@ class BufferGeometry extends EventDispatcher {
10662
10598
 
10663
10599
  // rotate geometry around world y-axis
10664
10600
 
10665
- _m1.makeRotationY( angle );
10601
+ _m1$2.makeRotationY( angle );
10666
10602
 
10667
- this.applyMatrix4( _m1 );
10603
+ this.applyMatrix4( _m1$2 );
10668
10604
 
10669
10605
  return this;
10670
10606
 
@@ -10674,9 +10610,9 @@ class BufferGeometry extends EventDispatcher {
10674
10610
 
10675
10611
  // rotate geometry around world z-axis
10676
10612
 
10677
- _m1.makeRotationZ( angle );
10613
+ _m1$2.makeRotationZ( angle );
10678
10614
 
10679
- this.applyMatrix4( _m1 );
10615
+ this.applyMatrix4( _m1$2 );
10680
10616
 
10681
10617
  return this;
10682
10618
 
@@ -10686,9 +10622,9 @@ class BufferGeometry extends EventDispatcher {
10686
10622
 
10687
10623
  // translate geometry
10688
10624
 
10689
- _m1.makeTranslation( x, y, z );
10625
+ _m1$2.makeTranslation( x, y, z );
10690
10626
 
10691
- this.applyMatrix4( _m1 );
10627
+ this.applyMatrix4( _m1$2 );
10692
10628
 
10693
10629
  return this;
10694
10630
 
@@ -10698,9 +10634,9 @@ class BufferGeometry extends EventDispatcher {
10698
10634
 
10699
10635
  // scale geometry
10700
10636
 
10701
- _m1.makeScale( x, y, z );
10637
+ _m1$2.makeScale( x, y, z );
10702
10638
 
10703
- this.applyMatrix4( _m1 );
10639
+ this.applyMatrix4( _m1$2 );
10704
10640
 
10705
10641
  return this;
10706
10642
 
@@ -10760,7 +10696,7 @@ class BufferGeometry extends EventDispatcher {
10760
10696
 
10761
10697
  if ( position && position.isGLBufferAttribute ) {
10762
10698
 
10763
- console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this );
10699
+ console.error( 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.', this );
10764
10700
 
10765
10701
  this.boundingBox.set(
10766
10702
  new Vector3( - Infinity, - Infinity, - Infinity ),
@@ -10830,7 +10766,7 @@ class BufferGeometry extends EventDispatcher {
10830
10766
 
10831
10767
  if ( position && position.isGLBufferAttribute ) {
10832
10768
 
10833
- console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this );
10769
+ console.error( 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.', this );
10834
10770
 
10835
10771
  this.boundingSphere.set( new Vector3(), Infinity );
10836
10772
 
@@ -10947,24 +10883,21 @@ class BufferGeometry extends EventDispatcher {
10947
10883
 
10948
10884
  }
10949
10885
 
10950
- const indices = index.array;
10951
- const positions = attributes.position.array;
10952
- const normals = attributes.normal.array;
10953
- const uvs = attributes.uv.array;
10954
-
10955
- const nVertices = positions.length / 3;
10886
+ const positionAttribute = attributes.position;
10887
+ const normalAttribute = attributes.normal;
10888
+ const uvAttribute = attributes.uv;
10956
10889
 
10957
10890
  if ( this.hasAttribute( 'tangent' ) === false ) {
10958
10891
 
10959
- this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * nVertices ), 4 ) );
10892
+ this.setAttribute( 'tangent', new BufferAttribute( new Float32Array( 4 * positionAttribute.count ), 4 ) );
10960
10893
 
10961
10894
  }
10962
10895
 
10963
- const tangents = this.getAttribute( 'tangent' ).array;
10896
+ const tangentAttribute = this.getAttribute( 'tangent' );
10964
10897
 
10965
10898
  const tan1 = [], tan2 = [];
10966
10899
 
10967
- for ( let i = 0; i < nVertices; i ++ ) {
10900
+ for ( let i = 0; i < positionAttribute.count; i ++ ) {
10968
10901
 
10969
10902
  tan1[ i ] = new Vector3();
10970
10903
  tan2[ i ] = new Vector3();
@@ -10984,13 +10917,13 @@ class BufferGeometry extends EventDispatcher {
10984
10917
 
10985
10918
  function handleTriangle( a, b, c ) {
10986
10919
 
10987
- vA.fromArray( positions, a * 3 );
10988
- vB.fromArray( positions, b * 3 );
10989
- vC.fromArray( positions, c * 3 );
10920
+ vA.fromBufferAttribute( positionAttribute, a );
10921
+ vB.fromBufferAttribute( positionAttribute, b );
10922
+ vC.fromBufferAttribute( positionAttribute, c );
10990
10923
 
10991
- uvA.fromArray( uvs, a * 2 );
10992
- uvB.fromArray( uvs, b * 2 );
10993
- uvC.fromArray( uvs, c * 2 );
10924
+ uvA.fromBufferAttribute( uvAttribute, a );
10925
+ uvB.fromBufferAttribute( uvAttribute, b );
10926
+ uvC.fromBufferAttribute( uvAttribute, c );
10994
10927
 
10995
10928
  vB.sub( vA );
10996
10929
  vC.sub( vA );
@@ -11023,7 +10956,7 @@ class BufferGeometry extends EventDispatcher {
11023
10956
 
11024
10957
  groups = [ {
11025
10958
  start: 0,
11026
- count: indices.length
10959
+ count: index.count
11027
10960
  } ];
11028
10961
 
11029
10962
  }
@@ -11038,9 +10971,9 @@ class BufferGeometry extends EventDispatcher {
11038
10971
  for ( let j = start, jl = start + count; j < jl; j += 3 ) {
11039
10972
 
11040
10973
  handleTriangle(
11041
- indices[ j + 0 ],
11042
- indices[ j + 1 ],
11043
- indices[ j + 2 ]
10974
+ index.getX( j + 0 ),
10975
+ index.getX( j + 1 ),
10976
+ index.getX( j + 2 )
11044
10977
  );
11045
10978
 
11046
10979
  }
@@ -11052,7 +10985,7 @@ class BufferGeometry extends EventDispatcher {
11052
10985
 
11053
10986
  function handleVertex( v ) {
11054
10987
 
11055
- n.fromArray( normals, v * 3 );
10988
+ n.fromBufferAttribute( normalAttribute, v );
11056
10989
  n2.copy( n );
11057
10990
 
11058
10991
  const t = tan1[ v ];
@@ -11068,10 +11001,7 @@ class BufferGeometry extends EventDispatcher {
11068
11001
  const test = tmp2.dot( tan2[ v ] );
11069
11002
  const w = ( test < 0.0 ) ? - 1.0 : 1.0;
11070
11003
 
11071
- tangents[ v * 4 ] = tmp.x;
11072
- tangents[ v * 4 + 1 ] = tmp.y;
11073
- tangents[ v * 4 + 2 ] = tmp.z;
11074
- tangents[ v * 4 + 3 ] = w;
11004
+ tangentAttribute.setXYZW( v, tmp.x, tmp.y, tmp.z, w );
11075
11005
 
11076
11006
  }
11077
11007
 
@@ -11084,9 +11014,9 @@ class BufferGeometry extends EventDispatcher {
11084
11014
 
11085
11015
  for ( let j = start, jl = start + count; j < jl; j += 3 ) {
11086
11016
 
11087
- handleVertex( indices[ j + 0 ] );
11088
- handleVertex( indices[ j + 1 ] );
11089
- handleVertex( indices[ j + 2 ] );
11017
+ handleVertex( index.getX( j + 0 ) );
11018
+ handleVertex( index.getX( j + 1 ) );
11019
+ handleVertex( index.getX( j + 2 ) );
11090
11020
 
11091
11021
  }
11092
11022
 
@@ -11915,7 +11845,6 @@ function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, n
11915
11845
  _uvC$1.fromBufferAttribute( uv1, c );
11916
11846
 
11917
11847
  intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() );
11918
- intersection.uv2 = intersection.uv1; // @deprecated, r152
11919
11848
 
11920
11849
  }
11921
11850
 
@@ -12214,13 +12143,22 @@ function cloneUniformsGroups( src ) {
12214
12143
 
12215
12144
  function getUnlitUniformColorSpace( renderer ) {
12216
12145
 
12217
- if ( renderer.getRenderTarget() === null ) {
12146
+ const currentRenderTarget = renderer.getRenderTarget();
12147
+
12148
+ if ( currentRenderTarget === null ) {
12218
12149
 
12219
12150
  // https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
12220
12151
  return renderer.outputColorSpace;
12221
12152
 
12222
12153
  }
12223
12154
 
12155
+ // https://github.com/mrdoob/three.js/issues/27868
12156
+ if ( currentRenderTarget.isXRRenderTarget === true ) {
12157
+
12158
+ return currentRenderTarget.texture.colorSpace;
12159
+
12160
+ }
12161
+
12224
12162
  return ColorManagement.workingColorSpace;
12225
12163
 
12226
12164
  }
@@ -12262,10 +12200,6 @@ class ShaderMaterial extends Material {
12262
12200
  this.forceSinglePass = true;
12263
12201
 
12264
12202
  this.extensions = {
12265
- derivatives: false, // set to use derivatives
12266
- fragDepth: false, // set to use fragment depth values
12267
- drawBuffers: false, // set to use draw buffers
12268
- shaderTextureLOD: false, // set to use shader texture LOD
12269
12203
  clipCullDistance: false, // set to use vertex shader clipping
12270
12204
  multiDraw: false // set to use vertex shader multi_draw / enable gl_DrawID
12271
12205
  };
@@ -12949,14 +12883,6 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
12949
12883
  const image = { width: size, height: size, depth: 1 };
12950
12884
  const images = [ image, image, image, image, image, image ];
12951
12885
 
12952
- if ( options.encoding !== undefined ) {
12953
-
12954
- // @deprecated, r152
12955
- warnOnce( 'THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace.' );
12956
- options.colorSpace = options.encoding === sRGBEncoding ? SRGBColorSpace : NoColorSpace;
12957
-
12958
- }
12959
-
12960
12886
  this.texture = new CubeTexture( images, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
12961
12887
 
12962
12888
  // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)
@@ -13514,9 +13440,7 @@ function WebGLAnimation() {
13514
13440
 
13515
13441
  }
13516
13442
 
13517
- function WebGLAttributes( gl, capabilities ) {
13518
-
13519
- const isWebGL2 = capabilities.isWebGL2;
13443
+ function WebGLAttributes( gl ) {
13520
13444
 
13521
13445
  const buffers = new WeakMap();
13522
13446
 
@@ -13543,15 +13467,7 @@ function WebGLAttributes( gl, capabilities ) {
13543
13467
 
13544
13468
  if ( attribute.isFloat16BufferAttribute ) {
13545
13469
 
13546
- if ( isWebGL2 ) {
13547
-
13548
- type = gl.HALF_FLOAT;
13549
-
13550
- } else {
13551
-
13552
- throw new Error( 'THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.' );
13553
-
13554
- }
13470
+ type = gl.HALF_FLOAT;
13555
13471
 
13556
13472
  } else {
13557
13473
 
@@ -13619,17 +13535,9 @@ function WebGLAttributes( gl, capabilities ) {
13619
13535
  for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
13620
13536
 
13621
13537
  const range = updateRanges[ i ];
13622
- if ( isWebGL2 ) {
13623
-
13624
- gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13625
- array, range.start, range.count );
13626
-
13627
- } else {
13628
-
13629
- gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13630
- array.subarray( range.start, range.start + range.count ) );
13631
13538
 
13632
- }
13539
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13540
+ array, range.start, range.count );
13633
13541
 
13634
13542
  }
13635
13543
 
@@ -13640,17 +13548,8 @@ function WebGLAttributes( gl, capabilities ) {
13640
13548
  // @deprecated, r159
13641
13549
  if ( updateRange.count !== - 1 ) {
13642
13550
 
13643
- if ( isWebGL2 ) {
13644
-
13645
- gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
13646
- array, updateRange.offset, updateRange.count );
13647
-
13648
- } else {
13649
-
13650
- gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
13651
- array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );
13652
-
13653
- }
13551
+ gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,
13552
+ array, updateRange.offset, updateRange.count );
13654
13553
 
13655
13554
  updateRange.count = - 1; // reset range
13656
13555
 
@@ -13899,9 +13798,9 @@ var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
13899
13798
 
13900
13799
  var colorspace_pars_fragment = "\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}";
13901
13800
 
13902
- var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
13801
+ var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
13903
13802
 
13904
- var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
13803
+ var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif";
13905
13804
 
13906
13805
  var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif";
13907
13806
 
@@ -13929,7 +13828,7 @@ var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertM
13929
13828
 
13930
13829
  var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif";
13931
13830
 
13932
- var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
13831
+ var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif";
13933
13832
 
13934
13833
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
13935
13834
 
@@ -13949,13 +13848,13 @@ var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGH
13949
13848
 
13950
13849
  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";
13951
13850
 
13952
- 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";
13851
+ var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
13953
13852
 
13954
- 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";
13853
+ var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
13955
13854
 
13956
- 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";
13855
+ var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif";
13957
13856
 
13958
- 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";
13857
+ var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif";
13959
13858
 
13960
13859
  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";
13961
13860
 
@@ -13969,11 +13868,13 @@ var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_META
13969
13868
 
13970
13869
  var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";
13971
13870
 
13871
+ var morphinstance_vertex = "#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[MORPHTARGETS_COUNT];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif";
13872
+
13972
13873
  var morphcolor_vertex = "#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif";
13973
13874
 
13974
13875
  var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif";
13975
13876
 
13976
- var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif";
13877
+ var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t#endif\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\t#ifndef USE_INSTANCING_MORPH\n\t\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\t#endif\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif";
13977
13878
 
13978
13879
  var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif";
13979
13880
 
@@ -14013,7 +13914,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
14013
13914
 
14014
13915
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
14015
13916
 
14016
- 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";
13917
+ 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";
14017
13918
 
14018
13919
  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";
14019
13920
 
@@ -14035,7 +13936,7 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
14035
13936
 
14036
13937
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
14037
13938
 
14038
- 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 CustomToneMapping( vec3 color ) { return color; }";
13939
+ 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, newPeak * vec3(1, 1, 1), g);\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
14039
13940
 
14040
13941
  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";
14041
13942
 
@@ -14055,17 +13956,17 @@ const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\n
14055
13956
 
14056
13957
  const vertex$g = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}";
14057
13958
 
14058
- const fragment$g = "#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
13959
+ const fragment$g = "#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
14059
13960
 
14060
13961
  const vertex$f = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}";
14061
13962
 
14062
13963
  const fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
14063
13964
 
14064
- const vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}";
13965
+ const vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}";
14065
13966
 
14066
13967
  const fragment$e = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}";
14067
13968
 
14068
- const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
13969
+ const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}";
14069
13970
 
14070
13971
  const fragment$d = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}";
14071
13972
 
@@ -14073,43 +13974,43 @@ const vertex$c = "varying vec3 vWorldDirection;\n#include <common>\nvoid main()
14073
13974
 
14074
13975
  const fragment$c = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
14075
13976
 
14076
- const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
13977
+ const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}";
14077
13978
 
14078
13979
  const fragment$b = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}";
14079
13980
 
14080
- const vertex$a = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}";
13981
+ const vertex$a = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}";
14081
13982
 
14082
13983
  const fragment$a = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
14083
13984
 
14084
- const vertex$9 = "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13985
+ const vertex$9 = "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
14085
13986
 
14086
13987
  const fragment$9 = "#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
14087
13988
 
14088
- const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}";
13989
+ const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}";
14089
13990
 
14090
13991
  const fragment$8 = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
14091
13992
 
14092
- const vertex$7 = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}";
13993
+ const vertex$7 = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}";
14093
13994
 
14094
13995
  const fragment$7 = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}";
14095
13996
 
14096
- const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
13997
+ const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
14097
13998
 
14098
13999
  const fragment$6 = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
14099
14000
 
14100
- 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 <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}";
14001
+ 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}";
14101
14002
 
14102
14003
  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}";
14103
14004
 
14104
- 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 <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}";
14005
+ 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}";
14105
14006
 
14106
14007
  const fragment$4 = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}";
14107
14008
 
14108
- const vertex$3 = "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}";
14009
+ const vertex$3 = "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}";
14109
14010
 
14110
14011
  const fragment$3 = "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}";
14111
14012
 
14112
- const vertex$2 = "#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
14013
+ const vertex$2 = "#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}";
14113
14014
 
14114
14015
  const fragment$2 = "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}";
14115
14016
 
@@ -14185,6 +14086,7 @@ const ShaderChunk = {
14185
14086
  map_particle_pars_fragment: map_particle_pars_fragment,
14186
14087
  metalnessmap_fragment: metalnessmap_fragment,
14187
14088
  metalnessmap_pars_fragment: metalnessmap_pars_fragment,
14089
+ morphinstance_vertex: morphinstance_vertex,
14188
14090
  morphcolor_vertex: morphcolor_vertex,
14189
14091
  morphnormal_vertex: morphnormal_vertex,
14190
14092
  morphtarget_pars_vertex: morphtarget_pars_vertex,
@@ -14293,6 +14195,7 @@ const UniformsLib = {
14293
14195
  envmap: {
14294
14196
 
14295
14197
  envMap: { value: null },
14198
+ envMapRotation: { value: /*@__PURE__*/ new Matrix3() },
14296
14199
  flipEnvMap: { value: - 1 },
14297
14200
  reflectivity: { value: 1.0 }, // basic, lambert, phong
14298
14201
  ior: { value: 1.5 }, // physical
@@ -14574,7 +14477,7 @@ const ShaderLib = {
14574
14477
  emissive: { value: /*@__PURE__*/ new Color( 0x000000 ) },
14575
14478
  roughness: { value: 1.0 },
14576
14479
  metalness: { value: 0.0 },
14577
- envMapIntensity: { value: 1 } // temporary
14480
+ envMapIntensity: { value: 1 }
14578
14481
  }
14579
14482
  ] ),
14580
14483
 
@@ -14713,7 +14616,8 @@ const ShaderLib = {
14713
14616
  envMap: { value: null },
14714
14617
  flipEnvMap: { value: - 1 },
14715
14618
  backgroundBlurriness: { value: 0 },
14716
- backgroundIntensity: { value: 1 }
14619
+ backgroundIntensity: { value: 1 },
14620
+ backgroundRotation: { value: /*@__PURE__*/ new Matrix3() }
14717
14621
  },
14718
14622
 
14719
14623
  vertexShader: ShaderChunk.backgroundCube_vert,
@@ -14837,6 +14741,8 @@ ShaderLib.physical = {
14837
14741
  };
14838
14742
 
14839
14743
  const _rgb = { r: 0, b: 0, g: 0 };
14744
+ const _e1$1 = /*@__PURE__*/ new Euler();
14745
+ const _m1$1 = /*@__PURE__*/ new Matrix4();
14840
14746
 
14841
14747
  function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha ) {
14842
14748
 
@@ -14933,10 +14839,24 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14933
14839
 
14934
14840
  }
14935
14841
 
14842
+ _e1$1.copy( scene.backgroundRotation );
14843
+
14844
+ // accommodate left-handed frame
14845
+ _e1$1.x *= - 1; _e1$1.y *= - 1; _e1$1.z *= - 1;
14846
+
14847
+ if ( background.isCubeTexture && background.isRenderTargetTexture === false ) {
14848
+
14849
+ // environment maps which are not cube render targets or PMREMs follow a different convention
14850
+ _e1$1.y *= - 1;
14851
+ _e1$1.z *= - 1;
14852
+
14853
+ }
14854
+
14936
14855
  boxMesh.material.uniforms.envMap.value = background;
14937
14856
  boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
14938
14857
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
14939
14858
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
14859
+ boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4( _m1$1.makeRotationFromEuler( _e1$1 ) );
14940
14860
  boxMesh.material.toneMapped = ColorManagement.getTransfer( background.colorSpace ) !== SRGBTransfer;
14941
14861
 
14942
14862
  if ( currentBackground !== background ||
@@ -15063,13 +14983,10 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
15063
14983
 
15064
14984
  }
15065
14985
 
15066
- function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
14986
+ function WebGLBindingStates( gl, attributes ) {
15067
14987
 
15068
14988
  const maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );
15069
14989
 
15070
- const extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );
15071
- const vaoAvailable = capabilities.isWebGL2 || extension !== null;
15072
-
15073
14990
  const bindingStates = {};
15074
14991
 
15075
14992
  const defaultState = createBindingState( null );
@@ -15080,38 +14997,18 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15080
14997
 
15081
14998
  let updateBuffers = false;
15082
14999
 
15083
- if ( vaoAvailable ) {
15000
+ const state = getBindingState( geometry, program, material );
15084
15001
 
15085
- const state = getBindingState( geometry, program, material );
15002
+ if ( currentState !== state ) {
15086
15003
 
15087
- if ( currentState !== state ) {
15004
+ currentState = state;
15005
+ bindVertexArrayObject( currentState.object );
15088
15006
 
15089
- currentState = state;
15090
- bindVertexArrayObject( currentState.object );
15091
-
15092
- }
15093
-
15094
- updateBuffers = needsUpdate( object, geometry, program, index );
15095
-
15096
- if ( updateBuffers ) saveCache( object, geometry, program, index );
15097
-
15098
- } else {
15099
-
15100
- const wireframe = ( material.wireframe === true );
15101
-
15102
- if ( currentState.geometry !== geometry.id ||
15103
- currentState.program !== program.id ||
15104
- currentState.wireframe !== wireframe ) {
15105
-
15106
- currentState.geometry = geometry.id;
15107
- currentState.program = program.id;
15108
- currentState.wireframe = wireframe;
15007
+ }
15109
15008
 
15110
- updateBuffers = true;
15009
+ updateBuffers = needsUpdate( object, geometry, program, index );
15111
15010
 
15112
- }
15113
-
15114
- }
15011
+ if ( updateBuffers ) saveCache( object, geometry, program, index );
15115
15012
 
15116
15013
  if ( index !== null ) {
15117
15014
 
@@ -15137,25 +15034,19 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15137
15034
 
15138
15035
  function createVertexArrayObject() {
15139
15036
 
15140
- if ( capabilities.isWebGL2 ) return gl.createVertexArray();
15141
-
15142
- return extension.createVertexArrayOES();
15037
+ return gl.createVertexArray();
15143
15038
 
15144
15039
  }
15145
15040
 
15146
15041
  function bindVertexArrayObject( vao ) {
15147
15042
 
15148
- if ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao );
15149
-
15150
- return extension.bindVertexArrayOES( vao );
15043
+ return gl.bindVertexArray( vao );
15151
15044
 
15152
15045
  }
15153
15046
 
15154
15047
  function deleteVertexArrayObject( vao ) {
15155
15048
 
15156
- if ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao );
15157
-
15158
- return extension.deleteVertexArrayOES( vao );
15049
+ return gl.deleteVertexArray( vao );
15159
15050
 
15160
15051
  }
15161
15052
 
@@ -15353,9 +15244,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15353
15244
 
15354
15245
  if ( attributeDivisors[ attribute ] !== meshPerAttribute ) {
15355
15246
 
15356
- const extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );
15357
-
15358
- extension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );
15247
+ gl.vertexAttribDivisor( attribute, meshPerAttribute );
15359
15248
  attributeDivisors[ attribute ] = meshPerAttribute;
15360
15249
 
15361
15250
  }
@@ -15396,12 +15285,6 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15396
15285
 
15397
15286
  function setupVertexAttributes( object, material, program, geometry ) {
15398
15287
 
15399
- if ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {
15400
-
15401
- if ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;
15402
-
15403
- }
15404
-
15405
15288
  initAttributes();
15406
15289
 
15407
15290
  const geometryAttributes = geometry.attributes;
@@ -15440,9 +15323,9 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15440
15323
  const type = attribute.type;
15441
15324
  const bytesPerElement = attribute.bytesPerElement;
15442
15325
 
15443
- // check for integer attributes (WebGL 2 only)
15326
+ // check for integer attributes
15444
15327
 
15445
- const integer = ( capabilities.isWebGL2 === true && ( type === gl.INT || type === gl.UNSIGNED_INT || geometryAttribute.gpuType === IntType ) );
15328
+ const integer = ( type === gl.INT || type === gl.UNSIGNED_INT || geometryAttribute.gpuType === IntType );
15446
15329
 
15447
15330
  if ( geometryAttribute.isInterleavedBufferAttribute ) {
15448
15331
 
@@ -15690,9 +15573,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
15690
15573
 
15691
15574
  }
15692
15575
 
15693
- function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15694
-
15695
- const isWebGL2 = capabilities.isWebGL2;
15576
+ function WebGLBufferRenderer( gl, extensions, info ) {
15696
15577
 
15697
15578
  let mode;
15698
15579
 
@@ -15714,28 +15595,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15714
15595
 
15715
15596
  if ( primcount === 0 ) return;
15716
15597
 
15717
- let extension, methodName;
15718
-
15719
- if ( isWebGL2 ) {
15720
-
15721
- extension = gl;
15722
- methodName = 'drawArraysInstanced';
15723
-
15724
- } else {
15725
-
15726
- extension = extensions.get( 'ANGLE_instanced_arrays' );
15727
- methodName = 'drawArraysInstancedANGLE';
15728
-
15729
- if ( extension === null ) {
15730
-
15731
- console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
15732
- return;
15733
-
15734
- }
15735
-
15736
- }
15737
-
15738
- extension[ methodName ]( mode, start, count, primcount );
15598
+ gl.drawArraysInstanced( mode, start, count, primcount );
15739
15599
 
15740
15600
  info.update( count, mode, primcount );
15741
15601
 
@@ -15746,6 +15606,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15746
15606
  if ( drawCount === 0 ) return;
15747
15607
 
15748
15608
  const extension = extensions.get( 'WEBGL_multi_draw' );
15609
+
15749
15610
  if ( extension === null ) {
15750
15611
 
15751
15612
  for ( let i = 0; i < drawCount; i ++ ) {
@@ -15834,8 +15695,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15834
15695
 
15835
15696
  }
15836
15697
 
15837
- const isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl.constructor.name === 'WebGL2RenderingContext';
15838
-
15839
15698
  let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
15840
15699
  const maxPrecision = getMaxPrecision( precision );
15841
15700
 
@@ -15846,8 +15705,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15846
15705
 
15847
15706
  }
15848
15707
 
15849
- const drawBuffers = isWebGL2 || extensions.has( 'WEBGL_draw_buffers' );
15850
-
15851
15708
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
15852
15709
 
15853
15710
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
@@ -15861,16 +15718,12 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15861
15718
  const maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );
15862
15719
 
15863
15720
  const vertexTextures = maxVertexTextures > 0;
15864
- const floatFragmentTextures = isWebGL2 || extensions.has( 'OES_texture_float' );
15865
- const floatVertexTextures = vertexTextures && floatFragmentTextures;
15866
15721
 
15867
- const maxSamples = isWebGL2 ? gl.getParameter( gl.MAX_SAMPLES ) : 0;
15722
+ const maxSamples = gl.getParameter( gl.MAX_SAMPLES );
15868
15723
 
15869
15724
  return {
15870
15725
 
15871
- isWebGL2: isWebGL2,
15872
-
15873
- drawBuffers: drawBuffers,
15726
+ isWebGL2: true, // keeping this for backwards compatibility
15874
15727
 
15875
15728
  getMaxAnisotropy: getMaxAnisotropy,
15876
15729
  getMaxPrecision: getMaxPrecision,
@@ -15889,8 +15742,6 @@ function WebGLCapabilities( gl, extensions, parameters ) {
15889
15742
  maxFragmentUniforms: maxFragmentUniforms,
15890
15743
 
15891
15744
  vertexTextures: vertexTextures,
15892
- floatFragmentTextures: floatFragmentTextures,
15893
- floatVertexTextures: floatVertexTextures,
15894
15745
 
15895
15746
  maxSamples: maxSamples
15896
15747
 
@@ -16309,6 +16160,7 @@ const _clearColor = /*@__PURE__*/ new Color();
16309
16160
  let _oldTarget = null;
16310
16161
  let _oldActiveCubeFace = 0;
16311
16162
  let _oldActiveMipmapLevel = 0;
16163
+ let _oldXrEnabled = false;
16312
16164
 
16313
16165
  // Golden Ratio
16314
16166
  const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
@@ -16376,6 +16228,9 @@ class PMREMGenerator {
16376
16228
  _oldTarget = this._renderer.getRenderTarget();
16377
16229
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
16378
16230
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
16231
+ _oldXrEnabled = this._renderer.xr.enabled;
16232
+
16233
+ this._renderer.xr.enabled = false;
16379
16234
 
16380
16235
  this._setSize( 256 );
16381
16236
 
@@ -16401,6 +16256,7 @@ class PMREMGenerator {
16401
16256
  * Generates a PMREM from an equirectangular texture, which can be either LDR
16402
16257
  * or HDR. The ideal input image size is 1k (1024 x 512),
16403
16258
  * as this matches best with the 256 x 256 cubemap output.
16259
+ * The smallest supported equirectangular image size is 64 x 32.
16404
16260
  */
16405
16261
  fromEquirectangular( equirectangular, renderTarget = null ) {
16406
16262
 
@@ -16412,6 +16268,7 @@ class PMREMGenerator {
16412
16268
  * Generates a PMREM from an cubemap texture, which can be either LDR
16413
16269
  * or HDR. The ideal input cube size is 256 x 256,
16414
16270
  * as this matches best with the 256 x 256 cubemap output.
16271
+ * The smallest supported cube size is 16 x 16.
16415
16272
  */
16416
16273
  fromCubemap( cubemap, renderTarget = null ) {
16417
16274
 
@@ -16489,6 +16346,8 @@ class PMREMGenerator {
16489
16346
  _cleanup( outputTarget ) {
16490
16347
 
16491
16348
  this._renderer.setRenderTarget( _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel );
16349
+ this._renderer.xr.enabled = _oldXrEnabled;
16350
+
16492
16351
  outputTarget.scissorTest = false;
16493
16352
  _setViewport( outputTarget, 0, 0, outputTarget.width, outputTarget.height );
16494
16353
 
@@ -16509,6 +16368,9 @@ class PMREMGenerator {
16509
16368
  _oldTarget = this._renderer.getRenderTarget();
16510
16369
  _oldActiveCubeFace = this._renderer.getActiveCubeFace();
16511
16370
  _oldActiveMipmapLevel = this._renderer.getActiveMipmapLevel();
16371
+ _oldXrEnabled = this._renderer.xr.enabled;
16372
+
16373
+ this._renderer.xr.enabled = false;
16512
16374
 
16513
16375
  const cubeUVRenderTarget = renderTarget || this._allocateTargets();
16514
16376
  this._textureToCubeUV( texture, cubeUVRenderTarget );
@@ -17191,24 +17053,26 @@ function WebGLCubeUVMaps( renderer ) {
17191
17053
 
17192
17054
  if ( isEquirectMap || isCubeMap ) {
17193
17055
 
17194
- if ( texture.isRenderTargetTexture && texture.needsPMREMUpdate === true ) {
17056
+ let renderTarget = cubeUVmaps.get( texture );
17195
17057
 
17196
- texture.needsPMREMUpdate = false;
17058
+ const currentPMREMVersion = renderTarget !== undefined ? renderTarget.texture.pmremVersion : 0;
17197
17059
 
17198
- let renderTarget = cubeUVmaps.get( texture );
17060
+ if ( texture.isRenderTargetTexture && texture.pmremVersion !== currentPMREMVersion ) {
17199
17061
 
17200
17062
  if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
17201
17063
 
17202
17064
  renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture, renderTarget ) : pmremGenerator.fromCubemap( texture, renderTarget );
17065
+ renderTarget.texture.pmremVersion = texture.pmremVersion;
17066
+
17203
17067
  cubeUVmaps.set( texture, renderTarget );
17204
17068
 
17205
17069
  return renderTarget.texture;
17206
17070
 
17207
17071
  } else {
17208
17072
 
17209
- if ( cubeUVmaps.has( texture ) ) {
17073
+ if ( renderTarget !== undefined ) {
17210
17074
 
17211
- return cubeUVmaps.get( texture ).texture;
17075
+ return renderTarget.texture;
17212
17076
 
17213
17077
  } else {
17214
17078
 
@@ -17218,7 +17082,9 @@ function WebGLCubeUVMaps( renderer ) {
17218
17082
 
17219
17083
  if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
17220
17084
 
17221
- const renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture );
17085
+ renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture );
17086
+ renderTarget.texture.pmremVersion = texture.pmremVersion;
17087
+
17222
17088
  cubeUVmaps.set( texture, renderTarget );
17223
17089
 
17224
17090
  texture.addEventListener( 'dispose', onTextureDispose );
@@ -17349,29 +17215,14 @@ function WebGLExtensions( gl ) {
17349
17215
 
17350
17216
  },
17351
17217
 
17352
- init: function ( capabilities ) {
17353
-
17354
- if ( capabilities.isWebGL2 ) {
17355
-
17356
- getExtension( 'EXT_color_buffer_float' );
17357
- getExtension( 'WEBGL_clip_cull_distance' );
17358
-
17359
- } else {
17360
-
17361
- getExtension( 'WEBGL_depth_texture' );
17362
- getExtension( 'OES_texture_float' );
17363
- getExtension( 'OES_texture_half_float' );
17364
- getExtension( 'OES_texture_half_float_linear' );
17365
- getExtension( 'OES_standard_derivatives' );
17366
- getExtension( 'OES_element_index_uint' );
17367
- getExtension( 'OES_vertex_array_object' );
17368
- getExtension( 'ANGLE_instanced_arrays' );
17369
-
17370
- }
17218
+ init: function () {
17371
17219
 
17220
+ getExtension( 'EXT_color_buffer_float' );
17221
+ getExtension( 'WEBGL_clip_cull_distance' );
17372
17222
  getExtension( 'OES_texture_float_linear' );
17373
17223
  getExtension( 'EXT_color_buffer_half_float' );
17374
17224
  getExtension( 'WEBGL_multisampled_render_to_texture' );
17225
+ getExtension( 'WEBGL_render_shared_exponent' );
17375
17226
 
17376
17227
  },
17377
17228
 
@@ -17599,9 +17450,7 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
17599
17450
 
17600
17451
  }
17601
17452
 
17602
- function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17603
-
17604
- const isWebGL2 = capabilities.isWebGL2;
17453
+ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
17605
17454
 
17606
17455
  let mode;
17607
17456
 
@@ -17632,28 +17481,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17632
17481
 
17633
17482
  if ( primcount === 0 ) return;
17634
17483
 
17635
- let extension, methodName;
17636
-
17637
- if ( isWebGL2 ) {
17638
-
17639
- extension = gl;
17640
- methodName = 'drawElementsInstanced';
17641
-
17642
- } else {
17643
-
17644
- extension = extensions.get( 'ANGLE_instanced_arrays' );
17645
- methodName = 'drawElementsInstancedANGLE';
17646
-
17647
- if ( extension === null ) {
17648
-
17649
- console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
17650
- return;
17651
-
17652
- }
17653
-
17654
- }
17655
-
17656
- extension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );
17484
+ gl.drawElementsInstanced( mode, count, type, start * bytesPerElement, primcount );
17657
17485
 
17658
17486
  info.update( count, mode, primcount );
17659
17487
 
@@ -17664,6 +17492,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17664
17492
  if ( drawCount === 0 ) return;
17665
17493
 
17666
17494
  const extension = extensions.get( 'WEBGL_multi_draw' );
17495
+
17667
17496
  if ( extension === null ) {
17668
17497
 
17669
17498
  for ( let i = 0; i < drawCount; i ++ ) {
@@ -17768,289 +17597,158 @@ function WebGLInfo( gl ) {
17768
17597
 
17769
17598
  }
17770
17599
 
17771
- function numericalSort( a, b ) {
17772
-
17773
- return a[ 0 ] - b[ 0 ];
17774
-
17775
- }
17776
-
17777
- function absNumericalSort( a, b ) {
17778
-
17779
- return Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );
17780
-
17781
- }
17782
-
17783
17600
  function WebGLMorphtargets( gl, capabilities, textures ) {
17784
17601
 
17785
- const influencesList = {};
17786
- const morphInfluences = new Float32Array( 8 );
17787
17602
  const morphTextures = new WeakMap();
17788
17603
  const morph = new Vector4();
17789
17604
 
17790
- const workInfluences = [];
17791
-
17792
- for ( let i = 0; i < 8; i ++ ) {
17793
-
17794
- workInfluences[ i ] = [ i, 0 ];
17795
-
17796
- }
17797
-
17798
17605
  function update( object, geometry, program ) {
17799
17606
 
17800
17607
  const objectInfluences = object.morphTargetInfluences;
17801
17608
 
17802
- if ( capabilities.isWebGL2 === true ) {
17803
-
17804
- // instead of using attributes, the WebGL 2 code path encodes morph targets
17805
- // into an array of data textures. Each layer represents a single morph target.
17806
-
17807
- const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
17808
- const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
17609
+ // instead of using attributes, the WebGL 2 code path encodes morph targets
17610
+ // into an array of data textures. Each layer represents a single morph target.
17809
17611
 
17810
- let entry = morphTextures.get( geometry );
17811
-
17812
- if ( entry === undefined || entry.count !== morphTargetsCount ) {
17813
-
17814
- if ( entry !== undefined ) entry.texture.dispose();
17815
-
17816
- const hasMorphPosition = geometry.morphAttributes.position !== undefined;
17817
- const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
17818
- const hasMorphColors = geometry.morphAttributes.color !== undefined;
17819
-
17820
- const morphTargets = geometry.morphAttributes.position || [];
17821
- const morphNormals = geometry.morphAttributes.normal || [];
17822
- const morphColors = geometry.morphAttributes.color || [];
17612
+ const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
17613
+ const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
17823
17614
 
17824
- let vertexDataCount = 0;
17615
+ let entry = morphTextures.get( geometry );
17825
17616
 
17826
- if ( hasMorphPosition === true ) vertexDataCount = 1;
17827
- if ( hasMorphNormals === true ) vertexDataCount = 2;
17828
- if ( hasMorphColors === true ) vertexDataCount = 3;
17617
+ if ( entry === undefined || entry.count !== morphTargetsCount ) {
17829
17618
 
17830
- let width = geometry.attributes.position.count * vertexDataCount;
17831
- let height = 1;
17619
+ if ( entry !== undefined ) entry.texture.dispose();
17832
17620
 
17833
- if ( width > capabilities.maxTextureSize ) {
17621
+ const hasMorphPosition = geometry.morphAttributes.position !== undefined;
17622
+ const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
17623
+ const hasMorphColors = geometry.morphAttributes.color !== undefined;
17834
17624
 
17835
- height = Math.ceil( width / capabilities.maxTextureSize );
17836
- width = capabilities.maxTextureSize;
17625
+ const morphTargets = geometry.morphAttributes.position || [];
17626
+ const morphNormals = geometry.morphAttributes.normal || [];
17627
+ const morphColors = geometry.morphAttributes.color || [];
17837
17628
 
17838
- }
17629
+ let vertexDataCount = 0;
17839
17630
 
17840
- const buffer = new Float32Array( width * height * 4 * morphTargetsCount );
17631
+ if ( hasMorphPosition === true ) vertexDataCount = 1;
17632
+ if ( hasMorphNormals === true ) vertexDataCount = 2;
17633
+ if ( hasMorphColors === true ) vertexDataCount = 3;
17841
17634
 
17842
- const texture = new DataArrayTexture( buffer, width, height, morphTargetsCount );
17843
- texture.type = FloatType;
17844
- texture.needsUpdate = true;
17635
+ let width = geometry.attributes.position.count * vertexDataCount;
17636
+ let height = 1;
17845
17637
 
17846
- // fill buffer
17638
+ if ( width > capabilities.maxTextureSize ) {
17847
17639
 
17848
- const vertexDataStride = vertexDataCount * 4;
17640
+ height = Math.ceil( width / capabilities.maxTextureSize );
17641
+ width = capabilities.maxTextureSize;
17849
17642
 
17850
- for ( let i = 0; i < morphTargetsCount; i ++ ) {
17643
+ }
17851
17644
 
17852
- const morphTarget = morphTargets[ i ];
17853
- const morphNormal = morphNormals[ i ];
17854
- const morphColor = morphColors[ i ];
17645
+ const buffer = new Float32Array( width * height * 4 * morphTargetsCount );
17855
17646
 
17856
- const offset = width * height * 4 * i;
17647
+ const texture = new DataArrayTexture( buffer, width, height, morphTargetsCount );
17648
+ texture.type = FloatType;
17649
+ texture.needsUpdate = true;
17857
17650
 
17858
- for ( let j = 0; j < morphTarget.count; j ++ ) {
17651
+ // fill buffer
17859
17652
 
17860
- const stride = j * vertexDataStride;
17653
+ const vertexDataStride = vertexDataCount * 4;
17861
17654
 
17862
- if ( hasMorphPosition === true ) {
17655
+ for ( let i = 0; i < morphTargetsCount; i ++ ) {
17863
17656
 
17864
- morph.fromBufferAttribute( morphTarget, j );
17657
+ const morphTarget = morphTargets[ i ];
17658
+ const morphNormal = morphNormals[ i ];
17659
+ const morphColor = morphColors[ i ];
17865
17660
 
17866
- buffer[ offset + stride + 0 ] = morph.x;
17867
- buffer[ offset + stride + 1 ] = morph.y;
17868
- buffer[ offset + stride + 2 ] = morph.z;
17869
- buffer[ offset + stride + 3 ] = 0;
17661
+ const offset = width * height * 4 * i;
17870
17662
 
17871
- }
17663
+ for ( let j = 0; j < morphTarget.count; j ++ ) {
17872
17664
 
17873
- if ( hasMorphNormals === true ) {
17665
+ const stride = j * vertexDataStride;
17874
17666
 
17875
- morph.fromBufferAttribute( morphNormal, j );
17667
+ if ( hasMorphPosition === true ) {
17876
17668
 
17877
- buffer[ offset + stride + 4 ] = morph.x;
17878
- buffer[ offset + stride + 5 ] = morph.y;
17879
- buffer[ offset + stride + 6 ] = morph.z;
17880
- buffer[ offset + stride + 7 ] = 0;
17669
+ morph.fromBufferAttribute( morphTarget, j );
17881
17670
 
17882
- }
17671
+ buffer[ offset + stride + 0 ] = morph.x;
17672
+ buffer[ offset + stride + 1 ] = morph.y;
17673
+ buffer[ offset + stride + 2 ] = morph.z;
17674
+ buffer[ offset + stride + 3 ] = 0;
17883
17675
 
17884
- if ( hasMorphColors === true ) {
17676
+ }
17885
17677
 
17886
- morph.fromBufferAttribute( morphColor, j );
17678
+ if ( hasMorphNormals === true ) {
17887
17679
 
17888
- buffer[ offset + stride + 8 ] = morph.x;
17889
- buffer[ offset + stride + 9 ] = morph.y;
17890
- buffer[ offset + stride + 10 ] = morph.z;
17891
- buffer[ offset + stride + 11 ] = ( morphColor.itemSize === 4 ) ? morph.w : 1;
17680
+ morph.fromBufferAttribute( morphNormal, j );
17892
17681
 
17893
- }
17682
+ buffer[ offset + stride + 4 ] = morph.x;
17683
+ buffer[ offset + stride + 5 ] = morph.y;
17684
+ buffer[ offset + stride + 6 ] = morph.z;
17685
+ buffer[ offset + stride + 7 ] = 0;
17894
17686
 
17895
17687
  }
17896
17688
 
17897
- }
17898
-
17899
- entry = {
17900
- count: morphTargetsCount,
17901
- texture: texture,
17902
- size: new Vector2( width, height )
17903
- };
17904
-
17905
- morphTextures.set( geometry, entry );
17906
-
17907
- function disposeTexture() {
17689
+ if ( hasMorphColors === true ) {
17908
17690
 
17909
- texture.dispose();
17691
+ morph.fromBufferAttribute( morphColor, j );
17910
17692
 
17911
- morphTextures.delete( geometry );
17693
+ buffer[ offset + stride + 8 ] = morph.x;
17694
+ buffer[ offset + stride + 9 ] = morph.y;
17695
+ buffer[ offset + stride + 10 ] = morph.z;
17696
+ buffer[ offset + stride + 11 ] = ( morphColor.itemSize === 4 ) ? morph.w : 1;
17912
17697
 
17913
- geometry.removeEventListener( 'dispose', disposeTexture );
17698
+ }
17914
17699
 
17915
17700
  }
17916
17701
 
17917
- geometry.addEventListener( 'dispose', disposeTexture );
17918
-
17919
17702
  }
17920
17703
 
17921
- //
17922
-
17923
- let morphInfluencesSum = 0;
17924
-
17925
- for ( let i = 0; i < objectInfluences.length; i ++ ) {
17926
-
17927
- morphInfluencesSum += objectInfluences[ i ];
17928
-
17929
- }
17930
-
17931
- const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
17932
-
17933
- program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
17934
- program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
17935
-
17936
- program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures );
17937
- program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size );
17938
-
17939
-
17940
- } else {
17941
-
17942
- // When object doesn't have morph target influences defined, we treat it as a 0-length array
17943
- // This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences
17944
-
17945
- const length = objectInfluences === undefined ? 0 : objectInfluences.length;
17946
-
17947
- let influences = influencesList[ geometry.id ];
17948
-
17949
- if ( influences === undefined || influences.length !== length ) {
17950
-
17951
- // initialise list
17952
-
17953
- influences = [];
17954
-
17955
- for ( let i = 0; i < length; i ++ ) {
17956
-
17957
- influences[ i ] = [ i, 0 ];
17958
-
17959
- }
17960
-
17961
- influencesList[ geometry.id ] = influences;
17704
+ entry = {
17705
+ count: morphTargetsCount,
17706
+ texture: texture,
17707
+ size: new Vector2( width, height )
17708
+ };
17962
17709
 
17963
- }
17710
+ morphTextures.set( geometry, entry );
17964
17711
 
17965
- // Collect influences
17712
+ function disposeTexture() {
17966
17713
 
17967
- for ( let i = 0; i < length; i ++ ) {
17714
+ texture.dispose();
17968
17715
 
17969
- const influence = influences[ i ];
17716
+ morphTextures.delete( geometry );
17970
17717
 
17971
- influence[ 0 ] = i;
17972
- influence[ 1 ] = objectInfluences[ i ];
17718
+ geometry.removeEventListener( 'dispose', disposeTexture );
17973
17719
 
17974
17720
  }
17975
17721
 
17976
- influences.sort( absNumericalSort );
17977
-
17978
- for ( let i = 0; i < 8; i ++ ) {
17979
-
17980
- if ( i < length && influences[ i ][ 1 ] ) {
17981
-
17982
- workInfluences[ i ][ 0 ] = influences[ i ][ 0 ];
17983
- workInfluences[ i ][ 1 ] = influences[ i ][ 1 ];
17722
+ geometry.addEventListener( 'dispose', disposeTexture );
17984
17723
 
17985
- } else {
17986
-
17987
- workInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;
17988
- workInfluences[ i ][ 1 ] = 0;
17989
-
17990
- }
17724
+ }
17991
17725
 
17992
- }
17726
+ //
17727
+ if ( object.isInstancedMesh === true && object.morphTexture !== null ) {
17993
17728
 
17994
- workInfluences.sort( numericalSort );
17729
+ program.getUniforms().setValue( gl, 'morphTexture', object.morphTexture, textures );
17995
17730
 
17996
- const morphTargets = geometry.morphAttributes.position;
17997
- const morphNormals = geometry.morphAttributes.normal;
17731
+ } else {
17998
17732
 
17999
17733
  let morphInfluencesSum = 0;
18000
17734
 
18001
- for ( let i = 0; i < 8; i ++ ) {
18002
-
18003
- const influence = workInfluences[ i ];
18004
- const index = influence[ 0 ];
18005
- const value = influence[ 1 ];
18006
-
18007
- if ( index !== Number.MAX_SAFE_INTEGER && value ) {
18008
-
18009
- if ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {
18010
-
18011
- geometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );
18012
-
18013
- }
18014
-
18015
- if ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {
18016
-
18017
- geometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );
18018
-
18019
- }
18020
-
18021
- morphInfluences[ i ] = value;
18022
- morphInfluencesSum += value;
18023
-
18024
- } else {
18025
-
18026
- if ( morphTargets && geometry.hasAttribute( 'morphTarget' + i ) === true ) {
18027
-
18028
- geometry.deleteAttribute( 'morphTarget' + i );
18029
-
18030
- }
18031
-
18032
- if ( morphNormals && geometry.hasAttribute( 'morphNormal' + i ) === true ) {
18033
-
18034
- geometry.deleteAttribute( 'morphNormal' + i );
18035
-
18036
- }
18037
-
18038
- morphInfluences[ i ] = 0;
17735
+ for ( let i = 0; i < objectInfluences.length; i ++ ) {
18039
17736
 
18040
- }
17737
+ morphInfluencesSum += objectInfluences[ i ];
18041
17738
 
18042
17739
  }
18043
17740
 
18044
- // GLSL shader uses formula baseinfluence * base + sum(target * influence)
18045
- // This allows us to switch between absolute morphs and relative morphs without changing shader code
18046
- // When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)
18047
17741
  const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
18048
17742
 
17743
+
18049
17744
  program.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );
18050
- program.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );
17745
+ program.getUniforms().setValue( gl, 'morphTargetInfluences', objectInfluences );
18051
17746
 
18052
17747
  }
18053
17748
 
17749
+ program.getUniforms().setValue( gl, 'morphTargetsTexture', entry.texture, textures );
17750
+ program.getUniforms().setValue( gl, 'morphTargetsTextureSize', entry.size );
17751
+
18054
17752
  }
18055
17753
 
18056
17754
  return {
@@ -19582,6 +19280,10 @@ function getToneMappingFunction( functionName, toneMapping ) {
19582
19280
  toneMappingName = 'AgX';
19583
19281
  break;
19584
19282
 
19283
+ case NeutralToneMapping:
19284
+ toneMappingName = 'Neutral';
19285
+ break;
19286
+
19585
19287
  case CustomToneMapping:
19586
19288
  toneMappingName = 'Custom';
19587
19289
  break;
@@ -19596,19 +19298,6 @@ function getToneMappingFunction( functionName, toneMapping ) {
19596
19298
 
19597
19299
  }
19598
19300
 
19599
- function generateExtensions( parameters ) {
19600
-
19601
- const chunks = [
19602
- ( parameters.extensionDerivatives || !! parameters.envMapCubeUVHeight || parameters.bumpMap || parameters.normalMapTangentSpace || parameters.clearcoatNormalMap || parameters.flatShading || parameters.alphaToCoverage || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',
19603
- ( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',
19604
- ( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',
19605
- ( parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''
19606
- ];
19607
-
19608
- return chunks.filter( filterEmptyLine ).join( '\n' );
19609
-
19610
- }
19611
-
19612
19301
  function generateVertexExtensions( parameters ) {
19613
19302
 
19614
19303
  const chunks = [
@@ -19776,27 +19465,21 @@ function generatePrecision( parameters ) {
19776
19465
  precision ${parameters.precision} int;
19777
19466
  precision ${parameters.precision} sampler2D;
19778
19467
  precision ${parameters.precision} samplerCube;
19468
+ precision ${parameters.precision} sampler3D;
19469
+ precision ${parameters.precision} sampler2DArray;
19470
+ precision ${parameters.precision} sampler2DShadow;
19471
+ precision ${parameters.precision} samplerCubeShadow;
19472
+ precision ${parameters.precision} sampler2DArrayShadow;
19473
+ precision ${parameters.precision} isampler2D;
19474
+ precision ${parameters.precision} isampler3D;
19475
+ precision ${parameters.precision} isamplerCube;
19476
+ precision ${parameters.precision} isampler2DArray;
19477
+ precision ${parameters.precision} usampler2D;
19478
+ precision ${parameters.precision} usampler3D;
19479
+ precision ${parameters.precision} usamplerCube;
19480
+ precision ${parameters.precision} usampler2DArray;
19779
19481
  `;
19780
19482
 
19781
- if ( parameters.isWebGL2 ) {
19782
-
19783
- precisionstring += `precision ${parameters.precision} sampler3D;
19784
- precision ${parameters.precision} sampler2DArray;
19785
- precision ${parameters.precision} sampler2DShadow;
19786
- precision ${parameters.precision} samplerCubeShadow;
19787
- precision ${parameters.precision} sampler2DArrayShadow;
19788
- precision ${parameters.precision} isampler2D;
19789
- precision ${parameters.precision} isampler3D;
19790
- precision ${parameters.precision} isamplerCube;
19791
- precision ${parameters.precision} isampler2DArray;
19792
- precision ${parameters.precision} usampler2D;
19793
- precision ${parameters.precision} usampler3D;
19794
- precision ${parameters.precision} usamplerCube;
19795
- precision ${parameters.precision} usampler2DArray;
19796
- `;
19797
-
19798
- }
19799
-
19800
19483
  if ( parameters.precision === 'highp' ) {
19801
19484
 
19802
19485
  precisionstring += '\n#define HIGH_PRECISION';
@@ -19945,8 +19628,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19945
19628
  const envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );
19946
19629
  const envMapCubeUVSize = generateCubeUVSize( parameters );
19947
19630
 
19948
- const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
19949
-
19950
19631
  const customVertexExtensions = generateVertexExtensions( parameters );
19951
19632
 
19952
19633
  const customDefines = generateDefines( defines );
@@ -19977,8 +19658,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19977
19658
 
19978
19659
  prefixFragment = [
19979
19660
 
19980
- customExtensions,
19981
-
19982
19661
  '#define SHADER_TYPE ' + parameters.shaderType,
19983
19662
  '#define SHADER_NAME ' + parameters.shaderName,
19984
19663
 
@@ -20007,6 +19686,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20007
19686
  parameters.batching ? '#define USE_BATCHING' : '',
20008
19687
  parameters.instancing ? '#define USE_INSTANCING' : '',
20009
19688
  parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
19689
+ parameters.instancingMorph ? '#define USE_INSTANCING_MORPH' : '',
20010
19690
 
20011
19691
  parameters.useFog && parameters.fog ? '#define USE_FOG' : '',
20012
19692
  parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '',
@@ -20099,10 +19779,10 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20099
19779
 
20100
19780
  parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
20101
19781
  parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',
20102
- ( parameters.morphColors && parameters.isWebGL2 ) ? '#define USE_MORPHCOLORS' : '',
20103
- ( parameters.morphTargetsCount > 0 && parameters.isWebGL2 ) ? '#define MORPHTARGETS_TEXTURE' : '',
20104
- ( parameters.morphTargetsCount > 0 && parameters.isWebGL2 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
20105
- ( parameters.morphTargetsCount > 0 && parameters.isWebGL2 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
19782
+ ( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
19783
+ ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
19784
+ ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',
19785
+ ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',
20106
19786
  parameters.doubleSided ? '#define DOUBLE_SIDED' : '',
20107
19787
  parameters.flipSided ? '#define FLIP_SIDED' : '',
20108
19788
 
@@ -20116,7 +19796,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20116
19796
  parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
20117
19797
 
20118
19798
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
20119
- ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
20120
19799
 
20121
19800
  'uniform mat4 modelMatrix;',
20122
19801
  'uniform mat4 modelViewMatrix;',
@@ -20138,6 +19817,12 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20138
19817
 
20139
19818
  '#endif',
20140
19819
 
19820
+ '#ifdef USE_INSTANCING_MORPH',
19821
+
19822
+ ' uniform sampler2D morphTexture;',
19823
+
19824
+ '#endif',
19825
+
20141
19826
  'attribute vec3 position;',
20142
19827
  'attribute vec3 normal;',
20143
19828
  'attribute vec2 uv;',
@@ -20214,8 +19899,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20214
19899
 
20215
19900
  prefixFragment = [
20216
19901
 
20217
- customExtensions,
20218
-
20219
19902
  generatePrecision( parameters ),
20220
19903
 
20221
19904
  '#define SHADER_TYPE ' + parameters.shaderType,
@@ -20303,7 +19986,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20303
19986
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
20304
19987
 
20305
19988
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
20306
- ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
20307
19989
 
20308
19990
  'uniform mat4 viewMatrix;',
20309
19991
  'uniform vec3 cameraPosition;',
@@ -20338,7 +20020,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20338
20020
  vertexShader = unrollLoops( vertexShader );
20339
20021
  fragmentShader = unrollLoops( fragmentShader );
20340
20022
 
20341
- if ( parameters.isWebGL2 && parameters.isRawShaderMaterial !== true ) {
20023
+ if ( parameters.isRawShaderMaterial !== true ) {
20342
20024
 
20343
20025
  // GLSL 3.0 conversion for built-in materials and ShaderMaterial
20344
20026
 
@@ -20346,14 +20028,12 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20346
20028
 
20347
20029
  prefixVertex = [
20348
20030
  customVertexExtensions,
20349
- 'precision mediump sampler2DArray;',
20350
20031
  '#define attribute in',
20351
20032
  '#define varying out',
20352
20033
  '#define texture2D texture'
20353
20034
  ].join( '\n' ) + '\n' + prefixVertex;
20354
20035
 
20355
20036
  prefixFragment = [
20356
- 'precision mediump sampler2DArray;',
20357
20037
  '#define varying in',
20358
20038
  ( parameters.glslVersion === GLSL3 ) ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;',
20359
20039
  ( parameters.glslVersion === GLSL3 ) ? '' : '#define gl_FragColor pc_fragColor',
@@ -20744,7 +20424,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20744
20424
  const _activeChannels = new Set();
20745
20425
  const programs = [];
20746
20426
 
20747
- const IS_WEBGL2 = capabilities.isWebGL2;
20748
20427
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
20749
20428
  const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
20750
20429
 
@@ -20908,8 +20587,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20908
20587
 
20909
20588
  const parameters = {
20910
20589
 
20911
- isWebGL2: IS_WEBGL2,
20912
-
20913
20590
  shaderID: shaderID,
20914
20591
  shaderType: material.type,
20915
20592
  shaderName: material.name,
@@ -20929,6 +20606,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20929
20606
  batching: IS_BATCHEDMESH,
20930
20607
  instancing: IS_INSTANCEDMESH,
20931
20608
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
20609
+ instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
20932
20610
 
20933
20611
  supportsVertexTextures: SUPPORTS_VERTEX_TEXTURES,
20934
20612
  numMultiviewViews: numMultiviewViews,
@@ -21083,16 +20761,9 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21083
20761
 
21084
20762
  index0AttributeName: material.index0AttributeName,
21085
20763
 
21086
- extensionDerivatives: HAS_EXTENSIONS && material.extensions.derivatives === true,
21087
- extensionFragDepth: HAS_EXTENSIONS && material.extensions.fragDepth === true,
21088
- extensionDrawBuffers: HAS_EXTENSIONS && material.extensions.drawBuffers === true,
21089
- extensionShaderTextureLOD: HAS_EXTENSIONS && material.extensions.shaderTextureLOD === true,
21090
20764
  extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance === true && extensions.has( 'WEBGL_clip_cull_distance' ),
21091
20765
  extensionMultiDraw: HAS_EXTENSIONS && material.extensions.multiDraw === true && extensions.has( 'WEBGL_multi_draw' ),
21092
20766
 
21093
- rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
21094
- rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
21095
- rendererExtensionShaderTextureLod: IS_WEBGL2 || extensions.has( 'EXT_shader_texture_lod' ),
21096
20767
  rendererExtensionParallelShaderCompile: extensions.has( 'KHR_parallel_shader_compile' ),
21097
20768
 
21098
20769
  customProgramCacheKey: material.customProgramCacheKey()
@@ -21208,13 +20879,13 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21208
20879
 
21209
20880
  _programLayers.disableAll();
21210
20881
 
21211
- if ( parameters.isWebGL2 )
21212
- _programLayers.enable( 0 );
21213
20882
  if ( parameters.supportsVertexTextures )
21214
- _programLayers.enable( 1 );
20883
+ _programLayers.enable( 0 );
21215
20884
  if ( parameters.instancing )
21216
- _programLayers.enable( 2 );
20885
+ _programLayers.enable( 1 );
21217
20886
  if ( parameters.instancingColor )
20887
+ _programLayers.enable( 2 );
20888
+ if ( parameters.instancingMorph )
21218
20889
  _programLayers.enable( 3 );
21219
20890
  if ( parameters.matcap )
21220
20891
  _programLayers.enable( 4 );
@@ -21822,7 +21493,7 @@ function shadowCastingAndTexturingLightsFirst( lightA, lightB ) {
21822
21493
 
21823
21494
  }
21824
21495
 
21825
- function WebGLLights( extensions, capabilities ) {
21496
+ function WebGLLights( extensions ) {
21826
21497
 
21827
21498
  const cache = new UniformsCache();
21828
21499
 
@@ -22071,41 +21742,15 @@ function WebGLLights( extensions, capabilities ) {
22071
21742
 
22072
21743
  if ( rectAreaLength > 0 ) {
22073
21744
 
22074
- if ( capabilities.isWebGL2 ) {
22075
-
22076
- // WebGL 2
22077
-
22078
- if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
22079
-
22080
- state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
22081
- state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
21745
+ if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
22082
21746
 
22083
- } else {
22084
-
22085
- state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
22086
- state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
22087
-
22088
- }
21747
+ state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
21748
+ state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
22089
21749
 
22090
21750
  } else {
22091
21751
 
22092
- // WebGL 1
22093
-
22094
- if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
22095
-
22096
- state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
22097
- state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
22098
-
22099
- } else if ( extensions.has( 'OES_texture_half_float_linear' ) === true ) {
22100
-
22101
- state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
22102
- state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
22103
-
22104
- } else {
22105
-
22106
- console.error( 'THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.' );
22107
-
22108
- }
21752
+ state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
21753
+ state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
22109
21754
 
22110
21755
  }
22111
21756
 
@@ -22258,9 +21903,9 @@ function WebGLLights( extensions, capabilities ) {
22258
21903
 
22259
21904
  }
22260
21905
 
22261
- function WebGLRenderState( extensions, capabilities ) {
21906
+ function WebGLRenderState( extensions ) {
22262
21907
 
22263
- const lights = new WebGLLights( extensions, capabilities );
21908
+ const lights = new WebGLLights( extensions );
22264
21909
 
22265
21910
  const lightsArray = [];
22266
21911
  const shadowsArray = [];
@@ -22300,7 +21945,9 @@ function WebGLRenderState( extensions, capabilities ) {
22300
21945
  lightsArray: lightsArray,
22301
21946
  shadowsArray: shadowsArray,
22302
21947
 
22303
- lights: lights
21948
+ lights: lights,
21949
+
21950
+ transmissionRenderTarget: null
22304
21951
  };
22305
21952
 
22306
21953
  return {
@@ -22315,7 +21962,7 @@ function WebGLRenderState( extensions, capabilities ) {
22315
21962
 
22316
21963
  }
22317
21964
 
22318
- function WebGLRenderStates( extensions, capabilities ) {
21965
+ function WebGLRenderStates( extensions ) {
22319
21966
 
22320
21967
  let renderStates = new WeakMap();
22321
21968
 
@@ -22326,14 +21973,14 @@ function WebGLRenderStates( extensions, capabilities ) {
22326
21973
 
22327
21974
  if ( renderStateArray === undefined ) {
22328
21975
 
22329
- renderState = new WebGLRenderState( extensions, capabilities );
21976
+ renderState = new WebGLRenderState( extensions );
22330
21977
  renderStates.set( scene, [ renderState ] );
22331
21978
 
22332
21979
  } else {
22333
21980
 
22334
21981
  if ( renderCallDepth >= renderStateArray.length ) {
22335
21982
 
22336
- renderState = new WebGLRenderState( extensions, capabilities );
21983
+ renderState = new WebGLRenderState( extensions );
22337
21984
  renderStateArray.push( renderState );
22338
21985
 
22339
21986
  } else {
@@ -22863,9 +22510,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22863
22510
 
22864
22511
  }
22865
22512
 
22866
- function WebGLState( gl, extensions, capabilities ) {
22867
-
22868
- const isWebGL2 = capabilities.isWebGL2;
22513
+ function WebGLState( gl ) {
22869
22514
 
22870
22515
  function ColorBuffer() {
22871
22516
 
@@ -23237,7 +22882,7 @@ function WebGLState( gl, extensions, capabilities ) {
23237
22882
 
23238
22883
  for ( let i = 0; i < count; i ++ ) {
23239
22884
 
23240
- if ( isWebGL2 && ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) ) {
22885
+ if ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) {
23241
22886
 
23242
22887
  gl.texImage3D( target, 0, gl.RGBA, 1, 1, dimensions, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
23243
22888
 
@@ -23256,13 +22901,8 @@ function WebGLState( gl, extensions, capabilities ) {
23256
22901
  const emptyTextures = {};
23257
22902
  emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
23258
22903
  emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
23259
-
23260
- if ( isWebGL2 ) {
23261
-
23262
- emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
23263
- emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
23264
-
23265
- }
22904
+ emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
22905
+ emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
23266
22906
 
23267
22907
  // init
23268
22908
 
@@ -23311,21 +22951,17 @@ function WebGLState( gl, extensions, capabilities ) {
23311
22951
 
23312
22952
  currentBoundFramebuffers[ target ] = framebuffer;
23313
22953
 
23314
- if ( isWebGL2 ) {
23315
-
23316
- // gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
22954
+ // gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER
23317
22955
 
23318
- if ( target === gl.DRAW_FRAMEBUFFER ) {
22956
+ if ( target === gl.DRAW_FRAMEBUFFER ) {
23319
22957
 
23320
- currentBoundFramebuffers[ gl.FRAMEBUFFER ] = framebuffer;
22958
+ currentBoundFramebuffers[ gl.FRAMEBUFFER ] = framebuffer;
23321
22959
 
23322
- }
23323
-
23324
- if ( target === gl.FRAMEBUFFER ) {
22960
+ }
23325
22961
 
23326
- currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] = framebuffer;
22962
+ if ( target === gl.FRAMEBUFFER ) {
23327
22963
 
23328
- }
22964
+ currentBoundFramebuffers[ gl.DRAW_FRAMEBUFFER ] = framebuffer;
23329
22965
 
23330
22966
  }
23331
22967
 
@@ -23354,33 +22990,19 @@ function WebGLState( gl, extensions, capabilities ) {
23354
22990
 
23355
22991
  }
23356
22992
 
23357
- if ( renderTarget.isWebGLMultipleRenderTargets ) {
23358
-
23359
- const textures = renderTarget.texture;
23360
-
23361
- if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
23362
-
23363
- for ( let i = 0, il = textures.length; i < il; i ++ ) {
23364
-
23365
- drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
22993
+ const textures = renderTarget.textures;
23366
22994
 
23367
- }
22995
+ if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
23368
22996
 
23369
- drawBuffers.length = textures.length;
22997
+ for ( let i = 0, il = textures.length; i < il; i ++ ) {
23370
22998
 
23371
- needsUpdate = true;
22999
+ drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
23372
23000
 
23373
23001
  }
23374
23002
 
23375
- } else {
23376
-
23377
- if ( drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
23378
-
23379
- drawBuffers[ 0 ] = gl.COLOR_ATTACHMENT0;
23380
-
23381
- needsUpdate = true;
23003
+ drawBuffers.length = textures.length;
23382
23004
 
23383
- }
23005
+ needsUpdate = true;
23384
23006
 
23385
23007
  }
23386
23008
 
@@ -23398,19 +23020,10 @@ function WebGLState( gl, extensions, capabilities ) {
23398
23020
 
23399
23021
  if ( needsUpdate ) {
23400
23022
 
23401
- if ( capabilities.isWebGL2 ) {
23402
-
23403
- gl.drawBuffers( drawBuffers );
23404
-
23405
- } else {
23406
-
23407
- extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
23408
-
23409
- }
23023
+ gl.drawBuffers( drawBuffers );
23410
23024
 
23411
23025
  }
23412
23026
 
23413
-
23414
23027
  }
23415
23028
 
23416
23029
  function useProgram( program ) {
@@ -23435,23 +23048,8 @@ function WebGLState( gl, extensions, capabilities ) {
23435
23048
  [ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT
23436
23049
  };
23437
23050
 
23438
- if ( isWebGL2 ) {
23439
-
23440
- equationToGL[ MinEquation ] = gl.MIN;
23441
- equationToGL[ MaxEquation ] = gl.MAX;
23442
-
23443
- } else {
23444
-
23445
- const extension = extensions.get( 'EXT_blend_minmax' );
23446
-
23447
- if ( extension !== null ) {
23448
-
23449
- equationToGL[ MinEquation ] = extension.MIN_EXT;
23450
- equationToGL[ MaxEquation ] = extension.MAX_EXT;
23451
-
23452
- }
23453
-
23454
- }
23051
+ equationToGL[ MinEquation ] = gl.MIN;
23052
+ equationToGL[ MaxEquation ] = gl.MAX;
23455
23053
 
23456
23054
  const factorToGL = {
23457
23055
  [ ZeroFactor ]: gl.ZERO,
@@ -24075,13 +23673,8 @@ function WebGLState( gl, extensions, capabilities ) {
24075
23673
  gl.activeTexture( gl.TEXTURE0 );
24076
23674
 
24077
23675
  gl.bindFramebuffer( gl.FRAMEBUFFER, null );
24078
-
24079
- if ( isWebGL2 === true ) {
24080
-
24081
- gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
24082
- gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
24083
-
24084
- }
23676
+ gl.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
23677
+ gl.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
24085
23678
 
24086
23679
  gl.useProgram( null );
24087
23680
 
@@ -24188,11 +23781,11 @@ function WebGLState( gl, extensions, capabilities ) {
24188
23781
 
24189
23782
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
24190
23783
 
24191
- const isWebGL2 = capabilities.isWebGL2;
24192
23784
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
24193
23785
  const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
24194
23786
  const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
24195
23787
 
23788
+ const _imageDimensions = new Vector2();
24196
23789
  const _videoTextures = new WeakMap();
24197
23790
  let _canvas;
24198
23791
 
@@ -24229,32 +23822,33 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24229
23822
 
24230
23823
  }
24231
23824
 
24232
- function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {
23825
+ function resizeImage( image, needsNewCanvas, maxSize ) {
24233
23826
 
24234
23827
  let scale = 1;
24235
23828
 
23829
+ const dimensions = getDimensions( image );
23830
+
24236
23831
  // handle case if texture exceeds max size
24237
23832
 
24238
- if ( image.width > maxSize || image.height > maxSize ) {
23833
+ if ( dimensions.width > maxSize || dimensions.height > maxSize ) {
24239
23834
 
24240
- scale = maxSize / Math.max( image.width, image.height );
23835
+ scale = maxSize / Math.max( dimensions.width, dimensions.height );
24241
23836
 
24242
23837
  }
24243
23838
 
24244
23839
  // only perform resize if necessary
24245
23840
 
24246
- if ( scale < 1 || needsPowerOfTwo === true ) {
23841
+ if ( scale < 1 ) {
24247
23842
 
24248
23843
  // only perform resize for certain image types
24249
23844
 
24250
23845
  if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
24251
23846
  ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
24252
- ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
24253
-
24254
- const floor = needsPowerOfTwo ? floorPowerOfTwo : Math.floor;
23847
+ ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
23848
+ ( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
24255
23849
 
24256
- const width = floor( scale * image.width );
24257
- const height = floor( scale * image.height );
23850
+ const width = Math.floor( scale * dimensions.width );
23851
+ const height = Math.floor( scale * dimensions.height );
24258
23852
 
24259
23853
  if ( _canvas === undefined ) _canvas = createCanvas( width, height );
24260
23854
 
@@ -24268,7 +23862,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24268
23862
  const context = canvas.getContext( '2d' );
24269
23863
  context.drawImage( image, 0, 0, width, height );
24270
23864
 
24271
- console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );
23865
+ console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + dimensions.width + 'x' + dimensions.height + ') to (' + width + 'x' + height + ').' );
24272
23866
 
24273
23867
  return canvas;
24274
23868
 
@@ -24276,7 +23870,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24276
23870
 
24277
23871
  if ( 'data' in image ) {
24278
23872
 
24279
- console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' );
23873
+ console.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + dimensions.width + 'x' + dimensions.height + ').' );
24280
23874
 
24281
23875
  }
24282
23876
 
@@ -24290,25 +23884,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24290
23884
 
24291
23885
  }
24292
23886
 
24293
- function isPowerOfTwo$1( image ) {
23887
+ function textureNeedsGenerateMipmaps( texture ) {
24294
23888
 
24295
- return isPowerOfTwo( image.width ) && isPowerOfTwo( image.height );
24296
-
24297
- }
24298
-
24299
- function textureNeedsPowerOfTwo( texture ) {
24300
-
24301
- if ( isWebGL2 ) return false;
24302
-
24303
- return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||
24304
- ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
24305
-
24306
- }
24307
-
24308
- function textureNeedsGenerateMipmaps( texture, supportsMips ) {
24309
-
24310
- return texture.generateMipmaps && supportsMips &&
24311
- texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
23889
+ return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
24312
23890
 
24313
23891
  }
24314
23892
 
@@ -24320,8 +23898,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24320
23898
 
24321
23899
  function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
24322
23900
 
24323
- if ( isWebGL2 === false ) return glFormat;
24324
-
24325
23901
  if ( internalFormatName !== null ) {
24326
23902
 
24327
23903
  if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
@@ -24359,6 +23935,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24359
23935
 
24360
23936
  }
24361
23937
 
23938
+ if ( glFormat === _gl.RG_INTEGER ) {
23939
+
23940
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8UI;
23941
+ if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RG16UI;
23942
+ if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RG32UI;
23943
+ if ( glType === _gl.BYTE ) internalFormat = _gl.RG8I;
23944
+ if ( glType === _gl.SHORT ) internalFormat = _gl.RG16I;
23945
+ if ( glType === _gl.INT ) internalFormat = _gl.RG32I;
23946
+
23947
+ }
23948
+
23949
+ if ( glFormat === _gl.RGB ) {
23950
+
23951
+ if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
23952
+
23953
+ }
23954
+
24362
23955
  if ( glFormat === _gl.RGBA ) {
24363
23956
 
24364
23957
  const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
@@ -24383,9 +23976,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24383
23976
 
24384
23977
  }
24385
23978
 
24386
- function getMipLevels( texture, image, supportsMips ) {
23979
+ function getMipLevels( texture, image ) {
24387
23980
 
24388
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
23981
+ if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
24389
23982
 
24390
23983
  return Math.log2( Math.max( image.width, image.height ) ) + 1;
24391
23984
 
@@ -24409,20 +24002,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24409
24002
 
24410
24003
  }
24411
24004
 
24412
- // Fallback filters for non-power-of-2 textures
24413
-
24414
- function filterFallback( f ) {
24415
-
24416
- if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
24417
-
24418
- return _gl.NEAREST;
24419
-
24420
- }
24421
-
24422
- return _gl.LINEAR;
24423
-
24424
- }
24425
-
24426
24005
  //
24427
24006
 
24428
24007
  function onTextureDispose( event ) {
@@ -24506,18 +24085,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24506
24085
 
24507
24086
  function deallocateRenderTarget( renderTarget ) {
24508
24087
 
24509
- const texture = renderTarget.texture;
24510
-
24511
24088
  const renderTargetProperties = properties.get( renderTarget );
24512
- const textureProperties = properties.get( texture );
24513
-
24514
- if ( textureProperties.__webglTexture !== undefined ) {
24515
-
24516
- _gl.deleteTexture( textureProperties.__webglTexture );
24517
-
24518
- info.memory.textures --;
24519
-
24520
- }
24521
24089
 
24522
24090
  if ( renderTarget.depthTexture ) {
24523
24091
 
@@ -24572,27 +24140,24 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24572
24140
 
24573
24141
  }
24574
24142
 
24575
- if ( renderTarget.isWebGLMultipleRenderTargets ) {
24576
-
24577
- for ( let i = 0, il = texture.length; i < il; i ++ ) {
24578
-
24579
- const attachmentProperties = properties.get( texture[ i ] );
24143
+ const textures = renderTarget.textures;
24580
24144
 
24581
- if ( attachmentProperties.__webglTexture ) {
24145
+ for ( let i = 0, il = textures.length; i < il; i ++ ) {
24582
24146
 
24583
- _gl.deleteTexture( attachmentProperties.__webglTexture );
24147
+ const attachmentProperties = properties.get( textures[ i ] );
24584
24148
 
24585
- info.memory.textures --;
24149
+ if ( attachmentProperties.__webglTexture ) {
24586
24150
 
24587
- }
24151
+ _gl.deleteTexture( attachmentProperties.__webglTexture );
24588
24152
 
24589
- properties.remove( texture[ i ] );
24153
+ info.memory.textures --;
24590
24154
 
24591
24155
  }
24592
24156
 
24157
+ properties.remove( textures[ i ] );
24158
+
24593
24159
  }
24594
24160
 
24595
- properties.remove( texture );
24596
24161
  properties.remove( renderTarget );
24597
24162
 
24598
24163
  }
@@ -24754,7 +24319,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24754
24319
  [ NotEqualCompare ]: _gl.NOTEQUAL
24755
24320
  };
24756
24321
 
24757
- function setTextureParameters( textureType, texture, supportsMips ) {
24322
+ function setTextureParameters( textureType, texture ) {
24758
24323
 
24759
24324
  if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
24760
24325
  ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
@@ -24764,48 +24329,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24764
24329
 
24765
24330
  }
24766
24331
 
24767
- if ( supportsMips ) {
24768
-
24769
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
24770
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
24771
-
24772
- if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
24773
-
24774
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
24775
-
24776
- }
24777
-
24778
- _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
24779
- _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
24780
-
24781
- } else {
24782
-
24783
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
24784
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
24785
-
24786
- if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
24787
-
24788
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );
24789
-
24790
- }
24791
-
24792
- if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {
24793
-
24794
- console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
24795
-
24796
- }
24797
-
24798
- _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
24799
- _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
24332
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
24333
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
24800
24334
 
24801
- if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {
24335
+ if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
24802
24336
 
24803
- console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );
24804
-
24805
- }
24337
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
24806
24338
 
24807
24339
  }
24808
24340
 
24341
+ _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
24342
+ _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
24343
+
24809
24344
  if ( texture.compareFunction ) {
24810
24345
 
24811
24346
  _gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
@@ -24815,15 +24350,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24815
24350
 
24816
24351
  if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
24817
24352
 
24818
- const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
24819
-
24820
24353
  if ( texture.magFilter === NearestFilter ) return;
24821
24354
  if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
24822
- if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
24823
- if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
24355
+ if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
24824
24356
 
24825
24357
  if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
24826
24358
 
24359
+ const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
24827
24360
  _gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
24828
24361
  properties.get( texture ).__currentAnisotropy = texture.anisotropy;
24829
24362
 
@@ -24977,97 +24510,41 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24977
24510
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
24978
24511
  _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24979
24512
 
24980
- const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false;
24981
- let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
24513
+ let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
24982
24514
  image = verifyColorSpace( texture, image );
24983
24515
 
24984
- const supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
24985
- glFormat = utils.convert( texture.format, texture.colorSpace );
24516
+ const glFormat = utils.convert( texture.format, texture.colorSpace );
24986
24517
 
24987
- let glType = utils.convert( texture.type ),
24988
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
24518
+ const glType = utils.convert( texture.type );
24519
+ let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
24989
24520
 
24990
- setTextureParameters( textureType, texture, supportsMips );
24521
+ setTextureParameters( textureType, texture );
24991
24522
 
24992
24523
  let mipmap;
24993
24524
  const mipmaps = texture.mipmaps;
24994
24525
 
24995
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
24526
+ const useTexStorage = ( texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
24996
24527
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
24997
24528
  const dataReady = source.dataReady;
24998
- const levels = getMipLevels( texture, image, supportsMips );
24529
+ const levels = getMipLevels( texture, image );
24999
24530
 
25000
24531
  if ( texture.isDepthTexture ) {
25001
24532
 
25002
24533
  // populate depth texture with dummy data
25003
24534
 
25004
- glInternalFormat = _gl.DEPTH_COMPONENT;
25005
-
25006
- if ( isWebGL2 ) {
25007
-
25008
- if ( texture.type === FloatType ) {
25009
-
25010
- glInternalFormat = _gl.DEPTH_COMPONENT32F;
25011
-
25012
- } else if ( texture.type === UnsignedIntType ) {
25013
-
25014
- glInternalFormat = _gl.DEPTH_COMPONENT24;
24535
+ glInternalFormat = _gl.DEPTH_COMPONENT16;
25015
24536
 
25016
- } else if ( texture.type === UnsignedInt248Type ) {
24537
+ if ( texture.type === FloatType ) {
25017
24538
 
25018
- glInternalFormat = _gl.DEPTH24_STENCIL8;
25019
-
25020
- } else {
25021
-
25022
- glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
25023
-
25024
- }
25025
-
25026
- } else {
25027
-
25028
- if ( texture.type === FloatType ) {
25029
-
25030
- console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
25031
-
25032
- }
25033
-
25034
- }
25035
-
25036
- // validation checks for WebGL 1
25037
-
25038
- if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
25039
-
25040
- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
25041
- // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
25042
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
25043
- if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
25044
-
25045
- console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
25046
-
25047
- texture.type = UnsignedIntType;
25048
- glType = utils.convert( texture.type );
25049
-
25050
- }
25051
-
25052
- }
25053
-
25054
- if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
25055
-
25056
- // Depth stencil textures need the DEPTH_STENCIL internal format
25057
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
25058
- glInternalFormat = _gl.DEPTH_STENCIL;
24539
+ glInternalFormat = _gl.DEPTH_COMPONENT32F;
25059
24540
 
25060
- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
25061
- // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
25062
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
25063
- if ( texture.type !== UnsignedInt248Type ) {
24541
+ } else if ( texture.type === UnsignedIntType ) {
25064
24542
 
25065
- console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
24543
+ glInternalFormat = _gl.DEPTH_COMPONENT24;
25066
24544
 
25067
- texture.type = UnsignedInt248Type;
25068
- glType = utils.convert( texture.type );
24545
+ } else if ( texture.type === UnsignedInt248Type ) {
25069
24546
 
25070
- }
24547
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
25071
24548
 
25072
24549
  }
25073
24550
 
@@ -25093,7 +24570,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25093
24570
  // if there are no manual mipmaps
25094
24571
  // set 0 level mipmap and then use GL to generate other mipmap levels
25095
24572
 
25096
- if ( mipmaps.length > 0 && supportsMips ) {
24573
+ if ( mipmaps.length > 0 ) {
25097
24574
 
25098
24575
  if ( useTexStorage && allocateMemory ) {
25099
24576
 
@@ -25340,11 +24817,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25340
24817
  // if there are no manual mipmaps
25341
24818
  // set 0 level mipmap and then use GL to generate other mipmap levels
25342
24819
 
25343
- if ( mipmaps.length > 0 && supportsMips ) {
24820
+ if ( mipmaps.length > 0 ) {
25344
24821
 
25345
24822
  if ( useTexStorage && allocateMemory ) {
25346
24823
 
25347
- state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
24824
+ const dimensions = getDimensions( mipmaps[ 0 ] );
24825
+
24826
+ state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, dimensions.width, dimensions.height );
25348
24827
 
25349
24828
  }
25350
24829
 
@@ -25376,7 +24855,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25376
24855
 
25377
24856
  if ( allocateMemory ) {
25378
24857
 
25379
- state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
24858
+ const dimensions = getDimensions( image );
24859
+
24860
+ state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, dimensions.width, dimensions.height );
25380
24861
 
25381
24862
  }
25382
24863
 
@@ -25396,7 +24877,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25396
24877
 
25397
24878
  }
25398
24879
 
25399
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
24880
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
25400
24881
 
25401
24882
  generateMipmap( textureType );
25402
24883
 
@@ -25446,7 +24927,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25446
24927
 
25447
24928
  if ( ! isCompressed && ! isDataTexture ) {
25448
24929
 
25449
- cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
24930
+ cubeImage[ i ] = resizeImage( texture.image[ i ], true, capabilities.maxCubemapSize );
25450
24931
 
25451
24932
  } else {
25452
24933
 
@@ -25459,17 +24940,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25459
24940
  }
25460
24941
 
25461
24942
  const image = cubeImage[ 0 ],
25462
- supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
25463
24943
  glFormat = utils.convert( texture.format, texture.colorSpace ),
25464
24944
  glType = utils.convert( texture.type ),
25465
24945
  glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
25466
24946
 
25467
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
24947
+ const useTexStorage = ( texture.isVideoTexture !== true );
25468
24948
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
25469
24949
  const dataReady = source.dataReady;
25470
- let levels = getMipLevels( texture, image, supportsMips );
24950
+ let levels = getMipLevels( texture, image );
25471
24951
 
25472
- setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
24952
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
25473
24953
 
25474
24954
  let mipmaps;
25475
24955
 
@@ -25547,7 +25027,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25547
25027
 
25548
25028
  if ( mipmaps.length > 0 ) levels ++;
25549
25029
 
25550
- state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[ 0 ].width, cubeImage[ 0 ].height );
25030
+ const dimensions = getDimensions( cubeImage[ 0 ] );
25031
+
25032
+ state.texStorage2D( _gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, dimensions.width, dimensions.height );
25551
25033
 
25552
25034
  }
25553
25035
 
@@ -25632,7 +25114,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25632
25114
 
25633
25115
  }
25634
25116
 
25635
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25117
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
25636
25118
 
25637
25119
  // We assume images for cube map have the same size.
25638
25120
  generateMipmap( _gl.TEXTURE_CUBE_MAP );
@@ -25774,7 +25256,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25774
25256
 
25775
25257
  } else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
25776
25258
 
25777
- let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
25259
+ let glInternalFormat = _gl.DEPTH_COMPONENT24;
25778
25260
 
25779
25261
  if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
25780
25262
 
@@ -25837,7 +25319,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25837
25319
 
25838
25320
  } else {
25839
25321
 
25840
- const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
25322
+ const textures = renderTarget.textures;
25841
25323
 
25842
25324
  for ( let i = 0; i < textures.length; i ++ ) {
25843
25325
 
@@ -26049,7 +25531,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26049
25531
 
26050
25532
  renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
26051
25533
 
26052
- if ( renderTarget.isWebGLMultipleRenderTargets !== true ) {
25534
+ const textures = renderTarget.textures;
25535
+
25536
+ const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
25537
+ const isMultipleRenderTargets = ( textures.length > 1 );
25538
+
25539
+ if ( ! isMultipleRenderTargets ) {
26053
25540
 
26054
25541
  if ( textureProperties.__webglTexture === undefined ) {
26055
25542
 
@@ -26062,10 +25549,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26062
25549
 
26063
25550
  }
26064
25551
 
26065
- const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
26066
- const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
26067
- const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
26068
-
26069
25552
  // Setup framebuffer
26070
25553
 
26071
25554
  if ( isCube ) {
@@ -26074,7 +25557,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26074
25557
 
26075
25558
  for ( let i = 0; i < 6; i ++ ) {
26076
25559
 
26077
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25560
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26078
25561
 
26079
25562
  renderTargetProperties.__webglFramebuffer[ i ] = [];
26080
25563
 
@@ -26094,7 +25577,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26094
25577
 
26095
25578
  } else {
26096
25579
 
26097
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25580
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26098
25581
 
26099
25582
  renderTargetProperties.__webglFramebuffer = [];
26100
25583
 
@@ -26112,35 +25595,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26112
25595
 
26113
25596
  if ( isMultipleRenderTargets ) {
26114
25597
 
26115
- if ( capabilities.drawBuffers ) {
25598
+ for ( let i = 0, il = textures.length; i < il; i ++ ) {
26116
25599
 
26117
- const textures = renderTarget.texture;
25600
+ const attachmentProperties = properties.get( textures[ i ] );
26118
25601
 
26119
- for ( let i = 0, il = textures.length; i < il; i ++ ) {
25602
+ if ( attachmentProperties.__webglTexture === undefined ) {
26120
25603
 
26121
- const attachmentProperties = properties.get( textures[ i ] );
25604
+ attachmentProperties.__webglTexture = _gl.createTexture();
26122
25605
 
26123
- if ( attachmentProperties.__webglTexture === undefined ) {
26124
-
26125
- attachmentProperties.__webglTexture = _gl.createTexture();
26126
-
26127
- info.memory.textures ++;
26128
-
26129
- }
25606
+ info.memory.textures ++;
26130
25607
 
26131
25608
  }
26132
25609
 
26133
- } else {
26134
-
26135
- console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
26136
-
26137
25610
  }
26138
25611
 
26139
25612
  }
26140
25613
 
26141
- if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
26142
-
26143
- const textures = isMultipleRenderTargets ? texture : [ texture ];
25614
+ if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
26144
25615
 
26145
25616
  renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
26146
25617
  renderTargetProperties.__webglColorRenderbuffer = [];
@@ -26184,11 +25655,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26184
25655
  if ( isCube ) {
26185
25656
 
26186
25657
  state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
26187
- setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
25658
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
26188
25659
 
26189
25660
  for ( let i = 0; i < 6; i ++ ) {
26190
25661
 
26191
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25662
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26192
25663
 
26193
25664
  for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
26194
25665
 
@@ -26204,7 +25675,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26204
25675
 
26205
25676
  }
26206
25677
 
26207
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25678
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
26208
25679
 
26209
25680
  generateMipmap( _gl.TEXTURE_CUBE_MAP );
26210
25681
 
@@ -26214,18 +25685,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26214
25685
 
26215
25686
  } else if ( isMultipleRenderTargets ) {
26216
25687
 
26217
- const textures = renderTarget.texture;
26218
-
26219
25688
  for ( let i = 0, il = textures.length; i < il; i ++ ) {
26220
25689
 
26221
25690
  const attachment = textures[ i ];
26222
25691
  const attachmentProperties = properties.get( attachment );
26223
25692
 
26224
25693
  state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
26225
- setTextureParameters( _gl.TEXTURE_2D, attachment, supportsMips );
25694
+ setTextureParameters( _gl.TEXTURE_2D, attachment );
26226
25695
  setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
26227
25696
 
26228
- if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) {
25697
+ if ( textureNeedsGenerateMipmaps( attachment ) ) {
26229
25698
 
26230
25699
  generateMipmap( _gl.TEXTURE_2D );
26231
25700
 
@@ -26241,15 +25710,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26241
25710
 
26242
25711
  if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
26243
25712
 
26244
- if ( isWebGL2 ) {
26245
-
26246
- glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
26247
-
26248
- } else {
26249
-
26250
- console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
26251
-
26252
- }
25713
+ glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
26253
25714
 
26254
25715
  }
26255
25716
 
@@ -26260,9 +25721,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26260
25721
  }
26261
25722
 
26262
25723
  state.bindTexture( glTextureType, textureProperties.__webglTexture );
26263
- setTextureParameters( glTextureType, texture, supportsMips );
25724
+ setTextureParameters( glTextureType, texture );
26264
25725
 
26265
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25726
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
26266
25727
 
26267
25728
  for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
26268
25729
 
@@ -26276,7 +25737,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26276
25737
 
26277
25738
  }
26278
25739
 
26279
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25740
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
26280
25741
 
26281
25742
  generateMipmap( glTextureType );
26282
25743
 
@@ -26298,15 +25759,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26298
25759
 
26299
25760
  function updateRenderTargetMipmap( renderTarget ) {
26300
25761
 
26301
- const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
26302
-
26303
- const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
25762
+ const textures = renderTarget.textures;
26304
25763
 
26305
25764
  for ( let i = 0, il = textures.length; i < il; i ++ ) {
26306
25765
 
26307
25766
  const texture = textures[ i ];
26308
25767
 
26309
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25768
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
26310
25769
 
26311
25770
  const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
26312
25771
  const webglTexture = properties.get( texture ).__webglTexture;
@@ -26323,16 +25782,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26323
25782
 
26324
25783
  function updateMultisampleRenderTarget( renderTarget ) {
26325
25784
 
26326
- if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
25785
+ if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
26327
25786
 
26328
- const textures = renderTarget.isWebGLMultipleRenderTargets ? renderTarget.texture : [ renderTarget.texture ];
25787
+ const textures = renderTarget.textures;
26329
25788
  const width = renderTarget.width;
26330
25789
  const height = renderTarget.height;
26331
25790
  let mask = _gl.COLOR_BUFFER_BIT;
26332
25791
  const invalidationArray = [];
26333
25792
  const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
26334
25793
  const renderTargetProperties = properties.get( renderTarget );
26335
- const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
25794
+ const isMultipleRenderTargets = ( textures.length > 1 );
26336
25795
 
26337
25796
  // If MRT we need to remove FBO attachments
26338
25797
  if ( isMultipleRenderTargets ) {
@@ -26367,7 +25826,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26367
25826
  if ( ignoreDepthValues === false ) {
26368
25827
 
26369
25828
  if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
26370
- if ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
25829
+
25830
+ // resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
25831
+
25832
+ if ( renderTarget.stencilBuffer && renderTargetProperties.__isTransmissionRenderTarget !== true ) mask |= _gl.STENCIL_BUFFER_BIT;
26371
25833
 
26372
25834
  }
26373
25835
 
@@ -26438,7 +25900,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26438
25900
 
26439
25901
  const renderTargetProperties = properties.get( renderTarget );
26440
25902
 
26441
- return isWebGL2 && renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
25903
+ return renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
26442
25904
 
26443
25905
  }
26444
25906
 
@@ -26463,7 +25925,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26463
25925
  const format = texture.format;
26464
25926
  const type = texture.type;
26465
25927
 
26466
- if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
25928
+ if ( texture.isCompressedTexture === true || texture.isVideoTexture === true ) return image;
26467
25929
 
26468
25930
  if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
26469
25931
 
@@ -26471,48 +25933,48 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26471
25933
 
26472
25934
  if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
26473
25935
 
26474
- if ( isWebGL2 === false ) {
25936
+ // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
26475
25937
 
26476
- // in WebGL 1, try to use EXT_sRGB extension and unsized formats
25938
+ if ( format !== RGBAFormat || type !== UnsignedByteType ) {
26477
25939
 
26478
- if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) {
25940
+ console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
26479
25941
 
26480
- texture.format = _SRGBAFormat;
26481
-
26482
- // it's not possible to generate mips in WebGL 1 with this extension
25942
+ }
26483
25943
 
26484
- texture.minFilter = LinearFilter;
26485
- texture.generateMipmaps = false;
25944
+ } else {
26486
25945
 
26487
- } else {
25946
+ console.error( 'THREE.WebGLTextures: Unsupported texture color space:', colorSpace );
26488
25947
 
26489
- // slow fallback (CPU decode)
25948
+ }
26490
25949
 
26491
- image = ImageUtils.sRGBToLinear( image );
25950
+ }
26492
25951
 
26493
- }
25952
+ return image;
26494
25953
 
26495
- } else {
25954
+ }
26496
25955
 
26497
- // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
25956
+ function getDimensions( image ) {
26498
25957
 
26499
- if ( format !== RGBAFormat || type !== UnsignedByteType ) {
25958
+ if ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) {
26500
25959
 
26501
- console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
25960
+ // if intrinsic data are not available, fallback to width/height
26502
25961
 
26503
- }
25962
+ _imageDimensions.width = image.naturalWidth || image.width;
25963
+ _imageDimensions.height = image.naturalHeight || image.height;
26504
25964
 
26505
- }
25965
+ } else if ( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) {
26506
25966
 
26507
- } else {
25967
+ _imageDimensions.width = image.displayWidth;
25968
+ _imageDimensions.height = image.displayHeight;
26508
25969
 
26509
- console.error( 'THREE.WebGLTextures: Unsupported texture color space:', colorSpace );
25970
+ } else {
26510
25971
 
26511
- }
25972
+ _imageDimensions.width = image.width;
25973
+ _imageDimensions.height = image.height;
26512
25974
 
26513
25975
  }
26514
25976
 
26515
- return image;
25977
+ return _imageDimensions;
26516
25978
 
26517
25979
  }
26518
25980
 
@@ -26539,9 +26001,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26539
26001
 
26540
26002
  }
26541
26003
 
26542
- function WebGLUtils( gl, extensions, capabilities ) {
26543
-
26544
- const isWebGL2 = capabilities.isWebGL2;
26004
+ function WebGLUtils( gl, extensions ) {
26545
26005
 
26546
26006
  function convert( p, colorSpace = NoColorSpace ) {
26547
26007
 
@@ -26552,6 +26012,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
26552
26012
  if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
26553
26013
  if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
26554
26014
  if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
26015
+ if ( p === UnsignedInt5999Type ) return gl.UNSIGNED_INT_5_9_9_9_REV;
26555
26016
 
26556
26017
  if ( p === ByteType ) return gl.BYTE;
26557
26018
  if ( p === ShortType ) return gl.SHORT;
@@ -26559,50 +26020,16 @@ function WebGLUtils( gl, extensions, capabilities ) {
26559
26020
  if ( p === IntType ) return gl.INT;
26560
26021
  if ( p === UnsignedIntType ) return gl.UNSIGNED_INT;
26561
26022
  if ( p === FloatType ) return gl.FLOAT;
26562
-
26563
- if ( p === HalfFloatType ) {
26564
-
26565
- if ( isWebGL2 ) return gl.HALF_FLOAT;
26566
-
26567
- extension = extensions.get( 'OES_texture_half_float' );
26568
-
26569
- if ( extension !== null ) {
26570
-
26571
- return extension.HALF_FLOAT_OES;
26572
-
26573
- } else {
26574
-
26575
- return null;
26576
-
26577
- }
26578
-
26579
- }
26023
+ if ( p === HalfFloatType ) return gl.HALF_FLOAT;
26580
26024
 
26581
26025
  if ( p === AlphaFormat ) return gl.ALPHA;
26026
+ if ( p === RGBFormat ) return gl.RGB;
26582
26027
  if ( p === RGBAFormat ) return gl.RGBA;
26583
26028
  if ( p === LuminanceFormat ) return gl.LUMINANCE;
26584
26029
  if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
26585
26030
  if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
26586
26031
  if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
26587
26032
 
26588
- // WebGL 1 sRGB fallback
26589
-
26590
- if ( p === _SRGBAFormat ) {
26591
-
26592
- extension = extensions.get( 'EXT_sRGB' );
26593
-
26594
- if ( extension !== null ) {
26595
-
26596
- return extension.SRGB_ALPHA_EXT;
26597
-
26598
- } else {
26599
-
26600
- return null;
26601
-
26602
- }
26603
-
26604
- }
26605
-
26606
26033
  // WebGL2 formats.
26607
26034
 
26608
26035
  if ( p === RedFormat ) return gl.RED;
@@ -26789,23 +26216,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
26789
26216
 
26790
26217
  //
26791
26218
 
26792
- if ( p === UnsignedInt248Type ) {
26793
-
26794
- if ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;
26795
-
26796
- extension = extensions.get( 'WEBGL_depth_texture' );
26797
-
26798
- if ( extension !== null ) {
26799
-
26800
- return extension.UNSIGNED_INT_24_8_WEBGL;
26801
-
26802
- } else {
26803
-
26804
- return null;
26805
-
26806
- }
26807
-
26808
- }
26219
+ if ( p === UnsignedInt248Type ) return gl.UNSIGNED_INT_24_8;
26809
26220
 
26810
26221
  // if "p" can't be resolved, assume the user defines a WebGL constant as a string (fallback/workaround for packed RGB formats)
26811
26222
 
@@ -27781,11 +27192,11 @@ void main() {
27781
27192
 
27782
27193
  if ( coord.x >= 1.0 ) {
27783
27194
 
27784
- gl_FragDepthEXT = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
27195
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
27785
27196
 
27786
27197
  } else {
27787
27198
 
27788
- gl_FragDepthEXT = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
27199
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
27789
27200
 
27790
27201
  }
27791
27202
 
@@ -27833,7 +27244,6 @@ class WebXRDepthSensing {
27833
27244
 
27834
27245
  const viewport = cameraXR.cameras[ 0 ].viewport;
27835
27246
  const material = new ShaderMaterial( {
27836
- extensions: { fragDepth: true },
27837
27247
  vertexShader: _occlusion_vertex,
27838
27248
  fragmentShader: _occlusion_fragment,
27839
27249
  uniforms: {
@@ -28139,10 +27549,10 @@ class WebXRManager extends EventDispatcher {
28139
27549
  currentPixelRatio = renderer.getPixelRatio();
28140
27550
  renderer.getSize( currentSize );
28141
27551
 
28142
- if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) {
27552
+ if ( session.renderState.layers === undefined ) {
28143
27553
 
28144
27554
  const layerInit = {
28145
- antialias: ( session.renderState.layers === undefined ) ? attributes.antialias : true,
27555
+ antialias: attributes.antialias,
28146
27556
  alpha: true,
28147
27557
  depth: attributes.depth,
28148
27558
  stencil: attributes.stencil,
@@ -28731,6 +28141,9 @@ class WebXRManager extends EventDispatcher {
28731
28141
 
28732
28142
  }
28733
28143
 
28144
+ const _e1 = /*@__PURE__*/ new Euler();
28145
+ const _m1 = /*@__PURE__*/ new Matrix4();
28146
+
28734
28147
  function WebGLMaterials( renderer, properties ) {
28735
28148
 
28736
28149
  function refreshTransformUniform( map, uniform ) {
@@ -28939,12 +28352,30 @@ function WebGLMaterials( renderer, properties ) {
28939
28352
 
28940
28353
  }
28941
28354
 
28942
- const envMap = properties.get( material ).envMap;
28355
+ const materialProperties = properties.get( material );
28356
+
28357
+ const envMap = materialProperties.envMap;
28358
+ const envMapRotation = materialProperties.envMapRotation;
28943
28359
 
28944
28360
  if ( envMap ) {
28945
28361
 
28946
28362
  uniforms.envMap.value = envMap;
28947
28363
 
28364
+ _e1.copy( envMapRotation );
28365
+
28366
+ // accommodate left-handed frame
28367
+ _e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
28368
+
28369
+ if ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) {
28370
+
28371
+ // environment maps which are not cube render targets or PMREMs follow a different convention
28372
+ _e1.y *= - 1;
28373
+ _e1.z *= - 1;
28374
+
28375
+ }
28376
+
28377
+ uniforms.envMapRotation.value.setFromMatrix4( _m1.makeRotationFromEuler( _e1 ) );
28378
+
28948
28379
  uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
28949
28380
 
28950
28381
  uniforms.reflectivity.value = material.reflectivity;
@@ -29100,11 +28531,10 @@ function WebGLMaterials( renderer, properties ) {
29100
28531
 
29101
28532
  }
29102
28533
 
29103
- const envMap = properties.get( material ).envMap;
29104
-
29105
- if ( envMap ) {
28534
+ if ( material.envMap ) {
29106
28535
 
29107
28536
  //uniforms.envMap.value = material.envMap; // part of uniforms common
28537
+
29108
28538
  uniforms.envMapIntensity.value = material.envMapIntensity;
29109
28539
 
29110
28540
  }
@@ -29300,7 +28730,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
29300
28730
  let updateList = {};
29301
28731
  let allocatedBindingPoints = [];
29302
28732
 
29303
- const maxBindingPoints = ( capabilities.isWebGL2 ) ? gl.getParameter( gl.MAX_UNIFORM_BUFFER_BINDINGS ) : 0; // binding points are global whereas block indices are per shader program
28733
+ const maxBindingPoints = gl.getParameter( gl.MAX_UNIFORM_BUFFER_BINDINGS ); // binding points are global whereas block indices are per shader program
29304
28734
 
29305
28735
  function bind( uniformsGroup, program ) {
29306
28736
 
@@ -29692,7 +29122,7 @@ class WebGLRenderer {
29692
29122
  canvas = createCanvasElement(),
29693
29123
  context = null,
29694
29124
  depth = true,
29695
- stencil = true,
29125
+ stencil = false,
29696
29126
  alpha = false,
29697
29127
  antialias = false,
29698
29128
  premultipliedAlpha = true,
@@ -29708,6 +29138,12 @@ class WebGLRenderer {
29708
29138
 
29709
29139
  if ( context !== null ) {
29710
29140
 
29141
+ if ( typeof WebGLRenderingContext !== 'undefined' && context instanceof WebGLRenderingContext ) {
29142
+
29143
+ throw new Error( 'THREE.WebGLRenderer: WebGL 1 is not supported since r163.' );
29144
+
29145
+ }
29146
+
29711
29147
  _alpha = context.getContextAttributes().alpha;
29712
29148
 
29713
29149
  } else {
@@ -29820,10 +29256,6 @@ class WebGLRenderer {
29820
29256
  let _clippingEnabled = false;
29821
29257
  let _localClippingEnabled = false;
29822
29258
 
29823
- // transmission
29824
-
29825
- let _transmissionRenderTarget = null;
29826
-
29827
29259
  // camera matrices cache
29828
29260
 
29829
29261
  const _projScreenMatrix = new Matrix4();
@@ -29843,15 +29275,10 @@ class WebGLRenderer {
29843
29275
 
29844
29276
  let _gl = context;
29845
29277
 
29846
- function getContext( contextNames, contextAttributes ) {
29278
+ function getContext( contextName, contextAttributes ) {
29847
29279
 
29848
- for ( let i = 0; i < contextNames.length; i ++ ) {
29849
-
29850
- const contextName = contextNames[ i ];
29851
- const context = canvas.getContext( contextName, contextAttributes );
29852
- if ( context !== null ) return context;
29853
-
29854
- }
29280
+ const context = canvas.getContext( contextName, contextAttributes );
29281
+ if ( context !== null ) return context;
29855
29282
 
29856
29283
  return null;
29857
29284
 
@@ -29880,19 +29307,13 @@ class WebGLRenderer {
29880
29307
 
29881
29308
  if ( _gl === null ) {
29882
29309
 
29883
- const contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];
29884
-
29885
- if ( _this.isWebGL1Renderer === true ) {
29310
+ const contextName = 'webgl2';
29886
29311
 
29887
- contextNames.shift();
29888
-
29889
- }
29890
-
29891
- _gl = getContext( contextNames, contextAttributes );
29312
+ _gl = getContext( contextName, contextAttributes );
29892
29313
 
29893
29314
  if ( _gl === null ) {
29894
29315
 
29895
- if ( getContext( contextNames ) ) {
29316
+ if ( getContext( contextName ) ) {
29896
29317
 
29897
29318
  throw new Error( 'Error creating WebGL context with your selected attributes.' );
29898
29319
 
@@ -29906,24 +29327,6 @@ class WebGLRenderer {
29906
29327
 
29907
29328
  }
29908
29329
 
29909
- if ( typeof WebGLRenderingContext !== 'undefined' && _gl instanceof WebGLRenderingContext ) { // @deprecated, r153
29910
-
29911
- console.warn( 'THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163.' );
29912
-
29913
- }
29914
-
29915
- // Some experimental-webgl implementations do not have getShaderPrecisionFormat
29916
-
29917
- if ( _gl.getShaderPrecisionFormat === undefined ) {
29918
-
29919
- _gl.getShaderPrecisionFormat = function () {
29920
-
29921
- return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
29922
-
29923
- };
29924
-
29925
- }
29926
-
29927
29330
  } catch ( error ) {
29928
29331
 
29929
29332
  console.error( 'THREE.WebGLRenderer: ' + error.message );
@@ -29943,22 +29346,21 @@ class WebGLRenderer {
29943
29346
  function initGLContext() {
29944
29347
 
29945
29348
  extensions = new WebGLExtensions( _gl );
29349
+ extensions.init();
29946
29350
 
29947
29351
  capabilities = new WebGLCapabilities( _gl, extensions, parameters );
29948
29352
 
29949
- extensions.init( capabilities );
29950
-
29951
- utils = new WebGLUtils( _gl, extensions, capabilities );
29353
+ utils = new WebGLUtils( _gl, extensions );
29952
29354
 
29953
- state = new WebGLState( _gl, extensions, capabilities );
29355
+ state = new WebGLState( _gl );
29954
29356
 
29955
29357
  info = new WebGLInfo( _gl );
29956
29358
  properties = new WebGLProperties();
29957
29359
  textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
29958
29360
  cubemaps = new WebGLCubeMaps( _this );
29959
29361
  cubeuvmaps = new WebGLCubeUVMaps( _this );
29960
- attributes = new WebGLAttributes( _gl, capabilities );
29961
- bindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );
29362
+ attributes = new WebGLAttributes( _gl );
29363
+ bindingStates = new WebGLBindingStates( _gl, attributes );
29962
29364
  geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
29963
29365
  objects = new WebGLObjects( _gl, geometries, attributes, info );
29964
29366
  morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
@@ -29966,14 +29368,14 @@ class WebGLRenderer {
29966
29368
  programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
29967
29369
  materials = new WebGLMaterials( _this, properties );
29968
29370
  renderLists = new WebGLRenderLists();
29969
- renderStates = new WebGLRenderStates( extensions, capabilities );
29371
+ renderStates = new WebGLRenderStates( extensions );
29970
29372
  background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
29971
29373
  multiview = new WebGLMultiview( _this, extensions, _gl );
29972
29374
  shadowMap = new WebGLShadowMap( _this, objects, capabilities );
29973
29375
  uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
29974
29376
 
29975
- bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );
29976
- indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );
29377
+ bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info );
29378
+ indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info );
29977
29379
 
29978
29380
  info.programs = programCache.programs;
29979
29381
 
@@ -30115,7 +29517,7 @@ class WebGLRenderer {
30115
29517
 
30116
29518
  }
30117
29519
 
30118
- state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
29520
+ state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).round() );
30119
29521
 
30120
29522
  };
30121
29523
 
@@ -30137,7 +29539,7 @@ class WebGLRenderer {
30137
29539
 
30138
29540
  }
30139
29541
 
30140
- state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
29542
+ state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).round() );
30141
29543
 
30142
29544
  };
30143
29545
 
@@ -30305,13 +29707,6 @@ class WebGLRenderer {
30305
29707
  xr.removeEventListener( 'sessionstart', onXRSessionStart );
30306
29708
  xr.removeEventListener( 'sessionend', onXRSessionEnd );
30307
29709
 
30308
- if ( _transmissionRenderTarget ) {
30309
-
30310
- _transmissionRenderTarget.dispose();
30311
- _transmissionRenderTarget = null;
30312
-
30313
- }
30314
-
30315
29710
  animation.stop();
30316
29711
 
30317
29712
  };
@@ -31080,17 +30475,19 @@ class WebGLRenderer {
31080
30475
 
31081
30476
  }
31082
30477
 
31083
- const isWebGL2 = capabilities.isWebGL2;
30478
+ if ( currentRenderState.state.transmissionRenderTarget === null ) {
31084
30479
 
31085
- if ( _transmissionRenderTarget === null ) {
31086
-
31087
- _transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
30480
+ currentRenderState.state.transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
31088
30481
  generateMipmaps: true,
31089
- type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
30482
+ type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
31090
30483
  minFilter: LinearMipmapLinearFilter,
31091
- samples: ( isWebGL2 ) ? 4 : 0
30484
+ samples: 4,
30485
+ stencilBuffer: stencil
31092
30486
  } );
31093
30487
 
30488
+ const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget );
30489
+ renderTargetProperties.__isTransmissionRenderTarget = true;
30490
+
31094
30491
  // debug
31095
30492
 
31096
30493
  /*
@@ -31103,22 +30500,15 @@ class WebGLRenderer {
31103
30500
 
31104
30501
  }
31105
30502
 
31106
- _this.getDrawingBufferSize( _vector2 );
31107
-
31108
- if ( isWebGL2 ) {
30503
+ const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget;
31109
30504
 
31110
- _transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
31111
-
31112
- } else {
31113
-
31114
- _transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
31115
-
31116
- }
30505
+ _this.getDrawingBufferSize( _vector2 );
30506
+ transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
31117
30507
 
31118
30508
  //
31119
30509
 
31120
30510
  const currentRenderTarget = _this.getRenderTarget();
31121
- _this.setRenderTarget( _transmissionRenderTarget );
30511
+ _this.setRenderTarget( transmissionRenderTarget );
31122
30512
 
31123
30513
  _this.getClearColor( _currentClearColor );
31124
30514
  _currentClearAlpha = _this.getClearAlpha();
@@ -31133,8 +30523,8 @@ class WebGLRenderer {
31133
30523
 
31134
30524
  renderObjects( opaqueObjects, scene, camera );
31135
30525
 
31136
- textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
31137
- textures.updateRenderTargetMipmap( _transmissionRenderTarget );
30526
+ textures.updateMultisampleRenderTarget( transmissionRenderTarget );
30527
+ textures.updateRenderTargetMipmap( transmissionRenderTarget );
31138
30528
 
31139
30529
  let renderTargetNeedsUpdate = false;
31140
30530
 
@@ -31167,8 +30557,8 @@ class WebGLRenderer {
31167
30557
 
31168
30558
  if ( renderTargetNeedsUpdate === true ) {
31169
30559
 
31170
- textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
31171
- textures.updateRenderTargetMipmap( _transmissionRenderTarget );
30560
+ textures.updateMultisampleRenderTarget( transmissionRenderTarget );
30561
+ textures.updateRenderTargetMipmap( transmissionRenderTarget );
31172
30562
 
31173
30563
  }
31174
30564
 
@@ -31255,6 +30645,7 @@ class WebGLRenderer {
31255
30645
  materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
31256
30646
  materialProperties.fog = scene.fog;
31257
30647
  materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
30648
+ materialProperties.envMapRotation = ( materialProperties.environment !== null && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
31258
30649
 
31259
30650
  if ( programs === undefined ) {
31260
30651
 
@@ -31367,6 +30758,7 @@ class WebGLRenderer {
31367
30758
  materialProperties.batching = parameters.batching;
31368
30759
  materialProperties.instancing = parameters.instancing;
31369
30760
  materialProperties.instancingColor = parameters.instancingColor;
30761
+ materialProperties.instancingMorph = parameters.instancingMorph;
31370
30762
  materialProperties.skinning = parameters.skinning;
31371
30763
  materialProperties.morphTargets = parameters.morphTargets;
31372
30764
  materialProperties.morphNormals = parameters.morphNormals;
@@ -31480,6 +30872,14 @@ class WebGLRenderer {
31480
30872
 
31481
30873
  needsProgramChange = true;
31482
30874
 
30875
+ } else if ( object.isInstancedMesh && materialProperties.instancingMorph === true && object.morphTexture === null ) {
30876
+
30877
+ needsProgramChange = true;
30878
+
30879
+ } else if ( object.isInstancedMesh && materialProperties.instancingMorph === false && object.morphTexture !== null ) {
30880
+
30881
+ needsProgramChange = true;
30882
+
31483
30883
  } else if ( materialProperties.envMap !== envMap ) {
31484
30884
 
31485
30885
  needsProgramChange = true;
@@ -31518,7 +30918,7 @@ class WebGLRenderer {
31518
30918
 
31519
30919
  needsProgramChange = true;
31520
30920
 
31521
- } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
30921
+ } else if ( materialProperties.morphTargetsCount !== morphTargetsCount ) {
31522
30922
 
31523
30923
  needsProgramChange = true;
31524
30924
 
@@ -31640,17 +31040,9 @@ class WebGLRenderer {
31640
31040
 
31641
31041
  if ( skeleton ) {
31642
31042
 
31643
- if ( capabilities.floatVertexTextures ) {
31644
-
31645
- if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
31043
+ if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
31646
31044
 
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
- }
31045
+ p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
31654
31046
 
31655
31047
  }
31656
31048
 
@@ -31665,7 +31057,7 @@ class WebGLRenderer {
31665
31057
 
31666
31058
  const morphAttributes = geometry.morphAttributes;
31667
31059
 
31668
- if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
31060
+ if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined ) ) {
31669
31061
 
31670
31062
  morphtargets.update( object, geometry, program );
31671
31063
 
@@ -31688,6 +31080,12 @@ class WebGLRenderer {
31688
31080
 
31689
31081
  }
31690
31082
 
31083
+ if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
31084
+
31085
+ m_uniforms.envMapIntensity.value = scene.environmentIntensity;
31086
+
31087
+ }
31088
+
31691
31089
  if ( refreshMaterial ) {
31692
31090
 
31693
31091
  p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
@@ -31715,7 +31113,7 @@ class WebGLRenderer {
31715
31113
 
31716
31114
  }
31717
31115
 
31718
- materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget );
31116
+ materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget );
31719
31117
 
31720
31118
  WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
31721
31119
 
@@ -31757,18 +31155,10 @@ class WebGLRenderer {
31757
31155
 
31758
31156
  for ( let i = 0, l = groups.length; i < l; i ++ ) {
31759
31157
 
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.' );
31158
+ const group = groups[ i ];
31770
31159
 
31771
- }
31160
+ uniformsGroups.update( group, program );
31161
+ uniformsGroups.bind( group, program );
31772
31162
 
31773
31163
  }
31774
31164
 
@@ -31937,7 +31327,7 @@ class WebGLRenderer {
31937
31327
 
31938
31328
  isCube = true;
31939
31329
 
31940
- } else if ( ( capabilities.isWebGL2 && renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
31330
+ } else if ( ( renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
31941
31331
 
31942
31332
  framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
31943
31333
 
@@ -31969,7 +31359,7 @@ class WebGLRenderer {
31969
31359
 
31970
31360
  const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
31971
31361
 
31972
- if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
31362
+ if ( framebufferBound && useDefaultFramebuffer ) {
31973
31363
 
31974
31364
  state.drawBuffers( renderTarget, framebuffer );
31975
31365
 
@@ -32030,11 +31420,10 @@ class WebGLRenderer {
32030
31420
 
32031
31421
  }
32032
31422
 
32033
- const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) );
31423
+ const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );
32034
31424
 
32035
31425
  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 ) {
31426
+ textureType !== FloatType && ! halfFloatSupportedByExt ) {
32038
31427
 
32039
31428
  console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
32040
31429
  return;
@@ -32118,15 +31507,8 @@ class WebGLRenderer {
32118
31507
 
32119
31508
  this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
32120
31509
 
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 = sourceBox.max.x - sourceBox.min.x + 1;
32129
- const height = sourceBox.max.y - sourceBox.min.y + 1;
31510
+ const width = Math.round( sourceBox.max.x - sourceBox.min.x );
31511
+ const height = Math.round( sourceBox.max.y - sourceBox.min.y );
32130
31512
  const depth = sourceBox.max.z - sourceBox.min.z + 1;
32131
31513
  const glFormat = utils.convert( dstTexture.format );
32132
31514
  const glType = utils.convert( dstTexture.type );
@@ -32173,9 +31555,8 @@ class WebGLRenderer {
32173
31555
 
32174
31556
  } else {
32175
31557
 
32176
- if ( srcTexture.isCompressedArrayTexture ) {
31558
+ if ( dstTexture.isCompressedArrayTexture ) {
32177
31559
 
32178
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' );
32179
31560
  _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
32180
31561
 
32181
31562
  } else {
@@ -32264,20 +31645,6 @@ class WebGLRenderer {
32264
31645
 
32265
31646
  }
32266
31647
 
32267
- get outputEncoding() { // @deprecated, r152
32268
-
32269
- console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
32270
- return this.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
32271
-
32272
- }
32273
-
32274
- set outputEncoding( encoding ) { // @deprecated, r152
32275
-
32276
- console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
32277
- this.outputColorSpace = encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
32278
-
32279
- }
32280
-
32281
31648
  get useLegacyLights() { // @deprecated, r155
32282
31649
 
32283
31650
  console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
@@ -32294,10 +31661,6 @@ class WebGLRenderer {
32294
31661
 
32295
31662
  }
32296
31663
 
32297
- class WebGL1Renderer extends WebGLRenderer {}
32298
-
32299
- WebGL1Renderer.prototype.isWebGL1Renderer = true;
32300
-
32301
31664
  class FogExp2 {
32302
31665
 
32303
31666
  constructor( color, density = 0.00025 ) {
@@ -32381,6 +31744,10 @@ class Scene extends Object3D {
32381
31744
 
32382
31745
  this.backgroundBlurriness = 0;
32383
31746
  this.backgroundIntensity = 1;
31747
+ this.backgroundRotation = new Euler();
31748
+
31749
+ this.environmentIntensity = 1;
31750
+ this.environmentRotation = new Euler();
32384
31751
 
32385
31752
  this.overrideMaterial = null;
32386
31753
 
@@ -32402,6 +31769,10 @@ class Scene extends Object3D {
32402
31769
 
32403
31770
  this.backgroundBlurriness = source.backgroundBlurriness;
32404
31771
  this.backgroundIntensity = source.backgroundIntensity;
31772
+ this.backgroundRotation.copy( source.backgroundRotation );
31773
+
31774
+ this.environmentIntensity = source.environmentIntensity;
31775
+ this.environmentRotation.copy( source.environmentRotation );
32405
31776
 
32406
31777
  if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();
32407
31778
 
@@ -32416,8 +31787,13 @@ class Scene extends Object3D {
32416
31787
  const data = super.toJSON( meta );
32417
31788
 
32418
31789
  if ( this.fog !== null ) data.object.fog = this.fog.toJSON();
31790
+
32419
31791
  if ( this.backgroundBlurriness > 0 ) data.object.backgroundBlurriness = this.backgroundBlurriness;
32420
31792
  if ( this.backgroundIntensity !== 1 ) data.object.backgroundIntensity = this.backgroundIntensity;
31793
+ data.object.backgroundRotation = this.backgroundRotation.toArray();
31794
+
31795
+ if ( this.environmentIntensity !== 1 ) data.object.environmentIntensity = this.environmentIntensity;
31796
+ data.object.environmentRotation = this.environmentRotation.toArray();
32421
31797
 
32422
31798
  return data;
32423
31799
 
@@ -33962,6 +33338,7 @@ class InstancedMesh extends Mesh {
33962
33338
 
33963
33339
  this.instanceMatrix = new InstancedBufferAttribute( new Float32Array( count * 16 ), 16 );
33964
33340
  this.instanceColor = null;
33341
+ this.morphTexture = null;
33965
33342
 
33966
33343
  this.count = count;
33967
33344
 
@@ -34044,6 +33421,7 @@ class InstancedMesh extends Mesh {
34044
33421
 
34045
33422
  this.instanceMatrix.copy( source.instanceMatrix );
34046
33423
 
33424
+ if ( source.morphTexture !== null ) this.morphTexture = source.morphTexture.clone();
34047
33425
  if ( source.instanceColor !== null ) this.instanceColor = source.instanceColor.clone();
34048
33426
 
34049
33427
  this.count = source.count;
@@ -34067,6 +33445,24 @@ class InstancedMesh extends Mesh {
34067
33445
 
34068
33446
  }
34069
33447
 
33448
+ getMorphAt( index, object ) {
33449
+
33450
+ const objectInfluences = object.morphTargetInfluences;
33451
+
33452
+ const array = this.morphTexture.source.data.data;
33453
+
33454
+ const len = objectInfluences.length + 1; // All influences + the baseInfluenceSum
33455
+
33456
+ const dataIndex = index * len + 1; // Skip the baseInfluenceSum at the beginning
33457
+
33458
+ for ( let i = 0; i < objectInfluences.length; i ++ ) {
33459
+
33460
+ objectInfluences[ i ] = array[ dataIndex + i ];
33461
+
33462
+ }
33463
+
33464
+ }
33465
+
34070
33466
  raycast( raycaster, intersects ) {
34071
33467
 
34072
33468
  const matrixWorld = this.matrixWorld;
@@ -34137,6 +33533,38 @@ class InstancedMesh extends Mesh {
34137
33533
 
34138
33534
  }
34139
33535
 
33536
+ setMorphAt( index, object ) {
33537
+
33538
+ const objectInfluences = object.morphTargetInfluences;
33539
+
33540
+ const len = objectInfluences.length + 1; // morphBaseInfluence + all influences
33541
+
33542
+ if ( this.morphTexture === null ) {
33543
+
33544
+ this.morphTexture = new DataTexture( new Float32Array( len * this.count ), len, this.count, RedFormat, FloatType );
33545
+
33546
+ }
33547
+
33548
+ const array = this.morphTexture.source.data.data;
33549
+
33550
+ let morphInfluencesSum = 0;
33551
+
33552
+ for ( let i = 0; i < objectInfluences.length; i ++ ) {
33553
+
33554
+ morphInfluencesSum += objectInfluences[ i ];
33555
+
33556
+ }
33557
+
33558
+ const morphBaseInfluence = this.geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;
33559
+
33560
+ const dataIndex = len * index;
33561
+
33562
+ array[ dataIndex ] = morphBaseInfluence;
33563
+
33564
+ array.set( objectInfluences, dataIndex + 1 );
33565
+
33566
+ }
33567
+
34140
33568
  updateMorphTargets() {
34141
33569
 
34142
33570
  }
@@ -34145,6 +33573,15 @@ class InstancedMesh extends Mesh {
34145
33573
 
34146
33574
  this.dispatchEvent( { type: 'dispose' } );
34147
33575
 
33576
+ if ( this.morphTexture !== null ) {
33577
+
33578
+ this.morphTexture.dispose();
33579
+ this.morphTexture = null;
33580
+
33581
+ }
33582
+
33583
+ return this;
33584
+
34148
33585
  }
34149
33586
 
34150
33587
  }
@@ -34207,7 +33644,7 @@ class MultiDrawRenderList {
34207
33644
  }
34208
33645
 
34209
33646
  const ID_ATTR_NAME = 'batchId';
34210
- const _matrix = /*@__PURE__*/ new Matrix4();
33647
+ const _matrix$1 = /*@__PURE__*/ new Matrix4();
34211
33648
  const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
34212
33649
  const _identityMatrix = /*@__PURE__*/ new Matrix4();
34213
33650
  const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
@@ -34334,8 +33771,7 @@ class BatchedMesh extends Mesh {
34334
33771
  const { array, itemSize, normalized } = srcAttribute;
34335
33772
 
34336
33773
  const dstArray = new array.constructor( maxVertexCount * itemSize );
34337
- const dstAttribute = new srcAttribute.constructor( dstArray, itemSize, normalized );
34338
- dstAttribute.setUsage( srcAttribute.usage );
33774
+ const dstAttribute = new BufferAttribute( dstArray, itemSize, normalized );
34339
33775
 
34340
33776
  geometry.setAttribute( attributeName, dstAttribute );
34341
33777
 
@@ -34362,7 +33798,7 @@ class BatchedMesh extends Mesh {
34362
33798
 
34363
33799
  }
34364
33800
 
34365
- // Make sure the geometry is compatible with the existing combined geometry atributes
33801
+ // Make sure the geometry is compatible with the existing combined geometry attributes
34366
33802
  _validateGeometry( geometry ) {
34367
33803
 
34368
33804
  // check that the geometry doesn't have a version of our reserved id attribute
@@ -34430,8 +33866,8 @@ class BatchedMesh extends Mesh {
34430
33866
 
34431
33867
  if ( active[ i ] === false ) continue;
34432
33868
 
34433
- this.getMatrixAt( i, _matrix );
34434
- this.getBoundingBoxAt( i, _box$1 ).applyMatrix4( _matrix );
33869
+ this.getMatrixAt( i, _matrix$1 );
33870
+ this.getBoundingBoxAt( i, _box$1 ).applyMatrix4( _matrix$1 );
34435
33871
  boundingBox.union( _box$1 );
34436
33872
 
34437
33873
  }
@@ -34455,8 +33891,8 @@ class BatchedMesh extends Mesh {
34455
33891
 
34456
33892
  if ( active[ i ] === false ) continue;
34457
33893
 
34458
- this.getMatrixAt( i, _matrix );
34459
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix );
33894
+ this.getMatrixAt( i, _matrix$1 );
33895
+ this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
34460
33896
  boundingSphere.union( _sphere$2 );
34461
33897
 
34462
33898
  }
@@ -34653,6 +34089,7 @@ class BatchedMesh extends Mesh {
34653
34089
  }
34654
34090
 
34655
34091
  dstAttribute.needsUpdate = true;
34092
+ dstAttribute.addUpdateRange( vertexStart * itemSize, vertexCount * itemSize );
34656
34093
 
34657
34094
  }
34658
34095
 
@@ -34676,6 +34113,7 @@ class BatchedMesh extends Mesh {
34676
34113
  }
34677
34114
 
34678
34115
  dstIndex.needsUpdate = true;
34116
+ dstIndex.addUpdateRange( indexStart, reservedRange.indexCount );
34679
34117
 
34680
34118
  }
34681
34119
 
@@ -35063,8 +34501,8 @@ class BatchedMesh extends Mesh {
35063
34501
  if ( visibility[ i ] && active[ i ] ) {
35064
34502
 
35065
34503
  // get the bounds in world space
35066
- this.getMatrixAt( i, _matrix );
35067
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix );
34504
+ this.getMatrixAt( i, _matrix$1 );
34505
+ this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35068
34506
 
35069
34507
  // determine whether the batched geometry is within the frustum
35070
34508
  let culled = false;
@@ -35121,8 +34559,8 @@ class BatchedMesh extends Mesh {
35121
34559
  if ( perObjectFrustumCulled ) {
35122
34560
 
35123
34561
  // get the bounds in world space
35124
- this.getMatrixAt( i, _matrix );
35125
- this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix );
34562
+ this.getMatrixAt( i, _matrix$1 );
34563
+ this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix$1 );
35126
34564
  culled = ! _frustum.intersectsSphere( _sphere$2 );
35127
34565
 
35128
34566
  }
@@ -36251,9 +35689,9 @@ class EllipseCurve extends Curve {
36251
35689
 
36252
35690
  }
36253
35691
 
36254
- getPoint( t, optionalTarget ) {
35692
+ getPoint( t, optionalTarget = new Vector2() ) {
36255
35693
 
36256
- const point = optionalTarget || new Vector2();
35694
+ const point = optionalTarget;
36257
35695
 
36258
35696
  const twoPi = Math.PI * 2;
36259
35697
  let deltaAngle = this.aEndAngle - this.aStartAngle;
@@ -41910,6 +41348,7 @@ class MeshStandardMaterial extends Material {
41910
41348
  this.alphaMap = null;
41911
41349
 
41912
41350
  this.envMap = null;
41351
+ this.envMapRotation = new Euler();
41913
41352
  this.envMapIntensity = 1.0;
41914
41353
 
41915
41354
  this.wireframe = false;
@@ -41965,6 +41404,7 @@ class MeshStandardMaterial extends Material {
41965
41404
  this.alphaMap = source.alphaMap;
41966
41405
 
41967
41406
  this.envMap = source.envMap;
41407
+ this.envMapRotation.copy( source.envMapRotation );
41968
41408
  this.envMapIntensity = source.envMapIntensity;
41969
41409
 
41970
41410
  this.wireframe = source.wireframe;
@@ -42242,6 +41682,7 @@ class MeshPhongMaterial extends Material {
42242
41682
  this.alphaMap = null;
42243
41683
 
42244
41684
  this.envMap = null;
41685
+ this.envMapRotation = new Euler();
42245
41686
  this.combine = MultiplyOperation;
42246
41687
  this.reflectivity = 1;
42247
41688
  this.refractionRatio = 0.98;
@@ -42295,6 +41736,7 @@ class MeshPhongMaterial extends Material {
42295
41736
  this.alphaMap = source.alphaMap;
42296
41737
 
42297
41738
  this.envMap = source.envMap;
41739
+ this.envMapRotation.copy( source.envMapRotation );
42298
41740
  this.combine = source.combine;
42299
41741
  this.reflectivity = source.reflectivity;
42300
41742
  this.refractionRatio = source.refractionRatio;
@@ -42506,6 +41948,7 @@ class MeshLambertMaterial extends Material {
42506
41948
  this.alphaMap = null;
42507
41949
 
42508
41950
  this.envMap = null;
41951
+ this.envMapRotation = new Euler();
42509
41952
  this.combine = MultiplyOperation;
42510
41953
  this.reflectivity = 1;
42511
41954
  this.refractionRatio = 0.98;
@@ -42557,6 +42000,7 @@ class MeshLambertMaterial extends Material {
42557
42000
  this.alphaMap = source.alphaMap;
42558
42001
 
42559
42002
  this.envMap = source.envMap;
42003
+ this.envMapRotation.copy( source.envMapRotation );
42560
42004
  this.combine = source.combine;
42561
42005
  this.reflectivity = source.reflectivity;
42562
42006
  this.refractionRatio = source.refractionRatio;
@@ -44016,7 +43460,7 @@ VectorKeyframeTrack.prototype.ValueTypeName = 'vector';
44016
43460
 
44017
43461
  class AnimationClip {
44018
43462
 
44019
- constructor( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) {
43463
+ constructor( name = '', duration = - 1, tracks = [], blendMode = NormalAnimationBlendMode ) {
44020
43464
 
44021
43465
  this.name = name;
44022
43466
  this.tracks = tracks;
@@ -45399,10 +44843,6 @@ class DataTextureLoader extends Loader {
45399
44843
 
45400
44844
  texture.colorSpace = texData.colorSpace;
45401
44845
 
45402
- } else if ( texData.encoding !== undefined ) { // @deprecated, r152
45403
-
45404
- texture.encoding = texData.encoding;
45405
-
45406
44846
  }
45407
44847
 
45408
44848
  if ( texData.flipY !== undefined ) {
@@ -46638,6 +46078,7 @@ class MaterialLoader extends Loader {
46638
46078
  if ( json.specularColorMap !== undefined ) material.specularColorMap = getTexture( json.specularColorMap );
46639
46079
 
46640
46080
  if ( json.envMap !== undefined ) material.envMap = getTexture( json.envMap );
46081
+ if ( json.envMapRotation !== undefined ) material.envMapRotation.fromArray( json.envMapRotation );
46641
46082
  if ( json.envMapIntensity !== undefined ) material.envMapIntensity = json.envMapIntensity;
46642
46083
 
46643
46084
  if ( json.reflectivity !== undefined ) material.reflectivity = json.reflectivity;
@@ -47633,7 +47074,6 @@ class ObjectLoader extends Loader {
47633
47074
  if ( data.internalFormat !== undefined ) texture.internalFormat = data.internalFormat;
47634
47075
  if ( data.type !== undefined ) texture.type = data.type;
47635
47076
  if ( data.colorSpace !== undefined ) texture.colorSpace = data.colorSpace;
47636
- if ( data.encoding !== undefined ) texture.encoding = data.encoding; // @deprecated, r152
47637
47077
 
47638
47078
  if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER );
47639
47079
  if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER );
@@ -47772,6 +47212,10 @@ class ObjectLoader extends Loader {
47772
47212
 
47773
47213
  if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
47774
47214
  if ( data.backgroundIntensity !== undefined ) object.backgroundIntensity = data.backgroundIntensity;
47215
+ if ( data.backgroundRotation !== undefined ) object.backgroundRotation.fromArray( data.backgroundRotation );
47216
+
47217
+ if ( data.environmentIntensity !== undefined ) object.environmentIntensity = data.environmentIntensity;
47218
+ if ( data.environmentRotation !== undefined ) object.environmentRotation.fromArray( data.environmentRotation );
47775
47219
 
47776
47220
  break;
47777
47221
 
@@ -52280,6 +51724,8 @@ class GLBufferAttribute {
52280
51724
 
52281
51725
  }
52282
51726
 
51727
+ const _matrix = /*@__PURE__*/ new Matrix4();
51728
+
52283
51729
  class Raycaster {
52284
51730
 
52285
51731
  constructor( origin, direction, near = 0, far = Infinity ) {
@@ -52332,9 +51778,20 @@ class Raycaster {
52332
51778
 
52333
51779
  }
52334
51780
 
51781
+ setFromXRController( controller ) {
51782
+
51783
+ _matrix.identity().extractRotation( controller.matrixWorld );
51784
+
51785
+ this.ray.origin.setFromMatrixPosition( controller.matrixWorld );
51786
+ this.ray.direction.set( 0, 0, - 1 ).applyMatrix4( _matrix );
51787
+
51788
+ return this;
51789
+
51790
+ }
51791
+
52335
51792
  intersectObject( object, recursive = true, intersects = [] ) {
52336
51793
 
52337
- intersectObject( object, this, intersects, recursive );
51794
+ intersect( object, this, intersects, recursive );
52338
51795
 
52339
51796
  intersects.sort( ascSort );
52340
51797
 
@@ -52346,7 +51803,7 @@ class Raycaster {
52346
51803
 
52347
51804
  for ( let i = 0, l = objects.length; i < l; i ++ ) {
52348
51805
 
52349
- intersectObject( objects[ i ], this, intersects, recursive );
51806
+ intersect( objects[ i ], this, intersects, recursive );
52350
51807
 
52351
51808
  }
52352
51809
 
@@ -52364,7 +51821,7 @@ function ascSort( a, b ) {
52364
51821
 
52365
51822
  }
52366
51823
 
52367
- function intersectObject( object, raycaster, intersects, recursive ) {
51824
+ function intersect( object, raycaster, intersects, recursive ) {
52368
51825
 
52369
51826
  if ( object.layers.test( raycaster.layers ) ) {
52370
51827
 
@@ -52378,7 +51835,7 @@ function intersectObject( object, raycaster, intersects, recursive ) {
52378
51835
 
52379
51836
  for ( let i = 0, l = children.length; i < l; i ++ ) {
52380
51837
 
52381
- intersectObject( children[ i ], raycaster, intersects, true );
51838
+ intersect( children[ i ], raycaster, intersects, true );
52382
51839
 
52383
51840
  }
52384
51841
 
@@ -52389,11 +51846,9 @@ function intersectObject( object, raycaster, intersects, recursive ) {
52389
51846
  /**
52390
51847
  * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
52391
51848
  *
52392
- * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up.
52393
- * The azimuthal angle (theta) is measured from the positive z-axis.
51849
+ * phi (the polar angle) is measured from the positive y-axis. The positive y-axis is up.
51850
+ * theta (the azimuthal angle) is measured from the positive z-axis.
52394
51851
  */
52395
-
52396
-
52397
51852
  class Spherical {
52398
51853
 
52399
51854
  constructor( radius = 1, phi = 0, theta = 0 ) {
@@ -52852,7 +52307,6 @@ class SpotLightHelper extends Object3D {
52852
52307
 
52853
52308
  this.light = light;
52854
52309
 
52855
- this.matrix = light.matrixWorld;
52856
52310
  this.matrixAutoUpdate = false;
52857
52311
 
52858
52312
  this.color = color;
@@ -52904,6 +52358,24 @@ class SpotLightHelper extends Object3D {
52904
52358
  this.light.updateWorldMatrix( true, false );
52905
52359
  this.light.target.updateWorldMatrix( true, false );
52906
52360
 
52361
+ // update the local matrix based on the parent and light target transforms
52362
+ if ( this.parent ) {
52363
+
52364
+ this.parent.updateWorldMatrix( true );
52365
+
52366
+ this.matrix
52367
+ .copy( this.parent.matrixWorld )
52368
+ .invert()
52369
+ .multiply( this.light.matrixWorld );
52370
+
52371
+ } else {
52372
+
52373
+ this.matrix.copy( this.light.matrixWorld );
52374
+
52375
+ }
52376
+
52377
+ this.matrixWorld.copy( this.light.matrixWorld );
52378
+
52907
52379
  const coneLength = this.light.distance ? this.light.distance : 1000;
52908
52380
  const coneWidth = coneLength * Math.tan( this.light.angle );
52909
52381
 
@@ -54344,6 +53816,26 @@ class ShapePath {
54344
53816
 
54345
53817
  }
54346
53818
 
53819
+ class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
53820
+
53821
+ constructor( width = 1, height = 1, count = 1, options = {} ) {
53822
+
53823
+ console.warn( 'THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.' );
53824
+
53825
+ super( width, height, { ...options, count } );
53826
+
53827
+ this.isWebGLMultipleRenderTargets = true;
53828
+
53829
+ }
53830
+
53831
+ get texture() {
53832
+
53833
+ return this.textures;
53834
+
53835
+ }
53836
+
53837
+ }
53838
+
54347
53839
  if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
54348
53840
 
54349
53841
  __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {
@@ -54483,7 +53975,6 @@ exports.ExtrudeGeometry = ExtrudeGeometry;
54483
53975
  exports.FileLoader = FileLoader;
54484
53976
  exports.Float16BufferAttribute = Float16BufferAttribute;
54485
53977
  exports.Float32BufferAttribute = Float32BufferAttribute;
54486
- exports.Float64BufferAttribute = Float64BufferAttribute;
54487
53978
  exports.FloatType = FloatType;
54488
53979
  exports.Fog = Fog;
54489
53980
  exports.FogExp2 = FogExp2;
@@ -54547,7 +54038,6 @@ exports.LineDashedMaterial = LineDashedMaterial;
54547
54038
  exports.LineLoop = LineLoop;
54548
54039
  exports.LineSegments = LineSegments;
54549
54040
  exports.LinearDisplayP3ColorSpace = LinearDisplayP3ColorSpace;
54550
- exports.LinearEncoding = LinearEncoding;
54551
54041
  exports.LinearFilter = LinearFilter;
54552
54042
  exports.LinearInterpolant = LinearInterpolant;
54553
54043
  exports.LinearMipMapLinearFilter = LinearMipMapLinearFilter;
@@ -54593,6 +54083,7 @@ exports.NearestMipMapLinearFilter = NearestMipMapLinearFilter;
54593
54083
  exports.NearestMipMapNearestFilter = NearestMipMapNearestFilter;
54594
54084
  exports.NearestMipmapLinearFilter = NearestMipmapLinearFilter;
54595
54085
  exports.NearestMipmapNearestFilter = NearestMipmapNearestFilter;
54086
+ exports.NeutralToneMapping = NeutralToneMapping;
54596
54087
  exports.NeverCompare = NeverCompare;
54597
54088
  exports.NeverDepth = NeverDepth;
54598
54089
  exports.NeverStencilFunc = NeverStencilFunc;
@@ -54667,6 +54158,7 @@ exports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;
54667
54158
  exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;
54668
54159
  exports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;
54669
54160
  exports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;
54161
+ exports.RGBFormat = RGBFormat;
54670
54162
  exports.RGB_BPTC_SIGNED_Format = RGB_BPTC_SIGNED_Format;
54671
54163
  exports.RGB_BPTC_UNSIGNED_Format = RGB_BPTC_UNSIGNED_Format;
54672
54164
  exports.RGB_ETC1_Format = RGB_ETC1_Format;
@@ -54752,6 +54244,7 @@ exports.UniformsLib = UniformsLib;
54752
54244
  exports.UniformsUtils = UniformsUtils;
54753
54245
  exports.UnsignedByteType = UnsignedByteType;
54754
54246
  exports.UnsignedInt248Type = UnsignedInt248Type;
54247
+ exports.UnsignedInt5999Type = UnsignedInt5999Type;
54755
54248
  exports.UnsignedIntType = UnsignedIntType;
54756
54249
  exports.UnsignedShort4444Type = UnsignedShort4444Type;
54757
54250
  exports.UnsignedShort5551Type = UnsignedShort5551Type;
@@ -54762,7 +54255,6 @@ exports.Vector3 = Vector3;
54762
54255
  exports.Vector4 = Vector4;
54763
54256
  exports.VectorKeyframeTrack = VectorKeyframeTrack;
54764
54257
  exports.VideoTexture = VideoTexture;
54765
- exports.WebGL1Renderer = WebGL1Renderer;
54766
54258
  exports.WebGL3DRenderTarget = WebGL3DRenderTarget;
54767
54259
  exports.WebGLArrayRenderTarget = WebGLArrayRenderTarget;
54768
54260
  exports.WebGLCoordinateSystem = WebGLCoordinateSystem;
@@ -54778,6 +54270,4 @@ exports.ZeroCurvatureEnding = ZeroCurvatureEnding;
54778
54270
  exports.ZeroFactor = ZeroFactor;
54779
54271
  exports.ZeroSlopeEnding = ZeroSlopeEnding;
54780
54272
  exports.ZeroStencilOp = ZeroStencilOp;
54781
- exports._SRGBAFormat = _SRGBAFormat;
54782
54273
  exports.createCanvasElement = createCanvasElement;
54783
- exports.sRGBEncoding = sRGBEncoding;