Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////
- //SISTEMA SOLAR POR MANUEL PATIÑO LOPEZ//
- /////////////////////// //
- //REVISION 2/4/16//
- ///////////////////
- //INICIO DEL PROGRAMA
- var createScene = function() {
- var scene = new BABYLON.Scene(engine);
- // ArcRotateCamera >> Camera rotating around a 3D point (here Vector zero)
- // Parameters : name, alpha, beta, radius, target, scene
- var arcCamera = new BABYLON.ArcRotateCamera("ArcRotateCamera", 1, 0.8, 10, new BABYLON.Vector3(0, 0, 0), scene);
- arcCamera.setPosition(new BABYLON.Vector3(0, 0, 50));
- arcCamera.target = new BABYLON.Vector3(3, 0, 0);
- // FreeCamera >> You can move around the world with mouse and keyboard (LEFT/RIGHT/UP/DOWN)
- // Parameters : name, position, scene
- var freeCamera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(0, 0, 5), scene);
- freeCamera.rotation = new BABYLON.Vector3(0, Math.PI, 0);
- // TouchCamera >> Move in your world with your touch screen (or with your mouse, by drag/drop)
- // Parameters : name, position, scene
- var touchCamera = new BABYLON.TouchCamera("TouchCamera", new BABYLON.Vector3(0, 0, 10), scene);
- touchCamera.rotation = new BABYLON.Vector3(0, Math.PI, 0);
- //Attach a camera to the scene and the canvas
- scene.activeCamera = freeCamera;
- freeCamera.attachControl(canvas, true);
- //LUCES
- var light0 = new BABYLON.PointLight("Omni0", new BABYLON.Vector3(0, 0, 0), scene);
- light0.diffuse = new BABYLON.Color3(1, 01, 01);
- light0.specular = new BABYLON.Color3(1, 1, 1);
- var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene);
- //VARIABLES DE PLANETAS TAMAÑOS, ETC
- var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 200, scene); //POR FINES DIDACTICOS TOMAMOS EL RADIO DEL SOL A 200
- var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2.4, scene);//POR FINES DIDACTICOS LA ESCALA SERA RADIO/1000
- var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 6, scene);
- var tierra = BABYLON.Mesh.CreateSphere('sphere1', 6, 6.37, scene);
- var marte = BABYLON.Mesh.CreateSphere('sphere1', 6, 3.39, scene);
- var jupiter = BABYLON.Mesh.CreateSphere('sphere1', 6, 71.4, scene);
- var saturno = BABYLON.Mesh.CreateSphere('sphere1', 6, 60.26, scene);
- var urano= BABYLON.Mesh.CreateSphere('sphere1', 6, 25.5, scene);
- var neptuno = BABYLON.Mesh.CreateSphere('sphere1', 6, 24.7, scene);
- // TEXTURAS?¿
- sol.material = new BABYLON.StandardMaterial("texture1", scene);
- sol.material.ambientTexture = new BABYLON.Texture("grass.png", scene);
- //Posiciones iniciales
- sol.position.x = 0
- sol.position.y = 6.5
- // Animacion MERCURIO
- var alpha = 0;
- scene.registerBeforeRender(function () {
- mercurio.rotation.x += 0.01;
- mercurio.rotation.z += 0.02;
- mercurio.position = new BABYLON.Vector3(Math.cos(alpha) *257, 10, Math.sin(alpha) * 257);
- alpha += 0.001087 //ALREDEDOR DE 87 DIAS TERRESTRES
- });
- //Animacion VENUS
- var beta = 0;
- scene.registerBeforeRender(function () {
- venus.rotation.x += 0.01;
- venus.rotation.z += 0.02;
- venus.position = new BABYLON.Vector3(Math.cos(beta) *308, 10, Math.sin(beta) * 308);
- beta += 0.0010254 ;//ALREDEDOR DE 254 DIAS TERRESTRES
- });
- //Animacion TIERRA
- var gamma = 0;
- scene.registerBeforeRender(function () {
- tierra.rotation.x += 0.01;
- tierra.rotation.z += 0.02;
- tierra.position = new BABYLON.Vector3(Math.cos(gamma) *349, 10, Math.sin(gamma) * 349);
- gamma += 0.00100365//ALREDEDOR DE 365 DIAS
- });
- //Animacion MARTE
- var delta = 0;
- marte.registerBeforeRender(function () {
- marte.rotation.x += 0.01;
- marte.rotation.z += 0.02;
- marte.position = new BABYLON.Vector3(Math.cos(delta) *427, 10, Math.sin(delta) * 427);
- delta += 0.00100686;//ALREDEDOR DE 686 DIAS
- });
- //Animacion JUPITER
- var epsilon = 0;
- scene.registerBeforeRender(function () {
- jupiter.rotation.x += 0.01;
- jupiter.rotation.z += 0.02;
- jupiter.position = new BABYLON.Vector3(Math.cos(epsilon) *998, 10, Math.sin(epsilon) * 998);
- epsilon += 0.00001004015;// ALREDEDOR DE 4015 DIAS
- });
- //Animacion SATURNO
- var dseta = 0;
- scene.registerBeforeRender(function () {
- saturno.rotation.x += 0.01;
- saturno.rotation.z += 0.02;
- saturno.position = new BABYLON.Vector3(Math.cos(dseta) *1629, 10, Math.sin(dseta) * 1629);
- dseta += 0.000010010585// ALREDEDOR DE 10585
- });
- //Animacion URANO
- var eta = 0;
- scene.registerBeforeRender(function () {
- urano.rotation.x += 0.01;
- urano.rotation.z += 0.02;
- urano.position = new BABYLON.Vector3(Math.cos(eta) *3070, 10, Math.sin(eta) * 3070);
- eta += 0.000010030660// ALREDEDOR DE 30660 DIAS
- });
- //Animacion NEPTUNO
- var iota = 0;
- scene.registerBeforeRender(function () {
- neptuno.rotation.x += 0.01;
- neptuno.rotation.z += 0.02;
- neptuno.position = new BABYLON.Vector3(Math.cos(iota) *4704, 10, Math.sin(iota) * 4704);
- iota += 0.000010059860;// ALREDEDOR DE 59860 DIAS
- });
- //PLUTON NO EXISTE
- return scene;
- };
Advertisement
Add Comment
Please, Sign In to add comment