Newer
Older
smartwell_front_dz / src / components / Mars3D / utils / GraphicLayer.js
wangxitong on 8 Jul 1 KB 达州变更
import * as mars3d from 'mars3d'
import Vue from 'vue'

/**
 *  四面体
 * @param graphicLayer
 * @param position
 * @param attr
 */
export function Tetrahedron(graphicLayer, position, attr, style = {}) {
  const tetrahedronPrimitive = new mars3d.graphic.Tetrahedron({
    position: position,
    style: {
      width: 8,
      height: 15,
      color: 'rgba(255,0,0,0.7)',
      moveHeight: 50
    },
    attr: attr
  })
  graphicLayer.addGraphic(tetrahedronPrimitive)
}
export function randomPoint(minJD, maxJD, minWD, maxWD) {
  // 114.882505, 25.778006, 0]
  // const jd = random(114.84 * 1000, 114.89 * 1000) / 1000
  // const wd = random(25.76 * 1000, 25.81 * 1000) / 1000
  const jd = random(minJD * 1000, maxJD * 1000) / 1000
  const wd = random(minWD * 1000, maxWD * 1000) / 1000
  return new mars3d.LngLatPoint(jd, wd, 100)
}

export function random(min, max) {
  return Math.floor(Math.random() * (max - min + 1) + min)
}

/**
 * 垂直飞线
 * @constructor
 */

export function FlyLine(graphicLayer, minJD, maxJD, minWD, maxWD) {
  const arrData = []
  for (let j = 0; j < 100; ++j) {
    const startPt = randomPoint(minJD, maxJD, minWD, maxWD)
    const endPt = startPt.clone()
    endPt.alt = random(1000, 2000)

    arrData.push({
      positions: [startPt, endPt],
      style: {
        width: 1,
        materialType: mars3d.MaterialType.LineFlowColor,
        materialOptions: {
          color: 'rgb(141,172,172)',
          speed: random(5, 10),
          startTime: random(1000, 3000),
          percent: 0.1,
          alpha: 0.01
        }
      }
    })
  }
  const upPoly = new mars3d.graphic.PolylineCombine({
    instances: arrData
  })
  graphicLayer.addGraphic(upPoly)
}