Mrm2299

Kon kamaras

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