super-three 0.160.1 → 0.162.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 (225) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +867 -499
  3. package/build/three.module.js +867 -496
  4. package/build/three.module.min.js +1 -1
  5. package/examples/jsm/Addons.js +5 -1
  6. package/examples/jsm/capabilities/WebGPU.js +13 -9
  7. package/examples/jsm/controls/DragControls.js +91 -30
  8. package/examples/jsm/controls/OrbitControls.js +130 -15
  9. package/examples/jsm/controls/TransformControls.js +6 -6
  10. package/examples/jsm/curves/NURBSUtils.js +59 -4
  11. package/examples/jsm/curves/NURBSVolume.js +62 -0
  12. package/examples/jsm/exporters/GLTFExporter.js +11 -1
  13. package/examples/jsm/exporters/USDZExporter.js +8 -7
  14. package/examples/jsm/helpers/TextureHelper.js +3 -3
  15. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  16. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  17. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  18. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  19. package/examples/jsm/libs/tween.module.js +32 -14
  20. package/examples/jsm/loaders/3DMLoader.js +57 -64
  21. package/examples/jsm/loaders/DDSLoader.js +1 -0
  22. package/examples/jsm/loaders/KTX2Loader.js +20 -5
  23. package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
  24. package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
  25. package/examples/jsm/loaders/LUTImageLoader.js +3 -2
  26. package/examples/jsm/loaders/MaterialXLoader.js +115 -16
  27. package/examples/jsm/loaders/SVGLoader.js +4 -3
  28. package/examples/jsm/loaders/VOXLoader.js +9 -2
  29. package/examples/jsm/loaders/VRMLLoader.js +7 -3
  30. package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
  31. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  32. package/examples/jsm/misc/Timer.js +13 -4
  33. package/examples/jsm/nodes/Nodes.js +24 -11
  34. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  35. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
  36. package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
  37. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  38. package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
  39. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  40. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  41. package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
  42. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +45 -0
  45. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  46. package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
  47. package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
  48. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  49. package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
  50. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  51. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  52. package/examples/jsm/nodes/core/AttributeNode.js +1 -1
  53. package/examples/jsm/nodes/core/Node.js +14 -4
  54. package/examples/jsm/nodes/core/NodeBuilder.js +26 -27
  55. package/examples/jsm/nodes/core/NodeFrame.js +18 -10
  56. package/examples/jsm/nodes/core/TempNode.js +1 -1
  57. package/examples/jsm/nodes/core/constants.js +1 -0
  58. package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
  59. package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
  60. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  61. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
  62. package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
  63. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  64. package/examples/jsm/nodes/display/PassNode.js +3 -2
  65. package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
  66. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
  67. package/examples/jsm/nodes/display/ViewportNode.js +0 -2
  68. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
  69. package/examples/jsm/nodes/fog/FogNode.js +2 -1
  70. package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
  71. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
  72. package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
  73. package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
  74. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
  75. package/examples/jsm/nodes/materials/Materials.js +1 -0
  76. package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
  77. package/examples/jsm/nodes/materials/NodeMaterial.js +43 -10
  78. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
  79. package/examples/jsm/nodes/math/CondNode.js +42 -7
  80. package/examples/jsm/nodes/math/MathNode.js +32 -2
  81. package/examples/jsm/nodes/math/MathUtils.js +15 -0
  82. package/examples/jsm/nodes/math/OperatorNode.js +13 -5
  83. package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
  84. package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
  85. package/examples/jsm/nodes/utils/JoinNode.js +2 -2
  86. package/examples/jsm/nodes/utils/LoopNode.js +5 -3
  87. package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
  88. package/examples/jsm/nodes/utils/RotateNode.js +68 -0
  89. package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
  90. package/examples/jsm/nodes/utils/SplitNode.js +4 -4
  91. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  92. package/examples/jsm/objects/GroundedSkybox.js +50 -0
  93. package/examples/jsm/objects/QuadMesh.js +8 -2
  94. package/examples/jsm/objects/Water2.js +8 -8
  95. package/examples/jsm/postprocessing/GTAOPass.js +11 -1
  96. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  97. package/examples/jsm/renderers/common/Backend.js +14 -0
  98. package/examples/jsm/renderers/common/Background.js +2 -2
  99. package/examples/jsm/renderers/common/Bindings.js +1 -1
  100. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  101. package/examples/jsm/renderers/common/DataMap.js +1 -1
  102. package/examples/jsm/renderers/common/Info.js +25 -1
  103. package/examples/jsm/renderers/common/Pipelines.js +8 -8
  104. package/examples/jsm/renderers/common/PostProcessing.js +2 -2
  105. package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
  106. package/examples/jsm/renderers/common/RenderContext.js +2 -0
  107. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  108. package/examples/jsm/renderers/common/RenderObject.js +46 -1
  109. package/examples/jsm/renderers/common/RenderObjects.js +3 -1
  110. package/examples/jsm/renderers/common/Renderer.js +290 -17
  111. package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
  112. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  113. package/examples/jsm/renderers/common/Textures.js +28 -18
  114. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  115. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
  116. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  117. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  118. package/examples/jsm/renderers/common/nodes/Nodes.js +5 -2
  119. package/examples/jsm/renderers/webgl/WebGLBackend.js +653 -272
  120. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +171 -39
  121. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +95 -8
  122. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
  123. package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
  124. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +424 -11
  125. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
  126. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
  127. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
  128. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +300 -112
  129. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
  130. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +71 -79
  131. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -1
  132. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
  133. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +87 -14
  134. package/examples/jsm/shaders/OutputShader.js +4 -0
  135. package/examples/jsm/transpiler/AST.js +1 -1
  136. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  137. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  138. package/examples/jsm/transpiler/TSLEncoder.js +1 -1
  139. package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
  140. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  141. package/examples/jsm/utils/SortUtils.js +2 -0
  142. package/examples/jsm/webxr/ARButton.js +12 -2
  143. package/examples/jsm/webxr/VRButton.js +25 -7
  144. package/examples/jsm/webxr/XRButton.js +12 -3
  145. package/examples/jsm/webxr/XRControllerModelFactory.js +14 -1
  146. package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
  147. package/package.json +5 -4
  148. package/src/Three.Legacy.js +20 -0
  149. package/src/Three.js +0 -1
  150. package/src/audio/Audio.js +1 -3
  151. package/src/cameras/PerspectiveCamera.js +35 -0
  152. package/src/constants.js +2 -6
  153. package/src/core/BufferAttribute.js +2 -12
  154. package/src/core/BufferGeometry.js +23 -29
  155. package/src/core/InterleavedBuffer.js +2 -1
  156. package/src/core/InterleavedBufferAttribute.js +20 -0
  157. package/src/core/Object3D.js +11 -0
  158. package/src/core/Raycaster.js +18 -4
  159. package/src/core/RenderTarget.js +44 -21
  160. package/src/extras/PMREMGenerator.js +2 -0
  161. package/src/extras/curves/EllipseCurve.js +2 -2
  162. package/src/helpers/SpotLightHelper.js +18 -1
  163. package/src/loaders/DataTextureLoader.js +0 -4
  164. package/src/loaders/MaterialLoader.js +1 -0
  165. package/src/loaders/ObjectLoader.js +2 -1
  166. package/src/materials/Material.js +2 -1
  167. package/src/materials/MeshBasicMaterial.js +3 -0
  168. package/src/materials/MeshLambertMaterial.js +3 -0
  169. package/src/materials/MeshPhongMaterial.js +3 -0
  170. package/src/materials/MeshStandardMaterial.js +3 -0
  171. package/src/materials/ShaderMaterial.js +2 -1
  172. package/src/math/Quaternion.js +13 -12
  173. package/src/math/Triangle.js +0 -30
  174. package/src/math/Vector3.js +7 -7
  175. package/src/objects/BatchedMesh.js +6 -7
  176. package/src/objects/InstancedMesh.js +53 -0
  177. package/src/objects/Mesh.js +0 -1
  178. package/src/objects/SkinnedMesh.js +0 -8
  179. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  180. package/src/renderers/WebGLRenderer.js +20 -23
  181. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
  182. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
  183. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  184. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  185. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  186. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  187. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  188. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  189. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +38 -7
  190. package/src/renderers/shaders/ShaderChunk.js +2 -0
  191. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  192. package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -2
  193. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +3 -2
  194. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -1
  195. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -2
  196. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
  197. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +2 -2
  198. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +4 -1
  199. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
  200. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -1
  201. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -1
  202. package/src/renderers/shaders/ShaderLib/points.glsl.js +2 -1
  203. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  204. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
  205. package/src/renderers/shaders/ShaderLib.js +2 -1
  206. package/src/renderers/shaders/UniformsLib.js +1 -0
  207. package/src/renderers/webgl/WebGLAttributes.js +2 -2
  208. package/src/renderers/webgl/WebGLBackground.js +18 -0
  209. package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
  210. package/src/renderers/webgl/WebGLMaterials.js +24 -1
  211. package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
  212. package/src/renderers/webgl/WebGLProgram.js +42 -4
  213. package/src/renderers/webgl/WebGLPrograms.js +38 -27
  214. package/src/renderers/webgl/WebGLState.js +11 -21
  215. package/src/renderers/webgl/WebGLTextures.js +170 -66
  216. package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
  217. package/src/renderers/webxr/WebXRManager.js +46 -0
  218. package/src/scenes/Scene.js +8 -0
  219. package/src/textures/Source.js +1 -0
  220. package/src/textures/Texture.js +1 -29
  221. package/build/three.js +0 -54519
  222. package/build/three.min.js +0 -7
  223. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  224. package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
  225. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -5,24 +5,27 @@ import NodeUniformsGroup from '../../common/nodes/NodeUniformsGroup.js';
