Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/math/p5.Vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Vector {
* @param {Number} xVal - The new value for the x component.
*/
set x(xVal) {
if (this.values.length > 1) {
if (this.values.length > 0) {
this.values[0] = xVal;
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/math/p5.Vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,12 @@ suite('p5.Vector', function () {
v = new Vector(1, 2, 3, 4);
expect(v.toString()).toBe('vector[1, 2, 3, 4]');
});

test('should show a value change for x with toString() for 1d Vector', function(){
v = new Vector(1);
v.x = 2;
expect(v.toString()).toBe('vector[2]');
})
});

describe('set heading', () => {
Expand Down