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

Updated builds.

上级 4312d652
...@@ -15363,6 +15363,7 @@ ...@@ -15363,6 +15363,7 @@
}; };
this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) ); this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
this.mergeVertices();
} }
...@@ -20099,7 +20100,8 @@ ...@@ -20099,7 +20100,8 @@
this.forceContextLoss = function () { this.forceContextLoss = function () {
extensions.get( 'WEBGL_lose_context' ).loseContext(); var extension = extensions.get( 'WEBGL_lose_context' );
if ( extension ) extension.loseContext();
}; };
...@@ -24274,11 +24276,15 @@ ...@@ -24274,11 +24276,15 @@
var indices = []; var indices = [];
var vertices = []; var vertices = [];
var normals = [];
var uvs = []; var uvs = [];
var EPS = 0.00001;
var pu = new Vector3(), pv = new Vector3(), normal = new Vector3();
var i, j; var i, j;
// generate vertices and uvs // generate vertices, normals and uvs
var sliceCount = slices + 1; var sliceCount = slices + 1;
...@@ -24293,6 +24299,33 @@ ...@@ -24293,6 +24299,33 @@
var p = func( u, v ); var p = func( u, v );
vertices.push( p.x, p.y, p.z ); vertices.push( p.x, p.y, p.z );
// approximate tangent vectors via finite differences
if ( u - EPS >= 0 ) {
pu.subVectors( p, func( u - EPS, v ) );
} else {
pu.subVectors( func( u + EPS, v ), p );
}
if ( v - EPS >= 0 ) {
pv.subVectors( p, func( u, v - EPS ) );
} else {
pv.subVectors( func( u, v + EPS ), p );
}
// cross product of tangent vectors returns surface normal
normal.crossVectors( pu, pv ).normalize();
normals.push( normal.x, normal.y, normal.z );
uvs.push( u, v ); uvs.push( u, v );
} }
...@@ -24323,12 +24356,9 @@ ...@@ -24323,12 +24356,9 @@
this.setIndex( indices ); this.setIndex( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
// generate normals
this.computeVertexNormals();
} }
ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
...@@ -25182,7 +25212,6 @@ ...@@ -25182,7 +25212,6 @@
var vertex = new Vector3(); var vertex = new Vector3();
var normal = new Vector3(); var normal = new Vector3();
var uv = new Vector2();
var P1 = new Vector3(); var P1 = new Vector3();
var P2 = new Vector3(); var P2 = new Vector3();
...@@ -25320,6 +25349,7 @@ ...@@ -25320,6 +25349,7 @@
}; };
this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) ); this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
this.mergeVertices();
} }
...@@ -27028,6 +27058,7 @@ ...@@ -27028,6 +27058,7 @@
}; };
this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) ); this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
this.mergeVertices();
} }
...@@ -27170,6 +27201,7 @@ ...@@ -27170,6 +27201,7 @@
}; };
this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) ); this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
this.mergeVertices();
} }
...@@ -27823,7 +27855,6 @@ ...@@ -27823,7 +27855,6 @@
// helper variables // helper variables
var index = 0; var index = 0;
var indexOffset = 0;
var indexArray = []; var indexArray = [];
var halfHeight = height / 2; var halfHeight = height / 2;
var groupStart = 0; var groupStart = 0;
...@@ -28126,6 +28157,7 @@ ...@@ -28126,6 +28157,7 @@
}; };
this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) ); this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
this.mergeVertices();
} }
......
此差异已折叠。
...@@ -15357,6 +15357,7 @@ function PlaneGeometry( width, height, widthSegments, heightSegments ) { ...@@ -15357,6 +15357,7 @@ function PlaneGeometry( width, height, widthSegments, heightSegments ) {
}; };
this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) ); this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
this.mergeVertices();
} }
...@@ -20093,7 +20094,8 @@ function WebGLRenderer( parameters ) { ...@@ -20093,7 +20094,8 @@ function WebGLRenderer( parameters ) {
this.forceContextLoss = function () { this.forceContextLoss = function () {
extensions.get( 'WEBGL_lose_context' ).loseContext(); var extension = extensions.get( 'WEBGL_lose_context' );
if ( extension ) extension.loseContext();
}; };
...@@ -24268,11 +24270,15 @@ function ParametricBufferGeometry( func, slices, stacks ) { ...@@ -24268,11 +24270,15 @@ function ParametricBufferGeometry( func, slices, stacks ) {
var indices = []; var indices = [];
var vertices = []; var vertices = [];
var normals = [];
var uvs = []; var uvs = [];
var EPS = 0.00001;
var pu = new Vector3(), pv = new Vector3(), normal = new Vector3();
var i, j; var i, j;
// generate vertices and uvs // generate vertices, normals and uvs
var sliceCount = slices + 1; var sliceCount = slices + 1;
...@@ -24287,6 +24293,33 @@ function ParametricBufferGeometry( func, slices, stacks ) { ...@@ -24287,6 +24293,33 @@ function ParametricBufferGeometry( func, slices, stacks ) {
var p = func( u, v ); var p = func( u, v );
vertices.push( p.x, p.y, p.z ); vertices.push( p.x, p.y, p.z );
// approximate tangent vectors via finite differences
if ( u - EPS >= 0 ) {
pu.subVectors( p, func( u - EPS, v ) );
} else {
pu.subVectors( func( u + EPS, v ), p );
}
if ( v - EPS >= 0 ) {
pv.subVectors( p, func( u, v - EPS ) );
} else {
pv.subVectors( func( u, v + EPS ), p );
}
// cross product of tangent vectors returns surface normal
normal.crossVectors( pu, pv ).normalize();
normals.push( normal.x, normal.y, normal.z );
uvs.push( u, v ); uvs.push( u, v );
} }
...@@ -24317,12 +24350,9 @@ function ParametricBufferGeometry( func, slices, stacks ) { ...@@ -24317,12 +24350,9 @@ function ParametricBufferGeometry( func, slices, stacks ) {
this.setIndex( indices ); this.setIndex( indices );
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
// generate normals
this.computeVertexNormals();
} }
ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
...@@ -25176,7 +25206,6 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, ...@@ -25176,7 +25206,6 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
var vertex = new Vector3(); var vertex = new Vector3();
var normal = new Vector3(); var normal = new Vector3();
var uv = new Vector2();
var P1 = new Vector3(); var P1 = new Vector3();
var P2 = new Vector3(); var P2 = new Vector3();
...@@ -25314,6 +25343,7 @@ function TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) { ...@@ -25314,6 +25343,7 @@ function TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {
}; };
this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) ); this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
this.mergeVertices();
} }
...@@ -27022,6 +27052,7 @@ function SphereGeometry( radius, widthSegments, heightSegments, phiStart, phiLen ...@@ -27022,6 +27052,7 @@ function SphereGeometry( radius, widthSegments, heightSegments, phiStart, phiLen
}; };
this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) ); this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
this.mergeVertices();
} }
...@@ -27164,6 +27195,7 @@ function RingGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, the ...@@ -27164,6 +27195,7 @@ function RingGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, the
}; };
this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) ); this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
this.mergeVertices();
} }
...@@ -27817,7 +27849,6 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments ...@@ -27817,7 +27849,6 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
// helper variables // helper variables
var index = 0; var index = 0;
var indexOffset = 0;
var indexArray = []; var indexArray = [];
var halfHeight = height / 2; var halfHeight = height / 2;
var groupStart = 0; var groupStart = 0;
...@@ -28120,6 +28151,7 @@ function CircleGeometry( radius, segments, thetaStart, thetaLength ) { ...@@ -28120,6 +28151,7 @@ function CircleGeometry( radius, segments, thetaStart, thetaLength ) {
}; };
this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) ); this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
this.mergeVertices();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册