You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
3.1 KiB
102 lines
3.1 KiB
<!DOCTYPE html>
|
|
<html lang="zh">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<base href="../../../../" />
|
|
<script src="page.js"></script>
|
|
<link type="text/css" rel="stylesheet" href="page.css" />
|
|
</head>
|
|
<body>
|
|
[page:Curve] → [page:CurvePath] → [page:Path] →
|
|
|
|
<h1>形状([name])</h1>
|
|
|
|
<p class="desc">
|
|
使用路径以及可选的孔洞来定义一个二维形状平面。
|
|
它可以和[page:ExtrudeGeometry]、[page:ShapeGeometry]一起使用,获取点,或者获取三角面。
|
|
</p>
|
|
|
|
<h2>代码示例</h2>
|
|
|
|
<code>
|
|
const heartShape = new THREE.Shape();
|
|
|
|
heartShape.moveTo( 25, 25 );
|
|
heartShape.bezierCurveTo( 25, 25, 20, 0, 0, 0 );
|
|
heartShape.bezierCurveTo( - 30, 0, - 30, 35, - 30, 35 );
|
|
heartShape.bezierCurveTo( - 30, 55, - 10, 77, 25, 95 );
|
|
heartShape.bezierCurveTo( 60, 77, 80, 55, 80, 35 );
|
|
heartShape.bezierCurveTo( 80, 35, 80, 0, 50, 0 );
|
|
heartShape.bezierCurveTo( 35, 0, 25, 25, 25, 25 );
|
|
|
|
const extrudeSettings = { depth: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 };
|
|
|
|
const geometry = new THREE.ExtrudeGeometry( heartShape, extrudeSettings );
|
|
|
|
const mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
|
|
</code>
|
|
|
|
<h2>例子</h2>
|
|
|
|
<p>
|
|
[example:webgl_geometry_shapes geometry / shapes ]<br/>
|
|
[example:webgl_geometry_extrude_shapes geometry / extrude / shapes ]<br/>
|
|
[example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2 ]
|
|
</p>
|
|
|
|
<h2>构造函数</h2>
|
|
|
|
|
|
<h3>[name]( [param:Array points] )</h3>
|
|
<p>
|
|
points -- (optional) 一个[page:Vector2 Vector2]数组。<br /><br />
|
|
|
|
从点来创建一个Shape。第一个点定义了偏移量,
|
|
接下来的点被作为[page:LineCurve LineCurves]加入到[page:CurvePath.curves curves]中。<br /><br />
|
|
|
|
如果没有点被指定,一个空的形状将会被创建,且[page:.currentPoint]将会被设为原点。
|
|
</p>
|
|
|
|
|
|
<h2>属性</h2>
|
|
<p>共有属性请参见其基类[page:Path]。</p>
|
|
|
|
<h3>[property:String uuid]</h3>
|
|
<p>
|
|
该类所创建的实例的[link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID]。它是自动被指定的,因此它不应当被编辑、更改。
|
|
</p>
|
|
|
|
<h3>[property:Array holes]</h3>
|
|
<p>一个[page:Path paths]数组,定义了形状上的孔洞。</p>
|
|
|
|
<h2>方法</h2>
|
|
<p>共有方法请参见其基类[page:Path]。</p>
|
|
|
|
<h3>[method:Array extractPoints]( [param:Integer divisions] )</h3>
|
|
<p>
|
|
divisions -- 结果的精细程度(细分数)。<br /><br />
|
|
|
|
在形状以及[page:.holes](孔洞)数组上调用[page:Curve.getPoints getPoints],并返回一个来自于:
|
|
<code>
|
|
{
|
|
shape
|
|
holes
|
|
}
|
|
</code>
|
|
的对象,其中的形状和孔洞是[page:Vector2 Vector2]数组。
|
|
</p>
|
|
|
|
<h3>[method:Array getPointsHoles]( [param:Integer divisions] )</h3>
|
|
<p>
|
|
divisions -- 结果的精细程度(细分数)。<br /><br />
|
|
|
|
获取一个表示形状上的孔洞的[page:Vector2 Vector2s]数组。
|
|
</p>
|
|
|
|
<h2>源代码</h2>
|
|
|
|
<p>
|
|
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
|
|
</p>
|
|
</body>
|
|
</html>
|
|
|