Skip to content

Commit

Permalink
Expose buildModuleUrl as part of the Cesium API
Browse files Browse the repository at this point in the history
It's been used in Sandcastle examples forever, but has always been marked
as private in jsdoc. In order to make it available in TypeScript, we need
to expose it.

Also cleaned up the doc to be more inline with what the current version
actually does.

Fixes #8922
  • Loading branch information
mramato committed Jun 5, 2020
1 parent 1ae6836 commit 5554f25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- Improved `MaterialProperty` JSDoc and TypeScript type definitions, which were missing the ability to take primitive types in addition to Property instances in their constructor.
- Fixed `EllipsoidGeodesic` JSDoc and TypeScript type definitions which incorrectly listed `result` as required.
- Fixed a bug with handling of PixelFormat's flipY. [#8893](https://github.com/CesiumGS/cesium/pull/8893)

* Fixed JSDoc and TypeScript for `buildModuleUrl`, which was accidentally excluded from the official CesiumJS API.

- Fixed JSDoc and TypeScript type definitions for all `ImageryProvider` types, which were missing `defaultNightAlpha` and `defaultDayAlpha` properties.
- Fixed JSDoc and TypeScript type definitions for `Viewer` options parameter, which was incorrectly listed as required.
- Fixed a memory leak where some 3D Tiles requests were being unintentionally retained after the requests were cancelled. [#8843](https://github.com/CesiumGS/cesium/pull/8843)
Expand Down
19 changes: 13 additions & 6 deletions Source/Core/buildModuleUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,20 @@ function buildModuleUrlFromBaseUrl(moduleID) {
var implementation;

/**
* Given a non-relative moduleID, returns an absolute URL to the file represented by that module ID,
* using, in order of preference, require.toUrl, the value of a global CESIUM_BASE_URL, or
* the base URL of the Cesium.js script.
* Given a relative URL under the Cesium base URL, returns an absolute URL.
* @function
*
* @private
* @param {String} relativeUrl The relative path.
*
* @example
* var viewer = new Cesium.Viewer("cesiumContainer", {
* imageryProvider: new Cesium.TileMapServiceImageryProvider({
* url: Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII"),
* }),
* baseLayerPicker: false,
* });
*/
function buildModuleUrl(moduleID) {
function buildModuleUrl(relativeUrl) {
if (!defined(implementation)) {
//select implementation
if (
Expand All @@ -111,7 +118,7 @@ function buildModuleUrl(moduleID) {
}
}

var url = implementation(moduleID);
var url = implementation(relativeUrl);
return url;
}

Expand Down

0 comments on commit 5554f25

Please sign in to comment.