* 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.
@@ -36,6 +36,10 @@
vectors, complex numbers and so on, however these are the most common uses in three.js.
</p>
+ <p>
+ Iterating through a Vector2 instance will yield its components (x, y) in the corresponding order.
+ </p>
+
<h2>Code Example</h2>
<code>
@@ -35,6 +35,10 @@
vectors and so on, however these are the most common uses in three.js.
+ Iterating through a Vector3 instance will yield its components (x, y, z) in the corresponding order.
@@ -34,6 +34,9 @@
There are other things a 4D vector can be used to represent, however these are the most common uses in three.js.
+ Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
@@ -33,6 +33,10 @@
其他的一些事物也可以使用二维向量进行表示,比如说动量矢量、复数等等;但以上这些是它在three.js中的常用用途。
<h2>代码示例</h2>
@@ -46,6 +46,9 @@
const d = a.distanceTo( b );
</code>
<h2>构造函数</h2>
@@ -45,6 +45,9 @@
const d = a.dot( b );
@@ -470,6 +470,13 @@ class Vector2 {
}
+ *[ Symbol.iterator ]() {
+ yield this.x;
+ yield this.y;
+ }
Vector2.prototype.isVector2 = true;
@@ -727,6 +727,14 @@ class Vector3 {
+ yield this.z;
Vector3.prototype.isVector3 = true;
@@ -648,6 +648,15 @@ class Vector4 {
+ yield this.w;
Vector4.prototype.isVector4 = true;