Mrm2299

Sistema solar 0.3.2

Mar 29th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. // You have to create a function called createScene. This function must return a BABYLON.Scene object
  2. // You can reference the following variables: scene, canvas
  3. // You must at least define a camera
  4. // More info here: https://github.com/BabylonJS/Babylon.js/wiki/The-Playground
  5.  
  6. var createScene = function() {
  7. var scene = new BABYLON.Scene(engine);
  8. var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
  9. camera.attachControl(canvas, false);
  10.  
  11.  
  12.  
  13. //Luces
  14. var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 0, 0), scene);
  15. light0.diffuse = new BABYLON.Color3(1, 01, 01);
  16. light0.specular = new BABYLON.Color3(1, 1, 1);
  17. var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);
  18.  
  19.  
  20.  
  21.  
  22.  
  23. // Variables planetas
  24. var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 52, scene);
  25. var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);
  26. var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 5, scene);
  27. sol.material = new BABYLON.StandardMaterial("texture1", scene);
  28. sol.material.ambientTexture = new BABYLON.Texture("grass.png", scene);
  29.  
  30. // Posiciones iniciales
  31. sol.position.x = 0
  32. sol.position.y = 6.5
  33.  
  34.  
  35. // Animacion MERCURIO
  36. var alpha = 0;
  37. scene.registerBeforeRender(function () {
  38. mercurio.rotation.x += 0.01;
  39. mercurio.rotation.z += 0.02;
  40. mercurio.position = new BABYLON.Vector3(Math.cos(alpha) *40, 10, Math.sin(alpha) * 40);
  41. alpha += 0.019;
  42.  
  43. });
  44.  
  45.  
  46. //Animacion Venus
  47. var beta = 0;
  48. scene.registerBeforeRender(function () {
  49. venus.rotation.x += 0.01;
  50. venus.rotation.z += 0.02;
  51. venus.position = new BABYLON.Vector3(Math.cos(beta) *60, 10, Math.sin(beta) * 60);
  52. beta += 0.01;
  53.  
  54. });
  55.  
  56.  
  57. //Animacion Tierra
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. return scene;
  65. };
Advertisement
Add Comment
Please, Sign In to add comment