当前位置:   article > 正文

photo-sphere-viewer 全景图Vr 720全景查看(vue篇)

photo-sphere-viewer

一、安装以及引入方式

  1. npm install @photo-sphere-viewer/core
  2. /***插件安装**/
  3. npm install @photo-sphere-viewer/markers-plugin
  4. npm install @photo-sphere-viewer/gallery-plugin
  5. npm install @photo-sphere-viewer/autorotate-plugin

二、PhotoSphereViewer.vue

  1. <template>
  2. <div id="viewer"></div>
  3. </template>
  4. <script>
  5. import { Viewer } from "@photo-sphere-viewer/core";
  6. import { MarkersPlugin } from "@photo-sphere-viewer/markers-plugin";
  7. import { GalleryPlugin } from "@photo-sphere-viewer/gallery-plugin";
  8. import { AutorotatePlugin } from "@photo-sphere-viewer/autorotate-plugin";
  9. import "@photo-sphere-viewer/core/index.css";
  10. import "@photo-sphere-viewer/markers-plugin/index.css";
  11. import "@photo-sphere-viewer/gallery-plugin/index.css";
  12. export default {
  13. props: {
  14. hasAnimate: {
  15. type: Boolean,
  16. default: true,
  17. },
  18. imgList: [],
  19. hasGallery: {
  20. type: Boolean,
  21. default: true,
  22. },
  23. },
  24. components: {},
  25. data() {
  26. return {
  27. viewer: "",
  28. panoramaUrl: "",
  29. markersPlugin: "",
  30. autorotatePlugin: "",
  31. galleryPlugin: "",
  32. currIndex: 0,
  33. animatedValues: {
  34. pitch: { start: -Math.PI / 2, end: 0.2 },
  35. yaw: { start: Math.PI, end: 0 },
  36. zoom: { start: 0, end: 50 },
  37. fisheye: { start: 2, end: 0 },
  38. },
  39. defaultUrl: require("../assets/3.jpg"),
  40. };
  41. },
  42. created() {},
  43. mounted() {
  44. this.panoramaUrl = this.imgList[0].panorama || this.defaultUrl;
  45. this.initViewer();
  46. this.handelListenerViewerClick();
  47. this.handleSelectMarker();
  48. this.handleHoverMarker();
  49. this.handleLeaveMarker();
  50. this.$nextTick(() => {
  51. this.handleGalleryChange();
  52. });
  53. },
  54. watch: {},
  55. methods: {
  56. initViewer() {
  57. const _this = this;
  58. this.viewer = new Viewer({
  59. container: "viewer",
  60. panorama: this.panoramaUrl || this.defaultUrl,
  61. caption: "test",
  62. loadingImg: require("../assets/loader.gif"),
  63. touchmoveTwoFingers: true,
  64. mousewheelCtrlKey: false,
  65. navbar: [
  66. "autorotate",
  67. "zoom",
  68. "markers",
  69. "move",
  70. "download",
  71. "gallery",
  72. {
  73. title: "Change points",
  74. content: "
    声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/326112
    推荐阅读
    相关标签