use consistent size/pixel ratio
This commit is contained in:
@@ -81,7 +81,6 @@ FLUTTER_PLUGIN_EXPORT void set_animation_frame_ffi(void* const assetManager, Ent
|
|||||||
FLUTTER_PLUGIN_EXPORT void stop_animation_ffi(void* const assetManager, EntityId asset, int index);
|
FLUTTER_PLUGIN_EXPORT void stop_animation_ffi(void* const assetManager, EntityId asset, int index);
|
||||||
FLUTTER_PLUGIN_EXPORT int get_animation_count_ffi(void* const assetManager, EntityId asset);
|
FLUTTER_PLUGIN_EXPORT int get_animation_count_ffi(void* const assetManager, EntityId asset);
|
||||||
FLUTTER_PLUGIN_EXPORT void get_animation_name_ffi(void* const assetManager, EntityId asset, char *const outPtr, int index);
|
FLUTTER_PLUGIN_EXPORT void get_animation_name_ffi(void* const assetManager, EntityId asset, char *const outPtr, int index);
|
||||||
FLUTTER_PLUGIN_EXPORT float get_animation_duration_ffi(void* const assetManager, EntityId asset, int index);
|
|
||||||
FLUTTER_PLUGIN_EXPORT void get_morph_target_name_ffi(void* const assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
|
FLUTTER_PLUGIN_EXPORT void get_morph_target_name_ffi(void* const assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
|
||||||
FLUTTER_PLUGIN_EXPORT int get_morph_target_name_count_ffi(void* const assetManager, EntityId asset, const char *meshName);
|
FLUTTER_PLUGIN_EXPORT int get_morph_target_name_count_ffi(void* const assetManager, EntityId asset, const char *meshName);
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
@override
|
@override
|
||||||
void setPixelRatio(double ratio) {
|
void setPixelRatio(double ratio) {
|
||||||
_pixelRatio = ratio;
|
_pixelRatio = ratio;
|
||||||
|
print("Set pixel ratio to $ratio");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -105,6 +106,8 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
}
|
}
|
||||||
size = ui.Size(width * _pixelRatio, height * _pixelRatio);
|
size = ui.Size(width * _pixelRatio, height * _pixelRatio);
|
||||||
|
|
||||||
|
print("Creating viewer with size $size");
|
||||||
|
|
||||||
var textures =
|
var textures =
|
||||||
await _channel.invokeMethod("createTexture", [size.width, size.height]);
|
await _channel.invokeMethod("createTexture", [size.width, size.height]);
|
||||||
var flutterTextureId = textures[0];
|
var flutterTextureId = textures[0];
|
||||||
@@ -145,14 +148,18 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_lib.create_swap_chain_ffi(
|
_lib.create_swap_chain_ffi(
|
||||||
_viewer!, Pointer<Void>.fromAddress(surfaceAddress), width, height);
|
_viewer!,
|
||||||
|
Pointer<Void>.fromAddress(surfaceAddress),
|
||||||
|
size.width.toInt(),
|
||||||
|
size.height.toInt());
|
||||||
if (nativeTexture != 0) {
|
if (nativeTexture != 0) {
|
||||||
assert(surfaceAddress == 0);
|
assert(surfaceAddress == 0);
|
||||||
_lib.create_render_target(_viewer!, nativeTexture, width, height);
|
_lib.create_render_target(
|
||||||
|
_viewer!, nativeTexture, size.width.toInt(), size.height.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
_lib.update_viewport_and_camera_projection_ffi(
|
_lib.update_viewport_and_camera_projection_ffi(
|
||||||
_viewer!, width, height, 1.0);
|
_viewer!, size.width.toInt(), size.height.toInt(), 1.0);
|
||||||
|
|
||||||
_assetManager = _lib.get_asset_manager(_viewer!);
|
_assetManager = _lib.get_asset_manager(_viewer!);
|
||||||
|
|
||||||
@@ -165,11 +172,12 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
Future resize(int width, int height, {double scaleFactor = 1.0}) async {
|
Future resize(int width, int height, {double scaleFactor = 1.0}) async {
|
||||||
_resizing = true;
|
_resizing = true;
|
||||||
setRendering(false);
|
setRendering(false);
|
||||||
_textureId = await _channel.invokeMethod(
|
size = ui.Size(width * _pixelRatio, height * _pixelRatio);
|
||||||
"resize", [width * _pixelRatio, height * _pixelRatio, scaleFactor]);
|
_textureId = await _channel
|
||||||
|
.invokeMethod("resize", [size.width, size.height, scaleFactor]);
|
||||||
_textureIdController.add(_textureId);
|
_textureIdController.add(_textureId);
|
||||||
_lib.update_viewport_and_camera_projection_ffi(
|
_lib.update_viewport_and_camera_projection_ffi(
|
||||||
_viewer!, width, height, scaleFactor);
|
_viewer!, size.width.toInt(), size.height.toInt(), scaleFactor);
|
||||||
_resizing = false;
|
_resizing = false;
|
||||||
setRendering(true);
|
setRendering(true);
|
||||||
}
|
}
|
||||||
@@ -448,7 +456,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
var duration =
|
var duration =
|
||||||
_lib.get_animation_duration_ffi(_assetManager!, asset, animationIndex);
|
_lib.get_animation_duration(_assetManager!, asset, animationIndex);
|
||||||
|
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user