replace some async methods with futures, fix setMaterialProperty4, update unproject, setMaterialPropertyInt, createUnlitMaterialInstance
This commit is contained in:
@@ -1147,8 +1147,8 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
set_main_camera(_viewer!);
|
set_main_camera(_viewer!);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ThermionEntity> getMainCamera() async {
|
Future<ThermionEntity> getMainCamera() {
|
||||||
return get_main_camera(_viewer!);
|
return Future.value(get_main_camera(_viewer!));
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -1290,7 +1290,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
Future setCameraPosition(double x, double y, double z) async {
|
Future setCameraPosition(double x, double y, double z) async {
|
||||||
var modelMatrix = await getCameraModelMatrix();
|
var modelMatrix = await getCameraModelMatrix();
|
||||||
modelMatrix.setTranslation(Vector3(x, y, z));
|
modelMatrix.setTranslation(Vector3(x, y, z));
|
||||||
await setCameraModelMatrix4(modelMatrix);
|
return setCameraModelMatrix4(modelMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -1965,22 +1965,22 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
Future setMaterialPropertyFloat4(ThermionEntity entity, String propertyName,
|
Future setMaterialPropertyFloat4(ThermionEntity entity, String propertyName,
|
||||||
int materialIndex, double f1, double f2, double f3, double f4) async {
|
int materialIndex, double f1, double f2, double f3, double f4) async {
|
||||||
final ptr = propertyName.toNativeUtf8(allocator: allocator);
|
final ptr = propertyName.toNativeUtf8(allocator: allocator);
|
||||||
var struct = Struct.create<float4>();
|
var struct = Struct.create<double4>();
|
||||||
struct.x = f1;
|
struct.x = f1;
|
||||||
struct.y = f2;
|
struct.y = f2;
|
||||||
struct.z = f3;
|
struct.z = f3;
|
||||||
struct.w = f3;
|
struct.w = f4;
|
||||||
set_material_property_float4(
|
set_material_property_float4(
|
||||||
_sceneManager!, entity, materialIndex, ptr.cast<Char>(), struct);
|
_sceneManager!, entity, materialIndex, ptr.cast<Char>(), struct);
|
||||||
allocator.free(ptr);
|
allocator.free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> unproject(
|
Future<Uint8List> unproject(ThermionEntity entity, Uint8List input,
|
||||||
ThermionEntity entity, Uint8List input, int inputWidth, int inputHeight, int outWidth, int outHeight) async {
|
int inputWidth, int inputHeight, int outWidth, int outHeight) async {
|
||||||
final outPtr = Uint8List(outWidth * outHeight * 4);
|
final outPtr = Uint8List(outWidth * outHeight * 4);
|
||||||
await withVoidCallback((callback) {
|
await withVoidCallback((callback) {
|
||||||
unproject_texture_ffi(
|
unproject_texture_ffi(_viewer!, entity, input.address, inputWidth,
|
||||||
_viewer!, entity, input.address, inputWidth, inputHeight, outPtr.address, outWidth, outHeight, callback);
|
inputHeight, outPtr.address, outWidth, outHeight, callback);
|
||||||
});
|
});
|
||||||
|
|
||||||
return outPtr.buffer.asUint8List();
|
return outPtr.buffer.asUint8List();
|
||||||
@@ -2098,6 +2098,24 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
ThermionFFIMaterialInstance materialInstance) async {
|
ThermionFFIMaterialInstance materialInstance) async {
|
||||||
destroy_material_instance(_sceneManager!, materialInstance._pointer);
|
destroy_material_instance(_sceneManager!, materialInstance._pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<ThermionFFIMaterialInstance> createUnlitMaterialInstance() async {
|
||||||
|
var instance = create_unlit_material_instance(_sceneManager!);
|
||||||
|
if (instance == nullptr) {
|
||||||
|
throw Exception("Failed to create material instance");
|
||||||
|
}
|
||||||
|
return ThermionFFIMaterialInstance(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future setMaterialPropertyInt(ThermionEntity entity, String propertyName,
|
||||||
|
int materialIndex, int value) {
|
||||||
|
final ptr = propertyName.toNativeUtf8(allocator: allocator);
|
||||||
|
set_material_property_int(
|
||||||
|
_sceneManager!, entity, materialIndex, ptr.cast<Char>(), value);
|
||||||
|
allocator.free(ptr);
|
||||||
|
return Future.value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThermionFFITexture extends ThermionTexture {
|
class ThermionFFITexture extends ThermionTexture {
|
||||||
|
|||||||
Reference in New Issue
Block a user