three.js 附件 / 核心Shape、Path
·
1,形状(Shape):
使用路径以及可选的孔洞来定义一个二维形状平面;它可以和 ExtrudeGeometry、ShapeGeometry 一起使用,获得点或者获取三角面,ExtrudeGeometry、ShapeGeometry后面讲解;
构造函数
Shape( points : Array )
points — (optional) 一个Vector2数组。
属性
.uuid : String
该类所创建的实例的UUID。它是自动被指定的,因此它不应当被编辑、更改。
.holes : Array
一个paths数组,定义了形状上的孔洞。
2,路径(Path)
该类定义了二维路径,提供了一些类似2D Canvas API 的方法来创建或者构造二维路径;
Path( points : Array )
points — (可选)Vector2s数组。
从传入的点中创建一条Path。第一个点定义了偏移量,接下来的点作为LineCurves被添加到curves数组中。倘若没有点被指定,一条空路径将会被创建,.currentPoint将被设置为原点。
常用方法有:
// 圆弧中心绝对定位的圆弧
.absarc(x, y, radius,startAngle, endAngle, clokwise);
---- x, y 绝对圆弧中心的坐标
---- radius 弧线半径
---- startAngle 起始角度
---- endAngle 终止角度
---- clockwise :boolean 顺时针创建弧线,默认false
.absellipse ( x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) : this
x, y — 椭圆的绝对中心。
xRadius — 椭圆x轴方向的半径。
yRadius — 椭圆y轴方向的半径。
startAngle — 起始角,以弧度来表示。
endAngle — 终止角,以弧度来表示。
clockwise — 以顺时针方向创建(扫过)椭圆。默认值为false。
rotation — 椭圆从X轴正方向逆时针的旋转角度(可选),以弧度表示,默认值为0。
添加一条绝对定位的EllipseCurve到路径中。
.arc ( x, y, radius, startAngle, endAngle, clockwise ) : this
x, y — 弧线的中心来自上次调用后的偏移量。
radius — 弧线的半径。
startAngle — 起始角,以弧度来表示。
endAngle — 终止角,以弧度来表示。
clockwise — 以顺时针方向创建(扫过)弧线。默认值为false。
添加一条EllipseCurve到路径中,位置相对于.currentPoint。
.bezierCurveTo ( cp1X, cp1Y, cp2X, cp2Y, x, y ) : this
从.currentPoint创建一条贝塞尔曲线,以(cp1X, cp1Y)和(cp2X, cp2Y)作为控制点,并将.currentPoint更新到x,y。
.ellipse ( x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation ) : this
x, y — 椭圆的中心来自上次调用后的偏移量。The center of the ellipse offset from the last call.
xRadius — 椭圆x轴方向的半径。
yRadius — 椭圆y轴方向的半径。
startAngle — 起始角,以弧度来表示。
endAngle — 终止角,以弧度来表示。
clockwise — 以顺时针方向创建(扫过)椭圆。默认值为false。
rotation — 椭圆从X轴正方向逆时针的旋转角度(可选),以弧度表示,默认值为0。
添加一条EllipseCurve到路径中,位置相对于.currentPoint。
.lineTo ( x : Float, y : Float ) : this
在当前路径上,从.currentPoint连接一条直线到x,y。
.moveTo ( x : Float, y : Float ) : this
将.currentPoint移动到x, y。
.quadraticCurveTo ( cpX : Float, cpY : Float, x : Float, y : Float ) : this
从.currentPoint创建一条二次曲线,以(cpX,cpY)作为控制点,并将.currentPoint更新到x,y。
.setFromPoints ( vector2s : Array ) : this
points — Vector2数组。
点将被作为LineCurves加入到curves数组中。
.splineThru ( points : Array ) : this
points –Vector2数组。
连接一条新的SplineCurve到路径上。
更多推荐


所有评论(0)