|
@@ -1,7 +1,36 @@
|
|
|
-import { ref } from "vue";
|
|
|
+import { nextTick, reactive, ref, watchEffect } from "vue";
|
|
|
+import { FixPoint, fixPoints } from "./store/fixPoint";
|
|
|
+import { baseLines } from "./store/baseLine";
|
|
|
+import { MeasureAtom, MeasuresRaw, Pos, Pos3D } from "./sdk";
|
|
|
+import { list } from "./store/measure";
|
|
|
+import { PhotoRaw } from "./store/photos";
|
|
|
+import { useSDK } from "./hook";
|
|
|
+
|
|
|
+type SDKAPI = {
|
|
|
+ getFixPoints: () => FixPoint[];
|
|
|
+ getBaseLine: () => MeasureAtom;
|
|
|
+ getMeasures: () => MeasuresRaw;
|
|
|
+ photo: (callback: (data: PhotoRaw) => void) => void;
|
|
|
+ getScreenPosition: (pos3d: Pos3D) => null | Pos;
|
|
|
+};
|
|
|
|
|
|
export const loaded = ref(false);
|
|
|
-export const sdkAPI: any = {
|
|
|
- // getFixPoints
|
|
|
+export const sdkAPI = reactive({
|
|
|
+ getFixPoints: () => JSON.parse(JSON.stringify(fixPoints.value)),
|
|
|
+ getBaseLine: () => JSON.parse(JSON.stringify(baseLines.value[0])),
|
|
|
+ getMeasures: () => JSON.parse(JSON.stringify(list.value)),
|
|
|
+ getScreenPosition: (pos3d: Pos3D) => {
|
|
|
+ const sdk = useSDK();
|
|
|
+ const data = sdk.scene.getScreenByPoint(pos3d);
|
|
|
+ return data.trueSide ? JSON.parse(JSON.stringify(data.pos)) : null;
|
|
|
+ },
|
|
|
+}) as SDKAPI;
|
|
|
+
|
|
|
+(window as any).getSDK = (callback: (sdk: SDKAPI) => {}) => {
|
|
|
+ const stopWatch = watchEffect(() => {
|
|
|
+ if (loaded.value && sdkAPI.photo) {
|
|
|
+ callback({ ...sdkAPI });
|
|
|
+ nextTick(() => stopWatch());
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
-(window as any).getSDK = (callback: () => {}) => {};
|