super-three 0.169.0 → 0.170.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 (195) hide show
  1. package/build/three.cjs +989 -1131
  2. package/build/three.module.js +990 -1128
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +8398 -9842
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +8398 -9842
  7. package/build/three.webgpu.nodes.min.js +1 -1
  8. package/examples/jsm/Addons.js +3 -3
  9. package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
  10. package/examples/jsm/animation/MMDPhysics.js +2 -0
  11. package/examples/jsm/controls/TransformControls.js +22 -6
  12. package/examples/jsm/csm/CSM.js +2 -2
  13. package/examples/jsm/csm/CSMFrustum.js +7 -4
  14. package/examples/jsm/csm/CSMHelper.js +2 -0
  15. package/examples/jsm/csm/CSMShadowNode.js +435 -0
  16. package/examples/jsm/curves/NURBSCurve.js +34 -3
  17. package/examples/jsm/exporters/GLTFExporter.js +138 -71
  18. package/examples/jsm/exporters/KTX2Exporter.js +35 -12
  19. package/examples/jsm/exporters/MMDExporter.js +6 -0
  20. package/examples/jsm/exporters/USDZExporter.js +21 -3
  21. package/examples/jsm/geometries/DecalGeometry.js +65 -20
  22. package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
  23. package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
  24. package/examples/jsm/interactive/HTMLMesh.js +1 -0
  25. package/examples/jsm/lighting/TiledLighting.js +18 -0
  26. package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
  27. package/examples/jsm/lines/LineMaterial.js +7 -2
  28. package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
  29. package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
  30. package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
  31. package/examples/jsm/loaders/3DMLoader.js +1 -0
  32. package/examples/jsm/loaders/3MFLoader.js +91 -0
  33. package/examples/jsm/loaders/FBXLoader.js +12 -2
  34. package/examples/jsm/loaders/GLTFLoader.js +2 -0
  35. package/examples/jsm/loaders/KTX2Loader.js +140 -49
  36. package/examples/jsm/loaders/LDrawLoader.js +22 -136
  37. package/examples/jsm/loaders/LottieLoader.js +1 -0
  38. package/examples/jsm/loaders/MMDLoader.js +9 -2
  39. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
  40. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
  41. package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
  42. package/examples/jsm/math/ColorSpaces.js +76 -0
  43. package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
  44. package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
  45. package/examples/jsm/misc/VolumeSlice.js +1 -0
  46. package/examples/jsm/objects/WaterMesh.js +8 -8
  47. package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
  48. package/examples/jsm/postprocessing/SSRPass.js +6 -0
  49. package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
  50. package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
  51. package/examples/jsm/shaders/FXAAShader.js +225 -224
  52. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  53. package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
  54. package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
  55. package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
  56. package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
  57. package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
  58. package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
  59. package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
  60. package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
  61. package/examples/jsm/tsl/display/FXAANode.js +316 -0
  62. package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
  63. package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
  64. package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
  65. package/examples/jsm/tsl/display/LensflareNode.js +161 -0
  66. package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
  67. package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
  68. package/examples/jsm/tsl/display/OutlineNode.js +434 -0
  69. package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
  70. package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
  71. package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
  72. package/examples/jsm/tsl/display/SMAANode.js +620 -0
  73. package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
  74. package/examples/jsm/tsl/display/SSRNode.js +343 -0
  75. package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
  76. package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
  77. package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
  78. package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
  79. package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
  80. package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
  81. package/examples/jsm/tsl/display/hashBlur.js +24 -0
  82. package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
  83. package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
  84. package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
  85. package/examples/jsm/webxr/Text2D.js +6 -6
  86. package/package.json +2 -2
  87. package/src/Three.WebGPU.Nodes.js +4 -0
  88. package/src/Three.WebGPU.js +4 -0
  89. package/src/constants.js +1 -6
  90. package/src/core/BufferGeometry.js +44 -6
  91. package/src/geometries/CylinderGeometry.js +2 -2
  92. package/src/materials/LineBasicMaterial.js +6 -2
  93. package/src/materials/LineDashedMaterial.js +6 -2
  94. package/src/materials/Material.js +14 -1
  95. package/src/materials/MeshBasicMaterial.js +6 -2
  96. package/src/materials/MeshDepthMaterial.js +6 -2
  97. package/src/materials/MeshDistanceMaterial.js +6 -2
  98. package/src/materials/MeshLambertMaterial.js +6 -2
  99. package/src/materials/MeshMatcapMaterial.js +6 -2
  100. package/src/materials/MeshNormalMaterial.js +6 -2
  101. package/src/materials/MeshPhongMaterial.js +6 -2
  102. package/src/materials/MeshPhysicalMaterial.js +6 -2
  103. package/src/materials/MeshStandardMaterial.js +6 -2
  104. package/src/materials/MeshToonMaterial.js +6 -2
  105. package/src/materials/PointsMaterial.js +6 -2
  106. package/src/materials/RawShaderMaterial.js +6 -2
  107. package/src/materials/ShaderMaterial.js +6 -2
  108. package/src/materials/ShadowMaterial.js +6 -2
  109. package/src/materials/SpriteMaterial.js +6 -2
  110. package/src/materials/nodes/NodeMaterial.js +31 -9
  111. package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
  112. package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
  113. package/src/math/ColorManagement.js +118 -85
  114. package/src/math/Vector4.js +11 -0
  115. package/src/nodes/Nodes.js +1 -21
  116. package/src/nodes/TSL.js +6 -24
  117. package/src/nodes/accessors/Camera.js +0 -1
  118. package/src/nodes/accessors/SceneNode.js +35 -1
  119. package/src/nodes/accessors/StorageBufferNode.js +32 -10
  120. package/src/nodes/accessors/VelocityNode.js +13 -3
  121. package/src/nodes/code/FunctionCallNode.js +16 -5
  122. package/src/nodes/code/ScriptableNode.js +4 -4
  123. package/src/nodes/core/Node.js +1 -0
  124. package/src/nodes/core/NodeBuilder.js +29 -5
  125. package/src/nodes/core/VarNode.js +15 -3
  126. package/src/nodes/display/ColorAdjustment.js +53 -4
  127. package/src/nodes/display/ColorSpaceFunctions.js +5 -5
  128. package/src/nodes/display/ColorSpaceNode.js +27 -39
  129. package/src/nodes/display/PassNode.js +6 -4
  130. package/src/nodes/display/ToneMappingNode.js +1 -1
  131. package/src/nodes/display/ViewportDepthNode.js +33 -1
  132. package/src/nodes/functions/PhysicalLightingModel.js +21 -15
  133. package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
  134. package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
  135. package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
  136. package/src/nodes/gpgpu/ComputeNode.js +9 -1
  137. package/src/nodes/lighting/AnalyticLightNode.js +12 -416
  138. package/src/nodes/lighting/LightsNode.js +24 -12
  139. package/src/nodes/lighting/PointLightNode.js +36 -26
  140. package/src/nodes/lighting/RectAreaLightNode.js +3 -0
  141. package/src/nodes/lighting/ShadowNode.js +484 -0
  142. package/src/nodes/utils/LoopNode.js +2 -2
  143. package/src/nodes/utils/Oscillators.js +6 -0
  144. package/src/nodes/utils/PostProcessingUtils.js +89 -0
  145. package/src/nodes/utils/ReflectorNode.js +101 -15
  146. package/src/nodes/utils/Timer.js +29 -0
  147. package/src/objects/BatchedMesh.js +458 -241
  148. package/src/renderers/WebGLRenderer.js +121 -126
  149. package/src/renderers/common/Attributes.js +4 -0
  150. package/src/renderers/common/Backend.js +2 -0
  151. package/src/renderers/common/Background.js +14 -4
  152. package/src/renderers/common/Bindings.js +3 -2
  153. package/src/renderers/common/Constants.js +2 -1
  154. package/src/renderers/common/Geometries.js +20 -0
  155. package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
  156. package/src/renderers/common/Lighting.js +45 -0
  157. package/src/renderers/common/PostProcessingUtils.js +86 -0
  158. package/src/renderers/common/RenderList.js +39 -11
  159. package/src/renderers/common/RenderLists.js +4 -2
  160. package/src/renderers/common/RenderObject.js +18 -1
  161. package/src/renderers/common/Renderer.js +165 -26
  162. package/src/renderers/common/Textures.js +30 -14
  163. package/src/renderers/common/nodes/NodeLibrary.js +1 -14
  164. package/src/renderers/common/nodes/Nodes.js +2 -2
  165. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
  166. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
  167. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
  168. package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
  169. package/src/renderers/webgl/WebGLCapabilities.js +0 -7
  170. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
  171. package/src/renderers/webgl/WebGLProgram.js +24 -28
  172. package/src/renderers/webgl/WebGLPrograms.js +5 -2
  173. package/src/renderers/webgl/WebGLState.js +37 -1
  174. package/src/renderers/webgl/WebGLTextures.js +29 -12
  175. package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
  176. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
  177. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
  178. package/src/renderers/webgpu/WebGPUBackend.js +105 -25
  179. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
  180. package/src/renderers/webgpu/WebGPURenderer.js +1 -1
  181. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
  182. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
  183. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
  184. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
  185. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
  186. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
  187. package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
  188. package/src/renderers/webxr/WebXRManager.js +4 -4
  189. package/examples/jsm/cameras/CinematicCamera.js +0 -208
  190. package/src/nodes/display/FXAANode.js +0 -332
  191. package/src/nodes/utils/OscNode.js +0 -85
  192. package/src/nodes/utils/TimerNode.js +0 -97
  193. package/src/renderers/webvr/WebVRManager.js +0 -495
  194. package/src/renderers/webvr/WebVRUtils.js +0 -66
  195. /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
