Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
add: new save button (downloading JSON object)
Browse files Browse the repository at this point in the history
  • Loading branch information
omedvediev committed Nov 18, 2022
1 parent 2017609 commit a3070c5
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/components/scenegraph/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,20 @@ export default class Toolbar extends Component {
}));

convertToObject = () => {
const entities = document.querySelectorAll('a-entity');
const entity = document.getElementById('streets');

const data = [];
if (entities.length) {
for (const entry of entities) {
data.push(getElementData(entry));
}
}
const data = getElementData(entity);

const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
JSON.stringify({ data: data })
)}`;

// const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
// stringify({ data: data })
// )}`;
// const link = document.createElement('a');
// link.href = jsonString;
// link.download = 'data.json';
const link = document.createElement('a');
link.href = jsonString;
link.download = 'data.json';

// link.click();
// link.remove();
link.click();
link.remove();
};

render() {
Expand Down

0 comments on commit a3070c5

Please sign in to comment.