From 0a06022b8f02b0bf2c85219eada6742f4931a7e0 Mon Sep 17 00:00:00 2001 From: Rob Blanckaert Date: Mon, 16 Mar 2015 20:56:28 -0400 Subject: [PATCH] Update vector.coffee Make Vector do the right thing if you forget new, --- app/lib/world/vector.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/lib/world/vector.coffee b/app/lib/world/vector.coffee index 712d99d64..2ded6f9f6 100644 --- a/app/lib/world/vector.coffee +++ b/app/lib/world/vector.coffee @@ -10,7 +10,9 @@ class Vector isVector: true apiProperties: ['x', 'y', 'z', 'magnitude', 'heading', 'distance', 'dot', 'equals', 'copy', 'distanceSquared', 'rotate'] - constructor: (@x=0, @y=0, @z=0) -> + constructor: (x=0, y=0, z=0) -> + return new Vector(x,y,z) unless this instanceof Vector + [@x, @y, @z] = [x,y,z] copy: -> new Vector(@x, @y, @z)