NodeBuilder.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import {
  5. CubeReflectionMapping,
  6. CubeRefractionMapping,
  7. CubeUVReflectionMapping,
  8. CubeUVRefractionMapping,
  9. LinearEncoding,
  10. GammaEncoding
  11. } from '../../../../build/three.module.js';
  12. import { NodeUniform } from './NodeUniform.js';
  13. import { NodeUtils } from './NodeUtils.js';
  14. import { NodeLib } from './NodeLib.js';
  15. import { FunctionNode } from './FunctionNode.js';
  16. import { ConstNode } from './ConstNode.js';
  17. import { StructNode } from './StructNode.js';
  18. import { Vector2Node } from '../inputs/Vector2Node.js';
  19. import { Vector3Node } from '../inputs/Vector3Node.js';
  20. import { Vector4Node } from '../inputs/Vector4Node.js';
  21. import { TextureNode } from '../inputs/TextureNode.js';
  22. import { CubeTextureNode } from '../inputs/CubeTextureNode.js';
  23. import { TextureCubeNode } from '../misc/TextureCubeNode.js';
  24. var elements = NodeUtils.elements,
  25. constructors = [ 'float', 'vec2', 'vec3', 'vec4' ],
  26. convertFormatToType = {
  27. float: 'f',
  28. vec2: 'v2',
  29. vec3: 'v3',
  30. vec4: 'v4',
  31. mat4: 'v4',
  32. int: 'i',
  33. bool: 'b'
  34. },
  35. convertTypeToFormat = {
  36. t: 'sampler2D',
  37. tc: 'samplerCube',
  38. b: 'bool',
  39. i: 'int',
  40. f: 'float',
  41. c: 'vec3',
  42. v2: 'vec2',
  43. v3: 'vec3',
  44. v4: 'vec4',
  45. m3: 'mat3',
  46. m4: 'mat4'
  47. };
  48. function NodeBuilder() {
  49. this.slots = [];
  50. this.caches = [];
  51. this.contexts = [];
  52. this.keywords = {};
  53. this.nodeData = {};
  54. this.requires = {
  55. uv: [],
  56. color: [],
  57. lights: false,
  58. fog: false
  59. };
  60. this.includes = {
  61. consts: [],
  62. functions: [],
  63. structs: []
  64. };
  65. this.attributes = {};
  66. this.prefixCode = [
  67. "#ifdef TEXTURE_LOD_EXT",
  68. " #define texCube(a, b) textureCube(a, b)",
  69. " #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)",
  70. " #define tex2D(a, b) texture2D(a, b)",
  71. " #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)",
  72. "#else",
  73. " #define texCube(a, b) textureCube(a, b)",
  74. " #define texCubeBias(a, b, c) textureCube(a, b, c)",
  75. " #define tex2D(a, b) texture2D(a, b)",
  76. " #define tex2DBias(a, b, c) texture2D(a, b, c)",
  77. "#endif",
  78. "#include <packing>",
  79. "#include <common>"
  80. ].join( "\n" );
  81. this.parsCode = {
  82. vertex: '',
  83. fragment: ''
  84. };
  85. this.code = {
  86. vertex: '',
  87. fragment: ''
  88. };
  89. this.nodeCode = {
  90. vertex: '',
  91. fragment: ''
  92. };
  93. this.resultCode = {
  94. vertex: '',
  95. fragment: ''
  96. };
  97. this.finalCode = {
  98. vertex: '',
  99. fragment: ''
  100. };
  101. this.inputs = {
  102. uniforms: {
  103. list: [],
  104. vertex: [],
  105. fragment: []
  106. },
  107. vars: {
  108. varying: [],
  109. vertex: [],
  110. fragment: []
  111. }
  112. };
  113. // send to material
  114. this.defines = {};
  115. this.uniforms = {};
  116. this.extensions = {};
  117. this.updaters = [];
  118. this.nodes = [];
  119. // --
  120. this.analyzing = false;
  121. }
  122. NodeBuilder.prototype = {
  123. constructor: NodeBuilder,
  124. build: function ( vertex, fragment ) {
  125. this.buildShader( 'vertex', vertex );
  126. this.buildShader( 'fragment', fragment );
  127. for ( var i = 0; i < this.requires.uv.length; i++ ) {
  128. if ( this.requires.uv[ i ] ) {
  129. var uvIndex = i > 0 ? i + 1 : '';
  130. this.addVaryCode( 'varying vec2 vUv' + uvIndex + ';' );
  131. if ( i > 0 ) {
  132. this.addVertexParsCode( 'attribute vec2 uv' + uvIndex + ';' );
  133. }
  134. this.addVertexFinalCode( 'vUv' + uvIndex + ' = uv' + uvIndex +';' );
  135. }
  136. }
  137. if ( this.requires.color[ 0 ] ) {
  138. this.addVaryCode( 'varying vec4 vColor;' );
  139. this.addVertexParsCode( 'attribute vec4 color;' );
  140. this.addVertexFinalCode( 'vColor = color;' );
  141. }
  142. if ( this.requires.color[ 1 ] ) {
  143. this.addVaryCode( 'varying vec4 vColor2;' );
  144. this.addVertexParsCode( 'attribute vec4 color2;' );
  145. this.addVertexFinalCode( 'vColor2 = color2;' );
  146. }
  147. if ( this.requires.position ) {
  148. this.addVaryCode( 'varying vec3 vPosition;' );
  149. this.addVertexFinalCode( 'vPosition = transformed;' );
  150. }
  151. if ( this.requires.worldPosition ) {
  152. this.addVaryCode( 'varying vec3 vWPosition;' );
  153. this.addVertexFinalCode( 'vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;' );
  154. }
  155. if ( this.requires.normal ) {
  156. this.addVaryCode( 'varying vec3 vObjectNormal;' );
  157. this.addVertexFinalCode( 'vObjectNormal = normal;' );
  158. }
  159. if ( this.requires.worldNormal ) {
  160. this.addVaryCode( 'varying vec3 vWNormal;' );
  161. this.addVertexFinalCode( 'vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;' );
  162. }
  163. return this;
  164. },
  165. buildShader: function ( shader, node ) {
  166. this.resultCode[ shader ] = node.build( this.setShader( shader ), 'v4' );
  167. },
  168. setMaterial: function ( material, renderer ) {
  169. this.material = material;
  170. this.renderer = renderer;
  171. this.requires.lights = material.lights;
  172. this.requires.fog = material.fog;
  173. this.mergeDefines( material.defines );
  174. return this;
  175. },
  176. addFlow: function ( slot, cache, context ) {
  177. return this.addSlot( slot ).addCache( cache ).addContext( context );
  178. },
  179. removeFlow: function () {
  180. return this.removeSlot().removeCache().removeContext();
  181. },
  182. addCache: function ( name ) {
  183. this.cache = name || '';
  184. this.caches.push( this.cache );
  185. return this;
  186. },
  187. removeCache: function () {
  188. this.caches.pop();
  189. this.cache = this.caches[ this.caches.length - 1 ] || '';
  190. return this;
  191. },
  192. addContext: function ( context ) {
  193. this.context = Object.assign( {}, this.context, context );
  194. this.context.extra = this.context.extra || {};
  195. this.contexts.push( this.context );
  196. return this;
  197. },
  198. removeContext: function () {
  199. this.contexts.pop();
  200. this.context = this.contexts[ this.contexts.length - 1 ] || {};
  201. return this;
  202. },
  203. addSlot: function ( name ) {
  204. this.slot = name || '';
  205. this.slots.push( this.slot );
  206. return this;
  207. },
  208. removeSlot: function () {
  209. this.slots.pop();
  210. this.slot = this.slots[ this.slots.length - 1 ] || '';
  211. return this;
  212. },
  213. addVertexCode: function ( code ) {
  214. this.addCode( code, 'vertex' );
  215. },
  216. addFragmentCode: function ( code ) {
  217. this.addCode( code, 'fragment' );
  218. },
  219. addCode: function ( code, shader ) {
  220. this.code[ shader || this.shader ] += code + '\n';
  221. },
  222. addVertexNodeCode: function ( code ) {
  223. this.addNodeCode( code, 'vertex' );
  224. },
  225. addFragmentNodeCode: function ( code ) {
  226. this.addNodeCode( code, 'fragment' );
  227. },
  228. addNodeCode: function ( code, shader ) {
  229. this.nodeCode[ shader || this.shader ] += code + '\n';
  230. },
  231. clearNodeCode: function ( shader ) {
  232. shader = shader || this.shader;
  233. var code = this.nodeCode[ shader ];
  234. this.nodeCode[ shader ] = '';
  235. return code;
  236. },
  237. clearVertexNodeCode: function ( ) {
  238. return this.clearNodeCode( 'vertex' );
  239. },
  240. clearFragmentNodeCode: function ( ) {
  241. return this.clearNodeCode( 'fragment' );
  242. },
  243. addVertexFinalCode: function ( code ) {
  244. this.addFinalCode( code, 'vertex' );
  245. },
  246. addFragmentFinalCode: function ( code ) {
  247. this.addFinalCode( code, 'fragment' );
  248. },
  249. addFinalCode: function ( code, shader ) {
  250. this.finalCode[ shader || this.shader ] += code + '\n';
  251. },
  252. addVertexParsCode: function ( code ) {
  253. this.addParsCode( code, 'vertex' );
  254. },
  255. addFragmentParsCode: function ( code ) {
  256. this.addParsCode( code, 'fragment' );
  257. },
  258. addParsCode: function ( code, shader ) {
  259. this.parsCode[ shader || this.shader ] += code + '\n';
  260. },
  261. addVaryCode: function ( code ) {
  262. this.addVertexParsCode( code );
  263. this.addFragmentParsCode( code );
  264. },
  265. isCache: function ( name ) {
  266. return this.caches.indexOf( name ) !== - 1;
  267. },
  268. isSlot: function ( name ) {
  269. return this.slots.indexOf( name ) !== - 1;
  270. },
  271. define: function ( name, value ) {
  272. this.defines[ name ] = value === undefined ? 1 : value;
  273. },
  274. require: function ( name ) {
  275. this.requires[ name ] = true;
  276. },
  277. isDefined: function ( name ) {
  278. return this.defines[ name ] !== undefined;
  279. },
  280. getVar: function ( uuid, type, ns, shader = 'varying', prefix = 'V', label = '' ) {
  281. var vars = this.getVars( shader ),
  282. data = vars[ uuid ];
  283. if ( ! data ) {
  284. var index = vars.length,
  285. name = ns ? ns : 'node' + prefix + index + ( label ? '_' + label : '' );
  286. data = { name: name, type: type };
  287. vars.push( data );
  288. vars[ uuid ] = data;
  289. }
  290. return data;
  291. },
  292. getTempVar: function ( uuid, type, ns, label ) {
  293. return this.getVar( uuid, type, ns, this.shader, 'T', label );
  294. },
  295. getAttribute: function ( name, type ) {
  296. if ( ! this.attributes[ name ] ) {
  297. var varying = this.getVar( name, type );
  298. this.addVertexParsCode( 'attribute ' + type + ' ' + name + ';' );
  299. this.addVertexFinalCode( varying.name + ' = ' + name + ';' );
  300. this.attributes[ name ] = { varying: varying, name: name, type: type };
  301. }
  302. return this.attributes[ name ];
  303. },
  304. getCode: function ( shader ) {
  305. return [
  306. this.prefixCode,
  307. this.parsCode[ shader ],
  308. this.getVarListCode( this.getVars( 'varying' ), 'varying' ),
  309. this.getVarListCode( this.inputs.uniforms[ shader ], 'uniform' ),
  310. this.getIncludesCode( 'consts', shader ),
  311. this.getIncludesCode( 'structs', shader ),
  312. this.getIncludesCode( 'functions', shader ),
  313. 'void main() {',
  314. this.getVarListCode( this.getVars( shader ) ),
  315. this.code[ shader ],
  316. this.resultCode[ shader ],
  317. this.finalCode[ shader ],
  318. '}'
  319. ].join( "\n" );
  320. },
  321. getVarListCode: function ( vars, prefix ) {
  322. prefix = prefix || '';
  323. var code = '';
  324. for ( var i = 0, l = vars.length; i < l; ++ i ) {
  325. var nVar = vars[ i ],
  326. type = nVar.type,
  327. name = nVar.name;
  328. var formatType = this.getFormatByType( type );
  329. if ( formatType === undefined ) {
  330. throw new Error( "Node pars " + formatType + " not found." );
  331. }
  332. code += prefix + ' ' + formatType + ' ' + name + ';\n';
  333. }
  334. return code;
  335. },
  336. getVars: function ( shader ) {
  337. return this.inputs.vars[ shader || this.shader ];
  338. },
  339. getNodeData: function ( node ) {
  340. var uuid = node.isNode ? node.uuid : node;
  341. return this.nodeData[ uuid ] = this.nodeData[ uuid ] || {};
  342. },
  343. createUniform: function ( shader, type, node, ns, needsUpdate, label ) {
  344. var uniforms = this.inputs.uniforms,
  345. index = uniforms.list.length;
  346. var uniform = new NodeUniform( {
  347. type: type,
  348. name: ns ? ns : 'nodeU' + index + ( label ? '_' + label : '' ),
  349. node: node,
  350. needsUpdate: needsUpdate
  351. } );
  352. uniforms.list.push( uniform );
  353. uniforms[ shader ].push( uniform );
  354. uniforms[ shader ][ uniform.name ] = uniform;
  355. this.uniforms[ uniform.name ] = uniform;
  356. return uniform;
  357. },
  358. createVertexUniform: function ( type, node, ns, needsUpdate, label ) {
  359. return this.createUniform( 'vertex', type, node, ns, needsUpdate, label );
  360. },
  361. createFragmentUniform: function ( type, node, ns, needsUpdate, label ) {
  362. return this.createUniform( 'fragment', type, node, ns, needsUpdate, label );
  363. },
  364. include: function ( node, parent, source ) {
  365. var includesStruct;
  366. node = typeof node === 'string' ? NodeLib.get( node ) : node;
  367. if ( this.context.include === false ) {
  368. return node.name;
  369. }
  370. if ( node instanceof FunctionNode ) {
  371. includesStruct = this.includes.functions;
  372. } else if ( node instanceof ConstNode ) {
  373. includesStruct = this.includes.consts;
  374. } else if ( node instanceof StructNode ) {
  375. includesStruct = this.includes.structs;
  376. }
  377. var includes = includesStruct[ this.shader ] = includesStruct[ this.shader ] || [];
  378. if ( node ) {
  379. var included = includes[ node.name ];
  380. if ( ! included ) {
  381. included = includes[ node.name ] = {
  382. node: node,
  383. deps: []
  384. };
  385. includes.push( included );
  386. included.src = node.build( this, 'source' );
  387. }
  388. if ( node instanceof FunctionNode && parent && includes[ parent.name ] && includes[ parent.name ].deps.indexOf( node ) == - 1 ) {
  389. includes[ parent.name ].deps.push( node );
  390. if ( node.includes && node.includes.length ) {
  391. var i = 0;
  392. do {
  393. this.include( node.includes[ i ++ ], parent );
  394. } while ( i < node.includes.length );
  395. }
  396. }
  397. if ( source ) {
  398. included.src = source;
  399. }
  400. return node.name;
  401. } else {
  402. throw new Error( "Include not found." );
  403. }
  404. },
  405. colorToVectorProperties: function ( color ) {
  406. return color.replace( 'r', 'x' ).replace( 'g', 'y' ).replace( 'b', 'z' ).replace( 'a', 'w' );
  407. },
  408. colorToVector: function ( color ) {
  409. return color.replace( /c/g, 'v3' );
  410. },
  411. getIncludes: function ( type, shader ) {
  412. return this.includes[ type ][ shader || this.shader ];
  413. },
  414. getIncludesCode: function () {
  415. function sortByPosition( a, b ) {
  416. return a.deps.length - b.deps.length;
  417. }
  418. return function getIncludesCode( type, shader ) {
  419. var includes = this.getIncludes( type, shader );
  420. if ( ! includes ) return '';
  421. var code = '',
  422. includes = includes.sort( sortByPosition );
  423. for ( var i = 0; i < includes.length; i ++ ) {
  424. if ( includes[ i ].src ) code += includes[ i ].src + '\n';
  425. }
  426. return code;
  427. };
  428. }(),
  429. getConstructorFromLength: function ( len ) {
  430. return constructors[ len - 1 ];
  431. },
  432. isTypeMatrix: function ( format ) {
  433. return /^m/.test( format );
  434. },
  435. getTypeLength: function ( type ) {
  436. if ( type === 'f' ) return 1;
  437. return parseInt( this.colorToVector( type ).substr( 1 ) );
  438. },
  439. getTypeFromLength: function ( len ) {
  440. if ( len === 1 ) return 'f';
  441. return 'v' + len;
  442. },
  443. findNode: function () {
  444. for ( var i = 0; i < arguments.length; i ++ ) {
  445. var nodeCandidate = arguments[ i ];
  446. if ( nodeCandidate !== undefined && nodeCandidate.isNode ) {
  447. return nodeCandidate;
  448. }
  449. }
  450. },
  451. resolve: function () {
  452. for ( var i = 0; i < arguments.length; i ++ ) {
  453. var nodeCandidate = arguments[ i ];
  454. if ( nodeCandidate !== undefined ) {
  455. if ( nodeCandidate.isNode ) {
  456. return nodeCandidate;
  457. } else if ( nodeCandidate.isTexture ) {
  458. switch ( nodeCandidate.mapping ) {
  459. case CubeReflectionMapping:
  460. case CubeRefractionMapping:
  461. return new CubeTextureNode( nodeCandidate );
  462. break;
  463. case CubeUVReflectionMapping:
  464. case CubeUVRefractionMapping:
  465. return new TextureCubeNode( new TextureNode( nodeCandidate ) );
  466. break;
  467. default:
  468. return new TextureNode( nodeCandidate );
  469. }
  470. } else if ( nodeCandidate.isVector2 ) {
  471. return new Vector2Node( nodeCandidate );
  472. } else if ( nodeCandidate.isVector3 ) {
  473. return new Vector3Node( nodeCandidate );
  474. } else if ( nodeCandidate.isVector4 ) {
  475. return new Vector4Node( nodeCandidate );
  476. }
  477. }
  478. }
  479. },
  480. format: function ( code, from, to ) {
  481. var typeToType = this.colorToVector( to + ' <- ' + from );
  482. switch ( typeToType ) {
  483. case 'f <- v2' : return code + '.x';
  484. case 'f <- v3' : return code + '.x';
  485. case 'f <- v4' : return code + '.x';
  486. case 'f <- i' :
  487. case 'f <- b' : return 'float( ' + code + ' )';
  488. case 'v2 <- f' : return 'vec2( ' + code + ' )';
  489. case 'v2 <- v3': return code + '.xy';
  490. case 'v2 <- v4': return code + '.xy';
  491. case 'v2 <- i' :
  492. case 'v2 <- b' : return 'vec2( float( ' + code + ' ) )';
  493. case 'v3 <- f' : return 'vec3( ' + code + ' )';
  494. case 'v3 <- v2': return 'vec3( ' + code + ', 0.0 )';
  495. case 'v3 <- v4': return code + '.xyz';
  496. case 'v3 <- i' :
  497. case 'v3 <- b' : return 'vec2( float( ' + code + ' ) )';
  498. case 'v4 <- f' : return 'vec4( ' + code + ' )';
  499. case 'v4 <- v2': return 'vec4( ' + code + ', 0.0, 1.0 )';
  500. case 'v4 <- v3': return 'vec4( ' + code + ', 1.0 )';
  501. case 'v4 <- i' :
  502. case 'v4 <- b' : return 'vec4( float( ' + code + ' ) )';
  503. case 'i <- f' :
  504. case 'i <- b' : return 'int( ' + code + ' )';
  505. case 'i <- v2' : return 'int( ' + code + '.x )';
  506. case 'i <- v3' : return 'int( ' + code + '.x )';
  507. case 'i <- v4' : return 'int( ' + code + '.x )';
  508. case 'b <- f' : return '( ' + code + ' != 0.0 )';
  509. case 'b <- v2' : return '( ' + code + ' != vec2( 0.0 ) )';
  510. case 'b <- v3' : return '( ' + code + ' != vec3( 0.0 ) )';
  511. case 'b <- v4' : return '( ' + code + ' != vec4( 0.0 ) )';
  512. case 'b <- i' : return '( ' + code + ' != 0 )';
  513. }
  514. return code;
  515. },
  516. getTypeByFormat: function ( format ) {
  517. return convertFormatToType[ format ] || format;
  518. },
  519. getFormatByType: function ( type ) {
  520. return convertTypeToFormat[ type ] || type;
  521. },
  522. getUuid: function ( uuid, useCache ) {
  523. useCache = useCache !== undefined ? useCache : true;
  524. if ( useCache && this.cache ) uuid = this.cache + '-' + uuid;
  525. return uuid;
  526. },
  527. getElementByIndex: function ( index ) {
  528. return elements[ index ];
  529. },
  530. getIndexByElement: function ( elm ) {
  531. return elements.indexOf( elm );
  532. },
  533. isShader: function ( shader ) {
  534. return this.shader === shader;
  535. },
  536. setShader: function ( shader ) {
  537. this.shader = shader;
  538. return this;
  539. },
  540. mergeDefines: function ( defines ) {
  541. for ( var name in defines ) {
  542. this.defines[ name ] = defines[ name ];
  543. }
  544. return this.defines;
  545. },
  546. mergeUniform: function ( uniforms ) {
  547. for ( var name in uniforms ) {
  548. this.uniforms[ name ] = uniforms[ name ];
  549. }
  550. return this.uniforms;
  551. },
  552. getTextureEncodingFromMap: function ( map ) {
  553. var encoding;
  554. if ( ! map ) {
  555. encoding = LinearEncoding;
  556. } else if ( map.isTexture ) {
  557. encoding = map.encoding;
  558. } else if ( map.isWebGLRenderTarget ) {
  559. console.warn( "THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead." );
  560. encoding = map.texture.encoding;
  561. }
  562. if ( encoding === LinearEncoding && this.context.gamma ) {
  563. encoding = GammaEncoding;
  564. }
  565. return encoding;
  566. }
  567. };
  568. export { NodeBuilder };