Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wynged committed Dec 7, 2022
1 parent 1e32fb2 commit b7005e9
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions Elements/src/Serialization/glTF/GltfExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -946,17 +946,19 @@ internal static Gltf InitializeGlTF(Model model,
};
gltf.Scenes = new[] { scene };

var lights = model.AllElementsOfType<Light>().ToList();
var extensions = lights.Any() ? new HashSet<string>() {
"KHR_materials_specular",
"KHR_materials_ior",
"KHR_materials_unlit",
"KHR_lights_punctual"
} : new HashSet<string>() {
var extensionsUsed = new HashSet<string> {
"KHR_materials_specular",
"KHR_materials_ior",
"KHR_materials_unlit"};
gltf.ExtensionsUsed = extensions.ToArray(extensions.Count);
"KHR_materials_unlit"
};

var lights = model.AllElementsOfType<Light>().ToList();
if (lights.Any())
{
extensionsUsed.Add("KHR_lights_punctual");
}

gltf.ExtensionsUsed = extensionsUsed.ToArray();

var bufferViews = new List<BufferView>();

Expand Down Expand Up @@ -1026,7 +1028,7 @@ internal static Gltf InitializeGlTF(Model model,
textures,
images,
samplers,
extensions,
extensionsUsed,
meshes,
nodes,
meshElementMap,
Expand Down Expand Up @@ -1102,9 +1104,9 @@ internal static Gltf InitializeGlTF(Model model,
gltf.Meshes = meshes.ToArray(meshes.Count);
}

if (extensions.Count > 0)
if (extensionsUsed.Count > 0)
{
gltf.ExtensionsUsed = extensions.ToArray();
gltf.ExtensionsUsed = extensionsUsed.ToArray();
}

// This is a hack! For web assembly, the ToArray() call creates
Expand Down

0 comments on commit b7005e9

Please sign in to comment.