Turbulenz is an HTML5 game engine and server-side APIs available in JavaScript and TypeScript for building and distributing 2D and 3D games that run on platforms that support HTML5 features such as modern browsers without the need for plugins.
.. contents:: :local:
Polycraft <https://turbulenz.com/games/polycraft>
__ - 3DSave the day <https://turbulenz.com/games/save-the-day>
__ - 2DDenki Blocks! <https://turbulenz.com/games/denkiblocks>
__ - 2DDenki Word Quest <https://turbulenz.com/games/denkiwordquest>
__ - 2DScore Rush <https://turbulenz.com/games/scorerush>
__ - 2DScore Rush MP <https://turbulenz.com/games/scorerush-mp>
__ - multiplayerSpace Ark <https://turbulenz.com/games/space-ark>
__ - 3DApathy <http://apathy.plankhead.com/>
- src <https://github.com/Zacqary/Apathy>
- 2Dsrc <https://github.com/zacqary/salty-dogs>
__Gargantia Sky Courier <http://fly.gargantia.jp>
__ - src <https://github.com/turbulenz/gargantia_editor>
__ - 3Dsrc <apps/sampleapp/scripts/sampleappmain.js>
__src <apps/inputapp/tsscripts/inputapp>
__src <apps/viewer/scripts/viewer.js>
__src <apps/multiworm/tsscripts/worm>
__src <apps/tictactoe/tsscripts/tictactoe>
__jsfiddle <http://jsfiddle.net/jamesaustin/WF47C/>
__src <apps/protolibsampleapp/scripts/protolibsampleapp.js>
__src <apps/protolibtemplateapp/scripts/app.js>
__Setup:
Device Initialization <http://biz.turbulenz.com/sample_assets/device_initialization.canvas.release.html>
__ - src <samples/tsscripts/templates/device_initialization.ts>
__Basic Loop <http://biz.turbulenz.com/sample_assets/basic_loop.canvas.release.html>
__ - src <samples/tsscripts/templates/basic_loop.ts>
__2D Rendering:
2D Canvas <http://biz.turbulenz.com/sample_assets/2dcanvas.canvas.release.html>
- src <samples/tsscripts/templates/2dcanvas.ts>
- jsfiddle <http://jsfiddle.net/jamesaustin/HRAw7/>
__Draw2D <http://biz.turbulenz.com/sample_assets/draw2d.canvas.release.html>
- src <samples/tsscripts/templates/draw2d.ts>
TextureEffects <http://biz.turbulenz.com/sample_assets/textureeffects.canvas.release.html>
- src <samples/tsscripts/templates/textureeffects.ts>
Immediate Mode Rendering <http://biz.turbulenz.com/sample_assets/immediate_mode_rendering.canvas.release.html>
- src <samples/tsscripts/templates/immediate_mode_rendering.ts>
src <samples/tsscripts/templates/loading.ts>
__src <samples/tsscripts/templates/svg.ts>
__3D Rendering:
Camera <http://biz.turbulenz.com/sample_assets/camera.canvas.release.html>
- src <samples/tsscripts/templates/camera.ts>
Material <http://biz.turbulenz.com/sample_assets/material.canvas.release.html>
- src <samples/tsscripts/templates/material.ts>
Forward rendering <http://biz.turbulenz.com/sample_assets/forward_rendering.canvas.release.html>
__ - src <samples/tsscripts/templates/forward_rendering.ts>
__Morphing <http://biz.turbulenz.com/sample_assets/morphing.canvas.release.html>
- src <samples/tsscripts/templates/morphing.ts>
Post effects <http://biz.turbulenz.com/sample_assets/postfx.canvas.release.html>
- src <samples/tsscripts/templates/postfx.ts>
Particles <http://biz.turbulenz.com/sample_assets/particles.canvas.release.html>
- src <samples/tsscripts/templates/particles.ts>
src <samples/tsscripts/templates/deferred_rendering.ts>
__src <samples/tsscripts/templates/load_model.ts>
__src <samples/tsscripts/templates/scene_loading.ts>
__Animation:
Animation <http://biz.turbulenz.com/sample_assets/animation.canvas.release.html>
- src <samples/tsscripts/templates/animation.ts>
Multiple animations <http://biz.turbulenz.com/sample_assets/multiple_animations.canvas.release.html>
__ - src <samples/tsscripts/templates/multiple_animations.ts>
__2D Physics:
2D Physics <http://biz.turbulenz.com/sample_assets/physics2d.canvas.release.html>
- src <samples/tsscripts/templates/physics2d.ts>
2D Physics constraints <http://biz.turbulenz.com/sample_assets/physics2d_constraints.canvas.release.html>
__ - src <samples/tsscripts/templates/physics2d_constraints.ts>
__2D Physics callbacks <http://biz.turbulenz.com/sample_assets/physics2d_callbacks.canvas.release.html>
__ - src <samples/tsscripts/templates/physics2d_callbacks.ts>
__3D Physics:
3D Physics <http://biz.turbulenz.com/sample_assets/physics.canvas.release.html>
- src <samples/tsscripts/templates/physics.ts>
3D Physics <benchmark(http://biz.turbulenz.com/sample_assets/physics_benchmark.canvas.release.html>
__ - src <samples/tsscripts/templates/physics_benchmark.ts>
__3D Physics collision mesh <http://biz.turbulenz.com/sample_assets/physics_collisionmesh.canvas.release.html>
__ - src <samples/tsscripts/templates/physics_collisionmesh.ts>
__src <samples/tsscripts/templates/physics_constraints.ts>
__Sound:
Sound <http://biz.turbulenz.com/sample_assets/sound.canvas.release.html>
- src <samples/tsscripts/templates/sound.ts>
Video:
Video playback <http://biz.turbulenz.com/sample_assets/video.canvas.release.html>
- src <samples/tsscripts/templates/video.ts>
Services:
src <samples/tsscripts/templates/leaderboards.ts>
__src <samples/tsscripts/templates/multichat.ts>
__src <samples/tsscripts/templates/payments.ts>
__src <samples/tsscripts/templates/userdata.ts>
__Graphics
Simple shader-based immediate mode API:
Vertex buffers, Index buffers and Textures can be created, updated and destroyed dynamically.
Multiple Streams of Vertex buffers can be used at the same time.
Support for 1D, 2D, 3D and Cube textures: Any pixel format supported by the hardware.
Asynchronous resource loading: multiple resource files can be downloaded on the fly, JavaScript code will be notified when resource is available for usage.
Multiple image file formats: DDS, JPG, PNG and TGA.
Support for textures archives containing multiple image files: less flexibility than individual files but better for optimal bandwidth usage.
Occlusion queries:
Fullscreen support (Supported platforms).
Take screenshot feature:
Video playback support:
Math
Math types:
Storage format optimized based on available support
Optimized operations support destination parameters, reducing object allocation.
Array to/from Math type conversion utilities.
Physics
3D
Easy-to-use efficient physics simulation.
Rigid bodies and collision objects: Plane, Box, Sphere, Capsule, Cylinder, Cone, Triangle Mesh, Convex Hull.
Constraints: Point to Point, Hinge, Cone Twist, 6DOF, Slider.
Ray and convex sweep queries: Returning closest point of impact and surface normal.
Character representation.
Contact callbacks.
2D
Efficient 2D physics simulation written specifically for JavaScript.
Shapes:
Collision detection:
Simulation world:
Rigid body simulation: Dynamic, Static, Kinematic objects.
Materials: Elasticity, Static/Dynamic/Rolling Friction, Density.
Arbiters:
Constraints: Point to Point, Distance, Weld, Angle, Motor, Line, Pulley, Custom Constraint.
Debug rendering:
Sound
Networking
Bi-directional, full-duplex communications channels, over a TCP socket:
Utilizes browser Websocket support.
Efficient native implementation of WebSockets for platforms without support:
HTTP-compatible handshake so that HTTP servers can share their default HTTP and HTTPS ports (80 and 443) with a WebSocket server.
Support for secure connections as part of the standard.
Support for data compression with the extension deflate-frame
.
Input
Access to input types: Keyboard, Mouse, Xbox360 Pad, Joysticks, Wheels, Touch, Multi-touch
Asynchronous event system when state changes:
Additional mouse features: hiding/showing platform icon, locking/unlocking (supported platforms).
Language independent keymapping.
Scene Graph
Flexible JSON file format: Could describe either a whole scene or individual meshes.
Asynchronous loading of external references:
Pluggable renderer system:
Geometry sharing: Geometry information can be optimally reused on multiple scene locations with different rendering effects.
Flexible scene hierarchy nodes: Lights, Geometries, Animation, Physics.
Visibility queries: Portals, Frustum, Overlapping Box.
Sorting and grouping: Visible nodes are sorted and grouped for optimal rendering: Opaque, Transparent, Decal.
Lazy evaluation of node updates.
Animation
3D animation for scene geometry.
Skeleton/Skinning animation.
Animation controllers:
Dynamically update scene data.
Resource Manager
Server Requests
HTTP & AJAX request functionality:
Deferred Renderer
Unlimited number of lights: Point, Spot, Directional, Ambient.
Texture based light falloff: Allows multi-colored lights and cheap fake shadows, for example the typical fan under a light source.
Materials with multiple texture maps: Specular color and intensity, Normal vector, Glow color, Alpha.
Pluggable post effects:
Exponential shadow maps:
Volumetric fog.
4 weight GPU skinning.
UV animation.
Wireframe mode.
Callbacks for additional passes: decals, transparency, debug
Available in plugin mode only until draw buffers are added to WebGL http://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/
Forward Renderer
Unlimited number of lights: Point, Spot, Directional, Ambient.
Texture based light falloff: Allows multi-colored lights and cheap fake shadows, for example the typical fan under a light source.
Materials with multiple texture maps: Specular color and intensity, Normal vector, Glow color, Alpha.
Pluggable post effects:
Exponential shadow maps:
4 weight GPU skinning.
UV animation.
Wireframe mode.
Callbacks for additional passes: decals, transparency, debug
Default Renderer
Simple Renderer
2D Rendering
Draw2D
2D sprite-based renderer: Batches sprites for efficiency.
Draw modes:
Scalable viewport: Input coordinate mapping.
Sort modes: Immediate, Deferred, Texture.
Blend modes: Opaque, Additive, Alpha.
Custom shader support.
Render-to-target support.
Texture effects: Distort, Gaussian Blur, Bloom, Color, Grey Scale, Sepia, Negative, Saturation, Hue, Brightness, Contrast.
Recording performance data.
Canvas2D
canvas 2D API <http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/>
__.canvas element specification <http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#the-canvas-element>
__Utilities
Allocation and management of graphics buffers: Vertex buffers, Index buffers.
API controlled JavaScript profiling:
Memory usage identification:
Encryption and decryption of server-side requests for TZO formats.
Debug utility with function stripping for performance:
Network Simulator:
Leaderboards
Badges
Payments
Userdata
Userprofile
Gameprofile
Game status of a player:
Multiplayer
Datashares
Notifications
Metrics
Custom event submission:
Bridge
Utilities
The main design goals of the Turbulenz Engine are performance, modularity and customizability. Users of the engine should be able to build any kind of game without limitations, in an efficient manner and with an end product that performs optimally when loading and during play.
To achieve this target the Turbulenz team followed these rules when writing code:
Modularity
High performance
Asynchronous loading
Data driven
Simple well documented file formats
Scalability
Power without control is nothing
Fault tolerant
Fast loading
Maintainability
Targeted
The Engine was created and is maintained by Turbulenz Limited <http://biz.turbulenz.com>
__ and was open sourced
in April 2013.
The latest release is 1.3.2 which is tagged in the repository or a tarball/zip can be can be downloaded from
here <https://github.com/turbulenz/turbulenz_engine/archive/release_1.3.2.tar.gz>
__
A full history of changes can be found in the Changelog <docs/source/changelog.rst>
__
The pre-requisites for the open source version of the Turbulenz Engine allowing you to use the various commands are
Python 2.7.x.
python2.7
On Windows if you didn't add Python to your path in the installer you may need to run C:\Python27\python.exe
You can check your version with
::
$ python --version Python 2.7.3
VirtualEnv - version 1.9.1 or higher recommended You can check your version with ::
$ virtualenv --version
1.9.1
UglifyJS, turbulenz_build, DefinitelyTyped and NvTriStrip which are included via Git submodules contained within the Turbulenz Engine repository.
Additional Python packages which will be automatically installed during the initial environment creation using a Python package manager.
Pre-requisites for building the tools cgfx2json and NvTriStrip via python manage.py tools
Compiler Toolchain
Windows : Any one of
Microsoft Visual Studio 2008 with SP1
Microsoft Visual Studio 2010
Visual C++ 2010 Express
Microsoft Visual Studio 2012 with update 2
Microsoft Visual Studio Express 2012 for Windows Desktop with update 2
Mac OSX : Xcode with the command line tools
Linux : GCC 4.6.x or higher
NVIDIA CgToolkit <https://developer.nvidia.com/cg-toolkit>
__ version 3.1 or higher. The repository
includes the binaries for Windows, if you're developing on Mac OSX or Linux please download and install it.
OpenGL development libraries, these are included on Windows and Mac OSX with the compiler toolchains. For
debian based linux distributions the libgl1-mesa-dev package will provide the required files (e.g. sudo apt-get install libgl1-mesa-dev
), for other linux distributions find the package supplying GL/gl.h and libGL.so
There are two ways to get up and running with the Turbulenz Engine, you can downloaded a packaged fully QA'd
snapshot release from the Turbulenz Hub <https://hub.turbulenz.com>
. These installers are available for
Windows, Mac OSX and Linux and will install all the required packages and dependencies to get started,
a full guide can be found at <http://docs.turbulenz.com/installing.html>
Note: SDK versions prior to 0.26.0 were released under a non open source license.
If you want to run with the latest version or would like to contribute to the open source project the steps for getting setup are included below. Use of the open source repository is tested against Windows, Mac OSX and Linux but may also work on other unix-like operating systems.
Clone the repository <http://github.com/turbulenz/turbulenz_engine>
__ (or if you wish you can fork the repository
on GitHub and clone that). To clone the repository maintained by Turbulenz use
::
$ git clone git://github.com/turbulenz/turbulenz_engine.git
The Turbulenz Engine submodules the following technology in the external folder
Initialize the Git submodules with ::
$ git submodule update --init
Check you have the pre-requisites
_ installed
From the cloned repository create a VirtualEnv environment to install the required Python packages and NodeJS, allowing you to use all the features of the Turbulenz Engine. Note if Python is not on your shell's path you will need to specify the full path for this first command. ::
$ python manage.py env
Activate the environment in your shell. ::
$ source env/bin/activate - for bash and similar shells
> env\scripts\activate.bat - for Windows
If you want to move onto the API tutorial section next then your final command is to build the JavaScript sources
from the TypeScript sources. The next section will detail some of the additional actions you can perform or you
can move onto Getting Started With The API
_
::
$ python manage.py jslib
The manage.py script at the top level of the repository provides a set of commands for managing the Engine, the
script should be run as python manage.py command
on Windows but can usually be shortcut to ./manage.py command
on unix shells. Running the script with --help
will give a list of commands available, most of these are
described below. All the commands other than the env command expect to have the VirtualEnv environment activated
as described in the setup section.
JavaScript Sources - The Turbulenz Engine source is written in TypeScript. To generate the JavaScript version of the engine source run the command ::
$ python manage.py jslib
Tools - The Turbulenz Engine includes a number of Python tools which are installed during the env command.
In addition the Engine includes a CGFX shader conversion tool which can be built with the following command.
See the pre-requisites
_ section for details of required compiler toolchains.
::
$ python manage.py tools
Documentation - The Turbulenz Engine documentation is based on restructured text sources. To build the html documentation run the command ::
$ python manage.py docs
Samples - Various samples are included with the Turbulenz Engine. These can be built from their TypeScript sources with the command below. This generates a set of html files, JavaScript and asset JSON files which can be served with a web server such as the Turbulenz Local Development Server. ::
$ python manage.py samples
Applications - The Turbulenz Engine project includes a few larger applications and some templates for building your own application. These can be found in the apps folder, and can be built with the command ::
$ python manage.py apps
You can also build individual apps by specifying their name e.g. ::
$ python manage.py apps multiworm
Command Line Tools - Various command line tools for processing code and assets are installed as part of the
virtual environment. These are available at the command line e.g. running dae2json
will execute the dae2json
tool used to convert Collada assets to a Turbulenz Engine JSON asset format. See the
tools <http://docs.turbulenz.com/tools/index.html>
__ section in the documentation for more details on the tools.
Local Development Server - Setting up the environment also includes a locally hosted web server which can be
used for development of HTML5 games and applications. See the
Local Server <https://github.com/turbulenz/turbulenz_local>
__ repository for more details.
To try the Turbulenz APIs requires only a text editor and a browser such as Google Chrome or Mozilla Firefox. Create an HTML file with the following content and place it in the root of the Turbulenz directory::
<html>
<head>
<title>Turbulenz - API - Clear Screen Example</title>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/debug.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/turbulenzengine.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/graphicsdevice.js"></script>
</head>
<body>
<canvas id="canvas" width="640px" height="480px"/>
<script>
TurbulenzEngine = WebGLTurbulenzEngine.create({
canvas: document.getElementById("canvas")
});
var graphicsDevice = TurbulenzEngine.createGraphicsDevice({});
var bgColor = [1.0, 1.0, 0.0, 1.0];
function update() {
if (graphicsDevice.beginFrame()) {
graphicsDevice.clear(bgColor, 1.0);
graphicsDevice.endFrame();
}
}
TurbulenzEngine.setInterval(update, 1000 / 60);
</script>
</body>
</html>
After defining a
To use assets such as images you will need to host a HTML file and assets on a webserver. Any webserver will work, a quick way to try is to activate the Turbulenz environment in the root of the Turbulenz directory and run::
python -m SimpleHTTPServer
This command will host the contents of the Turbulenz directory on your machine as a webserver.
To demonstrate loading an asset you can try loading an image file and drawing it as a textured sprite using the Draw2D API. Create another HTML file with the following content and also place it in the root of the Turbulenz directory::
<html>
<head>
<title>Turbulenz - API - Textured Sprite Example</title>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/debug.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/turbulenzengine.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/graphicsdevice.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/draw2d.js"></script>
</head>
<body>
<canvas id="canvas" width="640px" height="480px"/>
<script>
TurbulenzEngine = WebGLTurbulenzEngine.create({
canvas: document.getElementById("canvas")
});
var graphicsDevice = TurbulenzEngine.createGraphicsDevice({});
var draw2D = Draw2D.create({
graphicsDevice: graphicsDevice
});
var bgColor = [1.0, 1.0, 0.0, 1.0];
var sprite = Draw2DSprite.create({
width: 100,
height: 100,
x: graphicsDevice.width / 2,
y: graphicsDevice.height / 2,
color: [1.0, 1.0, 1.0, 1.0],
rotation: Math.PI / 4
});
var texture = graphicsDevice.createTexture({
src: "assets/textures/crate.jpg",
mipmaps: true,
onload: function (texture)
{
if (texture)
{
sprite.setTexture(texture);
sprite.setTextureRectangle([0, 0, texture.width, texture.height]);
}
}
});
var PI2 = Math.PI * 2;
var rotateAngle = PI2 / 360; // 1 deg per frame
function update() {
sprite.rotation += rotateAngle;
sprite.rotation %= PI2; // Wrap rotation at PI * 2
if (graphicsDevice.beginFrame()) {
graphicsDevice.clear(bgColor, 1.0);
draw2D.begin();
draw2D.drawSprite(sprite);
draw2D.end();
graphicsDevice.endFrame();
}
}
TurbulenzEngine.setInterval(update, 1000 / 60);
</script>
</body>
</html>
This time, instead of opening the file in the browser, navigate your browser to http://127.0.0.1:8000 or http://localhost:8000 and select the HTML file you created. You should see a spinning textured box in the middle of a yellow rectangle.
The next step is render a simple textured mesh in 3D. To do this you will need to build some assets from their source files. Make sure you have run the tools command to build the tools for your platform::
$ python manage.py tools
Note: The requirements for building the tools is different per platform. See the Pre-Requisites
_ section.
For this example you should use the Protolib <http://docs.turbulenz.com/protolib/protolib_api.html>
__ library, which is ideal for prototyping games using Turbulenz.
You will need these assets::
- models/duck.dae
- textures/duck.png
- textures/default_light.png
- shaders/shadowmapping.cgfx
- shaders/zonly.cgfx
- shaders/forwardrendering.cgfx
- shaders/forwardrenderingshadows.cgfx
- shaders/debug.cgfx
- shaders/font.cgfx
- shaders/simplesprite.cgfx
- fonts/opensans-8.fnt
- fonts/opensans-16.fnt
- fonts/opensans-32.fnt
- fonts/opensans-64.fnt
- fonts/opensans-128.fnt
- textures/opensans-8_0.png
- textures/opensans-16_0.png
- textures/opensans-32_0.png
- textures/opensans-64_0.png
- textures/opensans-128_0.png
Copy this text into a file called "deps.yaml" and place it in the root of the Turbulenz directory. Having built the tools you can now run this command with the Turbulenz environment activated::
$ python scripts/buildassets.py --root . --assets-path assets
This will build the assets listed in the deps.yaml and output a "staticmax" directory and "mapping_table.json" file containing the processed assets and a mapping to them for the webserver. When a library tries to request one of these files, it will be able to find it in the staticmax directory. Now you can create the mesh example HTML file and place it at the root of the Turbulenz directory::
<html>
<head>
<title>Turbulenz - API - Textured Mesh Example</title>
<script>
var TurbulenzEngine = {};
</script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/debug.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/vmath.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/turbulenzengine.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/graphicsdevice.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/inputdevice.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/sounddevice.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/webgl/mathdevice.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/aabbtree.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/assettracker.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/camera.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/draw2d.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/effectmanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/fontmanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/forwardrendering.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/geometry.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/indexbuffermanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/light.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/loadingscreen.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/material.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/observer.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/renderingcommon.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/requesthandler.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/resourceloader.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/scene.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/scenenode.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/shadermanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/shadowmapping.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/soundmanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/texturemanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/utilities.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/vertexbuffermanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/services/turbulenzbridge.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/services/turbulenzservices.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/services/gamesession.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/jslib/services/mappingtable.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/duimanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/jqueryextend.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/simplesprite.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/simplefonts.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/simplesceneloader.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/debugdraw.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/sceneloader.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/soundsourcemanager.js"></script>
<script src="https://github.com/turbulenz/turbulenz_engine/raw/master/protolib/protolib.js"></script>
</head>
<body>
<canvas id="canvas" width="640px" height="480px"/>
<script>
TurbulenzEngine = WebGLTurbulenzEngine.create({
canvas: document.getElementById("canvas")
});
var mathDevice = null;
var mesh = null;
var rotationMatrix = null;
var rotationAngleMatrix = null;
var protolib = Protolib.create({
onInitialized: function onIntializedFn(protolib)
{
mathDevice = protolib.getMathDevice();
protolib.setCameraPosition(mathDevice.v3Build(0, 1, -2));
protolib.setCameraDirection(mathDevice.v3Build(0, 0, 1));
protolib.setAmbientLightColor(mathDevice.v3Build(1, 1, 1));
protolib.addPointLight({
v3Position: mathDevice.v3Build(-1, 1, -1),
v3Color: mathDevice.v3Build(1, 1, 1),
radius: 10
});
mesh = protolib.loadMesh({
mesh: "models/duck.dae"
});
rotationMatrix = mathDevice.m43BuildIdentity();
rotationAngleMatrix = mathDevice.m43BuildIdentity();
mathDevice.m43SetAxisRotation(rotationAngleMatrix,
mathDevice.v3Build(0, 1, 0),
(Math.PI * 2) / 360);
}
})
function update() {
if (protolib.beginFrame())
{
if (mesh)
{
mesh.getRotationMatrix(rotationMatrix);
mathDevice.m43Mul(rotationMatrix, rotationAngleMatrix, rotationMatrix);
mesh.setRotationMatrix(rotationMatrix);
}
protolib.endFrame();
}
}
TurbulenzEngine.setInterval(update, 1000 / 60);
</script>
</body>
</html>
This file is quite similar to the previous examples, but it requires a few more Turbulenz libraries to run. This time you should see a spinning duck with a yellow texture on a white background and lit by a static point light.
For more information on how to build your own assets see the assets section <http://docs.turbulenz.com/starter/getting_started_guide.html#assets>
__ in the getting started guide.
If you would like to learn more or work through this example step-by-step (with troubleshooting hints), see the Getting Started Guide <http://docs.turbulenz.com/starter/getting_started_guide.html>
__ in the documentation.
For more information on the various APIs, see the following links:
Low-level API <http://docs.turbulenz.com/jslibrary_api/low_level_api.html>
, 2D Physics API <http://docs.turbulenz.com/jslibrary_api/physics2d_api.html>
, 3D Physics API <http://docs.turbulenz.com/jslibrary_api/physics3d_api.html>
__High-level API <http://docs.turbulenz.com/jslibrary_api/high_level_api.html>
__Turbulenz Services API <http://docs.turbulenz.com/turbulenz_services/index.html>
__Protolib API <http://docs.turbulenz.com/protolib/protolib_api.html>
__Full documentation for the Turbulenz Engine can be found at <http://docs.turbulenz.com/index.html>
__
This documentation is built from the source restructured text in the docs/source folder of the repository, the latest
version online is maintained from the latest release tag in the repository. If you wish to build up to date
documentation follow the setup guide and the run the manage.py docs
command, this will generate html docs in the
build/docs/html folder.
The following known issues exist with using the open source repository version of the Turbulenz Engine,
additional known issues also existing in the SDK releases of the engine can be found here
<http://docs.turbulenz.com/known_issues/index.html>
__
The Turbulenz Engine is licensed under the MIT license <LICENSE>
__
Our contributors are listed here <docs/source/contributors.rst>
__
Contributions are always encouraged whether they are small documentation tweaks, bug fixes or suggestions for larger
changes. You can check the issues <http://github.com/turbulenz/turbulenz_engine/issues>
_ or discussion forums <https://groups.google.com/group/turbulenz-engine-users>
first to see if anybody else is undertaking similar changes.
If you'd like to contribute any changes simply fork the project on Github and send us a pull request or send a Git patch to the discussion forums detailing the proposed changes. If accepted we'll add you to the list of contributors.
We include a .pylintrc file in the repository which allows you to check your code conforms to our standards. Our documentation is built from restructured text sources in the docs folder so please consider how your changes may affect the documentation.
Note: by contributing code to the Turbulenz Engine project in any form, including sending a pull request via Github,
a code fragment or patch via private email or public discussion groups, you agree to release your code under the
terms of the MIT license that you can find in the LICENSE <LICENSE>
__ file included in the source distribution.
| Turbulenz game site - turbulenz.com <https://turbulenz.com>
| Turbulenz developer service and SDK download - hub.turbulenz.com <https://hub.turbulenz.com>
| Documentation for this module and the SDK - docs.turbulenz.com <http://docs.turbulenz.com>
| About Turbulenz - biz.turbulenz.com <http://biz.turbulenz.com>