@@ -17,9 +17,7 @@ import {
17
17
  UnsignedInt248Type,
18
18
  UnsignedShort4444Type,
19
19
  UnsignedShort5551Type,
20
- WebGLCoordinateSystem,
21
- DisplayP3ColorSpace,
22
- LinearDisplayP3ColorSpace
20
+ WebGLCoordinateSystem
23
21
  } from '../constants.js';
24
22
  import { Color } from '../math/Color.js';
25
23
  import { Frustum } from '../math/Frustum.js';
@@ -52,7 +50,6 @@ import { WebGLState } from './webgl/WebGLState.js';
52
50
  import { WebGLTextures } from './webgl/WebGLTextures.js';
53
51
  import { WebGLUniforms } from './webgl/WebGLUniforms.js';
54
52
  import { WebGLUtils } from './webgl/WebGLUtils.js';
55
- import { WebVRManager } from './webvr/WebVRManager.js';
56
53
  import { WebXRManager } from './webxr/WebXRManager.js';
57
54
  import { WebGLMaterials } from './webgl/WebGLMaterials.js';
58
55
  import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
@@ -74,6 +71,7 @@ class WebGLRenderer {
74
71
  preserveDrawingBuffer = false,
75
72
  powerPreference = 'default',
76
73
  failIfMajorPerformanceCaveat = false,
74
+ reverseDepthBuffer = false,
77
75
  multiviewStereo = false,
78
76
  } = parameters;
