@mesh3d/cesium-vectortile-gl 0.4.4 → 0.4.6

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.
Files changed (51) hide show
  1. package/.gitattributes +11 -0
  2. package/.gitconfig +3 -0
  3. package/.husky/pre-commit +1 -0
  4. package/.prettierignore +5 -0
  5. package/.vscode/settings.json +25 -0
  6. package/LICENSE.md +203 -203
  7. package/README.md +202 -167
  8. package/Source/Cesium.d.ts +2692 -2691
  9. package/Source/VectorTileLOD.js +720 -532
  10. package/Source/VectorTileRenderList.js +70 -70
  11. package/Source/VectorTileset.js +473 -447
  12. package/Source/layers/BackgroundRenderLayer.js +91 -89
  13. package/Source/layers/FillRenderLayer.js +18 -18
  14. package/Source/layers/IRenderLayer.js +160 -152
  15. package/Source/layers/LineRenderLayer.js +104 -94
  16. package/Source/layers/SymbolRenderLayer.js +30 -31
  17. package/Source/layers/index.js +23 -16
  18. package/Source/layers/registerRenderLayer.js +24 -24
  19. package/Source/layers/visualizers/FillLayerVisualizer.js +542 -426
  20. package/Source/layers/visualizers/ILayerVisualizer.js +90 -94
  21. package/Source/layers/visualizers/LineLayerVisualizer.js +702 -571
  22. package/Source/layers/visualizers/SymbolLayerVisualizer.js +514 -244
  23. package/Source/sources/GeoJSONSource.js +53 -46
  24. package/Source/sources/ISource.js +39 -39
  25. package/Source/sources/VectorSource.js +94 -52
  26. package/Source/sources/granularitySettings.js +23 -20
  27. package/Source/sources/index.js +6 -11
  28. package/Source/sources/registerSource.js +17 -19
  29. package/Source/style/StyleLayer.js +43 -43
  30. package/Source/style/StyleLayerProperties.js +44 -43
  31. package/Source/style/index.js +2 -2
  32. package/Source/symbol/SymbolPlacements.js +117 -88
  33. package/Source/workers/VectorTileWorker.js +41 -0
  34. package/Source/workers/ellipsoid.js +47 -0
  35. package/Source/workers/processTileTask.js +329 -0
  36. package/Source/workers/styleEvaluator.js +168 -0
  37. package/benchmark.html +148 -0
  38. package/dist/cvt-gl-worker.js +9274 -0
  39. package/dist/cvt-gl-worker.js.map +1 -0
  40. package/dist/cvt-gl.js +2570 -2001
  41. package/dist/cvt-gl.js.map +1 -1
  42. package/dist/cvt-gl.min.js +3 -3
  43. package/dist/cvt-gl.min.js.map +1 -1
  44. package/eslint.config.mjs +58 -0
  45. package/index.js +9 -6
  46. package/mlt.html +26 -25
  47. package/package.json +64 -41
  48. package/prettier.config.mjs +30 -0
  49. package/vite.config.mjs +43 -0
  50. package/vite.worker.config.mjs +31 -0
  51. package/worker.html +26 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * ESLint 扁平配置(Flat Config)
