super-three 0.177.0 → 0.179.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 (211) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +959 -231
  3. package/build/three.core.js +751 -170
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +210 -64
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +78 -29
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +3269 -1545
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +3093 -1545
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +1 -2
  14. package/examples/jsm/capabilities/WebGL.js +0 -27
  15. package/examples/jsm/capabilities/WebGPU.js +1 -1
  16. package/examples/jsm/controls/ArcballControls.js +1 -1
  17. package/examples/jsm/controls/TransformControls.js +61 -14
  18. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  19. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  20. package/examples/jsm/exporters/USDZExporter.js +676 -299
  21. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  22. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  23. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  24. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  25. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  26. package/examples/jsm/loaders/EXRLoader.js +210 -22
  27. package/examples/jsm/loaders/FBXLoader.js +2 -2
  28. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  29. package/examples/jsm/loaders/TTFLoader.js +13 -1
  30. package/examples/jsm/loaders/USDLoader.js +219 -0
  31. package/examples/jsm/loaders/USDZLoader.js +4 -892
  32. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  33. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  34. package/examples/jsm/objects/LensflareMesh.js +3 -3
  35. package/examples/jsm/objects/SkyMesh.js +2 -2
  36. package/examples/jsm/physics/RapierPhysics.js +95 -16
  37. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  38. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  39. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  40. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  41. package/examples/jsm/transpiler/AST.js +381 -30
  42. package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
  43. package/examples/jsm/transpiler/Linker.js +327 -0
  44. package/examples/jsm/transpiler/TSLEncoder.js +197 -92
  45. package/examples/jsm/transpiler/Transpiler.js +17 -1
  46. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  47. package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
  48. package/examples/jsm/tsl/display/BloomNode.js +8 -7
  49. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
  50. package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
  51. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  52. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  53. package/examples/jsm/tsl/display/hashBlur.js +3 -3
  54. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  55. package/package.json +1 -1
  56. package/src/Three.Core.js +1 -0
  57. package/src/Three.TSL.js +77 -28
  58. package/src/Three.WebGPU.js +2 -0
  59. package/src/animation/KeyframeTrack.js +1 -1
  60. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  61. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  62. package/src/cameras/Camera.js +14 -0
  63. package/src/cameras/OrthographicCamera.js +1 -1
  64. package/src/cameras/PerspectiveCamera.js +1 -1
  65. package/src/constants.js +3 -3
  66. package/src/core/BufferAttribute.js +3 -3
  67. package/src/core/Clock.js +2 -8
  68. package/src/core/GLBufferAttribute.js +13 -1
  69. package/src/core/Object3D.js +1 -1
  70. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  71. package/src/extras/PMREMGenerator.js +11 -0
  72. package/src/extras/core/Path.js +22 -22
  73. package/src/helpers/CameraHelper.js +41 -11
  74. package/src/helpers/SkeletonHelper.js +35 -6
  75. package/src/lights/LightShadow.js +21 -8
  76. package/src/lights/PointLightShadow.js +1 -1
  77. package/src/loaders/FileLoader.js +27 -4
  78. package/src/loaders/ImageBitmapLoader.js +27 -4
  79. package/src/loaders/ImageLoader.js +55 -8
  80. package/src/loaders/Loader.js +14 -0
  81. package/src/loaders/LoadingManager.js +23 -0
  82. package/src/materials/MeshBasicMaterial.js +1 -1
  83. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  84. package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
  85. package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
  86. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  87. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
  88. package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
  89. package/src/materials/nodes/NodeMaterial.js +28 -5
  90. package/src/materials/nodes/PointsNodeMaterial.js +5 -0
  91. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  92. package/src/math/Frustum.js +25 -9
  93. package/src/math/FrustumArray.js +10 -5
  94. package/src/math/Line3.js +129 -2
  95. package/src/math/Matrix4.js +48 -27
  96. package/src/math/Quaternion.js +1 -1
  97. package/src/math/Spherical.js +2 -2
  98. package/src/nodes/Nodes.js +2 -3
  99. package/src/nodes/TSL.js +5 -3
  100. package/src/nodes/accessors/AccessorsUtils.js +7 -8
  101. package/src/nodes/accessors/Bitangent.js +31 -25
  102. package/src/nodes/accessors/Camera.js +12 -12
  103. package/src/nodes/accessors/Normal.js +95 -29
  104. package/src/nodes/accessors/Object3DNode.js +1 -1
  105. package/src/nodes/accessors/Position.js +7 -7
  106. package/src/nodes/accessors/ReferenceNode.js +18 -3
  107. package/src/nodes/accessors/ReflectVector.js +3 -3
  108. package/src/nodes/accessors/SceneNode.js +1 -1
  109. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  110. package/src/nodes/accessors/Tangent.js +25 -17
  111. package/src/nodes/accessors/TangentUtils.js +46 -0
  112. package/src/nodes/accessors/TextureBicubic.js +21 -3
  113. package/src/nodes/accessors/TextureNode.js +12 -0
  114. package/src/nodes/accessors/UniformArrayNode.js +0 -16
  115. package/src/nodes/core/ArrayNode.js +12 -0
  116. package/src/nodes/core/AssignNode.js +3 -0
  117. package/src/nodes/core/CacheNode.js +0 -14
  118. package/src/nodes/core/ContextNode.js +20 -1
  119. package/src/nodes/core/Node.js +15 -3
  120. package/src/nodes/core/NodeBuilder.js +228 -92
  121. package/src/nodes/core/NodeUtils.js +4 -1
  122. package/src/nodes/core/StackNode.js +49 -29
  123. package/src/nodes/core/SubBuildNode.js +89 -0
  124. package/src/nodes/core/UniformNode.js +63 -5
  125. package/src/nodes/core/VarNode.js +91 -2
  126. package/src/nodes/core/VaryingNode.js +6 -4
  127. package/src/nodes/display/BlendModes.js +2 -2
  128. package/src/nodes/display/FrontFacingNode.js +34 -2
  129. package/src/nodes/display/NormalMapNode.js +19 -50
  130. package/src/nodes/display/PassNode.js +157 -9
  131. package/src/nodes/display/ScreenNode.js +0 -26
  132. package/src/nodes/display/ViewportTextureNode.js +67 -7
  133. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
  134. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  135. package/src/nodes/functions/PhongLightingModel.js +3 -3
  136. package/src/nodes/functions/PhysicalLightingModel.js +16 -16
  137. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  138. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  139. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  140. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  141. package/src/nodes/lighting/EnvironmentNode.js +5 -5
  142. package/src/nodes/lighting/LightsNode.js +4 -4
  143. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  144. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  145. package/src/nodes/lighting/ShadowNode.js +2 -2
  146. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  147. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  148. package/src/nodes/math/ConditionalNode.js +1 -20
  149. package/src/nodes/math/MathNode.js +90 -55
  150. package/src/nodes/math/OperatorNode.js +22 -39
  151. package/src/nodes/tsl/TSLBase.js +1 -0
  152. package/src/nodes/tsl/TSLCore.js +114 -55
  153. package/src/nodes/utils/DebugNode.js +1 -1
  154. package/src/nodes/utils/EquirectUV.js +27 -0
  155. package/src/nodes/utils/EventNode.js +83 -0
  156. package/src/nodes/utils/LoopNode.js +0 -17
  157. package/src/nodes/utils/MatcapUV.js +22 -0
  158. package/src/nodes/utils/RTTNode.js +22 -5
  159. package/src/nodes/utils/ReflectorNode.js +11 -4
  160. package/src/nodes/utils/SampleNode.js +81 -0
  161. package/src/nodes/utils/TriplanarTextures.js +65 -0
  162. package/src/objects/BatchedMesh.js +4 -2
  163. package/src/renderers/WebGLRenderer.js +26 -24
  164. package/src/renderers/common/Background.js +2 -2
  165. package/src/renderers/common/Bindings.js +19 -18
  166. package/src/renderers/common/Color4.js +2 -2
  167. package/src/renderers/common/CubeRenderTarget.js +1 -1
  168. package/src/renderers/common/PostProcessing.js +60 -5
  169. package/src/renderers/common/RenderObject.js +68 -3
  170. package/src/renderers/common/Renderer.js +19 -16
  171. package/src/renderers/common/SampledTexture.js +3 -71
  172. package/src/renderers/common/Sampler.js +79 -0
  173. package/src/renderers/common/Storage3DTexture.js +100 -0
  174. package/src/renderers/common/StorageArrayTexture.js +84 -0
  175. package/src/renderers/common/StorageTexture.js +19 -0
  176. package/src/renderers/common/Textures.js +19 -3
  177. package/src/renderers/common/XRManager.js +31 -12
  178. package/src/renderers/common/XRRenderTarget.js +21 -4
  179. package/src/renderers/common/extras/PMREMGenerator.js +1 -1
  180. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  181. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
  182. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  183. package/src/renderers/webgl/WebGLAttributes.js +4 -0
  184. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  185. package/src/renderers/webgl/WebGLProgram.js +12 -6
  186. package/src/renderers/webgl/WebGLPrograms.js +6 -4
  187. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  188. package/src/renderers/webgl/WebGLState.js +4 -4
  189. package/src/renderers/webgl/WebGLTextures.js +19 -7
  190. package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
  191. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
  192. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
  193. package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
  194. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
  195. package/src/renderers/webgpu/WebGPUBackend.js +63 -16
  196. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
  197. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
  198. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
  199. package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
  200. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  201. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
  202. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  203. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  204. package/src/renderers/webxr/WebXRManager.js +68 -6
  205. package/src/textures/ExternalTexture.js +45 -0
  206. package/src/textures/FramebufferTexture.js +2 -2
  207. package/src/textures/Source.js +11 -1
  208. package/src/textures/VideoTexture.js +30 -2
  209. package/src/nodes/utils/EquirectUVNode.js +0 -65
  210. package/src/nodes/utils/MatcapUVNode.js +0 -49
  211. package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
