@plastic-software/three 0.181.2 → 0.182.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 (253) hide show
  1. package/README.md +3 -4
  2. package/build/three.cjs +1192 -522
  3. package/build/three.core.js +345 -219
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +864 -328
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +15 -3
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +3660 -1545
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +3659 -1544
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/controls/MapControls.js +55 -1
  14. package/examples/jsm/controls/OrbitControls.js +6 -6
  15. package/examples/jsm/controls/TrackballControls.js +6 -6
  16. package/examples/jsm/csm/CSM.js +2 -1
  17. package/examples/jsm/environments/RoomEnvironment.js +2 -0
  18. package/examples/jsm/geometries/DecalGeometry.js +1 -1
  19. package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
  20. package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
  21. package/examples/jsm/inspector/Inspector.js +53 -9
  22. package/examples/jsm/inspector/RendererInspector.js +12 -2
  23. package/examples/jsm/inspector/tabs/Console.js +2 -2
  24. package/examples/jsm/inspector/tabs/Parameters.js +2 -2
  25. package/examples/jsm/inspector/tabs/Performance.js +2 -2
  26. package/examples/jsm/inspector/tabs/Viewer.js +4 -4
  27. package/examples/jsm/inspector/ui/Profiler.js +1836 -31
  28. package/examples/jsm/inspector/ui/Style.js +948 -13
  29. package/examples/jsm/inspector/ui/Tab.js +188 -1
  30. package/examples/jsm/inspector/ui/Values.js +17 -1
  31. package/examples/jsm/loaders/3DMLoader.js +5 -4
  32. package/examples/jsm/loaders/DRACOLoader.js +5 -5
  33. package/examples/jsm/loaders/FBXLoader.js +0 -2
  34. package/examples/jsm/loaders/HDRLoader.js +0 -1
  35. package/examples/jsm/loaders/KTX2Loader.js +16 -0
  36. package/examples/jsm/loaders/LDrawLoader.js +2 -3
  37. package/examples/jsm/loaders/PCDLoader.js +1 -0
  38. package/examples/jsm/loaders/SVGLoader.js +1 -1
  39. package/examples/jsm/loaders/TDSLoader.js +0 -2
  40. package/examples/jsm/loaders/TGALoader.js +0 -2
  41. package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
  42. package/examples/jsm/loaders/VOXLoader.js +660 -117
  43. package/examples/jsm/loaders/VRMLLoader.js +2 -2
  44. package/examples/jsm/loaders/usd/USDCParser.js +1 -1
  45. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
  46. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
  47. package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
  48. package/examples/jsm/math/Octree.js +131 -1
  49. package/examples/jsm/misc/Volume.js +0 -1
  50. package/examples/jsm/misc/VolumeSlice.js +0 -1
  51. package/examples/jsm/objects/SkyMesh.js +13 -3
  52. package/examples/jsm/physics/AmmoPhysics.js +12 -7
  53. package/examples/jsm/physics/JoltPhysics.js +3 -1
  54. package/examples/jsm/physics/RapierPhysics.js +3 -1
  55. package/examples/jsm/postprocessing/OutputPass.js +9 -0
  56. package/examples/jsm/postprocessing/RenderPass.js +10 -0
  57. package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
  58. package/examples/jsm/renderers/Projector.js +268 -30
  59. package/examples/jsm/renderers/SVGRenderer.js +191 -58
  60. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
  61. package/examples/jsm/transpiler/AST.js +44 -0
  62. package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
  63. package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
  64. package/examples/jsm/transpiler/TSLEncoder.js +46 -3
  65. package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
  66. package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
  67. package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
  68. package/examples/jsm/tsl/display/BloomNode.js +11 -1
  69. package/examples/jsm/tsl/display/GTAONode.js +3 -2
  70. package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
  71. package/examples/jsm/tsl/display/SSGINode.js +7 -19
  72. package/examples/jsm/tsl/display/SSRNode.js +1 -1
  73. package/examples/jsm/tsl/display/SSSNode.js +4 -2
  74. package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
  75. package/examples/jsm/tsl/display/TRAANode.js +265 -114
  76. package/examples/jsm/tsl/display/radialBlur.js +68 -0
  77. package/examples/jsm/utils/ShadowMapViewer.js +24 -10
  78. package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
  79. package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
  80. package/package.json +14 -12
  81. package/src/Three.Core.js +1 -0
  82. package/src/Three.TSL.js +14 -2
  83. package/src/animation/AnimationUtils.js +1 -12
  84. package/src/animation/KeyframeTrack.js +1 -1
  85. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  86. package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
  87. package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
  88. package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
  89. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  90. package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
  91. package/src/constants.js +61 -5
  92. package/src/core/BufferGeometry.js +14 -2
  93. package/src/core/Raycaster.js +2 -2
  94. package/src/extras/PMREMGenerator.js +3 -10
  95. package/src/extras/TextureUtils.js +5 -1
  96. package/src/geometries/ExtrudeGeometry.js +2 -2
  97. package/src/geometries/PolyhedronGeometry.js +1 -1
  98. package/src/helpers/PointLightHelper.js +1 -1
  99. package/src/lights/DirectionalLight.js +13 -0
  100. package/src/lights/HemisphereLight.js +10 -0
  101. package/src/lights/Light.js +1 -11
  102. package/src/lights/LightProbe.js +0 -15
  103. package/src/lights/LightShadow.js +0 -3
  104. package/src/lights/PointLight.js +15 -0
  105. package/src/lights/PointLightShadow.js +0 -86
  106. package/src/lights/SpotLight.js +22 -1
  107. package/src/loaders/MaterialLoader.js +2 -1
  108. package/src/loaders/ObjectLoader.js +3 -1
  109. package/src/loaders/nodes/NodeLoader.js +2 -2
  110. package/src/materials/Material.js +2 -0
  111. package/src/materials/ShaderMaterial.js +20 -1
  112. package/src/materials/nodes/Line2NodeMaterial.js +2 -2
  113. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
  114. package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
  115. package/src/materials/nodes/NodeMaterial.js +59 -3
  116. package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
  117. package/src/math/Matrix4.js +40 -40
  118. package/src/math/Sphere.js +1 -1
  119. package/src/math/Vector3.js +0 -2
  120. package/src/nodes/TSL.js +4 -1
  121. package/src/nodes/accessors/BatchNode.js +10 -10
  122. package/src/nodes/accessors/BufferAttributeNode.js +98 -12
  123. package/src/nodes/accessors/BufferNode.js +29 -2
  124. package/src/nodes/accessors/ClippingNode.js +4 -4
  125. package/src/nodes/accessors/CubeTextureNode.js +20 -1
  126. package/src/nodes/accessors/InstanceNode.js +69 -29
  127. package/src/nodes/accessors/MaterialNode.js +9 -1
  128. package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
  129. package/src/nodes/accessors/ModelNode.js +1 -1
  130. package/src/nodes/accessors/Normal.js +2 -2
  131. package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
  132. package/src/nodes/accessors/ReferenceNode.js +4 -4
  133. package/src/nodes/accessors/RendererReferenceNode.js +1 -2
  134. package/src/nodes/accessors/SkinningNode.js +15 -2
  135. package/src/nodes/accessors/StorageBufferNode.js +4 -2
  136. package/src/nodes/accessors/Tangent.js +1 -11
  137. package/src/nodes/accessors/Texture3DNode.js +26 -1
  138. package/src/nodes/accessors/UniformArrayNode.js +2 -2
  139. package/src/nodes/accessors/UserDataNode.js +1 -2
  140. package/src/nodes/accessors/VertexColorNode.js +1 -2
  141. package/src/nodes/code/FunctionNode.js +1 -2
  142. package/src/nodes/core/ArrayNode.js +20 -1
  143. package/src/nodes/core/AssignNode.js +2 -2
  144. package/src/nodes/core/AttributeNode.js +2 -2
  145. package/src/nodes/core/ContextNode.js +103 -4
  146. package/src/nodes/core/NodeBuilder.js +56 -14
  147. package/src/nodes/core/NodeFrame.js +12 -4
  148. package/src/nodes/core/NodeUtils.js +5 -5
  149. package/src/nodes/core/ParameterNode.js +1 -2
  150. package/src/nodes/core/PropertyNode.js +19 -3
  151. package/src/nodes/core/StackNode.js +56 -8
  152. package/src/nodes/core/StructNode.js +1 -2
  153. package/src/nodes/core/StructTypeNode.js +11 -17
  154. package/src/nodes/core/UniformNode.js +19 -4
  155. package/src/nodes/core/VarNode.js +46 -21
  156. package/src/nodes/display/NormalMapNode.js +37 -2
  157. package/src/nodes/display/PassNode.js +77 -7
  158. package/src/nodes/display/ScreenNode.js +1 -0
  159. package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
  160. package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
  161. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  162. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
  163. package/src/nodes/functions/PhysicalLightingModel.js +102 -43
  164. package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
  165. package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
  166. package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
  167. package/src/nodes/lighting/AnalyticLightNode.js +53 -0
  168. package/src/nodes/lighting/LightsNode.js +2 -2
  169. package/src/nodes/lighting/PointShadowNode.js +141 -140
  170. package/src/nodes/lighting/ShadowFilterNode.js +53 -37
  171. package/src/nodes/lighting/ShadowNode.js +53 -19
  172. package/src/nodes/math/BitcountNode.js +433 -0
  173. package/src/nodes/math/PackFloatNode.js +98 -0
  174. package/src/nodes/math/UnpackFloatNode.js +96 -0
  175. package/src/nodes/pmrem/PMREMNode.js +1 -1
  176. package/src/nodes/tsl/TSLCore.js +4 -4
  177. package/src/nodes/utils/ArrayElementNode.js +13 -0
  178. package/src/nodes/utils/EventNode.js +1 -2
  179. package/src/nodes/utils/Packing.js +13 -1
  180. package/src/nodes/utils/PostProcessingUtils.js +33 -1
  181. package/src/nodes/utils/ReflectorNode.js +1 -1
  182. package/src/nodes/utils/SampleNode.js +1 -1
  183. package/src/nodes/utils/UVUtils.js +26 -0
  184. package/src/objects/BatchedMesh.js +5 -2
  185. package/src/objects/Line.js +1 -1
  186. package/src/objects/Mesh.js +1 -1
  187. package/src/objects/Points.js +1 -1
  188. package/src/objects/Skeleton.js +9 -0
  189. package/src/renderers/WebGLRenderer.js +145 -33
  190. package/src/renderers/common/Backend.js +8 -0
  191. package/src/renderers/common/Background.js +19 -9
  192. package/src/renderers/common/Binding.js +11 -0
  193. package/src/renderers/common/Bindings.js +7 -7
  194. package/src/renderers/common/Buffer.js +40 -0
  195. package/src/renderers/common/ChainMap.js +30 -6
  196. package/src/renderers/common/Geometries.js +12 -0
  197. package/src/renderers/common/RenderContexts.js +8 -1
  198. package/src/renderers/common/RenderObject.js +14 -1
  199. package/src/renderers/common/Renderer.js +53 -35
  200. package/src/renderers/common/Textures.js +1 -1
  201. package/src/renderers/common/UniformsGroup.js +1 -0
  202. package/src/renderers/common/XRManager.js +1 -0
  203. package/src/renderers/common/extras/PMREMGenerator.js +2 -8
  204. package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
  205. package/src/renderers/shaders/DFGLUTData.js +19 -34
  206. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
  207. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
  208. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
  209. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
  210. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
  211. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
  212. package/src/renderers/shaders/ShaderChunk.js +3 -3
  213. package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
  214. package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
  215. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
  216. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
  217. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
  218. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
  219. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
  220. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
  221. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
  222. package/src/renderers/shaders/ShaderLib.js +3 -3
  223. package/src/renderers/webgl/WebGLCapabilities.js +3 -4
  224. package/src/renderers/webgl/WebGLLights.js +18 -1
  225. package/src/renderers/webgl/WebGLOutput.js +267 -0
  226. package/src/renderers/webgl/WebGLProgram.js +43 -107
  227. package/src/renderers/webgl/WebGLPrograms.js +35 -45
  228. package/src/renderers/webgl/WebGLShadowMap.js +188 -25
  229. package/src/renderers/webgl/WebGLState.js +20 -20
  230. package/src/renderers/webgl/WebGLTextures.js +89 -28
  231. package/src/renderers/webgl/WebGLUniforms.js +40 -3
  232. package/src/renderers/webgl/WebGLUtils.js +6 -2
  233. package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
  234. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
  235. package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
  236. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
  237. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
  238. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
  239. package/src/renderers/webgpu/WebGPUBackend.js +61 -4
  240. package/src/renderers/webgpu/WebGPURenderer.js +1 -1
  241. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
  242. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
  243. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
  244. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
  245. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
  246. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
  247. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
  248. package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
  249. package/src/textures/CubeDepthTexture.js +76 -0
  250. package/src/textures/Source.js +1 -1
  251. package/src/textures/Texture.js +1 -1
  252. package/src/utils.js +13 -1
  253. package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
