container.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div class="canvas-layout">
  3. <p v-if="currentMeterPerPixel" class="meterPerPixel">1: {{ currentMeterPerPixel }}</p>
  4. <div class="scene-canvas" ref="sceneLayoutRef" />
  5. </div>
  6. </template>
  7. <script setup lang="ts">
  8. import { onActivated, onDeactivated, onMounted, ref, watchEffect } from "vue";
  9. import { customMap, disabledMap, setupLaser, useLoading, useParams } from "@/hook";
  10. import { store } from "@/store";
  11. import { currentApp } from "@/store/app";
  12. import { Loading } from "@kankan/components/index";
  13. import { LaserSDK, Mode } from "@/sdk";
  14. import { api } from "@/store/sync";
  15. const emit = defineEmits<{ (e: "loaded"): void }>();
  16. const sceneLayoutRef = ref<HTMLCanvasElement>();
  17. const active = ref(true);
  18. onActivated(() => (active.value = true));
  19. onDeactivated(() => (active.value = false));
  20. const handlerSDK = (sdk: LaserSDK) => {
  21. watchEffect(() => {
  22. sdk.scene.emit("visible", active.value);
  23. });
  24. };
  25. const currentMeterPerPixel = ref(0);
  26. onMounted(async () => {
  27. const sdk = await useLoading(
  28. setupLaser({
  29. sceneSelector: sceneLayoutRef.value,
  30. num: useParams().m,
  31. store: store,
  32. isDebug: useParams().test,
  33. getFileUrl: api.getFile,
  34. webSite: "",
  35. axios: null,
  36. basePath: currentApp.basePath,
  37. })
  38. );
  39. emit("loaded");
  40. sdk.scene.on("posChange", (pos) => {
  41. currentMeterPerPixel.value = pos.meterPerPixel
  42. ? Math.round(1 / pos.meterPerPixel)
  43. : null;
  44. });
  45. // 156 170
  46. // 90
  47. setTimeout(() => {
  48. watchEffect(() => {
  49. const doms = Array.from(
  50. sceneLayoutRef.value.querySelectorAll("#navCube, #home")
  51. ) as HTMLElement[];
  52. if (!disabledMap.mode) {
  53. if (customMap.mode === Mode.pano) {
  54. doms.forEach((dom) => {
  55. dom.style.display = "none";
  56. });
  57. } else {
  58. doms.forEach((dom) => {
  59. dom.style.display = "block";
  60. });
  61. }
  62. }
  63. handlerSDK(sdk);
  64. });
  65. Loading.hideAll();
  66. }, 1000);
  67. });
  68. </script>
  69. <style scoped lang="scss">
  70. .canvas-layout {
  71. width: 100%;
  72. height: 100%;
  73. position: relative;
  74. z-index: 0;
  75. }
  76. .scene-canvas {
  77. width: 100%;
  78. height: 100%;
  79. }
  80. .dire-canvas {
  81. position: absolute;
  82. right: 0;
  83. top: 0;
  84. }
  85. </style>
  86. <style lang="scss">
  87. .canvas-layout {
  88. .meterPerPixel,
  89. #navCube {
  90. position: absolute !important;
  91. right: calc(var(--boundMargin) + 10px) !important;
  92. top: calc(var(--boundMargin) + 10px) !important;
  93. z-index: 1;
  94. }
  95. #home {
  96. position: absolute !important;
  97. right: var(--boundMargin) !important;
  98. top: var(--boundMargin) !important;
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. width: 20px !important;
  103. height: 20px !important;
  104. font-family: "iconfont" !important;
  105. font-size: 20px;
  106. color: #fff;
  107. font-style: normal;
  108. -webkit-font-smoothing: antialiased;
  109. background: none !important;
  110. z-index: 2;
  111. color: #fff;
  112. transition: all 0.3s ease;
  113. &:before {
  114. content: "\e73e";
  115. pointer-events: none;
  116. }
  117. &:active {
  118. color: #3290ff;
  119. }
  120. }
  121. .meterPerPixel {
  122. text-align: center;
  123. width: 100px;
  124. color: #fff;
  125. margin-top: 100px;
  126. z-index: 999;
  127. pointer-events: none;
  128. font-weight: 400;
  129. line-height: 23px;
  130. font-size: 20px;
  131. text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.5);
  132. }
  133. }
  134. </style>