Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjspace committed Nov 25, 2024
1 parent cea182c commit 650408b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
19 changes: 6 additions & 13 deletions packages/engine/Source/Core/ITwinPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ITwinPlatform.ExportType = Object.freeze({

/**
* Types of Reality data
* https://developer.bentley.com/apis/reality-management/rm-rd-details/#types
* @see https://developer.bentley.com/apis/reality-management/rm-rd-details/#types
* @enum {string}
*/
ITwinPlatform.RealityDataType = Object.freeze({
Expand Down Expand Up @@ -88,13 +88,6 @@ ITwinPlatform.RealityDataType = Object.freeze({
Other: "Other",
});

ITwinPlatform.SupportedRealityDataTypes = [
ITwinPlatform.RealityDataType.Cesium3DTiles,
ITwinPlatform.RealityDataType.PNTS,
ITwinPlatform.RealityDataType.RealityMesh3DTiles,
ITwinPlatform.RealityDataType.Terrain3DTiles,
];

/**
* Gets or sets the default iTwin access token. This token should have the <code>itwin-platform</code> scope.
*
Expand Down Expand Up @@ -247,8 +240,8 @@ ITwinPlatform.getExports = async function (iModelId) {
*
* @private
*
* @param {string} iTwinId
* @param {string} realityDataId
* @param {string} iTwinId The id of the iTwin to load data from
* @param {string} realityDataId The id of the reality data to load
* @returns {Promise<RealityDataRepresentation>}
*/
ITwinPlatform.getRealityDataMetadata = async function (iTwinId, realityDataId) {
Expand Down Expand Up @@ -303,9 +296,9 @@ ITwinPlatform.getRealityDataMetadata = async function (iTwinId, realityDataId) {
*
* @private
*
* @param {string} iTwinId
* @param {string} realityDataId
* @param {string} rootDocument
* @param {string} iTwinId The id of the iTwin to load data from
* @param {string} realityDataId The id of the reality data to load
* @param {string} rootDocument The path of the root document for this reality data
* @returns {Promise<string>}
*/
ITwinPlatform.getRealityDataURL = async function (
Expand Down
34 changes: 28 additions & 6 deletions packages/engine/Source/Scene/ITwinData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import defined from "../Core/defined.js";
import Resource from "../Core/Resource.js";
import ITwinPlatform from "../Core/ITwinPlatform.js";
import RuntimeError from "../Core/RuntimeError.js";
import { Check } from "../Core/Check.js";

/**
* Methods for loading iTwin platform data into CesiumJS
Expand Down Expand Up @@ -73,12 +74,15 @@ ITwinData.createTilesetFromIModelId = async function (iModelId, options) {

/**
* Create a tileset for the specified reality data id. This function only works
* with 3D Tiles meshes and pointclouds
* with 3D Tiles meshes and point clouds.
*
* @param {string} iTwinId
* @param {string} realityDataId
* @param {ITwinPlatform.RealityDataType} type
* @param {string} rootDocument
* If the <code>type</code> or <code>rootDocument</code> are not provided this function
* will first request the full metadata for the specified reality data to fill these values.
*
* @param {string} iTwinId The id of the iTwin to load data from
* @param {string} realityDataId The id of the reality data to load
* @param {ITwinPlatform.RealityDataType} [type] The type of this reality data
* @param {string} [rootDocument] The path of the root document for this reality data
* @returns {Promise<Cesium3DTileset>}
*/
ITwinData.createTilesetForRealityDataId = async function (
Expand All @@ -87,6 +91,17 @@ ITwinData.createTilesetForRealityDataId = async function (
type,
rootDocument,
) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.string("iTwinId", iTwinId);
Check.typeOf.string("realityDataId", realityDataId);
if (defined(type)) {
Check.typeOf.string("type", type);
}
if (defined(rootDocument)) {
Check.typeOf.string("rootDocument", rootDocument);
}
//>>includeEnd('debug')

if (!defined(type) || !defined(rootDocument)) {
const metadata = await ITwinPlatform.getRealityDataMetadata(
iTwinId,
Expand All @@ -96,7 +111,14 @@ ITwinData.createTilesetForRealityDataId = async function (
type = metadata.type;
}

if (!ITwinPlatform.SupportedRealityDataTypes.includes(type)) {
const supportedRealityDataTypes = [
ITwinPlatform.RealityDataType.Cesium3DTiles,
ITwinPlatform.RealityDataType.PNTS,
ITwinPlatform.RealityDataType.RealityMesh3DTiles,
ITwinPlatform.RealityDataType.Terrain3DTiles,
];

if (!supportedRealityDataTypes.includes(type)) {
throw new RuntimeError(`Reality data type is not a mesh type: ${type}`);
}

Expand Down

0 comments on commit 650408b

Please sign in to comment.