super-three 0.156.0 → 0.157.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 (220) hide show
  1. package/build/three.cjs +279 -224
  2. package/build/three.js +279 -224
  3. package/build/three.min.js +2 -2
  4. package/build/three.module.js +276 -223
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/capabilities/WebGL.js +17 -0
  7. package/examples/jsm/controls/DragControls.js +3 -2
  8. package/examples/jsm/csm/CSMShader.js +25 -21
  9. package/examples/jsm/exporters/EXRExporter.js +102 -24
  10. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  11. package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
  12. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  14. package/examples/jsm/lights/LightProbeGenerator.js +37 -3
  15. package/examples/jsm/lines/LineMaterial.js +90 -156
  16. package/examples/jsm/loaders/3DMLoader.js +378 -104
  17. package/examples/jsm/loaders/GLTFLoader.js +1 -1
  18. package/examples/jsm/loaders/LDrawLoader.js +22 -16
  19. package/examples/jsm/loaders/RGBELoader.js +1 -1
  20. package/examples/jsm/loaders/USDZLoader.js +215 -12
  21. package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
  22. package/examples/jsm/nodes/Nodes.js +5 -1
  23. package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
  24. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +2 -2
  25. package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
  26. package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
  27. package/examples/jsm/nodes/accessors/CubeTextureNode.js +2 -2
  28. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +6 -5
  29. package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
  30. package/examples/jsm/nodes/accessors/LineMaterialNode.js +7 -9
  31. package/examples/jsm/nodes/accessors/MaterialNode.js +34 -46
  32. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +9 -9
  33. package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
  35. package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
  36. package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  38. package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
  39. package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
  40. package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
  41. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
  42. package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
  45. package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
  46. package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
  47. package/examples/jsm/nodes/accessors/TextureNode.js +12 -6
  48. package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
  49. package/examples/jsm/nodes/accessors/TextureStoreNode.js +1 -1
  50. package/examples/jsm/nodes/accessors/UVNode.js +1 -1
  51. package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
  52. package/examples/jsm/nodes/code/CodeNode.js +1 -1
  53. package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
  54. package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
  55. package/examples/jsm/nodes/code/FunctionNode.js +18 -7
  56. package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
  57. package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
  58. package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
  59. package/examples/jsm/nodes/core/AttributeNode.js +1 -1
  60. package/examples/jsm/nodes/core/BypassNode.js +1 -1
  61. package/examples/jsm/nodes/core/CacheNode.js +1 -1
  62. package/examples/jsm/nodes/core/ConstNode.js +1 -1
  63. package/examples/jsm/nodes/core/ContextNode.js +2 -2
  64. package/examples/jsm/nodes/core/IndexNode.js +1 -1
  65. package/examples/jsm/nodes/core/InputNode.js +1 -1
  66. package/examples/jsm/nodes/core/Node.js +28 -13
  67. package/examples/jsm/nodes/core/NodeBuilder.js +3 -17
  68. package/examples/jsm/nodes/core/NodeFrame.js +37 -14
  69. package/examples/jsm/nodes/core/OutputStructNode.js +8 -4
  70. package/examples/jsm/nodes/core/PropertyNode.js +3 -3
  71. package/examples/jsm/nodes/core/StackNode.js +1 -1
  72. package/examples/jsm/nodes/core/StructTypeNode.js +1 -1
  73. package/examples/jsm/nodes/core/TempNode.js +1 -1
  74. package/examples/jsm/nodes/core/UniformNode.js +3 -1
  75. package/examples/jsm/nodes/core/VarNode.js +1 -1
  76. package/examples/jsm/nodes/core/VaryingNode.js +1 -1
  77. package/examples/jsm/nodes/core/constants.js +1 -1
  78. package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
  79. package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
  80. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
  81. package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
  82. package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
  83. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  84. package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
  85. package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
  86. package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
  87. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
  88. package/examples/jsm/nodes/display/ViewportNode.js +2 -2
  89. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
  90. package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
  91. package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
  92. package/examples/jsm/nodes/fog/FogNode.js +2 -2
  93. package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
  94. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  95. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  96. package/examples/jsm/nodes/lighting/AONode.js +2 -2
  97. package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
  98. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
  99. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
  100. package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
  101. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
  102. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
  103. package/examples/jsm/nodes/lighting/LightNode.js +2 -2
  104. package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
  105. package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
  106. package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
  107. package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
  108. package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
  109. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
  110. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
  111. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +2 -2
  112. package/examples/jsm/nodes/materials/Materials.js +1 -0
  113. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
  114. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
  115. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
  116. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
  117. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  118. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
  119. package/examples/jsm/nodes/materials/NodeMaterial.js +27 -26
  120. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
  121. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  122. package/examples/jsm/nodes/math/CondNode.js +1 -1
  123. package/examples/jsm/nodes/math/HashNode.js +8 -9
  124. package/examples/jsm/nodes/math/MathNode.js +2 -2
  125. package/examples/jsm/nodes/math/OperatorNode.js +1 -1
  126. package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
  127. package/examples/jsm/nodes/shadernode/ShaderNode.js +81 -28
  128. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  129. package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
  130. package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
  131. package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
  132. package/examples/jsm/nodes/utils/JoinNode.js +1 -1
  133. package/examples/jsm/nodes/utils/LoopNode.js +11 -11
  134. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
  135. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  136. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  137. package/examples/jsm/nodes/utils/PackingNode.js +2 -2
  138. package/examples/jsm/nodes/utils/RemapNode.js +2 -2
  139. package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
  140. package/examples/jsm/nodes/utils/SetNode.js +62 -0
  141. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
  142. package/examples/jsm/nodes/utils/SplitNode.js +1 -1
  143. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
  144. package/examples/jsm/nodes/utils/TimerNode.js +2 -2
  145. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
  146. package/examples/jsm/objects/Sky.js +1 -3
  147. package/examples/jsm/postprocessing/OutputPass.js +3 -2
  148. package/examples/jsm/renderers/common/Background.js +2 -2
  149. package/examples/jsm/renderers/common/Bindings.js +3 -5
  150. package/examples/jsm/renderers/common/Pipelines.js +7 -7
  151. package/examples/jsm/renderers/common/RenderContext.js +3 -0
  152. package/examples/jsm/renderers/common/RenderObject.js +40 -16
  153. package/examples/jsm/renderers/common/RenderObjects.js +8 -14
  154. package/examples/jsm/renderers/common/Renderer.js +40 -13
  155. package/examples/jsm/renderers/common/SampledTexture.js +4 -2
  156. package/examples/jsm/renderers/common/StorageTexture.js +19 -0
  157. package/examples/jsm/renderers/common/Textures.js +14 -9
  158. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
  159. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +20 -10
  160. package/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -6
  161. package/examples/jsm/renderers/common/nodes/Nodes.js +51 -24
  162. package/examples/jsm/renderers/webgl/WebGLBackend.js +100 -5
  163. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +92 -6
  164. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +13 -0
  165. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +3 -3
  166. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +14 -2
  167. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +5 -5
  168. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +6 -3
  169. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  170. package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
  171. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +197 -167
  172. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  173. package/examples/jsm/shaders/MMDToonShader.js +4 -4
  174. package/examples/jsm/shaders/OutputShader.js +2 -2
  175. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
  176. package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
  177. package/package.json +1 -1
  178. package/src/Three.js +0 -2
  179. package/src/animation/AnimationUtils.js +3 -20
  180. package/src/animation/KeyframeTrack.js +8 -8
  181. package/src/cameras/Camera.js +1 -5
  182. package/src/cameras/CubeCamera.js +14 -8
  183. package/src/constants.js +7 -1
  184. package/src/core/RenderTarget.js +16 -7
  185. package/src/extras/core/CurvePath.js +4 -1
  186. package/src/loaders/MaterialLoader.js +1 -1
  187. package/src/loaders/ObjectLoader.js +6 -0
  188. package/src/materials/Material.js +8 -8
  189. package/src/math/Color.js +1 -5
  190. package/src/math/ColorManagement.js +82 -60
  191. package/src/objects/Sprite.js +2 -2
  192. package/src/renderers/WebGLRenderer.js +21 -2
  193. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  194. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
  195. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
  196. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
  197. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
  198. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
  199. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
  200. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
  201. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
  202. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
  203. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
  204. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
  205. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
  206. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
  207. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
  208. package/src/renderers/shaders/UniformsUtils.js +2 -2
  209. package/src/renderers/webgl/WebGLBackground.js +4 -3
  210. package/src/renderers/webgl/WebGLLights.js +14 -3
  211. package/src/renderers/webgl/WebGLProgram.js +34 -5
  212. package/src/renderers/webgl/WebGLPrograms.js +6 -2
  213. package/src/renderers/webgl/WebGLTextures.js +17 -6
  214. package/src/renderers/webgl/WebGLUtils.js +21 -23
  215. package/src/scenes/Fog.js +1 -0
  216. package/src/scenes/FogExp2.js +1 -0
  217. package/src/textures/Source.js +2 -2
  218. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
  219. package/src/lights/AmbientLightProbe.js +0 -21
  220. package/src/lights/HemisphereLightProbe.js +0 -30
