Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/building.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class Building {
options;

/**
* Create new building
* Download data for new building
*/
static async create(type, id) {
static async downloadDataAroundBuilding(type, id) {
var data;
if (type === 'way') {
data = await Building.getWayData(id);
Expand All @@ -42,8 +42,7 @@ class Building {
let xmlData = new window.DOMParser().parseFromString(data, 'text/xml');
const nodelist = Building.buildNodeList(xmlData);
const extents = Building.getExtents(id, xmlData, nodelist);
const innerData = await Building.getInnerData(...extents);
return new Building(id, innerData);
return await Building.getInnerData(...extents);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ function init() {
if (params.has('errorBox')) {
errorBox = true;
}
Building.create(type, id).then(function(myObj){
mainBuilding = myObj;
const helperSize = myObj.outerElement.getWidth();
Building.downloadDataAroundBuilding(type, id).then(function(innerData){
mainBuilding = new Building(id, innerData);
const helperSize = mainBuilding.outerElement.getWidth();
const helper = new GridHelper(helperSize / 0.9, helperSize / 9);
scene.add(helper);

const mesh = myObj.render();
const mesh = mainBuilding.render();
for (let i = 0; i < mesh.length; i++) {
if (mesh[i] && mesh[i].isObject3D) {
scene.add(mesh[i]);
Expand All @@ -69,7 +69,7 @@ function init() {
}
if (displayInfo) {
gui = new GUI();
const info = myObj.getInfo();
const info = mainBuilding.getInfo();
const folder = gui.addFolder(info.type + ' - ' + info.id);
createFolders(folder, info.options);
for (let i = 0; i < info.parts.length; i++) {
Expand Down