super-three 0.158.0 → 0.160.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 (191) hide show
  1. package/build/three.cjs +1719 -379
  2. package/build/three.js +1719 -379
  3. package/build/three.min.js +1 -1
  4. package/build/three.module.js +1718 -380
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/Addons.js +2 -1
  7. package/examples/jsm/controls/OrbitControls.js +50 -40
  8. package/examples/jsm/csm/CSMShader.js +52 -47
  9. package/examples/jsm/exporters/GLTFExporter.js +79 -1
  10. package/examples/jsm/exporters/USDZExporter.js +27 -19
  11. package/examples/jsm/helpers/TextureHelper.js +237 -0
  12. package/examples/jsm/interactive/HTMLMesh.js +9 -2
  13. package/examples/jsm/lines/LineMaterial.js +16 -33
  14. package/examples/jsm/loaders/ColladaLoader.js +0 -6
  15. package/examples/jsm/loaders/DRACOLoader.js +4 -3
  16. package/examples/jsm/loaders/FBXLoader.js +294 -124
  17. package/examples/jsm/loaders/GLTFLoader.js +71 -3
  18. package/examples/jsm/loaders/MaterialXLoader.js +73 -54
  19. package/examples/jsm/loaders/NRRDLoader.js +0 -13
  20. package/examples/jsm/loaders/SVGLoader.js +4 -4
  21. package/examples/jsm/loaders/USDZLoader.js +3 -17
  22. package/examples/jsm/math/Octree.js +15 -4
  23. package/examples/jsm/misc/Timer.js +119 -0
  24. package/examples/jsm/misc/TubePainter.js +3 -6
  25. package/examples/jsm/modifiers/CurveModifier.js +20 -2
  26. package/examples/jsm/nodes/Nodes.js +11 -7
  27. package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
  28. package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
  29. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
  30. package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
  31. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
  32. package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
  33. package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
  34. package/examples/jsm/nodes/accessors/TextureNode.js +122 -36
  35. package/examples/jsm/nodes/code/CodeNode.js +3 -3
  36. package/examples/jsm/nodes/core/AttributeNode.js +7 -1
  37. package/examples/jsm/nodes/core/CacheNode.js +4 -1
  38. package/examples/jsm/nodes/core/ConstNode.js +1 -1
  39. package/examples/jsm/nodes/core/Node.js +6 -3
  40. package/examples/jsm/nodes/core/NodeBuilder.js +84 -27
  41. package/examples/jsm/nodes/core/NodeFrame.js +10 -8
  42. package/examples/jsm/nodes/core/NodeUniform.js +12 -0
  43. package/examples/jsm/nodes/core/NodeUtils.js +3 -7
  44. package/examples/jsm/nodes/core/OutputStructNode.js +3 -3
  45. package/examples/jsm/nodes/core/PropertyNode.js +17 -2
  46. package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
  47. package/examples/jsm/nodes/core/UniformGroup.js +13 -0
  48. package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
  49. package/examples/jsm/nodes/core/UniformNode.js +17 -0
  50. package/examples/jsm/nodes/core/VarNode.js +2 -0
  51. package/examples/jsm/nodes/core/VaryingNode.js +1 -7
  52. package/examples/jsm/nodes/display/BumpMapNode.js +1 -1
  53. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
  54. package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
  55. package/examples/jsm/nodes/display/PassNode.js +182 -0
  56. package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
  57. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
  58. package/examples/jsm/nodes/display/ViewportNode.js +5 -8
  59. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +1 -1
  60. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +52 -17
  61. package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -12
  62. package/examples/jsm/nodes/lighting/LightsNode.js +34 -32
  63. package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +1 -1
  64. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +12 -12
  65. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
  66. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +1 -1
  67. package/examples/jsm/nodes/materials/NodeMaterial.js +66 -41
  68. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
  69. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
  70. package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
  71. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
  72. package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
  73. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
  74. package/examples/jsm/nodes/math/MathNode.js +2 -0
  75. package/examples/jsm/nodes/math/OperatorNode.js +19 -6
  76. package/examples/jsm/nodes/shadernode/ShaderNode.js +32 -3
  77. package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
  78. package/examples/jsm/nodes/utils/RemapNode.js +2 -2
  79. package/examples/jsm/nodes/utils/SplitNode.js +8 -2
  80. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
  81. package/examples/jsm/objects/QuadMesh.js +60 -0
  82. package/examples/jsm/postprocessing/GTAOPass.js +572 -0
  83. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  84. package/examples/jsm/renderers/common/Animation.js +10 -21
  85. package/examples/jsm/renderers/common/Backend.js +19 -3
  86. package/examples/jsm/renderers/common/Background.js +20 -22
  87. package/examples/jsm/renderers/common/Bindings.js +30 -21
  88. package/examples/jsm/renderers/common/ChainMap.js +3 -3
  89. package/examples/jsm/renderers/common/Color4.js +37 -0
  90. package/examples/jsm/renderers/common/Geometries.js +4 -4
  91. package/examples/jsm/renderers/common/Info.js +12 -2
  92. package/examples/jsm/renderers/common/Pipelines.js +3 -51
  93. package/examples/jsm/renderers/common/PostProcessing.js +25 -0
  94. package/examples/jsm/renderers/common/RenderContext.js +1 -1
  95. package/examples/jsm/renderers/common/RenderContexts.js +1 -1
  96. package/examples/jsm/renderers/common/RenderObject.js +13 -1
  97. package/examples/jsm/renderers/common/RenderObjects.js +4 -2
  98. package/examples/jsm/renderers/common/Renderer.js +137 -37
  99. package/examples/jsm/renderers/common/StorageTexture.js +1 -0
  100. package/examples/jsm/renderers/common/Textures.js +4 -1
  101. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
  102. package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
  103. package/examples/jsm/renderers/common/nodes/Nodes.js +74 -7
  104. package/examples/jsm/renderers/webgl/WebGLBackend.js +91 -33
  105. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +100 -31
  106. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +57 -5
  107. package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
  108. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
  109. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
  110. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
  111. package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
  112. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
  113. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
  114. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +186 -137
  115. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
  116. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +209 -90
  117. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
  118. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
  119. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
  120. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
  121. package/examples/jsm/shaders/FXAAShader.js +133 -133
  122. package/examples/jsm/shaders/GTAOShader.js +424 -0
  123. package/examples/jsm/shaders/OutputShader.js +4 -0
  124. package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
  125. package/examples/jsm/shaders/SAOShader.js +2 -3
  126. package/examples/jsm/shaders/SSAOShader.js +2 -3
  127. package/examples/jsm/transpiler/AST.js +40 -1
  128. package/examples/jsm/transpiler/GLSLDecoder.js +50 -8
  129. package/examples/jsm/transpiler/ShaderToyDecoder.js +4 -4
  130. package/examples/jsm/transpiler/TSLEncoder.js +124 -20
  131. package/examples/jsm/utils/SortUtils.js +158 -0
  132. package/examples/jsm/utils/TextureUtils.js +33 -21
  133. package/examples/jsm/webxr/ARButton.js +14 -0
  134. package/examples/jsm/webxr/VRButton.js +23 -8
  135. package/examples/jsm/webxr/XRButton.js +25 -11
  136. package/package.json +5 -6
  137. package/src/Three.js +1 -0
  138. package/src/constants.js +2 -1
  139. package/src/core/BufferAttribute.js +21 -2
  140. package/src/core/InterleavedBuffer.js +21 -1
  141. package/src/core/Object3D.js +60 -12
  142. package/src/core/UniformsGroup.js +7 -1
  143. package/src/extras/curves/LineCurve3.js +4 -0
  144. package/src/loaders/AudioLoader.js +1 -1
  145. package/src/loaders/BufferGeometryLoader.js +0 -7
  146. package/src/loaders/ImageBitmapLoader.js +25 -1
  147. package/src/loaders/ObjectLoader.js +49 -0
  148. package/src/materials/ShaderMaterial.js +2 -1
  149. package/src/math/ColorManagement.js +0 -16
  150. package/src/math/Quaternion.js +5 -4
  151. package/src/math/Sphere.js +2 -0
  152. package/src/math/Triangle.js +17 -5
  153. package/src/objects/BatchedMesh.js +1020 -0
  154. package/src/objects/Skeleton.js +1 -3
  155. package/src/renderers/WebGL3DRenderTarget.js +2 -2
  156. package/src/renderers/WebGLArrayRenderTarget.js +2 -2
  157. package/src/renderers/WebGLRenderer.js +23 -18
  158. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
  159. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
  160. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
  161. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
  162. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
  163. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
  164. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
  165. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
  166. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
  167. package/src/renderers/shaders/ShaderChunk.js +4 -0
  168. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  169. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  170. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -0
  171. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
  172. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
  173. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
  174. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
  175. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -0
  176. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
  177. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
  178. package/src/renderers/webgl/WebGLAttributes.js +39 -5
  179. package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
  180. package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
  181. package/src/renderers/webgl/WebGLExtensions.js +1 -0
  182. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
  183. package/src/renderers/webgl/WebGLLights.js +11 -2
  184. package/src/renderers/webgl/WebGLProgram.js +20 -1
  185. package/src/renderers/webgl/WebGLPrograms.js +5 -0
  186. package/src/renderers/webgl/WebGLShadowMap.js +35 -0
  187. package/src/renderers/webgl/WebGLTextures.js +7 -11
  188. package/src/renderers/webgl/WebGLUniforms.js +11 -1
  189. package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
  190. package/src/renderers/webxr/WebXRManager.js +16 -0
  191. package/examples/jsm/objects/BatchedMesh.js +0 -586
package/build/three.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const REVISION = '158';
8
+ const REVISION = '160';
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 ReinhardToneMapping = 2;
64
64
  const CineonToneMapping = 3;
65
65
  const ACESFilmicToneMapping = 4;
66
66
  const CustomToneMapping = 5;
67
+ const AgXToneMapping = 6;
67
68
  const AttachedBindMode = 'attached';
68
69
  const DetachedBindMode = 'detached';
69
70
 
