NodeLib.js 904 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.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. };