Permalink
Browse files

more work

  • Loading branch information...
1 parent 3dbc462 commit 5edfa71f297a349d12e3e7adeb88cba1c52bb1ac @jeromeetienne committed Feb 26, 2013
@@ -38411,7 +38411,6 @@ tQuery.Sprite.prototype.material = function(value){
console.assert( value instanceof THREE.SpriteMaterial )
// handle the setter case
this.each(function(tSprite){
-console.log('set material for', tSprite, value)
tSprite.material = value;
});
return this; // for the chained API
@@ -39463,6 +39462,9 @@ tQuery.mixinAttributes(tQuery.MeshPhongMaterial, {
specular : tQuery.convert.toThreeColor,
shininess : tQuery.convert.toNumber,
+
+ envMap : tQuery.convert.toTexture,
+ refractionRatio : tQuery.convert.toNumber,
bumpMap : tQuery.convert.toTexture,
bumpScale : tQuery.convert.toNumber,
@@ -39531,6 +39533,8 @@ tQuery.mixinAttributes(tQuery.SpriteMaterial, {
depthTest : tQuery.convert.toBoolean,
sizeAttenuation : tQuery.convert.toBoolean,
scaleByViewport : tQuery.convert.toBoolean,
+
+ fog : tQuery.convert.toBoolean,
});
@@ -40487,7 +40491,7 @@ requirejs.config({
"tquery.cannonjs": "plugins/cannonjs/tquery.object3d.cannonjs",
"tquery.car": "plugins/requirejs/confrequire/car.initrequire",
"tquery.checkerboard": "plugins/checkerboard/tquery.checkerboard",
- "tquery.controls": "plugins/controls/tquery.controlswrapper",
+ "tquery.controls": "plugins/controls/tquery.controlstween",
"tquery.csg": "plugins/csg/tquery.geometry.csg",
"tquery.datguituner": "plugins/datguituner/tquery.datguituner",
"tquery.deviceorientation": "plugins/deviceorientation/tquery.deviceorientation",
@@ -40508,6 +40512,7 @@ requirejs.config({
"tquery.minecraft": "plugins/requirejs/confrequire/minecraft.initrequire",
"tquery.modifiers": "plugins/modifiers/tquery.geometry.smooth",
"tquery.montainarena": "plugins/montainarena/tquery.montainarena",
+ "tquery.objectcoord": "plugins/objectcoord/tquery.object3d.coordinate",
"tquery.physics": "plugins/physics/tquery.physijs",
"tquery.planets": "plugins/requirejs/confrequire/planets.initrequire",
"tquery.poolball": "plugins/poolball/tquery.poolball",
@@ -40547,7 +40552,8 @@ requirejs.config({
"plugins/car/tquery.car.keyboard": [
"plugins/car/tquery.car"
],
- "plugins/controls/tquery.controlswrapper": [
+ "plugins/controls/tquery.controlstween": [
+ "plugins/controls/tquery.controlswrapper",
"three.js/controls/FirstPersonControls",
"three.js/controls/OrbitControls",
"three.js/controls/PointerLockControls",
View
@@ -38411,7 +38411,6 @@ tQuery.Sprite.prototype.material = function(value){
console.assert( value instanceof THREE.SpriteMaterial )
// handle the setter case
this.each(function(tSprite){
-console.log('set material for', tSprite, value)
tSprite.material = value;
});
return this; // for the chained API
@@ -39463,6 +39462,9 @@ tQuery.mixinAttributes(tQuery.MeshPhongMaterial, {
specular : tQuery.convert.toThreeColor,
shininess : tQuery.convert.toNumber,
+
+ envMap : tQuery.convert.toTexture,
+ refractionRatio : tQuery.convert.toNumber,
bumpMap : tQuery.convert.toTexture,
bumpScale : tQuery.convert.toNumber,
@@ -39531,6 +39533,8 @@ tQuery.mixinAttributes(tQuery.SpriteMaterial, {
depthTest : tQuery.convert.toBoolean,
sizeAttenuation : tQuery.convert.toBoolean,
scaleByViewport : tQuery.convert.toBoolean,
+
+ fog : tQuery.convert.toBoolean,
});
View
@@ -1185,7 +1185,6 @@ tQuery.Sprite.prototype.material = function(value){
console.assert( value instanceof THREE.SpriteMaterial )
// handle the setter case
this.each(function(tSprite){
-console.log('set material for', tSprite, value)
tSprite.material = value;
});
return this; // for the chained API
@@ -2237,6 +2236,9 @@ tQuery.mixinAttributes(tQuery.MeshPhongMaterial, {
specular : tQuery.convert.toThreeColor,
shininess : tQuery.convert.toNumber,
+
+ envMap : tQuery.convert.toTexture,
+ refractionRatio : tQuery.convert.toNumber,
bumpMap : tQuery.convert.toTexture,
bumpScale : tQuery.convert.toNumber,
@@ -2305,6 +2307,8 @@ tQuery.mixinAttributes(tQuery.SpriteMaterial, {
depthTest : tQuery.convert.toBoolean,
sizeAttenuation : tQuery.convert.toBoolean,
scaleByViewport : tQuery.convert.toBoolean,
+
+ fog : tQuery.convert.toBoolean,
});
@@ -55,6 +55,9 @@ tQuery.mixinAttributes(tQuery.MeshPhongMaterial, {
specular : tQuery.convert.toThreeColor,
shininess : tQuery.convert.toNumber,
+
+ envMap : tQuery.convert.toTexture,
+ refractionRatio : tQuery.convert.toNumber,
bumpMap : tQuery.convert.toTexture,
bumpScale : tQuery.convert.toNumber,
@@ -57,6 +57,8 @@ tQuery.mixinAttributes(tQuery.SpriteMaterial, {
depthTest : tQuery.convert.toBoolean,
sizeAttenuation : tQuery.convert.toBoolean,
scaleByViewport : tQuery.convert.toBoolean,
+
+ fog : tQuery.convert.toBoolean,
});
View
@@ -55,7 +55,6 @@ tQuery.Sprite.prototype.material = function(value){
console.assert( value instanceof THREE.SpriteMaterial )
// handle the setter case
this.each(function(tSprite){
-console.log('set material for', tSprite, value)
tSprite.material = value;
});
return this; // for the chained API
@@ -6,6 +6,8 @@
, 'tquery.simplemaze'
, 'tquery.controls'
, 'tquery.keyboard'
+ , 'tquery.fog'
+ , 'tquery.controls'
], function(){
var world = tQuery.createWorld().boilerplate().start();
@@ -16,64 +18,218 @@
.position(1,1,1)
// add pacman
- var pacman = tQuery.Pacman.create().addTo(world)
- .translateX(-1.5)
+ var playerContainer = tQuery.createObject3D().addTo(world)
+ var pacman = tQuery.Pacman.create().addTo(playerContainer)
world.loop().hook(function(delta, now){
pacman.rotateY(0.02)
})
+
+ tQuery.Pacman.create('eyes').addTo(world)
+ .translateZ(-3)
+
+ world.tRenderer().setClearColorHex( 0x000000, 1 );
+
+ // add the fog
+ //world.addFogExp2({density: 0.1});
+
+
+
+ world.removeCameraControls();
+
+ var cameraContainer = tQuery.createObject3D().addTo(world)
+ tQuery(world.tCamera()).addTo(cameraContainer)
+ .position(0,0,0).rotation(0,Math.PI,0)
+
+ var cameraMounts= [];
+
+ var mount3D = tQuery.createObject3D().addTo(playerContainer)
+ .position(tQuery.createVector3(0, 3, 1).setLength(30))
+ mount3D.get(0).lookAt(tQuery.createVector3())
+ cameraMounts.push(mount3D)
+
+ var mount3D = tQuery.createObject3D().addTo(playerContainer)
+ .position(tQuery.createVector3(0, 3, 3).setLength(6))
+ mount3D.get(0).lookAt(tQuery.createVector3())
+ 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))
+ 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, 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 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] )
+ }
+ })
- // world.removeCameraControls();
- // tQuery(world.tCamera()).addTo(pacman).positionY(1.5)
- // world.tCamera().lookAt(tQuery.createVector3())
- world.loop().hook(function(delta, now){
- var camera = tQuery(world.tCamera())
- if( camera.positionY() < 3.5 ) camera.positionY(3.5)
- });
// add a skymap
- tQuery.createSkymap('mars').addTo(world);
+ //tQuery.createSkymap('mars').addTo(world);
var maze = tQuery.createSimpleMaze({
map : [
- '*********',
- '* * *',
- '* ** ***',
- '* *',
- '*** *',
- '* *',
- '*********'
+'*******************',
+'* * *',
+'* ** *** * *** ** *',
+'* ** *** * *** ** *',
+'* *',
+'* ** * ***** * ** *',
+'* * * * *',
+'**** *** * *** ****',
+'**** * * ****',
+'**** * ** ** * ****',
+'* * * *',
+'**** * ***** * ****',
+'**** * * ****',
+'**** * ***** * ****',
+'* * *',
+'* ** *** * *** ** *',
+'*p * * p*',
+'** * * ***** * * **',
+'* * * * *',
+'* ****** * ****** *',
+'* *',
+'*******************',
],
+ // map : [
+ // '*********',
+ // '* * *',
+ // '* ** ***',
+ // '* *',
+ // '*** *',
+ // '* *',
+ // '*********'
+ // ],
enableCeiling : false
}).addTo(world)
var maze3D = maze.object3D();
+ // TODO should that be done by default
+ // - i think so
+ // - maybe i just pass THREE.* to the tQuery at the end
+ // - what if not all the elements are of the same time ? a console assert is triggered
+ tQuery.Object3D.registerInstance('elevateType', function(){
+ var tNodes = this.get();
+ return tQuery(tNodes);
+ })
+
+
+ var texture = THREE.ImageUtils.loadTexture('images/BluePaintedTiles.png')
+ tQuery('.wall', maze3D).elevateType()
+ .scaleYBy(0.4)
+ .setPhongMaterial()
+ .map(texture)
+ .bumpMap(texture)
+ .bumpScale(0.02)
+ .back()
+
+ var texture = THREE.ImageUtils.loadTexture('images/PaddedOrangeWall.png')
+ texture.wrapS = THREE.RepeatWrapping;
+ texture.wrapT = THREE.RepeatWrapping;
+ texture.repeat.set(maze.mapWidth(), maze.mapDepth());
+
+ tQuery('.ground', maze3D).elevateType()
+ .setPhongMaterial()
+ .map(texture)
+ .bumpMap(texture)
+ .bumpScale(0.05)
+ .back()
+
// to fix z-fighting with pacman shadow
- maze3D.positionY(-0.001)
+ maze3D.positionY(-0.003)
+ var material = tQuery.createSpriteMaterial()
+ .map('images/lensflare0_alpha.png')
+ .fog(true) // FIXME .fog() doesnt seem to work
+ maze.forEach(function(tileX, tileZ, value){
+ if( value !== ' '.charCodeAt(0) ) return;
+ tQuery.createSprite().addTo(world)
+ .addClass('plainPill')
+ .translateY(0.5)
+ .material(material)
+ .positionX(tileX + 0.5 - maze.mapWidth()/2)
+ .positionZ(tileZ + 0.5 - maze.mapDepth()/2)
+ })
+
+ var material = tQuery.createMeshPhongMaterial()
+ .color(0x00ffff)
+ .color(0xffff00)
+ .envMap(tQuery.createCubeTexture('swedishRoyalCastle'))
+ .bumpMap('../../assets/images/water.jpg')
+ .bumpScale(0.01)
+ maze.forEach(function(tileX, tileZ, value){
+ if( value !== 'p'.charCodeAt(0) ) return;
+ 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)
+ })
+
// very minimal controls
- var controls = {
+ var playerControls = {
update : function(delta, now){
+ var position = playerContainer.position().clone();
var keyboard = tQuery.keyboard();
- var speed = 2;
- if( keyboard.pressed('left') ){
- pacman.translateX(-speed * delta)
- }
- if( keyboard.pressed('right') ){
- pacman.translateX(+speed * delta)
- }
- if( keyboard.pressed('up') ){
- pacman.translateZ(-speed * delta)
- }
- if( keyboard.pressed('down') ){
- pacman.translateZ(+speed * delta)
- }
+ var speed = 3 * delta;
+
+ if( keyboard.pressed('left') ) position.x -= speed
+ if( keyboard.pressed('right') ) position.x += speed
+ if( keyboard.pressed('up') ) position.z -= speed
+ if( keyboard.pressed('down') ) position.z += speed
+
+ var coord = position.clone()
+ coord.x += maze.mapWidth()/2;
+ coord.z += maze.mapDepth()/2;
+
+ var playerW = 0.5 - 0.01 /* kindof epsilon */
+ var colliding = false
+ if( maze.getCoord(coord.x+playerW, coord.z+playerW) === '*'.charCodeAt(0) ) colliding = true;
+ if( maze.getCoord(coord.x+playerW, coord.z-playerW) === '*'.charCodeAt(0) ) colliding = true;
+ if( maze.getCoord(coord.x-playerW, coord.z+playerW) === '*'.charCodeAt(0) ) colliding = true;
+ if( maze.getCoord(coord.x-playerW, coord.z-playerW) === '*'.charCodeAt(0) ) colliding = true;
+colliding = false;
+ if( colliding === false ) playerContainer.position(position)
}
- };
-
+ }
+
// wrapper for this controls
tQuery.createControlsWrapper({
- controls : controls
+ controls : playerControls
}).start()
-
})
</script></body>
Oops, something went wrong.

0 comments on commit 5edfa71

Please sign in to comment.