Skip to content

Commit

Permalink
create newScene function first version
Browse files Browse the repository at this point in the history
  • Loading branch information
Algorush committed Apr 20, 2024
1 parent 2f70a8a commit eb08d4f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ if (typeof VERSION !== 'undefined') { console.log(`3DStreet Version: ${VERSION}`
var streetmixParsers = require('./aframe-streetmix-parsers');
var streetmixUtils = require('./tested/streetmix-utils');
require('./json-utils_1.1.js');
require('./street-utils.js');
require('./components/gltf-part');
require('./components/ocean');
require('./components/svg-extruder.js');
Expand Down
45 changes: 45 additions & 0 deletions src/street-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* global AFRAME, THREE */
/* 3DStreet utils functions */

/*
clear old scene elements and data. Create blank scene
*/
function newScene() {

const streetContainerEl = document.querySelector("#street-container");
const environmentEl = document.querySelector("#environment");
const referenceLayersEl = document.querySelector("#reference-layers");

// clear street-container element
while (streetContainerEl.firstChild) {
streetContainerEl.removeChild(streetContainerEl.lastChild);
}
// streetContainerEl.innerHTML = '';
// create default-street element
const defaultStreet = document.createElement("a-entity");
defaultStreet.id = "default-street";
streetContainerEl.appendChild(defaultStreet);

// clear environment element
while (environmentEl.firstChild) {
environmentEl.removeChild(environmentEl.lastChild);
}
// set default preset:day
environmentEl.setAttribute('street-environment', 'preset', 'day');

// clear reference layers
while (referenceLayersEl.firstChild) {
referenceLayersEl.removeChild(referenceLayersEl.lastChild);
}

// clear metadata
AFRAME.scenes[0].setAttribute('metadata', 'sceneId', '');
AFRAME.scenes[0].setAttribute('metadata', 'sceneTitle', '');

// clear url hash
setTimeout(function () {
window.location.hash = '';
});
}

STREET.utils.newScene = newScene;

0 comments on commit eb08d4f

Please sign in to comment.