@plastic-software/three 0.178.0 → 0.180.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.
- package/README.md +1 -1
- package/build/three.cjs +950 -230
- package/build/three.core.js +754 -138
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +197 -96
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +99 -25
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +4586 -1499
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +4544 -1499
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/capabilities/WebGPU.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/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- 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/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- 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 +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- 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/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- 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/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
- 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 +7 -6
- 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 +51 -41
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- 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 +2 -0
- package/src/Three.TSL.js +98 -24
- package/src/animation/AnimationClip.js +17 -2
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/Material.js +12 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/ColorManagement.js +7 -1
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- 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/Normal.js +11 -11
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +19 -4
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +83 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/ContextNode.js +44 -1
- package/src/nodes/core/Node.js +30 -22
- package/src/nodes/core/NodeBuilder.js +71 -32
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/StackNode.js +71 -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 +79 -14
- package/src/nodes/core/VarNode.js +83 -15
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +148 -2
- 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 +94 -4
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +1 -1
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +19 -3
- package/src/nodes/math/MathNode.js +72 -60
- package/src/nodes/math/OperatorNode.js +26 -25
- package/src/nodes/tsl/TSLCore.js +477 -142
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +10 -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 +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +21 -31
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +21 -18
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +55 -32
- package/src/renderers/common/SampledTexture.js +4 -72
- package/src/renderers/common/Sampler.js +91 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +52 -14
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +51 -17
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- 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 +21 -11
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -18
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
- 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 +87 -44
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +86 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +12 -2
- package/src/textures/VideoTexture.js +27 -2
- 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
|
}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FileLoader, Loader, TextureLoader, RepeatWrapping, MeshBasicNodeMaterial,
|
|
3
|
+
MeshPhysicalNodeMaterial, DoubleSide,
|
|
4
|
+
} from 'three/webgpu';
|
|
2
5
|
|
|
3
6
|
import {
|
|
4
7
|
float, bool, int, vec2, vec3, vec4, color, texture,
|
|
5
8
|
positionLocal, positionWorld, uv, vertexColor,
|
|
6
9
|
normalLocal, normalWorld, tangentLocal, tangentWorld,
|
|
7
|
-
|
|
8
|
-
asin, acos,
|
|
10
|
+
mul, abs, sign, floor, ceil, round, sin, cos, tan,
|
|
11
|
+
asin, acos, sqrt, exp, clamp, min, max, normalize, length, dot, cross, normalMap,
|
|
9
12
|
remap, smoothstep, luminance, mx_rgbtohsv, mx_hsvtorgb,
|
|
10
|
-
mix,
|
|
13
|
+
mix, saturation, transpose, determinant, inverse, log, reflect, refract, element,
|
|
11
14
|
mx_ramplr, mx_ramptb, mx_splitlr, mx_splittb,
|
|
12
15
|
mx_fractal_noise_float, mx_noise_float, mx_cell_noise_float, mx_worley_noise_float,
|
|
13
16
|
mx_transform_uv,
|
|
14
17
|
mx_safepower, mx_contrast,
|
|
15
18
|
mx_srgb_texture_to_lin_rec709,
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
mx_add, mx_atan2, mx_divide, mx_modulo, mx_multiply, mx_power, mx_subtract,
|
|
20
|
+
mx_timer, mx_frame, mat3, mx_ramp4,
|
|
21
|
+
mx_invert, mx_ifgreater, mx_ifgreatereq, mx_ifequal, distance,
|
|
22
|
+
mx_separate, mx_place2d, mx_rotate2d, mx_rotate3d, mx_heighttonormal,
|
|
23
|
+
mx_unifiednoise2d, mx_unifiednoise3d
|
|
18
24
|
} from 'three/tsl';
|
|
19
25
|
|
|
20
26
|
const colorSpaceLib = {
|
|
@@ -35,19 +41,9 @@ class MXElement {
|
|
|
35
41
|
|
|
36
42
|
// Ref: https://github.com/mrdoob/three.js/issues/24674
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
const mx_subtract = ( in1, in2 = float( 0 ) ) => sub( in1, in2 );
|
|
40
|
-
const mx_multiply = ( in1, in2 = float( 1 ) ) => mul( in1, in2 );
|
|
41
|
-
const mx_divide = ( in1, in2 = float( 1 ) ) => div( in1, in2 );
|
|
42
|
-
const mx_modulo = ( in1, in2 = float( 1 ) ) => mod( in1, in2 );
|
|
43
|
-
const mx_power = ( in1, in2 = float( 1 ) ) => pow( in1, in2 );
|
|
44
|
-
const mx_atan2 = ( in1 = float( 0 ), in2 = float( 1 ) ) => atan2( in1, in2 );
|
|
45
|
-
const mx_timer = () => timerLocal();
|
|
46
|
-
const mx_frame = () => frameId;
|
|
47
|
-
const mx_invert = ( in1, amount = float( 1 ) ) => sub( amount, in1 );
|
|
44
|
+
// Enhanced separate node to support multi-output referencing (outx, outy, outz, outw)
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
const extract = ( in1, index ) => in1.element( index );
|
|
46
|
+
// Type/arity-aware MaterialX node wrappers
|
|
51
47
|
|
|
52
48
|
const MXElements = [
|
|
53
49
|
|
|
@@ -70,7 +66,7 @@ const MXElements = [
|
|
|
70
66
|
new MXElement( 'acos', acos, [ 'in' ] ),
|
|
71
67
|
new MXElement( 'atan2', mx_atan2, [ 'in1', 'in2' ] ),
|
|
72
68
|
new MXElement( 'sqrt', sqrt, [ 'in' ] ),
|
|
73
|
-
|
|
69
|
+
new MXElement( 'ln', log, [ 'in' ] ),
|
|
74
70
|
new MXElement( 'exp', exp, [ 'in' ] ),
|
|
75
71
|
new MXElement( 'clamp', clamp, [ 'in', 'low', 'high' ] ),
|
|
76
72
|
new MXElement( 'min', min, [ 'in1', 'in2' ] ),
|
|
@@ -79,20 +75,27 @@ const MXElements = [
|
|
|
79
75
|
new MXElement( 'magnitude', length, [ 'in1', 'in2' ] ),
|
|
80
76
|
new MXElement( 'dotproduct', dot, [ 'in1', 'in2' ] ),
|
|
81
77
|
new MXElement( 'crossproduct', cross, [ 'in' ] ),
|
|
78
|
+
new MXElement( 'distance', distance, [ 'in1', 'in2' ] ),
|
|
82
79
|
new MXElement( 'invert', mx_invert, [ 'in', 'amount' ] ),
|
|
83
80
|
//new MtlXElement( 'transformpoint', ... ),
|
|
84
81
|
//new MtlXElement( 'transformvector', ... ),
|
|
85
82
|
//new MtlXElement( 'transformnormal', ... ),
|
|
86
|
-
|
|
83
|
+
new MXElement( 'transformmatrix', mul, [ 'in1', 'in2' ] ),
|
|
87
84
|
new MXElement( 'normalmap', normalMap, [ 'in', 'scale' ] ),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
new MXElement( 'transpose', transpose, [ 'in' ] ),
|
|
86
|
+
new MXElement( 'determinant', determinant, [ 'in' ] ),
|
|
87
|
+
new MXElement( 'invertmatrix', inverse, [ 'in' ] ),
|
|
88
|
+
new MXElement( 'creatematrix', mat3, [ 'in1', 'in2', 'in3' ] ),
|
|
91
89
|
//new MtlXElement( 'rotate2d', rotateUV, [ 'in', radians( 'amount' )** ] ),
|
|
92
90
|
//new MtlXElement( 'rotate3d', ... ),
|
|
93
91
|
//new MtlXElement( 'arrayappend', ... ),
|
|
94
92
|
//new MtlXElement( 'dot', ... ),
|
|
95
93
|
|
|
94
|
+
new MXElement( 'length', length, [ 'in' ] ),
|
|
95
|
+
new MXElement( 'crossproduct', cross, [ 'in1', 'in2' ] ),
|
|
96
|
+
new MXElement( 'floor', floor, [ 'in' ] ),
|
|
97
|
+
new MXElement( 'ceil', ceil, [ 'in' ] ),
|
|
98
|
+
|
|
96
99
|
// << Adjustment >>
|
|
97
100
|
new MXElement( 'remap', remap, [ 'in', 'inlow', 'inhigh', 'outlow', 'outhigh' ] ),
|
|
98
101
|
new MXElement( 'smoothstep', smoothstep, [ 'in', 'low', 'high' ] ),
|
|
@@ -113,6 +116,7 @@ const MXElements = [
|
|
|
113
116
|
// << Procedural >>
|
|
114
117
|
new MXElement( 'ramplr', mx_ramplr, [ 'valuel', 'valuer', 'texcoord' ] ),
|
|
115
118
|
new MXElement( 'ramptb', mx_ramptb, [ 'valuet', 'valueb', 'texcoord' ] ),
|
|
119
|
+
new MXElement( 'ramp4', mx_ramp4, [ 'valuetl', 'valuetr', 'valuebl', 'valuebr', 'texcoord' ] ),
|
|
116
120
|
new MXElement( 'splitlr', mx_splitlr, [ 'valuel', 'valuer', 'texcoord' ] ),
|
|
117
121
|
new MXElement( 'splittb', mx_splittb, [ 'valuet', 'valueb', 'texcoord' ] ),
|
|
118
122
|
new MXElement( 'noise2d', mx_noise_float, [ 'texcoord', 'amplitude', 'pivot' ] ),
|
|
@@ -122,23 +126,34 @@ const MXElements = [
|
|
|
122
126
|
new MXElement( 'cellnoise3d', mx_cell_noise_float, [ 'texcoord' ] ),
|
|
123
127
|
new MXElement( 'worleynoise2d', mx_worley_noise_float, [ 'texcoord', 'jitter' ] ),
|
|
124
128
|
new MXElement( 'worleynoise3d', mx_worley_noise_float, [ 'texcoord', 'jitter' ] ),
|
|
125
|
-
|
|
129
|
+
new MXElement( 'unifiednoise2d', mx_unifiednoise2d, [ 'type', 'texcoord', 'freq', 'offset', 'jitter', 'outmin', 'outmax', 'clampoutput', 'octaves', 'lacunarity', 'diminish' ] ),
|
|
130
|
+
new MXElement( 'unifiednoise3d', mx_unifiednoise3d, [ 'type', 'texcoord', 'freq', 'offset', 'jitter', 'outmin', 'outmax', 'clampoutput', 'octaves', 'lacunarity', 'diminish' ] ),
|
|
126
131
|
// << Supplemental >>
|
|
127
132
|
//new MtlXElement( 'tiledimage', ... ),
|
|
128
133
|
//new MtlXElement( 'triplanarprojection', triplanarTextures, [ 'filex', 'filey', 'filez' ] ),
|
|
129
134
|
//new MtlXElement( 'ramp4', ... ),
|
|
130
|
-
|
|
135
|
+
new MXElement( 'place2d', mx_place2d, [ 'texcoord', 'pivot', 'scale', 'rotate', 'offset', 'operationorder' ] ),
|
|
131
136
|
new MXElement( 'safepower', mx_safepower, [ 'in1', 'in2' ] ),
|
|
132
137
|
new MXElement( 'contrast', mx_contrast, [ 'in', 'amount', 'pivot' ] ),
|
|
133
138
|
//new MtlXElement( 'hsvadjust', ... ),
|
|
134
139
|
new MXElement( 'saturate', saturation, [ 'in', 'amount' ] ),
|
|
135
|
-
new MXElement( 'extract',
|
|
136
|
-
new MXElement( 'separate2',
|
|
137
|
-
new MXElement( 'separate3',
|
|
138
|
-
new MXElement( 'separate4',
|
|
140
|
+
new MXElement( 'extract', element, [ 'in', 'index' ] ),
|
|
141
|
+
new MXElement( 'separate2', mx_separate, [ 'in' ] ),
|
|
142
|
+
new MXElement( 'separate3', mx_separate, [ 'in' ] ),
|
|
143
|
+
new MXElement( 'separate4', mx_separate, [ 'in' ] ),
|
|
144
|
+
new MXElement( 'reflect', reflect, [ 'in', 'normal' ] ),
|
|
145
|
+
new MXElement( 'refract', refract, [ 'in', 'normal', 'ior' ] ),
|
|
139
146
|
|
|
140
147
|
new MXElement( 'time', mx_timer ),
|
|
141
|
-
new MXElement( 'frame', mx_frame )
|
|
148
|
+
new MXElement( 'frame', mx_frame ),
|
|
149
|
+
new MXElement( 'ifgreater', mx_ifgreater, [ 'value1', 'value2', 'in1', 'in2' ] ),
|
|
150
|
+
new MXElement( 'ifgreatereq', mx_ifgreatereq, [ 'value1', 'value2', 'in1', 'in2' ] ),
|
|
151
|
+
new MXElement( 'ifequal', mx_ifequal, [ 'value1', 'value2', 'in1', 'in2' ] ),
|
|
152
|
+
|
|
153
|
+
// Placeholder implementations for unsupported nodes
|
|
154
|
+
new MXElement( 'rotate2d', mx_rotate2d, [ 'in', 'amount' ] ),
|
|
155
|
+
new MXElement( 'rotate3d', mx_rotate3d, [ 'in', 'amount', 'axis' ] ),
|
|
156
|
+
new MXElement( 'heighttonormal', mx_heighttonormal, [ 'in', 'scale', 'texcoord' ] ),
|
|
142
157
|
|
|
143
158
|
];
|
|
144
159
|
|
|
@@ -220,6 +235,22 @@ class MaterialXLoader extends Loader {
|
|
|
220
235
|
/**
|
|
221
236
|
* Parses the given MaterialX data and returns the resulting materials.
|
|
222
237
|
*
|
|
238
|
+
* Supported standard_surface inputs:
|
|
239
|
+
* - base, base_color: Base color/albedo
|
|
240
|
+
* - opacity: Alpha/transparency
|
|
241
|
+
* - specular_roughness: Surface roughness
|
|
242
|
+
* - metalness: Metallic property
|
|
243
|
+
* - specular: Specular reflection intensity
|
|
244
|
+
* - specular_color: Specular reflection color
|
|
245
|
+
* - ior: Index of refraction
|
|
246
|
+
* - specular_anisotropy, specular_rotation: Anisotropic reflection
|
|
247
|
+
* - transmission, transmission_color: Transmission properties
|
|
248
|
+
* - thin_film_thickness, thin_film_ior: Thin film interference
|
|
249
|
+
* - sheen, sheen_color, sheen_roughness: Sheen properties
|
|
250
|
+
* - normal: Normal map
|
|
251
|
+
* - coat, coat_roughness, coat_color: Clearcoat properties
|
|
252
|
+
* - emission, emissionColor: Emission properties
|
|
253
|
+
*
|
|
223
254
|
* @param {string} text - The raw MaterialX data as a string.
|
|
224
255
|
* @return {Object<string,NodeMaterial>} A dictionary holding the parse node materials.
|
|
225
256
|
*/
|
|
@@ -235,6 +266,12 @@ class MaterialXNode {
|
|
|
235
266
|
|
|
236
267
|
constructor( materialX, nodeXML, nodePath = '' ) {
|
|
237
268
|
|
|
269
|
+
if ( ! materialX || typeof materialX !== 'object' ) {
|
|
270
|
+
|
|
271
|
+
console.warn( 'MaterialXNode: materialX argument is not an object!', { materialX, nodeXML, nodePath } );
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
238
275
|
this.materialX = materialX;
|
|
239
276
|
this.nodeXML = nodeXML;
|
|
240
277
|
this.nodePath = nodePath ? nodePath + '/' + this.name : this.name;
|
|
@@ -418,6 +455,37 @@ class MaterialXNode {
|
|
|
418
455
|
|
|
419
456
|
}
|
|
420
457
|
|
|
458
|
+
// Handle <input name="texcoord" type="vector2" ... />
|
|
459
|
+
if (
|
|
460
|
+
this.element === 'input' &&
|
|
461
|
+
this.name === 'texcoord' &&
|
|
462
|
+
this.type === 'vector2'
|
|
463
|
+
) {
|
|
464
|
+
|
|
465
|
+
// Try to get index from defaultgeomprop (e.g., "UV0" => 0)
|
|
466
|
+
let index = 0;
|
|
467
|
+
const defaultGeomProp = this.getAttribute( 'defaultgeomprop' );
|
|
468
|
+
if ( defaultGeomProp && /^UV(\d+)$/.test( defaultGeomProp ) ) {
|
|
469
|
+
|
|
470
|
+
index = parseInt( defaultGeomProp.match( /^UV(\d+)$/ )[ 1 ], 10 );
|
|
471
|
+
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
node = uv( index );
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Multi-output support for separate/separate3
|
|
479
|
+
if (
|
|
480
|
+
( this.element === 'separate3' || this.element === 'separate2' || this.element === 'separate4' ) &&
|
|
481
|
+
out && typeof out === 'string' && out.startsWith( 'out' )
|
|
482
|
+
) {
|
|
483
|
+
|
|
484
|
+
const inNode = this.getNodeByName( 'in' );
|
|
485
|
+
return mx_separate( inNode, out );
|
|
486
|
+
|
|
487
|
+
}
|
|
488
|
+
|
|
421
489
|
//
|
|
422
490
|
|
|
423
491
|
const type = this.type;
|
|
@@ -519,6 +587,18 @@ class MaterialXNode {
|
|
|
519
587
|
|
|
520
588
|
const nodeElement = MtlXLibrary[ element ];
|
|
521
589
|
|
|
590
|
+
if ( ! nodeElement ) {
|
|
591
|
+
|
|
592
|
+
throw new Error( `THREE.MaterialXLoader: Unexpected node ${ new XMLSerializer().serializeToString( this.nodeXML ) }.` );
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if ( ! nodeElement.nodeFunc ) {
|
|
597
|
+
|
|
598
|
+
throw new Error( `THREE.MaterialXLoader: Unexpected node 2 ${ new XMLSerializer().serializeToString( this.nodeXML ) }.` );
|
|
599
|
+
|
|
600
|
+
}
|
|
601
|
+
|
|
522
602
|
if ( out !== null ) {
|
|
523
603
|
|
|
524
604
|
node = nodeElement.nodeFunc( ...this.getNodesByNames( ...nodeElement.params ), out );
|
|
@@ -551,6 +631,11 @@ class MaterialXNode {
|
|
|
551
631
|
|
|
552
632
|
node = nodeToTypeClass( node );
|
|
553
633
|
|
|
634
|
+
} else {
|
|
635
|
+
|
|
636
|
+
console.warn( `THREE.MaterialXLoader: Unexpected node ${ new XMLSerializer().serializeToString( this.nodeXML ) }.` );
|
|
637
|
+
node = float( 0 );
|
|
638
|
+
|
|
554
639
|
}
|
|
555
640
|
|
|
556
641
|
node.name = this.name;
|
|
@@ -673,6 +758,12 @@ class MaterialXNode {
|
|
|
673
758
|
|
|
674
759
|
//
|
|
675
760
|
|
|
761
|
+
let opacityNode = null;
|
|
762
|
+
|
|
763
|
+
if ( inputs.opacity ) opacityNode = inputs.opacity;
|
|
764
|
+
|
|
765
|
+
//
|
|
766
|
+
|
|
676
767
|
let roughnessNode = null;
|
|
677
768
|
|
|
678
769
|
if ( inputs.specular_roughness ) roughnessNode = inputs.specular_roughness;
|
|
@@ -685,6 +776,64 @@ class MaterialXNode {
|
|
|
685
776
|
|
|
686
777
|
//
|
|
687
778
|
|
|
779
|
+
let specularIntensityNode = null;
|
|
780
|
+
|
|
781
|
+
if ( inputs.specular ) specularIntensityNode = inputs.specular;
|
|
782
|
+
|
|
783
|
+
//
|
|
784
|
+
|
|
785
|
+
let specularColorNode = null;
|
|
786
|
+
|
|
787
|
+
if ( inputs.specular_color ) specularColorNode = inputs.specular_color;
|
|
788
|
+
|
|
789
|
+
//
|
|
790
|
+
|
|
791
|
+
let iorNode = null;
|
|
792
|
+
|
|
793
|
+
if ( inputs.ior ) iorNode = inputs.ior;
|
|
794
|
+
|
|
795
|
+
//
|
|
796
|
+
|
|
797
|
+
let anisotropyNode = null;
|
|
798
|
+
let anisotropyRotationNode = null;
|
|
799
|
+
|
|
800
|
+
if ( inputs.specular_anisotropy ) anisotropyNode = inputs.specular_anisotropy;
|
|
801
|
+
if ( inputs.specular_rotation ) anisotropyRotationNode = inputs.specular_rotation;
|
|
802
|
+
|
|
803
|
+
//
|
|
804
|
+
|
|
805
|
+
let transmissionNode = null;
|
|
806
|
+
let transmissionColorNode = null;
|
|
807
|
+
|
|
808
|
+
if ( inputs.transmission ) transmissionNode = inputs.transmission;
|
|
809
|
+
if ( inputs.transmission_color ) transmissionColorNode = inputs.transmission_color;
|
|
810
|
+
|
|
811
|
+
//
|
|
812
|
+
|
|
813
|
+
let thinFilmThicknessNode = null;
|
|
814
|
+
let thinFilmIorNode = null;
|
|
815
|
+
|
|
816
|
+
if ( inputs.thin_film_thickness ) thinFilmThicknessNode = inputs.thin_film_thickness;
|
|
817
|
+
|
|
818
|
+
if ( inputs.thin_film_ior ) {
|
|
819
|
+
|
|
820
|
+
// Clamp IOR to valid range for Three.js (1.0 to 2.333)
|
|
821
|
+
thinFilmIorNode = clamp( inputs.thin_film_ior, float( 1.0 ), float( 2.333 ) );
|
|
822
|
+
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
//
|
|
826
|
+
|
|
827
|
+
let sheenNode = null;
|
|
828
|
+
let sheenColorNode = null;
|
|
829
|
+
let sheenRoughnessNode = null;
|
|
830
|
+
|
|
831
|
+
if ( inputs.sheen ) sheenNode = inputs.sheen;
|
|
832
|
+
if ( inputs.sheen_color ) sheenColorNode = inputs.sheen_color;
|
|
833
|
+
if ( inputs.sheen_roughness ) sheenRoughnessNode = inputs.sheen_roughness;
|
|
834
|
+
|
|
835
|
+
//
|
|
836
|
+
|
|
688
837
|
let clearcoatNode = null;
|
|
689
838
|
let clearcoatRoughnessNode = null;
|
|
690
839
|
|
|
@@ -717,13 +866,46 @@ class MaterialXNode {
|
|
|
717
866
|
//
|
|
718
867
|
|
|
719
868
|
material.colorNode = colorNode || color( 0.8, 0.8, 0.8 );
|
|
869
|
+
material.opacityNode = opacityNode || float( 1.0 );
|
|
720
870
|
material.roughnessNode = roughnessNode || float( 0.2 );
|
|
721
871
|
material.metalnessNode = metalnessNode || float( 0 );
|
|
872
|
+
material.specularIntensityNode = specularIntensityNode || float( 0.5 );
|
|
873
|
+
material.specularColorNode = specularColorNode || color( 1.0, 1.0, 1.0 );
|
|
874
|
+
material.iorNode = iorNode || float( 1.5 );
|
|
875
|
+
material.anisotropyNode = anisotropyNode || float( 0 );
|
|
876
|
+
material.anisotropyRotationNode = anisotropyRotationNode || float( 0 );
|
|
877
|
+
material.transmissionNode = transmissionNode || float( 0 );
|
|
878
|
+
material.transmissionColorNode = transmissionColorNode || color( 1.0, 1.0, 1.0 );
|
|
879
|
+
material.thinFilmThicknessNode = thinFilmThicknessNode || float( 0 );
|
|
880
|
+
material.thinFilmIorNode = thinFilmIorNode || float( 1.5 );
|
|
881
|
+
material.sheenNode = sheenNode || float( 0 );
|
|
882
|
+
material.sheenColorNode = sheenColorNode || color( 1.0, 1.0, 1.0 );
|
|
883
|
+
material.sheenRoughnessNode = sheenRoughnessNode || float( 0.5 );
|
|
722
884
|
material.clearcoatNode = clearcoatNode || float( 0 );
|
|
723
885
|
material.clearcoatRoughnessNode = clearcoatRoughnessNode || float( 0 );
|
|
724
886
|
if ( normalNode ) material.normalNode = normalNode;
|
|
725
887
|
if ( emissiveNode ) material.emissiveNode = emissiveNode;
|
|
726
888
|
|
|
889
|
+
// Auto-enable iridescence when thin film parameters are present
|
|
890
|
+
if ( thinFilmThicknessNode && thinFilmThicknessNode.value !== undefined && thinFilmThicknessNode.value > 0 ) {
|
|
891
|
+
|
|
892
|
+
material.iridescence = 1.0;
|
|
893
|
+
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
if ( opacityNode !== null ) {
|
|
897
|
+
|
|
898
|
+
material.transparent = true;
|
|
899
|
+
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
if ( transmissionNode !== null ) {
|
|
903
|
+
|
|
904
|
+
material.side = DoubleSide;
|
|
905
|
+
material.transparent = true;
|
|
906
|
+
|
|
907
|
+
}
|
|
908
|
+
|
|
727
909
|
}
|
|
728
910
|
|
|
729
911
|
/*setGltfPBR( material ) {
|