three.d.ts provides a type-safe and readable interface for three.js.
This porject is currently based on three.js r54. (You can also get three.d.ts r53)
only three.d.ts or zipped whole of the project contains some examples.
HTML API reference is available. (Experimental)
http://kontan.github.com/dtsdoc/three.d.ts.html
-
Download three.js (three.js r54 is recommended) and unzip it.
-
Download three.d.ts and place it at any directory.
-
Create your TypeScript source file.
-
To reference three.d.ts from your typescript code, write the following special comment at the top of the your source file:
/// <reference path="path/to/three.d.ts" />
The compiler will search type names and identifiers from the file. Even if you write a wrong path to the TypeScript ambient source file, the compiler will not complain about missing the file :-( The compiler will just says "The name 'THREE' does not exists in the current scope." Be careful about the path.
- Write your application. If you want to refer a API reference, watch official API reference (a little out of date) or read three.d.ts.
- Launch a shell and compile the your code.
- Create your html file to invoke the generated JavaScript source code. Don't forget to refer both of three.js and yourcode.js from your html source file. The previous special comment line does not influence the generated JavaScript.
- Open the html file. If your application doesn't work, source maps is useful to debug.
Enjoy three.js!
http://kontan.github.com/three.d.ts
- Prividing a lot more examples written in TypeScript.