fromGlbBytes static method

Future<FlutterSceneVrmAsset> fromGlbBytes(
  1. Uint8List bytes, {
  2. VrmValidationMode validation = VrmValidationMode.strict,
  3. GltfUriResolver? uriResolver,
  4. FlutterSceneVrmBindingOptions? bindingOptions,
  5. bool adoptBytes = false,
  6. int? jointPaletteCapacity,
})

Loads a VRM GLB from bytes into both flvtterm core and Flutter Scene.

With adoptBytes, the parsed model keeps views of bytes instead of copying the BIN chunk; the caller must not change bytes afterwards.

jointPaletteCapacity is the largest skin the renderer animates. A skin over it is replaced per mesh node by the joints that mesh weights (FlutterSceneResolvedImport.skinReduction); null leaves skins as authored and the renderer rejects oversized ones.

Implementation

static Future<FlutterSceneVrmAsset> fromGlbBytes(
  Uint8List bytes, {
  VrmValidationMode validation = VrmValidationMode.strict,
  GltfUriResolver? uriResolver,
  FlutterSceneVrmBindingOptions? bindingOptions,
  bool adoptBytes = false,
  int? jointPaletteCapacity,
}) async {
  final model = VrmModel.parseGlb(
    bytes,
    validation: validation,
    uriResolver: uriResolver,
    adoptBytes: adoptBytes,
  );
  final imported = await importResolvedFlutterSceneGlb(
    bytes,
    model,
    jointPaletteCapacity: jointPaletteCapacity,
  );
  final rootNode = imported.root;
  final corrections = await correctFlutterSceneMaterials(rootNode, model);
  return FlutterSceneVrmAsset._(
    model: model,
    rootNode: rootNode,
    alphaCorrectedMaterialIndices: corrections.alphaCorrectedMaterialIndices,
    straightAlphaTextureIndices: corrections.straightAlphaTextureIndices,
    binding: FlutterSceneVrmBinding.fromRootNode(
      rootNode,
      model: model,
      options: bindingOptions,
      skinReduction: imported.skinReduction,
    ),
  );
}