Advertisement
Guest User

jsfiddle error

a guest
Jan 20th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>JSFiddle Problem</title>
  5. </head>
  6. <style>
  7. body
  8. {
  9. position:absolute;
  10. left: 25%;
  11. margin: 0px;
  12. padding: 0px;
  13. }
  14. </style>
  15. <script src="http://stemkoski.github.io/Three.js/js/Three.js"></script>
  16.  
  17.  
  18. <body>
  19. <div id="container" style = "text-align: center;width: 100%;">
  20. </div>
  21. <script>
  22. // this function is executed on each animation frame
  23. function animate() {
  24. // render
  25. renderer.render(scene, camera);
  26.  
  27. // request new frame
  28. requestAnimationFrame(function () {
  29. animate();
  30. });
  31. }
  32.  
  33.  
  34. // renderer
  35. var renderer = new THREE.WebGLRenderer({
  36. antialias: true
  37. }); //antialiasing on! :)
  38. renderer.setClearColor(0xADD8E6, 1); //made the colour for the sky blue
  39. renderer.setSize(720, 600);
  40. document.body.appendChild(renderer.domElement);
  41.  
  42. // camera
  43. var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 800);
  44. camera.position.set(0, 150, 400);
  45.  
  46.  
  47.  
  48. // scene
  49. var scene = new THREE.Scene();
  50.  
  51. //CODE HERE
  52. var ashTexture = THREE.ImageUtils.loadTexture('http://www.mediafire.com/convkey/7344/ra2l3kgscpvjflafg.jpg');
  53. var ashMaterial = new THREE.SpriteMaterial({
  54. map: ashTexture
  55. });
  56. var imageWidth = ashMaterial.map.image.width;
  57. var imageHeight = ashMaterial.map.image.height;
  58. var Ash = new THREE.Sprite(ashMaterial);
  59. Ash.scale.set(2 * imageWidth, 2 * imageHeight, 1.0);
  60. Ash.position.set(100, 100, 0);
  61. scene.add(Ash);
  62.  
  63. //CODE ENDS HERE
  64.  
  65. // add subtle ambient lighting
  66. var ambientLight = new THREE.AmbientLight(0xbbbbbb);
  67. scene.add(ambientLight);
  68.  
  69. // directional lighting
  70. var directionalLight = new THREE.DirectionalLight(0xffffff);
  71. directionalLight.position.set(1, 1, 1).normalize();
  72. scene.add(directionalLight);
  73.  
  74. // start animation
  75. animate();
  76. </script>
  77. </div>
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement