In the program I am writing, I have a large asteroid field (implemented using a PointCloud): the problem I run into sometimes is that when the camera moves, the asteroids sometimes disappear as soon as they touch the edge of the screen. If the camera moves gradually, they get closer and closer to the edge and then suddenly pop! - they're gone, even though there should still be a piece of them in view. The problem isn't as obvious if the camera is moving quickly, but you can still spot it if you look closely. How do I fix that?
Here is a link to a JS fiddle with the code I'm using to create the asteroid field (you won't be able to test it, but you can look at it):
https://jsfiddle.net/yazwz464/
Asked
Active
Viewed 1,049 times
1

gameninja
- 61
- 8
-
your objects do not have the correct bounding sphere. – gaitat Aug 02 '16 at 19:43
-
@gaitat How do I fix that? – gameninja Aug 05 '16 at 16:18
-
1once you load an object call `geometry.computeBoundingSphere()` – gaitat Aug 05 '16 at 17:04
2 Answers
3
as gaitat said in his comment the points are culled by camera frustum most likely because your points appear larger than their geometry is
try setting Object3D.frustumCulled = false
for the objects

Derte Trdelnik
- 2,656
- 1
- 22
- 26
-
I already tried setting pointCloud.frustrumCulled to false, but it didn't make a difference. Is there anything else I could try? – gameninja Aug 05 '16 at 16:17
-
anything now would be a guess - can you provide a minimal code that reproduces the problem? jsfiddle preferably, it might be something trivial, obscure or even a bug in the library – Derte Trdelnik Aug 05 '16 at 17:51
-
I added a link to a JS fiddle as requested. I've never used JS fiddle before so I may or may not have done it properly. – gameninja Aug 20 '16 at 01:08
-
this is how a fiddle should look like http://jsfiddle.net/d9Lzdkkr/ (taken from [WestLangley answer](http://stackoverflow.com/questions/12666570/how-to-change-the-zorder-of-object-with-threejs/12666937#12666937)) you need to add animation loop, three library etc so it is displayed with the problem you are having – Derte Trdelnik Aug 24 '16 at 13:09
3
I am updating / modifying locations of points / vertices and was running into this issue also. In my case, I needed to both update the vertices AND compute the bounding sphere.
geometry.verticesNeedUpdate = true;
geometry.computeBoundingSphere();

Xander Luciano
- 3,753
- 7
- 32
- 53