Skip to content

Commit 81304af

Browse files
committed
Updated builds.
1 parent f405240 commit 81304af

File tree

2 files changed

+177
-95
lines changed

2 files changed

+177
-95
lines changed

build/three.js

Lines changed: 135 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30212,10 +30212,6 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
3021230212

3021330213
}
3021430214

30215-
// We must call _renderer.resetGLState() at the end of each iteration of
30216-
// the light loop in order to force material updates for each light.
30217-
_renderer.resetGLState();
30218-
3021930215
}
3022030216

3022130217
// Restore GL state.
@@ -30231,8 +30227,6 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
3023130227

3023230228
}
3023330229

30234-
_renderer.resetGLState();
30235-
3023630230
scope.needsUpdate = false;
3023730231

3023830232
};
@@ -37147,26 +37141,24 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
3714737141

3714837142
};
3714937143

37150-
// File:src/extras/geometries/LatheGeometry.js
37144+
// File:src/extras/geometries/LatheBufferGeometry.js
3715137145

3715237146
/**
37153-
* @author astrodud / http://astrodud.isgreat.org/
37154-
* @author zz85 / https://github.com/zz85
37155-
* @author bhouston / http://clara.io
37147+
* @author Mugen87 / https://github.com/Mugen87
3715637148
*/
3715737149

37158-
// points - to create a closed torus, one must use a set of points
37159-
// like so: [ a, b, c, d, a ], see first is the same as last.
37160-
// segments - the number of circumference segments to create
37161-
// phiStart - the starting radian
37162-
// phiLength - the radian (0 to 2*PI) range of the lathed section
37163-
// 2*pi is a closed lathe, less than 2PI is a portion.
37150+
// points - to create a closed torus, one must use a set of points
37151+
// like so: [ a, b, c, d, a ], see first is the same as last.
37152+
// segments - the number of circumference segments to create
37153+
// phiStart - the starting radian
37154+
// phiLength - the radian (0 to 2PI) range of the lathed section
37155+
// 2PI is a closed lathe, less than 2PI is a portion.
3716437156

