TextMaterial

new mars3d.material.TextMaterial(options)

文字贴图 primitive材质

参数名称 类型 描述信息
options object 可选

参数对象,包括以下:

参数名称 类型 默认值 描述信息
text string 可选

文本内容

font_family string "楷体" 可选

字体 ,可选项:微软雅黑,宋体,楷体,隶书,黑体,

font_size number 30 可选

字体大小

font_weight string "normal" 可选

是否加粗 ,可选项:bold (解释:是),normal (解释:否),

font_style string "normal" 可选

是否斜体 ,可选项:italic (解释:是),normal (解释:否),

font string '30px normal normal 楷体' 可选

上叙4个属性的一次性指定CSS字体的属性。

fill boolean true 可选

是否填充

color string new Cesium.Color(1.0, 1.0, 0.0, 1.0) 可选

文本颜色

stroke boolean false 可选

是否描边文本。

strokeColor Cesium.Color new Cesium.Color(1.0, 1.0, 1.0, 0.8) 可选

描边的颜色。

strokeWidth number 2 可选

描边的宽度。

background boolean false 可选

是否背景色。

backgroundColor Cesium.Color new Cesium.Color(1.0, 1.0, 1.0, 0.1) 可选

画布的背景色。

outlineWidth number 可选

边框的宽度。

outlineColor Cesium.Color color 可选

矩形边框的颜色。

padding number 10 可选

要在文本周围添加的填充的像素大小。

textBaseline string 'top' 可选

文本的基线。

speed number 0 可选

不为0时呈现文字滚动效果,数字代表滚动速度

使用示例:
var primitive = new mars3d.graphic.WallPrimitive({
  positions: [
    [121.479343, 29.791419, 25],
    [121.479197, 29.791474, 25],
  ],
  style: {
    diffHeight: 5,
    material: new mars3d.material.TextMaterial({
      text: "火星科技",
      color: "#3388cc",
      outlineWidth: 4,
    }),
  },
})
graphicLayer.addGraphic(primitive)

继承

  • Cesium.Material