Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. /**
  2. * Parses the <textures> block.
  3. * @param {textures block element} texturesNode
  4. */
  5. parseTextures(texturesNode) {
  6. // Parse block
  7. var children = texturesNode.children;
  8.  
  9. this.textures = [];
  10. var numTextures = 0;
  11.  
  12. // Any number of textures.
  13. for (var i = 0; i < children.length; i++) {
  14.  
  15. if (children[i].nodeName != "texture") {
  16. this.onXMLMinorError("unknown tag <" + children[i].nodeName + ">");
  17. continue;
  18. }
  19.  
  20. // Get id of the current texture.
  21. var textureId = this.reader.getString(children[i], 'id');
  22. if (textureId == null)
  23. return "no ID defined for texture";
  24.  
  25. // Checks for repeated IDs.
  26. if (this.textures[textureId] != null)
  27. return "ID must be unique for each texture (conflict: ID = " + textureId + ")";
  28.  
  29. // Specifications for the current texture.
  30.  
  31. // Retrieves the file path.
  32. var path = this.reader.getString(children[i], 'file');
  33. if (!(path != null && path != ""))
  34. return "unable to parse the file path for texture ID = " + textureId;
  35.  
  36. // Store Textures global information.
  37. var newTexture = new CGFappearance(this.scene);
  38. newTexture.loadTexture(path);
  39. this.textures[textureId] = newTexture;
  40.  
  41. numTextures++;
  42. }
  43.  
  44. this.log("Parsed textures");
  45.  
  46. return null;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement