parseNurbsGeometry method

dynamic parseNurbsGeometry(
  1. dynamic geoNode
)

Implementation

parseNurbsGeometry(geoNode) {
  var order = int.tryParse(geoNode.Order);

  if (order == null) {
    print('THREE.FBXLoader: Invalid Order ${geoNode.Order} given for geometry ID: ${geoNode.id}');
    return BufferGeometry();
  }

  var degree = order - 1;

  var knots = geoNode.KnotVector.a;
  var controlPoints = [];
  var pointsValues = geoNode.Points.a;

  for (var i = 0, l = pointsValues.length; i < l; i += 4) {
    controlPoints.add(Vector4().fromArray(pointsValues, i));
  }

  var startKnot, endKnot;

  if (geoNode.Form == 'Closed') {
    controlPoints.add(controlPoints[0]);
  } else if (geoNode.Form == 'Periodic') {
    startKnot = degree;
    endKnot = knots.length - 1 - startKnot;

    for (var i = 0; i < degree; ++i) {
      controlPoints.add(controlPoints[i]);
    }
  }

  var curve = NURBSCurve(degree, knots, controlPoints, startKnot, endKnot);
  var points = curve.getPoints(controlPoints.length * 12);

  return BufferGeometry().setFromPoints(points);
}