public string GetFeatureTableJson() { var offset = 0; FeatureTable.InstancesLength = Positions.Count; FeatureTable.PositionOffset = new ByteOffset() { byteOffset = offset }; if (NormalUps != null) { offset += Positions.ToBytes().Count(); FeatureTable.NormalUpOffset = new ByteOffset() { byteOffset = offset }; } if (NormalRights != null) { offset += NormalRights.ToBytes().Count(); FeatureTable.NormalRightOffset = new ByteOffset() { byteOffset = offset }; } if (ScaleNonUniforms != null) { offset += ScaleNonUniforms.ToBytes().Count(); FeatureTable.ScaleNonUniformOffset = new ByteOffset() { byteOffset = offset }; } var options = new JsonSerializerOptions() { IgnoreNullValues = true }; var featureTableJson = JsonSerializer.Serialize(FeatureTable, options); return(featureTableJson); }
public string GetFeatureTableJson(string batchIdSerializeType = "UNSIGNED_SHORT", int batchIdBytesLength = 0) { var offset = 0; FeatureTable.InstancesLength = Positions.Count; FeatureTable.PositionOffset = new ByteOffset() { offset = offset }; offset += Positions.ToBytes().Count(); if (NormalUps != null) { FeatureTable.NormalUpOffset = new ByteOffset() { offset = offset }; offset += NormalUps.ToBytes().Count(); } if (NormalRights != null) { FeatureTable.NormalRightOffset = new ByteOffset() { offset = offset }; offset += NormalRights.ToBytes().Count(); } if (ScaleNonUniforms != null) { FeatureTable.ScaleNonUniformOffset = new ByteOffset() { offset = offset }; offset += ScaleNonUniforms.ToBytes().Count(); } if (Scales != null) { FeatureTable.ScaleOffset = new ByteOffset() { offset = offset }; offset += Scales.ToBytes().Count(); } if (RtcCenter != null) { FeatureTable.RtcCenter = RtcCenter; offset += ((Vector3)RtcCenter).ToBytes().Count(); } if (BatchIds != null) { FeatureTable.BatchIdOffset = new ByteOffset() { offset = offset, componentType = batchIdSerializeType }; // not needed beacuse last one: offset += batchIdBytesLength; } var options = new JsonSerializerOptions() { IgnoreNullValues = true }; options.Converters.Add(new Vector3Converter()); var featureTableJson = JsonSerializer.Serialize(FeatureTable, options); return(featureTableJson); }