[R] positioning a light source within a rgl-plot

Duncan Murdoch murdoch.duncan at gmail.com
Sun Jan 27 16:48:36 CET 2013


On 13-01-27 10:37 AM, Alexander Senger wrote:
> Hello useRs,
>
>
> I would like to draw a 3D-surface using rgl with a point-like
> light-source within the scene, that is with finite distance of the
> light-source to the surface to be lit.

The rgl package doesn't support that.

>
>>From the help to the 'light3d' command I read:
>
> "They [the light-sources] are positioned either in world space or
> relative to the camera using polar coordinates."
>
> which *could* be understood as if such a thing would be possible. But
> probably this is wishful thinking as my naive approach:
>
> light3d(x = 0, y = 0, z = 1)

There are no x, y, z arguments to light3d.  Only directional sources at 
infinite distance are supported.
>
> gives an error about un-used arguments in the function call. Also
> skimming the web does not produce any helpful examples.
>
> So please advise if there is a way to achieve my desired setting.
> Alternatively any hint how and where to make (moderate) modifications to
> the source code to get this functionality would be very welcome.

It's rather tedious to make the changes.  You need to change rgl.light, 
the rgl_light function in api.cpp that it calls, and the parts of 
light.hpp and light.cpp that are called by that.  For completeness you'd 
also want to fix writeWebGL and scene3d and the functions they call.

Duncan Murdoch



More information about the R-help mailing list