Skip to main content
Glama

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
NameRequiredDescriptionDefault
longitudeYes经度(-180 ~ 180)
latitudeYes纬度(-90 ~ 90)
heightNo放置高度(米)
urlYesglTF/GLB 模型文件 URL
scaleNo模型缩放比例
headingNo航向角(度),0=正北
pitchNo俯仰角(度)
rollNo翻滚角(度)
labelNo模型标注文本

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,
      })
    }

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