File: Face3.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (131 lines) | stat: -rw-r--r-- 4,084 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<base href="../../../" />
		<script src="list.js"></script>
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
	</head>
	<body>
		<h1>[name]</h1>

		<p class="desc">
			在 [page:Geometry] 中被使用到的三角面片。这些三角面片会为所有标准几何体自动创建。
			然而,如果你正在构建一个自定义几何体,你需要手动创建这些三角面片。
		</p>


		<h2>示例</h2>

		<p>[example:svg_sandbox svg / sandbox ]</p>
		<p>[example:misc_exporter_obj exporter / obj ]</p>
		<p>[example:webgl_shaders_vector WebGL / shaders / vector ]</p>


		<code>
var material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } );

//创建仅有一个三角面片的几何体
var geometry = new THREE.Geometry();
geometry.vertices.push( new THREE.Vector3( -50, -50, 0 ) );
geometry.vertices.push( new THREE.Vector3(  50, -50, 0 ) );
geometry.vertices.push( new THREE.Vector3(  50,  50, 0 ) );

//利用顶点 0, 1, 2 创建一个面
var normal = new THREE.Vector3( 0, 1, 0 ); //optional
var color = new THREE.Color( 0xffaa00 ); //optional
var materialIndex = 0; //optional
var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex );

//将创建的面添加到几何体的面的队列
geometry.faces.push( face );

//如果没有特别指明,面和顶点的法向量可以通过如下代码自动计算
geometry.computeFaceNormals();
geometry.computeVertexNormals();

scene.add( new THREE.Mesh( geometry, material ) );
	</code>


		<h2>构造函数</h2>

		<h3>[name]( [param:Integer a], [param:Integer b], [param:Integer c], [param:Vector3 normal], [param:Color color], [param:Integer materialIndex] )</h3>
		<p>
			a — 顶点 A 的索引。<br />
			b — 顶点 B 的索引。<br />
			c — 顶点 C 的索引。<br /><br />

			normal — (可选) 面的法向量 ([page:Vector3 Vector3]) 或顶点法向量队列。
			如果参数传入单一矢量,则用该量设置面的法向量 [page:.normal],如果传入的是包含三个矢量的队列,
			则用该量设置 [page:.vertexNormals]<br /><br />

			color — (可选) 面的颜色值 [page:Color color] 或顶点颜色值的队列。
			如果参数传入单一矢量,则用该量设置 [page:.color],如果传入的是包含三个矢量的队列,
			则用该量设置 [page:.vertexColors]<br /><br />

			materialIndex — (可选) 材质队列中与该面对应的材质的索引。
		</p>

		<h2>属性</h2>

		<h3>[property:Integer a]</h3>
		<p>
			顶点 A 的索引。
		</p>

		<h3>[property:Integer b]</h3>
		<p>
			顶点 B 的索引。
		</p>

		<h3>[property:Integer c]</h3>
		<p>
			顶点 C 的索引。
		</p>

		<h3>[property:Vector3 normal]</h3>
		<p>
			面的法向量 - 矢量展示 Face3 的方向。如果该量是通过调用 [page:Geometry.computeFaceNormals] 自动计算的,
			该值等于归一化的两条边的差积。默认值是 *(0, 0, 0)*。
		</p>

		<h3>[property:Color color]</h3>
		<p>
			面的颜色值 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为
			[page:Materials THREE.FaceColors]。
		</p>

		<h3>[property:Array vertexNormals]</h3>
		<p>
			包含三个 [page:Vector3 vertex normals] 的队列。
		</p>

		<h3>[property:Array vertexColors]</h3>
		<p>
			包含 3 个顶点颜色值的队列 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为
			[page:Materials THREE.VertexColors]。
		</p>

		<h3>[property:Integer materialIndex]</h3>
		<p>
			材质队列中与该面相关的材质的索引。默认值为 *0*。
		</p>

		<h2>方法</h2>

		<h3>[method:Face3 clone]()</h3>
		<p>克隆该 Face3 对象。</p>

		<h3>[method:Face3 copy]( [param:Face3 face3] )</h3>
		<p>将参数指定的 Face3 对象的数据拷贝到当前对象。</p>


		<h2>源代码</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
		</p>
	</body>
</html>