Skip to content

Commit

Permalink
call json-utils.js from index.js
Browse files Browse the repository at this point in the history
move functions used elsewhere from json-utils to a global STREET object
  • Loading branch information
Algorush committed Feb 1, 2024
1 parent 938e55f commit 6539209
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 1 addition & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<!-- mapbox -->
<script src="./src/lib/aframe-mapbox-component.min.js"></script>

<!-- save / load -->
<script src="./src/json-utils.js"></script>

<!-- vr teleport controls -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/aframe-blink-controls.min.js"></script>

Expand Down Expand Up @@ -123,7 +120,7 @@
<script>

document.getElementById('inputfile')
.addEventListener('change', fileJSON);
.addEventListener('change', STREET.utils.fileJSON);

function buttonScreenshotTock() {
const screenshotEl = document.getElementById('screenshot');
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require('babel-polyfill');
if (typeof VERSION !== 'undefined') { console.log(`3DStreet Version: ${VERSION} (Date: ${new Date(COMMIT_DATE).toISOString().split('T')[0]}, Commit Hash: #${COMMIT_HASH})`); }
var streetmixParsers = require('./aframe-streetmix-parsers');
var streetmixUtils = require('./tested/streetmix-utils');
require('./json-utils.js');
require('./components/gltf-part');
require('./components/ocean');
require('./lib/aframe-cursor-teleport-component.min.js');
Expand Down
12 changes: 11 additions & 1 deletion src/json-utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* global AFRAME, Node */
/* version: 1.0 */

var STREET = {};
window.STREET = {};
STREET.utils = {};


function getSceneUuidFromURLHash () {
const currentHash = window.location.hash;
const match = currentHash.match(/#\/scenes\/([a-zA-Z0-9-]+)\.json/);
Expand Down Expand Up @@ -56,6 +57,8 @@ function convertDOMElToObject (entity) {
};
}

STREET.utils.convertDOMElToObject = convertDOMElToObject;

function getElementData (entity) {
if (!entity.isEntity) {
return;
Expand Down Expand Up @@ -220,6 +223,8 @@ function filterJSONstreet (removeProps, renameProps, streetJSON) {
return stringJSON;
}

STREET.utils.filterJSONstreet = filterJSONstreet;

/**
* function from 3dstreet-editor/src/lib/entity.js
* Gets the value for a component or component's property coming from mixins of
Expand Down Expand Up @@ -642,6 +647,8 @@ function createElementsFromJSON (streetJSON) {
STREET.notify.successMessage('Scene loaded from JSON');
}

STREET.utils.createElementsFromJSON = createElementsFromJSON;

// viewer widget click to paste json string of 3dstreet scene
function inputJSON () {
const stringJSON = prompt('Please paste 3DStreet JSON string');
Expand All @@ -660,3 +667,6 @@ function fileJSON () {
};
reader.readAsText(this.files[0]);
}

// temporarily place the UI function in utils, which is used in index.html.
STREET.utils.fileJSON = fileJSON;

0 comments on commit 6539209

Please sign in to comment.