diff --git a/src/GPUTileHandler.cs b/src/GPUTileHandler.cs index d2e6da9..7604089 100644 --- a/src/GPUTileHandler.cs +++ b/src/GPUTileHandler.cs @@ -5,7 +5,6 @@ using SharpGLTF.Schema2; using SharpGLTF.Schema2.Tiles3D; using SharpGLTF.Transforms; -using System; using System.Collections.Generic; using System.Linq; using System.Numerics; @@ -26,19 +25,24 @@ public static byte[] GetGPUTile(List instances, bool UseScaleNonUnifor settings.GpuMeshInstancingMinCount = 0; var model = sceneBuilder.ToGltf2(settings); - var schema = AddMetadataSchema(model); - var distinctModels = instances.Select(s => s.Model).Distinct(); + // check if one of the instances has tags + if (instances.Any(s => s.Tags != null)) + { + var schema = AddMetadataSchema(model); - var i = 0; + var distinctModels = instances.Select(s => s.Model).Distinct(); - foreach (var distinctModel in distinctModels) - { - var modelInstances = instances.Where(s => s.Model.Equals(distinctModel)).ToList(); - var featureIdBuilder = GetFeatureIdBuilder(schema, modelInstances); - var node = model.LogicalNodes[i]; - node.AddInstanceFeatureIds(featureIdBuilder); - i++; + var i = 0; + + foreach (var distinctModel in distinctModels) + { + var modelInstances = instances.Where(s => s.Model.Equals(distinctModel)).ToList(); + var featureIdBuilder = GetFeatureIdBuilder(schema, modelInstances); + var node = model.LogicalNodes[i]; + node.AddInstanceFeatureIds(featureIdBuilder); + i++; + } } foreach (var node in model.LogicalNodes)