These files typically have one buffer holding all the
binary data for a scene.
Methods
Method new()
Usage
Buffer$new(json = NULL, binfile = NULL)
Arguments
json
list read from glTF file.
binfile
optional External binary filename, or raw vector
Load from file.
Usage
Buffer$load(uri, buf = 0)
Arguments
uri
Which file to load.
buf
Which buffer number to load.
Method saveOpenBuffer()
Write open buffer to connection.
Usage
Buffer$saveOpenBuffer(con, buf = 0)
Arguments
con
Output connection.
buf
Buffer number.
Method getBuffer()
Get buffer object.
Usage
Buffer$getBuffer(buf, default = list(byteLength = 0))
Arguments
buf
Buffer number.
default
Default buffer object if buf
not found.
Method setBuffer()
Set buffer object.
Usage
Buffer$setBuffer(buf, buffer)
Arguments
buf
Buffer number.
buffer
New value to insert.
Method openBuffer()
Open a connection for the data in a buffer.
Returns
An open binary connection.
Method writeBuffer()
Write data to buffer.
Usage
Buffer$writeBuffer(values, type, size, buf = 0)
Arguments
values
Values to write.
type
Type to write.
size
Byte size of each value.
buf
Which buffer to write to.
Returns
Byte offset of start of bytes written.
Method closeBuffer()
Close the connection in a buffer.
If there was a connection open, this will save the
contents in the raw vector bytes
within the buffer object.
Method closeBuffers()
Close any open buffers.
Call this after working with a GLTF file to avoid warnings
from R about closing unused connections.
Method getBufferview()
Get bufferView
object.
Usage
Buffer$getBufferview(bufv)
Method addBufferView()
Add a new buffer view.
Usage
Buffer$addBufferView(values, type, size, target = NULL, buf = 0)
Arguments
values
Values to put in the view.
type
Type of values.
size
Size of values in bytes.
target
Optional target use for values.
buf
Which buffer to write to.
Returns
New bufferView
number.
Method openBufferview()
Open a connection to a buffer view.
Usage
Buffer$openBufferview(bufv)
Method setBufferview()
Set bufferView
object.
Usage
Buffer$setBufferview(bufv, bufferView)
Arguments
bufv
bufferView
number.
bufferView
New value to insert.
Method getAccessor()
Get accessor object
Method setAccessor()
Set accessor object.
Usage
Buffer$setAccessor(acc, accessor)
Arguments
acc
Accessor number.
accessor
New value to insert.
Method readAccessor()
Read data given by accessor number.
Returns
A vector or array as specified in the accessor. For the MATn
types, the 3rd index
indexes the element.
Method readAccessor0()
Read data given by accessor object.
Usage
Buffer$readAccessor0(accessor)
Returns
A vector or array as specified in the accessor. For the MATn
types, the 3rd index
indexes the element.
Method addAccessor()
Write values to accessor, not including min
and max
.
Usage
Buffer$addAccessor(
values,
target = NULL,
types = "anyGLTF",
normalized = FALSE
)
Arguments
values
Values to write.
target
Optional target use for values.
types
Which types can be used?
normalized
Are normalized integers allowed?
useDouble
Whether to write doubles or singles.
Returns
New accessor number
Method dataURI()
Convert buffer to data URI.
Returns
String containing data URI.
Convert to list.
Returns
List suitable for writing using JSON.
Method clone()
The objects of this class are cloneable with this method.
Usage
Buffer$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.