79
77
 
@@ -294,9 +292,13 @@ class WebGLRenderer {
294
292
 
295
293
  capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
296
294
 
297
- state = new WebGLState( _gl );
295
+ state = new WebGLState( _gl, extensions );
298
296
 
299
- if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
297
+ if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
298
+
299
+ state.buffers.depth.setReversed( true );
300
+
301
+ }
300
302
 
301
303
  info = new WebGLInfo( _gl );
302
304
  properties = new WebGLProperties();
@@ -337,7 +339,7 @@ class WebGLRenderer {
337
339
 
338
340
  // xr
339
341
 
340
- const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl, extensions, multiviewStereo ) : new WebVRManager( _this );
342
+ const xr = new WebXRManager( _this, _gl );
341
343
 
342
344
  this.xr = xr;
343
345
 
@@ -601,7 +603,6 @@ class WebGLRenderer {
601
603
  if ( depth ) {
602
604
 
603
605
  bits |= _gl.DEPTH_BUFFER_BIT;
604
- _gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
605
606
 
606
607
  }
607
608
 
@@ -1297,13 +1298,6 @@ class WebGLRenderer {
1297
1298
 
1298
1299
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
1299
1300
 
1300
- textures.runDeferredUploads();
1301
-
1302
- if ( xr.enabled && xr.submitFrame ) {
1303
-
1304
- xr.submitFrame();
1305
-
1306
- }
1307
1301
  // _gl.finish();
1308
1302
 
1309
1303
  bindingStates.resetDefaultState();
@@ -2016,7 +2010,9 @@ class WebGLRenderer {
2016
2010
 
2017
2011
  } else {
2018
2012
 
2019
- if ( capabilities.reverseDepthBuffer ) {
2013
+ const reverseDepthBuffer = state.buffers.depth.getReversed();
2014
+
2015
+ if ( reverseDepthBuffer ) {
2020
2016
 
2021
2017
  _currentProjectionMatrix.copy( camera.projectionMatrix );
2022
2018
 
@@ -2648,21 +2644,27 @@ class WebGLRenderer {
2648
2644
 
2649
2645
  }
2650
2646
 
2651
- let width, height, minX, minY;
2652
- let dstX, dstY;
2647
+ // gather the necessary dimensions to copy
2648
+ let width, height, depth, minX, minY, minZ;
2649
+ let dstX, dstY, dstZ;
2650
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
2653
2651
  if ( srcRegion !== null ) {
2654
2652
 
2655
2653
  width = srcRegion.max.x - srcRegion.min.x;
2656
2654
  height = srcRegion.max.y - srcRegion.min.y;
2655
+ depth = srcRegion.isBox3 ? srcRegion.max.z - srcRegion.min.z : 1;
2657
2656
  minX = srcRegion.min.x;
2658
2657
  minY = srcRegion.min.y;
2658
+ minZ = srcRegion.isBox3 ? srcRegion.min.z : 0;
2659
2659
 
2660
2660
  } else {
2661
2661
 
2662
- width = srcTexture.image.width;
2663
- height = srcTexture.image.height;
2662
+ width = image.width;
2663
+ height = image.height;
2664
+ depth = image.depth || 1;
2664
2665
  minX = 0;
2665
2666
  minY = 0;
2667
+ minZ = 0;
2666
2668
 
2667
2669
  }
2668
2670
 
@@ -2670,177 +2672,143 @@ class WebGLRenderer {
2670
2672
 
2671
2673
  dstX = dstPosition.x;
2672
2674
  dstY = dstPosition.y;
2675
+ dstZ = dstPosition.z;
2673
2676
 
2674
2677
  } else {
2675
2678
 
2676
2679
  dstX = 0;
2677
2680
  dstY = 0;
2681
+ dstZ = 0;
2678
2682
 
2679
2683
  }
2680
2684
 
2685
+ // Set up the destination target
2681
2686
  const glFormat = utils.convert( dstTexture.format );
2682
2687
  const glType = utils.convert( dstTexture.type );
2688
+ let glTarget;
2689
+
2690
+ if ( dstTexture.isData3DTexture ) {
2683
2691
 
2684
- textures.setTexture2D( dstTexture, 0 );
2692
+ textures.setTexture3D( dstTexture, 0 );
2693
+ glTarget = _gl.TEXTURE_3D;
2694
+
2695
+ } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
2696
+
2697
+ textures.setTexture2DArray( dstTexture, 0 );
2698
+ glTarget = _gl.TEXTURE_2D_ARRAY;
2699
+
2700
+ } else {
2701
+
2702
+ textures.setTexture2D( dstTexture, 0 );
2703
+ glTarget = _gl.TEXTURE_2D;
2704
+
2705
+ }
2685
2706
 
2686
- // As another texture upload may have changed pixelStorei
2687
- // parameters, make sure they are correct for the dstTexture
2688
2707
  _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
2689
2708
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
2690
2709
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
2691
2710
 
2711
+ // used for copying data from cpu
2692
2712
  const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
2693
2713
  const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
2694
2714
  const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
2695
2715
  const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
2696
2716
  const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
2697
2717
 
2698
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
2699
-
2700
2718
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
2701
2719
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
2702
2720
  _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
2703
2721
  _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
2722
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
2704
2723
 
2705
- if ( srcTexture.isDataTexture ) {
2706
-
2707
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
2708
-
2709
- } else {
2710
-
2711
- if ( srcTexture.isCompressedTexture ) {
2712
-
2713
- _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
2724
+ // set up the src texture
2725
+ const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
2726
+ const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
2727
+ if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
2714
2728
 
2715
- } else {
2729
+ const srcTextureProperties = properties.get( srcTexture );
2730
+ const dstTextureProperties = properties.get( dstTexture );
2731
+ const srcRenderTargetProperties = properties.get( srcTextureProperties.__renderTarget );
2732
+ const dstRenderTargetProperties = properties.get( dstTextureProperties.__renderTarget );
2716
2733
 
2717
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
2734
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, srcRenderTargetProperties.__webglFramebuffer );
2735
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, dstRenderTargetProperties.__webglFramebuffer );
2718
2736
 
2719
- }
2737
+ for ( let i = 0; i < depth; i ++ ) {
2720
2738
 
2721
- }
2739
+ // if the source or destination are a 3d target then a layer needs to be bound
2740
+ if ( isSrc3D ) {
2722
2741
 
2723
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
2724
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
2725
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
2726
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
2727
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
2742
+ _gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( srcTexture ).__webglTexture, level, minZ + i );
2728
2743
 
2729
- // Generate mipmaps only when copying level 0
2730
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
2744
+ }
2731
2745
 
2732
- state.unbindTexture();
2746
+ if ( srcTexture.isDepthTexture ) {
2733
2747
 
2734
- };
2748
+ if ( isDst3D ) {
2735
2749
 
2736
- this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
2750
+ _gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( dstTexture ).__webglTexture, level, dstZ + i );
2737
2751
 
2738
- // support previous signature with source box first
2739
- if ( srcTexture.isTexture !== true ) {
2740
-
2741
- // @deprecated, r165
2742
- warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
2743
-
2744
- srcRegion = arguments[ 0 ] || null;
2745
- dstPosition = arguments[ 1 ] || null;
2746
- srcTexture = arguments[ 2 ];
2747
- dstTexture = arguments[ 3 ];
2748
- level = arguments[ 4 ] || 0;
2752
+ }
2749
2753
 
2750
- }
2754
+ _gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.DEPTH_BUFFER_BIT, _gl.NEAREST );
2751
2755
 
