|
@@ -290,7 +290,23 @@ THREE.GLTFExporter.prototype = {
|
|
|
}
|
|
|
|
|
|
// Create a new dataview and dump the attribute's array into it
|
|
|
- var componentSize = componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ? 2 : 4;
|
|
|
+
|
|
|
+ var componentSize;
|
|
|
+
|
|
|
+ if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) {
|
|
|
+
|
|
|
+ componentSize = 1;
|
|
|
+
|
|
|
+ } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ) {
|
|
|
+
|
|
|
+ componentSize = 2;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ componentSize = 4;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var byteLength = getPaddedBufferSize( count * attribute.itemSize * componentSize );
|
|
|
var dataView = new DataView( new ArrayBuffer( byteLength ) );
|
|
|
var offset = 0;
|
|
@@ -315,6 +331,10 @@ THREE.GLTFExporter.prototype = {
|
|
|
|
|
|
dataView.setUint16( offset, value, true );
|
|
|
|
|
|
+ } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) {
|
|
|
+
|
|
|
+ dataView.setUint8( offset, value );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
offset += componentSize;
|
|
@@ -436,6 +456,10 @@ THREE.GLTFExporter.prototype = {
|
|
|
|
|
|
componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
|
|
|
|
|
|
+ } else if ( attribute.array.constructor === Uint8Array ) {
|
|
|
+
|
|
|
+ componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type.' );
|