make iOS/MacOS consistent re moveCameraToBoundingBox

This commit is contained in:
Nick Fisher
2023-09-27 14:21:31 +08:00
parent 182df02b06
commit 908c76d6c3
2 changed files with 8 additions and 6 deletions

View File

@@ -878,11 +878,13 @@ void FilamentViewer::moveCameraToAsset(EntityId entityId) {
return;
}
const filament::Aabb bb = asset->mAsset->getBoundingBox();
const filament::Aabb bb = asset->getBoundingBox();
auto corners = bb.getCorners();
Camera& cam =_view->getCamera();
_cameraPosition = math::mat4f::translation(bb.getCorners());
_cameraRotation = math::mat4f();
cam.setModelMatrix(_cameraPosition * _cameraRotation);
auto eye = corners.vertices[0] * 1.5;
auto lookAt = corners.vertices[7];
cam.lookAt(eye, lookAt);
Log("Moved camera to %f %f %f, lookAt %f %f %f, near %f far %f", eye[0], eye[1], eye[2], lookAt[0], lookAt[1], lookAt[2], cam.getNear(), cam.getCullingFar());
}
void FilamentViewer::setCameraRotation(float rads, float x, float y, float z) {

View File

@@ -98,7 +98,7 @@ extern "C" {
}
FLUTTER_PLUGIN_EXPORT void move_camera_to_asset(const void* const viewer, EntityId asset) {
((FilamentViewer*)viewer)->moveCameraToAsset(asset, asset);
((FilamentViewer*)viewer)->moveCameraToAsset(asset);
}
FLUTTER_PLUGIN_EXPORT void set_camera_focus_distance(const void* const viewer, float distance) {