2752
- let width, height, depth, minX, minY, minZ;
2753
- let dstX, dstY, dstZ;
2754
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
2755
- if ( srcRegion !== null ) {
2756
+ } else if ( isDst3D ) {
2756
2757
 
2757
- width = srcRegion.max.x - srcRegion.min.x;
2758
- height = srcRegion.max.y - srcRegion.min.y;
2759
- depth = srcRegion.max.z - srcRegion.min.z;
2760
- minX = srcRegion.min.x;
2761
- minY = srcRegion.min.y;
2762
- minZ = srcRegion.min.z;
2758
+ _gl.copyTexSubImage3D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
2763
2759
 
2764
- } else {
2760
+ } else {
2765
2761
 
2766
- width = image.width;
2767
- height = image.height;
2768
- depth = image.depth;
2769
- minX = 0;
2770
- minY = 0;
2771
- minZ = 0;
2762
+ _gl.copyTexSubImage2D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
2772
2763
 
2773
- }
2764
+ }
2774
2765
 
2775
- if ( dstPosition !== null ) {
2766
+ }
2776
2767
 
2777
- dstX = dstPosition.x;
2778
- dstY = dstPosition.y;
2779
- dstZ = dstPosition.z;
2768
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
2769
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
2780
2770
 
2781
2771
  } else {
2782
2772
 
2783
- dstX = 0;
2784
- dstY = 0;
2785
- dstZ = 0;
2786
-
2787
- }
2788
-
2789
- const glFormat = utils.convert( dstTexture.format );
2790
- const glType = utils.convert( dstTexture.type );
2791
- let glTarget;
2792
-
2793
- if ( dstTexture.isData3DTexture ) {
2773
+ if ( isDst3D ) {
2794
2774
 
2795
- textures.setTexture3D( dstTexture, 0 );
2796
- glTarget = _gl.TEXTURE_3D;
2775
+ // copy data into the 3d texture
2776
+ if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
2797
2777
 
2798
- } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
2778
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
2799
2779
 
2800
- textures.setTexture2DArray( dstTexture, 0 );
2801
- glTarget = _gl.TEXTURE_2D_ARRAY;
2780
+ } else if ( dstTexture.isCompressedArrayTexture ) {
2802
2781
 
2803
- } else {
2782
+ _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
2804
2783
 
2805
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' );
2806
- return;
2784
+ } else {
2807
2785
 
2808
- }
2786
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
2809
2787
 
