diff --git a/trimesh/base.py b/trimesh/base.py
index 06fc753c..7a6aaae8 100644
--- a/trimesh/base.py
+++ b/trimesh/base.py
@@ -1499,10 +1499,8 @@ class Trimesh(Geometry):
         >>> mesh.vertex_neighbors[0]
         [1, 2, 3, 4]
         """
-        graph = self.vertex_adjacency_graph
-        neighbors = [list(graph.neighbors(i)) for
-                     i in range(len(self.vertices))]
-        return np.array(neighbors)
+        return graph.neighbors(
+            edges=self.edges_unique, max_index=len(self.vertices))
 
     @caching.cache_decorator
     def is_winding_consistent(self):
diff --git a/trimesh/graph.py b/trimesh/graph.py
index efad2462..a93c087a 100644
--- a/trimesh/graph.py
+++ b/trimesh/graph.py
@@ -727,6 +727,40 @@ def edges_to_coo(edges, count=None, data=None):
     return matrix
 
 
+def neighbors(edges, max_index=None, directed=False):
+    """
+    Find the neigbors for each node in an edgelist graph.
+
+    TODO : re-write this with sparse matrix operations
+
+    Parameters
+    ------------
+    edges : (n, 2) int
+      Connected nodes
+    directed : bool
+      If True, only connect edges in one direction
+
+    Returns
+    ---------
+    neighbors : sequence
+      Vertex index corresponds to set of other vertex indices
+    """
+    neighbors = collections.defaultdict(set)
+    if directed:
+        [neighbors[edge[0]].add(edge[1])
+         for edge in edges]
+    else:
+        [(neighbors[edge[0]].add(edge[1]),
+          neighbors[edge[1]].add(edge[0]))
+         for edge in edges]
+
+    if max_index is None:
+        max_index = edges.max() + 1
+    array = [list(neighbors[i]) for i in range(max_index)]
+
+    return array
+
+
 def smoothed(mesh, angle=None, facet_minarea=15):
     """
     Return a non- watertight version of the mesh which
diff --git a/trimesh/scene/cameras.py b/trimesh/scene/cameras.py
index 517a04de..0c7d24d2 100644
--- a/trimesh/scene/cameras.py
+++ b/trimesh/scene/cameras.py
@@ -399,7 +399,7 @@ def ray_pixel_coords(camera):
 
     # create a matching array of pixel indexes for the rays
     pixels = util.grid_linspace(
-        bounds=[[0, res[1]], [res[0], 0]],
+        bounds=[[0, res[1] - 1], [res[0] - 1, 0]],
         count=res).astype(np.int64)
     assert xy.shape == pixels.shape
 
diff --git a/trimesh/scene/scene.py b/trimesh/scene/scene.py
index ece0440b..2a33d4bf 100644
--- a/trimesh/scene/scene.py
+++ b/trimesh/scene/scene.py
@@ -999,7 +999,7 @@ class Scene(Geometry):
         scale_3D = np.eye(4) * scale
 
         # preallocate transforms and geometries
-        nodes = self.graph.nodes_geometry
+        nodes = np.array(self.graph.nodes_geometry)
         transforms = np.zeros((len(nodes), 4, 4))
         geometries = [None] * len(nodes)
 
@@ -1027,7 +1027,7 @@ class Scene(Geometry):
                 # otherwise apply the full transform
                 result.geometry[geometry].apply_transform(new_geom)
 
