Skip to content

Commit fbdb745

Browse files
author
B3epBo0p
authored
Iterable vectors (mrdoob#22548)
* Add iterators to vectors * Provide documentation * Update translated documentation Copy English documentation where applicable. Some languages did not contain the math directory, which is where the English vector documentation is located.
1 parent af99874 commit fbdb745

File tree

9 files changed

+45
-0
lines changed

9 files changed

+45
-0
lines changed

docs/api/en/math/Vector2.html

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ <h1>[name]</h1>
3636
vectors, complex numbers and so on, however these are the most common uses in three.js.
3737
</p>
3838

39+
<p>
40+
Iterating through a Vector2 instance will yield its components (x, y) in the corresponding order.
41+
</p>
42+
3943
<h2>Code Example</h2>
4044

4145
<code>

docs/api/en/math/Vector3.html

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ <h1>[name]</h1>
3535
vectors and so on, however these are the most common uses in three.js.
3636
</p>
3737

38+
<p>
39+
Iterating through a Vector3 instance will yield its components (x, y, z) in the corresponding order.
40+
</p>
41+
3842

3943
<h2>Code Example</h2>
4044

docs/api/en/math/Vector4.html

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ <h1>[name]</h1>
3434
There are other things a 4D vector can be used to represent, however these are the most common uses in three.js.
3535
</p>
3636

37+
<p>
38+
Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
39+
</p>
3740

3841
<h2>Code Example</h2>
3942

docs/api/zh/math/Vector2.html

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ <h1>二维向量([name])</h1>
3333
其他的一些事物也可以使用二维向量进行表示,比如说动量矢量、复数等等;但以上这些是它在three.js中的常用用途。
3434
</p>
3535

36+
<p>
37+
Iterating through a Vector2 instance will yield its components (x, y) in the corresponding order.
38+
</p>
39+
3640
<h2>代码示例</h2>
3741

3842
<code>

docs/api/zh/math/Vector3.html

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ <h2>代码示例</h2>
4646
const d = a.distanceTo( b );
4747
</code>
4848

49+
<p>
50+
Iterating through a Vector3 instance will yield its components (x, y, z) in the corresponding order.
51+
</p>
4952

5053
<h2>构造函数</h2>
5154

docs/api/zh/math/Vector4.html

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ <h2>代码示例</h2>
4545
const d = a.dot( b );
4646
</code>
4747

48+
<p>
49+
Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
50+
</p>
4851

4952
<h2>构造函数</h2>
5053

src/math/Vector2.js

+7
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,13 @@ class Vector2 {
470470

471471
}
472472

473+
*[ Symbol.iterator ]() {
474+
475+
yield this.x;
476+
yield this.y;
477+
478+
}
479+
473480
}
474481

475482
Vector2.prototype.isVector2 = true;

src/math/Vector3.js

+8
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,14 @@ class Vector3 {
727727

728728
}
729729

730+
*[ Symbol.iterator ]() {
731+
732+
yield this.x;
733+
yield this.y;
734+
yield this.z;
735+
736+
}
737+
730738
}
731739

732740
Vector3.prototype.isVector3 = true;

src/math/Vector4.js

+9
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,15 @@ class Vector4 {
648648

649649
}
650650

651+
*[ Symbol.iterator ]() {
652+
653+
yield this.x;
654+
yield this.y;
655+
yield this.z;
656+
yield this.w;
657+
658+
}
659+
651660
}
652661

653662
Vector4.prototype.isVector4 = true;

0 commit comments

Comments
 (0)