MeshSurfaceSampler constructor

MeshSurfaceSampler(
  1. Mesh mesh
)

Implementation

MeshSurfaceSampler(Mesh mesh) {
  BufferGeometry? geometry = mesh.geometry;

  if (geometry == null || geometry.attributes['position'].itemSize != 3 ) {
    throw ( 'MeshSurfaceSampler: Requires BufferGeometry triangle mesh.' );
  }

  if ( geometry.index == null ) {
    console.warning( 'MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry.' );
    geometry = geometry.toNonIndexed();
  }

  this.geometry = geometry;
  randomFunction = math.Random().nextDouble;
  positionAttribute = this.geometry.getAttributeFromString( 'position' );
  colorAttribute = this.geometry.getAttributeFromString( 'color' );
  weightAttribute = null;
  distribution = null;
}