super-three 0.172.0 → 0.173.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 (178) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +439 -380
  3. package/build/three.core.js +413 -41
  4. package/build/three.core.min.js +2 -2
  5. package/build/three.module.js +28 -344
  6. package/build/three.module.min.js +2 -2
  7. package/build/three.tsl.js +11 -3
  8. package/build/three.tsl.min.js +2 -2
  9. package/build/three.webgpu.js +7550 -1798
  10. package/build/three.webgpu.min.js +2 -2
  11. package/build/three.webgpu.nodes.js +7551 -1798
  12. package/build/three.webgpu.nodes.min.js +2 -2
  13. package/examples/jsm/animation/CCDIKSolver.js +6 -5
  14. package/examples/jsm/capabilities/WebGPU.js +1 -1
  15. package/examples/jsm/controls/ArcballControls.js +23 -21
  16. package/examples/jsm/exporters/GLTFExporter.js +26 -25
  17. package/examples/jsm/geometries/TextGeometry.js +1 -12
  18. package/examples/jsm/interactive/InteractiveGroup.js +108 -51
  19. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  20. package/examples/jsm/loaders/GCodeLoader.js +3 -1
  21. package/examples/jsm/loaders/GLTFLoader.js +0 -2
  22. package/examples/jsm/loaders/TDSLoader.js +0 -1
  23. package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
  24. package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
  25. package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
  26. package/examples/jsm/misc/ProgressiveLightMapGPU.js +4 -3
  27. package/examples/jsm/misc/Volume.js +7 -5
  28. package/examples/jsm/misc/VolumeSlice.js +5 -3
  29. package/examples/jsm/objects/WaterMesh.js +25 -20
  30. package/examples/jsm/physics/JoltPhysics.js +7 -7
  31. package/examples/jsm/physics/RapierPhysics.js +4 -4
  32. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  33. package/examples/jsm/shaders/OutputShader.js +5 -1
  34. package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
  35. package/examples/jsm/transpiler/TSLEncoder.js +2 -0
  36. package/package.json +1 -1
  37. package/src/Three.Core.js +2 -0
  38. package/src/Three.TSL.js +9 -1
  39. package/src/cameras/ArrayCamera.js +1 -0
  40. package/src/constants.js +6 -1
  41. package/src/core/BufferAttribute.js +4 -0
  42. package/src/core/EventDispatcher.js +8 -6
  43. package/src/extras/ImageUtils.js +1 -11
  44. package/src/loaders/nodes/NodeObjectLoader.js +1 -1
  45. package/src/materials/nodes/MeshBasicNodeMaterial.js +1 -1
  46. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +1 -1
  47. package/src/materials/nodes/NodeMaterial.js +5 -5
  48. package/src/materials/nodes/NodeMaterials.js +0 -1
  49. package/src/materials/nodes/PointsNodeMaterial.js +109 -7
  50. package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
  51. package/src/materials/nodes/VolumeNodeMaterial.js +3 -3
  52. package/src/materials/nodes/manager/NodeMaterialObserver.js +8 -0
  53. package/src/nodes/Nodes.js +4 -0
  54. package/src/nodes/TSL.js +4 -0
  55. package/src/nodes/accessors/Arrays.js +30 -8
  56. package/src/nodes/accessors/BatchNode.js +3 -3
  57. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  58. package/src/nodes/accessors/Camera.js +64 -3
  59. package/src/nodes/accessors/InstanceNode.js +1 -1
  60. package/src/nodes/accessors/MaterialNode.js +9 -9
  61. package/src/nodes/accessors/ModelViewProjectionNode.js +1 -1
  62. package/src/nodes/accessors/Normal.js +6 -2
  63. package/src/nodes/accessors/Object3DNode.js +0 -1
  64. package/src/nodes/accessors/Position.js +6 -6
  65. package/src/nodes/accessors/ReferenceBaseNode.js +2 -4
  66. package/src/nodes/accessors/ReferenceNode.js +2 -3
  67. package/src/nodes/accessors/StorageBufferNode.js +42 -5
  68. package/src/nodes/accessors/Tangent.js +2 -2
  69. package/src/nodes/accessors/Texture3DNode.js +1 -1
  70. package/src/nodes/accessors/TextureNode.js +12 -5
  71. package/src/nodes/accessors/UniformArrayNode.js +9 -3
  72. package/src/nodes/accessors/VelocityNode.js +0 -2
  73. package/src/nodes/code/ScriptableNode.js +3 -3
  74. package/src/nodes/core/ArrayNode.js +125 -0
  75. package/src/nodes/core/ConstNode.js +8 -0
  76. package/src/nodes/core/Node.js +14 -1
  77. package/src/nodes/core/NodeBuilder.js +229 -19
  78. package/src/nodes/core/NodeUtils.js +11 -1
  79. package/src/nodes/core/NodeVar.js +17 -1
  80. package/src/nodes/core/OutputStructNode.js +19 -9
  81. package/src/nodes/core/StackNode.js +20 -1
  82. package/src/nodes/core/StructNode.js +121 -0
  83. package/src/nodes/core/StructType.js +13 -0
  84. package/src/nodes/core/StructTypeNode.js +82 -21
  85. package/src/nodes/core/TempNode.js +1 -1
  86. package/src/nodes/core/VarNode.js +94 -7
  87. package/src/nodes/core/VaryingNode.js +19 -3
  88. package/src/nodes/display/BlendModes.js +88 -1
  89. package/src/nodes/display/BumpMapNode.js +6 -6
  90. package/src/nodes/display/NormalMapNode.js +6 -6
  91. package/src/nodes/display/PassNode.js +3 -1
  92. package/src/nodes/display/ScreenNode.js +9 -0
  93. package/src/nodes/fog/Fog.js +17 -0
  94. package/src/nodes/gpgpu/AtomicFunctionNode.js +20 -4
  95. package/src/nodes/gpgpu/ComputeBuiltinNode.js +8 -0
  96. package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
  97. package/src/nodes/lighting/ShadowNode.js +1 -1
  98. package/src/nodes/math/ConditionalNode.js +8 -1
  99. package/src/nodes/math/MathNode.js +14 -1
  100. package/src/nodes/math/OperatorNode.js +96 -18
  101. package/src/nodes/pmrem/PMREMUtils.js +1 -1
  102. package/src/nodes/shapes/Shapes.js +33 -0
  103. package/src/nodes/tsl/TSLBase.js +1 -0
  104. package/src/nodes/tsl/TSLCore.js +22 -2
  105. package/src/nodes/utils/ArrayElementNode.js +1 -1
  106. package/src/nodes/utils/LoopNode.js +8 -1
  107. package/src/nodes/utils/MemberNode.js +68 -0
  108. package/src/nodes/utils/StorageArrayElementNode.js +14 -0
  109. package/src/nodes/utils/Timer.js +21 -0
  110. package/src/objects/BatchedMesh.js +1 -1
  111. package/src/objects/Line.js +6 -6
  112. package/src/renderers/WebGLRenderer.js +7 -0
  113. package/src/renderers/common/Animation.js +23 -1
  114. package/src/renderers/common/Backend.js +58 -15
  115. package/src/renderers/common/Background.js +14 -0
  116. package/src/renderers/common/Binding.js +1 -1
  117. package/src/renderers/common/BufferUtils.js +1 -1
  118. package/src/renderers/common/BundleGroup.js +1 -1
  119. package/src/renderers/common/ChainMap.js +9 -7
  120. package/src/renderers/common/ClippingContext.js +1 -1
  121. package/src/renderers/common/Color4.js +7 -3
  122. package/src/renderers/common/Geometries.js +2 -23
  123. package/src/renderers/common/Info.js +1 -45
  124. package/src/renderers/common/Lighting.js +8 -6
  125. package/src/renderers/common/Pipelines.js +3 -3
  126. package/src/renderers/common/PostProcessing.js +24 -8
  127. package/src/renderers/common/QuadMesh.js +1 -1
  128. package/src/renderers/common/RenderBundles.js +9 -3
  129. package/src/renderers/common/RenderContext.js +37 -3
  130. package/src/renderers/common/RenderContexts.js +30 -17
  131. package/src/renderers/common/RenderList.js +2 -2
  132. package/src/renderers/common/RenderLists.js +9 -3
  133. package/src/renderers/common/RenderObject.js +76 -17
  134. package/src/renderers/common/RenderObjects.js +9 -7
  135. package/src/renderers/common/Renderer.js +86 -67
  136. package/src/renderers/common/SampledTexture.js +0 -1
  137. package/src/renderers/common/StorageBufferAttribute.js +1 -1
  138. package/src/renderers/common/StorageInstancedBufferAttribute.js +1 -1
  139. package/src/renderers/common/StorageTexture.js +1 -1
  140. package/src/renderers/common/Textures.js +14 -7
  141. package/src/renderers/common/TimestampQueryPool.js +39 -0
  142. package/src/renderers/common/Uniform.js +37 -1
  143. package/src/renderers/common/UniformsGroup.js +2 -0
  144. package/src/renderers/common/XRManager.js +1193 -0
  145. package/src/renderers/common/XRRenderTarget.js +74 -0
  146. package/src/renderers/common/extras/PMREMGenerator.js +53 -8
  147. package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
  148. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  149. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -1
  150. package/src/renderers/common/nodes/NodeUniform.js +54 -2
  151. package/src/renderers/common/nodes/Nodes.js +25 -18
  152. package/src/renderers/webgl/WebGLBackground.js +4 -0
  153. package/src/renderers/webgl-fallback/WebGLBackend.js +295 -110
  154. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -17
  155. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +57 -0
  156. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
  157. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
  158. package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
  159. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +167 -21
  160. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
  161. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
  162. package/src/renderers/webgpu/WebGPUBackend.js +132 -149
  163. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +6 -4
  164. package/src/renderers/webgpu/WebGPURenderer.js +5 -4
  165. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +615 -41
  166. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +85 -6
  167. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +85 -0
  168. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
  169. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
  170. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +257 -9
  171. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
  172. package/src/renderers/webgpu/utils/WebGPUUtils.js +86 -4
  173. package/src/renderers/webxr/WebXRManager.js +13 -2
  174. package/src/textures/VideoFrameTexture.js +35 -0
  175. package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
  176. package/examples/jsm/objects/InstancedPoints.js +0 -19
  177. package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -209
  178. package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -37
