From 4d2294e6b2b4801e36e1feb766b3154ff3fadeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=86=B0cc?= Date: Mon, 5 Jun 2023 14:58:48 +0800 Subject: [PATCH] release: vite-plugin-earth@2.0.5 --- demo-mars3d/index.html | 2 +- demo-mars3d/package.json | 6 ++--- demo-mars3d/src/index.ts | 45 +------------------------------------- demo-mars3d/vite.config.ts | 3 +-- package.json | 8 ++----- src/index.ts | 21 +++++++++--------- 6 files changed, 19 insertions(+), 66 deletions(-) diff --git a/demo-mars3d/index.html b/demo-mars3d/index.html index 622651f..d3e3422 100644 --- a/demo-mars3d/index.html +++ b/demo-mars3d/index.html @@ -4,7 +4,7 @@ - mars3d-vite + demo-mars3d diff --git a/demo-mars3d/package.json b/demo-mars3d/package.json index 244c9dd..ea61b0d 100644 --- a/demo-mars3d/package.json +++ b/demo-mars3d/package.json @@ -9,12 +9,12 @@ "serve": "vite build && vite preview" }, "devDependencies": { - "vite": "^3.0.4", + "vite": "^4.3.4", "vite-plugin-earth": "link:.." }, "dependencies": { "@turf/turf": "^6.5.0", - "mars3d": "^3.5.0", - "mars3d-cesium": "^1.103.1" + "mars3d": "^3.5.4", + "mars3d-cesium": "^1.104.3" } } diff --git a/demo-mars3d/src/index.ts b/demo-mars3d/src/index.ts index 2cd0b26..1bad941 100644 --- a/demo-mars3d/src/index.ts +++ b/demo-mars3d/src/index.ts @@ -8,47 +8,4 @@ import 'mars3d/dist/mars3d.css'; * * */ -const map = new mars3d.Map('mars3dContainer', { - scene: { - center: { lat: 30.054604, lng: 108.885436, alt: 17036414, heading: 0, pitch: -90 }, - showSun: true, - showMoon: true, - showSkyBox: true, - showSkyAtmosphere: false, // 关闭球周边的白色轮廓 map.scene.skyAtmosphere = false - fog: true, - fxaa: true, - globe: { - showGroundAtmosphere: false, // 关闭大气(球表面白蒙蒙的效果) - depthTestAgainstTerrain: false, - baseColor: '#546a53' - }, - cameraController: { - zoomFactor: 3.0, - minimumZoomDistance: 1, - maximumZoomDistance: 50000000, - enableRotate: true, - enableZoom: true - } - }, - control: { - baseLayerPicker: true, // basemaps底图切换按钮 - homeButton: true, // 视角复位按钮 - sceneModePicker: true, // 二三维切换按钮 - navigationHelpButton: true, // 帮助按钮 - fullscreenButton: true, // 全屏按钮 - contextmenu: { hasDefault: true } // 右键菜单 - }, - terrain: { - url: '//data.mars3d.cn/terrain', - show: true - }, - basemaps: [ - { - name: '天地图影像', - icon: 'img/basemaps/tdt_img.png', - type: 'tdt', - layer: 'img_d', - show: true - } - ] -}); +const map = new mars3d.Map('mars3dContainer', {}); diff --git a/demo-mars3d/vite.config.ts b/demo-mars3d/vite.config.ts index fda5548..944e1a5 100644 --- a/demo-mars3d/vite.config.ts +++ b/demo-mars3d/vite.config.ts @@ -4,8 +4,7 @@ import earth from 'vite-plugin-earth'; export default defineConfig({ plugins: [ earth({ - useMars3D: true, - useCDN: { mars3d: '3.5.1' } + useMars3D: true }) ] }); diff --git a/package.json b/package.json index c840be5..4304ca9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-earth", - "version": "2.0.4", + "version": "2.0.5", "description": "Cesium & Mars3D library plugin for Vite", "main": "./dist/index.js", "module": "./dist/index.mjs", @@ -48,13 +48,9 @@ "prettier": "^2.2.1", "tsup": "^6.2.1", "typescript": "^4.2.2", - "vite": "^3.0.4" + "vite": "^4.3.4" }, "peerDependencies": { - "cesium": "^1.95.0", - "@turf/turf": "^6.5.0", - "mars3d-cesium": "^1.90.0", - "mars3d": "^3.2.0", "vite": ">=2.7.1" } } diff --git a/src/index.ts b/src/index.ts index 06a567c..d3c561d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,12 +13,13 @@ interface VitePluginEarthOptions { cesiumBuildRootPath?: string; cesiumBuildPath?: string; useMars3D?: boolean; - useCDN?: { - mars3d?: string; - mars3dCesium?: string; - cesium?: string; - turf?: string; - }; + useCDN?: + | { + mars3d?: string; + mars3dCesium?: string; + turf?: string; + } + | { cesium?: string }; } export default function vitePluginEarth(options: VitePluginEarthOptions = {}): Plugin { @@ -27,14 +28,14 @@ export default function vitePluginEarth(options: VitePluginEarthOptions = {}): P rebuildCesium = false, devMinifyCesium = false, cesiumBuildRootPath = `node_modules/${CESIUM_NAME}/Build`, - cesiumBuildPath = `node_modules/${CESIUM_NAME}/Build/Cesium/`, + cesiumBuildPath = `${cesiumBuildRootPath}/Cesium/`, useMars3D = false, useCDN = null } = options; // 默认使用的版本号 let cdnVersion = Object.assign( - { mars3d: '3.5.0', mars3dCesium: '1.103.1', cesium: '1.103.0', turf: '6.5.0' }, + { mars3d: '3.5.0', mars3dCesium: '1.103.1', cesium: '1.105.0', turf: '6.5.0' }, useCDN ); @@ -80,7 +81,7 @@ export default function vitePluginEarth(options: VitePluginEarthOptions = {}): P }; } else { // build 2) copy Cesium.js later - let external = ['cesium']; + let external = [CESIUM_NAME]; let plugins = [externalGlobals({ cesium: 'Cesium' })]; if (useMars3D) { @@ -191,7 +192,7 @@ export default function vitePluginEarth(options: VitePluginEarthOptions = {}): P tags.push({ tag: 'script', attrs: { - src: normalizePath(path.join(CESIUM_BASE_URL, 'Cesium.js')) + src: normalizePath(path.join(base, `${CESIUM_NAME}/Cesium.js`)) } }); }