Skip to content

Commit 4e1ba16

Browse files
committed
fix: 解决了cesium1.134.0+移除掉defaultValue导致vue-cesium视图渲染出错的问题,并兼容之前的版本
1 parent 646c345 commit 4e1ba16

File tree

25 files changed

+218
-54
lines changed

25 files changed

+218
-54
lines changed

packages/components/controls/compass/CameraFlightPath.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import { AnyFunction } from '@vue-cesium/utils/types'
88
*/
99
class CameraFlightPath {
1010
static createTween(scene, options) {
11-
const { Cartesian2, Cartesian3, defaultValue, defined, DeveloperError, EasingFunction, Math: CesiumMath, SceneMode } = Cesium
11+
const { Cartesian2, Cartesian3, defined, DeveloperError, EasingFunction, Math: CesiumMath, SceneMode } = Cesium
12+
const defaultValue = Cesium.defaultValue ?? (function (a: any,b: any) {
13+
if (a !== undefined && a !== null) {
14+
return a
15+
}
16+
return b
17+
})
1218
options = defaultValue(options, {})
1319
let destination = options.destination
1420

packages/components/controls/selection-indicator/use-selection-indicatior.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ export default function (instance: VcComponentInternalInstance, props, $services
136136
ignoreSplitter,
137137
viewer
138138
) => {
139-
const { defined, defaultValue } = Cesium
139+
const { defined } = Cesium
140+
const defaultValue = Cesium.defaultValue ?? (function (a:any, b:any) {
141+
if (a !== undefined && a !== null) {
142+
return a
143+
}
144+
return b
145+
})
140146
ignoreSplitter = defaultValue(ignoreSplitter, false)
141147
const result = new PickedFeatures()
142148

packages/components/controls/status-bar/MouseCoords.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ const scratchV1 = {}
187187
const scratchV2 = {}
188188

189189
export function extendForMouseCoords() {
190-
const { Globe, GlobeSurfaceTile, BoundingSphere, defaultValue, Cartesian3, defined, DeveloperError, IntersectionTests, SceneMode } = Cesium
190+
const { Globe, GlobeSurfaceTile, BoundingSphere, Cartesian3, defined, DeveloperError, IntersectionTests, SceneMode } = Cesium
191+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
192+
if (a !== undefined && a !== null) {
193+
return a
194+
}
195+
return b
196+
})
191197
Globe.prototype.pickTriangle =
192198
Globe.prototype.pickTriangle ||
193199
function (this, ray, scene, cullBackFaces, result) {

packages/components/controls/status-bar/prettifyCoordinates.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* @Author: zouyaoji@https://github.com/zouyaoji
33
* @Date: 2021-09-16 09:28:13
4-
* @LastEditTime: 2022-05-06 13:58:28
5-
* @LastEditors: zouyaoji
4+
* @LastEditTime: 2025-11-21 15:33:00
5+
* @LastEditors: whuls <hayzlsls@163.com>
66
* @Description:
77
* @FilePath: \vue-cesium@next\packages\components\controls\status-bar\prettifyCoordinates.ts
88
*/
@@ -22,7 +22,13 @@ function prettifyCoordinates(longitude, latitude, options) {
2222
longitude: '',
2323
elevation: ''
2424
}
25-
const { defaultValue, defined } = Cesium
25+
const { defined } = Cesium
26+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
27+
if (a !== undefined && a !== null) {
28+
return a
29+
}
30+
return b
31+
})
2632
const optionsDefaulted = defaultValue(options, {})
2733
const decimal = defaultValue(optionsDefaulted.decimal, 5)
2834

packages/components/overlays/wind/customPrimitive.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ class CustomPrimitive {
3131

3232
this.outputTexture = options.outputTexture
3333

34-
this.autoClear = Cesium.defaultValue(options.autoClear, false)
34+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
35+
if (a !== undefined && a !== null) {
36+
return a
37+
}
38+
return b
39+
})
40+
this.autoClear = defaultValue(options.autoClear, false)
3541
this.preExecute = options.preExecute
3642

3743
this.show = true

packages/components/providers/amap/AMapImageryProvider.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* @Author: zouyaoji@https://github.com/zouyaoji
33
* @Date: 2022-03-30 16:10:02
4-
* @LastEditTime: 2022-05-14 17:58:20
5-
* @LastEditors: zouyaoji
4+
* @LastEditTime: 2025-11-21 15:33:00
5+
* @LastEditors: whuls <hayzlsls@163.com>
66
* @Description:
77
* @FilePath: \vue-cesium@next\packages\components\providers\amap\AMapImageryProvider.ts
88
*/
@@ -32,7 +32,13 @@ class AMapImageryProvider {
3232
_scl: any
3333
_ltype: any
3434
constructor(options) {
35-
const { Resource, defaultValue, Credit, Event } = Cesium
35+
const { Resource, Credit, Event } = Cesium
36+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
37+
if (a !== undefined && a !== null) {
38+
return a
39+
}
40+
return b
41+
})
3642
this._url = options.url
3743
const resource = (Resource as any).createIfNeeded(this._url)
3844
resource.appendForwardSlash()

