Advertisement
seacloud9

SphericalHarmonics Issue

Jul 31st, 2011
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
  3. <!--[if IE 7 ]>    <html class="no-js ie7" lang="en"> <![endif]-->
  4. <!--[if IE 8 ]>    <html class="no-js ie8" lang="en"> <![endif]-->
  5. <!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
  6. <head>
  7.   <meta charset="utf-8">
  8.   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  9.  
  10.   <title>Twitter Garden</title>
  11.   <meta name="description" content="">
  12.   <meta name="author" content="">
  13.  
  14.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  15.   <link rel="shortcut icon" href="/favicon.ico">
  16.   <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  17.  
  18.   <link rel="stylesheet" href="css/style.css?v=2">
  19.   <script src="js/libs/modernizr-1.7.min.js"></script>
  20.  
  21. </head>
  22.  
  23. <body>
  24.  
  25.   <div id="container">
  26.    
  27.   </div> <!-- eo #container -->
  28.  
  29.  
  30.   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
  31.   <script>window.jQuery || document.write("<script src='js/libs/jquery-1.5.1.min.js'>\x3C/script>")</script>
  32.  
  33.  
  34.   <!-- scripts concatenated and minified via ant build script-->
  35.   <script src="js/plugins.js"></script>
  36.   <script src="js/script.js"></script>
  37.   <script type="text/javascript" src="js/mylibs/toxiclibs.js"></script>
  38.   <script type="text/javascript" src="js/mylibs/Three.js"></script>
  39.   <script type="text/javascript" src="js/mylibs/RequestAnimationFrame.js"></script>
  40.   <script type="text/javascript" src="js/mylibs/Detector.js"></script>
  41.   <script type="text/javascript" src="js/mylibs/Stats.js"></script>
  42.   <!-- end scripts-->
  43.  
  44.  
  45.   <!--[if lt IE 7 ]>
  46.     <script src="js/libs/dd_belatedpng.js"></script>
  47.     <script>DD_belatedPNG.fix("img, .png_bg");</script>
  48.   <![endif]-->
  49.  
  50.  
  51.  
  52.   <script>
  53.     var _gaq=[["_setAccount","UA-XXXXX-X"],["_trackPageview"]]; // Change UA-XXXXX-X to be your site's ID
  54.     (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
  55.     g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
  56.     s.parentNode.insertBefore(g,s)}(document,"script"));
  57.   </script>
  58.  
  59.   <script type="text/javascript">
  60.   $(function(){
  61.          $.getJSON('http://search.twitter.com/search.json?q=happiness&callback=?', function(data) {
  62.              
  63.           console.log(data);
  64.           $.each(data, function(key, val) {
  65.             //items.push('<li id="' + key + '">' + val + '</li>');
  66.           });
  67.    
  68.         });
  69.      
  70.      });
  71.      
  72.      if ( ! Detector.webgl ) {
  73.  
  74.                 Detector.addGetWebGLMessage();
  75.                 document.getElementById( 'container' ).innerHTML = "";
  76.  
  77.       }
  78.  
  79.     var container, stats;
  80.     var camera, scene, renderer;
  81.     var mesh,SurfaceMeshBuilder,geo,mesh3JS,material;
  82.    
  83.    
  84.    
  85.     init();
  86.     animate();
  87.    
  88.    
  89.    
  90.     function init() {
  91.                 container = document.getElementById( 'container' );
  92.  
  93.                 camera = new THREE.FirstPersonCamera( {
  94.  
  95.                     fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
  96.                     movementSpeed: 500, lookSpeed: 0.1, noFly: false, lookVertical: true
  97.  
  98.                 } );
  99.  
  100.                 camera.target.position.z = - 100;
  101.  
  102.                 scene = new THREE.Scene();
  103.                 scene.fog = new THREE.FogExp2( 0xaaccff, 0.0007 );
  104.  
  105.                 //var light = new THREE.PointLight( 0xffffff, 2 );
  106.                 //light.position.y = 500;
  107.                 //scene.addLight( light );
  108.  
  109.                 camera.position.y = 200;
  110.                 camera.target.position.y = camera.position.y;
  111.  
  112.                
  113.  
  114.                 //var texture = THREE.ImageUtils.loadTexture( "textures/water.jpg" );
  115.                 //texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
  116.                 //texture.repeat.set( 5, 5 );
  117.                 //material = new THREE.MeshBasicMaterial( { color:0x0044ff, opacity:1, map: texture } );
  118.                 material = new THREE.MeshNormalMaterial();
  119.                 var m = new Array(0.0,3.0,6.0,0.0,1.0,5.0,5.0,5.0);
  120.                 //var m = new Array(2.0,1.0,6.0,1.0,2.0,7.0,0.0,7.0);
  121.                 SurfaceMeshBuilder = new toxi.SurfaceMeshBuilder(new toxi.SphericalHarmonics(m));
  122.                 mesh = SurfaceMeshBuilder.createMesh(null,80, 60);
  123.  
  124.                 geo = new THREE.Geometry();
  125.                 geo.vertices = mesh.vertices;
  126.                 geo.faces = mesh.faces;
  127.                 //geo.vertices = mesh.getMeshAsVertexArray();
  128.                 //geo.faces = mesh.getFacesAsArray();
  129.  
  130.  
  131.                 //Having trouble with converting the mesh to threeJS geometry
  132.                 geo.boundingBox = mesh.getBoundingBox();
  133.                 geo.colors = '0x045415';
  134.                
  135.                 mesh3JS = new THREE.Mesh( geo, material );
  136.                 //mesh3JS.dynamic = true;
  137.                 //mesh3JS.rotation.x = - 90 * Math.PI / 180;
  138.                 //scene.addObject( mesh3JS );
  139.  
  140.                 renderer = new THREE.WebGLRenderer( { clearColor:0xaaccff, clearAlpha: 1 } );
  141.                 renderer.setSize( window.innerWidth, window.innerHeight );
  142.  
  143.                 container.innerHTML = "";
  144.  
  145.                 container.appendChild( renderer.domElement );
  146.  
  147.                 stats = new Stats();
  148.                 stats.domElement.style.position = 'absolute';
  149.                 stats.domElement.style.top = '0px';
  150.                 container.appendChild( stats.domElement );
  151.  
  152.             }
  153.            
  154.    
  155.  
  156.  
  157.             //
  158.  
  159.             function animate() {
  160.  
  161.                 requestAnimationFrame( animate );
  162.  
  163.                 render();
  164.                 stats.update();
  165.  
  166.             }
  167.  
  168.             function render() {
  169.  
  170.                 var time = new Date().getTime() * 0.01;
  171.  
  172.  
  173.  
  174.                 renderer.render(scene, camera);
  175.  
  176.             }
  177.  
  178.    
  179.  
  180.   </script>
  181. </body>
  182. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement