@mesh3d/cesium-vectortile-gl 0.4.6 → 0.5.2
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/README.md +29 -0
- package/Source/VectorTileset.js +61 -0
- package/Source/layers/BackgroundRenderLayer.js +15 -0
- package/Source/layers/FillRenderLayer.js +34 -0
- package/Source/layers/IRenderLayer.js +13 -0
- package/Source/layers/LineRenderLayer.js +43 -0
- package/Source/layers/SymbolRenderLayer.js +35 -0
- package/Source/layers/visualizers/FillLayerVisualizer.js +226 -9
- package/Source/layers/visualizers/LineLayerVisualizer.js +11 -2
- package/Source/layers/visualizers/SymbolLayerVisualizer.js +17 -3
- package/Source/style/StyleLayer.js +28 -0
- package/Source/style/StyleLayerProperties.js +22 -0
- package/logo.svg +46 -46
- package/package.json +6 -15
- package/style-edit.html +26 -0
- package/dist/THIRD-PARTY-LICENSES.txt +0 -772
- package/dist/cvt-gl-worker.js +0 -9274
- package/dist/cvt-gl-worker.js.map +0 -1
- package/dist/cvt-gl.js +0 -13706
- package/dist/cvt-gl.js.map +0 -1
- package/dist/cvt-gl.min.js +0 -135
- package/dist/cvt-gl.min.js.map +0 -1
|
@@ -92,6 +92,7 @@ export class LineLayerVisualizer extends ILayerVisualizer {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
scope.addFeature(lineFeature)
|
|
95
|
+
layer.features.push(lineFeature)
|
|
95
96
|
|
|
96
97
|
featureId++
|
|
97
98
|
}
|
|
@@ -560,6 +561,9 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
|
560
561
|
*/
|
|
561
562
|
onBatchTableCreated(batchTable) {
|
|
562
563
|
this._batchTable = batchTable
|
|
564
|
+
for (const layer of this.layers) {
|
|
565
|
+
layer._batchTable = batchTable
|
|
566
|
+
}
|
|
563
567
|
}
|
|
564
568
|
|
|
565
569
|
/**
|
|
@@ -667,6 +671,9 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
|
667
671
|
if (err.stack) console.trace(err.stack)
|
|
668
672
|
else console.error(err)
|
|
669
673
|
return
|
|
674
|
+
} finally {
|
|
675
|
+
//恢复系统的 commandList
|
|
676
|
+
frameState.commandList = preCommandList
|
|
670
677
|
}
|
|
671
678
|
|
|
672
679
|
//使用合批后的 drawCommand 创建副本,为渲染图层分配 drawCommand
|
|
@@ -678,14 +685,16 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
|
|
|
678
685
|
this.setState('error')
|
|
679
686
|
}
|
|
680
687
|
|
|
681
|
-
//恢复系统的 commandList
|
|
682
|
-
frameState.commandList = preCommandList
|
|
683
688
|
this.geometryInstances = []
|
|
684
689
|
}
|
|
685
690
|
|
|
686
691
|
if (this.primitive && frameState.camera.pitch > -1.309) {
|
|
687
692
|
warnOnce('line图层:不支持透视,建议保持相机俯仰角(pitch)小于 -75 度')
|
|
688
693
|
}
|
|
694
|
+
|
|
695
|
+
if (this._batchTable && this._batchTable._batchValuesDirty) {
|
|
696
|
+
this._batchTable.update(frameState)
|
|
697
|
+
}
|
|
689
698
|
}
|
|
690
699
|
|
|
691
700
|
destroy() {
|
|
@@ -82,7 +82,8 @@ export class SymbolLayerVisualizer extends ILayerVisualizer {
|
|
|
82
82
|
outlineWidth,
|
|
83
83
|
outlineColor,
|
|
84
84
|
textOffset,
|
|
85
|
-
textOrigin
|
|
85
|
+
textOrigin,
|
|
86
|
+
properties
|
|
86
87
|
) {
|
|
87
88
|
if (
|
|
88
89
|
!Cesium.Rectangle.contains(
|
|
@@ -116,6 +117,17 @@ export class SymbolLayerVisualizer extends ILayerVisualizer {
|
|
|
116
117
|
label.batchId = labels.length
|
|
117
118
|
labels.push(label)
|
|
118
119
|
layer.labels.push(label)
|
|
120
|
+
layer.features.push({
|
|
121
|
+
text,
|
|
122
|
+
font,
|
|
123
|
+
textSize,
|
|
124
|
+
textColor,
|
|
125
|
+
outlineWidth,
|
|
126
|
+
outlineColor,
|
|
127
|
+
textOffset,
|
|
128
|
+
textOrigin,
|
|
129
|
+
properties
|
|
130
|
+
})
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
for (const sourceFeature of features) {
|
|
@@ -229,7 +241,8 @@ export class SymbolLayerVisualizer extends ILayerVisualizer {
|
|
|
229
241
|
outlineWidth,
|
|
230
242
|
outlineColor,
|
|
231
243
|
textOffset,
|
|
232
|
-
textOrigin
|
|
244
|
+
textOrigin,
|
|
245
|
+
properties
|
|
233
246
|
)
|
|
234
247
|
} else if (geometryType == 'MultiPoint') {
|
|
235
248
|
coordinates.forEach(coord => {
|
|
@@ -242,7 +255,8 @@ export class SymbolLayerVisualizer extends ILayerVisualizer {
|
|
|
242
255
|
outlineWidth,
|
|
243
256
|
outlineColor,
|
|
244
257
|
textOffset,
|
|
245
|
-
textOrigin
|
|
258
|
+
textOrigin,
|
|
259
|
+
properties
|
|
246
260
|
)
|
|
247
261
|
})
|
|
248
262
|
} else {
|
|
@@ -21,6 +21,33 @@ export class StyleLayer {
|
|
|
21
21
|
if (layer.filter) {
|
|
22
22
|
this.filter = featureFilter(layer.filter)
|
|
23
23
|
}
|
|
24
|
+
this.paintVersion = 0
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setLayoutProperty(name, value) {
|
|
28
|
+
return this.layout.setProperty(name, value)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setPaintProperty(name, value) {
|
|
32
|
+
const changed = this.paint.setProperty(name, value)
|
|
33
|
+
if (changed) {
|
|
34
|
+
this.paintVersion++
|
|
35
|
+
}
|
|
36
|
+
return changed
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setFilter(filter) {
|
|
40
|
+
if (!filter) {
|
|
41
|
+
const changed = Cesium.defined(this.filter)
|
|
42
|
+
this.filter = null
|
|
43
|
+
delete this.data.filter
|
|
44
|
+
return changed
|
|
45
|
+
} else if (JSON.stringify(this.data.filter) !== JSON.stringify(filter)) {
|
|
46
|
+
this.data.filter = filter
|
|
47
|
+
this.filter = featureFilter(filter)
|
|
48
|
+
return true
|
|
49
|
+
}
|
|
50
|
+
return false
|
|
24
51
|
}
|
|
25
52
|
|
|
26
53
|
/**
|
|
@@ -30,6 +57,7 @@ export class StyleLayer {
|
|
|
30
57
|
* @returns
|
|
31
58
|
*/
|
|
32
59
|
convertColor(styleColor, result) {
|
|
60
|
+
if (!styleColor) return
|
|
33
61
|
const alphaScalar = styleColor.a > 0 ? 1 / styleColor.a : 1
|
|
34
62
|
if (!result) {
|
|
35
63
|
result = new Cesium.Color()
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { expression, latest } from '@maplibre/maplibre-gl-style-spec'
|
|
2
|
+
import { warnOnce } from 'maplibre-gl/src/util/util'
|
|
2
3
|
|
|
3
4
|
export class StyleLayerProperties {
|
|
4
5
|
constructor(groupName, styleProperties = {}) {
|
|
5
6
|
this.data = styleProperties
|
|
6
7
|
/**@type {Map<string,import('@maplibre/maplibre-gl-style-spec').StylePropertyExpression>} */
|
|
7
8
|
this.props = new Map()
|
|
9
|
+
this.groupName = groupName
|
|
8
10
|
|
|
9
11
|
const groupReference = latest[groupName]
|
|
10
12
|
for (const key in groupReference) {
|
|
@@ -20,6 +22,26 @@ export class StyleLayerProperties {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
setProperty(name, value) {
|
|
26
|
+
const groupReference = latest[this.groupName]
|
|
27
|
+
if (Object.hasOwnProperty.call(groupReference, name)) {
|
|
28
|
+
const reference = groupReference[name]
|
|
29
|
+
const oldValue = this.data[name]
|
|
30
|
+
if (oldValue === value) {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
const property = expression.normalizePropertyExpression(
|
|
34
|
+
!Cesium.defined(value) ? reference.default : value,
|
|
35
|
+
reference
|
|
36
|
+
)
|
|
37
|
+
this.props.set(name, property)
|
|
38
|
+
return true
|
|
39
|
+
} else {
|
|
40
|
+
warnOnce(`maplibre样式规范不支持属性:${this.groupName}.${name}`)
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
23
45
|
/**
|
|
24
46
|
* Replace tokens in a string template with values in an object
|
|
25
47
|
*
|
package/logo.svg
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
<svg width="400" height="400" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<!-- 背景透明 -->
|
|
3
|
-
<rect width="400" height="400" fill="transparent"/>
|
|
4
|
-
|
|
5
|
-
<!-- 地球:经纬线 + 瓦片网格 -->
|
|
6
|
-
<g stroke="#2196F3" stroke-width="1.5" fill="none" opacity="0.8">
|
|
7
|
-
<!-- 外圆(赤道) -->
|
|
8
|
-
<circle cx="200" cy="200" r="70" />
|
|
9
|
-
|
|
10
|
-
<!-- 经线(3条) -->
|
|
11
|
-
<path d="M200,130 A70,70 0 0,1 200,270" />
|
|
12
|
-
<path d="M200,130 A70,70 0 0,0 200,270" />
|
|
13
|
-
<line x1="130" y1="200" x2="270" y2="200" />
|
|
14
|
-
|
|
15
|
-
<!-- 瓦片网格(示意 MVT 分块) -->
|
|
16
|
-
<rect x="165" y="165" width="35" height="35" stroke-dasharray="2,2" opacity="0.6"/>
|
|
17
|
-
<rect x="200" y="165" width="35" height="35" stroke-dasharray="2,2" opacity="0.6"/>
|
|
18
|
-
<rect x="165" y="200" width="35" height="35" stroke-dasharray="2,2" opacity="0.6"/>
|
|
19
|
-
</g>
|
|
20
|
-
|
|
21
|
-
<!-- Mapbox 风格水滴(POI) -->
|
|
22
|
-
<path d="M200,165
|
|
23
|
-
C205,160 210,165 210,170
|
|
24
|
-
C210,190 200,200 200,200
|
|
25
|
-
C200,200 190,190 190,170
|
|
26
|
-
C190,165 195,160 200,165 Z"
|
|
27
|
-
fill="#2196F3" opacity="0.95"/>
|
|
28
|
-
|
|
29
|
-
<!-- 矢量数据流(从水滴延伸出的 MVT 折线) -->
|
|
30
|
-
<path d="M200,200
|
|
31
|
-
L210,210
|
|
32
|
-
L230,205
|
|
33
|
-
L250,220
|
|
34
|
-
L270,210"
|
|
35
|
-
fill="none"
|
|
36
|
-
stroke="#2196F3"
|
|
37
|
-
stroke-width="2.5"
|
|
38
|
-
stroke-linecap="round"
|
|
39
|
-
stroke-linejoin="round"/>
|
|
40
|
-
|
|
41
|
-
<!-- 项目名称 -->
|
|
42
|
-
<text x="200" y="330" text-anchor="middle"
|
|
43
|
-
font-family="ui-monospace, SFMono-Regular, 'JetBrains Mono', monospace"
|
|
44
|
-
font-size="24" fill="#2196F3" font-weight="600">
|
|
45
|
-
CVT-GL
|
|
46
|
-
</text>
|
|
1
|
+
<svg width="400" height="400" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<!-- 背景透明 -->
|
|
3
|
+
<rect width="400" height="400" fill="transparent"/>
|
|
4
|
+
|
|
5
|
+
<!-- 地球:经纬线 + 瓦片网格 -->
|
|
6
|
+
<g stroke="#2196F3" stroke-width="1.5" fill="none" opacity="0.8">
|
|
7
|
+
<!-- 外圆(赤道) -->
|
|
8
|
+
<circle cx="200" cy="200" r="70" />
|
|
9
|
+
|
|
10
|
+
<!-- 经线(3条) -->
|
|
11
|
+
<path d="M200,130 A70,70 0 0,1 200,270" />
|
|
12
|
+
<path d="M200,130 A70,70 0 0,0 200,270" />
|
|
13
|
+
<line x1="130" y1="200" x2="270" y2="200" />
|
|
14
|
+
|
|
15
|
+
<!-- 瓦片网格(示意 MVT 分块) -->
|
|
16
|
+
<rect x="165" y="165" width="35" height="35" stroke-dasharray="2,2" opacity="0.6"/>
|
|
17
|
+
<rect x="200" y="165" width="35" height="35" stroke-dasharray="2,2" opacity="0.6"/>
|
|
18
|
+
<rect x="165" y="200" width="35" height="35" stroke-dasharray="2,2" opacity="0.6"/>
|
|
19
|
+
</g>
|
|
20
|
+
|
|
21
|
+
<!-- Mapbox 风格水滴(POI) -->
|
|
22
|
+
<path d="M200,165
|
|
23
|
+
C205,160 210,165 210,170
|
|
24
|
+
C210,190 200,200 200,200
|
|
25
|
+
C200,200 190,190 190,170
|
|
26
|
+
C190,165 195,160 200,165 Z"
|
|
27
|
+
fill="#2196F3" opacity="0.95"/>
|
|
28
|
+
|
|
29
|
+
<!-- 矢量数据流(从水滴延伸出的 MVT 折线) -->
|
|
30
|
+
<path d="M200,200
|
|
31
|
+
L210,210
|
|
32
|
+
L230,205
|
|
33
|
+
L250,220
|
|
34
|
+
L270,210"
|
|
35
|
+
fill="none"
|
|
36
|
+
stroke="#2196F3"
|
|
37
|
+
stroke-width="2.5"
|
|
38
|
+
stroke-linecap="round"
|
|
39
|
+
stroke-linejoin="round"/>
|
|
40
|
+
|
|
41
|
+
<!-- 项目名称 -->
|
|
42
|
+
<text x="200" y="330" text-anchor="middle"
|
|
43
|
+
font-family="ui-monospace, SFMono-Regular, 'JetBrains Mono', monospace"
|
|
44
|
+
font-size="24" fill="#2196F3" font-weight="600">
|
|
45
|
+
CVT-GL
|
|
46
|
+
</text>
|
|
47
47
|
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mesh3d/cesium-vectortile-gl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "CesiumJS 矢量瓦片渲染库",
|
|
5
5
|
"main": "dist/cvt-gl.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -19,16 +19,9 @@
|
|
|
19
19
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
20
20
|
},
|
|
21
21
|
"lint-staged": {
|
|
22
|
-
"*.js": [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
],
|
|
26
|
-
"*.{json,jsonc,geojson,md,html,css,less,yml,yaml}": [
|
|
27
|
-
"prettier --write"
|
|
28
|
-
],
|
|
29
|
-
"*.{mjs,cjs}": [
|
|
30
|
-
"prettier --write"
|
|
31
|
-
]
|
|
22
|
+
"*.js": ["eslint --fix", "prettier --write"],
|
|
23
|
+
"*.{json,jsonc,geojson,md,html,css,less,yml,yaml}": ["prettier --write"],
|
|
24
|
+
"*.{mjs,cjs}": ["prettier --write"]
|
|
32
25
|
},
|
|
33
26
|
"repository": {
|
|
34
27
|
"type": "git",
|
|
@@ -58,7 +51,5 @@
|
|
|
58
51
|
"maplibre-gl": "^5.15.0",
|
|
59
52
|
"pbf": "^4.0.1"
|
|
60
53
|
},
|
|
61
|
-
"maintainers": [
|
|
62
|
-
|
|
63
|
-
]
|
|
64
|
-
}
|
|
54
|
+
"maintainers": ["weixiuyong"]
|
|
55
|
+
}
|
package/style-edit.html
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<html lang="zh-cn">
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="UTF-8" />
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
5
|
+
<title>样式修改示例 — CesiumJS 开源矢量瓦片渲染库</title>
|
|
6
|
+
<link rel="shortcut icon" href="./logo.svg" type="image/svg" />
|
|
7
|
+
<link
|
|
8
|
+
rel="stylesheet"
|
|
9
|
+
href="./node_modules/cesium/Build/Cesium/Widgets/widgets.css"
|
|
10
|
+
/>
|
|
11
|
+
<script src="./node_modules/cesium/Build/CesiumUnminified/Cesium.js"></script>
|
|
12
|
+
<style>
|
|
13
|
+
html,
|
|
14
|
+
body {
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<body>
|
|
24
|
+
<script type="module" src="./examples/style-edit.js"></script>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|