gltfWidget.Rd
This creates a widget holding a glTF scene, with controls to animate it if it supports animation, and with shaders that implement normal textures.
gltfWidget(gltf,
animation = 0,
start = times[1], stop = times[2],
times = gltf$timerange(animation),
method = c("shader", "rigid"),
add = FALSE, close = !add,
verbose = FALSE,
open3dParams = getr3dDefaults(),
usePBR = hasPBRparams(gltf),
PBRargs = list(), ...)
A "gltf"
object, e.g. produced by readglTF
.
Which animation to use? If no animation is present, this is ignored.
The starting and stopping times for the animation. Ignored if no animation.
An alternate way to specify the times. Ignored if no animation.
The
"shader"
method installs a custom shader to implement
the animation in GLSL, as intended for glTF. This is necessary
for the normal texture support.
The "rigid"
method duplicates vertices as necessary so
that all triangles remain rigid as the vertices move, and
should match the corresponding method in playgltf
.
Should the gltf object be added to an existing rgl scene, or should it open a new scene?
Should gltfWidget
close the rgl scene after
producing the widget?
Give some progress information.
A list to pass as the params
argument to
open3d
.
Whether to use physically based rendering methods.
The default
uses an internal function to determine if gltf
actually contains PBR parameters.
A list containing optional arguments to the setPBRshaders
function.
Additional parameters which will be passed to rgl::playwidget
.
See playgltf
for a description of the method
used for animation. The "fixed"
method is fast, but
doesn't do a good job on some animations.
If the gltf
object doesn't contain any animations,
or animation = NA
, this
will simply display it as a widget with no controls.
Physically based rendering (PBR, controlled by usePBR
) is
only used with method = "shader"
.
If PBR is not used, the V8 package is required so that the shaders can be modified.
A widget suitable for display or inclusion in an R Markdown document.
if ((interactive() || rgl::in_pkgdown_example()) && requireNamespace("manipulateWidget")) {
gltf <- readGLB(system.file("glb/RiggedSimple.glb", package = "rgl2gltf"))
gltfWidget(gltf)
}
#> Loading required namespace: manipulateWidget