Пример #1
0
        public async Task WaitAsync()
        {
            if (NodeLock == null)
            {
                await DotnetLock.WaitAsync();

                _dotNetLockTaken = true;
                return;
            }

            try
            {
                // We want to take the NPM lock first as is going to be the busiest one, and we want other threads to be
                // able to run dotnet new while we are waiting for another thread to finish running NPM.
                await NodeLock.WaitAsync();

                _nodeLockTaken = true;
                await DotnetLock.WaitAsync();

                _dotNetLockTaken = true;
            }
            catch
            {
                if (_nodeLockTaken)
                {
                    NodeLock.Release();
                    _nodeLockTaken = false;
                }
                throw;
            }
        }
Пример #2
0
        public bool ResetMap()
        {
            NodeLock.WaitLockEdit();

            foreach (var p in pendingLoaders)
            {
                p.loader?.Dispose();
                p.node?.Dispose();
            }

            pendingLoaders.Clear();

            foreach (var p in pendingActivations)
            {
                p.node?.Dispose();
            }

            pendingActivations.Clear();

            RemoveGameObjectHandles(_root);

            _controller.Reset();

            NodeLock.UnLock();

            return(true);
        }
Пример #3
0
        public bool Initialize()
        {
            _actionReceiver           = new NodeAction("DynamicLoadManager");
            _actionReceiver.OnAction += ActionReceiver_OnAction;

            _zflipMatrix = new Matrix4x4(new Vector4(1, 0, 0), new Vector4(0, 1, 0), new Vector4(0, 0, -1), new Vector4(0, 0, 0, 1));

            GizmoSDK.GizmoBase.Message.Send("SceneManager", MessageLevel.DEBUG, "Loading Graph");

            GizmoSDK.Gizmo3D.Platform.Initialize();

            NodeLock.WaitLockEdit();

            _native_camera             = new PerspCamera("Test");
            _native_camera.RoiPosition = true;
            _controller.Camera         = _native_camera;

            _native_scene = new Scene("TestScene");

            _native_context = new Context();

            //native_camera.Debug(native_context);

            _native_traverse_action = new CullTraverseAction();

            DynamicLoader.OnDynamicLoad += DynamicLoader_OnDynamicLoad;

            _native_camera.Scene = _native_scene;

            NodeLock.UnLock();

            DbManager.Initialize();

            return(true);
        }
 /// <summary>
 /// Adds the provided node lock to the opened node locks in this InGameState.
 /// </summary>
 /// <param name="nodeLock">Lock to add</param>
 public void ApplyOpenLock(NodeLock nodeLock)
 {
     if (!IsLockOpen(nodeLock))
     {
         OpenedLocks.Add(nodeLock.Name, nodeLock);
     }
 }
Пример #5
0
        public bool Uninitialize()
        {
            ResetMap();

            DynamicLoader.OnDynamicLoad -= DynamicLoader_OnDynamicLoad;
            _actionReceiver.OnAction    -= ActionReceiver_OnAction;

            NodeLock.WaitLockEdit();

            _native_camera.Debug(_native_context, false);
            _native_camera.Dispose();
            _native_camera = null;

            _native_context.Dispose();
            _native_context = null;

            _native_scene.Dispose();
            _native_scene = null;


            _actionReceiver.Dispose();
            _actionReceiver = null;

            NodeLock.UnLock();

            GizmoSDK.Gizmo3D.Platform.UnInitialize();

            _plugin_initializer = null;

            return(true);
        }
Пример #6
0
        public bool Uninitialize()
        {
            DynamicLoaderManager.StopManager();

            ResetMap();

            DynamicLoader.OnDynamicLoad -= DynamicLoader_OnDynamicLoad;
            _actionReceiver.OnAction    -= ActionReceiver_OnAction;

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                _native_camera.Debug(_native_context, false);
                _native_camera.Dispose();
                _native_camera = null;

                _native_context.Dispose();
                _native_context = null;

                _native_scene.Dispose();
                _native_scene = null;


                _actionReceiver.Dispose();
                _actionReceiver = null;
            }
            finally
            {
                NodeLock.UnLock();
            }


            return(true);
        }
