Mrm2299

SISTEMA SOLAR 0.5

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