fix setCameraModelMatrix4

This commit is contained in:
Nick Fisher
2024-09-13 10:36:24 +08:00
parent 571c7e60aa
commit d7149c8282

View File

@@ -1291,8 +1291,9 @@ class ThermionViewerFFI extends ThermionViewer {
@override @override
Future setCameraRotation(Quaternion quaternion) async { Future setCameraRotation(Quaternion quaternion) async {
var modelMatrix = await getCameraModelMatrix(); var modelMatrix = await getCameraModelMatrix();
modelMatrix.setRotation(quaternion.asRotationMatrix()); var translation = modelMatrix.getTranslation();
await setCameraModelMatrix(modelMatrix.storage); modelMatrix = Matrix4.compose(translation, quaternion, Vector3.all(1.0));
await setCameraModelMatrix4(modelMatrix);
} }
/// ///
@@ -1311,6 +1312,7 @@ class ThermionViewerFFI extends ThermionViewer {
Future setCameraModelMatrix4(Matrix4 modelMatrix) async { Future setCameraModelMatrix4(Matrix4 modelMatrix) async {
var mainCamera = get_camera(_viewer!, await getMainCamera()); var mainCamera = get_camera(_viewer!, await getMainCamera());
final out = allocator<double4x4>(1); final out = allocator<double4x4>(1);
matrix4ToDouble4x4(modelMatrix, out.ref);
set_camera_model_matrix(mainCamera, out.ref); set_camera_model_matrix(mainCamera, out.ref);
allocator.free(out); allocator.free(out);
} }
@@ -1815,8 +1817,6 @@ class ThermionViewerFFI extends ThermionViewer {
} }
} }
print("ALLOCATION DONE");
var entity = await withIntCallback((callback) => var entity = await withIntCallback((callback) =>
create_geometry_with_normals_ffi( create_geometry_with_normals_ffi(
_sceneManager!, _sceneManager!,
@@ -1943,6 +1943,4 @@ class ThermionViewerFFI extends ThermionViewer {
Future removeStencilHighlight(ThermionEntity entity) async { Future removeStencilHighlight(ThermionEntity entity) async {
remove_stencil_highlight(_sceneManager!, entity); remove_stencil_highlight(_sceneManager!, entity);
} }
} }