Пример #7
0
            override public void Release()
            {
                if (IsValid())
                {
                    NodeLock.WaitLockEdit();

                    base.Release();

                    NodeLock.UnLock();
                }
            }
Пример #8
0
            virtual public void ReleaseInRender()
            {
                if (IsValid())
                {
                    NodeLock.WaitLockRender();

                    base.Release();

                    NodeLock.UnLock();
                }
            }
Пример #9
0
        // The LoadMap function takes an URL and loads the map into GizmoSDK native db
        public bool LoadMap(string mapURL)
        {
            NodeLock.WaitLockEdit();      // We assume we do all editing from main thread and to allow render we assume we edit in edit mode

            if (!ResetMap())
            {
                NodeLock.UnLock();
                return(false);
            }

            var node = DbManager.LoadDB(mapURL);

            if (node == null || !node.IsValid())
            {
                NodeLock.UnLock();
                return(false);
            }

            MapUrl = mapURL;

            _native_scene.AddNode(node);

            _controller.CurrentMap = node;

            _native_scene.Debug();

            _root = new GameObject("root");

            GameObject scene = Traverse(node, null);

            scene.transform.SetParent(_root.transform, false);

            // As GizmoSDK has a flipped Z axis going out of the screen we need a top transform to flip Z
            _root.transform.localScale = new Vector3(1, 1, -1);

            //// Add example object under ROI --------------------------------------------------------------

            //MapPos mapPos;

            //GetMapPosition(new LatPos(1.0084718541, 0.24984267815,300),out mapPos, GroundClampType.GROUND,true);

            //GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            //sphere.transform.parent = FindFirstGameObjectTransform(mapPos.roiNode);
            //sphere.transform.localPosition = mapPos.position.ToVector3();
            //sphere.transform.localScale = new Vector3(10,10,10);

            //// ------------------------------------------------------------------------------------------

            NodeLock.UnLock();

            return(true);
        }
Пример #10
0
 // We need to release all existing objects in a locked mode
 void OnDestroy()
 {
     // Basically all nodes in the GameObject scene should already be release by callbacks but there might be some nodes left that needs this behaviour
     if (node != null)
     {
         if (node.IsValid())
         {
             NodeLock.WaitLockEdit();
             node.Dispose();
             NodeLock.UnLock();
         }
     }
 }
Пример #11
0
            public static bool UnInitialize(bool forceShutdown = false, bool shutdownBase = false)
            {
                NodeLock.WaitLockEdit();

                DynamicLoader.UnInitialize();

                UnInitializeFactories();

                NodeLock.UnLock();

                bool result = Platform_uninitialize(forceShutdown, shutdownBase);

                return(result);
            }
Пример #12
0
        public bool Uninitialize()
        {
            if (!_initialized)
            {
                return(false);
            }

            // Stop manager
            DynamicLoaderManager.StopManager();

            ResetMap();

            // Remove actions
            DynamicLoader.OnDynamicLoad -= DynamicLoader_OnDynamicLoad;
            _actionReceiver.OnAction    -= ActionReceiver_OnAction;

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                _native_camera.Debug(_native_context, false);
                _native_camera.Dispose();
                _native_camera = null;

                _native_context.Dispose();
                _native_context = null;

                _native_scene.Dispose();
                _native_scene = null;


                _actionReceiver.Dispose();
                _actionReceiver = null;
            }
            finally
            {
                NodeLock.UnLock();
            }

            // Drop platform streamer
            GizmoSDK.Gizmo3D.Platform.Uninitialize();

            _initialized = false;

            return(true);
        }
