### HTML and JavaScript: Example of tick and tick_next usage
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/tutorial-API_FrameTick
Provides a complete HTML and JavaScript example demonstrating the usage of `tick` and `tick_next` functions. This includes setting up the necessary HTML elements for displaying data and initializing the DigitalTwinAPI. The script showcases adding a tag, updating its text in each frame using `tick`, and retrieving tag information via `tick_next`.
```html
TICK
Test Debug Window
DeleteTag
PostEvent
Close
```
--------------------------------
### Registering and Initializing DigitalTwinAPI in Tick Page (JavaScript)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/tutorial-API_FrameTick
This snippet demonstrates how to initialize the DigitalTwinAPI within the tick page's `window.onload` event. It shows both synchronous and asynchronous initialization patterns, including awaiting API calls after initialization. The asynchronous example highlights the use of `await` for operations like deleting and adding tags.
```javascript
var fdapi;
window.onload = function () {
fdapi = new DigitalTwinAPI();
}
```
```javascript
window.onload = async function () {
fdapi = new DigitalTwinAPI();
await fdapi.tag.delete(id);
await fdapi.tag.add(data);
}
```
--------------------------------
### Example: CustomObject Path Movement Data
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/CustomObject
Provides an example structure for the `pathPointArr` parameter used in the `startMove` method, illustrating the format for time, coordinates, and optional rotation at each point.
```json
[
{"time":0,"coordinate":[ -15726.0537109375, 7340.0205078125, 0 ],"rotation": [0,90,0]},
{"time":0.5,"coordinate":[ -15700.7431640625, 7308.4287109375, 0 ],"rotation": [0,90,0]},
{"time":1,"coordinate":[ -15682.779296875, 7345.14697265625, 0 ],"rotation": [0,90,0]},
{"time":1.5,"coordinate":[ -15662.0478515625, 7312.79931640625, 0 ],"rotation": [0,90,0]}
]
```
--------------------------------
### Start HydrodynamicModel2 Playback (JavaScript)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/HydrodynamicModel2
The `startPlay` function initiates playback of HydrodynamicModel2 objects from a specified time. It requires a control object or array with the ID, display mode, and start time. An optional callback function is also supported.
```javascript
startPlay(data, fn)
```
--------------------------------
### startVolumeClip
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Tools
Starts a volume clip operation with specified parameters.
```APIDOC
## POST /startVolumeClip
### Description
Starts a volume clip operation. This function allows for defining a clipping box and its properties, including visibility and editability.
### Method
POST
### Endpoint
/startVolumeClip
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **bbox** (array) - Required - The bounding box for the clip operation.
- **direction** (number) - Required - 0 for forward clip, 1 for reverse clip.
- **isShowBBox** (boolean) - Optional - Whether to show the bounding box during clipping. Defaults to false.
- **isEditable** (boolean) - Optional - Whether the clipping box is editable. Defaults to false.
- **rotation** (array) - Optional - Euler angles [Pitch, Yaw, Roll] for rotating the bounding box.
- **fn** (function) - Optional - Callback function for asynchronous operations.
### Request Example
```json
{
"bbox": [[-10, -10, -10], [10, 10, 10]],
"direction": 0,
"isShowBBox": true,
"isEditable": true,
"rotation": [0, 0, 0],
"fn": "function() { console.log('Volume clip started'); }"
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "success"
}
```
```
--------------------------------
### Tick Page DigitalTwinAPI Initialization
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/tutorial-API_FrameTick
Details on how to initialize the DigitalTwinAPI within the tick page, including synchronous and asynchronous examples.
```APIDOC
## Tick Page Initialization
### Description
Initializing the `DigitalTwinAPI` within the tick page differs slightly from standard initialization. It does not require any parameters.
### Method
JavaScript (within tick page)
### Endpoint
N/A (Client-side script)
### Usage
#### Synchronous Initialization
```javascript
var fdapi;
window.onload = function() {
fdapi = new DigitalTwinAPI();
}
```
#### Asynchronous Initialization Example
```javascript
window.onload = async function() {
fdapi = new DigitalTwinAPI();
await fdapi.tag.delete(id);
await fdapi.tag.add(data);
}
```
### Parameters
None for `DigitalTwinAPI()` constructor within the tick page.
### Request Example
(See Usage section above)
### Response
N/A (Initialization is client-side)
### Notes
- Initialization typically occurs within the `window.onload` event.
- Asynchronous operations can be chained after initialization using `await`.
```
--------------------------------
### Async/Await API Calls with DTSCloudAPI (JavaScript)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/tutorial-API_AsyncCall
Demonstrates how to use async/await syntax for making asynchronous API calls to DTSCloudAPI. This method enhances code readability by allowing sequential execution of asynchronous operations. It includes examples of deleting a tag, getting camera information, adding a tag with specific coordinates and image, and focusing on the tag.
```javascript
await fdapi.tag.delete('tag1')
let cam = await fdapi.camera.get();
let o = new TagData('tag1');
o.coordinate = [cam.x, cam.y, 25.4];
o.imagePath = HostConfig.Path + '/samples/images/tag.png';
o.imageSize = [28, 28];
o.text = '北京银行';
o.showLine = true;
await fdapi.tag.add(o);
await fdapi.tag.focus(o.id, 500, 0.2);
log("Test Finished.");
```
--------------------------------
### Example of Batch Update for Finite Elements
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/FiniteElement
Demonstrates the usage of 'updateBegin' and 'updateEnd' for performing multiple property updates efficiently. In this example, the color of 1000 finite elements is changed to yellow, followed by a log message upon completion.
```javascript
fdapi.xxx.updateBegin();
for (let i = 0; i < 1000; i++) {
fdapi.xxx.setColor(i, Color.Yellow);
}
fdapi.xxx.updateEnd(function () {
log('update finished!');
});
```
--------------------------------
### Example Data Structure for HydrodynamicModel2
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/HydrodynamicModel2
This example demonstrates the expected data structure for creating a HydrodynamicModel2 object. It includes essential properties such as `id`, `jsonFilePath`, `coordinate`, `rotation`, `displayMode`, `valueRange`, `time`, `playTimes`, and a detailed `colors` object for custom color mapping.
```json
[
{
"id": "h1",
"jsonFilePath": "F:/UnrealProjects/water/out/writeFile.json",
"coordinate": [
12984831,
4800354.5,
0
],
"rotation": [
0,
0,
0
],
"displayMode": 0,
"valueRange": [
0,
3
],
"time": 1,
"playTimes": 1,
"colors":{
"gradient":true,
"invalidColor": [0,0,0,1],
"colorStops":[
{
"value":0,
"color":[0,0,1,1]
},
{
"value":0.25,
"color":[0,1,1,1]
},
{
"value":0.5,
"color":[0,1,0,1]
},
{
"value":0.75,
"color":[1,1,0,1]
},
{
"value":1,
"color":[1,0,0,1]
}
]
}
}
]
```
--------------------------------
### Polygon Coordinate Examples (JavaScript)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Polygon
Demonstrates different ways to define polygon coordinates, including simple polygons, polygons with holes, and multi-part polygons. These examples are crucial for understanding the input structure required by the Polygon class methods.
```javascript
let coords1 = [[872.16, -9485.86, 5.8], [864.77, -9196.58, 5.7], [624.34, -9209.29, 6.05], [482.58, -9373.57, 7.38]];
```
```javascript
let coords2 = [
[[9665.22, -11366.88, 5.7], [9765.4, -4511.22, 5.7], [4155.2, -4036.94, 5.7], [3098, -11010.32, 5.7], [6445.79, -12717.28, 6.78]],
[[8706.9, -9457.89, 5.7], [8824.84, -8055.4, 6.64], [7619.37, -8859.47, 6.72]],
[[5744.8, -7795.59, 5.7], [6205.21, -5724.74, 5.7], [4460.01, -5839.38, 6.05], [3966.28, -7712.46, 7.17]]
];
```
```javascript
let coords3 = [
//part1
[
[[9665.22, -11366.88, 5.7], [9765.4, -4511.22, 5.7], [4155.2, -4036.94, 5.7], [3098, -11010.32, 5.7], [6445.79, -12717.28, 6.78]],
[[8706.9, -9457.89, 5.7], [8824.84, -8055.4, 6.64], [7619.37, -8859.47, 6.72]],
[[5744.8, -7795.59, 5.7], [6205.21, -5724.74, 5.7], [4460.01, -5839.38, 6.05], [3966.28, -7712.46, 7.17]]
],
//part2
[
[[-4477.25, -4353.11, 5.7], [-1803.2, -6744.65, 5.7], [-562.18, -4590.14, 5.7], [-2271.85, -2595.33, 5.7]],
[[-2867.3, -4342.53, 5.7], [-2381.34, -5043.33, 5.7], [-1723.21, -4566.1, 6.25], [-1938.83, -3757.59, 5.7]]
]
];
```
--------------------------------
### Marker Detailed Information Example
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Marker
An example JSON object representing the detailed information of a marker, including its ID, coordinates, associated image paths, text content, and styling properties.
```json
{
"id": "m1",
"groupId": "",
"userData": "",
"coordinateType": 0,
"coordinate": [495269.375000, 2491073.250000, 25.400000],
"anchors": [-16.000000, 32.000000],
"range": [10.000000, 10000.000000],
"textRange": [100.000000, 6000.000000],
"imageSize": [28.000000, 28.000000],
"imagePath": "C:\\Users\\Administrator\\AppData\\Roaming\\Cloud\\SDK/images/tag.png",
"hoverImagePath": "C:\\Users\\Administrator\\AppData\\Roaming\\Cloud\\SDK/images/hilightarea.png",
"hoverImageSize": [28.000000, 28.000000],
"text": "北京银行",
"textOffset": [0.000000, 0.000000],
"fontSize": 12,
"fontOutlineSize": 1,
"textBackgroundColor": [1.000000, 1.000000, 1.000000, 1.000000],
"fontColor": [1.000000, 0.000000, 0.000000, 1.000000],
"fontOutlineColor": [1.000000, 0.000000, 0.000000, 1.000000],
"popupUrl": "C:\\Users\\Administrator\\AppData\\Roaming\\Cloud\\SDK/popup_simple.html",
"popupSize": [600.000000, 400.000000],
"popupOffset": [0.000000, 0.000000],
"popupBackgroundColor": [1.000000, 1.000000, 1.000000, 0.100000],
"lineSize": [2.000000, 100.000000],
"lineColor": [0.200000, 0.700000, 0.400000, 1.000000],
"lineOffset": [0.000000, 0.000000],
"autoHidePopupWindow": 1,
"autoHeight": 0,
"displayMode": 0,
"priority": 0,
"occlusioncull": 0
}
```
--------------------------------
### HydroDynamic2D API
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/HydroDynamic2D
This section covers the parameters and examples for creating and configuring 2D HydroDynamic models.
```APIDOC
## POST /websites/nangongwentian-fe_github_io_dtscloudapi6_1/HydroDynamic2D
### Description
Adds or updates 2D HydroDynamic model data. Supports constructing HydroDynamic2D objects with various properties for simulation and visualization.
### Method
POST
### Endpoint
/websites/nangongwentian-fe_github_io_dtscloudapi6_1/HydroDynamic2D
### Parameters
#### Request Body
- **data** (object | array) - Required - An array of HydroDynamic2D objects or a single object. Each object can have the following properties:
- **id** (string) - Required - The unique identifier for the HydroDynamic2D object.
- **groupId** (string) - Optional - Group identifier for organization.
- **userData** (string) - Optional - User-defined custom data.
- **bbox** (array) - Optional - Bounding box of the model in the format [minX, minY, minZ, maxX, maxY, maxZ]. Elements are floating-point numbers.
- **offset** (array) - Optional - Global offset for the model, defaults to [0, 0, 0].
- **dataSize** (array) - Optional - Resolution of the model data, e.g., [X, Y].
- **updateTime** (number) - Optional - Interpolation time for animation updates. Only effective during `update()` calls.
- **waterDepth** (string) - Required - Path to the TIF file for water depth data. Must have consistent resolution with `flowField` and `dem`.
- **flowField** (string) - Optional - Path to the TIF file for flow field data (velocity and direction). Must have consistent resolution with `waterDepth` and `dem`.
- **dem** (string) - Optional - Path to the TIF file for the riverbed DEM data. Must have consistent resolution with `waterDepth` and `flowField`.
- **collision** (boolean) - Optional - Enables model collision detection. Defaults to `false`. Enabling may affect loading efficiency.
- **displayMode** (`HydroDynamic2DStyle`) - Optional - Display style for the model. Values: 0 (realistic water, default), 1 (heatmap), 2 (flow field).
- **waterMode** (`WaterMode`) - Optional - Surface material type for realistic water style. Values: 0 (default), 1, 2. Can be overlaid with heatmap style.
- **waterColor** (Color) - Optional - Water surface color and transparency. Only effective when `displayMode` is 0. Supports four formats. If not provided, uses the default material color from `waterMode`.
- **waveBrightness** (number) - Optional - Brightness of wave rendering. Range: [0~1000]. Higher values increase brightness. Defaults to 1.
- **depthRange** (array) - Optional - Numerical range for water depth. If not provided, the system automatically calculates it from the TIF data.
- **alphaGradientDepthRange** (array) - Optional - Depth range for edge feathering. Defaults to [0, 2] meters. Alpha range is [0, 1]. Only effective when `alphaMode` is 1.
- **alphaMode** (number) - Optional - Transparency mode. Values: 0 (uses opacity from `colors` palette), 1 (uses depth from TIF data for transparency, default).
- **arrowColor** (Color) - Optional - Color and transparency for arrows. Supports four formats.
- **arrowTiling** (number) - Optional - Tiling factor for arrows.
- **arrowDisplayMode** (number) - Optional - Display mode for arrows. Values: 0 (default, influenced by `arrowColor`), 1 (heatmap, influenced by `arrowColors`). Defaults to 0.
- **arrowAlphaMode** (number) - Optional - Transparency mode for arrows. Only effective when `arrowDisplayMode` is 0. Values: 0 (uses `arrowColor` transparency), 1 (uses palette transparency). Defaults to 0.
- **arrowColors** (object) - Optional - Color palette for arrows when `arrowDisplayMode` is 1. Includes gradient control, default color for invalid pixels, and color stops.
- **gradient** (boolean) - Whether to use gradient colors.
- **invalidColor** (Color) - Default color for invalid pixels (e.g., white).
- **colorStops** (array) - Array of color stop objects, each with a `value` (number) and `color` (Color).
- **rippleDensity** (number) - Optional - Intensity of ripple effects. Defaults to 1.
- **rippleTiling** (number) - Optional - Tiling factor for ripple effects. Defaults to 1.
- **speedRange** (array) - Optional - Range for flow speed. Defaults to [0.1, 3].
- **speedFactor** (number) - Optional - Factor controlling the speed of ripples or particles. Defaults to 1.
- **flowThreshold** (array) - Optional - Depth range for ripple generation. Ripples are not generated outside this range. Defaults to [0.1, 0.4].
- **crestWaterSpeedRange** (array) - Optional - Flow speed range for ripple crest generation. Defaults to [0.2, 0.6]. Higher speeds within this range result in more pronounced crests.
- **colors** (object) - Optional - Custom color palette for the model. Includes gradient control, default color for invalid pixels, and color stops.
- **gradient** (boolean) - Whether to use gradient colors.
- **invalidColor** (Color) - Default color for invalid pixels.
- **colorStops** (array) - Array of color stop objects, each with a `value` (number) and `color` (Color). Opacity is effective when `alphaMode` is 0.
- **fn** (function) - Optional - Callback function for asynchronous operations.
### Request Example
```json
[
{
"id": "hdm",
"displayMode": 0,
"waterMode": 0,
"alphaMode": 1,
"depthRange": [0, 3],
"waterDepth": "d:\\waterDepth.tif",
"flowField": "d:\\flowField.tif",
"dem": "d:\\dem.tif",
"colors": {
"gradient": true,
"invalidColor": [0, 0, 0, 1],
"colorStops": [
{
"value": 0,
"color": [0, 0, 1, 1]
},
{
"value": 0.25,
"color": [0, 1, 1, 1]
},
{
"value": 0.5,
"color": [0, 1, 0, 1]
},
{
"value": 0.75,
"color": [1, 1, 0, 1]
},
{
"value": 1,
"color": [1, 0, 0, 1]
}
]
}
}
]
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "success"
}
```
```
--------------------------------
### Vehicle start
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Vehicle
Initiates the movement of specified vehicles at a given time.
```APIDOC
## POST /vehicles/start
### Description
Initiates the movement of specified vehicles at a given time.
### Method
POST
### Endpoint
`/vehicles/start`
### Parameters
#### Query Parameters
- **fn** (function) - Optional - Callback function for asynchronous operations.
#### Request Body
- **data** (object or array) - Required - Data structure for starting movement. Supports objects or arrays. Each object should have:
- **id** (string) - Vehicle object's ID.
- **timeStamp** (number) - The time at which the Vehicle object starts moving.
### Request Example
```json
[
{"id":"vc1","timeStamp":1},
{"id":"vc2","timeStamp":5},
{"id":"vc3","timeStamp":7}
]
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the operation.
#### Response Example
```json
{
"status": "success"
}
```
```
--------------------------------
### Batch Update Start
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/DynamicWater
Begins a batch update operation for modifying object properties multiple times. Call `updateEnd` after all modifications.
```APIDOC
## POST /api/dynamicWater/updateBegin
### Description
用于批量多次修改对象的属性。在开始修改之前调用updateBegin,然后可以多次调用setXXX方法,最后调用updateEnd提交修改更新数据。
### Method
POST
### Endpoint
/api/dynamicWater/updateBegin
### Parameters
None
### Example
```javascript
fdapi.xxx.updateBegin();
for (let i = 0; i < 1000; i++) {
fdapi.xxx.setColor(i, Color.Yellow);
}
fdapi.xxx.updateEnd(function() {
log('update finished!');
});
```
### Response
#### Success Response (200)
- **message** (string) - Indicates the start of the batch update.
```
--------------------------------
### updateBegin() and updateEnd(fn)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/ImageryLayer
Methods for batch modification of object properties. `updateBegin()` starts a batch modification session, and `updateEnd(fn)` commits the changes.
```APIDOC
## Batch Updates for ImageryLayer
### Description
These methods are used for performing batch modifications on object properties. Call `updateBegin()` before making multiple `setXXX` calls, and then call `updateEnd(fn)` to commit the changes.
### Methods
#### `updateBegin()`
* **Description**: Starts a batch modification session. This method is not asynchronous and does not require `await` or a callback function.
* **Inherited From**: `BaseObject#updateBegin`
* **Overrides**: `BaseObject#updateBegin`
*Example*
```javascript
fdapi.xxx.updateBegin();
for (let i = 0; i < 1000; i++) {
fdapi.xxx.setColor(i, Color.Yellow);
}
fdapi.xxx.updateEnd(function() {
log('update finished!');
});
```
#### `updateEnd(fn)`
* **Description**: Commits batch modifications started with `updateBegin()`. This method is asynchronous and can be used with a callback function or `await`.
* **Parameters**:
- **fn** (function) - Optional - Callback function to be executed after the update is complete.
```
--------------------------------
### Instance and Option Management
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/DigitalTwinPlayer
Methods for setting instance options and video stream resolution.
```APIDOC
## Instance and Option Management
### setInstanceOptions
#### Description
Sets instance options. This interface allows switching instances or project files without refreshing the page.
#### Parameters
* `o` (object) - Instance options. Supports the following properties:
* `iid` (string, Optional) - Instance ID. If you don't need to switch instances, you can omit this property.
* `pid` (string, Optional) - Project ID. If you don't need to switch projects, you can omit this property.
#### Returns
* Returns `false` if the set parameters are the same as the current instance's parameters, otherwise returns `true`.
### setResolution
#### Description
Sets the resolution of the video stream. If adaptive streaming is enabled in the cloud rendering backend, the video stream resolution will also adjust automatically. If adaptive streaming is not enabled, this call will have no effect.
**Note:**
* The maximum resolution supported for video streams is 4096*4096. If the set width or height exceeds this size, it will be automatically scaled proportionally to a suitable size.
* Because mobile devices often have high-resolution screens (multiple times the CSS resolution), the actual set width and height will be multiplied by the device pixel ratio.
#### Parameters
* `w` (number) - The width.
* `h` (number) - The height.
#### Returns
* Returns `undefined` if adaptive streaming is not enabled in the cloud rendering backend, or if the set resolution is the same as the current resolution. Otherwise, returns an array of the actual set resolution, e.g., `[3846, 2160]`.
```
--------------------------------
### Get TileLayer Object IDs Example
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/TileLayer
This example demonstrates how to retrieve all ObjectID information for a TileLayer. It returns an array of objects, where each object contains a 'id' and an 'objectIds' array.
```json
[
{
"id": "1",
"objectIds": [
"WorldSettings",
"Brush_0",
"SM_colum_02_2",
"SM_colum_3",
"SM_floor_130",
"SM_floor_195",
"SM_floor_313",
"SM_floor_352",
"SM_colum_24",
"SM_colum_25",
"SM_floor_399",
"SM_Road_04_5",
"SM_Road_05_8",
"SM_Road_5",
"SM_Road_6",
"SM_floor_400",
"SM_floor_401",
"SM_floor_402",
"SM_floor_403",
"SM_entrance_roof_01_11",
"P_raunfall2",
"P_raunfall4",
"SM_pot_4",
"SM_pot_9",
"PointLight13",
"PointLight14",
"SM_wall_30",
"SM_main_door_02_2",
"SM_main_door_3",
"SM_wall_51",
"SM_outdoor_wall_01_2",
"SM_column_04_2",
"SM_column_24",
"SM_column_29",
"SM_column_35",
"SM_ATM_4",
"SM_wall_140",
"SM_wall_141",
"SM_wall_142",
"SM_floor_01_28",
"SM_floor_2",
"SM_floor_3",
"SM_floor_4",
"SM_floor_5",
"SM_floor_6",
"SM_floor_7",
"SM_floor_8",
"SM_floor_9",
"SM_floor_10",
"SM_floor_11",
"SM_floor_12",
"SM_floor_03_414",
"SM_floor_05_15",
"SM_floor_06_57",
"SM_sofa_3",
"SM_sofa_4",
"Palm_01_30",
"Palm_02_33",
"Palm_04_36",
"Palm_03_39",
"SM_pot_5",
"SM_pot_6",
"SM_pot_7",
"SM_pot_8",
"SM_reception_01_2",
"PointLight22",
"PointLight23",
"PointLight24",
"PointLight27",
"SM_column_03_17",
"SM_column_4",
"SM_column_5",
"SM_wall_55",
"SM_wall_56",
"SM_wall_57",
"PointLight38",
"PointLight69",
"SM_elevator_glass_fence_31",
"SM_colum_13",
"SM_colum_20",
"SM_glass_window_01_4",
"SM_glass_window_2",
"SM_glass_window_3",
"SM_glass_window_4",
"SM_glass_window_5",
"SM_elevator_wall_03_15",
"SM_table_3",
"SM_table_4",
"SM_bed_6",
"SM_bed_7",
"SM_ATM_01_2",
"DecalActor75_2",
"DecalActor77",
"SM_wall_352",
"SM_ATM_6",
"EmergencyRoom_C_3"
]
}
]
```
--------------------------------
### init(option, fn)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/ImageryLayer
Initializes relevant parameters before adding layer services.
```APIDOC
## POST /imageryLayer/init
### Description
Initializes relevant parameters required before adding layer services.
### Method
POST
### Endpoint
`/imageryLayer/init`
### Parameters
#### Request Body
- **option** (object) - Required - Initialization object containing layer environment configuration and extent information:
- **xmlUrl** (string) - Required - The URL path for the XML protocol.
- **layerName** (string) - Required - The name of the layer.
- **tileMatrixName** (string) - Required - For WMTS, the tile matrix set name. For WMS, the coordinate type.
- **ogcEPSG** (string) - Required - The coordinate reference system type.
- **cachePath** (string) - Required - The path for caching.
- **mapMode** (boolean) - Required - `true` for a large map, `false` for a small map. Defaults to `false`.
- **renderMode** (number) - Required - Rendering mode. Values: 0 (Normal, default), 1 (Transparent), 2 (Annotation), 3 (Ground).
- **fn** (function) - Optional - Callback function for asynchronous operations.
```
--------------------------------
### Get Polygon Details (JavaScript)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Polygon
Retrieves the detailed information of a specific Polygon object by its ID. The example shows the expected JSON response structure for a Polygon's properties.
```javascript
let res = await api.polygon.get("polygon1", fn);
// Polygon details:
// {
// "id": "polygon1",
// "groupId": "",
// "userData": "",
// "depthTest": 0,
// "color": [0.000000, 0.000000, 1.000000, 1.000000],
// "style": 0,
// "brightness": 1.000000
// }
```
--------------------------------
### Get Layer Tree Information
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/InfoTree
Retrieves the current layer tree information. An optional callback function can be provided for asynchronous operations. The example shows the expected data structure for the layer tree.
```javascript
api.infoTree.get(fn);
```
--------------------------------
### Show All Foliages
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Misc
Displays all plants created in Explorer.
```APIDOC
## POST /showAllFoliages
### Description
Displays all plants created in Explorer.
### Method
POST
### Endpoint
/showAllFoliages
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **fn** (function) - Optional - A callback function to be executed after the operation. Refer to the secondary development documentation for asynchronous interface invocation.
### Request Example
```json
{
"fn": "callbackFunction"
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the success or failure of the operation.
#### Response Example
```json
{
"status": "success"
}
```
```
--------------------------------
### Get Panorama Details
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Panorama
Retrieves detailed information for one or more Panorama objects based on their IDs. Accepts a single ID or an array of IDs. An optional callback function can be provided for asynchronous operations. The example shows the structure of the returned panorama information.
```javascript
api.panorama.get(ids, fn);
```
```json
[
{
"id": "p1",
"groupId": "",
"userData": "",
"imagePath": "C:\\Users\\Administrator\\AppData\\Roaming\\Cloud\\SDK/assets/panorama1.jpg",
"coordinates": [495302.625000, 2491061.500000, 30.152344],
"yaw": 75.000000
}
]
```
--------------------------------
### DigitalTwinPlayer Constructor
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/DigitalTwinPlayer
Initializes a new DigitalTwinPlayer instance to create and display a 3D video stream on a webpage, allowing for interactive controls.
```APIDOC
## POST /websites/nangongwentian-fe_github_io_dtscloudapi6_1
### Description
Initializes a new DigitalTwinPlayer instance to create and display a 3D video stream on a webpage, allowing for interactive controls like keyboard, mouse, and touch input.
### Method
POST
### Endpoint
/websites/nangongwentian-fe_github_io_dtscloudapi6_1
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **host** (string) - Required - The service address in the format IP:Port (e.g., '192.168.1.29:8082').
- **option** (object) - Optional - Initialization options:
- **domId** (string) - Optional - The HTML element ID to use as the parent for the video tag. If not set, no video stream is transmitted, only API calls are made.
- **iid** (string) - Optional/Required - The ID of the cloud rendering instance. Required for API calls without video streams; optional for video streams (auto-assigned if not specified).
- **pid** (number) - Optional - The project ID to load in the instance. Be cautious if the instance is locked to a different project.
- **reset** (boolean) - Optional - If true, a new instance is created on each connection or refresh. Note: Setting to true will restart the instance on page refresh.
- **customString** (string) - Optional - User-defined information storage.
- **ui** (object) - Optional - Settings for UI component visibility:
- **startupInfo** (boolean) - Optional (default: true) - Whether to display detailed information during initialization.
- **statusIndicator** (boolean) - Optional (default: true) - Visibility of the status indicator light.
- **statusButton** (boolean) - Optional (default: false) - Visibility of the status information button.
- **fullscreenButton** (boolean) - Optional (default: false) - Visibility of the fullscreen button.
- **homeButton** (boolean) - Optional (default: false) - Visibility of the home button.
- **taskListBar** (number) - Optional (default: 1) - Visibility of the task queue (0: never, 1: during long operations, 2: always).
- **debugEventsPanel** (boolean) - Optional (default: false) - Visibility of touch event details (for debugging).
- **mainUI** (boolean) - Optional - Visibility of the Cloud toolbar.
- **campass** (boolean) - Optional - Visibility of the compass.
- **apiOptions** (object) - Optional - Initialization options for DigitalTwinAPI. Refer to `DigitalTwinAPI` documentation.
- **events** (object) - Optional - Callback functions for various events:
- **onConnClose** (function) - Callback for connection closure.
- **onVideoLoaded** (function) - Callback when the video stream is loaded.
- **onRtcStatsReport** (function) - Callback for receiving video stream statistics.
- **mouseKeyListener** (object) - Object containing callbacks for mouse and keyboard events (e.g., `onMouseEnter`, `onMouseDown`, `onKeyDown`).
- **touchListener** (function) - Callback for touch events.
- **onLoginRequired** (function) - Callback when login is required (if user system is enabled).
- **keyEventTarget** (string) - Optional (default: 'video') - Sets the target for keyboard events ('document', 'video', 'none').
- **password** (string) - Optional - Password for instance access if the service is password-protected.
- **urlExtraInfo** (object) - Optional - Additional information for the WebSocket connection URL.
- **useBuiltinCursors** (boolean) - Optional (default: true) - Whether to use built-in cursors.
- **useHttps** (boolean) - Optional (default: false) - Force HTTPS for WebSocket connection.
- **registerEvents** (boolean) - Optional (default: true) - Whether to register interaction events during initialization.
- **receiveRenderEvents** (boolean) - Optional (default: true) - Whether to receive events from the 3D rendering process. Set to false if multiple DigitalTwinPlayer instances access the same instance.
- **enableApiCallLog** (boolean) - Optional (default: false) - Enable client-side logging for API calls.
- **disableResizeObserver** (boolean) - Optional (default: false) - Disable the ResizeObserver to prevent continuous resizing issues.
- **enableEventSync** (boolean) - Optional (default: false) - Enable synchronization of interaction events across multiple DigitalTwinPlayer instances on the same page.
### Request Example
```json
{
"host": "192.168.1.29:8082",
"option": {
"domId": "video-container",
"iid": "instance-123",
"pid": 456,
"ui": {
"fullscreenButton": true,
"homeButton": true
},
"events": {
"onVideoLoaded": "() => console.log('Video loaded')",
"mouseKeyListener": {
"onMouseDown": "(event) => console.log('Mouse down', event)"
}
}
}
}
```
### Response
#### Success Response (200)
- **instance** (DigitalTwinPlayer) - The created DigitalTwinPlayer instance.
#### Response Example
```json
{
"message": "DigitalTwinPlayer initialized successfully",
"instance_id": "some_unique_id"
}
```
```
--------------------------------
### Initialize DigitalTwinAPI
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/DigitalTwinAPI
Constructs a DigitalTwinAPI object for API interface initialization. If the page displays cloud-rendered video streams, DigitalTwinPlayer should be used instead, which automatically creates and provides access to the DigitalTwinAPI instance via `getAPI()`. This constructor is for manual initialization when not using DigitalTwinPlayer.
```javascript
const api = new DigitalTwinAPI(host, options);
// Example options:
// const options = {
// onReady: () => {
// console.log('API is ready!');
// },
// onLog: (log) => {
// console.log('Log:', log);
// },
// onEvent: (event) => {
// console.log('Event:', event);
// },
// onApiVersion: (version) => {
// console.log('API Version:', version);
// }
// };
```
--------------------------------
### Add 3D Polygon Styling and Installer Changes
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/tutorial-API_Revision
3D Polygons now support custom styling. The installer has been modified to change the default installation location from 'Program Files' to 'AppData' to address write permission issues.
```javascript
// Example of adding a styled 3D Polygon (styling details depend on API)
let polygon3d = new Polygon3DData(...);
// ... set styling properties ...
fdapi.polygon3D.add(polygon3d);
```
--------------------------------
### React Integration with DigitalTwinAPI
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/tutorial-HelloWorld
This React.js example shows how to integrate the DigitalTwinAPI into a React component. It initializes the API in `componentDidMount` and cleans up resources in `componentWillUnmount`. The `ac.min.js` file should be imported, and the API referenced using the `acapi` prefix.
```javascript
//引入API
import * as acapi from '../ac.min'
class Content extends React.Component {
constructor(props) {
this.api = null;
}
componentDidMount() {
//初始化API实例并启动渲染,DigitalTwinPlayer对象的构造参数请参考API开发文档
this.api = new acapi.DigitalTwinPlayer("192.168.1.27:8081", { "domId": "player",'apiOptions': {...} }).getAPI();
}
componentWillUnmount() {
//关闭云渲染并释放资源
this.api.destroy();
}
render() {
return (
);
}
}
```
--------------------------------
### Start View Dome Analysis Configuration
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/Tools
Starts an openness analysis, which determines the visibility of the sky from a given point. Users can specify the observation point, radius of analysis, opacity, and colors for visible and invisible areas. If no start point is provided, it defaults to mouse interaction. An optional callback function can be supplied.
```javascript
startViewDomeAnalysis({
startPoint: [x, y],
radius: 1000,
opacity: 0.7,
visibleColor: Color.Red,
invisibleColor: Color.Green
}, fn);
```
--------------------------------
### Start HTTP Service (JavaScript)
Source: https://nangongwentian-fe.github.io/DTSCloudAPI6.1/doc/tutorial-API_Revision
Starts an HTTP service independently. This functionality is available in the configuration tool and allows for standalone HTTP server operations.
```javascript
configTool.startHttpService();
```