Mrm2299

CON SUS RESPECTIVAS TEXTURAS

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