5
5
  import NodeSampler from '../../common/nodes/NodeSampler.js';
6
6
  import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
7
7
 
8
- import UniformBuffer from '../../common/UniformBuffer.js';
9
- import StorageBuffer from '../../common/StorageBuffer.js';
10
- import { getVectorLength, getStrideLength } from '../../common/BufferUtils.js';
8
+ import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';
9
+ import NodeStorageBuffer from '../../common/nodes/NodeStorageBuffer.js';
11
10
 
12
- import { NodeBuilder, CodeNode, NodeMaterial } from '../../../nodes/Nodes.js';
11
+ import { NodeBuilder, CodeNode } from '../../../nodes/Nodes.js';
13
12
 
14
13
  import { getFormat } from '../utils/WebGPUTextureUtils.js';
15
14
 
16
15
  import WGSLNodeParser from './WGSLNodeParser.js';
17
16
 
17
+ // GPUShaderStage is not defined in browsers not supporting WebGPU
18
+ const GPUShaderStage = self.GPUShaderStage;
19
+
18
20
  const gpuShaderStageLib = {
19
- 'vertex': GPUShaderStage.VERTEX,
20
- 'fragment': GPUShaderStage.FRAGMENT,
21
- 'compute': GPUShaderStage.COMPUTE
21
+ 'vertex': GPUShaderStage ? GPUShaderStage.VERTEX : 1,
22
+ 'fragment': GPUShaderStage ? GPUShaderStage.FRAGMENT : 2,
23
+ 'compute': GPUShaderStage ? GPUShaderStage.COMPUTE : 4
22
24
  };
