From b5fffe617ee043aa49608a1f847ae6f07330f6e0 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Tue, 7 Nov 2023 13:15:12 +0800 Subject: [PATCH] use ffi-native for generated bindings --- lib/filament_controller_ffi.dart | 161 +- lib/generated_bindings.dart | 3401 ++++++++++-------------------- pubspec.yaml | 3 +- 3 files changed, 1174 insertions(+), 2391 deletions(-) diff --git a/lib/filament_controller_ffi.dart b/lib/filament_controller_ffi.dart index 9a8dc411..4b416437 100644 --- a/lib/filament_controller_ffi.dart +++ b/lib/filament_controller_ffi.dart @@ -28,8 +28,6 @@ class FilamentControllerFFI extends FilamentController { late Pointer? _assetManager; - late NativeLibrary _lib; - Pointer? _viewer; final String? uberArchivePath; @@ -80,7 +78,7 @@ class FilamentControllerFFI extends FilamentController { } else { dl = DynamicLibrary.open("libflutter_filament_android.so"); } - _lib = NativeLibrary(dl); + if (Platform.isWindows) { _channel.invokeMethod("usesBackingWindow").then((result) { _usesBackingWindow = result; @@ -98,7 +96,7 @@ class FilamentControllerFFI extends FilamentController { throw Exception("No viewer available, ignoring"); } _rendering = render; - _lib.set_rendering_ffi(_viewer!, render); + set_rendering_ffi(_viewer!, render); } @override @@ -106,12 +104,12 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.render_ffi(_viewer!); + render_ffi(_viewer!); } @override Future setFrameRate(int framerate) async { - _lib.set_frame_interval_ffi(1.0 / framerate); + set_frame_interval_ffi(1.0 / framerate); } @override @@ -137,7 +135,7 @@ class FilamentControllerFFI extends FilamentController { _viewer = null; _assetManager = null; - _lib.destroy_filament_viewer_ffi(viewer!); + destroy_filament_viewer_ffi(viewer!); hasViewer.value = false; } @@ -190,7 +188,7 @@ class FilamentControllerFFI extends FilamentController { dev.log("Got rendering surface"); - _viewer = _lib.create_filament_viewer_ffi( + _viewer = create_filament_viewer_ffi( Pointer.fromAddress(renderingSurface.sharedContext), _driver, uberArchivePath?.toNativeUtf8().cast() ?? nullptr, @@ -202,15 +200,15 @@ class FilamentControllerFFI extends FilamentController { throw Exception("Failed to create viewer. Check logs for details"); } - _assetManager = _lib.get_asset_manager(_viewer!); + _assetManager = get_asset_manager(_viewer!); - _lib.create_swap_chain_ffi(_viewer!, renderingSurface.surface, + create_swap_chain_ffi(_viewer!, renderingSurface.surface, rect.value!.width.toInt(), rect.value!.height.toInt()); dev.log("Created swap chain"); if (renderingSurface.textureHandle != 0) { dev.log( "Creating render target from native texture ${renderingSurface.textureHandle}"); - _lib.create_render_target_ffi(_viewer!, renderingSurface.textureHandle, + create_render_target_ffi(_viewer!, renderingSurface.textureHandle, rect.value!.width.toInt(), rect.value!.height.toInt()); } @@ -219,7 +217,7 @@ class FilamentControllerFFI extends FilamentController { width: rect.value!.width.toInt(), height: rect.value!.height.toInt()); dev.log("texture details ${textureDetails.value}"); - _lib.update_viewport_and_camera_projection_ffi( + update_viewport_and_camera_projection_ffi( _viewer!, rect.value!.width.toInt(), rect.value!.height.toInt(), 1.0); hasViewer.value = true; } @@ -310,10 +308,10 @@ class FilamentControllerFFI extends FilamentController { _resizing = true; - _lib.set_rendering_ffi(_viewer!, false); + set_rendering_ffi(_viewer!, false); if (!_usesBackingWindow) { - _lib.destroy_swap_chain_ffi(_viewer!); + destroy_swap_chain_ffi(_viewer!); } if (requiresTextureWidget) { @@ -337,17 +335,17 @@ class FilamentControllerFFI extends FilamentController { throw Exception("Failed to create viewer. Check logs for details"); } - _assetManager = _lib.get_asset_manager(_viewer!); + _assetManager = get_asset_manager(_viewer!); if (!_usesBackingWindow) { - _lib.create_swap_chain_ffi(_viewer!, renderingSurface.surface, + create_swap_chain_ffi(_viewer!, renderingSurface.surface, rect.value!.width.toInt(), rect.value!.height.toInt()); } if (renderingSurface.textureHandle != 0) { dev.log( "Creating render target from native texture ${renderingSurface.textureHandle}"); - _lib.create_render_target_ffi(_viewer!, renderingSurface.textureHandle, + create_render_target_ffi(_viewer!, renderingSurface.textureHandle, rect.value!.width.toInt(), rect.value!.height.toInt()); } @@ -356,7 +354,7 @@ class FilamentControllerFFI extends FilamentController { width: rect.value!.width.toInt(), height: rect.value!.height.toInt()); - _lib.update_viewport_and_camera_projection_ffi( + update_viewport_and_camera_projection_ffi( _viewer!, rect.value!.width.toInt(), rect.value!.height.toInt(), 1.0); await setRendering(_rendering); @@ -369,7 +367,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.clear_background_image_ffi(_viewer!); + clear_background_image_ffi(_viewer!); } @override @@ -377,7 +375,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_background_image_ffi( + set_background_image_ffi( _viewer!, path.toNativeUtf8().cast(), fillHeight); } @@ -386,7 +384,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_background_color_ffi( + set_background_color_ffi( _viewer!, color.red.toDouble() / 255.0, color.green.toDouble() / 255.0, @@ -400,7 +398,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_background_image_position_ffi(_viewer!, x, y, clamp); + set_background_image_position_ffi(_viewer!, x, y, clamp); } @override @@ -408,7 +406,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.load_skybox_ffi(_viewer!, skyboxPath.toNativeUtf8().cast()); + load_skybox_ffi(_viewer!, skyboxPath.toNativeUtf8().cast()); } @override @@ -416,8 +414,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.load_ibl_ffi( - _viewer!, lightingPath.toNativeUtf8().cast(), intensity); + load_ibl_ffi(_viewer!, lightingPath.toNativeUtf8().cast(), intensity); } @override @@ -425,7 +422,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.remove_skybox_ffi(_viewer!); + remove_skybox_ffi(_viewer!); } @override @@ -433,7 +430,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.remove_ibl_ffi(_viewer!); + remove_ibl_ffi(_viewer!); } @override @@ -451,8 +448,8 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - var entity = _lib.add_light_ffi(_viewer!, type, colour, intensity, posX, - posY, posZ, dirX, dirY, dirZ, castShadows); + var entity = add_light_ffi(_viewer!, type, colour, intensity, posX, posY, + posZ, dirX, dirY, dirZ, castShadows); return entity; } @@ -461,7 +458,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.remove_light_ffi(_viewer!, light); + remove_light_ffi(_viewer!, light); } @override @@ -469,7 +466,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.clear_lights_ffi(_viewer!); + clear_lights_ffi(_viewer!); } @override @@ -480,8 +477,8 @@ class FilamentControllerFFI extends FilamentController { if (unlit) { throw Exception("Not yet implemented"); } - var asset = _lib.load_glb_ffi( - _assetManager!, path.toNativeUtf8().cast(), unlit); + var asset = + load_glb_ffi(_assetManager!, path.toNativeUtf8().cast(), unlit); if (asset == _FILAMENT_ASSET_ERROR) { throw Exception("An error occurred loading the asset at $path"); } @@ -498,9 +495,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - var asset = _lib.load_gltf_ffi( - _assetManager!, - path.toNativeUtf8().cast(), + var asset = load_gltf_ffi(_assetManager!, path.toNativeUtf8().cast(), relativeResourcePath.toNativeUtf8().cast()); if (asset == _FILAMENT_ASSET_ERROR) { throw Exception("An error occurred loading the asset at $path"); @@ -513,7 +508,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, true); + grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, true); } @override @@ -521,7 +516,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.grab_update(_viewer!, x * _pixelRatio, y * _pixelRatio); + grab_update(_viewer!, x * _pixelRatio, y * _pixelRatio); } @override @@ -529,7 +524,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.grab_end(_viewer!); + grab_end(_viewer!); } @override @@ -537,7 +532,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, false); + grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, false); } @override @@ -545,7 +540,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.grab_update(_viewer!, x * _pixelRatio, y * _pixelRatio); + grab_update(_viewer!, x * _pixelRatio, y * _pixelRatio); } @override @@ -553,7 +548,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.grab_end(_viewer!); + grab_end(_viewer!); } @override @@ -567,7 +562,7 @@ 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!, entity, + set_morph_target_weights_ffi(_assetManager!, entity, meshName.toNativeUtf8().cast(), weightsPtr, weights.length); calloc.free(weightsPtr); } @@ -579,11 +574,11 @@ class FilamentControllerFFI extends FilamentController { throw Exception("No viewer available, ignoring"); } var names = []; - var count = _lib.get_morph_target_name_count_ffi( + var count = get_morph_target_name_count_ffi( _assetManager!, entity, meshName.toNativeUtf8().cast()); var outPtr = calloc(255); for (int i = 0; i < count; i++) { - _lib.get_morph_target_name(_assetManager!, entity, + get_morph_target_name(_assetManager!, entity, meshName.toNativeUtf8().cast(), outPtr, i); names.add(outPtr.cast().toDartString()); } @@ -596,11 +591,11 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - var animationCount = _lib.get_animation_count(_assetManager!, entity); + var animationCount = get_animation_count(_assetManager!, entity); var names = []; var outPtr = calloc(255); for (int i = 0; i < animationCount; i++) { - _lib.get_animation_name_ffi(_assetManager!, entity, outPtr, i); + get_animation_name_ffi(_assetManager!, entity, outPtr, i); names.add(outPtr.cast().toDartString()); } @@ -614,7 +609,7 @@ class FilamentControllerFFI extends FilamentController { throw Exception("No viewer available, ignoring"); } var duration = - _lib.get_animation_duration(_assetManager!, entity, animationIndex); + get_animation_duration(_assetManager!, entity, animationIndex); return duration; } @@ -649,7 +644,7 @@ class FilamentControllerFFI extends FilamentController { idxPtr.elementAt(i).value = index; } - _lib.set_morph_animation( + set_morph_animation( _assetManager!, entity, animation.meshName.toNativeUtf8().cast(), @@ -705,7 +700,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.remove_asset_ffi(_viewer!, entity); + remove_asset_ffi(_viewer!, entity); } @override @@ -713,7 +708,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.clear_assets_ffi(_viewer!); + clear_assets_ffi(_viewer!); } @override @@ -721,7 +716,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.scroll_begin(_viewer!); + scroll_begin(_viewer!); } @override @@ -729,7 +724,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.scroll_update(_viewer!, x, y, z); + scroll_update(_viewer!, x, y, z); } @override @@ -737,7 +732,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.scroll_end(_viewer!); + scroll_end(_viewer!); } @override @@ -749,7 +744,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.play_animation_ffi( + play_animation_ffi( _assetManager!, entity, index, loop, reverse, replaceActive, crossfade); } @@ -759,7 +754,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_animation_frame(_assetManager!, entity, index, animationFrame); + set_animation_frame(_assetManager!, entity, index, animationFrame); } @override @@ -767,7 +762,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.stop_animation(_assetManager!, entity, animationIndex); + stop_animation(_assetManager!, entity, animationIndex); } @override @@ -775,7 +770,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - var result = _lib.set_camera( + var result = set_camera( _viewer!, entity, name?.toNativeUtf8().cast() ?? nullptr); if (!result) { throw Exception("Failed to set camera"); @@ -788,7 +783,7 @@ class FilamentControllerFFI extends FilamentController { throw Exception("No viewer available, ignoring"); } - _lib.set_tone_mapping_ffi(_viewer!, mapper.index); + set_tone_mapping_ffi(_viewer!, mapper.index); } @override @@ -797,7 +792,7 @@ class FilamentControllerFFI extends FilamentController { throw Exception("No viewer available, ignoring"); } - _lib.set_post_processing_ffi(_viewer!, enabled); + set_post_processing_ffi(_viewer!, enabled); } @override @@ -805,7 +800,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_bloom_ffi(_viewer!, bloom); + set_bloom_ffi(_viewer!, bloom); } @override @@ -813,7 +808,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_camera_focal_length(_viewer!, focalLength); + set_camera_focal_length(_viewer!, focalLength); } @override @@ -821,7 +816,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_camera_focus_distance(_viewer!, focusDistance); + set_camera_focus_distance(_viewer!, focusDistance); } @override @@ -829,7 +824,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_camera_position(_viewer!, x, y, z); + set_camera_position(_viewer!, x, y, z); } @override @@ -837,7 +832,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.move_camera_to_asset(_viewer!, entity); + move_camera_to_asset(_viewer!, entity); } @override @@ -845,7 +840,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_view_frustum_culling(_viewer!, enabled); + set_view_frustum_culling(_viewer!, enabled); } @override @@ -854,7 +849,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_camera_exposure(_viewer!, aperture, shutterSpeed, sensitivity); + set_camera_exposure(_viewer!, aperture, shutterSpeed, sensitivity); } @override @@ -862,7 +857,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_camera_rotation(_viewer!, rads, x, y, z); + set_camera_rotation(_viewer!, rads, x, y, z); } @override @@ -875,7 +870,7 @@ class FilamentControllerFFI extends FilamentController { for (int i = 0; i < 16; i++) { ptr.elementAt(i).value = matrix[i]; } - _lib.set_camera_model_matrix(_viewer!, ptr); + set_camera_model_matrix(_viewer!, ptr); calloc.free(ptr); } @@ -885,7 +880,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - var result = _lib.set_material_color( + var result = set_material_color( _assetManager!, entity, meshName.toNativeUtf8().cast(), @@ -904,7 +899,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.transform_to_unit_cube(_assetManager!, entity); + transform_to_unit_cube(_assetManager!, entity); } @override @@ -913,7 +908,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_position(_assetManager!, entity, x, y, z); + set_position(_assetManager!, entity, x, y, z); } @override @@ -921,7 +916,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_scale(_assetManager!, entity, scale); + set_scale(_assetManager!, entity, scale); } @override @@ -930,7 +925,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - _lib.set_rotation(_assetManager!, entity, rads, x, y, z); + set_rotation(_assetManager!, entity, rads, x, y, z); } @override @@ -938,7 +933,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - if (_lib.hide_mesh( + if (hide_mesh( _assetManager!, entity, meshName.toNativeUtf8().cast()) != 1) {} } @@ -948,7 +943,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available, ignoring"); } - if (_lib.reveal_mesh( + if (reveal_mesh( _assetManager!, entity, meshName.toNativeUtf8().cast()) != 1) { throw Exception("Failed to reveal mesh $meshName"); @@ -957,7 +952,7 @@ class FilamentControllerFFI extends FilamentController { @override String? getNameForEntity(FilamentEntity entity) { - final result = _lib.get_name_for_entity(_assetManager!, entity); + final result = get_name_for_entity(_assetManager!, entity); if (result == nullptr) { return null; } @@ -972,7 +967,7 @@ class FilamentControllerFFI extends FilamentController { final outPtr = calloc(1); outPtr.value = 0; - _lib.pick_ffi(_viewer!, x, textureDetails.value!.height - y, outPtr); + pick_ffi(_viewer!, x, textureDetails.value!.height - y, outPtr); int wait = 0; while (outPtr.value == 0) { await Future.delayed(const Duration(milliseconds: 32)); @@ -992,7 +987,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available"); } - var arrayPtr = _lib.get_camera_view_matrix(_viewer!); + var arrayPtr = get_camera_view_matrix(_viewer!); var viewMatrix = Matrix4.fromList(arrayPtr.asTypedList(16)); calloc.free(arrayPtr); return viewMatrix; @@ -1003,7 +998,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available"); } - var arrayPtr = _lib.get_camera_model_matrix(_viewer!); + var arrayPtr = get_camera_model_matrix(_viewer!); var modelMatrix = Matrix4.fromList(arrayPtr.asTypedList(16)); calloc.free(arrayPtr); return modelMatrix; @@ -1014,7 +1009,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available"); } - var arrayPtr = _lib.get_camera_model_matrix(_viewer!); + var arrayPtr = get_camera_model_matrix(_viewer!); var doubleList = arrayPtr.asTypedList(16); var modelMatrix = Matrix4.fromFloat64List(doubleList); @@ -1029,7 +1024,7 @@ class FilamentControllerFFI extends FilamentController { if (_viewer == null) { throw Exception("No viewer available"); } - var arrayPtr = _lib.get_camera_model_matrix(_viewer!); + var arrayPtr = get_camera_model_matrix(_viewer!); var doubleList = arrayPtr.asTypedList(16); var modelMatrix = Matrix4.fromFloat64List(doubleList); var rotationMatrix = Matrix3.identity(); @@ -1050,7 +1045,7 @@ class FilamentControllerFFI extends FilamentController { if (mode != ManipulatorMode.ORBIT) { throw Exception("Manipulator mode $mode not yet implemented"); } - _lib.set_camera_manipulator_options( + set_camera_manipulator_options( _viewer!, mode.index, orbitSpeedX, orbitSpeedX, zoomSpeed); } } diff --git a/lib/generated_bindings.dart b/lib/generated_bindings.dart index 55e43d0c..4ec21a12 100644 --- a/lib/generated_bindings.dart +++ b/lib/generated_bindings.dart @@ -1,2339 +1,1126 @@ // AUTO GENERATED FILE, DO NOT EDIT. // // Generated by `package:ffigen`. -// ignore_for_file: type=lint, unused_element, unused_field +// ignore_for_file: type=lint import 'dart:ffi' as ffi; -class NativeLibrary { - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + symbol: 'create_filament_viewer', assetId: 'libflutter_filament') +external ffi.Pointer create_filament_viewer( + ffi.Pointer context, + ffi.Pointer loader, + ffi.Pointer platform, + ffi.Pointer uberArchivePath, +); - /// The symbols are looked up in [dynamicLibrary]. - NativeLibrary(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; +@ffi.Native)>( + symbol: 'destroy_filament_viewer', assetId: 'libflutter_filament') +external void destroy_filament_viewer( + ffi.Pointer viewer, +); - /// The symbols are looked up with [lookup]. - NativeLibrary.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) - : _lookup = lookup; +@ffi.Native< + ffi.Pointer Function( + LoadFilamentResourceFromOwner, + FreeFilamentResourceFromOwner, + ffi.Pointer)>( + symbol: 'make_resource_loader', assetId: 'libflutter_filament') +external ffi.Pointer make_resource_loader( + LoadFilamentResourceFromOwner loadFn, + FreeFilamentResourceFromOwner freeFn, + ffi.Pointer owner, +); - ffi.Pointer create_filament_viewer( - ffi.Pointer context, - ffi.Pointer loader, - ffi.Pointer platform, - ffi.Pointer uberArchivePath, - ) { - return _create_filament_viewer( - context, - loader, - platform, - uberArchivePath, - ); - } +@ffi.Native Function(ffi.Pointer)>( + symbol: 'get_asset_manager', assetId: 'libflutter_filament') +external ffi.Pointer get_asset_manager( + ffi.Pointer viewer, +); - late final _create_filament_viewerPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>>('create_filament_viewer'); - late final _create_filament_viewer = _create_filament_viewerPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.IntPtr, ffi.Uint32, ffi.Uint32)>( + symbol: 'create_render_target', assetId: 'libflutter_filament') +external void create_render_target( + ffi.Pointer viewer, + int texture, + int width, + int height, +); - void destroy_filament_viewer( - ffi.Pointer viewer, - ) { - return _destroy_filament_viewer( - viewer, - ); - } +@ffi.Native)>( + symbol: 'clear_background_image', assetId: 'libflutter_filament') +external void clear_background_image( + ffi.Pointer viewer, +); - late final _destroy_filament_viewerPtr = - _lookup)>>( - 'destroy_filament_viewer'); - late final _destroy_filament_viewer = _destroy_filament_viewerPtr - .asFunction)>(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Bool)>( + symbol: 'set_background_image', assetId: 'libflutter_filament') +external void set_background_image( + ffi.Pointer viewer, + ffi.Pointer path, + bool fillHeight, +); - ffi.Pointer make_resource_loader( - LoadFilamentResourceFromOwner loadFn, - FreeFilamentResourceFromOwner freeFn, - ffi.Pointer owner, - ) { - return _make_resource_loader( - loadFn, - freeFn, - owner, - ); - } +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Bool)>( + symbol: 'set_background_image_position', assetId: 'libflutter_filament') +external void set_background_image_position( + ffi.Pointer viewer, + double x, + double y, + bool clamp, +); - late final _make_resource_loaderPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - LoadFilamentResourceFromOwner, - FreeFilamentResourceFromOwner, - ffi.Pointer)>>('make_resource_loader'); - late final _make_resource_loader = _make_resource_loaderPtr.asFunction< - ffi.Pointer Function(LoadFilamentResourceFromOwner, - FreeFilamentResourceFromOwner, ffi.Pointer)>(); +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Float, ffi.Float)>( + symbol: 'set_background_color', assetId: 'libflutter_filament') +external void set_background_color( + ffi.Pointer viewer, + double r, + double g, + double b, + double a, +); - ffi.Pointer get_asset_manager( - ffi.Pointer viewer, - ) { - return _get_asset_manager( - viewer, - ); - } +@ffi.Native, ffi.Int)>( + symbol: 'set_tone_mapping', assetId: 'libflutter_filament') +external void set_tone_mapping( + ffi.Pointer viewer, + int toneMapping, +); - late final _get_asset_managerPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('get_asset_manager'); - late final _get_asset_manager = _get_asset_managerPtr - .asFunction Function(ffi.Pointer)>(); +@ffi.Native, ffi.Float)>( + symbol: 'set_bloom', assetId: 'libflutter_filament') +external void set_bloom( + ffi.Pointer viewer, + double strength, +); - void create_render_target( - ffi.Pointer viewer, - int texture, - int width, - int height, - ) { - return _create_render_target( - viewer, - texture, - width, - height, - ); - } +@ffi.Native, ffi.Pointer)>( + symbol: 'load_skybox', assetId: 'libflutter_filament') +external void load_skybox( + ffi.Pointer viewer, + ffi.Pointer skyboxPath, +); - late final _create_render_targetPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.IntPtr, ffi.Uint32, - ffi.Uint32)>>('create_render_target'); - late final _create_render_target = _create_render_targetPtr - .asFunction, int, int, int)>(); +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Float)>(symbol: 'load_ibl', assetId: 'libflutter_filament') +external void load_ibl( + ffi.Pointer viewer, + ffi.Pointer iblPath, + double intensity, +); - void clear_background_image( - ffi.Pointer viewer, - ) { - return _clear_background_image( - viewer, - ); - } +@ffi.Native)>( + symbol: 'remove_skybox', assetId: 'libflutter_filament') +external void remove_skybox( + ffi.Pointer viewer, +); - late final _clear_background_imagePtr = - _lookup)>>( - 'clear_background_image'); - late final _clear_background_image = _clear_background_imagePtr - .asFunction)>(); +@ffi.Native)>( + symbol: 'remove_ibl', assetId: 'libflutter_filament') +external void remove_ibl( + ffi.Pointer viewer, +); - void set_background_image( - ffi.Pointer viewer, - ffi.Pointer path, - bool fillHeight, - ) { - return _set_background_image( - viewer, - path, - fillHeight, - ); - } +@ffi.Native< + EntityId Function( + ffi.Pointer, + ffi.Uint8, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Bool)>(symbol: 'add_light', assetId: 'libflutter_filament') +external int add_light( + ffi.Pointer viewer, + int type, + double colour, + double intensity, + double posX, + double posY, + double posZ, + double dirX, + double dirY, + double dirZ, + bool shadows, +); - late final _set_background_imagePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('set_background_image'); - late final _set_background_image = _set_background_imagePtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, bool)>(); +@ffi.Native, EntityId)>( + symbol: 'remove_light', assetId: 'libflutter_filament') +external void remove_light( + ffi.Pointer viewer, + int entityId, +); - void set_background_image_position( - ffi.Pointer viewer, - double x, - double y, - bool clamp, - ) { - return _set_background_image_position( - viewer, - x, - y, - clamp, - ); - } +@ffi.Native)>( + symbol: 'clear_lights', assetId: 'libflutter_filament') +external void clear_lights( + ffi.Pointer viewer, +); - late final _set_background_image_positionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Bool)>>('set_background_image_position'); - late final _set_background_image_position = _set_background_image_positionPtr - .asFunction, double, double, bool)>(); +@ffi.Native< + EntityId Function(ffi.Pointer, ffi.Pointer, + ffi.Bool)>(symbol: 'load_glb', assetId: 'libflutter_filament') +external int load_glb( + ffi.Pointer assetManager, + ffi.Pointer assetPath, + bool unlit, +); - void set_background_color( - ffi.Pointer viewer, - double r, - double g, - double b, - double a, - ) { - return _set_background_color( - viewer, - r, - g, - b, - a, - ); - } +@ffi.Native< + EntityId Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + symbol: 'load_gltf', assetId: 'libflutter_filament') +external int load_gltf( + ffi.Pointer assetManager, + ffi.Pointer assetPath, + ffi.Pointer relativePath, +); - late final _set_background_colorPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Float, ffi.Float)>>('set_background_color'); - late final _set_background_color = _set_background_colorPtr.asFunction< - void Function(ffi.Pointer, double, double, double, double)>(); +@ffi.Native< + ffi.Bool Function( + ffi.Pointer, EntityId, ffi.Pointer)>( + symbol: 'set_camera', assetId: 'libflutter_filament') +external bool set_camera( + ffi.Pointer viewer, + int asset, + ffi.Pointer nodeName, +); - void set_tone_mapping( - ffi.Pointer viewer, - int toneMapping, - ) { - return _set_tone_mapping( - viewer, - toneMapping, - ); - } +@ffi.Native, ffi.Bool)>( + symbol: 'set_view_frustum_culling', assetId: 'libflutter_filament') +external void set_view_frustum_culling( + ffi.Pointer viewer, + bool enabled, +); - late final _set_tone_mappingPtr = _lookup< - ffi - .NativeFunction, ffi.Int)>>( - 'set_tone_mapping'); - late final _set_tone_mapping = _set_tone_mappingPtr - .asFunction, int)>(); - - void set_bloom( - ffi.Pointer viewer, - double strength, - ) { - return _set_bloom( - viewer, - strength, - ); - } - - late final _set_bloomPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float)>>('set_bloom'); - late final _set_bloom = - _set_bloomPtr.asFunction, double)>(); - - void load_skybox( - ffi.Pointer viewer, - ffi.Pointer skyboxPath, - ) { - return _load_skybox( - viewer, - skyboxPath, - ); - } - - late final _load_skyboxPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>>('load_skybox'); - late final _load_skybox = _load_skyboxPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); - - void load_ibl( - ffi.Pointer viewer, - ffi.Pointer iblPath, - double intensity, - ) { - return _load_ibl( - viewer, - iblPath, - intensity, - ); - } - - late final _load_iblPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Float)>>('load_ibl'); - late final _load_ibl = _load_iblPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, double)>(); - - void remove_skybox( - ffi.Pointer viewer, - ) { - return _remove_skybox( - viewer, - ); - } - - late final _remove_skyboxPtr = - _lookup)>>( - 'remove_skybox'); - late final _remove_skybox = - _remove_skyboxPtr.asFunction)>(); - - void remove_ibl( - ffi.Pointer viewer, - ) { - return _remove_ibl( - viewer, - ); - } - - late final _remove_iblPtr = - _lookup)>>( - 'remove_ibl'); - late final _remove_ibl = - _remove_iblPtr.asFunction)>(); - - int add_light( - ffi.Pointer viewer, - int type, - double colour, - double intensity, - double posX, - double posY, - double posZ, - double dirX, - double dirY, - double dirZ, - bool shadows, - ) { - return _add_light( - viewer, - type, - colour, - intensity, - posX, - posY, - posZ, - dirX, - dirY, - dirZ, - shadows, - ); - } - - late final _add_lightPtr = _lookup< - ffi.NativeFunction< - EntityId Function( - ffi.Pointer, - ffi.Uint8, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Bool)>>('add_light'); - late final _add_light = _add_lightPtr.asFunction< - int Function(ffi.Pointer, int, double, double, double, double, - double, double, double, double, bool)>(); - - void remove_light( - ffi.Pointer viewer, - int entityId, - ) { - return _remove_light( - viewer, - entityId, - ); - } - - late final _remove_lightPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId)>>('remove_light'); - late final _remove_light = - _remove_lightPtr.asFunction, int)>(); - - void clear_lights( - ffi.Pointer viewer, - ) { - return _clear_lights( - viewer, - ); - } - - late final _clear_lightsPtr = - _lookup)>>( - 'clear_lights'); - late final _clear_lights = - _clear_lightsPtr.asFunction)>(); - - int load_glb( - ffi.Pointer assetManager, - ffi.Pointer assetPath, - bool unlit, - ) { - return _load_glb( - assetManager, - assetPath, - unlit, - ); - } - - late final _load_glbPtr = _lookup< - ffi.NativeFunction< - EntityId Function(ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('load_glb'); - late final _load_glb = _load_glbPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, bool)>(); - - int load_gltf( - ffi.Pointer assetManager, - ffi.Pointer assetPath, - ffi.Pointer relativePath, - ) { - return _load_gltf( - assetManager, - assetPath, - relativePath, - ); - } - - late final _load_gltfPtr = _lookup< - ffi.NativeFunction< - EntityId Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>('load_gltf'); - late final _load_gltf = _load_gltfPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - bool set_camera( - ffi.Pointer viewer, - int asset, - ffi.Pointer nodeName, - ) { - return _set_camera( - viewer, - asset, - nodeName, - ); - } - - late final _set_cameraPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, EntityId, - ffi.Pointer)>>('set_camera'); - late final _set_camera = _set_cameraPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer)>(); - - void set_view_frustum_culling( - ffi.Pointer viewer, - bool enabled, - ) { - return _set_view_frustum_culling( - viewer, - enabled, - ); - } - - late final _set_view_frustum_cullingPtr = _lookup< - ffi - .NativeFunction, ffi.Bool)>>( - 'set_view_frustum_culling'); - late final _set_view_frustum_culling = _set_view_frustum_cullingPtr - .asFunction, bool)>(); - - void render( - ffi.Pointer viewer, - int frameTimeInNanos, - ffi.Pointer pixelBuffer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer buf, ffi.Size size, - ffi.Pointer data)>> - callback, - ffi.Pointer data, - ) { - return _render( - viewer, - frameTimeInNanos, - pixelBuffer, +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer buf, ffi.Size size, + ffi.Pointer data)>>, + ffi.Pointer)>( + symbol: 'render', assetId: 'libflutter_filament') +external void render( + ffi.Pointer viewer, + int frameTimeInNanos, + ffi.Pointer pixelBuffer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer buf, ffi.Size size, + ffi.Pointer data)>> callback, - data, - ); - } - - late final _renderPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Uint64, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer buf, - ffi.Size size, ffi.Pointer data)>>, - ffi.Pointer)>>('render'); - late final _render = _renderPtr.asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer buf, ffi.Size size, - ffi.Pointer data)>>, - ffi.Pointer)>(); - - void create_swap_chain( - ffi.Pointer viewer, - ffi.Pointer window, - int width, - int height, - ) { - return _create_swap_chain( - viewer, - window, - width, - height, - ); - } - - late final _create_swap_chainPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Uint32, ffi.Uint32)>>('create_swap_chain'); - late final _create_swap_chain = _create_swap_chainPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, int, int)>(); - - void destroy_swap_chain( - ffi.Pointer viewer, - ) { - return _destroy_swap_chain( - viewer, - ); - } - - late final _destroy_swap_chainPtr = - _lookup)>>( - 'destroy_swap_chain'); - late final _destroy_swap_chain = - _destroy_swap_chainPtr.asFunction)>(); - - void set_frame_interval( - ffi.Pointer viewer, - double interval, - ) { - return _set_frame_interval( - viewer, - interval, - ); - } - - late final _set_frame_intervalPtr = _lookup< - ffi - .NativeFunction, ffi.Float)>>( - 'set_frame_interval'); - late final _set_frame_interval = _set_frame_intervalPtr - .asFunction, double)>(); - - void update_viewport_and_camera_projection( - ffi.Pointer viewer, - int width, - int height, - double scaleFactor, - ) { - return _update_viewport_and_camera_projection( - viewer, - width, - height, - scaleFactor, - ); - } - - late final _update_viewport_and_camera_projectionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Uint32, ffi.Uint32, - ffi.Float)>>('update_viewport_and_camera_projection'); - late final _update_viewport_and_camera_projection = - _update_viewport_and_camera_projectionPtr - .asFunction, int, int, double)>(); - - void scroll_begin( - ffi.Pointer viewer, - ) { - return _scroll_begin( - viewer, - ); - } - - late final _scroll_beginPtr = - _lookup)>>( - 'scroll_begin'); - late final _scroll_begin = - _scroll_beginPtr.asFunction)>(); - - void scroll_update( - ffi.Pointer viewer, - double x, - double y, - double z, - ) { - return _scroll_update( - viewer, - x, - y, - z, - ); - } - - late final _scroll_updatePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Float)>>('scroll_update'); - late final _scroll_update = _scroll_updatePtr.asFunction< - void Function(ffi.Pointer, double, double, double)>(); - - void scroll_end( - ffi.Pointer viewer, - ) { - return _scroll_end( - viewer, - ); - } - - late final _scroll_endPtr = - _lookup)>>( - 'scroll_end'); - late final _scroll_end = - _scroll_endPtr.asFunction)>(); - - void grab_begin( - ffi.Pointer viewer, - double x, - double y, - bool pan, - ) { - return _grab_begin( - viewer, - x, - y, - pan, - ); - } - - late final _grab_beginPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Bool)>>('grab_begin'); - late final _grab_begin = _grab_beginPtr - .asFunction, double, double, bool)>(); - - void grab_update( - ffi.Pointer viewer, - double x, - double y, - ) { - return _grab_update( - viewer, - x, - y, - ); - } - - late final _grab_updatePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, ffi.Float, ffi.Float)>>('grab_update'); - late final _grab_update = _grab_updatePtr - .asFunction, double, double)>(); - - void grab_end( - ffi.Pointer viewer, - ) { - return _grab_end( - viewer, - ); - } - - late final _grab_endPtr = - _lookup)>>( - 'grab_end'); - late final _grab_end = - _grab_endPtr.asFunction)>(); - - void apply_weights( - ffi.Pointer assetManager, - int asset, - ffi.Pointer entityName, - ffi.Pointer weights, - int count, - ) { - return _apply_weights( - assetManager, - asset, - entityName, - weights, - count, - ); - } - - late final _apply_weightsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Int)>>('apply_weights'); - late final _apply_weights = _apply_weightsPtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, int)>(); - - void set_morph_target_weights( - ffi.Pointer assetManager, - int asset, - ffi.Pointer entityName, - ffi.Pointer morphData, - int numWeights, - ) { - return _set_morph_target_weights( - assetManager, - asset, - entityName, - morphData, - numWeights, - ); - } - - late final _set_morph_target_weightsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Int)>>('set_morph_target_weights'); - late final _set_morph_target_weights = - _set_morph_target_weightsPtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, int)>(); - - bool set_morph_animation( - ffi.Pointer assetManager, - int asset, - ffi.Pointer entityName, - ffi.Pointer morphData, - ffi.Pointer morphIndices, - int numMorphTargets, - int numFrames, - double frameLengthInMs, - ) { - return _set_morph_animation( - assetManager, - asset, - entityName, - morphData, - morphIndices, - numMorphTargets, - numFrames, - frameLengthInMs, - ); - } - - late final _set_morph_animationPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Float)>>('set_morph_animation'); - late final _set_morph_animation = _set_morph_animationPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, ffi.Pointer, int, int, double)>(); - - void set_bone_animation( - ffi.Pointer assetManager, - int asset, - ffi.Pointer frameData, - int numFrames, - int numBones, - ffi.Pointer> boneNames, - ffi.Pointer> meshName, - int numMeshTargets, - double frameLengthInMs, - ) { - return _set_bone_animation( - assetManager, - asset, - frameData, - numFrames, - numBones, - boneNames, - meshName, - numMeshTargets, - frameLengthInMs, - ); - } - - late final _set_bone_animationPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ffi.Int, - ffi.Float)>>('set_bone_animation'); - late final _set_bone_animation = _set_bone_animationPtr.asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer, - int, - int, - ffi.Pointer>, - ffi.Pointer>, - int, - double)>(); - - void play_animation( - ffi.Pointer assetManager, - int asset, - int index, - bool loop, - bool reverse, - bool replaceActive, - double crossfade, - ) { - return _play_animation( - assetManager, - asset, - index, - loop, - reverse, - replaceActive, - crossfade, - ); - } - - late final _play_animationPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, ffi.Int, ffi.Bool, - ffi.Bool, ffi.Bool, ffi.Float)>>('play_animation'); - late final _play_animation = _play_animationPtr.asFunction< - void Function( - ffi.Pointer, int, int, bool, bool, bool, double)>(); - - void set_animation_frame( - ffi.Pointer assetManager, - int asset, - int animationIndex, - int animationFrame, - ) { - return _set_animation_frame( - assetManager, - asset, - animationIndex, - animationFrame, - ); - } - - late final _set_animation_framePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, ffi.Int, - ffi.Int)>>('set_animation_frame'); - late final _set_animation_frame = _set_animation_framePtr - .asFunction, int, int, int)>(); - - void stop_animation( - ffi.Pointer assetManager, - int asset, - int index, - ) { - return _stop_animation( - assetManager, - asset, - index, - ); - } - - late final _stop_animationPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, EntityId, ffi.Int)>>('stop_animation'); - late final _stop_animation = _stop_animationPtr - .asFunction, int, int)>(); - - int get_animation_count( - ffi.Pointer assetManager, - int asset, - ) { - return _get_animation_count( - assetManager, - asset, - ); - } - - late final _get_animation_countPtr = _lookup< - ffi - .NativeFunction, EntityId)>>( - 'get_animation_count'); - late final _get_animation_count = _get_animation_countPtr - .asFunction, int)>(); - - void get_animation_name( - ffi.Pointer assetManager, - int asset, - ffi.Pointer outPtr, - int index, - ) { - return _get_animation_name( - assetManager, - asset, - outPtr, - index, - ); - } - - late final _get_animation_namePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, - ffi.Pointer, ffi.Int)>>('get_animation_name'); - late final _get_animation_name = _get_animation_namePtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, int)>(); - - double get_animation_duration( - ffi.Pointer assetManager, - int asset, - int index, - ) { - return _get_animation_duration( - assetManager, - asset, - index, - ); - } - - late final _get_animation_durationPtr = _lookup< - ffi.NativeFunction< - ffi.Float Function(ffi.Pointer, EntityId, - ffi.Int)>>('get_animation_duration'); - late final _get_animation_duration = _get_animation_durationPtr - .asFunction, int, int)>(); - - void get_morph_target_name( - ffi.Pointer assetManager, - int asset, - ffi.Pointer meshName, - ffi.Pointer outPtr, - int index, - ) { - return _get_morph_target_name( - assetManager, - asset, - meshName, - outPtr, - index, - ); - } - - late final _get_morph_target_namePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Int)>>('get_morph_target_name'); - late final _get_morph_target_name = _get_morph_target_namePtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, int)>(); - - int get_morph_target_name_count( - ffi.Pointer assetManager, - int asset, - ffi.Pointer meshName, - ) { - return _get_morph_target_name_count( - assetManager, - asset, - meshName, - ); - } - - late final _get_morph_target_name_countPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, EntityId, - ffi.Pointer)>>('get_morph_target_name_count'); - late final _get_morph_target_name_count = - _get_morph_target_name_countPtr.asFunction< - int Function(ffi.Pointer, int, ffi.Pointer)>(); - - void remove_asset( - ffi.Pointer viewer, - int asset, - ) { - return _remove_asset( - viewer, - asset, - ); - } - - late final _remove_assetPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId)>>('remove_asset'); - late final _remove_asset = - _remove_assetPtr.asFunction, int)>(); - - void clear_assets( - ffi.Pointer viewer, - ) { - return _clear_assets( - viewer, - ); - } - - late final _clear_assetsPtr = - _lookup)>>( - 'clear_assets'); - late final _clear_assets = - _clear_assetsPtr.asFunction)>(); - - bool set_material_color( - ffi.Pointer assetManager, - int asset, - ffi.Pointer meshName, - int materialIndex, - double r, - double g, - double b, - double a, - ) { - return _set_material_color( - assetManager, - asset, - meshName, - materialIndex, - r, - g, - b, - a, - ); - } - - late final _set_material_colorPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Int, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float)>>('set_material_color'); - late final _set_material_color = _set_material_colorPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer, int, - double, double, double, double)>(); - - void transform_to_unit_cube( - ffi.Pointer assetManager, - int asset, - ) { - return _transform_to_unit_cube( - assetManager, - asset, - ); - } - - late final _transform_to_unit_cubePtr = _lookup< - ffi - .NativeFunction, EntityId)>>( - 'transform_to_unit_cube'); - late final _transform_to_unit_cube = _transform_to_unit_cubePtr - .asFunction, int)>(); - - void set_position( - ffi.Pointer assetManager, - int asset, - double x, - double y, - double z, - ) { - return _set_position( - assetManager, - asset, - x, - y, - z, - ); - } - - late final _set_positionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, ffi.Float, - ffi.Float, ffi.Float)>>('set_position'); - late final _set_position = _set_positionPtr.asFunction< - void Function(ffi.Pointer, int, double, double, double)>(); - - void set_rotation( - ffi.Pointer assetManager, - int asset, - double rads, - double x, - double y, - double z, - ) { - return _set_rotation( - assetManager, - asset, - rads, - x, - y, - z, - ); - } - - late final _set_rotationPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, ffi.Float, - ffi.Float, ffi.Float, ffi.Float)>>('set_rotation'); - late final _set_rotation = _set_rotationPtr.asFunction< - void Function( - ffi.Pointer, int, double, double, double, double)>(); - - void set_scale( - ffi.Pointer assetManager, - int asset, - double scale, - ) { - return _set_scale( - assetManager, - asset, - scale, - ); - } - - late final _set_scalePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, EntityId, ffi.Float)>>('set_scale'); - late final _set_scale = _set_scalePtr - .asFunction, int, double)>(); - - void move_camera_to_asset( - ffi.Pointer viewer, - int asset, - ) { - return _move_camera_to_asset( - viewer, - asset, - ); - } - - late final _move_camera_to_assetPtr = _lookup< - ffi - .NativeFunction, EntityId)>>( - 'move_camera_to_asset'); - late final _move_camera_to_asset = _move_camera_to_assetPtr - .asFunction, int)>(); - - void set_camera_exposure( - ffi.Pointer viewer, - double aperture, - double shutterSpeed, - double sensitivity, - ) { - return _set_camera_exposure( - viewer, - aperture, - shutterSpeed, - sensitivity, - ); - } - - late final _set_camera_exposurePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Float)>>('set_camera_exposure'); - late final _set_camera_exposure = _set_camera_exposurePtr.asFunction< - void Function(ffi.Pointer, double, double, double)>(); - - void set_camera_position( - ffi.Pointer viewer, - double x, - double y, - double z, - ) { - return _set_camera_position( - viewer, - x, - y, - z, - ); - } - - late final _set_camera_positionPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Float)>>('set_camera_position'); - late final _set_camera_position = _set_camera_positionPtr.asFunction< - void Function(ffi.Pointer, double, double, double)>(); - - void get_camera_position( - ffi.Pointer viewer, - ) { - return _get_camera_position( - viewer, - ); - } - - late final _get_camera_positionPtr = - _lookup)>>( - 'get_camera_position'); - late final _get_camera_position = _get_camera_positionPtr - .asFunction)>(); - - void set_camera_rotation( - ffi.Pointer viewer, - double rads, - double x, - double y, - double z, - ) { - return _set_camera_rotation( - viewer, - rads, - x, - y, - z, - ); - } - - late final _set_camera_rotationPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Float, ffi.Float)>>('set_camera_rotation'); - late final _set_camera_rotation = _set_camera_rotationPtr.asFunction< - void Function(ffi.Pointer, double, double, double, double)>(); - - void set_camera_model_matrix( - ffi.Pointer viewer, - ffi.Pointer matrix, - ) { - return _set_camera_model_matrix( - viewer, - matrix, - ); - } - - late final _set_camera_model_matrixPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('set_camera_model_matrix'); - late final _set_camera_model_matrix = _set_camera_model_matrixPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); - - ffi.Pointer get_camera_model_matrix( - ffi.Pointer viewer, - ) { - return _get_camera_model_matrix( - viewer, - ); - } - - late final _get_camera_model_matrixPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('get_camera_model_matrix'); - late final _get_camera_model_matrix = _get_camera_model_matrixPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer get_camera_view_matrix( - ffi.Pointer viewer, - ) { - return _get_camera_view_matrix( - viewer, - ); - } - - late final _get_camera_view_matrixPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('get_camera_view_matrix'); - late final _get_camera_view_matrix = _get_camera_view_matrixPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer get_camera_projection_matrix( - ffi.Pointer viewer, - ) { - return _get_camera_projection_matrix( - viewer, - ); - } - - late final _get_camera_projection_matrixPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('get_camera_projection_matrix'); - late final _get_camera_projection_matrix = _get_camera_projection_matrixPtr - .asFunction Function(ffi.Pointer)>(); - - void set_camera_focal_length( - ffi.Pointer viewer, - double focalLength, - ) { - return _set_camera_focal_length( - viewer, - focalLength, - ); - } - - late final _set_camera_focal_lengthPtr = _lookup< - ffi - .NativeFunction, ffi.Float)>>( - 'set_camera_focal_length'); - late final _set_camera_focal_length = _set_camera_focal_lengthPtr - .asFunction, double)>(); - - void set_camera_focus_distance( - ffi.Pointer viewer, - double focusDistance, - ) { - return _set_camera_focus_distance( - viewer, - focusDistance, - ); - } - - late final _set_camera_focus_distancePtr = _lookup< - ffi - .NativeFunction, ffi.Float)>>( - 'set_camera_focus_distance'); - late final _set_camera_focus_distance = _set_camera_focus_distancePtr - .asFunction, double)>(); - - void set_camera_manipulator_options( - ffi.Pointer viewer, - int mode, - double orbitSpeedX, - double orbitSpeedY, - double zoomSpeed, - ) { - return _set_camera_manipulator_options( - viewer, - mode, - orbitSpeedX, - orbitSpeedY, - zoomSpeed, - ); - } - - late final _set_camera_manipulator_optionsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, _ManipulatorMode, ffi.Double, - ffi.Double, ffi.Double)>>('set_camera_manipulator_options'); - late final _set_camera_manipulator_options = - _set_camera_manipulator_optionsPtr.asFunction< - void Function(ffi.Pointer, int, double, double, double)>(); - - int hide_mesh( - ffi.Pointer assetManager, - int asset, - ffi.Pointer meshName, - ) { - return _hide_mesh( - assetManager, - asset, - meshName, - ); - } - - late final _hide_meshPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, EntityId, - ffi.Pointer)>>('hide_mesh'); - late final _hide_mesh = _hide_meshPtr.asFunction< - int Function(ffi.Pointer, int, ffi.Pointer)>(); - - int reveal_mesh( - ffi.Pointer assetManager, - int asset, - ffi.Pointer meshName, - ) { - return _reveal_mesh( - assetManager, - asset, - meshName, - ); - } - - late final _reveal_meshPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, EntityId, - ffi.Pointer)>>('reveal_mesh'); - late final _reveal_mesh = _reveal_meshPtr.asFunction< - int Function(ffi.Pointer, int, ffi.Pointer)>(); - - void set_post_processing( - ffi.Pointer viewer, - bool enabled, - ) { - return _set_post_processing( - viewer, - enabled, - ); - } - - late final _set_post_processingPtr = _lookup< - ffi - .NativeFunction, ffi.Bool)>>( - 'set_post_processing'); - late final _set_post_processing = _set_post_processingPtr - .asFunction, bool)>(); - - void pick( - ffi.Pointer viewer, - int x, - int y, - ffi.Pointer entityId, - ) { - return _pick( - viewer, - x, - y, - entityId, - ); - } - - late final _pickPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Int, - ffi.Pointer)>>('pick'); - late final _pick = _pickPtr.asFunction< - void Function(ffi.Pointer, int, int, ffi.Pointer)>(); - - ffi.Pointer get_name_for_entity( - ffi.Pointer assetManager, - int entityId, - ) { - return _get_name_for_entity( - assetManager, - entityId, - ); - } - - late final _get_name_for_entityPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, EntityId)>>('get_name_for_entity'); - late final _get_name_for_entity = _get_name_for_entityPtr - .asFunction Function(ffi.Pointer, int)>(); - - void ios_dummy() { - return _ios_dummy(); - } - - late final _ios_dummyPtr = - _lookup>('ios_dummy'); - late final _ios_dummy = _ios_dummyPtr.asFunction(); - - ffi.Pointer create_filament_viewer_ffi( - ffi.Pointer context, - ffi.Pointer platform, - ffi.Pointer uberArchivePath, - ffi.Pointer loader, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer renderCallbackOwner)>> - renderCallback, - ffi.Pointer renderCallbackOwner, - ) { - return _create_filament_viewer_ffi( - context, - platform, - uberArchivePath, - loader, + ffi.Pointer data, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Uint32, ffi.Uint32)>( + symbol: 'create_swap_chain', assetId: 'libflutter_filament') +external void create_swap_chain( + ffi.Pointer viewer, + ffi.Pointer window, + int width, + int height, +); + +@ffi.Native)>( + symbol: 'destroy_swap_chain', assetId: 'libflutter_filament') +external void destroy_swap_chain( + ffi.Pointer viewer, +); + +@ffi.Native, ffi.Float)>( + symbol: 'set_frame_interval', assetId: 'libflutter_filament') +external void set_frame_interval( + ffi.Pointer viewer, + double interval, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Uint32, ffi.Uint32, ffi.Float)>( + symbol: 'update_viewport_and_camera_projection', + assetId: 'libflutter_filament') +external void update_viewport_and_camera_projection( + ffi.Pointer viewer, + int width, + int height, + double scaleFactor, +); + +@ffi.Native)>( + symbol: 'scroll_begin', assetId: 'libflutter_filament') +external void scroll_begin( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, + ffi.Float)>(symbol: 'scroll_update', assetId: 'libflutter_filament') +external void scroll_update( + ffi.Pointer viewer, + double x, + double y, + double z, +); + +@ffi.Native)>( + symbol: 'scroll_end', assetId: 'libflutter_filament') +external void scroll_end( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, + ffi.Bool)>(symbol: 'grab_begin', assetId: 'libflutter_filament') +external void grab_begin( + ffi.Pointer viewer, + double x, + double y, + bool pan, +); + +@ffi.Native, ffi.Float, ffi.Float)>( + symbol: 'grab_update', assetId: 'libflutter_filament') +external void grab_update( + ffi.Pointer viewer, + double x, + double y, +); + +@ffi.Native)>( + symbol: 'grab_end', assetId: 'libflutter_filament') +external void grab_end( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Pointer, + ffi.Int)>(symbol: 'apply_weights', assetId: 'libflutter_filament') +external void apply_weights( + ffi.Pointer assetManager, + int asset, + ffi.Pointer entityName, + ffi.Pointer weights, + int count, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer, ffi.Pointer, ffi.Int)>( + symbol: 'set_morph_target_weights', assetId: 'libflutter_filament') +external void set_morph_target_weights( + ffi.Pointer assetManager, + int asset, + ffi.Pointer entityName, + ffi.Pointer morphData, + int numWeights, +); + +@ffi.Native< + ffi.Bool Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Float)>( + symbol: 'set_morph_animation', assetId: 'libflutter_filament') +external bool set_morph_animation( + ffi.Pointer assetManager, + int asset, + ffi.Pointer entityName, + ffi.Pointer morphData, + ffi.Pointer morphIndices, + int numMorphTargets, + int numFrames, + double frameLengthInMs, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ffi.Int, + ffi.Float)>( + symbol: 'set_bone_animation', assetId: 'libflutter_filament') +external void set_bone_animation( + ffi.Pointer assetManager, + int asset, + ffi.Pointer frameData, + int numFrames, + int numBones, + ffi.Pointer> boneNames, + ffi.Pointer> meshName, + int numMeshTargets, + double frameLengthInMs, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Int, + ffi.Bool, + ffi.Bool, + ffi.Bool, + ffi.Float)>(symbol: 'play_animation', assetId: 'libflutter_filament') +external void play_animation( + ffi.Pointer assetManager, + int asset, + int index, + bool loop, + bool reverse, + bool replaceActive, + double crossfade, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, ffi.Int, ffi.Int)>( + symbol: 'set_animation_frame', assetId: 'libflutter_filament') +external void set_animation_frame( + ffi.Pointer assetManager, + int asset, + int animationIndex, + int animationFrame, +); + +@ffi.Native, EntityId, ffi.Int)>( + symbol: 'stop_animation', assetId: 'libflutter_filament') +external void stop_animation( + ffi.Pointer assetManager, + int asset, + int index, +); + +@ffi.Native, EntityId)>( + symbol: 'get_animation_count', assetId: 'libflutter_filament') +external int get_animation_count( + ffi.Pointer assetManager, + int asset, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, ffi.Pointer, + ffi.Int)>(symbol: 'get_animation_name', assetId: 'libflutter_filament') +external void get_animation_name( + ffi.Pointer assetManager, + int asset, + ffi.Pointer outPtr, + int index, +); + +@ffi.Native, EntityId, ffi.Int)>( + symbol: 'get_animation_duration', assetId: 'libflutter_filament') +external double get_animation_duration( + ffi.Pointer assetManager, + int asset, + int index, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer, ffi.Pointer, ffi.Int)>( + symbol: 'get_morph_target_name', assetId: 'libflutter_filament') +external void get_morph_target_name( + ffi.Pointer assetManager, + int asset, + ffi.Pointer meshName, + ffi.Pointer outPtr, + int index, +); + +@ffi.Native< + ffi.Int Function( + ffi.Pointer, EntityId, ffi.Pointer)>( + symbol: 'get_morph_target_name_count', assetId: 'libflutter_filament') +external int get_morph_target_name_count( + ffi.Pointer assetManager, + int asset, + ffi.Pointer meshName, +); + +@ffi.Native, EntityId)>( + symbol: 'remove_asset', assetId: 'libflutter_filament') +external void remove_asset( + ffi.Pointer viewer, + int asset, +); + +@ffi.Native)>( + symbol: 'clear_assets', assetId: 'libflutter_filament') +external void clear_assets( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Bool Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Int, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float)>( + symbol: 'set_material_color', assetId: 'libflutter_filament') +external bool set_material_color( + ffi.Pointer assetManager, + int asset, + ffi.Pointer meshName, + int materialIndex, + double r, + double g, + double b, + double a, +); + +@ffi.Native, EntityId)>( + symbol: 'transform_to_unit_cube', assetId: 'libflutter_filament') +external void transform_to_unit_cube( + ffi.Pointer assetManager, + int asset, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, ffi.Float, ffi.Float, + ffi.Float)>(symbol: 'set_position', assetId: 'libflutter_filament') +external void set_position( + ffi.Pointer assetManager, + int asset, + double x, + double y, + double z, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float)>(symbol: 'set_rotation', assetId: 'libflutter_filament') +external void set_rotation( + ffi.Pointer assetManager, + int asset, + double rads, + double x, + double y, + double z, +); + +@ffi.Native, EntityId, ffi.Float)>( + symbol: 'set_scale', assetId: 'libflutter_filament') +external void set_scale( + ffi.Pointer assetManager, + int asset, + double scale, +); + +@ffi.Native, EntityId)>( + symbol: 'move_camera_to_asset', assetId: 'libflutter_filament') +external void move_camera_to_asset( + ffi.Pointer viewer, + int asset, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Float)>( + symbol: 'set_camera_exposure', assetId: 'libflutter_filament') +external void set_camera_exposure( + ffi.Pointer viewer, + double aperture, + double shutterSpeed, + double sensitivity, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Float)>( + symbol: 'set_camera_position', assetId: 'libflutter_filament') +external void set_camera_position( + ffi.Pointer viewer, + double x, + double y, + double z, +); + +@ffi.Native)>( + symbol: 'get_camera_position', assetId: 'libflutter_filament') +external void get_camera_position( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Float, ffi.Float)>( + symbol: 'set_camera_rotation', assetId: 'libflutter_filament') +external void set_camera_rotation( + ffi.Pointer viewer, + double rads, + double x, + double y, + double z, +); + +@ffi.Native, ffi.Pointer)>( + symbol: 'set_camera_model_matrix', assetId: 'libflutter_filament') +external void set_camera_model_matrix( + ffi.Pointer viewer, + ffi.Pointer matrix, +); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'get_camera_model_matrix', assetId: 'libflutter_filament') +external ffi.Pointer get_camera_model_matrix( + ffi.Pointer viewer, +); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'get_camera_view_matrix', assetId: 'libflutter_filament') +external ffi.Pointer get_camera_view_matrix( + ffi.Pointer viewer, +); + +@ffi.Native Function(ffi.Pointer)>( + symbol: 'get_camera_projection_matrix', assetId: 'libflutter_filament') +external ffi.Pointer get_camera_projection_matrix( + ffi.Pointer viewer, +); + +@ffi.Native, ffi.Float)>( + symbol: 'set_camera_focal_length', assetId: 'libflutter_filament') +external void set_camera_focal_length( + ffi.Pointer viewer, + double focalLength, +); + +@ffi.Native, ffi.Float)>( + symbol: 'set_camera_focus_distance', assetId: 'libflutter_filament') +external void set_camera_focus_distance( + ffi.Pointer viewer, + double focusDistance, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, _ManipulatorMode, ffi.Double, + ffi.Double, ffi.Double)>( + symbol: 'set_camera_manipulator_options', assetId: 'libflutter_filament') +external void set_camera_manipulator_options( + ffi.Pointer viewer, + int mode, + double orbitSpeedX, + double orbitSpeedY, + double zoomSpeed, +); + +@ffi.Native< + ffi.Int Function( + ffi.Pointer, EntityId, ffi.Pointer)>( + symbol: 'hide_mesh', assetId: 'libflutter_filament') +external int hide_mesh( + ffi.Pointer assetManager, + int asset, + ffi.Pointer meshName, +); + +@ffi.Native< + ffi.Int Function( + ffi.Pointer, EntityId, ffi.Pointer)>( + symbol: 'reveal_mesh', assetId: 'libflutter_filament') +external int reveal_mesh( + ffi.Pointer assetManager, + int asset, + ffi.Pointer meshName, +); + +@ffi.Native, ffi.Bool)>( + symbol: 'set_post_processing', assetId: 'libflutter_filament') +external void set_post_processing( + ffi.Pointer viewer, + bool enabled, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Int, + ffi.Pointer)>(symbol: 'pick', assetId: 'libflutter_filament') +external void pick( + ffi.Pointer viewer, + int x, + int y, + ffi.Pointer entityId, +); + +@ffi.Native Function(ffi.Pointer, EntityId)>( + symbol: 'get_name_for_entity', assetId: 'libflutter_filament') +external ffi.Pointer get_name_for_entity( + ffi.Pointer assetManager, + int entityId, +); + +@ffi.Native( + symbol: 'ios_dummy', assetId: 'libflutter_filament') +external void ios_dummy(); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi + .Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer renderCallbackOwner)>>, + ffi.Pointer)>( + symbol: 'create_filament_viewer_ffi', assetId: 'libflutter_filament') +external ffi.Pointer create_filament_viewer_ffi( + ffi.Pointer context, + ffi.Pointer platform, + ffi.Pointer uberArchivePath, + ffi.Pointer loader, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer renderCallbackOwner)>> renderCallback, - renderCallbackOwner, - ); - } - - late final _create_filament_viewer_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer renderCallbackOwner)>>, - ffi.Pointer)>>('create_filament_viewer_ffi'); - late final _create_filament_viewer_ffi = - _create_filament_viewer_ffiPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer renderCallbackOwner)>>, - ffi.Pointer)>(); - - void create_swap_chain_ffi( - ffi.Pointer viewer, - ffi.Pointer surface, - int width, - int height, - ) { - return _create_swap_chain_ffi( - viewer, - surface, - width, - height, - ); - } - - late final _create_swap_chain_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Uint32, ffi.Uint32)>>('create_swap_chain_ffi'); - late final _create_swap_chain_ffi = _create_swap_chain_ffiPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, int, int)>(); - - void destroy_swap_chain_ffi( - ffi.Pointer viewer, - ) { - return _destroy_swap_chain_ffi( - viewer, - ); - } - - late final _destroy_swap_chain_ffiPtr = - _lookup)>>( - 'destroy_swap_chain_ffi'); - late final _destroy_swap_chain_ffi = _destroy_swap_chain_ffiPtr - .asFunction)>(); - - void create_render_target_ffi( - ffi.Pointer viewer, - int nativeTextureId, - int width, - int height, - ) { - return _create_render_target_ffi( - viewer, - nativeTextureId, - width, - height, - ); - } - - late final _create_render_target_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.IntPtr, ffi.Uint32, - ffi.Uint32)>>('create_render_target_ffi'); - late final _create_render_target_ffi = _create_render_target_ffiPtr - .asFunction, int, int, int)>(); - - void destroy_filament_viewer_ffi( - ffi.Pointer viewer, - ) { - return _destroy_filament_viewer_ffi( - viewer, - ); - } - - late final _destroy_filament_viewer_ffiPtr = - _lookup)>>( - 'destroy_filament_viewer_ffi'); - late final _destroy_filament_viewer_ffi = _destroy_filament_viewer_ffiPtr - .asFunction)>(); - - void render_ffi( - ffi.Pointer viewer, - ) { - return _render_ffi( - viewer, - ); - } - - late final _render_ffiPtr = - _lookup)>>( - 'render_ffi'); - late final _render_ffi = - _render_ffiPtr.asFunction)>(); - - FilamentRenderCallback make_render_callback_fn_pointer( - FilamentRenderCallback arg0, - ) { - return _make_render_callback_fn_pointer( - arg0, - ); - } - - late final _make_render_callback_fn_pointerPtr = _lookup< - ffi.NativeFunction< - FilamentRenderCallback Function( - FilamentRenderCallback)>>('make_render_callback_fn_pointer'); - late final _make_render_callback_fn_pointer = - _make_render_callback_fn_pointerPtr.asFunction< - FilamentRenderCallback Function(FilamentRenderCallback)>(); - - void set_rendering_ffi( - ffi.Pointer viewer, - bool rendering, - ) { - return _set_rendering_ffi( - viewer, - rendering, - ); - } - - late final _set_rendering_ffiPtr = _lookup< - ffi - .NativeFunction, ffi.Bool)>>( - 'set_rendering_ffi'); - late final _set_rendering_ffi = _set_rendering_ffiPtr - .asFunction, bool)>(); - - void set_frame_interval_ffi( - double frameInterval, - ) { - return _set_frame_interval_ffi( - frameInterval, - ); - } - - late final _set_frame_interval_ffiPtr = - _lookup>( - 'set_frame_interval_ffi'); - late final _set_frame_interval_ffi = - _set_frame_interval_ffiPtr.asFunction(); - - void update_viewport_and_camera_projection_ffi( - ffi.Pointer viewer, - int width, - int height, - double scaleFactor, - ) { - return _update_viewport_and_camera_projection_ffi( - viewer, - width, - height, - scaleFactor, - ); - } - - late final _update_viewport_and_camera_projection_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Uint32, ffi.Uint32, - ffi.Float)>>('update_viewport_and_camera_projection_ffi'); - late final _update_viewport_and_camera_projection_ffi = - _update_viewport_and_camera_projection_ffiPtr - .asFunction, int, int, double)>(); - - void set_background_color_ffi( - ffi.Pointer viewer, - double r, - double g, - double b, - double a, - ) { - return _set_background_color_ffi( - viewer, - r, - g, - b, - a, - ); - } - - late final _set_background_color_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Float, ffi.Float)>>('set_background_color_ffi'); - late final _set_background_color_ffi = - _set_background_color_ffiPtr.asFunction< - void Function( - ffi.Pointer, double, double, double, double)>(); - - void clear_background_image_ffi( - ffi.Pointer viewer, - ) { - return _clear_background_image_ffi( - viewer, - ); - } - - late final _clear_background_image_ffiPtr = - _lookup)>>( - 'clear_background_image_ffi'); - late final _clear_background_image_ffi = _clear_background_image_ffiPtr - .asFunction)>(); - - void set_background_image_ffi( - ffi.Pointer viewer, - ffi.Pointer path, - bool fillHeight, - ) { - return _set_background_image_ffi( - viewer, - path, - fillHeight, - ); - } - - late final _set_background_image_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('set_background_image_ffi'); - late final _set_background_image_ffi = - _set_background_image_ffiPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, bool)>(); - - void set_background_image_position_ffi( - ffi.Pointer viewer, - double x, - double y, - bool clamp, - ) { - return _set_background_image_position_ffi( - viewer, - x, - y, - clamp, - ); - } - - late final _set_background_image_position_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, - ffi.Bool)>>('set_background_image_position_ffi'); - late final _set_background_image_position_ffi = - _set_background_image_position_ffiPtr.asFunction< - void Function(ffi.Pointer, double, double, bool)>(); - - void set_tone_mapping_ffi( - ffi.Pointer viewer, - int toneMapping, - ) { - return _set_tone_mapping_ffi( - viewer, - toneMapping, - ); - } - - late final _set_tone_mapping_ffiPtr = _lookup< - ffi - .NativeFunction, ffi.Int)>>( - 'set_tone_mapping_ffi'); - late final _set_tone_mapping_ffi = _set_tone_mapping_ffiPtr - .asFunction, int)>(); - - void set_bloom_ffi( - ffi.Pointer viewer, - double strength, - ) { - return _set_bloom_ffi( - viewer, - strength, - ); - } - - late final _set_bloom_ffiPtr = _lookup< - ffi - .NativeFunction, ffi.Float)>>( - 'set_bloom_ffi'); - late final _set_bloom_ffi = _set_bloom_ffiPtr - .asFunction, double)>(); - - void load_skybox_ffi( - ffi.Pointer viewer, - ffi.Pointer skyboxPath, - ) { - return _load_skybox_ffi( - viewer, - skyboxPath, - ); - } - - late final _load_skybox_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>>('load_skybox_ffi'); - late final _load_skybox_ffi = _load_skybox_ffiPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer)>(); - - void load_ibl_ffi( - ffi.Pointer viewer, - ffi.Pointer iblPath, - double intensity, - ) { - return _load_ibl_ffi( - viewer, - iblPath, - intensity, - ); - } - - late final _load_ibl_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Float)>>('load_ibl_ffi'); - late final _load_ibl_ffi = _load_ibl_ffiPtr.asFunction< - void Function(ffi.Pointer, ffi.Pointer, double)>(); - - void remove_skybox_ffi( - ffi.Pointer viewer, - ) { - return _remove_skybox_ffi( - viewer, - ); - } - - late final _remove_skybox_ffiPtr = - _lookup)>>( - 'remove_skybox_ffi'); - late final _remove_skybox_ffi = - _remove_skybox_ffiPtr.asFunction)>(); - - void remove_ibl_ffi( - ffi.Pointer viewer, - ) { - return _remove_ibl_ffi( - viewer, - ); - } - - late final _remove_ibl_ffiPtr = - _lookup)>>( - 'remove_ibl_ffi'); - late final _remove_ibl_ffi = - _remove_ibl_ffiPtr.asFunction)>(); - - int add_light_ffi( - ffi.Pointer viewer, - int type, - double colour, - double intensity, - double posX, - double posY, - double posZ, - double dirX, - double dirY, - double dirZ, - bool shadows, - ) { - return _add_light_ffi( - viewer, - type, - colour, - intensity, - posX, - posY, - posZ, - dirX, - dirY, - dirZ, - shadows, - ); - } - - late final _add_light_ffiPtr = _lookup< - ffi.NativeFunction< - EntityId Function( - ffi.Pointer, - ffi.Uint8, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Float, - ffi.Bool)>>('add_light_ffi'); - late final _add_light_ffi = _add_light_ffiPtr.asFunction< - int Function(ffi.Pointer, int, double, double, double, double, - double, double, double, double, bool)>(); - - void remove_light_ffi( - ffi.Pointer viewer, - int entityId, - ) { - return _remove_light_ffi( - viewer, - entityId, - ); - } - - late final _remove_light_ffiPtr = _lookup< - ffi - .NativeFunction, EntityId)>>( - 'remove_light_ffi'); - late final _remove_light_ffi = _remove_light_ffiPtr - .asFunction, int)>(); - - void clear_lights_ffi( - ffi.Pointer viewer, - ) { - return _clear_lights_ffi( - viewer, - ); - } - - late final _clear_lights_ffiPtr = - _lookup)>>( - 'clear_lights_ffi'); - late final _clear_lights_ffi = - _clear_lights_ffiPtr.asFunction)>(); - - int load_glb_ffi( - ffi.Pointer assetManager, - ffi.Pointer assetPath, - bool unlit, - ) { - return _load_glb_ffi( - assetManager, - assetPath, - unlit, - ); - } - - late final _load_glb_ffiPtr = _lookup< - ffi.NativeFunction< - EntityId Function(ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('load_glb_ffi'); - late final _load_glb_ffi = _load_glb_ffiPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, bool)>(); - - int load_gltf_ffi( - ffi.Pointer assetManager, - ffi.Pointer assetPath, - ffi.Pointer relativePath, - ) { - return _load_gltf_ffi( - assetManager, - assetPath, - relativePath, - ); - } - - late final _load_gltf_ffiPtr = _lookup< - ffi.NativeFunction< - EntityId Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>('load_gltf_ffi'); - late final _load_gltf_ffi = _load_gltf_ffiPtr.asFunction< - int Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - void remove_asset_ffi( - ffi.Pointer viewer, - int asset, - ) { - return _remove_asset_ffi( - viewer, - asset, - ); - } - - late final _remove_asset_ffiPtr = _lookup< - ffi - .NativeFunction, EntityId)>>( - 'remove_asset_ffi'); - late final _remove_asset_ffi = _remove_asset_ffiPtr - .asFunction, int)>(); - - void clear_assets_ffi( - ffi.Pointer viewer, - ) { - return _clear_assets_ffi( - viewer, - ); - } - - late final _clear_assets_ffiPtr = - _lookup)>>( - 'clear_assets_ffi'); - late final _clear_assets_ffi = - _clear_assets_ffiPtr.asFunction)>(); - - bool set_camera_ffi( - ffi.Pointer viewer, - int asset, - ffi.Pointer nodeName, - ) { - return _set_camera_ffi( - viewer, - asset, - nodeName, - ); - } - - late final _set_camera_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer, EntityId, - ffi.Pointer)>>('set_camera_ffi'); - late final _set_camera_ffi = _set_camera_ffiPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer)>(); - - void apply_weights_ffi( - ffi.Pointer assetManager, - int asset, - ffi.Pointer entityName, - ffi.Pointer weights, - int count, - ) { - return _apply_weights_ffi( - assetManager, - asset, - entityName, - weights, - count, - ); - } - - late final _apply_weights_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Int)>>('apply_weights_ffi'); - late final _apply_weights_ffi = _apply_weights_ffiPtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, int)>(); - - void set_morph_target_weights_ffi( - ffi.Pointer assetManager, - int asset, - ffi.Pointer entityName, - ffi.Pointer morphData, - int numWeights, - ) { - return _set_morph_target_weights_ffi( - assetManager, - asset, - entityName, - morphData, - numWeights, - ); - } - - late final _set_morph_target_weights_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Int)>>('set_morph_target_weights_ffi'); - late final _set_morph_target_weights_ffi = - _set_morph_target_weights_ffiPtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, int)>(); - - bool set_morph_animation_ffi( - ffi.Pointer assetManager, - int asset, - ffi.Pointer entityName, - ffi.Pointer morphData, - ffi.Pointer morphIndices, - int numMorphTargets, - int numFrames, - double frameLengthInMs, - ) { - return _set_morph_animation_ffi( - assetManager, - asset, - entityName, - morphData, - morphIndices, - numMorphTargets, - numFrames, - frameLengthInMs, - ); - } - - late final _set_morph_animation_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Float)>>('set_morph_animation_ffi'); - late final _set_morph_animation_ffi = _set_morph_animation_ffiPtr.asFunction< - bool Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, ffi.Pointer, int, int, double)>(); - - void set_bone_animation_ffi( - ffi.Pointer assetManager, - int asset, - ffi.Pointer frameData, - int numFrames, - int numBones, - ffi.Pointer> boneNames, - ffi.Pointer> meshName, - int numMeshTargets, - double frameLengthInMs, - ) { - return _set_bone_animation_ffi( - assetManager, - asset, - frameData, - numFrames, - numBones, - boneNames, - meshName, - numMeshTargets, - frameLengthInMs, - ); - } - - late final _set_bone_animation_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ffi.Int, - ffi.Float)>>('set_bone_animation_ffi'); - late final _set_bone_animation_ffi = _set_bone_animation_ffiPtr.asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer, - int, - int, - ffi.Pointer>, - ffi.Pointer>, - int, - double)>(); - - void play_animation_ffi( - ffi.Pointer assetManager, - int asset, - int index, - bool loop, - bool reverse, - bool replaceActive, - double crossfade, - ) { - return _play_animation_ffi( - assetManager, - asset, - index, - loop, - reverse, - replaceActive, - crossfade, - ); - } - - late final _play_animation_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, ffi.Int, ffi.Bool, - ffi.Bool, ffi.Bool, ffi.Float)>>('play_animation_ffi'); - late final _play_animation_ffi = _play_animation_ffiPtr.asFunction< - void Function( - ffi.Pointer, int, int, bool, bool, bool, double)>(); - - void set_animation_frame_ffi( - ffi.Pointer assetManager, - int asset, - int animationIndex, - int animationFrame, - ) { - return _set_animation_frame_ffi( - assetManager, - asset, - animationIndex, - animationFrame, - ); - } - - late final _set_animation_frame_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, ffi.Int, - ffi.Int)>>('set_animation_frame_ffi'); - late final _set_animation_frame_ffi = _set_animation_frame_ffiPtr - .asFunction, int, int, int)>(); - - void stop_animation_ffi( - ffi.Pointer assetManager, - int asset, - int index, - ) { - return _stop_animation_ffi( - assetManager, - asset, - index, - ); - } - - late final _stop_animation_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, EntityId, ffi.Int)>>('stop_animation_ffi'); - late final _stop_animation_ffi = _stop_animation_ffiPtr - .asFunction, int, int)>(); - - int get_animation_count_ffi( - ffi.Pointer assetManager, - int asset, - ) { - return _get_animation_count_ffi( - assetManager, - asset, - ); - } - - late final _get_animation_count_ffiPtr = _lookup< - ffi - .NativeFunction, EntityId)>>( - 'get_animation_count_ffi'); - late final _get_animation_count_ffi = _get_animation_count_ffiPtr - .asFunction, int)>(); - - void get_animation_name_ffi( - ffi.Pointer assetManager, - int asset, - ffi.Pointer outPtr, - int index, - ) { - return _get_animation_name_ffi( - assetManager, - asset, - outPtr, - index, - ); - } - - late final _get_animation_name_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, EntityId, - ffi.Pointer, ffi.Int)>>('get_animation_name_ffi'); - late final _get_animation_name_ffi = _get_animation_name_ffiPtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, int)>(); - - void get_morph_target_name_ffi( - ffi.Pointer assetManager, - int asset, - ffi.Pointer meshName, - ffi.Pointer outPtr, - int index, - ) { - return _get_morph_target_name_ffi( - assetManager, - asset, - meshName, - outPtr, - index, - ); - } - - late final _get_morph_target_name_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - EntityId, - ffi.Pointer, - ffi.Pointer, - ffi.Int)>>('get_morph_target_name_ffi'); - late final _get_morph_target_name_ffi = - _get_morph_target_name_ffiPtr.asFunction< - void Function(ffi.Pointer, int, ffi.Pointer, - ffi.Pointer, int)>(); - - int get_morph_target_name_count_ffi( - ffi.Pointer assetManager, - int asset, - ffi.Pointer meshName, - ) { - return _get_morph_target_name_count_ffi( - assetManager, - asset, - meshName, - ); - } - - late final _get_morph_target_name_count_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, EntityId, - ffi.Pointer)>>('get_morph_target_name_count_ffi'); - late final _get_morph_target_name_count_ffi = - _get_morph_target_name_count_ffiPtr.asFunction< - int Function(ffi.Pointer, int, ffi.Pointer)>(); - - void set_post_processing_ffi( - ffi.Pointer viewer, - bool enabled, - ) { - return _set_post_processing_ffi( - viewer, - enabled, - ); - } - - late final _set_post_processing_ffiPtr = _lookup< - ffi - .NativeFunction, ffi.Bool)>>( - 'set_post_processing_ffi'); - late final _set_post_processing_ffi = _set_post_processing_ffiPtr - .asFunction, bool)>(); - - void pick_ffi( - ffi.Pointer viewer, - int x, - int y, - ffi.Pointer entityId, - ) { - return _pick_ffi( - viewer, - x, - y, - entityId, - ); - } - - late final _pick_ffiPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Int, - ffi.Pointer)>>('pick_ffi'); - late final _pick_ffi = _pick_ffiPtr.asFunction< - void Function(ffi.Pointer, int, int, ffi.Pointer)>(); - - void ios_dummy_ffi() { - return _ios_dummy_ffi(); - } - - late final _ios_dummy_ffiPtr = - _lookup>('ios_dummy_ffi'); - late final _ios_dummy_ffi = _ios_dummy_ffiPtr.asFunction(); -} + ffi.Pointer renderCallbackOwner, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Uint32, ffi.Uint32)>( + symbol: 'create_swap_chain_ffi', assetId: 'libflutter_filament') +external void create_swap_chain_ffi( + ffi.Pointer viewer, + ffi.Pointer surface, + int width, + int height, +); + +@ffi.Native)>( + symbol: 'destroy_swap_chain_ffi', assetId: 'libflutter_filament') +external void destroy_swap_chain_ffi( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.IntPtr, ffi.Uint32, ffi.Uint32)>( + symbol: 'create_render_target_ffi', assetId: 'libflutter_filament') +external void create_render_target_ffi( + ffi.Pointer viewer, + int nativeTextureId, + int width, + int height, +); + +@ffi.Native)>( + symbol: 'destroy_filament_viewer_ffi', assetId: 'libflutter_filament') +external void destroy_filament_viewer_ffi( + ffi.Pointer viewer, +); + +@ffi.Native)>( + symbol: 'render_ffi', assetId: 'libflutter_filament') +external void render_ffi( + ffi.Pointer viewer, +); + +@ffi.Native( + symbol: 'make_render_callback_fn_pointer', assetId: 'libflutter_filament') +external FilamentRenderCallback make_render_callback_fn_pointer( + FilamentRenderCallback arg0, +); + +@ffi.Native, ffi.Bool)>( + symbol: 'set_rendering_ffi', assetId: 'libflutter_filament') +external void set_rendering_ffi( + ffi.Pointer viewer, + bool rendering, +); + +@ffi.Native( + symbol: 'set_frame_interval_ffi', assetId: 'libflutter_filament') +external void set_frame_interval_ffi( + double frameInterval, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Uint32, ffi.Uint32, ffi.Float)>( + symbol: 'update_viewport_and_camera_projection_ffi', + assetId: 'libflutter_filament') +external void update_viewport_and_camera_projection_ffi( + ffi.Pointer viewer, + int width, + int height, + double scaleFactor, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Float, ffi.Float)>( + symbol: 'set_background_color_ffi', assetId: 'libflutter_filament') +external void set_background_color_ffi( + ffi.Pointer viewer, + double r, + double g, + double b, + double a, +); + +@ffi.Native)>( + symbol: 'clear_background_image_ffi', assetId: 'libflutter_filament') +external void clear_background_image_ffi( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Bool)>( + symbol: 'set_background_image_ffi', assetId: 'libflutter_filament') +external void set_background_image_ffi( + ffi.Pointer viewer, + ffi.Pointer path, + bool fillHeight, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Bool)>( + symbol: 'set_background_image_position_ffi', assetId: 'libflutter_filament') +external void set_background_image_position_ffi( + ffi.Pointer viewer, + double x, + double y, + bool clamp, +); + +@ffi.Native, ffi.Int)>( + symbol: 'set_tone_mapping_ffi', assetId: 'libflutter_filament') +external void set_tone_mapping_ffi( + ffi.Pointer viewer, + int toneMapping, +); + +@ffi.Native, ffi.Float)>( + symbol: 'set_bloom_ffi', assetId: 'libflutter_filament') +external void set_bloom_ffi( + ffi.Pointer viewer, + double strength, +); + +@ffi.Native, ffi.Pointer)>( + symbol: 'load_skybox_ffi', assetId: 'libflutter_filament') +external void load_skybox_ffi( + ffi.Pointer viewer, + ffi.Pointer skyboxPath, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Float)>(symbol: 'load_ibl_ffi', assetId: 'libflutter_filament') +external void load_ibl_ffi( + ffi.Pointer viewer, + ffi.Pointer iblPath, + double intensity, +); + +@ffi.Native)>( + symbol: 'remove_skybox_ffi', assetId: 'libflutter_filament') +external void remove_skybox_ffi( + ffi.Pointer viewer, +); + +@ffi.Native)>( + symbol: 'remove_ibl_ffi', assetId: 'libflutter_filament') +external void remove_ibl_ffi( + ffi.Pointer viewer, +); + +@ffi.Native< + EntityId Function( + ffi.Pointer, + ffi.Uint8, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Float, + ffi.Bool)>(symbol: 'add_light_ffi', assetId: 'libflutter_filament') +external int add_light_ffi( + ffi.Pointer viewer, + int type, + double colour, + double intensity, + double posX, + double posY, + double posZ, + double dirX, + double dirY, + double dirZ, + bool shadows, +); + +@ffi.Native, EntityId)>( + symbol: 'remove_light_ffi', assetId: 'libflutter_filament') +external void remove_light_ffi( + ffi.Pointer viewer, + int entityId, +); + +@ffi.Native)>( + symbol: 'clear_lights_ffi', assetId: 'libflutter_filament') +external void clear_lights_ffi( + ffi.Pointer viewer, +); + +@ffi.Native< + EntityId Function(ffi.Pointer, ffi.Pointer, + ffi.Bool)>(symbol: 'load_glb_ffi', assetId: 'libflutter_filament') +external int load_glb_ffi( + ffi.Pointer assetManager, + ffi.Pointer assetPath, + bool unlit, +); + +@ffi.Native< + EntityId Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + symbol: 'load_gltf_ffi', assetId: 'libflutter_filament') +external int load_gltf_ffi( + ffi.Pointer assetManager, + ffi.Pointer assetPath, + ffi.Pointer relativePath, +); + +@ffi.Native, EntityId)>( + symbol: 'remove_asset_ffi', assetId: 'libflutter_filament') +external void remove_asset_ffi( + ffi.Pointer viewer, + int asset, +); + +@ffi.Native)>( + symbol: 'clear_assets_ffi', assetId: 'libflutter_filament') +external void clear_assets_ffi( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Bool Function( + ffi.Pointer, EntityId, ffi.Pointer)>( + symbol: 'set_camera_ffi', assetId: 'libflutter_filament') +external bool set_camera_ffi( + ffi.Pointer viewer, + int asset, + ffi.Pointer nodeName, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Pointer, + ffi.Int)>(symbol: 'apply_weights_ffi', assetId: 'libflutter_filament') +external void apply_weights_ffi( + ffi.Pointer assetManager, + int asset, + ffi.Pointer entityName, + ffi.Pointer weights, + int count, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer, ffi.Pointer, ffi.Int)>( + symbol: 'set_morph_target_weights_ffi', assetId: 'libflutter_filament') +external void set_morph_target_weights_ffi( + ffi.Pointer assetManager, + int asset, + ffi.Pointer entityName, + ffi.Pointer morphData, + int numWeights, +); + +@ffi.Native< + ffi.Bool Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Float)>( + symbol: 'set_morph_animation_ffi', assetId: 'libflutter_filament') +external bool set_morph_animation_ffi( + ffi.Pointer assetManager, + int asset, + ffi.Pointer entityName, + ffi.Pointer morphData, + ffi.Pointer morphIndices, + int numMorphTargets, + int numFrames, + double frameLengthInMs, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ffi.Int, + ffi.Float)>( + symbol: 'set_bone_animation_ffi', assetId: 'libflutter_filament') +external void set_bone_animation_ffi( + ffi.Pointer assetManager, + int asset, + ffi.Pointer frameData, + int numFrames, + int numBones, + ffi.Pointer> boneNames, + ffi.Pointer> meshName, + int numMeshTargets, + double frameLengthInMs, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, ffi.Int, ffi.Bool, + ffi.Bool, ffi.Bool, ffi.Float)>( + symbol: 'play_animation_ffi', assetId: 'libflutter_filament') +external void play_animation_ffi( + ffi.Pointer assetManager, + int asset, + int index, + bool loop, + bool reverse, + bool replaceActive, + double crossfade, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, ffi.Int, ffi.Int)>( + symbol: 'set_animation_frame_ffi', assetId: 'libflutter_filament') +external void set_animation_frame_ffi( + ffi.Pointer assetManager, + int asset, + int animationIndex, + int animationFrame, +); + +@ffi.Native, EntityId, ffi.Int)>( + symbol: 'stop_animation_ffi', assetId: 'libflutter_filament') +external void stop_animation_ffi( + ffi.Pointer assetManager, + int asset, + int index, +); + +@ffi.Native, EntityId)>( + symbol: 'get_animation_count_ffi', assetId: 'libflutter_filament') +external int get_animation_count_ffi( + ffi.Pointer assetManager, + int asset, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, EntityId, ffi.Pointer, ffi.Int)>( + symbol: 'get_animation_name_ffi', assetId: 'libflutter_filament') +external void get_animation_name_ffi( + ffi.Pointer assetManager, + int asset, + ffi.Pointer outPtr, + int index, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer, ffi.Pointer, ffi.Int)>( + symbol: 'get_morph_target_name_ffi', assetId: 'libflutter_filament') +external void get_morph_target_name_ffi( + ffi.Pointer assetManager, + int asset, + ffi.Pointer meshName, + ffi.Pointer outPtr, + int index, +); + +@ffi.Native< + ffi.Int Function( + ffi.Pointer, EntityId, ffi.Pointer)>( + symbol: 'get_morph_target_name_count_ffi', assetId: 'libflutter_filament') +external int get_morph_target_name_count_ffi( + ffi.Pointer assetManager, + int asset, + ffi.Pointer meshName, +); + +@ffi.Native, ffi.Bool)>( + symbol: 'set_post_processing_ffi', assetId: 'libflutter_filament') +external void set_post_processing_ffi( + ffi.Pointer viewer, + bool enabled, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Int, ffi.Int, ffi.Pointer)>( + symbol: 'pick_ffi', assetId: 'libflutter_filament') +external void pick_ffi( + ffi.Pointer viewer, + int x, + int y, + ffi.Pointer entityId, +); + +@ffi.Native( + symbol: 'ios_dummy_ffi', assetId: 'libflutter_filament') +external void ios_dummy_ffi(); final class __mbstate_t extends ffi.Union { @ffi.Array.multi([128]) diff --git a/pubspec.yaml b/pubspec.yaml index 600209e1..8851ea36 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,7 +28,8 @@ ffigen: headers: entry-points: - 'ios/include/FlutterFilamentFFIApi.h' - + ffi-native: + asset: 'libflutter_filament' flutter: plugin: platforms: