提交 db7a3497 编写于 作者: M Mr.doob

Merge pull request #5262 from dubejf/dev

BufferGeometry: Clone attributes
...@@ -100,6 +100,31 @@ THREE.BufferAttribute.prototype = { ...@@ -100,6 +100,31 @@ THREE.BufferAttribute.prototype = {
return this; return this;
},
clone: function () {
var attribute = new THREE.BufferAttribute( null, this.itemSize );
var types = [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array ];
var sourceArray = this.array;
for ( var i = 0, il = types.length; i < il; i ++ ) {
var type = types[ i ];
if ( sourceArray instanceof type ) {
attribute.array = new type( sourceArray );
break;
}
}
return attribute;
} }
}; };
......
...@@ -929,34 +929,10 @@ THREE.BufferGeometry.prototype = { ...@@ -929,34 +929,10 @@ THREE.BufferGeometry.prototype = {
var geometry = new THREE.BufferGeometry(); var geometry = new THREE.BufferGeometry();
var types = [ Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array ];
for ( var attr in this.attributes ) { for ( var attr in this.attributes ) {
var sourceAttr = this.attributes[ attr ]; var sourceAttr = this.attributes[ attr ];
var sourceArray = sourceAttr.array; geometry.addAttribute( attr, sourceAttr.clone() );
var attribute = {
itemSize: sourceAttr.itemSize,
array: null
};
for ( var i = 0, il = types.length; i < il; i ++ ) {
var type = types[ i ];
if ( sourceArray instanceof type ) {
attribute.array = new type( sourceArray );
break;
}
}
geometry.attributes[ attr ] = attribute;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册