Cesium场景回收及销毁

时间:2025-05-12 10:54:12
   //清空三维图层
        allClear(){
            if () {
              	 =
                 && ();
               }
            ();
            ();
             =
               && ();
            // 获取webgl上下文
            let gl = ._originalGLContext;
            // 当canvas大小改变时,页面就会自动刷新
             = 1;
             = 1;
             =
               && ();
            // 销毁webgl上下文
            ("WEBGL_lose_context").loseContext();
            gl = null;
            // 销毁页面计时器
            let end = setInterval(function () {}, 10000);
            for (let i = 1; i <= end; i++) {
              clearInterval(i);
            }
        },

经过测试,内存可以完全释放,不会发生内存泄漏的问题