Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // You have to create a function called createScene. This function must return a BABYLON.Scene object
- // You can reference the following variables: scene, canvas
- // You must at least define a camera
- // More info here: https://github.com/BabylonJS/Babylon.js/wiki/The-Playground
- var createScene = function() {
- var scene = new BABYLON.Scene(engine);
- var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
- camera.attachControl(canvas, false);
- //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 planetas
- var sol = BABYLON.Mesh.CreateSphere('sphere1', 16, 22, scene);
- var mercurio = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);
- var venus = BABYLON.Mesh.CreateSphere('sphere1', 6, 5, scene);
- // Posiciones iniciales
- sol.position.x = 0
- sol.position.y = 6.5
- mercurio.position.x = 0
- mercurio.position.y = 0
- venus.position.y =0
- venus.position.x=0
- // 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) *20, 10, Math.sin(alpha) * 20);
- alpha += 0.01;
- });
- //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) *30, 20, Math.sin(beta) * 30);
- beta += 0.02;
- });
- //Animacion Tierra
- return scene;
- };
Add Comment
Please, Sign In to add comment