|
@@ -1100,7 +1100,7 @@ THREE.GLTFLoader = ( function () {
|
|
|
// So morphTarget value will depend on mesh's position, then cloning attribute
|
|
|
// for the case if attribute is shared among two or more meshes.
|
|
|
|
|
|
- positionAttribute = accessors[ target.POSITION ].clone();
|
|
|
+ positionAttribute = cloneBufferAttribute( accessors[ target.POSITION ] );
|
|
|
var position = geometry.attributes.position;
|
|
|
|
|
|
for ( var j = 0, jl = positionAttribute.count; j < jl; j ++ ) {
|
|
@@ -1118,7 +1118,7 @@ THREE.GLTFLoader = ( function () {
|
|
|
|
|
|
// Copying the original position not to affect the final position.
|
|
|
// See the formula above.
|
|
|
- positionAttribute = geometry.attributes.position.clone();
|
|
|
+ positionAttribute = cloneBufferAttribute( geometry.attributes.position );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1135,7 +1135,7 @@ THREE.GLTFLoader = ( function () {
|
|
|
|
|
|
// see target.POSITION's comment
|
|
|
|
|
|
- normalAttribute = accessors[ target.NORMAL ].clone();
|
|
|
+ normalAttribute = cloneBufferAttribute( accessors[ target.NORMAL ] );
|
|
|
var normal = geometry.attributes.normal;
|
|
|
|
|
|
for ( var j = 0, jl = normalAttribute.count; j < jl; j ++ ) {
|
|
@@ -1151,7 +1151,7 @@ THREE.GLTFLoader = ( function () {
|
|
|
|
|
|
} else if ( geometry.attributes.normal !== undefined ) {
|
|
|
|
|
|
- normalAttribute = geometry.attributes.normal.clone();
|
|
|
+ normalAttribute = cloneBufferAttribute( geometry.attributes.normal );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1231,6 +1231,31 @@ THREE.GLTFLoader = ( function () {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function cloneBufferAttribute( attribute ) {
|
|
|
+
|
|
|
+ if ( attribute.isInterleavedBufferAttribute ) {
|
|
|
+
|
|
|
+ var count = attribute.count;
|
|
|
+ var itemSize = attribute.itemSize;
|
|
|
+ var array = attribute.array.slice( 0, count * itemSize );
|
|
|
+
|
|
|
+ for ( var i = 0; i < count; ++ i ) {
|
|
|
+
|
|
|
+ array[ i ] = attribute.getX( i );
|
|
|
+ if ( itemSize >= 2 ) array[ i + 1 ] = attribute.getY( i );
|
|
|
+ if ( itemSize >= 3 ) array[ i + 2 ] = attribute.getZ( i );
|
|
|
+ if ( itemSize >= 4 ) array[ i + 3 ] = attribute.getW( i );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return new THREE.BufferAttribute( array, itemSize, attribute.normalized );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return attribute.clone();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/* GLTF PARSER */
|
|
|
|
|
|
function GLTFParser( json, extensions, options ) {
|