Skip to content

Commit

Permalink
GLTFExporter: Add ability to process interleaved buffer attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed May 22, 2020
1 parent 5aae4a3 commit 39fbd2c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
19 changes: 16 additions & 3 deletions examples/js/exporters/GLTFExporter.js
Expand Up @@ -506,9 +506,22 @@ THREE.GLTFExporter.prototype = {

for ( var a = 0; a < attribute.itemSize; a ++ ) {

// @TODO Fails on InterleavedBufferAttribute, and could probably be
// optimized for normal BufferAttribute.
var value = attribute.array[ i * attribute.itemSize + a ];
var value;

if ( attribute.itemSize > 3 ) {

// no support for interleaved data for itemSize > 3

value = attribute.array[ i * attribute.itemSize + a ];

} else {

if ( a === 0 ) value = attribute.getX( i );
if ( a === 1 ) value = attribute.getY( i );
if ( a === 2 ) value = attribute.getZ( i );
if ( a === 3 ) value = attribute.getW( i );

}

if ( componentType === WEBGL_CONSTANTS.FLOAT ) {

Expand Down
19 changes: 16 additions & 3 deletions examples/jsm/exporters/GLTFExporter.js
Expand Up @@ -528,9 +528,22 @@ GLTFExporter.prototype = {

for ( var a = 0; a < attribute.itemSize; a ++ ) {

// @TODO Fails on InterleavedBufferAttribute, and could probably be
// optimized for normal BufferAttribute.
var value = attribute.array[ i * attribute.itemSize + a ];
var value;

if ( attribute.itemSize > 3 ) {

// no support for interleaved data for itemSize > 3

value = attribute.array[ i * attribute.itemSize + a ];

} else {

if ( a === 0 ) value = attribute.getX( i );
if ( a === 1 ) value = attribute.getY( i );
if ( a === 2 ) value = attribute.getZ( i );
if ( a === 3 ) value = attribute.getW( i );

}

if ( componentType === WEBGL_CONSTANTS.FLOAT ) {

Expand Down

0 comments on commit 39fbd2c

Please sign in to comment.