Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Parses the <textures> block.
- * @param {textures block element} texturesNode
- */
- parseTextures(texturesNode) {
- // Parse block
- var children = texturesNode.children;
- this.textures = [];
- var numTextures = 0;
- // Any number of textures.
- for (var i = 0; i < children.length; i++) {
- if (children[i].nodeName != "texture") {
- this.onXMLMinorError("unknown tag <" + children[i].nodeName + ">");
- continue;
- }
- // Get id of the current texture.
- var textureId = this.reader.getString(children[i], 'id');
- if (textureId == null)
- return "no ID defined for texture";
- // Checks for repeated IDs.
- if (this.textures[textureId] != null)
- return "ID must be unique for each texture (conflict: ID = " + textureId + ")";
- // Specifications for the current texture.
- // Retrieves the file path.
- var path = this.reader.getString(children[i], 'file');
- if (!(path != null && path != ""))
- return "unable to parse the file path for texture ID = " + textureId;
- // Store Textures global information.
- var newTexture = new CGFappearance(this.scene);
- newTexture.loadTexture(path);
- this.textures[textureId] = newTexture;
- numTextures++;
- }
- this.log("Parsed textures");
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement