panoramic-view
基于three.js加工的360°全景图片查看器,它基于 Web Component,因此支持 Layui、Vue、React、Angular 等几乎任何前端框架。它适配了 PC Web 端和手机端,并支持手机遥感和自动旋转播放。除此之外,它还提供了灵活的配置,开发者可以方便的使用其开发流程设计的应用。
panoramic-view开发文档
iajie.github.io/panoramic-v...
react集成
tsx
import React, { useEffect, useRef } from 'react';
import { PanoramicView } from 'panoramic-view';
import "panoramic-view/style.css";
const Panoramic: React.FC = ({}) => {
//定义 ref
const divRef = useRef(null);
//初始化 PanoramicView
useEffect(() => {
if (divRef.current) {
const panoramicView = new PanoramicView({
container: divRef.current,
fileList: [
{
name: "乌蒙大草原入口",
url: "1.jpg",
},
{
name: "乌蒙大草原漫游2",
url: "2.jpg",
},
{
name: "乌蒙大草原漫游3",
url: "3.jpg",
},
]
})
return () => {
panoramicView.destroy();
}
}
}, [])
return <div/>
}
export default Panoramic;
vue中使用
html
<template>
<div>
<h1>PanoramicView,一个基于three.js 的全景 图片/视频 查看器</h1>
</div>
<div ref="panoramic" style="height: 600px" />
</template>
<script setup lang="ts">
import { PanoramicView } from "panoramic-view";
import "panoramic-view/style.css";
import { onMounted, ref, onUnmounted } from 'vue';
const panoramic = ref();
const panoramicView = ref<PanoramicView>();
onMounted(() => {
panoramicView.value = new PanoramicView({
container: panoramic.value,
fileList: [
{
name: "乌蒙大草原入口",
url: "1.jpg",
},
{
name: "乌蒙大草原漫游2",
url: "2.jpg",
},
{
name: "乌蒙大草原漫游3",
url: "3.jpg",
},
]
});
});
onUnmounted(() => {
panoramicView.value?.destroy();
});
</script>