Пример #13
0
        private async Task <ProcessEx> RestoreAsync(ITestOutputHelper output, string workingDirectory)
        {
            // It's not safe to run multiple NPM installs in parallel
            // https://github.com/npm/npm/issues/2500
            await NodeLock.WaitAsync();

            try
            {
                output.WriteLine($"Restoring NPM packages in '{workingDirectory}' using npm...");
                var result = ProcessEx.RunViaShell(output, workingDirectory, "npm install");
                return(result);
            }
            finally
            {
                NodeLock.Release();
            }
        }
Пример #14
0
        public bool InitializeInternal()
        {
            _actionReceiver = new NodeAction("DynamicLoadManager");

            _actionReceiver.OnAction += ActionReceiver_OnAction;

            _zflipMatrix = new Matrix4x4(new Vector4(1, 0, 0), new Vector4(0, 1, 0), new Vector4(0, 0, -1), new Vector4(0, 0, 0, 1));

            GizmoSDK.GizmoBase.Message.Send("SceneManager", MessageLevel.DEBUG, "Loading Graph");

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                _native_camera              = new PerspCamera("Test");
                _native_camera.RoiPosition  = true;
                MapControl.SystemMap.Camera = _native_camera;

                _native_scene = new Scene("TestScene");

                _native_context = new Context();

#if DEBUG_CAMERA
                _native_camera.Debug(_native_context);      // Enable to debug view
#endif // DEBUG_CAMERA

                _native_traverse_action = new CullTraverseAction();

                DynamicLoader.OnDynamicLoad += DynamicLoader_OnDynamicLoad;

                _native_camera.Scene = _native_scene;
            }
            finally
            {
                NodeLock.UnLock();
            }


            DynamicLoader.UsePreCache(true);                    // Enable use of mipmap creation on dynamic loading
            DynamicLoaderManager.SetNumberOfActiveLoaders(4);   // Lets start with 4 parallell threads
            DynamicLoaderManager.StartManager();

            return(true);
        }
Пример #15
0
            public RoiNode GetClosestRoiNode(Vec3D position)
            {
                RoiNode node;

                // We must call this from a node locked state as childs might unload during other edits

                try
                {
                    NodeLock.WaitLockEdit();

                    node = CreateObject(Roi_getClosestRoiNode(GetNativeReference(), ref position)) as RoiNode;
                }
                finally
                {
                    NodeLock.UnLock();
                }

                return(node);
            }
Пример #16
0
 public void Release()
 {
     try
     {
         if (_dotNetLockTaken)
         {
             DotnetLock.Release();
             _dotNetLockTaken = false;
         }
     }
     finally
     {
         if (_nodeLockTaken)
         {
             NodeLock.Release();
             _nodeLockTaken = false;
         }
     }
 }
Пример #17
0
        // We need to release all existing objects in a locked mode
        void OnDestroy()
        {
            // Basically all nodes in the GameObject scene should already be release by callbacks but there might be some nodes left that needs this behaviour
            if (node != null)
            {
                if (inNodeUtilsRegistry)
                {
                    NodeUtils.RemoveGameObjectReference(node.GetNativeReference(), gameObject);
                    inNodeUtilsRegistry = false;
                }


                if (node.IsValid())
                {
                    NodeLock.WaitLockEdit();
                    node.Dispose();
                    NodeLock.UnLock();
                }
            }
        }
Пример #18
0
        public bool FindGameObjects(Node node, out List <GameObject> gameObjectList)
        {
            gameObjectList = null;

            if (node == null)
            {
                return(false);
            }

            if (!node.IsValid())
            {
                return(false);
            }

            NodeLock.WaitLockEdit();

            bool result = currentObjects.TryGetValue(node.GetNativeReference(), out gameObjectList);

            NodeLock.UnLock();

            return(result);
        }