@@ -1,4 +1,4 @@
1
- import { warnOnce, warn } from '../../../utils.js';
1
+ import { error, warnOnce, warn } from '../../../utils.js';
2
2
  import TimestampQueryPool from '../../common/TimestampQueryPool.js';
3
3
 
4
4
  /**
@@ -122,9 +122,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
122
122
 
123
123
  }
124
124
 
125
- } catch ( error ) {
125
+ } catch ( e ) {
126
126
 
127
- error( 'Error in beginQuery:', error );
127
+ error( 'Error in beginQuery:', e );
128
128
  this.activeQuery = null;
129
129
  this.queryStates.set( baseOffset, 'inactive' );
130
130
 
@@ -165,9 +165,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
165
165
  this.queryStates.set( baseOffset, 'ended' );
166
166
  this.activeQuery = null;
167
167
 
168
- } catch ( error ) {
168
+ } catch ( e ) {
169
169
 
170
- error( 'Error in endQuery:', error );
170
+ error( 'Error in endQuery:', e );
171
171
  // Reset state on error
172
172
  this.queryStates.set( baseOffset, 'inactive' );
173
173
  this.activeQuery = null;
@@ -258,9 +258,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
258
258
 
259
259
  return totalDuration;
260
260
 
261
- } catch ( error ) {
261
+ } catch ( e ) {
262
262
 
263
- error( 'Error resolving queries:', error );
263
+ error( 'Error resolving queries:', e );
264
264
  return this.lastValue;
265
265
 
266
266
  } finally {
@@ -346,9 +346,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
346
346
  const elapsed = this.gl.getQueryParameter( query, this.gl.QUERY_RESULT );
347
347
  resolve( Number( elapsed ) / 1e6 ); // Convert nanoseconds to milliseconds
348
348
 
349
- } catch ( error ) {
349
+ } catch ( e ) {
350
350
 
351
- error( 'Error checking query:', error );
351
+ error( 'Error checking query:', e );
352
352
  resolve( this.lastValue );
353
353
 
354
354
  }
@@ -1,4 +1,4 @@
1
- import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, RedFormat, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBTransfer, NoColorSpace, UnsignedInt101111Type } from '../../../constants.js';
1
+ import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, R11_EAC_Format, SIGNED_R11_EAC_Format, RG11_EAC_Format, SIGNED_RG11_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, RedFormat, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBTransfer, NoColorSpace, UnsignedInt101111Type } from '../../../constants.js';
2
2
  import { ColorManagement } from '../../../math/ColorManagement.js';
3
3
 
4
4
  /**
@@ -154,7 +154,7 @@ class WebGLUtils {
154
154
 
155
155
  // ETC
156
156
 
157
- if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
157
+ if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format || p === R11_EAC_Format || p === SIGNED_R11_EAC_Format || p === RG11_EAC_Format || p === SIGNED_RG11_EAC_Format ) {
158
158
 
159
159
  extension = extensions.get( 'WEBGL_compressed_texture_etc' );
160
160
 
@@ -162,6 +162,10 @@ class WebGLUtils {
162
162
 
163
163
  if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
164
164
  if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
165
+ if ( p === R11_EAC_Format ) return extension.COMPRESSED_R11_EAC;
166
+ if ( p === SIGNED_R11_EAC_Format ) return extension.COMPRESSED_SIGNED_R11_EAC;
167
+ if ( p === RG11_EAC_Format ) return extension.COMPRESSED_RG11_EAC;
168
+ if ( p === SIGNED_RG11_EAC_Format ) return extension.COMPRESSED_SIGNED_RG11_EAC;
165
169
 
166
170
  } else {
167
171
 
@@ -204,6 +204,8 @@ class WebGPUBackend extends Backend {
204
204
 
205
205
  device.lost.then( ( info ) => {
206
206
 
207
+ if ( info.reason === 'destroyed' ) return;
208
+
207
209
  const deviceLossInfo = {
208
210
  api: 'WebGPU',
209
211
  message: info.message || 'Unknown reason',
@@ -519,7 +521,7 @@ class WebGPUBackend extends Backend {
519
521
 
520
522
  const depthTextureData = this.get( renderContext.depthTexture );
521
523
  const options = {};
522
- if ( renderContext.depthTexture.isArrayTexture ) {
524
+ if ( renderContext.depthTexture.isArrayTexture || renderContext.depthTexture.isCubeTexture ) {
523
525
 
524
526
  options.dimension = GPUTextureViewDimension.TwoD;
525
527
  options.arrayLayerCount = 1;
@@ -1600,8 +1602,14 @@ class WebGPUBackend extends Backend {
1600
1602
  if ( indirect !== null ) {
1601
1603
 
1602
1604
  const buffer = this.get( indirect ).buffer;
1605
+ const indirectOffset = renderObject.getIndirectOffset();
1606
+ const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
1607
+
1608
+ for ( let i = 0; i < indirectOffsets.length; i ++ ) {
1603
1609
 
1604
- passEncoderGPU.drawIndexedIndirect( buffer, 0 );
1610
+ passEncoderGPU.drawIndexedIndirect( buffer, indirectOffsets[ i ] );
1611
+
1612
+ }
1605
1613
 
1606
1614
  } else {
1607
1615
 
@@ -1620,8 +1628,15 @@ class WebGPUBackend extends Backend {
1620
1628
  if ( indirect !== null ) {
1621
1629
 
1622
1630
  const buffer = this.get( indirect ).buffer;
1631
+ const indirectOffset = renderObject.getIndirectOffset();
1632
+ const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
1633
+
1634
+ for ( let i = 0; i < indirectOffsets.length; i ++ ) {
1635
+
1636
+ passEncoderGPU.drawIndirect( buffer, indirectOffsets[ i ] );
1637
+
1638
+ }
1623
1639
 
1624
- passEncoderGPU.drawIndirect( buffer, 0 );
1625
1640
 
1626
1641
  } else {
1627
1642
 
@@ -1652,7 +1667,9 @@ class WebGPUBackend extends Backend {
1652
1667
 
1653
1668
  data[ 0 ] = i;
1654
1669
 
1655
- const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, bindingsData.layout );
1670
+ const { layoutGPU } = bindingsData.layout;
1671
+
1672
+ const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, layoutGPU );
1656
1673
 
1657
1674
  indexesGPU.push( bindGroupIndex );
1658
1675
 
@@ -2144,6 +2161,17 @@ class WebGPUBackend extends Backend {
2144
2161
 
2145
2162
  }
2146
2163
 
2164
+ /**
2165
+ * Delete data associated with the current bind group.
2166
+ *
2167
+ * @param {BindGroup} bindGroup - The bind group.
2168
+ */
2169
+ deleteBindGroupData( bindGroup ) {
2170
+
2171
+ this.bindingUtils.deleteBindGroupData( bindGroup );
2172
+
2173
+ }
2174
+
2147
2175
  // attributes
