@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.
- package/build/three.cjs +167 -107
- package/build/three.core.js +112 -20
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +56 -90
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +30 -5
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2896 -1048
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2896 -1048
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +7 -7
- package/examples/jsm/controls/DragControls.js +6 -56
- package/examples/jsm/controls/FirstPersonControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +0 -8
- package/examples/jsm/exporters/GLTFExporter.js +30 -22
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/GLTFLoader.js +9 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +112 -32
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/TTFLoader.js +4 -4
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +2 -2
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
- package/examples/jsm/transpiler/TSLEncoder.js +2 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
- package/examples/jsm/tsl/display/BloomNode.js +3 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
- package/examples/jsm/tsl/display/GTAONode.js +8 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +47 -35
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/TRAANode.js +1 -1
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +29 -4
- package/src/animation/AnimationClip.js +17 -2
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/materials/Material.js +12 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +81 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/ColorManagement.js +7 -1
- package/src/nodes/Nodes.js +3 -0
- package/src/nodes/TSL.js +3 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +133 -7
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +2 -2
- package/src/nodes/accessors/InstanceNode.js +3 -1
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +71 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/AssignNode.js +4 -3
- package/src/nodes/core/ContextNode.js +24 -0
- package/src/nodes/core/Node.js +16 -20
- package/src/nodes/core/NodeBuilder.js +48 -14
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +1 -2
- package/src/nodes/core/StackNode.js +29 -4
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +16 -9
- package/src/nodes/core/VarNode.js +0 -21
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +1 -1
- package/src/nodes/display/ScreenNode.js +42 -13
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +42 -12
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
- package/src/nodes/lighting/LightsNode.js +1 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +18 -2
- package/src/nodes/math/MathNode.js +3 -15
- package/src/nodes/math/OperatorNode.js +4 -3
- package/src/nodes/tsl/TSLCore.js +432 -152
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +51 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +2 -2
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +1 -10
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +2 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +39 -19
- package/src/renderers/common/SampledTexture.js +1 -1
- package/src/renderers/common/Sampler.js +25 -13
- package/src/renderers/common/Textures.js +34 -12
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +35 -19
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +1 -1
- package/src/renderers/webgl/WebGLTextures.js +1 -0
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +186 -135
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +110 -17
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +35 -31
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +124 -34
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +9 -18
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +114 -25
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +39 -24
- package/src/textures/ExternalTexture.js +15 -4
- package/src/textures/Source.js +1 -1
- package/src/textures/VideoTexture.js +0 -3
- 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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
958
|
-
[
|
|
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
|
-
[
|
|
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
|
}
|