@anov/gis-skills-cli 0.0.0-stage → 0.3.3
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 +637 -0
- package/INSTALL.md +481 -0
- package/LICENSE +15 -0
- package/README.md +148 -2
- package/RELEASING.md +162 -0
- package/bin/anov-gis-skills.mjs +470 -0
- package/lib/mcp-config.mjs +273 -0
- package/package.json +43 -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,482 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: anovgis-primitives
|
|
3
|
+
description: '@anov/gis Primitive 体系(19 类),SDK 高性能图元层。涵盖 BillboardPrimitive / BounceBillboardPrimitive / BounceLabelPrimitive / CloudPrimitive / DiffuseWallPrimitive / ElecEllipsoidPrimitive / FlowLinePrimitive / GroundPolygonPrimitive / GroundPolylinePrimitive / LabelPrimitive / LightCylinderPrimitive / ModelPrimitive / ModelCollectionPrimitive / PointPrimitive / PolylinePrimitive / ScanCirclePrimitive / TrailLinePrimitive / VideoPrimitive / WaterPrimitive。v1.8.6 起 15 个 Primitive 类新增 `boundingSphere` getter 用于 `viewer.flyTo` 自动定位。触发关键词:Primitive、CloudPrimitive、DiffuseWallPrimitive、FlowLinePrimitive、LightCylinderPrimitive、ScanCirclePrimitive、TrailLinePrimitive、VideoPrimitive、WaterPrimitive、GroundPolygonPrimitive、GroundPolylinePrimitive、BounceBillboard、BounceLabel、ElecEllipsoid、雷达扫描 Primitive 版、尾迹线 Primitive 版、流动线 Primitive 版、扩散墙 Primitive 版、动态水面 Primitive 版。Use when 用 Primitive 版做扫描圆 / 雷达 / 尾迹线 / 流动线 / 扩散墙 / 动态水面 / 云层 / 光柱 / 弹跳图标、把所有 Primitive 类批量加入 PrimitiveLayer、把 Primitive 传给 viewer.flyTo 自动定位。'
|
|
4
|
+
anov-gis-baseline: 1.8.6
|
|
5
|
+
cesium-baseline: 1.143.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# anovgis-primitives — @anov/gis Primitive 体系速查
|
|
9
|
+
|
|
10
|
+
> ⚠️ **优先级**:本 skill 优先于 SDK 源码 / `node_modules/@anov/gis/`。
|
|
11
|
+
> 遇到 API 行为疑问先查本 skill 与 `anovgis-pitfalls`。**严禁**主动 Glob/Grep `node_modules/@anov/gis/src/...` / `dist/...`;除非用户明确要求并承担风险。
|
|
12
|
+
> 调试流程见 `using-anovgis` § 默认调试流程(Chrome DevTools 仅第 5 级兜底)。
|
|
13
|
+
>
|
|
14
|
+
> **Cesium 入口(铁律)**:`const Cesium = window.Cesium`。`@anov/gis` 启动时已把 Cesium 挂到 `window`,**不存在** `ANOVGIS.Cesium` 写法;本 skill 所有 `Cesium.*` 均从此变量取。底层 Cesium API 细节查 `cesiumjs-skills` 对应 skill(API 名通用,`import` 写法换成 `const Cesium = window.Cesium`)。
|
|
15
|
+
|
|
16
|
+
> `@anov/gis` 中"高性能图元"全部继承自抽象类 `Graphic`,但内部走 `Cesium.Primitive` / `GroundPrimitive` / `BillboardCollection` / `LabelCollection` / `PointPrimitiveCollection` / `PolylineCollection` 等 PrimitiveCollection,**性能高于 Entity 体系**。本 skill 覆盖 **19 个 Primitive 子类** + 通用容器 `PrimitiveLayer` + 通用模式。
|
|
17
|
+
>
|
|
18
|
+
> 源码根:`src/graphic/primitive/`(仅作语义锚点)。
|
|
19
|
+
>
|
|
20
|
+
> **版本基线**:`@anov/gis` v1.8.6;本文档 snippet 基于 v1.8.6 SDK 公开 API 行为锁定。
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Out-of-scope(v0.2.0 短版)
|
|
25
|
+
|
|
26
|
+
- ❌ 不要写 `Vector` 16 类(Point / Polyline / Polygon / ...) → `anovgis-vector-graphics`
|
|
27
|
+
- ❌ 不要写 `Model` / `Tileset` 加载 + 调色 + 抽壳 → `anovgis-models-3dtiles`
|
|
28
|
+
- ❌ 不要写 `*MaterialProperty` 版本(Primitive 自带材质 vs Property 挂在 entity) → `anovgis-materials`
|
|
29
|
+
- ❌ 不要写 `Cesium.Primitive` / `Cesium.DrawCommand` 原生用法(直接绘制底层) → v0.3.0 `anovgis-custom-primitive-worker`
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 1. 19 类 Primitive 速查表
|
|
34
|
+
|
|
35
|
+
### 1.1 广告牌 / 文字类(4 个)
|
|
36
|
+
|
|
37
|
+
| 类 | 构造签名 | 关键 options | 用途 |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| `BillboardPrimitive` | `(position, options)` | `image, scale, color, pixelOffset, scaleByDistance` | 高性能图标(用 `BillboardCollection`) |
|
|
40
|
+
| `BounceBillboardPrimitive` | `(position, icon)` | `size, maxOffsetY, offsetAmount` | 跳动图标(继承 BillboardPrimitive) |
|
|
41
|
+
| `BounceLabelPrimitive` | `(position, text)` | `font, fillColor, outlineColor, maxOffsetY, offsetAmount` | 跳动文字(继承 LabelPrimitive) |
|
|
42
|
+
| `LabelPrimitive` | `(position, options)` | `text, font, fillColor, style, scaleByDistance` | 高性能 Label(用 `LabelCollection`) |
|
|
43
|
+
|
|
44
|
+
### 1.2 点 / 线 / 面(5 个)
|
|
45
|
+
|
|
46
|
+
| 类 | 构造签名 | 关键 options | 用途 |
|
|
47
|
+
|---|---|---|---|
|
|
48
|
+
| `PointPrimitive` | `(position, options)` | `color, pixelSize, outlineColor, outlineWidth` | 高性能点(用 `PointPrimitiveCollection`) |
|
|
49
|
+
| `PolylinePrimitive` | `(positions, options)` | `width, material, clampToGround` | 高性能折线(用 `PolylineCollection`) |
|
|
50
|
+
| `GroundPolygonPrimitive` | `(polygonHierarchy, options)` | `material` | 贴地形面(用 `GroundPrimitive`) |
|
|
51
|
+
| `GroundPolylinePrimitive` | `(positions, options)` | `width, material` | 贴地形折线(用 `GroundPolylinePrimitive`) |
|
|
52
|
+
|
|
53
|
+
### 1.3 流动 / 扩散 / 雷达 / 尾迹(5 个)
|
|
54
|
+
|
|
55
|
+
| 类 | 构造签名 | 关键 options | 用途 |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `FlowLinePrimitive` | `(positions, width, options)` | `speed, color, percent` | 流动抛物线(Primitive 版) |
|
|
58
|
+
| `DiffuseWallPrimitive` | `(positions, options)` | `speed, color` | 扩散墙体(Primitive 版) |
|
|
59
|
+
| `ScanCirclePrimitive` | `(position, radius)` | `speed, color` | 雷达扫描圆(Primitive 版) |
|
|
60
|
+
| `TrailLinePrimitive` | `(positions, width=1)` | `color, speed` | 尾迹线(Primitive 版) |
|
|
61
|
+
|
|
62
|
+
### 1.4 容器 / 模型(3 个)
|
|
63
|
+
|
|
64
|
+
| 类 | 构造签名 | 关键 options | 用途 |
|
|
65
|
+
|---|---|---|---|
|
|
66
|
+
| `ModelPrimitive` | `(options)` | `url, scale, minimumPixelSize, maximumScale` | 自定义 Primitive 容器(单 glTF) |
|
|
67
|
+
| `ModelCollectionPrimitive` | `(options)` | `models: [...]` | 自定义 Primitive 容器(多模型集合) |
|
|
68
|
+
| `GroundPrimitive`(基础类) | — | — | 贴地形 Primitive 基类(多数 Primitive 内部用) |
|
|
69
|
+
|
|
70
|
+
### 1.5 装饰 / 特效(4 个)
|
|
71
|
+
|
|
72
|
+
| 类 | 构造签名 | 关键 options | 用途 |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| `CloudPrimitive` | `(position)` | `scale: {x, y}` | 云层(基于球面贴图) |
|
|
75
|
+
| `LightCylinderPrimitive` | `(center, length, topRadius, bottomRadius)` | `color` | 光柱(底环+旋转圆+渐变柱+粒子) |
|
|
76
|
+
| `WaterPrimitive` | `(positions, holes=[])` | `baseWaterColor, frequency, amplitude, animationSpeed, specularIntensity` | 动态水面(用 `Water` material) |
|
|
77
|
+
| `ElecEllipsoidPrimitive` | `(position, radius)` | `color, speed` | 电磁球 |
|
|
78
|
+
| `VideoPrimitive` | `(options)` | `url, material, scale` | 视频贴图(基于视频材质) |
|
|
79
|
+
| `BounceBillboardPrimitive` | (已列于 1.1) | — | 弹跳图标 |
|
|
80
|
+
| `BounceLabelPrimitive` | (已列于 1.1) | — | 弹跳文字 |
|
|
81
|
+
|
|
82
|
+
> **去重后 19 类**:Billboard / BounceBillboard / BounceLabel / LabelPrimitive / PointPrimitive / PolylinePrimitive / GroundPolygon / GroundPolyline / FlowLine / DiffuseWall / ScanCircle / TrailLine / ModelPrimitive / ModelCollection / Cloud / LightCylinder / Water / ElecEllipsoid / Video = **19 个**。
|
|
83
|
+
|
|
84
|
+
### 1.6 通用属性(v1.8.6 新增 `boundingSphere`)
|
|
85
|
+
|
|
86
|
+
v1.8.6 起,15 个 Primitive 类(除 VideoPrimitive / GroundPolygonPrimitive / GroundPolylinePrimitive 外)新增 `boundingSphere` getter。直接 `viewer.flyTo(primitive)` 时 SDK 用此 getter 自动计算 `range`,无需手动指定。
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
// v1.8.6 之前:手动指定 range
|
|
90
|
+
viewer.flyTo(primitive, 2.0, 0, Cesium.Math.toRadians(-45), 0);
|
|
91
|
+
// v1.8.6+:传 Primitive 实例 + range=0,内部用 boundingSphere 兜底
|
|
92
|
+
viewer.flyTo(primitive, 2.0, 0, Cesium.Math.toRadians(-45), 0);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 2. 通用容器 PrimitiveLayer
|
|
98
|
+
|
|
99
|
+
所有 Primitive 必须通过 `PrimitiveLayer` 接入 viewer:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
// 方式 A:链式
|
|
103
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
104
|
+
|
|
105
|
+
// 方式 B:标准
|
|
106
|
+
const layer = new ANOVGIS.PrimitiveLayer();
|
|
107
|
+
viewer.addLayer(layer);
|
|
108
|
+
|
|
109
|
+
// 加图元
|
|
110
|
+
layer.addGraphic(scanCirclePrimitive);
|
|
111
|
+
|
|
112
|
+
// 移除
|
|
113
|
+
layer.removeGraphic(primitive);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`PrimitiveLayer` 暴露 6 个子集合(与 Cesium `PrimitiveCollection` 子集对应):
|
|
117
|
+
- `layer.points` — `PointPrimitiveCollection`
|
|
118
|
+
- `layer.labels` — `LabelCollection`
|
|
119
|
+
- `layer.billboards` — `BillboardCollection`
|
|
120
|
+
- `layer.polylines` — `PolylineCollection`
|
|
121
|
+
- `layer.primitives` — `PrimitiveCollection`(云、水、光柱、扩散墙等)
|
|
122
|
+
- `layer.clouds` — 云专用 PrimitiveCollection
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 3. Primitive vs *MaterialProperty 边界(重要)
|
|
127
|
+
|
|
128
|
+
| 视觉 | Primitive 版(独立 Graphic) | Property 版(挂 entity.material) |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| 雷达扫描 | `ScanCirclePrimitive(pos, radius)` + `setOptions({ speed, color })` | `CircleScanMaterialProperty({ color, speed })` |
|
|
131
|
+
| 流动线 | `FlowLinePrimitive(positions, width, { speed, color, percent })` | `PolylineFlowMaterialProperty({ color, speed, percent, gradient })` |
|
|
132
|
+
| 扩散墙 | `DiffuseWallPrimitive(positions, { speed, color })` | `WallFlowMaterialProperty({ color, duration })` |
|
|
133
|
+
| 尾迹线 | `TrailLinePrimitive(positions, width)` | `PolylineTrailMaterialProperty({ color, speed })` |
|
|
134
|
+
| 水面 | `WaterPrimitive(positions, holes)` | `WaterMaterialProperty({ ... })` |
|
|
135
|
+
| 扩散波 | (无 Primitive 版)| `CircleWaveMaterialProperty({ color, duration, count, gradient })` |
|
|
136
|
+
|
|
137
|
+
**选择建议**:
|
|
138
|
+
- **Primitive 版**:适合批量创建(数百个以上)、需要精细控制样式(如 `color`/`speed`/`percent`)、单实例性能敏感。
|
|
139
|
+
- **Property 版**:适合挂载到 Entity(图元本身是 Cesium 原生 Entity)、需要时序属性(`CallbackProperty` / `SampledProperty`)、与 material 体系集成。
|
|
140
|
+
|
|
141
|
+
> ❌ **不要混用**:同一视觉不要同时挂 Property + Primitive,否则样式叠加。
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 4. Snippet(19 类全覆盖 + 容器 + 反模式)
|
|
146
|
+
|
|
147
|
+
### S1. PrimitiveLayer 创建 + 加图元
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
// 来源: src/layer/graphic/PrimitiveLayer.js + src/graphic/index.js
|
|
151
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
152
|
+
// 或
|
|
153
|
+
const layer = new ANOVGIS.PrimitiveLayer();
|
|
154
|
+
viewer.addLayer(layer);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
<a id="s2"></a>
|
|
158
|
+
### S2. ScanCirclePrimitive 雷达扫描
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
// 来源: examples/public/examples/html/model/cesium_three.html L309-316
|
|
162
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
163
|
+
const scan = new ANOVGIS.ScanCirclePrimitive(
|
|
164
|
+
Cesium.Cartesian3.fromDegrees(119.506, 35.361), // 中心
|
|
165
|
+
1000 // 半径(米)
|
|
166
|
+
);
|
|
167
|
+
scan.setOptions({
|
|
168
|
+
speed: 5,
|
|
169
|
+
color: new ANOVGIS.Color(0.5, 0.8, 1.0, 1.0)
|
|
170
|
+
});
|
|
171
|
+
layer.addGraphic(scan);
|
|
172
|
+
// v1.8.6+: viewer.flyTo(scan, 2.0, 0, -45, 0) // range=0 自动取 boundingSphere
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### S3. TrailLinePrimitive 尾迹线
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
// 来源: src/graphic/primitive/TrailLinePrimitive.js L7-77
|
|
179
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
180
|
+
const trail = new ANOVGIS.TrailLinePrimitive(
|
|
181
|
+
[[116.3, 39.9], [116.4, 40.0], [116.5, 39.8]], // positions
|
|
182
|
+
3 // width
|
|
183
|
+
);
|
|
184
|
+
trail.setOptions({
|
|
185
|
+
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), // 红色半透明
|
|
186
|
+
speed: 5
|
|
187
|
+
});
|
|
188
|
+
layer.addGraphic(trail);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### S4. WaterPrimitive 动态水面
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
// 来源: examples/public/examples/html/performance/wall_drawCommand2_Sci0.html L145-170
|
|
195
|
+
// positions 为 Cesium.Cartesian3[](来自 GeoJsonDataSource 的 polygon hierarchy)
|
|
196
|
+
const layer = new ANOVGIS.PrimitiveLayer();
|
|
197
|
+
viewer.addLayer(layer);
|
|
198
|
+
|
|
199
|
+
const water = new ANOVGIS.WaterPrimitive(positionCartesian3, holes);
|
|
200
|
+
water.setOptions({
|
|
201
|
+
baseWaterColor: ANOVGIS.Color.fromCssColorString('rgb(17,38,57)'),
|
|
202
|
+
frequency: 100.0, // 波浪频率
|
|
203
|
+
animationSpeed: 0.01, // 动画速度
|
|
204
|
+
amplitude: 10, // 振幅
|
|
205
|
+
specularIntensity: 0.2 // 高光强度
|
|
206
|
+
});
|
|
207
|
+
layer.addGraphic(water);
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### S5. FlowLinePrimitive 流动抛物线
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
// 来源: src/graphic/primitive/FlowLinePrimitive.js
|
|
214
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
215
|
+
const flow = new ANOVGIS.FlowLinePrimitive(
|
|
216
|
+
[[116.30, 39.90, 0], [116.40, 39.95, 200], [116.50, 39.92, 0]],
|
|
217
|
+
3, // width
|
|
218
|
+
{ speed: 5, color: Cesium.Color.CYAN.withAlpha(0.8), percent: 0.5 }
|
|
219
|
+
);
|
|
220
|
+
layer.addGraphic(flow);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### S6. DiffuseWallPrimitive 扩散墙体
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
// 来源: src/graphic/primitive/DiffuseWallPrimitive.js
|
|
227
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
228
|
+
const wall = new ANOVGIS.DiffuseWallPrimitive(
|
|
229
|
+
[[116.30, 39.90], [116.35, 39.90], [116.35, 39.95], [116.30, 39.95]],
|
|
230
|
+
{ speed: 5, color: Cesium.Color.fromCssColorString('rgba(255,200,0,0.6)'), height: 200 }
|
|
231
|
+
);
|
|
232
|
+
layer.addGraphic(wall);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
<a id="s7"></a>
|
|
236
|
+
### S7. CloudPrimitive 云层
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
// 来源: src/graphic/primitive/CloudPrimitive.js L7-18
|
|
240
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
241
|
+
const cloud = new ANOVGIS.CloudPrimitive([116.40, 39.90, 1500]);
|
|
242
|
+
cloud.setOptions({ scale: { x: 12, y: 8 } }); // 经向/纬向跨度(度)
|
|
243
|
+
layer.addGraphic(cloud); viewer.flyTo(cloud);
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### S8. LightCylinderPrimitive 光柱
|
|
247
|
+
|
|
248
|
+
```js
|
|
249
|
+
// 来源: src/graphic/primitive/LightCylinderPrimitive.js L14-25
|
|
250
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
251
|
+
const beam = new ANOVGIS.LightCylinderPrimitive(
|
|
252
|
+
[116.40, 39.90, 0], // center
|
|
253
|
+
500, // length
|
|
254
|
+
5, // topRadius
|
|
255
|
+
80 // bottomRadius
|
|
256
|
+
);
|
|
257
|
+
beam.setOptions({ color: Cesium.Color.fromCssColorString('rgba(255,200,80,1)') });
|
|
258
|
+
layer.addGraphic(beam); viewer.flyTo(beam);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### S9. ElecEllipsoidPrimitive 电磁球
|
|
262
|
+
|
|
263
|
+
```js
|
|
264
|
+
// 来源: src/graphic/primitive/ElecEllipsoidPrimitive.js L7-19
|
|
265
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
266
|
+
const elec = new ANOVGIS.ElecEllipsoidPrimitive(
|
|
267
|
+
[116.40, 39.90, 0],
|
|
268
|
+
{ x: 80, y: 80, z: 80 } // 椭球半径
|
|
269
|
+
);
|
|
270
|
+
elec.setOptions({
|
|
271
|
+
color: Cesium.Color.fromCssColorString('rgba(0,255,180,0.9)'),
|
|
272
|
+
speed: 5
|
|
273
|
+
});
|
|
274
|
+
layer.addGraphic(elec); viewer.flyTo(elec);
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### S10. BillboardPrimitive 高性能图标
|
|
278
|
+
|
|
279
|
+
```js
|
|
280
|
+
// 来源: src/graphic/primitive/BillboardPrimitive.js
|
|
281
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
282
|
+
const bb = new ANOVGIS.BillboardPrimitive(
|
|
283
|
+
[116.40, 39.90],
|
|
284
|
+
{
|
|
285
|
+
image: './assets/camera.png',
|
|
286
|
+
scale: 1.0,
|
|
287
|
+
color: Cesium.Color.WHITE,
|
|
288
|
+
scaleByDistance: new Cesium.NearFarScalar(100, 1.0, 10000, 0.1)
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
layer.addGraphic(bb);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### S11. BounceBillboardPrimitive 弹跳图标
|
|
295
|
+
|
|
296
|
+
```js
|
|
297
|
+
// 来源: src/graphic/primitive/BounceBillboardPrimitive.js L5-39
|
|
298
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
299
|
+
const bb = new ANOVGIS.BounceBillboardPrimitive(
|
|
300
|
+
[116.40, 39.90],
|
|
301
|
+
ANOVGIS.ShapeUtil.drawCanvalCircle('#ff5500', 48, ['告警'])
|
|
302
|
+
);
|
|
303
|
+
bb.size = [48, 48];
|
|
304
|
+
bb.setOptions({ maxOffsetY: 12, offsetAmount: 0.6 });
|
|
305
|
+
layer.addGraphic(bb);
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### S12. BounceLabelPrimitive 弹跳文字
|
|
309
|
+
|
|
310
|
+
```js
|
|
311
|
+
// 来源: src/graphic/primitive/BounceLabelPrimitive.js L5-39
|
|
312
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
313
|
+
const lb = new ANOVGIS.BounceLabelPrimitive([116.40, 39.91], '弹跳标签');
|
|
314
|
+
lb.setOptions({
|
|
315
|
+
maxOffsetY: 8, offsetAmount: 0.4,
|
|
316
|
+
font: '20px sans-serif',
|
|
317
|
+
fillColor: Cesium.Color.YELLOW,
|
|
318
|
+
outlineColor: Cesium.Color.BLACK, outlineWidth: 2,
|
|
319
|
+
style: Cesium.LabelStyle.FILL_AND_OUTLINE
|
|
320
|
+
});
|
|
321
|
+
layer.addGraphic(lb);
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### S13. LabelPrimitive 高性能文字
|
|
325
|
+
|
|
326
|
+
```js
|
|
327
|
+
// 来源: src/graphic/primitive/LabelPrimitive.js
|
|
328
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
329
|
+
const lb = new ANOVGIS.LabelPrimitive([116.40, 39.90], {
|
|
330
|
+
text: '高性能文字',
|
|
331
|
+
font: '30px sans-serif',
|
|
332
|
+
fillColor: Cesium.Color.WHITE,
|
|
333
|
+
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
334
|
+
outlineColor: Cesium.Color.BLACK, outlineWidth: 2,
|
|
335
|
+
scaleByDistance: new Cesium.NearFarScalar(100, 1.0, 10000, 0.1)
|
|
336
|
+
});
|
|
337
|
+
layer.addGraphic(lb);
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### S14. PointPrimitive 高性能点
|
|
341
|
+
|
|
342
|
+
```js
|
|
343
|
+
// 来源: src/graphic/primitive/PointPrimitive.js
|
|
344
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
345
|
+
const pt = new ANOVGIS.PointPrimitive([116.40, 39.90], {
|
|
346
|
+
color: Cesium.Color.RED,
|
|
347
|
+
pixelSize: 12,
|
|
348
|
+
outlineColor: Cesium.Color.WHITE,
|
|
349
|
+
outlineWidth: 2,
|
|
350
|
+
scaleByDistance: new Cesium.NearFarScalar(100, 1.0, 10000, 0.1)
|
|
351
|
+
});
|
|
352
|
+
layer.addGraphic(pt);
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### S15. PolylinePrimitive 高性能折线
|
|
356
|
+
|
|
357
|
+
```js
|
|
358
|
+
// 来源: src/graphic/primitive/PolylinePrimitive.js
|
|
359
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
360
|
+
const line = new ANOVGIS.PolylinePrimitive(
|
|
361
|
+
[[116.30, 39.90], [116.40, 39.95], [116.50, 39.92]],
|
|
362
|
+
{ width: 3, material: Cesium.Color.YELLOW, clampToGround: false }
|
|
363
|
+
);
|
|
364
|
+
layer.addGraphic(line);
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### S16. GroundPolygonPrimitive 贴地形面
|
|
368
|
+
|
|
369
|
+
```js
|
|
370
|
+
// 来源: src/graphic/primitive/GroundPolygonPrimitive.js
|
|
371
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
372
|
+
const positions = Cesium.Cartesian3.fromDegreesArray([
|
|
373
|
+
116.30, 39.90, 116.35, 39.90, 116.35, 39.95, 116.30, 39.95
|
|
374
|
+
]);
|
|
375
|
+
const ground = new ANOVGIS.GroundPolygonPrimitive(
|
|
376
|
+
new Cesium.PolygonHierarchy(positions),
|
|
377
|
+
{ material: Cesium.Color.fromCssColorString('rgba(0,200,0,0.5)') }
|
|
378
|
+
);
|
|
379
|
+
layer.addGraphic(ground);
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### S17. GroundPolylinePrimitive 贴地形折线
|
|
383
|
+
|
|
384
|
+
```js
|
|
385
|
+
// 来源: src/graphic/primitive/GroundPolylinePrimitive.js
|
|
386
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
387
|
+
const positions = Cesium.Cartesian3.fromDegreesArray([
|
|
388
|
+
116.30, 39.90, 116.35, 39.90, 116.40, 39.95
|
|
389
|
+
]);
|
|
390
|
+
const groundLine = new ANOVGIS.GroundPolylinePrimitive(positions, {
|
|
391
|
+
width: 3, material: Cesium.Color.YELLOW
|
|
392
|
+
});
|
|
393
|
+
layer.addGraphic(groundLine);
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### S18. ModelPrimitive 自定义 Primitive 容器
|
|
397
|
+
|
|
398
|
+
```js
|
|
399
|
+
// 来源: src/graphic/primitive/ModelPrimitive.js
|
|
400
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
401
|
+
const model = new ANOVGIS.ModelPrimitive({
|
|
402
|
+
url: '/data/model.glb',
|
|
403
|
+
scale: 1.0,
|
|
404
|
+
minimumPixelSize: 64,
|
|
405
|
+
maximumScale: 1.0
|
|
406
|
+
});
|
|
407
|
+
model.setOptions({ color: Cesium.Color.fromCssColorString('rgba(255,200,0,0.8)') });
|
|
408
|
+
layer.addGraphic(model);
|
|
409
|
+
viewer.flyTo(model, 2.0, 0, Cesium.Math.toRadians(-45), 0);
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### S19. ModelCollectionPrimitive 多模型集合
|
|
413
|
+
|
|
414
|
+
```js
|
|
415
|
+
// 来源: src/graphic/primitive/ModelCollectionPrimitive.js
|
|
416
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
417
|
+
const collection = new ANOVGIS.ModelCollectionPrimitive({
|
|
418
|
+
models: [
|
|
419
|
+
{ url: '/data/tree.glb', position: [116.40, 39.90, 0], scale: 2.0 },
|
|
420
|
+
{ url: '/data/tree.glb', position: [116.41, 39.90, 0], scale: 1.5 },
|
|
421
|
+
{ url: '/data/tree.glb', position: [116.42, 39.91, 0], scale: 2.5 }
|
|
422
|
+
]
|
|
423
|
+
});
|
|
424
|
+
layer.addGraphic(collection);
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### S20. VideoPrimitive 视频贴图
|
|
428
|
+
|
|
429
|
+
```js
|
|
430
|
+
// 来源: src/graphic/primitive/VideoPrimitive.js
|
|
431
|
+
const layer = new ANOVGIS.PrimitiveLayer().addTo(viewer);
|
|
432
|
+
const video = new ANOVGIS.VideoPrimitive({
|
|
433
|
+
url: '/data/sample.mp4',
|
|
434
|
+
positions: Cesium.Cartesian3.fromDegreesArray([
|
|
435
|
+
116.30, 39.90, 116.35, 39.90, 116.35, 39.95, 116.30, 39.95
|
|
436
|
+
]),
|
|
437
|
+
scale: 1.0
|
|
438
|
+
});
|
|
439
|
+
layer.addGraphic(video);
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### S21. v1.8.6 boundingSphere 自动定位(flyTo 0-range)
|
|
443
|
+
|
|
444
|
+
```js
|
|
445
|
+
// 来源: v1.8.6 起 viewer.flyTo 支持 Primitive + range=0 内部兜底
|
|
446
|
+
// 示例:将所有 Primitive 集中定位
|
|
447
|
+
const allPrimitives = layer.points.values.concat(
|
|
448
|
+
layer.billboards.values,
|
|
449
|
+
layer.primitives.values
|
|
450
|
+
);
|
|
451
|
+
allPrimitives.forEach(p => {
|
|
452
|
+
viewer.flyTo(p, 2.0, 0, Cesium.Math.toRadians(-45), 0); // range=0 自动取 boundingSphere
|
|
453
|
+
});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## 5. 反模式
|
|
459
|
+
|
|
460
|
+
| 错误 | 后果 | 正确做法 |
|
|
461
|
+
|---|---|---|
|
|
462
|
+
| Primitive 与 `*MaterialProperty` 混用同一图元 | 视觉叠加 / 性能浪费 / 样式错乱 | 二选一,按 §3 表选择 |
|
|
463
|
+
| 不用 `PrimitiveLayer` 直接 `addGraphic(primitive)` | 无法触发事件 / 难以批量管理 | 必须 `viewer.addLayer(new ANOVGIS.PrimitiveLayer())` |
|
|
464
|
+
| `viewer.flyTo(primitive, 2, 0, -45, 0)` range 写 0 但 v1.8.5 之前 | 黑屏(无 boundingSphere) | 升级 SDK 到 v1.8.6+ 或手动计算 range |
|
|
465
|
+
| 大量 Primitive(>10000)不分批 | 卡顿 / 帧率下降 | 改用 `PrimitiveCollection` 集合,或降到 `VectorLayer` |
|
|
466
|
+
| `primitive.setOptions({ color: someColor.red })` 改子字段 | P5 陷阱,uniform 不更新 | `primitive.setOptions({ color: new Cesium.Color(...) })` 整体赋值 |
|
|
467
|
+
| 用 Primitive 跑时序动画(每帧 setOptions)| 严重卡顿 | 改用 `CallbackProperty` + `*MaterialProperty` |
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## 6. 关联阅读
|
|
472
|
+
|
|
473
|
+
- 抽象类:`src/graphic/Graphic.js`
|
|
474
|
+
- Primitive 源码:`src/graphic/primitive/`(19 个 .js 文件)
|
|
475
|
+
- 容器:`src/layer/graphic/PrimitiveLayer.js`
|
|
476
|
+
- 兄弟 skill:
|
|
477
|
+
- [`anovgis-vector-graphics`](../anovgis-vector-graphics/SKILL.md) — Vector 16 + Model 2 类
|
|
478
|
+
- [`anovgis-materials`](../anovgis-materials/SKILL.md) — 18 个 `*MaterialProperty`
|
|
479
|
+
- [`anovgis-models-3dtiles`](../anovgis-models-3dtiles/SKILL.md) — `Model` / `Tileset` 加载
|
|
480
|
+
- `anovgis-custom-primitive-worker`(v0.3.0)— Cesium 原生 `DrawCommand` / `GeometryInstance` 自定义图元
|
|
481
|
+
- DOMAINS.md:`#1.1-graphic/` 拆分说明
|
|
482
|
+
- DEMO-SKILL-MAP.md:`#5-model/` 与 `#10-performance/` demo 路由
|