Skip to content

Commit

Permalink
Merge pull request #61 from Geodan/improve_tags_error_handling
Browse files Browse the repository at this point in the history
improve tags error handling
  • Loading branch information
bertt authored Jun 11, 2024
2 parents 8549f95 + 842fbb1 commit b3dfeef
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/TileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,40 +161,40 @@ private static byte[] GetGpuGlb(object model, List<Instance> positions, bool Use
var settings = SceneBuilderSchema2Settings.WithGpuInstancing;
settings.GpuMeshInstancingMinCount = 0;
var gltf = sceneBuilder.ToGltf2(settings);
PropertyTable propertyTable = null;

var rootMetadata = gltf.UseStructuralMetadata();
var schema = rootMetadata.UseEmbeddedSchema("schema");
var schemaClass = schema.UseClassMetadata("propertyTable");

if(tags.Count > 0)
if (tags.Count > 0 && tags[0] != null)
{
var propertyTable = schemaClass.AddPropertyTable(positions.Count);
var rootMetadata = gltf.UseStructuralMetadata();
var schema = rootMetadata.UseEmbeddedSchema("schema");
var schemaClass = schema.UseClassMetadata("propertyTable");

propertyTable = schemaClass.AddPropertyTable(positions.Count);

if (tags[0] != null)
var properties = TinyJson.GetProperties(tags[0]);
foreach (var property in properties)
{
var properties = TinyJson.GetProperties(tags[0]);
foreach(var property in properties)
{
var values = TinyJson.GetValues(tags, property);
var values = TinyJson.GetValues(tags, property);

var nameProperty = schemaClass
.UseProperty(property)
.WithStringType();
var nameProperty = schemaClass
.UseProperty(property)
.WithStringType();

// todo: use other types than string
var strings = values.Select(s => s.ToString()).ToArray();
// todo: use other types than string
var strings = values.Select(s => s.ToString()).ToArray();

propertyTable
.UseProperty(nameProperty)
.SetValues(strings);
}
propertyTable
.UseProperty(nameProperty)
.SetValues(strings);
}
}

var featureId0 = propertyTable!= null?
new FeatureIDBuilder(positions.Count, 0, propertyTable):
new FeatureIDBuilder(positions.Count, 0);

gltf.LogicalNodes[0].AddInstanceFeatureIds(featureId0);

var featureId0 = new FeatureIDBuilder(positions.Count, 0, propertyTable);
gltf.LogicalNodes[0].AddInstanceFeatureIds(featureId0);
}

// todo: use exisiting transformation...
gltf.LogicalNodes[0].LocalTransform = Matrix4x4.CreateTranslation(translation);

Expand Down

0 comments on commit b3dfeef

Please sign in to comment.