Update vector.coffee

Make Vector do the right thing if you forget new,
This commit is contained in:
Rob Blanckaert 2015-03-16 20:56:28 -04:00
parent 2d89de8183
commit 0a06022b8f

View file

@ -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)