photo-sphere-viewer中文文档

photo-sphere-viewer中文文档

勤学如春起之苗,不见其增,日有所长;
辍学如磨刀之石,不见其损,日有所亏。

业务这边想要实现右边链接的效果阿里云付费全景图,类似VR看房,支持360° x 360°任意旋转,支持自定义添加标注,支持切换场景等功能,效果如下

在这里插入图片描述

阿里云的全景图需要付费,而且个别功能不满足我们业务需要,那边无法及时调整,所以后面由我们内部自己实现

前端组长这边提供了photo-sphere-viewer相关的文章作为参考

内部基于 photo-sphere-viewer 插件实现效果如下
在这里插入图片描述

全景图实现使用了 photo-sphere-viewer 插件,它基于three.js和uEvent 2实现

这边实现主要用了 photo-sphere-viewer和他的标记Markers插件

安装插件

使用 npm 或 yarn 下载安装

npm install photo-sphere-viewer --save

yarn add photo-sphere-viewer 

文章使用的版本"photo-sphere-viewer": "^4.3.0"

使用如下

import MarkersPlugin from 'photo-sphere-viewer/dist/plugins/markers'
import 'photo-sphere-viewer/dist/plugins/markers.css';

import { MarkersPlugin } from 'photo-sphere-viewer/dist/plugins/markers'
import 'photo-sphere-viewer/dist/plugins/markers.css'

this.viewer = new Viewer({
    container:document.querySelector('#viewer'),
    panorama:'https://aupup-mall-pub.oss-cn-shenzhen.aliyuncs.com/public/aa28925e-8ef9-4a2d-9217-e82a86b6ee15.jpg',
    size:{
        width: '100%',
        height: '100%',
    },
    plugins: [
        [MarkersPlugin, {
            markers: [
                {
                    id:'circle',
                    tooltip:'A circle of radius 30',
                    circle:30,
                    svgStyle : {
                        fill:'rgba(255,255,0,0.3)',
                        stroke:'yellow',
                        strokeWidth:'2px',
                    },
                    longitude: -1.5,
                    latitude: -0.28,
                    anchor: 'center right',
                }
            ],
        }],
    ],
});

Configuration 配置项

在这里插入图片描述

一个陌生的对象,打断点后,去控制台查看,可以很方便看到对象的属性方法之类的信息

Standard options 常规配置

container (required)
  • type: HTMLElement | string

全景图的容器,可以是DOM元素或者DOM的ID

container: document.querySelector('.viewer')

container: 'viewer' // will target [id="viewer"]
adapter 适配器
  • default: equirectangular

用于加载全景图的适配器

panorama (required)
  • type: *

全景图地址,如果用默认的适配器,只支持传单个

plugins 插件
  • type: array

Introduction to plugins
这里只用到标注插件,后面单独介绍

caption 标题
  • type: string

导航栏中显示的文本。如果导航栏被禁用,它无论如何都会显示,但没有按钮。允许使用 HTML

size 全景图宽度高度
  • type: { width: integer, height: integer }

全景容器的最终尺寸。默认情况下使用容器的大小,并在窗口调整大小期间遵循

markers 标注

标注的配置

navbar 导航栏

导航栏的配置

minF
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值