(This is a follow-up question to the answer found here.)
I would like to define a clip plane dynamically from the current ViewPoint of my Graphics3D. Based on the solution found in the link above, I would like to do something like this (where the ClipPlanes option depends on the ViewPoint variable vp):
DynamicModule[
{vp},
{vp} = Options[Graphics3D, ViewPoint][[All, 2]];
Graphics3D[{FaceForm[Red, Blue], Sphere[]}, Axes -> True, ViewPoint -> Dynamic[vp],
ClipPlanes -> {{Sequence@@vp,0}}, ClipPlanesStyle -> Directive[Opacity[.2], Blue]
]
]
Unfortunately this doesn't work, and I couldn't figure out how to do it.
Answer
I think this may be the behavior you desire. I am borrowing Kuba's modified ClipPanes specification. One should not need RawBoxes here I think but it does serve the purpose to get our Dynamic expression into the Front End box form.
DynamicModule[{vp},
{vp} = Options[Graphics3D, ViewPoint][[All, 2]];
Graphics3D[{FaceForm[Red, Blue], Sphere[]},
Axes -> True,
ViewPoint -> Dynamic[vp],
ClipPlanes -> RawBoxes @ Dynamic @ {{Sequence @@ Cross[vp, {0, 0, 1}], 1}},
ClipPlanesStyle -> Directive[Opacity[.2], Blue]
]
]
In Evaluation leak from Dynamic in Button's action John Fultz writes with fair authority:
Front end options, which includes all box options, can take
Dynamicheads. That basically means that the FE will compute the value of theDynamicand use it for the option. And that it will be updated whenever aDynamicdependency updates.
Since:
Graphic3Dexpression is transformed into aGraphics3DBox(as may be viewed with menu command Cell > Show Expression)ClipPlanesremains as an option therein
it stands to reason that this must work if we can keep our Dynamic option value unmolested, and RawBoxes serves to do that.

Comments
Post a Comment