loadGlb method

  1. @override
Future<ThermionEntity> loadGlb(
  1. String path, {
  2. int numInstances = 1,
})
override

Load the .glb asset at the given path and insert into the scene.

Implementation

@override
Future<ThermionEntity> loadGlb(String path, {int numInstances = 1}) async {
  final promise = _module.ccall(
      "load_glb",
      "int",
      ["void*".toJS, "string".toJS, "int".toJS].toJS,
      [_sceneManager!, path.toJS, numInstances.toJS].toJS,
      {"async": true}.jsify()) as JSPromise<JSNumber>;
  final entityId = (await promise.toDart).toDartInt;
  if (entityId == -1) {
    throw Exception("Failed to load GLB");
  }
  return entityId;
}