import { params, showTaggingPositionsStack } from "@/env"; import { sdk, getTaggingPosNode, playSceneGuide, pauseSceneGuide } from "@/sdk"; import { getPathNode, pauseScenePath, playScenePath } from "@/sdk/association/path"; import { getFuseModel, getFuseModelShowVariable, getGuidePaths, getTaggingPositions, guides, paths, Tagging, taggings, } from "@/store"; import { nextTick, ref, toRaw } from "vue"; import store from './data' export const data = store[params.caseId as unknown as "573"]; export const getLinkAttr = (name: string, type?: string) => { const t = taggings.value.find((t) => t.title.trim() === name.trim()); if (t) { return "./images/point.png"; } const p = paths.value.find((p) => p.name.trim() === name.trim()); if (p) { if (type === 'point') { return "./images/point.png"; } else { return "./images/video.png"; } } const g = guides.value.find((p) => p.title.trim() === name.trim()); if (g) { return "./images/video.png"; } if (name.includes('://')) { return "./images/路径@1x (2).png" } console.error(toRaw(taggings.value), toRaw(guides.value), toRaw(paths.value), name) console.error(`找不到${name}对应的导览或热点`); }; let cleanup: (() => void) | null = null; export const flyLink = async (name: string, type?: string) => { cleanup && cleanup(); const t = taggings.value.find((t) => t.title.trim() === name.trim()); if (t) { cleanup = flyTaggingPositions(t); return; } const p = paths.value.find((p) => p.name.trim() === name.trim()); if (p) { if (type === 'point') { getPathNode(p.id)?.fly() return; } else { cleanup = pauseScenePath; await playScenePath(p, true); cleanup = null; return; } } const g = guides.value.find((p) => p.title.trim() === name.trim()); if (g) { cleanup = pauseSceneGuide; await playSceneGuide(getGuidePaths(g), undefined, false); cleanup = null; return; } if (name.includes('://')) { window.open(name) } }; const flyTaggingPositions = (tagging: Tagging, callback?: () => void) => { const positions = getTaggingPositions(tagging); let isStop = false; const flyIndex = (i: number) => { if (isStop || i >= positions.length) { callback && nextTick(callback); return; } const position = positions[i]; const model = getFuseModel(position.modelId); if (!model || !getFuseModelShowVariable(model).value) { flyIndex(i + 1); return; } const pop = showTaggingPositionsStack.push(ref(new WeakSet([position]))); sdk.comeTo({ position: getTaggingPosNode(position)!.getImageCenter(), modelId: position.modelId, dur: 300, // distance: 3, maxDis:15, isFlyToTag: true }); setTimeout(() => { pop(); flyIndex(i + 1); }, 2000); }; flyIndex(0); return () => (isStop = true); };