import * as THREE from 'three'
/**
 * @param {Array<Array<number>>} ring - 外环经纬度数组 [[lng,lat], ...]
 * @returns {THREE.LineLoop}
 */
export default function createLine (ring) {
  const vertices = new Float32Array(ring.length * 3)
  ring.forEach((p, i) => {
    vertices[i * 3]     = p[0]      // 经度 -> X
    vertices[i * 3 + 1] = p[1]      // 纬度 -> Y
    vertices[i * 3 + 2] = 0
  })
  const geometry = new THREE.BufferGeometry()
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
  // const material = new THREE.LineBasicMaterial({ color: 0x00cccc })
  const material = new THREE.LineBasicMaterial({ color: 0x00cccc })
  return new THREE.LineLoop(geometry, material)
}
