photo-sphere-viewer.js 全景图Vr 720全景 原生使用js

使用教程

插件官网添加链接描述(其实使用自行查看)
index.html

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vr全景</title>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core/index.min.css"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/markers-plugin/index.min.css"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/virtual-tour-plugin/index.min.css"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/gallery-plugin/index.min.css"
    />
    <style></style>
</head>
 
<body>
    <div id="viewer" style="width: 100%; height: 100%;"></div>
</body>
 
</html>
<script src="https://cdn.jsdelivr.net/npm/three/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/core/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/markers-plugin/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/autorotate-plugin/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/virtual-tour-plugin/index.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/@photo-sphere-viewer/gallery-plugin/index.min.js">
</script>
<script>
//动画参数
const animatedValues = {
  pitch: {
    start: -Math.PI / 2,
    end: 0.2,
  },
  yaw: {
    start: Math.PI,
    end: 0,
  },
  zoom: {
    start: 0,
    end: 50,
  },
  fisheye: {
    start: 2,
    end: 0,
  },
};
var currIndex = 0;
//初始化实例
const viewer = new PhotoSphereViewer.Viewer({
  container: "viewer",
  panorama: "http://szgctest.shengtucuican.cn/image/DSC00169.jpg",
  navbar: ["gallery"],
  plugins: [
    [
      PhotoSphereViewer.GalleryPlugin,
      {
        visibleOnLoad: true,
      },
    ],
    [
      PhotoSphereViewer.VirtualTourPlugin,
      {
        positionMode: "gps",
        renderMode: "3d",
        arrowStyle: {
          color: "#999",
          hoverColor: "#666",
          outlineColor: "#ccc",
          scale: [0.2, 0.6],
        },
      },
    ],
    [
      PhotoSphereViewer.GalleryPlugin,
      {
        /*图库*/
        visibleOnLoad: true,
        hideOnClick: true,
      },
    ],
  ],
});

var gallery = viewer.getPlugin(PhotoSphereViewer.GalleryPlugin);
gallery.setItems([
  {
    id: "1",
    panorama: "http://szgctest.shengtucuican.cn/image/DSC00169.jpg",
    thumbnail: "http://szgctest.shengtucuican.cn/image/DSC00169.jpg",
  },
  {
    id: "2",
    panorama: "http://szgctest.shengtucuican.cn/image/DSC00115.jpg",
    thumbnail: "http://szgctest.shengtucuican.cn/image/DSC00115.jpg",
  },
]);

var virtualTour = viewer.getPlugin(PhotoSphereViewer.VirtualTourPlugin);

var markerLighthouse = {
  id: "1",
  image: "http://szgctest.shengtucuican.cn/image/DSC00169.jpg",

  size: { width: 32, height: 32 },
  anchor: "bottom bottom",
  gps: [100.155973, 1115.666601, -1],
};
virtualTour.setNodes(
  [
    {
      id: "1",
      panorama: "http://szgctest.shengtucuican.cn/image/DSC00169.jpg",
      thumbnail: "http://szgctest.shengtucuican.cn/image/DSC00169.jpg",
      name: "大门",
      links: [{ nodeId: "2" }],
      markers: [markerLighthouse],
      gps: [100, 0, 2],
      panoData: { poseHeading: 0 },
      map: { x: 1920, y: 1250, color: "red" },
    },
    {
      id: "2",
      panorama: "http://szgctest.shengtucuican.cn/image/DSC00115.jpg",
      thumbnail: "http://szgctest.shengtucuican.cn/image/DSC00115.jpg",
      name: "会议室",
      links: [{ nodeId: "1" }],
      markers: [markerLighthouse],
      gps: [100, 0, 2],
      panoData: { poseHeading: 0 },
      map: { x: 1920, y: 1250, color: "red" },
    },
  ],
  "1"
);

function onloadFunction() {
  // autorotate.stop();
  new PhotoSphereViewer.utils.Animation({
    properties: animatedValues,
    duration: 2500,
    easing: "inOutQuad",
    onTick: (properties) => {
      viewer.setOption("fisheye", properties.fisheye);
      viewer.rotate({
        yaw: properties.yaw,
        pitch: properties.pitch,
      });
      viewer.zoom(properties.zoom);
    },
  }).then(() => {
    autorotate.start();
  });
}
</script>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值