2810
- _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
2811
- _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
2812
- _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
2813
-
2814
- const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
2815
- const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
2816
- const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
2817
- const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
2818
- const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
2788
+ }
2819
2789
 
2820
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
2821
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
2822
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
2823
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
2824
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
2790
+ } else {
2825
2791
 
2826
- if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
2792
+ // copy data into the 2d texture
2793
+ if ( srcTexture.isDataTexture ) {
2827
2794
 
2828
- _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
2795
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
2829
2796
 
2830
- } else {
2797
+ } else if ( srcTexture.isCompressedTexture ) {
2831
2798
 
2832
- if ( dstTexture.isCompressedArrayTexture ) {
2799
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
2833
2800
 
2834
- _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
2801
+ } else {
2835
2802
 
2836
- } else {
2803
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
2837
2804
 
2838
- _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
2805
+ }
2839
2806
 
2840
2807
  }
2841
2808
 
2842
2809
  }
2843
2810
 
2811
+ // reset values
2844
2812
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
2845
2813
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
2846
2814
  _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
@@ -2848,12 +2816,39 @@ class WebGLRenderer {
2848
2816
  _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
2849
2817
 
2850
2818
  // Generate mipmaps only when copying level 0
2851
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
2819
+ if ( level === 0 && dstTexture.generateMipmaps ) {
2820
+
2821
+ _gl.generateMipmap( glTarget );
2822
+
2823
+ }
2852
2824
 
2853
2825
  state.unbindTexture();
2854
2826
 
2855
2827
  };
