From f1ff99dc9c88130fcc8b25ff011091d3c7bcc5fe Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Mon, 2 Sep 2024 11:56:05 +0200 Subject: [PATCH] emit newScene event when all the entities are created --- src/editor/components/scenegraph/Toolbar.js | 1 + src/editor/lib/toolbar.js | 8 ++------ src/json-utils_1.1.js | 2 ++ src/street-utils.js | 2 -- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/editor/components/scenegraph/Toolbar.js b/src/editor/components/scenegraph/Toolbar.js index 6c70f8130..41d8250c8 100644 --- a/src/editor/components/scenegraph/Toolbar.js +++ b/src/editor/components/scenegraph/Toolbar.js @@ -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 }) => { diff --git a/src/editor/lib/toolbar.js b/src/editor/lib/toolbar.js index 27e20cdf7..8185bb328 100644 --- a/src/editor/lib/toolbar.js +++ b/src/editor/lib/toolbar.js @@ -1,5 +1,3 @@ -import Events from './Events'; - export function inputStreetmix() { const streetmixURL = prompt( 'Please enter a Streetmix URL', @@ -21,8 +19,7 @@ export function inputStreetmix() { streetmixURL ); - // update sceneGraph - Events.emit('updatescenegraph'); + AFRAME.scenes[0].emit('newScene'); } export function createElementsForScenesFromJSON(streetData) { @@ -38,6 +35,7 @@ export function createElementsForScenesFromJSON(streetData) { } STREET.utils.createEntities(streetData, streetContainerEl); + AFRAME.scenes[0].emit('newScene'); } export function fileJSON(event) { @@ -45,8 +43,6 @@ export function fileJSON(event) { reader.onload = function () { STREET.utils.createElementsFromJSON(reader.result); - // update sceneGraph - Events.emit('updatescenegraph'); }; reader.readAsText(event.target.files[0]); diff --git a/src/json-utils_1.1.js b/src/json-utils_1.1.js index 90c7b240d..35ac16e10 100644 --- a/src/json-utils_1.1.js +++ b/src/json-utils_1.1.js @@ -640,6 +640,7 @@ function inputStreetmix() { 'streetmixStreetURL', streetmixURL ); + AFRAME.scenes[0].emit('newScene'); } STREET.utils.inputStreetmix = inputStreetmix; @@ -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; diff --git a/src/street-utils.js b/src/street-utils.js index 4f844a2bd..4ff5f0970 100644 --- a/src/street-utils.js +++ b/src/street-utils.js @@ -74,8 +74,6 @@ function newScene( window.location.hash = ''; }); } - - AFRAME.scenes[0].emit('newScene'); } STREET.utils.newScene = newScene;