Time modifier which affects
Delays execution of code by returning a promise which resolves in time seconds. Used with async/await keywords.
Example:
async function myFunction(){
//doSomething
await Time.delay(1); // wait for a second
//doAnotherThing
}
For more information see ES6 Promises and async function.
delay in seconds.
Executes a function after a delay.
function to execute after delay.
delay in seconds.
Repeats execution of a function every period.
Example
const myEllipsoid = Scene.createEllipsoid(0, 0, 0)
Time.scheduleRepeating(() => {
myEllipsoid.speech = `${Time.currentTime.toFixed(2)} seconds have passed.`
}, 1)
function to execute repeatedly.
period in seconds. Default is 0, causing script to be repeated every frame.
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))
})
function to execute every frame.
Repeats execution of a function every period.
The callback is called after physics for the frame is calculated.
period in seconds. Default is 0, causing script to be repeated every frame.
function to execute repeatedly.
Manages script execution and engine time.
Timemethods and properties allow you to