Пример #19
0
        public bool ResetMap()
        {
            //MapUrl = null;

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                foreach (var p in pendingLoaders)
                {
                    p.loader?.Dispose();
                    p.node?.Dispose();
                }

                pendingLoaders.Clear();

                foreach (var p in pendingActivations)
                {
                    p.node?.Dispose();
                }

                pendingActivations.Clear();

                if (_root)
                {
                    Free(_root.transform);
                    _root = null;
                }


                MapControl.SystemMap.Reset();
            }
            finally
            {
                NodeLock.UnLock();
            }

            return(true);
        }
Пример #20
0
        public void Reset()
        {
            try
            {
                NodeLock.WaitLockEdit();        // All change of map parameters shall be done in locked edit mode

                _mapType = MapType.UNKNOWN;

                _topRoi     = null;
                _currentMap = null;
                _nodeURL    = null;

                _origin   = new Vec3D(0, 0, 0);
                _metaData = new CoordinateSystemMetaData();

                _coordSystem = new CoordinateSystem();
            }
            finally
            {
                NodeLock.UnLock();
            }
        }
Пример #21
0
        // Update is called once per frame
        private void Update()
        {
            NodeLock.WaitLockEdit();

            ProcessPendingUpdates();

            // Transfer camera parameters

            PerspCamera perspCamera = _native_camera as PerspCamera;

            if (perspCamera != null)
            {
                perspCamera.VerticalFOV   = UnityCamera.fieldOfView;
                perspCamera.HorizontalFOV = 2 * Mathf.Atan(Mathf.Tan(UnityCamera.fieldOfView * Mathf.Deg2Rad / 2) * UnityCamera.aspect) * Mathf.Rad2Deg;;
                perspCamera.NearClipPlane = UnityCamera.nearClipPlane;
                perspCamera.FarClipPlane  = UnityCamera.farClipPlane;
            }

            Matrix4x4 unity_camera_transform = UnityCamera.transform.worldToLocalMatrix;

            Matrix4x4 gz_transform = _zflipMatrix * unity_camera_transform * _zflipMatrix;

            _native_camera.Transform = gz_transform.ToMatrix4();

            IWorldCoord ctrl = UnityCamera.GetComponent <IWorldCoord>();

            if (ctrl != null)
            {
                _native_camera.Position = ctrl.Position;
            }

            NodeLock.UnLock();

            NodeLock.WaitLockRender();
            _native_camera.Render(_native_context, 1000, 1000, 1000, _native_traverse_action);
            //native_camera.DebugRefresh();
            NodeLock.UnLock();
        }
Пример #22
0
        public bool ResetMap()
        {
            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                foreach (var p in pendingLoaders)
                {
                    p.loader?.Dispose();
                    p.node?.Dispose();
                }

                pendingLoaders.Clear();

                foreach (var p in pendingActivations)
                {
                    p.node?.Dispose();
                }

                pendingActivations.Clear();

                RemoveGameObjectHandles(_root);

                GameObject.Destroy(_root);

                _root = null;

                MapControl.SystemMap.Reset();
            }
            finally
            {
                NodeLock.UnLock();
            }

            return(true);
        }
