I am a newer in Mathematica. I have drawn a rotating ball here using dynamic, but I cannot see its rotating since the colors on the sphere are always a same pattern and they do not rotate. Are there any ways to fix the colors so I can see a rotating ball?

Dynamic[Graphics3D[{Rotate[Ellipsoid[{0, 0, 0}, {2, 2, 2}], 
Clock[{0, 2 \[Pi]}, 3], {0, 0, 1}]}, Boxed -> False, PlotRange -> 3]]

1 Answer 1


The colours on the sphere are due to illumination (Lighting).

To solve this problem, it is important to be aware that the default lights are fixed relative to the camera, not relative to the coordinate system. If the coordinate system is rotated (as happens when you drag with the mouse), the lights do not move with it.

In the example you show, you are rotating a sphere. A sphere is symmetric to rotation, so absolutely nothing changes in the geometry. It seems to me that what you really want is rotating the camera, while keeping the lights fixed.

We start by taking the default lighting specification and constructing a version with lights in standard (instead of ImageScaled) coordinates:

newLights = Block[{ImageScaled = 2 # &},
   {{"Ambient", RGBColor[0.4, 0.2, 0.2]}, {"Directional", 
     RGBColor[0, 0.18, 0.5], ImageScaled[{2, 0, 2}]}, {"Directional", 
     RGBColor[0.18, 0.5, 0.18], 
     ImageScaled[{2, 2, 3}]}, {"Directional", RGBColor[0.5, 0.18, 0], 
     ImageScaled[{0, 2, 2}]}, {"Directional", RGBColor[0, 0, 0.18], 
     ImageScaled[{0, 0, 2}]}}

Then rotate the ViewPoint instead of the object:

Graphics3D[{Sphere[{0, 0, 0}, 1]},
 Boxed -> False, PlotRange -> 3, 
 ViewPoint -> Dynamic[RotationTransform[Clock[{0, 2 π}, 3], {0, 0, 1}][{1.3, -2.4, 2.}]],
 SphericalRegion -> True,
 Lighting -> newLights]

What I did here is pretty sloppy because a ViewPoint only specifies where the camera is, but not where it is looking. For this particular object, SphericalRegion -> True was sufficient to fix the point/direction where the camera is looking. For more complicated applications consider using ViewVector instead of ViewPoint. ViewAngle may also be useful to fix the field of view. If these are left to be computed automatically, they may change during rotation, causing weird effects.

  • $\begingroup$ Yes! It works. By the way, why this time the sphere is becoming larger and smaller randomly?Manipulate[ Graphics3D[{Sphere[{0, 0, 0}, 1]}, Boxed -> False, Lighting -> {{"Directional", Red, {1, 0, 0}}, {"Directional", Yellow, {0.5, 0.5, 0}}, {"Directional", Blue, {0, 1, 0}}, {"Directional", Pink, {-0.5, -0.5, 0}}}, ViewPoint -> {Cos[[Theta]], Sin[[Theta]], 0}, PlotRange -> 1], {[Theta], 0, 2 [Pi]}] $\endgroup$ Oct 31, 2016 at 13:05
  • $\begingroup$ I know it. SphericalRegion -> True, thanks. $\endgroup$ Oct 31, 2016 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.