|
@@ -65,6 +65,8 @@ THREE.BufferGeometry.prototype = {
|
|
|
|
|
|
this.attributes[ name ] = attribute;
|
|
|
|
|
|
+ return this;
|
|
|
+
|
|
|
},
|
|
|
|
|
|
getAttribute: function ( name ) {
|
|
@@ -77,6 +79,8 @@ THREE.BufferGeometry.prototype = {
|
|
|
|
|
|
delete this.attributes[ name ];
|
|
|
|
|
|
+ return this;
|
|
|
+
|
|
|
},
|
|
|
|
|
|
addGroup: function ( start, count, materialIndex ) {
|
|
@@ -820,6 +824,52 @@ THREE.BufferGeometry.prototype = {
|
|
|
|
|
|
},
|
|
|
|
|
|
+ toNonIndexed: function () {
|
|
|
+
|
|
|
+ if ( this.index === null ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' );
|
|
|
+ return this;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var geometry2 = new THREE.BufferGeometry();
|
|
|
+
|
|
|
+ var indices = this.index.array;
|
|
|
+ var attributes = this.attributes;
|
|
|
+
|
|
|
+ for ( var name in attributes ) {
|
|
|
+
|
|
|
+ var attribute = attributes[ name ];
|
|
|
+
|
|
|
+ var array = attribute.array;
|
|
|
+ var itemSize = attribute.itemSize;
|
|
|
+
|
|
|
+ var array2 = new array.constructor( indices.length * itemSize );
|
|
|
+
|
|
|
+ var index = 0;
|
|
|
+ var index2 = 0;
|
|
|
+
|
|
|
+ for ( var i = 0; i < indices.length; i ++ ) {
|
|
|
+
|
|
|
+ index = indices[ i ] * itemSize;
|
|
|
+
|
|
|
+ for ( var j = 0; j < itemSize; j ++ ) {
|
|
|
+
|
|
|
+ array2[ index2 ++ ] = array[ index ++ ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ geometry2.addAttribute( name, new THREE.BufferAttribute( array2, itemSize ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return geometry2;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
toJSON: function () {
|
|
|
|
|
|
var data = {
|