Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Time

Namespace for managing script execution and engine time.

Time methods and properties allow you to

  • Set up functions that are called every frame or in repeating intervals
  • Delay script execution
  • Get engine time data

See Time.scheduleRepeating

See Time.schedule

Index

Variables

Functions

Variables

Const currentTime

currentTime: number
returns

time (in seconds) that passed since start.

Functions

schedule

  • schedule(func: function, delay: number): Disposable
  • Executes a function after a delay.

    Parameters

    • func: function

      function to execute after delay.

        • (): void
        • Returns void

    • delay: number

      delay in seconds.

    Returns Disposable

scheduleRepeating

  • scheduleRepeating(func: function, period: number): Disposable
  • scheduleRepeating(func: function): Disposable
  • Repeats execution of a function every period.

    Example `

    //Creates an ellipsoid which says the time that passed since start every second
    const myEllipsoid = Scene.createEllipsoid(0, 0, 0)
    Time.scheduleRepeating(() => {
        myEllipsoid.speech = `${Time.currentTime.toFixed(2)} seconds have passed.`
    }, 1)

    `

    Parameters

    • func: function

      function to execute repeatedly.

        • (deltaTime: number): void
        • Parameters

          • deltaTime: number

          Returns void

    • period: number

      period in seconds. Default is 0, causing script to be repeated every frame.

    Returns Disposable

  • Repeats execution of a function every frame.

    Example `

    //Creates an ellipsoid which says the time that passed since start every frame
    const myEllipsoid = Scene.createEllipsoid(0, 0, 0)
    Time.scheduleRepeating(() => {
        myEllipsoid.speech = `${Time.currentTime.toFixed(2)} seconds have passed.`
    })
    
    //Creates a cuboid which moves at a constant speed independent of device performance
    const myCuboid = Scene.createCuboid(0, 0, 0)
    let speed = 0.1
    Time.scheduleRepeating(deltaTime => {
        let currentPosition = myCuboid.transform.position
        myCuboid.transform.position = currentPosition.add(Vector3.axisX.mult(speed * deltaTime))
    })

    `

    Parameters

    • func: function

      function to execute every frame.

        • (deltaTime: number): void
        • Parameters

          • deltaTime: number

          Returns void

    Returns Disposable

Generated using TypeDoc