diff --git a/src/data/local_storage.js b/src/data/local_storage.js index 09c4ff8749..bfdec038fa 100644 --- a/src/data/local_storage.js +++ b/src/data/local_storage.js @@ -147,7 +147,7 @@ function storage(p5, fn){ value = value.toString(); } else if (value instanceof p5.Vector) { type = 'p5.Vector'; - const coord = [value.x, value.y, value.z]; + const coord = value.values; value = coord; } value = JSON.stringify(value); diff --git a/src/math/p5.Vector.js b/src/math/p5.Vector.js index 739c6406af..a264fb811e 100644 --- a/src/math/p5.Vector.js +++ b/src/math/p5.Vector.js @@ -265,14 +265,14 @@ class Vector { * function setup() { * let v = createVector(20, 30); * - * // Prints 'p5.Vector Object : [20, 30, 0]'. + * // Prints 'vector[20, 30, 0]'. * print(v.toString()); * } * * */ toString() { - return `[${this._values.join(', ')}]`; + return `vector[${this._values.join(', ')}]`; } /** diff --git a/test/unit/math/p5.Vector.js b/test/unit/math/p5.Vector.js index 8e2dcf157d..4028ee2dba 100644 --- a/test/unit/math/p5.Vector.js +++ b/test/unit/math/p5.Vector.js @@ -2035,7 +2035,7 @@ suite('p5.Vector', function () { describe('vector to string', () => { it('should return the string version of a vector', () => { v = new mockP5.Vector(1, 2, 3, 4); - expect(v.toString()).toBe('[1, 2, 3, 4]'); + expect(v.toString()).toBe('vector[1, 2, 3, 4]'); }); });