Пример #23
0
    public override void OnInspectorGUI()
    {
        if (m_Instance == null)
        {
            return;
        }

        this.DrawDefaultInspector();

        // Expose the decorated fields
        ExposeProperties.Expose(m_fields);

        GUILayoutOption[] emptyOptions = new GUILayoutOption[0];

        if (m_Instance.node == null || !m_Instance.node.IsValid())
        {
            EditorGUILayout.LabelField("No created native Node Handle", emptyOptions);

            m_defaultClass = EditorGUILayout.TextField("Class Name", m_defaultClass, emptyOptions);

            EditorGUILayout.BeginHorizontal(emptyOptions);

            if (GUILayout.Button("Create " + m_defaultClass))
            {
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            return;
        }

        /////////////////////////////////////////////////////
        /// Presentation Area of node attributes
        /// Shall reamin Locked
        ///

        try
        {
            NodeLock.WaitLockEdit();

            /////////////////////////////////////////////////////////////////////////////////////////////

            bool change = false;

            if (PropEdit_Object(m_Instance.node as GizmoSDK.GizmoBase.Object))
            {
                change = true;
            }

            if (PropEdit_Node(m_Instance.node as Node))
            {
                change = true;
            }

            if (PropEdit_DynamicLoader(m_Instance.node as DynamicLoader))
            {
                change = true;
            }

            if (change)
            {
                m_Instance.node.SetDirtySaveData(true);
            }

            if (m_Instance.node.HasDirtySaveData())
            {
                EditorGUILayout.BeginHorizontal(emptyOptions);

                if (GUILayout.Button("Save"))
                {
                    m_Instance.node.SaveDirtyData();
                }

                GUILayout.FlexibleSpace();

                EditorGUILayout.EndHorizontal();
            }

            //////////////////////////////////////////////////////////////////////////////////////////
        }
        finally
        {
            NodeLock.UnLock();
        }
    }
 /// <summary>
 /// Returns whether the provided node lock is open in this InGameState.
 /// </summary>
 /// <param name="nodeLock">The node lock to check</param>
 /// <returns></returns>
 public bool IsLockOpen(NodeLock nodeLock)
 {
     return(OpenedLocks.ContainsKey(nodeLock.Name));
 }
Пример #25
0
        // Update is called once per frame
        private void Update()
        {
            try
            {
                Performance.Enter("SM.Update");

                if (!NodeLock.TryLockEdit(30))      // 30 msek allow latency of other pending editor
                {
                    Message.Send(ID, MessageLevel.DEBUG, "Lock contention detected! NodeLock::TryLockEdit() FRAME LOST");

                    // We failed to refresh scene in reasonable time but we still need to issue updates;

                    Performance.Enter("SM.Update.PreTraverse");
                    if (SceneManagerCamera != null)
                    {
                        SceneManagerCamera.PreTraverse();
                    }
                    OnPreTraverse?.Invoke();
                    Performance.Leave();

                    return;
                }

                try // We are now locked in edit
                {
                    Performance.Enter("SM.ProcessPendingUpdates");
                    ProcessPendingUpdates();
                }
                finally
                {
                    Performance.Leave();

                    NodeLock.UnLock();
                }

                // Notify about we are starting to traverse -----------------------

                Performance.Enter("SM.Update.PreTraverse");
                if (SceneManagerCamera != null)
                {
                    SceneManagerCamera.PreTraverse();
                }
                OnPreTraverse?.Invoke();
                Performance.Leave();

                // Check if camera present ---------------------------------------

                if (SceneManagerCamera == null)
                {
                    return;
                }


                // ---------------------------------------------------------------

                var UnityCamera = SceneManagerCamera.Camera;

                if (UnityCamera == null)
                {
                    return;
                }

                if (!NodeLock.TryLockRender(30))    // 30 millisek latency allowed
                {
                    Message.Send(ID, MessageLevel.DEBUG, "Lock contention detected! NodeLock::TryLockRender() FRAME LOST");
                    return;
                }

                try // We are now locked in read
                {
                    // Transfer camera parameters

                    PerspCamera perspCamera = _native_camera as PerspCamera;

                    if (perspCamera != null)
                    {
                        perspCamera.VerticalFOV   = UnityCamera.fieldOfView;
                        perspCamera.HorizontalFOV = 2 * Mathf.Atan(Mathf.Tan(UnityCamera.fieldOfView * Mathf.Deg2Rad / 2) * UnityCamera.aspect) * Mathf.Rad2Deg;;
                        perspCamera.NearClipPlane = UnityCamera.nearClipPlane;
                        perspCamera.FarClipPlane  = UnityCamera.farClipPlane;
                    }

                    Matrix4x4 unity_camera_transform = UnityCamera.transform.worldToLocalMatrix;

                    _native_camera.Transform = unity_camera_transform.ToZFlippedMatrix4();

                    _native_camera.Position = SceneManagerCamera.GlobalPosition;

                    _native_camera.Render(_native_context, 1000, 1000, 1000, _native_traverse_action);

#if DEBUG_CAMERA
                    _native_camera.DebugRefresh();
#endif
                }
                finally
                {
                    NodeLock.UnLock();
                }

                UpdateNodeInternals();

                // -------------------------------------------------------------
            }
            finally
            {
                // Notify about we are ready in traverse -----------------------

                Performance.Enter("SM.Update.PostTraverse");
                if (SceneManagerCamera != null)
                {
                    SceneManagerCamera.PostTraverse();
                }
                OnPostTraverse?.Invoke();
                Performance.Leave();

                // Leave Scm update -------------------------------------------
                Performance.Leave();
            }
        }
Пример #26
0
        public bool InitializeInternal()
        {
            // Initialize streamer APIs
            if (!GizmoSDK.Gizmo3D.Platform.Initialize())
            {
                return(false);
            }

            // Initialize formats
            DbManager.Initialize();

            GizmoSDK.GizmoBase.Message.Send("SceneManager", MessageLevel.DEBUG, "Initialize Graph Streaming");

            // Add builder for registered types
            AddDefaultBuilders();

            // Setup internal subscription events
            _actionReceiver           = new NodeAction("DynamicLoadManager");
            _actionReceiver.OnAction += ActionReceiver_OnAction;

            DynamicLoader.OnDynamicLoad += DynamicLoader_OnDynamicLoad;


            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                // Camera setup
                _native_camera              = new PerspCamera("Test");
                _native_camera.RoiPosition  = true;
                MapControl.SystemMap.Camera = _native_camera;

                // Top scene
                _native_scene        = new Scene("Scene");
                _native_camera.Scene = _native_scene;

                // Top context
                _native_context = new Context();

#if DEBUG_CAMERA
                // If we want to visualize debug 3D
                _native_camera.Debug(_native_context);      // Enable to debug view
#endif // DEBUG_CAMERA

                // Default travrser
                _native_traverse_action = new CullTraverseAction();

                // _native_traverse_action.SetOmniTraverser(true);  // To skip camera cull and use LOD in omni directions
            }
            finally
            {
                NodeLock.UnLock();
            }

            // Set up dynamic loading
            DynamicLoader.UsePreCache(true);                                        // Enable use of mipmap creation on dynamic loading
            DynamicLoaderManager.SetNumberOfActiveLoaders(Settings.DynamicLoaders); // Lets start with 4 parallell threads
            DynamicLoaderManager.StartManager();

            // Start coroutines for asset loading
            StartCoroutine(AssetLoader());

            return(true);
        }
