@@ -16,7 +16,7 @@ public static void Tile(string sourcePath, string destPath, int lods, double bas
1616 {
1717
1818 Console . WriteLine ( " ?> Working on objs conversion" ) ;
19-
19+
2020 ConvertAllB3dm ( sourcePath , destPath , lods ) ;
2121
2222 Console . WriteLine ( " -> Generating tileset.json" ) ;
@@ -26,7 +26,7 @@ public static void Tile(string sourcePath, string destPath, int lods, double bas
2626 Console . WriteLine ( " ?> Using default coordinates" ) ;
2727 coords = DefaultGpsCoords ;
2828 }
29-
29+
3030 // Don't ask me why 100, I have no idea but it works
3131 // https://github.com/CesiumGS/3d-tiles/issues/162
3232 //const int baseError = 100;
@@ -40,9 +40,7 @@ public static void Tile(string sourcePath, string destPath, int lods, double bas
4040 {
4141 GeometricError = baseError ,
4242 Refine = "ADD" ,
43-
4443 Transform = coords . ToEcefTransform ( ) ,
45- Children = new List < TileElement > ( )
4644 }
4745 } ;
4846
@@ -54,11 +52,11 @@ public static void Tile(string sourcePath, string destPath, int lods, double bas
5452 var minZ = double . MaxValue ;
5553
5654 var masterDescriptors = boundsMapper [ 0 ] . Keys ;
57-
55+
5856 foreach ( var descriptor in masterDescriptors )
5957 {
6058 var currentTileElement = tileset . Root ;
61-
59+
6260 var refBox = boundsMapper [ 0 ] [ descriptor ] ;
6361
6462 for ( var lod = lods - 1 ; lod >= 0 ; lod -- )
@@ -87,14 +85,15 @@ public static void Tile(string sourcePath, string destPath, int lods, double bas
8785 {
8886 GeometricError = lod == 0 ? 0 : CalculateGeometricError ( refBox , box3 , lod ) ,
8987 Refine = "REPLACE" ,
90- Children = new List < TileElement > ( ) ,
9188 Content = new Content
9289 {
9390 Uri = $ "LOD-{ lod } /{ Path . GetFileNameWithoutExtension ( descriptor ) } .b3dm"
9491 } ,
9592 BoundingVolume = box3 . ToBoundingVolume ( )
9693 } ;
9794
95+ if ( currentTileElement . Children == null )
96+ currentTileElement . Children = new List < TileElement > ( ) ;
9897 currentTileElement . Children . Add ( tile ) ;
9998 currentTileElement = tile ;
10099 }
@@ -116,7 +115,7 @@ private static double CalculateGeometricError(Box3 refBox, Box3 box, int lod)
116115 var dW = Math . Abs ( refBox . Width - box . Width ) / box . Width + 1 ;
117116 var dH = Math . Abs ( refBox . Height - box . Height ) / box . Height + 1 ;
118117 var dD = Math . Abs ( refBox . Depth - box . Depth ) / box . Depth + 1 ;
119-
118+
120119 return Math . Pow ( dW + dH + dD , lod ) ;
121120
122121 }
0 commit comments