super-three 0.154.1 → 0.156.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 (172) hide show
  1. package/build/three.cjs +360 -160
  2. package/build/three.js +360 -160
  3. package/build/three.min.js +1 -1
  4. package/build/three.module.js +355 -161
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/controls/OrbitControls.js +155 -25
  7. package/examples/jsm/csm/CSMShader.js +35 -1
  8. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  9. package/examples/jsm/exporters/USDZExporter.js +1 -0
  10. package/examples/jsm/interactive/SelectionHelper.js +7 -0
  11. package/examples/jsm/libs/tween.module.js +790 -735
  12. package/examples/jsm/libs/utif.module.js +1644 -1558
  13. package/examples/jsm/loaders/DDSLoader.js +46 -3
  14. package/examples/jsm/loaders/EXRLoader.js +4 -4
  15. package/examples/jsm/loaders/FBXLoader.js +3 -1
  16. package/examples/jsm/loaders/GLTFLoader.js +25 -10
  17. package/examples/jsm/loaders/KTX2Loader.js +128 -79
  18. package/examples/jsm/loaders/LDrawLoader.js +1 -1
  19. package/examples/jsm/loaders/LogLuvLoader.js +2 -2
  20. package/examples/jsm/loaders/MMDLoader.js +10 -7
  21. package/examples/jsm/loaders/NRRDLoader.js +3 -3
  22. package/examples/jsm/loaders/PLYLoader.js +1 -1
  23. package/examples/jsm/loaders/RGBELoader.js +48 -66
  24. package/examples/jsm/loaders/STLLoader.js +7 -0
  25. package/examples/jsm/loaders/TGALoader.js +10 -10
  26. package/examples/jsm/loaders/VRMLLoader.js +1 -1
  27. package/examples/jsm/misc/GPUComputationRenderer.js +0 -9
  28. package/examples/jsm/misc/Volume.js +4 -6
  29. package/examples/jsm/nodes/Nodes.js +8 -6
  30. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +29 -3
  31. package/examples/jsm/nodes/accessors/CubeTextureNode.js +20 -3
  32. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +15 -4
  33. package/examples/jsm/nodes/accessors/InstanceNode.js +8 -8
  34. package/examples/jsm/nodes/accessors/LineMaterialNode.js +31 -0
  35. package/examples/jsm/nodes/accessors/MaterialNode.js +73 -61
  36. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +3 -0
  37. package/examples/jsm/nodes/accessors/Object3DNode.js +2 -2
  38. package/examples/jsm/nodes/accessors/SceneNode.js +6 -0
  39. package/examples/jsm/nodes/accessors/TextureNode.js +54 -9
  40. package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
  41. package/examples/jsm/nodes/core/AttributeNode.js +2 -2
  42. package/examples/jsm/nodes/core/LightingModel.js +7 -9
  43. package/examples/jsm/nodes/core/Node.js +28 -3
  44. package/examples/jsm/nodes/core/NodeBuilder.js +94 -12
  45. package/examples/jsm/nodes/core/NodeUniform.js +1 -1
  46. package/examples/jsm/nodes/core/OutputStructNode.js +58 -0
  47. package/examples/jsm/nodes/core/PropertyNode.js +6 -0
  48. package/examples/jsm/nodes/core/StackNode.js +4 -4
  49. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  50. package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
  51. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  52. package/examples/jsm/nodes/display/ViewportNode.js +19 -5
  53. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -2
  54. package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
  55. package/examples/jsm/nodes/functions/PhongLightingModel.js +53 -14
  56. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +236 -97
  57. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  58. package/examples/jsm/nodes/gpgpu/ComputeNode.js +13 -0
  59. package/examples/jsm/nodes/lighting/AONode.js +1 -1
  60. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +58 -20
  61. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +7 -10
  62. package/examples/jsm/nodes/lighting/EnvironmentNode.js +22 -12
  63. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +1 -1
  64. package/examples/jsm/nodes/lighting/LightingContextNode.js +12 -9
  65. package/examples/jsm/nodes/lighting/PointLightNode.js +7 -10
  66. package/examples/jsm/nodes/lighting/SpotLightNode.js +7 -10
  67. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  68. package/examples/jsm/nodes/materials/Materials.js +2 -0
  69. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
  70. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -0
  71. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
  72. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +19 -2
  73. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +2 -2
  74. package/examples/jsm/nodes/materials/NodeMaterial.js +61 -26
  75. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  76. package/examples/jsm/nodes/math/HashNode.js +35 -0
  77. package/examples/jsm/nodes/shadernode/ShaderNode.js +6 -2
  78. package/examples/jsm/nodes/utils/SplitNode.js +1 -1
  79. package/examples/jsm/objects/Reflector.js +1 -9
  80. package/examples/jsm/objects/Refractor.js +0 -8
  81. package/examples/jsm/offscreen/scene.js +0 -1
  82. package/examples/jsm/postprocessing/FilmPass.js +3 -5
  83. package/examples/jsm/postprocessing/MaskPass.js +4 -1
  84. package/examples/jsm/postprocessing/OutputPass.js +33 -14
  85. package/examples/jsm/postprocessing/RenderPass.js +30 -12
  86. package/examples/jsm/postprocessing/SAOPass.js +23 -98
  87. package/examples/jsm/postprocessing/SSAOPass.js +10 -30
  88. package/examples/jsm/postprocessing/UnrealBloomPass.js +21 -17
  89. package/examples/jsm/renderers/common/Backend.js +11 -8
  90. package/examples/jsm/renderers/common/Background.js +22 -20
  91. package/examples/jsm/renderers/common/Binding.js +14 -0
  92. package/examples/jsm/renderers/common/Bindings.js +7 -10
  93. package/examples/jsm/renderers/common/Geometries.js +1 -1
  94. package/examples/jsm/renderers/common/Pipelines.js +96 -47
  95. package/examples/jsm/renderers/common/RenderContext.js +1 -0
  96. package/examples/jsm/renderers/common/RenderContexts.js +41 -5
  97. package/examples/jsm/renderers/common/RenderList.js +12 -4
  98. package/examples/jsm/renderers/common/RenderObject.js +26 -6
  99. package/examples/jsm/renderers/common/RenderObjects.js +10 -7
  100. package/examples/jsm/renderers/common/Renderer.js +82 -42
  101. package/examples/jsm/renderers/common/SampledTexture.js +2 -1
  102. package/examples/jsm/renderers/common/Sampler.js +1 -1
  103. package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
  104. package/examples/jsm/renderers/common/Textures.js +172 -20
  105. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +2 -2
  106. package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -1
  107. package/examples/jsm/renderers/common/nodes/Nodes.js +58 -13
  108. package/examples/jsm/renderers/webgl/WebGLBackend.js +607 -0
  109. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +118 -17
  110. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
  111. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
  112. package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
  113. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +199 -0
  114. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
  115. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
  116. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +1 -1
  117. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +320 -84
  118. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
  119. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +120 -66
  120. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
  121. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +55 -36
  122. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +96 -5
  123. package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +24 -22
  124. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +117 -139
  125. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +60 -142
  126. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +7 -6
  127. package/examples/jsm/shaders/FilmShader.js +11 -54
  128. package/examples/jsm/shaders/OutputShader.js +19 -2
  129. package/examples/jsm/shaders/SAOShader.js +0 -13
  130. package/examples/jsm/shaders/SSAOShader.js +33 -26
  131. package/examples/jsm/utils/BufferGeometryUtils.js +13 -4
  132. package/examples/jsm/webxr/OculusHandPointerModel.js +2 -2
  133. package/package.json +2 -2
  134. package/src/Three.js +3 -0
  135. package/src/animation/PropertyBinding.js +1 -1
  136. package/src/audio/Audio.js +6 -0
  137. package/src/cameras/CubeCamera.js +1 -4
  138. package/src/constants.js +4 -1
  139. package/src/core/BufferAttribute.js +20 -0
  140. package/src/core/Object3D.js +2 -15
  141. package/src/core/RenderTarget.js +122 -0
  142. package/src/core/UniformsGroup.js +2 -2
  143. package/src/geometries/CapsuleGeometry.js +1 -1
  144. package/src/loaders/DataTextureLoader.js +19 -2
  145. package/src/materials/Material.js +2 -2
  146. package/src/math/Vector2.js +2 -2
  147. package/src/math/Vector3.js +3 -3
  148. package/src/math/Vector4.js +4 -4
  149. package/src/objects/Line.js +1 -1
  150. package/src/objects/Mesh.js +1 -1
  151. package/src/objects/Points.js +1 -1
  152. package/src/renderers/WebGLMultipleRenderTargets.js +0 -2
  153. package/src/renderers/WebGLRenderTarget.js +3 -110
  154. package/src/renderers/WebGLRenderer.js +83 -57
  155. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +1 -2
  156. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
  157. package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
  158. package/src/renderers/webgl/WebGLBackground.js +5 -14
  159. package/src/renderers/webgl/WebGLGeometries.js +5 -1
  160. package/src/renderers/webgl/WebGLMaterials.js +1 -1
  161. package/src/renderers/webgl/WebGLProgram.js +2 -0
  162. package/src/renderers/webgl/WebGLPrograms.js +19 -3
  163. package/src/renderers/webgl/WebGLTextures.js +101 -16
  164. package/src/renderers/webgl/WebGLUtils.js +27 -20
  165. package/src/textures/CompressedCubeTexture.js +19 -0
  166. package/src/textures/Texture.js +2 -2
  167. package/src/utils.js +9 -1
  168. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +0 -30
  169. package/examples/jsm/renderers/common/RenderTarget.js +0 -15
  170. package/examples/jsm/renderers/common/nodes/NodeRender.js +0 -302
  171. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
  172. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +0 -0
