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

Updated builds.

上级 25e42863
......@@ -9580,13 +9580,19 @@ THREE.BufferGeometry.prototype = {
var j, jl;
var iA, iB, iC;
var offsets = this.offsets;
if ( this.drawcalls.length === 0 ) {
this.addDrawCall( 0, indices.length, 0 );
}
var drawcalls = this.drawcalls;
for ( j = 0, jl = offsets.length; j < jl; ++ j ) {
for ( j = 0, jl = drawcalls.length; j < jl; ++ j ) {
var start = offsets[ j ].start;
var count = offsets[ j ].count;
var index = offsets[ j ].index;
var start = drawcalls[ j ].start;
var count = drawcalls[ j ].count;
var index = drawcalls[ j ].index;
for ( i = start, il = start + count; i < il; i += 3 ) {
......@@ -9632,11 +9638,11 @@ THREE.BufferGeometry.prototype = {
}
for ( j = 0, jl = offsets.length; j < jl; ++ j ) {
for ( j = 0, jl = drawcalls.length; j < jl; ++ j ) {
var start = offsets[ j ].start;
var count = offsets[ j ].count;
var index = offsets[ j ].index;
var start = drawcalls[ j ].start;
var count = drawcalls[ j ].count;
var index = drawcalls[ j ].index;
for ( i = start, il = start + count; i < il; i += 3 ) {
......@@ -10103,7 +10109,7 @@ THREE.Geometry.prototype = {
var addFace = function ( a, b, c ) {
var vertexNormals = normals !== undefined ? [ tempNormals[ a ], tempNormals[ b ], tempNormals[ c ] ] : [];
var vertexNormals = normals !== undefined ? [ tempNormals[ a ].clone(), tempNormals[ b ].clone(), tempNormals[ c ].clone() ] : [];
var vertexColors = colors !== undefined ? [ scope.colors[ a ], scope.colors[ b ], scope.colors[ c ] ] : [];
scope.faces.push( new THREE.Face3( a, b, c, vertexNormals, vertexColors ) );
......@@ -31718,7 +31724,33 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
THREE.Geometry.call( this );
this.type = 'PlaneGeometry';
this.parameters = {
width: width,
height: height,
widthSegments: widthSegments,
heightSegments: heightSegments
};
this.fromBufferGeometry( new THREE.PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
};
THREE.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype );
// File:src/extras/geometries/PlaneBufferGeometry.js
/**
* @author mrdoob / http://mrdoob.com/
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
*/
THREE.PlaneBufferGeometry = function ( width, height, widthSegments, heightSegments ) {
THREE.BufferGeometry.call( this );
this.type = 'PlaneBufferGeometry';
this.parameters = {
width: width,
height: height,
......@@ -31726,70 +31758,83 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
heightSegments: heightSegments
};
var ix, iz;
var width_half = width / 2;
var height_half = height / 2;
var gridX = widthSegments || 1;
var gridZ = heightSegments || 1;
var gridY = heightSegments || 1;
var gridX1 = gridX + 1;
var gridZ1 = gridZ + 1;
var gridY1 = gridY + 1;
var segment_width = width / gridX;
var segment_height = height / gridZ;
var segment_height = height / gridY;
var vertices = new Float32Array( gridX1 * gridY1 * 3 );
var normals = new Float32Array( gridX1 * gridY1 * 3 );
var uvs = new Float32Array( gridX1 * gridY1 * 2 );
var normal = new THREE.Vector3( 0, 0, 1 );
var offset = 0;
var offset2 = 0;
for ( iz = 0; iz < gridZ1; iz ++ ) {
for ( var iy = 0; iy < gridY1; iy ++ ) {
var y = iz * segment_height - height_half;
var y = iy * segment_height - height_half;
for ( ix = 0; ix < gridX1; ix ++ ) {
for ( var ix = 0; ix < gridX1; ix ++ ) {
var x = ix * segment_width - width_half;
this.vertices.push( new THREE.Vector3( x, - y, 0 ) );
vertices[ offset ] = x;
vertices[ offset + 1 ] = - y;
normals[ offset + 2 ] = 1;
uvs[ offset2 ] = ix / gridX;
uvs[ offset2 + 1 ] = 1 - ( iy / gridY );
offset += 3;
offset2 += 2;
}
}
for ( iz = 0; iz < gridZ; iz ++ ) {
offset = 0;
for ( ix = 0; ix < gridX; ix ++ ) {
var indices = new ( ( vertices.length / 3 ) > 65535 ? Uint32Array : Uint16Array )( gridX * gridY * 6 );
var a = ix + gridX1 * iz;
var b = ix + gridX1 * ( iz + 1 );
var c = ( ix + 1 ) + gridX1 * ( iz + 1 );
var d = ( ix + 1 ) + gridX1 * iz;
for ( var iy = 0; iy < gridY; iy ++ ) {
var uva = new THREE.Vector2( ix / gridX, 1 - iz / gridZ );
var uvb = new THREE.Vector2( ix / gridX, 1 - ( iz + 1 ) / gridZ );
var uvc = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - ( iz + 1 ) / gridZ );
var uvd = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - iz / gridZ );
for ( var ix = 0; ix < gridX; ix ++ ) {
var face = new THREE.Face3( a, b, d );
face.normal.copy( normal );
face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
var a = ix + gridX1 * iy;
var b = ix + gridX1 * ( iy + 1 );
var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
var d = ( ix + 1 ) + gridX1 * iy;
this.faces.push( face );
this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
indices[ offset ] = a;
indices[ offset + 1 ] = b;
indices[ offset + 2 ] = d;
face = new THREE.Face3( b, c, d );
face.normal.copy( normal );
face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
indices[ offset + 3 ] = b;
indices[ offset + 4 ] = c;
indices[ offset + 5 ] = d;
this.faces.push( face );
this.faceVertexUvs[ 0 ].push( [ uvb.clone(), uvc, uvd.clone() ] );
offset += 6;
}
}
this.addAttribute( 'index', new THREE.BufferAttribute( 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 ) );
};
THREE.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype );
THREE.PlaneBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
// File:src/extras/geometries/RingGeometry.js
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册