Buffer interpolators
x3dom extends the standard interpolators with an option to use a binary data file, the buffer. This extension is based on how gltf uses binary data, and in fact the gltf inline function takes advantage of this extension. A few addtional fields for the interpolator nodes facilitate.
The buffer field defines the url to the binary data file. Accessor field nodes define key and keyValue pointers into the buffer and an additional offset for a view into the buffer. They also define size and data type for key and keyValue.
Here a glTF explanation of the terms: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#binary-data-storage
<coordinateinterpolator id="ci1" DEF='smdimport_1-GEOMETRY-COORD-INTERP' buffer="interpolatorBuffer.bin" duration="1">
<bufferaccessor buffertype="SAMPLER_INPUT" view="0" byteoffset="0" count="25" components="1" componenttype="5126"></bufferaccessor>
<bufferaccessor buffertype="SAMPLER_OUTPUT" view="1" byteoffset="0" count="118800" components="3" componenttype="5126"></bufferaccessor>
<bufferview byteoffset="1425700"></bufferview>
<bufferview byteoffset="1425800"></bufferview>
</coordinateinterpolator>
Using a binary buffer for data storage has the advantage of loading large data sets quickly and smaller downloads. A single buffer file can contain data of all interpolator data sets. A conversion utility would take a xml scene, extract all interpolator nodes, write out binary floats for the first key, record the first byte offset, write out binary floats for the first keyValues, record the byte offset, and continue to the rest of the interpolators. The written file is the buffer file. Then two BufferView nodes are created for each interpolator with its byte offsets for key and keyValue data. Then input and output BufferAccessor nodes are created with 0 byte offsets relative to the corresponding view.
The url to the binary file, that contains the binary buffer data. [ could be MFString to be consistent with Urls in x3d which have fallback options ]. Binary data are expected in little endian byte order.
Specifies the duration of the complete sequence. In glTF key values are time stamps whereas in x3d key values are typically fractions between 0 and 1. The duration value is used to normalize input key data by division.
A list of BufferAccessor nodes. One of bufferType "SAMPLER_INPUT" is intended for the key, and one of bufferType "SAMPLER_OUTPUT" for the keyValue. Both nodes are required. Other bufferTypes are ignored.
-
The node has these fields:
Specifies if the accessor’s elements are scalars, vectors, or matrices, or sampler input or output. Use "SAMPLER_INPUT" for key, and "SAMPLER_OUTPUT" for keyValue. Other values may be used for binary buffer storage of geometry or other nodes. Due to glTF standards, SAMPLER_INPUT values (keys) will be divided by the value of the duration field of the interpolator (see above).
The related buffer view. Index into the related array of bufferViews.
The buffer byteOffset. The offset from the beginning of the referenced view in bytes.
The buffer component type. The type of numerical representation of elements as GL enum. Allowed values:
5120 BYTE 5121 UNSIGNED_BYTE 5122 SHORT 5123 UNSIGNED_SHORT 5125 UNSIGNED_INT 5126 FLOAT
Attribute normalization. If true, integer values will be normalized to [0,1] or [-1,1] based on their representation range.
The buffer element count. The count times the number of elements defined by the components field is used to determine the size of the data in the buffer.
The buffer components. The number of elements per value. 1 for scalar, 3 for 3d vectors, for example.
The buffer byteStride. not used.
A list of BufferView nodes. Each nodes defines a byte offsets into the binary buffer.
-
The node has these fields:
The hint representing the intended GPU buffer type as GL enum to use with this buffer view. Allowed values:
34962 ARRAY_BUFFER 34963 ELEMENT_ARRAY_BUFFER
The offset into the buffer in bytes.
The stride, in bytes, between vertex attributes. Not used for interpolator. Always assumes tightly packed.
The length of the bufferView in bytes. Not used.
X3DOM wiki