Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add up axis function #3

Open
wants to merge 2 commits into
base: needle/feature/wasm-improvements
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion pxr/usd/usd/wrapStageJs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "pxr/usd/sdf/wrapPathJs.h"
#include "pxr/base/tf/wrapTokenJs.h"
#include "pxr/usd/usd/emscriptenPtrRegistrationHelper.h"
#include "pxr/usd/usdGeom/metrics.h"
#include "pxr/usd/usdGeom/tokens.h"
#include <functional>

#include <iostream>
Expand Down Expand Up @@ -86,6 +88,19 @@ void Export(pxr::UsdStage& self, const std::string &fileName, bool addFileFormat
self.Export(fileName, addFileFormatComments, arguments);
}

char GetUpAxis(pxr::UsdStage& self)
{
// Convert the UsdStage& to a UsdStageRefPtr
pxr::UsdStageRefPtr stageRefPtr(&self);

// Convert the UsdStageRefPtr to a UsdStageWeakPtr
pxr::UsdStageWeakPtr stageWeakPtr(stageRefPtr);

// Use the weak pointer to get the stage up axis
auto upAxisToken = pxr::UsdGeomGetStageUpAxis(stageWeakPtr);
return upAxisToken == pxr::UsdGeomTokens->y ? 'y' : upAxisToken == pxr::UsdGeomTokens->z ? 'z' : 'x';
}

void MyExit()
{
emscripten_force_exit(0);
Expand All @@ -109,12 +124,12 @@ EMSCRIPTEN_BINDINGS(UsdStage) {

.class_function("Open", &Open)
.class_function("Open", select_overload<pxr::UsdStageRefPtr(const pxr::SdfLayerHandle &layer, pxr::UsdStage::InitialLoadSet)>(&pxr::UsdStage::Open))

.class_function("Exit", &MyExit)
.function("ExportToString", &exportToString<pxr::UsdStage>)
.function("DefinePrim", &pxr::UsdStage::DefinePrim)
.function("Download", &download)
.function("Export", &Export)
.function("GetUpAxis", &GetUpAxis)
.function("GetPrimAtPath", &pxr::UsdStage::GetPrimAtPath)
.function("SetDefaultPrim", &pxr::UsdStage::SetDefaultPrim)
.function("OverridePrim", &pxr::UsdStage::OverridePrim)
Expand Down