{"size": 592, "ext": "js", "max_stars_repo_path": "modules/math/src/geometry/attributes/get-attribute-from-geometry.js", "max_stars_repo_name": "andybak/loaders.gl", "max_stars_repo_stars_event_min_datetime": "2019-10-17T02:19:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-25T07:00:01.000Z", "max_issues_repo_path": "modules/math/src/geometry/attributes/get-attribute-from-geometry.js", "max_issues_repo_name": "andybak/loaders.gl", "max_issues_repo_issues_event_min_datetime": "2021-09-02T05:18:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T11:05:43.000Z", "max_forks_repo_path": "modules/math/src/geometry/attributes/get-attribute-from-geometry.js", "max_forks_repo_name": "andybak/loaders.gl", "max_forks_repo_forks_event_min_datetime": "2021-11-17T13:22:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-01T16:27:33.000Z"}
{"max_stars_count": 5, "max_issues_count": 4, "max_forks_count": 6, "avg_line_length": 22.7692307692, "max_line_length": 65, "alphanum_fraction": 0.6841216216}
import isGeometry from '../is-geometry';
import assert from '../utils/assert';

export function getPositions(geometry) {
  // If geometry, extract positions
  if (isGeometry(geometry)) {
    const {attributes} = geometry;
    const position = attributes.POSITION || attributes.positions;
    assert(position);
    return position;
  }

  // If arraybuffer, assume 3 components
  if (ArrayBuffer.isView(geometry)) {
    return {values: geometry, size: 3};
  }

  // Else assume accessor object
  if (geometry) {
    assert(geometry.values);
    return geometry;
  }

  return assert(false);
}