Пример #27
0
        // Update is called once per frame
        private void Update()
        {
            if (!NodeLock.TryLockEdit(30))      // 30 msek allow latency of other pending editor
            {
                // We failed to refresh scene in reasonable time but we still need to issue updates;

                if (SceneManagerCamera == null)
                {
                    return;
                }

                Performance.Enter("PreTraverse");
                SceneManagerCamera.PreTraverse();
                OnPreTraverse?.Invoke();
                Performance.Leave();

                Performance.Enter("PostTraverse");
                SceneManagerCamera.PostTraverse();
                OnPostTraverse?.Invoke();
                Performance.Leave();

                return;
            }

            try // We are now locked in edit
            {
                ProcessPendingUpdates();
            }
            finally
            {
                NodeLock.UnLock();
            }

            if (SceneManagerCamera == null)
            {
                return;
            }

            // Notify about we are starting to traverse -----------------------

            Performance.Enter("PreTraverse");
            SceneManagerCamera.PreTraverse();
            OnPreTraverse?.Invoke();
            Performance.Leave();

            // -------------------------------------------------------------

            var UnityCamera = SceneManagerCamera.Camera;

            if (UnityCamera == null)
            {
                return;
            }

            if (!NodeLock.TryLockRender(30))    // 30 millisek latency allowed
            {
                return;
            }

            try // We are now locked in read
            {
                // Transfer camera parameters

                PerspCamera perspCamera = _native_camera as PerspCamera;

                if (perspCamera != null)
                {
                    perspCamera.VerticalFOV   = UnityCamera.fieldOfView;
                    perspCamera.HorizontalFOV = 2 * Mathf.Atan(Mathf.Tan(UnityCamera.fieldOfView * Mathf.Deg2Rad / 2) * UnityCamera.aspect) * Mathf.Rad2Deg;;
                    perspCamera.NearClipPlane = UnityCamera.nearClipPlane;
                    perspCamera.FarClipPlane  = UnityCamera.farClipPlane;
                }

                Matrix4x4 unity_camera_transform = UnityCamera.transform.worldToLocalMatrix;

                Matrix4x4 gz_transform = _zflipMatrix * unity_camera_transform * _zflipMatrix;

                _native_camera.Transform = gz_transform.ToMatrix4();

                var p = SceneManagerCamera.Position;
                _native_camera.Position = new Vec3D(p.x, p.y, -p.z);

                _native_camera.Render(_native_context, 1000, 1000, 1000, _native_traverse_action);

#if DEBUG_CAMERA
                _native_camera.DebugRefresh();
#endif
            }
            finally
            {
                NodeLock.UnLock();
            }

            UpdateNodeInternals();

            // Notify about we are ready in traverse -----------------------

            Performance.Enter("PostTraverse");
            SceneManagerCamera.PostTraverse();
            OnPostTraverse?.Invoke();
            Performance.Leave();

            // -------------------------------------------------------------
        }