2856
2828
 
2829
+ this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
2830
+
2831
+ // support previous signature with source box first
2832
+ if ( srcTexture.isTexture !== true ) {
2833
+
2834
+ // @deprecated, r165
2835
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
2836
+
2837
+ srcRegion = arguments[ 0 ] || null;
2838
+ dstPosition = arguments[ 1 ] || null;
2839
+ srcTexture = arguments[ 2 ];
2840
+ dstTexture = arguments[ 3 ];
2841
+ level = arguments[ 4 ] || 0;
2842
+
2843
+ }
2844
+
2845
+ // @deprecated, r170
2846
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
2847
+
2848
+ return this.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
2849
+
2850
+ };
2851
+
2857
2852
  this.initRenderTarget = function ( target ) {
2858
2853
 
2859
2854
  if ( properties.get( target ).__webglFramebuffer === undefined ) {
@@ -2924,8 +2919,8 @@ class WebGLRenderer {
2924
2919
  this._outputColorSpace = colorSpace;
2925
2920
 
2926
2921
  const gl = this.getContext();
2927
- gl.drawingBufferColorSpace = colorSpace === DisplayP3ColorSpace ? 'display-p3' : 'srgb';
2928
- gl.unpackColorSpace = ColorManagement.workingColorSpace === LinearDisplayP3ColorSpace ? 'display-p3' : 'srgb';
2922
+ gl.drawingBufferColorspace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
2923
+ gl.unpackColorSpace = ColorManagement._getUnpackColorSpace();
2929
2924
 
2930
2925
  }
2931
2926
 
@@ -45,6 +45,10 @@ class Attributes extends DataMap {
45
45
 
46
46
  this.backend.createStorageAttribute( attribute );
47
47
 
48
+ } else if ( type === AttributeType.INDIRECT ) {
49
+
50
+ this.backend.createIndirectStorageAttribute( attribute );
51
+
48
52
  }
49
53
 
50
54
  data.version = this._getBufferAttribute( attribute ).version;
@@ -193,6 +193,8 @@ class Backend {
193
193
 
194
194
  }
195
195
 
196
+ dispose() { }
197
+
196
198
  }
197
199
 
198
200
  export default Backend;
@@ -1,6 +1,6 @@
1
1
  import DataMap from './DataMap.js';
2
2
  import Color4 from './Color4.js';
3
- import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, modelViewProjection } from '../../nodes/TSL.js';
3
+ import { vec4, context, normalWorld, backgroundBlurriness, backgroundIntensity, backgroundRotation, modelViewProjection } from '../../nodes/TSL.js';
4
4
  import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
