loadGltf method

  1. @override
Future<ThermionEntity> loadGltf(
  1. String path,
  2. String relativeResourcePath, {
  3. bool force = false,
})
override

Load the .gltf asset at the given path and insert into the scene. relativeResourcePath is the folder path where the glTF resources are stored; this is usually the parent directory of the .gltf file itself.

Implementation

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