├── .gitignore ├── LICENSE ├── README.md └── src ├── i3d.tile ├── BufferPadding.cs ├── ByteConvertor.cs ├── ByteOffset.cs ├── FeatureTable.cs ├── FloatExtensions.cs ├── I3dm.cs ├── I3dmHeader.cs ├── I3dmReader.cs ├── I3dmWriter.cs ├── Vector3Convertor.cs ├── Vector3Extensions.cs └── i3dm.tile.csproj ├── i3dm.tile.benchmarks ├── I3dmBenchmarks.cs ├── Program.cs ├── barrel.glb ├── barrel.i3dm └── i3dm.tile.benchmarks.csproj ├── i3dm.tile.sln └── i3dm.tile.tests ├── BufferPaddingTests.cs ├── ByteConvertorTests.cs ├── FeatureTableTests.cs ├── FloatExtensionTests.cs ├── I3dmCompareTests.cs ├── I3dmReaderTest.cs ├── I3dmWriterTest.cs ├── i3dm.tile.tests.csproj └── testfixtures ├── 4326_1.i3dm ├── barrel.batch ├── barrel.glb ├── barrel.i3dm ├── external_uri.i3dm ├── i3dm.withpadding.i3dm ├── instancedAnimated.i3dm ├── instancedOrientation.i3dm ├── instancedRTC.i3dm ├── instancedTextured.i3dm ├── instancedWithBatchTable.i3dm ├── stoel000.glb ├── tree.batch ├── tree.glb ├── tree.i3dm └── tree_billboard.i3dm /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | /src/*.ncrunchsolution 352 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Bert Temme 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # i3dm-tile-cs 2 | 3 | .NET 8 library for reading/writing Instanced 3DTiles (i3dm) 4 | 5 | i3dm specs: 6 | 7 | https://github.com/CesiumGS/3d-tiles/tree/master/specification/TileFormats/Instanced3DModel 8 | 9 | ## NuGet 10 | 11 | https://www.nuget.org/packages/i3dm.tile/ 12 | 13 | ## Sample code 14 | 15 | Reading i3dm. Supply the i3dm filename. 16 | 17 | ``` 18 | var i3dmfile = File.OpenRead(@"test.i3dm"); 19 | var i3dm = I3dmReader.Read(i3dmfile); 20 | ``` 21 | 22 | The i3dm object contains the glTF, FeatureTable (for instance Positions, NormalUps, NormalRights, ScaleNonUniforms, Scales) and 23 | BatchTable information. 24 | 25 | Writing i3dm. Supply the GLB (as byte[]) and instance positions (as list of Vector3). Optionally 26 | instance NormalUps, NormalRights, Scales and ScaleNonUniforms can be provided. 27 | 28 | ``` 29 | var i3dm = new I3dm.Tile.I3dm(positions, glb); 30 | var bytes = I3dmWriter.Write(i3dm); 31 | ``` 32 | 33 | When writing an i3dm, also an external url can be provided to the glTF model instead of embedding the glTF in each tile: 34 | 35 | ``` 36 | var glbUrl = "http://myserver/test.glb"; 37 | var i3dm = new I3dm.Tile.I3dm(positions, glbUrl); 38 | var bytes = I3dmWriter.Write(i3dm); 39 | ``` 40 | 41 | Batch Id's are written in the FeatureTable by default as type 'UNSIGNED_SHORT', sample to use 'UNSIGNED_BYTE': 42 | 43 | ``` 44 | var batchIds = new List() { 0, 1 }; 45 | var i3dm = new I3dm.Tile.I3dm(positions, glb); 46 | i3dm.BatchIds = batchIds; 47 | var bytes = I3dmWriter.Write(i3dm, "UNSIGNED_BYTE"); 48 | ``` 49 | 50 | ## Benchmarks 51 | 52 | ``` 53 | BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19041.329 (2004/?/20H1) 54 | Intel Core i7-9750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores 55 | .NET Core SDK=3.1.301 56 | [Host] : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT 57 | DefaultJob : .NET Core 3.1.5 (CoreCLR 4.700.20.26901, CoreFX 4.700.20.27001), X64 RyuJIT 58 | 59 | 60 | | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | 61 | |---------- |-----------:|---------:|---------:|---------:|---------:|---------:|----------:| 62 | | ReadI3dm | 163.4 us | 1.79 us | 1.59 us | 111.0840 | 111.0840 | 111.0840 | 359.43 KB | 63 | | WriteI3dm | 2,208.6 us | 41.15 us | 36.48 us | 109.3750 | 109.3750 | 109.3750 | 418.31 KB | 64 | ``` 65 | 66 | ## Known limits 67 | 68 | Not implemented (yet): 69 | 70 | - quantized and oct encoded properties 71 | 72 | QUANTIZED_VOLUME_OFFSET, QUANTIZED_VOLUME_SCALE, POSITION_QUANTIZED, NORMAL_UP_OCT32P, NORMAL_RIGHT_OCT32P 73 | 74 | 75 | ## Dependencies 76 | 77 | - System.Text.Json 78 | 79 | ## History 80 | 81 | 2024-07-24 - 1.1.3 Fix reading I3dm with glb padding 82 | 83 | 2024-07-24 - 1.1.2 Fix reading I3dm with external uri (gltfFormat == 0) 84 | 85 | 2024-07-24 - 1.1.1 Fix reading I3dm with padding bytes 86 | 87 | 2024-07-24 - 1.1 to .NET 8 88 | 89 | 2022-12-08 - 1.0 to .NET 6 90 | 91 | 2021-09-23 - 0.5.1 Add padding rules 92 | 93 | 2020-11-04 - 0.5: Breaking change: void I3dmWriter.Write(string path, I3dm i3dm) -> byte[] I3dmWriter.Write(I3dm i3dm) 94 | 95 | 2020-11-02 - 0.4.2: add write to stream 96 | 97 | 2020-11-02 - 0.4.1: add support for composite tiles (cmpt) 98 | 99 | 2020-10-19 - 0.3.3: add support for external glb (gltfFormat == 0) 100 | 101 | 2020-08-27 - 0.3.2: add support for rtc_center for high precision positions 102 | 103 | 2020-07-01 - 0.3.1: adding 8 byte padding requirements 104 | 105 | 2020-06-29 - 0.3: adding FeatureTable batchIds formats (unsigned byte, unsigned short, unsigned int), scale and rtc_center 106 | 107 | 2020-06-25 - 0.2: Adding writing i3dm tiles 108 | 109 | 2020-06-22 - 0.1: Initial version - reading i3dm tiles -------------------------------------------------------------------------------- /src/i3d.tile/BufferPadding.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Text; 3 | 4 | namespace I3dm.Tile 5 | { 6 | public static class BufferPadding 7 | { 8 | private static int boundary = 8; 9 | public static byte[] AddPadding(byte[] bytes) 10 | { 11 | var remainder = bytes.Length % boundary; 12 | var padding = (remainder == 0) ? 0 : boundary - remainder; 13 | var whitespace = new string(' ', padding); 14 | var paddingBytes = Encoding.UTF8.GetBytes(whitespace); 15 | var res = bytes.Concat(paddingBytes); 16 | return res.ToArray(); 17 | } 18 | public static string AddPadding(string input) 19 | { 20 | var bytes = Encoding.UTF8.GetBytes(input); 21 | var paddedBytes = BufferPadding.AddPadding(bytes); 22 | var result = Encoding.UTF8.GetString(paddedBytes); 23 | return result; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/i3d.tile/ByteConvertor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace I3dm.Tile 5 | { 6 | public static class ByteConvertor 7 | { 8 | public static byte[] ToBytes(List ids) 9 | { 10 | var res = new List(); 11 | foreach (var id in ids) 12 | { 13 | if (typeof(T).Equals(typeof(byte))) 14 | { 15 | res.Add((byte)id); 16 | } 17 | else if (typeof(T).Equals(typeof(ushort))) 18 | { 19 | var p = Convert.ToUInt16(id); 20 | res.AddRange(BitConverter.GetBytes(p)); 21 | } 22 | else if (typeof(T).Equals(typeof(uint))) 23 | { 24 | var p = Convert.ToUInt32(id); 25 | res.AddRange(BitConverter.GetBytes(p)); 26 | } 27 | 28 | } 29 | return res.ToArray(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/i3d.tile/ByteOffset.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace I3dm.Tile 4 | { 5 | public class ByteOffset 6 | { 7 | [JsonPropertyName("byteOffset")] 8 | 9 | public int offset { get; set; } 10 | 11 | public string componentType { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/i3d.tile/FeatureTable.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace I3dm.Tile 5 | { 6 | // todo: add QUANTIZED_VOLUME_OFFSET, QUANTIZED_VOLUME_SCALE 7 | // todo: add POSITION_QUANTIZED, NORMAL_UP_OCT32P, NORMAL_RIGHT_OCT32P 8 | public class FeatureTable 9 | { 10 | public FeatureTable() 11 | { 12 | IsEastNorthUp = true; 13 | } 14 | 15 | [JsonPropertyName("INSTANCES_LENGTH")] 16 | public int InstancesLength { get; set; } 17 | 18 | [JsonPropertyName("POSITION")] 19 | public ByteOffset PositionOffset { get; set; } 20 | 21 | [JsonPropertyName("NORMAL_UP")] 22 | public ByteOffset NormalUpOffset { get; set; } 23 | 24 | [JsonPropertyName("NORMAL_RIGHT")] 25 | public ByteOffset NormalRightOffset { get; set; } 26 | 27 | [JsonPropertyName("SCALE_NON_UNIFORM")] 28 | public ByteOffset ScaleNonUniformOffset { get; set; } 29 | 30 | [JsonPropertyName("SCALE")] 31 | public ByteOffset ScaleOffset { get; set; } 32 | 33 | [JsonPropertyName("BATCH_ID")] 34 | public ByteOffset BatchIdOffset { get; set; } 35 | 36 | [JsonPropertyName("EAST_NORTH_UP")] 37 | public bool IsEastNorthUp { get; set; } 38 | 39 | [JsonPropertyName("RTC_CENTER")] 40 | public Vector3? RtcCenter { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /src/i3d.tile/FloatExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace I3dm.Tile 5 | { 6 | public static class FloatExtensions 7 | { 8 | public static byte[] ToBytes(this IEnumerable floats) 9 | { 10 | var bytes = new List(); 11 | foreach (var f in floats) 12 | { 13 | bytes.AddRange(BitConverter.GetBytes(f)); 14 | } 15 | return bytes.ToArray(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/i3d.tile/I3dm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Numerics; 5 | using System.Text.Json; 6 | using System.Text.Json.Serialization; 7 | 8 | namespace I3dm.Tile 9 | { 10 | public class I3dm 11 | { 12 | private I3dm() 13 | { 14 | I3dmHeader = new I3dmHeader(); 15 | FeatureTable = new FeatureTable(); 16 | FeatureTableJson = string.Empty; 17 | BatchTableJson = string.Empty; 18 | FeatureTableBinary = new byte[0]; 19 | BatchTableBinary = new byte[0]; 20 | } 21 | 22 | public I3dm(List positions, byte[] glb) : this() 23 | { 24 | I3dmHeader.GltfFormat = 1; 25 | Positions = positions; 26 | GlbData = glb; 27 | } 28 | 29 | public I3dm(List positions, string glbUrl) : this() 30 | { 31 | I3dmHeader.GltfFormat = 0; 32 | Positions = positions; 33 | GlbUrl = glbUrl; 34 | } 35 | 36 | public I3dmHeader I3dmHeader { get; set; } 37 | public string FeatureTableJson { get; set; } 38 | public byte[] FeatureTableBinary { get; set; } 39 | public string BatchTableJson { get; set; } 40 | public byte[] BatchTableBinary { get; set; } 41 | public byte[] GlbData { get; set; } 42 | public string GlbUrl { get; set; } 43 | public FeatureTable FeatureTable { get; set; } 44 | public List Positions { get; set; } 45 | public List NormalUps { get; set; } 46 | public List NormalRights { get; set; } 47 | public List ScaleNonUniforms { get; set; } 48 | public List Scales { get; set; } 49 | public List BatchIds { get; set; } 50 | public Vector3? RtcCenter { get; set; } 51 | public bool HasPadding { get; set; } 52 | public string Uri { get; set; } 53 | 54 | public string GetFeatureTableJson(string batchIdSerializeType = "UNSIGNED_SHORT", int batchIdBytesLength=0) 55 | { 56 | var offset = 0; 57 | FeatureTable.InstancesLength = Positions.Count; 58 | FeatureTable.PositionOffset = new ByteOffset() { offset = offset }; 59 | offset += Positions.ToBytes().Count(); 60 | if (NormalUps != null) 61 | { 62 | FeatureTable.NormalUpOffset = new ByteOffset() { offset = offset}; 63 | offset += NormalUps.ToBytes().Count(); 64 | } 65 | if (NormalRights != null) 66 | { 67 | FeatureTable.NormalRightOffset = new ByteOffset() { offset = offset }; 68 | offset += NormalRights.ToBytes().Count(); 69 | } 70 | if (ScaleNonUniforms != null) 71 | { 72 | FeatureTable.ScaleNonUniformOffset = new ByteOffset() { offset = offset }; 73 | offset += ScaleNonUniforms.ToBytes().Count(); 74 | } 75 | if (Scales != null) 76 | { 77 | FeatureTable.ScaleOffset = new ByteOffset() { offset = offset }; 78 | offset += Scales.ToBytes().Count(); 79 | } 80 | if(RtcCenter != null) 81 | { 82 | FeatureTable.RtcCenter = RtcCenter; 83 | offset += ((Vector3)RtcCenter).ToBytes().Count(); 84 | } 85 | if (BatchIds != null) 86 | { 87 | FeatureTable.BatchIdOffset = new ByteOffset() { offset = offset, componentType = batchIdSerializeType }; 88 | // not needed beacuse last one: offset += batchIdBytesLength; 89 | } 90 | 91 | var options = new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull}; 92 | options.Converters.Add(new Vector3Converter()); 93 | var featureTableJson = JsonSerializer.Serialize(FeatureTable, options); 94 | return featureTableJson; 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/i3d.tile/I3dmHeader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace I3dm.Tile 8 | { 9 | public class I3dmHeader 10 | { 11 | public string Magic { get; set; } 12 | public int Version { get; set; } 13 | public int ByteLength { get; set; } 14 | public int FeatureTableJsonByteLength { get; set; } 15 | public int FeatureTableBinaryByteLength { get; set; } 16 | public int BatchTableJsonByteLength { get; set; } 17 | public int BatchTableBinaryByteLength { get; set; } 18 | 19 | public int GltfFormat { get; set; } 20 | 21 | public I3dmHeader() 22 | { 23 | Magic = "i3dm"; 24 | Version = 1; 25 | FeatureTableJsonByteLength = 0; 26 | FeatureTableBinaryByteLength = 0; 27 | BatchTableJsonByteLength = 0; 28 | BatchTableBinaryByteLength = 0; 29 | GltfFormat = 1; 30 | } 31 | 32 | public I3dmHeader(BinaryReader reader) 33 | { 34 | Magic = Encoding.UTF8.GetString(reader.ReadBytes(4)); 35 | Version = (int)reader.ReadUInt32(); 36 | ByteLength = (int)reader.ReadUInt32(); 37 | 38 | FeatureTableJsonByteLength = (int)reader.ReadUInt32(); 39 | FeatureTableBinaryByteLength = (int)reader.ReadUInt32(); 40 | BatchTableJsonByteLength = (int)reader.ReadUInt32(); 41 | BatchTableBinaryByteLength = (int)reader.ReadUInt32(); 42 | GltfFormat = (int)reader.ReadUInt32(); 43 | } 44 | 45 | public int Length 46 | { 47 | get 48 | { 49 | return 32 + FeatureTableJsonByteLength + FeatureTableBinaryByteLength + BatchTableJsonByteLength + BatchTableBinaryByteLength; 50 | } 51 | } 52 | 53 | public byte[] AsBinary() 54 | { 55 | var magicBytes = Encoding.UTF8.GetBytes(Magic); 56 | var versionBytes = BitConverter.GetBytes(Version); 57 | var byteLengthBytes = BitConverter.GetBytes(ByteLength); 58 | var featureTableJsonByteLengthBytes = BitConverter.GetBytes(FeatureTableJsonByteLength); 59 | var featureTableBinaryByteLengthBytes = BitConverter.GetBytes(FeatureTableBinaryByteLength); 60 | var batchTableJsonByteLength = BitConverter.GetBytes(BatchTableJsonByteLength); 61 | var batchTableBinaryByteLength = BitConverter.GetBytes(BatchTableBinaryByteLength); 62 | var gltfFormatBytes = BitConverter.GetBytes(GltfFormat); 63 | 64 | return magicBytes. 65 | Concat(versionBytes). 66 | Concat(byteLengthBytes). 67 | Concat(featureTableJsonByteLengthBytes). 68 | Concat(featureTableBinaryByteLengthBytes). 69 | Concat(batchTableJsonByteLength). 70 | Concat(batchTableBinaryByteLength). 71 | Concat(gltfFormatBytes). 72 | ToArray(); 73 | } 74 | 75 | public List Validate() 76 | { 77 | var res = new List(); 78 | 79 | var headerByteLength = AsBinary().Count(); 80 | var featureTableJsonByteOffset = headerByteLength; 81 | var featureTableBinaryByteOffset = featureTableJsonByteOffset + FeatureTableJsonByteLength; 82 | var batchTableJsonByteOffset = featureTableBinaryByteOffset + FeatureTableBinaryByteLength; 83 | var batchTableBinaryByteOffset = batchTableJsonByteOffset + BatchTableJsonByteLength; 84 | var glbByteOffset = batchTableBinaryByteOffset + BatchTableBinaryByteLength; 85 | 86 | if (featureTableBinaryByteOffset % 8 > 0) 87 | { 88 | res.Add("Feature table binary must be aligned to an 8-byte boundary."); 89 | } 90 | if (batchTableBinaryByteOffset % 8 > 0) 91 | { 92 | res.Add("Batch table binary must be aligned to an 8-byte boundary."); 93 | } 94 | if (glbByteOffset % 8 > 0) 95 | { 96 | res.Add("Glb must be aligned to an 8-byte boundary."); 97 | } 98 | 99 | return res; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/i3d.tile/I3dmReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Numerics; 6 | using System.Text; 7 | using System.Text.Json; 8 | using System.Text.Json.Serialization; 9 | 10 | namespace I3dm.Tile 11 | { 12 | public struct I3dmReader 13 | { 14 | public static I3dm Read(BinaryReader reader) 15 | { 16 | var i3dmHeader = new I3dmHeader(reader); 17 | var featureTableJson = Encoding.UTF8.GetString(reader.ReadBytes(i3dmHeader.FeatureTableJsonByteLength)); 18 | var featureTableBytes = reader.ReadBytes(i3dmHeader.FeatureTableBinaryByteLength); 19 | var batchTableJson = Encoding.UTF8.GetString(reader.ReadBytes(i3dmHeader.BatchTableJsonByteLength)); 20 | var batchTableBytes = reader.ReadBytes(i3dmHeader.BatchTableBinaryByteLength); 21 | 22 | // the rest of the file is the glb 23 | var glbMaxLength = i3dmHeader.ByteLength - i3dmHeader.Length; 24 | var glbBuffer = reader.ReadBytes(glbMaxLength); 25 | 26 | 27 | var serializeOptions = new JsonSerializerOptions(); 28 | serializeOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; 29 | serializeOptions.Converters.Add(new Vector3Converter()); 30 | var featureTable = JsonSerializer.Deserialize(featureTableJson.TrimEnd(), serializeOptions); 31 | 32 | var positions = GetVector3Collection(featureTable.InstancesLength, featureTable.PositionOffset.offset, featureTableBytes); 33 | 34 | var i3dm = i3dmHeader.GltfFormat == 0 ? 35 | new I3dm(positions, Encoding.UTF8.GetString(glbBuffer).TrimEnd()) : 36 | new I3dm(positions, glbBuffer); 37 | 38 | if (i3dmHeader.GltfFormat == 0) 39 | { 40 | // if the glb is a uri 41 | var uri = Encoding.UTF8.GetString(glbBuffer).TrimEnd(); 42 | i3dm.Uri = uri; 43 | } 44 | else 45 | { 46 | // but we get the length from the glb itself 47 | var glbLength = BitConverter.ToInt32(glbBuffer, 8); 48 | 49 | // if the glb is shorter than the expected length, we need to trim the buffer 50 | if (glbLength < glbMaxLength) 51 | { 52 | glbBuffer = glbBuffer.Take(glbLength).ToArray(); 53 | i3dm.HasPadding = true; 54 | } 55 | i3dm.GlbData= glbBuffer; 56 | } 57 | 58 | i3dm.I3dmHeader = i3dmHeader; 59 | i3dm.FeatureTableJson = featureTableJson; 60 | i3dm.FeatureTableBinary = featureTableBytes; 61 | i3dm.BatchTableJson = batchTableJson; 62 | i3dm.BatchTableBinary = batchTableBytes; 63 | i3dm.FeatureTable = featureTable; 64 | 65 | if (featureTable.NormalUpOffset != null) 66 | { 67 | i3dm.NormalUps = GetVector3Collection(featureTable.InstancesLength, featureTable.NormalUpOffset.offset, featureTableBytes); 68 | } 69 | if (featureTable.NormalRightOffset != null) 70 | { 71 | i3dm.NormalRights = GetVector3Collection(featureTable.InstancesLength, featureTable.NormalRightOffset.offset, featureTableBytes); 72 | } 73 | if (featureTable.ScaleNonUniformOffset != null) 74 | { 75 | i3dm.ScaleNonUniforms= GetVector3Collection(featureTable.InstancesLength, featureTable.ScaleNonUniformOffset.offset, featureTableBytes); 76 | } 77 | if (featureTable.BatchIdOffset != null) 78 | { 79 | i3dm.BatchIds = GetBatchIdCollection(featureTable.InstancesLength, featureTable.BatchIdOffset.offset, featureTableBytes, featureTable.BatchIdOffset.componentType); 80 | } 81 | if (featureTable.ScaleOffset != null) 82 | { 83 | i3dm.Scales = GetFloatCollection(featureTable.InstancesLength, featureTable.ScaleOffset.offset, featureTableBytes); 84 | } 85 | if (featureTable.RtcCenter != null) 86 | { 87 | i3dm.RtcCenter = featureTable.RtcCenter; 88 | } 89 | 90 | return i3dm; 91 | } 92 | 93 | public static I3dm Read(Stream stream) 94 | { 95 | var reader = new BinaryReader(stream); 96 | var i3dm = Read(reader); 97 | return i3dm; 98 | } 99 | 100 | 101 | private static List GetFloatCollection(int instances, int offset, byte[] featureTable) 102 | { 103 | var res = new List(); 104 | for (var i = 0; i < instances; i++) 105 | { 106 | res.Add(BitConverter.ToSingle(featureTable, i * 4 + offset)); 107 | } 108 | 109 | return res; 110 | } 111 | 112 | private static List GetBatchIdCollection(int instances, int offset, byte[] featureTable, string componentType) 113 | { 114 | var res = new List(); 115 | for (var i = 0; i < instances; i++) 116 | { 117 | int batchId=0; 118 | switch (componentType) 119 | { 120 | case "UNSIGNED_BYTE": 121 | batchId = featureTable[i + offset]; 122 | break; 123 | case "UNSIGNED_SHORT": 124 | batchId = BitConverter.ToUInt16(featureTable, i*2 + offset); 125 | break; 126 | case "UNSIGNED_INT": 127 | batchId = (int)BitConverter.ToUInt32(featureTable, i*4 + offset); 128 | break; 129 | } 130 | res.Add(batchId); 131 | } 132 | 133 | return res; 134 | } 135 | 136 | private static List GetVector3Collection(int instances, int offset, byte[] featureTable) 137 | { 138 | var res = new List(); 139 | for (var i = 0; i < instances; i++) 140 | { 141 | Vector3 vector = GetVector3(offset, featureTable, i); 142 | res.Add(vector); 143 | } 144 | return res; 145 | } 146 | 147 | private static Vector3 GetVector3(int offset, byte[] featureTable, int i=0) 148 | { 149 | var x = BitConverter.ToSingle(featureTable, i * 12 + 0 + offset); 150 | var y = BitConverter.ToSingle(featureTable, i * 12 + 4 + offset); 151 | var z = BitConverter.ToSingle(featureTable, i * 12 + 8 + offset); 152 | var vector = new Vector3(x, y, z); 153 | return vector; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/i3d.tile/I3dmWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Numerics; 5 | using System.Text; 6 | 7 | namespace I3dm.Tile 8 | { 9 | public struct I3dmWriter 10 | { 11 | public static byte[] Write(I3dm i3dm, string batchIdSerializeType = "UNSIGNED_SHORT") 12 | { 13 | UpdateProperties(i3dm, batchIdSerializeType); 14 | var stream = new MemoryStream(); 15 | WriteToStream(i3dm, stream); 16 | return stream.ToArray(); 17 | } 18 | 19 | private static void WriteToStream(I3dm i3dm, Stream stream) 20 | { 21 | var binaryWriter = new BinaryWriter(stream); 22 | binaryWriter.Write(i3dm.I3dmHeader.AsBinary()); 23 | 24 | binaryWriter.Write(Encoding.UTF8.GetBytes(i3dm.FeatureTableJson)); 25 | if (i3dm.FeatureTableBinary != null) 26 | { 27 | binaryWriter.Write(i3dm.FeatureTableBinary); 28 | } 29 | binaryWriter.Write(Encoding.UTF8.GetBytes(i3dm.BatchTableJson)); 30 | 31 | if (i3dm.BatchTableBinary != null) 32 | { 33 | binaryWriter.Write(i3dm.BatchTableBinary); 34 | } 35 | 36 | if (i3dm.I3dmHeader.GltfFormat == 0) 37 | { 38 | binaryWriter.Write(Encoding.UTF8.GetBytes(i3dm.GlbUrl)); 39 | } 40 | else 41 | { 42 | binaryWriter.Write(i3dm.GlbData); 43 | } 44 | binaryWriter.Flush(); 45 | binaryWriter.Close(); 46 | } 47 | 48 | private static void UpdateProperties(I3dm i3dm, string batchIdSerializeType) 49 | { 50 | var batchIdBytes = new byte[0]; 51 | if (i3dm.BatchIds != null) 52 | { 53 | batchIdBytes = GetBatchIdsBytes(i3dm.BatchIds, batchIdSerializeType); 54 | } 55 | 56 | i3dm.FeatureTableJson = BufferPadding.AddPadding(i3dm.GetFeatureTableJson(batchIdSerializeType, batchIdBytes.Length)); 57 | 58 | var featureTableBinary = new List(); 59 | featureTableBinary.AddRange(i3dm.Positions.ToBytes()); 60 | if (i3dm.NormalUps != null) 61 | { 62 | featureTableBinary.AddRange(i3dm.NormalUps.ToBytes()); 63 | } 64 | if (i3dm.NormalRights != null) 65 | { 66 | featureTableBinary.AddRange(i3dm.NormalRights.ToBytes()); 67 | } 68 | if (i3dm.ScaleNonUniforms != null) 69 | { 70 | featureTableBinary.AddRange(i3dm.ScaleNonUniforms.ToBytes()); 71 | } 72 | if (i3dm.Scales != null) 73 | { 74 | featureTableBinary.AddRange(i3dm.Scales.ToBytes()); 75 | } 76 | if (i3dm.BatchIds != null) 77 | { 78 | featureTableBinary.AddRange(batchIdBytes); 79 | } 80 | if (i3dm.RtcCenter != null) 81 | { 82 | featureTableBinary.AddRange(((Vector3)i3dm.RtcCenter).ToBytes()); 83 | } 84 | if (i3dm.BatchTableJson != string.Empty) 85 | { 86 | i3dm.BatchTableJson = BufferPadding.AddPadding(i3dm.BatchTableJson); 87 | } 88 | if (i3dm.BatchTableBinary != null) 89 | { 90 | i3dm.BatchTableBinary = BufferPadding.AddPadding(i3dm.BatchTableBinary); 91 | } 92 | 93 | i3dm.FeatureTableBinary = BufferPadding.AddPadding(featureTableBinary.ToArray()); 94 | 95 | var header_length = 28; 96 | 97 | if(i3dm.I3dmHeader.GltfFormat == 0) 98 | { 99 | i3dm.GlbUrl = BufferPadding.AddPadding(i3dm.GlbUrl); 100 | } 101 | else 102 | { 103 | i3dm.GlbData = BufferPadding.AddPadding(i3dm.GlbData); 104 | } 105 | 106 | var glbLength = i3dm.I3dmHeader.GltfFormat == 0 ? i3dm.GlbUrl.Length : i3dm.GlbData.Length; 107 | 108 | i3dm.I3dmHeader.ByteLength = 109 | glbLength + header_length + 110 | i3dm.FeatureTableJson.Length + 111 | Encoding.UTF8.GetByteCount(i3dm.BatchTableJson) + 112 | i3dm.BatchTableBinary.Length + 113 | i3dm.FeatureTableBinary.Length + 114 | BitConverter.GetBytes(i3dm.I3dmHeader.GltfFormat).Length; 115 | 116 | i3dm.I3dmHeader.FeatureTableJsonByteLength = i3dm.FeatureTableJson.Length; 117 | i3dm.I3dmHeader.BatchTableJsonByteLength = Encoding.UTF8.GetByteCount(i3dm.BatchTableJson); 118 | i3dm.I3dmHeader.FeatureTableBinaryByteLength = i3dm.FeatureTableBinary.Length; 119 | i3dm.I3dmHeader.BatchTableBinaryByteLength = i3dm.BatchTableBinary.Length; 120 | } 121 | 122 | private static byte[] GetBatchIdsBytes(List inputs, string batchIdSerializeType) 123 | { 124 | byte[] res = null; 125 | switch (batchIdSerializeType) 126 | { 127 | case "UNSIGNED_BYTE": 128 | res = ByteConvertor.ToBytes(inputs); 129 | break; 130 | case "UNSIGNED_SHORT": 131 | res = ByteConvertor.ToBytes(inputs); 132 | break; 133 | case "UNSIGNED_INT": 134 | res = ByteConvertor.ToBytes(inputs); 135 | break; 136 | } 137 | 138 | return res; 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/i3d.tile/Vector3Convertor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Numerics; 4 | using System.Text.Json; 5 | using System.Text.Json.Serialization; 6 | 7 | namespace I3dm.Tile 8 | { 9 | public class Vector3Converter : JsonConverter 10 | { 11 | public override void Write(Utf8JsonWriter writer, Vector3 vector, JsonSerializerOptions options) 12 | { 13 | writer.WriteStartArray(); 14 | writer.WriteNumberValue(vector.X); 15 | writer.WriteNumberValue(vector.Y); 16 | writer.WriteNumberValue(vector.Z); 17 | writer.WriteEndArray(); 18 | } 19 | 20 | public override Vector3 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 21 | { 22 | if(reader.TokenType == JsonTokenType.StartArray) 23 | { 24 | reader.Read(); 25 | var elements = new List(); 26 | 27 | while (reader.TokenType != JsonTokenType.EndArray) 28 | { 29 | var val = JsonSerializer.Deserialize(ref reader, options); 30 | elements.Add(val); 31 | reader.Read(); 32 | } 33 | 34 | return new Vector3(elements[0], elements[1], elements[2]); 35 | } 36 | throw new JsonException(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/i3d.tile/Vector3Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Numerics; 4 | 5 | namespace I3dm.Tile 6 | { 7 | public static class Vector3Extensions 8 | { 9 | public static byte[] ToBytes(this Vector3 vector) 10 | { 11 | var res = new List(); 12 | res.AddRange(BitConverter.GetBytes(vector.X)); 13 | res.AddRange(BitConverter.GetBytes(vector.Y)); 14 | res.AddRange(BitConverter.GetBytes(vector.Z)); 15 | return res.ToArray(); 16 | } 17 | 18 | public static byte[] ToBytes(this IEnumerable vectors) 19 | { 20 | var bytes = new List(); 21 | foreach (var vector in vectors) 22 | { 23 | bytes.AddRange(vector.ToBytes()); 24 | } 25 | return bytes.ToArray(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/i3d.tile/i3dm.tile.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | I3dm.Tile 6 | 1.1.3 7 | Bert Temme 8 | 9 | Read/Write instanced 3D Tile models 10 | MIT 11 | https://github.com/bertt/i3dm-tile-cs 12 | https://github.com/bertt/i3dm-tile-cs 13 | git 14 | 3dtile gltf 15 | add padding rules 16 | true 17 | Bert Temme 18 | 1.0 19 | 1.0 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/i3dm.tile.benchmarks/I3dmBenchmarks.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Attributes; 2 | using I3dm.Tile; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | 7 | namespace i3dm.tile.benchmarks 8 | { 9 | [MemoryDiagnoser] 10 | public class I3dmBenchmarks 11 | { 12 | private I3dm.Tile.I3dm i3dm; 13 | private byte[] GlbModel ; 14 | 15 | [GlobalSetup] 16 | public void Setup() 17 | { 18 | GlbModel = File.ReadAllBytes(@"barrel.glb"); 19 | 20 | var pos1 = new Vector3(100, 101, 102); 21 | var pos2 = new Vector3(200, 201, 202); 22 | var positions = new List() { pos1, pos2 }; 23 | 24 | i3dm = new I3dm.Tile.I3dm(positions, GlbModel); 25 | i3dm.RtcCenter = new Vector3(100, 100, 100); 26 | 27 | 28 | } 29 | 30 | [Benchmark] 31 | public void ReadI3dm() 32 | { 33 | var Stream = File.OpenRead("barrel.i3dm"); 34 | var i3dm1 = I3dmReader.Read(Stream); 35 | } 36 | 37 | [Benchmark] 38 | public void WriteI3dm() 39 | { 40 | var bytes = I3dmWriter.Write(i3dm); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/i3dm.tile.benchmarks/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | using System; 3 | 4 | namespace i3dm.tile.benchmarks 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | var summary = BenchmarkRunner.Run(); 11 | Console.Write(summary); 12 | Console.WriteLine("Press any key to continue..."); 13 | Console.ReadKey(); 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/i3dm.tile.benchmarks/barrel.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.benchmarks/barrel.glb -------------------------------------------------------------------------------- /src/i3dm.tile.benchmarks/barrel.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.benchmarks/barrel.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.benchmarks/i3dm.tile.benchmarks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | PreserveNewest 19 | 20 | 21 | PreserveNewest 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/i3dm.tile.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30204.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "i3dm.tile", "i3d.tile\i3dm.tile.csproj", "{64CB6F2B-A128-4C31-AF13-41FCAC823389}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "i3dm.tile.tests", "i3dm.tile.tests\i3dm.tile.tests.csproj", "{85FF97CE-E640-44BB-B467-FAE27308EA65}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{11E60337-EEA6-4DFC-B276-A14FE520BB98}" 11 | ProjectSection(SolutionItems) = preProject 12 | ..\README.md = ..\README.md 13 | EndProjectSection 14 | EndProject 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "i3dm.tile.benchmarks", "i3dm.tile.benchmarks\i3dm.tile.benchmarks.csproj", "{31237202-C1A4-43DD-8159-600EEF55C649}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {64CB6F2B-A128-4C31-AF13-41FCAC823389}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {64CB6F2B-A128-4C31-AF13-41FCAC823389}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {64CB6F2B-A128-4C31-AF13-41FCAC823389}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {64CB6F2B-A128-4C31-AF13-41FCAC823389}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {85FF97CE-E640-44BB-B467-FAE27308EA65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {85FF97CE-E640-44BB-B467-FAE27308EA65}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {85FF97CE-E640-44BB-B467-FAE27308EA65}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {85FF97CE-E640-44BB-B467-FAE27308EA65}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {31237202-C1A4-43DD-8159-600EEF55C649}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {31237202-C1A4-43DD-8159-600EEF55C649}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {31237202-C1A4-43DD-8159-600EEF55C649}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {31237202-C1A4-43DD-8159-600EEF55C649}.Release|Any CPU.Build.0 = Release|Any CPU 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {DDD217B0-3137-4901-A438-288EACE48678} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/BufferPaddingTests.cs: -------------------------------------------------------------------------------- 1 | using I3dm.Tile; 2 | using NUnit.Framework; 3 | 4 | namespace i3dm.tile.tests 5 | { 6 | public class BufferPaddingTests 7 | { 8 | [Test] 9 | public void Initial() 10 | { 11 | 12 | var featureTableJson = "{\"INSTANCES_LENGTH\":2,\"POSITION\":{\"byteOffset\":0},\"EAST_NORTH_UP\":false,\"RTC_CENTER\":[10,10,10]}"; 13 | var paddedJson = BufferPadding.AddPadding(featureTableJson); 14 | Assert.That(paddedJson == "{\"INSTANCES_LENGTH\":2,\"POSITION\":{\"byteOffset\":0},\"EAST_NORTH_UP\":false,\"RTC_CENTER\":[10,10,10]}"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/ByteConvertorTests.cs: -------------------------------------------------------------------------------- 1 | using I3dm.Tile; 2 | using NUnit.Framework; 3 | using System.Collections.Generic; 4 | 5 | namespace i3dm.tile.tests 6 | { 7 | public class ByteConvertorTests 8 | { 9 | [Test] 10 | public void ByteConvertorToBytesTest() 11 | { 12 | var input = new List() { 1, 2, 3 }; 13 | 14 | var res = ByteConvertor.ToBytes(input); 15 | 16 | Assert.That(res.Length == 3); 17 | } 18 | 19 | [Test] 20 | public void ByteConvertorToShortsTest() 21 | { 22 | var input = new List() { 1, 2, 3 }; 23 | 24 | var res = ByteConvertor.ToBytes(input); 25 | 26 | Assert.That(res.Length == 6); 27 | } 28 | 29 | [Test] 30 | public void ByteConvertorToIntsTest() 31 | { 32 | var input = new List() { 1, 2, 3 }; 33 | 34 | var res = ByteConvertor.ToBytes(input); 35 | 36 | Assert.That(res.Length == 12); 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/FeatureTableTests.cs: -------------------------------------------------------------------------------- 1 | using I3dm.Tile; 2 | using NUnit.Framework; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | using System.Text.Json; 7 | using System.Text.Json.Serialization; 8 | 9 | namespace i3dm.tile.tests 10 | { 11 | public class FeatureTableTests 12 | { 13 | 14 | [Test] 15 | public void FeatureTableWithRtcCenterTest() 16 | { 17 | // arrange 18 | var featureTableJson = @"{""INSTANCES_LENGTH"":25,""RTC_CENTER"":[1215013.8340490046,-4736316.75897742,4081608.4380407534],""EAST_NORTH_UP"":true,""POSITION"":{""byteOffset"":0}} "; 19 | 20 | // act 21 | var serializeOptions = new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull}; 22 | serializeOptions.Converters.Add(new Vector3Converter()); 23 | var featureTable = JsonSerializer.Deserialize(featureTableJson,serializeOptions); 24 | 25 | // assert 26 | Assert.That(featureTable != null); 27 | Assert.That(featureTable.InstancesLength == 25); 28 | Assert.That(featureTable.RtcCenter.Equals(new Vector3(1215013.8340490046f, -4736316.75897742f, 4081608.4380407534f))); 29 | } 30 | 31 | [Test] 32 | public void SerializeFeatureTablejsonTest() 33 | { 34 | // arrange 35 | var featureTableJson = @"{""INSTANCES_LENGTH"":25,""EAST_NORTH_UP"":true,""POSITION"":{""byteOffset"":0}}"; 36 | 37 | // act 38 | var featureTable = JsonSerializer.Deserialize(featureTableJson); 39 | 40 | // assert 41 | Assert.That(featureTable.InstancesLength == 25); 42 | Assert.That(featureTable.IsEastNorthUp); 43 | Assert.That(featureTable.PositionOffset.offset==0); 44 | } 45 | 46 | [Test] 47 | public void DeserializeFeatureTableToJsonTest() 48 | { 49 | // arrange 50 | var positions = new List(); 51 | positions.Add(new Vector3(0, 0, 0)); 52 | positions.Add(new Vector3(1, 1, 1)); 53 | var treeGlb = File.ReadAllBytes(@"testfixtures/barrel.glb"); 54 | var i3dm = new I3dm.Tile.I3dm(positions, treeGlb); 55 | i3dm.Positions = positions; 56 | 57 | // act 58 | var featureTableJson = i3dm.GetFeatureTableJson(); 59 | var serializeOptions = new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }; 60 | serializeOptions.Converters.Add(new Vector3Converter()); 61 | var featureTable = JsonSerializer.Deserialize(featureTableJson,serializeOptions); 62 | 63 | // assert 64 | Assert.That(featureTable.InstancesLength == 2); 65 | Assert.That(featureTable.IsEastNorthUp== true); 66 | Assert.That(featureTable.PositionOffset.offset== 0); 67 | } 68 | 69 | [Test] 70 | public void PositionsToByteArrayTest() 71 | { 72 | // arrange 73 | var positions = new List 74 | { 75 | new Vector3(0, 0, 0), 76 | new Vector3(1, 1, 1) 77 | }; 78 | 79 | // act 80 | var bytes = positions.ToBytes(); 81 | 82 | // Assert 83 | // should be 4 bytes each value, 2 positions, 3 values (x, y, z) each 84 | Assert.That(bytes.Length == 2*3*4); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/FloatExtensionTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections.Generic; 3 | using I3dm.Tile; 4 | 5 | namespace i3dm.tile.tests 6 | { 7 | public class FloatExtensionTests 8 | { 9 | [Test] 10 | public void TestToByteForFloat() 11 | { 12 | var f1 = 1.4f; 13 | var f2 = 1.8f; 14 | var floats = new List { f1, f2 }; 15 | 16 | var bytes = floats.ToBytes(); 17 | Assert.That(bytes.Length == 8); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/I3dmCompareTests.cs: -------------------------------------------------------------------------------- 1 | using I3dm.Tile; 2 | using NUnit.Framework; 3 | using System.IO; 4 | 5 | namespace i3dm.tile.tests 6 | { 7 | public class I3dmCompareTests 8 | { 9 | [Test] 10 | public void I3dmComparerTests() 11 | { 12 | var i3dmfile = File.OpenRead(@"testfixtures/tree.i3dm"); 13 | var treeI3dm = I3dmReader.Read(i3dmfile); 14 | 15 | var i3dmAfterfile = File.OpenRead(@"testfixtures/tree.i3dm"); 16 | var treeI3dmAfter = I3dmReader.Read(i3dmAfterfile); 17 | 18 | Assert.That(treeI3dm.FeatureTableBinary.Length == treeI3dmAfter.FeatureTableBinary.Length); 19 | 20 | for(var i=0;i< treeI3dmAfter.FeatureTableBinary.Length; i++) 21 | { 22 | Assert.That(treeI3dm.FeatureTableBinary[i] == treeI3dmAfter.FeatureTableBinary[i]); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/I3dmReaderTest.cs: -------------------------------------------------------------------------------- 1 | using I3dm.Tile; 2 | using NUnit.Framework; 3 | using SharpGLTF.Validation; 4 | using System.IO; 5 | using System.Numerics; 6 | 7 | namespace i3dm.tile.tests 8 | { 9 | public class Tests 10 | { 11 | string expectedMagicHeader = "i3dm"; 12 | int expectedVersionHeader = 1; 13 | 14 | [Test] 15 | public void ReadWithExternalUri() 16 | { 17 | var i3dmfile = File.OpenRead(@"testfixtures/external_uri.i3dm"); 18 | var i3dm = I3dmReader.Read(i3dmfile); 19 | Assert.That(i3dm.Uri == "box1.glb"); 20 | } 21 | 22 | [Test] 23 | public void ReadWithPadding() 24 | { 25 | var i3dmfile = File.OpenRead(@"testfixtures/i3dm.withpadding.i3dm"); 26 | var i3dm = I3dmReader.Read(i3dmfile); 27 | Assert.That(i3dm.HasPadding); 28 | } 29 | [Test] 30 | public void ReadInstancedRTCTest() 31 | { 32 | // arrange 33 | var i3dmfile = File.OpenRead(@"testfixtures/instancedRTC.i3dm"); 34 | Assert.That(i3dmfile != null); 35 | 36 | var i3dm = I3dmReader.Read(i3dmfile); 37 | 38 | Assert.That(i3dm!=null); 39 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":25,\"RTC_CENTER\":[1215013.8340490046,-4736316.75897742,4081608.4380407534],\"EAST_NORTH_UP\":true,\"POSITION\":{\"byteOffset\":0}} "); 40 | Assert.That(i3dm.Positions[0] == new Vector3(-64.70168f, -69.73304f, -61.245365f)); 41 | } 42 | 43 | [Test] 44 | public void InstancedAnimatedTest() 45 | { 46 | // arrange 47 | var i3dmfile = File.OpenRead(@"testfixtures/instancedAnimated.i3dm"); 48 | Assert.That(i3dmfile != null); 49 | 50 | // act 51 | var i3dm = I3dmReader.Read(i3dmfile); 52 | Assert.That(expectedMagicHeader == i3dm.I3dmHeader.Magic); 53 | Assert.That(expectedVersionHeader == i3dm.I3dmHeader.Version); 54 | Assert.That(i3dm.I3dmHeader.GltfFormat == 1); 55 | Assert.That(i3dm.BatchTableJson.Length >= 0); 56 | Assert.That(i3dm.GlbData.Length > 0); 57 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":25,\"EAST_NORTH_UP\":true,\"POSITION\":{\"byteOffset\":0}}"); 58 | Assert.That(i3dm.FeatureTable.InstancesLength == 25); 59 | var stream = new MemoryStream(i3dm.GlbData); 60 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 61 | Assert.That(glb.LogicalAnimations.Count == 1); 62 | Assert.That(glb.LogicalAnimations[0].Name == "Object_0Action"); 63 | } 64 | 65 | [Test] 66 | public void InstancedTexturedTest() 67 | { 68 | // arrange 69 | // source: https://github.com/flywave/go-3dtile/tree/master/data/Textured/instancedTextured.i3dm 70 | var i3dmfile = File.OpenRead(@"testfixtures/instancedTextured.i3dm"); 71 | Assert.That(i3dmfile != null); 72 | // act 73 | var i3dm = I3dmReader.Read(i3dmfile); 74 | Assert.That(expectedMagicHeader == i3dm.I3dmHeader.Magic); 75 | Assert.That(expectedVersionHeader == i3dm.I3dmHeader.Version); 76 | Assert.That(i3dm.I3dmHeader.GltfFormat == 1); 77 | Assert.That(i3dm.BatchTableJson.Length >= 0); 78 | Assert.That(i3dm.GlbData.Length > 0); 79 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":1,\"POSITION\":{\"byteOffset\":0}} "); 80 | Assert.That(i3dm.FeatureTable.InstancesLength == 1); 81 | var stream = new MemoryStream(i3dm.GlbData); 82 | try 83 | { 84 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 85 | } 86 | catch (SchemaException le) 87 | { 88 | // we expect schemaexception because no support for gltf1' 89 | Assert.That(le != null); 90 | Assert.That(le.Message == "Unknown version number: 1Model generated by <> seems to be malformed; Please, check the file at https://github.khronos.org/glTF-Validator/"); 91 | } 92 | } 93 | 94 | [Test] 95 | public void InstancedBarrelTest() 96 | { 97 | // arrange 98 | // source: https://github.com/PrincessGod/objTo3d-tiles/blob/master/bin/barrel/output/Instancedbarrel/barrel.i3dm 99 | var i3dmfile = File.OpenRead(@"testfixtures/barrel.i3dm"); 100 | Assert.That(i3dmfile != null); 101 | // act 102 | var i3dm = I3dmReader.Read(i3dmfile); 103 | Assert.That(expectedMagicHeader == i3dm.I3dmHeader.Magic); 104 | Assert.That(expectedVersionHeader == i3dm.I3dmHeader.Version); 105 | 106 | Assert.That(i3dm.I3dmHeader.FeatureTableBinaryByteLength == 496); 107 | Assert.That(i3dm.I3dmHeader.GltfFormat == 1); 108 | Assert.That(i3dm.BatchTableJson.Length >= 0); 109 | Assert.That(i3dm.BatchTableJson == "{\"name\":[\"center\",\"right\",\"left\",\"top\",\"bottom\",\"up\",\"right-top\",\"right-bottom\",\"left-top\",\"left-bottom\"],\"id\":[0,1,2,3,4,5,6,7,8,9]} "); 110 | Assert.That(i3dm.GlbData.Length > 0); 111 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":10,\"POSITION\":{\"byteOffset\":0},\"BATCH_ID\":{\"byteOffset\":120,\"componentType\":\"UNSIGNED_BYTE\"},\"NORMAL_UP\":{\"byteOffset\":132},\"NORMAL_RIGHT\":{\"byteOffset\":252},\"SCALE_NON_UNIFORM\":{\"byteOffset\":372}} "); 112 | Assert.That(i3dm.FeatureTable.InstancesLength == 10); 113 | Assert.That(i3dm.FeatureTable.BatchIdOffset.componentType== "UNSIGNED_BYTE"); 114 | 115 | Assert.That(i3dm.Positions[0].Equals(new Vector3(0, 0, 0))); 116 | Assert.That(i3dm.Positions[1].Equals(new Vector3(20, 0, 0))); 117 | Assert.That(i3dm.BatchIds[0]==0); 118 | Assert.That(i3dm.BatchIds[1] == 1); 119 | Assert.That(i3dm.BatchIds[2] == 2); 120 | Assert.That(i3dm.BatchIds[9] == 9); 121 | 122 | Assert.That(i3dm.FeatureTableBinary.Length == 496); 123 | var stream = new MemoryStream(i3dm.GlbData); 124 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 125 | glb.SaveGLB(@"barrel.glb"); 126 | } 127 | 128 | 129 | [Test] 130 | public void InstancedWithBatchTableTest() 131 | { 132 | // arrange 133 | // source: http://vcities.umsl.edu/Cesium1.54/Apps/SampleData/Cesium3DTiles/Instanced/InstancedWithBatchTable/ 134 | var i3dmfile = File.OpenRead(@"testfixtures/instancedWithBatchTable.i3dm"); 135 | Assert.That(i3dmfile != null); 136 | // act 137 | var i3dm = I3dmReader.Read(i3dmfile); 138 | Assert.That(expectedMagicHeader == i3dm.I3dmHeader.Magic); 139 | Assert.That(expectedVersionHeader == i3dm.I3dmHeader.Version); 140 | Assert.That(i3dm.I3dmHeader.GltfFormat == 1); 141 | Assert.That(i3dm.BatchTableJson.Length >= 0); 142 | Assert.That(i3dm.BatchTableJson == "{\"Height\":[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]} "); 143 | Assert.That(i3dm.GlbData.Length > 0); 144 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":25,\"EAST_NORTH_UP\":true,\"POSITION\":{\"byteOffset\":0}}"); 145 | Assert.That(i3dm.FeatureTableBinary.Length == 304); 146 | var stream = new MemoryStream(i3dm.GlbData); 147 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 148 | glb.SaveGLB(@"instancedwithbatchtable.glb"); 149 | } 150 | 151 | [Test] 152 | public void InstancedOrientationTest() 153 | { 154 | // arrange 155 | // source: http://vcities.umsl.edu/Cesium1.54/Apps/SampleData/Cesium3DTiles/Instanced/InstancedOrientation/ 156 | var i3dmfile = File.OpenRead(@"testfixtures/instancedOrientation.i3dm"); 157 | Assert.That(i3dmfile != null); 158 | // act 159 | var i3dm = I3dmReader.Read(i3dmfile); 160 | Assert.That(expectedMagicHeader == i3dm.I3dmHeader.Magic); 161 | Assert.That(expectedVersionHeader == i3dm.I3dmHeader.Version); 162 | Assert.That(i3dm.I3dmHeader.GltfFormat == 1); 163 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":25,\"POSITION\":{\"byteOffset\":0},\"NORMAL_UP\":{\"byteOffset\":300},\"NORMAL_RIGHT\":{\"byteOffset\":600}} "); 164 | Assert.That(i3dm.BatchTableJson.Length >= 0); 165 | Assert.That(i3dm.GlbData.Length > 0); 166 | Assert.That(i3dm.BatchTableJson == "{\"Height\":[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]} "); 167 | Assert.That(i3dm.FeatureTableBinary.Length == 904); 168 | var stream = new MemoryStream(i3dm.GlbData); 169 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 170 | Assert.That(glb != null); 171 | glb.SaveGLB(@"instancedorientation.glb"); 172 | } 173 | 174 | [Test] 175 | public void TreeBillboardTest() 176 | { 177 | // arrange 178 | var i3dmfile = File.OpenRead(@"testfixtures/tree_billboard.i3dm"); 179 | Assert.That(i3dmfile != null); 180 | // act 181 | var i3dm = I3dmReader.Read(i3dmfile); 182 | Assert.That(expectedMagicHeader == i3dm.I3dmHeader.Magic); 183 | Assert.That(expectedVersionHeader == i3dm.I3dmHeader.Version); 184 | Assert.That(i3dm.I3dmHeader.GltfFormat == 1); 185 | Assert.That(i3dm.BatchTableJson.Length >= 0); 186 | Assert.That(i3dm.GlbData.Length > 0); 187 | Assert.That(i3dm.FeatureTableBinary.Length == 304); 188 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":25,\"EAST_NORTH_UP\":true,\"POSITION\":{\"byteOffset\":0}}"); 189 | Assert.That(i3dm.BatchTableJson == "{\"Height\":[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]} "); 190 | Assert.That(i3dm.FeatureTableBinary.Length == 304); 191 | var stream = new MemoryStream(i3dm.GlbData); 192 | try 193 | { 194 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 195 | } 196 | catch (LinkException le) 197 | { 198 | // we expect linkexception because SharpGLTF does not support KHR_techniques_webgl' 199 | Assert.That(le != null); 200 | Assert.That(le.Message == "Extensions: KHR_techniques_webglModel generated by <> seems to be malformed; Please, check the file at https://github.khronos.org/glTF-Validator/"); 201 | } 202 | } 203 | 204 | [Test] 205 | public void TreeTest() 206 | { 207 | // arrange 208 | var i3dmfile = File.OpenRead(@"testfixtures/tree.i3dm"); 209 | Assert.That(i3dmfile != null); 210 | // act 211 | var i3dm = I3dmReader.Read(i3dmfile); 212 | Assert.That(expectedMagicHeader == i3dm.I3dmHeader.Magic); 213 | Assert.That(expectedVersionHeader == i3dm.I3dmHeader.Version); 214 | Assert.That(i3dm.I3dmHeader.GltfFormat == 1); 215 | Assert.That(i3dm.BatchTableJson.Length >= 0); 216 | Assert.That(i3dm.GlbData.Length > 0); 217 | Assert.That(i3dm.FeatureTableBinary.Length == 304); 218 | Assert.That(i3dm.BatchTableJson == "{\"Height\":[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]} "); 219 | Assert.That(i3dm.FeatureTableJson == "{\"INSTANCES_LENGTH\":25,\"EAST_NORTH_UP\":true,\"POSITION\":{\"byteOffset\":0}}"); 220 | Assert.That(i3dm.FeatureTableBinary.Length == 304); 221 | Assert.That(i3dm.Positions[0].Equals(new Vector3(1214947.2f, -4736379f, 4081540.8f))); 222 | var stream = new MemoryStream(i3dm.GlbData); 223 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 224 | Assert.That(glb.Asset.Version.Major == 2.0); 225 | Assert.That(glb.Asset.Generator == "COLLADA2GLTF"); 226 | glb.SaveGLB(@"tree.glb"); 227 | } 228 | } 229 | } -------------------------------------------------------------------------------- /src/i3dm.tile.tests/I3dmWriterTest.cs: -------------------------------------------------------------------------------- 1 | using I3dm.Tile; 2 | using NUnit.Framework; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Numerics; 6 | 7 | namespace i3dm.tile.tests 8 | { 9 | public class I3dmWriterTest 10 | { 11 | private static string treeUrlGlb = "https://bertt.github.io/mapbox_3dtiles_samples/samples/instanced/trees_external_gltf/tree.glb"; 12 | 13 | [Test] 14 | public void WriteToBytesTest() 15 | { 16 | // arrange 17 | var i3dm = GetTestI3dm(treeUrlGlb); 18 | 19 | // act 20 | var bytes = I3dmWriter.Write(i3dm); 21 | 22 | // assert 23 | Assert.That(bytes.Length > 0); 24 | 25 | // check padding rules 26 | Assert.That(bytes.Length % 8 == 0); 27 | 28 | // and try to recreate i3dm 29 | var stream = new MemoryStream(bytes); 30 | var i3dmRound = I3dmReader.Read(stream); 31 | 32 | // assert again 33 | Assert.That(i3dmRound.Positions.Count == 2); 34 | Assert.That(i3dmRound.GlbUrl.StartsWith(treeUrlGlb)); 35 | } 36 | 37 | [Test] 38 | public void WriteI3dmWithExternalGltfTest() 39 | { 40 | // arrange 41 | var i3dm = GetTestI3dm(treeUrlGlb); 42 | i3dm.RtcCenter = new Vector3(100, 100, 100); 43 | 44 | // act 45 | var bytes = I3dmWriter.Write(i3dm); 46 | 47 | // assert 48 | var headerValidateErrors = i3dm.I3dmHeader.Validate(); 49 | Assert.That(headerValidateErrors.Count == 0); 50 | 51 | var i3dmActual = I3dmReader.Read(new MemoryStream(bytes)); 52 | Assert.That(i3dmActual.GlbUrl.StartsWith(treeUrlGlb)); 53 | Assert.That(i3dmActual.RtcCenter.Equals(i3dm.RtcCenter)); 54 | } 55 | 56 | private static I3dm.Tile.I3dm GetTestI3dm(string treeUrlGlb) 57 | { 58 | var pos1 = new Vector3(100, 101, 102); 59 | var pos2 = new Vector3(200, 201, 202); 60 | var positions = new List() { pos1, pos2 }; 61 | 62 | var i3dm = new I3dm.Tile.I3dm(positions, treeUrlGlb); 63 | return i3dm; 64 | } 65 | 66 | [Test] 67 | public void WriteI3dmWithRtcCenterTest() 68 | { 69 | var treeGlb = File.ReadAllBytes(@"testfixtures/tree.glb"); 70 | var pos1 = new Vector3(100, 101, 102); 71 | var pos2 = new Vector3(200, 201, 202); 72 | var positions = new List() { pos1, pos2 }; 73 | 74 | var i3dm = new I3dm.Tile.I3dm(positions, treeGlb); 75 | i3dm.RtcCenter = new Vector3(100, 100, 100); 76 | 77 | var i3dmBytes = I3dmWriter.Write(i3dm); 78 | var ms = new MemoryStream(i3dmBytes); 79 | 80 | var headerValidateErrors = i3dm.I3dmHeader.Validate(); 81 | Assert.That(headerValidateErrors.Count == 0); 82 | 83 | var i3dmActual = I3dmReader.Read(ms); 84 | 85 | Assert.That(i3dmActual.RtcCenter.Equals(i3dm.RtcCenter)); 86 | } 87 | 88 | [Test] 89 | public void WriteI3dmHelloWorld() 90 | { 91 | // arrange 92 | var treeGlb = File.ReadAllBytes(@"testfixtures/tree.glb"); 93 | var pos1 = new Vector3(100, 101, 102); 94 | var pos2 = new Vector3(200, 201, 202); 95 | var positions = new List() { pos1, pos2 }; 96 | var batchIds = new List() { 9, 11 }; 97 | 98 | var i3dm = new I3dm.Tile.I3dm(positions, treeGlb); 99 | i3dm.BatchIds = batchIds; 100 | 101 | // act 102 | var bytes = I3dmWriter.Write(i3dm); 103 | 104 | // asssert 105 | var headerValidateErrors = i3dm.I3dmHeader.Validate(); 106 | Assert.That(headerValidateErrors.Count == 0); 107 | 108 | var i3dmActual = I3dmReader.Read(new MemoryStream(bytes)); 109 | Assert.That(i3dmActual.Positions.Count == 2); 110 | Assert.That(i3dmActual.Positions[0].Equals(pos1)); 111 | Assert.That(i3dmActual.Positions[1].Equals(pos2)); 112 | Assert.That(i3dmActual.BatchIds.Count == 2); 113 | Assert.That(i3dmActual.BatchIds[0] == 9); 114 | Assert.That(i3dmActual.BatchIds[1] == 11); 115 | Assert.That(i3dmActual.FeatureTable.BatchIdOffset.componentType == "UNSIGNED_SHORT"); 116 | } 117 | 118 | [Test] 119 | public void WriteI3dmHelloWorldWithScales() 120 | { 121 | // arrange 122 | var treeGlb = File.ReadAllBytes(@"testfixtures/tree.glb"); 123 | var pos1 = new Vector3(100, 101, 102); 124 | var pos2 = new Vector3(200, 201, 202); 125 | var positions = new List() { pos1, pos2 }; 126 | var scales = new List { 2, 3 }; 127 | var batchIds = new List() { 9, 11 }; 128 | 129 | var i3dm = new I3dm.Tile.I3dm(positions, treeGlb); 130 | i3dm.BatchIds = batchIds; 131 | i3dm.Scales = scales; 132 | 133 | // act 134 | var bytes = I3dmWriter.Write(i3dm); 135 | 136 | // assert 137 | var headerValidateErrors = i3dm.I3dmHeader.Validate(); 138 | Assert.That(headerValidateErrors.Count == 0); 139 | 140 | var i3dmActual = I3dmReader.Read(new MemoryStream(bytes)); 141 | Assert.That(i3dmActual.Positions.Count == 2); 142 | Assert.That(i3dmActual.Positions[0].Equals(pos1)); 143 | Assert.That(i3dmActual.Positions[1].Equals(pos2)); 144 | Assert.That(i3dmActual.BatchIds.Count == 2); 145 | Assert.That(i3dmActual.BatchIds[0] == 9); 146 | Assert.That(i3dmActual.BatchIds[1] == 11); 147 | Assert.That(i3dmActual.FeatureTable.BatchIdOffset.componentType == "UNSIGNED_SHORT"); 148 | Assert.That(i3dmActual.Scales[0] == 2); 149 | Assert.That(i3dmActual.Scales[1] == 3); 150 | } 151 | 152 | [Test] 153 | public void WriteI3dmHelloWorldWithBatchIdType() 154 | { 155 | var treeGlb = File.ReadAllBytes(@"testfixtures/tree.glb"); 156 | var pos1 = new Vector3(100, 101, 102); 157 | var pos2 = new Vector3(200, 201, 202); 158 | var positions = new List() { pos1, pos2 }; 159 | var batchIds = new List() { 9, 11 }; 160 | 161 | var i3dm = new I3dm.Tile.I3dm(positions, treeGlb); 162 | 163 | var types = new List { "UNSIGNED_BYTE", "UNSIGNED_SHORT", "UNSIGNED_INT" }; 164 | 165 | // write i3dm with every type for batch_id 166 | foreach (var type in types) 167 | { 168 | i3dm.BatchIds = batchIds; 169 | var bytes = I3dmWriter.Write(i3dm, type); 170 | 171 | var headerValidateErrors = i3dm.I3dmHeader.Validate(); 172 | Assert.That(headerValidateErrors.Count == 0); 173 | 174 | var i3dmActual = I3dmReader.Read(new MemoryStream(bytes)); 175 | Assert.That(i3dmActual.Positions.Count == 2); 176 | Assert.That(i3dmActual.Positions[0].Equals(pos1)); 177 | Assert.That(i3dmActual.Positions[1].Equals(pos2)); 178 | Assert.That(i3dmActual.BatchIds.Count == 2); 179 | Assert.That(i3dmActual.BatchIds[0] == 9); 180 | Assert.That(i3dmActual.BatchIds[1] == 11); 181 | Assert.That(i3dmActual.FeatureTable.BatchIdOffset.componentType == type); 182 | 183 | var stream = new MemoryStream(i3dmActual.GlbData); 184 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 185 | Assert.That(glb.Asset.Version.Major == 2.0); 186 | } 187 | } 188 | 189 | [Test] 190 | public void WriteBarrelI3dmWithBatchIdShortTest() 191 | { 192 | // arrange 193 | var originalFile = @"testfixtures/barrel.i3dm"; 194 | var i3dmOriginalfile = File.OpenRead(originalFile); 195 | 196 | var i3dmOriginal = I3dmReader.Read(i3dmOriginalfile); 197 | Assert.That(i3dmOriginal.I3dmHeader.FeatureTableBinaryByteLength == 496); 198 | Assert.That(i3dmOriginal.FeatureTable.BatchIdOffset.componentType == "UNSIGNED_BYTE"); 199 | i3dmOriginal.FeatureTable.BatchIdOffset.componentType = "UNSIGNED_SHORT"; 200 | var bytes = I3dmWriter.Write(i3dmOriginal); 201 | 202 | var headerValidateErrors = i3dmOriginal.I3dmHeader.Validate(); 203 | Assert.That(headerValidateErrors.Count == 0); 204 | 205 | // act 206 | var i3dmActualShort = I3dmReader.Read(new MemoryStream(bytes)); 207 | 208 | // assert 209 | i3dmActualShort.FeatureTable.BatchIdOffset.componentType = "UNSIGNED_SHORT"; 210 | } 211 | 212 | [Test] 213 | public void WriteBarrelI3dmTest() 214 | { 215 | // arrange 216 | var i3dmExpectedfile = File.OpenRead(@"testfixtures/barrel.i3dm"); 217 | var i3dmExpected = I3dmReader.Read(i3dmExpectedfile); 218 | var positions = i3dmExpected.Positions; 219 | Assert.That(positions.Count == 10); 220 | Assert.That(i3dmExpected.FeatureTableJson == "{\"INSTANCES_LENGTH\":10,\"POSITION\":{\"byteOffset\":0},\"BATCH_ID\":{\"byteOffset\":120,\"componentType\":\"UNSIGNED_BYTE\"},\"NORMAL_UP\":{\"byteOffset\":132},\"NORMAL_RIGHT\":{\"byteOffset\":252},\"SCALE_NON_UNIFORM\":{\"byteOffset\":372}} "); 221 | 222 | // act 223 | var bytes = I3dmWriter.Write(i3dmExpected); 224 | 225 | // assert 226 | var i3dmActual = I3dmReader.Read(new MemoryStream(bytes)); 227 | Assert.That(i3dmActual.Positions.Count == 10); 228 | Assert.That(i3dmActual.FeatureTable.IsEastNorthUp == true); 229 | Assert.That(i3dmActual.Positions[0].Equals(i3dmExpected.Positions[0])); 230 | var stream = new MemoryStream(i3dmActual.GlbData); 231 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 232 | Assert.That(glb.Asset.Version.Major == 2.0); 233 | Assert.That(glb.Asset.Generator == "obj2gltf"); 234 | } 235 | 236 | [Test] 237 | public void WriteTreeI3dmTest() 238 | { 239 | // arrange 240 | var i3dmExpectedfile = File.OpenRead(@"testfixtures/tree.i3dm"); 241 | var i3dmExpected = I3dmReader.Read(i3dmExpectedfile); 242 | var positions = i3dmExpected.Positions; 243 | Assert.That(positions.Count == 25); 244 | 245 | var treeGlb = File.ReadAllBytes(@"testfixtures/tree.glb"); 246 | var i3dm = new I3dm.Tile.I3dm(positions, treeGlb); 247 | i3dm.FeatureTable.IsEastNorthUp = true; 248 | i3dm.BatchTableJson = @"{""Height"":[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]} "; 249 | 250 | // act 251 | var bytes = I3dmWriter.Write(i3dm); 252 | 253 | // assert 254 | var i3dmActual = I3dmReader.Read(new MemoryStream(bytes)); 255 | 256 | Assert.That(i3dmActual.I3dmHeader.Version == 1); 257 | Assert.That(i3dmActual.I3dmHeader.Magic == "i3dm"); 258 | Assert.That(i3dmActual.I3dmHeader.GltfFormat == 1); 259 | Assert.That(i3dmActual.I3dmHeader.BatchTableJsonByteLength == 88); 260 | Assert.That(i3dmActual.I3dmHeader.FeatureTableJsonByteLength == 72); 261 | Assert.That(i3dmActual.I3dmHeader.BatchTableBinaryByteLength == 0); 262 | Assert.That(i3dmActual.Positions.Count == 25); 263 | Assert.That(i3dmActual.FeatureTable.IsEastNorthUp == true); 264 | Assert.That(i3dmActual.Positions[0].Equals(new Vector3(1214947.2f, -4736379f, 4081540.8f))); 265 | var stream = new MemoryStream(i3dmActual.GlbData); 266 | var glb = SharpGLTF.Schema2.ModelRoot.ReadGLB(stream); 267 | Assert.That(glb.Asset.Version.Major == 2.0); 268 | Assert.That(glb.Asset.Generator == "COLLADA2GLTF"); 269 | } 270 | 271 | [Test] 272 | public void WriteTreeBasicI3dmTest() 273 | { 274 | // arrange 275 | var treeGlb = File.ReadAllBytes(@"testfixtures/tree.glb"); 276 | var mapbox_positions = new List(); 277 | 278 | mapbox_positions.Add(new Vector3(-8407346.9596f, 4743739.3031f, 38.29f)); 279 | mapbox_positions.Add(new Vector3(-8406181.2949f, 4744924.0771f, 38.29f)); 280 | 281 | var i3dm = new I3dm.Tile.I3dm(mapbox_positions, treeGlb); 282 | i3dm.BatchTableJson = "{\"Height\":[100,101]}"; 283 | i3dm.FeatureTable.IsEastNorthUp = true; 284 | 285 | // act 286 | var bytes = I3dmWriter.Write(i3dm); 287 | 288 | // assert 289 | Assert.That(bytes.Length > 0); 290 | } 291 | 292 | 293 | [Test] 294 | public void TestRotations() 295 | { 296 | var seatGlb = File.ReadAllBytes(@"testfixtures/stoel000.glb"); 297 | var positions = new List(); 298 | positions.Add(new Vector3(1214947.2f, -4736379f, 4081540.8f)); 299 | 300 | var i3dm = new I3dm.Tile.I3dm(positions, seatGlb); 301 | i3dm.FeatureTable.IsEastNorthUp = true; 302 | 303 | var rotationsUp = new List(); 304 | var rotationsRight = new List(); 305 | rotationsUp.Add(new Vector3(0.9686397001928082f, 0.24846957803801f, 0)); 306 | rotationsRight.Add(new Vector3(0.1598520208967612f, -0.6231709121869502f, -0.765575173068789f)); 307 | i3dm.NormalUps = rotationsUp; 308 | i3dm.NormalRights = rotationsRight; 309 | 310 | // act 311 | var bytes = I3dmWriter.Write(i3dm); 312 | 313 | // assert 314 | Assert.That(bytes.Length > 0); 315 | } 316 | } 317 | } 318 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/i3dm.tile.tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | PreserveNewest 30 | 31 | 32 | PreserveNewest 33 | 34 | 35 | PreserveNewest 36 | 37 | 38 | PreserveNewest 39 | 40 | 41 | PreserveNewest 42 | 43 | 44 | PreserveNewest 45 | 46 | 47 | PreserveNewest 48 | 49 | 50 | PreserveNewest 51 | 52 | 53 | PreserveNewest 54 | 55 | 56 | PreserveNewest 57 | 58 | 59 | PreserveNewest 60 | 61 | 62 | PreserveNewest 63 | 64 | 65 | PreserveNewest 66 | 67 | 68 | PreserveNewest 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/4326_1.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/4326_1.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/barrel.batch: -------------------------------------------------------------------------------- 1 | {"INSTANCES_LENGTH":10,"POSITION":{"byteOffset":0},"BATCH_ID":{"byteOffset":120,"componentType":"UNSIGNED_BYTE"},"NORMAL_UP":{"byteOffset":132},"NORMAL_RIGHT":{"byteOffset":252},"SCALE_NON_UNIFORM":{"byteOffset":372}} 2 | {"name":["center","right","left","top","bottom","up","right-top","right-bottom","left-top","left-bottom"],"id":[0,1,2,3,4,5,6,7,8,9]} -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/barrel.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/barrel.glb -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/barrel.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/barrel.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/external_uri.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/external_uri.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/i3dm.withpadding.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/i3dm.withpadding.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/instancedAnimated.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/instancedAnimated.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/instancedOrientation.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/instancedOrientation.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/instancedRTC.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/instancedRTC.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/instancedTextured.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/instancedTextured.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/instancedWithBatchTable.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/instancedWithBatchTable.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/stoel000.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/stoel000.glb -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/tree.batch: -------------------------------------------------------------------------------- 1 | {"INSTANCES_LENGTH":25,"EAST_NORTH_UP":true,"POSITION":{"byteOffset":0}} 2 | {"Height":[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]} -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/tree.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/tree.glb -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/tree.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/tree.i3dm -------------------------------------------------------------------------------- /src/i3dm.tile.tests/testfixtures/tree_billboard.i3dm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bertt/i3dm-tile-cs/004d72bff33ff70175a948e25767dbca1b408dcd/src/i3dm.tile.tests/testfixtures/tree_billboard.i3dm --------------------------------------------------------------------------------