cesium-xs-sdk 1.0.0
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 +104 -0
- package/dist/cesium-xs-sdk.cjs.js +7387 -0
- package/dist/cesium-xs-sdk.cjs.js.map +1 -0
- package/dist/cesium-xs-sdk.esm.js +7383 -0
- package/dist/cesium-xs-sdk.esm.js.map +1 -0
- package/dist/cesium-xs-sdk.umd.js +2 -0
- package/dist/cesium-xs-sdk.umd.js.map +1 -0
- package/package.json +78 -0
- package/src/core/Config.js +176 -0
- package/src/core/ModuleManager.js +157 -0
- package/src/index.d.ts +358 -0
- package/src/index.js +59 -0
- package/src/modules/EditorModule.js +370 -0
- package/src/modules/EventModule.js +211 -0
- package/src/modules/GraphicModule.js +1037 -0
- package/src/modules/PlotGraphicType.js +43 -0
- package/src/modules/SceneModule.js +600 -0
- package/src/modules/tools/BaseTool.js +155 -0
- package/src/modules/tools/DeleteTool.js +252 -0
- package/src/modules/tools/DrawTool.js +961 -0
- package/src/modules/tools/EditTool.js +1585 -0
- package/src/modules/tools/SelectTool.js +526 -0
- package/src/react.d.ts +18 -0
- package/src/react.js +49 -0
- package/src/utils/CoordinateUtil.js +63 -0
- package/src/utils/GeoCalcUtil.js +95 -0
- package/src/utils/PlotGeometryUtil.js +1134 -0
- package/src/vue.d.ts +18 -0
- package/src/vue.js +76 -0
- package/src/vue2.d.ts +20 -0
- package/src/vue2.js +75 -0
package/src/vue.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ModuleManager, SceneModule, GraphicModule, EventModule, EditorModule } from './index.js';
|
|
2
|
+
|
|
3
|
+
export interface UseXs3dResult {
|
|
4
|
+
sdk: any;
|
|
5
|
+
viewer: any;
|
|
6
|
+
sceneModule: any;
|
|
7
|
+
graphicModule: any;
|
|
8
|
+
eventModule: any;
|
|
9
|
+
editorModule: any;
|
|
10
|
+
isReady: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useXs3d(
|
|
14
|
+
container: string | { value?: string; element?: { value?: string | HTMLElement } },
|
|
15
|
+
options?: Record<string, any>
|
|
16
|
+
): UseXs3dResult;
|
|
17
|
+
|
|
18
|
+
export default useXs3d;
|
package/src/vue.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue 3 适配器
|
|
3
|
+
* 提供 useXs3d 组合式函数,管理 SDK 初始化与销毁生命周期
|
|
4
|
+
*/
|
|
5
|
+
import { ref, shallowRef, onMounted, onUnmounted } from 'vue';
|
|
6
|
+
import xs3d from './index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 在 Vue 组件中使用 XS 3D SDK
|
|
10
|
+
* @param {string|Ref<string>} container 容器元素 ID,或传 { element: ref } 直接使用 DOM 引用
|
|
11
|
+
* @param {Object} options 初始化配置(同 xs3d.init)
|
|
12
|
+
* @returns {Object}
|
|
13
|
+
* - sdk: SDK 根实例(shallowRef)
|
|
14
|
+
* - viewer: Cesium Viewer(shallowRef)
|
|
15
|
+
* - sceneModule, graphicModule, eventModule, editorModule: 各模块(shallowRef)
|
|
16
|
+
* - isReady: 是否初始化完成(ref)
|
|
17
|
+
*/
|
|
18
|
+
export function useXs3d(container, options = {}) {
|
|
19
|
+
const sdk = shallowRef(null);
|
|
20
|
+
const viewer = shallowRef(null);
|
|
21
|
+
const sceneModule = shallowRef(null);
|
|
22
|
+
const graphicModule = shallowRef(null);
|
|
23
|
+
const eventModule = shallowRef(null);
|
|
24
|
+
const editorModule = shallowRef(null);
|
|
25
|
+
const isReady = ref(false);
|
|
26
|
+
|
|
27
|
+
let instance = null;
|
|
28
|
+
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
// 支持传入 ref 或直接传 id
|
|
31
|
+
const target = typeof container === 'string'
|
|
32
|
+
? container
|
|
33
|
+
: container?.value ?? container?.element?.value;
|
|
34
|
+
|
|
35
|
+
if (!target) {
|
|
36
|
+
console.warn('useXs3d: container 未定义,跳过初始化');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
instance = xs3d.init(target, options);
|
|
41
|
+
|
|
42
|
+
sdk.value = instance;
|
|
43
|
+
viewer.value = instance.viewer;
|
|
44
|
+
sceneModule.value = instance.sceneModule;
|
|
45
|
+
graphicModule.value = instance.graphicModule;
|
|
46
|
+
eventModule.value = instance.eventModule;
|
|
47
|
+
editorModule.value = instance.editorModule;
|
|
48
|
+
isReady.value = true;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
onUnmounted(() => {
|
|
52
|
+
if (instance) {
|
|
53
|
+
xs3d.destroy();
|
|
54
|
+
instance = null;
|
|
55
|
+
sdk.value = null;
|
|
56
|
+
viewer.value = null;
|
|
57
|
+
sceneModule.value = null;
|
|
58
|
+
graphicModule.value = null;
|
|
59
|
+
eventModule.value = null;
|
|
60
|
+
editorModule.value = null;
|
|
61
|
+
isReady.value = false;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
sdk,
|
|
67
|
+
viewer,
|
|
68
|
+
sceneModule,
|
|
69
|
+
graphicModule,
|
|
70
|
+
eventModule,
|
|
71
|
+
editorModule,
|
|
72
|
+
isReady
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default useXs3d;
|
package/src/vue2.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="cesium" />
|
|
2
|
+
|
|
3
|
+
import type { ModuleManager, SceneModule, GraphicModule, EventModule, EditorModule } from './index.js';
|
|
4
|
+
|
|
5
|
+
export interface UseXs3dResult {
|
|
6
|
+
sdk: any;
|
|
7
|
+
viewer: any;
|
|
8
|
+
sceneModule: any;
|
|
9
|
+
graphicModule: any;
|
|
10
|
+
eventModule: any;
|
|
11
|
+
editorModule: any;
|
|
12
|
+
isReady: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function useXs3d(
|
|
16
|
+
container: string | { value?: string; element?: { value?: string | HTMLElement } },
|
|
17
|
+
options?: Record<string, any>
|
|
18
|
+
): UseXs3dResult;
|
|
19
|
+
|
|
20
|
+
export default useXs3d;
|
package/src/vue2.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue 2 适配器(需配合 @vue/composition-api 或 Vue 2.7 使用)
|
|
3
|
+
* 提供 useXs3d 组合式函数,管理 SDK 初始化与销毁生命周期
|
|
4
|
+
*/
|
|
5
|
+
import { ref, shallowRef, onMounted, onUnmounted } from '@vue/composition-api';
|
|
6
|
+
import xs3d from './index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 在 Vue 2 组件中使用 XS 3D SDK
|
|
10
|
+
* @param {string|Ref<string>} container 容器元素 ID,或包含 element ref 的对象
|
|
11
|
+
* @param {Object} options 初始化配置(同 xs3d.init)
|
|
12
|
+
* @returns {Object}
|
|
13
|
+
* - sdk: SDK 根实例(shallowRef)
|
|
14
|
+
* - viewer: Cesium Viewer(shallowRef)
|
|
15
|
+
* - sceneModule, graphicModule, eventModule, editorModule: 各模块(shallowRef)
|
|
16
|
+
* - isReady: 是否初始化完成(ref)
|
|
17
|
+
*/
|
|
18
|
+
export function useXs3d(container, options = {}) {
|
|
19
|
+
const sdk = shallowRef(null);
|
|
20
|
+
const viewer = shallowRef(null);
|
|
21
|
+
const sceneModule = shallowRef(null);
|
|
22
|
+
const graphicModule = shallowRef(null);
|
|
23
|
+
const eventModule = shallowRef(null);
|
|
24
|
+
const editorModule = shallowRef(null);
|
|
25
|
+
const isReady = ref(false);
|
|
26
|
+
|
|
27
|
+
let instance = null;
|
|
28
|
+
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
const target = typeof container === 'string'
|
|
31
|
+
? container
|
|
32
|
+
: container?.value ?? container?.element?.value;
|
|
33
|
+
|
|
34
|
+
if (!target) {
|
|
35
|
+
console.warn('useXs3d (Vue 2): container 未定义,跳过初始化');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
instance = xs3d.init(target, options);
|
|
40
|
+
|
|
41
|
+
sdk.value = instance;
|
|
42
|
+
viewer.value = instance.viewer;
|
|
43
|
+
sceneModule.value = instance.sceneModule;
|
|
44
|
+
graphicModule.value = instance.graphicModule;
|
|
45
|
+
eventModule.value = instance.eventModule;
|
|
46
|
+
editorModule.value = instance.editorModule;
|
|
47
|
+
isReady.value = true;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
onUnmounted(() => {
|
|
51
|
+
if (instance) {
|
|
52
|
+
xs3d.destroy();
|
|
53
|
+
instance = null;
|
|
54
|
+
sdk.value = null;
|
|
55
|
+
viewer.value = null;
|
|
56
|
+
sceneModule.value = null;
|
|
57
|
+
graphicModule.value = null;
|
|
58
|
+
eventModule.value = null;
|
|
59
|
+
editorModule.value = null;
|
|
60
|
+
isReady.value = false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
sdk,
|
|
66
|
+
viewer,
|
|
67
|
+
sceneModule,
|
|
68
|
+
graphicModule,
|
|
69
|
+
eventModule,
|
|
70
|
+
editorModule,
|
|
71
|
+
isReady
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default useXs3d;
|