@@ -1628,22 +1629,6 @@ const ColorManagement = {
1628
1629
 
1629
1630
  _workingColorSpace: LinearSRGBColorSpace,
1630
1631
 
1631
- get legacyMode() {
1632
-
1633
- console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.' );
1634
-
1635
- return ! this.enabled;
1636
-
1637
- },
1638
-
1639
- set legacyMode( legacyMode ) {
1640
-
1641
- console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.' );
1642
-
1643
- this.enabled = ! legacyMode;
1644
-
1645
- },
1646
-
1647
1632
  get workingColorSpace() {
1648
1633
 
1649
1634
  return this._workingColorSpace;
@@ -3085,9 +3070,9 @@ class DataArrayTexture extends Texture {
3085
3070
 
3086
3071
  class WebGLArrayRenderTarget extends WebGLRenderTarget {
3087
3072
 
3088
- constructor( width = 1, height = 1, depth = 1 ) {
3073
+ constructor( width = 1, height = 1, depth = 1, options = {} ) {
3089
3074
 
3090
- super( width, height );
3075
+ super( width, height, options );
3091
3076
 
3092
3077
  this.isWebGLArrayRenderTarget = true;
3093
3078
 
@@ -3134,9 +3119,9 @@ class Data3DTexture extends Texture {
3134
3119
 
3135
3120
  class WebGL3DRenderTarget extends WebGLRenderTarget {
3136
3121
 
3137
- constructor( width = 1, height = 1, depth = 1 ) {
3122
+ constructor( width = 1, height = 1, depth = 1, options = {} ) {
3138
3123
 
3139
- super( width, height );
3124
+ super( width, height, options );
3140
3125
 
3141
3126
  this.isWebGL3DRenderTarget = true;
3142
3127
 
@@ -3427,7 +3412,7 @@ class Quaternion {
3427
3412
 
3428
3413
  }
3429
3414
 
3430
- setFromEuler( euler, update ) {
3415
+ setFromEuler( euler, update = true ) {
3431
3416
 
3432
3417
  const x = euler._x, y = euler._y, z = euler._z, order = euler._order;
3433
3418
 
@@ -3495,7 +3480,7 @@ class Quaternion {
3495
3480
 
3496
3481
  }
3497
3482
 
3498
- if ( update !== false ) this._onChangeCallback();
3483
+ if ( update === true ) this._onChangeCallback();
3499
3484
 
3500
3485
  return this;
3501
3486
 
@@ -3790,8 +3775,7 @@ class Quaternion {
3790
3775
  this._y = s * y + t * this._y;
3791
3776
  this._z = s * z + t * this._z;
3792
3777
 
3793
- this.normalize();
3794
- this._onChangeCallback();
3778
+ this.normalize(); // normalize calls _onChangeCallback()
3795
3779
 
3796
3780
  return this;
3797
3781
 
@@ -3879,6 +3863,8 @@ class Quaternion {
3879
3863
  this._z = attribute.getZ( index );
3880
3864
  this._w = attribute.getW( index );
3881
3865
 
3866
+ this._onChangeCallback();
3867
+
3882
3868
  return this;
3883
3869
 
3884
3870
  }
@@ -4414,9 +4400,9 @@ class Vector3 {
4414
4400
 
4415
4401
  projectOnPlane( planeNormal ) {
4416
4402
 
4417
- _vector$b.copy( this ).projectOnVector( planeNormal );
4403
+ _vector$c.copy( this ).projectOnVector( planeNormal );
4418
4404
 
4419
- return this.sub( _vector$b );
4405
+ return this.sub( _vector$c );
4420
4406
 
4421
4407
  }
4422
4408
 
@@ -4425,7 +4411,7 @@ class Vector3 {
4425
4411
  // reflect incident vector off plane orthogonal to normal
4426
4412
  // normal is assumed to have unit length
4427
4413
 
4428
- return this.sub( _vector$b.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
4414
+ return this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
4429
4415
 
4430
4416
  }
4431
4417
 
@@ -4627,7 +4613,7 @@ class Vector3 {
4627
4613
 
4628
4614
  }
4629
4615
 
4630
- const _vector$b = /*@__PURE__*/ new Vector3();
4616
+ const _vector$c = /*@__PURE__*/ new Vector3();
4631
4617
  const _quaternion$4 = /*@__PURE__*/ new Quaternion();
4632
4618
 
4633
4619
  class Box3 {
@@ -4656,7 +4642,7 @@ class Box3 {
4656
4642
 
4657
4643
  for ( let i = 0, il = array.length; i < il; i += 3 ) {
4658
4644
 
4659
- this.expandByPoint( _vector$a.fromArray( array, i ) );
4645
+ this.expandByPoint( _vector$b.fromArray( array, i ) );
4660
4646
 
4661
4647
  }
4662
4648
 
@@ -4670,7 +4656,7 @@ class Box3 {
4670
4656
 
4671
4657
  for ( let i = 0, il = attribute.count; i < il; i ++ ) {
4672
4658
 
4673
- this.expandByPoint( _vector$a.fromBufferAttribute( attribute, i ) );
4659
+ this.expandByPoint( _vector$b.fromBufferAttribute( attribute, i ) );
4674
4660
 
4675
4661
  }
4676
4662
 
@@ -4694,7 +4680,7 @@ class Box3 {
4694
4680
 
4695
4681
  setFromCenterAndSize( center, size ) {
4696
4682
 
4697
- const halfSize = _vector$a.copy( size ).multiplyScalar( 0.5 );
4683
+ const halfSize = _vector$b.copy( size ).multiplyScalar( 0.5 );
4698
4684
 
4699
4685
  this.min.copy( center ).sub( halfSize );
4700
4686
  this.max.copy( center ).add( halfSize );
@@ -4804,16 +4790,16 @@ class Box3 {
4804
4790
 
4805
4791
  if ( object.isMesh === true ) {
4806
4792
 
4807
- object.getVertexPosition( i, _vector$a );
4793
+ object.getVertexPosition( i, _vector$b );
4808
4794
 
4809
4795
  } else {
4810
4796
 
4811
- _vector$a.fromBufferAttribute( positionAttribute, i );
4797
+ _vector$b.fromBufferAttribute( positionAttribute, i );
4812
4798
 
4813
4799
  }
4814
4800
 
4815
- _vector$a.applyMatrix4( object.matrixWorld );
4816
- this.expandByPoint( _vector$a );
4801
+ _vector$b.applyMatrix4( object.matrixWorld );
4802
+ this.expandByPoint( _vector$b );
4817
4803
 
4818
4804
  }
4819
4805
 
@@ -4829,7 +4815,7 @@ class Box3 {
4829
4815
 
4830
4816
  }
4831
4817
 
4832
- _box$3.copy( object.boundingBox );
4818
+ _box$4.copy( object.boundingBox );
4833
4819
 
4834
4820
 
4835
4821
  } else {
@@ -4842,13 +4828,13 @@ class Box3 {
4842
4828
 
4843
4829
  }
4844
4830
 
4845
- _box$3.copy( geometry.boundingBox );
4831
+ _box$4.copy( geometry.boundingBox );
4846
4832
 
4847
4833
  }
4848
4834
 
4849
- _box$3.applyMatrix4( object.matrixWorld );
4835
+ _box$4.applyMatrix4( object.matrixWorld );
4850
4836
 
4851
- this.union( _box$3 );
4837
+ this.union( _box$4 );
4852
4838
 
4853
4839
  }
4854
4840
 
@@ -4907,10 +4893,10 @@ class Box3 {
4907
4893
  intersectsSphere( sphere ) {
4908
4894
 
4909
4895
  // Find the point on the AABB closest to the sphere center.
4910
- this.clampPoint( sphere.center, _vector$a );
4896
+ this.clampPoint( sphere.center, _vector$b );
4911
4897
 
4912
4898
  // If that point is inside the sphere, the AABB and sphere intersect.
4913
- return _vector$a.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
4899
+ return _vector$b.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
4914
4900
 
4915
4901
  }
4916
4902
 
@@ -5022,7 +5008,7 @@ class Box3 {
5022
5008
 
5023
5009
  distanceToPoint( point ) {
5024
5010
 
5025
- return this.clampPoint( point, _vector$a ).distanceTo( point );
5011
+ return this.clampPoint( point, _vector$b ).distanceTo( point );
5026
5012
 
5027
5013
  }
5028
5014
 
@@ -5036,7 +5022,7 @@ class Box3 {
5036
5022
 
5037
5023
  this.getCenter( target.center );
5038
5024
 
5039
- target.radius = this.getSize( _vector$a ).length() * 0.5;
5025
+ target.radius = this.getSize( _vector$b ).length() * 0.5;
5040
5026
 
5041
5027
  }
5042
5028
 
@@ -5114,9 +5100,9 @@ const _points = [
5114
5100
  /*@__PURE__*/ new Vector3()
5115
5101
  ];
5116
5102
 
5117
- const _vector$a = /*@__PURE__*/ new Vector3();
5103
+ const _vector$b = /*@__PURE__*/ new Vector3();
5118
5104
 
5119
- const _box$3 = /*@__PURE__*/ new Box3();
5105
+ const _box$4 = /*@__PURE__*/ new Box3();
5120
5106
 
5121
5107
  // triangle centered vertices
5122
5108
 
@@ -5161,7 +5147,7 @@ function satForAxes( axes, v0, v1, v2, extents ) {
5161
5147
 
5162
5148
  }
5163
5149
 
5164
- const _box$2 = /*@__PURE__*/ new Box3();
5150
+ const _box$3 = /*@__PURE__*/ new Box3();
5165
5151
  const _v1$6 = /*@__PURE__*/ new Vector3();
5166
5152
  const _v2$3 = /*@__PURE__*/ new Vector3();
5167
5153
 
@@ -5169,6 +5155,8 @@ class Sphere {
5169
5155
 
5170
5156
  constructor( center = new Vector3(), radius = - 1 ) {
5171
5157
 
5158
+ this.isSphere = true;
5159
+
5172
5160
  this.center = center;
5173
5161
  this.radius = radius;
5174
5162
 
@@ -5193,7 +5181,7 @@ class Sphere {
5193
5181
 
5194
5182
  } else {
5195
5183
 
5196
- _box$2.setFromPoints( points ).getCenter( center );
5184
+ _box$3.setFromPoints( points ).getCenter( center );
5197
5185
 
5198
5186
  }
5199
5187
 
@@ -5400,7 +5388,7 @@ class Sphere {
5400
5388
 
5401
5389
  }
5402
5390
 
5403
- const _vector$9 = /*@__PURE__*/ new Vector3();
5391
+ const _vector$a = /*@__PURE__*/ new Vector3();
5404
5392
  const _segCenter = /*@__PURE__*/ new Vector3();
5405
5393
  const _segDir = /*@__PURE__*/ new Vector3();
5406
5394
  const _diff = /*@__PURE__*/ new Vector3();
@@ -5452,7 +5440,7 @@ class Ray {
5452
5440
 
5453
5441
  recast( t ) {
5454
5442
 
5455
- this.origin.copy( this.at( t, _vector$9 ) );
5443
+ this.origin.copy( this.at( t, _vector$a ) );
5456
5444
 
5457
5445
  return this;
5458
5446
 
@@ -5482,7 +5470,7 @@ class Ray {
5482
5470
 
5483
5471
  distanceSqToPoint( point ) {
5484
5472
 
5485
- const directionDistance = _vector$9.subVectors( point, this.origin ).dot( this.direction );
5473
+ const directionDistance = _vector$a.subVectors( point, this.origin ).dot( this.direction );
5486
5474
 
5487
5475
  // point behind the ray
5488
5476
 
@@ -5492,9 +5480,9 @@ class Ray {
5492
5480
 
5493
5481
  }
5494
5482
 
5495
- _vector$9.copy( this.origin ).addScaledVector( this.direction, directionDistance );
5483
+ _vector$a.copy( this.origin ).addScaledVector( this.direction, directionDistance );
5496
5484
 
5497
- return _vector$9.distanceToSquared( point );
5485
+ return _vector$a.distanceToSquared( point );
5498
5486
 
5499
5487
  }
5500
5488
 
@@ -5619,9 +5607,9 @@ class Ray {
5619
5607
 
5620
5608
  intersectSphere( sphere, target ) {
5621
5609
 
5622
- _vector$9.subVectors( sphere.center, this.origin );
5623
- const tca = _vector$9.dot( this.direction );
5624
- const d2 = _vector$9.dot( _vector$9 ) - tca * tca;
5610
+ _vector$a.subVectors( sphere.center, this.origin );
5611
+ const tca = _vector$a.dot( this.direction );
5612
+ const d2 = _vector$a.dot( _vector$a ) - tca * tca;
5625
5613
  const radius2 = sphere.radius * sphere.radius;
5626
5614
 
5627
5615
  if ( d2 > radius2 ) return null;
@@ -5788,7 +5776,7 @@ class Ray {
5788
5776
 
5789
5777
  intersectsBox( box ) {
5790
5778
 
5791
- return this.intersectBox( box, _vector$9 ) !== null;
5779
+ return this.intersectBox( box, _vector$a ) !== null;
5792
5780
 
5793
5781
  }
5794
5782
 
@@ -6801,7 +6789,7 @@ const _x = /*@__PURE__*/ new Vector3();
6801
6789
  const _y = /*@__PURE__*/ new Vector3();
6802
6790
  const _z = /*@__PURE__*/ new Vector3();
6803
6791
 
6804
- const _matrix = /*@__PURE__*/ new Matrix4();
6792
+ const _matrix$1 = /*@__PURE__*/ new Matrix4();
6805
6793
  const _quaternion$3 = /*@__PURE__*/ new Quaternion();
6806
6794
 
6807
6795
  class Euler {
@@ -7036,9 +7024,9 @@ class Euler {
7036
7024
 
7037
7025
  setFromQuaternion( q, order, update ) {
7038
7026
 
7039
- _matrix.makeRotationFromQuaternion( q );
7027
+ _matrix$1.makeRotationFromQuaternion( q );
7040
7028
 
7041
- return this.setFromRotationMatrix( _matrix, order, update );
7029
+ return this.setFromRotationMatrix( _matrix$1, order, update );
7042
7030
 
7043
7031
  }
7044
7032
 
@@ -7260,9 +7248,9 @@ class Object3D extends EventDispatcher {
7260
7248
  this.matrixWorld = new Matrix4();
7261
7249
 
7262
7250
  this.matrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE;
7263
- this.matrixWorldNeedsUpdate = false;
7264
7251
 
7265
7252
  this.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE; // checked by the renderer
7253
+ this.matrixWorldNeedsUpdate = false;
7266
7254
 
7267
7255
  this.layers = new Layers();
7268
7256
  this.visible = true;
@@ -7279,6 +7267,10 @@ class Object3D extends EventDispatcher {
7279
7267
 
7280
7268
  }
7281
7269
 
7270
+ onBeforeShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}
7271
+
7272
+ onAfterShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}
7273
+
7282
7274
  onBeforeRender( /* renderer, scene, camera, geometry, material, group */ ) {}
7283
7275
 
7284
7276
  onAfterRender( /* renderer, scene, camera, geometry, material, group */ ) {}
@@ -7619,21 +7611,15 @@ class Object3D extends EventDispatcher {
7619
7611
 
7620
7612
  }
7621
7613
 
7622
- getObjectsByProperty( name, value ) {
7623
-
7624
- let result = [];
7614
+ getObjectsByProperty( name, value, result = [] ) {
7625
7615
 
7626
7616
  if ( this[ name ] === value ) result.push( this );
7627
7617
 
7628
- for ( let i = 0, l = this.children.length; i < l; i ++ ) {
7629
-
7630
- const childResult = this.children[ i ].getObjectsByProperty( name, value );
7618
+ const children = this.children;
7631
7619
 
7632
- if ( childResult.length > 0 ) {
7620
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
7633
7621
 
7634
- result = result.concat( childResult );
7635
-
7636
- }
7622
+ children[ i ].getObjectsByProperty( name, value, result );
7637
7623
 
7638
7624
  }
7639
7625
 
@@ -7881,6 +7867,56 @@ class Object3D extends EventDispatcher {
7881
7867
 
7882
7868
  }
7883
7869
 
7870
+ if ( this.isBatchedMesh ) {
7871
+
7872
+ object.type = 'BatchedMesh';
7873
+ object.perObjectFrustumCulled = this.perObjectFrustumCulled;
7874
+ object.sortObjects = this.sortObjects;
7875
+
7876
+ object.drawRanges = this._drawRanges;
7877
+ object.reservedRanges = this._reservedRanges;
7878
+
7879
+ object.visibility = this._visibility;
7880
+ object.active = this._active;
7881
+ object.bounds = this._bounds.map( bound => ( {
7882
+ boxInitialized: bound.boxInitialized,
7883
+ boxMin: bound.box.min.toArray(),
7884
+ boxMax: bound.box.max.toArray(),
7885
+
7886
+ sphereInitialized: bound.sphereInitialized,
7887
+ sphereRadius: bound.sphere.radius,
7888
+ sphereCenter: bound.sphere.center.toArray()
7889
+ } ) );
7890
+
7891
+ object.maxGeometryCount = this._maxGeometryCount;
7892
+ object.maxVertexCount = this._maxVertexCount;
7893
+ object.maxIndexCount = this._maxIndexCount;
7894
+
7895
+ object.geometryInitialized = this._geometryInitialized;
7896
+ object.geometryCount = this._geometryCount;
7897
+
7898
+ object.matricesTexture = this._matricesTexture.toJSON( meta );
7899
+
7900
+ if ( this.boundingSphere !== null ) {
7901
+
7902
+ object.boundingSphere = {
7903
+ center: object.boundingSphere.center.toArray(),
7904
+ radius: object.boundingSphere.radius
7905
+ };
7906
+
7907
+ }
7908
+
7909
+ if ( this.boundingBox !== null ) {
7910
+
7911
+ object.boundingBox = {
7912
+ min: object.boundingBox.min.toArray(),
7913
+ max: object.boundingBox.max.toArray()
7914
+ };
7915
+
7916
+ }
7917
+
7918
+ }
7919
+
7884
7920
  //
7885
7921
 
7886
7922
  function serialize( library, element ) {
@@ -8081,9 +8117,9 @@ class Object3D extends EventDispatcher {
8081
8117
  this.matrixWorld.copy( source.matrixWorld );
8082
8118
 
8083
8119
  this.matrixAutoUpdate = source.matrixAutoUpdate;
8084
- this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
8085
8120
 
8086
8121
  this.matrixWorldAutoUpdate = source.matrixWorldAutoUpdate;
8122
+ this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;
8087
8123
 
8088
8124
  this.layers.mask = source.layers.mask;
8089
8125
  this.visible = source.visible;
@@ -8179,9 +8215,8 @@ class Triangle {
8179
8215
  // collinear or singular triangle
8180
8216
  if ( denom === 0 ) {
8181
8217
 
8182
- // arbitrary location outside of triangle?
8183
- // not sure if this is the best idea, maybe should be returning undefined
8184
- return target.set( - 2, - 1, - 1 );
8218
+ target.set( 0, 0, 0 );
8219
+ return null;
8185
8220
 
8186
8221
  }
8187
8222
 
@@ -8196,7 +8231,12 @@ class Triangle {
8196
8231
 
8197
8232
  static containsPoint( point, a, b, c ) {
8198
8233
 
8199
- this.getBarycoord( point, a, b, c, _v3$1 );
8234
+ // if the triangle is degenerate then we can't contain a point
8235
+ if ( this.getBarycoord( point, a, b, c, _v3$1 ) === null ) {
8236
+
8237
+ return false;
8238
+
8239
+ }
8200
8240
 
8201
8241
  return ( _v3$1.x >= 0 ) && ( _v3$1.y >= 0 ) && ( ( _v3$1.x + _v3$1.y ) <= 1 );
8202
8242
 
@@ -8218,7 +8258,15 @@ class Triangle {
8218
8258
 
8219
8259
  static getInterpolation( point, p1, p2, p3, v1, v2, v3, target ) {
8220
8260
 
8221
- this.getBarycoord( point, p1, p2, p3, _v3$1 );
8261
+ if ( this.getBarycoord( point, p1, p2, p3, _v3$1 ) === null ) {
8262
+
8263
+ target.x = 0;
8264
+ target.y = 0;
8265
+ if ( 'z' in target ) target.z = 0;
8266
+ if ( 'w' in target ) target.w = 0;
8267
+ return null;
8268
+
8269
+ }
8222
8270
 
8223
8271
  target.setScalar( 0 );
8224
8272
  target.addScaledVector( v1, _v3$1.x );
@@ -9824,7 +9872,7 @@ const DataUtils = {
9824
9872
  fromHalfFloat: fromHalfFloat,
9825
9873
  };
9826
9874
 
9827
- const _vector$8 = /*@__PURE__*/ new Vector3();
9875
+ const _vector$9 = /*@__PURE__*/ new Vector3();
9828
9876
  const _vector2$1 = /*@__PURE__*/ new Vector2();
9829
9877
 
9830
9878
  class BufferAttribute {
@@ -9847,7 +9895,8 @@ class BufferAttribute {
9847
9895
  this.normalized = normalized;
9848
9896
 
9849
9897
  this.usage = StaticDrawUsage;
9850
- this.updateRange = { offset: 0, count: - 1 };
9898
+ this._updateRange = { offset: 0, count: - 1 };
9899
+ this.updateRanges = [];
9851
9900
  this.gpuType = FloatType;
9852
9901
 
9853
9902
  this.version = 0;
@@ -9862,6 +9911,13 @@ class BufferAttribute {
9862
9911
 
9863
9912
  }
9864
9913
 
9914
+ get updateRange() {
9915
+
9916
+ console.warn( 'THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
9917
+ return this._updateRange;
9918
+
9919
+ }
9920
+
9865
9921
  setUsage( value ) {
9866
9922
 
9867
9923
  this.usage = value;
@@ -9870,6 +9926,18 @@ class BufferAttribute {
9870
9926
 
9871
9927
  }
9872
9928
 
9929
+ addUpdateRange( start, count ) {
9930
+
9931
+ this.updateRanges.push( { start, count } );
9932
+
9933
+ }
9934
+
9935
+ clearUpdateRanges() {
9936
+
9937
+ this.updateRanges.length = 0;
9938
+
9939
+ }
9940
+
9873
9941
  copy( source ) {
9874
9942
 
9875
9943
  this.name = source.name;
@@ -9925,10 +9993,10 @@ class BufferAttribute {
9925
9993
 
9926
9994
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9927
9995
 
9928
- _vector$8.fromBufferAttribute( this, i );
9929
- _vector$8.applyMatrix3( m );
9996
+ _vector$9.fromBufferAttribute( this, i );
9997
+ _vector$9.applyMatrix3( m );
9930
9998
 
9931
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
9999
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9932
10000
 
9933
10001
  }
9934
10002
 
@@ -9942,11 +10010,11 @@ class BufferAttribute {
9942
10010
 
9943
10011
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9944
10012
 
9945
- _vector$8.fromBufferAttribute( this, i );
10013
+ _vector$9.fromBufferAttribute( this, i );
9946
10014
 
9947
- _vector$8.applyMatrix4( m );
10015
+ _vector$9.applyMatrix4( m );
9948
10016
 
9949
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
10017
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9950
10018
 
9951
10019
  }
9952
10020
 
@@ -9958,11 +10026,11 @@ class BufferAttribute {
9958
10026
 
9959
10027
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9960
10028
 
9961
- _vector$8.fromBufferAttribute( this, i );
10029
+ _vector$9.fromBufferAttribute( this, i );
9962
10030
 
9963
- _vector$8.applyNormalMatrix( m );
10031
+ _vector$9.applyNormalMatrix( m );
9964
10032
 
9965
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
10033
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9966
10034
 
9967
10035
  }
9968
10036
 
@@ -9974,11 +10042,11 @@ class BufferAttribute {
9974
10042
 
9975
10043
  for ( let i = 0, l = this.count; i < l; i ++ ) {
9976
10044
 
9977
- _vector$8.fromBufferAttribute( this, i );
10045
+ _vector$9.fromBufferAttribute( this, i );
9978
10046
 
9979
- _vector$8.transformDirection( m );
10047
+ _vector$9.transformDirection( m );
9980
10048
 
9981
- this.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
10049
+ this.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );
9982
10050
 
9983
10051
  }
9984
10052
 
@@ -10180,7 +10248,6 @@ class BufferAttribute {
10180
10248
 
10181
10249
  if ( this.name !== '' ) data.name = this.name;
10182
10250
  if ( this.usage !== StaticDrawUsage ) data.usage = this.usage;
10183
- if ( this.updateRange.offset !== 0 || this.updateRange.count !== - 1 ) data.updateRange = this.updateRange;
10184
10251
 
10185
10252
  return data;
10186
10253
 
@@ -10438,9 +10505,9 @@ let _id$2 = 0;
10438
10505
  const _m1 = /*@__PURE__*/ new Matrix4();
10439
10506
  const _obj = /*@__PURE__*/ new Object3D();
10440
10507
  const _offset = /*@__PURE__*/ new Vector3();
10441
- const _box$1 = /*@__PURE__*/ new Box3();
10508
+ const _box$2 = /*@__PURE__*/ new Box3();
10442
10509
  const _boxMorphTargets = /*@__PURE__*/ new Box3();
10443
- const _vector$7 = /*@__PURE__*/ new Vector3();
10510
+ const _vector$8 = /*@__PURE__*/ new Vector3();
10444
10511
 
10445
10512
  class BufferGeometry extends EventDispatcher {
10446
10513
 
@@ -10745,20 +10812,20 @@ class BufferGeometry extends EventDispatcher {
10745
10812
  for ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
10746
10813
 
10747
10814
  const morphAttribute = morphAttributesPosition[ i ];
10748
- _box$1.setFromBufferAttribute( morphAttribute );
10815
+ _box$2.setFromBufferAttribute( morphAttribute );
10749
10816
 
10750
10817
  if ( this.morphTargetsRelative ) {
10751
10818
 
10752
- _vector$7.addVectors( this.boundingBox.min, _box$1.min );
10753
- this.boundingBox.expandByPoint( _vector$7 );
10819
+ _vector$8.addVectors( this.boundingBox.min, _box$2.min );
10820
+ this.boundingBox.expandByPoint( _vector$8 );
10754
10821
 
10755
- _vector$7.addVectors( this.boundingBox.max, _box$1.max );
10756
- this.boundingBox.expandByPoint( _vector$7 );
10822
+ _vector$8.addVectors( this.boundingBox.max, _box$2.max );
10823
+ this.boundingBox.expandByPoint( _vector$8 );
10757
10824
 
10758
10825
  } else {
10759
10826
 
10760
- this.boundingBox.expandByPoint( _box$1.min );
10761
- this.boundingBox.expandByPoint( _box$1.max );
10827
+ this.boundingBox.expandByPoint( _box$2.min );
10828
+ this.boundingBox.expandByPoint( _box$2.max );
10762
10829
 
10763
10830
  }
10764
10831
 
@@ -10807,7 +10874,7 @@ class BufferGeometry extends EventDispatcher {
10807
10874
 
10808
10875
  const center = this.boundingSphere.center;
10809
10876
 
10810
- _box$1.setFromBufferAttribute( position );
10877
+ _box$2.setFromBufferAttribute( position );
10811
10878
 
10812
10879
  // process morph attributes if present
10813
10880
 
@@ -10820,16 +10887,16 @@ class BufferGeometry extends EventDispatcher {
10820
10887
 
10821
10888
  if ( this.morphTargetsRelative ) {
10822
10889
 
10823
- _vector$7.addVectors( _box$1.min, _boxMorphTargets.min );
10824
- _box$1.expandByPoint( _vector$7 );
10890
+ _vector$8.addVectors( _box$2.min, _boxMorphTargets.min );
10891
+ _box$2.expandByPoint( _vector$8 );
10825
10892
 
10826
- _vector$7.addVectors( _box$1.max, _boxMorphTargets.max );
10827
- _box$1.expandByPoint( _vector$7 );
10893
+ _vector$8.addVectors( _box$2.max, _boxMorphTargets.max );
10894
+ _box$2.expandByPoint( _vector$8 );
10828
10895
 
10829
10896
  } else {
10830
10897
 
10831
- _box$1.expandByPoint( _boxMorphTargets.min );
10832
- _box$1.expandByPoint( _boxMorphTargets.max );
10898
+ _box$2.expandByPoint( _boxMorphTargets.min );
10899
+ _box$2.expandByPoint( _boxMorphTargets.max );
10833
10900
 
10834
10901
  }
10835
10902
 
@@ -10837,7 +10904,7 @@ class BufferGeometry extends EventDispatcher {
10837
10904
 
10838
10905
  }
10839
10906
 
10840
- _box$1.getCenter( center );
10907
+ _box$2.getCenter( center );
10841
10908
 
10842
10909
  // second, try to find a boundingSphere with a radius smaller than the
10843
10910
  // boundingSphere of the boundingBox: sqrt(3) smaller in the best case
@@ -10846,9 +10913,9 @@ class BufferGeometry extends EventDispatcher {
10846
10913
 
10847
10914
  for ( let i = 0, il = position.count; i < il; i ++ ) {
10848
10915
 
10849
- _vector$7.fromBufferAttribute( position, i );
10916
+ _vector$8.fromBufferAttribute( position, i );
10850
10917
 
10851
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$7 ) );
10918
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
10852
10919
 
10853
10920
  }
10854
10921
 
@@ -10863,16 +10930,16 @@ class BufferGeometry extends EventDispatcher {
10863
10930
 
10864
10931
  for ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
10865
10932
 
10866
- _vector$7.fromBufferAttribute( morphAttribute, j );
10933
+ _vector$8.fromBufferAttribute( morphAttribute, j );
10867
10934
 
10868
10935
  if ( morphTargetsRelative ) {
10869
10936
 
10870
10937
  _offset.fromBufferAttribute( position, j );
10871
- _vector$7.add( _offset );
10938
+ _vector$8.add( _offset );
10872
10939
 
10873
10940
  }
10874
10941
 
10875
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$7 ) );
10942
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$8 ) );
10876
10943
 
10877
10944
  }
10878
10945
 
@@ -11155,11 +11222,11 @@ class BufferGeometry extends EventDispatcher {
11155
11222
 
11156
11223
  for ( let i = 0, il = normals.count; i < il; i ++ ) {
11157
11224
 
11158
- _vector$7.fromBufferAttribute( normals, i );
11225
+ _vector$8.fromBufferAttribute( normals, i );
11159
11226
 
11160
- _vector$7.normalize();
11227
+ _vector$8.normalize();
11161
11228
 
11162
- normals.setXYZ( i, _vector$7.x, _vector$7.y, _vector$7.z );
11229
+ normals.setXYZ( i, _vector$8.x, _vector$8.y, _vector$8.z );
11163
11230
 
11164
11231
  }
11165
11232
 
@@ -11501,7 +11568,7 @@ class BufferGeometry extends EventDispatcher {
11501
11568
 
11502
11569
  const _inverseMatrix$3 = /*@__PURE__*/ new Matrix4();
11503
11570
  const _ray$3 = /*@__PURE__*/ new Ray();
11504
- const _sphere$5 = /*@__PURE__*/ new Sphere();
11571
+ const _sphere$6 = /*@__PURE__*/ new Sphere();
11505
11572
  const _sphereHitAt = /*@__PURE__*/ new Vector3();
11506
11573
 
11507
11574
  const _vA$1 = /*@__PURE__*/ new Vector3();
@@ -11649,16 +11716,16 @@ class Mesh extends Object3D {
11649
11716
 
11650
11717
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
11651
11718
 
11652
- _sphere$5.copy( geometry.boundingSphere );
11653
- _sphere$5.applyMatrix4( matrixWorld );
11719
+ _sphere$6.copy( geometry.boundingSphere );
11720
+ _sphere$6.applyMatrix4( matrixWorld );
11654
11721
 
11655
11722
  // check distance from ray origin to bounding sphere
11656
11723
 
11657
11724
  _ray$3.copy( raycaster.ray ).recast( raycaster.near );
11658
11725
 
11659
- if ( _sphere$5.containsPoint( _ray$3.origin ) === false ) {
11726
+ if ( _sphere$6.containsPoint( _ray$3.origin ) === false ) {
11660
11727
 
11661
- if ( _ray$3.intersectSphere( _sphere$5, _sphereHitAt ) === null ) return;
11728
+ if ( _ray$3.intersectSphere( _sphere$6, _sphereHitAt ) === null ) return;
11662
11729
 
11663
11730
  if ( _ray$3.origin.distanceToSquared( _sphereHitAt ) > ( raycaster.far - raycaster.near ) ** 2 ) return;
11664
11731
 
@@ -12228,7 +12295,8 @@ class ShaderMaterial extends Material {
12228
12295
  derivatives: false, // set to use derivatives
12229
12296
  fragDepth: false, // set to use fragment depth values
12230
12297
  drawBuffers: false, // set to use draw buffers
12231
- shaderTextureLOD: false // set to use shader texture LOD
12298
+ shaderTextureLOD: false, // set to use shader texture LOD
12299
+ clipCullDistance: false // set to use vertex shader clipping
12232
12300
  };
12233
12301
 
12234
12302
  // When rendered geometry doesn't include these attributes but the material does,
@@ -13211,8 +13279,8 @@ class Plane {
13211
13279
 
13212
13280
  }
13213
13281
 
13214
- const _sphere$4 = /*@__PURE__*/ new Sphere();
13215
- const _vector$6 = /*@__PURE__*/ new Vector3();
13282
+ const _sphere$5 = /*@__PURE__*/ new Sphere();
13283
+ const _vector$7 = /*@__PURE__*/ new Vector3();
13216
13284
 
13217
13285
  class Frustum {
13218
13286
 
@@ -13290,7 +13358,7 @@ class Frustum {
13290
13358
 
13291
13359
  if ( object.boundingSphere === null ) object.computeBoundingSphere();
13292
13360
 
13293
- _sphere$4.copy( object.boundingSphere ).applyMatrix4( object.matrixWorld );
13361
+ _sphere$5.copy( object.boundingSphere ).applyMatrix4( object.matrixWorld );
13294
13362
 
13295
13363
  } else {
13296
13364
 
@@ -13298,21 +13366,21 @@ class Frustum {
13298
13366
 
13299
13367
  if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
13300
13368
 
13301
- _sphere$4.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
13369
+ _sphere$5.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
13302
13370
 
13303
13371
  }
13304
13372
 
13305
- return this.intersectsSphere( _sphere$4 );
13373
+ return this.intersectsSphere( _sphere$5 );
13306
13374
 
13307
13375
  }
13308
13376
 
13309
13377
  intersectsSprite( sprite ) {
13310
13378
 
13311
- _sphere$4.center.set( 0, 0, 0 );
13312
- _sphere$4.radius = 0.7071067811865476;
13313
- _sphere$4.applyMatrix4( sprite.matrixWorld );
13379
+ _sphere$5.center.set( 0, 0, 0 );
13380
+ _sphere$5.radius = 0.7071067811865476;
13381
+ _sphere$5.applyMatrix4( sprite.matrixWorld );
13314
13382
 
13315
- return this.intersectsSphere( _sphere$4 );
13383
+ return this.intersectsSphere( _sphere$5 );
13316
13384
 
13317
13385
  }
13318
13386
 
@@ -13348,11 +13416,11 @@ class Frustum {
13348
13416
 
13349
13417
  // corner at max distance
13350
13418
 
13351
- _vector$6.x = plane.normal.x > 0 ? box.max.x : box.min.x;
13352
- _vector$6.y = plane.normal.y > 0 ? box.max.y : box.min.y;
13353
- _vector$6.z = plane.normal.z > 0 ? box.max.z : box.min.z;
13419
+ _vector$7.x = plane.normal.x > 0 ? box.max.x : box.min.x;
13420
+ _vector$7.y = plane.normal.y > 0 ? box.max.y : box.min.y;
13421
+ _vector$7.z = plane.normal.z > 0 ? box.max.z : box.min.z;
13354
13422
 
13355
- if ( plane.distanceToPoint( _vector$6 ) < 0 ) {
13423
+ if ( plane.distanceToPoint( _vector$7 ) < 0 ) {
13356
13424
 
13357
13425
  return false;
13358
13426
 
@@ -13452,6 +13520,7 @@ function WebGLAttributes( gl, capabilities ) {
13452
13520
 
13453
13521
  const array = attribute.array;
13454
13522
  const usage = attribute.usage;
13523
+ const size = array.byteLength;
13455
13524
 
13456
13525
  const buffer = gl.createBuffer();
13457
13526
 
@@ -13520,7 +13589,8 @@ function WebGLAttributes( gl, capabilities ) {
13520
13589
  buffer: buffer,
13521
13590
  type: type,
13522
13591
  bytesPerElement: array.BYTES_PER_ELEMENT,
13523
- version: attribute.version
13592
+ version: attribute.version,
13593
+ size: size
13524
13594
  };
13525
13595
 
13526
13596
  }
@@ -13528,17 +13598,43 @@ function WebGLAttributes( gl, capabilities ) {
13528
13598
  function updateBuffer( buffer, attribute, bufferType ) {
13529
13599
 
13530
13600
  const array = attribute.array;
13531
- const updateRange = attribute.updateRange;
13601
+ const updateRange = attribute._updateRange; // deprecated
13602
+ const updateRanges = attribute.updateRanges;
13532
13603
 
13533
13604
  gl.bindBuffer( bufferType, buffer );
13534
13605
 
13535
- if ( updateRange.count === - 1 ) {
13606
+ if ( updateRange.count === - 1 && updateRanges.length === 0 ) {
13536
13607
 
13537
13608
  // Not using update ranges
13538
-
13539
13609
  gl.bufferSubData( bufferType, 0, array );
13540
13610
 
13541
- } else {
13611
+ }
13612
+
13613
+ if ( updateRanges.length !== 0 ) {
13614
+
13615
+ for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
13616
+
13617
+ const range = updateRanges[ i ];
13618
+ if ( isWebGL2 ) {
13619
+
13620
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13621
+ array, range.start, range.count );
13622
+
13623
+ } else {
13624
+
13625
+ gl.bufferSubData( bufferType, range.start * array.BYTES_PER_ELEMENT,
13626
+ array.subarray( range.start, range.start + range.count ) );
13627
+
13628
+ }
13629
+
13630
+ }
13631
+
13632
+ attribute.clearUpdateRanges();
13633
+
13634
+ }
13635
+
13636
+ // deprecated
13637
+ if ( updateRange.count !== - 1 ) {
13542
13638
 
13543
13639
  if ( isWebGL2 ) {
13544
13640
 
@@ -13617,6 +13713,12 @@ function WebGLAttributes( gl, capabilities ) {
13617
13713
 
13618
13714
  } else if ( data.version < attribute.version ) {
13619
13715
 
13716
+ if ( data.size !== attribute.array.byteLength ) {
13717
+
13718
+ throw new Error( 'THREE.WebGLAttributes: The size of the buffer attribute\'s array buffer does not match the original size. Resizing buffer attributes is not supported.' );
13719
+
13720
+ }
13721
+
13620
13722
  updateBuffer( data.buffer, attribute, bufferType );
13621
13723
 
13622
13724
  data.version = attribute.version;
@@ -13745,6 +13847,10 @@ var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D(
13745
13847
 
13746
13848
  var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";
13747
13849
 
13850
+ var batching_pars_vertex = "#ifdef USE_BATCHING\n\tattribute float batchId;\n\tuniform highp sampler2D batchingTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif";
13851
+
13852
+ var batching_vertex = "#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( batchId );\n#endif";
13853
+
13748
13854
  var begin_vertex = "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif";
13749
13855
 
13750
13856
  var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif";
@@ -13773,9 +13879,9 @@ var color_vertex = "#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#el
13773
13879
 
13774
13880
  var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
13775
13881
 
13776
- var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
13882
+ var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif";
13777
13883
 
13778
- var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
13884
+ var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif";
13779
13885
 
13780
13886
  var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif";
13781
13887
 
@@ -13829,7 +13935,7 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor
13829
13935
 
13830
13936
  var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong";
13831
13937
 
13832
- var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif";
13938
+ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
13833
13939
 
13834
13940
  var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
13835
13941
 
@@ -13893,7 +13999,7 @@ var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normaliz
13893
13999
 
13894
14000
  var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif";
13895
14001
 
13896
- var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;";
14002
+ var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;";
13897
14003
 
13898
14004
  var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif";
13899
14005
 
@@ -13913,7 +14019,7 @@ var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n
13913
14019
 
13914
14020
  var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
13915
14021
 
13916
- var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif";
14022
+ var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif";
13917
14023
 
13918
14024
  var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif";
13919
14025
 
@@ -13925,7 +14031,7 @@ var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D spe
13925
14031
 
13926
14032
  var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif";
13927
14033
 
13928
- 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}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
14034
+ 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 = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\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\treturn color;\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }";
13929
14035
 
13930
14036
  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";
13931
14037
 
@@ -13937,7 +14043,7 @@ var uv_pars_vertex = "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvary
13937
14043
 
13938
14044
  var uv_vertex = "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif";
13939
14045
 
13940
- var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif";
14046
+ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif";
13941
14047
 
13942
14048
  const vertex$h = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
13943
14049
 
@@ -13951,11 +14057,11 @@ const vertex$f = "varying vec3 vWorldDirection;\n#include <common>\nvoid main()
13951
14057
 
13952
14058
  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}";
13953
14059
 
13954
- const vertex$e = "#include <common>\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 <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}";
14060
+ 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}";
13955
14061
 
13956
14062
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\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}";
13957
14063
 
13958
- const vertex$d = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\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 <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}";
14064
+ 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}";
13959
14065
 
13960
14066
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\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}";
13961
14067
 
@@ -13967,31 +14073,31 @@ const vertex$b = "uniform float scale;\nattribute float lineDistance;\nvarying f
13967
14073
 
13968
14074
  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\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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}";
13969
14075
 
13970
- const vertex$a = "#include <common>\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#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}";
14076
+ 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}";
13971
14077
 
13972
14078
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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}";
13973
14079
 
13974
- const vertex$9 = "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\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 <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}";
14080
+ 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}";
13975
14081
 
13976
14082
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <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}";
13977
14083
 
13978
- const vertex$8 = "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\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 <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}";
14084
+ 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}";
13979
14085
 
13980
14086
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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}";
13981
14087
 
13982
- 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 <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 <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}";
14088
+ 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}";
13983
14089
 
13984
14090
  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\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 ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}";
13985
14091
 
13986
- const vertex$6 = "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\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 <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}";
14092
+ 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}";
13987
14093
 
13988
14094
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <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}";
13989
14095
 
13990
- const vertex$5 = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <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 <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}";
14096
+ 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}";
13991
14097
 
13992
14098
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <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}";
13993
14099
 
13994
- const vertex$4 = "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\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 <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}";
14100
+ 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}";
13995
14101
 
13996
14102
  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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <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}";
13997
14103
 
@@ -13999,7 +14105,7 @@ const vertex$3 = "uniform float size;\nuniform float scale;\n#include <common>\n
13999
14105
 
14000
14106
  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\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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}";
14001
14107
 
14002
- const vertex$2 = "#include <common>\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 <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}";
14108
+ 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}";
14003
14109
 
14004
14110
  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}";
14005
14111
 
@@ -14016,6 +14122,8 @@ const ShaderChunk = {
14016
14122
  alphatest_pars_fragment: alphatest_pars_fragment,
14017
14123
  aomap_fragment: aomap_fragment,
14018
14124
  aomap_pars_fragment: aomap_pars_fragment,
14125
+ batching_pars_vertex: batching_pars_vertex,
14126
+ batching_vertex: batching_vertex,
14019
14127
  begin_vertex: begin_vertex,
14020
14128
  beginnormal_vertex: beginnormal_vertex,
14021
14129
  bsdfs: bsdfs,
@@ -15629,11 +15737,42 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
15629
15737
 
15630
15738
  }
15631
15739
 
15740
+ function renderMultiDraw( starts, counts, drawCount ) {
15741
+
15742
+ if ( drawCount === 0 ) return;
15743
+
15744
+ const extension = extensions.get( 'WEBGL_multi_draw' );
15745
+ if ( extension === null ) {
15746
+
15747
+ for ( let i = 0; i < drawCount; i ++ ) {
15748
+
15749
+ this.render( starts[ i ], counts[ i ] );
15750
+
15751
+ }
15752
+
15753
+ } else {
15754
+
15755
+ extension.multiDrawArraysWEBGL( mode, starts, 0, counts, 0, drawCount );
15756
+
15757
+ let elementCount = 0;
15758
+ for ( let i = 0; i < drawCount; i ++ ) {
15759
+
15760
+ elementCount += counts[ i ];
15761
+
15762
+ }
15763
+
15764
+ info.update( elementCount, mode, 1 );
15765
+
15766
+ }
15767
+
15768
+ }
15769
+
15632
15770
  //
15633
15771
 
15634
15772
  this.setMode = setMode;
15635
15773
  this.render = render;
15636
15774
  this.renderInstances = renderInstances;
15775
+ this.renderMultiDraw = renderMultiDraw;
15637
15776
 
15638
15777
  }
15639
15778
 
@@ -15943,7 +16082,7 @@ function WebGLCubeMaps( renderer ) {
15943
16082
 
15944
16083
  function get( texture ) {
15945
16084
 
15946
- if ( texture && texture.isTexture && texture.isRenderTargetTexture === false ) {
16085
+ if ( texture && texture.isTexture ) {
15947
16086
 
15948
16087
  const mapping = texture.mapping;
15949
16088
 
@@ -17211,6 +17350,7 @@ function WebGLExtensions( gl ) {
17211
17350
  if ( capabilities.isWebGL2 ) {
17212
17351
 
17213
17352
  getExtension( 'EXT_color_buffer_float' );
17353
+ getExtension( 'WEBGL_clip_cull_distance' );
17214
17354
 
17215
17355
  } else {
17216
17356
 
@@ -17515,12 +17655,43 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
17515
17655
 
17516
17656
  }
17517
17657
 
17658
+ function renderMultiDraw( starts, counts, drawCount ) {
17659
+
17660
+ if ( drawCount === 0 ) return;
17661
+
17662
+ const extension = extensions.get( 'WEBGL_multi_draw' );
17663
+ if ( extension === null ) {
17664
+
17665
+ for ( let i = 0; i < drawCount; i ++ ) {
17666
+
17667
+ this.render( starts[ i ] / bytesPerElement, counts[ i ] );
17668
+
17669
+ }
17670
+
17671
+ } else {
17672
+
17673
+ extension.multiDrawElementsWEBGL( mode, counts, 0, type, starts, 0, drawCount );
17674
+
17675
+ let elementCount = 0;
17676
+ for ( let i = 0; i < drawCount; i ++ ) {
17677
+
17678
+ elementCount += counts[ i ];
17679
+
17680
+ }
17681
+
17682
+ info.update( elementCount, mode, 1 );
17683
+
17684
+ }
17685
+
17686
+ }
17687
+
17518
17688
  //
17519
17689
 
17520
17690
  this.setMode = setMode;
17521
17691
  this.setIndex = setIndex;
17522
17692
  this.render = render;
17523
17693
  this.renderInstances = renderInstances;
17694
+ this.renderMultiDraw = renderMultiDraw;
17524
17695
 
17525
17696
  }
17526
17697
 
@@ -18073,6 +18244,60 @@ function WebGLObjects( gl, geometries, attributes, info ) {
18073
18244
 
18074
18245
  }
18075
18246
 
18247
+ class DepthTexture extends Texture {
18248
+
18249
+ constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
18250
+
18251
+ format = format !== undefined ? format : DepthFormat;
18252
+
18253
+ if ( format !== DepthFormat && format !== DepthStencilFormat ) {
18254
+
18255
+ throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
18256
+
18257
+ }
18258
+
18259
+ if ( type === undefined && format === DepthFormat ) type = UnsignedIntType;
18260
+ if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
18261
+
18262
+ super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
18263
+
18264
+ this.isDepthTexture = true;
18265
+
18266
+ this.image = { width: width, height: height };
18267
+
18268
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
18269
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
18270
+
18271
+ this.flipY = false;
18272
+ this.generateMipmaps = false;
18273
+
18274
+ this.compareFunction = null;
18275
+
18276
+ }
18277
+
18278
+
18279
+ copy( source ) {
18280
+
18281
+ super.copy( source );
18282
+
18283
+ this.compareFunction = source.compareFunction;
18284
+
18285
+ return this;
18286
+
18287
+ }
18288
+
18289
+ toJSON( meta ) {
18290
+
18291
+ const data = super.toJSON( meta );
18292
+
18293
+ if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction;
18294
+
18295
+ return data;
18296
+
18297
+ }
18298
+
18299
+ }
18300
+
18076
18301
  /**
18077
18302
  * Uniforms of a program.
18078
18303
  * Those form a tree structure with a special top-level container for the root,
@@ -18118,6 +18343,10 @@ function WebGLObjects( gl, geometries, attributes, info ) {
18118
18343
 
18119
18344
 
18120
18345
  const emptyTexture = /*@__PURE__*/ new Texture();
18346
+
18347
+ const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
18348
+ emptyShadowTexture.compareFunction = LessEqualCompare;
18349
+
18121
18350
  const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
18122
18351
  const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
18123
18352
  const emptyCubeTexture = /*@__PURE__*/ new CubeTexture();
@@ -18634,7 +18863,9 @@ function setValueT1( gl, v, textures ) {
18634
18863
 
18635
18864
  }
18636
18865
 
18637
- textures.setTexture2D( v || emptyTexture, unit );
18866
+ const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
18867
+
18868
+ textures.setTexture2D( v || emptyTexture2D, unit );
18638
18869
 
18639
18870
  }
18640
18871
 
@@ -19018,6 +19249,7 @@ class SingleUniform {
19018
19249
  this.id = id;
19019
19250
  this.addr = addr;
19020
19251
  this.cache = [];
19252
+ this.type = activeInfo.type;
19021
19253
  this.setValue = getSingularSetter( activeInfo.type );
19022
19254
 
19023
19255
  // this.path = activeInfo.name; // DEBUG
@@ -19033,6 +19265,7 @@ class PureArrayUniform {
19033
19265
  this.id = id;
19034
19266
  this.addr = addr;
19035
19267
  this.cache = [];
19268
+ this.type = activeInfo.type;
19036
19269
  this.size = activeInfo.size;
19037
19270
  this.setValue = getPureArraySetter( activeInfo.type );
19038
19271
 
@@ -19341,6 +19574,10 @@ function getToneMappingFunction( functionName, toneMapping ) {
19341
19574
  toneMappingName = 'ACESFilmic';
19342
19575
  break;
19343
19576
 
19577
+ case AgXToneMapping:
19578
+ toneMappingName = 'AgX';
19579
+ break;
19580
+
19344
19581
  case CustomToneMapping:
19345
19582
  toneMappingName = 'Custom';
19346
19583
  break;
@@ -19368,6 +19605,16 @@ function generateExtensions( parameters ) {
19368
19605
 
19369
19606
  }
19370
19607
 
19608
+ function generateVertexExtensions( parameters ) {
19609
+
19610
+ const chunks = [
19611
+ parameters.extensionClipCullDistance ? '#extension GL_ANGLE_clip_cull_distance : require' : ''
19612
+ ];
19613
+
19614
+ return chunks.filter( filterEmptyLine ).join( '\n' );
19615
+
19616
+ }
19617
+
19371
19618
  function generateDefines( defines ) {
19372
19619
 
19373
19620
  const chunks = [];
@@ -19672,6 +19919,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19672
19919
 
19673
19920
  const customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );
19674
19921
 
19922
+ const customVertexExtensions = generateVertexExtensions( parameters );
19923
+
19675
19924
  const customDefines = generateDefines( defines );
19676
19925
 
19677
19926
  const program = gl.createProgram();
@@ -19726,6 +19975,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19726
19975
 
19727
19976
  customDefines,
19728
19977
 
19978
+ parameters.extensionClipCullDistance ? '#define USE_CLIP_DISTANCE' : '',
19979
+ parameters.batching ? '#define USE_BATCHING' : '',
19729
19980
  parameters.instancing ? '#define USE_INSTANCING' : '',
19730
19981
  parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',
19731
19982
 
@@ -20065,6 +20316,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20065
20316
  versionString = '#version 300 es\n';
20066
20317
 
20067
20318
  prefixVertex = [
20319
+ customVertexExtensions,
20068
20320
  'precision mediump sampler2DArray;',
20069
20321
  '#define attribute in',
20070
20322
  '#define varying out',
@@ -20558,6 +20810,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20558
20810
  const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
20559
20811
 
20560
20812
  const IS_INSTANCEDMESH = object.isInstancedMesh === true;
20813
+ const IS_BATCHEDMESH = object.isBatchedMesh === true;
20561
20814
 
20562
20815
  const HAS_MAP = !! material.map;
20563
20816
  const HAS_MATCAP = !! material.matcap;
@@ -20643,6 +20896,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20643
20896
 
20644
20897
  precision: precision,
20645
20898
 
20899
+ batching: IS_BATCHEDMESH,
20646
20900
  instancing: IS_INSTANCEDMESH,
20647
20901
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
20648
20902
 
@@ -20805,6 +21059,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20805
21059
  extensionFragDepth: HAS_EXTENSIONS && material.extensions.fragDepth === true,
20806
21060
  extensionDrawBuffers: HAS_EXTENSIONS && material.extensions.drawBuffers === true,
20807
21061
  extensionShaderTextureLOD: HAS_EXTENSIONS && material.extensions.shaderTextureLOD === true,
21062
+ extensionClipCullDistance: HAS_EXTENSIONS && material.extensions.clipCullDistance && extensions.has( 'WEBGL_clip_cull_distance' ),
20808
21063
 
20809
21064
  rendererExtensionFragDepth: IS_WEBGL2 || extensions.has( 'EXT_frag_depth' ),
20810
21065
  rendererExtensionDrawBuffers: IS_WEBGL2 || extensions.has( 'WEBGL_draw_buffers' ),
@@ -20954,6 +21209,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20954
21209
  _programLayers.enable( 17 );
20955
21210
  if ( parameters.alphaHash )
20956
21211
  _programLayers.enable( 18 );
21212
+ if ( parameters.batching )
21213
+ _programLayers.enable( 19 );
20957
21214
 
20958
21215
  array.push( _programLayers.mask );
20959
21216
  _programLayers.disableAll();
@@ -21779,8 +22036,17 @@ function WebGLLights( extensions, capabilities ) {
21779
22036
 
21780
22037
  // WebGL 2
21781
22038
 
21782
- state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
21783
- state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
22039
+ if ( extensions.has( 'OES_texture_float_linear' ) === true ) {
22040
+
22041
+ state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
22042
+ state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
22043
+
22044
+ } else {
22045
+
22046
+ state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
22047
+ state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
22048
+
22049
+ }
21784
22050
 
21785
22051
  } else {
21786
22052
 
@@ -22417,6 +22683,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22417
22683
 
22418
22684
  cachedMaterial = result.clone();
22419
22685
  materialsForVariant[ keyB ] = cachedMaterial;
22686
+ material.addEventListener( 'dispose', onMaterialDispose );
22420
22687
 
22421
22688
  }
22422
22689
 
@@ -22493,8 +22760,12 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22493
22760
 
22494
22761
  const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
22495
22762
 
22763
+ object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22764
+
22496
22765
  _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
22497
22766
 
22767
+ object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, group );
22768
+
22498
22769
  }
22499
22770
 
22500
22771
  }
@@ -22503,8 +22774,12 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22503
22774
 
22504
22775
  const depthMaterial = getDepthMaterial( object, material, light, type );
22505
22776
 
22777
+ object.onBeforeShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22778
+
22506
22779
  _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
22507
22780
 
22781
+ object.onAfterShadow( _renderer, object, camera, shadowCamera, geometry, depthMaterial, null );
22782
+
22508
22783
  }
22509
22784
 
22510
22785
  }
@@ -22521,6 +22796,32 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
22521
22796
 
22522
22797
  }
22523
22798
 
22799
+ function onMaterialDispose( event ) {
22800
+
22801
+ const material = event.target;
22802
+
22803
+ material.removeEventListener( 'dispose', onMaterialDispose );
22804
+
22805
+ // make sure to remove the unique distance/depth materials used for shadow map rendering
22806
+
22807
+ for ( const id in _materialCache ) {
22808
+
22809
+ const cache = _materialCache[ id ];
22810
+
22811
+ const uuid = event.target.uuid;
22812
+
22813
+ if ( uuid in cache ) {
22814
+
22815
+ const shadowMaterial = cache[ uuid ];
22816
+ shadowMaterial.dispose();
22817
+ delete cache[ uuid ];
22818
+
22819
+ }
22820
+
22821
+ }
22822
+
22823
+ }
22824
+
22524
22825
  }
22525
22826
 
22526
22827
  function WebGLState( gl, extensions, capabilities ) {
@@ -23849,10 +24150,6 @@ function WebGLState( gl, extensions, capabilities ) {
23849
24150
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
23850
24151
 
23851
24152
  const isWebGL2 = capabilities.isWebGL2;
23852
- const maxTextures = capabilities.maxTextures;
23853
- const maxCubemapSize = capabilities.maxCubemapSize;
23854
- const maxTextureSize = capabilities.maxTextureSize;
23855
- const maxSamples = capabilities.maxSamples;
23856
24153
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
23857
24154
  const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
23858
24155
  const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
@@ -24275,9 +24572,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24275
24572
 
24276
24573
  const textureUnit = textureUnits;
24277
24574
 
24278
- if ( textureUnit >= maxTextures ) {
24575
+ if ( textureUnit >= capabilities.maxTextures ) {
24279
24576
 
24280
- console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );
24577
+ console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
24281
24578
 
24282
24579
  }
24283
24580
 
@@ -24634,7 +24931,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24634
24931
  _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
24635
24932
 
24636
24933
  const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo$1( texture.image ) === false;
24637
- let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
24934
+ let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
24638
24935
  image = verifyColorSpace( texture, image );
24639
24936
 
24640
24937
  const supportsMips = isPowerOfTwo$1( image ) || isWebGL2,
@@ -24648,7 +24945,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24648
24945
  let mipmap;
24649
24946
  const mipmaps = texture.mipmaps;
24650
24947
 
24651
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
24948
+ const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
24652
24949
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
24653
24950
  const levels = getMipLevels( texture, image, supportsMips );
24654
24951
 
@@ -25061,7 +25358,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25061
25358
 
25062
25359
  if ( ! isCompressed && ! isDataTexture ) {
25063
25360
 
25064
- cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );
25361
+ cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
25065
25362
 
25066
25363
  } else {
25067
25364
 
@@ -26020,7 +26317,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26020
26317
 
26021
26318
  function getRenderTargetSamples( renderTarget ) {
26022
26319
 
26023
- return Math.min( maxSamples, renderTarget.samples );
26320
+ return Math.min( capabilities.maxSamples, renderTarget.samples );
26024
26321
 
26025
26322
  }
26026
26323
 
@@ -27353,60 +27650,6 @@ class WebXRController {
27353
27650
 
27354
27651
  }
27355
27652
 
27356
- class DepthTexture extends Texture {
27357
-
27358
- constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
27359
-
27360
- format = format !== undefined ? format : DepthFormat;
27361
-
27362
- if ( format !== DepthFormat && format !== DepthStencilFormat ) {
27363
-
27364
- throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
27365
-
27366
- }
27367
-
27368
- if ( type === undefined && format === DepthFormat ) type = UnsignedIntType;
27369
- if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
27370
-
27371
- super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
27372
-
27373
- this.isDepthTexture = true;
27374
-
27375
- this.image = { width: width, height: height };
27376
-
27377
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
27378
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
27379
-
27380
- this.flipY = false;
27381
- this.generateMipmaps = false;
27382
-
27383
- this.compareFunction = null;
27384
-
27385
- }
27386
-
27387
-
27388
- copy( source ) {
27389
-
27390
- super.copy( source );
27391
-
27392
- this.compareFunction = source.compareFunction;
27393
-
27394
- return this;
27395
-
27396
- }
27397
-
27398
- toJSON( meta ) {
27399
-
27400
- const data = super.toJSON( meta );
27401
-
27402
- if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction;
27403
-
27404
- return data;
27405
-
27406
- }
27407
-
27408
- }
27409
-
27410
27653
  class WebXRManager extends EventDispatcher {
27411
27654
 
27412
27655
  constructor( renderer, gl, extensions, useMultiview ) {
@@ -27440,6 +27683,9 @@ class WebXRManager extends EventDispatcher {
27440
27683
  const controllers = [];
27441
27684
  const controllerInputSources = [];
27442
27685
 
27686
+ const currentSize = new Vector2();
27687
+ let currentPixelRatio = null;
27688
+
27443
27689
  //
27444
27690
 
27445
27691
  const cameraL = new PerspectiveCamera();
@@ -27583,6 +27829,9 @@ class WebXRManager extends EventDispatcher {
27583
27829
 
27584
27830
  scope.isPresenting = false;
27585
27831
 
27832
+ renderer.setPixelRatio( currentPixelRatio );
27833
+ renderer.setSize( currentSize.width, currentSize.height, false );
27834
+
27586
27835
  scope.dispatchEvent( { type: 'sessionend' } );
27587
27836
 
27588
27837
  }
@@ -27670,6 +27919,9 @@ class WebXRManager extends EventDispatcher {
27670
27919
 
27671
27920
  }
27672
27921
 
27922
+ currentPixelRatio = renderer.getPixelRatio();
27923
+ renderer.getSize( currentSize );
27924
+
27673
27925
  if ( ( session.renderState.layers === undefined ) || ( renderer.capabilities.isWebGL2 === false ) ) {
27674
27926
 
27675
27927
  const layerInit = {
@@ -27684,6 +27936,9 @@ class WebXRManager extends EventDispatcher {
27684
27936
 
27685
27937
  session.updateRenderState( { baseLayer: glBaseLayer } );
27686
27938
 
27939
+ renderer.setPixelRatio( 1 );
27940
+ renderer.setSize( glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, false );
27941
+
27687
27942
  newRenderTarget = new WebGLRenderTarget(
27688
27943
  glBaseLayer.framebufferWidth,
27689
27944
  glBaseLayer.framebufferHeight,
@@ -27729,6 +27984,9 @@ class WebXRManager extends EventDispatcher {
27729
27984
 
27730
27985
  session.updateRenderState( { layers: [ glProjLayer ] } );
27731
27986
 
27987
+ renderer.setPixelRatio( 1 );
27988
+ renderer.setSize( glProjLayer.textureWidth, glProjLayer.textureHeight, false );
27989
+
27732
27990
  const renderTargetOptions = {
27733
27991
  format: RGBAFormat,
27734
27992
  type: UnsignedByteType,
@@ -28877,57 +29135,62 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
28877
29135
 
28878
29136
  for ( let i = 0, il = uniforms.length; i < il; i ++ ) {
28879
29137
 
28880
- const uniform = uniforms[ i ];
29138
+ const uniformArray = Array.isArray( uniforms[ i ] ) ? uniforms[ i ] : [ uniforms[ i ] ];
28881
29139
 
28882
- // partly update the buffer if necessary
29140
+ for ( let j = 0, jl = uniformArray.length; j < jl; j ++ ) {
28883
29141
 
28884
- if ( hasUniformChanged( uniform, i, cache ) === true ) {
29142
+ const uniform = uniformArray[ j ];
28885
29143
 
28886
- const offset = uniform.__offset;
29144
+ if ( hasUniformChanged( uniform, i, j, cache ) === true ) {
28887
29145
 
28888
- const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
29146
+ const offset = uniform.__offset;
28889
29147
 
28890
- let arrayOffset = 0;
29148
+ const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
28891
29149
 
28892
- for ( let i = 0; i < values.length; i ++ ) {
29150
+ let arrayOffset = 0;
28893
29151
 
28894
- const value = values[ i ];
29152
+ for ( let k = 0; k < values.length; k ++ ) {
28895
29153
 
28896
- const info = getUniformSize( value );
29154
+ const value = values[ k ];
28897
29155
 
28898
- if ( typeof value === 'number' ) {
29156
+ const info = getUniformSize( value );
28899
29157
 
28900
- uniform.__data[ 0 ] = value;
28901
- gl.bufferSubData( gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data );
29158
+ // TODO add integer and struct support
29159
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
28902
29160
 
28903
- } else if ( value.isMatrix3 ) {
29161
+ uniform.__data[ 0 ] = value;
29162
+ gl.bufferSubData( gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data );
28904
29163
 
28905
- // manually converting 3x3 to 3x4
29164
+ } else if ( value.isMatrix3 ) {
28906
29165
 
28907
- uniform.__data[ 0 ] = value.elements[ 0 ];
28908
- uniform.__data[ 1 ] = value.elements[ 1 ];
28909
- uniform.__data[ 2 ] = value.elements[ 2 ];
28910
- uniform.__data[ 3 ] = value.elements[ 0 ];
28911
- uniform.__data[ 4 ] = value.elements[ 3 ];
28912
- uniform.__data[ 5 ] = value.elements[ 4 ];
28913
- uniform.__data[ 6 ] = value.elements[ 5 ];
28914
- uniform.__data[ 7 ] = value.elements[ 0 ];
28915
- uniform.__data[ 8 ] = value.elements[ 6 ];
28916
- uniform.__data[ 9 ] = value.elements[ 7 ];
28917
- uniform.__data[ 10 ] = value.elements[ 8 ];
28918
- uniform.__data[ 11 ] = value.elements[ 0 ];
29166
+ // manually converting 3x3 to 3x4
28919
29167
 
28920
- } else {
29168
+ uniform.__data[ 0 ] = value.elements[ 0 ];
29169
+ uniform.__data[ 1 ] = value.elements[ 1 ];
29170
+ uniform.__data[ 2 ] = value.elements[ 2 ];
29171
+ uniform.__data[ 3 ] = 0;
29172
+ uniform.__data[ 4 ] = value.elements[ 3 ];
29173
+ uniform.__data[ 5 ] = value.elements[ 4 ];
29174
+ uniform.__data[ 6 ] = value.elements[ 5 ];
29175
+ uniform.__data[ 7 ] = 0;
29176
+ uniform.__data[ 8 ] = value.elements[ 6 ];
29177
+ uniform.__data[ 9 ] = value.elements[ 7 ];
29178
+ uniform.__data[ 10 ] = value.elements[ 8 ];
29179
+ uniform.__data[ 11 ] = 0;
29180
+
29181
+ } else {
28921
29182
 
28922
- value.toArray( uniform.__data, arrayOffset );
29183
+ value.toArray( uniform.__data, arrayOffset );
28923
29184
 
28924
- arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
29185
+ arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
29186
+
29187
+ }
28925
29188
 
28926
29189
  }
28927
29190
 
28928
- }
29191
+ gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data );
28929
29192
 
28930
- gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data );
29193
+ }
28931
29194
 
28932
29195
  }
28933
29196
 
@@ -28937,31 +29200,22 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
28937
29200
 
28938
29201
  }
28939
29202
 
28940
- function hasUniformChanged( uniform, index, cache ) {
29203
+ function hasUniformChanged( uniform, index, indexArray, cache ) {
28941
29204
 
28942
29205
  const value = uniform.value;
29206
+ const indexString = index + '_' + indexArray;
28943
29207
 
28944
- if ( cache[ index ] === undefined ) {
29208
+ if ( cache[ indexString ] === undefined ) {
28945
29209
 
28946
29210
  // cache entry does not exist so far
28947
29211
 
28948
- if ( typeof value === 'number' ) {
29212
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
28949
29213
 
28950
- cache[ index ] = value;
29214
+ cache[ indexString ] = value;
28951
29215
 
28952
29216
  } else {
28953
29217
 
28954
- const values = Array.isArray( value ) ? value : [ value ];
28955
-
28956
- const tempValues = [];
28957
-
28958
- for ( let i = 0; i < values.length; i ++ ) {
28959
-
28960
- tempValues.push( values[ i ].clone() );
28961
-
28962
- }
28963
-
28964
- cache[ index ] = tempValues;
29218
+ cache[ indexString ] = value.clone();
28965
29219
 
28966
29220
  }
28967
29221
 
@@ -28969,32 +29223,25 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
28969
29223
 
28970
29224
  } else {
28971
29225
 
29226
+ const cachedObject = cache[ indexString ];
29227
+
28972
29228
  // compare current value with cached entry
28973
29229
 
28974
- if ( typeof value === 'number' ) {
29230
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
28975
29231
 
28976
- if ( cache[ index ] !== value ) {
29232
+ if ( cachedObject !== value ) {
28977
29233
 
28978
- cache[ index ] = value;
29234
+ cache[ indexString ] = value;
28979
29235
  return true;
28980
29236
 
28981
29237
  }
28982
29238
 
28983
29239
  } else {
28984
29240
 
28985
- const cachedObjects = Array.isArray( cache[ index ] ) ? cache[ index ] : [ cache[ index ] ];
28986
- const values = Array.isArray( value ) ? value : [ value ];
28987
-
28988
- for ( let i = 0; i < cachedObjects.length; i ++ ) {
28989
-
28990
- const cachedObject = cachedObjects[ i ];
29241
+ if ( cachedObject.equals( value ) === false ) {
28991
29242
 
28992
- if ( cachedObject.equals( values[ i ] ) === false ) {
28993
-
28994
- cachedObject.copy( values[ i ] );
28995
- return true;
28996
-
28997
- }
29243
+ cachedObject.copy( value );
29244
+ return true;
28998
29245
 
28999
29246
  }
29000
29247
 
@@ -29015,63 +29262,53 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
29015
29262
 
29016
29263
  let offset = 0; // global buffer offset in bytes
29017
29264
  const chunkSize = 16; // size of a chunk in bytes
29018
- let chunkOffset = 0; // offset within a single chunk in bytes
29019
29265
 
29020
29266
  for ( let i = 0, l = uniforms.length; i < l; i ++ ) {
29021
29267
 
29022
- const uniform = uniforms[ i ];
29023
-
29024
- const infos = {
29025
- boundary: 0, // bytes
29026
- storage: 0 // bytes
29027
- };
29268
+ const uniformArray = Array.isArray( uniforms[ i ] ) ? uniforms[ i ] : [ uniforms[ i ] ];
29028
29269
 
29029
- const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
29270
+ for ( let j = 0, jl = uniformArray.length; j < jl; j ++ ) {
29030
29271
 
29031
- for ( let j = 0, jl = values.length; j < jl; j ++ ) {
29272
+ const uniform = uniformArray[ j ];
29032
29273
 
29033
- const value = values[ j ];
29274
+ const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ];
29034
29275
 
29035
- const info = getUniformSize( value );
29276
+ for ( let k = 0, kl = values.length; k < kl; k ++ ) {
29036
29277
 
29037
- infos.boundary += info.boundary;
29038
- infos.storage += info.storage;
29278
+ const value = values[ k ];
29039
29279
 
29040
- }
29041
-
29042
- // the following two properties will be used for partial buffer updates
29280
+ const info = getUniformSize( value );
29043
29281
 
29044
- uniform.__data = new Float32Array( infos.storage / Float32Array.BYTES_PER_ELEMENT );
29045
- uniform.__offset = offset;
29282
+ // Calculate the chunk offset
29283
+ const chunkOffsetUniform = offset % chunkSize;
29046
29284
 
29047
- //
29285
+ // Check for chunk overflow
29286
+ if ( chunkOffsetUniform !== 0 && ( chunkSize - chunkOffsetUniform ) < info.boundary ) {
29048
29287
 
29049
- if ( i > 0 ) {
29288
+ // Add padding and adjust offset
29289
+ offset += ( chunkSize - chunkOffsetUniform );
29050
29290
 
29051
- chunkOffset = offset % chunkSize;
29291
+ }
29052
29292
 
29053
- const remainingSizeInChunk = chunkSize - chunkOffset;
29293
+ // the following two properties will be used for partial buffer updates
29054
29294
 
29055
- // check for chunk overflow
29295
+ uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT );
29296
+ uniform.__offset = offset;
29056
29297
 
29057
- if ( chunkOffset !== 0 && ( remainingSizeInChunk - infos.boundary ) < 0 ) {
29058
29298
 
29059
- // add padding and adjust offset
29299
+ // Update the global offset
29300
+ offset += info.storage;
29060
29301
 
29061
- offset += ( chunkSize - chunkOffset );
29062
- uniform.__offset = offset;
29063
29302
 
29064
29303
  }
29065
29304
 
29066
29305
  }
29067
29306
 
29068
- offset += infos.storage;
29069
-
29070
29307
  }
29071
29308
 
29072
29309
  // ensure correct final padding
29073
29310
 
29074
- chunkOffset = offset % chunkSize;
29311
+ const chunkOffset = offset % chunkSize;
29075
29312
 
29076
29313
  if ( chunkOffset > 0 ) offset += ( chunkSize - chunkOffset );
29077
29314
 
@@ -29093,9 +29330,9 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
29093
29330
 
29094
29331
  // determine sizes according to STD140
29095
29332
 
29096
- if ( typeof value === 'number' ) {
29333
+ if ( typeof value === 'number' || typeof value === 'boolean' ) {
29097
29334
 
29098
- // float/int
29335
+ // float/int/bool
29099
29336
 
29100
29337
  info.boundary = 4;
29101
29338
  info.storage = 4;
@@ -30026,7 +30263,11 @@ class WebGLRenderer {
30026
30263
 
30027
30264
  }
30028
30265
 
30029
- if ( object.isInstancedMesh ) {
30266
+ if ( object.isBatchedMesh ) {
30267
+
30268
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
30269
+
30270
+ } else if ( object.isInstancedMesh ) {
30030
30271
 
30031
30272
  renderer.renderInstances( drawStart, drawCount, object.count );
30032
30273
 
@@ -30862,6 +31103,7 @@ class WebGLRenderer {
30862
31103
  const materialProperties = properties.get( material );
30863
31104
 
30864
31105
  materialProperties.outputColorSpace = parameters.outputColorSpace;
31106
+ materialProperties.batching = parameters.batching;
30865
31107
  materialProperties.instancing = parameters.instancing;
30866
31108
  materialProperties.instancingColor = parameters.instancingColor;
30867
31109
  materialProperties.skinning = parameters.skinning;
@@ -30945,6 +31187,14 @@ class WebGLRenderer {
30945
31187
 
30946
31188
  needsProgramChange = true;
30947
31189
 
31190
+ } else if ( object.isBatchedMesh && materialProperties.batching === false ) {
31191
+
31192
+ needsProgramChange = true;
31193
+
31194
+ } else if ( ! object.isBatchedMesh && materialProperties.batching === true ) {
31195
+
31196
+ needsProgramChange = true;
31197
+
30948
31198
  } else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
30949
31199
 
30950
31200
  needsProgramChange = true;
@@ -31134,7 +31384,6 @@ class WebGLRenderer {
31134
31384
  if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
31135
31385
 
31136
31386
  p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
31137
- p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
31138
31387
 
31139
31388
  } else {
31140
31389
 
@@ -31146,6 +31395,13 @@ class WebGLRenderer {
31146
31395
 
31147
31396
  }
31148
31397
 
31398
+ if ( object.isBatchedMesh ) {
31399
+
31400
+ p_uniforms.setOptional( _gl, object, 'batchingTexture' );
31401
+ p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
31402
+
31403
+ }
31404
+
31149
31405
  const morphAttributes = geometry.morphAttributes;
31150
31406
 
31151
31407
  if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
@@ -31620,7 +31876,7 @@ class WebGLRenderer {
31620
31876
  textures.setTexture3D( dstTexture, 0 );
31621
31877
  glTarget = _gl.TEXTURE_3D;
31622
31878
 
31623
- } else if ( dstTexture.isDataArrayTexture ) {
31879
+ } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
31624
31880
 
31625
31881
  textures.setTexture2DArray( dstTexture, 0 );
31626
31882
  glTarget = _gl.TEXTURE_2D_ARRAY;
@@ -31642,7 +31898,7 @@ class WebGLRenderer {
31642
31898
  const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
31643
31899
  const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
31644
31900
 
31645
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ 0 ] : srcTexture.image;
31901
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
31646
31902
 
31647
31903
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
31648
31904
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
@@ -31747,20 +32003,6 @@ class WebGLRenderer {
31747
32003
 
31748
32004
  }
31749
32005
 
31750
- get physicallyCorrectLights() { // @deprecated, r150
31751
-
31752
- console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
31753
- return ! this.useLegacyLights;
31754
-
31755
- }
31756
-
31757
- set physicallyCorrectLights( value ) { // @deprecated, r150
31758
-
31759
- console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
31760
- this.useLegacyLights = ! value;
31761
-
31762
- }
31763
-
31764
32006
  get outputEncoding() { // @deprecated, r152
31765
32007
 
31766
32008
  console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
@@ -31933,7 +32175,8 @@ class InterleavedBuffer {
31933
32175
  this.count = array !== undefined ? array.length / stride : 0;
31934
32176
 
31935
32177
  this.usage = StaticDrawUsage;
31936
- this.updateRange = { offset: 0, count: - 1 };
32178
+ this._updateRange = { offset: 0, count: - 1 };
32179
+ this.updateRanges = [];
31937
32180
 
31938
32181
  this.version = 0;
31939
32182
 
@@ -31949,6 +32192,13 @@ class InterleavedBuffer {
31949
32192
 
31950
32193
  }
31951
32194
 
32195
+ get updateRange() {
32196
+
32197
+ console.warn( 'THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead.' ); // @deprecated, r159
32198
+ return this._updateRange;
32199
+
32200
+ }
32201
+
31952
32202
  setUsage( value ) {
31953
32203
 
31954
32204
  this.usage = value;
@@ -31957,6 +32207,18 @@ class InterleavedBuffer {
31957
32207
 
31958
32208
  }
31959
32209
 
32210
+ addUpdateRange( start, count ) {
32211
+
32212
+ this.updateRanges.push( { start, count } );
32213
+
32214
+ }
32215
+
32216
+ clearUpdateRanges() {
32217
+
32218
+ this.updateRanges.length = 0;
32219
+
32220
+ }
32221
+
31960
32222
  copy( source ) {
31961
32223
 
31962
32224
  this.array = new source.array.constructor( source.array );
@@ -32063,7 +32325,7 @@ class InterleavedBuffer {
32063
32325
 
32064
32326
  }
32065
32327
 
32066
- const _vector$5 = /*@__PURE__*/ new Vector3();
32328
+ const _vector$6 = /*@__PURE__*/ new Vector3();
32067
32329
 
32068
32330
  class InterleavedBufferAttribute {
32069
32331
 
@@ -32103,11 +32365,11 @@ class InterleavedBufferAttribute {
32103
32365
 
32104
32366
  for ( let i = 0, l = this.data.count; i < l; i ++ ) {
32105
32367
 
32106
- _vector$5.fromBufferAttribute( this, i );
32368
+ _vector$6.fromBufferAttribute( this, i );
32107
32369
 
32108
- _vector$5.applyMatrix4( m );
32370
+ _vector$6.applyMatrix4( m );
32109
32371
 
32110
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
32372
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
32111
32373
 
32112
32374
  }
32113
32375
 
@@ -32119,11 +32381,11 @@ class InterleavedBufferAttribute {
32119
32381
 
32120
32382
  for ( let i = 0, l = this.count; i < l; i ++ ) {
32121
32383
 
32122
- _vector$5.fromBufferAttribute( this, i );
32384
+ _vector$6.fromBufferAttribute( this, i );
32123
32385
 
32124
- _vector$5.applyNormalMatrix( m );
32386
+ _vector$6.applyNormalMatrix( m );
32125
32387
 
32126
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
32388
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
32127
32389
 
32128
32390
  }
32129
32391
 
@@ -32135,11 +32397,11 @@ class InterleavedBufferAttribute {
32135
32397
 
32136
32398
  for ( let i = 0, l = this.count; i < l; i ++ ) {
32137
32399
 
32138
- _vector$5.fromBufferAttribute( this, i );
32400
+ _vector$6.fromBufferAttribute( this, i );
32139
32401
 
32140
- _vector$5.transformDirection( m );
32402
+ _vector$6.transformDirection( m );
32141
32403
 
32142
- this.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z );
32404
+ this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z );
32143
32405
 
32144
32406
  }
32145
32407
 
@@ -32826,7 +33088,7 @@ const _vector3 = /*@__PURE__*/ new Vector3();
32826
33088
  const _matrix4 = /*@__PURE__*/ new Matrix4();
32827
33089
  const _vertex = /*@__PURE__*/ new Vector3();
32828
33090
 
32829
- const _sphere$3 = /*@__PURE__*/ new Sphere();
33091
+ const _sphere$4 = /*@__PURE__*/ new Sphere();
32830
33092
  const _inverseMatrix$2 = /*@__PURE__*/ new Matrix4();
32831
33093
  const _ray$2 = /*@__PURE__*/ new Ray();
32832
33094
 
@@ -32923,10 +33185,10 @@ class SkinnedMesh extends Mesh {
32923
33185
 
32924
33186
  if ( this.boundingSphere === null ) this.computeBoundingSphere();
32925
33187
 
32926
- _sphere$3.copy( this.boundingSphere );
32927
- _sphere$3.applyMatrix4( matrixWorld );
33188
+ _sphere$4.copy( this.boundingSphere );
33189
+ _sphere$4.applyMatrix4( matrixWorld );
32928
33190
 
32929
- if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return;
33191
+ if ( raycaster.ray.intersectsSphere( _sphere$4 ) === false ) return;
32930
33192
 
32931
33193
  // convert ray to local space of skinned mesh
32932
33194
 
@@ -33105,7 +33367,7 @@ class DataTexture extends Texture {
33105
33367
  }
33106
33368
 
33107
33369
  const _offsetMatrix = /*@__PURE__*/ new Matrix4();
33108
- const _identityMatrix = /*@__PURE__*/ new Matrix4();
33370
+ const _identityMatrix$1 = /*@__PURE__*/ new Matrix4();
33109
33371
 
33110
33372
  class Skeleton {
33111
33373
 
@@ -33118,7 +33380,6 @@ class Skeleton {
33118
33380
  this.boneMatrices = null;
33119
33381
 
33120
33382
  this.boneTexture = null;
33121
- this.boneTextureSize = 0;
33122
33383
 
33123
33384
  this.init();
33124
33385
 
@@ -33235,7 +33496,7 @@ class Skeleton {
33235
33496
 
33236
33497
  // compute the offset between the current and the original transform
33237
33498
 
33238
- const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix;
33499
+ const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix$1;
33239
33500
 
33240
33501
  _offsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] );
33241
33502
  _offsetMatrix.toArray( boneMatrices, i * 16 );
@@ -33266,7 +33527,7 @@ class Skeleton {
33266
33527
  // 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
33267
33528
 
33268
33529
  let size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
33269
- size = ceilPowerOfTwo( size );
33530
+ size = Math.ceil( size / 4 ) * 4;
33270
33531
  size = Math.max( size, 4 );
33271
33532
 
33272
33533
  const boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
@@ -33277,7 +33538,6 @@ class Skeleton {
33277
33538
 
33278
33539
  this.boneMatrices = boneMatrices;
33279
33540
  this.boneTexture = boneTexture;
33280
- this.boneTextureSize = size;
33281
33541
 
33282
33542
  return this;
33283
33543
 
@@ -33416,8 +33676,8 @@ const _instanceIntersects = [];
33416
33676
 
33417
33677
  const _box3 = /*@__PURE__*/ new Box3();
33418
33678
  const _identity = /*@__PURE__*/ new Matrix4();
33419
- const _mesh = /*@__PURE__*/ new Mesh();
33420
- const _sphere$2 = /*@__PURE__*/ new Sphere();
33679
+ const _mesh$1 = /*@__PURE__*/ new Mesh();
33680
+ const _sphere$3 = /*@__PURE__*/ new Sphere();
33421
33681
 
33422
33682
  class InstancedMesh extends Mesh {
33423
33683
 
@@ -33497,9 +33757,9 @@ class InstancedMesh extends Mesh {
33497
33757
 
33498
33758
  this.getMatrixAt( i, _instanceLocalMatrix );
33499
33759
 
33500
- _sphere$2.copy( geometry.boundingSphere ).applyMatrix4( _instanceLocalMatrix );
33760
+ _sphere$3.copy( geometry.boundingSphere ).applyMatrix4( _instanceLocalMatrix );
33501
33761
 
33502
- this.boundingSphere.union( _sphere$2 );
33762
+ this.boundingSphere.union( _sphere$3 );
33503
33763
 
33504
33764
  }
33505
33765
 
@@ -33539,19 +33799,19 @@ class InstancedMesh extends Mesh {
33539
33799
  const matrixWorld = this.matrixWorld;
33540
33800
  const raycastTimes = this.count;
33541
33801
 
33542
- _mesh.geometry = this.geometry;
33543
- _mesh.material = this.material;
33802
+ _mesh$1.geometry = this.geometry;
33803
+ _mesh$1.material = this.material;
33544
33804
 
33545
- if ( _mesh.material === undefined ) return;
33805
+ if ( _mesh$1.material === undefined ) return;
33546
33806
 
33547
33807
  // test with bounding sphere first
33548
33808
 
33549
33809
  if ( this.boundingSphere === null ) this.computeBoundingSphere();
33550
33810
 
33551
- _sphere$2.copy( this.boundingSphere );
33552
- _sphere$2.applyMatrix4( matrixWorld );
33811
+ _sphere$3.copy( this.boundingSphere );
33812
+ _sphere$3.applyMatrix4( matrixWorld );
33553
33813
 
33554
- if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) return;
33814
+ if ( raycaster.ray.intersectsSphere( _sphere$3 ) === false ) return;
33555
33815
 
33556
33816
  // now test each instance
33557
33817
 
@@ -33565,9 +33825,9 @@ class InstancedMesh extends Mesh {
33565
33825
 
33566
33826
  // the mesh represents this single instance
33567
33827
 
33568
- _mesh.matrixWorld = _instanceWorldMatrix;
33828
+ _mesh$1.matrixWorld = _instanceWorldMatrix;
33569
33829
 
33570
- _mesh.raycast( raycaster, _instanceIntersects );
33830
+ _mesh$1.raycast( raycaster, _instanceIntersects );
33571
33831
 
33572
33832
  // process the result of raycast
33573
33833
 
@@ -33616,6 +33876,1011 @@ class InstancedMesh extends Mesh {
33616
33876
 
33617
33877
  }
33618
33878
 
33879
+ function sortOpaque( a, b ) {
33880
+
33881
+ return a.z - b.z;
33882
+
33883
+ }
33884
+
33885
+ function sortTransparent( a, b ) {
33886
+
33887
+ return b.z - a.z;
33888
+
33889
+ }
33890
+
33891
+ class MultiDrawRenderList {
33892
+
33893
+ constructor() {
33894
+
33895
+ this.index = 0;
33896
+ this.pool = [];
33897
+ this.list = [];
33898
+
33899
+ }
33900
+
33901
+ push( drawRange, z ) {
33902
+
33903
+ const pool = this.pool;
33904
+ const list = this.list;
33905
+ if ( this.index >= pool.length ) {
33906
+
33907
+ pool.push( {
33908
+
33909
+ start: - 1,
33910
+ count: - 1,
33911
+ z: - 1,
33912
+
33913
+ } );
33914
+
33915
+ }
33916
+
33917
+ const item = pool[ this.index ];
33918
+ list.push( item );
33919
+ this.index ++;
33920
+
33921
+ item.start = drawRange.start;
33922
+ item.count = drawRange.count;
33923
+ item.z = z;
33924
+
33925
+ }
33926
+
33927
+ reset() {
33928
+
33929
+ this.list.length = 0;
33930
+ this.index = 0;
33931
+
33932
+ }
33933
+
33934
+ }
33935
+
33936
+ const ID_ATTR_NAME = 'batchId';
33937
+ const _matrix = /*@__PURE__*/ new Matrix4();
33938
+ const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
33939
+ const _identityMatrix = /*@__PURE__*/ new Matrix4();
33940
+ const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
33941
+ const _frustum = /*@__PURE__*/ new Frustum();
33942
+ const _box$1 = /*@__PURE__*/ new Box3();
33943
+ const _sphere$2 = /*@__PURE__*/ new Sphere();
33944
+ const _vector$5 = /*@__PURE__*/ new Vector3();
33945
+ const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
33946
+ const _mesh = /*@__PURE__*/ new Mesh();
33947
+ const _batchIntersects = [];
33948
+
33949
+ // @TODO: SkinnedMesh support?
33950
+ // @TODO: geometry.groups support?
33951
+ // @TODO: geometry.drawRange support?
33952
+ // @TODO: geometry.morphAttributes support?
33953
+ // @TODO: Support uniform parameter per geometry
33954
+ // @TODO: Add an "optimize" function to pack geometry and remove data gaps
33955
+
33956
+ // copies data from attribute "src" into "target" starting at "targetOffset"
33957
+ function copyAttributeData( src, target, targetOffset = 0 ) {
33958
+
33959
+ const itemSize = target.itemSize;
33960
+ if ( src.isInterleavedBufferAttribute || src.array.constructor !== target.array.constructor ) {
33961
+
33962
+ // use the component getters and setters if the array data cannot
33963
+ // be copied directly
33964
+ const vertexCount = src.count;
33965
+ for ( let i = 0; i < vertexCount; i ++ ) {
33966
+
33967
+ for ( let c = 0; c < itemSize; c ++ ) {
33968
+
33969
+ target.setComponent( i + targetOffset, c, src.getComponent( i, c ) );
33970
+
33971
+ }
33972
+
33973
+ }
33974
+
33975
+ } else {
33976
+
33977
+ // faster copy approach using typed array set function
33978
+ target.array.set( src.array, targetOffset * itemSize );
33979
+
33980
+ }
33981
+
33982
+ target.needsUpdate = true;
33983
+
33984
+ }
33985
+
33986
+ class BatchedMesh extends Mesh {
33987
+
33988
+ get maxGeometryCount() {
33989
+
33990
+ return this._maxGeometryCount;
33991
+
33992
+ }
33993
+
33994
+ constructor( maxGeometryCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
33995
+
33996
+ super( new BufferGeometry(), material );
33997
+
33998
+ this.isBatchedMesh = true;
33999
+ this.perObjectFrustumCulled = true;
34000
+ this.sortObjects = true;
34001
+ this.boundingBox = null;
34002
+ this.boundingSphere = null;
34003
+ this.customSort = null;
34004
+
34005
+ this._drawRanges = [];
34006
+ this._reservedRanges = [];
34007
+
34008
+ this._visibility = [];
34009
+ this._active = [];
34010
+ this._bounds = [];
34011
+
34012
+ this._maxGeometryCount = maxGeometryCount;
34013
+ this._maxVertexCount = maxVertexCount;
34014
+ this._maxIndexCount = maxIndexCount;
34015
+
34016
+ this._geometryInitialized = false;
34017
+ this._geometryCount = 0;
34018
+ this._multiDrawCounts = new Int32Array( maxGeometryCount );
34019
+ this._multiDrawStarts = new Int32Array( maxGeometryCount );
34020
+ this._multiDrawCount = 0;
34021
+ this._visibilityChanged = true;
34022
+
34023
+ // Local matrix per geometry by using data texture
34024
+ this._matricesTexture = null;
34025
+
34026
+ this._initMatricesTexture();
34027
+
34028
+ }
34029
+
34030
+ _initMatricesTexture() {
34031
+
34032
+ // layout (1 matrix = 4 pixels)
34033
+ // RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
34034
+ // with 8x8 pixel texture max 16 matrices * 4 pixels = (8 * 8)
34035
+ // 16x16 pixel texture max 64 matrices * 4 pixels = (16 * 16)
34036
+ // 32x32 pixel texture max 256 matrices * 4 pixels = (32 * 32)
34037
+ // 64x64 pixel texture max 1024 matrices * 4 pixels = (64 * 64)
34038
+
34039
+ let size = Math.sqrt( this._maxGeometryCount * 4 ); // 4 pixels needed for 1 matrix
34040
+ size = Math.ceil( size / 4 ) * 4;
34041
+ size = Math.max( size, 4 );
34042
+
34043
+ const matricesArray = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
34044
+ const matricesTexture = new DataTexture( matricesArray, size, size, RGBAFormat, FloatType );
34045
+
34046
+ this._matricesTexture = matricesTexture;
34047
+
34048
+ }
34049
+
34050
+ _initializeGeometry( reference ) {
34051
+
34052
+ const geometry = this.geometry;
34053
+ const maxVertexCount = this._maxVertexCount;
34054
+ const maxGeometryCount = this._maxGeometryCount;
34055
+ const maxIndexCount = this._maxIndexCount;
34056
+ if ( this._geometryInitialized === false ) {
34057
+
34058
+ for ( const attributeName in reference.attributes ) {
34059
+
34060
+ const srcAttribute = reference.getAttribute( attributeName );
34061
+ const { array, itemSize, normalized } = srcAttribute;
34062
+
34063
+ const dstArray = new array.constructor( maxVertexCount * itemSize );
34064
+ const dstAttribute = new srcAttribute.constructor( dstArray, itemSize, normalized );
34065
+ dstAttribute.setUsage( srcAttribute.usage );
34066
+
34067
+ geometry.setAttribute( attributeName, dstAttribute );
34068
+
34069
+ }
34070
+
34071
+ if ( reference.getIndex() !== null ) {
34072
+
34073
+ const indexArray = maxVertexCount > 65536
34074
+ ? new Uint32Array( maxIndexCount )
34075
+ : new Uint16Array( maxIndexCount );
34076
+
34077
+ geometry.setIndex( new BufferAttribute( indexArray, 1 ) );
34078
+
34079
+ }
34080
+
34081
+ const idArray = maxGeometryCount > 65536
34082
+ ? new Uint32Array( maxVertexCount )
34083
+ : new Uint16Array( maxVertexCount );
34084
+ geometry.setAttribute( ID_ATTR_NAME, new BufferAttribute( idArray, 1 ) );
34085
+
34086
+ this._geometryInitialized = true;
34087
+
34088
+ }
34089
+
34090
+ }
34091
+
34092
+ // Make sure the geometry is compatible with the existing combined geometry atributes
34093
+ _validateGeometry( geometry ) {
34094
+
34095
+ // check that the geometry doesn't have a version of our reserved id attribute
34096
+ if ( geometry.getAttribute( ID_ATTR_NAME ) ) {
34097
+
34098
+ throw new Error( `BatchedMesh: Geometry cannot use attribute "${ ID_ATTR_NAME }"` );
34099
+
34100
+ }
34101
+
34102
+ // check to ensure the geometries are using consistent attributes and indices
34103
+ const batchGeometry = this.geometry;
34104
+ if ( Boolean( geometry.getIndex() ) !== Boolean( batchGeometry.getIndex() ) ) {
34105
+
34106
+ throw new Error( 'BatchedMesh: All geometries must consistently have "index".' );
34107
+
34108
+ }
34109
+
34110
+ for ( const attributeName in batchGeometry.attributes ) {
34111
+
34112
+ if ( attributeName === ID_ATTR_NAME ) {
34113
+
34114
+ continue;
34115
+
34116
+ }
34117
+
34118
+ if ( ! geometry.hasAttribute( attributeName ) ) {
34119
+
34120
+ throw new Error( `BatchedMesh: Added geometry missing "${ attributeName }". All geometries must have consistent attributes.` );
34121
+
34122
+ }
34123
+
34124
+ const srcAttribute = geometry.getAttribute( attributeName );
34125
+ const dstAttribute = batchGeometry.getAttribute( attributeName );
34126
+ if ( srcAttribute.itemSize !== dstAttribute.itemSize || srcAttribute.normalized !== dstAttribute.normalized ) {
34127
+
34128
+ throw new Error( 'BatchedMesh: All attributes must have a consistent itemSize and normalized value.' );
34129
+
34130
+ }
34131
+
34132
+ }
34133
+
34134
+ }
34135
+
34136
+ setCustomSort( func ) {
34137
+
34138
+ this.customSort = func;
34139
+ return this;
34140
+
34141
+ }
34142
+
34143
+ computeBoundingBox() {
34144
+
34145
+ if ( this.boundingBox === null ) {
34146
+
34147
+ this.boundingBox = new Box3();
34148
+
34149
+ }
34150
+
34151
+ const geometryCount = this._geometryCount;
34152
+ const boundingBox = this.boundingBox;
34153
+ const active = this._active;
34154
+
34155
+ boundingBox.makeEmpty();
34156
+ for ( let i = 0; i < geometryCount; i ++ ) {
34157
+
34158
+ if ( active[ i ] === false ) continue;
34159
+
34160
+ this.getMatrixAt( i, _matrix );
34161
+ this.getBoundingBoxAt( i, _box$1 ).applyMatrix4( _matrix );
34162
+ boundingBox.union( _box$1 );
34163
+
34164
+ }
34165
+
34166
+ }
34167
+
34168
+ computeBoundingSphere() {
34169
+
34170
+ if ( this.boundingSphere === null ) {
34171
+
34172
+ this.boundingSphere = new Sphere();
34173
+
34174
+ }
34175
+
34176
+ const geometryCount = this._geometryCount;
34177
+ const boundingSphere = this.boundingSphere;
34178
+ const active = this._active;
34179
+
34180
+ boundingSphere.makeEmpty();
34181
+ for ( let i = 0; i < geometryCount; i ++ ) {
34182
+
34183
+ if ( active[ i ] === false ) continue;
34184
+
34185
+ this.getMatrixAt( i, _matrix );
34186
+ this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix );
34187
+ boundingSphere.union( _sphere$2 );
34188
+
34189
+ }
34190
+
34191
+ }
34192
+
34193
+ addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
34194
+
34195
+ this._initializeGeometry( geometry );
34196
+
34197
+ this._validateGeometry( geometry );
34198
+
34199
+ // ensure we're not over geometry
34200
+ if ( this._geometryCount >= this._maxGeometryCount ) {
34201
+
34202
+ throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34203
+
34204
+ }
34205
+
34206
+ // get the necessary range fo the geometry
34207
+ const reservedRange = {
34208
+ vertexStart: - 1,
34209
+ vertexCount: - 1,
34210
+ indexStart: - 1,
34211
+ indexCount: - 1,
34212
+ };
34213
+
34214
+ let lastRange = null;
34215
+ const reservedRanges = this._reservedRanges;
34216
+ const drawRanges = this._drawRanges;
34217
+ const bounds = this._bounds;
34218
+ if ( this._geometryCount !== 0 ) {
34219
+
34220
+ lastRange = reservedRanges[ reservedRanges.length - 1 ];
34221
+
34222
+ }
34223
+
34224
+ if ( vertexCount === - 1 ) {
34225
+
34226
+ reservedRange.vertexCount = geometry.getAttribute( 'position' ).count;
34227
+
34228
+ } else {
34229
+
34230
+ reservedRange.vertexCount = vertexCount;
34231
+
34232
+ }
34233
+
34234
+ if ( lastRange === null ) {
34235
+
34236
+ reservedRange.vertexStart = 0;
34237
+
34238
+ } else {
34239
+
34240
+ reservedRange.vertexStart = lastRange.vertexStart + lastRange.vertexCount;
34241
+
34242
+ }
34243
+
34244
+ const index = geometry.getIndex();
34245
+ const hasIndex = index !== null;
34246
+ if ( hasIndex ) {
34247
+
34248
+ if ( indexCount === - 1 ) {
34249
+
34250
+ reservedRange.indexCount = index.count;
34251
+
34252
+ } else {
34253
+
34254
+ reservedRange.indexCount = indexCount;
34255
+
34256
+ }
34257
+
34258
+ if ( lastRange === null ) {
34259
+
34260
+ reservedRange.indexStart = 0;
34261
+
34262
+ } else {
34263
+
34264
+ reservedRange.indexStart = lastRange.indexStart + lastRange.indexCount;
34265
+
34266
+ }
34267
+
34268
+ }
34269
+
34270
+ if (
34271
+ reservedRange.indexStart !== - 1 &&
34272
+ reservedRange.indexStart + reservedRange.indexCount > this._maxIndexCount ||
34273
+ reservedRange.vertexStart + reservedRange.vertexCount > this._maxVertexCount
34274
+ ) {
34275
+
34276
+ throw new Error( 'BatchedMesh: Reserved space request exceeds the maximum buffer size.' );
34277
+
34278
+ }
34279
+
34280
+ const visibility = this._visibility;
34281
+ const active = this._active;
34282
+ const matricesTexture = this._matricesTexture;
34283
+ const matricesArray = this._matricesTexture.image.data;
34284
+
34285
+ // push new visibility states
34286
+ visibility.push( true );
34287
+ active.push( true );
34288
+
34289
+ // update id
34290
+ const geometryId = this._geometryCount;
34291
+ this._geometryCount ++;
34292
+
34293
+ // initialize matrix information
34294
+ _identityMatrix.toArray( matricesArray, geometryId * 16 );
34295
+ matricesTexture.needsUpdate = true;
34296
+
34297
+ // add the reserved range and draw range objects
34298
+ reservedRanges.push( reservedRange );
34299
+ drawRanges.push( {
34300
+ start: hasIndex ? reservedRange.indexStart : reservedRange.vertexStart,
34301
+ count: - 1
34302
+ } );
34303
+ bounds.push( {
34304
+ boxInitialized: false,
34305
+ box: new Box3(),
34306
+
34307
+ sphereInitialized: false,
34308
+ sphere: new Sphere()
34309
+ } );
34310
+
34311
+ // set the id for the geometry
34312
+ const idAttribute = this.geometry.getAttribute( ID_ATTR_NAME );
34313
+ for ( let i = 0; i < reservedRange.vertexCount; i ++ ) {
34314
+
34315
+ idAttribute.setX( reservedRange.vertexStart + i, geometryId );
34316
+
34317
+ }
34318
+
34319
+ idAttribute.needsUpdate = true;
34320
+
34321
+ // update the geometry
34322
+ this.setGeometryAt( geometryId, geometry );
34323
+
34324
+ return geometryId;
34325
+
34326
+ }
34327
+
34328
+ setGeometryAt( id, geometry ) {
34329
+
34330
+ if ( id >= this._geometryCount ) {
34331
+
34332
+ throw new Error( 'BatchedMesh: Maximum geometry count reached.' );
34333
+
34334
+ }
34335
+
34336
+ this._validateGeometry( geometry );
34337
+
34338
+ const batchGeometry = this.geometry;
34339
+ const hasIndex = batchGeometry.getIndex() !== null;
34340
+ const dstIndex = batchGeometry.getIndex();
34341
+ const srcIndex = geometry.getIndex();
34342
+ const reservedRange = this._reservedRanges[ id ];
34343
+ if (
34344
+ hasIndex &&
34345
+ srcIndex.count > reservedRange.indexCount ||
34346
+ geometry.attributes.position.count > reservedRange.vertexCount
34347
+ ) {
34348
+
34349
+ throw new Error( 'BatchedMesh: Reserved space not large enough for provided geometry.' );
34350
+
34351
+ }
34352
+
34353
+ // copy geometry over
34354
+ const vertexStart = reservedRange.vertexStart;
34355
+ const vertexCount = reservedRange.vertexCount;
34356
+ for ( const attributeName in batchGeometry.attributes ) {
34357
+
34358
+ if ( attributeName === ID_ATTR_NAME ) {
34359
+
34360
+ continue;
34361
+
34362
+ }
34363
+
34364
+ // copy attribute data
34365
+ const srcAttribute = geometry.getAttribute( attributeName );
34366
+ const dstAttribute = batchGeometry.getAttribute( attributeName );
34367
+ copyAttributeData( srcAttribute, dstAttribute, vertexStart );
34368
+
34369
+ // fill the rest in with zeroes
34370
+ const itemSize = srcAttribute.itemSize;
34371
+ for ( let i = srcAttribute.count, l = vertexCount; i < l; i ++ ) {
34372
+
34373
+ const index = vertexStart + i;
34374
+ for ( let c = 0; c < itemSize; c ++ ) {
34375
+
34376
+ dstAttribute.setComponent( index, c, 0 );
34377
+
34378
+ }
34379
+
34380
+ }
34381
+
34382
+ dstAttribute.needsUpdate = true;
34383
+
34384
+ }
34385
+
34386
+ // copy index
34387
+ if ( hasIndex ) {
34388
+
34389
+ const indexStart = reservedRange.indexStart;
34390
+
34391
+ // copy index data over
34392
+ for ( let i = 0; i < srcIndex.count; i ++ ) {
34393
+
34394
+ dstIndex.setX( indexStart + i, vertexStart + srcIndex.getX( i ) );
34395
+
34396
+ }
34397
+
34398
+ // fill the rest in with zeroes
34399
+ for ( let i = srcIndex.count, l = reservedRange.indexCount; i < l; i ++ ) {
34400
+
34401
+ dstIndex.setX( indexStart + i, vertexStart );
34402
+
34403
+ }
34404
+
34405
+ dstIndex.needsUpdate = true;
34406
+
34407
+ }
34408
+
34409
+ // store the bounding boxes
34410
+ const bound = this._bounds[ id ];
34411
+ if ( geometry.boundingBox !== null ) {
34412
+
34413
+ bound.box.copy( geometry.boundingBox );
34414
+ bound.boxInitialized = true;
34415
+
34416
+ } else {
34417
+
34418
+ bound.boxInitialized = false;
34419
+
34420
+ }
34421
+
34422
+ if ( geometry.boundingSphere !== null ) {
34423
+
34424
+ bound.sphere.copy( geometry.boundingSphere );
34425
+ bound.sphereInitialized = true;
34426
+
34427
+ } else {
34428
+
34429
+ bound.sphereInitialized = false;
34430
+
34431
+ }
34432
+
34433
+ // set drawRange count
34434
+ const drawRange = this._drawRanges[ id ];
34435
+ const posAttr = geometry.getAttribute( 'position' );
34436
+ drawRange.count = hasIndex ? srcIndex.count : posAttr.count;
34437
+ this._visibilityChanged = true;
34438
+
34439
+ return id;
34440
+
34441
+ }
34442
+
34443
+ deleteGeometry( geometryId ) {
34444
+
34445
+ // Note: User needs to call optimize() afterward to pack the data.
34446
+
34447
+ const active = this._active;
34448
+ if ( geometryId >= active.length || active[ geometryId ] === false ) {
34449
+
34450
+ return this;
34451
+
34452
+ }
34453
+
34454
+ active[ geometryId ] = false;
34455
+ this._visibilityChanged = true;
34456
+
34457
+ return this;
34458
+
34459
+ }
34460
+
34461
+ // get bounding box and compute it if it doesn't exist
34462
+ getBoundingBoxAt( id, target ) {
34463
+
34464
+ const active = this._active;
34465
+ if ( active[ id ] === false ) {
34466
+
34467
+ return this;
34468
+
34469
+ }
34470
+
34471
+ // compute bounding box
34472
+ const bound = this._bounds[ id ];
34473
+ const box = bound.box;
34474
+ const geometry = this.geometry;
34475
+ if ( bound.boxInitialized === false ) {
34476
+
34477
+ box.makeEmpty();
34478
+
34479
+ const index = geometry.index;
34480
+ const position = geometry.attributes.position;
34481
+ const drawRange = this._drawRanges[ id ];
34482
+ for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
34483
+
34484
+ let iv = i;
34485
+ if ( index ) {
34486
+
34487
+ iv = index.getX( iv );
34488
+
34489
+ }
34490
+
34491
+ box.expandByPoint( _vector$5.fromBufferAttribute( position, iv ) );
34492
+
34493
+ }
34494
+
34495
+ bound.boxInitialized = true;
34496
+
34497
+ }
34498
+
34499
+ target.copy( box );
34500
+ return target;
34501
+
34502
+ }
34503
+
34504
+ // get bounding sphere and compute it if it doesn't exist
34505
+ getBoundingSphereAt( id, target ) {
34506
+
34507
+ const active = this._active;
34508
+ if ( active[ id ] === false ) {
34509
+
34510
+ return this;
34511
+
34512
+ }
34513
+
34514
+ // compute bounding sphere
34515
+ const bound = this._bounds[ id ];
34516
+ const sphere = bound.sphere;
34517
+ const geometry = this.geometry;
34518
+ if ( bound.sphereInitialized === false ) {
34519
+
34520
+ sphere.makeEmpty();
34521
+
34522
+ this.getBoundingBoxAt( id, _box$1 );
34523
+ _box$1.getCenter( sphere.center );
34524
+
34525
+ const index = geometry.index;
34526
+ const position = geometry.attributes.position;
34527
+ const drawRange = this._drawRanges[ id ];
34528
+
34529
+ let maxRadiusSq = 0;
34530
+ for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
34531
+
34532
+ let iv = i;
34533
+ if ( index ) {
34534
+
34535
+ iv = index.getX( iv );
34536
+
34537
+ }
34538
+
34539
+ _vector$5.fromBufferAttribute( position, iv );
34540
+ maxRadiusSq = Math.max( maxRadiusSq, sphere.center.distanceToSquared( _vector$5 ) );
34541
+
34542
+ }
34543
+
34544
+ sphere.radius = Math.sqrt( maxRadiusSq );
34545
+ bound.sphereInitialized = true;
34546
+
34547
+ }
34548
+
34549
+ target.copy( sphere );
34550
+ return target;
34551
+
34552
+ }
34553
+
34554
+ setMatrixAt( geometryId, matrix ) {
34555
+
34556
+ // @TODO: Map geometryId to index of the arrays because
34557
+ // optimize() can make geometryId mismatch the index
34558
+
34559
+ const active = this._active;
34560
+ const matricesTexture = this._matricesTexture;
34561
+ const matricesArray = this._matricesTexture.image.data;
34562
+ const geometryCount = this._geometryCount;
34563
+ if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
34564
+
34565
+ return this;
34566
+
34567
+ }
34568
+
34569
+ matrix.toArray( matricesArray, geometryId * 16 );
34570
+ matricesTexture.needsUpdate = true;
34571
+
34572
+ return this;
34573
+
34574
+ }
34575
+
34576
+ getMatrixAt( geometryId, matrix ) {
34577
+
34578
+ const active = this._active;
34579
+ const matricesArray = this._matricesTexture.image.data;
34580
+ const geometryCount = this._geometryCount;
34581
+ if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
34582
+
34583
+ return null;
34584
+
34585
+ }
34586
+
34587
+ return matrix.fromArray( matricesArray, geometryId * 16 );
34588
+
34589
+ }
34590
+
34591
+ setVisibleAt( geometryId, value ) {
34592
+
34593
+ const visibility = this._visibility;
34594
+ const active = this._active;
34595
+ const geometryCount = this._geometryCount;
34596
+
34597
+ // if the geometry is out of range, not active, or visibility state
34598
+ // does not change then return early
34599
+ if (
34600
+ geometryId >= geometryCount ||
34601
+ active[ geometryId ] === false ||
34602
+ visibility[ geometryId ] === value
34603
+ ) {
34604
+
34605
+ return this;
34606
+
34607
+ }
34608
+
34609
+ visibility[ geometryId ] = value;
34610
+ this._visibilityChanged = true;
34611
+
34612
+ return this;
34613
+
34614
+ }
34615
+
34616
+ getVisibleAt( geometryId ) {
34617
+
34618
+ const visibility = this._visibility;
34619
+ const active = this._active;
34620
+ const geometryCount = this._geometryCount;
34621
+
34622
+ // return early if the geometry is out of range or not active
34623
+ if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
34624
+
34625
+ return false;
34626
+
34627
+ }
34628
+
34629
+ return visibility[ geometryId ];
34630
+
34631
+ }
34632
+
34633
+ raycast( raycaster, intersects ) {
34634
+
34635
+ const visibility = this._visibility;
34636
+ const active = this._active;
34637
+ const drawRanges = this._drawRanges;
34638
+ const geometryCount = this._geometryCount;
34639
+ const matrixWorld = this.matrixWorld;
34640
+ const batchGeometry = this.geometry;
34641
+
34642
+ // iterate over each geometry
34643
+ _mesh.material = this.material;
34644
+ _mesh.geometry.index = batchGeometry.index;
34645
+ _mesh.geometry.attributes = batchGeometry.attributes;
34646
+ if ( _mesh.geometry.boundingBox === null ) {
34647
+
34648
+ _mesh.geometry.boundingBox = new Box3();
34649
+
34650
+ }
34651
+
34652
+ if ( _mesh.geometry.boundingSphere === null ) {
34653
+
34654
+ _mesh.geometry.boundingSphere = new Sphere();
34655
+
34656
+ }
34657
+
34658
+ for ( let i = 0; i < geometryCount; i ++ ) {
34659
+
34660
+ if ( ! visibility[ i ] || ! active[ i ] ) {
34661
+
34662
+ continue;
34663
+
34664
+ }
34665
+
34666
+ const drawRange = drawRanges[ i ];
34667
+ _mesh.geometry.setDrawRange( drawRange.start, drawRange.count );
34668
+
34669
+ // ge the intersects
34670
+ this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
34671
+ this.getBoundingBoxAt( i, _mesh.geometry.boundingBox );
34672
+ this.getBoundingSphereAt( i, _mesh.geometry.boundingSphere );
34673
+ _mesh.raycast( raycaster, _batchIntersects );
34674
+
34675
+ // add batch id to the intersects
34676
+ for ( let j = 0, l = _batchIntersects.length; j < l; j ++ ) {
34677
+
34678
+ const intersect = _batchIntersects[ j ];
34679
+ intersect.object = this;
34680
+ intersect.batchId = i;
34681
+ intersects.push( intersect );
34682
+
34683
+ }
34684
+
34685
+ _batchIntersects.length = 0;
34686
+
34687
+ }
34688
+
34689
+ _mesh.material = null;
34690
+ _mesh.geometry.index = null;
34691
+ _mesh.geometry.attributes = {};
34692
+ _mesh.geometry.setDrawRange( 0, Infinity );
34693
+
34694
+ }
34695
+
34696
+ copy( source ) {
34697
+
34698
+ super.copy( source );
34699
+
34700
+ this.geometry = source.geometry.clone();
34701
+ this.perObjectFrustumCulled = source.perObjectFrustumCulled;
34702
+ this.sortObjects = source.sortObjects;
34703
+ this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
34704
+ this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;
34705
+
34706
+ this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
34707
+ this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
34708
+
34709
+ this._visibility = source._visibility.slice();
34710
+ this._active = source._active.slice();
34711
+ this._bounds = source._bounds.map( bound => ( {
34712
+ boxInitialized: bound.boxInitialized,
34713
+ box: bound.box.clone(),
34714
+
34715
+ sphereInitialized: bound.sphereInitialized,
34716
+ sphere: bound.sphere.clone()
34717
+ } ) );
34718
+
34719
+ this._maxGeometryCount = source._maxGeometryCount;
34720
+ this._maxVertexCount = source._maxVertexCount;
34721
+ this._maxIndexCount = source._maxIndexCount;
34722
+
34723
+ this._geometryInitialized = source._geometryInitialized;
34724
+ this._geometryCount = source._geometryCount;
34725
+ this._multiDrawCounts = source._multiDrawCounts.slice();
34726
+ this._multiDrawStarts = source._multiDrawStarts.slice();
34727
+
34728
+ this._matricesTexture = source._matricesTexture.clone();
34729
+ this._matricesTexture.image.data = this._matricesTexture.image.slice();
34730
+
34731
+ return this;
34732
+
34733
+ }
34734
+
34735
+ dispose() {
34736
+
34737
+ // Assuming the geometry is not shared with other meshes
34738
+ this.geometry.dispose();
34739
+
34740
+ this._matricesTexture.dispose();
34741
+ this._matricesTexture = null;
34742
+ return this;
34743
+
34744
+ }
34745
+
34746
+ onBeforeRender( renderer, scene, camera, geometry, material/*, _group*/ ) {
34747
+
34748
+ // if visibility has not changed and frustum culling and object sorting is not required
34749
+ // then skip iterating over all items
34750
+ if ( ! this._visibilityChanged && ! this.perObjectFrustumCulled && ! this.sortObjects ) {
34751
+
34752
+ return;
34753
+
34754
+ }
34755
+
34756
+ // the indexed version of the multi draw function requires specifying the start
34757
+ // offset in bytes.
34758
+ const index = geometry.getIndex();
34759
+ const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
34760
+
34761
+ const visibility = this._visibility;
34762
+ const multiDrawStarts = this._multiDrawStarts;
34763
+ const multiDrawCounts = this._multiDrawCounts;
34764
+ const drawRanges = this._drawRanges;
34765
+ const perObjectFrustumCulled = this.perObjectFrustumCulled;
34766
+
34767
+ // prepare the frustum in the local frame
34768
+ if ( perObjectFrustumCulled ) {
34769
+
34770
+ _projScreenMatrix$2
34771
+ .multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse )
34772
+ .multiply( this.matrixWorld );
34773
+ _frustum.setFromProjectionMatrix(
34774
+ _projScreenMatrix$2,
34775
+ renderer.isWebGPURenderer ? WebGPUCoordinateSystem : WebGLCoordinateSystem
34776
+ );
34777
+
34778
+ }
34779
+
34780
+ let count = 0;
34781
+ if ( this.sortObjects ) {
34782
+
34783
+ // get the camera position in the local frame
34784
+ _invMatrixWorld.copy( this.matrixWorld ).invert();
34785
+ _vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
34786
+
34787
+ for ( let i = 0, l = visibility.length; i < l; i ++ ) {
34788
+
34789
+ if ( visibility[ i ] ) {
34790
+
34791
+ // get the bounds in world space
34792
+ this.getMatrixAt( i, _matrix );
34793
+ this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix );
34794
+
34795
+ // determine whether the batched geometry is within the frustum
34796
+ let culled = false;
34797
+ if ( perObjectFrustumCulled ) {
34798
+
34799
+ culled = ! _frustum.intersectsSphere( _sphere$2 );
34800
+
34801
+ }
34802
+
34803
+ if ( ! culled ) {
34804
+
34805
+ // get the distance from camera used for sorting
34806
+ const z = _vector$5.distanceTo( _sphere$2.center );
34807
+ _renderList.push( drawRanges[ i ], z );
34808
+
34809
+ }
34810
+
34811
+ }
34812
+
34813
+ }
34814
+
34815
+ // Sort the draw ranges and prep for rendering
34816
+ const list = _renderList.list;
34817
+ const customSort = this.customSort;
34818
+ if ( customSort === null ) {
34819
+
34820
+ list.sort( material.transparent ? sortTransparent : sortOpaque );
34821
+
34822
+ } else {
34823
+
34824
+ customSort.call( this, list, camera );
34825
+
34826
+ }
34827
+
34828
+ for ( let i = 0, l = list.length; i < l; i ++ ) {
34829
+
34830
+ const item = list[ i ];
34831
+ multiDrawStarts[ count ] = item.start * bytesPerElement;
34832
+ multiDrawCounts[ count ] = item.count;
34833
+ count ++;
34834
+
34835
+ }
34836
+
34837
+ _renderList.reset();
34838
+
34839
+ } else {
34840
+
34841
+ for ( let i = 0, l = visibility.length; i < l; i ++ ) {
34842
+
34843
+ if ( visibility[ i ] ) {
34844
+
34845
+ // determine whether the batched geometry is within the frustum
34846
+ let culled = false;
34847
+ if ( perObjectFrustumCulled ) {
34848
+
34849
+ // get the bounds in world space
34850
+ this.getMatrixAt( i, _matrix );
34851
+ this.getBoundingSphereAt( i, _sphere$2 ).applyMatrix4( _matrix );
34852
+ culled = ! _frustum.intersectsSphere( _sphere$2 );
34853
+
34854
+ }
34855
+
34856
+ if ( ! culled ) {
34857
+
34858
+ const range = drawRanges[ i ];
34859
+ multiDrawStarts[ count ] = range.start * bytesPerElement;
34860
+ multiDrawCounts[ count ] = range.count;
34861
+ count ++;
34862
+
34863
+ }
34864
+
34865
+ }
34866
+
34867
+ }
34868
+
34869
+ }
34870
+
34871
+ this._multiDrawCount = count;
34872
+ this._visibilityChanged = false;
34873
+
34874
+ }
34875
+
34876
+ onBeforeShadow( renderer, object, camera, shadowCamera, geometry, depthMaterial/* , group */ ) {
34877
+
34878
+ this.onBeforeRender( renderer, null, shadowCamera, geometry, depthMaterial );
34879
+
34880
+ }
34881
+
34882
+ }
34883
+
33619
34884
  class LineBasicMaterial extends Material {
33620
34885
 
33621
34886
  constructor( parameters ) {
@@ -35431,6 +36696,7 @@ class LineCurve3 extends Curve {
35431
36696
  this.v2 = v2;
35432
36697
 
35433
36698
  }
36699
+
35434
36700
  getPoint( t, optionalTarget = new Vector3() ) {
35435
36701
 
35436
36702
  const point = optionalTarget;
@@ -35449,6 +36715,7 @@ class LineCurve3 extends Curve {
35449
36715
  return point;
35450
36716
 
35451
36717
  }
36718
+
35452
36719
  // Line curve is linear, so we can overwrite default getPointAt
35453
36720
  getPointAt( u, optionalTarget ) {
35454
36721
 
@@ -35478,6 +36745,7 @@ class LineCurve3 extends Curve {
35478
36745
  return this;
35479
36746
 
35480
36747
  }
36748
+
35481
36749
  toJSON() {
35482
36750
 
35483
36751
  const data = super.toJSON();
@@ -35488,6 +36756,7 @@ class LineCurve3 extends Curve {
35488
36756
  return data;
35489
36757
 
35490
36758
  }
36759
+
35491
36760
  fromJSON( json ) {
35492
36761
 
35493
36762
  super.fromJSON( json );
@@ -45390,13 +46659,6 @@ class BufferGeometryLoader extends Loader {
45390
46659
  if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name;
45391
46660
  if ( attribute.usage !== undefined ) bufferAttribute.setUsage( attribute.usage );
45392
46661
 
45393
- if ( attribute.updateRange !== undefined ) {
45394
-
45395
- bufferAttribute.updateRange.offset = attribute.updateRange.offset;
45396
- bufferAttribute.updateRange.count = attribute.updateRange.count;
45397
-
45398
- }
45399
-
45400
46662
  geometry.setAttribute( key, bufferAttribute );
45401
46663
 
45402
46664
  }
@@ -46338,6 +47600,52 @@ class ObjectLoader extends Loader {
46338
47600
 
46339
47601
  break;
46340
47602
 
47603
+ case 'BatchedMesh':
47604
+
47605
+ geometry = getGeometry( data.geometry );
47606
+ material = getMaterial( data.material );
47607
+
47608
+ object = new BatchedMesh( data.maxGeometryCount, data.maxVertexCount, data.maxIndexCount, material );
47609
+ object.geometry = geometry;
47610
+ object.perObjectFrustumCulled = data.perObjectFrustumCulled;
47611
+ object.sortObjects = data.sortObjects;
47612
+
47613
+ object._drawRanges = data.drawRanges;
47614
+ object._reservedRanges = data.reservedRanges;
47615
+
47616
+ object._visibility = data.visibility;
47617
+ object._active = data.active;
47618
+ object._bounds = data.bounds.map( bound => {
47619
+
47620
+ const box = new Box3();
47621
+ box.min.fromArray( bound.boxMin );
47622
+ box.max.fromArray( bound.boxMax );
47623
+
47624
+ const sphere = new Sphere();
47625
+ sphere.radius = bound.sphereRadius;
47626
+ sphere.center.fromArray( bound.sphereCenter );
47627
+
47628
+ return {
47629
+ boxInitialized: bound.boxInitialized,
47630
+ box: box,
47631
+
47632
+ sphereInitialized: bound.sphereInitialized,
47633
+ sphere: sphere
47634
+ };
47635
+
47636
+ } );
47637
+
47638
+ object._maxGeometryCount = data.maxGeometryCount;
47639
+ object._maxVertexCount = data.maxVertexCount;
47640
+ object._maxIndexCount = data.maxIndexCount;
47641
+
47642
+ object._geometryInitialized = data.geometryInitialized;
47643
+ object._geometryCount = data.geometryCount;
47644
+
47645
+ object._matricesTexture = getTexture( data.matricesTexture.uuid );
47646
+
47647
+ break;
47648
+
46341
47649
  case 'LOD':
46342
47650
 
46343
47651
  object = new LOD();
@@ -46585,6 +47893,25 @@ class ImageBitmapLoader extends Loader {
46585
47893
 
46586
47894
  scope.manager.itemStart( url );
46587
47895
 
47896
+ // If cached is a promise, wait for it to resolve
47897
+ if ( cached.then ) {
47898
+
47899
+ cached.then( imageBitmap => {
47900
+
47901
+ if ( onLoad ) onLoad( imageBitmap );
47902
+
47903
+ scope.manager.itemEnd( url );
47904
+
47905
+ } ).catch( e => {
47906
+
47907
+ if ( onError ) onError( e );
47908
+
47909
+ } );
47910
+ return;
47911
+
47912
+ }
47913
+
47914
+ // If cached is not a promise (i.e., it's already an imageBitmap)
46588
47915
  setTimeout( function () {
46589
47916
 
46590
47917
  if ( onLoad ) onLoad( cached );
@@ -46601,7 +47928,7 @@ class ImageBitmapLoader extends Loader {
46601
47928
  fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include';
46602
47929
  fetchOptions.headers = this.requestHeader;
46603
47930
 
46604
- fetch( url, fetchOptions ).then( function ( res ) {
47931
+ const promise = fetch( url, fetchOptions ).then( function ( res ) {
46605
47932
 
46606
47933
  return res.blob();
46607
47934
 
@@ -46617,15 +47944,20 @@ class ImageBitmapLoader extends Loader {
46617
47944
 
46618
47945
  scope.manager.itemEnd( url );
46619
47946
 
47947
+ return imageBitmap;
47948
+
46620
47949
  } ).catch( function ( e ) {
46621
47950
 
46622
47951
  if ( onError ) onError( e );
46623
47952
 
47953
+ Cache.remove( url );
47954
+
46624
47955
  scope.manager.itemError( url );
46625
47956
  scope.manager.itemEnd( url );
46626
47957
 
46627
47958
  } );
46628
47959
 
47960
+ Cache.add( url, promise );
46629
47961
  scope.manager.itemStart( url );
46630
47962
 
46631
47963
  }
@@ -46686,7 +48018,7 @@ class AudioLoader extends Loader {
46686
48018
 
46687
48019
  onLoad( audioBuffer );
46688
48020
 
46689
- }, handleError );
48021
+ } ).catch( handleError );
46690
48022
 
46691
48023
  } catch ( e ) {
46692
48024
 
@@ -50550,7 +51882,13 @@ class UniformsGroup extends EventDispatcher {
50550
51882
 
50551
51883
  for ( let i = 0, l = uniformsSource.length; i < l; i ++ ) {
50552
51884
 
50553
- this.uniforms.push( uniformsSource[ i ].clone() );
51885
+ const uniforms = Array.isArray( uniformsSource[ i ] ) ? uniformsSource[ i ] : [ uniformsSource[ i ] ];
51886
+
51887
+ for ( let j = 0; j < uniforms.length; j ++ ) {
51888
+
51889
+ this.uniforms.push( uniforms[ j ].clone() );
51890
+
51891
+ }
50554
51892
 
50555
51893
  }
50556
51894
 
@@ -52761,6 +54099,7 @@ exports.AddEquation = AddEquation;
52761
54099
  exports.AddOperation = AddOperation;
52762
54100
  exports.AdditiveAnimationBlendMode = AdditiveAnimationBlendMode;
52763
54101
  exports.AdditiveBlending = AdditiveBlending;
54102
+ exports.AgXToneMapping = AgXToneMapping;
52764
54103
  exports.AlphaFormat = AlphaFormat;
52765
54104
  exports.AlwaysCompare = AlwaysCompare;
52766
54105
  exports.AlwaysDepth = AlwaysDepth;
@@ -52785,6 +54124,7 @@ exports.AxesHelper = AxesHelper;
52785
54124
  exports.BackSide = BackSide;
52786
54125
  exports.BasicDepthPacking = BasicDepthPacking;
52787
54126
  exports.BasicShadowMap = BasicShadowMap;
54127
+ exports.BatchedMesh = BatchedMesh;
52788
54128
  exports.Bone = Bone;
52789
54129
  exports.BooleanKeyframeTrack = BooleanKeyframeTrack;
52790
54130
  exports.Box2 = Box2;