package/build/three.cjs CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const REVISION = '154';
8
+ const REVISION = '156';
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 };
@@ -129,6 +129,8 @@ const RGBA_ASTC_10x10_Format = 37819;
129
129
  const RGBA_ASTC_12x10_Format = 37820;
130
130
  const RGBA_ASTC_12x12_Format = 37821;
131
131
  const RGBA_BPTC_Format = 36492;
132
+ const RGB_BPTC_SIGNED_Format = 36494;
133
+ const RGB_BPTC_UNSIGNED_Format = 36495;
132
134
  const RED_RGTC1_Format = 36283;
133
135
  const SIGNED_RED_RGTC1_Format = 36284;
134
136
  const RED_GREEN_RGTC2_Format = 36285;
@@ -161,6 +163,7 @@ const NoColorSpace = '';
161
163
  const SRGBColorSpace = 'srgb';
162
164
  const LinearSRGBColorSpace = 'srgb-linear';
163
165
  const DisplayP3ColorSpace = 'display-p3';
166
+ const LinearDisplayP3ColorSpace = 'display-p3-linear';
164
167
 
165
168
  const ZeroStencilOp = 0;
166
169
  const KeepStencilOp = 7680;
@@ -921,8 +924,8 @@ class Vector2 {
921
924
 
922
925
  roundToZero() {
923
926
 
924
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
925
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
927
+ this.x = Math.trunc( this.x );
928
+ this.y = Math.trunc( this.y );
926
929
 
927
930
  return this;
928
931
 
@@ -1530,6 +1533,14 @@ function createElementNS( name ) {
1530
1533
 
1531
1534
  }
1532
1535
 
1536
+ function createCanvasElement() {
1537
+
1538
+ const canvas = createElementNS( 'canvas' );
1539
+ canvas.style.display = 'block';
1540
+ return canvas;
1541
+
1542
+ }
1543
+
1533
1544
  const _cache = {};
1534
1545
 
1535
1546
  function warnOnce( message ) {
@@ -1921,7 +1932,7 @@ function serializeImage( image ) {
1921
1932
 
1922
1933
  }
1923
1934
 
1924
- let textureId = 0;
1935
+ let _textureId = 0;
1925
1936
 
1926
1937
  class Texture extends EventDispatcher {
1927
1938
 
@@ -1931,7 +1942,7 @@ class Texture extends EventDispatcher {
1931
1942
 
1932
1943
  this.isTexture = true;
1933
1944
 
1934
- Object.defineProperty( this, 'id', { value: textureId ++ } );
1945
+ Object.defineProperty( this, 'id', { value: _textureId ++ } );
1935
1946
 
1936
1947
  this.uuid = generateUUID();
1937
1948
 
@@ -2741,10 +2752,10 @@ class Vector4 {
2741
2752
 
2742
2753
  roundToZero() {
2743
2754
 
2744
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
2745
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
2746
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
2747
- this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
2755
+ this.x = Math.trunc( this.x );
2756
+ this.y = Math.trunc( this.y );
2757
+ this.z = Math.trunc( this.z );
2758
+ this.w = Math.trunc( this.w );
2748
2759
 
2749
2760
  return this;
2750
2761
 
@@ -2885,13 +2896,13 @@ class Vector4 {
2885
2896
  * Texture parameters for an auto-generated target texture
2886
2897
  * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
2887
2898
  */
2888
- class WebGLRenderTarget extends EventDispatcher {
2899
+ class RenderTarget extends EventDispatcher {
2889
2900
 
2890
2901
  constructor( width = 1, height = 1, options = {} ) {
2891
2902
 
2892
2903
  super();
2893
2904
 
2894
- this.isWebGLRenderTarget = true;
2905
+ this.isRenderTarget = true;
2895
2906
 
2896
2907
  this.width = width;
2897
2908
  this.height = height;
@@ -2994,6 +3005,18 @@ class WebGLRenderTarget extends EventDispatcher {
2994
3005
 
2995
3006
  }
2996
3007
 
3008
+ class WebGLRenderTarget extends RenderTarget {
3009
+
3010
+ constructor( width = 1, height = 1, options = {} ) {
3011
+
3012
+ super( width, height, options );
3013
+
3014
+ this.isWebGLRenderTarget = true;
3015
+
3016
+ }
3017
+
3018
+ }
3019
+
2997
3020
  class DataArrayTexture extends Texture {
2998
3021
 
2999
3022
  constructor( data = null, width = 1, height = 1, depth = 1 ) {
@@ -3128,8 +3151,6 @@ class WebGLMultipleRenderTargets extends WebGLRenderTarget {
3128
3151
  this.viewport.set( 0, 0, width, height );
3129
3152
  this.scissor.set( 0, 0, width, height );
3130
3153
 
3131
- return this;
3132
-
3133
3154
  }
3134
3155
 
3135
3156
  copy( source ) {
@@ -4242,9 +4263,9 @@ class Vector3 {
4242
4263
 
4243
4264
  roundToZero() {
4244
4265
 
4245
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
4246
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
4247
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
4266
+ this.x = Math.trunc( this.x );
4267
+ this.y = Math.trunc( this.y );
4268
+ this.z = Math.trunc( this.z );
4248
4269
 
4249
4270
  return this;
4250
4271
 
@@ -7474,20 +7495,7 @@ class Object3D extends EventDispatcher {
7474
7495
 
7475
7496
  clear() {
7476
7497
 
7477
- for ( let i = 0; i < this.children.length; i ++ ) {
7478
-
7479
- const object = this.children[ i ];
7480
-
7481
- object.parent = null;
7482
-
7483
- object.dispatchEvent( _removedEvent );
7484
-
7485
- }
7486
-
7487
- this.children.length = 0;
7488
-
7489
- return this;
7490
-
7498
+ return this.remove( ... this.children );
7491
7499
 
7492
7500
  }
7493
7501
 
@@ -8027,7 +8035,7 @@ class Object3D extends EventDispatcher {
8027
8035
  this.frustumCulled = source.frustumCulled;
8028
8036
  this.renderOrder = source.renderOrder;
8029
8037
 
8030
- this.animations = source.animations;
8038
+ this.animations = source.animations.slice();
8031
8039
 
8032
8040
  this.userData = JSON.parse( JSON.stringify( source.userData ) );
8033
8041
 
@@ -8378,7 +8386,7 @@ class Triangle {
8378
8386
 
8379
8387
  }
8380
8388
 
8381
- let materialId = 0;
8389
+ let _materialId = 0;
8382
8390
 
8383
8391
  class Material extends EventDispatcher {
8384
8392
 
@@ -8388,7 +8396,7 @@ class Material extends EventDispatcher {
8388
8396
 
8389
8397
  this.isMaterial = true;
8390
8398
 
8391
- Object.defineProperty( this, 'id', { value: materialId ++ } );
8399
+ Object.defineProperty( this, 'id', { value: _materialId ++ } );
8392
8400
 
8393
8401
  this.uuid = generateUUID();
8394
8402
 
@@ -9919,6 +9927,26 @@ class BufferAttribute {
9919
9927
 
9920
9928
  }
9921
9929
 
9930
+ getComponent( index, component ) {
9931
+
9932
+ let value = this.array[ index * this.itemSize + component ];
9933
+
9934
+ if ( this.normalized ) value = denormalize( value, this.array );
9935
+
9936
+ return value;
9937
+
9938
+ }
9939
+
9940
+ setComponent( index, component, value ) {
9941
+
9942
+ if ( this.normalized ) value = normalize( value, this.array );
9943
+
9944
+ this.array[ index * this.itemSize + component ] = value;
9945
+
9946
+ return this;
9947
+
9948
+ }
9949
+
9922
9950
  getX( index ) {
9923
9951
 
9924
9952
  let x = this.array[ index * this.itemSize ];
@@ -10337,7 +10365,7 @@ class Float64BufferAttribute extends BufferAttribute {
10337
10365
 
10338
10366
  }
10339
10367
 
10340
- let _id$1 = 0;
10368
+ let _id$2 = 0;
10341
10369
 
10342
10370
  const _m1 = /*@__PURE__*/ new Matrix4();
10343
10371
  const _obj = /*@__PURE__*/ new Object3D();
@@ -10354,7 +10382,7 @@ class BufferGeometry extends EventDispatcher {
10354
10382
 
10355
10383
  this.isBufferGeometry = true;
10356
10384
 
10357
- Object.defineProperty( this, 'id', { value: _id$1 ++ } );
10385
+ Object.defineProperty( this, 'id', { value: _id$2 ++ } );
10358
10386
 
10359
10387
  this.uuid = generateUUID();
10360
10388
 
@@ -11459,7 +11487,7 @@ class Mesh extends Object3D {
11459
11487
 
11460
11488
  }
11461
11489
 
11462
- this.material = source.material;
11490
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
11463
11491
  this.geometry = source.geometry;
11464
11492
 
11465
11493
  return this;
@@ -12701,10 +12729,8 @@ class CubeCamera extends Object3D {
12701
12729
 
12702
12730
  const currentRenderTarget = renderer.getRenderTarget();
12703
12731
 
12704
- const currentToneMapping = renderer.toneMapping;
12705
12732
  const currentXrEnabled = renderer.xr.enabled;
12706
12733
 
12707
- renderer.toneMapping = NoToneMapping;
12708
12734
  renderer.xr.enabled = false;
12709
12735
 
12710
12736
  const generateMipmaps = renderTarget.texture.generateMipmaps;
@@ -12733,7 +12759,6 @@ class CubeCamera extends Object3D {
12733
12759
 
12734
12760
  renderer.setRenderTarget( currentRenderTarget );
12735
12761
 
12736
- renderer.toneMapping = currentToneMapping;
12737
12762
  renderer.xr.enabled = currentXrEnabled;
12738
12763
 
12739
12764
  renderTarget.texture.needsPMREMUpdate = true;
@@ -13656,7 +13681,7 @@ var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGEN
13656
13681
 
13657
13682
  var bsdfs = "float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated";
13658
13683
 
13659
- var iridescence_fragment = "#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif";
13684
+ var iridescence_fragment = "#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif";
13660
13685
 
13661
13686
  var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif";
13662
13687
 
@@ -13752,7 +13777,7 @@ var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_
13752
13777
 
13753
13778
  var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif";
13754
13779
 
13755
- var map_fragment = "#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif";
13780
+ var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
13756
13781
 
13757
13782
  var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif";
13758
13783
 
@@ -13846,7 +13871,7 @@ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defin
13846
13871
 
13847
13872
  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}";
13848
13873
 
13849
- const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
13874
+ const fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}";
13850
13875
 
13851
13876
  const vertex$g = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}";
13852
13877
 
@@ -14666,24 +14691,15 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
14666
14691
 
14667
14692
  }
14668
14693
 
14669
- const xr = renderer.xr;
14670
- const environmentBlendMode = xr.getEnvironmentBlendMode();
14694
+ const environmentBlendMode = renderer.xr.getEnvironmentBlendMode();
14671
14695
 
14672
- switch ( environmentBlendMode ) {
14696
+ if ( environmentBlendMode === 'additive' ) {
14673
14697
 
14674
- case 'opaque':
14675
- forceClear = true;
14676
- break;
14698
+ state.buffers.color.setClear( 0, 0, 0, 1, premultipliedAlpha );
14677
14699
 
14678
- case 'additive':
14679
- state.buffers.color.setClear( 0, 0, 0, 1, premultipliedAlpha );
14680
- forceClear = true;
14681
- break;
14700
+ } else if ( environmentBlendMode === 'alpha-blend' ) {
14682
14701
 
14683
- case 'alpha-blend':
14684
- state.buffers.color.setClear( 0, 0, 0, 0, premultipliedAlpha );
14685
- forceClear = true;
14686
- break;
14702
+ state.buffers.color.setClear( 0, 0, 0, 0, premultipliedAlpha );
14687
14703
 
14688
14704
  }
14689
14705
 
@@ -17284,7 +17300,7 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
17284
17300
 
17285
17301
  }
17286
17302
 
17287
- } else {
17303
+ } else if ( geometryPosition !== undefined ) {
17288
17304
 
17289
17305
  const array = geometryPosition.array;
17290
17306
  version = geometryPosition.version;
@@ -17299,6 +17315,10 @@ function WebGLGeometries( gl, attributes, info, bindingStates ) {
17299
17315
 
17300
17316
  }
17301
17317
 
17318
+ } else {
17319
+
17320
+ return;
17321
+
17302
17322
  }
17303
17323
 
17304
17324
  const attribute = new ( arrayNeedsUint32( indices ) ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );
@@ -19794,6 +19814,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
19794
19814
 
19795
19815
  parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
19796
19816
 
19817
+ parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
19818
+
19797
19819
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
19798
19820
  ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',
19799
19821
 
@@ -20028,7 +20050,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20028
20050
 
20029
20051
  }
20030
20052
 
20031
- let _id = 0;
20053
+ let _id$1 = 0;
20032
20054
 
20033
20055
  class WebGLShaderCache {
20034
20056
 
@@ -20142,7 +20164,7 @@ class WebGLShaderStage {
20142
20164
 
20143
20165
  constructor( code ) {
20144
20166
 
20145
- this.id = _id ++;
20167
+ this.id = _id$1 ++;
20146
20168
 
20147
20169
  this.code = code;
20148
20170
  this.usedTimes = 0;
@@ -20306,6 +20328,18 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20306
20328
  const HAS_ATTRIBUTE_UV2 = !! geometry.attributes.uv2;
20307
20329
  const HAS_ATTRIBUTE_UV3 = !! geometry.attributes.uv3;
20308
20330
 
20331
+ let toneMapping = NoToneMapping;
20332
+
20333
+ if ( material.toneMapped ) {
20334
+
20335
+ if ( currentRenderTarget === null || currentRenderTarget.isXRRenderTarget === true ) {
20336
+
20337
+ toneMapping = renderer.toneMapping;
20338
+
20339
+ }
20340
+
20341
+ }
20342
+
20309
20343
  const parameters = {
20310
20344
 
20311
20345
  isWebGL2: IS_WEBGL2,
@@ -20466,8 +20500,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20466
20500
  shadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,
20467
20501
  shadowMapType: renderer.shadowMap.type,
20468
20502
 
20469
- toneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,
20470
- useLegacyLights: renderer.useLegacyLights,
20503
+ toneMapping: toneMapping,
20504
+ useLegacyLights: renderer._useLegacyLights,
20505
+
20506
+ decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( material.map.colorSpace === SRGBColorSpace ),
20471
20507
 
20472
20508
  premultipliedAlpha: material.premultipliedAlpha,
20473
20509
 
@@ -20670,6 +20706,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20670
20706
  _programLayers.enable( 17 );
20671
20707
  if ( parameters.pointsUvs )
20672
20708
  _programLayers.enable( 18 );
20709
+ if ( parameters.decodeVideoTexture )
20710
+ _programLayers.enable( 19 );
20673
20711
 
20674
20712
  array.push( _programLayers.mask );
20675
20713
 
@@ -23639,6 +23677,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
23639
23677
 
23640
23678
  }
23641
23679
 
23680
+ if ( glFormat === _gl.RED_INTEGER ) {
23681
+
23682
+ if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8UI;
23683
+ if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.R16UI;
23684
+ if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.R32UI;
23685
+ if ( glType === _gl.BYTE ) internalFormat = _gl.R8I;
23686
+ if ( glType === _gl.SHORT ) internalFormat = _gl.R16I;
23687
+ if ( glType === _gl.INT ) internalFormat = _gl.R32I;
23688
+
23689
+ }
23690
+
23642
23691
  if ( glFormat === _gl.RG ) {
23643
23692
 
23644
23693
  if ( glType === _gl.FLOAT ) internalFormat = _gl.RG32F;
@@ -23815,14 +23864,32 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
23815
23864
 
23816
23865
  for ( let i = 0; i < 6; i ++ ) {
23817
23866
 
23818
- _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );
23867
+ if ( Array.isArray( renderTargetProperties.__webglFramebuffer[ i ] ) ) {
23868
+
23869
+ for ( let level = 0; level < renderTargetProperties.__webglFramebuffer[ i ].length; level ++ ) _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ][ level ] );
23870
+
23871
+ } else {
23872
+
23873
+ _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );
23874
+
23875
+ }
23876
+
23819
23877
  if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] );
23820
23878
 
23821
23879
  }
23822
23880
 
23823
23881
  } else {
23824
23882
 
23825
- _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );
23883
+ if ( Array.isArray( renderTargetProperties.__webglFramebuffer ) ) {
23884
+
23885
+ for ( let level = 0; level < renderTargetProperties.__webglFramebuffer.length; level ++ ) _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ level ] );
23886
+
23887
+ } else {
23888
+
23889
+ _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );
23890
+
23891
+ }
23892
+
23826
23893
  if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer );
23827
23894
  if ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer );
23828
23895
 
@@ -24201,7 +24268,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24201
24268
  glFormat = utils.convert( texture.format, texture.colorSpace );
24202
24269
 
24203
24270
  let glType = utils.convert( texture.type ),
24204
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
24271
+ glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
24205
24272
 
24206
24273
  setTextureParameters( textureType, texture, supportsMips );
24207
24274
 
@@ -24797,7 +24864,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24797
24864
  // Render targets
24798
24865
 
24799
24866
  // Setup storage for target texture and bind it to correct framebuffer
24800
- function setupFrameBufferTexture( framebuffer, renderTarget, texture, attachment, textureTarget ) {
24867
+ function setupFrameBufferTexture( framebuffer, renderTarget, texture, attachment, textureTarget, level ) {
24801
24868
 
24802
24869
  const glFormat = utils.convert( texture.format, texture.colorSpace );
24803
24870
  const glType = utils.convert( texture.type );
@@ -24806,13 +24873,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24806
24873
 
24807
24874
  if ( ! renderTargetProperties.__hasExternalTextures ) {
24808
24875
 
24876
+ const width = Math.max( 1, renderTarget.width >> level );
24877
+ const height = Math.max( 1, renderTarget.height >> level );
24878
+
24809
24879
  if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {
24810
24880
 
24811
- state.texImage3D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null );
24881
+ state.texImage3D( textureTarget, level, glInternalFormat, width, height, renderTarget.depth, 0, glFormat, glType, null );
24812
24882
 
24813
24883
  } else {
24814
24884
 
24815
- state.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
24885
+ state.texImage2D( textureTarget, level, glInternalFormat, width, height, 0, glFormat, glType, null );
24816
24886
 
24817
24887
  }
24818
24888
 
@@ -24826,7 +24896,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24826
24896
 
24827
24897
  } else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
24828
24898
 
24829
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
24899
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
24830
24900
 
24831
24901
  }
24832
24902
 
@@ -25047,7 +25117,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25047
25117
 
25048
25118
  if ( colorTexture !== undefined ) {
25049
25119
 
25050
- setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D );
25120
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, 0 );
25051
25121
 
25052
25122
  }
25053
25123
 
@@ -25094,13 +25164,41 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25094
25164
 
25095
25165
  for ( let i = 0; i < 6; i ++ ) {
25096
25166
 
25097
- renderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();
25167
+ if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25168
+
25169
+ renderTargetProperties.__webglFramebuffer[ i ] = [];
25170
+
25171
+ for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
25172
+
25173
+ renderTargetProperties.__webglFramebuffer[ i ][ level ] = _gl.createFramebuffer();
25174
+
25175
+ }
25176
+
25177
+ } else {
25178
+
25179
+ renderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();
25180
+
25181
+ }
25098
25182
 
25099
25183
  }
25100
25184
 
25101
25185
  } else {
25102
25186
 
25103
- renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();
25187
+ if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25188
+
25189
+ renderTargetProperties.__webglFramebuffer = [];
25190
+
25191
+ for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
25192
+
25193
+ renderTargetProperties.__webglFramebuffer[ level ] = _gl.createFramebuffer();
25194
+
25195
+ }
25196
+
25197
+ } else {
25198
+
25199
+ renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();
25200
+
25201
+ }
25104
25202
 
25105
25203
  if ( isMultipleRenderTargets ) {
25106
25204
 
@@ -25180,7 +25278,19 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25180
25278
 
25181
25279
  for ( let i = 0; i < 6; i ++ ) {
25182
25280
 
25183
- setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i );
25281
+ if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25282
+
25283
+ for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
25284
+
25285
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ][ level ], renderTarget, texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level );
25286
+
25287
+ }
25288
+
25289
+ } else {
25290
+
25291
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0 );
25292
+
25293
+ }
25184
25294
 
