import BoundingSphere from "../Core/BoundingSphere.js";
import Cartesian3 from "../Core/Cartesian3.js";
import Cartographic from "../Core/Cartographic.js";
import Clock from "../Core/Clock.js";
import Frozen from "../Core/Frozen.js";
import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";
import Ellipsoid from "../Core/Ellipsoid.js";
import Event from "../Core/Event.js";
import EventHelper from "../Core/EventHelper.js";
import FeatureDetection from "../Core/FeatureDetection.js";
import formatError from "../Core/formatError.js";
import HeadingPitchRange from "../Core/HeadingPitchRange.js";
import Matrix4 from "../Core/Matrix4.js";
import BoundingSphereState from "../DataSources/BoundingSphereState.js";
import DataSourceCollection from "../DataSources/DataSourceCollection.js";
import DataSourceDisplay from "../DataSources/DataSourceDisplay.js";
import EntityView from "../DataSources/EntityView.js";
import getElement from "../DataSources/getElement.js";
import Property from "../DataSources/Property.js";
import Cesium3DTileset from "../Scene/Cesium3DTileset.js";
import computeFlyToLocationForRectangle from "../Scene/computeFlyToLocationForRectangle.js";
import Globe from "../Scene/Globe.js";
import ImageryLayer from "../Scene/ImageryLayer.js";
import Moon from "../Scene/Moon.js";
import Scene from "../Scene/Scene.js";
import SceneMode from "../Scene/SceneMode.js";
import ScreenSpaceEventHandler from "../Core/ScreenSpaceEventHandler.js";
import ShadowMode from "../Scene/ShadowMode.js";
import SkyAtmosphere from "../Scene/SkyAtmosphere.js";
import SkyBox from "../Scene/SkyBox.js";
import Sun from "../Scene/Sun.js";
import TimeDynamicPointCloud from "../Scene/TimeDynamicPointCloud.js";
import VoxelPrimitive from "../Scene/VoxelPrimitive.js";
function trackDataSourceClock(clock, dataSource) {
if (defined(dataSource)) {
const dataSourceClock = dataSource.clock;
if (defined(dataSourceClock)) {
dataSourceClock.getValue(clock);
}
}
}
function startRenderLoop(widget) {
widget._renderLoopRunning = true;
let lastFrameTime = 0;
function render(frameTime) {
if (widget.isDestroyed()) {
return;
}
if (widget._useDefaultRenderLoop) {
try {
const targetFrameRate = widget._targetFrameRate;
if (!defined(targetFrameRate)) {
widget.resize();
widget.render();
requestAnimationFrame(render);
} else {
const interval = 1000.0 / targetFrameRate;
const delta = frameTime - lastFrameTime;
if (delta > interval) {
widget.resize();
widget.render();
lastFrameTime = frameTime - (delta % interval);
}
requestAnimationFrame(render);
}
} catch (error) {
widget._useDefaultRenderLoop = false;
widget._renderLoopRunning = false;
if (widget._showRenderLoopErrors) {
const title =
"An error occurred while rendering. Rendering has stopped.";
widget.showErrorPanel(title, undefined, error);
}
}
} else {
widget._renderLoopRunning = false;
}
}
requestAnimationFrame(render);
}
function configurePixelRatio(widget) {
let pixelRatio = widget._useBrowserRecommendedResolution
? 1.0
: window.devicePixelRatio;
pixelRatio *= widget._resolutionScale;
if (defined(widget._scene)) {
widget._scene.pixelRatio = pixelRatio;
}
return pixelRatio;
}
function configureCanvasSize(widget) {
const canvas = widget._canvas;
let width = canvas.clientWidth;
let height = canvas.clientHeight;
const pixelRatio = configurePixelRatio(widget);
widget._canvasClientWidth = width;
widget._canvasClientHeight = height;
width *= pixelRatio;
height *= pixelRatio;
canvas.width = width;
canvas.height = height;
widget._canRender = width !== 0 && height !== 0;
widget._lastDevicePixelRatio = window.devicePixelRatio;
}
function configureCameraFrustum(widget) {
const canvas = widget._canvas;
const width = canvas.width;
const height = canvas.height;
if (width !== 0 && height !== 0) {
const frustum = widget._scene.camera.frustum;
if (defined(frustum.aspectRatio)) {
frustum.aspectRatio = width / height;
} else {
frustum.top = frustum.right * (height / width);
frustum.bottom = -frustum.top;
}
}
}
/**
* A widget containing a Cesium scene.
*
* @alias CesiumWidget
* @constructor
*
* @param {Element|string} container The DOM element or ID that will contain the widget.
* @param {object} [options] Object with the following properties:
* @param {Clock} [options.clock=new Clock()] The clock to use to control current time.
* @param {boolean} [options.shouldAnimate=false] true if the clock should attempt to advance simulation time by default, false otherwise.
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.default] The default ellipsoid.
* @param {ImageryLayer|false} [options.baseLayer=ImageryLayer.fromWorldImagery()] The bottommost imagery layer applied to the globe. If set to false, no imagery provider will be added.
* @param {TerrainProvider} [options.terrainProvider=new EllipsoidTerrainProvider(options.ellipsoid)] The terrain provider.
* @param {Terrain} [options.terrain] A terrain object which handles asynchronous terrain provider. Can only specify if options.terrainProvider is undefined.
* @param {SkyBox| false} [options.skyBox] The skybox used to render the stars. When undefined and the WGS84 ellipsoid used, the default stars are used. If set to false, no skyBox, Sun, or Moon will be added.
* @param {SkyAtmosphere | false} [options.skyAtmosphere] Blue sky, and the glow around the Earth's limb. Enabled when the default ellipsoid used. Set to false to turn it off.
* @param {SceneMode} [options.sceneMode=SceneMode.SCENE3D] The initial scene mode.
* @param {boolean} [options.scene3DOnly=false] When true, each geometry instance will only be rendered in 3D to save GPU memory.
* @param {boolean} [options.orderIndependentTranslucency=true] If true and the configuration supports it, use order independent translucency.
* @param {MapProjection} [options.mapProjection=new GeographicProjection(options.ellipsoid)] The map projection to use in 2D and Columbus View modes.
* @param {Globe | false} [options.globe=new Globe(options.ellipsoid)] The globe to use in the scene. If set to false, no globe will be added and the sky atmosphere will be hidden by default.
* @param {boolean} [options.useDefaultRenderLoop=true] True if this widget should control the render loop, false otherwise.
* @param {boolean} [options.useBrowserRecommendedResolution=true] If true, render at the browser's recommended resolution and ignore window.devicePixelRatio.
* @param {number} [options.targetFrameRate] The target frame rate when using the default render loop.
* @param {boolean} [options.showRenderLoopErrors=true] If true, this widget will automatically display an HTML panel to the user containing the error, if a render loop error occurs.
* @param {boolean} [options.automaticallyTrackDataSourceClocks=true] If true, this widget will automatically track the clock settings of newly added DataSources, updating if the DataSource's clock changes. Set this to false if you want to configure the clock independently.
* @param {ContextOptions} [options.contextOptions] Context and WebGL creation properties passed to {@link Scene}.
* @param {Element|string} [options.creditContainer] The DOM element or ID that will contain the {@link CreditDisplay}. If not specified, the credits are added
* to the bottom of the widget itself.
* @param {Element|string} [options.creditViewport] The DOM element or ID that will contain the credit pop up created by the {@link CreditDisplay}. If not specified, it will appear over the widget itself.
* @param {DataSourceCollection} [options.dataSources=new DataSourceCollection()] The collection of data sources visualized by the widget. If this parameter is provided,
* the instance is assumed to be owned by the caller and will not be destroyed when the widget is destroyed.
* @param {boolean} [options.shadows=false] Determines if shadows are cast by light sources.
* @param {ShadowMode} [options.terrainShadows=ShadowMode.RECEIVE_ONLY] Determines if the terrain casts or receives shadows from light sources.
* @param {MapMode2D} [options.mapMode2D=MapMode2D.INFINITE_SCROLL] Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
* @param {boolean} [options.blurActiveElementOnCanvasFocus=true] If true, the active element will blur when the widget's canvas is clicked. Setting this to false is useful for cases when the canvas is clicked only for retrieving position or an entity data without actually meaning to set the canvas to be the active element.
* @param {boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}.
* @param {number} [options.maximumRenderTimeChange=0.0] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested. See {@link https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/|Improving Performance with Explicit Rendering}.
* @param {number} [options.msaaSamples=4] If provided, this value controls the rate of multisample antialiasing. Typical multisampling rates are 2, 4, and sometimes 8 samples per pixel. Higher sampling rates of MSAA may impact performance in exchange for improved visual quality. This value only applies to WebGL2 contexts that support multisample render targets. Set to 1 to disable MSAA.
*
* @exception {DeveloperError} Element with id "container" does not exist in the document.
*
* @demo {@link https://sandcastle.cesium.com/index.html?src=Cesium%20Widget.html|Cesium Sandcastle Cesium Widget Demo}
*
* @example
* // For each example, include a link to CesiumWidget.css stylesheet in HTML head,
* // and in the body, include:
useDefaultRenderLoop
* is true. If undefined, the browser's requestAnimationFrame implementation
* determines the frame rate. If defined, this value must be greater than 0. A value higher
* than the underlying requestAnimationFrame implementation will have no effect.
* @memberof CesiumWidget.prototype
*
* @type {number}
*/
targetFrameRate: {
get: function () {
return this._targetFrameRate;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
if (value <= 0) {
throw new DeveloperError(
"targetFrameRate must be greater than 0, or undefined.",
);
}
//>>includeEnd('debug');
this._targetFrameRate = value;
},
},
/**
* Gets or sets whether or not this widget should control the render loop.
* If true the widget will use requestAnimationFrame to
* perform rendering and resizing of the widget, as well as drive the
* simulation clock. If set to false, you must manually call the
* resize, render methods as part of a custom
* render loop. If an error occurs during rendering, {@link Scene}'s
* renderError event will be raised and this property
* will be set to false. It must be set back to true to continue rendering
* after the error.
* @memberof CesiumWidget.prototype
*
* @type {boolean}
*/
useDefaultRenderLoop: {
get: function () {
return this._useDefaultRenderLoop;
},
set: function (value) {
if (this._useDefaultRenderLoop !== value) {
this._useDefaultRenderLoop = value;
if (value && !this._renderLoopRunning) {
startRenderLoop(this);
}
}
},
},
/**
* Gets or sets a scaling factor for rendering resolution. Values less than 1.0 can improve
* performance on less powerful devices while values greater than 1.0 will render at a higher
* resolution and then scale down, resulting in improved visual fidelity.
* For example, if the widget is laid out at a size of 640x480, setting this value to 0.5
* will cause the scene to be rendered at 320x240 and then scaled up while setting
* it to 2.0 will cause the scene to be rendered at 1280x960 and then scaled down.
* @memberof CesiumWidget.prototype
*
* @type {number}
* @default 1.0
*/
resolutionScale: {
get: function () {
return this._resolutionScale;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
if (value <= 0) {
throw new DeveloperError("resolutionScale must be greater than 0.");
}
//>>includeEnd('debug');
if (this._resolutionScale !== value) {
this._resolutionScale = value;
this._forceResize = true;
}
},
},
/**
* Boolean flag indicating if the browser's recommended resolution is used.
* If true, the browser's device pixel ratio is ignored and 1.0 is used instead,
* effectively rendering based on CSS pixels instead of device pixels. This can improve
* performance on less powerful devices that have high pixel density. When false, rendering
* will be in device pixels. {@link CesiumWidget#resolutionScale} will still take effect whether
* this flag is true or false.
* @memberof CesiumWidget.prototype
*
* @type {boolean}
* @default true
*/
useBrowserRecommendedResolution: {
get: function () {
return this._useBrowserRecommendedResolution;
},
set: function (value) {
if (this._useBrowserRecommendedResolution !== value) {
this._useBrowserRecommendedResolution = value;
this._forceResize = true;
}
},
},
/**
* Gets or sets whether or not data sources can temporarily pause
* animation in order to avoid showing an incomplete picture to the user.
* For example, if asynchronous primitives are being processed in the
* background, the clock will not advance until the geometry is ready.
*
* @memberof CesiumWidget.prototype
*
* @type {boolean}
*/
allowDataSourcesToSuspendAnimation: {
get: function () {
return this._allowDataSourcesToSuspendAnimation;
},
set: function (value) {
this._allowDataSourcesToSuspendAnimation = value;
},
},
/**
* Gets or sets the Entity instance currently being tracked by the camera.
* @memberof CesiumWidget.prototype
* @type {Entity | undefined}
*/
trackedEntity: {
get: function () {
return this._trackedEntity;
},
set: function (value) {
if (this._trackedEntity !== value) {
this._trackedEntity = value;
//Cancel any pending zoom
cancelZoom(this);
const scene = this.scene;
const sceneMode = scene.mode;
//Stop tracking
if (!defined(value) || !defined(value.position)) {
this._needTrackedEntityUpdate = false;
if (
sceneMode === SceneMode.COLUMBUS_VIEW ||
sceneMode === SceneMode.SCENE2D
) {
scene.screenSpaceCameraController.enableTranslate = true;
}
if (
sceneMode === SceneMode.COLUMBUS_VIEW ||
sceneMode === SceneMode.SCENE3D
) {
scene.screenSpaceCameraController.enableTilt = true;
}
this._entityView = undefined;
this.camera.lookAtTransform(Matrix4.IDENTITY);
} else {
//We can't start tracking immediately, so we set a flag and start tracking
//when the bounding sphere is ready (most likely next frame).
this._needTrackedEntityUpdate = true;
}
this._trackedEntityChanged.raiseEvent(value);
this.scene.requestRender();
}
},
},
/**
* Gets the event that is raised when the tracked entity changes.
* @memberof CesiumWidget.prototype
* @type {Event}
* @readonly
*/
trackedEntityChanged: {
get: function () {
return this._trackedEntityChanged;
},
},
/**
* Gets or sets the data source to track with the widget's clock.
* @memberof CesiumWidget.prototype
* @type {DataSource}
*/
clockTrackedDataSource: {
get: function () {
return this._clockTrackedDataSource;
},
set: function (value) {
if (this._clockTrackedDataSource !== value) {
this._clockTrackedDataSource = value;
trackDataSourceClock(this.clock, value);
}
},
},
});
/**
* Show an error panel to the user containing a title and a longer error message,
* which can be dismissed using an OK button. This panel is displayed automatically
* when a render loop error occurs, if showRenderLoopErrors was not false when the
* widget was constructed.
*
* @param {string} title The title to be displayed on the error panel. This string is interpreted as text.
* @param {string} [message] A helpful, user-facing message to display prior to the detailed error information. This string is interpreted as HTML.
* @param {string} [error] The error to be displayed on the error panel. This string is formatted using {@link formatError} and then displayed as text.
*/
CesiumWidget.prototype.showErrorPanel = function (title, message, error) {
const element = this._element;
const overlay = document.createElement("div");
overlay.className = "cesium-widget-errorPanel";
const content = document.createElement("div");
content.className = "cesium-widget-errorPanel-content";
overlay.appendChild(content);
const errorHeader = document.createElement("div");
errorHeader.className = "cesium-widget-errorPanel-header";
errorHeader.appendChild(document.createTextNode(title));
content.appendChild(errorHeader);
const errorPanelScroller = document.createElement("div");
errorPanelScroller.className = "cesium-widget-errorPanel-scroll";
content.appendChild(errorPanelScroller);
function resizeCallback() {
errorPanelScroller.style.maxHeight = `${Math.max(
Math.round(element.clientHeight * 0.9 - 100),
30,
)}px`;
}
resizeCallback();
if (defined(window.addEventListener)) {
window.addEventListener("resize", resizeCallback, false);
}
const hasMessage = defined(message);
const hasError = defined(error);
if (hasMessage || hasError) {
const errorMessage = document.createElement("div");
errorMessage.className = "cesium-widget-errorPanel-message";
errorPanelScroller.appendChild(errorMessage);
if (hasError) {
let errorDetails = formatError(error);
if (!hasMessage) {
if (typeof error === "string") {
error = new Error(error);
}
message = formatError({
name: error.name,
message: error.message,
});
errorDetails = error.stack;
}
//IE8 does not have a console object unless the dev tools are open.
if (typeof console !== "undefined") {
console.error(`${title}\n${message}\n${errorDetails}`);
}
const errorMessageDetails = document.createElement("div");
errorMessageDetails.className =
"cesium-widget-errorPanel-message-details collapsed";
const moreDetails = document.createElement("span");
moreDetails.className = "cesium-widget-errorPanel-more-details";
moreDetails.appendChild(document.createTextNode("See more..."));
errorMessageDetails.appendChild(moreDetails);
errorMessageDetails.onclick = function (e) {
errorMessageDetails.removeChild(moreDetails);
errorMessageDetails.appendChild(document.createTextNode(errorDetails));
errorMessageDetails.className =
"cesium-widget-errorPanel-message-details";
content.className = "cesium-widget-errorPanel-content expanded";
errorMessageDetails.onclick = undefined;
};
errorPanelScroller.appendChild(errorMessageDetails);
}
errorMessage.innerHTML = `${message}
`; } const buttonPanel = document.createElement("div"); buttonPanel.className = "cesium-widget-errorPanel-buttonPanel"; content.appendChild(buttonPanel); const okButton = document.createElement("button"); okButton.setAttribute("type", "button"); okButton.className = "cesium-button"; okButton.appendChild(document.createTextNode("OK")); okButton.onclick = function () { if (defined(resizeCallback) && defined(window.removeEventListener)) { window.removeEventListener("resize", resizeCallback, false); } element.removeChild(overlay); }; buttonPanel.appendChild(okButton); element.appendChild(overlay); }; /** * @returns {boolean} true if the object has been destroyed, false otherwise. */ CesiumWidget.prototype.isDestroyed = function () { return false; }; /** * Destroys the widget. Should be called if permanently * removing the widget from layout. */ CesiumWidget.prototype.destroy = function () { // Unsubscribe from data sources const dataSources = this.dataSources; const dataSourceLength = dataSources.length; for (let i = 0; i < dataSourceLength; i++) { this._dataSourceRemoved(dataSources, dataSources.get(i)); } this._dataSourceRemoved(undefined, this._dataSourceDisplay.defaultDataSource); this._dataSourceDisplay = this._dataSourceDisplay.destroy(); if (defined(this._scene)) { this._scene.renderError.removeEventListener(this._onRenderError); this._scene = this._scene.destroy(); } this._container.removeChild(this._element); this._creditContainer.removeChild(this._innerCreditContainer); this._eventHelper.removeAll(); if (this._destroyDataSourceCollection) { this._dataSourceCollection = this._dataSourceCollection.destroy(); } destroyObject(this); }; /** * Updates the canvas size, camera aspect ratio, and viewport size. * This function is called automatically as needed unless *useDefaultRenderLoop is set to false.
*/
CesiumWidget.prototype.resize = function () {
const canvas = this._canvas;
if (
!this._forceResize &&
this._canvasClientWidth === canvas.clientWidth &&
this._canvasClientHeight === canvas.clientHeight &&
this._lastDevicePixelRatio === window.devicePixelRatio
) {
return;
}
this._forceResize = false;
configureCanvasSize(this);
configureCameraFrustum(this);
this._scene.requestRender();
};
/**
* Renders the scene. This function is called automatically
* unless useDefaultRenderLoop is set to false;
*/
CesiumWidget.prototype.render = function () {
if (this._canRender) {
this._scene.initializeFrame();
const currentTime = this._clock.tick();
this._scene.render(currentTime);
} else {
this._clock.tick();
}
};
/**
* @private
*/
CesiumWidget.prototype._dataSourceAdded = function (
dataSourceCollection,
dataSource,
) {
const entityCollection = dataSource.entities;
entityCollection.collectionChanged.addEventListener(
CesiumWidget.prototype._onEntityCollectionChanged,
this,
);
};
/**
* @private
*/
CesiumWidget.prototype._dataSourceRemoved = function (
dataSourceCollection,
dataSource,
) {
const entityCollection = dataSource.entities;
entityCollection.collectionChanged.removeEventListener(
CesiumWidget.prototype._onEntityCollectionChanged,
this,
);
if (defined(this.trackedEntity)) {
if (
entityCollection.getById(this.trackedEntity.id) === this.trackedEntity
) {
this.trackedEntity = undefined;
}
}
};
/**
* @private
*/
CesiumWidget.prototype._updateCanAnimate = function (isUpdated) {
this._clock.canAnimate = isUpdated;
};
const boundingSphereScratch = new BoundingSphere();
/**
* @private
*/
CesiumWidget.prototype._onTick = function (clock) {
const time = clock.currentTime;
const isUpdated = this._dataSourceDisplay.update(time);
if (this._allowDataSourcesToSuspendAnimation) {
this._canAnimateUpdateCallback(isUpdated);
}
const entityView = this._entityView;
if (defined(entityView)) {
const trackedEntity = this._trackedEntity;
const trackedState = this._dataSourceDisplay.getBoundingSphere(
trackedEntity,
false,
entityView.boundingSphere ?? boundingSphereScratch,
);
if (trackedState === BoundingSphereState.DONE) {
entityView.update(time);
}
}
};
/**
* @private
*/
CesiumWidget.prototype._onEntityCollectionChanged = function (
collection,
added,
removed,
) {
const length = removed.length;
for (let i = 0; i < length; i++) {
const removedObject = removed[i];
if (this.trackedEntity === removedObject) {
this.trackedEntity = undefined;
}
}
};
/**
* @private
*/
CesiumWidget.prototype._clearTrackedObject = function () {
this.trackedEntity = undefined;
};
/**
* @private
*/
CesiumWidget.prototype._onDataSourceChanged = function (dataSource) {
if (this.clockTrackedDataSource === dataSource) {
trackDataSourceClock(this.clock, dataSource);
}
};
/**
* @private
*/
CesiumWidget.prototype._onDataSourceAdded = function (
dataSourceCollection,
dataSource,
) {
if (this._automaticallyTrackDataSourceClocks) {
this.clockTrackedDataSource = dataSource;
}
const id = dataSource.entities.id;
const removalFunc = this._eventHelper.add(
dataSource.changedEvent,
CesiumWidget.prototype._onDataSourceChanged,
this,
);
this._dataSourceChangedListeners[id] = removalFunc;
};
/**
* @private
*/
CesiumWidget.prototype._onDataSourceRemoved = function (
dataSourceCollection,
dataSource,
) {
const resetClock = this.clockTrackedDataSource === dataSource;
const id = dataSource.entities.id;
this._dataSourceChangedListeners[id]();
this._dataSourceChangedListeners[id] = undefined;
if (resetClock) {
const numDataSources = dataSourceCollection.length;
if (this._automaticallyTrackDataSourceClocks && numDataSources > 0) {
this.clockTrackedDataSource = dataSourceCollection.get(
numDataSources - 1,
);
} else {
this.clockTrackedDataSource = undefined;
}
}
};
/**
* Asynchronously sets the camera to view the provided entity, entities, or data source.
* If the data source is still in the process of loading or the visualization is otherwise still loading,
* this method waits for the data to be ready before performing the zoom.
*
* The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. * The heading and the pitch angles are defined in the local east-north-up reference frame. * The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch * angles are above the plane. Negative pitch angles are below the plane. The range is the distance from the center. If the range is * zero, a range will be computed such that the whole bounding sphere is visible.
* *In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the * target will be the range. The heading will be determined from the offset. If the heading cannot be * determined from the offset, the heading will be north.
* * @param {Entity|Entity[]|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud|PromiseThe offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. * The heading and the pitch angles are defined in the local east-north-up reference frame. * The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch * angles are above the plane. Negative pitch angles are below the plane. The range is the distance from the center. If the range is * zero, a range will be computed such that the whole bounding sphere is visible.
* *In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the * target will be the range. The heading will be determined from the offset. If the heading cannot be * determined from the offset, the heading will be north.
* * @param {Entity|Entity[]|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud|Promise