three.js 源码注释(九十四)extras/core/Shape.js

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

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

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


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

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

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


/**
 * @author zz85 / http://www.lab4games.net/zz85/blog
 * Defines a 2d shape plane using paths.
 **/

// STEP 1 Create a path.
// 1. 创建路径
// STEP 2 Turn path into shape.
// 2. 将路径变成截面
// STEP 3 ExtrudeGeometry takes in Shape/Shapes
// 3. 将截面拉伸成几何体
// STEP 3a - Extract points from each shape, turn to vertices
// 3a. 导出所有的截面顶点到vertices属性中
// STEP 3b - Triangulate each shape, add faces.
// 3b. 组织所有的顶点为三角面.
/*
///Shape对象将二维平面生成图形对象的抽象基类.
///
*/
///<summary>Shape</summary>
THREE.Shape = function () {

	THREE.Path.apply( this, arguments );	//调用Path对象的call方法,将原本属于Path的方法交给当前对象Shape来使用.
	this.holes = [];	//将孔洞存放到holes数组中.

};
/*************************************************
****下面是Shape对象的方法属性定义,继承自Path对象.
**************************************************/
THREE.Shape.prototype = Object.create( THREE.Path.prototype );

/*
///extrude生成拉伸几何体的便利方法.
///
/// parameters = {
///
///  curveSegments: <int>, // number of points on the curves 曲线上的顶点数量
///  steps: <int>, // number of points for z-side extrusions / used for subdividing segements of extrude spline too 步数,曲线拉伸的细分线段数
///  amount: <int>, // Depth to extrude the shape 拉伸线段的厚度.
///
///  bevelEnabled: <bool>, // turn on bevel 是否启用倒角
///  bevelThickness: <float>, // how deep into the original shape bevel goes 倒角的厚度
///  bevelSize: <float>, // how far from shape outline is bevel 从截面外轮廓倒角的尺寸.
///  bevelSegments: <int>, // number of bevel layers 倒角部分的细分线段数.
///
///  extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined) 截面拉伸的路径,3d的spline对象.
///  frames: <THREE.TubeGeometry.FrenetFrames> // containing arrays of tangents, normals, binormals 包含三角形,法线,副法线数组.
///
///  material: <int> // material index for front and back faces 正面和背面材质索引
///  extrudeMaterial: <int> // material index for extrusion and beveled faces 拉伸体和斜面的材质索引
///  uvGenerator: <Object> // object that provides UV generator functions UV坐标生成函数.
///
/// }
*/
///<summary>extrude</summary>
///<param name ="options" type="String">参数选项</param>
///<returns type="THREE.ExtrudeGeometry">拉伸几何体.</returns>
// Convenience method to return ExtrudeGeometry
// 生成拉伸几何体的便利方法.
THREE.Shape.prototype.extrude = function ( options ) {

	var extruded = new THREE.ExtrudeGeometry( this, options );
	return extruded;

};
/*
///makeGeometry创建图形几何体的便利方法
///
/// parameters = {
///
///	curveSegments: <int>, // number of points on the curves. NOT USED AT THE MOMENT. 曲线上的顶点数量
///
///	material: <int> // material index for front and back faces 正面和背面材质索引
///	uvGenerator: <Object> // object that provides UV generator functions UV坐标生成函数
///
/// }
*/
///<summary>makeGeometry</summary>
///<param name ="options" type="String">参数选项</param>
///<returns type="THREE.ShapeGeometry">拉伸几何体.</returns>
// Convenience method to return ShapeGeometry
// 创建图形几何体的便利方法.
THREE.Shape.prototype.makeGeometry = function ( options ) {

	var geometry = new THREE.ShapeGeometry( this, options );
	return geometry;

};
/*
///getPointsHoles方法根据divisions将孔洞等分,获得在孔洞对象上等分点的点序列.如果没有设置参数divisions.返回对应等分孔洞顶点的坐标数组.
///定量等分孔洞
*/
///<summary>getPointsHoles</summary>
///<param name ="divisions" type="int">根据divisions将孔洞等分,获得在孔洞对象上等分点的点序列.如果没有设置参数divisions.</param>
///<returns type="Vector3Array">返回对应等分孔洞顶点的坐标数组.</returns>
// Get points of holes
// 定量等分,获得所有孔洞的顶点
THREE.Shape.prototype.getPointsHoles = function ( divisions ) {

	var i, il = this.holes.length, holesPts = [];

	for ( i = 0; i < il; i ++ ) {

		holesPts[ i ] = this.holes[ i ].getTransformedPoints( divisions, this.bends );

	}

	return holesPts;	//返回对应等分孔洞顶点的坐标数组

};
/*
///getSpacedPointsHoles方法根据divisions将孔洞等分,获得在孔洞对象上等分点的点序列.如果没有设置参数divisions.返回对应等分孔洞顶点的坐标数组.
///定距等分孔洞
*/
///<summary>getSpacedPointsHoles</summary>
///<param name ="divisions
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值