1.0.0 • Published 7 years ago

playcanvas-update-fn v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

Introduction

Specifies a function to be called every game frame until it returns false.

Installation

npm install --save playcanvas-update-fn

Usage

import update from 'playcanvas-update-fn'

...

let w = new pc.Vec3;

MyScript.prototype.moveTo = function(position) {
    let t = 0;
    this.startPosition.copy(this.entity.getPosition());
    //Call update until the movement is complete
    update(dt=>{
        t += dt;
        this.entity.setPosition(w.lerp(this.startPosition, position, t));
        return t < 1;
    });
} 
 

Requirements

Requires PlayCanvas Engine to be running on the page. Uses ES6/Babel/PlayCanvas template.