Skip to content

Commit

Permalink
Add support for .glb besides .gltf
Browse files Browse the repository at this point in the history
  • Loading branch information
Son-HNguyen committed Mar 2, 2020
1 parent 9fd2fb3 commit 737b4a0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions js/CitydbKmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,10 @@
var linkNode = queryFirstNode(modelNode, 'Link', namespaces.kml);
var hostAndPath = sourceUri.substring(0, sourceUri.lastIndexOf("/"));
var uri = hostAndPath.concat("/", queryStringValue(linkNode, 'href', namespaces.kml).replace(".dae", ".gltf").trim());
checkExists(uri, function() {
// if a .gltf file does not exist --> search for .glb
uri = hostAndPath.concat("/", queryStringValue(linkNode, 'href', namespaces.kml).replace(".dae", ".glb").trim());
})

entity.label = '';
entity.position = position;
Expand All @@ -1629,6 +1633,16 @@
uri: uri,
asynchronous: false
};

function checkExists(url, callback) {
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function() {
if (this.readyState !== this.DONE) {
callback()
}
}
xhr.open('HEAD', url)
}
}

var geometryTypes = {
Expand Down

0 comments on commit 737b4a0

Please sign in to comment.