MeshGeometry.fromMeshData constructor

MeshGeometry.fromMeshData(
  1. MeshData data, {
  2. GeometryStorage storage = GeometryStorage.fixed,
})

Uploads a mesh from a MeshData snapshot built off the render isolate.

The snapshot's CPU work (vertex assembly, normal generation) can run on a background isolate; this constructor performs only the GPU upload. See MeshData for the recipe. storage selects whether the mesh can later be updated in place.

Implementation

factory MeshGeometry.fromMeshData(
  MeshData data, {
  GeometryStorage storage = GeometryStorage.fixed,
}) {
  final geometry = MeshGeometry.fromArrays(
    positions: data.positions,
    normals: data.normals,
    texCoords: data.texCoords,
    colors: data.colors,
    indices: data.indices,
    primitiveType: data.primitiveType,
    storage: storage,
  );
  for (final entry in data.customAttributes.entries) {
    geometry.setCustomAttribute(
      entry.key,
      entry.value.data,
      components: entry.value.components,
    );
  }
  return geometry;
}