@@ -23,12 +23,9 @@ function math(p5, fn) {
2323 * This allows for flexibility in representing vectors in higher-dimensional
2424 * spaces.
2525 *
26- * - Calling `createVector()` **with no arguments** is **deprecated** and will emit
27- * a friendly warning. Use `createVector(0)`, `createVector(0, 0)`, or
28- * `createVector(0, 0, 0)` instead.
29- * - To prevent `NaN` appearing in subsequent operations, missing components are
30- * padded with zeros: `createVector(x)` -> `[x, 0, 0]`, `createVector(x, y)` -> `[x, y, 0]`.
31- * This is for backwards compatibility only; explicitly pass all intended components.
26+ * Calling `createVector()` **with no arguments** is **deprecated** and will emit
27+ * a friendly warning. Use `createVector(0)`, `createVector(0, 0)`, or
28+ * `createVector(0, 0, 0)` instead.
3229 *
3330 * <a href="#/p5.Vector">p5.Vector</a> objects are often used to program
3431 * motion because they simplify the math. For example, a moving ball has a
@@ -103,36 +100,21 @@ function math(p5, fn) {
103100 * </div>
104101 */
105102 fn . createVector = function ( x , y , z ) {
106- const argc = arguments . length ;
107-
108- if ( argc === 0 && typeof p5 !== 'undefined' && p5 . _friendlyError ) {
103+ if ( arguments . length === 0 ) {
109104 p5 . _friendlyError (
110105 'Calling createVector() with no arguments is deprecated and will be removed in a future release. Pass zeros for the desired dimensionality.'
111106 ) ;
112107 }
113- const safeArgs =
114- argc === 1 ? [ x , 0 , 0 ]
115- : argc === 2 ? [ x , y , 0 ]
116- : [ ...arguments ] ;
117-
118- let v ;
119108 if ( this instanceof p5 ) {
120- v = new p5 . Vector (
109+ return new p5 . Vector (
121110 this . _fromRadians . bind ( this ) ,
122111 this . _toRadians . bind ( this ) ,
123- ...safeArgs
112+ ...arguments
124113 ) ;
125114 } else {
126- v = new p5 . Vector ( ... safeArgs ) ;
115+ return new p5 . Vector ( x , y , z ) ;
127116 }
128-
129- Object . defineProperty ( v , '_origDimension' , {
130- get ( ) { return argc ; } ,
131- } ) ;
132-
133- return v ;
134117 } ;
135-
136118
137119 /**
138120 * Creates a new <a href="#/p5.Matrix">p5.Matrix</a> object.
0 commit comments