-
Notifications
You must be signed in to change notification settings - Fork 7
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
Added the Cesium Omniverse Python API with a function to create anchors #496
Conversation
def anchor_xform_at_path( | ||
path: Path, latitude: Optional[float] = None, longitude: Optional[float] = None, height: Optional[float] = None | ||
): | ||
with CesiumInterfaceManager() as interface: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to go through the old codebase and make sure we're grabbing the singleton elsewhere as a different quick PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
The python script I used. from asyncio import ensure_future
from cesium.omniverse.api.globe_anchor import anchor_xform_at_path
locations = [
{"name": "NewYork", "latitude": 40.7128, "longitude": -74.0060, "population": 8336817},
{"name": "LosAngeles", "latitude": 34.0522, "longitude": -118.2437, "population": 39776830},
{"name": "Chicago", "latitude": 41.8781, "longitude": -87.6298, "population": 2716000},
{"name": "Houston", "latitude": 29.7604, "longitude": -95.3698, "population": 2320257},
{"name": "Phoenix", "latitude": 33.4484, "longitude": -112.0740, "population": 1680992},
{"name": "Philadelphia", "latitude": 39.9526, "longitude": -75.1652, "population": 1584064},
{"name": "SanAntonio", "latitude": 29.4241, "longitude": -98.4936, "population": 1547253},
{"name": "SanDiego", "latitude": 32.7157, "longitude": -117.1611, "population": 1423851},
{"name": "Dallas", "latitude": 32.7767, "longitude": -96.7970, "population": 1343573},
{"name": "SanJose", "latitude": 37.3541, "longitude": -121.9552, "population": 1030119},
]
ctx = omni.usd.get_context()
stage = ctx.get_stage()
async def main():
for location in locations:
anchor_path = "/World/" + location["name"] + "_anchor"
geom_path = anchor_path + "/" + location["name"]
# Create the anchor prim
omni.kit.commands.execute(
"CreateMeshPrimWithDefaultXform", prim_type="Cylinder", prim_path=anchor_path
)
# Creat the actual prim geometry - keep object scaling separate from the globe anchor
omni.kit.commands.execute(
"CreateMeshPrimWithDefaultXform", prim_type="Cylinder", prim_path=geom_path
)
anchor_prim = stage.GetPrimAtPath(anchor_path)
geom_prim = stage.GetPrimAtPath(geom_path)
# Anchor the prim
anchor_xform_at_path(anchor_prim.GetPath(), location["latitude"], location["longitude"], 0.0)
geom_prim = stage.GetPrimAtPath(geom_path)
geom_prim.GetAttribute("xformOp:scale").Set(
(50000.0, 1000000.0, 50000.0)
)
ensure_future(main()) |
Resolves #493.
The implementation for the Cesium Omniverse Python API is pretty simple. A bigger issue here is around the changes to allow us to move the anchor to a lat/long/height early in the process. This is a bit hacky but it works. Probably needs a refactor pass in the future.
2023-10-18.17-37-38.mp4