scene.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. ifrWindow[data.data]()
  37. }
  38. })
  39. },
  40. watch: {
  41. theme(newVal) {
  42. if (newVal == "xuting") {
  43. this.$refs.ifr.contentWindow.postMessage(
  44. {
  45. source: "changeExhition",
  46. data: {
  47. quat: [
  48. -0.001489144851378805,
  49. 0.8167267402741333,
  50. 0.002107772549575186,
  51. 0.5770188587943806,
  52. ],
  53. index: 0,
  54. },
  55. },
  56. "*"
  57. );
  58. }
  59. if (newVal == "e") {
  60. this.$refs.ifr.contentWindow.postMessage(
  61. {
  62. source: "changeExhition",
  63. data: {
  64. quat: [
  65. 0.028523630856794317,
  66. 0.953183703881663,
  67. -0.09519870492067249,
  68. 0.2855948602103702,
  69. ],
  70. index: 30,
  71. },
  72. },
  73. "*"
  74. );
  75. }
  76. },
  77. },
  78. };
  79. </script>
  80. <style lang="less" scoped>
  81. .scene-body {
  82. width: 100%;
  83. height: 100vh;
  84. position: relative;
  85. overflow: hidden;
  86. > iframe {
  87. width: 100%;
  88. height: 100%;
  89. }
  90. }
  91. </style>