@plastic-software/three 0.179.0 → 0.180.1

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 (173) hide show
  1. package/build/three.cjs +167 -107
  2. package/build/three.core.js +112 -20
  3. package/build/three.core.min.js +1 -1
  4. package/build/three.module.js +56 -90
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +30 -5
  7. package/build/three.tsl.min.js +1 -1
  8. package/build/three.webgpu.js +2896 -1048
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2896 -1048
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +1 -1
  13. package/examples/jsm/controls/ArcballControls.js +7 -7
  14. package/examples/jsm/controls/DragControls.js +6 -56
  15. package/examples/jsm/controls/FirstPersonControls.js +2 -2
  16. package/examples/jsm/controls/PointerLockControls.js +0 -8
  17. package/examples/jsm/exporters/GLTFExporter.js +30 -22
  18. package/examples/jsm/exporters/KTX2Exporter.js +4 -2
  19. package/examples/jsm/exporters/PLYExporter.js +1 -1
  20. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  21. package/examples/jsm/lines/Line2.js +3 -3
  22. package/examples/jsm/lines/LineGeometry.js +1 -1
  23. package/examples/jsm/lines/LineSegments2.js +2 -2
  24. package/examples/jsm/lines/Wireframe.js +2 -2
  25. package/examples/jsm/lines/WireframeGeometry2.js +1 -1
  26. package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
  27. package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
  28. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  29. package/examples/jsm/loaders/EXRLoader.js +5 -5
  30. package/examples/jsm/loaders/GLTFLoader.js +9 -5
  31. package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
  32. package/examples/jsm/loaders/HDRLoader.js +486 -0
  33. package/examples/jsm/loaders/KTX2Loader.js +112 -32
  34. package/examples/jsm/loaders/RGBELoader.js +7 -473
  35. package/examples/jsm/loaders/TTFLoader.js +4 -4
  36. package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
  37. package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
  38. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  39. package/examples/jsm/math/ColorSpaces.js +19 -1
  40. package/examples/jsm/math/ConvexHull.js +2 -2
  41. package/examples/jsm/math/Lut.js +2 -2
  42. package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
  43. package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
  44. package/examples/jsm/misc/Volume.js +1 -1
  45. package/examples/jsm/postprocessing/OutlinePass.js +1 -1
  46. package/examples/jsm/postprocessing/SSRPass.js +37 -8
  47. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
  48. package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
  49. package/examples/jsm/transpiler/TSLEncoder.js +2 -10
  50. package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
  51. package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
  52. package/examples/jsm/tsl/display/BloomNode.js +3 -3
  53. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
  54. package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
  55. package/examples/jsm/tsl/display/GTAONode.js +8 -0
  56. package/examples/jsm/tsl/display/GaussianBlurNode.js +47 -35
  57. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  58. package/examples/jsm/tsl/display/SSRNode.js +180 -65
  59. package/examples/jsm/tsl/display/TRAANode.js +1 -1
  60. package/examples/jsm/tsl/display/boxBlur.js +64 -0
  61. package/examples/jsm/tsl/display/hashBlur.js +15 -18
  62. package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
  63. package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
  64. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  65. package/package.json +1 -1
  66. package/src/Three.Core.js +1 -0
  67. package/src/Three.TSL.js +29 -4
  68. package/src/animation/AnimationClip.js +17 -2
  69. package/src/constants.js +11 -3
  70. package/src/core/BufferGeometry.js +2 -2
  71. package/src/extras/TextureUtils.js +2 -1
  72. package/src/extras/lib/earcut.js +1 -1
  73. package/src/lights/webgpu/ProjectorLight.js +1 -1
  74. package/src/materials/Material.js +12 -0
  75. package/src/materials/MeshDistanceMaterial.js +1 -1
  76. package/src/materials/nodes/PointsNodeMaterial.js +81 -28
  77. package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
  78. package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
  79. package/src/math/ColorManagement.js +7 -1
  80. package/src/nodes/Nodes.js +3 -0
  81. package/src/nodes/TSL.js +3 -0
  82. package/src/nodes/accessors/BufferNode.js +1 -1
  83. package/src/nodes/accessors/Camera.js +133 -7
  84. package/src/nodes/accessors/ClippingNode.js +6 -5
  85. package/src/nodes/accessors/CubeTextureNode.js +2 -2
  86. package/src/nodes/accessors/InstanceNode.js +3 -1
  87. package/src/nodes/accessors/Object3DNode.js +1 -1
  88. package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
  89. package/src/nodes/accessors/ReferenceNode.js +1 -1
  90. package/src/nodes/accessors/Texture3DNode.js +13 -0
  91. package/src/nodes/accessors/TextureNode.js +71 -19
  92. package/src/nodes/code/FunctionCallNode.js +19 -0
  93. package/src/nodes/code/FunctionNode.js +23 -0
  94. package/src/nodes/core/AssignNode.js +4 -3
  95. package/src/nodes/core/ContextNode.js +24 -0
  96. package/src/nodes/core/Node.js +16 -20
  97. package/src/nodes/core/NodeBuilder.js +48 -14
  98. package/src/nodes/core/NodeFrame.js +1 -1
  99. package/src/nodes/core/NodeUniform.js +1 -1
  100. package/src/nodes/core/NodeUtils.js +1 -2
  101. package/src/nodes/core/StackNode.js +29 -4
  102. package/src/nodes/core/StructNode.js +5 -5
  103. package/src/nodes/core/StructTypeNode.js +1 -0
  104. package/src/nodes/core/SubBuildNode.js +2 -2
  105. package/src/nodes/core/UniformNode.js +16 -9
  106. package/src/nodes/core/VarNode.js +0 -21
  107. package/src/nodes/display/FrontFacingNode.js +4 -8
  108. package/src/nodes/display/PassNode.js +1 -1
  109. package/src/nodes/display/ScreenNode.js +42 -13
  110. package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
  111. package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
  112. package/src/nodes/display/ViewportTextureNode.js +42 -12
  113. package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
  114. package/src/nodes/lighting/LightsNode.js +1 -1
  115. package/src/nodes/math/BitcastNode.js +156 -0
  116. package/src/nodes/math/ConditionalNode.js +18 -2
  117. package/src/nodes/math/MathNode.js +3 -15
  118. package/src/nodes/math/OperatorNode.js +4 -3
  119. package/src/nodes/tsl/TSLCore.js +432 -152
  120. package/src/nodes/utils/JoinNode.js +3 -1
  121. package/src/nodes/utils/MemberNode.js +58 -7
  122. package/src/nodes/utils/RTTNode.js +1 -1
  123. package/src/nodes/utils/ReflectorNode.js +51 -7
  124. package/src/nodes/utils/SampleNode.js +12 -2
  125. package/src/nodes/utils/SplitNode.js +11 -0
  126. package/src/nodes/utils/Timer.js +0 -47
  127. package/src/objects/BatchedMesh.js +2 -2
  128. package/src/objects/LOD.js +1 -1
  129. package/src/objects/Sprite.js +2 -2
  130. package/src/renderers/WebGLRenderer.js +1 -10
  131. package/src/renderers/common/Attributes.js +1 -1
  132. package/src/renderers/common/Backend.js +19 -1
  133. package/src/renderers/common/Bindings.js +2 -0
  134. package/src/renderers/common/ChainMap.js +1 -1
  135. package/src/renderers/common/DataMap.js +1 -1
  136. package/src/renderers/common/Pipelines.js +1 -1
  137. package/src/renderers/common/RenderContext.js +2 -2
  138. package/src/renderers/common/RenderObject.js +14 -2
  139. package/src/renderers/common/Renderer.js +39 -19
  140. package/src/renderers/common/SampledTexture.js +1 -1
  141. package/src/renderers/common/Sampler.js +25 -13
  142. package/src/renderers/common/Textures.js +34 -12
  143. package/src/renderers/common/TimestampQueryPool.js +3 -3
  144. package/src/renderers/common/XRManager.js +35 -19
  145. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  146. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  147. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
  148. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  149. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
  150. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
  151. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
  152. package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
  153. package/src/renderers/webgl/WebGLProgram.js +4 -4
  154. package/src/renderers/webgl/WebGLShadowMap.js +1 -1
  155. package/src/renderers/webgl/WebGLTextures.js +1 -0
  156. package/src/renderers/webgl/WebGLUtils.js +3 -2
  157. package/src/renderers/webgl-fallback/WebGLBackend.js +186 -135
  158. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +110 -17
  159. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
  160. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
  161. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
  162. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
  163. package/src/renderers/webgpu/WebGPUBackend.js +35 -31
  164. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +124 -34
  165. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
  166. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +9 -18
  167. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +114 -25
  168. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
  169. package/src/renderers/webxr/WebXRManager.js +39 -24
  170. package/src/textures/ExternalTexture.js +15 -4
  171. package/src/textures/Source.js +1 -1
  172. package/src/textures/VideoTexture.js +0 -3
  173. package/examples/jsm/loaders/RGBMLoader.js +0 -1148