23
25
 
24
26
  const supports = {
25
- instance: true
27
+ instance: true,
28
+ storageBuffer: true
26
29
  };
27
30
 
28
31
  const wgslFnOpLib = {
@@ -51,6 +54,11 @@ const wgslTypeLib = {
51
54
  uvec4: 'vec4<u32>',
52
55
  bvec4: 'vec4<bool>',
53
56
 
57
+ mat2: 'mat2x2<f32>',
58
+ imat2: 'mat2x2<i32>',
59
+ umat2: 'mat2x2<u32>',
60
+ bmat2: 'mat2x2<bool>',
61
+
54
62
  mat3: 'mat3x3<f32>',
55
63
  imat3: 'mat3x3<i32>',
56
64
  umat3: 'mat3x3<u32>',
@@ -65,7 +73,14 @@ const wgslTypeLib = {
65
73
  const wgslMethods = {
66
74
  dFdx: 'dpdx',
67
75
  dFdy: '- dpdy',
68
- mod: 'threejs_mod',
76
+ mod_float: 'threejs_mod_float',
77
+ mod_vec2: 'threejs_mod_vec2',
78
+ mod_vec3: 'threejs_mod_vec3',
79
+ mod_vec4: 'threejs_mod_vec4',
80
+ equals_bool: 'threejs_equals_bool',
81
+ equals_bvec2: 'threejs_equals_bvec2',
82
+ equals_bvec3: 'threejs_equals_bvec3',
83
+ equals_bvec4: 'threejs_equals_bvec4',
69
84
  lessThanEqual: 'threejs_lessThanEqual',
70
85
  greaterThan: 'threejs_greaterThan',
71
86
  inversesqrt: 'inverseSqrt',
@@ -94,13 +109,14 @@ fn threejs_greaterThan( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {
94
109
 
95
110
  }
96
111
  ` ),
97
- mod: new CodeNode( `
98
- fn threejs_mod( x : f32, y : f32 ) -> f32 {
99
-
100
- return x - y * floor( x / y );
101
-
102
- }
103
- ` ),
112
+ mod_float: new CodeNode( 'fn threejs_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }' ),
113
+ mod_vec2: new CodeNode( 'fn threejs_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }' ),
114
+ mod_vec3: new CodeNode( 'fn threejs_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }' ),
115
+ mod_vec4: new CodeNode( 'fn threejs_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }' ),
116
+ equals_bool: new CodeNode( 'fn threejs_equals_bool( a : bool, b : bool ) -> bool { return a == b; }' ),
117
+ equals_bvec2: new CodeNode( 'fn threejs_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }' ),
118
+ equals_bvec3: new CodeNode( 'fn threejs_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }' ),
119
+ equals_bvec4: new CodeNode( 'fn threejs_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }' ),
104
120
  repeatWrapping: new CodeNode( `
105
121
  fn threejs_repeatWrapping( uv : vec2<f32>, dimension : vec2<u32> ) -> vec2<u32> {
106
122
 
@@ -124,24 +140,6 @@ class WGSLNodeBuilder extends NodeBuilder {
124
140
 
125
141
  }
126
142
 
127
- build() {
128
-
129
- const { object, material } = this;
130
-
131
- if ( material !== null ) {
132
-
133
- NodeMaterial.fromMaterial( material ).build( this );
134
-
135
- } else {
136
-
137
- this.addFlow( 'compute', object );
138
-
139
- }
140
-
141
- return super.build();
142
-
143
- }
144
-
145
143
  needsColorSpaceToLinear( texture ) {
146
144
 
147
145
  return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
@@ -222,6 +220,12 @@ class WGSLNodeBuilder extends NodeBuilder {
222
220
 
223
221
  }
224
222
 
223
+ generateTextureStore( texture, textureProperty, uvIndexSnippet, valueSnippet ) {
224
+
225
+ return `textureStore( ${ textureProperty }, ${ uvIndexSnippet }, ${ valueSnippet } )`;
226
+
227
+ }
228
+
225
229
  isUnfilterable( texture ) {
226
230
 
227
231
  return texture.isDataTexture === true && texture.type === FloatType;
@@ -297,7 +301,7 @@ class WGSLNodeBuilder extends NodeBuilder {
297
301
  const name = node.name;
298
302
  const type = node.type;
299
303
 
300
- if ( type === 'texture' || type === 'cubeTexture' ) {
304
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
301
305
 
302
306
  return name;
303
307
 
@@ -350,11 +354,11 @@ class WGSLNodeBuilder extends NodeBuilder {
350
354
 
351
355
  const bindings = this.bindings[ shaderStage ];
352
356
 
353
- if ( type === 'texture' || type === 'cubeTexture' ) {
357
+ if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
354
358
 
355
359
  let texture = null;
356
360
 
357
- if ( type === 'texture' ) {
361
+ if ( type === 'texture' || type === 'storageTexture' ) {
358
362
 
359
363
  texture = new NodeSampledTexture( uniformNode.name, uniformNode.node );
360
364
 
@@ -386,8 +390,8 @@ class WGSLNodeBuilder extends NodeBuilder {
386
390
 
387
391
  } else if ( type === 'buffer' || type === 'storageBuffer' ) {
388
392
 
389
- const bufferClass = type === 'storageBuffer' ? StorageBuffer : UniformBuffer;
390
- const buffer = new bufferClass( 'NodeBuffer_' + node.id, node.value );
393
+ const bufferClass = type === 'storageBuffer' ? NodeStorageBuffer : NodeUniformBuffer;
394
+ const buffer = new bufferClass( node );
391
395
  buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
392
396
 
393
397
  bindings.push( buffer );
@@ -414,31 +418,9 @@ class WGSLNodeBuilder extends NodeBuilder {
414
418
 
415
419
  }
416
420
 
417
- if ( node.isArrayUniformNode === true ) {
418
-
419
- uniformGPU = [];
421
+ uniformGPU = this.getNodeUniform( uniformNode, type );
420
422
 
421
- for ( const uniformNode of node.nodes ) {
422
-
423
- const uniformNodeGPU = this.getNodeUniform( uniformNode, type );
424
-
425
- // fit bounds to buffer
426
- uniformNodeGPU.boundary = getVectorLength( uniformNodeGPU.itemSize );
427
- uniformNodeGPU.itemSize = getStrideLength( uniformNodeGPU.itemSize );
428
-
429
- uniformsGroup.addUniform( uniformNodeGPU );
430
-
431
- uniformGPU.push( uniformNodeGPU );
432
-
433
- }
434
-
435
- } else {
436
-
437
- uniformGPU = this.getNodeUniform( uniformNode, type );
438
-
439
- uniformsGroup.addUniform( uniformGPU );
440
-
441
- }
423
+ uniformsGroup.addUniform( uniformGPU );
442
424
 
443
425
  }
444
426
 
@@ -737,7 +719,7 @@ ${ flowData.code }
737
719
 
738
720
  for ( const uniform of uniforms ) {
739
721
 
740
- if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' ) {
722
+ if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' ) {
741
723
 
742
724
  const texture = uniform.node.value;
743
725
 
@@ -809,17 +791,7 @@ ${ flowData.code }
809
791
  snippets: []
810
792
  } );
811
793
 
812
- if ( Array.isArray( uniform.value ) === true ) {
813
-
814
- const length = uniform.value.length;
815
-
816
- group.snippets.push( `uniform ${vectorType}[ ${length} ] ${uniform.name}` );
817
-
818
- } else {
819
-
820
- group.snippets.push( `\t${uniform.name} : ${ vectorType}` );
821
-
822
- }
794
+ group.snippets.push( `\t${ uniform.name } : ${ vectorType }` );
823
795
 
824
796
  }
825
797
 
@@ -936,15 +908,23 @@ ${ flowData.code }
936
908
 
937
909
  }
938
910
 
939
- getMethod( method ) {
911
+ getMethod( method, output = null ) {
940
912
 
941
- if ( wgslPolyfill[ method ] !== undefined ) {
913
+ let wgslMethod;
942
914
 
943
- this._include( method );
915
+ if ( output !== null ) {
916
+
917
+ wgslMethod = this._getWGSLMethod( method + '_' + output );
944
918
 
945
919
  }
946
920
 
947
- return wgslMethods[ method ] || method;
921
+ if ( wgslMethod === undefined ) {
922
+
923
+ wgslMethod = this._getWGSLMethod( method );
924
+
925
+ }
926
+
927
+ return wgslMethod || method;
948
928
 
949
929
  }
950
930
 
@@ -960,6 +940,18 @@ ${ flowData.code }
960
940
 
961
941
  }
962
942
 
943
+ _getWGSLMethod( method ) {
944
+
945
+ if ( wgslPolyfill[ method ] !== undefined ) {
946
+
947
+ this._include( method );
948
+
949
+ }
950
+
951
+ return wgslMethods[ method ];
952
+
953
+ }
954
+
963
955
  _include( name ) {
964
956
 
965
957
  const codeNode = wgslPolyfill[ name ];
@@ -42,7 +42,21 @@ class WebGPUAttributeUtils {
42
42
 
43
43
  const device = backend.device;
44
44
 
45
- const array = bufferAttribute.array;
45
+ let array = bufferAttribute.array;
46
+
47
+ if ( ( bufferAttribute.isStorageBufferAttribute || bufferAttribute.isStorageInstancedBufferAttribute ) && bufferAttribute.itemSize === 3 ) {
48
+
49
+ bufferAttribute.itemSize = 4;
50
+ array = new array.constructor( bufferAttribute.count * 4 );
51
+
52
+ for ( let i = 0; i < bufferAttribute.count; i ++ ) {
53
+
54
+ array.set( bufferAttribute.array.subarray( i * 3, i * 3 + 3 ), i * 4 );
55
+
56
+ }
57
+
58
+ }
59
+
46
60
  const size = array.byteLength + ( ( 4 - ( array.byteLength % 4 ) ) % 4 ); // ensure 4 byte alignment, see #20441
47
61
 
48
62
  buffer = device.createBuffer( {
@@ -23,7 +23,7 @@ class WebGPUPipelineUtils {
23
23
 
24
24
  }
25
25
 
26
- createRenderPipeline( renderObject ) {
26
+ createRenderPipeline( renderObject, promises ) {
27
27
 
28
28
  const { object, material, geometry, pipeline } = renderObject;
29
29
  const { vertexProgram, fragmentProgram } = pipeline;
@@ -102,9 +102,22 @@ class WebGPUPipelineUtils {
102
102
  const primitiveState = this._getPrimitiveState( object, geometry, material );
103
103
  const depthCompare = this._getDepthCompare( material );
104
104
  const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
105
- const sampleCount = utils.getSampleCount( renderObject.context );
105
+ let sampleCount = utils.getSampleCount( renderObject.context );
106
106
 
107
- pipelineData.pipeline = device.createRenderPipeline( {
107
+ if ( sampleCount > 1 ) {
108
+
109
+ // WebGPU only supports power-of-two sample counts and 2 is not a valid value
110
+ sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
111
+
112
+ if ( sampleCount === 2 ) {
113
+
114
+ sampleCount = 4;
115
+
116
+ }
117
+
118
+ }
119
+
120
+ const pipelineDescriptor = {
108
121
  vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
109
122
  fragment: Object.assign( {}, fragmentModule, { targets } ),
110
123
  primitive: primitiveState,
@@ -124,7 +137,28 @@ class WebGPUPipelineUtils {
124
137
  layout: device.createPipelineLayout( {
125
138
  bindGroupLayouts: [ bindingsData.layout ]
126
139
  } )
127
- } );
140
+ };
141
+
142
+ if ( promises === null ) {
143
+
144
+ pipelineData.pipeline = device.createRenderPipeline( pipelineDescriptor );
145
+
146
+ } else {
147
+
148
+ const p = new Promise( ( resolve /*, reject*/ ) => {
149
+
150
+ device.createRenderPipelineAsync( pipelineDescriptor ).then( pipeline => {
151
+
152
+ pipelineData.pipeline = pipeline;
153
+ resolve();
154
+
155
+ } );
156
+
157
+ } );
158
+
159
+ promises.push( p );
160
+
161
+ }
128
162
 
129
163
  }
130
164
 
@@ -113,7 +113,21 @@ class WebGPUTextureUtils {
113
113
  const dimension = this._getDimension( texture );
114
114
  const format = texture.internalFormat || getFormat( texture, backend.device );
115
115
 
116
- const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
116
+ let sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
117
+
118
+ if ( sampleCount > 1 ) {
119
+
120
+ // WebGPU only supports power-of-two sample counts and 2 is not a valid value
121
+ sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
122
+
123
+ if ( sampleCount === 2 ) {
124
+
125
+ sampleCount = 4;
126
+
127
+ }
128
+
129
+ }
130
+
117
131
  const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
118
132
 
119
133
  let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
@@ -313,13 +327,13 @@ class WebGPUTextureUtils {
313
327
 
314
328
  if ( texture.isDataTexture || texture.isData3DTexture ) {
315
329
 
316
- this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, false );
330
+ this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
317
331
 
318
332
  } else if ( texture.isDataArrayTexture ) {
319
333
 
320
334
  for ( let i = 0; i < options.image.depth; i ++ ) {
321
335
 
322
- this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, i, false, i );
336
+ this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, i, texture.flipY, i );
323
337
 
324
338
  }
325
339
 
@@ -360,6 +374,9 @@ class WebGPUTextureUtils {
360
374
  const format = textureData.textureDescriptorGPU.format;
361
375
  const bytesPerTexel = this._getBytesPerTexel( format );
362
376
 
377
+ let bytesPerRow = width * bytesPerTexel;
378
+ bytesPerRow = Math.ceil( bytesPerRow / 256 ) * 256; // Align to 256 bytes
379
+
363
380
  const readBuffer = device.createBuffer(
364
381
  {
365
382
  size: width * height * bytesPerTexel,
@@ -376,7 +393,7 @@ class WebGPUTextureUtils {
376
393
  },
377
394
  {
378
395
  buffer: readBuffer,
379
- bytesPerRow: width * bytesPerTexel
396
+ bytesPerRow: bytesPerRow
380
397
  },
381
398
  {
382
399
  width: width,
@@ -665,15 +682,57 @@ class WebGPUTextureUtils {
665
682
 
666
683
  _getBytesPerTexel( format ) {
667
684
 
668
- if ( format === GPUTextureFormat.R8Unorm ) return 1;
669
- if ( format === GPUTextureFormat.R16Float ) return 2;
670
- if ( format === GPUTextureFormat.RG8Unorm ) return 2;
671
- if ( format === GPUTextureFormat.RG16Float ) return 4;
672
- if ( format === GPUTextureFormat.R32Float ) return 4;
673
- if ( format === GPUTextureFormat.RGBA8Unorm || format === GPUTextureFormat.RGBA8UnormSRGB ) return 4;
674
- if ( format === GPUTextureFormat.RG32Float ) return 8;
675
- if ( format === GPUTextureFormat.RGBA16Float ) return 8;
676
- if ( format === GPUTextureFormat.RGBA32Float ) return 16;
685
+ // 8-bit formats
686
+ if ( format === GPUTextureFormat.R8Unorm ||
687
+ format === GPUTextureFormat.R8Snorm ||
688
+ format === GPUTextureFormat.R8Uint ||
689
+ format === GPUTextureFormat.R8Sint ) return 1;
690
+
691
+ // 16-bit formats
692
+ if ( format === GPUTextureFormat.R16Uint ||
693
+ format === GPUTextureFormat.R16Sint ||
694
+ format === GPUTextureFormat.R16Float ||
695
+ format === GPUTextureFormat.RG8Unorm ||
696
+ format === GPUTextureFormat.RG8Snorm ||
697
+ format === GPUTextureFormat.RG8Uint ||
698
+ format === GPUTextureFormat.RG8Sint ) return 2;
699
+
700
+ // 32-bit formats
701
+ if ( format === GPUTextureFormat.R32Uint ||
702
+ format === GPUTextureFormat.R32Sint ||
703
+ format === GPUTextureFormat.R32Float ||
704
+ format === GPUTextureFormat.RG16Uint ||
705
+ format === GPUTextureFormat.RG16Sint ||
706
+ format === GPUTextureFormat.RG16Float ||
707
+ format === GPUTextureFormat.RGBA8Unorm ||
708
+ format === GPUTextureFormat.RGBA8UnormSRGB ||
709
+ format === GPUTextureFormat.RGBA8Snorm ||
710
+ format === GPUTextureFormat.RGBA8Uint ||
711
+ format === GPUTextureFormat.RGBA8Sint ||
712
+ format === GPUTextureFormat.BGRA8Unorm ||
713
+ format === GPUTextureFormat.BGRA8UnormSRGB ||
714
+ // Packed 32-bit formats
715
+ format === GPUTextureFormat.RGB9E5UFloat ||
716
+ format === GPUTextureFormat.RGB10A2Unorm ||
717
+ format === GPUTextureFormat.RG11B10UFloat ||
718
+ format === GPUTextureFormat.Depth32Float ||
719
+ format === GPUTextureFormat.Depth24Plus ||
720
+ format === GPUTextureFormat.Depth24PlusStencil8 ||
721
+ format === GPUTextureFormat.Depth32FloatStencil8 ) return 4;
722
+
723
+ // 64-bit formats
724
+ if ( format === GPUTextureFormat.RG32Uint ||
725
+ format === GPUTextureFormat.RG32Sint ||
726
+ format === GPUTextureFormat.RG32Float ||
727
+ format === GPUTextureFormat.RGBA16Uint ||
728
+ format === GPUTextureFormat.RGBA16Sint ||
729
+ format === GPUTextureFormat.RGBA16Float ) return 8;
730
+
731
+ // 128-bit formats
732
+ if ( format === GPUTextureFormat.RGBA32Uint ||
733
+ format === GPUTextureFormat.RGBA32Sint ||
734
+ format === GPUTextureFormat.RGBA32Float ) return 16;
735
+
677
736
 
678
737
  }
679
738
 
@@ -699,6 +758,9 @@ class WebGPUTextureUtils {
699
758
  if ( format === GPUTextureFormat.RG16Sint ) return Int16Array;
700
759
  if ( format === GPUTextureFormat.RGBA16Uint ) return Uint16Array;
701
760
  if ( format === GPUTextureFormat.RGBA16Sint ) return Int16Array;
761
+ if ( format === GPUTextureFormat.R16Float ) return Float32Array;
762
+ if ( format === GPUTextureFormat.RG16Float ) return Float32Array;
763
+ if ( format === GPUTextureFormat.RGBA16Float ) return Float32Array;
702
764
 
703
765
 
704
766
  if ( format === GPUTextureFormat.R32Uint ) return Uint32Array;
@@ -711,6 +773,17 @@ class WebGPUTextureUtils {
711
773
  if ( format === GPUTextureFormat.RGBA32Sint ) return Int32Array;
712
774
  if ( format === GPUTextureFormat.RGBA32Float ) return Float32Array;
713
775
 
776
+ if ( format === GPUTextureFormat.BGRA8Unorm ) return Uint8Array;
777
+ if ( format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
778
+ if ( format === GPUTextureFormat.RGB10A2Unorm ) return Uint32Array;
779
+ if ( format === GPUTextureFormat.RGB9E5UFloat ) return Uint32Array;
780
+ if ( format === GPUTextureFormat.RG11B10UFloat ) return Uint32Array;
781
+
782
+ if ( format === GPUTextureFormat.Depth32Float ) return Float32Array;
783
+ if ( format === GPUTextureFormat.Depth24Plus ) return Uint32Array;
784
+ if ( format === GPUTextureFormat.Depth24PlusStencil8 ) return Uint32Array;
785
+ if ( format === GPUTextureFormat.Depth32FloatStencil8 ) return Float32Array;
786
+
714
787
  }
715
788
 
716
789
  _getDimension( texture ) {
@@ -741,7 +814,7 @@ export function getFormat( texture, device = null ) {
741
814
 
742
815
  let formatGPU;
743
816
 
744
- if ( /*texture.isRenderTargetTexture === true ||*/ texture.isFramebufferTexture === true ) {
817
+ if ( texture.isFramebufferTexture === true && texture.type === UnsignedByteType ) {
745
818
 
746
819
  formatGPU = GPUTextureFormat.BGRA8Unorm;
747
820
 
@@ -64,6 +64,10 @@ const OutputShader = {
64
64
 
65
65
  gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
66
66
 
67
+ #elif defined( NEUTRAL_TONE_MAPPING )
68
+
69
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
70
+
67
71
  #endif
68
72
 
69
73
  // color space
@@ -267,4 +267,4 @@ export class For {
267
267
 
268
268
  }
269
269
 
270
- }
270
+ }
@@ -938,4 +938,4 @@ class GLSLDecoder {
938
938
 
939
939
  }
940
940
 
941
- export default GLSLDecoder;
941
+ export default GLSLDecoder;
@@ -46,4 +46,4 @@ class ShaderToyDecoder extends GLSLDecoder {
46
46
 
47
47
  }
48
48
 
49
- export default ShaderToyDecoder;
49
+ export default ShaderToyDecoder;
@@ -712,4 +712,4 @@ ${ this.tab }} );\n\n`;
712
712
 
713
713
  }
714
714
 
715
- export default TSLEncoder;
715
+ export default TSLEncoder;
@@ -311,13 +311,6 @@ function mergeAttributes( attributes ) {
311
311
 
312
312
  const attribute = attributes[ i ];
313
313
 
314
- if ( attribute.isInterleavedBufferAttribute ) {
315
-
316
- console.error( 'THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported.' );
317
- return null;
318
-
319
- }
320
-
321
314
  if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
322
315
  if ( TypedArray !== attribute.array.constructor ) {
323
316
 
@@ -350,22 +343,41 @@ function mergeAttributes( attributes ) {
350
343
 
351
344
  }
352
345
 
353
- arrayLength += attribute.array.length;
346
+ arrayLength += attribute.count * itemSize;
354
347
 
355
348
  }
356
349
 
357
350
  const array = new TypedArray( arrayLength );
351
+ const result = new BufferAttribute( array, itemSize, normalized );
358
352
  let offset = 0;
359
353
 
360
354
  for ( let i = 0; i < attributes.length; ++ i ) {
361
355
 
362
- array.set( attributes[ i ].array, offset );
356
+ const attribute = attributes[ i ];
357
+ if ( attribute.isInterleavedBufferAttribute ) {
358
+
359
+ const tupleOffset = offset / itemSize;
360
+ for ( let j = 0, l = attribute.count; j < l; j ++ ) {
361
+
362
+ for ( let c = 0; c < itemSize; c ++ ) {
363
363
 
364
- offset += attributes[ i ].array.length;
364
+ const value = attribute.getComponent( j, c );
365
+ result.setComponent( j + tupleOffset, c, value );
366
+
367
+ }
368
+
369
+ }
370
+
371
+ } else {
372
+
373
+ array.set( attribute.array, offset );
374
+
375
+ }
376
+
377
+ offset += attribute.count * itemSize;
365
378
 
366
379
  }
367
380
 
368
- const result = new BufferAttribute( array, itemSize, normalized );
369
381
  if ( gpuType !== undefined ) {
370
382
 
371
383
  result.gpuType = gpuType;
@@ -1345,26 +1357,10 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */
1345
1357
 
1346
1358
  }
1347
1359
 
1348
- function mergeBufferGeometries( geometries, useGroups = false ) {
1349
-
1350
- console.warn( 'THREE.BufferGeometryUtils: mergeBufferGeometries() has been renamed to mergeGeometries().' ); // @deprecated, r151
1351
- return mergeGeometries( geometries, useGroups );
1352
-
1353
- }
1354
-
1355
- function mergeBufferAttributes( attributes ) {
1356
-
1357
- console.warn( 'THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes().' ); // @deprecated, r151
1358
- return mergeAttributes( attributes );
1359
-
1360
- }
1361
-
1362
1360
  export {
1363
1361
  computeMikkTSpaceTangents,
1364
1362
  mergeGeometries,
1365
- mergeBufferGeometries,
1366
1363
  mergeAttributes,
1367
- mergeBufferAttributes,
1368
1364
  interleaveAttributes,
1369
1365
  estimateBytesUsed,
1370
1366
  mergeVertices,
@@ -200,7 +200,8 @@ function retarget( target, source, options = {} ) {
200
200
  function retargetClip( target, source, clip, options = {} ) {
201
201
 
202
202
  options.useFirstFramePosition = options.useFirstFramePosition !== undefined ? options.useFirstFramePosition : false;
203
- options.fps = options.fps !== undefined ? options.fps : 30;
203
+ // Calculate the fps from the source clip based on the track with the most frames, unless fps is already provided.
204
+ options.fps = options.fps !== undefined ? options.fps : ( Math.max( ...clip.tracks.map( track => track.times.length ) ) / clip.duration );
204
205
  options.names = options.names || [];
205
206
 
206
207
  if ( ! source.isObject3D ) {
@@ -210,7 +211,7 @@ function retargetClip( target, source, clip, options = {} ) {
210
211
  }
211
212
 
212
213
  const numFrames = Math.round( clip.duration * ( options.fps / 1000 ) * 1000 ),
213
- delta = 1 / options.fps,
214
+ delta = clip.duration / ( numFrames - 1 ),
214
215
  convertedTracks = [],
215
216
  mixer = new AnimationMixer( source ),
216
217
  bones = getBones( target.skeleton ),
@@ -287,7 +288,17 @@ function retargetClip( target, source, clip, options = {} ) {
287
288
 
288
289
  }
289
290
 
290
- mixer.update( delta );
291
+ if ( i === numFrames - 2 ) {
292
+
293
+ // last mixer update before final loop iteration
294
+ // make sure we do not go over or equal to clip duration
295
+ mixer.update( delta - 0.0000001 );
296
+
297
+ } else {
298
+
299
+ mixer.update( delta );
300
+
301
+ }
291
302
 
292
303
  source.updateMatrixWorld();
293
304
 
@@ -13,8 +13,10 @@ const bins_buffer = new ArrayBuffer( ( ITERATIONS + 1 ) * BIN_SIZE * 4 );
13
13
 
14
14
  let c = 0;
15
15
  for ( let i = 0; i < ( ITERATIONS + 1 ); i ++ ) {
16
+
16
17
  bins[ i ] = new Uint32Array( bins_buffer, c, BIN_SIZE );
17
18
  c += BIN_SIZE * 4;
19
+
18
20
  }
19
21
 
20
22
  const defaultGet = ( el ) => el;