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
@@ -2,6 +2,14 @@ import { IntType } from '../../../constants.js';
2
2
 
3
3
  let _id = 0;
4
4
 
5
+ /**
6
+ * This module is internally used in context of compute shaders.
7
+ * This type of shader is not natively supported in WebGL 2 and
8
+ * thus implemented via Transform Feedback. `DualAttributeData`
9
+ * manages the related data.
10
+ *
11
+ * @private
12
+ */
5
13
  class DualAttributeData {
6
14
 
7
15
  constructor( attributeData, dualBuffer ) {
@@ -46,14 +54,35 @@ class DualAttributeData {
46
54
 
47
55
  }
48
56
 
57
+ /**
58
+ * A WebGL 2 backend utility module for managing shader attributes.
59
+ *
60
+ * @private
61
+ */
49
62
  class WebGLAttributeUtils {
50
63
 
64
+ /**
65
+ * Constructs a new utility object.
66
+ *
67
+ * @param {WebGLBackend} backend - The WebGL 2 backend.
68
+ */
51
69
  constructor( backend ) {
52
70
 
71
+ /**
72
+ * A reference to the WebGL 2 backend.
73
+ *
74
+ * @type {WebGLBackend}
75
+ */
53
76
  this.backend = backend;
54
77
 
55
78
  }
56
79
 
80
+ /**
81
+ * Creates the GPU buffer for the given buffer attribute.
82
+ *
83
+ * @param {BufferAttribute} attribute - The buffer attribute.
84
+ * @param {GLenum } bufferType - A flag that indicates the buffer type and thus binding point target.
85
+ */
57
86
  createAttribute( attribute, bufferType ) {
58
87
 
59
88
  const backend = this.backend;
@@ -151,6 +180,11 @@ class WebGLAttributeUtils {
151
180
 
152
181
  }
153
182
 
183
+ /**
184
+ * Updates the GPU buffer of the given buffer attribute.
185
+ *
186
+ * @param {BufferAttribute} attribute - The buffer attribute.
187
+ */
154
188
  updateAttribute( attribute ) {
155
189
 
156
190
  const backend = this.backend;
@@ -190,6 +224,11 @@ class WebGLAttributeUtils {
190
224
 
191
225
  }
192
226
 
227
+ /**
228
+ * Destroys the GPU buffer of the given buffer attribute.
229
+ *
230
+ * @param {BufferAttribute} attribute - The buffer attribute.
231
+ */
193
232
  destroyAttribute( attribute ) {
194
233
 
195
234
  const backend = this.backend;
@@ -209,6 +248,14 @@ class WebGLAttributeUtils {
209
248
 
210
249
  }
211
250
 
251
+ /**
252
+ * This method performs a readback operation by moving buffer data from
253
+ * a storage buffer attribute from the GPU to the CPU.
254
+ *
255
+ * @async
256
+ * @param {StorageBufferAttribute} attribute - The storage buffer attribute.
257
+ * @return {Promise<ArrayBuffer>} A promise that resolves with the buffer data when the data are ready.
258
+ */
212
259
  async getArrayBufferAsync( attribute ) {
213
260
 
214
261
  const backend = this.backend;
@@ -247,6 +294,16 @@ class WebGLAttributeUtils {
247
294
 
248
295
  }
249
296
 
297
+ /**
298
+ * Creates a WebGL buffer with the given data.
299
+ *
300
+ * @private
301
+ * @param {WebGL2RenderingContext} gl - The rendering context.
302
+ * @param {GLenum } bufferType - A flag that indicates the buffer type and thus binding point target.
303
+ * @param {TypedArray} array - The array of the buffer attribute.
304
+ * @param {GLenum} usage - The usage.
305
+ * @return {WebGLBuffer} The WebGL buffer.
306
+ */
250
307
  _createBuffer( gl, bufferType, array, usage ) {
251
308
 
252
309
  const bufferGPU = gl.createBuffer();
@@ -1,13 +1,41 @@
1
+ /**
2
+ * A WebGL 2 backend utility module for managing the device's capabilities.
3
+ *
4
+ * @private
5
+ */
1
6
  class WebGLCapabilities {
2
7
 
8
+ /**
9
+ * Constructs a new utility object.
10
+ *
11
+ * @param {WebGLBackend} backend - The WebGL 2 backend.
12
+ */
3
13
  constructor( backend ) {
4
14
 
15
+ /**
16
+ * A reference to the WebGL 2 backend.
17
+ *
18
+ * @type {WebGLBackend}
19
+ */
5
20
  this.backend = backend;
6
21
 
22
+ /**
23
+ * This value holds the cached max anisotropy value.
24
+ *
25
+ * @type {Number?}
26
+ * @default null
27
+ */
7
28
  this.maxAnisotropy = null;
8
29
 
9
30
  }
10
31
 
32
+ /**
33
+ * Returns the maximum anisotropy texture filtering value. This value
34
+ * depends on the device and is reported by the `EXT_texture_filter_anisotropic`
35
+ * WebGL extension.
36
+ *
37
+ * @return {Number} The maximum anisotropy texture filtering value.
38
+ */
11
39
  getMaxAnisotropy() {
12
40
 
13
41
  if ( this.maxAnisotropy !== null ) return this.maxAnisotropy;
@@ -1,16 +1,55 @@
1
+ /**
2
+ * A WebGL 2 backend utility module for managing extensions.
3
+ *
4
+ * @private
5
+ */
1
6
  class WebGLExtensions {
2
7
 
8
+ /**
9
+ * Constructs a new utility object.
10
+ *
11
+ * @param {WebGLBackend} backend - The WebGL 2 backend.
12
+ */
3
13
  constructor( backend ) {
4
14
 
15
+ /**
16
+ * A reference to the WebGL 2 backend.
17
+ *
18
+ * @type {WebGLBackend}
19
+ */
5
20
  this.backend = backend;
6
21
 
22
+ /**
23
+ * A reference to the rendering context.
24
+ *
25
+ * @type {WebGL2RenderingContext}
26
+ */
7
27
  this.gl = this.backend.gl;
28
+
29
+ /**
30
+ * A list with all the supported WebGL extensions.
31
+ *
32
+ * @type {Array<String>}
33
+ */
8
34
  this.availableExtensions = this.gl.getSupportedExtensions();
9
35
 
36
+ /**
37
+ * A dictionary with requested WebGL extensions.
38
+ * The key is the name of the extension, the value
39
+ * the requested extension object.
40
+ *
41
+ * @type {Object<String,Object>}
42
+ */
10
43
  this.extensions = {};
11
44
 
12
45
  }
13
46
 
47
+ /**
48
+ * Returns the extension object for the given extension name.
49
+ *
50
+ * @param {String} name - The extension name.
51
+ * @return {Object} The extension object.
52
+ */
14
53
  get( name ) {
15
54
 
16
55
  let extension = this.extensions[ name ];
@@ -27,6 +66,12 @@ class WebGLExtensions {
27
66
 
28
67
  }
29
68
 
69
+ /**
70
+ * Returns `true` if the requested extension is available.
71
+ *
72
+ * @param {String} name - The extension name.
73
+ * @return {Boolean} Whether the given extension is available or not.
74
+ */
30
75
  has( name ) {
31
76
 
32
77
  return this.availableExtensions.includes( name );