| | 1 | | using GLTFast; |
| | 2 | | using System; |
| | 3 | | using GLTFast.Loading; |
| | 4 | |
|
| | 5 | | namespace DCL.GLTFast.Wrappers |
| | 6 | | { |
| | 7 | | internal class GLTFastTexturePromiseWrapper : ITextureDownload |
| | 8 | | { |
| | 9 | | private readonly AssetPromiseKeeper_Texture texturePromiseKeeper; |
| | 10 | | private AssetPromise_Texture assetPromiseTexture; |
| | 11 | |
|
| 34 | 12 | | public GLTFastTexturePromiseWrapper(AssetPromiseKeeper_Texture texturePromiseKeeper, AssetPromise_Texture assetP |
| | 13 | | { |
| 34 | 14 | | this.texturePromiseKeeper = texturePromiseKeeper; |
| 34 | 15 | | this.assetPromiseTexture = assetPromiseTexture; |
| | 16 | |
|
| 34 | 17 | | this.assetPromiseTexture.OnSuccessEvent += OnSuccess; |
| 34 | 18 | | assetPromiseTexture.OnFailEvent += OnFail; |
| 34 | 19 | | } |
| | 20 | |
|
| | 21 | | public void Dispose() |
| | 22 | | { |
| 102 | 23 | | if (assetPromiseTexture == null) return; |
| | 24 | |
|
| 34 | 25 | | assetPromiseTexture.OnSuccessEvent -= OnSuccess; |
| 34 | 26 | | assetPromiseTexture.OnFailEvent -= OnFail; |
| | 27 | |
|
| 34 | 28 | | assetPromiseTexture = null; |
| 34 | 29 | | } |
| | 30 | |
|
| 102 | 31 | | public bool Success { get; private set; } |
| | 32 | |
|
| 0 | 33 | | public string Error { get; private set; } |
| | 34 | |
|
| 0 | 35 | | public byte[] Data => Array.Empty<byte>(); |
| | 36 | |
|
| 0 | 37 | | public string Text => string.Empty; |
| | 38 | |
|
| 0 | 39 | | public bool? IsBinary => true; |
| | 40 | |
|
| | 41 | | public IDisposableTexture GetTexture(bool forceSampleLinear) => |
| 34 | 42 | | new GLTFastDisposableDisposableTexturePromise(assetPromiseTexture, texturePromiseKeeper); |
| | 43 | |
|
| | 44 | | private void OnSuccess(Asset_Texture assetTexture) |
| | 45 | | { |
| 34 | 46 | | Success = true; |
| 34 | 47 | | } |
| | 48 | |
|
| | 49 | | private void OnFail(Asset_Texture arg1, Exception arg2) |
| | 50 | | { |
| 0 | 51 | | Error = arg2.ToString(); |
| 0 | 52 | | } |
| | 53 | | } |
| | 54 | | } |