scene.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="scene-body">
  3. <iframe
  4. ref="ifr"
  5. :src="`scene.html?m=1079${firstView[viewId]}`"
  6. allowfullscreen="true"
  7. frameborder="0"
  8. ></iframe>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. props: ["tourStatus"],
  14. data(){
  15. return {
  16. firstView: {
  17. xuting:
  18. "&firstView=pano:0,qua:-0.001489144851378805,0.8167267402741333,0.002107772549575186,0.5770188587943806",
  19. e:
  20. "&firstView=pano:30,qua:0.028523630856794317, 0.953183703881663, -0.09519870492067249, 0.2855948602103702",
  21. },
  22. viewId:this.$route.params.type
  23. }
  24. },
  25. mounted() {
  26. let ifrWindow = this.$refs.ifr.contentWindow
  27. this.$bus.$on('ifrMessage',(data)=>{
  28. if (data.events=='flyToPano') {
  29. let { x, y, z, w } = data.data.quaternion
  30. ifrWindow.player.flyToPano({
  31. pano: ifrWindow.player.model.panos.index[data.data.id],
  32. quaternion: new ifrWindow.THREE.Quaternion(x, y, z, w),
  33. });
  34. }
  35. if (data.events=='toggleTour') {
  36. console.log(ifrWindow[data.data]);
  37. ifrWindow[data.data]()
  38. }
  39. })
  40. },
  41. watch: {
  42. theme(newVal) {
  43. if (newVal == "xuting") {
  44. this.$refs.ifr.contentWindow.postMessage(
  45. {
  46. source: "changeExhition",
  47. data: {
  48. quat: [
  49. -0.001489144851378805,
  50. 0.8167267402741333,
  51. 0.002107772549575186,
  52. 0.5770188587943806,
  53. ],
  54. index: 0,
  55. },
  56. },
  57. "*"
  58. );
  59. }
  60. if (newVal == "e") {
  61. this.$refs.ifr.contentWindow.postMessage(
  62. {
  63. source: "changeExhition",
  64. data: {
  65. quat: [
  66. 0.028523630856794317,
  67. 0.953183703881663,
  68. -0.09519870492067249,
  69. 0.2855948602103702,
  70. ],
  71. index: 30,
  72. },
  73. },
  74. "*"
  75. );
  76. }
  77. },
  78. },
  79. };
  80. </script>
  81. <style lang="less" scoped>
  82. .scene-body {
  83. width: 100%;
  84. height: 100vh;
  85. position: relative;
  86. overflow: hidden;
  87. > iframe {
  88. width: 100%;
  89. height: 100%;
  90. }
  91. }
  92. </style>