I built a cubic, then use MousePosition
together with GUIScreenShot
to take a floating region with fixed size (200*200) on the screen, and use it as dynamic texture on the cubic. My code is
Needs["GUIKit`"];
$HistoryLength = 1;
DynamicModule[{mpp},
Dynamic@{
Refresh[
ClearSystemCache[];
g = GUIScreenShot[With[{mp = MousePosition[]}, mpp = {mp - 100, mp + 100}]];
Graphics3D[{Texture[g], Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, Lighting -> "Neutral"],
UpdateInterval -> .5],
mpp, g},
Initialization :> (
vtc = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};
coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};)]
You can see the result by executing the code then moving your mouse around. Like this,
But there are two strange problems,
1) the size of the floating area taken should be always 200*200, however it will actually change.
2) the memory usage will constantly grow as we move our mouse, but I have already used $HistoryLength=1
and ClearSystemCache[]
.
Any suggestion?