A tutorial on how to get started with Away3D TypeScript
To get started with Away3D TS you will need to install NodeJS, the TypeScript Compiler (which uses NodeJS), and a web server. While it is possible to use Away3D TS without Typescript, it provides a more familiar language for ActionScript developers and many advantages.
NodeJS - http://nodejs.org/
The first thing you will need to do to get up and running is install NodeJS. You can obtain the official distribution from here: http://nodejs.org/. You can also use a package manager like Homebrew which can install Node (and other things), from here: http://brew.sh .
TypeScript Compiler - http://www.typescriptlang.org/
TOnce NodeJS is installed, you will be ready to install the TypeScript compiler. On Windows, open the Command Prompt and run:
npm install -g typescript
OsX / Linux users, try the above command but you may need to sudo depending on your package manager and installation configuration:
sudo npm install -g typescript
There are many options you can use to run a webserver: PHP, Python, MAMP, WAMP, IIS.
MAMP / WAMP
These servers are easy to use and have a nice GUI :
Alternatively, as you will be using Node for Typescript anyway, you can use npm to install a Node based http server:
NodeJS http-server - https://github.com/nodeapps/http-server
Is ‘a simple zero-configuration command-line http server’. To install it run:
npm install http-server -g
to start the server run the following from a directory:
and visit http://localhost:8080 to view your server.
Development with Away3D TS - Getting Started
We created some examples to get you started, these are also on GitHub:
1) Clone the Away3D examples Git repository, or download the examples using this link
git clone http://github.com/away3d/away3d-examples-ts
2) Navigate to the the Away3D example folder
3) Edit the src/TorusPrimitive.ts TypeScript file by adding the following to the render() function:
this._mesh.rotationX += 1;
tsc src/TorusPrimitive.ts --sourcemap --out bin/js/TorusPrimitive.js
5) Start the HTTP server
http-server will give you a connection address, usually http://localhost:8080/. Open this with your browser, click on the bin directory, then TorusPrimitive.html. If you open up the debugging panel in your web browser, you should see the TypesSript source thanks to the use of source maps.
Try adding the following line in the initLights() function for an experiment:
this._light.ambientColor = 0xff0000; this._light.ambient = 0.6;
Eclipse - https://github.com/palantir/eclipse-typescript
WebStorm / PHPStorm - http://www.jetbrains.com/webstorm/
Flash Develop - http://www.flashdevelop.org/
Visual Studio - http://www.microsoft.com/visualstudio/eng/downloads#d-express-web
Sublime - http://www.sublimetext.com/