Giter Club home page Giter Club logo

playcanvas-typescript-template's Introduction

playcanvas-typescript-template

Minimal setup to set up a local PlayCanvas development using TypeScript.

This works with my other parcel plugin parcel-plugin-playcanvas for a seamless local <-> PlayCanvas Editor workflow.

How to use

  • Clone this repo
  • npm install or yarn install to pull the dependencies
  • npm run serve or yarn serve for development, .ts files are watched and rebundle and upload to PlayCanvas automatically
  • npm build for a production build

Example usage

import { createScript } from "../../extensions/create-script-decorator"
import { ScriptTypeBase } from "../../extensions/script-type-base"
import { IAttributeCollection } from "../../@types"

@createScript()
export class HelloWorld extends ScriptTypeBase implements pc.ScriptType {
  name = 'ABC'

  attributes: IAttributeCollection = {
    test: { type: 'string' }
  }

  initialize() {
    console.log(this.test)
  }
}

Inspiration and credits

https://github.com/whydoidoit/babel-playcanvas-template

https://github.com/snowfrogdev/typescript-playcanvas-template

Thank you!

playcanvas-typescript-template's People

Contributors

hxhieu avatar vmwxiong avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vmwxiong

playcanvas-typescript-template's Issues

this.entity.setPosition(Vec3.LEFT) results in "nan" position values

this script:

import { createScript } from "../../extensions/create-script-decorator";
import { ScriptTypeBase } from "../../extensions/script-type-base";
import { IAttributeCollection } from "../../@types/system";
import { Vec3 } from "playcanvas";

@createScript()
export class HelloWorld extends ScriptTypeBase implements pc.ScriptType {
  name = 'ABC'

  initialize() {
    this.entity.setPosition(Vec3.LEFT);
    console.log(this.entity.getPosition());
  }
}

results in position: Object { x: NaN, y: NaN, z: NaN }

or

import { createScript } from "../../extensions/create-script-decorator";
import { ScriptTypeBase } from "../../extensions/script-type-base";
import { IAttributeCollection } from "../../@types/system";
import pc from "playcanvas";

@createScript()
export class HelloWorld extends ScriptTypeBase implements pc.ScriptType {
  name = 'ABC'

  initialize() {
    this.entity.setPosition(pc.Vec3.LEFT);
    console.log(this.entity.getPosition());
  }
}

results in error: n.default is undefined

Step to reproduce:

  • clone this repository from latest commit
  • setup credentials
  • insert both of these snippets into src/components/hello.ts
  • run build command
  • attach script to entity in playcanvas and hit launch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.