/**
   * Constructor function
   */
  constructor() {
    super(SIZE, SIZE, SIZE, SIZE)
    this.applyMatrix(new THREE.Matrix4().makeRotationX(-Math.PI / 2))

    const zeroVector = new THREE.Vector3();

    const positions = this.attributes.position.array

    for (let j = 0; j < positions.length; j += 3) {

      positions[j + 0] += random(-2, 2)
      positions[j + 1] = 0
      positions[j + 2] += random(-2, 2)

      const vector = new THREE.Vector3(
        positions[j + 0],
        positions[j + 1],
        positions[j + 2])

      const factor = (-vector.distanceTo(zeroVector) * 0.2) * HEIGHT
      positions[j + 1] += factor  //+ random(2, 5)//simplex.noise3D(positions[j+0]*0.5, positions[j+2]*0.5) * HEIGHT

    }

    this.attributes.position.needsUpdate = true

    this.computeFaceNormals();
    this.computeVertexNormals();
  }
示例#2
0
function addRandomPoints (positions, bounds, count) {
  var min = bounds[0]
  var max = bounds[1]

  for (var i = 0; i < count; i++) {
    positions.push([ // random [ x, y ]
      random(min[0], max[0]),
      random(min[1], max[1])
    ])
  }
}
示例#3
0
 const randomGeoInterval = () => {
   hasNextGeometry = false;
   setTimeout(() => {
     if (!hasNextGeometry) {
       hasNextGeometry = true;
       // fake data for iOS
       geo.nextGeometry();
     }
     randomGeoInterval();
   }, randomFloat(500, 2000));
 };
示例#4
0
 const randomPaletteInterval = () => {
   hasNextPalette = false;
   setTimeout(() => {
     if (!hasNextPalette && !ignorePaletteSwap) {
       hasNextPalette = true;
       // fake data for iOS
       geo.nextPalette();
     }
     randomPaletteInterval();
   }, randomFloat(4000, 8000));
 };