index.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import React, { useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { myData, otherUrl } from '@/utils/http'
  4. import Hot2 from '@/pages/A2visit/PanoVideo/Hot2'
  5. import { HotSpot, Krpano, Scene, View } from '@dage/krpano'
  6. import HotIcon from '@/components/HotIcon'
  7. // window.draggbleHotspotEvent = (ath: number, atv: number) => {
  8. // console.log(`ath: ${ath}, atv: ${atv}`)
  9. // }
  10. function A22Pano() {
  11. const [acInd, setAcInd] = useState(-1)
  12. const [activeIdx, setActiveIdx] = useState(-1)
  13. return (
  14. <div className={styles.A22Pano}>
  15. <Krpano className={styles.pano} currentScene='a22'>
  16. <Scene
  17. name='a22'
  18. previewUrl={otherUrl + 'pano/a22.tiles/thumb.jpg'}
  19. imageTagAttributes={{
  20. type: 'cube',
  21. tileSize: 512,
  22. multires: true
  23. }}
  24. images={[
  25. {
  26. tiledImageWidth: 2816,
  27. tiledImageHeight: 2816,
  28. url: otherUrl + 'pano/a22.tiles/%s/l3/%v/l3_%s_%v_%h.jpg'
  29. },
  30. {
  31. tiledImageWidth: 1536,
  32. tiledImageHeight: 1536,
  33. url: otherUrl + 'pano/a22.tiles/%s/l2/%v/l2_%s_%v_%h.jpg'
  34. },
  35. {
  36. tiledImageWidth: 768,
  37. tiledImageHeight: 768,
  38. url: otherUrl + 'pano/a22.tiles/%s/l1/%v/l1_%s_%v_%h.jpg'
  39. }
  40. ]}
  41. >
  42. <View hlookat={0} vlookat={0} fovType='MFOV' fov={120} fovMin={70} fovMax={130} />
  43. {myData.visit2.hot.map((item, index) => (
  44. // 热点图标
  45. <HotSpot
  46. key={index}
  47. type='text'
  48. name={item.name}
  49. atv={item.atv}
  50. ath={item.ath}
  51. edge='top'
  52. distorted={true}
  53. scale={item.size}
  54. bg={false}
  55. onOver={() => setActiveIdx(index)}
  56. onOut={() => setActiveIdx(-1)}
  57. onClick={() => setAcInd(index)}
  58. // @ts-ignore
  59. // onDown='draggable_hotspot()'
  60. >
  61. <HotIcon
  62. isModel={item.isModel ? true : false}
  63. key={index}
  64. index={index}
  65. isHoverAc={activeIdx === index}
  66. hoverSrc={item.hoverSrc}
  67. panoWidth='128px'
  68. />
  69. </HotSpot>
  70. ))}
  71. </Scene>
  72. </Krpano>
  73. {acInd !== -1 ? (
  74. <Hot2
  75. data={myData.visit2.hot[acInd].data}
  76. closeFu={() => setAcInd(-1)}
  77. name={myData.visit2.hot[acInd].name}
  78. />
  79. ) : null}
  80. </div>
  81. )
  82. }
  83. const MemoA22Pano = React.memo(A22Pano)
  84. export default MemoA22Pano