store.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import { params, showTaggingPositionsStack } from "@/env";
  2. import { sdk, getTaggingPosNode, playSceneGuide, pauseSceneGuide } from "@/sdk";
  3. import { getPathNode, pauseScenePath, playScenePath } from "@/sdk/association/path";
  4. import {
  5. getFuseModel,
  6. getFuseModelShowVariable,
  7. getGuidePaths,
  8. getTaggingPositions,
  9. guides,
  10. paths,
  11. Tagging,
  12. taggings,
  13. } from "@/store";
  14. import { nextTick, ref, toRaw } from "vue";
  15. import store from './data'
  16. export const data = store[params.caseId as unknown as "573"];
  17. export const getLinkAttr = (name: string, type?: string) => {
  18. const t = taggings.value.find((t) => t.title.trim() === name.trim());
  19. if (t) {
  20. return "./images/point.png";
  21. }
  22. const p = paths.value.find((p) => p.name.trim() === name.trim());
  23. if (p) {
  24. if (type === 'point') {
  25. return "./images/point.png";
  26. } else {
  27. return "./images/video.png";
  28. }
  29. }
  30. const g = guides.value.find((p) => p.title.trim() === name.trim());
  31. if (g) {
  32. return "./images/video.png";
  33. }
  34. if (name.includes('://')) {
  35. return "./images/路径@1x (2).png"
  36. }
  37. console.error(toRaw(taggings.value), toRaw(guides.value), toRaw(paths.value), name)
  38. console.error(`找不到${name}对应的导览或热点`);
  39. };
  40. let cleanup: (() => void) | null = null;
  41. export const flyLink = async (name: string, type?: string) => {
  42. cleanup && cleanup();
  43. const t = taggings.value.find((t) => t.title.trim() === name.trim());
  44. if (t) {
  45. cleanup = flyTaggingPositions(t);
  46. return;
  47. }
  48. const p = paths.value.find((p) => p.name.trim() === name.trim());
  49. if (p) {
  50. if (type === 'point') {
  51. getPathNode(p.id)?.fly()
  52. return;
  53. } else {
  54. cleanup = pauseScenePath;
  55. await playScenePath(p, true);
  56. cleanup = null;
  57. return;
  58. }
  59. }
  60. const g = guides.value.find((p) => p.title.trim() === name.trim());
  61. if (g) {
  62. cleanup = pauseSceneGuide;
  63. await playSceneGuide(getGuidePaths(g), undefined, false);
  64. cleanup = null;
  65. return;
  66. }
  67. if (name.includes('://')) {
  68. window.open(name)
  69. }
  70. };
  71. const flyTaggingPositions = (tagging: Tagging, callback?: () => void) => {
  72. const positions = getTaggingPositions(tagging);
  73. let isStop = false;
  74. const flyIndex = (i: number) => {
  75. if (isStop || i >= positions.length) {
  76. callback && nextTick(callback);
  77. return;
  78. }
  79. const position = positions[i];
  80. const model = getFuseModel(position.modelId);
  81. if (!model || !getFuseModelShowVariable(model).value) {
  82. flyIndex(i + 1);
  83. return;
  84. }
  85. const pop = showTaggingPositionsStack.push(ref(new WeakSet([position])));
  86. sdk.comeTo({
  87. position: getTaggingPosNode(position)!.getImageCenter(),
  88. modelId: position.modelId,
  89. dur: 300,
  90. // distance: 3,
  91. maxDis:15,
  92. isFlyToTag: true
  93. });
  94. setTimeout(() => {
  95. pop();
  96. flyIndex(i + 1);
  97. }, 2000);
  98. };
  99. flyIndex(0);
  100. return () => (isStop = true);
  101. };