5
5
 
6
6
  import { Mesh } from '../../objects/Mesh.js';
@@ -56,7 +56,7 @@ class Background extends DataMap {
56
56
 
57
57
  const backgroundMeshNode = context( vec4( backgroundNode ).mul( backgroundIntensity ), {
58
58
  // @TODO: Add Texture2D support using node context
59
- getUV: () => normalWorld,
59
+ getUV: () => backgroundRotation.mul( normalWorld ),
60
60
  getTextureLevel: () => backgroundBlurriness
61
61
  } );
62
62
 
@@ -111,8 +111,6 @@ class Background extends DataMap {
111
111
 
112
112
  if ( renderer.autoClear === true || forceClear === true ) {
113
113
 
114
- _clearColor.multiplyScalar( _clearColor.a );
115
-
116
114
  const clearColorValue = renderContext.clearColorValue;
117
115
 
118
116
  clearColorValue.r = _clearColor.r;
@@ -120,6 +118,18 @@ class Background extends DataMap {
120
118
  clearColorValue.b = _clearColor.b;
121
119
  clearColorValue.a = _clearColor.a;
122
120
 
121
+ // premultiply alpha
122
+
123
+ if ( renderer.backend.isWebGLBackend === true || renderer.alpha === true ) {
124
+
125
+ clearColorValue.r *= clearColorValue.a;
126
+ clearColorValue.g *= clearColorValue.a;
127
+ clearColorValue.b *= clearColorValue.a;
128
+
129
+ }
130
+
131
+ //
132
+
123
133
  renderContext.depthClearValue = renderer._clearDepth;
124
134
  renderContext.stencilClearValue = renderer._clearStencil;
125
135
 
@@ -101,8 +101,9 @@ class Bindings extends DataMap {
101
101
  } else if ( binding.isStorageBuffer ) {
102
102
 
103
103
  const attribute = binding.attribute;
104
+ const attributeType = attribute.isIndirectStorageBufferAttribute ? AttributeType.INDIRECT : AttributeType.STORAGE;
104
105
 
105
- this.attributes.update( attribute, AttributeType.STORAGE );
106
+ this.attributes.update( attribute, attributeType );
106
107
 
107
108
  }
108
109
 
@@ -176,7 +177,7 @@ class Bindings extends DataMap {
176
177
 
177
178
  textureData.needsMipmap = true;
178
179
 
179
- } else if ( texture.generateMipmaps === true && this.textures.needsMipmaps( texture ) && textureData.needsMipmap === true ) {
180
+ } else if ( this.textures.needsMipmaps( texture ) && textureData.needsMipmap === true ) {
180
181
 
181
182
  this.backend.generateMipmaps( texture );
182
183
 
@@ -1,7 +1,8 @@
1
1
  export const AttributeType = {
2
2
  VERTEX: 1,
3
3
  INDEX: 2,
4
- STORAGE: 4
4
+ STORAGE: 3,
5
+ INDIRECT: 4
5
6
  };
6
7
 
7
8
  // size of a chunk in bytes (STD140 layout)
@@ -144,6 +144,8 @@ class Geometries extends DataMap {
144
144
 
145
145
  updateAttributes( renderObject ) {
146
146
 
147
+ // attributes
148
+
147
149
  const attributes = renderObject.getAttributes();
148
150
 
149
151
  for ( const attribute of attributes ) {
@@ -160,6 +162,8 @@ class Geometries extends DataMap {
160
162
 
161
163
  }
162
164
 
165
+ // indexes
166
+
163
167
  const index = this.getIndex( renderObject );
164
168
 
165
169
  if ( index !== null ) {
@@ -168,6 +172,16 @@ class Geometries extends DataMap {
168
172
 
169
173
  }
170
174
 
175
+ // indirect
176
+
177
+ const indirect = renderObject.geometry.indirect;
178
+
179
+ if ( indirect !== null ) {
180
+
181
+ this.updateAttribute( indirect, AttributeType.INDIRECT );
182
+
183
+ }
184
+
171
185
  }
172
186
 
173
187
  updateAttribute( attribute, type ) {
@@ -206,6 +220,12 @@ class Geometries extends DataMap {
206
220
 
207
221
  }
208
222
 
223
+ getIndirect( renderObject ) {
224
+
225
+ return renderObject.geometry.indirect;
226
+
227
+ }
228
+
209
229
  getIndex( renderObject ) {
210
230
 
211
231
  const { geometry, material } = renderObject;
@@ -0,0 +1,15 @@
1
+ import StorageBufferAttribute from './StorageBufferAttribute.js';
2
+
3
+ class IndirectStorageBufferAttribute extends StorageBufferAttribute {
4
+
5
+ constructor( array, itemSize ) {
6
+
7
+ super( array, itemSize, Uint32Array );
8
+
9
+ this.isIndirectStorageBufferAttribute = true;
10
+
11
+ }
12
+
13
+ }
14
+
15
+ export default IndirectStorageBufferAttribute;
@@ -0,0 +1,45 @@
1
+ import { LightsNode } from '../../nodes/Nodes.js';
2
+ import ChainMap from './ChainMap.js';
3
+
4
+ const _defaultLights = /*@__PURE__*/ new LightsNode();
5
+
6
+ class Lighting extends ChainMap {
7
+
8
+ constructor() {
9
+
10
+ super();
11
+
12
+ }
13
+
14
+ createNode( lights = [] ) {
15
+
16
+ return new LightsNode().setLights( lights );
17
+
18
+ }
19
+
20
+ getNode( scene, camera ) {
21
+
22
+ // ignore post-processing
23
+
24
+ if ( scene.isQuadMesh ) return _defaultLights;
25
+
26
+ // tiled lighting
27
+
28
+ const keys = [ scene, camera ];
29
+
30
+ let node = this.get( keys );
31
+
32
+ if ( node === undefined ) {
33
+
34
+ node = this.createNode();
35
+ this.set( keys, node );
36
+
37
+ }
38
+
39
+ return node;
40
+
41
+ }
42
+
43
+ }
44
+
45
+ export default Lighting;