Movable Grippers (in WebView and VR)ΒΆ
The movable component allows you to wrap objects inside,
and change their position and orientation. The following
exmaple shows how to detect the OBJECT_MOVE
events.
Detecting MovementΒΆ
To get the current location of the gripper, you can bind
to the OBJECT_MOVE
event. The event object also contains
the key of the movable that is being moved. This is a way
to identify the movable object.
I plan to make it possible to bind the event listener to a specific movable object for a more compact API.
@app.add_handler("OBJECT_MOVE")
async def handler(event, session):
print(f"Movement Event: key-{event.key}", event.value)
As usual, we spawn the main session:
@app.spawn(start=True)
async def main(session: VuerSession):
session.set @ DefaultScene()
session.upsert @ Movable(Gripper(key="not-moving"))
import numpy as np
for i in range(10000):
# We move the gripper at a const speed around the origin.
x = np.sin(i / 60) / 2
y = np.cos(i / 60) / 2
session.upsert @ Movable(Gripper(), position=[x, y, 0], key='moving-one')
await sleep(0.016)