fromAsset static method

Future<GaussianSplats> fromAsset(
  1. String assetPath, {
  2. SplatFormat? format,
  3. double alphaCullThreshold = 1.0 / 255.0,
  4. int maxShDegree = 2,
  5. SplatColorSpace colorSpace = SplatColorSpace.displayReferred,
})

Loads and decodes a splat file from the asset bundle.

The format is sniffed from the file magic, falling back to the asset extension (.ply vs .splat); pass format to override. Decoding and packing run on a background isolate.

Implementation

static Future<GaussianSplats> fromAsset(
  String assetPath, {
  SplatFormat? format,
  double alphaCullThreshold = 1.0 / 255.0,
  int maxShDegree = 2,
  SplatColorSpace colorSpace = SplatColorSpace.displayReferred,
}) async {
  final bytes = await rootBundle.load(assetPath);
  return fromBytes(
    bytes.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes),
    format:
        format ??
        (assetPath.toLowerCase().endsWith('.ply')
            ? SplatFormat.ply
            : SplatFormat.splat),
    alphaCullThreshold: alphaCullThreshold,
    maxShDegree: maxShDegree,
    colorSpace: colorSpace,
  );
}