spite/THREE.MeshLine

Line disappers as gets zooomed in

kurosh-z opened this issue · 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

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.

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

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

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!