Examples

In this section you will find some examples that demonstrate how to use THREE.BasicThirdPersonGame. If you have downloaded the package from GitHub you will find the following structure inside the root folder:

js/
	game/
		...
		game.core.js
		game.core.demo1.js
		game.core.demo2.js
		game.core.demo3.js
		game.core.demo4.js
		game.core.demo5.js
		...
	libs/

demo1_simple.html
demo2_movable_rigid_bodies.html
demo3_fixed_camera_angle.html
demo4_aync_models.html
demo5_shadows.html

So for each demo there is a separate HTML file and a corresponding game.core.demoX.js. All demos access the same module files like game.three.js or game.cannon.js and they only differ in their _game.level.create functions and partly some other areas.

Demo 1 - Simple demo

A simple example with basic controls. You can control the player with the keys W, A, S, D and SPACE. There are some boxes you can jump on and a simple game over logic when falling beneath the ground floor. There's also a simple user interface element that demonstrates how to include a GUI.

Open demo

Demo 2 - Movable rigid body boxes

An example that demonstrates rigid bodies that can be pushed away by the player. It's based on demo 1 and only changes the _game.level.create method.

Open demo

Demo 3 - Fixed camera angle

An example of having a semi-fixed camera that uses a fixed angle. It's based on demo 2.

Open demo

Demo 4 - Asynchronous model loading

An example that implements asynchronous JSON model loading. It's based on demo 2.

Open demo

Demo 5 - Shadows

An example that implements THREE.js shadows based on a spot light. It's based on demo 1.

Open demo