25185
25295
  }
25186
25296
 
@@ -25203,7 +25313,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25203
25313
 
25204
25314
  state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
25205
25315
  setTextureParameters( _gl.TEXTURE_2D, attachment, supportsMips );
25206
- setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D );
25316
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
25207
25317
 
25208
25318
  if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) {
25209
25319
 
@@ -25235,7 +25345,20 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25235
25345
 
25236
25346
  state.bindTexture( glTextureType, textureProperties.__webglTexture );
25237
25347
  setTextureParameters( glTextureType, texture, supportsMips );
25238
- setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType );
25348
+
25349
+ if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
25350
+
25351
+ for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
25352
+
25353
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ level ], renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType, level );
25354
+
25355
+ }
25356
+
25357
+ } else {
25358
+
25359
+ setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType, 0 );
25360
+
25361
+ }
25239
25362
 
25240
25363
  if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
25241
25364
 
@@ -25424,13 +25547,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25424
25547
  const format = texture.format;
25425
25548
  const type = texture.type;
25426
25549
 
25427
- if ( texture.isCompressedTexture === true || texture.format === _SRGBAFormat ) return image;
25550
+ if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
25428
25551
 
25429
25552
  if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
25430
25553
 
25431
25554
  // sRGB
25432
25555
 
