fix resizing
This commit is contained in:
@@ -362,17 +362,16 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
_item(value: 32, child: Text('set camera model matrix')),
|
_item(value: 32, child: Text('set camera model matrix')),
|
||||||
])),
|
])),
|
||||||
Container(
|
Container(
|
||||||
width: _vertical ? 200 : 400,
|
width: _vertical ? 200 : 400,
|
||||||
height: _vertical ? 400 : 200,
|
height: _vertical ? 400 : 200,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: SizedBox(
|
child: FilamentGestureDetector(
|
||||||
child: FilamentGestureDetector(
|
showControlOverlay: true,
|
||||||
showControlOverlay: true,
|
controller: _filamentController,
|
||||||
controller: _filamentController,
|
child: FilamentWidget(
|
||||||
child: FilamentWidget(
|
controller: _filamentController,
|
||||||
controller: _filamentController,
|
)),
|
||||||
)),
|
),
|
||||||
)),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,10 +187,15 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
createPixelBuffer(width:Int(args[0]), height:Int(args[1]))
|
createPixelBuffer(width:Int(args[0]), height:Int(args[1]))
|
||||||
createDisplayLink()
|
createDisplayLink()
|
||||||
result(self.flutterTextureId)
|
result(self.flutterTextureId)
|
||||||
case "getResourceLoader":
|
|
||||||
let callback = make_resource_loader(loadResource, freeResource, Unmanaged.passUnretained(self).toOpaque())
|
|
||||||
result(unsafeBitCast(callback, to:Int64.self))
|
|
||||||
case "resize":
|
case "resize":
|
||||||
|
rendering = false
|
||||||
|
destroy_swap_chain(viewer)
|
||||||
|
let args = call.arguments as! [Any]
|
||||||
|
resize(width:args[0] as! Int32, height:args[1] as! Int32)
|
||||||
|
var pixelBufferTextureId = unsafeBitCast(pixelBuffer!, to: UnsafeRawPointer.self)
|
||||||
|
create_swap_chain(viewer, pixelBufferTextureId, UInt32(args[0] as! Int64), UInt32(args[1] as! Int64))
|
||||||
|
update_viewport_and_camera_projection(viewer, Int32(args[0] as! Int64), Int32(args[1] as! Int64), Float(args[2] as! Double))
|
||||||
|
rendering = true
|
||||||
result(self.flutterTextureId);
|
result(self.flutterTextureId);
|
||||||
case "createFilamentViewer":
|
case "createFilamentViewer":
|
||||||
let callback = make_resource_loader(loadResource, freeResource, Unmanaged.passUnretained(self).toOpaque())
|
let callback = make_resource_loader(loadResource, freeResource, Unmanaged.passUnretained(self).toOpaque())
|
||||||
@@ -208,10 +213,6 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
case "getAssetManager":
|
case "getAssetManager":
|
||||||
let assetManager = get_asset_manager(viewer)
|
let assetManager = get_asset_manager(viewer)
|
||||||
result(unsafeBitCast(assetManager, to:Int64.self))
|
result(unsafeBitCast(assetManager, to:Int64.self))
|
||||||
case "createRenderTarget":
|
|
||||||
let args = call.arguments as! [Any]
|
|
||||||
create_render_target(viewer, args[0] as! UInt32, args[1] as! UInt32, args[2] as! UInt32)
|
|
||||||
result(true)
|
|
||||||
case "clearBackgroundImage":
|
case "clearBackgroundImage":
|
||||||
clear_background_image(viewer)
|
clear_background_image(viewer)
|
||||||
result(true)
|
result(true)
|
||||||
|
|||||||
@@ -97,21 +97,9 @@ class FilamentController {
|
|||||||
|
|
||||||
Future resize(int width, int height,
|
Future resize(int width, int height,
|
||||||
{double contentScaleFactor = 1.0}) async {
|
{double contentScaleFactor = 1.0}) async {
|
||||||
// await setRendering(false);
|
_textureId = await _channel.invokeMethod("resize",
|
||||||
// _textureIdController.add(null);
|
[width * _pixelRatio, height * _pixelRatio, contentScaleFactor]);
|
||||||
// await _channel.invokeMethod("destroy_swap_chain(_viewer);
|
_textureIdController.add(_textureId);
|
||||||
// size = ui.Size(width * _pixelRatio, height * _pixelRatio);
|
|
||||||
|
|
||||||
// _textureId = await _channel.invokeMethod("resize",
|
|
||||||
// [width * _pixelRatio, height * _pixelRatio, contentScaleFactor]);
|
|
||||||
|
|
||||||
// _textureIdController.add(_textureId);
|
|
||||||
// await _channel.invokeMethod("create_swap_chain( nullptr, width, height);
|
|
||||||
// await _channel.invokeMethod("create_render_target(
|
|
||||||
// await _channel.invokeMethod("getGlTextureId"), width, height);
|
|
||||||
// await _channel.invokeMethod("update_viewport_and_camera_projection(
|
|
||||||
// width, height, contentScaleFactor);
|
|
||||||
// await setRendering(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearBackgroundImage() async {
|
void clearBackgroundImage() async {
|
||||||
|
|||||||
@@ -103,14 +103,19 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
width: constraints.maxWidth,
|
width: constraints.maxWidth,
|
||||||
child: ResizeObserver(
|
child: ResizeObserver(
|
||||||
onResized: (Size oldSize, Size newSize) async {
|
onResized: (Size oldSize, Size newSize) async {
|
||||||
// setState(() {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
// _resizing = true;
|
setState(() {
|
||||||
// });
|
_resizing = true;
|
||||||
|
});
|
||||||
|
|
||||||
await widget.controller.resize(
|
await widget.controller.resize(
|
||||||
newSize.width.toInt(), newSize.height.toInt());
|
newSize.width.toInt(), newSize.height.toInt());
|
||||||
setState(() {
|
WidgetsBinding.instance
|
||||||
_resizing = false;
|
.addPostFrameCallback((_) async {
|
||||||
|
setState(() {
|
||||||
|
_resizing = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Platform.isLinux
|
child: Platform.isLinux
|
||||||
|
|||||||
Reference in New Issue
Block a user