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

`Geometry::computeNormals` → `Geometry::computeFaceNormals`

上级 1053ab24
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -80,7 +80,6 @@
}
plane.computeNormals();
plane.computeCentroids();
mesh = new THREE.Mesh( plane, material );
......
......@@ -87,10 +87,6 @@
}
// geometry.computeNormals();
// geometry.computeVertexNormals();
// geometry.sortFacesByMaterial();
texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );
......
......@@ -2,7 +2,7 @@ var Bird = function () {
var scope = this;
THREE.Geometry.call(this);
THREE.Geometry.call( this );
v( 5, 0, 0 );
v( - 5, - 2, 1 );
......@@ -21,7 +21,7 @@ var Bird = function () {
f3( 5, 6, 7 );
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
function v( x, y, z ) {
......
......@@ -1434,7 +1434,7 @@ var Qrcode = function () {
f4(19,20,362,361,m2);
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
function v( x, y, z ) {
......
......@@ -4884,7 +4884,7 @@ var WaltHead = function () {
f3( 1222, 991, 646 );
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
function v( x, y, z ) {
......@@ -4908,4 +4908,4 @@ var WaltHead = function () {
}
WaltHead.prototype = new THREE.Geometry();
WaltHead.prototype.constructor = WaltHead;
\ No newline at end of file
WaltHead.prototype.constructor = WaltHead;
......@@ -185,7 +185,7 @@
geometry.faces.push( face );
}
geometry.computeNormals();
geometry.computeFaceNormals();
geometry.computeCentroids();
geometry.sortFacesByMaterial();
......
......@@ -46,7 +46,7 @@ THREE.Geometry.prototype = {
},
computeNormals: function ( useVertexNormals ) {
computeFaceNormals: function ( useVertexNormals ) {
var n, nl, v, vl, vertex, f, fl, face, vA, vB, vC,
cb = new THREE.Vector3(), ab = new THREE.Vector3();
......
......@@ -244,7 +244,7 @@ THREE.Loader.prototype = {
currentOffset += init_quads_smooth_uv( currentOffset );
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
//var e = (new Date).getTime();
......@@ -706,7 +706,7 @@ THREE.Loader.prototype = {
init_faces();
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
function init_vertices() {
......
......@@ -38,21 +38,21 @@ var Cube = function ( width, height, depth, segments_width, segments_height, mat
}
this.sides = { px: true, nx: true, py: true, ny: true, pz: true, nz: true };
if( sides != undefined ) {
for( var s in sides ) {
if ( this.sides[ s ] != undefined ) {
this.sides[ s ] = sides[ s ];
}
}
}
this.sides.px && buildPlane( 'z', 'y', 1 * flip, - 1, depth, height, - width_half, this.materials[ 0 ] ); // px
this.sides.nx && buildPlane( 'z', 'y', - 1 * flip, - 1, depth, height, width_half, this.materials[ 1 ] ); // nx
this.sides.py && buildPlane( 'x', 'z', 1 * flip, 1, width, depth, height_half, this.materials[ 2 ] ); // py
......@@ -173,7 +173,7 @@ var Cube = function ( width, height, depth, segments_width, segments_height, mat
}
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
}
......
......@@ -2,82 +2,80 @@
* @author kile / http://kile.stravaganza.org/
*/
var Cylinder = function (numSegs, topRad, botRad, height, topOffset, botOffset) {
var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset ) {
THREE.Geometry.call(this);
THREE.Geometry.call( this );
var scope = this, i;
var scope = this,
pi = Math.PI, i;
// VERTICES
// Top circle vertices
for (i = 0; i < numSegs; i++) {
for ( i = 0; i < numSegs; i ++ ) {
v( Math.sin( 2 * pi * i / numSegs ) * topRad, Math.cos( 2 * pi * i / numSegs ) * topRad, 0 );
v(
Math.sin(2 * 3.1415 * i / numSegs)*topRad,
Math.cos(2 * 3.1415 * i / numSegs)*topRad,
0);
}
// Bottom circle vertices
for (i = 0; i < numSegs; i++) {
for ( i = 0; i < numSegs; i ++ ) {
v( Math.sin( 2 * pi * i / numSegs ) * botRad, Math.cos( 2 * pi * i / numSegs ) * botRad, height );
v(
Math.sin(2 * 3.1415 * i / numSegs)*botRad,
Math.cos(2 * 3.1415 * i / numSegs)*botRad,
height);
}
// FACES
// Body
for (i = 0; i < numSegs; i++) {
// Body
for ( i = 0; i < numSegs; i++ ) {
f4(i, i + numSegs, numSegs + (i + 1) % numSegs, (i + 1) % numSegs, '#ff0000');
f4( i, i + numSegs, numSegs + ( i + 1 ) % numSegs, ( i + 1 ) % numSegs, '#ff0000' );
}
// Bottom circle
if (botRad != 0) {
if ( botRad != 0 ) {
v( 0, 0, - topOffset );
v(0, 0, -topOffset);
for ( i = numSegs; i < numSegs + ( numSegs / 2 ); i++ ) {
for (i = numSegs; i < numSegs + (numSegs / 2); i++) {
f4( 2 * numSegs, ( 2 * i - 2 * numSegs ) % numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs, ( 2 * i - 2 * numSegs + 2 ) % numSegs );
f4(2 * numSegs,
(2 * i - 2 * numSegs) % numSegs,
(2 * i - 2 * numSegs + 1) % numSegs,
(2 * i - 2 * numSegs + 2) % numSegs);
}
}
// Top circle
if (topRad != 0) {
if ( topRad != 0 ) {
v( 0, 0, height + topOffset );
v(0, 0, height + topOffset);
for ( i = numSegs + ( numSegs / 2 ); i < 2 * numSegs; i ++ ) {
for (i = numSegs + (numSegs / 2); i < 2 * numSegs; i++) {
f4( ( 2 * i - 2 * numSegs + 2 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs ) % numSegs+numSegs, 2 * numSegs + 1 );
f4( (2 * i - 2 * numSegs + 2) % numSegs + numSegs,
(2 * i - 2 * numSegs + 1) % numSegs + numSegs,
(2 * i - 2 * numSegs) % numSegs+numSegs,
2 * numSegs + 1);
}
}
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
function v(x, y, z) {
function v( x, y, z ) {
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
}
function f4(a, b, c, d) {
function f4( a, b, c, d ) {
scope.faces.push( new THREE.Face4( a, b, c, d ) );
}
}
Cylinder.prototype = new THREE.Geometry();
......
......@@ -53,7 +53,7 @@ var Plane = function ( width, height, segments_width, segments_height ) {
}
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.sortFacesByMaterial();
}
......
......@@ -10,7 +10,7 @@ var Sphere = function ( radius, segments_width, segments_height ) {
var gridX = segments_width || 8,
gridY = segments_height || 6;
var i, j;
var i, j, pi = Math.PI;
var iHor = Math.max( 3, gridX );
var iVer = Math.max( 2, gridY );
var aVtc = [];
......@@ -18,16 +18,16 @@ var Sphere = function ( radius, segments_width, segments_height ) {
for ( j = 0; j < ( iVer + 1 ) ; j++ ) {
var fRad1 = j / iVer;
var fZ = radius * Math.cos( fRad1 * Math.PI );
var fRds = radius * Math.sin( fRad1 * Math.PI );
var fZ = radius * Math.cos( fRad1 * pi );
var fRds = radius * Math.sin( fRad1 * pi );
var aRow = [];
var oVtx = 0;
for ( i = 0; i < iHor; i++ ) {
var fRad2 = 2 * i / iHor;
var fX = fRds * Math.sin( fRad2 * Math.PI );
var fY = fRds * Math.cos( fRad2 * Math.PI );
var fX = fRds * Math.sin( fRad2 * pi );
var fY = fRds * Math.cos( fRad2 * pi );
if ( !( ( j == 0 || j == iVer ) && i > 0 ) ) {
......@@ -104,7 +104,8 @@ var Sphere = function ( radius, segments_width, segments_height ) {
}
this.computeCentroids();
this.computeNormals();
this.computeFaceNormals();
this.computeVertexNormals();
this.sortFacesByMaterial();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册