updateEntity
Modify properties of existing 3D entities on a Cesium globe, including position, color, labels, scale, and visibility.
Instructions
更新已有实体的属性(位置、颜色、标签、缩放、可见性)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entityId | Yes | 实体ID(addMarker/addPolyline 等返回的 entityId) | |
| position | No | 新位置坐标 | |
| label | No | 新标注文本 | |
| color | No | 新颜色(CSS 格式) | |
| scale | No | 新缩放比例 | |
| show | No | 是否显示 |
Implementation Reference
- The actual implementation of the updateEntity logic that modifies a Cesium entity's properties.
export function updateEntity(viewer: Cesium.Viewer, params: UpdateEntityParams): boolean { const entity = viewer.entities.getById(params.entityId) if (!entity) return false if (params.position) { const { longitude, latitude, height } = params.position validateCoordinate(longitude, latitude, height) entity.position = new Cesium.ConstantPositionProperty( Cesium.Cartesian3.fromDegrees(longitude, latitude, height ?? 0), ) } if (params.label !== undefined && entity.label) { entity.label.text = new Cesium.ConstantProperty(params.label) } if (params.color !== undefined) { const c = parseColor(params.color) if (entity.point) entity.point.color = new Cesium.ConstantProperty(c) if (entity.polyline) entity.polyline.material = new Cesium.ColorMaterialProperty(c) if (entity.polygon) entity.polygon.material = new Cesium.ColorMaterialProperty(c) } if (params.scale !== undefined) { if (entity.model) entity.model.scale = new Cesium.ConstantProperty(params.scale) if (entity.label) entity.label.scale = new Cesium.ConstantProperty(params.scale) - Definition of the UpdateEntityParams interface.
export interface UpdateEntityParams { entityId: string position?: { longitude: number; latitude: number; height?: number } label?: string color?: ColorInput scale?: number show?: boolean - packages/cesium-mcp-bridge/src/bridge.ts:521-523 (registration)Registration/Method wrapper for updateEntity in the bridge class.
updateEntity(params: UpdateEntityParams): boolean { return updateEntity(this._viewer, params) }