mout99 Posted July 2, 2017 Share Posted July 2, 2017 I can see through my obj, how to concert it? // Get the canvas element from our HTML below var canvas = document.querySelector("#renderCanvas"); // Load the BABYLON 3D engine var engine = new BABYLON.Engine(canvas, false); // ------------------------------------------------------------- // Here begins a function that we will 'call' just after it's built var createScene = function () { var scene = new BABYLON.Scene(engine); //Adding a light var light = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene); light.diffuse = new BABYLON.Color3(1, 1, 1); light.intensity = 0.6; light.groundColor = new BABYLON.Color3(1, 1, 1); light.direction = new BABYLON.Vector3(0, -1, 0); //Adding an Arc Rotate Camera var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene); camera.wheelPrecision = 100.0; camera.attachControl(canvas, false); // The first parameter can be used to specify which mesh to import. Here we import all meshes BABYLON.SceneLoader.ImportMesh("", "obj/", "teste.obj", scene, function (newMeshes) { BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; var zeromat = new BABYLON.StandardMaterial("zeromat", scene); zeromat.diffuseTexture = new BABYLON.Texture("obj/back2.jpg", scene); zeromat.backFaceCulling = true; zeromat.wireframe = false; scene.meshes[0].material = zeromat; var meiomat = new BABYLON.StandardMaterial("meiomat", scene); meiomat.diffuseColor = new BABYLON.Color3(0.9, 0.9, 0.9); scene.meshes[1].material = meiomat; // Set the target of the camera to the first imported mesh // camera.maxZ = 100; camera.maxZ = 0; camera.setPosition(new BABYLON.Vector3(7000,7000,7000)); camera.target = newMeshes[0]; camera.wheelPrecision = 0.1; }); // Move the light with the camera scene.registerBeforeRender(function () { }); return scene; } var scene = createScene(); // Register a render loop to repeatedly render the scene engine.runRenderLoop(function () { scene.render(); }); // Watch for browser/canvas resize events window.addEventListener("resize", function () { engine.resize(); }); Quote Link to comment Share on other sites More sharing options...
adam Posted July 2, 2017 Share Posted July 2, 2017 I would try flipFaces: https://github.com/BabylonJS/Babylon.js/blob/19e68dfffc7a36243da0b72650b4bee7596664cc/src/Mesh/babylon.mesh.ts#L1750 Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 2, 2017 Author Share Posted July 2, 2017 how I use? did not quite understand Quote Link to comment Share on other sites More sharing options...
adam Posted July 2, 2017 Share Posted July 2, 2017 Call flipFaces on the mesh once when it is loaded. yourMesh.flipFaces(true); Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 2, 2017 Author Share Posted July 2, 2017 Unfortunately it did not help, is there anything else I can do? Thank you anyway for the help. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 3, 2017 Share Posted July 3, 2017 Can you provide a repro in the PG You can also try material.backFaceCulling = false; Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 3, 2017 Author Share Posted July 3, 2017 When I apply material.backFaceCulling = false; , It looks like this: Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 3, 2017 Share Posted July 3, 2017 So please share a repro on the PG. It is nearly impossible to help you with just a pic Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 4, 2017 Author Share Posted July 4, 2017 here it i https://www.babylonjs-playground.com/#NC5QEE I attached the .obj file also if PG does not work teste.obj Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 4, 2017 Author Share Posted July 4, 2017 I tried with another file and the result was this: Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 4, 2017 Share Posted July 4, 2017 Your PG does not work...we are getting a CORS issue. Can you try to save it to github. I know we can load it from there with rawgit CDN. Can you make sure you export your objects in left handed mode? Can you try another format (like gltf?) or load your obj in blender and export a .babylon from there Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 4, 2017 Author Share Posted July 4, 2017 You can not download my attachment and see if it works there ?, I also tried using a .stl loader but I did not succeed Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 4, 2017 Share Posted July 4, 2017 No I cannot Help me helping you Quote Link to comment Share on other sites More sharing options...
mout99 Posted July 4, 2017 Author Share Posted July 4, 2017 See, I made a progress, I removed the camera.maxZ = 0; That there was in the code, now the obj appears, but it is disappearing with the distance what I do to solve now? -edit: Finally I managed to solve, but I had to put the value camera.maxZ = 45000; Is not that going to be a problem? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 5, 2017 Share Posted July 5, 2017 Hey, good to hear that you solved it. Yeah, big numbers in camera.maxZ are normal and necessary... when you have big numbers like... camera.setPosition(new BABYLON.Vector3(7000,7000,7000)); Yesterday, I worked on your playground a bit, and had some problems getting .obj to load in playground. Then I got too busy in my real life. I came back this morning to do more testing... and you have it solved. Well done! As you noticed, forum helpers REALLY LIKE playground demos that can reproduce/show the problem. As a less-popular alternative, helpers like zips of the entire project... .blend files, .babylon files, html, JS, etc. These helper preferences might seem strict and uncaring, now... but later, when you become a forum helper... you will agree. Playground demos that show the problem... REALLY helps the forum helpers... a lot. Sometimes, our over-worked forum helpers are working 5-8 issues per day, and it gets "heavy". Sometimes, it is VERY necessary to use playgrounds... simply to help with the work-load. BabylonJS is very popular... lots of people use it. I hope you didn't get discouraged. You did great, though. You tried to get us a playground, and then you kept experimenting... and you had success. MY best friend... is the "search in code" (right side) input box... at our playground search page. Search for correct keywords/terms, and the searcher will nicely-help with issues and learning. It is like having a personal BJS teacher... 24 hours per day. I bet I have used that searcher over 500 times, so far. I love it. It is my buddy. Be well, M... cya around the forum. Please mark thread as solved if/when finished with it. Thx. 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.