@@ -15,7 +15,7 @@ import {
15
15
 
16
16
  import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from 'three';
17
17
 
18
- import WebGPUTextureMipmapUtils from './WebGPUTextureMipmapUtils.js';
18
+ import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
19
19
 
20
20
  const _compareToWebGPU = {
21
21
  [ NeverCompare ]: 'never',
@@ -28,13 +28,15 @@ const _compareToWebGPU = {
28
28
  [ NotEqualCompare ]: 'not-equal'
29
29
  };
30
30
 
31
+ const _flipMap = [ 0, 1, 3, 2, 4, 5 ];
32
+
31
33
  class WebGPUTextureUtils {
32
34
 
33
35
  constructor( backend ) {
34
36
 
35
37
  this.backend = backend;
36
38
 
37
- this.mipmapUtils = null;
39
+ this._passUtils = null;
38
40
 
39
41
  this.defaultTexture = null;
40
42
  this.defaultCubeTexture = null;
@@ -104,14 +106,14 @@ class WebGPUTextureUtils {
104
106
  const { width, height, depth, levels } = options;
105
107
 
106
108
  const dimension = this._getDimension( texture );
107
- const format = texture.internalFormat || this._getFormat( texture );
109
+ const format = texture.internalFormat || getFormat( texture, this.device );
108
110
 
109
111
  const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
110
112
  const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
111
113
 
112
114
  let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
113
115
 
114
- if ( options.store === true ) {
116
+ if ( texture.isStorageTexture === true ) {
115
117
 
116
118
  usage |= GPUTextureUsage.STORAGE_BINDING;
117
119
 
@@ -237,7 +239,7 @@ class WebGPUTextureUtils {
237
239
 
238
240
  if ( texture.isDataTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
239
241
 
240
- this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU );
242
+ this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, false );
241
243
 
242
244
  } else if ( texture.isCompressedTexture ) {
243
245
 
@@ -245,7 +247,7 @@ class WebGPUTextureUtils {
245
247
 
246
248
  } else if ( texture.isCubeTexture ) {
247
249
 
248
- this._copyCubeMapToTexture( options.images, texture, textureData.texture, textureDescriptorGPU );
250
+ this._copyCubeMapToTexture( options.images, textureData.texture, textureDescriptorGPU, texture.flipY );
249
251
 
250
252
  } else if ( texture.isVideoTexture ) {
251
253
 
@@ -255,7 +257,7 @@ class WebGPUTextureUtils {
255
257
 
256
258
  } else {
257
259
 
258
- this._copyImageToTexture( options.image, textureData.texture );
260
+ this._copyImageToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
259
261
 
260
262
  }
261
263
 
@@ -361,19 +363,21 @@ class WebGPUTextureUtils {
361
363
 
362
364
  }
363
365
 
364
- _copyCubeMapToTexture( images, texture, textureGPU, textureDescriptorGPU ) {
366
+ _copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY ) {
365
367
 
366
368
  for ( let i = 0; i < 6; i ++ ) {
367
369
 
368
370
  const image = images[ i ];
369
371
 
372
+ const flipIndex = flipY === true ? _flipMap[ i ] : i;
373
+
370
374
  if ( image.isDataTexture ) {
371
375
 
372
- this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, i );
376
+ this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
373
377
 
374
378
  } else {
375
379
 
376
- this._copyImageToTexture( image, textureGPU, i );
380
+ this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
377
381
 
378
382
  }
379
383
 
@@ -381,7 +385,7 @@ class WebGPUTextureUtils {
381
385
 
382
386
  }
383
387
 
384
- _copyImageToTexture( image, textureGPU, originDepth = 0 ) {
388
+ _copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY ) {
385
389
 
386
390
  const device = this.backend.device;
387
391
 
@@ -399,21 +403,41 @@ class WebGPUTextureUtils {
399
403
  }
400
404
  );
401
405
 
406
+ if ( flipY === true ) {
407
+
408
+ this._flipY( textureGPU, textureDescriptorGPU, originDepth );
409
+
410
+ }
411
+
402
412
  }
403
413
 
404
- _generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
414
+ _getPassUtils() {
405
415
 
406
- if ( this.mipmapUtils === null ) {
416
+ let passUtils = this._passUtils;
407
417
 
408
- this.mipmapUtils = new WebGPUTextureMipmapUtils( this.backend.device );
418
+ if ( passUtils === null ) {
419
+
420
+ this._passUtils = passUtils = new WebGPUTexturePassUtils( this.backend.device );
409
421
 
410
422
  }
411
423
 
412
- this.mipmapUtils.generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
424
+ return passUtils;
425
+
426
+ }
427
+
428
+ _generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
429
+
430
+ this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
431
+
432
+ }
433
+
434
+ _flipY( textureGPU, textureDescriptorGPU, originDepth = 0 ) {
435
+
436
+ this._getPassUtils().flipY( textureGPU, textureDescriptorGPU, originDepth );
413
437
 
414
438
  }
415
439
 
416
- _copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth = 0 ) {
440
+ _copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY ) {
417
441
 
418
442
  // @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
419
443
  // @TODO: Consider to support valid buffer layouts with other formats like RGB
@@ -442,6 +466,12 @@ class WebGPUTextureUtils {
442
466
  depthOrArrayLayers: ( image.depth !== undefined ) ? image.depth : 1
443
467
  } );
444
468
 
469
+ if ( flipY === true ) {
470
+
471
+ this._flipY( textureGPU, textureDescriptorGPU, originDepth );
472
+
473
+ }
474
+
445
475
  }
446
476
 
447
477
  _copyCompressedBufferToTexture( mipmaps, textureGPU, textureDescriptorGPU ) {
@@ -619,237 +649,237 @@ class WebGPUTextureUtils {
619
649
 
620
650
  }
621
651
 
622
- _getFormat( texture ) {
652
+ }
623
653
 
624
- const format = texture.format;
625
- const type = texture.type;
626
- const colorSpace = texture.colorSpace;
654
+ export function getFormat( texture, device = null ) {
627
655
 
628
- let formatGPU;
656
+ const format = texture.format;
657
+ const type = texture.type;
658
+ const colorSpace = texture.colorSpace;
629
659
 
630
- if ( /*texture.isRenderTargetTexture === true ||*/ texture.isFramebufferTexture === true ) {
660
+ let formatGPU;
631
661
 
632
- formatGPU = GPUTextureFormat.BGRA8Unorm;
662
+ if ( /*texture.isRenderTargetTexture === true ||*/ texture.isFramebufferTexture === true ) {
633
663
 
634
- } else if ( texture.isCompressedTexture === true ) {
664
+ formatGPU = GPUTextureFormat.BGRA8Unorm;
635
665
 
636
- switch ( format ) {
666
+ } else if ( texture.isCompressedTexture === true ) {
637
667
 
638
- case RGBA_S3TC_DXT1_Format:
639
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
640
- break;
668
+ switch ( format ) {
641
669
 
642
- case RGBA_S3TC_DXT3_Format:
643
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
644
- break;
670
+ case RGBA_S3TC_DXT1_Format:
671
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
672
+ break;
645
673
 
646
- case RGBA_S3TC_DXT5_Format:
647
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
648
- break;
674
+ case RGBA_S3TC_DXT3_Format:
675
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
676
+ break;
649
677
 
650
- case RGB_ETC2_Format:
651
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
652
- break;
678
+ case RGBA_S3TC_DXT5_Format:
679
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
680
+ break;
653
681
 
654
- case RGBA_ETC2_EAC_Format:
655
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
656
- break;
682
+ case RGB_ETC2_Format:
683
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
684
+ break;
657
685
 
658
- case RGBA_ASTC_4x4_Format:
659
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
660
- break;
686
+ case RGBA_ETC2_EAC_Format:
687
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
688
+ break;
661
689
 
662
- case RGBA_ASTC_5x4_Format:
663
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
664
- break;
690
+ case RGBA_ASTC_4x4_Format:
691
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
692
+ break;
665
693
 
666
- case RGBA_ASTC_5x5_Format:
667
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
668
- break;
694
+ case RGBA_ASTC_5x4_Format:
695
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
696
+ break;
669
697
 
670
- case RGBA_ASTC_6x5_Format:
671
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
672
- break;
698
+ case RGBA_ASTC_5x5_Format:
699
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
700
+ break;
673
701
 
674
- case RGBA_ASTC_6x6_Format:
675
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
676
- break;
702
+ case RGBA_ASTC_6x5_Format:
703
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
704
+ break;
677
705
 
678
- case RGBA_ASTC_8x5_Format:
679
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
680
- break;
706
+ case RGBA_ASTC_6x6_Format:
707
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
708
+ break;
681
709
 
682
- case RGBA_ASTC_8x6_Format:
683
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
684
- break;
710
+ case RGBA_ASTC_8x5_Format:
711
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
712
+ break;
685
713
 
686
- case RGBA_ASTC_8x8_Format:
687
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
688
- break;
714
+ case RGBA_ASTC_8x6_Format:
715
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
716
+ break;
689
717
 
690
- case RGBA_ASTC_10x5_Format:
691
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
692
- break;
718
+ case RGBA_ASTC_8x8_Format:
719
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
720
+ break;
693
721
 
694
- case RGBA_ASTC_10x6_Format:
695
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
696
- break;
722
+ case RGBA_ASTC_10x5_Format:
723
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
724
+ break;
697
725
 
698
- case RGBA_ASTC_10x8_Format:
699
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
700
- break;
726
+ case RGBA_ASTC_10x6_Format:
727
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
728
+ break;
701
729
 
702
- case RGBA_ASTC_10x10_Format:
703
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
704
- break;
730
+ case RGBA_ASTC_10x8_Format:
731
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
732
+ break;
705
733
 
706
- case RGBA_ASTC_12x10_Format:
707
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
708
- break;
734
+ case RGBA_ASTC_10x10_Format:
735
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
736
+ break;
709
737
 
710
- case RGBA_ASTC_12x12_Format:
711
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
712
- break;
738
+ case RGBA_ASTC_12x10_Format:
739
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
740
+ break;
713
741
 
714
- default:
715
- console.error( 'WebGPURenderer: Unsupported texture format.', format );
742
+ case RGBA_ASTC_12x12_Format:
743
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
744
+ break;
716
745
 
717
- }
746
+ default:
747
+ console.error( 'WebGPURenderer: Unsupported texture format.', format );
718
748
 
719
- } else {
749
+ }
720
750
 
721
- switch ( format ) {
751
+ } else {
722
752
 
723
- case RGBAFormat:
753
+ switch ( format ) {
724
754
 
725
- switch ( type ) {
755
+ case RGBAFormat:
726
756
 
727
- case UnsignedByteType:
728
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
729
- break;
757
+ switch ( type ) {
730
758
 
731
- case HalfFloatType:
732
- formatGPU = GPUTextureFormat.RGBA16Float;
733
- break;
759
+ case UnsignedByteType:
760
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
761
+ break;
734
762
 
735
- case FloatType:
736
- formatGPU = GPUTextureFormat.RGBA32Float;
737
- break;
763
+ case HalfFloatType:
764
+ formatGPU = GPUTextureFormat.RGBA16Float;
765
+ break;
738
766
 
739
- default:
740
- console.error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
767
+ case FloatType:
768
+ formatGPU = GPUTextureFormat.RGBA32Float;
769
+ break;
741
770
 
742
- }
771
+ default:
772
+ console.error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
743
773
 
744
- break;
774
+ }
745
775
 
746
- case RedFormat:
776
+ break;
747
777
 
748
- switch ( type ) {
778
+ case RedFormat:
749
779
 
750
- case UnsignedByteType:
751
- formatGPU = GPUTextureFormat.R8Unorm;
752
- break;
780
+ switch ( type ) {
753
781
 
754
- case HalfFloatType:
755
- formatGPU = GPUTextureFormat.R16Float;
756
- break;
782
+ case UnsignedByteType:
783
+ formatGPU = GPUTextureFormat.R8Unorm;
784
+ break;
757
785
 
758
- case FloatType:
759
- formatGPU = GPUTextureFormat.R32Float;
760
- break;
786
+ case HalfFloatType:
787
+ formatGPU = GPUTextureFormat.R16Float;
788
+ break;
761
789
 
762
- default:
763
- console.error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
790
+ case FloatType:
791
+ formatGPU = GPUTextureFormat.R32Float;
792
+ break;
764
793
 
765
- }
794
+ default:
795
+ console.error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
766
796
 
767
- break;
797
+ }
768
798
 
769
- case RGFormat:
799
+ break;
770
800
 
771
- switch ( type ) {
801
+ case RGFormat:
772
802
 
773
- case UnsignedByteType:
774
- formatGPU = GPUTextureFormat.RG8Unorm;
775
- break;
803
+ switch ( type ) {
776
804
 
777
- case HalfFloatType:
778
- formatGPU = GPUTextureFormat.RG16Float;
779
- break;
805
+ case UnsignedByteType:
806
+ formatGPU = GPUTextureFormat.RG8Unorm;
807
+ break;
780
808
 
781
- case FloatType:
782
- formatGPU = GPUTextureFormat.RG32Float;
783
- break;
809
+ case HalfFloatType:
810
+ formatGPU = GPUTextureFormat.RG16Float;
811
+ break;
784
812
 
785
- default:
786
- console.error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
813
+ case FloatType:
814
+ formatGPU = GPUTextureFormat.RG32Float;
815
+ break;
787
816
 
788
- }
817
+ default:
818
+ console.error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
789
819
 
790
- break;
820
+ }
791
821
 
792
- case DepthFormat:
822
+ break;
793
823
 
794
- switch ( type ) {
824
+ case DepthFormat:
795
825
 
796
- case UnsignedShortType:
797
- formatGPU = GPUTextureFormat.Depth16Unorm;
798
- break;
826
+ switch ( type ) {
799
827
 
800
- case UnsignedIntType:
801
- formatGPU = GPUTextureFormat.Depth24Plus;
802
- break;
828
+ case UnsignedShortType:
829
+ formatGPU = GPUTextureFormat.Depth16Unorm;
830
+ break;
803
831
 
804
- case FloatType:
805
- formatGPU = GPUTextureFormat.Depth32Float;
806
- break;
832
+ case UnsignedIntType:
833
+ formatGPU = GPUTextureFormat.Depth24Plus;
834
+ break;
807
835
 
808
- default:
809
- console.error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
836
+ case FloatType:
837
+ formatGPU = GPUTextureFormat.Depth32Float;
838
+ break;
810
839
 
811
- }
840
+ default:
841
+ console.error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
812
842
 
813
- break;
843
+ }
814
844
 
815
- case DepthStencilFormat:
845
+ break;
816
846
 
817
- switch ( type ) {
847
+ case DepthStencilFormat:
818
848
 
819
- case UnsignedInt248Type:
820
- formatGPU = GPUTextureFormat.Depth24PlusStencil8;
821
- break;
849
+ switch ( type ) {
822
850
 
823
- case FloatType:
851
+ case UnsignedInt248Type:
852
+ formatGPU = GPUTextureFormat.Depth24PlusStencil8;
853
+ break;
824
854
 
825
- if ( this.device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {
855
+ case FloatType:
826
856
 
827
- console.error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );
857
+ if ( device && device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {
828
858
 
829
- }
859
+ console.error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );
830
860
 
831
- formatGPU = GPUTextureFormat.Depth32FloatStencil8;
861
+ }
832
862
 
833
- break;
863
+ formatGPU = GPUTextureFormat.Depth32FloatStencil8;
834
864
 
835
- default:
836
- console.error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
865
+ break;
837
866
 
838
- }
867
+ default:
868
+ console.error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
839
869
 
840
- break;
870
+ }
841
871
 
842
- default:
843
- console.error( 'WebGPURenderer: Unsupported texture format.', format );
872
+ break;
844
873
 
845
- }
874
+ default:
875
+ console.error( 'WebGPURenderer: Unsupported texture format.', format );
846
876
 
847
877
  }
848
878
 
849
- return formatGPU;
850
-
851
879
  }
852
880
 
881
+ return formatGPU;
882
+
853
883
  }
854
884
 
855
885
  export default WebGPUTextureUtils;
@@ -34,7 +34,7 @@ const GammaCorrectionShader = {
34
34
 
35
35
  vec4 tex = texture2D( tDiffuse, vUv );
36
36
 
37
- gl_FragColor = LinearTosRGB( tex );
37
+ gl_FragColor = sRGBTransferOETF( tex );
38
38
 
39
39
  }`
40
40
 
@@ -27,17 +27,17 @@ struct BlinnPhongMaterial {
27
27
 
28
28
  };
29
29
 
30
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
30
+ void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
31
31
 
32
- vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
32
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
33
33
 
34
34
  reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
35
35
 
36
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
36
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
37
37
 
38
38
  }
39
39
 
40
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
40
+ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
41
41
 
42
42
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
43
43
 
@@ -65,9 +65,9 @@ const OutputShader = {
65
65
 
66
66
  // color space
67
67
 
68
- #ifdef SRGB_COLOR_SPACE
68
+ #ifdef SRGB_TRANSFER
69
69
 
70
- gl_FragColor = LinearTosRGB( gl_FragColor );
70
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
71
71
 
72
72
  #endif
73
73
 
@@ -57,10 +57,10 @@ const SubsurfaceScatteringShader = {
57
57
  'uniform float thicknessAttenuation;',
58
58
  'uniform vec3 thicknessColor;',
59
59
 
60
- 'void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in GeometricContext geometry, inout ReflectedLight reflectedLight) {',
60
+ 'void RE_Direct_Scattering(const in IncidentLight directLight, const in vec2 uv, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, inout ReflectedLight reflectedLight) {',
61
61
  ' vec3 thickness = thicknessColor * texture2D(thicknessMap, uv).r;',
62
- ' vec3 scatteringHalf = normalize(directLight.direction + (geometry.normal * thicknessDistortion));',
63
- ' float scatteringDot = pow(saturate(dot(geometry.viewDir, -scatteringHalf)), thicknessPower) * thicknessScale;',
62
+ ' vec3 scatteringHalf = normalize(directLight.direction + (geometryNormal * thicknessDistortion));',
63
+ ' float scatteringDot = pow(saturate(dot(geometryViewDir, -scatteringHalf)), thicknessPower) * thicknessScale;',
64
64
  ' vec3 scatteringIllu = (scatteringDot + thicknessAmbient) * thickness;',
65
65
  ' reflectedLight.directDiffuse += scatteringIllu * thicknessAttenuation * directLight.color;',
66
66
  '}',
@@ -69,12 +69,12 @@ const SubsurfaceScatteringShader = {
69
69
 
70
70
  replaceAll(
71
71
  ShaderChunk[ 'lights_fragment_begin' ],
72
- 'RE_Direct( directLight, geometry, material, reflectedLight );',
72
+ 'RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );',
73
73
  [
74
- 'RE_Direct( directLight, geometry, material, reflectedLight );',
74
+ 'RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );',
75
75
 
76
76
  '#if defined( SUBSURFACE ) && defined( USE_UV )',
77
- ' RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);',
77
+ ' RE_Direct_Scattering(directLight, vUv, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, reflectedLight);',
78
78
  '#endif',
79
79
  ].join( '\n' )
80
80
  ),
@@ -555,7 +555,7 @@ export function deinterleaveGeometry( geometry ) {
555
555
  }
556
556
 
557
557
  /**
558
- * @param {Array<BufferGeometry>} geometry
558
+ * @param {BufferGeometry} geometry
559
559
  * @return {number}
560
560
  */
561
561
  function estimateBytesUsed( geometry ) {
@@ -631,8 +631,10 @@ function mergeVertices( geometry, tolerance = 1e-4 ) {
631
631
  }
632
632
 
633
633
  // convert the error tolerance to an amount of decimal places to truncate to
634
- const decimalShift = Math.log10( 1 / tolerance );
635
- const shiftMultiplier = Math.pow( 10, decimalShift );
634
+ const halfTolerance = tolerance * 0.5;
635
+ const exponent = Math.log10( 1 / tolerance );
636
+ const hashMultiplier = Math.pow( 10, exponent );
637
+ const hashAdditive = halfTolerance * hashMultiplier;
636
638
  for ( let i = 0; i < vertexCount; i ++ ) {
637
639
 
638
640
  const index = indices ? indices.getX( i ) : i;
@@ -648,7 +650,7 @@ function mergeVertices( geometry, tolerance = 1e-4 ) {
648
650
  for ( let k = 0; k < itemSize; k ++ ) {
649
651
 
650
652
  // double tilde truncates the decimal value
651
- hash += `${ ~ ~ ( attribute[ getters[ k ] ]( index ) * shiftMultiplier ) },`;
653
+ hash += `${ ~ ~ ( attribute[ getters[ k ] ]( index ) * hashMultiplier + hashAdditive ) },`;
652
654
 
653
655
  }
654
656
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-three",
3
- "version": "0.156.0",
3
+ "version": "0.157.0",
4
4
  "description": "JavaScript 3D library",
5
5
  "type": "module",
6
6
  "main": "./build/three.js",