智慧园区前端大屏
shuishen
2024-12-02 b67f46b4a768b4cd72d4e463c5dffefe977ddeb7
src/views/pd/components/dynamicPanel.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-11-09 15:41:35
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-28 19:36:24
 * @LastEditTime: 2024-12-02 21:53:13
 * @FilePath: \bigScreen\src\views\pd\components\dynamicPanel.vue
 * @Description: 
 * 
@@ -46,8 +46,8 @@
        lng: 115.10343807,
        lat: 27.27256126
      },
      linePosition: '115.10341051,27.27251643,80;115.10357817,27.27278003,80',
      lineTime: 10000,
      linePosition: '115.10341051,27.27251643,64;115.10357817,27.27278003,64',
      lineTime: 5000,
      threeContent: '关闭绿源污水处理厂旁雨水排口,拦截污染水体。',
      threePointPosition: {
@@ -86,7 +86,7 @@
        lng: 115.10627858,
        lat: 27.29434439
      },
      linePosition: '115.10627726,27.29408853,80;115.10627703,27.29456132,80',
      linePosition: '115.10627726,27.29408853,64;115.10627703,27.29456132,64',
      lineTime: 5000,
      twoContent: '园区关闭北区雨水排口,拦截污染水体。',
@@ -196,7 +196,7 @@
]
let positions = modelPosition.map(i => [i.lng, i.lat, 64].join(',')).join(';')
let positions = modelPosition.map(i => [i.lng, i.lat, i.ele || 64].join(',')).join(';')
let tc = new DC.TrackController(window.$viewer)
let track = new DC.Track(positions, 5)
track.setModel(VITE_APP_BASE + 'gltf/car.gltf', {
@@ -208,6 +208,173 @@
})
tc.addTrack(track)
const synth = window.speechSynthesis
const speak = (msg, continueFun = () => { }) => {
  let u = new SpeechSynthesisUtterance()
  let voices = synth.getVoices()
  u.text = msg
  u.rate = 2
  let findObj = voices.some(voice => voice.lang == 'zh-CN')
  if (!findObj) {
    u.lang = 'zh-TW'
  }
  u.onend = () => {
    continueFun()
  }
  synth.speak(u)
}
const publicFun = (item) => {
  let threeCenter = DC.Position.fromObject(item.threePointPosition)
  let threeCircle = new DC.Circle(threeCenter, 30)
  threeCircle.setStyle({
    material: new DC.CircleWaveMaterialProperty({
      color: DC.Color.fromRandom(),
      speed: 20,
      count: 5,
      gradient: 0.5
    })
  })
  dynamicVectorLayer.addOverlay(threeCircle)
  let threeContent = new DC.DivIcon(
    new DC.Position(item.threePointPosition.lng, item.threePointPosition.lat, 70),
    `<div class="dynamic-map-popup">
                  <div class="content-wrap">
                    <div class="content">
                      <p>${item.threeContent}</p>
                    </div>
                  </div>
                  <div class="arrow"></div>
                </div>`
  )
  dynamicHtmlLayer.addOverlay(threeContent)
  window.$viewer.flyToPosition(new DC.Position(item.threePointPosition.lng, item.threePointPosition.lat, 400, 0, -90, 0), () => {
    speak(item.threeContent, () => {
      let FourCenter = DC.Position.fromObject(item.fourPointPosition)
      let fourCircle = new DC.Circle(FourCenter, 10)
      fourCircle.setStyle({
        material: new DC.CircleWaveMaterialProperty({
          color: DC.Color.fromRandom(),
          speed: 20,
          count: 5,
          gradient: 0.5
        })
      })
      dynamicVectorLayer.addOverlay(fourCircle)
      let fourContent = new DC.DivIcon(
        new DC.Position(item.fourPointPosition.lng, item.fourPointPosition.lat, 70),
        `<div class="dynamic-event-profile-map-popup">
                      <div class="content-wrap">
                        <div class="content">
                          <p>${item.fourContent}</p>
                        </div>
                      </div>
                      <div class="arrow"></div>
                    </div>`
      )
      dynamicHtmlLayer.addOverlay(fourContent)
      // 执行对应的事件函数
      window.$viewer.flyToPosition(new DC.Position(item.fourPointPosition.lng, item.fourPointPosition.lat, 400, 0, -90, 0), () => {
        speak(item.fourContent, () => {
          if (item.fivePointPosition) {
            let fiveCenter = DC.Position.fromObject(item.fivePointPosition)
            let fiveCircle = new DC.Circle(fiveCenter, 10)
            fiveCircle.setStyle({
              material: new DC.CircleWaveMaterialProperty({
                color: DC.Color.fromRandom(),
                speed: 20,
                count: 5,
                gradient: 0.5
              })
            })
            dynamicVectorLayer.addOverlay(fiveCircle)
            let fiveContent = new DC.DivIcon(
              new DC.Position(item.fivePointPosition.lng, item.fivePointPosition.lat, 70),
              `<div class="dynamic-event-profile-map-popup">
                              <div class="content-wrap">
                                <div class="content">
                                  <p>${item.fiveContent}</p>
                                </div>
                              </div>
                              <div class="arrow"></div>
                          </div>`
            )
            dynamicHtmlLayer.addOverlay(fiveContent)
            // 执行对应的事件函数
            window.$viewer.flyToPosition(new DC.Position(item.fivePointPosition.lng, item.fivePointPosition.lat, 400, 0, -90, 0), () => {
              speak(item.fiveContent)
            }, 3)
          }
        })
      }, 3)
    })
  }, 3)
}
const twoFun = (item, cb = () => { }) => {
  let twoCenter = DC.Position.fromObject(item.twoPointPosition)
  let twoCircle = new DC.Circle(twoCenter, 10)
  twoCircle.setStyle({
    material: new DC.CircleWaveMaterialProperty({
      color: DC.Color.fromRandom(),
      speed: 20,
      count: 5,
      gradient: 0.5
    })
  })
  dynamicVectorLayer.addOverlay(twoCircle)
  let twoContent = new DC.DivIcon(
    new DC.Position(item.twoPointPosition.lng, item.twoPointPosition.lat, 70),
    `<div class="dynamic-event-profile-map-popup">
          <div class="content-wrap">
            <div class="content">
              <p>${item.twoContent}</p>
              </div>
              </div>
              <div class="arrow"></div>
              </div>`
    // <p>特征污染物:${item.specificPollutant}</p>
  )
  dynamicHtmlLayer.addOverlay(twoContent)
  // 执行对应的事件函数
  window.$viewer.flyToPosition(new DC.Position(item.twoPointPosition.lng, item.twoPointPosition.lat, 400, 0, -90, 0), () => {
    speak(item.twoContent, () => {
      cb()
    })
  }, 3)
}
const createLinePath = (item, cb = () => { }) => {
  let polyline = new DC.Polyline(item.linePosition)
  polyline.setStyle({
    width: 20,
    material: new DC.PolylineImageTrailMaterialProperty({
      color: DC.Color.RED,
      speed: 20,
      image: VITE_APP_BASE + 'img/mapicon/right.png',
      repeat: { x: 5, y: 1 }
    }),
    clampToGround: false
  })
  dynamicLineVectorLayer.addOverlay(polyline)
  window.$viewer.flyToPosition(new DC.Position(item.lineCenter.lng, item.lineCenter.lat, 400, 0, -90, 0), () => {
    lineTime = setTimeout(() => {
      cb()
    }, item.lineTime)
  }, 3)
}
const schemeStart = (item) => {
  emit('closePanel')
@@ -259,6 +426,26 @@
        // <p>特征污染物:${item.specificPollutant}</p>
      )
      dynamicHtmlLayer.addOverlay(oneCentent)
      speak(item.oneCentent, () => {
        if (item.key == 2) {
          createLinePath(item, () => {
            twoFun(item, () => {
              publicFun(item)
            })
          })
        } else if (item.key == 1) {
          twoFun(item, () => {
            createLinePath(item, () => {
              publicFun(item)
            })
          })
        } else {
          twoFun(item, () => {
            publicFun(item)
          })
        }
      })
    }
    if (item.showModel) {
      oneLoad()
@@ -268,144 +455,11 @@
      }, 3)
    }
  }, item.onetime)
  item.linePosition && (lineTime = setTimeout(() => {
    let polyline = new DC.Polyline(item.linePosition)
    polyline.setStyle({
      width: 20,
      material: new DC.PolylineImageTrailMaterialProperty({
        color: DC.Color.RED,
        speed: 20,
        image: VITE_APP_BASE + 'img/mapicon/right.png',
        repeat: { x: 5, y: 1 }
      }),
      clampToGround: false
    })
    dynamicLineVectorLayer.addOverlay(polyline)
    window.$viewer.flyToPosition(new DC.Position(item.lineCenter.lng, item.lineCenter.lat, 400, 0, -90, 0), () => { }, 3)
  }, item.lineTime))
  timeTwo = setTimeout(() => {
    let twoCenter = DC.Position.fromObject(item.twoPointPosition)
    let twoCircle = new DC.Circle(twoCenter, 10)
    twoCircle.setStyle({
      material: new DC.CircleWaveMaterialProperty({
        color: DC.Color.fromRandom(),
        speed: 20,
        count: 5,
        gradient: 0.5
      })
    })
    dynamicVectorLayer.addOverlay(twoCircle)
    let twoContent = new DC.DivIcon(
      new DC.Position(item.twoPointPosition.lng, item.twoPointPosition.lat, 70),
      `<div class="dynamic-event-profile-map-popup">
          <div class="content-wrap">
            <div class="content">
              <p>${item.twoContent}</p>
              </div>
              </div>
              <div class="arrow"></div>
              </div>`
      // <p>特征污染物:${item.specificPollutant}</p>
    )
    dynamicHtmlLayer.addOverlay(twoContent)
    // 执行对应的事件函数
    window.$viewer.flyToPosition(new DC.Position(item.twoPointPosition.lng, item.twoPointPosition.lat, 400, 0, -90, 0), () => { }, 3)
  }, item.twotime)
  timeThree = setTimeout(() => {
    let threeCenter = DC.Position.fromObject(item.threePointPosition)
    let threeCircle = new DC.Circle(threeCenter, 30)
    threeCircle.setStyle({
      material: new DC.CircleWaveMaterialProperty({
        color: DC.Color.fromRandom(),
        speed: 20,
        count: 5,
        gradient: 0.5
      })
    })
    dynamicVectorLayer.addOverlay(threeCircle)
    let threeContent = new DC.DivIcon(
      new DC.Position(item.threePointPosition.lng, item.threePointPosition.lat, 70),
      `<div class="dynamic-map-popup">
          <div class="content-wrap">
            <div class="content">
              <p>${item.threeContent}</p>
            </div>
          </div>
          <div class="arrow"></div>
        </div>`
    )
    dynamicHtmlLayer.addOverlay(threeContent)
    window.$viewer.flyToPosition(new DC.Position(item.threePointPosition.lng, item.threePointPosition.lat, 400, 0, -90, 0), () => { }, 3)
  }, item.threetime)
  item.fourPointPosition && (timeFour = setTimeout(() => {
    let FourCenter = DC.Position.fromObject(item.fourPointPosition)
    let fourCircle = new DC.Circle(FourCenter, 10)
    fourCircle.setStyle({
      material: new DC.CircleWaveMaterialProperty({
        color: DC.Color.fromRandom(),
        speed: 20,
        count: 5,
        gradient: 0.5
      })
    })
    dynamicVectorLayer.addOverlay(fourCircle)
    let fourContent = new DC.DivIcon(
      new DC.Position(item.fourPointPosition.lng, item.fourPointPosition.lat, 70),
      `<div class="dynamic-event-profile-map-popup">
          <div class="content-wrap">
            <div class="content">
              <p>${item.fourContent}</p>
              </div>
              </div>
              <div class="arrow"></div>
              </div>`
    )
    dynamicHtmlLayer.addOverlay(fourContent)
    // 执行对应的事件函数
    window.$viewer.flyToPosition(new DC.Position(item.fourPointPosition.lng, item.fourPointPosition.lat, 400, 0, -90, 0), () => { }, 3)
  }, item.fourtime))
  item.fivePointPosition && (timeFive = setTimeout(() => {
    let fiveCenter = DC.Position.fromObject(item.fivePointPosition)
    let fiveCircle = new DC.Circle(fiveCenter, 10)
    fiveCircle.setStyle({
      material: new DC.CircleWaveMaterialProperty({
        color: DC.Color.fromRandom(),
        speed: 20,
        count: 5,
        gradient: 0.5
      })
    })
    dynamicVectorLayer.addOverlay(fiveCircle)
    let fiveContent = new DC.DivIcon(
      new DC.Position(item.fivePointPosition.lng, item.fivePointPosition.lat, 70),
      `<div class="dynamic-event-profile-map-popup">
          <div class="content-wrap">
            <div class="content">
              <p>${item.fiveContent}</p>
              </div>
              </div>
              <div class="arrow"></div>
              </div>`
    )
    dynamicHtmlLayer.addOverlay(fiveContent)
    // 执行对应的事件函数
    window.$viewer.flyToPosition(new DC.Position(item.fivePointPosition.lng, item.fivePointPosition.lat, 400, 0, -90, 0), () => { }, 3)
  }, item.fivetime))
}
const clearAll = () => {
  window.speechSynthesis.cancel()
  lineTime && (clearTimeout(lineTime), lineTime = null)
  timeOne && (clearTimeout(timeOne), timeOne = null)
  timeTwo && (clearTimeout(timeTwo), timeTwo = null)