Skip to content

Commit 61031fb

Browse files
committed
fix b3dm logical bug
1 parent e770b2f commit 61031fb

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

lib/obj23dtiles.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ obj23dtiles.combine = combine;
1313
function obj23dtiles(objPath, outputPath, options) {
1414
console.time('Total');
1515

16+
if(typeof options.tilesetOptions === 'string') {
17+
options.tilesetOptions = fsExtra.readJsonSync(options.tilesetOptions);
18+
}
19+
if(typeof options.customBatchTable === 'string') {
20+
options.customBatchTable = fsExtra.readJsonSync(options.customBatchTable);
21+
}
22+
if (typeof options.customFeatureTable === 'string') {
23+
options.customFeatureTable = fsExtra.readJsonSync(options.customFeatureTable);
24+
}
25+
1626
if (options && options.tileset) {
1727
if(!options.i3dm) {
1828
options.binary = true;
1929
options.batchId = true;
2030
options.b3dm = true;
21-
if(typeof options.tilesetOptions === 'string') {
22-
options.tilesetOptions = fsExtra.readJsonSync(options.tilesetOptions);
23-
}
24-
if(typeof options.customBatchTable === 'string') {
25-
options.customBatchTable = fsExtra.readJsonSync(options.customBatchTable);
26-
}
27-
if (typeof options.customFeatureTable === 'string') {
28-
options.customFeatureTable = fsExtra.readJsonSync(options.customFeatureTable);
29-
}
3031

3132
obj2Tileset(objPath, outputPath, options)
3233
.then(function(result) {

lib/obj2b3dm.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,25 @@ function obj2B3dm(objPath, options) {
1717
var glb = result.gltf;
1818
var batchTableJson = result.batchTableJson;
1919
var customBatchTable = batchTableJson;
20+
var length = batchTableJson.maxPoint.length; // maxPoint always be there
2021
return new Promise(function (resolve, reject) {
2122
if (options.customBatchTable) {
22-
var length = options.customBatchTable[Object.keys(options.customBatchTable)[0]].length;
23-
if (length !== batchTableJson.batchId.length ) {
23+
length = options.customBatchTable[Object.keys(options.customBatchTable)[0]].length;
24+
if (length !== batchTableJson.maxPoint.length ) {
2425
reject('Custom BatchTable properties\'s length should be equals to default BatchTable \'batchId\' length.');
2526
}
2627
customBatchTable = options.customBatchTable;
27-
resolve({
28-
b3dm : createB3dm({
29-
glb: glb,
30-
featureTableJson: {
31-
BATCH_LENGTH: length
32-
},
33-
batchTableJson: customBatchTable
34-
}),
35-
batchTableJson : batchTableJson
36-
});
3728
}
29+
resolve({
30+
b3dm : createB3dm({
31+
glb: glb,
32+
featureTableJson: {
33+
BATCH_LENGTH: length
34+
},
35+
batchTableJson: customBatchTable
36+
}),
37+
batchTableJson : batchTableJson
38+
});
3839
});
3940
});
4041
}

0 commit comments

Comments
 (0)