2148
2176
 
2149
2177
  /**
@@ -2473,8 +2501,37 @@ class WebGPUBackend extends Backend {
2473
2501
 
2474
2502
  dispose() {
2475
2503
 
2504
+ this.bindingUtils.dispose();
2476
2505
  this.textureUtils.dispose();
2477
2506
 
2507
+ if ( this.occludedResolveCache ) {
2508
+
2509
+ for ( const buffer of this.occludedResolveCache.values() ) {
2510
+
2511
+ buffer.destroy();
2512
+
2513
+ }
2514
+
2515
+ this.occludedResolveCache.clear();
2516
+
2517
+ }
2518
+
2519
+ if ( this.timestampQueryPool ) {
2520
+
2521
+ for ( const queryPool of Object.values( this.timestampQueryPool ) ) {
2522
+
2523
+ if ( queryPool !== null ) queryPool.dispose();
2524
+
2525
+ }
2526
+
2527
+ }
2528
+
2529
+ if ( this.parameters.device === undefined && this.device !== null ) {
2530
+
2531
+ this.device.destroy();
2532
+
2533
+ }
2534
+
2478
2535
  }
2479
2536
 
2480
2537
  }
@@ -40,7 +40,7 @@ class WebGPURenderer extends Renderer {
40
40
  * @property {boolean} [forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
41
41
  * @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
42
42
  * @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
43
- * @property {number} [colorBufferType=HalfFloatType] - Defines the type of color buffers. The default `HalfFloatType` is recommend for best
43
+ * @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best
44
44
  * quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
45
45
  */
