scene.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="scene-body">
  3. <iframe ref="ifr" id="ifr" :key="viewId" :src="`scene.html?m=1248${boothItem?(boothItem || firstView[viewId]):''}`" allowfullscreen="true" frameborder="0"></iframe>
  4. </div>
  5. </template>
  6. <script>
  7. import { region } from "@/data/raw.js";
  8. import { Booth } from "@/data/booth.js";
  9. let firstView = {};
  10. region.forEach((item) => {
  11. let { x, y, z, w } = item.firstView.panoQuaternion;
  12. firstView[item.id] = `&firstView=pano:${item.firstView.panoId},qua:${x + ", " + y + ", " + z + ", " + w}`;
  13. });
  14. export default {
  15. props: ["tourStatus"],
  16. data() {
  17. return {
  18. firstView,
  19. viewId: this.$route.params.type,
  20. boothId: this.$route.query.boothId,
  21. boothRepeat: this.$route.query.boothRepeat,
  22. };
  23. },
  24. computed: {
  25. boothItem: function() {
  26. let tmp = "";
  27. if (this.boothId) {
  28. let tt = "";
  29. let cutt = "";
  30. for (let index = 0; index < Booth.length; index++) {
  31. const item = Booth[index];
  32. tt = item.company.filter((sub) => sub.panoId == this.boothId);
  33. if (tt.length > 0) {
  34. cutt = tt[0];
  35. break;
  36. }
  37. }
  38. if (tt.length > 1 && this.boothRepeat) {
  39. cutt = tt[this.boothRepeat.split("_")[1]];
  40. }
  41. console.log(cutt);
  42. let panoQuat = cutt.firstView.split("qua:")[1];
  43. let [x, y, z, w] = panoQuat.split(",");
  44. tmp = `&firstView=pano:${cutt.panoId},qua:${x + ", " + y + ", " + z + ", " + w}`;
  45. }
  46. return tmp;
  47. },
  48. },
  49. mounted() {
  50. let ifrWindow = this.$refs.ifr.contentWindow;
  51. this.$bus.$on("ifrMessage", (data) => {
  52. if (data.events == "flyToPano") {
  53. let panoQuat = data.data.firstView.split("qua:")[1];
  54. let [x, y, z, w] = panoQuat.split(",");
  55. let fnname = "flyToPano";
  56. if (ifrWindow.player.mode == "panorama") {
  57. fnname = "blackToPano";
  58. }
  59. ifrWindow.player[fnname]({
  60. pano: ifrWindow.player.model.panos.index[data.data.panoId],
  61. quaternion: new ifrWindow.THREE.Quaternion(Number(x), Number(y), Number(z), Number(w)),
  62. });
  63. }
  64. if (data.events == "toggleTour") {
  65. ifrWindow[data.data]();
  66. if (data.data == "startAndPlay") {
  67. ifrWindow.postMessage(
  68. {
  69. source: "clickStartAndPlay",
  70. data: "clickStartAndPlay",
  71. },
  72. "*"
  73. );
  74. }
  75. }
  76. });
  77. },
  78. watch: {
  79. theme(newVal) {
  80. let currentRegion = region.find((item) => item.id == newVal);
  81. this.$refs.ifr.contentWindow.postMessage(
  82. {
  83. source: "changeTheme",
  84. data: newVal,
  85. },
  86. "*"
  87. );
  88. window.g_lock = true;
  89. if (this.$route.params.isjump == "yes") {
  90. this.$refs.ifr.contentWindow.postMessage(
  91. {
  92. source: "changeExhition",
  93. data: {
  94. quat: currentRegion.firstView.panoQuaternion,
  95. index: currentRegion.firstView.panoId,
  96. },
  97. },
  98. "*"
  99. );
  100. }
  101. },
  102. },
  103. };
  104. </script>
  105. <style lang="less" scoped>
  106. .scene-body {
  107. width: 100%;
  108. height: 100vh;
  109. overflow: hidden;
  110. > iframe {
  111. width: 100%;
  112. height: 100%;
  113. position: absolute;
  114. left: 0;
  115. right: 0;
  116. top: 0;
  117. bottom: 0;
  118. }
  119. }
  120. </style>