Permalink
Browse files

better lighting

  • Loading branch information...
1 parent 6433f39 commit a90959378e5a74b7c9d65944443da5bd8472feec @jeromeetienne committed Feb 26, 2013
View
BIN plugins/pacman/examples/images/lensflare0_alpha.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
103 plugins/pacman/examples/pacmaze.html
@@ -11,11 +11,6 @@
], function(){
var world = tQuery.createWorld().boilerplate().start();
- // put some lights
- tQuery.createAmbientLight().addTo(world)
- .color(0x444444)
- tQuery.createDirectionalLight().addTo(world)
- .position(1,1,1)
// add pacman
var playerContainer = tQuery.createObject3D().addTo(world)
@@ -29,9 +24,31 @@
world.tRenderer().setClearColorHex( 0x000000, 1 );
+ // put some lights
+ // tQuery.createAmbientLight().addTo(world)
+ // .color(0x444444)
+ tQuery.createDirectionalLight().addTo(world)
+ .position(1,0.5,0)
+ .color(0xff8866)
+ .intensity(2)
+ tQuery.createDirectionalLight().addTo(world)
+ .position(-1,0,0)
+ .color(0x4444aa)
+ .intensity(0.5)
+
+// .intensity(0.1)
+ tQuery.createPointLight().addTo(playerContainer)
+ .color(0x88CC88)
+ .distance(6)
+ .positionY(2)
+// .intensity(2)
+
// add the fog
//world.addFogExp2({density: 0.1});
+ // add a skymap
+ tQuery.createSkymap('skybox').addTo(world);
+
world.removeCameraControls();
@@ -52,6 +69,11 @@
mount3D.get(0).lookAt(tQuery.createVector3())
cameraMounts.push(mount3D)
+ var mount3D = tQuery.createObject3D().addTo(playerContainer)
+ .position(tQuery.createVector3(0, 3, 5).setLength(4))
+ mount3D.get(0).lookAt(tQuery.createVector3(0, 0.5, -1))
+ cameraMounts.push(mount3D)
+
var mount3D = tQuery.createObject3D().addTo(pacman)
.position(tQuery.createVector3(0, 1.5, -3).setLength(3))
mount3D.get(0).lookAt(tQuery.createVector3(0, 0.5, 2))
@@ -62,42 +84,19 @@
mount3D.get(0).lookAt(tQuery.createVector3(0, 0.5, 0))
cameraMounts.push(mount3D)
- cameraContainer.addTo(cameraMounts[3])
-
- // var controls = tQuery.createControlsTween({
- // source : cameraContainer,
- // target : cameraContainer,
- // positionTween : function(source, target, deltaSecond){
- // var damping = 3 * deltaSecond;
- // return target.clone().sub(source).multiplyScalar(damping)
- // },
- // rotationTween : function(source, target, deltaSecond){
- // var damping = 3 * deltaSecond;
- // return target.clone().sub(source).multiplyScalar(damping)
- // },
- // }).start();
- world.loop().hook(function(){
+ var mountIdx = 2;
+ cameraContainer.addTo(cameraMounts[mountIdx])
+ tQuery.keyboard().domElement().addEventListener('keydown', function(){
+ var nMounts = cameraMounts.length;
var keyboard = tQuery.keyboard();
- if( keyboard.pressed('1') ){
- cameraContainer.addTo(cameraMounts[0])
- //controls.target( cameraMounts[0] )
- }else if( keyboard.pressed('2') ){
- cameraContainer.addTo(cameraMounts[1])
- //controls.target( cameraMounts[1] )
- }else if( keyboard.pressed('3') ){
- cameraContainer.addTo(cameraMounts[2])
- //controls.target( cameraMounts[2] )
- }else if( keyboard.pressed('4') ){
- cameraContainer.addTo(cameraMounts[3])
- //controls.target( cameraMounts[2] )
- }
- })
-
+ if( keyboard.pressed('1') ) mountIdx += -1;
+ if( keyboard.pressed('2') ) mountIdx += +1;
+ mountIdx = (mountIdx + nMounts) % nMounts;
+ var mount = cameraMounts[mountIdx];
+ cameraContainer.addTo(mount)
+ });
- // add a skymap
- //tQuery.createSkymap('mars').addTo(world);
-
var maze = tQuery.createSimpleMaze({
map : [
'*******************',
@@ -146,23 +145,35 @@
})
- var texture = THREE.ImageUtils.loadTexture('images/BluePaintedTiles.png')
+ //var texture = THREE.ImageUtils.loadTexture('images/BluePaintedTiles.png')
+ var texture = THREE.ImageUtils.loadTexture('../../assets/images/wood.jpg')
+ //var texture = THREE.ImageUtils.loadTexture('../../assets/images/plywood.jpg')
+ //var texture = THREE.ImageUtils.loadTexture('../../assets/images/water.jpg')
tQuery('.wall', maze3D).elevateType()
.scaleYBy(0.4)
- .setPhongMaterial()
+ .setPhongMaterial()
.map(texture)
+ .envMap(tQuery.createCubeTexture('mars'))
+ .reflectivity(0.4)
.bumpMap(texture)
.bumpScale(0.02)
.back()
- var texture = THREE.ImageUtils.loadTexture('images/PaddedOrangeWall.png')
+// var texture = THREE.ImageUtils.loadTexture('images/PaddedOrangeWall.png')
+ var texture = THREE.ImageUtils.loadTexture('../../assets/images/water.jpg')
+// var texture = THREE.ImageUtils.loadTexture('../../assets/images/plywood.jpg')
+// var texture = THREE.ImageUtils.loadTexture('../../assets/images/rocks.jpg')
+// var texture = THREE.ImageUtils.loadTexture('../../assets/images/wood.jpg')
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
- texture.repeat.set(maze.mapWidth(), maze.mapDepth());
+ texture.repeat.set(maze.mapWidth()/8, maze.mapDepth()/8);
+// texture.repeat.set(maze.mapWidth(), maze.mapDepth());
tQuery('.ground', maze3D).elevateType()
.setPhongMaterial()
.map(texture)
+ .envMap(tQuery.createCubeTexture('mars'))
+ .reflectivity(0.6)
.bumpMap(texture)
.bumpScale(0.05)
.back()
@@ -188,16 +199,20 @@
.color(0xffff00)
.envMap(tQuery.createCubeTexture('swedishRoyalCastle'))
.bumpMap('../../assets/images/water.jpg')
- .bumpScale(0.01)
+ .bumpScale(0.005)
maze.forEach(function(tileX, tileZ, value){
if( value !== 'p'.charCodeAt(0) ) return;
- tQuery.createSphere().addTo(world)
+ var object3D = tQuery.createSphere().addTo(world)
.addClass('energyPill')
.material(material)
.scaleBy(1/3)
.translateY(0.5)
.positionX(tileX + 0.5 - maze.mapWidth()/2)
.positionZ(tileZ + 0.5 - maze.mapDepth()/2)
+ world.loop().hook(function(delta, now){
+ var angle = 0.5 * delta * Math.PI * 2;
+ object3D.rotateY(angle)
+ })
})
// very minimal controls

0 comments on commit a909593

Please sign in to comment.