start using menu for example project & add methods for getting camera model/view matrices

This commit is contained in:
Nick Fisher
2023-11-03 22:17:39 +08:00
parent f5cc7a8174
commit 48be185bba
15 changed files with 895 additions and 729 deletions

View File

@@ -440,9 +440,10 @@ abstract class FilamentController {
///
/// Sets the options for manipulating the camera via the viewport.
/// ManipulatorMode.FREE_FLIGHT and ManipulatorMode.MAP are currently unsupported and will throw an exception.
///
Future setCameraManipulatorOptions(
{ManipulatorMode mode = ManipulatorMode.FREE_FLIGHT,
{ManipulatorMode mode = ManipulatorMode.ORBIT,
double orbitSpeedX = 0.01,
double orbitSpeedY = 0.01,
double zoomSpeed = 0.01});

View File

@@ -1012,8 +1012,11 @@ class FilamentControllerFFI extends FilamentController {
var arrayPtr = _lib.get_camera_model_matrix(_viewer!);
var doubleList = arrayPtr.asTypedList(16);
var modelMatrix = Matrix4.fromFloat64List(doubleList);
var position = modelMatrix.getColumn(3).xyz;
calloc.free(arrayPtr);
return modelMatrix.getColumn(3).xyz;
return position;
}
@override
@@ -1032,13 +1035,16 @@ class FilamentControllerFFI extends FilamentController {
@override
Future setCameraManipulatorOptions(
{ManipulatorMode mode = ManipulatorMode.FREE_FLIGHT,
{ManipulatorMode mode = ManipulatorMode.ORBIT,
double orbitSpeedX = 0.01,
double orbitSpeedY = 0.01,
double zoomSpeed = 0.01}) async {
if (_viewer == null) {
throw Exception("No viewer available");
}
if (mode != ManipulatorMode.ORBIT) {
throw Exception("Manipulator mode $mode not yet implemented");
}
_lib.set_camera_manipulator_options(
_viewer!, mode.index, orbitSpeedX, orbitSpeedX, zoomSpeed);
}