1. 程式人生 > >three.js 原始碼註釋(七十八)extras/geometries/IcosahedronGeometry.js

three.js 原始碼註釋(七十八)extras/geometries/IcosahedronGeometry.js


俺也是剛開始學,好多地兒肯定不對還請見諒.

以下程式碼是THREE.JS 原始碼檔案中extras/geometries/IcosahedronGeometry.js檔案的註釋.


/**
 * @author timothypratley / https://github.com/timothypratley
 */
/*
///IcosahedronGeometry用來在三維空間內建立一個二十面體物件.
///
///	用法: var geometry = new THREE.IcosahedronGeometry(70);	
/// 	  var material = new THREE.MeshBasicMaterial({color: 0x00ff00});
/// 	  var icos = new THREE.Mesh(geometry,material);
/// 	  scene.add(icos);
*/
///<summary>IcosahedronGeometry</summary>
///<param name ="radius" type="float">二十面體半徑</param>
///<param name ="detail" type="int">細節因子,預設為0,當超過0將會有更多的頂點,當前的幾何體就不會是二十面體,當引數detail大於1,將會變成一個球體.</param>
THREE.IcosahedronGeometry = function ( radius, detail ) {

	this.parameters = {
		radius: radius,	//二十面體半徑
		detail: detail	//細節因子,預設為0,當超過0將會有更多的頂點,當前的幾何體就不會是二十面體,當引數detail大於1,將會變成一個球體
	};

	var t = ( 1 + Math.sqrt( 5 ) ) / 2;

	var vertices = [
		- 1,  t,  0,    1,  t,  0,   - 1, - t,  0,    1, - t,  0,
		 0, - 1,  t,    0,  1,  t,    0, - 1, - t,    0,  1, - t,
		 t,  0, - 1,    t,  0,  1,   - t,  0, - 1,   - t,  0,  1
	]; //頂點陣列

	var indices = [
		 0, 11,  5,    0,  5,  1,    0,  1,  7,    0,  7, 10,    0, 10, 11,
		 1,  5,  9,    5, 11,  4,   11, 10,  2,   10,  7,  6,    7,  1,  8,
		 3,  9,  4,    3,  4,  2,    3,  2,  6,    3,  6,  8,    3,  8,  9,
		 4,  9,  5,    2,  4, 11,    6,  2, 10,    8,  6,  7,    9,  8,  1
	];	//指數.

	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );	//呼叫PolyhedronGeometry物件的call方法,將原本屬於Geometry的方法交給當前物件IcosahedronGeometry來使用.

};
/*************************************************
****下面是IcosahedronGeometry物件的方法屬性定義,繼承自Geometry物件.
**************************************************/
THREE.IcosahedronGeometry.prototype = Object.create( THREE.Geometry.prototype );



以下程式碼是THREE.JS 原始碼檔案中extras/geometries/IcosahedronGeometry.js檔案的註釋.