merge method

Sp3dObj merge(
  1. Sp3dObj other
)

(en)Merge another object into this object. This operation is high cost. id, name, author, physics, option, layerNum and drawMode values do not change.

(ja)このオブジェクトに別のオブジェクトをマージします。この操作は高コストです。 このオブジェクト固有のパラメータ(id,name,author,physics)とオプション値、 layerNum、drawModeは変更されません。

  • other : other obj.

Implementation

Sp3dObj merge(Sp3dObj other) {
  Sp3dObj copyOther = other.deepCopy();
  // 追加する各要素のインデックスを変更。
  final int myVerticesLen = vertices.length;
  final int myMaterialLen = materials.length;
  final int myImageLen = images.length;
  for (Sp3dMaterial i in copyOther.materials) {
    if (i.imageIndex != null) {
      i.imageIndex = i.imageIndex! + myImageLen;
    }
  }
  for (Sp3dFragment i in copyOther.fragments) {
    for (Sp3dFace j in i.faces) {
      if (j.materialIndex != null) {
        j.materialIndex = j.materialIndex! + myMaterialLen;
      }
      for (int k = 0; k < j.vertexIndexList.length; k++) {
        j.vertexIndexList[k] += myVerticesLen;
      }
    }
  }
  // 追加
  for (Uint8List i in copyOther.images) {
    images.add(i);
  }
  for (Sp3dMaterial i in copyOther.materials) {
    materials.add(i);
  }
  for (Sp3dV3D i in copyOther.vertices) {
    vertices.add(i);
  }
  for (Sp3dFragment i in copyOther.fragments) {
    fragments.add(i);
  }
  return this;
}