| propertySetter {rgl} | R Documentation |
propertySlider writes out HTML code to control WebGL displays on the same page via a slider; par3dinterpSetter and
propertySetter return Javascript code
to be used in HTML controls.
propertySlider(setter = propertySetter,
minS = min(param), maxS = max(param), step = 1, init = minS,
labels = displayVals(sliderVals),
id = basename(tempfile("input")), name = id,
outputid = paste0(id, "text"),
...)
propertySetter(values, entries, properties, objids, prefixes = "",
param = seq_len(NROW(values)), interp = TRUE, digits = 7)
par3dinterpSetter(fn, from, to, steps, subscene, omitConstant = TRUE, ...)
setter |
A function to write Javascript code, or its output, or a list containing several of these. |
minS, maxS, step, init |
Slider values to be displayed. |
labels |
Labels to display for each slider value. The
defaults are calculated using internal variables. If |
id |
The |
name |
The name of the input control that will be generated. |
outputid |
The |
... |
See Details below. |
values |
An array of values; rows correspond to slider positions. |
entries, properties, objids, prefixes |
Vectors describing
the columns of |
param |
Parameter values corresponding to each row of |
interp |
Whether to interpolate values. If |
digits |
How many significant digits to emit in the Javascript code. |
fn |
A function returned from |
from, to, steps |
Values where |
subscene |
Which subscene's properties should be modified? |
omitConstant |
If |
The ... parameters to propertySlider will be passed to
setter if the latter is a function, otherwise ignored.
The ... parameters to par3dinterpSetter will be passed
to propertySetter.
propertySetter is a low-level general purpose function for modifying
properties of objects in the scene. It is mainly for internal use.
propertySlider uses it to generate Javascript for a slider control
to manipulate those properties. par3dinterpSetter uses
it to set parameters corresponding to values produced by the result of
par3dinterp.
The rows of the values matrix correspond to different settings
for numeric properties. The columns are values to insert into those properties.
Argument entries gives the numeric (zero based) index into the Javascript
property named by properties, for the object id objids, in the
display with prefix prefixes. All of these may be vectors, corresponding
to the columns of values. All but entries will be recycled
to the appropriate length; its length needs to match the number of
columns in values.
There are two modes for determining the values to substitute. In the simplest
mode (interp = FALSE in propertySetter),
each row of values corresponds to a location for the slider, and
the values are simply copied into place. This requires that param,
min, max and step take on their default values.
In other cases, linear interpolation is used between successive rows of values,
with extrapolation outside the range of param
repeating the first or last row. param should then
contain the values that correspond to exact rows.
In both cases, param must be a strictly increasing vector.
propertySlider prints the full code to generate the control,
and returns the id of the control that was generated.
propertySetter returns a single element character vector
containing the Javascript source for a function to set
the appropriate properties. It does not assign the function
to a variable or include any of the HTML wrapper text that
propertySlider adds.
The character vector has class
"propertySetter", and an attribute named "env"
which gives access to the local environment where it was
created, so for example attr(value, "env")$prefixes will
give access to the prefixes argument if value
was produced by "propertySetter".
Duncan Murdoch
writeWebGL. clipplaneSlider makes
use of propertySlider.
ageSetter can be used as the setter argument
to propertySlider to modify objects according to a linear (age)
scale.
# Just the setter function
cat(propertySetter(1:4, entries = 12, properties = "values", objids = 13))
# A 4-position slider
propertySlider(values = 1:4, entries = 12, properties = "values", objids = 13, interp = FALSE)
# A 10-position slider interpolating the 4-position slider
propertySlider(values = 1:4, entries = 12, properties = "values", objids = 13,
step = (4-1)/9)
# The userMatrix interpolation from example(play3d)
M <- r3dDefaults$userMatrix
fn <- par3dinterp(time = (0:2)*0.75, userMatrix = list(M,
rotate3d(M, pi/2, 1, 0, 0),
rotate3d(M, pi/2, 0, 1, 0) ) )
cat(par3dinterpSetter(fn, 0, 3, steps=10))