@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.
Files changed (245) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +950 -230
  3. package/build/three.core.js +754 -138
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +197 -96
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +99 -25
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +4586 -1499
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +4544 -1499
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +2 -3
  14. package/examples/jsm/capabilities/WebGPU.js +1 -1
  15. package/examples/jsm/controls/ArcballControls.js +7 -7
  16. package/examples/jsm/controls/DragControls.js +6 -56
  17. package/examples/jsm/controls/FirstPersonControls.js +2 -2
  18. package/examples/jsm/controls/PointerLockControls.js +0 -8
  19. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  20. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  21. package/examples/jsm/exporters/GLTFExporter.js +30 -22
  22. package/examples/jsm/exporters/KTX2Exporter.js +4 -2
  23. package/examples/jsm/exporters/PLYExporter.js +1 -1
  24. package/examples/jsm/exporters/USDZExporter.js +676 -299
  25. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  26. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  27. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  28. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  29. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  30. package/examples/jsm/lines/Line2.js +3 -3
  31. package/examples/jsm/lines/LineGeometry.js +1 -1
  32. package/examples/jsm/lines/LineSegments2.js +2 -2
  33. package/examples/jsm/lines/Wireframe.js +2 -2
  34. package/examples/jsm/lines/WireframeGeometry2.js +1 -1
  35. package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
  36. package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
  37. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  38. package/examples/jsm/loaders/EXRLoader.js +210 -22
  39. package/examples/jsm/loaders/FBXLoader.js +1 -1
  40. package/examples/jsm/loaders/GLTFLoader.js +9 -5
  41. package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
  42. package/examples/jsm/loaders/HDRLoader.js +486 -0
  43. package/examples/jsm/loaders/KTX2Loader.js +112 -32
  44. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  45. package/examples/jsm/loaders/RGBELoader.js +7 -473
  46. package/examples/jsm/loaders/TTFLoader.js +13 -1
  47. package/examples/jsm/loaders/USDLoader.js +219 -0
  48. package/examples/jsm/loaders/USDZLoader.js +4 -892
  49. package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
  50. package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
  51. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  52. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  53. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  54. package/examples/jsm/math/ColorSpaces.js +19 -1
  55. package/examples/jsm/math/ConvexHull.js +2 -2
  56. package/examples/jsm/math/Lut.js +2 -2
  57. package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
  58. package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
  59. package/examples/jsm/misc/Volume.js +1 -1
  60. package/examples/jsm/objects/LensflareMesh.js +3 -3
  61. package/examples/jsm/objects/SkyMesh.js +2 -2
  62. package/examples/jsm/physics/RapierPhysics.js +14 -5
  63. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  64. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  65. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  66. package/examples/jsm/postprocessing/SSRPass.js +37 -8
  67. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  68. package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
  69. package/examples/jsm/transpiler/TSLEncoder.js +2 -10
  70. package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
  71. package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
  72. package/examples/jsm/tsl/display/BloomNode.js +7 -6
  73. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
  74. package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
  75. package/examples/jsm/tsl/display/GTAONode.js +8 -0
  76. package/examples/jsm/tsl/display/GaussianBlurNode.js +51 -41
  77. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  78. package/examples/jsm/tsl/display/SSRNode.js +180 -65
  79. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  80. package/examples/jsm/tsl/display/boxBlur.js +64 -0
  81. package/examples/jsm/tsl/display/hashBlur.js +15 -18
  82. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  83. package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
  84. package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
  85. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  86. package/package.json +1 -1
  87. package/src/Three.Core.js +2 -0
  88. package/src/Three.TSL.js +98 -24
  89. package/src/animation/AnimationClip.js +17 -2
  90. package/src/animation/KeyframeTrack.js +1 -1
  91. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  92. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  93. package/src/cameras/Camera.js +14 -0
  94. package/src/cameras/OrthographicCamera.js +1 -1
  95. package/src/cameras/PerspectiveCamera.js +1 -1
  96. package/src/constants.js +11 -3
  97. package/src/core/BufferGeometry.js +2 -2
  98. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  99. package/src/extras/PMREMGenerator.js +11 -0
  100. package/src/extras/TextureUtils.js +2 -1
  101. package/src/extras/lib/earcut.js +1 -1
  102. package/src/helpers/CameraHelper.js +41 -11
  103. package/src/helpers/SkeletonHelper.js +35 -6
  104. package/src/lights/LightShadow.js +21 -8
  105. package/src/lights/PointLightShadow.js +1 -1
  106. package/src/lights/webgpu/ProjectorLight.js +1 -1
  107. package/src/loaders/FileLoader.js +25 -2
  108. package/src/loaders/ImageBitmapLoader.js +23 -0
  109. package/src/loaders/Loader.js +14 -0
  110. package/src/loaders/LoadingManager.js +23 -0
  111. package/src/materials/Material.js +12 -0
  112. package/src/materials/MeshBasicMaterial.js +1 -1
  113. package/src/materials/MeshDistanceMaterial.js +1 -1
  114. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  115. package/src/materials/nodes/NodeMaterial.js +1 -1
  116. package/src/materials/nodes/PointsNodeMaterial.js +86 -28
  117. package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
  118. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  119. package/src/math/ColorManagement.js +7 -1
  120. package/src/math/Frustum.js +19 -8
  121. package/src/math/FrustumArray.js +10 -5
  122. package/src/math/Line3.js +129 -2
  123. package/src/math/Matrix4.js +48 -27
  124. package/src/math/Spherical.js +2 -2
  125. package/src/nodes/Nodes.js +4 -0
  126. package/src/nodes/TSL.js +4 -0
  127. package/src/nodes/accessors/BufferNode.js +1 -1
  128. package/src/nodes/accessors/Camera.js +142 -16
  129. package/src/nodes/accessors/ClippingNode.js +6 -5
  130. package/src/nodes/accessors/CubeTextureNode.js +2 -2
  131. package/src/nodes/accessors/InstanceNode.js +3 -1
  132. package/src/nodes/accessors/Normal.js +11 -11
  133. package/src/nodes/accessors/Object3DNode.js +1 -1
  134. package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
  135. package/src/nodes/accessors/ReferenceNode.js +19 -4
  136. package/src/nodes/accessors/SceneNode.js +1 -1
  137. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  138. package/src/nodes/accessors/Texture3DNode.js +13 -0
  139. package/src/nodes/accessors/TextureNode.js +83 -19
  140. package/src/nodes/code/FunctionCallNode.js +19 -0
  141. package/src/nodes/code/FunctionNode.js +23 -0
  142. package/src/nodes/core/ArrayNode.js +12 -0
  143. package/src/nodes/core/AssignNode.js +6 -2
  144. package/src/nodes/core/ContextNode.js +44 -1
  145. package/src/nodes/core/Node.js +30 -22
  146. package/src/nodes/core/NodeBuilder.js +71 -32
  147. package/src/nodes/core/NodeFrame.js +1 -1
  148. package/src/nodes/core/NodeUniform.js +1 -1
  149. package/src/nodes/core/NodeUtils.js +5 -3
  150. package/src/nodes/core/StackNode.js +71 -4
  151. package/src/nodes/core/StructNode.js +5 -5
  152. package/src/nodes/core/StructTypeNode.js +1 -0
  153. package/src/nodes/core/SubBuildNode.js +2 -2
  154. package/src/nodes/core/UniformNode.js +79 -14
  155. package/src/nodes/core/VarNode.js +83 -15
  156. package/src/nodes/display/FrontFacingNode.js +4 -8
  157. package/src/nodes/display/PassNode.js +148 -2
  158. package/src/nodes/display/ScreenNode.js +42 -13
  159. package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
  160. package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
  161. package/src/nodes/display/ViewportTextureNode.js +94 -4
  162. package/src/nodes/functions/PhysicalLightingModel.js +2 -2
  163. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  164. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  165. package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
  166. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  167. package/src/nodes/lighting/LightsNode.js +1 -1
  168. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  169. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  170. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  171. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  172. package/src/nodes/math/BitcastNode.js +156 -0
  173. package/src/nodes/math/ConditionalNode.js +19 -3
  174. package/src/nodes/math/MathNode.js +72 -60
  175. package/src/nodes/math/OperatorNode.js +26 -25
  176. package/src/nodes/tsl/TSLCore.js +477 -142
  177. package/src/nodes/utils/DebugNode.js +1 -1
  178. package/src/nodes/utils/EventNode.js +83 -0
  179. package/src/nodes/utils/JoinNode.js +3 -1
  180. package/src/nodes/utils/MemberNode.js +58 -7
  181. package/src/nodes/utils/RTTNode.js +10 -1
  182. package/src/nodes/utils/ReflectorNode.js +51 -7
  183. package/src/nodes/utils/SampleNode.js +12 -2
  184. package/src/nodes/utils/SplitNode.js +11 -0
  185. package/src/nodes/utils/Timer.js +0 -47
  186. package/src/objects/BatchedMesh.js +6 -4
  187. package/src/objects/LOD.js +1 -1
  188. package/src/objects/Sprite.js +2 -2
  189. package/src/renderers/WebGLRenderer.js +21 -31
  190. package/src/renderers/common/Attributes.js +1 -1
  191. package/src/renderers/common/Backend.js +19 -1
  192. package/src/renderers/common/Bindings.js +21 -18
  193. package/src/renderers/common/ChainMap.js +1 -1
  194. package/src/renderers/common/Color4.js +2 -2
  195. package/src/renderers/common/DataMap.js +1 -1
  196. package/src/renderers/common/Pipelines.js +1 -1
  197. package/src/renderers/common/PostProcessing.js +60 -5
  198. package/src/renderers/common/RenderContext.js +2 -2
  199. package/src/renderers/common/RenderObject.js +14 -2
  200. package/src/renderers/common/Renderer.js +55 -32
  201. package/src/renderers/common/SampledTexture.js +4 -72
  202. package/src/renderers/common/Sampler.js +91 -0
  203. package/src/renderers/common/Storage3DTexture.js +21 -0
  204. package/src/renderers/common/StorageArrayTexture.js +21 -0
  205. package/src/renderers/common/StorageTexture.js +19 -0
  206. package/src/renderers/common/Textures.js +52 -14
  207. package/src/renderers/common/TimestampQueryPool.js +3 -3
  208. package/src/renderers/common/XRManager.js +51 -17
  209. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  210. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  211. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  212. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
  213. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  214. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
  215. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
  216. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +21 -11
  217. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  218. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  219. package/src/renderers/webgl/WebGLMaterials.js +6 -6
  220. package/src/renderers/webgl/WebGLProgram.js +24 -18
  221. package/src/renderers/webgl/WebGLPrograms.js +4 -4
  222. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  223. package/src/renderers/webgl/WebGLTextures.js +20 -7
  224. package/src/renderers/webgl/WebGLUtils.js +3 -2
  225. package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
  226. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
  227. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
  228. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
  229. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
  230. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
  231. package/src/renderers/webgpu/WebGPUBackend.js +87 -44
  232. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
  233. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
  234. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
  235. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
  236. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
  237. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
  238. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  239. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  240. package/src/renderers/webxr/WebXRManager.js +86 -11
  241. package/src/textures/ExternalTexture.js +56 -0
  242. package/src/textures/FramebufferTexture.js +2 -2
  243. package/src/textures/Source.js +12 -2
  244. package/src/textures/VideoTexture.js +27 -2
  245. 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
  }
