# Manipulating a Graphics3D output with a large number of geometric primitives

I'm attempting to view and rotate a Graphics3D object with a very large set of geometric primitives ($\approx 10^6$ objects such as spheres or lines), and everything is functioning very slowly. Are there any tricks for speeding up object display / manipulations or to spread the burden of redrawing the image over multiple cores?

Also, how can I specify that the object should initially appear larger in the Mathematica workbook? More specifically, I mean that I would like to specify that the output for some Graphics3D[...] command should initially be displayed at a specified size in the workbook?

• For the second part, does ImageSize do what you want? – acl Mar 8 '13 at 22:34
• – Vitaliy Kaurov Mar 8 '13 at 22:45
• The number of objects you have is in the same order as the number of pixels on your screen. You won't be able to visualize them anyhow. This doesn't seem to make much sense. – Sjoerd C. de Vries Mar 8 '13 at 22:48
• You could use ViewRange to restrict your viewing space. I assume (but haven't tested ) that this will reduce drawing time. – Sjoerd C. de Vries Mar 8 '13 at 22:53
• Why not add your code? For Line primitives try the line collection syntax which renders quicker. See reference.wolfram.com/mathematica/ref/Line.html and mathematica.stackexchange.com/questions/1900/… – Yves Klett Mar 9 '13 at 9:28

For image size look at this question. For the rest... Well I think @SjoerdC.deVries thoughts are spot on. I also can add that probably a powerful video card will make a difference. With 10^5 spheres my GPU load goes sky-high. Yet in terms of memory and computational time to simply create the graphics initially you need to use GraphicsComplex because it is treated as single graphics primitive. This may also help you with some further manipulations. For example if you are adding spheres with a Dynamic slider - GraphicsComplex will work much faster. Here is some simple numbers:

Compute 10^5 points:

p = RandomReal[1, {10^5, 3}];


Build 10^5 spheres using GraphicsComplex and compute time and size

obj = GraphicsComplex[p, Sphere[Range[10^5], .01]];
t0 = AbsoluteTime[];
gr = Graphics3D[obj]
AbsoluteTime[] - t0
gr // ByteCount


Build 10^5 spheres, each separately and compute time and size

obj = Sphere[#, .01] & /@ p;
t0 = AbsoluteTime[];
gr = Graphics3D[obj]
AbsoluteTime[] - t0
gr // ByteCount