7

My buffergeometry disappears after moving the camera to close. You can also see that in drawcalls Three.js example that has TrackballControls. In my case it's alot worser. My points disappear at the distance from 0 to 400 and my lines disappear at the distance from 0 to 100. My objects are working fine with a simple geometry but not with a buffergeometry. I found out that it has something to do with the centroid of the buffergeometry. I tryed to use different camera's, to change the camera range and still it doesn't work. How can I stop my objects to disappear after moving the camera?

Update

Got it working by adding linesMesh.frustumCulled = false; and removing geometry.computeBoundingSphere();. Thanks for all the help.

A. I.
  • 127
  • 2
  • 8
  • Does this have some custom vertex shader, if so, try setting yourMesh.frustrumCulled = false; – pailhead Sep 30 '15 at 15:49
  • Thanks for your comment, but I dont use any custom vertex shaders. I started from the threejs.org/examples/#webgl_buffergeometry_drawcalls example, then I added custom positions with Tween animations for points and lines and now lines and points disappear when I move my camera. Without the animations only the lines disappear when I move the camera to the center of the buffergeometry, just like in the Three.js drawcalls example. – A. I. Sep 30 '15 at 16:32
  • If you really want help, you need to make it easy for someone to help you. – WestLangley Sep 30 '15 at 18:06
  • What is the bounding sphere radius for your `linesMesh` geometry? And why? – WestLangley Sep 30 '15 at 23:40
  • please accept the answer – pailhead Jul 18 '17 at 16:17

3 Answers3

13

Three.js thinks your object is outside the frustum. Add the line

linesMesh.frustumCulled = false;

and it should stop it from disappearing.

Naftali Beder
  • 1,066
  • 1
  • 10
  • 27
pailhead
  • 5,162
  • 2
  • 25
  • 46
0

I suggest that you check your camera's .near clipping parameter. Objects close to the camera will naturally be cut off.

bjorke
  • 3,295
  • 1
  • 16
  • 20
  • I tryed that, but still my points and lines disappear. In http://threejs.org/examples/#webgl_buffergeometry_drawcalls you can see what I'm getting after you keep zooming in with the camera. At some camera position the lines will disappear. In my case points also get disappeared. – A. I. Sep 30 '15 at 00:07
  • this is how cameras work. But be aware, you are not really 'zooming' -- you're moving the camera closer (until it intersects the geometry). If you want to zoom without colliding the camera with the scene, change the FOV (and call `updateProjectionMatrix()` ) – bjorke Sep 30 '15 at 00:14
  • My objects already disappear at the distance of 50-100 and that makes it look like a serious glitch. I prefer to have the fov at 45. My points dont get rendered at the distance of +-400. My objects are animated and so I thought the centroid has something to do with this. – A. I. Sep 30 '15 at 00:26
0

I had a similar issue with BufferGeometry and while myMesh.frustrumCulled = false; did solve the issue, so did myMesh.geometry.computeBoundingSphere();

Reimund
  • 2,346
  • 1
  • 21
  • 25