super-three 0.155.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 (268) hide show
  1. package/build/three.cjs +361 -324
  2. package/build/three.js +361 -324
  3. package/build/three.min.js +2 -2
  4. package/build/three.module.js +354 -323
  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/controls/OrbitControls.js +13 -5
  9. package/examples/jsm/csm/CSMShader.js +59 -21
  10. package/examples/jsm/exporters/EXRExporter.js +102 -24
  11. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  12. package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
  14. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  15. package/examples/jsm/libs/tween.module.js +790 -735
  16. package/examples/jsm/libs/utif.module.js +1644 -1558
  17. package/examples/jsm/lights/LightProbeGenerator.js +37 -3
  18. package/examples/jsm/lines/LineMaterial.js +90 -156
  19. package/examples/jsm/loaders/3DMLoader.js +378 -104
  20. package/examples/jsm/loaders/DDSLoader.js +46 -3
  21. package/examples/jsm/loaders/EXRLoader.js +4 -4
  22. package/examples/jsm/loaders/FBXLoader.js +2 -0
  23. package/examples/jsm/loaders/GLTFLoader.js +18 -8
  24. package/examples/jsm/loaders/KTX2Loader.js +126 -77
  25. package/examples/jsm/loaders/LDrawLoader.js +22 -16
  26. package/examples/jsm/loaders/LogLuvLoader.js +2 -2
  27. package/examples/jsm/loaders/MMDLoader.js +10 -7
  28. package/examples/jsm/loaders/RGBELoader.js +48 -66
  29. package/examples/jsm/loaders/STLLoader.js +7 -0
  30. package/examples/jsm/loaders/USDZLoader.js +215 -12
  31. package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
  32. package/examples/jsm/nodes/Nodes.js +8 -1
  33. package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +30 -4
  35. package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
  36. package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/CubeTextureNode.js +19 -4
  38. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +4 -5
  39. package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
  40. package/examples/jsm/nodes/accessors/LineMaterialNode.js +29 -0
  41. package/examples/jsm/nodes/accessors/MaterialNode.js +23 -13
  42. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +12 -9
  43. package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
  44. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
  45. package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
  46. package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
  47. package/examples/jsm/nodes/accessors/Object3DNode.js +3 -3
  48. package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
  49. package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
  50. package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
  51. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
  52. package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
  53. package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
  54. package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
  55. package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
  56. package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
  57. package/examples/jsm/nodes/accessors/TextureNode.js +18 -8
  58. package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
  59. package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
  60. package/examples/jsm/nodes/accessors/UVNode.js +1 -1
  61. package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
  62. package/examples/jsm/nodes/code/CodeNode.js +1 -1
  63. package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
  64. package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
  65. package/examples/jsm/nodes/code/FunctionNode.js +18 -7
  66. package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
  67. package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
  68. package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
  69. package/examples/jsm/nodes/core/AttributeNode.js +3 -3
  70. package/examples/jsm/nodes/core/BypassNode.js +1 -1
  71. package/examples/jsm/nodes/core/CacheNode.js +1 -1
  72. package/examples/jsm/nodes/core/ConstNode.js +1 -1
  73. package/examples/jsm/nodes/core/ContextNode.js +2 -2
  74. package/examples/jsm/nodes/core/IndexNode.js +1 -1
  75. package/examples/jsm/nodes/core/InputNode.js +1 -1
  76. package/examples/jsm/nodes/core/Node.js +45 -14
  77. package/examples/jsm/nodes/core/NodeBuilder.js +83 -15
  78. package/examples/jsm/nodes/core/NodeFrame.js +37 -14
  79. package/examples/jsm/nodes/core/NodeUniform.js +1 -1
  80. package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
  81. package/examples/jsm/nodes/core/PropertyNode.js +3 -1
  82. package/examples/jsm/nodes/core/StackNode.js +5 -5
  83. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  84. package/examples/jsm/nodes/core/TempNode.js +1 -1
  85. package/examples/jsm/nodes/core/UniformNode.js +3 -1
  86. package/examples/jsm/nodes/core/VarNode.js +1 -1
  87. package/examples/jsm/nodes/core/VaryingNode.js +1 -1
  88. package/examples/jsm/nodes/core/constants.js +1 -1
  89. package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
  90. package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
  91. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
  92. package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
  93. package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
  94. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  95. package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
  96. package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
  97. package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
  98. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
  99. package/examples/jsm/nodes/display/ViewportNode.js +21 -7
  100. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
  101. package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
  102. package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
  103. package/examples/jsm/nodes/fog/FogNode.js +2 -2
  104. package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
  105. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  106. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  107. package/examples/jsm/nodes/lighting/AONode.js +2 -2
  108. package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
  109. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
  110. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
  111. package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
  112. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
  113. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
  114. package/examples/jsm/nodes/lighting/LightNode.js +2 -2
  115. package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
  116. package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
  117. package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
  118. package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
  119. package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
  120. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
  121. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
  122. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  123. package/examples/jsm/nodes/materials/Materials.js +2 -0
  124. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
  125. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
  126. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
  127. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
  128. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  129. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
  130. package/examples/jsm/nodes/materials/NodeMaterial.js +39 -29
  131. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
  132. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  133. package/examples/jsm/nodes/math/CondNode.js +1 -1
  134. package/examples/jsm/nodes/math/HashNode.js +34 -0
  135. package/examples/jsm/nodes/math/MathNode.js +2 -2
  136. package/examples/jsm/nodes/math/OperatorNode.js +1 -1
  137. package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
  138. package/examples/jsm/nodes/shadernode/ShaderNode.js +85 -28
  139. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  140. package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
  141. package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
  142. package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
  143. package/examples/jsm/nodes/utils/JoinNode.js +1 -1
  144. package/examples/jsm/nodes/utils/LoopNode.js +11 -11
  145. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
  146. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  147. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  148. package/examples/jsm/nodes/utils/PackingNode.js +2 -2
  149. package/examples/jsm/nodes/utils/RemapNode.js +2 -2
  150. package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
  151. package/examples/jsm/nodes/utils/SetNode.js +62 -0
  152. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
  153. package/examples/jsm/nodes/utils/SplitNode.js +2 -2
  154. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
  155. package/examples/jsm/nodes/utils/TimerNode.js +2 -2
  156. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
  157. package/examples/jsm/objects/Sky.js +1 -3
  158. package/examples/jsm/postprocessing/FilmPass.js +3 -5
  159. package/examples/jsm/postprocessing/OutputPass.js +3 -2
  160. package/examples/jsm/postprocessing/RenderPass.js +30 -12
  161. package/examples/jsm/postprocessing/SAOPass.js +23 -98
  162. package/examples/jsm/postprocessing/SSAOPass.js +10 -30
  163. package/examples/jsm/renderers/common/Backend.js +11 -8
  164. package/examples/jsm/renderers/common/Background.js +2 -2
  165. package/examples/jsm/renderers/common/Binding.js +6 -0
  166. package/examples/jsm/renderers/common/Bindings.js +4 -5
  167. package/examples/jsm/renderers/common/Pipelines.js +9 -9
  168. package/examples/jsm/renderers/common/RenderContext.js +3 -0
  169. package/examples/jsm/renderers/common/RenderContexts.js +26 -1
  170. package/examples/jsm/renderers/common/RenderList.js +12 -4
  171. package/examples/jsm/renderers/common/RenderObject.js +43 -15
  172. package/examples/jsm/renderers/common/RenderObjects.js +8 -14
  173. package/examples/jsm/renderers/common/Renderer.js +52 -16
  174. package/examples/jsm/renderers/common/SampledTexture.js +6 -3
  175. package/examples/jsm/renderers/common/Sampler.js +1 -1
  176. package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
  177. package/examples/jsm/renderers/common/StorageTexture.js +19 -0
  178. package/examples/jsm/renderers/common/Textures.js +166 -21
  179. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
  180. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +21 -11
  181. package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -7
  182. package/examples/jsm/renderers/common/nodes/Nodes.js +79 -18
  183. package/examples/jsm/renderers/webgl/WebGLBackend.js +702 -0
  184. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +207 -20
  185. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
  186. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
  187. package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
  188. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +212 -0
  189. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
  190. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
  191. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +4 -4
  192. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +14 -2
  193. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +282 -43
  194. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
  195. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +93 -60
  196. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
  197. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
  198. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -14
  199. package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
  200. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +205 -284
  201. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
  202. package/examples/jsm/shaders/FilmShader.js +11 -54
  203. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  204. package/examples/jsm/shaders/MMDToonShader.js +4 -4
  205. package/examples/jsm/shaders/OutputShader.js +2 -2
  206. package/examples/jsm/shaders/SAOShader.js +0 -13
  207. package/examples/jsm/shaders/SSAOShader.js +33 -26
  208. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
  209. package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
  210. package/package.json +1 -1
  211. package/src/Three.js +1 -2
  212. package/src/animation/AnimationUtils.js +3 -20
  213. package/src/animation/KeyframeTrack.js +8 -8
  214. package/src/audio/Audio.js +6 -0
  215. package/src/cameras/Camera.js +1 -5
  216. package/src/cameras/CubeCamera.js +14 -8
  217. package/src/constants.js +10 -1
  218. package/src/core/Object3D.js +1 -14
  219. package/src/core/RenderTarget.js +16 -7
  220. package/src/core/UniformsGroup.js +2 -2
  221. package/src/extras/core/CurvePath.js +4 -1
  222. package/src/loaders/DataTextureLoader.js +0 -2
  223. package/src/loaders/MaterialLoader.js +1 -1
  224. package/src/loaders/ObjectLoader.js +6 -0
  225. package/src/materials/Material.js +10 -10
  226. package/src/math/Color.js +1 -5
  227. package/src/math/ColorManagement.js +82 -60
  228. package/src/math/Vector2.js +2 -2
  229. package/src/math/Vector3.js +3 -3
  230. package/src/math/Vector4.js +4 -4
  231. package/src/objects/Line.js +1 -1
  232. package/src/objects/Mesh.js +1 -1
  233. package/src/objects/Points.js +1 -1
  234. package/src/objects/Sprite.js +2 -2
  235. package/src/renderers/WebGLRenderer.js +42 -51
  236. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  237. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
  238. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
  239. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
  240. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
  241. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
  242. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
  243. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
  244. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
  245. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
  246. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
  247. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
  248. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
  249. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
  250. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
  251. package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
  252. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
  253. package/src/renderers/shaders/UniformsUtils.js +2 -2
  254. package/src/renderers/webgl/WebGLBackground.js +9 -17
  255. package/src/renderers/webgl/WebGLLights.js +14 -3
  256. package/src/renderers/webgl/WebGLProgram.js +36 -5
  257. package/src/renderers/webgl/WebGLPrograms.js +9 -1
  258. package/src/renderers/webgl/WebGLTextures.js +19 -8
  259. package/src/renderers/webgl/WebGLUtils.js +25 -20
  260. package/src/scenes/Fog.js +1 -0
  261. package/src/scenes/FogExp2.js +1 -0
  262. package/src/textures/Source.js +2 -2
  263. package/src/textures/Texture.js +2 -2
  264. package/src/utils.js +9 -1
  265. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
  266. package/src/lights/AmbientLightProbe.js +0 -21
  267. package/src/lights/HemisphereLightProbe.js +0 -30
  268. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
