properly free memory in model/view matrix getters
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_filament/filament_controller.dart';
|
import 'package:flutter_filament/filament_controller.dart';
|
||||||
@@ -105,6 +107,12 @@ class _SceneMenuState extends State<SceneMenu> {
|
|||||||
},
|
},
|
||||||
child: const Text("Move camera to shapes asset"),
|
child: const Text("Move camera to shapes asset"),
|
||||||
),
|
),
|
||||||
|
MenuItemButton(
|
||||||
|
onPressed: () {
|
||||||
|
widget.controller!.setCameraRotation(pi / 4, 0.0, 1.0, 0.0);
|
||||||
|
},
|
||||||
|
child: const Text("Rotate camera 45 degrees around y axis"),
|
||||||
|
),
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ abstract class FilamentController {
|
|||||||
Future<Matrix4> getCameraViewMatrix();
|
Future<Matrix4> getCameraViewMatrix();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set the camera position in world space.
|
/// Set the camera position in world space. Note this is not persistent - any viewport navigation will reset the camera transform.
|
||||||
///
|
///
|
||||||
Future setCameraPosition(double x, double y, double z);
|
Future setCameraPosition(double x, double y, double z);
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ abstract class FilamentController {
|
|||||||
double aperture, double shutterSpeed, double sensitivity);
|
double aperture, double shutterSpeed, double sensitivity);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Rotate the camera by [rads] around the given axis.
|
/// Rotate the camera by [rads] around the given axis. Note this is not persistent - any viewport navigation will reset the camera transform.
|
||||||
///
|
///
|
||||||
Future setCameraRotation(double rads, double x, double y, double z);
|
Future setCameraRotation(double rads, double x, double y, double z);
|
||||||
|
|
||||||
|
|||||||
@@ -992,7 +992,9 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
throw Exception("No viewer available");
|
throw Exception("No viewer available");
|
||||||
}
|
}
|
||||||
var arrayPtr = _lib.get_camera_view_matrix(_viewer!);
|
var arrayPtr = _lib.get_camera_view_matrix(_viewer!);
|
||||||
return Matrix4.fromList(arrayPtr.asTypedList(16));
|
var viewMatrix = Matrix4.fromList(arrayPtr.asTypedList(16));
|
||||||
|
calloc.free(arrayPtr);
|
||||||
|
return viewMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -1001,7 +1003,9 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
throw Exception("No viewer available");
|
throw Exception("No viewer available");
|
||||||
}
|
}
|
||||||
var arrayPtr = _lib.get_camera_model_matrix(_viewer!);
|
var arrayPtr = _lib.get_camera_model_matrix(_viewer!);
|
||||||
return Matrix4.fromList(arrayPtr.asTypedList(16));
|
var modelMatrix = Matrix4.fromList(arrayPtr.asTypedList(16));
|
||||||
|
calloc.free(arrayPtr);
|
||||||
|
return modelMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user