码迷,mamicode.com
首页 > Web开发 > 详细

three.js 源码注释(七十八)extras/geometries/IcosahedronGeometry.js

时间:2015-01-31 12:51:22      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:webgl   three.js   三维   数据可视化   web3d   

商域无疆 (http://blog.csdn.net/omni360/)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:商域无疆 -  本博客专注于 敏捷开发及移动和物联设备研究:数据可视化、GOLANG、Html5、WEBGL、THREE.JS否则,出自本博客的文章拒绝转载或再转载,谢谢合作。


俺也是刚开始学,好多地儿肯定不对还请见谅.

以下代码是THREE.JS 源码文件中extras/geometries/IcosahedronGeometry.js文件的注释.

更多更新在 : https://github.com/omni360/three.js.sourcecode


/**
 * @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 );


商域无疆 (http://blog.csdn.net/omni360/)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:商域无疆 -  本博客专注于 敏捷开发及移动和物联设备研究:数据可视化、GOLANG、Html5、WEBGL、THREE.JS否则,出自本博客的文章拒绝转载或再转载,谢谢合作。


以下代码是THREE.JS 源码文件中extras/geometries/IcosahedronGeometry.js文件的注释.

更多更新在 : https://github.com/omni360/three.js.sourcecode

three.js 源码注释(七十八)extras/geometries/IcosahedronGeometry.js

标签:webgl   three.js   三维   数据可视化   web3d   

原文地址:http://blog.csdn.net/omni360/article/details/43328601

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!