Skip to content

Commit

Permalink
Cleanup doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ggetz committed Feb 8, 2023
1 parent b6b0663 commit e6ca00d
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions packages/engine/Source/Scene/Terrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ async function handlePromise(instance, promise) {
* @example
* // Create
* const viewer = new Cesium.Viewer("cesiumContainer", {
* terrainProvider: new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
* terrain: new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
* });
*
* @example
* // Handle loading events
* const terrain = new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
*
* scene.setTerrain(terrain);
*
* terrain.readyEvent.addEventListener(provider => {
* scene.terrainProvider = provider;
* scene.globe.enableLighting = true;
*
* terrain.provider.errorEvent.addEventListener(error => {
Expand All @@ -57,18 +58,18 @@ async function handlePromise(instance, promise) {
* alert(`Encountered an error while creating terrain! ${error}`);
* });
*
* @param {Promise<TerrainProvider>} A promise which resolves to a terrain provider
* @param {Promise<TerrainProvider>} terrainProviderPromise A promise which resolves to a terrain provider
*/
function Terrain(providerPromise) {
function Terrain(terrainProviderPromise) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("providerPromise", providerPromise);
Check.typeOf.object("terrainProviderPromise", terrainProviderPromise);
//>>includeEnd('debug');

this._provider = undefined;
this._errorEvent = new Event();
this._readyEvent = new Event();

handlePromise(this, providerPromise);
handlePromise(this, terrainProviderPromise);
}

Object.defineProperties(Terrain.prototype, {
Expand All @@ -77,7 +78,7 @@ Object.defineProperties(Terrain.prototype, {
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
* are passed an instance of {@link TileProviderError}.
* @memberof TerrainProvider.prototype
* @type {Event<TerrainProvider.ErrorEvent>}
* @type {Event<Terrain.ErrorEvent>}
* @readonly
*/
errorEvent: {
Expand All @@ -90,7 +91,7 @@ Object.defineProperties(Terrain.prototype, {
* Gets an event that is raised when the terrain provider has been successfully created. Event listeners
* are passed the created instance of {@link TerrainProvider}.
* @memberof TerrainProvider.prototype
* @type {Event<TerrainProvider.ReadyEvent>}
* @type {Event<Terrain.ReadyEvent>}
* @readonly
*/
readyEvent: {
Expand Down Expand Up @@ -120,40 +121,41 @@ Object.defineProperties(Terrain.prototype, {
* @param {Object} [options] Object with the following properties:
* @param {Boolean} [options.requestVertexNormals=false] Flag that indicates if the client should request additional lighting information from the server if available.
* @param {Boolean} [options.requestWaterMask=false] Flag that indicates if the client should request per tile water masks from the server if available.
* @returns {<Terrain>} A promise that resolves to the created CesiumTerrainProvider
* @returns {Terrain} An asynchronous helper object for a CesiumTerrainProvider
*
* @see Ion
* @see createWorldTerrainAsync
*
* @example
* // Create Cesium World Terrain with default settings
* const viewer = new Cesium.Viewer("cesiumContainer", {
* terrainProvider: Cesium.Terrain.fromWorldTerrain()
* terrain: Cesium.Terrain.fromWorldTerrain()
* });
*
* @example
* // Create Cesium World Terrain with water and normals.
* const viewer1 = new Cesium.Viewer("cesiumContainer", {
* terrainProvider: Cesium.Terrain.fromWorldTerrain({
* terrain: Cesium.Terrain.fromWorldTerrain({
* requestWaterMask: true,
* requestVertexNormals: true
* });
* });
*
* @example
* // Handle loading events
* const providerManager = Cesium.Terrain.fromWorldTerrain();
* const terrain = Cesium.Terrain.fromWorldTerrain();
*
* scene.setTerrain(terrain);
*
* providerManager.readyEvent.addEventListener(provider => {
* viewer.terrainProvider = provider;
* viewer.scene.globe.enableLighting = true;
* terrain.readyEvent.addEventListener(provider => {
* scene.globe.enableLighting = true;
*
* providerManager.provider.errorEvent.addEventListener(error => {
* terrain.provider.errorEvent.addEventListener(error => {
* alert(`Encountered an error while loading terrain tiles! ${error}`);
* });
* });
*
* providerManager.errorEvent.addEventListener(error => {
* terrain.errorEvent.addEventListener(error => {
* alert(`Encountered an error while creating terrain! ${error}`);
* });
*/
Expand Down

0 comments on commit e6ca00d

Please sign in to comment.