Adding a method that sets the components of the vector with a random number [0-1]
@@ -457,6 +457,11 @@ export class Vector2 implements Vector {
*
* @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
*/
- manhattanDistanceTo( v: Vector2 ): number;
+ manhattanDistanceTo( v: Vector2 ): number;
+
+ /**
+ * Sets this vector's x and y from Math.random
+ */
+ random(): this;
}
@@ -482,7 +482,16 @@ Object.assign( Vector2.prototype, {
return this;
- }
+ },
+ random: function () {
+ this.x = Math.random();
+ this.y = Math.random();
+ return this;
+ }
} );
@@ -285,6 +285,11 @@ export class Vector3 implements Vector {
attribute: BufferAttribute,
index: number,
offset?: number
- ): this;
+ ): this;
+ * Sets this vector's x, y and z from Math.random
@@ -712,7 +712,17 @@ Object.assign( Vector3.prototype, {
+ this.z = Math.random();
@@ -208,6 +208,11 @@ export class Vector4 implements Vector {
+ * Sets this vector's x, y, z and w from Math.random
@@ -646,7 +646,18 @@ Object.assign( Vector4.prototype, {
+ this.w = Math.random();