Mrm2299

SOLAR SYSTEM (0.3)

Mar 27th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 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.  
  22.  
  23. // Variables planetas
  24. var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 22, scene);
  25. var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);
  26. var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 5, scene);
  27.  
  28. // Posiciones iniciales
  29. sol.position.x = 0
  30. sol.position.y = 6.5
  31. mercurio.position.x = 0
  32. mercurio.position.y = 0
  33. venus.position.y =0
  34. venus.position.x=0
  35.  
  36. // Animacion MERCURIO
  37. var alpha = 0;
  38. scene.registerBeforeRender(function () {
  39. mercurio.rotation.x += 0.01;
  40. mercurio.rotation.z += 0.02;
  41. mercurio.position = new BABYLON.Vector3(Math.cos(alpha) *20, 10, Math.sin(alpha) * 20);
  42. alpha += 0.01;
  43.  
  44. });
  45.  
  46.  
  47. //Animacion Venus
  48. var beta = 0;
  49. scene.registerBeforeRender(function () {
  50. venus.rotation.x += 0.01;
  51. venus.rotation.z += 0.02;
  52. venus.position = new BABYLON.Vector3(Math.cos(beta) *30, 20, Math.sin(beta) * 30);
  53. beta += 0.02;
  54.  
  55. });
  56.  
  57.  
  58. //Animacion Tierra
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. return scene;
  66. };
Add Comment
Please, Sign In to add comment