Mrm2299

DDDDDD

Apr 17th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.96 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.  
  6. <title>Babylon.js sample code</title>
  7. <!-- Babylon.js -->
  8. <script src="http://www.babylonjs.com/hand.minified-1.2.js"></script>
  9. <script src="http://www.babylonjs.com/cannon.js"></script>
  10. <script src="http://www.babylonjs.com/oimo.js"></script>
  11. <script src="http://www.babylonjs.com/babylon.js"></script>
  12. <style>
  13. html, body {
  14. overflow: hidden;
  15. width: 100%;
  16. height: 100%;
  17. margin: 0;
  18. padding: 0;
  19. }
  20.  
  21. #renderCanvas {
  22. width: 100%;
  23. height: 100%;
  24. touch-action: none;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <canvas id="renderCanvas"></canvas>
  30. <script>
  31. var canvas = document.getElementById("renderCanvas");
  32. var engine = new BABYLON.Engine(canvas, true);
  33.  
  34.  
  35.  
  36.  
  37. //////////////////////////////////////////
  38. //SISTEMA SOLAR POR MANUEL PATIΓ‘O LOPEZ//
  39. /////////////////////// //
  40. //REVISION 2/4/16//
  41. ///////////////////
  42.  
  43.  
  44.  
  45. //INICIO DEL PROGRAMA
  46.  
  47.  
  48. var createScene = function() {
  49. var scene = new BABYLON.Scene(engine);
  50.  
  51.  
  52.  
  53.  
  54.  
  55. //CAMARAS
  56.  
  57. var camara = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(110, 111, -115), scene);
  58. camara.speed=20
  59. camara.attachControl(canvas, false);
  60.  
  61.  
  62.  
  63. //LUCES
  64.  
  65. var luzsol = new BABYLON.PointLight("Omni1", new BABYLON.Vector3(0, 0, 0), scene);
  66. var luzespacio = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);
  67. luzespacio.intensity = 0.5
  68. luzsol.intensity = 0.9
  69.  
  70.  
  71.  
  72. //VARIABLES DE PLANETAS TAMAΓ‘OS, ETC
  73. var particulas = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene)
  74. var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 200, scene); //POR FINES DIDACTICOS TOMAMOS EL RADIO DEL SOL A 200
  75. var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2.4, scene);//POR FINES DIDACTICOS LA ESCALA SERA RADIO/1000
  76. var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 6, scene);
  77. var tierra = BABYLON.Mesh.CreateSphere('sphere1', 6, 6.37, scene);
  78. var marte = BABYLON.Mesh.CreateSphere('sphere1', 6, 3.39, scene);
  79. var jupiter = BABYLON.Mesh.CreateSphere('sphere1', 6, 71.4, scene);
  80. var saturno = BABYLON.Mesh.CreateSphere('sphere1', 6, 60.26, scene);
  81. var urano= BABYLON.Mesh.CreateSphere('sphere1', 6, 25.5, scene);
  82. var neptuno = BABYLON.Mesh.CreateSphere('sphere1', 6, 24.7, scene);
  83.  
  84.  
  85.  
  86. // TEXTURAS Y MATERIALES
  87.  
  88. // Skybox
  89. var skybox = BABYLON.Mesh.CreateBox("skyBox", 10000.5, scene);
  90.  
  91. var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
  92. skyboxMaterial.backFaceCulling = false;
  93. skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("textures/univ", scene);
  94. skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  95. skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
  96. skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
  97. skybox.material = skyboxMaterial;
  98.  
  99.  
  100. //SOL
  101. var material = new BABYLON.StandardMaterial("materialsol", scene);
  102. sol.material = new BABYLON.StandardMaterial("luz", scene);
  103. sol.material.diffuseColor = new BABYLON.Color3(01, 01, 01);
  104. sol.material.specularColor = new BABYLON.Color3(01, 01, 01);
  105. sol.material.emissiveColor = new BABYLON.Color3(01, 1, 01);
  106. sol.material.ambientTexture = new BABYLON.Texture("sun.png", scene);
  107.  
  108.  
  109. //MERCURIO
  110. var material = new BABYLON.StandardMaterial("materialmercurio", scene);
  111. mercurio.material = material;
  112. material.diffuseTexture = new BABYLON.Texture("mercurio.png", scene);
  113. material.diffuseTexture.hasAlpha = false;
  114. material.diffuseColor = new BABYLON.Color3(1, 1, 1);
  115. material.specularPower = 32;
  116. material.specularTexture = new BABYLON.Texture("mercurio.png", scene);
  117.  
  118.  
  119. //VENUS
  120. var material = new BABYLON.StandardMaterial("materialvenus", scene);
  121. venus.material = material;
  122. material.diffuseTexture = new BABYLON.Texture("venus.png", scene);
  123. material.diffuseTexture.hasAlpha = false;
  124. material.diffuseColor = new BABYLON.Color3(1, 1, 1);
  125. material.specularPower = 32;
  126. material.specularTexture = new BABYLON.Texture("venus.png", scene);
  127.  
  128.  
  129. //TIERRA
  130. var material = new BABYLON.StandardMaterial("materialtierra", scene);
  131. tierra.material = material;
  132. material.diffuseTexture = new BABYLON.Texture("tierra.png", scene);
  133. material.diffuseTexture.hasAlpha = false;
  134. material.diffuseColor = new BABYLON.Color3(1, 1, 1);
  135. material.specularPower = 32;
  136. material.specularTexture = new BABYLON.Texture("tierraspec.png", scene);
  137.  
  138.  
  139. //MARTE
  140. var material = new BABYLON.StandardMaterial("materialmarte", scene);
  141. marte.material = material;
  142. material.diffuseTexture = new BABYLON.Texture("marte.png", scene);
  143. material.diffuseTexture.hasAlpha = false;
  144. material.diffuseColor = new BABYLON.Color3(1, 1, 1);
  145. material.specularPower = 32;
  146. material.specularTexture = new BABYLON.Texture("marte.png", scene);
  147.  
  148.  
  149. //JUPITER
  150. var material = new BABYLON.StandardMaterial("materialjupiter", scene);
  151. jupiter.material = material;
  152. material.diffuseTexture = new BABYLON.Texture("jupiter.png", scene);
  153. material.diffuseTexture.hasAlpha = false;
  154. material.diffuseColor = new BABYLON.Color3(1, 1, 1);
  155. material.specularPower = 32;
  156. material.specularTexture = new BABYLON.Texture("jupiter.png", scene);
  157.  
  158.  
  159. //URANO
  160. var material = new BABYLON.StandardMaterial("materialurano", scene);
  161. urano.material = material;
  162. material.diffuseTexture = new BABYLON.Texture("urano.png", scene);
  163. material.diffuseTexture.hasAlpha = false;
  164. material.diffuseColor = new BABYLON.Color3(1, 1, 1);
  165. material.specularPower = 32;
  166. material.specularTexture = new BABYLON.Texture("urano.png", scene);
  167.  
  168.  
  169. //NEPTUNO
  170. var material = new BABYLON.StandardMaterial("materialneptuno", scene);
  171. neptuno.material = material;
  172. material.diffuseTexture = new BABYLON.Texture("neptuno.png", scene);
  173. material.diffuseTexture.hasAlpha = false;
  174. material.diffuseColor = new BABYLON.Color3(1, 1, 1);
  175. material.specularPower = 32;
  176. material.specularTexture = new BABYLON.Texture("neptuno.png", scene);
  177.  
  178. //Posicion inicial del sol
  179. particulas.rotation.x += 0.01
  180. //sol.position.x = 0
  181. //sol.position.y = 6.5
  182.  
  183.  
  184.  
  185.  
  186. // Animacion MERCURIO
  187.  
  188. var alpha = 0;
  189. scene.registerBeforeRender(function () {
  190. mercurio.rotation.x += 0.01;
  191. mercurio.rotation.z += 0.02;
  192. mercurio.position = new BABYLON.Vector3(Math.cos(alpha) *257, 10, Math.sin(alpha) * 257);
  193. alpha += 0.001087 //ALREDEDOR DE 87 DIAS TERRESTRES
  194. });
  195.  
  196.  
  197.  
  198. //Animacion VENUS
  199.  
  200. var beta = 0;
  201. scene.registerBeforeRender(function () {
  202. venus.rotation.x += 0.01;
  203. venus.rotation.z += 0.02;
  204. venus.position = new BABYLON.Vector3(Math.cos(beta) *308, 10, Math.sin(beta) * 308);
  205. beta += 0.0010254 ;//ALREDEDOR DE 254 DIAS TERRESTRES
  206. });
  207.  
  208.  
  209.  
  210. //Animacion TIERRA
  211.  
  212. var gamma = 0;
  213. scene.registerBeforeRender(function () {
  214. tierra.rotation.x += 0.01;
  215. tierra.rotation.z += 0.02;
  216. tierra.position = new BABYLON.Vector3(Math.cos(gamma) *349, 10, Math.sin(gamma) * 349);
  217. gamma += 0.00100365//ALREDEDOR DE 365 DIAS
  218. });
  219.  
  220.  
  221.  
  222. //Animacion MARTE
  223.  
  224. var delta = 0;
  225. marte.registerBeforeRender(function () {
  226. marte.rotation.x += 0.01;
  227. marte.rotation.z += 0.02;
  228. marte.position = new BABYLON.Vector3(Math.cos(delta) *427, 10, Math.sin(delta) * 427);
  229. delta += 0.00100686;//ALREDEDOR DE 686 DIAS
  230. });
  231.  
  232.  
  233.  
  234. //Animacion JUPITER
  235.  
  236. var epsilon = 0;
  237. scene.registerBeforeRender(function () {
  238. jupiter.rotation.x += 0.01;
  239. jupiter.rotation.z += 0.02;
  240. jupiter.position = new BABYLON.Vector3(Math.cos(epsilon) *998, 10, Math.sin(epsilon) * 998);
  241. epsilon += 0.00001004015;// ALREDEDOR DE 4015 DIAS
  242. });
  243.  
  244.  
  245.  
  246. //Animacion SATURNO
  247.  
  248. var dseta = 0;
  249. scene.registerBeforeRender(function () {
  250. saturno.rotation.x += 0.01;
  251. saturno.rotation.z += 0.02;
  252. saturno.position = new BABYLON.Vector3(Math.cos(dseta) *1629, 10, Math.sin(dseta) * 1629);
  253. dseta += 0.0010010585// ALREDEDOR DE 10585
  254. });
  255.  
  256.  
  257.  
  258. //Animacion URANO
  259.  
  260. var eta = 0;
  261. scene.registerBeforeRender(function () {
  262. urano.rotation.x += 0.01;
  263. urano.rotation.z += 0.02;
  264. urano.position = new BABYLON.Vector3(Math.cos(eta) *3070, 10, Math.sin(eta) * 3070);
  265. eta += 0.000010030660// ALREDEDOR DE 30660 DIAS
  266. });
  267.  
  268.  
  269.  
  270. //Animacion NEPTUNO
  271.  
  272. var iota = 0;
  273. scene.registerBeforeRender(function () {
  274. neptuno.rotation.x += 0.01;
  275. neptuno.rotation.z += 0.02;
  276. neptuno.position = new BABYLON.Vector3(Math.cos(iota) *4704, 10, Math.sin(iota) * 4704);
  277. iota += 0.000010059860;// ALREDEDOR DE 59860 DIAS
  278. });
  279.  
  280.  
  281.  
  282. //PLUTON NO EXISTE
  283.  
  284.  
  285.  
  286. return scene;
  287. };
  288.  
  289.  
  290. ////////////////////////////////////////
  291. ////////////////////////////////////////
  292. ////////////////////////////////////////
  293.  
  294. var scene = createScene();
  295.  
  296. engine.runRenderLoop(function () {
  297. scene.render();
  298. });
  299.  
  300. // Resize
  301. window.addEventListener("resize", function () {
  302. engine.resize();
  303. });
  304. </script>
  305. </body>
  306. </html>
Advertisement
Add Comment
Please, Sign In to add comment