Félix Flores

  • Content count

  • Joined

  • Last visited

  1. long loading time

    Thanks for the answer, I ´m using instances, and for the models I reduced the resolution using mesh lab, for the others objects I'm using planes with textures. maybe If I reduce the textures resolution.
  2. long loading time

    Hello again. I continue develop a site with babylonjs, but I have a few problems. I have a scene created with blender, I generate the babylon file, the scene has some textures, I converted the textures to a ktx format, with the script in the babylon page. You can see the page in: http://entornomexicano.com/ I import the scene with: if (!BABYLON.Engine.isSupported()){ console.log("Motor no soportado"); return; } canvas = document.getElementById("renderCanvas"); engine = new BABYLON.Engine(canvas, true); // Asignamos los tipos de textura compimidos que se pueden usar var available = ['-astc.ktx', '-dxt.ktx', '-pvrtc.ktx', '-etc1.ktx', '-etc2.ktx']; var formatUsed = engine.setTextureFormatToUse(available); BABYLON.SceneLoader.Load(blendPath + "scene1/", "landScape.babylon", engine, function (newScene) { // asignamos la escena scene = newScene; // Creamos el entorno y las luces createSkybox("models/scene1/sky2.jpg"); createWaterMesh("waterMesh", imgPath + "waterbump.png", new BABYLON.Vector3(0, -0.08, 0), 6, getMeshListToRender()); createCamera(1, new BABYLON.Vector3(-0.23, 0.56,-2.73), new BABYLON.Vector3(0, 0, 0)); // arch camera createParticleSystem(); createLights(); createShadows(); createVolumetricLightEffect(); createActionsContollers(); // Wait for textures and shaders to be ready scene.executeWhenReady(function () { // Quitamos la imagen del cargador cuando termine el proceso de carga $("#loaderPadre").remove(); scene.createOrUpdateSelectionOctree(); // quitamos los calculos de los objetos para hacer mas eficiente la escena scene.meshes.forEach(function (mesh) { if(mesh.name.search("NO_") === -1) mesh.freezeWorldMatrix(); }); // Funcion para cuando se redimensiona la ventana $(window).on('resize', function() { engine.resize(); }); // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function() { // console.log(engine.getFps()); scene.render(); }); }); }, function (progress) { if(progress.total == 0) return; $(".textoCarga").text( ((progress.loaded/progress.total)*100).toFixed(2) + "%"); }); In the callback function I return the loadign progress, but in some devices the progres is too slow, and When I already have 100% the scene still takes time to show, maybe i have doing some wrong. Somebody know, What I can do for resolve that? And other problem is the performance of the scene, I rremoved some elements and I have down the quality of the shadows, but the fps is 30, How I can increase the speed? the complete code is in: https://github.com/flelix/entorno-models.git in the folder: entorno-models/code/proyBabylon/entorno/ here you can see the project. I hope you can help me. Thanks and regards.
  3. How to turn off and turn on lights, correctly

    Hey thanks for the advice, I will try do that, but the link that you share me doesn't works
  4. Hello, I am developing a 3d page, with babylonjs, I have the scene, that I am modeling and exporting in "blender" to a babylon file. In code I am adding shadows and lights, some of these lights I need turn on an turn off whe the lamp is clicked. I create the lights like this: //Luz global light[0] = new BABYLON.DirectionalLight("LuzGlobal", new BABYLON.Vector3(0, -1, 1), scene); light[0].diffuse = new BABYLON.Color3(1, 1, 1); light[0].specular = new BABYLON.Color3(1, 1, 1); light[0].direction = new BABYLON.Vector3(0, -1, 1); light[0].position.x = 27; light[0].position.y = 28; light[0].position.z = -89; light[0].intensity = 1.0; //createLensFlare(); //Creamos las luces de las lamparas light[1] = new BABYLON.SpotLight("lampara1", scene.getMeshByName("lamp1").position, new BABYLON.Vector3(0, -1, 0), 0.8, 2, scene); light[1].diffuse = new BABYLON.Color3(1, 1, 1); light[1].specular = new BABYLON.Color3(1, 1, 1); light[2] = new BABYLON.SpotLight("lampara2", scene.getMeshByName("lamp2").position, new BABYLON.Vector3(0, -1, 0), 0.8, 2, scene); light[2].diffuse = new BABYLON.Color3(1, 1, 1); light[2].specular = new BABYLON.Color3(1, 1, 1); light[3] = new BABYLON.SpotLight("lampara3", scene.getMeshByName("lamp3").position, new BABYLON.Vector3(0, -1, 0), 0.8, 2, scene); light[3].diffuse = new BABYLON.Color3(1, 1, 1); light[3].specular = new BABYLON.Color3(1, 1, 1); light[4] = new BABYLON.SpotLight("lampara4", scene.getMeshByName("lamp4").position, new BABYLON.Vector3(0, -1, 0), 0.8, 2, scene); light[4].diffuse = new BABYLON.Color3(1, 1, 1); light[4].specular = new BABYLON.Color3(1, 1, 1); And I switch the state like this: // Apagamos o prendemos la luz de la lampara 1 scene.getMeshByName("lamaparaCalle1").actionManager = new BABYLON.ActionManager(scene); scene.getMeshByName("lamaparaCalle1").actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function (evt) { if(light[1].isEnabled() == true){ light[1].setEnabled(false); if(scene.getMeshByName("vlsT1") != null) scene.getMeshByName("vlsT1").setEnabled(false); } else{ light[1].setEnabled(true); if(scene.getMeshByName("vlsT1") != null) scene.getMeshByName("vlsT1").setEnabled(true); } })); // Apagamos o prendemos la luz de la lampara 2 scene.getMeshByName("lamaparaCalle2").actionManager = new BABYLON.ActionManager(scene); scene.getMeshByName("lamaparaCalle2").actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function (evt) { if(light[2].isEnabled() == true){ light[2].setEnabled(false); if(scene.getMeshByName("vlsT2") != null) scene.getMeshByName("vlsT2").setEnabled(false); } else{ light[2].setEnabled(true); if(scene.getMeshByName("vlsT2") != null) scene.getMeshByName("vlsT2").setEnabled(true); } })); // Apagamos o prendemos la luz de la lampara 3 scene.getMeshByName("lamaparaCalle3").actionManager = new BABYLON.ActionManager(scene); scene.getMeshByName("lamaparaCalle3").actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function (evt) { if(light[3].isEnabled() == true){ light[3].setEnabled(false); if(scene.getMeshByName("vlsT3") != null) scene.getMeshByName("vlsT3").setEnabled(false); } else{ light[3].setEnabled(true); if(scene.getMeshByName("vlsT3") != null) scene.getMeshByName("vlsT3").setEnabled(true); } })); // Apagamos o prendemos la luz de la lampara 4 scene.getMeshByName("lamaparaCalle4").actionManager = new BABYLON.ActionManager(scene); scene.getMeshByName("lamaparaCalle4").actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function (evt) { if(light[4].isEnabled() == true){ light[4].setEnabled(false); if(scene.getMeshByName("vlsT4") != null) scene.getMeshByName("vlsT4").setEnabled(false); } else{ light[4].setEnabled(true); if(scene.getMeshByName("vlsT4") != null) scene.getMeshByName("vlsT4").setEnabled(true); } })); But the first time that i turn off the lights the scene is paused and then continue, what is the best way to do that? maybe I am doing something wrong. the complete source is: https://github.com/flelix/entorno-models.git the project path is: entorno-models/code/proyBabylon/p2/ thanks and regards
  5. Problem loading babylon file from host

    Hey thanks @aWeirdo, the problem was one uppercase letter in the file name.
  6. Hello I want to load a scene generated from blender, the generated file is .babylon, in my local, I have no a problem loadding the sene but in the host I can´t, in the console I have the next problem: Uncaught Error: Error status: 404 - Unable to load models/scene1/landScape.babylon at XMLHttpRequest.e.onreadystatechange (babylon.custom.js:3) Searching in google I se that I need to add mime types but I don´t know how. my html code is: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Entorno Mexicano</title> <link href="css/style.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> <canvas id="renderCanvas"></canvas> <!-- Carga de los js que se utilizan --> <!-- Babylon.js --> <script src="js/babylon.custom.js"></script> <script src="js/jquery-3.1.0.min.js"></script> <!-- codigo js personalizado --> <script src="js/main.js"></script> </body> </html> and my js file is: if (BABYLON.Engine.isSupported()) { canvas = document.getElementById("renderCanvas"); engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("models/scene1/", "landScape.babylon", engine, function (newScene) { scene = newScene; // Wait for textures and shaders to be ready scene.executeWhenReady(function () { // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function() { scene.render(); }); // Funcion para cuando se redimensiona la ventana $(window).on('resize', function() { engine.resize(); }); }); }, function (progress) { $(".textoCarga").text( ((progress.loaded/progress.total)*100).toFixed(2) + "%"); }); } Any idea why I can do Thanks an regards
  7. Hello This is my first Time in this forum. I am doing a scene with babylon js and I am using water material for some elements, when the mesh is created in code with createGround function it works fine, but when I import scene from blender, and add water material to any mesh, the result is not the expected. some one know what is the process to do that. thanks