Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.1 KB

README.md

File metadata and controls

45 lines (33 loc) · 1.1 KB

playcanvas-typescript-rollup

Basic starter project for writing a PlayCanvas project with TypeScript and Rollup.

Setup

npm i, then npm run build to compile once, or npm run watch to watch files.

Script example

import * as pc from "playcanvas";

/**
 * TODO: Add description.
 */
export class PcScript extends pc.ScriptType {
  /**
   * Called when script is about to run for the first time.
   */
  public initialize(): void {}

  /**
   * Called for enabled (running state) scripts on each tick.
   *
   * @param dt - The delta time in seconds since the last frame.
   */
  public update(dt: number): void {}
}

// Register script copmonent.
pc.registerScript(PcScript, "pcScript");

// Register component attributes.
PcScript.attributes.add("scriptAttribute", {
  type: "boolean",
  default: false,
});