initVertexData static method

dynamic initVertexData({
  1. dynamic widthsegments = 5,
  2. dynamic heightsegments = 5,
})

Implementation

static initVertexData({widthsegments:5, heightsegments:5})
{
  g = new THREE.PlaneGeometry(1, 1, widthsegments, heightsegments);
  g.rotateX(-math.pi * 0.5);
  _waterVertData = [];
  var v3 = new THREE.Vector3(); // for re-use
  for (var i = 0; i < g.attributes['position'].count; i++) {
    v3.fromBufferAttribute(g.attributes['position'], i);
    _waterVertData.add({
      'initH': v3.y,
      'amplitude': THREE.MathUtils.randFloatSpread(2)/100,
      'phase': THREE.MathUtils.randFloat(0, math.pi)
    });
  }

}