import * as async from "async" ; export function loadAsset ( player , entry , callback ) { player . getAssetData ( `assets/${ entry . storagePath }/sprite.json` , "json" , ( err , data ) => { data . textures = { } ; const mapsList = data . maps as string [ ] ; data . textures = { } ; async . each ( mapsList , ( key , cb ) => { const image = new Image ( ) ; image . onload = ( ) => { const texture = data . textures [ key ] = new SupEngine . THREE . Texture ( image ) ; ( < any > texture ) . size = { width : image . width , height : image . height } ; texture . needsUpdate = true ; if ( data . filtering === "pixelated" ) { texture . magFilter = SupEngine . THREE . NearestFilter ; texture . minFilter = SupEngine . THREE . NearestFilter ; } if ( data . wrapping === "repeat" ) { texture . wrapS = SupEngine . THREE . RepeatWrapping ; texture . wrapT = SupEngine . THREE . RepeatWrapping ; } else if ( data . wrapping === "mirroredRepeat" ) { texture . wrapS = SupEngine . THREE . MirroredRepeatWrapping ; texture . wrapT = SupEngine . THREE . MirroredRepeatWrapping ; } cb ( ) ; } ; image . onerror = ( ) => { cb ( ) ; } ; image . src = `${ player . dataURL }assets/${ entry . storagePath }/map-${ key }.dat` ; } , ( ) => { callback ( null , data ) ; } ) ; } ) ; } export function createOuterAsset ( player , asset ) { return new ( < any > window ) . Sup . Sprite ( asset ) ; }