Skip to content
Browse files

more on dynamic cubemap

  • Loading branch information...
1 parent 831e8f4 commit 0e1080de3f51a4a635b0476dd49dd82fd10b27eb @jeromeetienne committed Feb 27, 2013
Showing with 117 additions and 5 deletions.
  1. +104 −0 plugins/skymap/examples/demo.html
  2. +13 −5 plugins/skymap/examples/dynamic.html
View
104 plugins/skymap/examples/demo.html
@@ -0,0 +1,104 @@
+<!doctype html><title>Minimal tQuery Page</title>
+<script src="../../../build/tquery-bundle-require.js"></script>
+<body><script>
+require([ 'tquery.skymap'
+ , 'tquery.grassground'
+ , 'tquery.minecraft'
+], function(){
+ var world = tQuery.createWorld().boilerplate().start()
+
+ var controls = tQuery.world.getCameraControls();
+ controls.rangeX *= 1/10;
+ controls.rangeY *= 1/10;
+ controls.target.y = 0.75;
+ // keep the camera above the ground
+ world.loop().hook(function(delta, now){
+ var camera = tQuery(world.tCamera())
+ var minHeight = 0.1;
+ if( camera.positionY() < minHeight ) camera.positionY(minHeight)
+ })
+
+ tQuery.createSkymap('mars').addTo(world);
+
+ tQuery.createGrassGround({
+ textureRepeatX : 10,
+ textureRepeatY : 10,
+ }).addTo(world).scale(30)
+ .translateY(-0.001)
+ .receiveShadow(true)
+
+ var cubeCamera = new THREE.CubeCamera( 0.001, 1000, 256 );
+ // to avoid flickering on the border of the sphere
+ cubeCamera.renderTarget.minFilter = THREE.LinearMipMapLinearFilter;
+
+
+ var sphere = tQuery.createSphere().addTo(world).translateY(0.8)
+ .setBasicMaterial()
+ .envMap(cubeCamera.renderTarget)
+ .color(0xffff00)
+ .back()
+
+
+ // TODO make a better API
+
+
+ tQuery(cubeCamera).addTo(sphere)
+
+ world.loop().hook(function(){
+ sphere.visible(false) // *cough*
+
+ cubeCamera.updateCubeMap( world.tRenderer(), world.tScene() );
+
+ sphere.visible(true) // *cough*
+ })
+
+ world.loop().hook(function(delta, now){
+ var angle = 0.2 * now * Math.PI * 2;
+ sphere.positionY(Math.sin(angle)*0.5 + 0.6)
+ .scale(Math.sin(angle)*0.3 + 1)
+ })
+
+
+ var container = tQuery.createObject3D().addTo(world)
+ world.loop().hook(function(delta, now){
+ var angle = 0.2 * now*Math.PI*2;
+ container.rotationY(angle)
+ })
+
+ // init flash
+ var character = tQuery.createMinecraftChar({
+ skinUrl : '../../minecraft/examples/images/theflash.png'
+ }).addTo(container)
+ tQuery.createMinecraftCharAnimations(character).start('walk')
+ tQuery.createMinecraftCharHeadAnimations(character).start('yes');
+ var angle = 0/3 * Math.PI * 2;
+ character.object3D()
+ .translateX(Math.cos(angle) * 0.8)
+ .translateZ(Math.sin(angle) * 0.8)
+ .rotateY(Math.PI - angle)
+
+ // init batman
+ var character = tQuery.createMinecraftChar({
+ skinUrl : '../../minecraft/examples/images/batman.png'
+ }).addTo(container)
+ tQuery.createMinecraftCharAnimations(character).start('walk')
+ tQuery.createMinecraftCharHeadAnimations(character).start('yes');
+ var angle = 1/3 * Math.PI * 2;
+ character.object3D()
+ .translateX(Math.cos(angle) * 0.8)
+ .translateZ(Math.sin(angle) * 0.8)
+ .rotateY(Math.PI - angle)
+
+ // init mario
+ var character = tQuery.createMinecraftChar({
+ skinUrl : '../../minecraft/examples/images/Mario.png'
+ }).addTo(container)
+ tQuery.createMinecraftCharAnimations(character).start('walk')
+ tQuery.createMinecraftCharHeadAnimations(character).start('yes');
+ var angle = 2/3 * Math.PI * 2;
+ character.object3D()
+ .translateX(Math.cos(angle) * 0.8)
+ .translateZ(Math.sin(angle) * 0.8)
+ .rotateY(Math.PI - angle)
+})
+</script></body>
View
18 plugins/skymap/examples/dynamic.html
@@ -28,13 +28,15 @@
// attempts to make a puddle
var sphere = tQuery.createPlane().addTo(world)
+
.setBasicMaterial()
.envMap(cubeCamera.renderTarget)
.color(0xffff00)
.back()
- .scaleBy(10)
-// .positionY(5).positionZ(-3)
+ //.scaleBy(10)
+// .positionY(5).positionZ(-3)
+// tQuery(cubeCamera).addTo(sphere)
tQuery(cubeCamera).addTo(sphere)
world.loop().hook(function(){
@@ -51,15 +53,21 @@
// .scale(Math.sin(angle)*0.3 + 1)
// })
- var character = tQuery.createMinecraftChar().addTo(world)
+ var character = tQuery.createMinecraftChar({
+ skinUrl : '../../minecraft/examples/images/theflash.png'
+ }).addTo(world)
character.object3D().translateX(-0.7)
.rotateY(Math.PI/3)
- var character = tQuery.createMinecraftChar().addTo(world)
+ var character = tQuery.createMinecraftChar({
+ skinUrl : '../../minecraft/examples/images/batman.png'
+ }).addTo(world)
character.object3D().translateX(+0.7)
.rotateY(-Math.PI/3)
- var character = tQuery.createMinecraftChar().addTo(world)
+ var character = tQuery.createMinecraftChar({
+ skinUrl : '../../minecraft/examples/images/Mario.png'
+ }).addTo(world)
character.object3D()
.rotateY(Math.PI)
.translateX(0.4)

0 comments on commit 0e1080d

Please sign in to comment.
Something went wrong with that request. Please try again.