Advertisement
Guest User

Untitled

a guest
Apr 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. _resolveSpine(entry: any) {
  2. if(!entry.options || !entry.options.metadata || !entry.options.metadata.data)
  3. return;
  4. const pack = entry.options.metadata as IPacket;
  5. if(pack.mime != "application/json")
  6. return;
  7.  
  8. const text = decodeURIComponent(pack.data.replace("data:application/json;,",""));
  9. const json = JSON.parse(unescape(text));
  10. if(!json.bones)
  11. return;
  12.  
  13. const path = pack.path;
  14. const atlasPath = path.replace(".json", ".atlas");
  15. const imagePath = path.replace(".json", ".png");
  16.  
  17. const imageRes = this.bundle[imagePath].data;
  18. const atlasRes = decodeURIComponent(this.bundle[atlasPath].data.replace("data:text/plain;,",""));
  19.  
  20. const image = new Image();
  21. image.src = imageRes;
  22. entry.options.metadata.image = PIXI.BaseTexture.from(image);
  23. entry.options.metadata.atlasRawData = atlasRes;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement