super-three 0.162.0 → 0.163.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/build/three.cjs +407 -1014
  2. package/build/three.module.js +406 -1013
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/TransformControls.js +3 -3
  5. package/examples/jsm/exporters/GLTFExporter.js +21 -4
  6. package/examples/jsm/exporters/USDZExporter.js +15 -0
  7. package/examples/jsm/geometries/TextGeometry.js +10 -2
  8. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  9. package/examples/jsm/libs/fflate.module.js +694 -496
  10. package/examples/jsm/lines/LineMaterial.js +0 -2
  11. package/examples/jsm/loaders/3MFLoader.js +2 -0
  12. package/examples/jsm/loaders/EXRLoader.js +89 -19
  13. package/examples/jsm/loaders/FBXLoader.js +1 -1
  14. package/examples/jsm/loaders/GLTFLoader.js +6 -0
  15. package/examples/jsm/loaders/KTX2Loader.js +2 -6
  16. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  17. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  18. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  19. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  20. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  21. package/examples/jsm/nodes/Nodes.js +6 -1
  22. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  23. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  24. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +1 -1
  25. package/examples/jsm/nodes/accessors/MorphNode.js +13 -3
  26. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  27. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  28. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  29. package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
  30. package/examples/jsm/nodes/core/Node.js +55 -4
  31. package/examples/jsm/nodes/core/NodeBuilder.js +21 -16
  32. package/examples/jsm/nodes/core/NodeFrame.js +10 -10
  33. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  34. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  35. package/examples/jsm/nodes/display/PassNode.js +17 -1
  36. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  37. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  38. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  39. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  40. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  41. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  42. package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
  43. package/examples/jsm/nodes/materials/NodeMaterial.js +33 -11
  44. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  45. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  46. package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
  47. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  48. package/examples/jsm/objects/QuadMesh.js +7 -23
  49. package/examples/jsm/physics/RapierPhysics.js +4 -4
  50. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  51. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  52. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  53. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  54. package/examples/jsm/renderers/common/Animation.js +3 -0
  55. package/examples/jsm/renderers/common/Background.js +5 -5
  56. package/examples/jsm/renderers/common/Info.js +11 -19
  57. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  58. package/examples/jsm/renderers/common/RenderContext.js +1 -1
  59. package/examples/jsm/renderers/common/RenderObject.js +4 -4
  60. package/examples/jsm/renderers/common/RenderObjects.js +1 -1
  61. package/examples/jsm/renderers/common/Renderer.js +25 -8
  62. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
  63. package/examples/jsm/renderers/common/nodes/Nodes.js +5 -18
  64. package/examples/jsm/renderers/webgl/WebGLBackend.js +148 -24
  65. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
  66. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +3 -3
  67. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +1 -1
  68. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  69. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +43 -0
  70. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
  71. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
  72. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
  73. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +54 -25
  74. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +5 -3
  75. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +25 -0
  76. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  77. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +92 -18
  78. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  79. package/examples/jsm/utils/TextureUtils.js +1 -1
  80. package/package.json +1 -1
  81. package/src/Three.js +0 -1
  82. package/src/animation/AnimationClip.js +1 -1
  83. package/src/constants.js +3 -3
  84. package/src/core/Object3D.js +10 -7
  85. package/src/extras/PMREMGenerator.js +9 -0
  86. package/src/loaders/ObjectLoader.js +2 -0
  87. package/src/materials/ShaderMaterial.js +0 -4
  88. package/src/math/Spherical.js +4 -5
  89. package/src/objects/BatchedMesh.js +4 -3
  90. package/src/objects/InstancedMesh.js +10 -0
  91. package/src/renderers/WebGLRenderer.js +55 -114
  92. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  93. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  94. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  95. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  96. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  97. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  98. package/src/renderers/shaders/ShaderLib.js +1 -1
  99. package/src/renderers/shaders/UniformsUtils.js +10 -1
  100. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  101. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  102. package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
  103. package/src/renderers/webgl/WebGLCapabilities.js +2 -12
  104. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  105. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  106. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
  107. package/src/renderers/webgl/WebGLLights.js +6 -32
  108. package/src/renderers/webgl/WebGLMaterials.js +2 -3
  109. package/src/renderers/webgl/WebGLMorphtargets.js +79 -217
  110. package/src/renderers/webgl/WebGLProgram.js +18 -47
  111. package/src/renderers/webgl/WebGLPrograms.js +20 -32
  112. package/src/renderers/webgl/WebGLRenderStates.js +8 -6
  113. package/src/renderers/webgl/WebGLState.js +15 -59
  114. package/src/renderers/webgl/WebGLTextures.js +75 -237
  115. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  116. package/src/renderers/webgl/WebGLUtils.js +6 -57
  117. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  118. package/src/renderers/webxr/WebXRManager.js +2 -2
  119. package/src/scenes/Scene.js +7 -1
  120. package/src/textures/Texture.js +11 -1
  121. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  122. package/src/renderers/WebGL1Renderer.js +0 -7
