# readFile

Function

Source: https://github.com/playcanvas/splat-transform/blob/b6424a5b3b929695fbaafe738a995adb1240d675/src/lib/read.ts#L138

```ts
readFile(readFileOptions: ReadFileOptions): Promise<ChunkSource[]>
```

Reads a Gaussian splat file and returns its data as [ChunkSource](https://api.playcanvas.com/splat-transform/interfaces/ChunkSource.md)s
(usually one; a Streamed SOG/LCC/LCC2 container yields a single structural multi-LOD source).

Readers are chunk-native: `ply`/`splat`/`spz`/`lcc`/`lcc2`/`lod` return lazy /
streaming sources whose `close()` releases the underlying file(s); whole-blob
formats (`sog`/`mjs`/`ksplat`) are decoded up front and returned resident.
Callers that need a `DataTable` materialize at their own boundary (and call
`source.close()` when done).

Per-format progress (decoding bars, multi-payload bars) is emitted directly
by each reader through the global [logger](https://api.playcanvas.com/splat-transform/variables/logger.md); install a renderer via
`logger.setRenderer(...)` to consume those events.

**Parameters**

- `readFileOptions` ([`ReadFileOptions`](https://api.playcanvas.com/splat-transform/types/ReadFileOptions.md)): Options specifying the file to read and how to read it.

**Returns** `Promise<`[`ChunkSource`](https://api.playcanvas.com/splat-transform/interfaces/ChunkSource.md)`[]>`: Promise resolving to an array of chunk sources containing the splat data.

**Example**

```ts
import { readFile, getInputFormat, UrlReadFileSystem } from '@playcanvas/splat-transform';

const filename = 'scene.ply';
const fileSystem = new UrlReadFileSystem('https://example.com/');
const sources = await readFile({
    filename,
    inputFormat: getInputFormat(filename),
    fileSystem
});
```