@@ -9,6 +9,8 @@ import {
9
9
  HalfFloatType,
10
10
  LinearFilter,
11
11
  LinearMipmapLinearFilter,
12
+ NearestFilter,
13
+ NearestMipmapNearestFilter,
12
14
  LinearSRGBColorSpace,
13
15
  Loader,
14
16
  NoColorSpace,
@@ -19,6 +21,7 @@ import {
19
21
  RGBA_S3TC_DXT3_Format,
20
22
  RGBA_ETC2_EAC_Format,
21
23
  RGBA_PVRTC_4BPPV1_Format,
24
+ RGBA_PVRTC_2BPPV1_Format,
22
25
  RGBA_S3TC_DXT1_Format,
23
26
  RGBA_S3TC_DXT5_Format,
24
27
  RGB_BPTC_UNSIGNED_Format,
@@ -26,10 +29,17 @@ import {
26
29
  RGB_ETC2_Format,
27
30
  RGB_PVRTC_4BPPV1_Format,
28
31
  RGB_S3TC_DXT1_Format,
32
+ SIGNED_RED_GREEN_RGTC2_Format,
33
+ SIGNED_RED_RGTC1_Format,
34
+ RED_GREEN_RGTC2_Format,
35
+ RED_RGTC1_Format,
36
+ RGBFormat,
29
37
  RGFormat,
30
38
  RedFormat,
31
39
  SRGBColorSpace,
32
- UnsignedByteType
40
+ UnsignedByteType,
41
+ UnsignedInt5999Type,
42
+ UnsignedInt101111Type
33
43
  } from 'three';
34
44
  import { WorkerPool } from '../utils/WorkerPool.js';
35
45
  import {
@@ -42,6 +52,7 @@ import {
42
52
  KHR_SUPERCOMPRESSION_NONE,
43
53
  KHR_SUPERCOMPRESSION_ZSTD,
44
54
  VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT,
55
+ VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT,
45
56
  VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
46
57
  VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
47
58
  VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
@@ -52,12 +63,18 @@ import {
52
63
  VK_FORMAT_BC1_RGB_UNORM_BLOCK,
53
64
  VK_FORMAT_BC3_SRGB_BLOCK,
54
65
  VK_FORMAT_BC3_UNORM_BLOCK,
66
+ VK_FORMAT_BC4_SNORM_BLOCK,
67
+ VK_FORMAT_BC4_UNORM_BLOCK,
55
68
  VK_FORMAT_BC5_SNORM_BLOCK,
56
69
  VK_FORMAT_BC5_UNORM_BLOCK,
57
70
  VK_FORMAT_BC7_SRGB_BLOCK,
58
71
  VK_FORMAT_BC7_UNORM_BLOCK,
59
72
  VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
60
73
  VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
74
+ VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG,
75
+ VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG,
76
+ VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG,
77
+ VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG,
61
78
  VK_FORMAT_R16G16B16A16_SFLOAT,
62
79
  VK_FORMAT_R16G16_SFLOAT,
63
80
  VK_FORMAT_R16_SFLOAT,
@@ -70,6 +87,8 @@ import {
70
87
  VK_FORMAT_R8G8_UNORM,
71
88
  VK_FORMAT_R8_SRGB,
72
89
  VK_FORMAT_R8_UNORM,
90
+ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
91
+ VK_FORMAT_B10G11R11_UFLOAT_PACK32,
73
92
  VK_FORMAT_UNDEFINED
74
93
  } from '../libs/ktx-parse.module.js';
75
94
  import { ZSTDDecoder } from '../libs/zstddec.module.js';
@@ -183,10 +202,10 @@ class KTX2Loader extends Loader {
183
202
  this.workerConfig = {
184
203
  astcSupported: await renderer.hasFeatureAsync( 'texture-compression-astc' ),
185
204
  astcHDRSupported: false, // https://github.com/gpuweb/gpuweb/issues/3856
186
- etc1Supported: await renderer.hasFeatureAsync( 'texture-compression-etc1' ),
205
+ etc1Supported: await renderer.hasFeatureAsync( 'texture-compression-etc2' ),
187
206
  etc2Supported: await renderer.hasFeatureAsync( 'texture-compression-etc2' ),
188
207
  dxtSupported: await renderer.hasFeatureAsync( 'texture-compression-bc' ),
189
- bptcSupported: await renderer.hasFeatureAsync( 'texture-compression-bptc' ),
208
+ bptcSupported: await renderer.hasFeatureAsync( 'texture-compression-bc' ),
190
209
  pvrtcSupported: await renderer.hasFeatureAsync( 'texture-compression-pvrtc' )
191
210
  };
192
211
 
@@ -208,10 +227,10 @@ class KTX2Loader extends Loader {
208
227
  this.workerConfig = {
209
228
  astcSupported: renderer.hasFeature( 'texture-compression-astc' ),
210
229
  astcHDRSupported: false, // https://github.com/gpuweb/gpuweb/issues/3856
211
- etc1Supported: renderer.hasFeature( 'texture-compression-etc1' ),
230
+ etc1Supported: renderer.hasFeature( 'texture-compression-etc2' ),
212
231
  etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ),
213
232
  dxtSupported: renderer.hasFeature( 'texture-compression-bc' ),
214
- bptcSupported: renderer.hasFeature( 'texture-compression-bptc' ),
233
+ bptcSupported: renderer.hasFeature( 'texture-compression-bc' ),
215
234
  pvrtcSupported: renderer.hasFeature( 'texture-compression-pvrtc' )
216
235
  };
217
236
 
@@ -918,74 +937,114 @@ KTX2Loader.BasisWorker = function () {
918
937
  // Parsing for non-Basis textures. These textures may have supercompression
919
938
  // like Zstd, but they do not require transcoding.
920
939
 
921
- const UNCOMPRESSED_FORMATS = new Set( [ RGBAFormat, RGFormat, RedFormat ] );
940
+ const UNCOMPRESSED_FORMATS = new Set( [ RGBAFormat, RGBFormat, RGFormat, RedFormat ] );
922
941
 
923
942
  const FORMAT_MAP = {
924
943
 
925
944
  [ VK_FORMAT_R32G32B32A32_SFLOAT ]: RGBAFormat,
926
- [ VK_FORMAT_R16G16B16A16_SFLOAT ]: RGBAFormat,
927
- [ VK_FORMAT_R8G8B8A8_UNORM ]: RGBAFormat,
928
- [ VK_FORMAT_R8G8B8A8_SRGB ]: RGBAFormat,
929
-
930
945
  [ VK_FORMAT_R32G32_SFLOAT ]: RGFormat,
931
- [ VK_FORMAT_R16G16_SFLOAT ]: RGFormat,
932
- [ VK_FORMAT_R8G8_UNORM ]: RGFormat,
933
- [ VK_FORMAT_R8G8_SRGB ]: RGFormat,
934
-
935
946
  [ VK_FORMAT_R32_SFLOAT ]: RedFormat,
947
+
948
+ [ VK_FORMAT_R16G16B16A16_SFLOAT ]: RGBAFormat,
949
+ [ VK_FORMAT_R16G16_SFLOAT ]: RGFormat,
936
950
  [ VK_FORMAT_R16_SFLOAT ]: RedFormat,
951
+
952
+ [ VK_FORMAT_R8G8B8A8_SRGB ]: RGBAFormat,
953
+ [ VK_FORMAT_R8G8B8A8_UNORM ]: RGBAFormat,
954
+ [ VK_FORMAT_R8G8_SRGB ]: RGFormat,
955
+ [ VK_FORMAT_R8G8_UNORM ]: RGFormat,
937
956
  [ VK_FORMAT_R8_SRGB ]: RedFormat,
938
957
  [ VK_FORMAT_R8_UNORM ]: RedFormat,
939
958
 
940
- [ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: RGB_ETC2_Format,
959
+ [ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 ]: RGBFormat,
960
+ [ VK_FORMAT_B10G11R11_UFLOAT_PACK32 ]: RGBFormat,
961
+
941
962
  [ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK ]: RGBA_ETC2_EAC_Format,
963
+ [ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: RGB_ETC2_Format,
942
964
 
943
965
  [ VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT ]: RGBA_ASTC_4x4_Format,
944
966
  [ VK_FORMAT_ASTC_4x4_SRGB_BLOCK ]: RGBA_ASTC_4x4_Format,
945
967
  [ VK_FORMAT_ASTC_4x4_UNORM_BLOCK ]: RGBA_ASTC_4x4_Format,
968
+ [ VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT ]: RGBA_ASTC_6x6_Format,
946
969
  [ VK_FORMAT_ASTC_6x6_SRGB_BLOCK ]: RGBA_ASTC_6x6_Format,
947
970
  [ VK_FORMAT_ASTC_6x6_UNORM_BLOCK ]: RGBA_ASTC_6x6_Format,
948
971
 
949
- [ VK_FORMAT_BC1_RGBA_UNORM_BLOCK ]: RGBA_S3TC_DXT1_Format,
950
972
  [ VK_FORMAT_BC1_RGBA_SRGB_BLOCK ]: RGBA_S3TC_DXT1_Format,
951
- [ VK_FORMAT_BC1_RGB_UNORM_BLOCK ]: RGB_S3TC_DXT1_Format,
973
+ [ VK_FORMAT_BC1_RGBA_UNORM_BLOCK ]: RGBA_S3TC_DXT1_Format,
952
974
  [ VK_FORMAT_BC1_RGB_SRGB_BLOCK ]: RGB_S3TC_DXT1_Format,
975
+ [ VK_FORMAT_BC1_RGB_UNORM_BLOCK ]: RGB_S3TC_DXT1_Format,
953
976
 
954
977
  [ VK_FORMAT_BC3_SRGB_BLOCK ]: RGBA_S3TC_DXT3_Format,
955
978
  [ VK_FORMAT_BC3_UNORM_BLOCK ]: RGBA_S3TC_DXT3_Format,
956
979
 
957
- [ VK_FORMAT_BC5_SNORM_BLOCK ]: RGBA_S3TC_DXT5_Format,
958
- [ VK_FORMAT_BC5_UNORM_BLOCK ]: RGBA_S3TC_DXT5_Format,
980
+ [ VK_FORMAT_BC4_SNORM_BLOCK ]: SIGNED_RED_RGTC1_Format,
981
+ [ VK_FORMAT_BC4_UNORM_BLOCK ]: RED_RGTC1_Format,
982
+
983
+ [ VK_FORMAT_BC5_SNORM_BLOCK ]: SIGNED_RED_GREEN_RGTC2_Format,
984
+ [ VK_FORMAT_BC5_UNORM_BLOCK ]: RED_GREEN_RGTC2_Format,
959
985
 
960
986
  [ VK_FORMAT_BC7_SRGB_BLOCK ]: RGBA_BPTC_Format,
961
987
  [ VK_FORMAT_BC7_UNORM_BLOCK ]: RGBA_BPTC_Format,
962
988
 
989
+ [ VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG ]: RGBA_PVRTC_4BPPV1_Format,
990
+ [ VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG ]: RGBA_PVRTC_4BPPV1_Format,
991
+ [ VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG ]: RGBA_PVRTC_2BPPV1_Format,
992
+ [ VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG ]: RGBA_PVRTC_2BPPV1_Format,
993
+
963
994
  };
964
995
 
965
996
  const TYPE_MAP = {
966
997
 
967
998
  [ VK_FORMAT_R32G32B32A32_SFLOAT ]: FloatType,
968
- [ VK_FORMAT_R16G16B16A16_SFLOAT ]: HalfFloatType,
969
- [ VK_FORMAT_R8G8B8A8_UNORM ]: UnsignedByteType,
970
- [ VK_FORMAT_R8G8B8A8_SRGB ]: UnsignedByteType,
971
-
972
999
  [ VK_FORMAT_R32G32_SFLOAT ]: FloatType,
973
- [ VK_FORMAT_R16G16_SFLOAT ]: HalfFloatType,
974
- [ VK_FORMAT_R8G8_UNORM ]: UnsignedByteType,
975
- [ VK_FORMAT_R8G8_SRGB ]: UnsignedByteType,
976
-
977
1000
  [ VK_FORMAT_R32_SFLOAT ]: FloatType,
1001
+
1002
+ [ VK_FORMAT_R16G16B16A16_SFLOAT ]: HalfFloatType,
1003
+ [ VK_FORMAT_R16G16_SFLOAT ]: HalfFloatType,
978
1004
  [ VK_FORMAT_R16_SFLOAT ]: HalfFloatType,
1005
+
1006
+ [ VK_FORMAT_R8G8B8A8_SRGB ]: UnsignedByteType,
1007
+ [ VK_FORMAT_R8G8B8A8_UNORM ]: UnsignedByteType,
1008
+ [ VK_FORMAT_R8G8_SRGB ]: UnsignedByteType,
1009
+ [ VK_FORMAT_R8G8_UNORM ]: UnsignedByteType,
979
1010
  [ VK_FORMAT_R8_SRGB ]: UnsignedByteType,
980
1011
  [ VK_FORMAT_R8_UNORM ]: UnsignedByteType,
981
1012
 
982
- [ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: UnsignedByteType,
1013
+ [ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 ]: UnsignedInt5999Type,
1014
+ [ VK_FORMAT_B10G11R11_UFLOAT_PACK32 ]: UnsignedInt101111Type,
1015
+
983
1016
  [ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK ]: UnsignedByteType,
1017
+ [ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK ]: UnsignedByteType,
984
1018
 
985
1019
  [ VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT ]: HalfFloatType,
1020
+ [ VK_FORMAT_ASTC_4x4_SRGB_BLOCK ]: UnsignedByteType,
1021
+ [ VK_FORMAT_ASTC_4x4_UNORM_BLOCK ]: UnsignedByteType,
1022
+ [ VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT ]: HalfFloatType,
986
1023
  [ VK_FORMAT_ASTC_6x6_SRGB_BLOCK ]: UnsignedByteType,
987
1024
  [ VK_FORMAT_ASTC_6x6_UNORM_BLOCK ]: UnsignedByteType,
988
1025
 
1026
+ [ VK_FORMAT_BC1_RGBA_SRGB_BLOCK ]: UnsignedByteType,
1027
+ [ VK_FORMAT_BC1_RGBA_UNORM_BLOCK ]: UnsignedByteType,
1028
+ [ VK_FORMAT_BC1_RGB_SRGB_BLOCK ]: UnsignedByteType,
1029
+ [ VK_FORMAT_BC1_RGB_UNORM_BLOCK ]: UnsignedByteType,
1030
+
1031
+ [ VK_FORMAT_BC3_SRGB_BLOCK ]: UnsignedByteType,
1032
+ [ VK_FORMAT_BC3_UNORM_BLOCK ]: UnsignedByteType,
1033
+
1034
+ [ VK_FORMAT_BC4_SNORM_BLOCK ]: UnsignedByteType,
1035
+ [ VK_FORMAT_BC4_UNORM_BLOCK ]: UnsignedByteType,
1036
+
1037
+ [ VK_FORMAT_BC5_SNORM_BLOCK ]: UnsignedByteType,
1038
+ [ VK_FORMAT_BC5_UNORM_BLOCK ]: UnsignedByteType,
1039
+
1040
+ [ VK_FORMAT_BC7_SRGB_BLOCK ]: UnsignedByteType,
1041
+ [ VK_FORMAT_BC7_UNORM_BLOCK ]: UnsignedByteType,
1042
+
1043
+ [ VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG ]: UnsignedByteType,
1044
+ [ VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG ]: UnsignedByteType,
1045
+ [ VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG ]: UnsignedByteType,
1046
+ [ VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG ]: UnsignedByteType,
1047
+
989
1048
  };
990
1049
 
991
1050
  async function createRawTexture( container ) {
@@ -994,7 +1053,14 @@ async function createRawTexture( container ) {
994
1053
 
995
1054
  if ( FORMAT_MAP[ vkFormat ] === undefined ) {
996
1055
 
997
- throw new Error( 'THREE.KTX2Loader: Unsupported vkFormat.' );
1056
+ throw new Error( 'THREE.KTX2Loader: Unsupported vkFormat: ' + vkFormat );
1057
+
1058
+ }
1059
+
1060
+ // TODO: Merge the TYPE_MAP warning into the thrown error above, after r190.
1061
+ if ( TYPE_MAP[ vkFormat ] === undefined ) {
1062
+
1063
+ console.warn( 'THREE.KTX2Loader: Missing ".type" for vkFormat: ' + vkFormat );
998
1064
 
999
1065
  }
1000
1066
 
@@ -1024,7 +1090,6 @@ async function createRawTexture( container ) {
1024
1090
 
1025
1091
  const mipmaps = [];
1026
1092
 
1027
-
1028
1093
  for ( let levelIndex = 0; levelIndex < container.levels.length; levelIndex ++ ) {
1029
1094
 
1030
1095
  const levelWidth = Math.max( 1, container.pixelWidth >> levelIndex );
@@ -1071,6 +1136,16 @@ async function createRawTexture( container ) {
1071
1136
 
1072
1137
  );
1073
1138
 
1139
+ } else if ( TYPE_MAP[ vkFormat ] === UnsignedInt5999Type || TYPE_MAP[ vkFormat ] === UnsignedInt101111Type ) {
1140
+
1141
+ data = new Uint32Array(
1142
+
1143
+ levelData.buffer,
1144
+ levelData.byteOffset,
1145
+ levelData.byteLength / Uint32Array.BYTES_PER_ELEMENT
1146
+
1147
+ );
1148
+
1074
1149
  } else {
1075
1150
 
1076
1151
  data = levelData;
@@ -1088,6 +1163,9 @@ async function createRawTexture( container ) {
1088
1163
 
1089
1164
  }
1090
1165
 
1166
+ // levelCount = 0 implies runtime-generated mipmaps.
1167
+ const useMipmaps = container.levelCount === 0 || mipmaps.length > 1;
1168
+
1091
1169
  let texture;
1092
1170
 
1093
1171
  if ( UNCOMPRESSED_FORMATS.has( FORMAT_MAP[ vkFormat ] ) ) {
@@ -1095,14 +1173,16 @@ async function createRawTexture( container ) {
1095
1173
  texture = container.pixelDepth === 0
1096
1174
  ? new DataTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight )
1097
1175
  : new Data3DTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight, container.pixelDepth );
1176
+ texture.minFilter = useMipmaps ? NearestMipmapNearestFilter : NearestFilter;
1177
+ texture.magFilter = NearestFilter;
1178
+ texture.generateMipmaps = container.levelCount === 0;
1098
1179
 
1099
1180
  } else {
1100
1181
 
1101
1182
  if ( container.pixelDepth > 0 ) throw new Error( 'THREE.KTX2Loader: Unsupported pixelDepth.' );
1102
1183
 
1103
1184
  texture = new CompressedTexture( mipmaps, container.pixelWidth, container.pixelHeight );
1104
-
1105
- texture.minFilter = mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter;
1185
+ texture.minFilter = useMipmaps ? LinearMipmapLinearFilter : LinearFilter;
1106
1186
  texture.magFilter = LinearFilter;
1107
1187
 
1108
1188
  }