@@ -32,25 +32,82 @@ const _compareToWebGPU = {
32
32
 
33
33
  const _flipMap = [ 0, 1, 3, 2, 4, 5 ];
34
34
 
35
+ /**
36
+ * A WebGPU backend utility module for managing textures.
37
+ *
38
+ * @private
39
+ */
35
40
  class WebGPUTextureUtils {
36
41
 
42
+ /**
43
+ * Constructs a new utility object.
44
+ *
45
+ * @param {WebGPUBackend} backend - The WebGPU backend.
46
+ */
37
47
  constructor( backend ) {
38
48
 
49
+ /**
50
+ * A reference to the WebGPU backend.
51
+ *
52
+ * @type {WebGPUBackend}
53
+ */
39
54
  this.backend = backend;
40
55
 
56
+ /**
57
+ * A reference to the pass utils.
58
+ *
59
+ * @type {WebGPUTexturePassUtils?}
60
+ * @default null
61
+ */
41
62
  this._passUtils = null;
42
63
 
64
+ /**
65
+ * A dictionary for managing default textures. The key
66
+ * is the texture format, the value the texture object.
67
+ *
68
+ * @type {Object<String,Texture>}
69
+ */
43
70
  this.defaultTexture = {};
71
+
72
+ /**
73
+ * A dictionary for managing default cube textures. The key
74
+ * is the texture format, the value the texture object.
75
+ *
76
+ * @type {Object<String,CubeTexture>}
77
+ */
44
78
  this.defaultCubeTexture = {};
79
+
80
+ /**
81
+ * A default video frame.
82
+ *
83
+ * @type {VideoFrame?}
84
+ * @default null
85
+ */
45
86
  this.defaultVideoFrame = null;
46
87
 
88
+ /**
89
+ * Represents the color attachment of the default framebuffer.
90
+ *
91
+ * @type {GPUTexture?}
92
+ * @default null
93
+ */
47
94
  this.colorBuffer = null;
48
95
 
96
+ /**
97
+ * Represents the depth attachment of the default framebuffer.
98
+ *
99
+ * @type {DepthTexture}
100
+ */
49
101
  this.depthTexture = new DepthTexture();
50
102
  this.depthTexture.name = 'depthBuffer';
51
103
 
52
104
  }
53
105
 
106
+ /**
107
+ * Creates a GPU sampler for the given texture.
108
+ *
109
+ * @param {Texture} texture - The texture to create the sampler for.
110
+ */
54
111
  createSampler( texture ) {
55
112
 
56
113
  const backend = this.backend;
@@ -86,6 +143,12 @@ class WebGPUTextureUtils {
86
143
 
87
144
  }
88
145
 
146
+ /**
147
+ * Creates a default texture for the given texture that can be used
148
+ * as a placeholder until the actual texture is ready for usage.
149
+ *
150
+ * @param {Texture} texture - The texture to create a default texture for.
151
+ */
89
152
  createDefaultTexture( texture ) {
90
153
 
91
154
  let textureGPU;
@@ -110,6 +173,13 @@ class WebGPUTextureUtils {
110
173
 
111
174
  }
112
175
 
176
+ /**
177
+ * Defines a texture on the GPU for the given texture object.
178
+ *
179
+ * @param {Texture} texture - The texture.
180
+ * @param {Object} [options={}] - Optional configuration parameter.
181
+ * @return {undefined}
182
+ */
113
183
  createTexture( texture, options = {} ) {
114
184
 
115
185
  const backend = this.backend;
@@ -221,6 +291,11 @@ class WebGPUTextureUtils {
221
291
 
222
292
  }
223
293
 
294
+ /**
295
+ * Destroys the GPU data for the given texture object.
296
+ *
297
+ * @param {Texture} texture - The texture.
298
+ */
224
299
  destroyTexture( texture ) {
225
300
 
226
301
  const backend = this.backend;
@@ -234,6 +309,11 @@ class WebGPUTextureUtils {
234
309
 
235
310
  }
236
311
 
312
+ /**
313
+ * Destroys the GPU sampler for the given texture.
314
+ *
315
+ * @param {Texture} texture - The texture to destroy the sampler for.
316
+ */
237
317
  destroySampler( texture ) {
238
318
 
239
319
  const backend = this.backend;
@@ -243,6 +323,11 @@ class WebGPUTextureUtils {
243
323
 
244
324
  }
245
325
 
326
+ /**
327
+ * Generates mipmaps for the given texture.
328
+ *
329
+ * @param {Texture} texture - The texture.
330
+ */
246
331
  generateMipmaps( texture ) {
247
332
 
248
333
  const textureData = this.backend.get( texture );
@@ -269,6 +354,12 @@ class WebGPUTextureUtils {
269
354
 
270
355
  }
271
356
 
357
+ /**
358
+ * Returns the color buffer representing the color
359
+ * attachment of the default framebuffer.
360
+ *
361
+ * @return {GPUTexture} The color buffer.
362
+ */
272
363
  getColorBuffer() {
273
364
 
274
365
  if ( this.colorBuffer ) this.colorBuffer.destroy();
@@ -292,6 +383,14 @@ class WebGPUTextureUtils {
292
383
 
293
384
  }
294
385
 
386
+ /**
387
+ * Returns the depth buffer representing the depth
388
+ * attachment of the default framebuffer.
389
+ *
390
+ * @param {Boolean} [depth=true] - Whether depth is enabled or not.
391
+ * @param {Boolean} [stencil=false] - Whether stencil is enabled or not.
392
+ * @return {GPUTexture} The depth buffer.
393
+ */
295
394
  getDepthBuffer( depth = true, stencil = false ) {
296
395
 
297
396
  const backend = this.backend;
@@ -338,6 +437,12 @@ class WebGPUTextureUtils {
338
437
 
339
438
  }
340
439
 
440
+ /**
441
+ * Uploads the updated texture data to the GPU.
442
+ *
443
+ * @param {Texture} texture - The texture.
444
+ * @param {Object} [options={}] - Optional configuration parameter.
445
+ */
341
446
  updateTexture( texture, options ) {
342
447
 
343
448
  const textureData = this.backend.get( texture );
@@ -389,6 +494,18 @@ class WebGPUTextureUtils {
389
494
 
390
495
  }
391
496
 
497
+ /**
498
+ * Returns texture data as a typed array.
499
+ *
500
+ * @async
501
+ * @param {Texture} texture - The texture to copy.
502
+ * @param {Number} x - The x coordinate of the copy origin.
503
+ * @param {Number} y - The y coordinate of the copy origin.
504
+ * @param {Number} width - The width of the copy.
505
+ * @param {Number} height - The height of the copy.
506
+ * @param {Number} faceIndex - The face index.
507
+ * @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
508
+ */
392
509
  async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
393
510
 
394
511
  const device = this.backend.device;
@@ -438,6 +555,13 @@ class WebGPUTextureUtils {
438
555
 
439
556
  }
440
557
 
558
+ /**
559
+ * Returns `true` if the given texture is an environment map.
560
+ *
561
+ * @private
562
+ * @param {Texture} texture - The texture.
563
+ * @return {Boolean} Whether the given texture is an environment map or not.
564
+ */
441
565
  _isEnvironmentTexture( texture ) {
442
566
 
443
567
  const mapping = texture.mapping;
@@ -446,6 +570,13 @@ class WebGPUTextureUtils {
446
570
 
447
571
  }
448
572
 
573
+ /**
574
+ * Returns the default GPU texture for the given format.
575
+ *
576
+ * @private
577
+ * @param {String} format - The GPU format.
578
+ * @return {GPUTexture} The GPU texture.
579
+ */
449
580
  _getDefaultTextureGPU( format ) {
450
581
 
451
582
  let defaultTexture = this.defaultTexture[ format ];
@@ -466,6 +597,13 @@ class WebGPUTextureUtils {
466
597
 
467
598
  }
468
599
 
600
+ /**
601
+ * Returns the default GPU cube texture for the given format.
602
+ *
603
+ * @private
604
+ * @param {String} format - The GPU format.
605
+ * @return {GPUTexture} The GPU texture.
606
+ */
469
607
  _getDefaultCubeTextureGPU( format ) {
470
608
 
471
609
  let defaultCubeTexture = this.defaultTexture[ format ];
@@ -486,6 +624,12 @@ class WebGPUTextureUtils {
486
624
 
487
625
  }
488
626
 
627
+ /**
628
+ * Returns the default video frame used as default data in context of video textures.
629
+ *
630
+ * @private
631
+ * @return {VideoFrame} The video frame.
632
+ */
489
633
  _getDefaultVideoFrame() {
490
634
 
491
635
  let defaultVideoFrame = this.defaultVideoFrame;
@@ -507,6 +651,15 @@ class WebGPUTextureUtils {
507
651
 
508
652
  }
509
653
 
654
+ /**
655
+ * Uploads cube texture image data to the GPU memory.
656
+ *
657
+ * @private
658
+ * @param {Array} images - The cube image data.
659
+ * @param {GPUTexture} textureGPU - The GPU texture.
660
+ * @param {Object} textureDescriptorGPU - The GPU texture descriptor.
661
+ * @param {Boolean} flipY - Whether to flip texture data along their vertical axis or not.
662
+ */
510
663
  _copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY ) {
511
664
 
512
665
  for ( let i = 0; i < 6; i ++ ) {
@@ -529,13 +682,24 @@ class WebGPUTextureUtils {
529
682
 
530
683
  }
531
684
 
685
+ /**
686
+ * Uploads texture image data to the GPU memory.
687
+ *
688
+ * @private
689
+ * @param {HTMLImageElement|ImageBitmap|HTMLCanvasElement} image - The image data.
690
+ * @param {GPUTexture} textureGPU - The GPU texture.
691
+ * @param {Object} textureDescriptorGPU - The GPU texture descriptor.
692
+ * @param {Number} originDepth - The origin depth.
693
+ * @param {Boolean} flipY - Whether to flip texture data along their vertical axis or not.
694
+ */
532
695
  _copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY ) {
533
696
 
534
697
  const device = this.backend.device;
535
698
 
536
699
  device.queue.copyExternalImageToTexture(
537
700
  {
538
- source: image
701
+ source: image,
702
+ flipY: flipY
539
703
  }, {
540
704
  texture: textureGPU,
541
705
  mipLevel: 0,
@@ -547,14 +711,14 @@ class WebGPUTextureUtils {
547
711
  }
548
712
  );
549
713
 
550
- if ( flipY === true ) {
551
-
552
- this._flipY( textureGPU, textureDescriptorGPU, originDepth );
553
-
554
- }
555
-
556
714
  }
557
715
 
716
+ /**
717
+ * Returns the pass utils singleton.
718
+ *
719
+ * @private
720
+ * @return {WebGPUTexturePassUtils} The utils instance.
721
+ */
558
722
  _getPassUtils() {
559
723
 
560
724
  let passUtils = this._passUtils;
@@ -569,18 +733,45 @@ class WebGPUTextureUtils {
569
733
 
570
734
  }
571
735
 
736
+ /**
737
+ * Generates mipmaps for the given GPU texture.
738
+ *
739
+ * @private
740
+ * @param {GPUTexture} textureGPU - The GPU texture object.
741
+ * @param {Object} textureDescriptorGPU - The texture descriptor.
742
+ * @param {Number} [baseArrayLayer=0] - The index of the first array layer accessible to the texture view.
743
+ */
572
744
  _generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
573
745
 
574
746
  this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
575
747
 
576
748
  }
577
749
 
750
+ /**
751
+ * Flip the contents of the given GPU texture along its vertical axis.
752
+ *
753
+ * @private
754
+ * @param {GPUTexture} textureGPU - The GPU texture object.
755
+ * @param {Object} textureDescriptorGPU - The texture descriptor.
756
+ * @param {Number} [originDepth=0] - The origin depth.
757
+ */
578
758
  _flipY( textureGPU, textureDescriptorGPU, originDepth = 0 ) {
579
759
 
580
760
  this._getPassUtils().flipY( textureGPU, textureDescriptorGPU, originDepth );
581
761
 
582
762
  }
583
763
 
764
+ /**
765
+ * Uploads texture buffer data to the GPU memory.
766
+ *
767
+ * @private
768
+ * @param {Object} image - An object defining the image buffer data.
769
+ * @param {GPUTexture} textureGPU - The GPU texture.
770
+ * @param {Object} textureDescriptorGPU - The GPU texture descriptor.
771
+ * @param {Number} originDepth - The origin depth.
772
+ * @param {Boolean} flipY - Whether to flip texture data along their vertical axis or not.
773
+ * @param {Number} [depth=0] - TODO.
774
+ */
584
775
  _copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, depth = 0 ) {
585
776
 
586
777
  // @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
@@ -618,6 +809,14 @@ class WebGPUTextureUtils {
618
809
 
619
810
  }
620
811
 
812
+ /**
813
+ * Uploads compressed texture data to the GPU memory.
814
+ *
815
+ * @private
816
+ * @param {Array<Object>} mipmaps - An array with mipmap data.
817
+ * @param {GPUTexture} textureGPU - The GPU texture.
818
+ * @param {Object} textureDescriptorGPU - The GPU texture descriptor.
819
+ */
621
820
  _copyCompressedBufferToTexture( mipmaps, textureGPU, textureDescriptorGPU ) {
622
821
 
623
822
  // @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
@@ -665,10 +864,16 @@ class WebGPUTextureUtils {
665
864
 
666
865
  }
667
866
 
867
+ /**
868
+ * This method is only relevant for compressed texture formats. It returns a block
869
+ * data descriptor for the given GPU compressed texture format.
870
+ *
871
+ * @private
872
+ * @param {String} format - The GPU compressed texture format.
873
+ * @return {Object} The block data descriptor.
874
+ */
668
875
  _getBlockData( format ) {
669
876
 
670
- // this method is only relevant for compressed texture formats
671
-
672
877
  if ( format === GPUTextureFormat.BC1RGBAUnorm || format === GPUTextureFormat.BC1RGBAUnormSRGB ) return { byteLength: 8, width: 4, height: 4 }; // DXT1
673
878
  if ( format === GPUTextureFormat.BC2RGBAUnorm || format === GPUTextureFormat.BC2RGBAUnormSRGB ) return { byteLength: 16, width: 4, height: 4 }; // DXT3
674
879
  if ( format === GPUTextureFormat.BC3RGBAUnorm || format === GPUTextureFormat.BC3RGBAUnormSRGB ) return { byteLength: 16, width: 4, height: 4 }; // DXT5
@@ -702,6 +907,13 @@ class WebGPUTextureUtils {
702
907
 
703
908
  }
704
909
 
910
+ /**
911
+ * Converts the three.js uv wrapping constants to GPU address mode constants.
912
+ *
913
+ * @private
914
+ * @param {Number} value - The three.js constant defining a uv wrapping mode.
915
+ * @return {String} The GPU address mode.
916
+ */
705
917
  _convertAddressMode( value ) {
706
918
 
707
919
  let addressMode = GPUAddressMode.ClampToEdge;
@@ -720,6 +932,13 @@ class WebGPUTextureUtils {
720
932
 
721
933
  }
722
934
 
935
+ /**
936
+ * Converts the three.js filter constants to GPU filter constants.
937
+ *
938
+ * @private
939
+ * @param {Number} value - The three.js constant defining a filter mode.
940
+ * @return {String} The GPU filter mode.
941
+ */
723
942
  _convertFilterMode( value ) {
724
943
 
725
944
  let filterMode = GPUFilterMode.Linear;
@@ -734,6 +953,13 @@ class WebGPUTextureUtils {
734
953
 
735
954
  }
736
955
 
956
+ /**
957
+ * Returns the bytes-per-texel value for the given GPU texture format.
958
+ *
959
+ * @private
960
+ * @param {String} format - The GPU texture format.
961
+ * @return {Number} The bytes-per-texel.
962
+ */
737
963
  _getBytesPerTexel( format ) {
738
964
 
739
965
  // 8-bit formats
@@ -790,6 +1016,13 @@ class WebGPUTextureUtils {
790
1016
 
791
1017
  }
792
1018
 
1019
+ /**
1020
+ * Returns the corresponding typed array type for the given GPU texture format.
1021
+ *
1022
+ * @private
1023
+ * @param {String} format - The GPU texture format.
1024
+ * @return {TypedArray.constructor} The typed array type.
1025
+ */
793
1026
  _getTypedArrayType( format ) {
794
1027
 
795
1028
  if ( format === GPUTextureFormat.R8Uint ) return Uint8Array;
@@ -840,6 +1073,13 @@ class WebGPUTextureUtils {
840
1073
 
841
1074
  }
842
1075
 
1076
+ /**
1077
+ * Returns the GPU dimensions for the given texture.
1078
+ *
1079
+ * @private
1080
+ * @param {Texture} texture - The texture.
1081
+ * @return {String} The GPU dimension.
1082
+ */
843
1083
  _getDimension( texture ) {
844
1084
 
845
1085
  let dimension;
@@ -860,6 +1100,14 @@ class WebGPUTextureUtils {
860
1100
 
861
1101
  }
862
1102
 
1103
+ /**
1104
+ * Returns the GPU format for the given texture.
1105
+ *
1106
+ * @param {Texture} texture - The texture.
1107
+ * @param {GPUDevice?} [device=null] - The GPU device which is used for feature detection.
1108
+ * It is not necessary to apply the device for most formats.
1109
+ * @return {String} The GPU format.
1110
+ */
863
1111
  export function getFormat( texture, device = null ) {
864
1112
 
865
1113
  const format = texture.format;