diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index bd8c0c86fb95a19420e4930a9d05997b23c5d9d3..b1449b751728eec6af096459fa6ce4493dd7f3bd 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -1910,7 +1910,7 @@ THREE.GLTFLoader = ( function () { if ( bufferView !== null ) { // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes. - bufferAttribute.setArray( bufferAttribute.array.slice() ); + bufferAttribute = new THREE.BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized ); } diff --git a/examples/js/utils/BufferGeometryUtils.js b/examples/js/utils/BufferGeometryUtils.js index 473d48661d36fbfcaf5dd848eca1821c06609180..5225b84ef4c151cea5e0d0132c52b3e4eacb26c6 100644 --- a/examples/js/utils/BufferGeometryUtils.js +++ b/examples/js/utils/BufferGeometryUtils.js @@ -589,19 +589,9 @@ THREE.BufferGeometryUtils = { var name = attributeNames[ i ]; var oldAttribute = geometry.getAttribute( name ); - var attribute; var buffer = new oldAttribute.array.constructor( attrArrays[ name ] ); - if ( oldAttribute.isInterleavedBufferAttribute ) { - - attribute = new THREE.BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.itemSize ); - - } else { - - attribute = geometry.getAttribute( name ).clone(); - attribute.setArray( buffer ); - - } + var attribute = new THREE.BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.normalized ); result.addAttribute( name, attribute ); @@ -610,8 +600,10 @@ THREE.BufferGeometryUtils = { for ( var j = 0; j < morphAttrsArrays[ name ].length; j ++ ) { - var morphAttribute = geometry.morphAttributes[ name ][ j ].clone(); - morphAttribute.setArray( new morphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] ) ); + var oldMorphAttribute = geometry.morphAttributes[ name ][ j ]; + + var buffer = new oldMorphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] ); + var morphAttribute = new THREE.BufferAttribute( buffer, oldMorphAttribute.itemSize, oldMorphAttribute.normalized ); result.morphAttributes[ name ][ j ] = morphAttribute; } @@ -620,23 +612,7 @@ THREE.BufferGeometryUtils = { } - // Generate an index buffer typed array - var cons = Uint8Array; - if ( newIndices.length >= Math.pow( 2, 8 ) ) cons = Uint16Array; - if ( newIndices.length >= Math.pow( 2, 16 ) ) cons = Uint32Array; - - var newIndexBuffer = new cons( newIndices ); - var newIndices = null; - if ( indices === null ) { - - newIndices = new THREE.BufferAttribute( newIndexBuffer, 1 ); - - } else { - - newIndices = geometry.getIndex().clone(); - newIndices.setArray( newIndexBuffer ); - - } + // indices result.setIndex( newIndices ); diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index adf5cddce421260e275fc2dd78a99495cd0bcebb..c1ea344e49a5db0f2d71721f7607ddbedd0efe83 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -1974,7 +1974,7 @@ var GLTFLoader = ( function () { if ( bufferView !== null ) { // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes. - bufferAttribute.setArray( bufferAttribute.array.slice() ); + bufferAttribute = new BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized ); } diff --git a/examples/jsm/utils/BufferGeometryUtils.js b/examples/jsm/utils/BufferGeometryUtils.js index 3b3d8f954f8da6fa8f3a0e229010f737b0ef639f..9e86d9b2c438533f0d5641ea60ff26f701c009bb 100644 --- a/examples/jsm/utils/BufferGeometryUtils.js +++ b/examples/jsm/utils/BufferGeometryUtils.js @@ -598,19 +598,9 @@ var BufferGeometryUtils = { var name = attributeNames[ i ]; var oldAttribute = geometry.getAttribute( name ); - var attribute; var buffer = new oldAttribute.array.constructor( attrArrays[ name ] ); - if ( oldAttribute.isInterleavedBufferAttribute ) { - - attribute = new BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.itemSize ); - - } else { - - attribute = geometry.getAttribute( name ).clone(); - attribute.setArray( buffer ); - - } + var attribute = new BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.normalized ); result.addAttribute( name, attribute ); @@ -619,8 +609,10 @@ var BufferGeometryUtils = { for ( var j = 0; j < morphAttrsArrays[ name ].length; j ++ ) { - var morphAttribute = geometry.morphAttributes[ name ][ j ].clone(); - morphAttribute.setArray( new morphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] ) ); + var oldMorphAttribute = geometry.morphAttributes[ name ][ j ]; + + var buffer = new oldMorphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] ); + var morphAttribute = new BufferAttribute( buffer, oldMorphAttribute.itemSize, oldMorphAttribute.normalized ); result.morphAttributes[ name ][ j ] = morphAttribute; } @@ -629,23 +621,7 @@ var BufferGeometryUtils = { } - // Generate an index buffer typed array - var cons = Uint8Array; - if ( newIndices.length >= Math.pow( 2, 8 ) ) cons = Uint16Array; - if ( newIndices.length >= Math.pow( 2, 16 ) ) cons = Uint32Array; - - var newIndexBuffer = new cons( newIndices ); - var newIndices = null; - if ( indices === null ) { - - newIndices = new BufferAttribute( newIndexBuffer, 1 ); - - } else { - - newIndices = geometry.getIndex().clone(); - newIndices.setArray( newIndexBuffer ); - - } + // indices result.setIndex( newIndices );