Skip to content

Commit a43bfea

Browse files
authored
Merge pull request #59 from decentraland/chore/revert-gltfast-update
chore: revert gltfast update
2 parents 26f6430 + dc004b7 commit a43bfea

5 files changed

Lines changed: 29 additions & 24 deletions

File tree

Assets/Scripts/Loading/BinaryDownloadProvider.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public BinaryDownloadProvider(Dictionary<string, string> content)
2626
/// </summary>
2727
/// <param name="url">URI to request</param>
2828
/// <returns>Object representing the request</returns>
29-
public async Task<IDownload> Request(Uri url)
29+
public async Task<IDownload> RequestAsync(Uri url)
3030
{
3131
var req = new AwaitableDownload(url);
3232
await req.WaitAsync();
@@ -39,7 +39,7 @@ public async Task<IDownload> Request(Uri url)
3939
/// <param name="url">URI to request</param>
4040
/// <param name="nonReadable">If true, resulting texture is not CPU readable (uses less memory)</param>
4141
/// <returns>Object representing the request</returns>
42-
public async Task<ITextureDownload> RequestTexture(Uri url, bool nonReadable)
42+
public async Task<ITextureDownload> RequestTextureAsync(Uri url, bool nonReadable, bool forceLinear)
4343
{
4444
var fileName = Path.GetFileName(url.LocalPath);
4545
var file = _content[fileName];
@@ -159,10 +159,6 @@ public void Dispose()
159159

160160
public class AwaitableTextureDownload : AwaitableDownload, ITextureDownload
161161
{
162-
163-
/// <inheritdoc />
164-
public Texture2D Texture => (m_Request?.downloadHandler as DownloadHandlerTexture)?.texture;
165-
166162
/// <summary>
167163
/// Parameter-less constructor, required for inheritance.
168164
/// </summary>
@@ -196,5 +192,17 @@ void Init(Uri url, bool nonReadable)
196192
m_Request = CreateRequest(url, nonReadable);
197193
m_AsyncOperation = m_Request.SendWebRequest();
198194
}
195+
196+
/// <inheritdoc />
197+
public IDisposableTexture GetTexture(bool linear)
198+
{
199+
return (m_Request?.downloadHandler as DownloadHandlerTexture)?.texture.ToDisposableTexture();
200+
}
201+
}
202+
203+
internal static class DisposableTextureExtensions
204+
{
205+
internal static IDisposableTexture ToDisposableTexture(this Texture2D texture2D) =>
206+
new NonReusableTexture(texture2D);
199207
}
200208
}

