Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emit newScene event when all the entities are created #825

Merged
merged 1 commit into from
Sep 4, 2024
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
1 change: 1 addition & 0 deletions src/editor/components/scenegraph/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default class Toolbar extends Component {
newHandler = () => {
AFRAME.INSPECTOR.selectEntity(null);
STREET.utils.newScene();
AFRAME.scenes[0].emit('newScene');
};

cloudSaveHandler = async ({ doSaveAs = false }) => {
Expand Down
8 changes: 2 additions & 6 deletions src/editor/lib/toolbar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Events from './Events';

export function inputStreetmix() {
const streetmixURL = prompt(
'Please enter a Streetmix URL',
Expand All @@ -21,8 +19,7 @@ export function inputStreetmix() {
streetmixURL
);

// update sceneGraph
Events.emit('updatescenegraph');
AFRAME.scenes[0].emit('newScene');
}

export function createElementsForScenesFromJSON(streetData) {
Expand All @@ -38,15 +35,14 @@ export function createElementsForScenesFromJSON(streetData) {
}

STREET.utils.createEntities(streetData, streetContainerEl);
AFRAME.scenes[0].emit('newScene');
}

export function fileJSON(event) {
let reader = new FileReader();

reader.onload = function () {
STREET.utils.createElementsFromJSON(reader.result);
// update sceneGraph
Events.emit('updatescenegraph');
};

reader.readAsText(event.target.files[0]);
Expand Down
2 changes: 2 additions & 0 deletions src/json-utils_1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ function inputStreetmix() {
'streetmixStreetURL',
streetmixURL
);
AFRAME.scenes[0].emit('newScene');
}

STREET.utils.inputStreetmix = inputStreetmix;
Expand Down Expand Up @@ -677,6 +678,7 @@ function createElementsFromJSON(streetJSON) {

createEntities(streetObject.data, streetContainerEl);
STREET.notify.successMessage('Scene loaded from JSON');
AFRAME.scenes[0].emit('newScene');
}

STREET.utils.createElementsFromJSON = createElementsFromJSON;
Expand Down
2 changes: 0 additions & 2 deletions src/street-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ function newScene(
window.location.hash = '';
});
}

AFRAME.scenes[0].emit('newScene');
}

STREET.utils.newScene = newScene;
Expand Down