@@ -171,6 +171,16 @@ class RenderObject {
171
171
  */
172
172
  this.attributes = null;
173
173
 
174
+ /**
175
+ * An object holding the version of the
176
+ * attributes. The keys are the attribute names
177
+ * and the values are the attribute versions.
178
+ *
179
+ * @type {?Object<string, number>}
180
+ * @default null
181
+ */
182
+ this.attributesId = null;
183
+
174
184
  /**
175
185
  * A reference to a render pipeline the render
176
186
  * object is processed with.
@@ -290,7 +300,7 @@ class RenderObject {
290
300
 
291
301
  /**
292
302
  * An event listener which is executed when `dispose()` is called on
293
- * the render object's material.
303
+ * the material of this render object.
294
304
  *
295
305
  * @method
296
306
  */
@@ -300,7 +310,23 @@ class RenderObject {
300
310
 
301
311
  };
302
312
 
313
+ /**
314
+ * An event listener which is executed when `dispose()` is called on
315
+ * the geometry of this render object.
316
+ *
317
+ * @method
318
+ */
319
+ this.onGeometryDispose = () => {
320
+
321
+ // clear geometry cache attributes
322
+
323
+ this.attributes = null;
324
+ this.attributesId = null;
325
+
326
+ };
327
+
303
328
  this.material.addEventListener( 'dispose', this.onMaterialDispose );
329
+ this.geometry.addEventListener( 'dispose', this.onGeometryDispose );
304
330
 
305
331
  }
