Permalink
Browse files

Adding a bigger map and misc tweaks to make it feel more game-like.

  • Loading branch information...
1 parent 8f48518 commit e55044e42710dd95b4f60f9e541217239be28efb Jay Phillips committed Apr 4, 2012
View
12 README.md
@@ -1,17 +1,15 @@
-This is a basic demo showing how to integrate a [ThreeJS](https://github.com/mrdoob/three.js/) WebGL scene loaded from a [Collada](http://en.wikipedia.org/wiki/COLLADA) (.dae) file with the [Ammo.js](https://github.com/kripken/ammo.js) physics engine. The physics engine is used for collision detection and falling physics. The goal of this project is to create an efficient first-person 3D environment the user can walk around in.
-
-There is also a branch showing how to do this with [jiglibjs2](https://github.com/bartdeboer/JigLibJS2) [here](https://github.com/jicksta/threejs-collada-physics/tree/jiglibjs2) and one using [Physijs](https://github.com/chandlerprall/Physijs) located [here](https://github.com/jicksta/threejs-collada-physics/tree/physijs). At the moment the Physijs branch has no-clipping player movement.
+This is a basic game engine showing how to integrate a [ThreeJS](https://github.com/mrdoob/three.js/) WebGL scene loaded from a [Collada](http://en.wikipedia.org/wiki/COLLADA) (.dae) file. The environment has robust collision detection and physics thanks to the [Ammo.js](https://github.com/kripken/ammo.js) physics engine, a port of the C++ Bullet engine. The goal of this project is to create an efficient late-90s era first-person 3D game engine the user can walk around in.
Don't forget to do `git submodule update --init` to initialize the submodule if you clone this branch.
-The Collada files were exported from Google Sketchup. The original .skp files are located in `models/sketchup`. Note: At
-the moment this importer does not support .dae files exported from a Sketchup document that has groups. You must explode
+The Collada files were exported from Google SketchUp. The original .skp files are located in `models/sketchup`. Note: At
+the moment this importer does not support .dae files exported from a SketchUp document that has groups. You must explode
your groups before exporting.
The COLLADA meshes are loaded into the physics engine by iterating over every face in the COLLADA document and creating a non-movable triangular mesh rigid body. The standard `THREE.ColladaLoader` parses the COLLADA XML, although it should be noted that it does not fully support all of COLLADA's features yet.
-![building.skp Sketchup file](https://img.skitch.com/20120330-84191a9e41kdqkjufymwupb8xs.png)
-![building.dae in WebGL](https://img.skitch.com/20120330-dr71et6cedhpb11e9akbrdhify.png)
+![Map from SketchUp file](https://img.skitch.com/20120404-eprjfyk87jfdpjj1kem2rqtqwp.png)
+![Map rendered with WebGL](https://img.skitch.com/20120404-kw2pb5p99578e4hqa1nq294uga.png)
All files excluding those in the `lib/` directory are licensed under the MIT License.
View
18 game.js
@@ -42,7 +42,7 @@ var VIEW_WIDTH = document.body.clientWidth,
var domElement = document.getElementById("container");
var clock = new THREE.Clock;
-var scene = new THREE.Scene;
+var scene = createScene();
var stats = createStats();
var camera = createCamera();
@@ -55,7 +55,7 @@ setupControls();
var renderer = createRenderer();
-loadCollada("models/building.dae", 0.002, function() {
+loadCollada("models/bigmap.dae", 4, function() {
physics.update(viewState());
});
@@ -67,9 +67,15 @@ function render() {
stats.update();
}
+function createScene() {
+ var scene = new THREE.Scene;
+ scene.fog = new THREE.FogExp2(0xaaaaaa, 0.00055);
+ return scene;
+}
+
function createCamera() {
var camera = new THREE.PerspectiveCamera(camera, VIEW_WIDTH / VIEW_HEIGHT, 0.1, 20000);
- camera.position.set(-10, 1, 0);
+ camera.position.set(0, 1, 0);
scene.add(camera);
return camera;
}
@@ -79,8 +85,8 @@ function setupPhysics(fn) {
}
function setupLighting() {
- var ambientLight = new THREE.PointLight(0xFFFFFF, 1, 75);
- ambientLight.position.y = 7;
+ var ambientLight = new THREE.PointLight(0xFFFFFF, 1, 25000);
+ ambientLight.position.y = 5;
scene.add(ambientLight);
}
@@ -159,7 +165,7 @@ function viewState() {
} else if (left) {
camera.rotation.y += 0.07;
} else if (forward || backward) {
- var movementSpeeds = forward ? -8 : 6;
+ var movementSpeeds = forward ? -12 : 10;
var cameraRotation = new THREE.Matrix4().extractRotation(camera.matrixWorld);
var velocityVector = new THREE.Vector3(0, 0, movementSpeeds);
cameraRotation.multiplyVector3(velocityVector);
View
644 models/bigmap.dae
644 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN models/bigmap/Concrete_Stamped_Ashlar_.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN models/bigmap/Vegetation_HoneyLocust_.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN models/sketchup/bigmap.skp
Binary file not shown.
View
336 models/terrain-building.dae
336 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 physics.js
@@ -26,7 +26,7 @@ var AmmoWorker = {
var agentMass = 100;
var startTransform = new Ammo.btTransform();
startTransform.setIdentity();
- startTransform.setOrigin(new Ammo.btVector3(0, 10, 0)); // Set initial position
+ startTransform.setOrigin(new Ammo.btVector3(0, 20, 0)); // Set initial position
var localInertia = new Ammo.btVector3(0, 0, 0);

0 comments on commit e55044e

Please sign in to comment.