functionCesiumWidget(container, options) { if (!defined(container)) { thrownewDeveloperError("container is required."); }
container = getElement(container); options = defaultValue(options, defaultValue.EMPTY_OBJECT); //Configure the widget DOM elements var element = document.createElement("div"); element.className = "cesium-widget"; container.appendChild(element); var canvas = document.createElement("canvas");
// Blue sky, and the glow around the Earth's limb. var skyAtmosphere = options.skyAtmosphere; if (!defined(skyAtmosphere)) { skyAtmosphere = newSkyAtmosphere(ellipsoid); } if (skyAtmosphere !== false) { scene.skyAtmosphere = skyAtmosphere; }
创建天空盒、大气环境等环境因素。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//Set the base imagery layer var imageryProvider = options.globe === false ? false : options.imageryProvider; if (!defined(imageryProvider)) { imageryProvider = createWorldImagery(); }
if (imageryProvider !== false) { scene.imageryLayers.addImageryProvider(imageryProvider); }
//Set the terrain provider if one is provided. if (defined(options.terrainProvider) && options.globe !== false) { scene.terrainProvider = options.terrainProvider; }
if (defined(options.sceneMode)) { if (options.sceneMode === SceneMode.SCENE2D) { this._scene.morphTo2D(0); } if (options.sceneMode === SceneMode.COLUMBUS_VIEW) { this._scene.morphToColumbusView(0); }}
判断scene的视图模式是二维、三维还是2.5的。
1
var that = this;this._onRenderError = function (scene, error) { that._useDefaultRenderLoop = false; that._renderLoopRunning = false; if (that._showRenderLoopErrors) { var title = "An error occurred while rendering. Rendering has stopped."; that.showErrorPanel(title, undefined, error); }};scene.renderError.addEventListener(this._onRenderError);