Function create

  • Creates a Vec2; may be called with x, y, z to set initial values.

    Note: Since passing in a raw JavaScript array is valid in all circumstances, if you want to force a JavaScript array into a Vec2's specified type it would be faster to use

    const v = vec2.clone(someJSArray);
    

    Note: a consequence of the implementation is if your Vec2Type = Array instead of Float32Array or Float64Array then any values you don't pass in will be undefined. Usually this is not an issue since (a) using Array is rare and (b) using vec2.create is usually used to create a Vec2 to be filled out as in

    const sum = vec2.create();
    vec2.add(v1, v2, sum);

    Parameters

    • x: number = 0

      Initial x value.

    • y: number = 0

      Initial y value.

    Returns Vec2

    the created vector