Mrm2299

SISTEMA SOLAR 0.3

Apr 2nd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. // You have to create a function called createScene. This function must return a BABYLON.Scene object
  2. // You can reference the following variables: scene, canvas
  3. // You must at least define a camera
  4. // More info here: https://github.com/BabylonJS/Babylon.js/wiki/The-Playground
  5.  
  6. var createScene = function() {
  7. var scene = new BABYLON.Scene(engine);
  8. var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
  9. camera.attachControl(canvas, false);
  10.  
  11.  
  12.  
  13. //Luces
  14. var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 0, 0), scene);
  15. light0.diffuse = new BABYLON.Color3(1, 01, 01);
  16. light0.specular = new BABYLON.Color3(1, 1, 1);
  17. var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);
  18.  
  19.  
  20.  
  21. // Variables planetas
  22. var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 52, scene);
  23. var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);
  24. var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 5, scene);
  25. var tierra = BABYLON.Mesh.CreateSphere('sphere1', 6, 5.4, scene);
  26. var marte = BABYLON.Mesh.CreateSphere('sphere1', 6, 2.4, scene);
  27. var jupiter = BABYLON.Mesh.CreateSphere('sphere1', 6, 10, scene);
  28. var saturno = BABYLON.Mesh.CreateSphere('sphere1', 6, 9, scene);
  29. var urano= BABYLON.Mesh.CreateSphere('sphere1', 6, 1, scene);
  30. var neptuno = BABYLON.Mesh.CreateSphere('sphere1', 6, 1.8, scene);
  31.  
  32.  
  33. sol.material = new BABYLON.StandardMaterial("texture1", scene);
  34. sol.material.ambientTexture = new BABYLON.Texture("grass.png", scene);
  35.  
  36.  
  37. // Posiciones iniciales
  38. sol.position.x = 0
  39. sol.position.y = 6.5
  40.  
  41.  
  42.  
  43. // Animacion MERCURIO
  44. var alpha = 0;
  45. scene.registerBeforeRender(function () {
  46. mercurio.rotation.x += 0.01;
  47. mercurio.rotation.z += 0.02;
  48. mercurio.position = new BABYLON.Vector3(Math.cos(alpha) *60, 10, Math.sin(alpha) * 40);
  49. alpha += 0.0087;//ALREDEDOR DE 87 DIAS TERRESTRES
  50.  
  51. });
  52.  
  53.  
  54.  
  55. //Animacion VENUS
  56. var beta = 0;
  57. scene.registerBeforeRender(function () {
  58. venus.rotation.x += 0.01;
  59. venus.rotation.z += 0.02;
  60. venus.position = new BABYLON.Vector3(Math.cos(beta) *80, 10, Math.sin(beta) * 60);
  61. beta += 0.00254;//ALREDEDOR DE 254 DIAS TERRESTRES
  62.  
  63. });
  64.  
  65.  
  66. //Animacion TIERRA
  67.  
  68. var gamma = 0;
  69. scene.registerBeforeRender(function () {
  70. tierra.rotation.x += 0.01;
  71. tierra.rotation.z += 0.02;
  72. tierra.position = new BABYLON.Vector3(Math.cos(gamma) *100, 10, Math.sin(gamma) * 80);
  73. gamma += 0.00365;//ALREDEDOR DE 365 DIAS
  74.  
  75. });
  76.  
  77.  
  78.  
  79. //Animacion MARTE
  80. var delta = 0;
  81. marte.registerBeforeRender(function () {
  82. marte.rotation.x += 0.01;
  83. marte.rotation.z += 0.02;
  84. marte.position = new BABYLON.Vector3(Math.cos(delta) *120, 10, Math.sin(delta) * 100);
  85. delta += 0.00686;//ALREDEDOR DE 686 DIAS
  86.  
  87. });
  88.  
  89.  
  90. //Animacion JUPITER
  91. var epsilon = 0;
  92. scene.registerBeforeRender(function () {
  93. jupiter.rotation.x += 0.01;
  94. jupiter.rotation.z += 0.02;
  95. jupiter.position = new BABYLON.Vector3(Math.cos(epsilon) *140, 10, Math.sin(epsilon) * 120);
  96. epsilon += 0.0004379;// ALREDEDOR DE 4379 DIAS
  97.  
  98. });
  99.  
  100. //Animacion SATURNO
  101. var dseta = 0;
  102. scene.registerBeforeRender(function () {
  103. saturno.rotation.x += 0.01;
  104. saturno.rotation.z += 0.02;
  105. saturno.position = new BABYLON.Vector3(Math.cos(dseta) *160, 10, Math.sin(dseta) * 140);
  106. dseta += 0.000010585;// ALREDEDOR DE 10585 DIAS
  107.  
  108. });
  109.  
  110. //Animacion URANO
  111. var eta = 0;
  112. scene.registerBeforeRender(function () {
  113. urano.rotation.x += 0.01;
  114. urano.rotation.z += 0.02;
  115. urano.position = new BABYLON.Vector3(Math.cos(eta) *180, 10, Math.sin(eta) * 160);
  116. eta += 0.000010585;// ALREDEDOR DE 10585 DIAS
  117.  
  118. });
  119.  
  120.  
  121. //Animacion NEPTUNO
  122. var dseta = 0;
  123. scene.registerBeforeRender(function () {
  124. neptuno.rotation.x += 0.01;
  125. neptuno.rotation.z += 0.02;
  126. neptuno.position = new BABYLON.Vector3(Math.cos(dseta) *200, 10, Math.sin(dseta) * 180);
  127. dseta += 0.000010585;// ALREDEDOR DE 10585 DIAS
  128.  
  129. });
  130.  
  131. return scene;
  132. };
Advertisement
Add Comment
Please, Sign In to add comment