diff --git a/gulpfile.js b/gulpfile.js index 595d2af7..49fdb174 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -200,7 +200,12 @@ async function combineJs(options) { if (options.node && options.obfuscate) { await gulp .src('dist/index.js') - .pipe(javascriptObfuscator(obfuscatorConfig)) + .pipe( + javascriptObfuscator({ + ...obfuscatorConfig, + target: 'browser-no-eval', + }) + ) .pipe(gulp.dest('dist')) .on('end', () => { addCopyright(options) diff --git a/package.json b/package.json index 50735062..f2a640eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dvgis/dc-sdk", - "version": "3.3.0", + "version": "3.5.0", "license": "MIT", "description": "The SDK is based on Cesium for secondary development of 2, 3D all-in-one WebGis application framework, the framework optimizes the use of Cesium and add some additional features, designed for developers to quickly build WebGis applications.", "repository": "https://github.com/dvgis/dc-sdk.git", @@ -16,7 +16,7 @@ ], "author": "Caven Chen ", "type": "module", - "main": "dist/index.cjs", + "main": "dist/index.js", "scripts": { "dev": "rimraf dist && gulp dev", "build": "rimraf dist && gulp build", @@ -35,7 +35,7 @@ "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-transform-runtime": "^7.21.4", "@babel/preset-env": "^7.21.5", - "@cesium/engine": "^8.0.0", + "@cesium/engine": "^9.1.0", "chalk": "^5.2.0", "esbuild": "^0.20.1", "esbuild-plugin-glsl": "^1.2.1", @@ -67,6 +67,6 @@ "dist" ], "dependencies": { - "@dvgis/dc-common": "^1.0.0" + "@dvgis/dc-common": "^2.0.0" } } diff --git a/src/index.js b/src/index.js index 0529820d..9e1414cb 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,8 @@ const DEF_BASE_URL = './libs/dc-sdk/resources/' let _baseUrl = DEF_BASE_URL +let __isInitialized = false + export const config = { set baseUrl(baseUrl) { _baseUrl = baseUrl @@ -19,8 +21,10 @@ export const config = { } export function ready(options = {}) { + if(__isInitialized){ + return Promise.resolve() + } __cmdOut && __cmdOut() - if (options['baseUrl']) { this.config.baseUrl = options['baseUrl'] } @@ -75,6 +79,7 @@ export function ready(options = {}) { this[key] = modules[key] }) } + __isInitialized = true resolve() }).catch((e) => { throw new Error(e.message) diff --git a/src/modules/exts/Viewer.js b/src/modules/exts/Viewer.js index 221f6e6e..8de1b92d 100644 --- a/src/modules/exts/Viewer.js +++ b/src/modules/exts/Viewer.js @@ -27,6 +27,7 @@ const { Matrix4, Property, SceneMode, + ScreenSpaceEventType, TimeDynamicPointCloud, VoxelPrimitive, Color, @@ -63,7 +64,7 @@ function trackDataSourceClock(timeline, clock, dataSource) { * @property {ContextOptions} [contextOptions] Context and WebGL creation properties passed to {@link Scene}. * @property {SceneMode} [sceneMode=SceneMode.SCENE3D] The initial scene mode. * @property {MapProjection} [mapProjection=new GeographicProjection()] The map projection to use in 2D and Columbus View modes. - * @property {Globe|false} [globe=new Globe(mapProjection.ellipsoid)] The globe to use in the scene. If set to false, no globe will be added. + * @property {Globe|false} [globe=new Globe(mapProjection.ellipsoid)] The globe to use in the scene. If set to false, no globe will be added and the sky atmosphere will be hidden by default. * @property {boolean} [orderIndependentTranslucency=true] If true and the configuration supports it, use order independent translucency. * @property {Element|string} [creditContainer] The DOM element or ID that will contain the {@link CreditDisplay}. If not specified, the credits are added to the bottom of the widget itself. * @property {Element|string} [creditViewport] The DOM element or ID that will contain the credit pop up created by the {@link CreditDisplay}. If not specified, it will appear over the widget itself. @@ -794,6 +795,18 @@ Viewer.prototype.destroy = function () { let i + if ( + defined(this.screenSpaceEventHandler) && + !this.screenSpaceEventHandler.isDestroyed() + ) { + this.screenSpaceEventHandler.removeInputAction( + ScreenSpaceEventType.LEFT_CLICK + ) + this.screenSpaceEventHandler.removeInputAction( + ScreenSpaceEventType.LEFT_DOUBLE_CLICK + ) + } + // Unsubscribe from data sources const dataSources = this.dataSources const dataSourceLength = dataSources.length