3
+ * @see https://eslint.org/docs/latest/use/configure/configuration-files
4
+ */
5
+ import js from '@eslint/js'
6
+ import prettier from 'eslint-config-prettier'
7
+
8
+ export default [
9
+ {
10
+ ignores: [
11
+ 'dist/**',
12
+ 'node_modules/**',
13
+ '*.config.js',
14
+ '*.config.mjs',
15
+ '*.config.cjs',
16
+ 'vite.config.js',
17
+ 'Cesium.d.ts'
18
+ ]
19
+ },
20
+ js.configs.recommended,
21
+ prettier,
22
+ {
23
+ files: ['**/*.js'],
24
+ languageOptions: {
25
+ ecmaVersion: 'latest',
26
+ sourceType: 'module',
27
+ globals: {
28
+ Cesium: 'readonly',
29
+ // 浏览器 / 运行环境全局
30
+ window: 'readonly',
31
+ document: 'readonly',
32
+ fetch: 'readonly',
33
+ console: 'readonly',
34
+ requestAnimationFrame: 'readonly',
35
+ devicePixelRatio: 'readonly',
36
+ URL: 'readonly',
37
+ performance: 'readonly',
38
+ setTimeout: 'readonly'
39
+ }
40
+ },
41
+ rules: {
42
+ // 代码风格由 Prettier 统一处理
43
+ 'no-unused-vars': [
44
+ 'warn',
45
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
46
+ ],
47
+ 'no-empty': ['warn', { allowEmptyCatch: true }]
48
+ }
49
+ },
50
+ {
51
+ files: ['Source/workers/**/*.js'],
52
+ languageOptions: {
53
+ globals: {
54
+ self: 'readonly'
55
+ }
56
+ }
57
+ }
58
+ ]
package/index.js CHANGED
@@ -1,6 +1,9 @@
1
- export * from "./Source/sources";
2
- export * from "./Source/style";
3
- export * from "./Source/layers";
4
- export { VectorTileLOD } from "./Source/VectorTileLOD";
5
- export { VectorTileRenderList } from "./Source/VectorTileRenderList";
6
- export { VectorTileset } from "./Source/VectorTileset";
1
+ export * from './Source/sources'
2
+ export * from './Source/style'
3
+ export * from './Source/layers'
4
+ export { VectorTileLOD } from './Source/VectorTileLOD'
5
+ export { VectorTileRenderList } from './Source/VectorTileRenderList'
6
+ export { VectorTileset } from './Source/VectorTileset'
7
+
8
+ /** 构建产物中 Worker 脚本文件名,用于构造 workerUrl(与 cvt-gl.js 同目录) */
9
+ export const DEFAULT_WORKER_FILENAME = 'cvt-gl-worker.js'
package/mlt.html CHANGED
@@ -1,25 +1,26 @@
1
- <html lang="zh-cn">
2
-
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>CesiumJS 开源矢量瓦片渲染库</title>
7
- <link rel="shortcut icon" href="./logo.svg" type="image/svg">
8
- <link rel="stylesheet" href="./node_modules/cesium/Build/Cesium/Widgets/widgets.css">
9
- <script src="./node_modules/cesium/Build/CesiumUnminified/Cesium.js"></script>
10
- <style>
11
- html,
12
- body {
13
- width: 100%;
14
- height: 100%;
15
- margin: 0;
16
- padding: 0;
17
- }
18
- </style>
19
- </head>
20
-
21
- <body>
22
- <script type="module" src="./examples/index-mlt.js"></script>
23
- </body>
24
-
25
- </html>
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/index-mlt.js"></script>
25
+ </body>
26
+ </html>
package/package.json CHANGED
@@ -1,41 +1,64 @@
1
- {
2
- "name": "@mesh3d/cesium-vectortile-gl",
3
- "version": "0.4.4",
4
- "description": "CesiumJS 矢量瓦片渲染库",
5
- "main": "dist/cvt-gl.js",
6
- "module": "index.js",
7
- "private": false,
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "scripts": {
12
- "build": "vite build",
13
- "dev": "vite dev",
14
- "test": "echo \"Error: no test specified\" && exit 1"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/mesh-3d/cesium-vectortile-gl.git"
19
- },
20
- "author": {
21
- "name": "mesh-3d",
22
- "url": "https://github.com/mesh-3d"
23
- },
24
- "license": "Apache-2.0",
25
- "devDependencies": {
26
- "cesium": "^1.136.0",
27
- "vite": "^7.3.0",
28
- "vite-plugin-license": "^0.0.2"
29
- },
30
- "dependencies": {
31
- "@mapbox/vector-tile": "^2.0.4",
32
- "@maplibre/maplibre-gl-style-spec": "^24.4.1",
33
- "@maplibre/vt-pbf": "^4.2.0",
34
- "geojson-vt": "^4.0.2",
35
- "maplibre-gl": "^5.15.0",
36
- "pbf": "^4.0.1"
37
- },
38
- "maintainers": [
39
- "weixiuyong"
40
- ]
41
- }
1
+ {
2
+ "name": "@mesh3d/cesium-vectortile-gl",
3
+ "version": "0.4.6",
4
+ "description": "CesiumJS 矢量瓦片渲染库",
5
+ "main": "dist/cvt-gl.js",
6
+ "module": "index.js",
7
+ "private": false,
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "scripts": {
12
+ "build": "vite build && vite build --config vite.worker.config.mjs",
13
+ "dev": "vite dev",
14
+ "lint": "eslint .",
15
+ "lint:fix": "eslint . --fix",
16
+ "format": "prettier --write .",
17
+ "format:check": "prettier --check .",
18
+ "prepare": "husky",
19
+ "test": "echo \"Error: no test specified\" && exit 1"
20
+ },
21
+ "lint-staged": {
22
+ "*.js": [
23
+ "eslint --fix",
24
+ "prettier --write"
25
+ ],
26
+ "*.{json,jsonc,geojson,md,html,css,less,yml,yaml}": [
27
+ "prettier --write"
28
+ ],
29
+ "*.{mjs,cjs}": [
30
+ "prettier --write"
31
+ ]
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/mesh-3d/cesium-vectortile-gl.git"
36
+ },
37
+ "author": {
38
+ "name": "mesh-3d",
39
+ "url": "https://github.com/mesh-3d"
40
+ },
41
+ "license": "Apache-2.0",
42
+ "devDependencies": {
43
+ "@eslint/js": "^9.15.0",
44
+ "cesium": "^1.136.0",
45
+ "eslint": "^9.15.0",
46
+ "eslint-config-prettier": "^9.1.0",
47
+ "husky": "^9.1.7",
48
+ "lint-staged": "^15.4.3",
49
+ "prettier": "^3.4.2",
50
+ "vite": "^7.3.0",
51
+ "vite-plugin-license": "^0.0.2"
52
+ },
53
+ "dependencies": {
54
+ "@mapbox/vector-tile": "^2.0.4",
55
+ "@maplibre/maplibre-gl-style-spec": "^24.4.1",
56
+ "@maplibre/vt-pbf": "^4.2.0",
57
+ "geojson-vt": "^4.0.2",
58
+ "maplibre-gl": "^5.15.0",
59
+ "pbf": "^4.0.1"
60
+ },
61
+ "maintainers": [
62
+ "weixiuyong"
63
+ ]
64
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * prettier 配置文件
3
+ * @see https://prettier.io/docs/en/options.html
4
+ * @type {import("prettier").Config}
5
+ */
6
+ const config = {
7
+ arrowParens: 'avoid',
8
+ bracketSpacing: true,
9
+ endOfLine: 'lf', // 统一为 LF(可选:crlf | auto)
10
+
11
+ // 为 JSON/JSONC 文件单独配置(兼容 JSON 语法)
12
+ overrides: [
13
+ {
14
+ files: ['*.json', '*.jsonc', '*.geojson'], // 匹配 JSON/JSONC 文件
15
+ options: {
16
+ parser: 'json', // 指定 JSON 解析器
17
+ singleQuote: false, // JSON 必须用双引号,禁用单引号
18
+ trailingComma: 'none' // 避免 JSON 末尾逗号报错
19
+ }
20
+ }
21
+ ],
22
+ printWidth: 80,
23
+ semi: false,
24
+ singleQuote: true,
25
+ tabWidth: 2,
26
+ trailingComma: 'none',
27
+ useTabs: false
28
+ }
29
+
30
+ export default config
@@ -0,0 +1,43 @@
1
+ import { defineConfig } from 'vite'
2
+ import path from 'path'
3
+ import { fileURLToPath } from 'url'
4
+ import license from 'vite-plugin-license'
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
+
8
+ // https://vitejs.dev/config/
9
+ export default defineConfig({
10
+ resolve: {
11
+ alias: {
12
+ '@': path.resolve(__dirname, 'Source')
13
+ }
14
+ },
15
+ define: {
16
+ 'process.env': {}
17
+ },
18
+ build: {
19
+ outDir: './dist',
20
+ lib: {
21
+ entry: path.resolve(__dirname, 'index.js'),
22
+ name: 'CVT',
23
+ fileName(format) {
24
+ if (format == 'es') {
25
+ return 'cvt-gl.js'
26
+ } else {
27
+ return 'cvt-gl.min.js'
28
+ }
29
+ }
30
+ },
31
+ sourcemap: true
32
+ },
33
+ esbuild: {
34
+ drop: ['debugger']
35
+ },
36
+ plugins: [
37
+ license({
38
+ thirdParty: {
39
+ output: './dist/THIRD-PARTY-LICENSES.txt'
40
+ }
41
+ })
42
+ ]
43
+ })
@@ -0,0 +1,31 @@
1
+ import { defineConfig } from 'vite'
2
+ import path from 'path'
3
+ import { fileURLToPath } from 'url'
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
6
+
7
+ /** 仅构建 Vector Tile Worker,输出到 dist/cvt-gl-worker.js */
8
+ export default defineConfig({
9
+ resolve: {
10
+ alias: {
11
+ '@': path.resolve(__dirname, 'Source')
12
+ }
13
+ },
14
+ define: {
15
+ 'process.env': {}
16
+ },
17
+ build: {
18
+ outDir: './dist',
19
+ emptyOutDir: false,
20
+ lib: {
21
+ entry: path.resolve(__dirname, 'Source/workers/VectorTileWorker.js'),
22
+ name: 'VectorTileWorker',
23
+ fileName: () => 'cvt-gl-worker.js',
24
+ formats: ['es']
25
+ },
26
+ sourcemap: true
27
+ },
28
+ esbuild: {
29
+ drop: ['debugger']
30
+ }
31
+ })
package/worker.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>矢量瓦片 - Web Worker 示例</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/index-worker.js"></script>
25
+ </body>
26
+ </html>