-            for node, T in zip(self.graph.nodes_geometry[group],
+            for node, T in zip(nodes[group],
                                transforms[group]):
                 # generate the new transforms
                 transform = util.multi_dot(
diff --git a/trimesh/scene/transforms.py b/trimesh/scene/transforms.py
index e9e85dd9..d739c48a 100644
--- a/trimesh/scene/transforms.py
+++ b/trimesh/scene/transforms.py
@@ -263,7 +263,7 @@ class TransformForest(object):
         nodes : (n,) array
           All node names
         """
-        nodes = np.array(list(self.transforms.nodes()))
+        nodes = list(self.transforms.nodes())
         return nodes
 
     @caching.cache_decorator
@@ -276,10 +276,9 @@ class TransformForest(object):
         nodes_geometry : (m,) array
           Node names which have geometry associated
         """
-        nodes = np.array(
-            [n for n, attr in self.transforms.nodes(data=True)
-             if 'geometry' in attr])
-
+        nodes = [n for n, attr in
+                 self.transforms.nodes(data=True)
+                 if 'geometry' in attr]
         return nodes
 
     @caching.cache_decorator
diff --git a/trimesh/version.py b/trimesh/version.py
index 3994639a..29dbcd28 100644
--- a/trimesh/version.py
+++ b/trimesh/version.py
@@ -1,1 +1,1 @@
-__version__ = '3.6.26'
+__version__ = '3.6.29'

pixel out of range in [scene.camera_rays()]
```
scene.camera.resolution = [512, 512]
origins, vectors, pixels = scene.camera_rays()
print(pixels[:3])
```
**output**
```
[[  0 512]
 [  0 510]
 [  0 509]]
```

the **512** should be **511**

I think that's because in `cameras.ray_pixel_coords` method:

```
    pixels = util.grid_linspace(
        bounds=[[0, res[1]], [res[0], 0]],
        count=res).astype(np.int64)
```
should change to
`bounds=[[0, res[1]-1], [res[0]-1, 0]]`

But I am not sure it's consistent with other code somewhere I don't know
diff --git a/tests/generic.py b/tests/generic.py
index e3861220..f7c53e3b 100644
--- a/tests/generic.py
+++ b/tests/generic.py
@@ -71,7 +71,7 @@ except ImportError as E:
     has_path = False
 
 try:
-    from scipy import spatial, csgraph
+    from scipy import spatial, sparse
 except BaseException as E:
     if all_dep:
         raise E
diff --git a/tests/test_camera.py b/tests/test_camera.py
index f37c9a5f..69f45815 100644
--- a/tests/test_camera.py
+++ b/tests/test_camera.py
@@ -123,6 +123,18 @@ class CameraTests(g.unittest.TestCase):
         g.trimesh.scene.cameras.look_at(points, fov, center=points[0])
         g.trimesh.scene.cameras.look_at(points, fov, distance=1)
 
+    def test_ray_index(self):
+        # make sure to_rays is giving valid indexes
+        s = g.trimesh.scene.Scene()
+        res = g.np.array([512, 512])
+        for i in range(0, 1000, 79):
+            current = res + i
+            s.camera.resolution = current
+            # get ray index of camera
+            rid = s.camera.to_rays()[1]
+            assert all(rid.min(axis=0) == 0)
+            assert all(rid.max(axis=0) == current - 1)
+
 
 if __name__ == '__main__':
     g.trimesh.util.attach_to_log()

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc libspatialindex-dev
3.6
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
autoprop==4.1.0
backports.cached-property==1.0.2
certifi==2021.5.30
chardet==5.0.0
charset-normalizer==2.0.12
colorlog==6.9.0
coverage==6.2
cycler==0.11.0
Cython==3.0.12
decorator==4.4.2
execnet==1.9.0
glooey==0.3.6
idna==3.10
imageio==2.15.0
importlib-metadata==4.8.3
iniconfig==1.1.1
jsonschema==3.2.0
kiwisolver==1.3.1
lxml==5.3.1
matplotlib==3.3.4
meshio==4.4.6
more-itertools==8.14.0
mpmath==1.3.0
msgpack==1.0.5
networkx==2.5.1
numpy==1.19.5
packaging==21.3
Pillow==8.4.0
pluggy==1.0.0
psutil==7.0.0
py==1.11.0
pycollada==0.8
pyglet==2.0.10
pyparsing==3.1.4
pyrsistent==0.18.0
pytest==7.0.1
pytest-asyncio==0.16.0
pytest-cov==4.0.0
pytest-mock==3.6.1
pytest-xdist==3.0.2
python-dateutil==2.9.0.post0
python-fcl==0.7.0.5
PyWavelets==1.1.1
PyYAML==6.0.1
requests==2.27.1
Rtree==0.9.7
scikit-image==0.17.2
scipy==1.5.4
Shapely==1.8.5.post1
signature_dispatch==1.0.0
six==1.17.0
svg.path==6.2
sympy==1.9
tifffile==2020.9.3
tomli==1.2.3
triangle==20220202
-e git+https://github.com/mikedh/trimesh.git@7ecffb6302388aebe24508f97c33f50fbf9827fe#egg=trimesh
typeguard==2.13.3
typing==3.7.4.3
typing_extensions==4.1.1
urllib3==1.26.20
vecrec==0.3.1
xxhash==3.2.0
zipp==3.6.0

name: trimesh
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - autoprop==4.1.0
      - backports-cached-property==1.0.2
      - chardet==5.0.0
      - charset-normalizer==2.0.12
      - colorlog==6.9.0
      - coverage==6.2
      - cycler==0.11.0
      - cython==3.0.12
      - decorator==4.4.2
      - execnet==1.9.0
      - glooey==0.3.6
      - idna==3.10
      - imageio==2.15.0
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jsonschema==3.2.0
      - kiwisolver==1.3.1
      - lxml==5.3.1
      - matplotlib==3.3.4
      - meshio==4.4.6
      - more-itertools==8.14.0
      - mpmath==1.3.0
      - msgpack==1.0.5
      - networkx==2.5.1
      - numpy==1.19.5
      - packaging==21.3
      - pillow==8.4.0
      - pluggy==1.0.0
      - psutil==7.0.0
      - py==1.11.0
      - pycollada==0.8
      - pyglet==2.0.10
      - pyparsing==3.1.4
      - pyrsistent==0.18.0
      - pytest==7.0.1
      - pytest-asyncio==0.16.0
      - pytest-cov==4.0.0
      - pytest-mock==3.6.1
      - pytest-xdist==3.0.2
      - python-dateutil==2.9.0.post0
      - python-fcl==0.7.0.5
      - pywavelets==1.1.1
      - pyyaml==6.0.1
      - requests==2.27.1
      - rtree==0.9.7
      - scikit-image==0.17.2
      - scipy==1.5.4
      - shapely==1.8.5.post1
      - signature-dispatch==1.0.0
      - six==1.17.0
      - svg-path==6.2
      - sympy==1.9
      - tifffile==2020.9.3
      - tomli==1.2.3
      - triangle==20220202
      - typeguard==2.13.3
      - typing==3.7.4.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - vecrec==0.3.1
      - xxhash==3.2.0
      - zipp==3.6.0
prefix: /opt/conda/envs/trimesh

tests/test_camera.py::CameraTests::test_ray_index
tests/test_camera.py::CameraTests::test_K tests/test_camera.py::CameraTests::test_consistency tests/test_camera.py::CameraTests::test_focal_updates_on_resolution_change tests/test_camera.py::CameraTests::test_fov_updates_on_resolution_change tests/test_camera.py::CameraTests::test_lookat
trimesh/scene/scene.py trimesh/graph.py trimesh/version.py trimesh/scene/cameras.py trimesh/scene/transforms.py trimesh/base.py
trimesh/scene/scene.py trimesh/graph.py trimesh/version.py trimesh/scene/cameras.py trimesh/scene/transforms.py trimesh/base.py