306
332
 
@@ -439,6 +465,7 @@ class RenderObject {
439
465
 
440
466
  this.geometry = geometry;
441
467
  this.attributes = null;
468
+ this.attributesId = null;
442
469
 
443
470
  }
444
471
 
@@ -458,9 +485,25 @@ class RenderObject {
458
485
  const attributes = [];
459
486
  const vertexBuffers = new Set();
460
487
 
488
+ const attributesId = {};
489
+
461
490
  for ( const nodeAttribute of nodeAttributes ) {
462
491
 
463
- const attribute = nodeAttribute.node && nodeAttribute.node.attribute ? nodeAttribute.node.attribute : geometry.getAttribute( nodeAttribute.name );
492
+ let attribute;
493
+
494
+ if ( nodeAttribute.node && nodeAttribute.node.attribute ) {
495
+
496
+ // node attribute
497
+ attribute = nodeAttribute.node.attribute;
498
+
499
+ } else {
500
+
501
+ // geometry attribute
502
+ attribute = geometry.getAttribute( nodeAttribute.name );
503
+
504
+ attributesId[ nodeAttribute.name ] = attribute.version;
505
+
506
+ }
464
507
 
465
508
  if ( attribute === undefined ) continue;
466
509
 
@@ -472,6 +515,7 @@ class RenderObject {
472
515
  }
473
516
 
474
517
  this.attributes = attributes;
518
+ this.attributesId = attributesId;
475
519
  this.vertexBuffers = Array.from( vertexBuffers.values() );
476
520
 
477
521
  return attributes;
@@ -736,7 +780,27 @@ class RenderObject {
736
780
  */
737
781
  get needsGeometryUpdate() {
738
782
 
739
- return this.geometry.id !== this.object.geometry.id;
783
+ if ( this.geometry.id !== this.object.geometry.id ) return true;
784
+
785
+ if ( this.attributes !== null ) {
786
+
787
+ const attributesId = this.attributesId;
788
+
789
+ for ( const name in attributesId ) {
790
+
791
+ const attribute = this.geometry.getAttribute( name );
792
+
793
+ if ( attribute === undefined || attributesId[ name ] !== attribute.id ) {
794
+
795
+ return true;
796
+
797
+ }
798
+
799
+ }
800
+
801
+ }
802
+
803
+ return false;
740
804
 
741
805
  }
742
806
 
@@ -814,6 +878,7 @@ class RenderObject {
814
878
  dispose() {
815
879
 
816
880
  this.material.removeEventListener( 'dispose', this.onMaterialDispose );
881
+ this.geometry.removeEventListener( 'dispose', this.onGeometryDispose );
817
882
 
818
883
  this.onDispose();
819
884
 
@@ -21,13 +21,14 @@ import XRManager from './XRManager.js';
21
21
  import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
22
22
 
23
23
  import { Scene } from '../../scenes/Scene.js';
24
+ import { ColorManagement } from '../../math/ColorManagement.js';
24
25
  import { Frustum } from '../../math/Frustum.js';
25
26
  import { FrustumArray } from '../../math/FrustumArray.js';
26
27
  import { Matrix4 } from '../../math/Matrix4.js';
27
28
  import { Vector2 } from '../../math/Vector2.js';
28
29
  import { Vector4 } from '../../math/Vector4.js';
29
30
  import { RenderTarget } from '../../core/RenderTarget.js';
30
- import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, LinearSRGBColorSpace, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
31
+ import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
31
32
 
32
33
  import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
33
34
 
@@ -1210,7 +1211,7 @@ class Renderer {
1210
1211
  const { currentToneMapping, currentColorSpace } = this;
1211
1212
 
1212
1213
  const useToneMapping = currentToneMapping !== NoToneMapping;
1213
- const useColorSpace = currentColorSpace !== LinearSRGBColorSpace;
1214
+ const useColorSpace = currentColorSpace !== ColorManagement.workingColorSpace;
1214
1215
 
1215
1216
  if ( useToneMapping === false && useColorSpace === false ) return null;
1216
1217
 
@@ -1226,7 +1227,7 @@ class Renderer {
1226
1227
  stencilBuffer: stencil,
1227
1228
  type: this._colorBufferType,
1228
1229
  format: RGBAFormat,
1229
- colorSpace: LinearSRGBColorSpace,
1230
+ colorSpace: ColorManagement.workingColorSpace,
1230
1231
  generateMipmaps: false,
1231
1232
  minFilter: LinearFilter,
1232
1233
  magFilter: LinearFilter,
@@ -1260,7 +1261,7 @@ class Renderer {
1260
1261
  frameBufferTarget.scissorTest = this._scissorTest;
1261
1262
  frameBufferTarget.multiview = outputRenderTarget !== null ? outputRenderTarget.multiview : false;
1262
1263
  frameBufferTarget.resolveDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.resolveDepthBuffer : true;
1263
- frameBufferTarget.autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget.autoAllocateDepthBuffer : false;
1264
+ frameBufferTarget._autoAllocateDepthBuffer = outputRenderTarget !== null ? outputRenderTarget._autoAllocateDepthBuffer : false;
1264
1265
 
1265
1266
  return frameBufferTarget;
1266
1267
 
@@ -1412,7 +1413,7 @@ class Renderer {
1412
1413
  if ( ! camera.isArrayCamera ) {
1413
1414
 
1414
1415
  _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
1415
- frustum.setFromProjectionMatrix( _projScreenMatrix, coordinateSystem );
1416
+ frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );
1416
1417
 
1417
1418
  }
1418
1419
 
@@ -2130,8 +2131,8 @@ class Renderer {
2130
2131
  }
2131
2132
 
2132
2133
  /**
2133
- * The current output tone mapping of the renderer. When a render target is set,
2134
- * the output tone mapping is always `NoToneMapping`.
2134
+ * The current tone mapping of the renderer. When not producing screen output,
2135
+ * the tone mapping is always `NoToneMapping`.
2135
2136
  *
2136
2137
  * @type {number}
2137
2138
  */
@@ -2142,14 +2143,14 @@ class Renderer {
2142
2143
  }
2143
2144
 
2144
2145
  /**
2145
- * The current output color space of the renderer. When a render target is set,
2146
- * the output color space is always `LinearSRGBColorSpace`.
2146
+ * The current color space of the renderer. When not producing screen output,
2147
+ * the color space is always the working color space.
2147
2148
  *
2148
2149
  * @type {string}
2149
2150
  */
2150
2151
  get currentColorSpace() {
2151
2152
 
2152
- return this.isOutputTarget ? this.outputColorSpace : LinearSRGBColorSpace;
2153
+ return this.isOutputTarget ? this.outputColorSpace : ColorManagement.workingColorSpace;
2153
2154
 
2154
2155
  }
2155
2156
 
@@ -2308,9 +2309,10 @@ class Renderer {
2308
2309
  * if the renderer has been initialized.
2309
2310
  *
2310
2311
  * @param {Node|Array<Node>} computeNodes - The compute node(s).
2312
+ * @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2311
2313
  * @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
2312
2314
  */
2313
- compute( computeNodes ) {
2315
+ compute( computeNodes, dispatchSizeOrCount = null ) {
2314
2316
 
2315
2317
  if ( this._isDeviceLost === true ) return;
2316
2318
 
@@ -2389,7 +2391,7 @@ class Renderer {
2389
2391
  const computeBindings = bindings.getForCompute( computeNode );
2390
2392
  const computePipeline = pipelines.getForCompute( computeNode, computeBindings );
2391
2393
 
2392
- backend.compute( computeNodes, computeNode, computeBindings, computePipeline );
2394
+ backend.compute( computeNodes, computeNode, computeBindings, computePipeline, dispatchSizeOrCount );
2393
2395
 
2394
2396
  }
2395
2397
 
@@ -2406,13 +2408,14 @@ class Renderer {
2406
2408
  *
2407
2409
  * @async
2408
2410
  * @param {Node|Array<Node>} computeNodes - The compute node(s).
2411
+ * @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
2409
2412
  * @return {Promise} A Promise that resolve when the compute has finished.
2410
2413
  */
2411
- async computeAsync( computeNodes ) {
2414
+ async computeAsync( computeNodes, dispatchSizeOrCount = null ) {
2412
2415
 
2413
2416
  if ( this._initialized === false ) await this.init();
2414
2417
 
2415
- this.compute( computeNodes );
2418
+ this.compute( computeNodes, dispatchSizeOrCount );
2416
2419
 
2417
2420
  }
2418
2421
 
@@ -2961,7 +2964,7 @@ class Renderer {
2961
2964
  * @param {LightsNode} lightsNode - The current lights node.
2962
2965
  * @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
2963
2966
  * @param {ClippingContext} clippingContext - The clipping context.
2964
- * @param {?string} [passId=null] - An optional ID for identifying the pass.
2967
+ * @param {string} [passId] - An optional ID for identifying the pass.
2965
2968
  */
2966
2969
  _renderObjectDirect( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
2967
2970
 
@@ -3016,7 +3019,7 @@ class Renderer {
3016
3019
  * @param {LightsNode} lightsNode - The current lights node.
3017
3020
  * @param {?{start: number, count: number}} group - Only relevant for objects using multiple materials. This represents a group entry from the respective `BufferGeometry`.
3018
3021
  * @param {ClippingContext} clippingContext - The clipping context.
3019
- * @param {?string} [passId=null] - An optional ID for identifying the pass.
3022
+ * @param {string} [passId] - An optional ID for identifying the pass.
3020
3023
  */
3021
3024
  _createObjectPipeline( object, material, scene, camera, lightsNode, group, clippingContext, passId ) {
3022
3025
 
@@ -1,4 +1,4 @@
1
- import Binding from './Binding.js';
1
+ import Sampler from './Sampler.js';
2
2
 
3
3
  let _id = 0;
4
4
 
@@ -8,7 +8,7 @@ let _id = 0;
8
8
  * @private
9
9
  * @augments Binding
10
10
  */
11
- class SampledTexture extends Binding {
11
+ class SampledTexture extends Sampler {
12
12
 
13
13
  /**
14
14
  * Constructs a new sampled texture.
@@ -18,7 +18,7 @@ class SampledTexture extends Binding {
18
18
  */
19
19
  constructor( name, texture ) {
20
20
 
21
- super( name );
21
+ super( name, texture );
22
22
 
23
23
  /**
24
24
  * This identifier.
@@ -27,20 +27,6 @@ class SampledTexture extends Binding {
27
27
  */
28
28
  this.id = _id ++;
29
29
 
30
- /**
31
- * The texture this binding is referring to.
32
- *
33
- * @type {?Texture}
34
- */
35
- this.texture = texture;
36
-
37
- /**
38
- * The binding's version.
39
- *
40
- * @type {number}
41
- */
42
- this.version = texture ? texture.version : 0;
43
-
44
30
  /**
45
31
  * Whether the texture is a storage texture or not.
46
32
  *
@@ -49,15 +35,6 @@ class SampledTexture extends Binding {
49
35
  */
50
36
  this.store = false;
51
37
 
52
- /**
53
- * The binding's generation which is an additional version
54
- * qualifier.
55
- *
56
- * @type {?number}
57
- * @default null
58
- */
59
- this.generation = null;
60
-
61
38
  /**
62
39
  * This flag can be used for type testing.
63
40
  *
@@ -69,51 +46,6 @@ class SampledTexture extends Binding {
69
46
 
70
47
  }
71
48
 
72
- /**
73
- * Returns `true` whether this binding requires an update for the
74
- * given generation.
75
- *
76
- * @param {number} generation - The generation.
77
- * @return {boolean} Whether an update is required or not.
78
- */
79
- needsBindingsUpdate( generation ) {
80
-
81
- const { texture } = this;
82
-
83
- if ( generation !== this.generation ) {
84
-
85
- this.generation = generation;
86
-
87
- return true;
88
-
89
- }
90
-
91
- return texture.isVideoTexture;
92
-
93
- }
94
-
95
- /**
96
- * Updates the binding.
97
- *
98
- * @return {boolean} Whether the texture has been updated and must be
99
- * uploaded to the GPU.
100
- */
101
- update() {
102
-
103
- const { texture, version } = this;
104
-
105
- if ( version !== texture.version ) {
106
-
107
- this.version = texture.version;
108
-
109
- return true;
110
-
111
- }
112
-
113
- return false;
114
-
115
- }
116
-
117
49
  }
118
50
 
119
51
  /**
@@ -18,6 +18,17 @@ class Sampler extends Binding {
18
18
 
19
19
  super( name );
20
20
 
21
+ /**
22
+ * This function is called when the texture is disposed.
23
+ * @type {function}
24
+ * @private
25
+ */
26
+ this._onDisposeTexture = () => {
27
+
28
+ this.texture = null;
29
+
30
+ };
31
+
21
32
  /**
22
33
  * The texture the sampler is referring to.
23
34
  *
@@ -32,6 +43,15 @@ class Sampler extends Binding {
32
43
  */
33
44
  this.version = texture ? texture.version : 0;
34
45
 
46
+ /**
47
+ * The binding's generation which is an additional version
48
+ * qualifier.
49
+ *
50
+ * @type {?number}
51
+ * @default null
52
+ */
53
+ this.generation = null;
54
+
35
55
  /**
36
56
  * This flag can be used for type testing.
37
57
  *
@@ -43,6 +63,65 @@ class Sampler extends Binding {
43
63
 
44
64
  }
45
65
 
66
+ /**
67
+ * Sets the texture of this sampler.
68
+ * @param {?Texture} value - The texture to set.
69
+ */
70
+ set texture( value ) {
71
+
72
+ if ( this._texture === value ) return;
73
+
74
+ if ( this._texture ) {
75
+
76
+ this._texture.removeEventListener( 'dispose', this._onDisposeTexture );
77
+
78
+ }
79
+
80
+ this._texture = value;
81
+
82
+ this.generation = null;
83
+ this.version = 0;
84
+
85
+ if ( this._texture ) {
86
+
87
+ this._texture.addEventListener( 'dispose', this._onDisposeTexture );
88
+
89
+ }
90
+
91
+ }
92
+
93
+ /**
94
+ * Gets the texture of this sampler.
95
+ * @return {?Texture} The texture.
96
+ */
97
+ get texture() {
98
+
99
+ return this._texture;
100
+
101
+ }
102
+
103
+ /**
104
+ * Updates the binding.
105
+ *
106
+ * @return {boolean} Whether the texture has been updated and must be
107
+ * uploaded to the GPU.
108
+ */
109
+ update() {
110
+
111
+ const { texture, version } = this;
112
+
113
+ if ( version !== texture.version ) {
114
+
115
+ this.version = texture.version;
116
+
117
+ return true;
118
+
119
+ }
120
+
121
+ return false;
122
+
123
+ }
124
+
46
125
  }
47
126
 
48
127
  export default Sampler;
@@ -0,0 +1,100 @@
1
+ import { Texture } from '../../textures/Texture.js';
2
+ import { LinearFilter, ClampToEdgeWrapping } from '../../constants.js';
3
+
4
+ /**
5
+ * This special type of texture is intended for compute shaders.
6
+ * It can be used to compute the data of a texture with a compute shader.
7
+ *
8
+ * Note: This type of texture can only be used with `WebGPURenderer`
9
+ * and a WebGPU backend.
10
+ *
11
+ * @augments Texture
12
+ */
13
+ class Storage3DTexture extends Texture {
14
+
15
+ /**
16
+ * Constructs a new storage texture.
17
+ *
18
+ * @param {number} [width=1] - The storage texture's width.
19
+ * @param {number} [height=1] - The storage texture's height.
20
+ * @param {number} [depth=1] - The storage texture's depth.
21
+ */
22
+ constructor( width = 1, height = 1, depth = 1 ) {
23
+
24
+ super();
25
+
26
+ //inherited from texture. Must be false for 3DTexture
27
+ this.isArrayTexture = false;
28
+
29
+ /**
30
+ * The image object which just represents the texture's dimension.
31
+ *
32
+ * @type {{width: number, height: number, depth: number}}
33
+ */
34
+ this.image = { width, height, depth };
35
+
36
+ /**
37
+ * The default `magFilter` for storage textures is `THREE.LinearFilter`.
38
+ *
39
+ * @type {number}
40
+ */
41
+ this.magFilter = LinearFilter;
42
+
43
+ /**
44
+ * The default `minFilter` for storage textures is `THREE.LinearFilter`.
45
+ *
46
+ * @type {number}
47
+ */
48
+ this.minFilter = LinearFilter;
49
+
50
+ /**
51
+ * This defines how the texture is wrapped in the depth direction and corresponds to
52
+ * *W* in UVW mapping.
53
+ *
54
+ * @type {number}
55
+ */
56
+ this.wrapR = ClampToEdgeWrapping;
57
+
58
+ /**
59
+ * This flag can be used for type testing.
60
+ *
61
+ * @type {boolean}
62
+ * @readonly
63
+ * @default true
64
+ */
65
+ this.isStorageTexture = true;
66
+
67
+ /**
68
+ * Indicates whether this texture is a 3D texture.
69
+ *
70
+ * @type {boolean}
71
+ *
72
+ */
73
+ this.is3DTexture = true;
74
+
75
+ }
76
+
77
+ /**
78
+ * Sets the size of the storage 3d texture.
79
+ *
80
+ * @param {number} width - The new width of the storage texture.
81
+ * @param {number} height - The new height of the storage texture.
82
+ * @param {number} depth - The new depth of the storage texture.
83
+ */
84
+ setSize( width, height, depth ) {
85
+
86
+ if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
87
+
88
+ this.image.width = width;
89
+ this.image.height = height;
90
+ this.image.depth = depth;
91
+
92
+ this.dispose();
93
+
94
+ }
95
+
96
+ }
97
+
98
+ }
99
+
100
+ export default Storage3DTexture;
@@ -0,0 +1,84 @@
1
+ import { Texture } from '../../textures/Texture.js';
2
+ import { LinearFilter } from '../../constants.js';
3
+
4
+ /**
5
+ * This special type of texture is intended for compute shaders.
6
+ * It can be used to compute the data of a texture with a compute shader.
7
+ *
8
+ * Note: This type of texture can only be used with `WebGPURenderer`
9
+ * and a WebGPU backend.
10
+ *
11
+ * @augments Texture
12
+ */
13
+ class StorageArrayTexture extends Texture {
14
+
15
+ /**
16
+ * Constructs a new storage texture.
17
+ *
18
+ * @param {number} [width=1] - The storage texture's width.
19
+ * @param {number} [height=1] - The storage texture's height.
20
+ * @param {number} [depth=1] - The storage texture's depth.
21
+ */
22
+ constructor( width = 1, height = 1, depth = 1 ) {
23
+
24
+ super();
25
+
26
+ //inherited from texture
27
+ this.isArrayTexture = true;
28
+
29
+ /**
30
+ * The image object which just represents the texture's dimension.
31
+ *
32
+ * @type {{width: number, height: number, depth: number}}
33
+ */
34
+ this.image = { width, height, depth };
35
+
36
+ /**
37
+ * The default `magFilter` for storage textures is `THREE.LinearFilter`.
38
+ *
39
+ * @type {number}
40
+ */
41
+ this.magFilter = LinearFilter;
42
+
43
+ /**
44
+ * The default `minFilter` for storage textures is `THREE.LinearFilter`.
45
+ *
46
+ * @type {number}
47
+ */
48
+ this.minFilter = LinearFilter;
49
+
50
+ /**
51
+ * This flag can be used for type testing.
52
+ *
53
+ * @type {boolean}
54
+ * @readonly
55
+ * @default true
56
+ */
57
+ this.isStorageTexture = true;
58
+
59
+ }
60
+
61
+ /**
62
+ * Sets the size of the storage array texture.
63
+ *
64
+ * @param {number} width - The new width of the storage texture.
65
+ * @param {number} height - The new height of the storage texture.
66
+ * @param {number} depth - The new depth of the storage texture.
67
+ */
68
+ setSize( width, height, depth ) {
69
+
70
+ if ( this.image.width !== width || this.image.height !== height || this.image.depth !== depth ) {
71
+
72
+ this.image.width = width;
73
+ this.image.height = height;
74
+ this.image.depth = depth;
75
+
76
+ this.dispose();
77
+
78
+ }
79
+
80
+ }
81
+
82
+ }
83
+
84
+ export default StorageArrayTexture;
@@ -54,6 +54,25 @@ class StorageTexture extends Texture {
54
54
 
55
55
  }
56
56
 
57
+ /**
58
+ * Sets the size of the storage texture.
59
+ *
60
+ * @param {number} width - The new width of the storage texture.
61
+ * @param {number} height - The new height of the storage texture.
62
+ */
63
+ setSize( width, height ) {
64
+
65
+ if ( this.image.width !== width || this.image.height !== height ) {
66
+
67
+ this.image.width = width;
68
+ this.image.height = height;
69
+
70
+ this.dispose();
71
+
72
+ }
73
+
74
+ }
75
+
57
76
  }
58
77
 
59
78
  export default StorageTexture;
@@ -366,9 +366,25 @@ class Textures extends DataMap {
366
366
 
367
367
  if ( image.image !== undefined ) image = image.image;
368
368
 
369
- target.width = image.width || 1;
370
- target.height = image.height || 1;
371
- target.depth = texture.isCubeTexture ? 6 : ( image.depth || 1 );
369
+ if ( image instanceof HTMLVideoElement ) {
370
+
371
+ target.width = image.videoWidth || 1;
372
+ target.height = image.videoHeight || 1;
373
+ target.depth = 1;
374
+
375
+ } else if ( image instanceof VideoFrame ) {
376
+
377
+ target.width = image.displayWidth || 1;
378
+ target.height = image.displayHeight || 1;
379
+ target.depth = 1;
380
+
381
+ } else {
382
+
383
+ target.width = image.width || 1;
384
+ target.height = image.height || 1;
385
+ target.depth = texture.isCubeTexture ? 6 : ( image.depth || 1 );
386
+
387
+ }
372
388
 
373
389
  } else {
374
390