Skip to content

mult: method not converting param to vector if param is number #2

Description

@biofractal

Before

mult: (v)->
    @x *= v.x
    @y *= v.y
    @z *= v.z

After

mult: (v)->
    v = new Vector v, v, v if typeof v is 'number'
    @x *= v.x
    @y *= v.y
    @z *= v.z

This bug was discovered when using the limit method as limit: expects a scalar value yet it passes it to mult: which expects a Vector value, like so:

limit: (high)-> 
    if @mag() > high 
        @normalize()
        @mult(high)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions