melonJS
    Preparing search index...

    Class ObservableVector3d

    Represents a point in a 3D coordinate vector that can be observed for changes.

    Index
    • Creates a new ObservableVector3d instance.

      Parameters

      • x: number = 0

        The x-coordinate of the vector. Default is 0.

      • y: number = 0

        The y-coordinate of the vector. Default is 0.

      • z: number = 0

        The z-coordinate of the vector. Default is 0.

      • Optionalcallback: () => void

        The callback function to be called when the point changes. Default is undefined.

      Returns ObservableVector3d

    • return true if this vector is equal to the given values or vector

      Parameters

      • ...args:
            | [number, number, number]
            | [number, number]
            | [number]
            | [Vector2d]
            | [Vector3d]
            | [ObservableVector3d]

        other vector or vector components

      Returns boolean

      true if both vectors are equal

    • Multiply this vector values by the given scalar, per axis. y defaults to x but z defaults to 1, so scale(n) scales x and y only and leaves z, a renderable's depth (its draw order), as it was. To scale all three, pass all three, scale(n, n, n), or divide with ObservableVector3d#div.

      Parameters

      • x: number

        x component

      • Optionaly: number = x

        y component, x when left out

      • Optionalz: number = 1

        z component, 1 (unchanged) when left out

      Returns ObservableVector3d

      Reference to this object for method chaining

    • Sets the callback function to be called when the point changes.

      Parameters

      • callback: (() => void) | undefined

        The callback function, or undefined to remove it.

      Returns void