Пример #28
0
        // The LoadMap function takes an URL and loads the map into GizmoSDK native db
        public bool LoadMap(string mapURL)
        {
            NodeLock.WaitLockEdit(); // We assume we do all editing from main thread and to allow render we assume we edit in edit mode

            try                      // We are now locked in edit
            {
                if (!ResetMap())
                {
                    return(false);
                }

                var node = DbManager.LoadDB(mapURL);

                if (node == null || !node.IsValid())
                {
                    Message.Send(ID, MessageLevel.WARNING, $"Failed to load map {mapURL}");
                    return(false);
                }

                MapUrl = mapURL;

                MapControl.SystemMap.NodeURL    = mapURL;
                MapControl.SystemMap.CurrentMap = node;

                _native_scene.AddNode(MapControl.SystemMap.CurrentMap);

                _native_scene.Debug();

                _root = new GameObject("root");

                GameObject scene = Traverse(MapControl.SystemMap.CurrentMap, null);

                if (scene != null)
                {
                    scene.transform.SetParent(_root.transform, false);
                }

                // As GizmoSDK has a flipped Z axis going out of the screen we need a top transform to flip Z
                _root.transform.localScale = new Vector3(1, 1, -1);


                //// Add example object under ROI --------------------------------------------------------------

                //MapPos mapPos;

                //GetMapPosition(new LatPos(1.0084718541, 0.24984267815, 300), out mapPos, GroundClampType.GROUND, true);

                //_test = GameObject.CreatePrimitive(PrimitiveType.Sphere);

                //_test.transform.parent = FindFirstGameObjectTransform(mapPos.roiNode);
                //_test.transform.localPosition = mapPos.position.ToVector3();
                //_test.transform.localScale = new Vector3(10, 10, 10);

                if (SceneManagerCamera != null)
                {
                    SceneManagerCamera.MapChanged();
                }

                OnMapChanged?.Invoke(node);
            }
            finally
            {
                NodeLock.UnLock();
            }

            return(true);
        }