# Raycasting Point Clouds has mistake and slow

**URL:** <https://discourse.threejs.org/t/raycasting-point-clouds-has-mistake-and-slow/8925>\
**Category:** Questions\
**Tags:** points, points-material, raycaster\
**Created:** [August 8, 2019, 7:37am UTC](https://discourse.threejs.org/t/raycasting-point-clouds-has-mistake-and-slow/8925 "2019-08-08T07:37:52Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![EliasHasle](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/eliashasle/32/3010_2.png) [@EliasHasle](https://discourse.threejs.org/u/EliasHasle)\
**Post date:** [August 8, 2019, 2:42pm UTC](https://discourse.threejs.org/t/raycasting-point-clouds-has-mistake-and-slow/8925/4 "2019-08-08T14:42:58Z")

</div>

If the point cloud is static, you can benefit greatly from employing a spatial index (still on CPU!). You will need to replace the `raycast` method, as I did with Mesh.raycast here: [Octree injection for faster raycasting/raytracing](https://discourse.threejs.org/t/octree-injection-for-faster-raycasting-raytracing/8291)

The principle is that you build the spatial index once, and then use it to accelerate multiple searches afterwards. An octree is just one among several possible options, and my implementation above is a bit naïve.

---

_[View the full topic](https://discourse.threejs.org/t/raycasting-point-clouds-has-mistake-and-slow/8925)._