@@ -1,13 +1,10 @@
1
- import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, RGB_ETC1_Format, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
2
- import * as MathUtils from '../../math/MathUtils.js';
3
- import { ImageUtils } from '../../extras/ImageUtils.js';
1
+ import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, RGB_ETC1_Format, DepthFormat, DepthStencilFormat, UnsignedIntType, UnsignedInt248Type, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, NoColorSpace, LinearSRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, SRGBTransfer, LinearTransfer } from '../../constants.js';
4
2
  import { createElementNS } from '../../utils.js';
5
3
  import { ColorManagement } from '../../math/ColorManagement.js';
6
4
  import { Vector2 } from '../../math/Vector2.js';
7
5
 
8
6
  function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
9
7
 
10
- const isWebGL2 = capabilities.isWebGL2;
11
8
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
12
9
  const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
13
10
  const multiviewExt = extensions.has( 'OCULUS_multiview' ) ? extensions.get( 'OCULUS_multiview' ) : null;
@@ -49,7 +46,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
49
46
 
50
47
  }
51
48
 
52
- function resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {
49
+ function resizeImage( image, needsNewCanvas, maxSize ) {
53
50
 
54
51
  let scale = 1;
55
52
 
@@ -65,7 +62,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
65
62
 
66
63
  // only perform resize if necessary
67
64
 
68
- if ( scale < 1 || needsPowerOfTwo === true ) {
65
+ if ( scale < 1 ) {
69
66
 
70
67
  // only perform resize for certain image types
71
68
 
@@ -74,10 +71,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
74
71
  ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
75
72
  ( typeof VideoFrame !== 'undefined' && image instanceof VideoFrame ) ) {
76
73
 
77
- const floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;
78
-
79
- const width = floor( scale * dimensions.width );
80
- const height = floor( scale * dimensions.height );
74
+ const width = Math.floor( scale * dimensions.width );
75
+ const height = Math.floor( scale * dimensions.height );
81
76
 
82
77
  if ( _canvas === undefined ) _canvas = createCanvas( width, height );
83
78
 
@@ -113,27 +108,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
113
108
 
114
109
  }
115
110
 
116
- function isPowerOfTwo( image ) {
117
-
118
- const dimensions = getDimensions( image );
119
-
120
- return MathUtils.isPowerOfTwo( dimensions.width ) && MathUtils.isPowerOfTwo( dimensions.height );
121
-
122
- }
123
-
124
- function textureNeedsPowerOfTwo( texture ) {
125
-
126
- if ( isWebGL2 ) return false;
111
+ function textureNeedsGenerateMipmaps( texture ) {
127
112
 
128
- return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||
129
- ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
130
-
131
- }
132
-
133
- function textureNeedsGenerateMipmaps( texture, supportsMips ) {
134
-
135
- return texture.generateMipmaps && supportsMips &&
136
- texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
113
+ return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
137
114
 
138
115
  }
139
116
 
@@ -145,8 +122,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
145
122
 
146
123
  function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
147
124
 
148
- if ( isWebGL2 === false ) return glFormat;
149
-
150
125
  if ( internalFormatName !== null ) {
151
126
 
152
127
  if ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];
@@ -195,6 +170,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
195
170
 
196
171
  }
197
172
 
173
+ if ( glFormat === _gl.RGB ) {
174
+
175
+ if ( glType === _gl.UNSIGNED_INT_5_9_9_9_REV ) internalFormat = _gl.RGB9_E5;
176
+
177
+ }
178
+
198
179
  if ( glFormat === _gl.RGBA ) {
199
180
 
200
181
  const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
@@ -219,9 +200,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
219
200
 
220
201
  }
221
202
 
222
- function getMipLevels( texture, image, supportsMips ) {
203
+ function getMipLevels( texture, image ) {
223
204
 
224
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
205
+ if ( textureNeedsGenerateMipmaps( texture ) === true || ( texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) ) {
225
206
 
226
207
  return Math.log2( Math.max( image.width, image.height ) ) + 1;
227
208
 
@@ -245,20 +226,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
245
226
 
246
227
  }
247
228
 
248
- // Fallback filters for non-power-of-2 textures
249
-
250
- function filterFallback( f ) {
251
-
252
- if ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {
253
-
254
- return _gl.NEAREST;
255
-
256
- }
257
-
258
- return _gl.LINEAR;
259
-
260
- }
261
-
262
229
  //
263
230
 
264
231
  function onTextureDispose( event ) {
@@ -576,7 +543,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
576
543
  [ NotEqualCompare ]: _gl.NOTEQUAL
577
544
  };
578
545
 
579
- function setTextureParameters( textureType, texture, supportsMips ) {
546
+ function setTextureParameters( textureType, texture ) {
580
547
 
581
548
  if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false &&
582
549
  ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
@@ -586,48 +553,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
586
553
 
587
554
  }
588
555
 
589
- if ( supportsMips ) {
556
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
557
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
590
558
 
591
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );
592
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );
559
+ if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
593
560
 
594
- if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
595
-
596
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
597
-
598
- }
599
-
600
- _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
601
- _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
602
-
603
- } else {
604
-
605
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
606
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
607
-
608
- if ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {
609
-
610
- _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );
611
-
612
- }
613
-
614
- if ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {
615
-
616
- console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );
617
-
618
- }
619
-
620
- _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
621
- _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
622
-
623
- if ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {
624
-
625
- console.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );
626
-
627
- }
561
+ _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );
628
562
 
