Skip to main content
Glama

updateEntity

Modify properties of existing 3D entities on a Cesium globe, including position, color, labels, scale, and visibility.

Instructions

更新已有实体的属性(位置、颜色、标签、缩放、可见性)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityIdYes实体ID(addMarker/addPolyline 等返回的 entityId)
positionNo新位置坐标
labelNo新标注文本
colorNo新颜色(CSS 格式)
scaleNo新缩放比例
showNo是否显示

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
  • Registration/Method wrapper for updateEntity in the bridge class.
    updateEntity(params: UpdateEntityParams): boolean {
      return updateEntity(this._viewer, params)
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gaopengbin/cesium-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server