@anov/gis-skills-cli 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +618 -0
- package/INSTALL.md +478 -0
- package/LICENSE +15 -0
- package/README.md +148 -2
- package/RELEASING.md +160 -0
- package/bin/anov-gis-skills.mjs +408 -0
- package/lib/mcp-config.mjs +273 -0
- package/package.json +42 -4
- package/skills/anovgis-analysis/SKILL.md +585 -0
- package/skills/anovgis-effects/SKILL.md +260 -0
- package/skills/anovgis-imagery-terrain/SKILL.md +505 -0
- package/skills/anovgis-layers/SKILL.md +627 -0
- package/skills/anovgis-materials/SKILL.md +635 -0
- package/skills/anovgis-models-3dtiles/SKILL.md +448 -0
- package/skills/anovgis-pitfalls/SKILL.md +561 -0
- package/skills/anovgis-popup-widget/SKILL.md +474 -0
- package/skills/anovgis-primitives/SKILL.md +482 -0
- package/skills/anovgis-vector-graphics/SKILL.md +602 -0
- package/skills/anovgis-viewer/SKILL.md +618 -0
- package/skills/using-anovgis/DEMO-MAP.md +64 -0
- package/skills/using-anovgis/DEMO-SKILL-MAP.md +248 -0
- package/skills/using-anovgis/DOMAINS.md +183 -0
- package/skills/using-anovgis/REFERENCE.md +114 -0
- package/skills/using-anovgis/SKILL.md +392 -0
- package/skills/using-anovgis/templates/README.md +154 -0
- package/skills/using-anovgis/templates/combo1-vue3-vite.md +295 -0
- package/skills/using-anovgis/templates/combo2-vue2-cli.md +119 -0
- package/skills/using-anovgis/templates/combo3-html-cdn.md +107 -0
- package/skills/using-anovgis/templates/combo4-vanilla-webpack.md +91 -0
- package/skills/using-anovgis/templates/wizard-profiles.md +105 -0
- package/vendor/cesiumjs-skills/LICENSE +201 -0
- package/vendor/cesiumjs-skills/NOTICE +18 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-3d-tiles/SKILL.md +465 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-camera/SKILL.md +500 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-core-utilities/SKILL.md +403 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/REFERENCE.md +397 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/SKILL.md +351 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/01-diffuse-tint.js +38 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/02-texture-swap.js +42 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/03-feature-id-tileset.js +29 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/04-translucent-override.js +37 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/05-vertex-displacement.js +49 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/06-metadata-ramp.js +34 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/07-voxel-shader.js +27 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/README.md +19 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/_sandcastle-template.html +9 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-entities/SKILL.md +389 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-imagery/SKILL.md +471 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-interaction/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-materials-shaders/SKILL.md +292 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-models-particles/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-primitives/SKILL.md +537 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-spatial-math/SKILL.md +358 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-terrain-environment/SKILL.md +401 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-time-properties/SKILL.md +353 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-viewer-setup/SKILL.md +434 -0
- package/vendor/cesiumjs-skills/skills/using-cesiumjs-skills/SKILL.md +35 -0
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: anovgis-vector-graphics
|
|
3
|
+
description: '@anov/gis 图元层(Graphic 体系)。涵盖 Graphic 抽象类 API、Vector 16 类(Point/Polyline/Polygon/Circle/Ellipse/Rect/Wall/Box/Cylinder/Ellipsoid/Corridor/PolylineVolume/Plane/Billboard/Label)、Model 2 类(Model / Tileset)、Primitive 17 类(Billboard/BounceBillboard/BounceLabel/Cloud/DiffuseWall/ElecEllipsoid/FlowLine/LabelPrimitive/LightCylinder/ModelPrimitive/PointPrimitive/PolylinePrimitive/ScanCircle/TrailLine/Video/Water)、8 个典型 snippet。触发关键词:graphic、Point、Polyline、Polygon、Billboard、Label、Tileset、Primitive、WaterPrimitive、ScanCirclePrimitive、TrailLinePrimitive、highlight、selectedHighlight、bindPopup、addEventListener、customshader、自定义 shader、GLSL、cesium_three、three.js 融合、ThreeLayer、div 弹窗、divInfo。Use when 创建点/线/面/图标/文字/立方体/球/圆柱、加载 3D Tiles 模型 + 鼠标拾取 popup、做扫描圆 / 雷达 / 尾迹线 / 动态水面 / 流动线 Primitive 版、绑定 Popup 或 Tooltip、div 弹窗。'
|
|
4
|
+
anov-gis-baseline: 1.8.6
|
|
5
|
+
cesium-baseline: 1.143.0
|
|
6
|
+
---
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# anovgis-vector-graphics — @anov/gis 图元层速查
|
|
10
|
+
|
|
11
|
+
> ⚠️ **优先级**:本 skill 优先于 SDK 源码 / `node_modules/@anov/gis/`。
|
|
12
|
+
> 遇到 API 行为疑问先查本 skill 与 `anovgis-pitfalls`。**严禁**主动 Glob/Grep `node_modules/@anov/gis/src/...` / `dist/...`;除非用户明确要求并承担风险。
|
|
13
|
+
> 调试流程见 `using-anovgis` § 默认调试流程(Chrome DevTools 仅第 5 级兜底)。
|
|
14
|
+
>
|
|
15
|
+
> **Cesium 入口(铁律)**:`const Cesium = window.Cesium`。`@anov/gis` 启动时已把 Cesium 挂到 `window`,**不存在** `ANOVGIS.Cesium` 写法;本 skill 所有 `Cesium.*` 均从此变量取。底层 Cesium API 细节查 `cesiumjs-skills` 对应 skill(API 名通用,`import` 写法换成 `const Cesium = window.Cesium`)。
|
|
16
|
+
|
|
17
|
+
> `@anov/gis` 中所有"看得见的实体"都继承自抽象类 `Graphic`。本 skill 涵盖 Vector(16)、Model(2)、Primitive(17)共 35 个图元 + Graphic 基类 API + 8 个真实 snippet。锁定 `@anov/gis` **v1.8.6**(Cesium **1.143.0**)。
|
|
18
|
+
>
|
|
19
|
+
> 源码根:`src/graphic/index.js`;抽象类:`src/graphic/Graphic.js`(仅作语义锚点,不要去翻 `node_modules` 实物)。
|
|
20
|
+
>
|
|
21
|
+
> **与 material 体系的边界**:扫描圆 / 流动线 / 扩散墙有 *两套*——`ScanCirclePrimitive` / `FlowLinePrimitive` / `DiffuseWallPrimitive`(Primitive 版,独立 Graphic)与 `CircleScanMaterialProperty` / `PolylineFlowMaterialProperty` / `WallFlowMaterialProperty`(Property 版,挂 entity.material)。本文件只覆盖 Primitive 版;Property 版见 `anovgis-materials`。
|
|
22
|
+
|
|
23
|
+
## Out-of-scope(v0.2.0 短版)
|
|
24
|
+
|
|
25
|
+
- ❌ 不要写 Primitive 19 类完整用法(本文件仅 §4 + §5 提到 17 类作为衔接,权威列表见 [`anovgis-primitives`](../anovgis-primitives/SKILL.md))
|
|
26
|
+
- ❌ 不要写 `Tileset` 加载 + 拾取 + 抽壳 + 调色 → [`anovgis-models-3dtiles`](../anovgis-models-3dtiles/SKILL.md)
|
|
27
|
+
- ❌ 不要写 `bindPopup` / `bindTooltip` / `highlight` 业务封装 + `tilesetpopup` / `imagerylayerpopup` → [`anovgis-popup-widget`](../anovgis-popup-widget/SKILL.md)
|
|
28
|
+
- ❌ 不要写 `*MaterialProperty`(挂在 entity.material 上的版本) → [`anovgis-materials`](../anovgis-materials/SKILL.md)
|
|
29
|
+
- ❌ 不要写 Draw / Measure / HeatMap / WindLayer → [`anovgis-analysis`](../anovgis-analysis/SKILL.md)
|
|
30
|
+
- ❌ 不要写 `ThreeLayer` 桥接 → v0.3.0 `anovgis-three-layer`
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 1. Graphic 抽象类 API
|
|
35
|
+
|
|
36
|
+
所有 Vector / Model / Primitive 子类都继承以下能力:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// 属性
|
|
40
|
+
graphic.graphicId // 内部 uuid(只读)
|
|
41
|
+
graphic.businessID // 业务 id(set id(...) 等价)
|
|
42
|
+
graphic.type // 子类类型字符串('polygon'/'billboard'/'tileset'/'water_primitive'...)
|
|
43
|
+
graphic.nativeObjCesium // 对应的 Cesium 原生对象(Entity / Primitive / Cesium3DTileset / Promise)
|
|
44
|
+
graphic.attr // 业务属性(任意 JSON)
|
|
45
|
+
graphic.show = true // 显隐(同步到 _nativeObjCesium.show)
|
|
46
|
+
graphic.state // 内部状态(INITIALIZED / ADDED / REMOVED)
|
|
47
|
+
graphic.contextMenu // 右键菜单数组
|
|
48
|
+
|
|
49
|
+
// 行为
|
|
50
|
+
graphic.setOptions(style) // 修改样式(不同子类签名不同)
|
|
51
|
+
graphic.addTo(layer) // 加入图层(layer.addGraphic 的别名)
|
|
52
|
+
graphic.remove() // 从图层移除(layer.removeGraphic)
|
|
53
|
+
graphic.addEventListener(type, fn) // 订阅事件(MouseEventType / GraphicEventType)
|
|
54
|
+
graphic.removeEventListener(type, fn)
|
|
55
|
+
graphic.raiseEvent(type, params) // 主动触发事件
|
|
56
|
+
graphic.bindPopup(opts) // 绑定 Popup(用于 click 时弹信息框)
|
|
57
|
+
graphic.bindTooltip(opts) // 绑定 Tooltip
|
|
58
|
+
|
|
59
|
+
// 飞行(由 Viewer 提供,Graphic 本身不定义 flyTo)
|
|
60
|
+
viewer.flyTo(graphic | layer | [lng,lat,height])
|
|
61
|
+
viewer.flyToTileset(tileset, pitch, range, heading) // Tileset 专用
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
事件枚举(`ANOVGIS.MouseEventType`):`CLICK / RIGHT_CLICK / MOUSE_MOVE / MOUSE_OUT / LEFT_DOWN / LEFT_UP / WHEEL`。
|
|
65
|
+
|
|
66
|
+
容器 Layer:`VectorLayer`(Point/Polyline/Polygon/...)/ `TilesetLayer`(Tileset)/ `PrimitiveLayer`(Primitive)。`layer.addGraphic(g)` 触发 `ADDED` 状态。
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
<a id="vector-table"></a>
|
|
71
|
+
## 2. Vector 速查表(16 类,全部继承自 Graphic,内部用 `Cesium.Entity`)
|
|
72
|
+
|
|
73
|
+
| 类 | 构造签名(简化) | 典型用途 |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `Point` | `new Point(position, options)` | 单点;可挂 `label` 子图元 |
|
|
76
|
+
| `Polyline` | `new Polyline(positions, options)` | 折线;至少 2 点 |
|
|
77
|
+
| `Polygon` | `new Polygon(positions, options)` | 面;支持 `holes` |
|
|
78
|
+
| `Circle` | `new Circle(center, options)` | 圆面 |
|
|
79
|
+
| `Ellipse` | `new Ellipse(center, options)` | 椭圆面 |
|
|
80
|
+
| `Rect` | `new Rect(west/south/east/north, options)` | 矩形面(Rectangle) |
|
|
81
|
+
| `Wall` | `new Wall(positions, options)` | 墙(带高度的面) |
|
|
82
|
+
| `Box` | `new Box(position, options)` | 立方体 |
|
|
83
|
+
| `Cylinder` | `new Cylinder(position, options)` | 圆柱 |
|
|
84
|
+
| `Ellipsoid` | `new Ellipsoid(position, options)` | 球 |
|
|
85
|
+
| `Corridor` | `new Corridor(positions, options)` | 走廊 |
|
|
86
|
+
| `PolylineVolume` | `new PolylineVolume(positions, profile, options)` | 沿线拉伸体 |
|
|
87
|
+
| `Plane` | `new Plane(origin, options)` | 平面 |
|
|
88
|
+
| `Billboard` | `new Billboard(position, options)` | 图标;支持 `image` URL/Canvas |
|
|
89
|
+
| `Label` | `new Label(position, options)` | 文字;`font` 字段可指定自定义字体 |
|
|
90
|
+
| `DivIcon` | `new DivIcon(options)` | DOM 图标(与 Billboard 平行) |
|
|
91
|
+
|
|
92
|
+
通用 options:`material / outline / outlineColor / outlineWidth / height / heightReference / clampToGround / classificationType / label(Point/Polygon 内嵌)/ billboard(Polygon 内嵌)/ highlight / selectedHighlight / infoData`。
|
|
93
|
+
|
|
94
|
+
**高亮机制**:构造时传 `highlight: { material: ..., width: ... }`,鼠标悬停时自动切换;`selectedHighlight` 用于 click 后保持高亮。
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 3. Model 速查表(2 类)
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
new ANOVGIS.Model({ position, url, ... }) // 单 glTF 模型(单 options 对象)
|
|
102
|
+
new ANOVGIS.Tileset(options) // 3D Tiles
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> ⚠️ `Model` 只收**一个 options 对象**(源码 `src/graphic/model/Model.js:7` 是 `constructor(options)`),`position` / `url` 都在里面 —— 不是 `(url, options)`。
|
|
106
|
+
|
|
107
|
+
### `Tileset`(3D Tiles,重点)
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
const tileset = new ANOVGIS.Tileset({
|
|
111
|
+
url: '...tileset.json',
|
|
112
|
+
maximumScreenSpaceError: 6,
|
|
113
|
+
skipLevels: true,
|
|
114
|
+
highlight: { color: '#ff0000' }, // 鼠标悬停样式
|
|
115
|
+
selectedHighlight: { color: 'rgba(255,0,255,0.8)' }
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
tileset.ready(t => console.log('loaded', t)) // 异步加载完成回调(Cesium 1.143 fromUrl → Promise)
|
|
119
|
+
tileset.clampToGround() // 贴地
|
|
120
|
+
tileset.setStyle(new ANOVGIS.Cesium3DTileStyle({ color: 'condition' }))
|
|
121
|
+
tileset.setTileVisible(callback) // 瓦片可见回调
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
> Cesium 1.143:`tileset._nativeObjCesium` 现在是 `Promise<Cesium3DTileset>`(来自 `Cesium3DTileset.fromUrl`);SDK 内部已封装,请用 `tileset.ready(callback)` 替代旧的 `readyEvent`。
|
|
125
|
+
|
|
126
|
+
`Model` 为单 glTF 模型;addTo 后用 `viewer.flyTo(graphic)` 定位。
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 4. Primitive 速查表(17 类,全部继承自 Graphic,内部用 `Cesium.Primitive` / `GroundPrimitive`)
|
|
131
|
+
|
|
132
|
+
| 类 | 构造签名 | 用途 / 关键 options |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `BillboardPrimitive` | `(position, options)` | 高性能图标(用 `BillboardCollection`) |
|
|
135
|
+
| `BounceBillboardPrimitive` | `(position, options)` | 跳动图标 |
|
|
136
|
+
| `BounceLabelPrimitive` | `(position, options)` | 跳动文字 |
|
|
137
|
+
| `CloudPrimitive` | `(options)` | 云层 |
|
|
138
|
+
| `DiffuseWallPrimitive` | `(positions, options)` | 扩散墙体(Primitive 版,非 WallFlowMaterialProperty) |
|
|
139
|
+
| `ElecEllipsoidPrimitive` | `(position, options)` | 电磁球 |
|
|
140
|
+
| `FlowLinePrimitive` | `(positions, width, options)` | 流动抛物线(`speed`/`color`/`percent`,Primitive 版) |
|
|
141
|
+
| `LabelPrimitive` | `(position, options)` | 高性能 Label |
|
|
142
|
+
| `LightCylinderPrimitive` | `(position, options)` | 光柱 |
|
|
143
|
+
| `ModelPrimitive` | `(options)` | 自定义 Primitive 容器 |
|
|
144
|
+
| `PointPrimitive` | `(position, options)` | 高性能点 |
|
|
145
|
+
| `PolylinePrimitive` | `(positions, options)` | 高性能折线 |
|
|
146
|
+
| `ScanCirclePrimitive` | `(position, radius)` | 雷达扫描圆(`color`/`speed`,Primitive 版) |
|
|
147
|
+
| `TrailLinePrimitive` | `(positions, width=1)` | 尾迹线(`color`/`speed`) |
|
|
148
|
+
| `VideoPrimitive` | `(options)` | 视频贴图 |
|
|
149
|
+
| `WaterPrimitive` | `(positions, holes=[])` | 动态水面(`baseWaterColor`/`frequency`/`amplitude`/`animationSpeed`/`specularIntensity`) |
|
|
150
|
+
|
|
151
|
+
> 容器:`new ANOVGIS.PrimitiveLayer().addTo(viewer)`。Primitive 版 ≠ MaterialProperty 版:扫描圆 / 流动线 / 扩散墙另有对应的 `*MaterialProperty`(挂在 entity.material 上),两者**不要混用**——见顶部边界说明。
|
|
152
|
+
|
|
153
|
+
> §1.4 合并说明:以下 3 个原始图元来自 `04-material.md` §1.4("非 MaterialProperty,自带 material"),归本 skill:ScanCirclePrimitive(雷达)/ DiffuseWallPrimitive(扩散墙)/ FlowLinePrimitive(流动线 Primitive 版)。它们都是独立 `Graphic`,构造时 `new XxxPrimitive(pos, ...)`,已并入上表。
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 5. 典型 snippet(8 个,全部可粘贴运行)
|
|
158
|
+
|
|
159
|
+
### S1. 创建 Point + 加入 VectorLayer + 内嵌 label
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
// 来源: examples/public/examples/html/graphics/point.html L57-90
|
|
163
|
+
const layer = new ANOVGIS.VectorLayer()
|
|
164
|
+
viewer.addLayer(layer)
|
|
165
|
+
|
|
166
|
+
const point = new ANOVGIS.Point([116.4, 39.9, 0], {
|
|
167
|
+
color: ANOVGIS.Color.WHITE,
|
|
168
|
+
pixelSize: 12,
|
|
169
|
+
outlineColor: ANOVGIS.Color.BLUE,
|
|
170
|
+
outlineWidth: 2,
|
|
171
|
+
label: {
|
|
172
|
+
text: '文字标签',
|
|
173
|
+
font: '25px sans-serif',
|
|
174
|
+
color: '#ffff00',
|
|
175
|
+
clampToGround: true,
|
|
176
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
177
|
+
pixelOffset: new Cesium.Cartesian2(0.0, -12)
|
|
178
|
+
},
|
|
179
|
+
infoData: { title: '标题', fieldsMap: [{ nameC: '编号', value: 123 }] }
|
|
180
|
+
})
|
|
181
|
+
layer.addGraphic(point)
|
|
182
|
+
viewer.flyTo(layer)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
<a id="s2"></a>
|
|
186
|
+
### S2. 创建 Polygon + 高亮 + 弹窗 Popup
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
// 来源: examples/public/examples/html/graphics/polygon.html L60-82
|
|
190
|
+
// + graphics/polyline.html L57-71 (bindPopup 模式)
|
|
191
|
+
const layer = new ANOVGIS.VectorLayer()
|
|
192
|
+
viewer.addLayer(layer)
|
|
193
|
+
layer.bindPopup({
|
|
194
|
+
viewer, showTitle: true,
|
|
195
|
+
useDefaultHtmlTemplate: true
|
|
196
|
+
})
|
|
197
|
+
layer.addEventListener(ANOVGIS.MouseEventType.CLICK, (e) => {
|
|
198
|
+
const g = e.graphic
|
|
199
|
+
if (g) layer.popup.show(e.position, g.infoData)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
const polygon = new ANOVGIS.Polygon(
|
|
203
|
+
'116.0,42.0;112.0,42.0;118.0,40.0',
|
|
204
|
+
{
|
|
205
|
+
material: 'rgba(255,0,0,0.5)',
|
|
206
|
+
highlight: { material: 'rgba(255,255,0,0.6)' }, // 鼠标悬停变黄
|
|
207
|
+
label: { text: '这是多边形', clampToGround: true,
|
|
208
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM }
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
polygon.setOptions({
|
|
212
|
+
polyline: { // 自动补边界线
|
|
213
|
+
positions: [...polygon.positions, polygon.positions[0]],
|
|
214
|
+
width: 5, material: Cesium.Color.YELLOW
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
layer.addGraphic(polygon)
|
|
218
|
+
viewer.flyTo(layer)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
<a id="s3"></a>
|
|
222
|
+
### S3. 创建 Billboard + 自定义 Canvas 图像
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
// 来源: examples/public/examples/html/graphics/billboard.html L79-94
|
|
226
|
+
// 用 ANOVGIS.ShapeUtil.drawCanvalCircle 生成 canvas 贴图
|
|
227
|
+
const billboard = new ANOVGIS.Billboard([116.4, 39.9], {
|
|
228
|
+
image: ANOVGIS.ShapeUtil.drawCanvalCircle(
|
|
229
|
+
Cesium.Color.BLUE.toCssColorString(),
|
|
230
|
+
60,
|
|
231
|
+
['北京', 1234] // [line1, line2]
|
|
232
|
+
),
|
|
233
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
234
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
235
|
+
scaleByDistance: { near: 1000000, nearValue: 1.0,
|
|
236
|
+
far: 10000000, farValue: 0.0 }
|
|
237
|
+
})
|
|
238
|
+
const layer = new ANOVGIS.VectorLayer()
|
|
239
|
+
viewer.addLayer(layer)
|
|
240
|
+
layer.addGraphic(billboard)
|
|
241
|
+
viewer.flyTo(billboard)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### S4. Tileset + ready 回调 + 鼠标拾取
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
// 来源: examples/public/examples/html/event/tilesetpopup.html L48-93
|
|
248
|
+
const layer = new ANOVGIS.TilesetLayer()
|
|
249
|
+
viewer.addLayer(layer)
|
|
250
|
+
|
|
251
|
+
const tileset = new ANOVGIS.Tileset({
|
|
252
|
+
url: '/data/beijingchouxi/tileset.json',
|
|
253
|
+
highlight: { color: '#ff0000' },
|
|
254
|
+
selectedHighlight: { color: 'rgba(255,0,255,0.8)' }
|
|
255
|
+
})
|
|
256
|
+
tileset.ready((t) => console.log('3D Tiles loaded:', t))
|
|
257
|
+
layer.addGraphic(tileset)
|
|
258
|
+
|
|
259
|
+
// 条件样式(按属性着色)
|
|
260
|
+
const style = new ANOVGIS.Cesium3DTileStyle({ color: {
|
|
261
|
+
conditions: [
|
|
262
|
+
['Number(${floor}) >= 40', 'rgba(45,0,75,0.5)'],
|
|
263
|
+
['Number(${floor}) >= 10', 'rgb(248,176,87)'],
|
|
264
|
+
['true', 'rgb(127,59,8)']
|
|
265
|
+
]
|
|
266
|
+
}})
|
|
267
|
+
tileset.setStyle(style)
|
|
268
|
+
|
|
269
|
+
// 拾取 + Popup
|
|
270
|
+
layer.bindPopup({ viewer, showTitle: true, useDefaultHtmlTemplate: true })
|
|
271
|
+
layer.addEventListener(ANOVGIS.MouseEventType.CLICK, (e) => {
|
|
272
|
+
const infoData = {
|
|
273
|
+
title: e.feature.getProperty('name1'),
|
|
274
|
+
fieldsMap: [
|
|
275
|
+
{ nameC: '名称', value: e.feature.getProperty('name1') },
|
|
276
|
+
{ nameC: '楼层', value: e.feature.getProperty('floor') }
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
layer.popup.show(e.position, infoData)
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
viewer.flyToTileset(tileset, 2, 0.5, -35) // pitch=2, range=0.5, heading=-35
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### S5. TrailLinePrimitive(尾迹线)
|
|
286
|
+
|
|
287
|
+
```js
|
|
288
|
+
// 来源: src/graphic/primitive/TrailLinePrimitive.js L7-77 (无 examples HTML,按 src 推断)
|
|
289
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer)
|
|
290
|
+
const trail = new ANOVGIS.TrailLinePrimitive(
|
|
291
|
+
[[116.3, 39.9], [116.4, 40.0], [116.5, 39.8]], // positions
|
|
292
|
+
3 // width
|
|
293
|
+
)
|
|
294
|
+
trail.setOptions({
|
|
295
|
+
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), // 红色半透明
|
|
296
|
+
speed: 5 // 流动速度
|
|
297
|
+
})
|
|
298
|
+
layer.addGraphic(trail)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### S6. ScanCirclePrimitive(扫描圆 / 雷达)
|
|
302
|
+
|
|
303
|
+
```js
|
|
304
|
+
// 来源: examples/public/examples/html/model/customshader.html L309-326
|
|
305
|
+
// 另见 04-material.md §3.4 来源 B:cesium_three.html L309-316(Primitive 正确写法)
|
|
306
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer)
|
|
307
|
+
const circle = new ANOVGIS.ScanCirclePrimitive(
|
|
308
|
+
'121.49536592256028,31.241616722278213', // 中心 [lng,lat]
|
|
309
|
+
5000 // 半径(米)
|
|
310
|
+
)
|
|
311
|
+
circle.setOptions({
|
|
312
|
+
speed: 5,
|
|
313
|
+
color: new ANOVGIS.Color(0.5, 0.8, 1.0, 1.0)
|
|
314
|
+
})
|
|
315
|
+
layer.addGraphic(circle)
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### S7. WaterPrimitive(动态水面)
|
|
319
|
+
|
|
320
|
+
```js
|
|
321
|
+
// 来源: examples/public/examples/html/performance/wall_drawCommand2_Sci0.html L145-170
|
|
322
|
+
const layer = new ANOVGIS.PrimitiveLayer()
|
|
323
|
+
viewer.addLayer(layer)
|
|
324
|
+
|
|
325
|
+
// positions 为 Cesium.Cartesian3 数组(来自 GeoJsonDataSource 的 polygon hierarchy)
|
|
326
|
+
const water = new ANOVGIS.WaterPrimitive(positionCartesian3, holes)
|
|
327
|
+
water.setOptions({
|
|
328
|
+
baseWaterColor: ANOVGIS.Color.fromCssColorString('rgb(17,38,57)'),
|
|
329
|
+
frequency: 100.0, // 波浪频率
|
|
330
|
+
animationSpeed: 0.01, // 动画速度
|
|
331
|
+
amplitude: 10, // 振幅
|
|
332
|
+
specularIntensity: 0.2 // 高光强度
|
|
333
|
+
})
|
|
334
|
+
layer.addGraphic(water)
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
<a id="s8"></a>
|
|
338
|
+
### S8. Label + 自定义字体 + 按视距缩放
|
|
339
|
+
|
|
340
|
+
```js
|
|
341
|
+
// 来源: examples/public/examples/html/graphics/label.html L80-105
|
|
342
|
+
const layer = new ANOVGIS.VectorLayer()
|
|
343
|
+
viewer.addLayer(layer)
|
|
344
|
+
|
|
345
|
+
// 自定义字体(楷体)
|
|
346
|
+
const v1 = new ANOVGIS.Label([116.4, 39.9], {
|
|
347
|
+
text: '数字科技',
|
|
348
|
+
font: '46px 楷体', // 浏览器/系统已安装的字体名
|
|
349
|
+
scale: 0.5,
|
|
350
|
+
color: '#00ffff',
|
|
351
|
+
outline: true,
|
|
352
|
+
outlineColor: '#000000',
|
|
353
|
+
outlineWidth: 2,
|
|
354
|
+
horizontalOrigin: ANOVGIS.HorizontalOrigin.CENTER,
|
|
355
|
+
verticalOrigin: ANOVGIS.VerticalOrigin.BOTTOM
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
// 按视距缩放
|
|
359
|
+
const v2 = new ANOVGIS.Label([116.5, 39.9], {
|
|
360
|
+
text: '按视距缩放标签',
|
|
361
|
+
font: '70px 楷体',
|
|
362
|
+
color: '#00ff00',
|
|
363
|
+
scaleByDistance: new ANOVGIS.NearFarScalar(10000, 1.0, 500000, 0.1)
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
layer.addGraphic(v1)
|
|
367
|
+
layer.addGraphic(v2)
|
|
368
|
+
viewer.flyTo(layer)
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## 6. 关联文件
|
|
374
|
+
|
|
375
|
+
- 抽象类:`src/graphic/Graphic.js`
|
|
376
|
+
- 导出清单:`src/graphic/index.js`(Vector 16 + Model 2 + Primitive 17 = 35 个导出 + `Graphic` / `GraphicType` / `DivIcon`)
|
|
377
|
+
- Layer 容器:`src/layer/graphic/VectorLayer.js`、`TilesetLayer.js`、`PrimitiveLayer.js`(用于 `addGraphic`,详见 `02-layer.md`)
|
|
378
|
+
- MaterialProperty(给 Vector/Primitive 用):`04-material.md` / `anovgis-material` skill
|
|
379
|
+
- 真实 HTML demo:`examples/public/examples/html/graphics/`、`model/`、`event/`、`performance/`
|
|
380
|
+
|
|
381
|
+
> ⚠️ **POI 样式铁律(v0.2.4 加)**:写 POI / graphic 样式前先查 `using-anovgis/REFERENCE.md` 速查表跳到对应章节,**严禁凭想象造"一个红圆点 + label"这种最简实现**。
|
|
382
|
+
> - 至少三层叠:中心实心点(point) + 发光外环(billboard,canvas) + label(顶部偏移)
|
|
383
|
+
> - 发光 canvas 用 `ANOVGIS.ShapeUtil.drawCanvalCircle` 生成(见本 skill § S5)
|
|
384
|
+
> - 视距缩放统一用 `scaleByDistance: new ANOVGIS.NearFarScalar(near, scaleNear, far, scaleFar)`
|
|
385
|
+
> - `disableDepthTestDistance: Number.POSITIVE_INFINITY` 防止被地形/楼块遮挡
|
|
386
|
+
> - 选中态用 `selectedHighlight` 而不是手动改色
|
|
387
|
+
>
|
|
388
|
+
> SDK v1.8.6 `examples/public/examples/html/graphics/` 下的 `point.html` / `billboard.html` / `label.html` / `divInfo.html` 是原始参考 demo,本 skill § S5/S6/S9 已嵌入核心代码,无需读外部文件。
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## 7. 各 Vector / Primitive 实战补充(11 个 snippet)
|
|
393
|
+
|
|
394
|
+
> §5 8 个 snippet 覆盖了 Point / Polygon / Billboard / Label / Tileset / TrailLine / ScanCircle / Water。本节按 §2 Vector / §4 Primitive 速查表类顺序补全 **6 Vector + 5 Primitive**,共 11 个 snippet。字段名按 SDK 实际签名(核 `src/graphic/vector/*` 与 `src/graphic/primitive/*`)。
|
|
395
|
+
|
|
396
|
+
<a id="s9"></a>
|
|
397
|
+
### S9. Point 同时挂 label + billboard + 高亮 + Tooltip/Popup
|
|
398
|
+
|
|
399
|
+
> ⚠️ **批量 POI 标绘先看选型**(v0.2.13):本 snippet 是 **Billboard 路线**(`Point` 内嵌 `billboard` + `label`)。
|
|
400
|
+
> 做 POI 标绘时**默认走 `DivIcon`(DOM 路线)**,`HtmlLayer` + `new ANOVGIS.DivIcon(position, html)`;
|
|
401
|
+
> **POI 数量 > 100 才先问用户**选 DivIcon 还是 Billboard。完整选型规则 + 两套可粘贴代码见
|
|
402
|
+
> [`using-anovgis` § POI 标绘选型(DivIcon 默认)](../using-anovgis/SKILL.md#poi-selection)。
|
|
403
|
+
|
|
404
|
+
```js
|
|
405
|
+
// 来源: examples/public/examples/html/graphics/point.html L54-122
|
|
406
|
+
// Point 是"一个位置叠 N 个 graphic"的容器;options 直接写 label / billboard 子图元
|
|
407
|
+
const layer = new ANOVGIS.VectorLayer(); viewer.addLayer(layer)
|
|
408
|
+
const positions = Array.from({length: 100}, () => [116+Math.random()*0.5, 39+Math.random()*0.5])
|
|
409
|
+
positions.forEach((pos, i) => {
|
|
410
|
+
const p = new ANOVGIS.Point(pos, {
|
|
411
|
+
pixelSize: 12, color: ANOVGIS.Color.WHITE,
|
|
412
|
+
outlineColor: ANOVGIS.Color.BLUE, outlineWidth: 2,
|
|
413
|
+
label: { text: '文字标签', font: '25px sans-serif', color: '#ffff00',
|
|
414
|
+
clampToGround: true, verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
415
|
+
pixelOffset: new Cesium.Cartesian2(0, -12) },
|
|
416
|
+
billboard: { image: ANOVGIS.ShapeUtil.drawCanvalCircle('#00ff00', 60, ['pt', i]),
|
|
417
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM },
|
|
418
|
+
infoData: { title: `第${i}个`, fieldsMap: [{ nameC: '编号', value: i }] },
|
|
419
|
+
highlight: { pixelSize: 17, outlineColor: '#ff0000', outlineWidth: 3 }
|
|
420
|
+
})
|
|
421
|
+
p.bindTooltip({ viewer, showTitle: true, offsetY: '-10', useDefaultHtmlTemplate: true })
|
|
422
|
+
p.addEventListener(ANOVGIS.MouseEventType.MOUSE_MOVE, e => p.tooltip.show(e.position, e.graphic.infoData))
|
|
423
|
+
p.bindPopup({ viewer, showTitle: true })
|
|
424
|
+
p.addEventListener(ANOVGIS.MouseEventType.CLICK, e => p.popup.show(e.position, e.graphic.infoData))
|
|
425
|
+
layer.addGraphic(p)
|
|
426
|
+
})
|
|
427
|
+
viewer.flyTo(layer)
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### S10. PolylineVolume 沿线拉伸(横截面 shape)
|
|
431
|
+
|
|
432
|
+
```js
|
|
433
|
+
// 来源: src/graphic/vector/PolylineVolume.js L7-77(构造 new PolylineVolume(positions, shape))
|
|
434
|
+
// shape 是二维 Cartesian2 数组(横截面多边形),按路径走生成管状体
|
|
435
|
+
const layer = new ANOVGIS.VectorLayer(); viewer.addLayer(layer)
|
|
436
|
+
const shape = [new Cesium.Cartesian2(-100, 0), new Cesium.Cartesian2(-100, 50),
|
|
437
|
+
new Cesium.Cartesian2( 100, 50), new Cesium.Cartesian2( 100, 0)]
|
|
438
|
+
const tube = new ANOVGIS.PolylineVolume(
|
|
439
|
+
[[116.30, 39.90, 0], [116.40, 39.95, 200], [116.50, 39.92, 0]], shape)
|
|
440
|
+
tube.setOptions({
|
|
441
|
+
material: 'rgba(255,140,0,0.7)', outline: true, outlineColor: Cesium.Color.RED,
|
|
442
|
+
cornerType: Cesium.CornerType.ROUNDED
|
|
443
|
+
})
|
|
444
|
+
layer.addGraphic(tube); viewer.flyTo(tube)
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### S11. Wall 拉伸高度 + outline + 流向材质
|
|
448
|
+
|
|
449
|
+
```js
|
|
450
|
+
// 来源: examples/public/examples/html/performance/js/UIC.js L206-249
|
|
451
|
+
// + geojsonLayer/wall.html L54-66
|
|
452
|
+
const layer = new ANOVGIS.VectorLayer(); viewer.addLayer(layer)
|
|
453
|
+
const positions = [[116.30, 39.90], [116.35, 39.90], [116.35, 39.95],
|
|
454
|
+
[116.30, 39.95], [116.30, 39.90]] // 闭合矩形
|
|
455
|
+
const wall = new ANOVGIS.Wall(positions, {
|
|
456
|
+
maximumHeights: new Array(positions.length).fill(200), // 顶高 200m
|
|
457
|
+
minimumHeights: new Array(positions.length).fill(0), // 底高 0
|
|
458
|
+
material: new ANOVGIS.WallFlowMaterialProperty({ // 流向材质
|
|
459
|
+
color: Cesium.Color.fromCssColorString('rgba(59,179,249,0.6)'),
|
|
460
|
+
duration: 1000 }),
|
|
461
|
+
outline: true,
|
|
462
|
+
outlineColor: Cesium.Color.fromCssColorString('rgba(255,255,0,1)')
|
|
463
|
+
})
|
|
464
|
+
layer.addGraphic(wall); viewer.flyTo(wall)
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### S12. Cylinder 锥/柱 + heading/pitch/roll 朝向
|
|
468
|
+
|
|
469
|
+
```js
|
|
470
|
+
// 来源: src/graphic/vector/Cylinder.js L8-18(构造 new Cylinder(pos, length, topRadius, bottomRadius))
|
|
471
|
+
// pos 接受 ANOVGIS.Position 实例带 heading/pitch/roll,内部走 headingPitchRollQuaternion
|
|
472
|
+
const layer = new ANOVGIS.VectorLayer(); viewer.addLayer(layer)
|
|
473
|
+
// 灯塔:底径 60,顶径 30,高 400,航向 30°
|
|
474
|
+
const tower = new ANOVGIS.Cylinder(
|
|
475
|
+
new ANOVGIS.Position(116.40, 39.90, 0, { heading: 30, pitch: 0, roll: 0 }),
|
|
476
|
+
400, 30, 60)
|
|
477
|
+
tower.setOptions({ material: 'rgba(255,200,120,0.9)', outline: true,
|
|
478
|
+
outlineColor: '#444', slicePartitions: 32 })
|
|
479
|
+
layer.addGraphic(tower)
|
|
480
|
+
// 圆锥(topRadius=0)
|
|
481
|
+
const cone = new ANOVGIS.Cylinder(
|
|
482
|
+
new ANOVGIS.Position(116.42, 39.90, 0, { heading: 0, pitch: 0, roll: 0 }),
|
|
483
|
+
200, 0, 80)
|
|
484
|
+
cone.setOptions({ material: Cesium.Color.DARKRED })
|
|
485
|
+
layer.addGraphic(cone); viewer.flyTo(layer)
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### S13. Box 阵列(per-instance + heading 不同)
|
|
489
|
+
|
|
490
|
+
```js
|
|
491
|
+
// 来源: src/graphic/vector/Box.js L7-25(构造 new Box(position, length, width, height))
|
|
492
|
+
// Box 接受 heading/pitch/roll;批量模拟建筑阵列
|
|
493
|
+
const layer = new ANOVGIS.VectorLayer(); viewer.addLayer(layer)
|
|
494
|
+
const bases = [
|
|
495
|
+
{ lng: 116.40, lat: 39.90, h: 0, heading: 0 },
|
|
496
|
+
{ lng: 116.41, lat: 39.90, h: 0, heading: 30 },
|
|
497
|
+
{ lng: 116.40, lat: 39.91, h: 50, heading: 0 },
|
|
498
|
+
{ lng: 116.41, lat: 39.91, h: 50, heading: 45 }
|
|
499
|
+
]
|
|
500
|
+
bases.forEach(b => {
|
|
501
|
+
const box = new ANOVGIS.Box(
|
|
502
|
+
new ANOVGIS.Position(b.lng, b.lat, b.h, { heading: b.heading, pitch: 0, roll: 0 }),
|
|
503
|
+
300, 200, 200) // length, width, height
|
|
504
|
+
box.setOptions({ material: 'rgba(100,180,255,0.8)',
|
|
505
|
+
outline: true, outlineColor: '#003366' })
|
|
506
|
+
layer.addGraphic(box)
|
|
507
|
+
})
|
|
508
|
+
viewer.flyTo(layer)
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### S14. Plane 平面(自定义 normal + 距离)
|
|
512
|
+
|
|
513
|
+
```js
|
|
514
|
+
// 来源: src/graphic/vector/Plane.js L7-38(构造 new Plane(position, width, height, {normal, distance}))
|
|
515
|
+
// normal: 'X' / 'Y' / 'Z' / Cartesian3;distance 是平面到 position 的偏移
|
|
516
|
+
const layer = new ANOVGIS.VectorLayer(); viewer.addLayer(layer)
|
|
517
|
+
// 水平(normal=Z)
|
|
518
|
+
const ground = new ANOVGIS.Plane([116.40, 39.90, 100], 6000, 4000,
|
|
519
|
+
{ normal: 'Z', distance: 0 })
|
|
520
|
+
ground.setOptions({ material: 'rgba(0,200,255,0.4)', outline: true, outlineColor: '#0066aa' })
|
|
521
|
+
layer.addGraphic(ground)
|
|
522
|
+
// 倾斜(normal=UNIT_X,沿 Y 轴立起来)
|
|
523
|
+
const tilted = new ANOVGIS.Plane([116.42, 39.90, 50], 3000, 2000,
|
|
524
|
+
{ normal: Cesium.Cartesian3.UNIT_X, distance: 0 })
|
|
525
|
+
tilted.setOptions({ material: 'rgba(255,200,0,0.5)' })
|
|
526
|
+
layer.addGraphic(tilted); viewer.flyTo(layer)
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### S15. BounceBillboardPrimitive 弹跳广告牌
|
|
530
|
+
|
|
531
|
+
```js
|
|
532
|
+
// 来源: src/graphic/primitive/BounceBillboardPrimitive.js L5-39(继承 BillboardPrimitive)
|
|
533
|
+
// 构造 (position, icon);setOptions 接受 maxOffsetY/offsetAmount
|
|
534
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer)
|
|
535
|
+
const bb = new ANOVGIS.BounceBillboardPrimitive(
|
|
536
|
+
[116.40, 39.90],
|
|
537
|
+
ANOVGIS.ShapeUtil.drawCanvalCircle('#ff5500', 48, ['告警']))
|
|
538
|
+
bb.size = [48, 48]
|
|
539
|
+
bb.setOptions({ maxOffsetY: 12, offsetAmount: 0.6 })
|
|
540
|
+
layer.addGraphic(bb)
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### S16. BounceLabelPrimitive 弹跳文字
|
|
544
|
+
|
|
545
|
+
```js
|
|
546
|
+
// 来源: src/graphic/primitive/BounceLabelPrimitive.js L5-39(继承 LabelPrimitive)
|
|
547
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer)
|
|
548
|
+
const lb = new ANOVGIS.BounceLabelPrimitive([116.40, 39.91], '弹跳标签')
|
|
549
|
+
lb.setOptions({
|
|
550
|
+
maxOffsetY: 8, offsetAmount: 0.4,
|
|
551
|
+
font: '20px sans-serif', fillColor: Cesium.Color.YELLOW,
|
|
552
|
+
outlineColor: Cesium.Color.BLACK, outlineWidth: 2,
|
|
553
|
+
style: Cesium.LabelStyle.FILL_AND_OUTLINE
|
|
554
|
+
})
|
|
555
|
+
layer.addGraphic(lb)
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### S17. CloudPrimitive 云层
|
|
559
|
+
|
|
560
|
+
```js
|
|
561
|
+
// 来源: src/graphic/primitive/CloudPrimitive.js L7-18(构造 new CloudPrimitive(position))
|
|
562
|
+
// nativeObjCesium 直接 {position, scale},绕开 Entity 走 PrimitiveCollection
|
|
563
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer)
|
|
564
|
+
const cloud = new ANOVGIS.CloudPrimitive([116.40, 39.90, 1500])
|
|
565
|
+
cloud.setOptions({ scale: { x: 12, y: 8 } }) // 经向/纬向跨度(度)
|
|
566
|
+
layer.addGraphic(cloud); viewer.flyTo(cloud)
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### S18. ElecEllipsoidPrimitive 电磁球
|
|
570
|
+
|
|
571
|
+
```js
|
|
572
|
+
// 来源: src/graphic/primitive/ElecEllipsoidPrimitive.js L7-19
|
|
573
|
+
// 构造 new ElecEllipsoidPrimitive(position, radius);用 EllipsoidElectric material
|
|
574
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer)
|
|
575
|
+
const elec = new ANOVGIS.ElecEllipsoidPrimitive(
|
|
576
|
+
[116.40, 39.90, 0], { x: 80, y: 80, z: 80 }) // 椭球半径
|
|
577
|
+
elec.setOptions({
|
|
578
|
+
color: Cesium.Color.fromCssColorString('rgba(0,255,180,0.9)'),
|
|
579
|
+
speed: 5
|
|
580
|
+
})
|
|
581
|
+
layer.addGraphic(elec); viewer.flyTo(elec)
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
### S19. LightCylinderPrimitive 灯柱(底环+旋转圆+渐变柱+粒子)
|
|
585
|
+
|
|
586
|
+
```js
|
|
587
|
+
// 来源: src/graphic/primitive/LightCylinderPrimitive.js L14-25
|
|
588
|
+
// 构造 new LightCylinderPrimitive(center, length, topRadius, bottomRadius)
|
|
589
|
+
// alt=0 时贴地用 GroundPrimitive;alt>0 走 Primitive;内部异步加载粒子 PNG
|
|
590
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer)
|
|
591
|
+
const beam = new ANOVGIS.LightCylinderPrimitive(
|
|
592
|
+
[116.40, 39.90, 0], // center
|
|
593
|
+
500, // length
|
|
594
|
+
5, // topRadius
|
|
595
|
+
80 // bottomRadius
|
|
596
|
+
)
|
|
597
|
+
beam.setOptions({ color: Cesium.Color.fromCssColorString('rgba(255,200,80,1)') })
|
|
598
|
+
layer.addGraphic(beam); viewer.flyTo(beam)
|
|
599
|
+
```
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
---
|