Fix typos and comments in FilamentControllerFFI
and AnimationBuilder classes
This commit is contained in:
@@ -125,7 +125,7 @@ class AnimationBuilder {
|
||||
|
||||
// _BoneAnimationDatas!.add(DartBoneAnimationData([boneName], [meshName], animData));
|
||||
|
||||
return this;
|
||||
// return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,10 +114,10 @@ class FilamentControllerFFI extends FilamentController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future setDimensions(Rect rect, double ratio) async {
|
||||
Future setDimensions(Rect rect, double pixelRatio) async {
|
||||
this.rect.value = Rect.fromLTWH(rect.left, rect.top,
|
||||
rect.width * _pixelRatio, rect.height * _pixelRatio);
|
||||
_pixelRatio = ratio;
|
||||
_pixelRatio = pixelRatio;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -190,7 +190,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
print("Got rendering surface");
|
||||
|
||||
_viewer = _lib.create_filament_viewer_ffi(
|
||||
Pointer<Void>.fromAddress(renderingSurface.sharedContext ?? 0),
|
||||
Pointer<Void>.fromAddress(renderingSurface.sharedContext),
|
||||
_driver,
|
||||
uberArchivePath?.toNativeUtf8().cast<Char>() ?? nullptr,
|
||||
loader,
|
||||
@@ -557,7 +557,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
|
||||
@override
|
||||
Future setMorphTargetWeights(
|
||||
FilamentEntity asset, String meshName, List<double> weights) async {
|
||||
FilamentEntity entity, String meshName, List<double> weights) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
@@ -566,23 +566,23 @@ class FilamentControllerFFI extends FilamentController {
|
||||
for (int i = 0; i < weights.length; i++) {
|
||||
weightsPtr.elementAt(i).value = weights[i];
|
||||
}
|
||||
_lib.set_morph_target_weights_ffi(_assetManager!, asset,
|
||||
_lib.set_morph_target_weights_ffi(_assetManager!, entity,
|
||||
meshName.toNativeUtf8().cast<Char>(), weightsPtr, weights.length);
|
||||
calloc.free(weightsPtr);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> getMorphTargetNames(
|
||||
FilamentEntity asset, String meshName) async {
|
||||
FilamentEntity entity, String meshName) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
var names = <String>[];
|
||||
var count = _lib.get_morph_target_name_count_ffi(
|
||||
_assetManager!, asset, meshName.toNativeUtf8().cast<Char>());
|
||||
_assetManager!, entity, meshName.toNativeUtf8().cast<Char>());
|
||||
var outPtr = calloc<Char>(255);
|
||||
for (int i = 0; i < count; i++) {
|
||||
_lib.get_morph_target_name(_assetManager!, asset,
|
||||
_lib.get_morph_target_name(_assetManager!, entity,
|
||||
meshName.toNativeUtf8().cast<Char>(), outPtr, i);
|
||||
names.add(outPtr.cast<Utf8>().toDartString());
|
||||
}
|
||||
@@ -591,15 +591,15 @@ class FilamentControllerFFI extends FilamentController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<String>> getAnimationNames(FilamentEntity asset) async {
|
||||
Future<List<String>> getAnimationNames(FilamentEntity entity) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
var animationCount = _lib.get_animation_count(_assetManager!, asset);
|
||||
var animationCount = _lib.get_animation_count(_assetManager!, entity);
|
||||
var names = <String>[];
|
||||
var outPtr = calloc<Char>(255);
|
||||
for (int i = 0; i < animationCount; i++) {
|
||||
_lib.get_animation_name_ffi(_assetManager!, asset, outPtr, i);
|
||||
_lib.get_animation_name_ffi(_assetManager!, entity, outPtr, i);
|
||||
names.add(outPtr.cast<Utf8>().toDartString());
|
||||
}
|
||||
|
||||
@@ -663,7 +663,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
|
||||
@override
|
||||
Future setBoneAnimation(
|
||||
FilamentEntity asset, BoneAnimationData animation) async {
|
||||
FilamentEntity entity, BoneAnimationData animation) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
@@ -700,11 +700,11 @@ class FilamentControllerFFI extends FilamentController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future removeAsset(FilamentEntity asset) async {
|
||||
Future removeAsset(FilamentEntity entity) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.remove_asset_ffi(_viewer!, asset);
|
||||
_lib.remove_asset_ffi(_viewer!, entity);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -740,7 +740,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future playAnimation(FilamentEntity asset, int index,
|
||||
Future playAnimation(FilamentEntity entity, int index,
|
||||
{bool loop = false,
|
||||
bool reverse = false,
|
||||
bool replaceActive = true,
|
||||
@@ -749,33 +749,33 @@ class FilamentControllerFFI extends FilamentController {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.play_animation_ffi(
|
||||
_assetManager!, asset, index, loop, reverse, replaceActive, crossfade);
|
||||
_assetManager!, entity, index, loop, reverse, replaceActive, crossfade);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setAnimationFrame(
|
||||
FilamentEntity asset, int index, int animationFrame) async {
|
||||
FilamentEntity entity, int index, int animationFrame) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.set_animation_frame(_assetManager!, asset, index, animationFrame);
|
||||
_lib.set_animation_frame(_assetManager!, entity, index, animationFrame);
|
||||
}
|
||||
|
||||
@override
|
||||
Future stopAnimation(FilamentEntity asset, int animationIndex) async {
|
||||
Future stopAnimation(FilamentEntity entity, int animationIndex) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.stop_animation(_assetManager!, asset, animationIndex);
|
||||
_lib.stop_animation(_assetManager!, entity, animationIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setCamera(FilamentEntity asset, String? name) async {
|
||||
Future setCamera(FilamentEntity entity, String? name) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
var result = _lib.set_camera(
|
||||
_viewer!, asset, name?.toNativeUtf8().cast<Char>() ?? nullptr);
|
||||
_viewer!, entity, name?.toNativeUtf8().cast<Char>() ?? nullptr);
|
||||
if (!result) {
|
||||
throw Exception("Failed to set camera");
|
||||
}
|
||||
@@ -832,11 +832,11 @@ class FilamentControllerFFI extends FilamentController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future moveCameraToAsset(FilamentEntity asset) async {
|
||||
Future moveCameraToAsset(FilamentEntity entity) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.move_camera_to_asset(_viewer!, asset);
|
||||
_lib.move_camera_to_asset(_viewer!, entity);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -879,47 +879,48 @@ class FilamentControllerFFI extends FilamentController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future setMaterialColor(FilamentEntity asset, String meshName,
|
||||
Future setMaterialColor(FilamentEntity entity, String meshName,
|
||||
int materialIndex, Color color) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
var result = _lib.set_material_color(
|
||||
_assetManager!,
|
||||
asset,
|
||||
entity,
|
||||
meshName.toNativeUtf8().cast<Char>(),
|
||||
materialIndex,
|
||||
color.red.toDouble() / 255.0,
|
||||
color.green.toDouble() / 255.0,
|
||||
color.blue.toDouble() / 255.0,
|
||||
color.alpha.toDouble() / 255.0);
|
||||
if (result != 1) {
|
||||
if (!result) {
|
||||
throw Exception("Failed to set material color");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future transformToUnitCube(FilamentEntity asset) async {
|
||||
Future transformToUnitCube(FilamentEntity entity) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.transform_to_unit_cube(_assetManager!, asset);
|
||||
_lib.transform_to_unit_cube(_assetManager!, entity);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setPosition(FilamentEntity asset, double x, double y, double z) async {
|
||||
Future setPosition(
|
||||
FilamentEntity entity, double x, double y, double z) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.set_position(_assetManager!, asset, x, y, z);
|
||||
_lib.set_position(_assetManager!, entity, x, y, z);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setScale(FilamentEntity asset, double scale) async {
|
||||
Future setScale(FilamentEntity entity, double scale) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
_lib.set_scale(_assetManager!, asset, scale);
|
||||
_lib.set_scale(_assetManager!, entity, scale);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -942,12 +943,12 @@ class FilamentControllerFFI extends FilamentController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future reveal(FilamentEntity asset, String meshName) async {
|
||||
Future reveal(FilamentEntity entity, String meshName) async {
|
||||
if (_viewer == null) {
|
||||
throw Exception("No viewer available, ignoring");
|
||||
}
|
||||
if (_lib.reveal_mesh(
|
||||
_assetManager!, asset, meshName.toNativeUtf8().cast<Char>()) !=
|
||||
_assetManager!, entity, meshName.toNativeUtf8().cast<Char>()) !=
|
||||
1) {
|
||||
throw Exception("Failed to reveal mesh $meshName");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user