46
46
 
@@ -19,8 +19,7 @@ import ExpressionNode from '../../../nodes/code/ExpressionNode.js';
19
19
  import { FloatType, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter } from '../../../constants.js';
20
20
  import { warn, error } from '../../../utils.js';
21
21
 
22
- // GPUShaderStage is not defined in browsers not supporting WebGPU
23
- const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
22
+ import { GPUShaderStage } from '../utils/WebGPUConstants.js';
24
23
 
25
24
  const accessNames = {
26
25
  [ NodeAccess.READ_ONLY ]: 'read',
@@ -35,9 +34,9 @@ const wrapNames = {
35
34
  };
36
35
 
37
36
  const gpuShaderStageLib = {
38
- 'vertex': GPUShaderStage ? GPUShaderStage.VERTEX : 1,
39
- 'fragment': GPUShaderStage ? GPUShaderStage.FRAGMENT : 2,
40
- 'compute': GPUShaderStage ? GPUShaderStage.COMPUTE : 4
37
+ 'vertex': GPUShaderStage.VERTEX,
38
+ 'fragment': GPUShaderStage.FRAGMENT,
39
+ 'compute': GPUShaderStage.COMPUTE
41
40
  };
42
41
 
43
42
  const supports = {
@@ -129,7 +128,13 @@ const wgslMethods = {
129
128
  equals_bvec3: 'tsl_equals_bvec3',
130
129
  equals_bvec4: 'tsl_equals_bvec4',
131
130
  inversesqrt: 'inverseSqrt',
132
- bitcast: 'bitcast<f32>'
131
+ bitcast: 'bitcast<f32>',
132
+ floatpack_snorm_2x16: 'pack2x16snorm',
133
+ floatpack_unorm_2x16: 'pack2x16unorm',
134
+ floatpack_float16_2x16: 'pack2x16float',
135
+ floatunpack_snorm_2x16: 'unpack2x16snorm',
136
+ floatunpack_unorm_2x16: 'unpack2x16unorm',
137
+ floatunpack_float16_2x16: 'unpack2x16float'
133
138
  };
134
139
 
135
140
  //
@@ -286,7 +291,7 @@ class WGSLNodeBuilder extends NodeBuilder {
286
291
  */
287
292
  generateWrapFunction( texture ) {
288
293
 
289
- const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.isData3DTexture ? '3d' : '2d' }T`;
294
+ const functionName = `tsl_coord_${ wrapNames[ texture.wrapS ] }S_${ wrapNames[ texture.wrapT ] }_${ texture.is3DTexture || texture.isData3DTexture ? '3d' : '2d' }T`;
290
295
 
291
296
  let nodeCode = wgslCodeCache[ functionName ];
292
297
 
@@ -295,7 +300,7 @@ class WGSLNodeBuilder extends NodeBuilder {
295
300
  const includes = [];
296
301
 
297
302
  // For 3D textures, use vec3f; for texture arrays, keep vec2f since array index is separate
298
- const coordType = texture.isData3DTexture ? 'vec3f' : 'vec2f';
303
+ const coordType = texture.is3DTexture || texture.isData3DTexture ? 'vec3f' : 'vec2f';
299
304
  let code = `fn ${ functionName }( coord : ${ coordType } ) -> ${ coordType } {\n\n\treturn ${ coordType }(\n`;
300
305
 
301
306
  const addWrapSnippet = ( wrap, axis ) => {
@@ -334,7 +339,7 @@ class WGSLNodeBuilder extends NodeBuilder {
334
339
 
335
340
  addWrapSnippet( texture.wrapT, 'y' );
336
341
 
337
- if ( texture.isData3DTexture ) {
342
+ if ( texture.is3DTexture || texture.isData3DTexture ) {
338
343
 
339
344
  code += ',\n';
340
345
  addWrapSnippet( texture.wrapR, 'z' );
@@ -392,7 +397,7 @@ class WGSLNodeBuilder extends NodeBuilder {
392
397
  const { primarySamples } = this.renderer.backend.utils.getTextureSampleData( texture );
393
398
  const isMultisampled = primarySamples > 1;
394
399
 
395
- if ( texture.isData3DTexture ) {
400
+ if ( texture.is3DTexture || texture.isData3DTexture ) {
396
401
 
397
402
  dimensionType = 'vec3<u32>';
398
403
 
@@ -418,7 +423,7 @@ class WGSLNodeBuilder extends NodeBuilder {
418
423
 
419
424
  textureData.dimensionsSnippet[ levelSnippet ] = textureDimensionNode;
420
425
 
421
- if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
426
+ if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.is3DTexture || texture.isData3DTexture ) {
422
427
 
423
428
  textureData.arrayLayerCount = new VarNode(
424
429
  new ExpressionNode(
@@ -488,7 +493,7 @@ class WGSLNodeBuilder extends NodeBuilder {
488
493
  const wrapFunction = this.generateWrapFunction( texture );
489
494
  const textureDimension = this.generateTextureDimension( texture, textureProperty, levelSnippet );
490
495
 
491
- const vecType = texture.isData3DTexture ? 'vec3' : 'vec2';
496
+ const vecType = texture.is3DTexture || texture.isData3DTexture ? 'vec3' : 'vec2';
492
497
 
493
498
  if ( offsetSnippet ) {
494
499
 
@@ -797,7 +802,7 @@ class WGSLNodeBuilder extends NodeBuilder {
797
802
  const name = node.name;
798
803
  const type = node.type;
799
804
 
800
- if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
805
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'cubeDepthTexture' || type === 'storageTexture' || type === 'texture3D' ) {
801
806
 
802
807
  return name;
803
808
 
@@ -923,7 +928,7 @@ class WGSLNodeBuilder extends NodeBuilder {
923
928
 
924
929
  const bindings = this.getBindGroupArray( groupName, shaderStage );
925
930
 
926
- if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {
931
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'cubeDepthTexture' || type === 'storageTexture' || type === 'texture3D' ) {
927
932
 
928
933
  let texture = null;
929
934
 
@@ -941,7 +946,7 @@ class WGSLNodeBuilder extends NodeBuilder {
941
946
 
942
947
  }
943
948
 
944
- } else if ( type === 'cubeTexture' ) {
949
+ } else if ( type === 'cubeTexture' || type === 'cubeDepthTexture' ) {
945
950
 
946
951
  texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, group, access );
947
952
 
@@ -974,10 +979,21 @@ class WGSLNodeBuilder extends NodeBuilder {
974
979
 
975
980
  } else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
976
981
 
977
- const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
982
+ const sharedData = this.getSharedDataFromNode( node );
978
983
 
979
- const buffer = new bufferClass( node, group );
980
- buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
984
+ let buffer = sharedData.buffer;
985
+
986
+ if ( buffer === undefined ) {
987
+
988
+ const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
989
+
990
+ buffer = new bufferClass( node, group );
991
+
992
+ sharedData.buffer = buffer;
993
+
994
+ }
995
+
996
+ buffer.setVisibility( buffer.getVisibility() | gpuShaderStageLib[ shaderStage ] );
981
997
 
982
998
  bindings.push( buffer );
983
999
 
@@ -1698,7 +1714,7 @@ ${ flowData.code }
1698
1714
  const groupName = uniform.groupNode.name;
1699
1715
  const uniformIndexes = this.bindingsIndexes[ groupName ];
1700
1716
 
1701
- if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
1717
+ if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'cubeDepthTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
1702
1718
 
1703
1719
  const texture = uniform.node.value;
1704
1720
 
@@ -1728,7 +1744,11 @@ ${ flowData.code }
1728
1744
 
1729
1745
  }
1730
1746
 
1731
- if ( texture.isCubeTexture === true ) {
1747
+ if ( texture.isCubeTexture === true && texture.isDepthTexture === true ) {
1748
+
1749
+ textureType = 'texture_depth_cube';
1750
+
1751
+ } else if ( texture.isCubeTexture === true ) {
1732
1752
 
1733
1753
  textureType = 'texture_cube<f32>';
1734
1754
 
@@ -1820,9 +1840,7 @@ ${ flowData.code }
1820
1840
 
1821
1841
  }
1822
1842
 
1823
- let code = bindingSnippets.join( '\n' );
1824
- code += bufferSnippets.join( '\n' );
1825
- code += structSnippets.join( '\n' );
1843
+ const code = [ ...bindingSnippets, ...bufferSnippets, ...structSnippets ].join( '\n' );
1826
1844
 
1827
1845
  return code;
1828
1846
 
@@ -1980,6 +1998,30 @@ ${ flowData.code }
1980
1998
 
1981
1999
  }
1982
2000
 
2001
+ /**
2002
+ * Returns the float packing method name for a given numeric encoding.
2003
+ *
2004
+ * @param {string} encoding - The numeric encoding that describes how the float values are mapped to the integer range.
2005
+ * @returns {string} The resolve WGSL float packing method name.
2006
+ */
2007
+ getFloatPackingMethod( encoding ) {
2008
+
2009
+ return this.getMethod( `floatpack_${ encoding }_2x16` );
2010
+
2011
+ }
2012
+
2013
+ /**
2014
+ * Returns the float unpacking method name for a given numeric encoding.
2015
+ *
2016
+ * @param {string} encoding - The numeric encoding that describes how the integer values are mapped to the float range.
2017
+ * @returns {string} The resolve WGSL float unpacking method name.
2018
+ */
2019
+ getFloatUnpackingMethod( encoding ) {
2020
+
2021
+ return this.getMethod( `floatunpack_${ encoding }_2x16` );
2022
+
2023
+ }
2024
+
1983
2025
  /**
1984
2026
  * Returns the native snippet for a ternary operation.
1985
2027
  *
@@ -1,7 +1,7 @@
1
1
  import { GPUInputStepMode } from './WebGPUConstants.js';
2
2
 
3
3
  import { Float16BufferAttribute } from '../../../core/BufferAttribute.js';
4
- import { error } from '../../../utils.js';
4
+ import { isTypedArray, error } from '../../../utils.js';
5
5
 
6
6
  const typedArraysToVertexFormatPrefix = new Map( [
7
7
  [ Int8Array, [ 'sint8', 'snorm8' ]],
@@ -174,7 +174,6 @@ class WebGPUAttributeUtils {
174
174
  }
175
175
 
176
176
 
177
- const isTypedArray = this._isTypedArray( array );
178
177
  const updateRanges = bufferAttribute.updateRanges;
179
178
 
180
179
  if ( updateRanges.length === 0 ) {
@@ -190,7 +189,8 @@ class WebGPUAttributeUtils {
190
189
 
191
190
  } else {
192
191
 
193
- const byteOffsetFactor = isTypedArray ? 1 : array.BYTES_PER_ELEMENT;
192
+ const isTyped = isTypedArray( array );
193
+ const byteOffsetFactor = isTyped ? 1 : array.BYTES_PER_ELEMENT;
194
194
 
195
195
  for ( let i = 0, l = updateRanges.length; i < l; i ++ ) {
196
196
 
@@ -211,7 +211,7 @@ class WebGPUAttributeUtils {
211
211
 
212
212
  }
213
213
 
214
- const bufferOffset = dataOffset * ( isTypedArray ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
214
+ const bufferOffset = dataOffset * ( isTyped ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
215
215
 
216
216
  device.queue.writeBuffer(
217
217
  buffer,
@@ -415,19 +415,6 @@ class WebGPUAttributeUtils {
415
415
 
416
416
  }
417
417
 
418
- /**
419
- * Returns `true` if the given array is a typed array.
420
- *
421
- * @private
422
- * @param {any} array - The array.
423
- * @return {boolean} Whether the given array is a typed array or not.
424
- */
425
- _isTypedArray( array ) {
426
-
427
- return ArrayBuffer.isView( array ) && ! ( array instanceof DataView );
428
-
429
- }
430
-
431
418
  /**
432
419
  * Utility method for handling interleaved buffer attributes correctly.
433
420
  * To process them, their `InterleavedBuffer` is returned.