|
@@ -1,30 +1,96 @@
|
|
|
-import React, { useMemo, useState } from 'react'
|
|
|
+import React, { useMemo, useRef, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
-import { myData } from '@/utils/http'
|
|
|
+import { myData, otherUrl } from '@/utils/http'
|
|
|
import Hot2 from '@/pages/A2visit/PanoVideo/Hot2'
|
|
|
import HotIcon from '@/components/HotIcon'
|
|
|
+import { KrpanoMiddleware, KrpanoMiddlewareMethods } from '@/components/KrpanoMiddleware'
|
|
|
+import { HotSpot, Krpano, Scene, View } from '@dage/krpano'
|
|
|
+
|
|
|
function PanoImg() {
|
|
|
// 0为 第一种模式的热点 其他为第二种
|
|
|
const [ind, setInd] = useState(-1)
|
|
|
+ const [activeIdx, setActiveIdx] = useState(-1)
|
|
|
+ const middlewareIns = useRef<KrpanoMiddlewareMethods>(null)
|
|
|
|
|
|
const data = useMemo(() => {
|
|
|
if (ind !== -1) return myData.banquet.hot[ind].data
|
|
|
else return []
|
|
|
}, [ind])
|
|
|
|
|
|
- return (
|
|
|
- <div className={styles.PanoImg}>
|
|
|
- {/* 待完善 */}
|
|
|
- 全景图
|
|
|
- {myData.banquet.hot.map((item, index) => (
|
|
|
- // 热点图标
|
|
|
- <HotIcon key={index} index={index} clickSon={val => setInd(val)} hoverSrc={item.hoverSrc} />
|
|
|
- ))}
|
|
|
- {ind === -1 ? null : (
|
|
|
- <Hot2 data={data} closeFu={() => setInd(-1)} name={myData.banquet.hot[ind].name} />
|
|
|
- )}
|
|
|
- </div>
|
|
|
- )
|
|
|
+ return <>
|
|
|
+ <KrpanoMiddleware ref={middlewareIns}>
|
|
|
+ <Krpano className={styles.PanoImg} currentScene='scene1' onReady={() => middlewareIns.current?.ready()}>
|
|
|
+ <Scene name='scene1'
|
|
|
+ previewUrl={otherUrl + 'pano/pano2.tiles/preview.jpg'}
|
|
|
+ imageTagAttributes={{
|
|
|
+ type: "cube",
|
|
|
+ tileSize: 512,
|
|
|
+ multires: true,
|
|
|
+ }}
|
|
|
+ images={[
|
|
|
+ {
|
|
|
+ tiledImageWidth: 2624,
|
|
|
+ tiledImageHeight: 2624,
|
|
|
+ url: otherUrl + "pano/pano2.tiles/%s/l3/%v/l3_%s_%v_%h.jpg",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ tiledImageWidth: 1280,
|
|
|
+ tiledImageHeight: 1280,
|
|
|
+ url: otherUrl + "pano/pano2.tiles/%s/l2/%v/l2_%s_%v_%h.jpg",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ tiledImageWidth: 640,
|
|
|
+ tiledImageHeight: 640,
|
|
|
+ url: otherUrl + "pano/pano2.tiles/%s/l1/%v/l1_%s_%v_%h.jpg",
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ <View
|
|
|
+ hlookat={0}
|
|
|
+ vlookat={0}
|
|
|
+ fovType="MFOV"
|
|
|
+ fov={120}
|
|
|
+ maxPixelZoom={2}
|
|
|
+ fovMin={70}
|
|
|
+ fovMax={140}
|
|
|
+ limitView="range"
|
|
|
+ hlookatMin={-90}
|
|
|
+ hlookatMax={90}
|
|
|
+ vlookatMin={-80}
|
|
|
+ vlookatMax={80}
|
|
|
+ />
|
|
|
+ {myData.banquet.hot.map((item, index) => (
|
|
|
+ // 热点图标
|
|
|
+ <HotSpot
|
|
|
+ key={index}
|
|
|
+ type="text"
|
|
|
+ name={item.name}
|
|
|
+ atv={item.atv}
|
|
|
+ ath={item.ath}
|
|
|
+ edge="top"
|
|
|
+ distorted={true}
|
|
|
+ scale={item.size}
|
|
|
+ bg={false}
|
|
|
+ onOver={() => setActiveIdx(index)}
|
|
|
+ onOut={() => setActiveIdx(-1)}
|
|
|
+ onClick={() => setInd(index)}
|
|
|
+ >
|
|
|
+ <HotIcon key={index}
|
|
|
+ index={index}
|
|
|
+ isHoverAc={activeIdx === index}
|
|
|
+ hoverSrc={item.hoverSrc}
|
|
|
+ panoWidth='146px'
|
|
|
+ />
|
|
|
+ </HotSpot>
|
|
|
+ ))}
|
|
|
+ </Scene>
|
|
|
+ </Krpano>
|
|
|
+ </KrpanoMiddleware>
|
|
|
+
|
|
|
+ {ind === -1 ? null : (
|
|
|
+ <Hot2 data={data} closeFu={() => setInd(-1)} name={myData.banquet.hot[ind].name} />
|
|
|
+ )}
|
|
|
+ </>
|
|
|
}
|
|
|
|
|
|
const MemoPanoImg = React.memo(PanoImg)
|