createBufferGeometryFromObject static method

dynamic createBufferGeometryFromObject(
  1. dynamic object
)

Implementation

static createBufferGeometryFromObject(object) {
  var buffergeometry = three.BufferGeometry();

  var geometry = object.geometry;

  if (object.isPoints || object.isLine) {
    var positions = three.Float32BufferAttribute(geometry.vertices.length * 3, 3, false);
    var colors = three.Float32BufferAttribute(geometry.colors.length * 3, 3, false);

    buffergeometry.setAttribute('position', positions.copyVector3sArray(geometry.vertices));
    buffergeometry.setAttribute('color', colors.copyColorsArray(geometry.colors));

    if (geometry.lineDistances && geometry.lineDistances.length == geometry.vertices.length) {
      var lineDistances = three.Float32BufferAttribute(geometry.lineDistances.length, 1, false);

      buffergeometry.setAttribute('lineDistance', lineDistances.copyArray(geometry.lineDistances));
    }

    if (geometry.boundingSphere != null) {
      buffergeometry.boundingSphere = geometry.boundingSphere.clone();
    }

    if (geometry.boundingBox != null) {
      buffergeometry.boundingBox = geometry.boundingBox.clone();
    }
  } else if (object.isMesh) {
    buffergeometry = geometry.toBufferGeometry();
  }

  return buffergeometry;
}