Hilo3d API - v2.0.0
    Preparing search index...

    Class Vector2

    二维向量

    Index
    • Creates a new empty vec2

      Parameters

      • x: number = 0

        X component

      • y: number = 0

        Y component

      Returns Vector2

    className: string = 'Vector2'

    类名

    elements: vec2
    isVector2: boolean = true
    • Calculates the euclidian distance between two vec2's

      Parameters

      • a: Vector2
      • Optionalb: Vector2

        如果不传,计算 this 和 a 的结果

      Returns number

      distance between a and b

    • Returns whether or not the vectors have approximately the same elements in the same position.

      Parameters

      • a: Vector2
      • Optionalb: Vector2

        如果不传,计算 this 和 a 的结果

      Returns boolean

      True if the vectors are equal, false otherwise.

    • Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)

      Parameters

      • a: Vector2
      • Optionalb: Vector2

        如果不传,计算 this 和 a 的结果

      Returns boolean

      True if the vectors are equal, false otherwise.

    • Math.floor the components of this

      Returns this

      this

    • 从数组赋值

      Parameters

      • array: ArrayLike<number>

        数组

      • offset: number = 0

        数组偏移值

      Returns this

      this

    • Calculates the length of this

      Returns number

      length of this

    • Performs a linear interpolation between two vec2's

      Parameters

      • v: Vector2
      • t: number

        interpolation amount between the two vectors

      Returns this

      this

    • Generates a random vector with the given scale

      Parameters

      • Optionalscale: number

        Length of the resulting vector. If ommitted, a unit vector will be returned

      Returns this

      this

    • Math.round the components of this

      Returns this

      this

    • Scales this by a scalar number

      Parameters

      • scale: number

        amount to scale the vector by

      Returns this

      this

    • Adds two vec2's after scaling the second vector by a scalar value

      Parameters

      • scale: number

        the amount to scale the second vector by before adding

      • a: Vector2
      • Optionalb: Vector2

        如果不传,计算 this 和 a 的结果

      Returns this

      this

    • Set the components of a vec4 to the given values

      Parameters

      • x: number

        X component

      • y: number

        Y component

      Returns this

      this

    • Calculates the squared euclidian distance between two vec2's

      Parameters

      • a: Vector2
      • Optionalb: Vector2

        如果不传,计算 this 和 a 的结果

      Returns number

      squared distance between a and b

    • Calculates the squared length of this

      Returns number

      squared length of this