addModel
Place 3D models (glTF/GLB) at specific geographic coordinates on a 3D globe, returning an entity ID for further manipulation.
Instructions
在指定经纬度放置 3D 模型(glTF/GLB),返回 entityId
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| longitude | Yes | 经度(-180 ~ 180) | |
| latitude | Yes | 纬度(-90 ~ 90) | |
| height | No | 放置高度(米) | |
| url | Yes | glTF/GLB 模型文件 URL | |
| scale | No | 模型缩放比例 | |
| heading | No | 航向角(度),0=正北 | |
| pitch | No | 俯仰角(度) | |
| roll | No | 翻滚角(度) | |
| label | No | 模型标注文本 |
Implementation Reference
- The implementation of the `addModel` tool, which takes longitude, latitude, height, URL, and other parameters to create a 3D model entity in Cesium.
export function addModel(viewer: Cesium.Viewer, params: AddModelParams): Cesium.Entity { const { longitude, latitude, height = 0, url, scale = 1, heading = 0, pitch = 0, roll = 0, label } = params validateCoordinate(longitude, latitude, height) const position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height) const hpr = new Cesium.HeadingPitchRoll( Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll), ) const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr) return viewer.entities.add({ position, orientation: orientation as any, model: { uri: url, scale, }, label: label ? { text: label, font: '13px sans-serif', fillColor: Cesium.Color.WHITE, outlineColor: Cesium.Color.BLACK, outlineWidth: 2, style: Cesium.LabelStyle.FILL_AND_OUTLINE, pixelOffset: new Cesium.Cartesian2(0, -24), verticalOrigin: Cesium.VerticalOrigin.BOTTOM, disableDepthTestDistance: Number.POSITIVE_INFINITY, } : undefined, }) }