@@ -1,20 +1,26 @@
1
- import { FileLoader, Loader, TextureLoader, RepeatWrapping, MeshBasicNodeMaterial, MeshPhysicalNodeMaterial } from 'three/webgpu';
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
- add, sub, mul, div, mod, abs, sign, floor, ceil, round, pow, sin, cos, tan,
8
- asin, acos, atan2, sqrt, exp, clamp, min, max, normalize, length, dot, cross, normalMap,
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, split,
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
- saturation,
17
- timerLocal, frameId
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
- const mx_add = ( in1, in2 = float( 0 ) ) => add( in1, in2 );
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
- const separate = ( in1, channel ) => split( in1, channel.at( - 1 ) );
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
- //new MtlXElement( 'ln', ... ),
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
- //new MtlXElement( 'transformmatrix', ... ),
83
+ new MXElement( 'transformmatrix', mul, [ 'in1', 'in2' ] ),
87
84
  new MXElement( 'normalmap', normalMap, [ 'in', 'scale' ] ),
88
- //new MtlXElement( 'transpose', ... ),
89
- //new MtlXElement( 'determinant', ... ),
90
- //new MtlXElement( 'invertmatrix', ... ),
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
- //new MtlXElement( 'place2d', mx_place2d, [ 'texcoord', 'pivot', 'scale', 'rotate', 'offset' ] ),
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', extract, [ 'in', 'index' ] ),
136
- new MXElement( 'separate2', separate, [ 'in' ] ),
137
- new MXElement( 'separate3', separate, [ 'in' ] ),
138
- new MXElement( 'separate4', separate, [ 'in' ] ),
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 ) {