Flow constructor

Flow(
  1. dynamic mesh, {
  2. dynamic numberOfCurves = 1,
})

@param {Mesh} mesh The mesh to clone and modify to bend around the curve @param {number} numberOfCurves The amount of space that should preallocated for additional curves

Implementation

Flow(mesh, {numberOfCurves = 1}) {
  var obj3D = mesh.clone();
  var splineTexure = initSplineTexture(numberOfCurves: numberOfCurves);
  var uniforms = getUniforms(splineTexure);
  obj3D.traverse((child) {
    if (child is Mesh || child is InstancedMesh) {
      child.material = child.material.clone();
      modifyShader(child.material, uniforms, numberOfCurves: numberOfCurves);
    }
  });

  curveArray = List.filled(numberOfCurves, null);
  curveLengthArray = List.filled(numberOfCurves, null);

  object3D = obj3D;
  this.splineTexure = splineTexure;
  this.uniforms = uniforms;
}