@@ -4,7 +4,7 @@ import {
4
4
 
5
5
  import {
6
6
  CubeTexture, Texture,
7
- NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter, LinearFilter,
7
+ NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
8
8
  RepeatWrapping, MirroredRepeatWrapping,
9
9
  RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
10
10
  RGBAFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
@@ -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;
@@ -97,18 +99,26 @@ class WebGPUTextureUtils {
97
99
 
98
100
  }
99
101
 
100
- const { width, height, depth } = this._getSize( texture );
102
+ if ( options.needsMipmaps === undefined ) options.needsMipmaps = false;
103
+ if ( options.levels === undefined ) options.levels = 1;
104
+ if ( options.depth === undefined ) options.depth = 1;
105
+
106
+ const { width, height, depth, levels } = options;
101
107
 
102
- const needsMipmaps = this._needsMipmaps( texture );
103
108
  const dimension = this._getDimension( texture );
104
- const mipLevelCount = this._getMipLevelCount( texture, width, height, needsMipmaps );
105
- const format = texture.internalFormat || this._getFormat( texture );
109
+ const format = texture.internalFormat || getFormat( texture, this.device );
106
110
 
107
111
  const sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
108
112
  const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
109
113
 
110
114
  let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
111
115
 
116
+ if ( texture.isStorageTexture === true ) {
117
+
118
+ usage |= GPUTextureUsage.STORAGE_BINDING;
119
+
120
+ }
121
+
112
122
  if ( texture.isCompressedTexture !== true ) {
113
123
 
114
124
  usage |= GPUTextureUsage.RENDER_ATTACHMENT;
@@ -122,7 +132,7 @@ class WebGPUTextureUtils {
122
132
  height: height,
123
133
  depthOrArrayLayers: depth,
124
134
  },
125
- mipLevelCount: mipLevelCount,
135
+ mipLevelCount: levels,
126
136
  sampleCount: primarySampleCount,
127
137
  dimension: dimension,
128
138
  format: format,
@@ -170,7 +180,6 @@ class WebGPUTextureUtils {
170
180
 
171
181
  textureData.initialized = true;
172
182
 
173
- textureData.needsMipmaps = needsMipmaps;
174
183
  textureData.textureDescriptorGPU = textureDescriptorGPU;
175
184
 
176
185
  }
@@ -217,20 +226,20 @@ class WebGPUTextureUtils {
217
226
 
218
227
  }
219
228
 
220
- updateTexture( texture ) {
229
+ updateTexture( texture, options ) {
221
230
 
222
231
  const textureData = this.backend.get( texture );
223
232
 
224
- const { needsMipmaps, textureDescriptorGPU } = textureData;
233
+ const { textureDescriptorGPU } = textureData;
225
234
 
226
- if ( textureDescriptorGPU === undefined ) // unsupported texture format
235
+ if ( texture.isRenderTargetTexture || ( textureDescriptorGPU === undefined /* unsupported texture format */ ) )
227
236
  return;
228
237
 
229
238
  // transfer texture data
230
239
 
231
240
  if ( texture.isDataTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
232
241
 
233
- this._copyBufferToTexture( texture.image, textureData.texture, textureDescriptorGPU, needsMipmaps );
242
+ this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, false );
234
243
 
235
244
  } else if ( texture.isCompressedTexture ) {
236
245
 
@@ -238,15 +247,7 @@ class WebGPUTextureUtils {
238
247
 
239
248
  } else if ( texture.isCubeTexture ) {
240
249
 
241
- if ( texture.image.length === 6 ) {
242
-
243
- this._copyCubeMapToTexture( texture.image, texture, textureData.texture, textureDescriptorGPU, needsMipmaps );
244
-
245
- }
246
-
247
- } else if ( texture.isRenderTargetTexture ) {
248
-
249
- if ( needsMipmaps === true ) this._generateMipmaps( textureData.texture, textureDescriptorGPU );
250
+ this._copyCubeMapToTexture( options.images, textureData.texture, textureDescriptorGPU, texture.flipY );
250
251
 
251
252
  } else if ( texture.isVideoTexture ) {
252
253
 
@@ -254,13 +255,9 @@ class WebGPUTextureUtils {
254
255
 
255
256
  textureData.externalTexture = video;
256
257
 
257
- } else if ( texture.image !== null ) {
258
-
259
- this._copyImageToTexture( texture.image, texture, textureData.texture, textureDescriptorGPU, needsMipmaps );
260
-
261
258
  } else {
262
259
 
263
- console.warn( 'WebGPUTextureUtils: Unable to update texture.' );
260
+ this._copyImageToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
264
261
 
265
262
  }
266
263
 
@@ -336,7 +333,7 @@ class WebGPUTextureUtils {
336
333
  texture.minFilter = NearestFilter;
337
334
  texture.magFilter = NearestFilter;
338
335
 
339
- this.createTexture( texture );
336
+ this.createTexture( texture, { width: 1, height: 1 } );
340
337
 
341
338
  this.defaultTexture = defaultTexture = texture;
342
339
 
@@ -356,7 +353,7 @@ class WebGPUTextureUtils {
356
353
  texture.minFilter = NearestFilter;
357
354
  texture.magFilter = NearestFilter;
358
355
 
359
- this.createTexture( texture );
356
+ this.createTexture( texture, { width: 1, height: 1, depth: 6 } );
360
357
 
361
358
  this.defaultCubeTexture = defaultCubeTexture = texture;
362
359
 
@@ -366,45 +363,21 @@ class WebGPUTextureUtils {
366
363
 
367
364
  }
368
365
 
369
- _copyImageToTexture( image, texture, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth ) {
370
-
371
- if ( this._isHTMLImage( image ) ) {
372
-
373
- this._getImageBitmapFromHTML( image, texture ).then( imageBitmap => {
374
-
375
- this._copyExternalImageToTexture( imageBitmap, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth );
376
-
377
- } );
378
-
379
- } else {
380
-
381
- // assume ImageBitmap
382
-
383
- this._copyExternalImageToTexture( image, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth );
384
-
385
- }
386
-
387
- }
388
-
389
- _isHTMLImage( image ) {
390
-
391
- return ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement );
392
-
393
- }
394
-
395
- _copyCubeMapToTexture( images, texture, textureGPU, textureDescriptorGPU, needsMipmaps ) {
366
+ _copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY ) {
396
367
 
397
368
  for ( let i = 0; i < 6; i ++ ) {
398
369
 
399
370
  const image = images[ i ];
400
371
 
372
+ const flipIndex = flipY === true ? _flipMap[ i ] : i;
373
+
401
374
  if ( image.isDataTexture ) {
402
375
 
403
- this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, needsMipmaps, i );
376
+ this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
404
377
 
405
378
  } else {
406
379
 
407
- this._copyImageToTexture( image, texture, textureGPU, textureDescriptorGPU, needsMipmaps, i );
380
+ this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
408
381
 
409
382
  }
410
383
 
@@ -412,7 +385,7 @@ class WebGPUTextureUtils {
412
385
 
413
386
  }
414
387
 
415
- _copyExternalImageToTexture( image, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth = 0 ) {
388
+ _copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY ) {
416
389
 
417
390
  const device = this.backend.device;
418
391
 
@@ -430,37 +403,41 @@ class WebGPUTextureUtils {
430
403
  }
431
404
  );
432
405
 
433
- if ( needsMipmaps ) this._generateMipmaps( textureGPU, textureDescriptorGPU, originDepth );
406
+ if ( flipY === true ) {
407
+
408
+ this._flipY( textureGPU, textureDescriptorGPU, originDepth );
409
+
410
+ }
434
411
 
435
412
  }
436
413
 
437
- _generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
414
+ _getPassUtils() {
415
+
416
+ let passUtils = this._passUtils;
438
417
 
439
- if ( this.mipmapUtils === null ) {
418
+ if ( passUtils === null ) {
440
419
 
441
- this.mipmapUtils = new WebGPUTextureMipmapUtils( this.backend.device );
420
+ this._passUtils = passUtils = new WebGPUTexturePassUtils( this.backend.device );
442
421
 
443
422
  }
444
423
 
445
- this.mipmapUtils.generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
424
+ return passUtils;
446
425
 
447
426
  }
448
427
 
449
- _getImageBitmapFromHTML( image, texture ) {
428
+ _generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
450
429
 
451
- const width = image.width;
452
- const height = image.height;
430
+ this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
453
431
 
454
- const options = {};
432
+ }
455
433
 
456
- options.imageOrientation = ( texture.flipY === true ) ? 'flipY' : 'none';
457
- options.premultiplyAlpha = ( texture.premultiplyAlpha === true ) ? 'premultiply' : 'default';
434
+ _flipY( textureGPU, textureDescriptorGPU, originDepth = 0 ) {
458
435
 
459
- return createImageBitmap( image, 0, 0, width, height, options );
436
+ this._getPassUtils().flipY( textureGPU, textureDescriptorGPU, originDepth );
460
437
 
461
438
  }
462
439
 
463
- _copyBufferToTexture( image, textureGPU, textureDescriptorGPU, needsMipmaps, originDepth = 0 ) {
440
+ _copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY ) {
464
441
 
465
442
  // @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
466
443
  // @TODO: Consider to support valid buffer layouts with other formats like RGB
@@ -489,7 +466,11 @@ class WebGPUTextureUtils {
489
466
  depthOrArrayLayers: ( image.depth !== undefined ) ? image.depth : 1
490
467
  } );
491
468
 
492
- if ( needsMipmaps === true ) this._generateMipmaps( textureGPU, textureDescriptorGPU, originDepth );
469
+ if ( flipY === true ) {
470
+
471
+ this._flipY( textureGPU, textureDescriptorGPU, originDepth );
472
+
473
+ }
493
474
 
494
475
  }
495
476
 
@@ -600,44 +581,6 @@ class WebGPUTextureUtils {
600
581
 
601
582
  }
602
583
 
603
- _getSize( texture ) {
604
-
605
- const image = texture.image;
606
-
607
- let width, height, depth;
608
-
609
- if ( texture.isCubeTexture ) {
610
-
611
- const faceImage = image.length > 0 ? image[ 0 ].image || image[ 0 ] : null;
612
-
613
- width = faceImage ? faceImage.width : 1;
614
- height = faceImage ? faceImage.height : 1;
615
- depth = 6; // one image for each side of the cube map
616
-
617
- } else if ( image !== null ) {
618
-
619
- width = image.width;
620
- height = image.height;
621
- depth = ( image.depth !== undefined ) ? image.depth : 1;
622
-
623
- } else {
624
-
625
- width = height = depth = 1;
626
-
627
- }
628
-
629
- return { width, height, depth };
630
-
631
- }
632
-
633
- _needsMipmaps( texture ) {
634
-
635
- if ( this._isEnvironmentTexture( texture ) ) return true;
636
-
637
- return ( texture.isCompressedTexture !== true ) /*&& ( texture.generateMipmaps === true )*/ && ( texture.minFilter !== NearestFilter ) && ( texture.minFilter !== LinearFilter );
638
-
639
- }
640
-
641
584
  _getBytesPerTexel( format ) {
642
585
 
643
586
  if ( format === GPUTextureFormat.R8Unorm ) return 1;
@@ -706,259 +649,237 @@ class WebGPUTextureUtils {
706
649
 
707
650
  }
708
651
 
709
- _getMipLevelCount( texture, width, height, needsMipmaps ) {
710
-
711
- let mipLevelCount;
712
-
713
- if ( texture.isCompressedTexture ) {
714
-
715
- mipLevelCount = texture.mipmaps.length;
716
-
717
- } else if ( needsMipmaps ) {
718
-
719
- mipLevelCount = Math.floor( Math.log2( Math.max( width, height ) ) ) + 1;
720
-
721
- } else {
722
-
723
- mipLevelCount = 1; // a texture without mipmaps has a base mip (mipLevel 0)
724
-
725
- }
726
-
727
- return mipLevelCount;
728
-
729
- }
730
-
731
- _getFormat( texture ) {
652
+ }
732
653
 
733
- const format = texture.format;
734
- const type = texture.type;
735
- const colorSpace = texture.colorSpace;
654
+ export function getFormat( texture, device = null ) {
736
655
 
737
- let formatGPU;
656
+ const format = texture.format;
657
+ const type = texture.type;
658
+ const colorSpace = texture.colorSpace;
738
659
 
739
- if ( /*texture.isRenderTargetTexture === true ||*/ texture.isFramebufferTexture === true ) {
660
+ let formatGPU;
740
661
 
741
- formatGPU = GPUTextureFormat.BGRA8Unorm;
662
+ if ( /*texture.isRenderTargetTexture === true ||*/ texture.isFramebufferTexture === true ) {
742
663
 
743
- } else if ( texture.isCompressedTexture === true ) {
664
+ formatGPU = GPUTextureFormat.BGRA8Unorm;
744
665
 
745
- switch ( format ) {
666
+ } else if ( texture.isCompressedTexture === true ) {
746
667
 
747
- case RGBA_S3TC_DXT1_Format:
748
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
749
- break;
668
+ switch ( format ) {
750
669
 
751
- case RGBA_S3TC_DXT3_Format:
752
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
753
- break;
670
+ case RGBA_S3TC_DXT1_Format:
671
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
672
+ break;
754
673
 
755
- case RGBA_S3TC_DXT5_Format:
756
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
757
- break;
674
+ case RGBA_S3TC_DXT3_Format:
675
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
676
+ break;
758
677
 
759
- case RGB_ETC2_Format:
760
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
761
- break;
678
+ case RGBA_S3TC_DXT5_Format:
679
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
680
+ break;
762
681
 
763
- case RGBA_ETC2_EAC_Format:
764
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
765
- break;
682
+ case RGB_ETC2_Format:
683
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
684
+ break;
766
685
 
767
- case RGBA_ASTC_4x4_Format:
768
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
769
- break;
686
+ case RGBA_ETC2_EAC_Format:
687
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
688
+ break;
770
689
 
771
- case RGBA_ASTC_5x4_Format:
772
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
773
- break;
690
+ case RGBA_ASTC_4x4_Format:
691
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
692
+ break;
774
693
 
775
- case RGBA_ASTC_5x5_Format:
776
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
777
- break;
694
+ case RGBA_ASTC_5x4_Format:
695
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
696
+ break;
778
697
 
779
- case RGBA_ASTC_6x5_Format:
780
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
781
- break;
698
+ case RGBA_ASTC_5x5_Format:
699
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
700
+ break;
782
701
 
783
- case RGBA_ASTC_6x6_Format:
784
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
785
- break;
702
+ case RGBA_ASTC_6x5_Format:
703
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
704
+ break;
786
705
 
787
- case RGBA_ASTC_8x5_Format:
788
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
789
- break;
706
+ case RGBA_ASTC_6x6_Format:
707
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
708
+ break;
790
709
 
791
- case RGBA_ASTC_8x6_Format:
792
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
793
- break;
710
+ case RGBA_ASTC_8x5_Format:
711
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
712
+ break;
794
713
 
795
- case RGBA_ASTC_8x8_Format:
796
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
797
- break;
714
+ case RGBA_ASTC_8x6_Format:
715
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
716
+ break;
798
717
 
799
- case RGBA_ASTC_10x5_Format:
800
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
801
- break;
718
+ case RGBA_ASTC_8x8_Format:
719
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
720
+ break;
802
721
 
803
- case RGBA_ASTC_10x6_Format:
804
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
805
- break;
722
+ case RGBA_ASTC_10x5_Format:
723
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
724
+ break;
806
725
 
807
- case RGBA_ASTC_10x8_Format:
808
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
809
- break;
726
+ case RGBA_ASTC_10x6_Format:
727
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
728
+ break;
810
729
 
811
- case RGBA_ASTC_10x10_Format:
812
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
813
- break;
730
+ case RGBA_ASTC_10x8_Format:
731
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
732
+ break;
814
733
 
815
- case RGBA_ASTC_12x10_Format:
816
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
817
- break;
734
+ case RGBA_ASTC_10x10_Format:
735
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
736
+ break;
818
737
 
819
- case RGBA_ASTC_12x12_Format:
820
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
821
- break;
738
+ case RGBA_ASTC_12x10_Format:
739
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
740
+ break;
822
741
 
823
- default:
824
- console.error( 'WebGPURenderer: Unsupported texture format.', format );
742
+ case RGBA_ASTC_12x12_Format:
743
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
744
+ break;
825
745
 
826
- }
746
+ default:
747
+ console.error( 'WebGPURenderer: Unsupported texture format.', format );
827
748
 
828
- } else {
749
+ }
829
750
 
830
- switch ( format ) {
751
+ } else {
831
752
 
832
- case RGBAFormat:
753
+ switch ( format ) {
833
754
 
834
- switch ( type ) {
755
+ case RGBAFormat:
835
756
 
836
- case UnsignedByteType:
837
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
838
- break;
757
+ switch ( type ) {
839
758
 
840
- case HalfFloatType:
841
- formatGPU = GPUTextureFormat.RGBA16Float;
842
- break;
759
+ case UnsignedByteType:
760
+ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
761
+ break;
843
762
 
844
- case FloatType:
845
- formatGPU = GPUTextureFormat.RGBA32Float;
846
- break;
763
+ case HalfFloatType:
764
+ formatGPU = GPUTextureFormat.RGBA16Float;
765
+ break;
847
766
 
848
- default:
849
- console.error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
767
+ case FloatType:
768
+ formatGPU = GPUTextureFormat.RGBA32Float;
769
+ break;
850
770
 
851
- }
771
+ default:
772
+ console.error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
852
773
 
853
- break;
774
+ }
854
775
 
855
- case RedFormat:
776
+ break;
856
777
 
857
- switch ( type ) {
778
+ case RedFormat:
858
779
 
859
- case UnsignedByteType:
860
- formatGPU = GPUTextureFormat.R8Unorm;
861
- break;
780
+ switch ( type ) {
862
781
 
863
- case HalfFloatType:
864
- formatGPU = GPUTextureFormat.R16Float;
865
- break;
782
+ case UnsignedByteType:
783
+ formatGPU = GPUTextureFormat.R8Unorm;
784
+ break;
866
785
 
867
- case FloatType:
868
- formatGPU = GPUTextureFormat.R32Float;
869
- break;
786
+ case HalfFloatType:
787
+ formatGPU = GPUTextureFormat.R16Float;
788
+ break;
870
789
 
871
- default:
872
- console.error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
790
+ case FloatType:
791
+ formatGPU = GPUTextureFormat.R32Float;
792
+ break;
873
793
 
874
- }
794
+ default:
795
+ console.error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
875
796
 
876
- break;
797
+ }
877
798
 
878
- case RGFormat:
799
+ break;
879
800
 
880
- switch ( type ) {
801
+ case RGFormat:
881
802
 
882
- case UnsignedByteType:
883
- formatGPU = GPUTextureFormat.RG8Unorm;
884
- break;
803
+ switch ( type ) {
885
804
 
886
- case HalfFloatType:
887
- formatGPU = GPUTextureFormat.RG16Float;
888
- break;
805
+ case UnsignedByteType:
806
+ formatGPU = GPUTextureFormat.RG8Unorm;
807
+ break;
889
808
 
890
- case FloatType:
891
- formatGPU = GPUTextureFormat.RG32Float;
892
- break;
809
+ case HalfFloatType:
810
+ formatGPU = GPUTextureFormat.RG16Float;
811
+ break;
893
812
 
894
- default:
895
- console.error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
813
+ case FloatType:
814
+ formatGPU = GPUTextureFormat.RG32Float;
815
+ break;
896
816
 
897
- }
817
+ default:
818
+ console.error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
898
819
 
899
- break;
820
+ }
900
821
 
901
- case DepthFormat:
822
+ break;
902
823
 
903
- switch ( type ) {
824
+ case DepthFormat:
904
825
 
905
- case UnsignedShortType:
906
- formatGPU = GPUTextureFormat.Depth16Unorm;
907
- break;
826
+ switch ( type ) {
908
827
 
909
- case UnsignedIntType:
910
- formatGPU = GPUTextureFormat.Depth24Plus;
911
- break;
828
+ case UnsignedShortType:
829
+ formatGPU = GPUTextureFormat.Depth16Unorm;
830
+ break;
912
831
 
913
- case FloatType:
914
- formatGPU = GPUTextureFormat.Depth32Float;
915
- break;
832
+ case UnsignedIntType:
833
+ formatGPU = GPUTextureFormat.Depth24Plus;
834
+ break;
916
835
 
917
- default:
918
- console.error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
836
+ case FloatType:
837
+ formatGPU = GPUTextureFormat.Depth32Float;
838
+ break;
919
839
 
920
- }
840
+ default:
841
+ console.error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
921
842
 
922
- break;
843
+ }
923
844
 
924
- case DepthStencilFormat:
845
+ break;
925
846
 
926
- switch ( type ) {
847
+ case DepthStencilFormat:
927
848
 
928
- case UnsignedInt248Type:
929
- formatGPU = GPUTextureFormat.Depth24PlusStencil8;
930
- break;
849
+ switch ( type ) {
931
850
 
932
- case FloatType:
851
+ case UnsignedInt248Type:
852
+ formatGPU = GPUTextureFormat.Depth24PlusStencil8;
853
+ break;
933
854
 
934
- if ( this.device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {
855
+ case FloatType:
935
856
 
936
- 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 ) {
937
858
 
938
- }
859
+ console.error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );
939
860
 
940
- formatGPU = GPUTextureFormat.Depth32FloatStencil8;
861
+ }
941
862
 
942
- break;
863
+ formatGPU = GPUTextureFormat.Depth32FloatStencil8;
943
864
 
944
- default:
945
- console.error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
865
+ break;
946
866
 
947
- }
867
+ default:
868
+ console.error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
948
869
 
949
- break;
870
+ }
950
871
 
951
- default:
952
- console.error( 'WebGPURenderer: Unsupported texture format.', format );
872
+ break;
953
873
 
954
- }
874
+ default:
875
+ console.error( 'WebGPURenderer: Unsupported texture format.', format );
955
876
 
956
877
  }
957
878
 
958
- return formatGPU;
959
-
960
879
  }
961
880
 
881
+ return formatGPU;
882
+
962
883
  }
963
884
 
964
885
  export default WebGPUTextureUtils;