Skip to content

Commit 6785f7e

Browse files
committed
Hoist pyglet.math.Vec3 import to module level (review)
1 parent b422e5a commit 6785f7e

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

source/isaaclab_visualizers/isaaclab_visualizers/newton/newton_visualizer.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import numpy as np
1414
import warp as wp
1515
from newton.viewer import ViewerGL
16+
from pyglet.math import Vec3 as PygletVec3
1617

1718
from isaaclab.visualizers.base_visualizer import BaseVisualizer
1819

@@ -463,17 +464,8 @@ def _apply_camera_pose(self, pose: tuple[tuple[float, float, float], tuple[float
463464
if self._viewer is None:
464465
return
465466
cam_pos, cam_target = pose
466-
# Newton's ``Camera.translate()`` adds a ``pyglet.math.Vec3`` delta to
467-
# ``camera.pos`` via ``+=`` every viewer update. warp 1.13's strict
468-
# ``__add__`` rejects ``wp.vec3 + pyglet.math.Vec3`` with
469-
# ``TypeError: Built-in functions cannot be called with non-Warp array
470-
# types``. The exception is silenced by the visualizer's try/except,
471-
# which then skips ``renderer.render()`` -- the FBO is never written
472-
# and the frame reads back fully black. Assigning a ``pyglet.math.Vec3``
473-
# here keeps the add homogeneous.
474-
from pyglet.math import Vec3 as _PyVec3
475-
476-
self._viewer.camera.pos = _PyVec3(float(cam_pos[0]), float(cam_pos[1]), float(cam_pos[2]))
467+
# Match Newton's Camera native pos type: PyVec3, not wp.vec3.
468+
self._viewer.camera.pos = PygletVec3(float(cam_pos[0]), float(cam_pos[1]), float(cam_pos[2]))
477469
cam_pos_np = np.array(cam_pos, dtype=np.float32)
478470
cam_target_np = np.array(cam_target, dtype=np.float32)
479471
direction = cam_target_np - cam_pos_np

0 commit comments

Comments
 (0)