25433
- if ( colorSpace === SRGBColorSpace ) {
25556
+ if ( colorSpace === SRGBColorSpace || colorSpace === DisplayP3ColorSpace ) {
25434
25557
 
25435
25558
  if ( isWebGL2 === false ) {
25436
25559
 
@@ -25496,6 +25619,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25496
25619
 
25497
25620
  }
25498
25621
 
25622
+ const LinearTransferFunction = 0;
25623
+ const SRGBTransferFunction = 1;
25624
+
25499
25625
  function WebGLUtils( gl, extensions, capabilities ) {
25500
25626
 
25501
25627
  const isWebGL2 = capabilities.isWebGL2;
@@ -25504,6 +25630,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
25504
25630
 
25505
25631
  let extension;
25506
25632
 
25633
+ const transferFunction = ( colorSpace === SRGBColorSpace || colorSpace === DisplayP3ColorSpace ) ? SRGBTransferFunction : LinearTransferFunction;
25634
+
25507
25635
  if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
25508
25636
  if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
25509
25637
  if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
@@ -25570,7 +25698,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
25570
25698
 
25571
25699
  if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
25572
25700
 
25573
- if ( colorSpace === SRGBColorSpace ) {
25701
+ if ( transferFunction === SRGBTransferFunction ) {
25574
25702
 
25575
25703
  extension = extensions.get( 'WEBGL_compressed_texture_s3tc_srgb' );
25576
25704
 
@@ -25655,8 +25783,8 @@ function WebGLUtils( gl, extensions, capabilities ) {
25655
25783
 
25656
25784
  if ( extension !== null ) {
25657
25785
 
25658
- if ( p === RGB_ETC2_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
25659
- if ( p === RGBA_ETC2_EAC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
25786
+ if ( p === RGB_ETC2_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
25787
+ if ( p === RGBA_ETC2_EAC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
25660
25788
 
25661
25789
  } else {
25662
25790
 
@@ -25678,20 +25806,20 @@ function WebGLUtils( gl, extensions, capabilities ) {
25678
25806
 
25679
25807
  if ( extension !== null ) {
25680
25808
 
25681
- if ( p === RGBA_ASTC_4x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
25682
- if ( p === RGBA_ASTC_5x4_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
25683
- if ( p === RGBA_ASTC_5x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
25684
- if ( p === RGBA_ASTC_6x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
25685
- if ( p === RGBA_ASTC_6x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
25686
- if ( p === RGBA_ASTC_8x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
25687
- if ( p === RGBA_ASTC_8x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
25688
- if ( p === RGBA_ASTC_8x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
25689
- if ( p === RGBA_ASTC_10x5_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
25690
- if ( p === RGBA_ASTC_10x6_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
25691
- if ( p === RGBA_ASTC_10x8_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
25692
- if ( p === RGBA_ASTC_10x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
25693
- if ( p === RGBA_ASTC_12x10_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
25694
- if ( p === RGBA_ASTC_12x12_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
25809
+ if ( p === RGBA_ASTC_4x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR;
25810
+ if ( p === RGBA_ASTC_5x4_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR;
25811
+ if ( p === RGBA_ASTC_5x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR;
25812
+ if ( p === RGBA_ASTC_6x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR;
25813
+ if ( p === RGBA_ASTC_6x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR;
25814
+ if ( p === RGBA_ASTC_8x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR;
25815
+ if ( p === RGBA_ASTC_8x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR;
25816
+ if ( p === RGBA_ASTC_8x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR;
25817
+ if ( p === RGBA_ASTC_10x5_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR;
25818
+ if ( p === RGBA_ASTC_10x6_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR;
25819
+ if ( p === RGBA_ASTC_10x8_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR;
25820
+ if ( p === RGBA_ASTC_10x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR;
25821
+ if ( p === RGBA_ASTC_12x10_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR;
25822
+ if ( p === RGBA_ASTC_12x12_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR;
25695
25823
 
25696
25824
  } else {
25697
25825
 
@@ -25703,13 +25831,15 @@ function WebGLUtils( gl, extensions, capabilities ) {
25703
25831
 
25704
25832
  // BPTC
25705
25833
 
25706
- if ( p === RGBA_BPTC_Format ) {
25834
+ if ( p === RGBA_BPTC_Format || p === RGB_BPTC_SIGNED_Format || p === RGB_BPTC_UNSIGNED_Format ) {
25707
25835
 
25708
25836
  extension = extensions.get( 'EXT_texture_compression_bptc' );
25709
25837
 
25710
25838
  if ( extension !== null ) {
25711
25839
 
25712
- if ( p === RGBA_BPTC_Format ) return ( colorSpace === SRGBColorSpace ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
25840
+ if ( p === RGBA_BPTC_Format ) return ( transferFunction === SRGBTransferFunction ) ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT;
25841
+ if ( p === RGB_BPTC_SIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
25842
+ if ( p === RGB_BPTC_UNSIGNED_Format ) return extension.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
25713
25843
 
25714
25844
  } else {
25715
25845
 
@@ -27750,7 +27880,7 @@ function WebGLMaterials( renderer, properties ) {
27750
27880
  uniforms.lightMap.value = material.lightMap;
27751
27881
 
27752
27882
  // artist-friendly light intensity scaling factor
27753
- const scaleFactor = ( renderer.useLegacyLights === true ) ? Math.PI : 1;
27883
+ const scaleFactor = ( renderer._useLegacyLights === true ) ? Math.PI : 1;
27754
27884
 
27755
27885
  uniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;
27756
27886
 
@@ -28497,14 +28627,6 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
28497
28627
 
28498
28628
  }
28499
28629
 
28500
- function createCanvasElement() {
28501
-
28502
- const canvas = createElementNS( 'canvas' );
28503
- canvas.style.display = 'block';
28504
- return canvas;
28505
-
28506
- }
28507
-
28508
28630
  class WebGLRenderer {
28509
28631
 
28510
28632
  constructor( parameters = {} ) {
@@ -28589,7 +28711,7 @@ class WebGLRenderer {
28589
28711
 
28590
28712
  // physical lights
28591
28713
 
28592
- this.useLegacyLights = true;
28714
+ this._useLegacyLights = false;
28593
28715
 
28594
28716
  // tone mapping
28595
28717
 
@@ -29232,6 +29354,9 @@ class WebGLRenderer {
29232
29354
  if ( material.wireframe === true ) {
29233
29355
 
29234
29356
  index = geometries.getWireframeAttribute( geometry );
29357
+
29358
+ if ( index === undefined ) return;
29359
+
29235
29360
  rangeFactor = 2;
29236
29361
 
29237
29362
  }
@@ -29396,7 +29521,7 @@ class WebGLRenderer {
29396
29521
 
29397
29522
  } );
29398
29523
 
29399
- currentRenderState.setupLights( _this.useLegacyLights );
29524
+ currentRenderState.setupLights( _this._useLegacyLights );
29400
29525
 
29401
29526
  scene.traverse( function ( object ) {
29402
29527
 
@@ -29549,7 +29674,7 @@ class WebGLRenderer {
29549
29674
 
29550
29675
  // render scene
29551
29676
 
29552
- currentRenderState.setupLights( _this.useLegacyLights );
29677
+ currentRenderState.setupLights( _this._useLegacyLights );
29553
29678
 
29554
29679
  if ( camera.isArrayCamera ) {
29555
29680
 
@@ -30043,6 +30168,7 @@ class WebGLRenderer {
30043
30168
 
30044
30169
  materialProperties.outputColorSpace = parameters.outputColorSpace;
30045
30170
  materialProperties.instancing = parameters.instancing;
30171
+ materialProperties.instancingColor = parameters.instancingColor;
30046
30172
  materialProperties.skinning = parameters.skinning;
30047
30173
  materialProperties.morphTargets = parameters.morphTargets;
30048
30174
  materialProperties.morphNormals = parameters.morphNormals;
@@ -30071,7 +30197,18 @@ class WebGLRenderer {
30071
30197
  const morphTargets = !! geometry.morphAttributes.position;
30072
30198
  const morphNormals = !! geometry.morphAttributes.normal;
30073
30199
  const morphColors = !! geometry.morphAttributes.color;
30074
- const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
30200
+
30201
+ let toneMapping = NoToneMapping;
30202
+
30203
+ if ( material.toneMapped ) {
30204
+
30205
+ if ( _currentRenderTarget === null || _currentRenderTarget.isXRRenderTarget === true ) {
30206
+
30207
+ toneMapping = _this.toneMapping;
30208
+
30209
+ }
30210
+
30211
+ }
30075
30212
 
30076
30213
  const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
30077
30214
  const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
@@ -30126,6 +30263,14 @@ class WebGLRenderer {
30126
30263
 
30127
30264
  needsProgramChange = true;
30128
30265
 
30266
+ } else if ( object.isInstancedMesh && materialProperties.instancingColor === true && object.instanceColor === null ) {
30267
+
30268
+ needsProgramChange = true;
30269
+
30270
+ } else if ( object.isInstancedMesh && materialProperties.instancingColor === false && object.instanceColor !== null ) {
30271
+
30272
+ needsProgramChange = true;
30273
+
30129
30274
  } else if ( materialProperties.envMap !== envMap ) {
30130
30275
 
30131
30276
  needsProgramChange = true;
@@ -30212,48 +30357,28 @@ class WebGLRenderer {
30212
30357
 
30213
30358
  if ( refreshProgram || _currentCamera !== camera ) {
30214
30359
 
30215
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
30216
-
30217
- if ( capabilities.logarithmicDepthBuffer ) {
30218
-
30219
- p_uniforms.setValue( _gl, 'logDepthBufFC',
30220
- 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
30221
-
30222
- }
30360
+ // common camera uniforms
30223
30361
 
30224
- if ( _currentCamera !== camera ) {
30362
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
30363
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
30225
30364
 
30226
- _currentCamera = camera;
30365
+ const uCamPos = p_uniforms.map.cameraPosition;
30227
30366
 
30228
- // lighting uniforms depend on the camera so enforce an update
30229
- // now, in case this material supports lights - or later, when
30230
- // the next material that does gets activated:
30367
+ if ( uCamPos !== undefined ) {
30231
30368
 
30232
- refreshMaterial = true; // set to true on material change
30233
- refreshLights = true; // remains set until update done
30369
+ uCamPos.setValue( _gl, _vector3.setFromMatrixPosition( camera.matrixWorld ) );
30234
30370
 
30235
30371
  }
30236
30372
 
30237
- // load material specific uniforms
30238
- // (shader material also gets them for the sake of genericity)
30239
-
30240
- if ( material.isShaderMaterial ||
30241
- material.isMeshPhongMaterial ||
30242
- material.isMeshToonMaterial ||
30243
- material.isMeshStandardMaterial ||
30244
- material.envMap ) {
30245
-
30246
- const uCamPos = p_uniforms.map.cameraPosition;
30247
-
30248
- if ( uCamPos !== undefined ) {
30249
-
30250
- uCamPos.setValue( _gl,
30251
- _vector3.setFromMatrixPosition( camera.matrixWorld ) );
30373
+ if ( capabilities.logarithmicDepthBuffer ) {
30252
30374
 
30253
- }
30375
+ p_uniforms.setValue( _gl, 'logDepthBufFC',
30376
+ 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
30254
30377
 
30255
30378
  }
30256
30379
 
30380
+ // consider moving isOrthographic to UniformLib and WebGLMaterials, see https://github.com/mrdoob/three.js/pull/26467#issuecomment-1645185067
30381
+
30257
30382
  if ( material.isMeshPhongMaterial ||
30258
30383
  material.isMeshToonMaterial ||
30259
30384
  material.isMeshLambertMaterial ||
@@ -30265,16 +30390,16 @@ class WebGLRenderer {
30265
30390
 
30266
30391
  }
30267
30392
 
30268
- if ( material.isMeshPhongMaterial ||
30269
- material.isMeshToonMaterial ||
30270
- material.isMeshLambertMaterial ||
30271
- material.isMeshBasicMaterial ||
30272
- material.isMeshStandardMaterial ||
30273
- material.isShaderMaterial ||
30274
- material.isShadowMaterial ||
30275
- object.isSkinnedMesh ) {
30393
+ if ( _currentCamera !== camera ) {
30394
+
30395
+ _currentCamera = camera;
30396
+
30397
+ // lighting uniforms depend on the camera so enforce an update
30398
+ // now, in case this material supports lights - or later, when
30399
+ // the next material that does gets activated:
30276
30400
 
30277
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
30401
+ refreshMaterial = true; // set to true on material change
30402
+ refreshLights = true; // remains set until update done
30278
30403
 
30279
30404
  }
30280
30405
 
@@ -30567,7 +30692,16 @@ class WebGLRenderer {
30567
30692
 
30568
30693
  if ( renderTarget.isWebGLCubeRenderTarget ) {
30569
30694
 
30570
- framebuffer = __webglFramebuffer[ activeCubeFace ];
30695
+ if ( Array.isArray( __webglFramebuffer[ activeCubeFace ] ) ) {
30696
+
30697
+ framebuffer = __webglFramebuffer[ activeCubeFace ][ activeMipmapLevel ];
30698
+
30699
+ } else {
30700
+
30701
+ framebuffer = __webglFramebuffer[ activeCubeFace ];
30702
+
30703
+ }
30704
+
30571
30705
  isCube = true;
30572
30706
 
30573
30707
  } else if ( ( capabilities.isWebGL2 && renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
@@ -30576,7 +30710,15 @@ class WebGLRenderer {
30576
30710
 
30577
30711
  } else {
30578
30712
 
30579
- framebuffer = __webglFramebuffer;
30713
+ if ( Array.isArray( __webglFramebuffer ) ) {
30714
+
30715
+ framebuffer = __webglFramebuffer[ activeMipmapLevel ];
30716
+
30717
+ } else {
30718
+
30719
+ framebuffer = __webglFramebuffer;
30720
+
30721
+ }
30580
30722
 
30581
30723
  }
30582
30724
 
@@ -30875,14 +31017,14 @@ class WebGLRenderer {
30875
31017
 
30876
31018
  get physicallyCorrectLights() { // @deprecated, r150
30877
31019
 
30878
- console.warn( 'THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
31020
+ console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
30879
31021
  return ! this.useLegacyLights;
30880
31022
 
30881
31023
  }
30882
31024
 
30883
31025
  set physicallyCorrectLights( value ) { // @deprecated, r150
30884
31026
 
30885
- console.warn( 'THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
31027
+ console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
30886
31028
  this.useLegacyLights = ! value;
30887
31029
 
30888
31030
  }
@@ -30901,6 +31043,20 @@ class WebGLRenderer {
30901
31043
 
30902
31044
  }
30903
31045
 
31046
+ get useLegacyLights() { // @deprecated, r155
31047
+
31048
+ console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
31049
+ return this._useLegacyLights;
31050
+
31051
+ }
31052
+
31053
+ set useLegacyLights( value ) { // @deprecated, r155
31054
+
31055
+ console.warn( 'THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.' );
31056
+ this._useLegacyLights = value;
31057
+
31058
+ }
31059
+
30904
31060
  }
30905
31061
 
30906
31062
  class WebGL1Renderer extends WebGLRenderer {}
@@ -32800,7 +32956,7 @@ class Line extends Object3D {
32800
32956
 
32801
32957
  super.copy( source, recursive );
32802
32958
 
32803
- this.material = source.material;
32959
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
32804
32960
  this.geometry = source.geometry;
32805
32961
 
32806
32962
  return this;
@@ -33121,7 +33277,7 @@ class Points extends Object3D {
33121
33277
 
33122
33278
  super.copy( source, recursive );
33123
33279
 
33124
- this.material = source.material;
33280
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
33125
33281
  this.geometry = source.geometry;
33126
33282
 
33127
33283
  return this;
@@ -33361,6 +33517,21 @@ class CompressedArrayTexture extends CompressedTexture {
33361
33517
 
33362
33518
  }
33363
33519
 
33520
+ class CompressedCubeTexture extends CompressedTexture {
33521
+
33522
+ constructor( images, format, type ) {
33523
+
33524
+ super( undefined, images[ 0 ].width, images[ 0 ].height, format, type, CubeReflectionMapping );
33525
+
33526
+ this.isCompressedCubeTexture = true;
33527
+ this.isCubeTexture = true;
33528
+
33529
+ this.image = images;
33530
+
33531
+ }
33532
+
33533
+ }
33534
+
33364
33535
  class CanvasTexture extends Texture {
33365
33536
 
33366
33537
  constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
@@ -35471,7 +35642,7 @@ class CapsuleGeometry extends LatheGeometry {
35471
35642
 
35472
35643
  this.parameters = {
35473
35644
  radius: radius,
35474
- height: length,
35645
+ length: length,
35475
35646
  capSegments: capSegments,
35476
35647
  radialSegments: radialSegments,
35477
35648
  };
@@ -42921,9 +43092,26 @@ class DataTextureLoader extends Loader {
42921
43092
  loader.setWithCredentials( scope.withCredentials );
42922
43093
  loader.load( url, function ( buffer ) {
42923
43094
 
42924
- const texData = scope.parse( buffer );
43095
+ let texData;
43096
+
43097
+ try {
43098
+
43099
+ texData = scope.parse( buffer );
43100
+
43101
+ } catch ( error ) {
42925
43102
 
42926
- if ( ! texData ) return;
43103
+ if ( onError !== undefined ) {
43104
+
43105
+ onError( error );
43106
+
43107
+ } else {
43108
+
43109
+ console.error( error );
43110
+ return;
43111
+
43112
+ }
43113
+
43114
+ }
42927
43115
 
42928
43116
  if ( texData.image !== undefined ) {
42929
43117
 
@@ -46345,6 +46533,12 @@ class Audio extends Object3D {
46345
46533
 
46346
46534
  disconnect() {
46347
46535
 
46536
+ if ( this._connected === false ) {
46537
+
46538
+ return;
46539
+
46540
+ }
46541
+
46348
46542
  if ( this.filters.length > 0 ) {
46349
46543
 
46350
46544
  this.source.disconnect( this.filters[ 0 ] );
@@ -47460,7 +47654,7 @@ class PropertyBinding {
47460
47654
  // ensure there is a value node
47461
47655
  if ( ! targetObject ) {
47462
47656
 
47463
- console.error( 'THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\'t found.' );
47657
+ console.warn( 'THREE.PropertyBinding: No target node found for track: ' + this.path + '.' );
47464
47658
  return;
47465
47659
 
47466
47660
  }
@@ -49593,7 +49787,7 @@ class Uniform {
49593
49787
 
49594
49788
  }
49595
49789
 
49596
- let id = 0;
49790
+ let _id = 0;
49597
49791
 
49598
49792
  class UniformsGroup extends EventDispatcher {
49599
49793
 
@@ -49603,7 +49797,7 @@ class UniformsGroup extends EventDispatcher {
49603
49797
 
49604
49798
  this.isUniformsGroup = true;
49605
49799
 
49606
- Object.defineProperty( this, 'id', { value: id ++ } );
49800
+ Object.defineProperty( this, 'id', { value: _id ++ } );
49607
49801
 
49608
49802
  this.name = '';
49609
49803
 
@@ -51925,6 +52119,7 @@ exports.Color = Color;
51925
52119
  exports.ColorKeyframeTrack = ColorKeyframeTrack;
51926
52120
  exports.ColorManagement = ColorManagement;
51927
52121
  exports.CompressedArrayTexture = CompressedArrayTexture;
52122
+ exports.CompressedCubeTexture = CompressedCubeTexture;
51928
52123
  exports.CompressedTexture = CompressedTexture;
51929
52124
  exports.CompressedTextureLoader = CompressedTextureLoader;
51930
52125
  exports.ConeGeometry = ConeGeometry;
@@ -52046,6 +52241,7 @@ exports.LineCurve3 = LineCurve3;
52046
52241
  exports.LineDashedMaterial = LineDashedMaterial;
52047
52242
  exports.LineLoop = LineLoop;
52048
52243
  exports.LineSegments = LineSegments;
52244
+ exports.LinearDisplayP3ColorSpace = LinearDisplayP3ColorSpace;
52049
52245
  exports.LinearEncoding = LinearEncoding;
52050
52246
  exports.LinearFilter = LinearFilter;
52051
52247
  exports.LinearInterpolant = LinearInterpolant;
@@ -52162,6 +52358,8 @@ exports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;
52162
52358
  exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;
52163
52359
  exports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;
52164
52360
  exports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;
52361
+ exports.RGB_BPTC_SIGNED_Format = RGB_BPTC_SIGNED_Format;
52362
+ exports.RGB_BPTC_UNSIGNED_Format = RGB_BPTC_UNSIGNED_Format;
52165
52363
  exports.RGB_ETC1_Format = RGB_ETC1_Format;
52166
52364
  exports.RGB_ETC2_Format = RGB_ETC2_Format;
52167
52365
  exports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;
@@ -52176,6 +52374,7 @@ exports.RectAreaLight = RectAreaLight;
52176
52374
  exports.RedFormat = RedFormat;
52177
52375
  exports.RedIntegerFormat = RedIntegerFormat;
52178
52376
  exports.ReinhardToneMapping = ReinhardToneMapping;
52377
+ exports.RenderTarget = RenderTarget;
52179
52378
  exports.RepeatWrapping = RepeatWrapping;
52180
52379
  exports.ReplaceStencilOp = ReplaceStencilOp;
52181
52380
  exports.ReverseSubtractEquation = ReverseSubtractEquation;
@@ -52270,4 +52469,5 @@ exports.ZeroFactor = ZeroFactor;
52270
52469
  exports.ZeroSlopeEnding = ZeroSlopeEnding;
52271
52470
  exports.ZeroStencilOp = ZeroStencilOp;
52272
52471
  exports._SRGBAFormat = _SRGBAFormat;
52472
+ exports.createCanvasElement = createCanvasElement;
52273
52473
  exports.sRGBEncoding = sRGBEncoding;