# Action with near object which one is better LOD vs raycast

**URL:** <https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817>\
**Category:** Questions\
**Tags:** raycaster, lod\
**Created:** [June 3, 2022, 5:29am UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817 "2022-06-03T05:29:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aswwwcom](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@aswwwcom](https://discourse.threejs.org/u/aswwwcom)\
**Post date:** [June 3, 2022, 5:29am UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/1 "2022-06-03T05:29:37Z")

</div>

Hi, I have no supervier in my workplace I think I ask alot in here

Anyway, The question is same as in title.

I’d like to make an action like show sprite near by object, which can interact object. Recently I’m using LOD for my code.

I think raycasting in every frame to every interactable object is very inefficient.  
But also I think it is very unusual to use LOD to make some action when only near.

Is LOD is more efficient then raycasting to every object?  
plus I’m using bvh so I think the raycast is fast enough.

---

<div class="post-metadata">

**Author:** ![vielzutun.ch](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/vielzutun.ch/32/21366_2.png) [@vielzutun.ch](https://discourse.threejs.org/u/vielzutun.ch)\
**Post date:** [June 3, 2022, 7:58am UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/2 "2022-06-03T07:58:58Z")

</div>

> [@aswwwcom](#):
>
> But also I think it is very unusual to use LOD to make some action when only near.

From a strictly practical point of view (irrespective of any performance considerations) I would prefer to interact with nearby objects. Because they occupy more screen space, and are thus easier to hit (i.e.: harder to miss) with a mouse, and also provide higher resolution in the visual feedback of any such interaction.

LODs are not meant for simplifying interaction. Rather, they make it easier on the GPU for rendering, because few large triangles render faster than many tiny triangles covering the same screen space.

Lastly: if a raycaster finds an LOD or its current(!) representation depending on distance of camera should be irrelevant to you. Because you’ll want to interact with the object itself, not with its current representation within the LOD. But I think. others will be better able on clarifying that.

---

<div class="post-metadata">

**Author:** ![rrrr\_rrrr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/rrrr_rrrr/32/7697_2.png) [@rrrr\_rrrr](https://discourse.threejs.org/u/rrrr_rrrr)\
**Post date:** [June 3, 2022, 2:48pm UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/3 "2022-06-03T14:48:20Z")

</div>

> [@aswwwcom](#):
>
> I’d like to make an action like show sprite near by object, which can interact object.

Are you aiming to display some label when the mouse is close to the object ?  
If so, what shape are these objects.

---

<div class="post-metadata">

**Author:** ![aswwwcom](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@aswwwcom](https://discourse.threejs.org/u/aswwwcom)\
**Post date:** [June 3, 2022, 3:13pm UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/4 "2022-06-03T15:13:47Z")

</div>

nope not the mouse but the character

I’ll show you what I want 🙂  
when far

 ![IMG_7459.PNG](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/c/f/cf470ebc0850021e33c0c69b865f21f306028ad5.jpeg)  
when near  
 ![IMG_7460.PNG](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/8/d/8d0d44e55c407fe6edc8c52054cb692d622cab90.jpeg)

---

<div class="post-metadata">

**Author:** ![rrrr\_rrrr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/rrrr_rrrr/32/7697_2.png) [@rrrr\_rrrr](https://discourse.threejs.org/u/rrrr_rrrr)\
**Post date:** [June 3, 2022, 3:27pm UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/5 "2022-06-03T15:27:48Z")

</div>

Would distance[Obj\_1, Obj\_2] \< Obj\_1.geometry.boundingSphere.radius + Obj\_2.geometry.boundingSphere.radius  
work?

You can get away with 100’s of these equations and **NOT** kill your FPS.

---

<div class="post-metadata">

**Author:** ![aswwwcom](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@aswwwcom](https://discourse.threejs.org/u/aswwwcom)\
**Post date:** [June 3, 2022, 3:44pm UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/6 "2022-06-03T15:44:44Z")

</div>

so you mean If I manually check the distance between obstacle and character it won’t affect framrate right?

---

<div class="post-metadata">

**Author:** ![rrrr\_rrrr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/rrrr_rrrr/32/7697_2.png) [@rrrr\_rrrr](https://discourse.threejs.org/u/rrrr_rrrr)\
**Post date:** [June 3, 2022, 4:15pm UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/7 "2022-06-03T16:15:27Z")

</div>

> [@aswwwcom](#):
>
> so you mean If I manually check the distance between obstacle and character it won’t affect framrate right ?

Unless, you are doing 1000’s on low profile machine.  
Here is a vid with collision detection using this concept.

---

<div class="post-metadata">

**Author:** ![aswwwcom](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@aswwwcom](https://discourse.threejs.org/u/aswwwcom)\
**Post date:** [June 3, 2022, 4:36pm UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/8 "2022-06-03T16:36:49Z")

</div>

Oh I got it! Thanks for your help! I think I’ll use that way! 🙂

---

<div class="post-metadata">

**Author:** ![rrrr\_rrrr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/rrrr_rrrr/32/7697_2.png) [@rrrr\_rrrr](https://discourse.threejs.org/u/rrrr_rrrr)\
**Post date:** [June 4, 2022, 3:14am UTC](https://discourse.threejs.org/t/action-with-near-object-which-one-is-better-lod-vs-raycast/38817/9 "2022-06-04T03:14:40Z")

</div>

Keep in mind, BSR might not be best way to go, specially for objects that have high w/h ratio.  
Anyway, if you ran into any problems, start a new thread.

Good luck.
