spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.13k stars 379 forks source link

Line disappers as gets zooomed in #97

Open kurosh-z opened 4 years ago

kurosh-z commented 4 years ago

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

ardo314 commented 4 years ago

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.

Jeremboo commented 4 years ago

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

kurosh-z commented 4 years ago

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

kamikat commented 2 years ago

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!