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

Updated builds.

上级 c170af7b
......@@ -8938,6 +8938,22 @@ THREE.DynamicBufferAttribute = function ( array, itemSize ) {
THREE.DynamicBufferAttribute.prototype = Object.create( THREE.BufferAttribute.prototype );
THREE.DynamicBufferAttribute.prototype.constructor = THREE.DynamicBufferAttribute;
// File:src/core/IndexBufferAttribute.js
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.IndexBufferAttribute = function ( array, itemSize ) {
THREE.BufferAttribute.call( this, array, itemSize );
};
THREE.IndexBufferAttribute.prototype = Object.create( THREE.BufferAttribute.prototype );
THREE.IndexBufferAttribute.prototype.constructor = THREE.IndexBufferAttribute;
// File:src/core/InstancedBufferAttribute.js
/**
......@@ -10757,6 +10773,13 @@ THREE.BufferGeometry.prototype = {
}
if ( name === 'index' && attribute instanceof THREE.IndexBufferAttribute === false ) {
console.warn( 'THREE.BufferGeometry.addAttribute: Use THREE.IndexBufferAttribute for index attribute.' );
attribute = new THREE.IndexBufferAttribute( attribute.array, attribute.itemSize );
}
this.attributes[ name ] = attribute;
},
......@@ -11176,8 +11199,9 @@ THREE.BufferGeometry.prototype = {
if ( geometry.indices.length > 0 ) {
var indices = new Uint16Array( geometry.indices.length * 3 );
this.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
var TypeArray = geometry.vertices.length > 65535 ? Uint32Array : Uint16Array;
var indices = new TypeArray( geometry.indices.length * 3 );
this.addAttribute( 'index', new THREE.IndexBufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
}
......@@ -11717,57 +11741,6 @@ THREE.BufferGeometry.prototype = {
},
/*
reoderBuffers:
Reorder attributes based on a new indexBuffer and indexMap.
indexBuffer - Uint16Array of the new ordered indices.
indexMap - Int32Array where the position is the new vertex ID and the value the old vertex ID for each vertex.
vertexCount - Amount of total vertices considered in this reordering (in case you want to grow the vertex stack).
*/
reorderBuffers: function ( indexBuffer, indexMap, vertexCount ) {
/* Create a copy of all attributes for reordering. */
var sortedAttributes = {};
for ( var attr in this.attributes ) {
if ( attr === 'index' )
continue;
var sourceArray = this.attributes[ attr ].array;
sortedAttributes[ attr ] = new sourceArray.constructor( this.attributes[ attr ].itemSize * vertexCount );
}
/* Move attribute positions based on the new index map */
for ( var new_vid = 0; new_vid < vertexCount; new_vid ++ ) {
var vid = indexMap[ new_vid ];
for ( var attr in this.attributes ) {
if ( attr === 'index' )
continue;
var attrArray = this.attributes[ attr ].array;
var attrSize = this.attributes[ attr ].itemSize;
var sortedAttr = sortedAttributes[ attr ];
for ( var k = 0; k < attrSize; k ++ )
sortedAttr[ new_vid * attrSize + k ] = attrArray[ vid * attrSize + k ];
}
}
/* Carry the new sorted buffers locally */
this.attributes[ 'index' ].array = indexBuffer;
for ( var attr in this.attributes ) {
if ( attr === 'index' )
continue;
this.attributes[ attr ].array = sortedAttributes[ attr ];
this.attributes[ attr ].numItems = this.attributes[ attr ].itemSize * vertexCount;
}
},
toJSON: function () {
var data = {
......@@ -18078,7 +18051,7 @@ THREE.Sprite = ( function () {
var uvs = new Float32Array( [ 0, 0, 1, 0, 1, 1, 0, 1 ] );
var geometry = new THREE.BufferGeometry();
geometry.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ) );
geometry.addAttribute( 'index', new THREE.IndexBufferAttribute( indices, 1 ) );
geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
......@@ -23863,7 +23836,7 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
for ( var name in attributes ) {
updateAttribute( attributes[ name ], name );
updateAttribute( attributes[ name ] );
}
......@@ -23877,7 +23850,7 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
for ( var i = 0, l = array.length; i < l; i ++ ) {
updateAttribute( array[ i ], i );
updateAttribute( array[ i ] );
}
......@@ -23887,9 +23860,19 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
}
function updateAttribute( attribute, name ) {
function updateAttribute( attribute ) {
var bufferType;
if ( attribute instanceof THREE.IndexBufferAttribute ) {
bufferType = gl.ELEMENT_ARRAY_BUFFER;
} else {
bufferType = gl.ARRAY_BUFFER;
var bufferType = name === 'index' ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;
}
var data = ( attribute instanceof THREE.InterleavedBufferAttribute ) ? attribute.data : attribute;
......@@ -23969,9 +23952,11 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
function getWireframeAttribute( geometry ) {
if ( geometry._wireframe !== undefined ) {
var property = properties.get( geometry );
return geometry._wireframe;
if ( property.wireframe !== undefined ) {
return property.wireframe;
}
......@@ -24020,11 +24005,11 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
console.timeEnd( 'wireframe' );
var TypeArray = position.count > 65535 ? Uint32Array : Uint16Array;
var attribute = new THREE.BufferAttribute( new TypeArray( indices ), 1 );
var attribute = new THREE.IndexBufferAttribute( new TypeArray( indices ), 1 );
updateAttribute( attribute, 'index' );
updateAttribute( attribute );
geometry._wireframe = attribute;
property.wireframe = attribute;
return attribute;
......@@ -24046,7 +24031,6 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
this.getWireframeAttribute = getWireframeAttribute;
this.update = update;
this.updateAttribute = updateAttribute;
this.clear = function () {
......@@ -31333,7 +31317,7 @@ THREE.CircleBufferGeometry = function ( radius, segments, thetaStart, thetaLengt
}
this.addAttribute( 'index', new THREE.BufferAttribute( new Uint16Array( indices ), 1 ) );
this.addAttribute( 'index', new THREE.IndexBufferAttribute( new Uint16Array( indices ), 1 ) );
this.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
......@@ -31494,7 +31478,7 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme
var uv2 = uvs[ 0 ][ x + 1 ].clone();
var uv3 = new THREE.Vector2( uv2.x, 0 );
this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) );
this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ], undefined, 1 ) );
this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] );
}
......@@ -31521,7 +31505,7 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme
var uv2 = uvs[ heightSegments ][ x ].clone();
var uv3 = new THREE.Vector2( uv2.x, 1 );
this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) );
this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ], undefined, 2 ) );
this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] );
}
......@@ -32730,7 +32714,7 @@ THREE.PlaneBufferGeometry = function ( width, height, widthSegments, heightSegme
}
this.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ) );
this.addAttribute( 'index', new THREE.IndexBufferAttribute( indices, 1 ) );
this.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
......@@ -33091,7 +33075,7 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
}
this.addAttribute( 'index', new THREE.BufferAttribute( new Uint16Array( indices ), 1 ) );
this.addAttribute( 'index', new THREE.IndexBufferAttribute( new Uint16Array( indices ), 1 ) );
this.addAttribute( 'position', positions );
this.addAttribute( 'normal', normals );
this.addAttribute( 'uv', uvs );
......@@ -33765,7 +33749,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
var v2 = p[ indices[ i + 1 ] ];
var v3 = p[ indices[ i + 2 ] ];
faces[ j ] = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
faces[ j ] = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ], undefined, j );
}
......@@ -33842,9 +33826,9 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
// Approximate a curved face with recursively sub-divided triangles.
function make( v1, v2, v3 ) {
function make( v1, v2, v3, materialIndex ) {
var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ], undefined, materialIndex );
that.faces.push( face );
centroid.copy( v1 ).add( v2 ).add( v3 ).divideScalar( 3 );
......@@ -33870,6 +33854,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
var c = prepare( that.vertices[ face.c ] );
var v = [];
var materialIndex = face.materialIndex;
// Construct all of the vertices for this subdivision.
for ( var i = 0 ; i <= cols; i ++ ) {
......@@ -33909,7 +33895,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
make(
v[ i ][ k + 1 ],
v[ i + 1 ][ k ],
v[ i ][ k ]
v[ i ][ k ],
materialIndex
);
} else {
......@@ -33917,7 +33904,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
make(
v[ i ][ k + 1 ],
v[ i + 1 ][ k + 1 ],
v[ i + 1 ][ k ]
v[ i + 1 ][ k ],
materialIndex
);
}
......
此差异已折叠。
......@@ -12,4 +12,4 @@ THREE.DynamicBufferAttribute = function ( array, itemSize ) {
};
THREE.DynamicBufferAttribute.prototype = Object.create( THREE.BufferAttribute.prototype );
THREE.DynamicBufferAttribute.prototype.constructor = THREE.DynamicBufferAttribute;
\ No newline at end of file
THREE.DynamicBufferAttribute.prototype.constructor = THREE.DynamicBufferAttribute;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册