NodeLib.js 923 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. var NodeLib = {
  5. nodes: {},
  6. keywords: {},
  7. add: function ( node ) {
  8. this.nodes[ node.name ] = node;
  9. },
  10. addKeyword: function ( name, callback, cache ) {
  11. cache = cache !== undefined ? cache : true;
  12. this.keywords[ name ] = { callback: callback, cache: cache };
  13. },
  14. remove: function ( node ) {
  15. delete this.nodes[ node.name ];
  16. },
  17. removeKeyword: function ( name ) {
  18. delete this.keywords[ name ];
  19. },
  20. get: function ( name ) {
  21. return this.nodes[ name ];
  22. },
  23. getKeyword: function ( name, material ) {
  24. return this.keywords[ name ].callback.call( this, material );
  25. },
  26. getKeywordData: function ( name ) {
  27. return this.keywords[ name ];
  28. },
  29. contains: function ( name ) {
  30. return this.nodes[ name ] != undefined;
  31. },
  32. containsKeyword: function ( name ) {
  33. return this.keywords[ name ] != undefined;
  34. }
  35. };
  36. export { NodeLib };