37165-
THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
37157+
THREE.LatheBufferGeometry = function ( points, segments, phiStart, phiLength ) {
3716637158

37167-
THREE.Geometry.call( this );
37159+
THREE.BufferGeometry.call( this );
3716837160

37169-
this.type = 'LatheGeometry';
37161+
this.type = 'LatheBufferGeometry';
3717037162

3717137163
this.parameters = {
3717237164
points: points,
@@ -37175,81 +37167,169 @@ THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
3717537167
phiLength: phiLength
3717637168
};
3717737169

37178-
segments = segments || 12;
37170+
segments = Math.floor( segments ) || 12;
3717937171
phiStart = phiStart || 0;
37180-
phiLength = phiLength || 2 * Math.PI;
37172+
phiLength = phiLength || Math.PI * 2;
37173+
37174+
// clamp phiLength so it's in range of [ 0, 2PI ]
37175+
phiLength = THREE.Math.clamp( phiLength, 0, Math.PI * 2 );
37176+
37177+
// these are used to calculate buffer length
37178+
var vertexCount = ( segments + 1 ) * points.length;
37179+
var indexCount = segments * points.length * 2 * 3;
3718137180

37181+
// buffers
37182+
var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
37183+
var vertices = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
37184+
var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
37185+
37186+
// helper variables
37187+
var index = 0, indexOffset = 0, base;
3718237188
var inversePointLength = 1.0 / ( points.length - 1 );
3718337189
var inverseSegments = 1.0 / segments;
37190+
var vertex = new THREE.Vector3();
37191+
var uv = new THREE.Vector2();
37192+
var i, j;
37193+
37194+
// generate vertices and uvs
3718437195

37185-
for ( var i = 0, il = segments; i <= il; i ++ ) {
37196+
for ( i = 0; i <= segments; i ++ ) {
3718637197

3718737198
var phi = phiStart + i * inverseSegments * phiLength;
3718837199

3718937200
var sin = Math.sin( phi );
3719037201
var cos = Math.cos( phi );
3719137202

37192-
for ( var j = 0, jl = points.length; j < jl; j ++ ) {
37203+
for ( j = 0; j <= ( points.length - 1 ); j ++ ) {
3719337204

37194-
var point = points[ j ];
37195-
37196-
var vertex = new THREE.Vector3();
37205+
// vertex
37206+
vertex.x = points[ j ].x * sin;
37207+
vertex.y = points[ j ].y;
37208+
vertex.z = points[ j ].x * cos;
37209+
vertices.setXYZ( index, vertex.x, vertex.y, vertex.z );
3719737210

37198-
vertex.x = point.x * sin;
37199-
vertex.y = point.y;
37200-
vertex.z = point.x * cos;
37211+
// uv
37212+
uv.x = i / segments;
37213+
uv.y = j / ( points.length - 1 );
37214+
uvs.setXY( index, uv.x, uv.y );
3720137215

37202-
this.vertices.push( vertex );
37216+
// increase index
37217+
index ++;
3720337218

3720437219
}
3720537220

3720637221
}
3720737222

37208-
var np = points.length;
37223+
// generate indices
37224+
37225+
for ( i = 0; i < segments; i ++ ) {
3720937226

37210-
for ( var i = 0, il = segments; i < il; i ++ ) {
37227+
for ( j = 0; j < ( points.length - 1 ); j ++ ) {
3721137228

37212-
for ( var j = 0, jl = points.length - 1; j < jl; j ++ ) {
37229+
base = j + i * points.length;
3721337230

37214-
var base = j + np * i;
37231+
// indices
3721537232
var a = base;
37216-
var b = base + np;
37217-
var c = base + 1 + np;
37233+
var b = base + points.length;
37234+
var c = base + points.length + 1;
3721837235
var d = base + 1;
3721937236

37220-
var u0 = i * inverseSegments;
37221-
var v0 = j * inversePointLength;
37222-
var u1 = u0 + inverseSegments;
37223-
var v1 = v0 + inversePointLength;
37237+
// face one
37238+
indices.setX( indexOffset, a ); indexOffset++;
37239+
indices.setX( indexOffset, b ); indexOffset++;
37240+
indices.setX( indexOffset, d ); indexOffset++;
3722437241

37225-
this.faces.push( new THREE.Face3( a, b, d ) );
37242+
// face two
37243+
indices.setX( indexOffset, b ); indexOffset++;
37244+
indices.setX( indexOffset, c ); indexOffset++;
37245+
indices.setX( indexOffset, d ); indexOffset++;
3722637246

37227-
this.faceVertexUvs[ 0 ].push( [
37247+
}
3722837248

37229-
new THREE.Vector2( u0, v0 ),
37230-
new THREE.Vector2( u1, v0 ),
37231-
new THREE.Vector2( u0, v1 )
37249+
}
3723237250

37233-
] );
37251+
// build geometry
3723437252

37235-
this.faces.push( new THREE.Face3( b, c, d ) );
37253+
this.setIndex( indices );
37254+
this.addAttribute( 'position', vertices );
37255+
this.addAttribute( 'uv', uvs );
3723637256

37237-
this.faceVertexUvs[ 0 ].push( [
37257+
// generate normals
3723837258

37239-
new THREE.Vector2( u1, v0 ),
37240-
new THREE.Vector2( u1, v1 ),
37241-
new THREE.Vector2( u0, v1 )
37259+
this.computeVertexNormals();
3724237260

37243-
] );
37261+
// if the geometry is closed, we need to average the normals along the seam.
37262+
// because the corresponding vertices are identical (but still have different UVs).
3724437263

37264+
if( phiLength === Math.PI * 2 ) {
3724537265

37246-
}
37266+
var normals = this.attributes.normal.array;
37267+
var n1 = new THREE.Vector3();
37268+
var n2 = new THREE.Vector3();
37269+
var n = new THREE.Vector3();
37270+
37271+
// this is the buffer offset for the last line of vertices
37272+
base = segments * points.length * 3;
37273+
37274+
for( i = 0, j = 0; i < points.length; i ++, j += 3 ) {
37275+
37276+
// select the normal of the vertex in the first line
37277+
n1.x = normals[ j + 0 ];
37278+
n1.y = normals[ j + 1 ];
37279+
n1.z = normals[ j + 2 ];
37280+
37281+
// select the normal of the vertex in the last line
37282+
n2.x = normals[ base + j + 0 ];
37283+
n2.y = normals[ base + j + 1 ];
37284+
n2.z = normals[ base + j + 2 ];
37285+
37286+
// average normals
37287+
n.addVectors( n1, n2 ).normalize();
37288+
37289+
// assign the new values to both normals
37290+
normals[ j + 0 ] = normals[ base + j + 0 ] = n.x;
37291+
normals[ j + 1 ] = normals[ base + j + 1 ] = n.y;
37292+
normals[ j + 2 ] = normals[ base + j + 2 ] = n.z;
37293+
37294+
} // next row
3724737295

3724837296
}
3724937297

37298+
};
37299+
37300+
THREE.LatheBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
37301+
THREE.LatheBufferGeometry.prototype.constructor = THREE.LatheBufferGeometry;
37302+
37303+
// File:src/extras/geometries/LatheGeometry.js
37304+
37305+
/**
37306+
* @author astrodud / http://astrodud.isgreat.org/
37307+
* @author zz85 / https://github.com/zz85
37308+
* @author bhouston / http://clara.io
37309+
*/
37310+
37311+
// points - to create a closed torus, one must use a set of points
37312+
// like so: [ a, b, c, d, a ], see first is the same as last.
37313+
// segments - the number of circumference segments to create
37314+
// phiStart - the starting radian
37315+
// phiLength - the radian (0 to 2PI) range of the lathed section
37316+
// 2PI is a closed lathe, less than 2PI is a portion.
37317+
37318+
THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
37319+
37320+
THREE.Geometry.call( this );
37321+
37322+
this.type = 'LatheGeometry';
37323+
37324+
this.parameters = {
37325+
points: points,
37326+
segments: segments,
37327+
phiStart: phiStart,
37328+
phiLength: phiLength
37329+
};
37330+
37331+
this.fromBufferGeometry( new THREE.LatheBufferGeometry( points, segments, phiStart, phiLength ) );
3725037332
this.mergeVertices();
37251-
this.computeFaceNormals();
37252-
this.computeVertexNormals();
3725337333

3725437334
};
3725537335

0 commit comments

Comments
 (0)