three#CurvePath JavaScript Examples

The following examples show how to use three#CurvePath. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Geo.js    From CUBE.gl with MIT License 5 votes vote down vote up
function addRoadFat(d, terrain) {
  const curves = new CurvePath();
  let lastPoint = null;

  // Loop for all nodes
  for (let i = 0; i < d.length; i++) {
    if (!d[0][1]) return

    const el = d[i]

    // Just in case
    if (!el[0] || !el[1]) return

    let elp = [el[0], el[1]]

    // convert position from the center position
    elp = new Coordinate('GPS', { latitude: elp[1], longitude: elp[0] }).ComputeWorldCoordinate()

    // WAIT FOR MERGE adjust height according to terrain data
    // Rotate
    const vector = new THREE.Vector3(elp.world.x, elp.world.y, elp.world.z)
    const axis = new THREE.Vector3(0, 0, 1)
    const angle = Math.PI

    vector.applyAxisAngle(axis, angle)

    let y = 0

    if (terrain) {
      const dem = shortEst({ x: vector.x, z: vector.z }, terrain.vertices)
      if (dem) {
        y = -dem.y
      }
    }

    // Draw Line in Pair [1,1], [1,2], [1,2], [2,5], [2,5], [3,6]
    const thisPoint = new THREE.Vector3(elp.world.x, elp.world.y + y, elp.world.z);
    if(lastPoint) {
      const curve = new THREE.LineCurve3(lastPoint, thisPoint)
      curves.add(curve)
    }
    lastPoint = thisPoint;
    // if (i !== 0 && i !== d.length - 1) points.push(new THREE.Vector3(elp.world.x, elp.world.y + y, elp.world.z))
  }

  return curves
}