THREE.MeshLine icon indicating copy to clipboard operation
THREE.MeshLine copied to clipboard

Line disappers as gets zooomed in

Open kurosh-z opened this issue 6 years ago • 4 comments

Hi , I'm trying to make a simple axis helper and I'm using Meshline for shaft of each arrows. The problem is that it disappears as I zoom in. using fat line instead, seems to work fine! Is there any way to fix this behavior ? meshline: meshline threejs fat line: line2

kurosh-z avatar Feb 17 '20 08:02 kurosh-z

While implementing that shader in Unity I also had this problem. It seems that when you get too close and on some specific camera angles, the line flips to the other side and shows it back face, which wont be rendered. So my temporary solution, until I find the error in the code, is to disable backface culling for my lines.

ardo314 avatar Mar 05 '20 07:03 ardo314

It's probably due to the feature called frustumCulled: https://threejs.org/docs/index.html#api/en/core/Object3D.frustumCulled

Check every frame if the object is in the frustum of the camera before rendering the object. Otherwise, the object gets rendered every frame even if it isn't visible. Default is true.

The quicker solution will be to do that: mesh.frustumCulled = false

But the recommended solution will be to define a proper boundingBox to your geometry: https://threejs.org/docs/index.html#api/en/core/Geometry.boundingBox

Jeremboo avatar Apr 08 '20 01:04 Jeremboo

It's probably due to the feature called frustumCulled: https://threejs.org/docs/index.html#api/en/core/Object3D.frustumCulled

Check every frame if the object is in the frustum of the camera before rendering the object. Otherwise, the object gets rendered every frame even if it isn't visible. Default is true.

The quicker solution will be to do that: mesh.frustumCulled = false

But the recommended solution will be to define a proper boundingBox to your geometry: https://threejs.org/docs/index.html#api/en/core/Geometry.boundingBox

Did you test it yourself ? Cause nothing seems to be changing with mesh.frustumCulled=false! ezgif com-video-to-gif

kurosh-z avatar May 24 '20 11:05 kurosh-z

While implementing that shader in Unity I also had this problem. It seems that when you get too close and on some specific camera angles, the line flips to the other side and shows it back face, which wont be rendered. So my temporary solution, until I find the error in the code, is to disable backface culling for my lines.

Thanks @ardo314 for the important information. Set material.side = THREE.DoubleSide solves the problem in my case!

kamikat avatar Jul 21 '21 08:07 kamikat