packages/components/providers/baidu/BaiduMapImageryProvider.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ class BaiduMapImageryProvider {
4141
| 'grayscale'
4242
| 'hardedge'
4343
constructor(options) {
44-
const { Resource, defaultValue, Credit, Event } = Cesium
44+
const { Resource, Credit, Event } = Cesium
45+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
46+
if (a !== undefined && a !== null) {
47+
return a
48+
}
49+
return b
50+
})
4551
this._subdomains = defaultValue(options.subdomains, ['0', '1', '2', '3'])
4652
if (options.url) {
4753
this._url = options.url

packages/components/providers/baidu/BaiduMapTilingScheme.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ class BaiduMapMercatorTilingScheme {
1414
_rectangle: any
1515
resolutions: number[]
1616
constructor(options) {
17-
const { defaultValue, Ellipsoid, WebMercatorProjection, Cartesian2, Cartographic, Math: CesiumMath, Rectangle } = Cesium
17+
const { Ellipsoid, WebMercatorProjection, Cartesian2, Cartographic, Math: CesiumMath, Rectangle } = Cesium
18+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
19+
if (a !== undefined && a !== null) {
20+
return a
21+
}
22+
return b
23+
})
1824
options = options || {}
1925
this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84)
2026
this._projection = new WebMercatorProjection(this._ellipsoid)

packages/components/providers/supermap/SuperMapImageryProvider.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ class SuperMapImageryProvider {
3232
_readyPromise: any
3333
_options: any
3434
constructor(options) {
35-
const { appendForwardSlash, Credit, defaultValue, defined, DeveloperError, Event, Resource, Math } = Cesium
35+
const { appendForwardSlash, Credit, defined, DeveloperError, Event, Resource, Math } = Cesium
36+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
37+
if (a !== undefined && a !== null) {
38+
return a
39+
}
40+
return b
41+
})
3642
options = defaultValue(options, {})
3743
const { url } = options
3844
if (!defined(url)) {
@@ -312,7 +318,13 @@ function getMaximumLevelbyScale(scale) {
312318

313319
function onFulfilledRest3D(this, xmlText) {
314320
const options = parseConfigFromXmlText.call(this, xmlText)
315-
const { defaultValue, defined, GeographicTilingScheme, Math, Rectangle } = Cesium
321+
const { defined, GeographicTilingScheme, Math, Rectangle } = Cesium
322+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
323+
if (a !== undefined && a !== null) {
324+
return a
325+
}
326+
return b
327+
})
316328
this._fileExtension = defaultValue(options.fileExtentName, 'png')
317329
this._tileWidth = defaultValue(options.imageSizeWidth, 256)
318330
this._tileHeight = defaultValue(options.imageSizeHeight, 256)
@@ -422,7 +434,13 @@ function queryNodes(xmlNode, attribute, namespaceURI) {
422434
}
423435

424436
function onFulfilledTileMap(this, response) {
425-
const { Cartesian3, defaultValue, defined, GeographicTilingScheme, Math: CesiumMath, Rectangle, WebMercatorTilingScheme } = Cesium
437+
const { Cartesian3, defined, GeographicTilingScheme, Math: CesiumMath, Rectangle, WebMercatorTilingScheme } = Cesium
438+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
439+
if (a !== undefined && a !== null) {
440+
return a
441+
}
442+
return b
443+
})
426444
const coordUnit = response.prjCoordSys.coordUnit
427445
this._coordUnit = coordUnit
428446
const bounds = response.bounds

packages/components/providers/tencent/TencentImageryProvider.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import defer from '@vue-cesium/utils/defer'
33
/*
44
* @Author: zouyaoji@https://github.com/zouyaoji
55
* @Date: 2022-03-30 16:10:02
6-
* @LastEditTime: 2022-05-14 17:58:25
7-
* @LastEditors: zouyaoji
6+
* @LastEditTime: 2025-11-21 15:33:00
7+
* @LastEditors: whuls <hayzlsls@163.com>
88
* @Description:
99
* @FilePath: \vue-cesium@next\packages\components\providers\tencent\TencentImageryProvider.ts
1010
*/
@@ -33,7 +33,13 @@ class TencentImageryProvider {
3333
_readyPromise: any
3434
_style: string
3535
constructor(options) {
36-
const { Resource, defaultValue, Credit, Event } = Cesium
36+
const { Resource, Credit, Event } = Cesium
37+
const defaultValue = Cesium.defaultValue ?? (function (a: any, b: any) {
38+
if (a !== undefined && a !== null) {
39+
return a
40+
}
41+
return b
42+
})
3743
this._subdomains = options.subdomains || ['1', '2', '3']
3844
this._url = options.url || [options.protocol || '', TILE_URL[options.mapStyle] || TILE_URL['vector']].join('')
3945

0 commit comments

Comments
 (0)