MaterialXLoader.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. import {
  2. FileLoader, Loader, TextureLoader, MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, RepeatWrapping,
  3. float, bool, int, vec2, vec3, vec4, color, texture,
  4. positionLocal, positionWorld, uv, vertexColor,
  5. normalLocal, normalWorld, tangentLocal, tangentWorld,
  6. add, sub, mul, div, mod, abs, sign, floor, ceil, round, pow, sin, cos, tan,
  7. asin, acos, atan2, sqrt, exp, clamp, min, max, normalize, length, dot, cross, normalMap,
  8. remap, smoothstep, luminance, mx_rgbtohsv, mx_hsvtorgb,
  9. mix,
  10. mx_ramplr, mx_ramptb, mx_splitlr, mx_splittb,
  11. mx_fractal_noise_float, mx_noise_float, mx_cell_noise_float, mx_worley_noise_float,
  12. mx_transform_uv,
  13. mx_safepower, mx_contrast,
  14. mx_srgb_texture_to_lin_rec709,
  15. saturation
  16. } from 'three';
  17. const colorSpaceLib = {
  18. mx_srgb_texture_to_lin_rec709
  19. };
  20. class MXElement {
  21. constructor( name, nodeFunc, params = null ) {
  22. this.name = name;
  23. this.nodeFunc = nodeFunc;
  24. this.params = params;
  25. }
  26. }
  27. // Ref: https://github.com/mrdoob/three.js/issues/24674
  28. const mx_add = ( in1, in2 = float( 0 ) ) => add( in1, in2 );
  29. const mx_subtract = ( in1, in2 = float( 0 ) ) => sub( in1, in2 );
  30. const mx_multiply = ( in1, in2 = float( 1 ) ) => mul( in1, in2 );
  31. const mx_divide = ( in1, in2 = float( 1 ) ) => div( in1, in2 );
  32. const mx_modulo = ( in1, in2 = float( 1 ) ) => mod( in1, in2 );
  33. const mx_power = ( in1, in2 = float( 1 ) ) => pow( in1, in2 );
  34. const mx_atan2 = ( in1 = float( 0 ), in2 = float( 1 ) ) => atan2( in1, in2 );
  35. const MXElements = [
  36. // << Math >>
  37. new MXElement( 'add', mx_add, [ 'in1', 'in2' ] ),
  38. new MXElement( 'subtract', mx_subtract, [ 'in1', 'in2' ] ),
  39. new MXElement( 'multiply', mx_multiply, [ 'in1', 'in2' ] ),
  40. new MXElement( 'divide', mx_divide, [ 'in1', 'in2' ] ),
  41. new MXElement( 'modulo', mx_modulo, [ 'in1', 'in2' ] ),
  42. new MXElement( 'absval', abs, [ 'in1', 'in2' ] ),
  43. new MXElement( 'sign', sign, [ 'in1', 'in2' ] ),
  44. new MXElement( 'floor', floor, [ 'in1', 'in2' ] ),
  45. new MXElement( 'ceil', ceil, [ 'in1', 'in2' ] ),
  46. new MXElement( 'round', round, [ 'in1', 'in2' ] ),
  47. new MXElement( 'power', mx_power, [ 'in1', 'in2' ] ),
  48. new MXElement( 'sin', sin, [ 'in' ] ),
  49. new MXElement( 'cos', cos, [ 'in' ] ),
  50. new MXElement( 'tan', tan, [ 'in' ] ),
  51. new MXElement( 'asin', asin, [ 'in' ] ),
  52. new MXElement( 'acos', acos, [ 'in' ] ),
  53. new MXElement( 'atan2', mx_atan2, [ 'in1', 'in2' ] ),
  54. new MXElement( 'sqrt', sqrt, [ 'in' ] ),
  55. //new MtlXElement( 'ln', ... ),
  56. new MXElement( 'exp', exp, [ 'in' ] ),
  57. new MXElement( 'clamp', clamp, [ 'in', 'low', 'high' ] ),
  58. new MXElement( 'min', min, [ 'in1', 'in2' ] ),
  59. new MXElement( 'max', max, [ 'in1', 'in2' ] ),
  60. new MXElement( 'normalize', normalize, [ 'in' ] ),
  61. new MXElement( 'magnitude', length, [ 'in1', 'in2' ] ),
  62. new MXElement( 'dotproduct', dot, [ 'in1', 'in2' ] ),
  63. new MXElement( 'crossproduct', cross, [ 'in' ] ),
  64. //new MtlXElement( 'transformpoint', ... ),
  65. //new MtlXElement( 'transformvector', ... ),
  66. //new MtlXElement( 'transformnormal', ... ),
  67. //new MtlXElement( 'transformmatrix', ... ),
  68. new MXElement( 'normalmap', normalMap, [ 'in', 'scale' ] ),
  69. //new MtlXElement( 'transpose', ... ),
  70. //new MtlXElement( 'determinant', ... ),
  71. //new MtlXElement( 'invertmatrix', ... ),
  72. //new MtlXElement( 'rotate2d', rotateUV, [ 'in', radians( 'amount' )** ] ),
  73. //new MtlXElement( 'rotate3d', ... ),
  74. //new MtlXElement( 'arrayappend', ... ),
  75. //new MtlXElement( 'dot', ... ),
  76. // << Adjustment >>
  77. new MXElement( 'remap', remap, [ 'in', 'inlow', 'inhigh', 'outlow', 'outhigh' ] ),
  78. new MXElement( 'smoothstep', smoothstep, [ 'in', 'low', 'high' ] ),
  79. //new MtlXElement( 'curveadjust', ... ),
  80. //new MtlXElement( 'curvelookup', ... ),
  81. new MXElement( 'luminance', luminance, [ 'in', 'lumacoeffs' ] ),
  82. new MXElement( 'rgbtohsv', mx_rgbtohsv, [ 'in' ] ),
  83. new MXElement( 'hsvtorgb', mx_hsvtorgb, [ 'in' ] ),
  84. // << Mix >>
  85. new MXElement( 'mix', mix, [ 'bg', 'fg', 'mix' ] ),
  86. // << Channel >>
  87. new MXElement( 'combine2', vec2, [ 'in1', 'in2' ] ),
  88. new MXElement( 'combine3', vec3, [ 'in1', 'in2', 'in3' ] ),
  89. new MXElement( 'combine4', vec4, [ 'in1', 'in2', 'in3', 'in4' ] ),
  90. // << Procedural >>
  91. new MXElement( 'ramplr', mx_ramplr, [ 'valuel', 'valuer', 'texcoord' ] ),
  92. new MXElement( 'ramptb', mx_ramptb, [ 'valuet', 'valueb', 'texcoord' ] ),
  93. new MXElement( 'splitlr', mx_splitlr, [ 'valuel', 'valuer', 'texcoord' ] ),
  94. new MXElement( 'splittb', mx_splittb, [ 'valuet', 'valueb', 'texcoord' ] ),
  95. new MXElement( 'noise2d', mx_noise_float, [ 'texcoord', 'amplitude', 'pivot' ] ),
  96. new MXElement( 'noise3d', mx_noise_float, [ 'texcoord', 'amplitude', 'pivot' ] ),
  97. new MXElement( 'fractal3d', mx_fractal_noise_float, [ 'position', 'octaves', 'lacunarity', 'diminish', 'amplitude' ] ),
  98. new MXElement( 'cellnoise2d', mx_cell_noise_float, [ 'texcoord' ] ),
  99. new MXElement( 'cellnoise3d', mx_cell_noise_float, [ 'texcoord' ] ),
  100. new MXElement( 'worleynoise2d', mx_worley_noise_float, [ 'texcoord', 'jitter' ] ),
  101. new MXElement( 'worleynoise3d', mx_worley_noise_float, [ 'texcoord', 'jitter' ] ),
  102. // << Supplemental >>
  103. //new MtlXElement( 'tiledimage', ... ),
  104. //new MtlXElement( 'triplanarprojection', triplanarTextures, [ 'filex', 'filey', 'filez' ] ),
  105. //new MtlXElement( 'ramp4', ... ),
  106. //new MtlXElement( 'place2d', mx_place2d, [ 'texcoord', 'pivot', 'scale', 'rotate', 'offset' ] ),
  107. new MXElement( 'safepower', mx_safepower, [ 'in1', 'in2' ] ),
  108. new MXElement( 'contrast', mx_contrast, [ 'in', 'amount', 'pivot' ] ),
  109. //new MtlXElement( 'hsvadjust', ... ),
  110. new MXElement( 'saturate', saturation, [ 'in', 'amount' ] ),
  111. //new MtlXElement( 'extract', ... ),
  112. //new MtlXElement( 'separate2', ... ),
  113. //new MtlXElement( 'separate3', ... ),
  114. //new MtlXElement( 'separate4', ... )
  115. ];
  116. const MtlXLibrary = {};
  117. MXElements.forEach( element => MtlXLibrary[ element.name ] = element );
  118. class MaterialXLoader extends Loader {
  119. constructor( manager ) {
  120. super( manager );
  121. }
  122. load( url, onLoad, onProgress, onError ) {
  123. const _onError = function ( e ) {
  124. if ( onError ) {
  125. onError( e );
  126. } else {
  127. console.error( e );
  128. }
  129. };
  130. new FileLoader( this.manager )
  131. .setPath( this.path )
  132. .load( url, async ( text ) => {
  133. try {
  134. onLoad( this.parse( text ) );
  135. } catch ( e ) {
  136. _onError( e );
  137. }
  138. }, onProgress, _onError );
  139. return this;
  140. }
  141. parse( text ) {
  142. return new MaterialX( this.manager, this.path ).parse( text );
  143. }
  144. }
  145. class MaterialXNode {
  146. constructor( materialX, nodeXML, nodePath = '' ) {
  147. this.materialX = materialX;
  148. this.nodeXML = nodeXML;
  149. this.nodePath = nodePath ? nodePath + '/' + this.name : this.name;
  150. this.parent = null;
  151. this.node = null;
  152. this.children = [];
  153. }
  154. get element() {
  155. return this.nodeXML.nodeName;
  156. }
  157. get nodeGraph() {
  158. return this.getAttribute( 'nodegraph' );
  159. }
  160. get nodeName() {
  161. return this.getAttribute( 'nodename' );
  162. }
  163. get interfaceName() {
  164. return this.getAttribute( 'interfacename' );
  165. }
  166. get output() {
  167. return this.getAttribute( 'output' );
  168. }
  169. get name() {
  170. return this.getAttribute( 'name' );
  171. }
  172. get type() {
  173. return this.getAttribute( 'type' );
  174. }
  175. get value() {
  176. return this.getAttribute( 'value' );
  177. }
  178. getNodeGraph() {
  179. let nodeX = this;
  180. while ( nodeX !== null ) {
  181. if ( nodeX.element === 'nodegraph' ) {
  182. break;
  183. }
  184. nodeX = nodeX.parent;
  185. }
  186. return nodeX;
  187. }
  188. getRoot() {
  189. let nodeX = this;
  190. while ( nodeX.parent !== null ) {
  191. nodeX = nodeX.parent;
  192. }
  193. return nodeX;
  194. }
  195. get referencePath() {
  196. let referencePath = null;
  197. if ( this.nodeGraph !== null && this.output !== null ) {
  198. referencePath = this.nodeGraph + '/' + this.output;
  199. } else if ( this.nodeName !== null || this.interfaceName !== null ) {
  200. referencePath = this.getNodeGraph().nodePath + '/' + ( this.nodeName || this.interfaceName );
  201. }
  202. return referencePath;
  203. }
  204. get hasReference() {
  205. return this.referencePath !== null;
  206. }
  207. get isConst() {
  208. return this.element === 'input' && this.value !== null && this.type !== 'filename';
  209. }
  210. getColorSpaceNode() {
  211. const csSource = this.getAttribute( 'colorspace' );
  212. const csTarget = this.getRoot().getAttribute( 'colorspace' );
  213. const nodeName = `mx_${ csSource }_to_${ csTarget }`;
  214. return colorSpaceLib[ nodeName ];
  215. }
  216. getTexture() {
  217. const filePrefix = this.getRecursiveAttribute( 'fileprefix' ) || '';
  218. let loader = this.materialX.textureLoader;
  219. const uri = filePrefix + this.value;
  220. if ( uri ) {
  221. const handler = this.materialX.manager.getHandler( uri );
  222. if ( handler !== null ) loader = handler;
  223. }
  224. const texture = loader.load( uri );
  225. texture.wrapS = texture.wrapT = RepeatWrapping;
  226. texture.flipY = false;
  227. return texture;
  228. }
  229. getClassFromType( type ) {
  230. let nodeClass = null;
  231. if ( type === 'integer' ) nodeClass = int;
  232. else if ( type === 'float' ) nodeClass = float;
  233. else if ( type === 'vector2' ) nodeClass = vec2;
  234. else if ( type === 'vector3' ) nodeClass = vec3;
  235. else if ( type === 'vector4' || type === 'color4' ) nodeClass = vec4;
  236. else if ( type === 'color3' ) nodeClass = color;
  237. else if ( type === 'boolean' ) nodeClass = bool;
  238. return nodeClass;
  239. }
  240. getNode() {
  241. let node = this.node;
  242. if ( node !== null ) {
  243. return node;
  244. }
  245. //
  246. const type = this.type;
  247. if ( this.isConst ) {
  248. const nodeClass = this.getClassFromType( type );
  249. node = nodeClass( ...this.getVector() );
  250. } else if ( this.hasReference ) {
  251. node = this.materialX.getMaterialXNode( this.referencePath ).getNode();
  252. } else {
  253. const element = this.element;
  254. if ( element === 'convert' ) {
  255. const nodeClass = this.getClassFromType( type );
  256. node = nodeClass( this.getNodeByName( 'in' ) );
  257. } else if ( element === 'constant' ) {
  258. node = this.getNodeByName( 'value' );
  259. } else if ( element === 'position' ) {
  260. const space = this.getAttribute( 'space' );
  261. node = space === 'world' ? positionWorld : positionLocal;
  262. } else if ( element === 'normal' ) {
  263. const space = this.getAttribute( 'space' );
  264. node = space === 'world' ? normalWorld : normalLocal;
  265. } else if ( element === 'tangent' ) {
  266. const space = this.getAttribute( 'space' );
  267. node = space === 'world' ? tangentWorld : tangentLocal;
  268. } else if ( element === 'texcoord' ) {
  269. const indexNode = this.getChildByName( 'index' );
  270. const index = indexNode ? parseInt( indexNode.value ) : 0;
  271. node = uv( index );
  272. } else if ( element === 'geomcolor' ) {
  273. const indexNode = this.getChildByName( 'index' );
  274. const index = indexNode ? parseInt( indexNode.value ) : 0;
  275. node = vertexColor( index );
  276. } else if ( element === 'tiledimage' ) {
  277. const file = this.getChildByName( 'file' );
  278. const textureFile = file.getTexture();
  279. const uvTiling = mx_transform_uv( ...this.getNodesByNames( [ 'uvtiling', 'uvoffset' ] ) );
  280. node = texture( textureFile, uvTiling );
  281. const colorSpaceNode = file.getColorSpaceNode();
  282. if ( colorSpaceNode ) {
  283. node = colorSpaceNode( node );
  284. }
  285. } else if ( element === 'image' ) {
  286. const file = this.getChildByName( 'file' );
  287. const uvNode = this.getNodeByName( 'texcoord' );
  288. const textureFile = file.getTexture();
  289. node = texture( textureFile, uvNode );
  290. const colorSpaceNode = file.getColorSpaceNode();
  291. if ( colorSpaceNode ) {
  292. node = colorSpaceNode( node );
  293. }
  294. } else if ( MtlXLibrary[ element ] !== undefined ) {
  295. const nodeElement = MtlXLibrary[ element ];
  296. node = nodeElement.nodeFunc( ...this.getNodesByNames( ...nodeElement.params ) );
  297. }
  298. }
  299. //
  300. if ( node === null ) {
  301. console.warn( `THREE.MaterialXLoader: Unexpected node ${ new XMLSerializer().serializeToString( this.nodeXML ) }.` );
  302. node = float( 0 );
  303. }
  304. //
  305. const nodeToTypeClass = this.getClassFromType( type );
  306. if ( nodeToTypeClass !== null ) {
  307. node = nodeToTypeClass( node );
  308. }
  309. node.name = this.name;
  310. this.node = node;
  311. return node;
  312. }
  313. getChildByName( name ) {
  314. for ( const input of this.children ) {
  315. if ( input.name === name ) {
  316. return input;
  317. }
  318. }
  319. }
  320. getNodes() {
  321. const nodes = {};
  322. for ( const input of this.children ) {
  323. const node = input.getNode();
  324. nodes[ node.name ] = node;
  325. }
  326. return nodes;
  327. }
  328. getNodeByName( name ) {
  329. const child = this.getChildByName( name );
  330. return child ? child.getNode() : undefined;
  331. }
  332. getNodesByNames( ...names ) {
  333. const nodes = [];
  334. for ( const name of names ) {
  335. const node = this.getNodeByName( name );
  336. if ( node ) nodes.push( node );
  337. }
  338. return nodes;
  339. }
  340. getValue() {
  341. return this.value.trim();
  342. }
  343. getVector() {
  344. const vector = [];
  345. for ( const val of this.getValue().split( /[,|\s]/ ) ) {
  346. if ( val !== '' ) {
  347. vector.push( Number( val.trim() ) );
  348. }
  349. }
  350. return vector;
  351. }
  352. getAttribute( name ) {
  353. return this.nodeXML.getAttribute( name );
  354. }
  355. getRecursiveAttribute( name ) {
  356. let attribute = this.nodeXML.getAttribute( name );
  357. if ( attribute === null && this.parent !== null ) {
  358. attribute = this.parent.getRecursiveAttribute( name );
  359. }
  360. return attribute;
  361. }
  362. setStandardSurfaceToGltfPBR( material ) {
  363. const inputs = this.getNodes();
  364. //
  365. let colorNode = null;
  366. if ( inputs.base && inputs.base_color ) colorNode = mul( inputs.base, inputs.base_color );
  367. else if ( inputs.base ) colorNode = inputs.base;
  368. else if ( inputs.base_color ) colorNode = inputs.base_color;
  369. //
  370. let roughnessNode = null;
  371. if ( inputs.specular_roughness ) roughnessNode = inputs.specular_roughness;
  372. //
  373. let metalnessNode = null;
  374. if ( inputs.metalness ) metalnessNode = inputs.metalness;
  375. //
  376. let clearcoatNode = null;
  377. let clearcoatRoughnessNode = null;
  378. if ( inputs.coat ) clearcoatNode = inputs.coat;
  379. if ( inputs.coat_roughness ) clearcoatRoughnessNode = inputs.coat_roughness;
  380. if ( inputs.coat_color ) {
  381. colorNode = colorNode ? mul( colorNode, inputs.coat_color ) : colorNode;
  382. }
  383. //
  384. let normalNode = null;
  385. if ( inputs.normal ) normalNode = inputs.normal;
  386. //
  387. let emissiveNode = null;
  388. if ( inputs.emission ) emissiveNode = inputs.emission;
  389. if ( inputs.emissionColor ) {
  390. emissiveNode = emissiveNode ? mul( emissiveNode, inputs.emissionColor ) : emissiveNode;
  391. }
  392. //
  393. material.colorNode = colorNode || color( 0.8, 0.8, 0.8 );
  394. material.roughnessNode = roughnessNode || float( 0.2 );
  395. material.metalnessNode = metalnessNode || float( 0 );
  396. material.clearcoatNode = clearcoatNode || float( 0 );
  397. material.clearcoatRoughnessNode = clearcoatRoughnessNode || float( 0 );
  398. if ( normalNode ) material.normalNode = normalNode;
  399. if ( emissiveNode ) material.emissiveNode = emissiveNode;
  400. }
  401. /*setGltfPBR( material ) {
  402. const inputs = this.getNodes();
  403. console.log( inputs );
  404. }*/
  405. setMaterial( material ) {
  406. const element = this.element;
  407. if ( element === 'gltf_pbr' ) {
  408. //this.setGltfPBR( material );
  409. } else if ( element === 'standard_surface' ) {
  410. this.setStandardSurfaceToGltfPBR( material );
  411. }
  412. }
  413. toBasicMaterial() {
  414. const material = new MeshBasicNodeMaterial();
  415. material.name = this.name;
  416. for ( const nodeX of this.children.toReversed() ) {
  417. if ( nodeX.name === 'out' ) {
  418. material.colorNode = nodeX.getNode();
  419. break;
  420. }
  421. }
  422. return material;
  423. }
  424. toPhysicalMaterial() {
  425. const material = new MeshPhysicalNodeMaterial();
  426. material.name = this.name;
  427. for ( const nodeX of this.children ) {
  428. const shaderProperties = this.materialX.getMaterialXNode( nodeX.nodeName );
  429. shaderProperties.setMaterial( material );
  430. }
  431. return material;
  432. }
  433. toMaterials() {
  434. const materials = {};
  435. let isUnlit = true;
  436. for ( const nodeX of this.children ) {
  437. if ( nodeX.element === 'surfacematerial' ) {
  438. const material = nodeX.toPhysicalMaterial();
  439. materials[ material.name ] = material;
  440. isUnlit = false;
  441. }
  442. }
  443. if ( isUnlit ) {
  444. for ( const nodeX of this.children ) {
  445. if ( nodeX.element === 'nodegraph' ) {
  446. const material = nodeX.toBasicMaterial();
  447. materials[ material.name ] = material;
  448. }
  449. }
  450. }
  451. return materials;
  452. }
  453. add( materialXNode ) {
  454. materialXNode.parent = this;
  455. this.children.push( materialXNode );
  456. }
  457. }
  458. class MaterialX {
  459. constructor( manager, path ) {
  460. this.manager = manager;
  461. this.path = path;
  462. this.resourcePath = '';
  463. this.nodesXLib = new Map();
  464. //this.nodesXRefLib = new WeakMap();
  465. this.textureLoader = new TextureLoader( manager );
  466. }
  467. addMaterialXNode( materialXNode ) {
  468. this.nodesXLib.set( materialXNode.nodePath, materialXNode );
  469. }
  470. /*getMaterialXNodeFromXML( xmlNode ) {
  471. return this.nodesXRefLib.get( xmlNode );
  472. }*/
  473. getMaterialXNode( ...names ) {
  474. return this.nodesXLib.get( names.join( '/' ) );
  475. }
  476. parseNode( nodeXML, nodePath = '' ) {
  477. const materialXNode = new MaterialXNode( this, nodeXML, nodePath );
  478. if ( materialXNode.nodePath ) this.addMaterialXNode( materialXNode );
  479. for ( const childNodeXML of nodeXML.children ) {
  480. const childMXNode = this.parseNode( childNodeXML, materialXNode.nodePath );
  481. materialXNode.add( childMXNode );
  482. }
  483. return materialXNode;
  484. }
  485. parse( text ) {
  486. const rootXML = new DOMParser().parseFromString( text, 'application/xml' ).documentElement;
  487. this.textureLoader.setPath( this.path );
  488. //
  489. const materials = this.parseNode( rootXML ).toMaterials();
  490. return { materials };
  491. }
  492. }
  493. export { MaterialXLoader };