loadGlbFromBuffer method

Future<ThermionEntity> loadGlbFromBuffer(
  1. Uint8List data, {
  2. int numInstances = 1,
})

Implementation

Future<ThermionEntity> loadGlbFromBuffer(Uint8List data,
    {int numInstances = 1}) async {
  if (numInstances != 1) {
    throw Exception("TODO");
  }
  final ptr = _module._malloc(data.length);
  _module.writeArrayToMemory(data.toJS, ptr);

  final result = _module.ccall(
      "load_glb_from_buffer",
      "int",
      ["void*".toJS, "void*".toJS, "size_t".toJS].toJS,
      [_sceneManager!, ptr, data.lengthInBytes.toJS].toJS,
      null) as JSNumber;
  final entityId = result.toDartInt;
  _module._free(ptr);
  if (entityId == -1) {
    throw Exception("Failed to load GLB");
  }
  return entityId;
}