Shawn Dao Posted August 2, 2016 Share Posted August 2, 2016 I'm a beginner with babylonjs. I'm trying to make a demo to see how it's work. Everything work fine with "Bane, Batman, Penguin" sample But when i try to load the model downloaded from sketchfab.com it just not working properly. Here what i've got. What's happening? What am i missing? Here the entire code // The first step is to get the reference of the canvas element from our HTML document: var canvas = document.getElementById('renderCanvas'); // Then, load the Babylon 3D engine: var engine = new BABYLON.Engine(canvas, true); // After that, we create our scene. In order to keep your program compatible with the Babylon.js Playground, we recommend that you insert a "createScene" function at this point. Beside generating a Babylon Scene Object, createScene() is where you will add your basic scene requirements: a camera, a light, and two basic meshes (a sphere and a ground plane). var createScene = function() { // This creates a basic Babylon Scene object (non-mesh) var scene = new BABYLON.Scene(engine); // Light new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); // Uncaught Error: No camera defined var cam = new BABYLON.ArcRotateCamera("ArcRotateCamera", 0, 0, 5, new BABYLON.Vector3(0, 3, 0), scene); // Panning: Ctrl + Left click => Right click // AttachControl Params: canvas, noPreventDefault, useCtrlForPanning cam.attachControl(canvas, true, false); var loader = new BABYLON.AssetsManager(scene); var obj = loader.addMeshTask("azir", "", "sample/azir/", "b_azir.obj"); loader.onFinish = function() { engine.runRenderLoop(function() { scene.render(); }); }; loader.load(); return scene; }; // Now that our createScene() function is ready, we need to call it: var scene = createScene(); // The next three javascript lines are very important, as they register a render loop to repeatedly render the scene on the canvas: engine.runRenderLoop(function() { scene.render(); }); // Lastly, you should implement a little canvas/window resize event handler, like this: window.addEventListener('resize', function() { engine.resize(); }); Expectation: https://sketchfab.com/models/a3aa2827a6764f90aede27b9c0d5a630 azir.zip Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 2, 2016 Share Posted August 2, 2016 A few things to check: 1) is the .mtl file included in the object 2) are the textures loading correctly 3) is the light strong enough? (dunno, the entire scene looks a bit dark, also with the other models). 4) have you loaded the object in a different application (like meshlab for example)? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 2, 2016 Share Posted August 2, 2016 @RaananW it just don't working out of the box http://www.babylonjs-playground.com/#RBMUC#2 Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 2, 2016 Share Posted August 2, 2016 Seems like it is working in your demo, what do you mean by "not working out of the box"? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 2, 2016 Share Posted August 2, 2016 I don't know exactlyload texture form Obj file err i really don't know, i just see that some floating point numbers are changed. in How to apply show diffuse texture with PBR? the material is not overloading to a scene. here http://www.html5gamedevs.com/topic/24210-textures-not-loaded/ the mirror material of the obj has refuses babylonjs from load. i think something with babylonjs the reflectionTexture texture. Quote Link to comment Share on other sites More sharing options...
RaananW Posted August 2, 2016 Share Posted August 2, 2016 Sorry, I can't follow You pasted before a demo of the loader, where the object is perfectly shown. Did you modify the object in any way? Obj doesn't support PBR, it only supports the standard material. if you want to use PBR you will have to create it by yourself and attach it to the right mesh. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 2, 2016 Share Posted August 2, 2016 https://translate.google.de/?espv=2&bav=on.2,or.r_cp.&biw=1364&bih=668&dpr=1&ion=1&um=1&ie=UTF-8&hl=en&client=tw-ob#auto/fr/yes i modify them in one or in another way%2C obj works not out of the box. i will do some test later (maybe) Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 2, 2016 Share Posted August 2, 2016 the workaround for this file Quote Link to comment Share on other sites More sharing options...
Shawn Dao Posted August 3, 2016 Author Share Posted August 3, 2016 2 hours ago, Nabroski said: the workaround for this file Thanks, let me try Quote Link to comment Share on other sites More sharing options...
Shawn Dao Posted August 3, 2016 Author Share Posted August 3, 2016 11 hours ago, RaananW said: A few things to check: 1) is the .mtl file included in the object 2) are the textures loading correctly 3) is the light strong enough? (dunno, the entire scene looks a bit dark, also with the other models). 4) have you loaded the object in a different application (like meshlab for example)? 1. I saw this line mtllib b_azir.mtl in the object 2. How can i check it? 3. I dont think it's related to the light because the texture quite clearly 4. Not yet. But I'm going to use babylonjs for my project so need to workaround to fix it. and i think Nabroski had it. Quote Link to comment Share on other sites More sharing options...
Shawn Dao Posted August 3, 2016 Author Share Posted August 3, 2016 @Nabroski Help me with this, I'm using Blender to edit the object but it's not looks like you did Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 3, 2016 Share Posted August 3, 2016 they changes something inside blender, and im too lazy to read the doc this one is working out of the box with objhttps://download.blender.org/release/Blender2.62/ Quote Link to comment Share on other sites More sharing options...
Shawn Dao Posted August 3, 2016 Author Share Posted August 3, 2016 Does this workaround fix the babylonjs issue @Nabroski ? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 3, 2016 Share Posted August 3, 2016 @Shawn Dao the last time i tested it it works, report if you run into troubles, ask questions etc. i also changed the texture from .tga to .png, but try the simplest solution first. Good Luck Quote Link to comment Share on other sites More sharing options...
Shawn Dao Posted August 3, 2016 Author Share Posted August 3, 2016 Hi @Nabroski I can see the textures on the Blender now. What's next? I have tried to export the model and load it from the babylonjs. Same result. Btw: What is simplest solution you mean? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 3, 2016 Share Posted August 3, 2016 you have to delate the material and create a new material inside blender and then export it to obj, its only two clicks. you can do it also with babylonjs, also very easyhttp://www.babylonjs-playground.com/#RBMUC#3 Good Luck Quote Link to comment Share on other sites More sharing options...
Shawn Dao Posted August 3, 2016 Author Share Posted August 3, 2016 You're my saver @Nabroski, thank you very much for the babylonjs sample. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.