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

BufferGeometry/Loader: Handle index.

上级 63f58304
......@@ -1084,10 +1084,20 @@ THREE.BufferGeometry.prototype = {
data.data = { attributes: {} };
var attributes = this.attributes;
var groups = this.groups;
var index = this.index;
var boundingSphere = this.boundingSphere;
if ( index !== null ) {
var array = Array.prototype.slice.call( index.array );
data.data.index = {
type: index.array.constructor.name,
array: array
};
}
var attributes = this.attributes;
for ( var key in attributes ) {
......@@ -1103,12 +1113,16 @@ THREE.BufferGeometry.prototype = {
}
var groups = this.groups;
if ( groups.length > 0 ) {
data.data.groups = JSON.parse( JSON.stringify( groups ) );
}
var boundingSphere = this.boundingSphere;
if ( boundingSphere !== null ) {
data.data.boundingSphere = {
......
......@@ -36,6 +36,15 @@ THREE.BufferGeometryLoader.prototype = {
var geometry = new THREE.BufferGeometry();
var index = json.data.index;
if ( index !== undefined ) {
var typedArray = new self[ index.type ]( index.array );
geometry.addIndex( new THREE.BufferAttribute( typedArray, 1 ) );
}
var attributes = json.data.attributes;
for ( var key in attributes ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册