make iOS/MacOS consistent re moveCameraToBoundingBox
This commit is contained in:
@@ -872,17 +872,19 @@ void FilamentViewer::setCameraPosition(float x, float y, float z) {
|
|||||||
|
|
||||||
void FilamentViewer::moveCameraToAsset(EntityId entityId) {
|
void FilamentViewer::moveCameraToAsset(EntityId entityId) {
|
||||||
|
|
||||||
auto asset = _assetManager->getAssetByEntityId(entityId);
|
auto asset = _assetManager->getAssetByEntityId(entityId);
|
||||||
if(!asset) {
|
if(!asset) {
|
||||||
Log("Failed to find asset attached to specified entity id.");
|
Log("Failed to find asset attached to specified entity id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const filament::Aabb bb = asset->mAsset->getBoundingBox();
|
const filament::Aabb bb = asset->getBoundingBox();
|
||||||
|
auto corners = bb.getCorners();
|
||||||
Camera& cam =_view->getCamera();
|
Camera& cam =_view->getCamera();
|
||||||
_cameraPosition = math::mat4f::translation(bb.getCorners());
|
auto eye = corners.vertices[0] * 1.5;
|
||||||
_cameraRotation = math::mat4f();
|
auto lookAt = corners.vertices[7];
|
||||||
cam.setModelMatrix(_cameraPosition * _cameraRotation);
|
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) {
|
void FilamentViewer::setCameraRotation(float rads, float x, float y, float z) {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void move_camera_to_asset(const void* const viewer, EntityId asset) {
|
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) {
|
FLUTTER_PLUGIN_EXPORT void set_camera_focus_distance(const void* const viewer, float distance) {
|
||||||
|
|||||||
Reference in New Issue
Block a user