Fix rotate issue

This commit is contained in:
2026-06-06 09:34:39 +08:00
parent d4b46b438c
commit 3b0250b882
3 changed files with 174 additions and 4 deletions
+12
View File
@@ -13,6 +13,7 @@
#include <pxr/usd/usdGeom/metrics.h>
#include <pxr/usd/usdGeom/tokens.h>
#include <pxr/usd/usdGeom/xform.h>
#include <pxr/usd/usdGeom/xformCommonAPI.h>
#include <pxr/usd/sdf/layer.h>
#include <pxr/usd/sdf/reference.h>
#include <pxr/usd/sdf/primSpec.h>
@@ -202,6 +203,17 @@ void SceneHierarchyPanel::Render() {
try {
UsdPrim newPrim = m_stage->DefinePrim(primPath, TfToken(typeName));
if (newPrim.IsValid()) {
// Set correct camera orientation for the current up-axis
if (std::string(typeName) == "Camera") {
bool isZUp = (UsdGeomGetStageUpAxis(m_stage) == UsdGeomTokens->z);
if (isZUp) {
pxr::UsdGeomXformCommonAPI xformAPI(newPrim);
xformAPI.SetRotate(
pxr::GfVec3f(90.f, 0.f, 0.f),
pxr::UsdGeomXformCommonAPI::RotationOrderXYZ,
pxr::UsdTimeCode::Default());
}
}
LOG_INFO("Created prim '" + primPath.GetString() + "' of type " + baseName);
SetSelectedPathFromClick(primPath.GetString());
} else {