diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 39031acaa1..2aa84bff03 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -113,17 +113,19 @@ void EntityTreeRenderer::resetEntitiesScriptEngine() { void EntityTreeRenderer::clear() { leaveAllEntities(); + // unload and stop the engine if (_entitiesScriptEngine) { - // Unload and stop the engine here (instead of in its deleter) to - // avoid marshalling unload signals back to this thread + // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread _entitiesScriptEngine->unloadAllEntityScripts(); _entitiesScriptEngine->stop(); } + // reset the engine if (_wantScripts && !_shuttingDown) { resetEntitiesScriptEngine(); } + // remove all entities from the scene auto scene = _viewState->getMain3DScene(); render::PendingChanges pendingChanges; foreach(auto entity, _entitiesInScene) { @@ -132,6 +134,10 @@ void EntityTreeRenderer::clear() { scene->enqueuePendingChanges(pendingChanges); _entitiesInScene.clear(); + // reset the zone to the default (while we load the next scene) + _bestZone = nullptr; + applyZonePropertiesToScene(_bestZone); + OctreeRenderer::clear(); }