The glTF file spec is described here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html. This object encapsulates most of the data from those files.
rgl::Buffer
-> gltf
scene
The default scene number
Inherited methods
rgl::Buffer$addBufferView()
rgl::Buffer$as.list()
rgl::Buffer$closeBuffer()
rgl::Buffer$closeBuffers()
rgl::Buffer$dataURI()
rgl::Buffer$getAccessor()
rgl::Buffer$getBuffer()
rgl::Buffer$getBufferview()
rgl::Buffer$load()
rgl::Buffer$openBuffer()
rgl::Buffer$openBufferview()
rgl::Buffer$readAccessor()
rgl::Buffer$saveOpenBuffer()
rgl::Buffer$setAccessor()
rgl::Buffer$setBuffer()
rgl::Buffer$setBufferview()
rgl::Buffer$writeBuffer()
new()
Gltf$new(json = NULL, defaultbin = NULL)
addAccessor()
Write values to accessor, including min
and max
.
The glTF standard requires min
and max
values in
accessors, whereas other uses of buffers may not.
This function stores in the usual way using the
Buffer$addAccessor()
method, and then adds
min
and max
values.
The standard also doesn't support signed 4 byte integers or double precision values, so we test for those here.
values
Values to write.
target
Optional target use for values.
types
Allowed types (from names of rgl::gltfTypes
), or c("any", "anyGLTF")
).
normalized
Are these normalized integer values?
getScene()
Get scene object.
Scene object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-scene.
getNode()
Get node object.
Node object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-node.
addNode()
Add a node object.
getSkin()
Get skin object.
Skin object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-skin.
getInverseBindMatrices()
Get "inverse bind matrices".
These matrices undo the existing transformation before applying the skin transformations.
getForwardBindMatrices()
Get "forward bind matrices".
These matrices applying the skin transformations.
getCamera()
Get camera object.
Camera object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-camera.
getMesh()
Get mesh object.
Mesh object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-mesh.
getMaterial()
Get material object.
Material object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-material.
getTexture()
Get texture object.
Texture object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-texture.
getImage()
Get image object.
Image object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-image.
addMaterial()
Construct and possibly add material.
This will return an existing material if possible.
Gltf$addMaterial(mat, defaultMaterial = list())
writeVectors()
Write data.
makePrimitive()
Create a primitive record.
inds
Indices of vertices.
mode
Mode of primitive.
attributes
Primitive attributes.
matnum
Material number.
Primitive record, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-primitive.
getAsset()
Get asset list.
Asset object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-asset.
getAnimation()
Get animation.
Animation object, documented here: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-animation.
initAnimation()
Initialize animation.
This builds all of the interpolation functions in the samplers.
settime()
Set time for an animation.
This evaluates all the interpolators and modifies self to reflect the specified time point.
print()
Print gltf
objects with various levels of detail.
## ------------------------------------------------
## Method `Gltf$print`
## ------------------------------------------------
# \donttest{
samples <- "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0"
gltf <- readGLB(paste0(samples, "/2CylinderEngine/glTF-Binary/2CylinderEngine.glb?raw=true"))
gltf$print(names = "meshes")
#> asset fields:
#> GLtf version 2.0 file.
#> Generated by COLLADA2GLTF.
#> Scenes ( 1 )
#> Nodes ( 82 )
#> Buffers ( 1 )
#> Bufferviews ( 2 )
#> Meshes ( 29 )
#> 0: Piston_123-844_0_Parts_1
#> 1: body_24
#> 2: body_23
#> 3: body_22
#> 4: body_21
#> 5: body_20
#> 6: Spring_Link__0_Parts_1
#> 7: body_19
#> 8: body_18
#> 9: body_17
#> 10: body_16
#> 11: body_15
#> 12: body_14
#> 13: body_13
#> 14: body_12
#> 15: body_11
#> 16: body_10
#> 17: body_9
#> 18: body_8
#> 19: body_7
#> 20: body_6
#> 21: body_5
#> 22: body_4
#> 23: body
#> 24: body_3
#> 25: body_2
#> 26: body_1
#> 27: rod_123-699_0_Parts_1
#> 28: Lifter_123-923_0_Parts_1
#> Cameras ( 1 )
#> Accessors ( 102 )
#> Materials ( 34 )
# }