|
@@ -1,10 +1,11 @@
|
|
-import React, { useMemo, useState } from 'react'
|
|
|
|
|
|
+import React, { useMemo, useRef, useState } from 'react'
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
import Hot1 from './Hot1'
|
|
import Hot1 from './Hot1'
|
|
import Hot2 from './Hot2'
|
|
import Hot2 from './Hot2'
|
|
-import { baseURL, myData } from '@/utils/http'
|
|
|
|
|
|
+import { otherUrl, myData } from '@/utils/http'
|
|
import HotIcon from '@/components/HotIcon'
|
|
import HotIcon from '@/components/HotIcon'
|
|
import { HotSpot, Krpano, VideoScene, videoSceneModel, View } from '@dage/krpano'
|
|
import { HotSpot, Krpano, VideoScene, videoSceneModel, View } from '@dage/krpano'
|
|
|
|
+import { KrpanoMiddleware, KrpanoMiddlewareMethods } from '@/components/KrpanoMiddleware'
|
|
|
|
|
|
window.draggbleHotspotEvent = (ath: number, atv: number) => {
|
|
window.draggbleHotspotEvent = (ath: number, atv: number) => {
|
|
console.log(`ath: ${ath}, atv: ${atv}`)
|
|
console.log(`ath: ${ath}, atv: ${atv}`)
|
|
@@ -14,57 +15,53 @@ function PanoVideo() {
|
|
// 0为 第一种模式的热点 其他为第二种
|
|
// 0为 第一种模式的热点 其他为第二种
|
|
const [ind, setInd] = useState(-1)
|
|
const [ind, setInd] = useState(-1)
|
|
const [activeIdx, setActiveIdx] = useState(-1)
|
|
const [activeIdx, setActiveIdx] = useState(-1)
|
|
|
|
+ const middlewareIns = useRef<KrpanoMiddlewareMethods>(null)
|
|
|
|
|
|
const data = useMemo(() => {
|
|
const data = useMemo(() => {
|
|
if (ind !== -1) return myData.visit.hot[ind].data
|
|
if (ind !== -1) return myData.visit.hot[ind].data
|
|
else return []
|
|
else return []
|
|
}, [ind])
|
|
}, [ind])
|
|
|
|
|
|
- const onReady = () => {
|
|
|
|
- window.ReactKrpanoActionProxy?.krpanoRenderer?.call('set(control.dragging, false);')
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return (
|
|
|
|
- <>
|
|
|
|
- <Krpano className={styles.PanoVideo} currentScene='scene1' onReady={onReady}>
|
|
|
|
- <VideoScene
|
|
|
|
- name='scene1'
|
|
|
|
- videointerfaceXmlUrl='/skin/videointerface.xml'
|
|
|
|
- videoplayerUrl='/plugins/videoplayer.js'
|
|
|
|
|
|
+ return <>
|
|
|
|
+ <KrpanoMiddleware ref={middlewareIns}>
|
|
|
|
+ <Krpano className={styles.PanoVideo} currentScene='scene1' onReady={() => middlewareIns.current?.ready()}>
|
|
|
|
+ <VideoScene name='scene1'
|
|
|
|
+ videointerfaceXmlUrl="./skin/videointerface.xml"
|
|
|
|
+ videoplayerUrl="./plugins/videoplayer.js"
|
|
sourceList={[
|
|
sourceList={[
|
|
{
|
|
{
|
|
- res: '2000x1000',
|
|
|
|
- url: baseURL + '/pano/1.mp4',
|
|
|
|
- poster: ''
|
|
|
|
- }
|
|
|
|
|
|
+ res: "2000x1000",
|
|
|
|
+ url: otherUrl + "pano/1.mp4",
|
|
|
|
+ poster: "",
|
|
|
|
+ },
|
|
]}
|
|
]}
|
|
- playRes='2000x1000'
|
|
|
|
|
|
+ playRes="2000x1000"
|
|
onVisibility={() => {
|
|
onVisibility={() => {
|
|
- if (document.visibilityState === 'visible') {
|
|
|
|
- videoSceneModel.play()
|
|
|
|
|
|
+ if (document.visibilityState === "visible") {
|
|
|
|
+ videoSceneModel.play();
|
|
}
|
|
}
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
<View
|
|
<View
|
|
hlookat={0}
|
|
hlookat={0}
|
|
vlookat={0}
|
|
vlookat={0}
|
|
- fovType='MFOV'
|
|
|
|
|
|
+ fovType="MFOV"
|
|
fov={100}
|
|
fov={100}
|
|
maxPixelZoom={2}
|
|
maxPixelZoom={2}
|
|
fovMin={70}
|
|
fovMin={70}
|
|
fovMax={140}
|
|
fovMax={140}
|
|
- limitView='auto'
|
|
|
|
|
|
+ limitView="auto"
|
|
/>
|
|
/>
|
|
|
|
|
|
{myData.visit.hot.map((item, index) => (
|
|
{myData.visit.hot.map((item, index) => (
|
|
// 热点图标
|
|
// 热点图标
|
|
<HotSpot
|
|
<HotSpot
|
|
key={index}
|
|
key={index}
|
|
- type='text'
|
|
|
|
|
|
+ type="text"
|
|
name={item.name}
|
|
name={item.name}
|
|
atv={item.atv}
|
|
atv={item.atv}
|
|
ath={item.ath}
|
|
ath={item.ath}
|
|
- edge='top'
|
|
|
|
|
|
+ edge="top"
|
|
distorted={true}
|
|
distorted={true}
|
|
scale={item.size}
|
|
scale={item.size}
|
|
bg={false}
|
|
bg={false}
|
|
@@ -82,14 +79,14 @@ function PanoVideo() {
|
|
))}
|
|
))}
|
|
</VideoScene>
|
|
</VideoScene>
|
|
</Krpano>
|
|
</Krpano>
|
|
|
|
+ </KrpanoMiddleware>
|
|
|
|
|
|
- {ind === -1 ? null : ind === 0 ? (
|
|
|
|
- <Hot1 data={data} closeFu={() => setInd(-1)} />
|
|
|
|
- ) : (
|
|
|
|
- <Hot2 data={data} closeFu={() => setInd(-1)} name={myData.visit.hot[ind].name} />
|
|
|
|
- )}
|
|
|
|
- </>
|
|
|
|
- )
|
|
|
|
|
|
+ {ind === -1 ? null : ind === 0 ? (
|
|
|
|
+ <Hot1 data={data} closeFu={() => setInd(-1)} />
|
|
|
|
+ ) : (
|
|
|
|
+ <Hot2 data={data} closeFu={() => setInd(-1)} name={myData.visit.hot[ind].name} />
|
|
|
|
+ )}
|
|
|
|
+ </>
|
|
}
|
|
}
|
|
|
|
|
|
const MemoPanoVideo = React.memo(PanoVideo)
|
|
const MemoPanoVideo = React.memo(PanoVideo)
|