fixes for createMaterialInstance
This commit is contained in:
@@ -16,6 +16,16 @@ external ffi.Pointer<ffi.Void> make_resource_loader(
|
||||
ffi.Pointer<ffi.Void> owner,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<ffi.Void> Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>)>(isLeaf: true)
|
||||
external ffi.Pointer<ffi.Void> create_filament_viewer(
|
||||
ffi.Pointer<ffi.Void> context,
|
||||
ffi.Pointer<ffi.Void> loader,
|
||||
ffi.Pointer<ffi.Void> platform,
|
||||
ffi.Pointer<ffi.Char> uberArchivePath,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>(isLeaf: true)
|
||||
external void destroy_filament_viewer(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
@@ -211,13 +221,14 @@ external int load_glb(
|
||||
|
||||
@ffi.Native<
|
||||
EntityId Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>, ffi.Size,
|
||||
ffi.Bool, ffi.Int)>(isLeaf: true)
|
||||
ffi.Bool, ffi.Int, ffi.Int)>(isLeaf: true)
|
||||
external int load_glb_from_buffer(
|
||||
ffi.Pointer<ffi.Void> sceneManager,
|
||||
ffi.Pointer<ffi.Void> data,
|
||||
int length,
|
||||
bool keepData,
|
||||
int priority,
|
||||
int layer,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
@@ -418,7 +429,7 @@ external bool set_morph_animation(
|
||||
ffi.Pointer<ffi.Void>, TMaterialKey)>(isLeaf: true)
|
||||
external ffi.Pointer<TMaterialInstance> create_material_instance(
|
||||
ffi.Pointer<ffi.Void> sceneManager,
|
||||
TMaterialKey key,
|
||||
TMaterialKey materialConfig,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
|
||||
@@ -2045,7 +2045,6 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
bool hasVolume = false}) async {
|
||||
final key = Struct.create<TMaterialKey>();
|
||||
|
||||
// Set all the fields of the TMaterialKey struct
|
||||
key.doubleSided = doubleSided;
|
||||
key.unlit = unlit;
|
||||
key.hasVertexColors = hasVertexColors;
|
||||
@@ -2058,7 +2057,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
key.enableDiagnostics = enableDiagnostics;
|
||||
key.unnamed.unnamed.hasMetallicRoughnessTexture =
|
||||
hasMetallicRoughnessTexture;
|
||||
key.unnamed.unnamed.metallicRoughnessUV = metallicRoughnessUV;
|
||||
key.unnamed.unnamed.metallicRoughnessUV = 0;
|
||||
key.baseColorUV = baseColorUV;
|
||||
key.hasClearCoatTexture = hasClearCoatTexture;
|
||||
key.clearCoatUV = clearCoatUV;
|
||||
@@ -2084,14 +2083,11 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
key.hasIOR = hasIOR;
|
||||
key.hasVolume = hasVolume;
|
||||
|
||||
// Assuming there's a method to create the MaterialInstance using the key
|
||||
final materialInstance = create_material_instance(_sceneManager!, key);
|
||||
|
||||
if (materialInstance == nullptr) {
|
||||
throw Exception("Failed to create material instance");
|
||||
}
|
||||
|
||||
// Don't forget to free the memory allocated for the struct
|
||||
return ThermionFFIMaterialInstance(materialInstance);
|
||||
}
|
||||
|
||||
@@ -2100,7 +2096,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
///
|
||||
Future destroyMaterialInstance(
|
||||
ThermionFFIMaterialInstance materialInstance) async {
|
||||
destroy_material_instance(_viewer!, materialInstance._pointer);
|
||||
destroy_material_instance(_sceneManager!, materialInstance._pointer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user