629
563
  }
630
564
 
565
+ _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );
566
+ _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );
567
+
631
568
  if ( texture.compareFunction ) {
632
569
 
633
570
  _gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
@@ -639,8 +576,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
639
576
 
640
577
  if ( texture.magFilter === NearestFilter ) return;
641
578
  if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
642
- if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
643
- if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only
579
+ if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension
644
580
 
645
581
  if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
646
582
 
@@ -798,97 +734,41 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
798
734
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
799
735
  _gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );
800
736
 
801
- const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
802
- let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
737
+ let image = resizeImage( texture.image, false, capabilities.maxTextureSize );
803
738
  image = verifyColorSpace( texture, image );
804
739
 
805
- const supportsMips = isPowerOfTwo( image ) || isWebGL2,
806
- glFormat = utils.convert( texture.format, texture.colorSpace );
740
+ const glFormat = utils.convert( texture.format, texture.colorSpace );
807
741
 
808
- let glType = utils.convert( texture.type ),
809
- glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
742
+ const glType = utils.convert( texture.type );
743
+ let glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture );
810
744
 
811
- setTextureParameters( textureType, texture, supportsMips );
745
+ setTextureParameters( textureType, texture );
812
746
 
813
747
  let mipmap;
814
748
  const mipmaps = texture.mipmaps;
815
749
 
816
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
750
+ const useTexStorage = ( texture.isVideoTexture !== true && glInternalFormat !== RGB_ETC1_Format );
817
751
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
818
752
  const dataReady = source.dataReady;
819
- const levels = getMipLevels( texture, image, supportsMips );
753
+ const levels = getMipLevels( texture, image );
820
754
 
821
755
  if ( texture.isDepthTexture ) {
822
756
 
823
757
  // populate depth texture with dummy data
824
758
 
825
- glInternalFormat = _gl.DEPTH_COMPONENT;
826
-
827
- if ( isWebGL2 ) {
828
-
829
- if ( texture.type === FloatType ) {
830
-
831
- glInternalFormat = _gl.DEPTH_COMPONENT32F;
832
-
833
- } else if ( texture.type === UnsignedIntType ) {
834
-
835
- glInternalFormat = _gl.DEPTH_COMPONENT24;
759
+ glInternalFormat = _gl.DEPTH_COMPONENT16;
836
760
 
837
- } else if ( texture.type === UnsignedInt248Type ) {
838
-
839
- glInternalFormat = _gl.DEPTH24_STENCIL8;
840
-
841
- } else {
761
+ if ( texture.type === FloatType ) {
842
762
 
843
- glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D
844
-
845
- }
846
-
847
- } else {
848
-
849
- if ( texture.type === FloatType ) {
850
-
851
- console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );
852
-
853
- }
854
-
855
- }
856
-
857
- // validation checks for WebGL 1
858
-
859
- if ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
860
-
861
- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
862
- // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
863
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
864
- if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
865
-
866
- console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
867
-
868
- texture.type = UnsignedIntType;
869
- glType = utils.convert( texture.type );
870
-
871
- }
872
-
873
- }
874
-
875
- if ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {
876
-
877
- // Depth stencil textures need the DEPTH_STENCIL internal format
878
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
879
- glInternalFormat = _gl.DEPTH_STENCIL;
763
+ glInternalFormat = _gl.DEPTH_COMPONENT32F;
880
764
 
881
- // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
882
- // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
883
- // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
884
- if ( texture.type !== UnsignedInt248Type ) {
765
+ } else if ( texture.type === UnsignedIntType ) {
885
766
 
886
- console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
767
+ glInternalFormat = _gl.DEPTH_COMPONENT24;
887
768
 
888
- texture.type = UnsignedInt248Type;
889
- glType = utils.convert( texture.type );
769
+ } else if ( texture.type === UnsignedInt248Type ) {
890
770
 
891
- }
771
+ glInternalFormat = _gl.DEPTH24_STENCIL8;
892
772
 
893
773
  }
