Mrm2299

Revision X

Apr 2nd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1.  
  2.  
  3. //////////////////////////////////////////
  4. //SISTEMA SOLAR POR MANUEL PATIÑO LOPEZ//
  5. /////////////////////// //
  6. //REVISION 2/4/16//
  7. ///////////////////
  8.  
  9. //INICIO DEL PROGRAMA
  10.  
  11. var createScene = function() {
  12. var scene = new BABYLON.Scene(engine);
  13. var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
  14. camera.attachControl(canvas, false);
  15.  
  16.  
  17.  
  18. //LUCES
  19.  
  20. var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 0, 0), scene);
  21. light0.diffuse = new BABYLON.Color3(1, 01, 01);
  22. light0.specular = new BABYLON.Color3(1, 1, 1);
  23. var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);
  24.  
  25.  
  26.  
  27. //VARIABLES DE PLANETAS TAMAÑOS, ETC
  28.  
  29. var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 200, scene); //POR FINES DIDACTICOS TOMAMOS EL RADIO DEL SOL A 200
  30. var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2.4, scene);//POR FINES DIDACTICOS LA ESCALA SERA RADIO/1000
  31. var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 6, scene);
  32. var tierra = BABYLON.Mesh.CreateSphere('sphere1', 6, 6.37, scene);
  33. var marte = BABYLON.Mesh.CreateSphere('sphere1', 6, 3.39, scene);
  34. var jupiter = BABYLON.Mesh.CreateSphere('sphere1', 6, 71.4, scene);
  35. var saturno = BABYLON.Mesh.CreateSphere('sphere1', 6, 60.26, scene);
  36. var urano= BABYLON.Mesh.CreateSphere('sphere1', 6, 25.5, scene);
  37. var neptuno = BABYLON.Mesh.CreateSphere('sphere1', 6, 24.7, scene);
  38.  
  39. // TEXTURAS?¿
  40.  
  41. sol.material = new BABYLON.StandardMaterial("texture1", scene);
  42. sol.material.ambientTexture = new BABYLON.Texture("grass.png", scene);
  43.  
  44.  
  45. //Posiciones iniciales
  46.  
  47. sol.position.x = 0
  48. sol.position.y = 6.5
  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) *60, 10, Math.sin(alpha) * 40);
  59. alpha += 0.0087;//ALREDEDOR DE 87 DIAS TERRESTRES
  60.  
  61. });
  62.  
  63.  
  64.  
  65. //Animacion VENUS
  66.  
  67. var beta = 0;
  68. scene.registerBeforeRender(function () {
  69. venus.rotation.x += 0.01;
  70. venus.rotation.z += 0.02;
  71. venus.position = new BABYLON.Vector3(Math.cos(beta) *80, 10, Math.sin(beta) * 60);
  72. beta += 0.00254;//ALREDEDOR DE 254 DIAS TERRESTRES
  73.  
  74. });
  75.  
  76.  
  77. //Animacion TIERRA
  78.  
  79. var gamma = 0;
  80. scene.registerBeforeRender(function () {
  81. tierra.rotation.x += 0.01;
  82. tierra.rotation.z += 0.02;
  83. tierra.position = new BABYLON.Vector3(Math.cos(gamma) *100, 10, Math.sin(gamma) * 80);
  84. gamma += 0.00365;//ALREDEDOR DE 365 DIAS
  85.  
  86. });
  87.  
  88.  
  89.  
  90. //Animacion MARTE
  91. var delta = 0;
  92. marte.registerBeforeRender(function () {
  93. marte.rotation.x += 0.01;
  94. marte.rotation.z += 0.02;
  95. marte.position = new BABYLON.Vector3(Math.cos(delta) *120, 10, Math.sin(delta) * 100);
  96. delta += 0.00686;//ALREDEDOR DE 686 DIAS
  97.  
  98. });
  99.  
  100.  
  101. //Animacion JUPITER
  102. var epsilon = 0;
  103. scene.registerBeforeRender(function () {
  104. jupiter.rotation.x += 0.01;
  105. jupiter.rotation.z += 0.02;
  106. jupiter.position = new BABYLON.Vector3(Math.cos(epsilon) *140, 10, Math.sin(epsilon) * 120);
  107. epsilon += 0.0004379;// ALREDEDOR DE 4379 DIAS
  108.  
  109. });
  110.  
  111. //Animacion SATURNO
  112.  
  113. var dseta = 0;
  114. scene.registerBeforeRender(function () {
  115. saturno.rotation.x += 0.01;
  116. saturno.rotation.z += 0.02;
  117. saturno.position = new BABYLON.Vector3(Math.cos(dseta) *160, 10, Math.sin(dseta) * 140);
  118. dseta += 0.000010585;// ALREDEDOR DE 10585 DIAS
  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) *180, 10, Math.sin(eta) * 160);
  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) *200, 10, Math.sin(dseta) * 180);
  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. };
Add Comment
Please, Sign In to add comment