{"action":"created","issue":{"url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/2729","labels_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/2729/labels{/name}","comments_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/2729/comments","events_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/2729/events","html_url":"https://github.com/geoadmin/mf-geoadmin3/pull/2729","id":109084373,"number":2729,"title":"Lazy loading and initialisation of cesium","user":{"login":"gjn","id":2572317,"avatar_url":"https://avatars.githubusercontent.com/u/2572317?v=3","gravatar_id":"","url":"https://api.github.com/users/gjn","html_url":"https://github.com/gjn","followers_url":"https://api.github.com/users/gjn/followers","following_url":"https://api.github.com/users/gjn/following{/other_user}","gists_url":"https://api.github.com/users/gjn/gists{/gist_id}","starred_url":"https://api.github.com/users/gjn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjn/subscriptions","organizations_url":"https://api.github.com/users/gjn/orgs","repos_url":"https://api.github.com/users/gjn/repos","events_url":"https://api.github.com/users/gjn/events{/privacy}","received_events_url":"https://api.github.com/users/gjn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-09-30T13:18:03Z","updated_at":"2015-10-07T06:57:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/pulls/2729","html_url":"https://github.com/geoadmin/mf-geoadmin3/pull/2729","diff_url":"https://github.com/geoadmin/mf-geoadmin3/pull/2729.diff","patch_url":"https://github.com/geoadmin/mf-geoadmin3/pull/2729.patch"},"body":"Currently, cesium initialisation [1] is done once the 3d mode is activated by the user (clicking 3D button) or when application starts in 3d mode directly.\r\n\r\nThis PR adds  the initialisation process [1] after a given idle time [2]. This gets rid of the `First 2d->3d switch bug` described in the minutes document by assuring that the cesium viewer is ready when the user clicks the 3D button. Also, switching to 3D for the first time should be faster as the library and 3d view is already present.\r\n\r\nAs @gberaudo said, this could be extended to even load 3D terrain/tiles in the background. This is for a separate PR. Again, the hard part is the really define the 'idle' state [2].\r\n\r\n[Testlink](https://mf-geoadmin3.dev.bgdi.ch/gjn_idle_load/?dev3d=true)\r\n\r\n[1] cesium inistialisation is in fact 2 parts: loading of the script from the server and initialisation of the cesium view, which is synchronized with the ol3 map.\r\n[2] Idle state is not easy to determine (you can find alot about it with google). We currently use angulars https interceptor to detect if all http/ajac requests are finished and wait 2 seconds to emit an idle event. Unfortunately, this check ignores the ol3 map tile requests.\r\n\r\nAddendum: we don't use defer/async because we want to load cesium depending on browser capabilities."},"comment":{"url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/comments/146096214","html_url":"https://github.com/geoadmin/mf-geoadmin3/pull/2729#issuecomment-146096214","issue_url":"https://api.github.com/repos/geoadmin/mf-geoadmin3/issues/2729","id":146096214,"user":{"login":"gjn","id":2572317,"avatar_url":"https://avatars.githubusercontent.com/u/2572317?v=3","gravatar_id":"","url":"https://api.github.com/users/gjn","html_url":"https://github.com/gjn","followers_url":"https://api.github.com/users/gjn/followers","following_url":"https://api.github.com/users/gjn/following{/other_user}","gists_url":"https://api.github.com/users/gjn/gists{/gist_id}","starred_url":"https://api.github.com/users/gjn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjn/subscriptions","organizations_url":"https://api.github.com/users/gjn/orgs","repos_url":"https://api.github.com/users/gjn/repos","events_url":"https://api.github.com/users/gjn/events{/privacy}","received_events_url":"https://api.github.com/users/gjn/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T06:57:35Z","updated_at":"2015-10-07T06:57:35Z","body":"@oterral I've adapted the PR a little bit, pre-loading after idle is now done only on desktop. Also working with promises now and cesium initailisation moved out of maincontroller."}}