Buffer: R6 Class for binary buffers in glTF files.

BufferR Documentation

R6 Class for binary buffers in glTF files.

Description

These files typically have one buffer holding all the binary data for a scene.

Methods

Public 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


Method load()

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.

Returns

A list containing components described here: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-buffer.


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.

Usage
Buffer$openBuffer(buf)
Arguments
buf

Buffer number.

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.

Usage
Buffer$closeBuffer(buf)
Arguments
buf

The buffer number.


Method closeBuffers()

Close any open buffers.

Call this after working with a GLTF file to avoid warnings from R about closing unused connections.

Usage
Buffer$closeBuffers()

Method getBufferview()

Get bufferView object.

Usage
Buffer$getBufferview(bufv)
Arguments
bufv

bufferView number.

Returns

A list containing components described here: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-bufferview.


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)
Arguments
bufv

Which bufferView.

Returns

A connection.


Method setBufferview()

Set bufferView object.

Usage
Buffer$setBufferview(bufv, bufferView)
Arguments
bufv

bufferView number.

bufferView

New value to insert.


Method getAccessor()

Get accessor object

Usage
Buffer$getAccessor(acc)
Arguments
acc

Accessor number

Returns

A list containing components described here: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-accessor


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.

Usage
Buffer$readAccessor(acc)
Arguments
acc

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)
Arguments
accessor

Accessor object

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.

Usage
Buffer$dataURI(buf = 0)
Arguments
buf

Buffer to convert.

Returns

String containing data URI.


Method as.list()

Convert to list.

Usage
Buffer$as.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.


rgl documentation built on Oct. 28, 2024, 5:07 p.m.