Assets/Scripts/Loading/GLTFLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static async Task<LoadedModel> LoadModel(BodyShape bodyShape, EntityDefin
4242
root.SetActive(false);
4343
root.transform.SetParent(parent, false);
4444

45-
var instantiator = new DclGameObjectInstantiator(importer, root.transform);
45+
var instantiator = new GameObjectInstantiator(importer, root.transform);
4646
await importer.InstantiateSceneAsync(instantiator);
4747

4848
Sanitize(root.transform);

Assets/Scripts/Loading/ToonMaterialGenerator.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
using GLTFast;
33
using GLTFast.Logging;
44
using GLTFast.Materials;
5-
using GLTFast.Schema;
65
using UnityEngine;
76
using UnityEngine.Rendering;
8-
using Material = UnityEngine.Material;
97

108
namespace Loading
119
{
@@ -37,28 +35,28 @@ public ToonMaterialGenerator(AvatarColors avatarColors)
3735
//_avatarColors = avatarColors;
3836
}
3937

40-
public Material GenerateMaterial(MaterialBase gltfMaterial, IGltfReadable gltf,
38+
public Material GenerateMaterial(int materialIndex, GLTFast.Schema.Material gltfMaterial, IGltfReadable gltf,
4139
bool pointsSupport = false)
4240
{
4341
var isFacialFeature = IsFacialFeature(gltfMaterial.name);
4442
var mat = new Material(isFacialFeature ? CommonAssets.FacialFeaturesMaterial : CommonAssets.AvatarMaterial)
4543
{ name = gltfMaterial.name };
4644

4745
// Base color and texture
48-
var baseColor = gltfMaterial.PbrMetallicRoughness.BaseColor;
46+
var baseColor = gltfMaterial.pbrMetallicRoughness.BaseColor;
4947
mat.SetColor(BASE_COLOR_ID, baseColor);
5048

51-
if (gltfMaterial.PbrMetallicRoughness.BaseColorTexture.index != -1)
49+
if (gltfMaterial.pbrMetallicRoughness.baseColorTexture.index != -1)
5250
{
53-
mat.SetTexture(MAIN_TEX_ID, gltf.GetTexture(gltfMaterial.PbrMetallicRoughness.BaseColorTexture.index));
51+
mat.SetTexture(MAIN_TEX_ID, gltf.GetTexture(gltfMaterial.pbrMetallicRoughness.baseColorTexture.index));
5452
}
5553

5654
// Emission
5755
mat.SetColor(EMISSIVE_COLOR_ID, gltfMaterial.Emissive * EMISSIVE_MAGIC_NUMBER);
5856

59-
if (gltfMaterial.EmissiveTexture.index != -1)
57+
if (gltfMaterial.emissiveTexture.index != -1)
6058
{
61-
mat.SetTexture(EMISSIVE_TEX_ID, gltf.GetTexture(gltfMaterial.EmissiveTexture.index));
59+
mat.SetTexture(EMISSIVE_TEX_ID, gltf.GetTexture(gltfMaterial.emissiveTexture.index));
6260
}
6361

6462
// Alpha

Packages/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"com.atteneder.gltfast": "https://github.com/decentraland/unity-gltf.git#chore/gltfast-update",
3+
"com.atteneder.gltfast": "https://github.com/decentraland/unity-gltf.git",
44
"com.decentraland.unity-shared-dependencies": "git@github.com:decentraland/unity-shared-dependencies.git#main",
55
"com.unity.cinemachine": "3.1.4",
66
"com.unity.ide.rider": "3.0.39",

Packages/packages-lock.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
{
22
"dependencies": {
33
"com.atteneder.gltfast": {
4-
"version": "https://github.com/decentraland/unity-gltf.git#chore/gltfast-update",
4+
"version": "https://github.com/decentraland/unity-gltf.git",
55
"depth": 0,
66
"source": "git",
77
"dependencies": {
88
"com.unity.modules.jsonserialize": "1.0.0",
99
"com.unity.modules.unitywebrequest": "1.0.0",
1010
"com.unity.mathematics": "1.2.6",
11-
"com.unity.burst": "1.8.24",
12-
"com.unity.collections": "1.2.4"
11+
"com.unity.burst": "1.6.6"
1312
},
14-
"hash": "59e20d09a7665395eb9141180c55abdce61fdbc7"
13+
"hash": "e4587451389b6cf93b084ae434d0cc3d32a45076"
1514
},
1615
"com.decentraland.unity-shared-dependencies": {
1716
"version": "git@github.com:decentraland/unity-shared-dependencies.git#main",
1817
"depth": 0,
1918
"source": "git",
2019
"dependencies": {},
21-
"hash": "0132f23fb5d1bfa1634a872ef28e131067df7a69"
20+
"hash": "f040030e82c51bdddce67ae18149e22b5b4c4c0d"
2221
},
2322
"com.unity.burst": {
2423
"version": "1.8.28",
@@ -42,7 +41,7 @@
4241
},
4342
"com.unity.collections": {
4443
"version": "6.4.0",
45-
"depth": 1,
44+
"depth": 2,
4645
"source": "builtin",
4746
"dependencies": {
4847
"com.unity.burst": "1.8.23",
@@ -94,7 +93,7 @@
9493
},
9594
"com.unity.nuget.mono-cecil": {
9695
"version": "1.11.6",
97-
"depth": 2,
96+
"depth": 3,
9897
"source": "registry",
9998
"dependencies": {},
10099
"url": "https://packages.unity.com"
@@ -183,7 +182,7 @@
183182
},
184183
"com.unity.test-framework.performance": {
185184
"version": "3.2.0",
186-
"depth": 2,
185+
"depth": 3,
187186
"source": "registry",
188187
"dependencies": {
189188
"com.unity.test-framework": "1.1.33",

0 commit comments

Comments
 (0)