From 45322ce97566a8fe1ce7573cff62934a20d041fd Mon Sep 17 00:00:00 2001 From: Felix Herbst Date: Tue, 6 Sep 2022 22:13:07 +0200 Subject: [PATCH] wip add SHORT support (for exporting meshopt-compressed meshes, not working yet) --- examples/jsm/exporters/GLTFExporter.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/jsm/exporters/GLTFExporter.js b/examples/jsm/exporters/GLTFExporter.js index c3f0a3f04baaa6..d1236b6fb2bb33 100644 --- a/examples/jsm/exporters/GLTFExporter.js +++ b/examples/jsm/exporters/GLTFExporter.js @@ -157,6 +157,7 @@ const WEBGL_CONSTANTS = { BYTE: 0x1400, UNSIGNED_BYTE: 0x1401, + SHORT: 0x1402, UNSIGNED_SHORT: 0x1403, FLOAT: 0x1406, UNSIGNED_INT: 0x1405, @@ -952,6 +953,10 @@ class GLTFWriter { dataView.setInt8( offset, value ); + } else if ( componentType === WEBGL_CONSTANTS.SHORT ) { + + dataView.setInt16( offset, value ); + } offset += componentSize; @@ -1074,6 +1079,10 @@ class GLTFWriter { componentType = WEBGL_CONSTANTS.BYTE; + } else if ( attribute.array.constructor === Int16Array ) { + + componentType = WEBGL_CONSTANTS.SHORT; + } else { throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type: ' + attribute.array.constructor );