894
774
 
@@ -914,7 +794,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
914
794
  // if there are no manual mipmaps
915
795
  // set 0 level mipmap and then use GL to generate other mipmap levels
916
796
 
917
- if ( mipmaps.length > 0 && supportsMips ) {
797
+ if ( mipmaps.length > 0 ) {
918
798
 
919
799
  if ( useTexStorage && allocateMemory ) {
920
800
 
@@ -1161,7 +1041,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1161
1041
  // if there are no manual mipmaps
1162
1042
  // set 0 level mipmap and then use GL to generate other mipmap levels
1163
1043
 
1164
- if ( mipmaps.length > 0 && supportsMips ) {
1044
+ if ( mipmaps.length > 0 ) {
1165
1045
 
1166
1046
  if ( useTexStorage && allocateMemory ) {
1167
1047
 
@@ -1221,7 +1101,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1221
1101
 
1222
1102
  }
1223
1103
 
1224
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
1104
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
1225
1105
 
1226
1106
  generateMipmap( textureType );
1227
1107
 
@@ -1271,7 +1151,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1271
1151
 
1272
1152
  if ( ! isCompressed && ! isDataTexture ) {
1273
1153
 
1274
- cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
1154
+ cubeImage[ i ] = resizeImage( texture.image[ i ], true, capabilities.maxCubemapSize );
1275
1155
 
1276
1156
  } else {
1277
1157
 
@@ -1284,17 +1164,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1284
1164
  }
1285
1165
 
1286
1166
  const image = cubeImage[ 0 ],
1287
- supportsMips = isPowerOfTwo( image ) || isWebGL2,
1288
1167
  glFormat = utils.convert( texture.format, texture.colorSpace ),
1289
1168
  glType = utils.convert( texture.type ),
1290
1169
  glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
1291
1170
 
1292
- const useTexStorage = ( isWebGL2 && texture.isVideoTexture !== true );
1171
+ const useTexStorage = ( texture.isVideoTexture !== true );
1293
1172
  const allocateMemory = ( sourceProperties.__version === undefined ) || ( forceUpload === true );
1294
1173
  const dataReady = source.dataReady;
1295
- let levels = getMipLevels( texture, image, supportsMips );
1174
+ let levels = getMipLevels( texture, image );
1296
1175
 
1297
- setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
1176
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
1298
1177
 
1299
1178
  let mipmaps;
1300
1179
 
@@ -1459,7 +1338,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1459
1338
 
1460
1339
  }
1461
1340
 
1462
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
1341
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
1463
1342
 
1464
1343
  // We assume images for cube map have the same size.
1465
1344
  generateMipmap( _gl.TEXTURE_CUBE_MAP );
@@ -1601,7 +1480,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1601
1480
 
1602
1481
  } else if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {
1603
1482
 
1604
- let glInternalFormat = ( isWebGL2 === true ) ? _gl.DEPTH_COMPONENT24 : _gl.DEPTH_COMPONENT16;
1483
+ let glInternalFormat = _gl.DEPTH_COMPONENT24;
1605
1484
 
1606
1485
  if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
1607
1486
 
@@ -1880,7 +1759,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1880
1759
 
1881
1760
  const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
1882
1761
  const isMultipleRenderTargets = ( textures.length > 1 );
1883
- const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
1884
1762
 
1885
1763
  if ( ! isMultipleRenderTargets ) {
1886
1764
 
@@ -1903,7 +1781,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1903
1781
 
1904
1782
  for ( let i = 0; i < 6; i ++ ) {
1905
1783
 
1906
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
1784
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
1907
1785
 
1908
1786
  renderTargetProperties.__webglFramebuffer[ i ] = [];
1909
1787
 
@@ -1923,7 +1801,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1923
1801
 
1924
1802
  } else {
1925
1803
 
1926
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
1804
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
1927
1805
 
1928
1806
  renderTargetProperties.__webglFramebuffer = [];
1929
1807
 
@@ -1941,31 +1819,23 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1941
1819
 
1942
1820
  if ( isMultipleRenderTargets ) {
1943
1821
 
1944
- if ( capabilities.drawBuffers ) {
1822
+ for ( let i = 0, il = textures.length; i < il; i ++ ) {
1945
1823
 
1946
- for ( let i = 0, il = textures.length; i < il; i ++ ) {
1824
+ const attachmentProperties = properties.get( textures[ i ] );
1947
1825
 
1948
- const attachmentProperties = properties.get( textures[ i ] );
1826
+ if ( attachmentProperties.__webglTexture === undefined ) {
1949
1827
 
1950
- if ( attachmentProperties.__webglTexture === undefined ) {
1828
+ attachmentProperties.__webglTexture = _gl.createTexture();
1951
1829
 
1952
- attachmentProperties.__webglTexture = _gl.createTexture();
1953
-
1954
- info.memory.textures ++;
1955
-
1956
- }
1830
+ info.memory.textures ++;
1957
1831
 
1958
1832
  }
1959
1833
 
1960
- } else {
1961
-
1962
- console.warn( 'THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.' );
1963
-
1964
1834
  }
1965
1835
 
1966
1836
  }
1967
1837
 
1968
- if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
1838
+ if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
1969
1839
 
1970
1840
  renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
1971
1841
  renderTargetProperties.__webglColorRenderbuffer = [];
@@ -2009,11 +1879,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2009
1879
  if ( isCube ) {
2010
1880
 
2011
1881
  state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
2012
- setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
1882
+ setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture );
2013
1883
 
2014
1884
  for ( let i = 0; i < 6; i ++ ) {
2015
1885
 
2016
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
1886
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
2017
1887
 
2018
1888
  for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
2019
1889
 
@@ -2029,7 +1899,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2029
1899
 
2030
1900
  }
2031
1901
 
2032
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
1902
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
2033
1903
 
2034
1904
  generateMipmap( _gl.TEXTURE_CUBE_MAP );
2035
1905
 
@@ -2045,10 +1915,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2045
1915
  const attachmentProperties = properties.get( attachment );
2046
1916
 
2047
1917
  state.bindTexture( _gl.TEXTURE_2D, attachmentProperties.__webglTexture );
2048
- setTextureParameters( _gl.TEXTURE_2D, attachment, supportsMips );
1918
+ setTextureParameters( _gl.TEXTURE_2D, attachment );
2049
1919
  setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D, 0 );
2050
1920
 
2051
- if ( textureNeedsGenerateMipmaps( attachment, supportsMips ) ) {
1921
+ if ( textureNeedsGenerateMipmaps( attachment ) ) {
2052
1922
 
2053
1923
  generateMipmap( _gl.TEXTURE_2D );
2054
1924
 
@@ -2064,15 +1934,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2064
1934
 
2065
1935
  if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
2066
1936
 
2067
- if ( isWebGL2 ) {
2068
-
2069
- glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
2070
-
2071
- } else {
2072
-
2073
- console.error( 'THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.' );
2074
-
2075
- }
1937
+ glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
2076
1938
 
2077
1939
  }
2078
1940
 
@@ -2083,9 +1945,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2083
1945
  }
2084
1946
 
2085
1947
  state.bindTexture( glTextureType, textureProperties.__webglTexture );
2086
- setTextureParameters( glTextureType, texture, supportsMips );
1948
+ setTextureParameters( glTextureType, texture );
2087
1949
 
2088
- if ( isWebGL2 && texture.mipmaps && texture.mipmaps.length > 0 ) {
1950
+ if ( texture.mipmaps && texture.mipmaps.length > 0 ) {
2089
1951
 
2090
1952
  for ( let level = 0; level < texture.mipmaps.length; level ++ ) {
2091
1953
 
@@ -2099,7 +1961,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2099
1961
 
2100
1962
  }
2101
1963
 
2102
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
1964
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
2103
1965
 
2104
1966
  generateMipmap( glTextureType );
2105
1967
 
@@ -2121,15 +1983,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2121
1983
 
2122
1984
  function updateRenderTargetMipmap( renderTarget ) {
2123
1985
 
2124
- const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
2125
-
2126
1986
  const textures = renderTarget.textures;
2127
1987
 
2128
1988
  for ( let i = 0, il = textures.length; i < il; i ++ ) {
2129
1989
 
2130
1990
  const texture = textures[ i ];
2131
1991
 
2132
- if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
1992
+ if ( textureNeedsGenerateMipmaps( texture ) ) {
2133
1993
 
2134
1994
  const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
2135
1995
  const webglTexture = properties.get( texture ).__webglTexture;
@@ -2146,7 +2006,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2146
2006
 
2147
2007
  function updateMultisampleRenderTarget( renderTarget ) {
2148
2008
 
2149
- if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
2009
+ if ( ( renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
2150
2010
 
2151
2011
  const textures = renderTarget.textures;
2152
2012
  const width = renderTarget.width;
@@ -2190,7 +2050,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2190
2050
  if ( ignoreDepthValues === false ) {
2191
2051
 
2192
2052
  if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;
2193
- if ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;
2053
+
2054
+ // resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)
2055
+
2056
+ if ( renderTarget.stencilBuffer && renderTargetProperties.__isTransmissionRenderTarget !== true ) mask |= _gl.STENCIL_BUFFER_BIT;
2194
2057
 
2195
2058
  }
2196
2059
 
@@ -2261,7 +2124,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2261
2124
 
2262
2125
  const renderTargetProperties = properties.get( renderTarget );
2263
2126
 
2264
- return isWebGL2 && renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
2127
+ return renderTarget.samples > 0 && extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTargetProperties.__useRenderToTexture !== false;
2265
2128
 
2266
2129
  }
2267
2130
 
@@ -2286,7 +2149,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2286
2149
  const format = texture.format;
2287
2150
  const type = texture.type;
2288
2151
 
2289
- if ( texture.isCompressedTexture === true || texture.isVideoTexture === true || texture.format === _SRGBAFormat ) return image;
2152
+ if ( texture.isCompressedTexture === true || texture.isVideoTexture === true ) return image;
2290
2153
 
2291
2154
  if ( colorSpace !== LinearSRGBColorSpace && colorSpace !== NoColorSpace ) {
2292
2155
 
@@ -2294,36 +2157,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
2294
2157
 
2295
2158
  if ( ColorManagement.getTransfer( colorSpace ) === SRGBTransfer ) {
2296
2159
 
2297
- if ( isWebGL2 === false ) {
2298
-
2299
- // in WebGL 1, try to use EXT_sRGB extension and unsized formats
2300
-
2301
- if ( extensions.has( 'EXT_sRGB' ) === true && format === RGBAFormat ) {
2160
+ // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
2302
2161
 
2303
- texture.format = _SRGBAFormat;
2162
+ if ( format !== RGBAFormat || type !== UnsignedByteType ) {
2304
2163
 
2305
- // it's not possible to generate mips in WebGL 1 with this extension
2306
-
2307
- texture.minFilter = LinearFilter;
2308
- texture.generateMipmaps = false;
2309
-
2310
- } else {
2311
-
2312
- // slow fallback (CPU decode)
2313
-
2314
- image = ImageUtils.sRGBToLinear( image );
2315
-
2316
- }
2317
-
2318
- } else {
2319
-
2320
- // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format
2321
-
2322
- if ( format !== RGBAFormat || type !== UnsignedByteType ) {
2323
-
2324
- console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
2325
-
2326
- }
2164
+ console.warn( 'THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.' );
2327
2165
 
2328
2166
  }
2329
2167
 
@@ -4,7 +4,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
4
4
  let updateList = {};
5
5
  let allocatedBindingPoints = [];
6
6
 
7
- const maxBindingPoints = ( capabilities.isWebGL2 ) ? gl.getParameter( gl.MAX_UNIFORM_BUFFER_BINDINGS ) : 0; // binding points are global whereas block indices are per shader program
7
+ const maxBindingPoints = gl.getParameter( gl.MAX_UNIFORM_BUFFER_BINDINGS ); // binding points are global whereas block indices are per shader program
8
8
 
9
9
  function bind( uniformsGroup, program ) {
10
10