How to merge geometry after loading in three.js?

Messages
6th November 2017 - 03:16:47 PM
BufferGeometry.merge(bufferGeometryFromSEA3D file) does not work properly for me :/ Any help is welcome. Thank you.
9th November 2017 - 05:43:32 AM
Hi.

You can post the code in codepen or simlar? It should work, the SEA3D uses THREE.BufferGeometry as default.
9th November 2017 - 12:07:45 PM
I think three.js can't merge indexed buffer geometry. three.js merge method is doing nothing with indexes:

merge: function ( geometry, offset ) {

if ( ! ( geometry && geometry.isBufferGeometry ) ) {

console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );
return;

}

if ( offset === undefined ) offset = 0;

var attributes = this.attributes;

for ( var key in attributes ) {

if ( geometry.attributes[ key ] === undefined ) continue;

var attribute1 = attributes[ key ];
var attributeArray1 = attribute1.array;

var attribute2 = geometry.attributes[ key ];
var attributeArray2 = attribute2.array;

var attributeSize = attribute2.itemSize;

for ( var i = 0, j = attributeSize * offset; i < attributeArray2.length; i ++, j ++ ) {
attributeArray1[ j ] = attributeArray2[ i ];
}

}

return this;

}
9th November 2017 - 03:14:39 PM
I think three.js can't merge indexed buffer geometry.


Just study this topic:
https://github.com/mrdoob/three.js/pull/9529
10th November 2017 - 09:31:53 AM
@remus

i have tested this, but it produce this geo: https://i.imgur.com/Uveyc9j.png from merging of: https://i.imgur.com/7i10amQ.png


Maybe there is any chance to load Sea3D as Geometry? parser options for sea3d loader doesnt work.
10th November 2017 - 04:29:55 PM
Maybe be necessary convert THREE.BufferGeometry to THREE.Geometry:

https://github.com/sunag/sea3d/blob/853922b252bf011cfd6870b1741204b52da43ced/Source/Three.JS/SEA3DLoader.js#L1831

But it would be a three.js bug not sea3d!?
14th November 2017 - 07:04:37 PM
To convert try use:

Help