Mrm2299

SISTEMA SOLAR REVISION 2/4/16

Apr 2nd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1.  
  2.  
  3.  
  4. //////////////////////////////////////////
  5. //SISTEMA SOLAR POR MANUEL PATIÑO LOPEZ//
  6. /////////////////////// //
  7. //REVISION 2/4/16//
  8. ///////////////////
  9.  
  10. //INICIO DEL PROGRAMA
  11.  
  12. var createScene = function() {
  13. var scene = new BABYLON.Scene(engine);
  14. var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
  15. camera.attachControl(canvas, false);
  16.  
  17.  
  18.  
  19. //LUCES
  20.  
  21. var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 0, 0), scene);
  22. light0.diffuse = new BABYLON.Color3(1, 01, 01);
  23. light0.specular = new BABYLON.Color3(1, 1, 1);
  24. var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);
  25.  
  26.  
  27.  
  28. //VARIABLES DE PLANETAS TAMAÑOS, ETC
  29.  
  30. var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 52, scene);
  31. var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);
  32. var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 5, scene);
  33. var tierra = BABYLON.Mesh.CreateSphere('sphere1', 6, 5.4, scene);
  34. var marte = BABYLON.Mesh.CreateSphere('sphere1', 6, 2.4, scene);
  35. var jupiter = BABYLON.Mesh.CreateSphere('sphere1', 6, 10, scene);
  36. var saturno = BABYLON.Mesh.CreateSphere('sphere1', 6, 9, scene);
  37. var urano= BABYLON.Mesh.CreateSphere('sphere1', 6, 1, scene);
  38. var neptuno = BABYLON.Mesh.CreateSphere('sphere1', 6, 1.8, scene);
  39.  
  40. // TEXTURAS?¿
  41.  
  42. sol.material = new BABYLON.StandardMaterial("texture1", scene);
  43. sol.material.ambientTexture = new BABYLON.Texture("grass.png", scene);
  44.  
  45.  
  46. //Posiciones iniciales
  47.  
  48. sol.position.x = 0
  49. sol.position.y = 6.5
  50.  
  51.  
  52.  
  53. // Animacion MERCURIO
  54.  
  55. var alpha = 0;
  56. scene.registerBeforeRender(function () {
  57. mercurio.rotation.x += 0.01;
  58. mercurio.rotation.z += 0.02;
  59. mercurio.position = new BABYLON.Vector3(Math.cos(alpha) *60, 10, Math.sin(alpha) * 40);
  60. alpha += 0.0087;//ALREDEDOR DE 87 DIAS TERRESTRES
  61.  
  62. });
  63.  
  64.  
  65.  
  66. //Animacion VENUS
  67.  
  68. var beta = 0;
  69. scene.registerBeforeRender(function () {
  70. venus.rotation.x += 0.01;
  71. venus.rotation.z += 0.02;
  72. venus.position = new BABYLON.Vector3(Math.cos(beta) *80, 10, Math.sin(beta) * 60);
  73. beta += 0.00254;//ALREDEDOR DE 254 DIAS TERRESTRES
  74.  
  75. });
  76.  
  77.  
  78. //Animacion TIERRA
  79.  
  80. var gamma = 0;
  81. scene.registerBeforeRender(function () {
  82. tierra.rotation.x += 0.01;
  83. tierra.rotation.z += 0.02;
  84. tierra.position = new BABYLON.Vector3(Math.cos(gamma) *100, 10, Math.sin(gamma) * 80);
  85. gamma += 0.00365;//ALREDEDOR DE 365 DIAS
  86.  
  87. });
  88.  
  89.  
  90.  
  91. //Animacion MARTE
  92. var delta = 0;
  93. marte.registerBeforeRender(function () {
  94. marte.rotation.x += 0.01;
  95. marte.rotation.z += 0.02;
  96. marte.position = new BABYLON.Vector3(Math.cos(delta) *120, 10, Math.sin(delta) * 100);
  97. delta += 0.00686;//ALREDEDOR DE 686 DIAS
  98.  
  99. });
  100.  
  101.  
  102. //Animacion JUPITER
  103. var epsilon = 0;
  104. scene.registerBeforeRender(function () {
  105. jupiter.rotation.x += 0.01;
  106. jupiter.rotation.z += 0.02;
  107. jupiter.position = new BABYLON.Vector3(Math.cos(epsilon) *140, 10, Math.sin(epsilon) * 120);
  108. epsilon += 0.0004379;// ALREDEDOR DE 4379 DIAS
  109.  
  110. });
  111.  
  112. //Animacion SATURNO
  113.  
  114. var dseta = 0;
  115. scene.registerBeforeRender(function () {
  116. saturno.rotation.x += 0.01;
  117. saturno.rotation.z += 0.02;
  118. saturno.position = new BABYLON.Vector3(Math.cos(dseta) *160, 10, Math.sin(dseta) * 140);
  119. dseta += 0.000010585;// ALREDEDOR DE 10585 DIAS
  120.  
  121. });
  122.  
  123. //Animacion URANO
  124.  
  125. var eta = 0;
  126. scene.registerBeforeRender(function () {
  127. urano.rotation.x += 0.01;
  128. urano.rotation.z += 0.02;
  129. urano.position = new BABYLON.Vector3(Math.cos(eta) *180, 10, Math.sin(eta) * 160);
  130. eta += 0.000010585;// ALREDEDOR DE 10585 DIAS
  131.  
  132. });
  133.  
  134.  
  135. //Animacion NEPTUNO
  136.  
  137. var dseta = 0;
  138. scene.registerBeforeRender(function () {
  139. neptuno.rotation.x += 0.01;
  140. neptuno.rotation.z += 0.02;
  141. neptuno.position = new BABYLON.Vector3(Math.cos(dseta) *200, 10, Math.sin(dseta) * 180);
  142. dseta += 0.000010585;// ALREDEDOR DE 10585 DIAS
  143.  
  144. });
  145.  
  146.  
  147.  
  148. //PLUTON NO EXISTE
  149.  
  150.  
  151.  
  152.  
  153. return scene;
  154. };
Add Comment
Please, Sign In to add comment