example/threejs/asset/three.js
function subdivide( face, detail ) {

		var cols = Math.pow( 2, detail );
		var a = prepare( that.vertices[ face.a ] );
		var b = prepare( that.vertices[ face.b ] );
		var c = prepare( that.vertices[ face.c ] );
		var v = [];

		// Construct all of the vertices for this subdivision.

		for ( var i = 0 ; i <= cols; i ++ ) {

			v[ i ] = [];

			var aj = prepare( a.clone().lerp( c, i / cols ) );
			var bj = prepare( b.clone().lerp( c, i / cols ) );
			var rows = cols - i;

			for ( var j = 0; j <= rows; j ++ ) {

				if ( j === 0 && i === cols ) {

					v[ i ][ j ] = aj;

				} else {

					v[ i ][ j ] = prepare( aj.clone().lerp( bj, j / rows ) );

				}

			}

		}

		// Construct all of the faces.

		for ( var i = 0; i < cols ; i ++ ) {

			for ( var j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {

				var k = Math.floor( j / 2 );

				if ( j % 2 === 0 ) {

					make(
						v[ i ][ k + 1 ],
						v[ i + 1 ][ k ],
						v[ i ][ k ]
					);

				} else {

					make(
						v[ i ][ k + 1 ],
						v[ i + 1 ][ k + 1 ],
						v[ i + 1 ][ k ]
					);

				}

			}

		}

	}
function subdivide( face, detail ) {

		var cols = Math.pow( 2, detail );
		var a = prepare( that.vertices[ face.a ] );
		var b = prepare( that.vertices[ face.b ] );
		var c = prepare( that.vertices[ face.c ] );
		var v = [];

		// Construct all of the vertices for this subdivision.

		for ( var i = 0 ; i <= cols; i ++ ) {

			v[ i ] = [];

			var aj = prepare( a.clone().lerp( c, i / cols ) );
			var bj = prepare( b.clone().lerp( c, i / cols ) );
			var rows = cols - i;

			for ( var j = 0; j <= rows; j ++ ) {

				if ( j === 0 && i === cols ) {

					v[ i ][ j ] = aj;

				} else {

					v[ i ][ j ] = prepare( aj.clone().lerp( bj, j / rows ) );

				}

			}

		}

		// Construct all of the faces.

		for ( var i = 0; i < cols ; i ++ ) {

			for ( var j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {

				var k = Math.floor( j / 2 );

				if ( j % 2 === 0 ) {

					make(
						v[ i ][ k + 1 ],
						v[ i + 1 ][ k ],
						v[ i ][ k ]
					);

				} else {

					make(
						v[ i ][ k + 1 ],
						v[ i + 1 ][ k + 1 ],
						v[ i + 1 ][ k ]
					);

				}

			}

		}

	}
function subdivide ( face , detail ) { var cols = Math . pow ( 2 , detail ) ; var a = prepare ( that . vertices [ face . a ] ) ; var b = prepare ( that . vertices [ face . b ] ) ; var c = prepare ( that . vertices [ face . c ] ) ; var v = [ ] ; // Construct all of the vertices for this subdivision. for ( var i = 0 ; i <= cols ; i ++ ) { v [ i ] = [ ] ; var aj = prepare ( a . clone ( ) . lerp ( c , i / cols ) ) ; var bj = prepare ( b . clone ( ) . lerp ( c , i / cols ) ) ; var rows = cols - i ; for ( var j = 0 ; j <= rows ; j ++ ) { if ( j === 0 && i === cols ) { v [ i ] [ j ] = aj ; } else { v [ i ] [ j ] = prepare ( aj . clone ( ) . lerp ( bj , j / rows ) ) ; } } } // Construct all of the faces. for ( var i = 0 ; i < cols ; i ++ ) { for ( var j = 0 ; j < 2 * ( cols - i ) - 1 ; j ++ ) { var k = Math . floor ( j / 2 ) ; if ( j % 2 === 0 ) { make ( v [ i ] [ k + 1 ] , v [ i + 1 ] [ k ] , v [ i ] [ k ] ) ; } else { make ( v [ i ] [ k + 1 ] , v [ i + 1 ] [ k + 1 ] , v [ i + 1 ] [ k ] ) ; } } } }
Analytically subdivide a face to the required detail level.
Analytically subdivide a face to the required detail level .