Search the Community

Showing results for tags 'obj'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 24 results

  1. Hello, For a test, I download a zip file. I extract files with JSZip. All files are OBJ files. I use babylon.objFileLoader for OBJ files. After extraction, I try to use BABYLON.SceneLoader.ImportMesh with rawData like this : var rawData = "data:" + contentOfFiles; BABYLON.SceneLoader.ImportMesh("", "model.obj", rawData, scene, function(){ console.log("Success"); }, function(){ console.log("PROGRESS"); }); But that's not work :((( I receive this message : importMesh of undefined from undefined version: undefined, exporter version: undefined importMesh has failed JSON parse Someone have an idea ? How can I import mu obj files ? Thanks Loïc
  2. Hi team, @Deltakosh I have a question relative to the optimization of my scene. I have to load a huge amount of building models to represent a 3D city enviroment. I need to improve the FPS of my scene. In recent days, I have tested the SPS but each building is a different mesh and I don't reach an important improvement. All of this buildings share the same texture and material but each of them have a lot of triangles... How can I get a great performance for rendering of all them? Thanks!
  3. Hi team, @jerome @Wingnut I have an question relative to solid particle system (SPS). I need to create a SPS composed with different buildings (.obj files). This is my code but i only can add one of them. How can I solve it? var models = function(edificios_texto) { var t = 0; var loader = new BABYLON.AssetsManager(scene); edificios_texto.forEach(function() { if(edificios_texto[t].length!=2){ return; } var edificio = loader.addMeshTask(t, "","<?=$url?>assets/modelos/",edificios_texto[t]+".obj"); var nM; //mesh of building edificio.onSuccess = function (task) { task.loadedMeshes.forEach(function(b) { b.scaling = new BABYLON.Vector3(2.65, 2.65, 2.65); b.rotation.y = Math.PI; b.computeWorldMatrix(true); var vertex_data = BABYLON.VertexData.ExtractFromMesh(b); for (var i = 0; i < vertex_data.normals.length; i+=3) { vertex_data.positions[i] *= -1; } vertex_data.applyToMesh(b); }); nM = BABYLON.Mesh.MergeMeshes(task.loadedMeshes); for (var i = 0; i < edificios.length; i++) { if(edificios[i].descripcion == edificios_texto[edificio.name]){ var myPositionFunction = function(particle, s) { var utmPlaceX = edificios[i].x; var utmPlaceZ = edificios[i].z; var utmPlaceXFromCentre = utmPlaceX - mapCentreX; var utmPlaceZFromCentre = utmPlaceZ - mapCentreZ; var x = utmPlaceXFromCentre/scaleX; var z = utmPlaceZFromCentre/scaleZ; particle.position.x = x; particle.position.z = z; particle.position.y = alturas[ edificios_texto[edificio.name]]; particle.color = new BABYLON.Color4(0, 0, 1,0.5); }; spsEdificios.addShape(nM, 1, {positionFunction: myPositionFunction}); nM.dispose(); break; } } var buildings = spsEdificios.buildMesh(); spsEdificios.mesh.hasVertexAlpha = true; } t++; }); loader.load(); }; Thanks!
  4. Hello I am still somewhat new to Babylon and i'm having the following problem. I am loading an .obj model into my scene and I wish to apply a standard material onto the meshes, after the model has loaded. But my problem is, that the materials are not applied in the success callback. I have a button to maually apply the materials and it works fine. document.getElementById("applyMaterials").addEventListener("click", function(e) { var meshMaterial = new BABYLON.StandardMaterial("meshMaterial", scene); meshMaterial.backFaceCulling = false; meshesGlobal.forEach(function(element) { element.material = meshMaterial; }, this); }); I have tried my code in the playground with the skull.babylon model and it works fine. http://www.babylonjs-playground.com/index.html#EAY2GH Am I missing someting? Thanks!
  5. Hello! I need to export my objects to obj. I found an example that I could adapt. But I can not incorporate the position of the object in the scene. Any idea? note: I'm a beginner*** BABYLON.Mesh.prototype.exportOBJ = function() { var output=[]; output.push("mtllib savedFile.mtl"); for(var i2 = 0; i2< selectedItems.length; i2++) { output.push("g object"+i2); output.push("o object_"+i2); output.push("usemtl material"+i2); var g = window[selectedItem[i2]].geometry; console.log(selectedItem[i2]); trunkVerts = g.getVerticesData('position'); trunkNormals = g.getVerticesData('normal'); trunkUV = g.getVerticesData('uv'); trunkFaces = g.getIndices(); for(var i=0;i<trunkVerts.length;i+=3){ output.push("v "+trunkVerts[i]+" "+trunkVerts[i+1]+" "+trunkVerts[i+2]); } for(i=0;i<trunkNormals.length;i+=3){ output.push("vn "+trunkNormals[i]+" "+trunkNormals[i+1]+" "+trunkNormals[i+2]); } for(i=0;i<trunkUV.length;i+=2){ output.push("vt "+trunkUV[i]+" "+trunkUV[i+1]); } for(i=0;i<trunkFaces.length;i+=3) { output.push( "f "+(trunkFaces[i+2]+1)+"/"+(trunkFaces[i+2]+1)+"/"+(trunkFaces[i+2]+1)+ " "+(trunkFaces[i+1]+1)+"/"+(trunkFaces[i+1]+1)+"/"+(trunkFaces[i+1]+1)+ " "+(trunkFaces[i]+1)+"/"+(trunkFaces[i]+1)+"/"+(trunkFaces[i]+1) ); } } var text = output.join("\n"); var fileBlob; try{ fileBlob=new Blob([text]); }catch(e){ var blobBuilder=window.BlobBuilder || window.MozBlobBuilder || window.WebKitBlobBuilder; var bb=new blobBuilder(); bb.append([text]); fileBlob=bb.getBlob(); } var URL=window.URL || window.webkitURL; var link=URL.createObjectURL(fileBlob); return link; }
  6. I'm trying to load an OBJ in the playground. There are 2 meshes in the OBJ with exact same number of vertices. This works in normal code when I use BABYLON.SceneLoader.Load() but when I use this special playground technique I get funny side-effects. One of the meshes is twice the number of vertices as the other one: http://www.babylonjs-playground.com/#28YUR5#202 You can see it in the console output. Is there another way to load an OBJ in the playground?
  7. Hello! I have been trying to load some OBJ files with Babylon. After a few attempts, I managed to get it up and running: BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; let loader = new BABYLON.AssetsManager(this.scene); loader.useDefaultLoadingScreen = false; let player_task = loader.addMeshTask('player_mesh', '', MESH_PATH, 'player.obj'); player_task.onSuccess = function (task) { // Meshes task.loadedMeshes.forEach(function(m) { m.position = BABYLON.Vector3.Zero(); m.scaling.x = 0.13; m.scaling.y = 0.13; m.scaling.z = 0.13; this.set_player_mesh(m); }.bind(this)); }.bind(this); } loader.onFinish = function() { this.babylon_engine.runRenderLoop(function () { this.scene.render(); }.bind(this)); }.bind(this); loader.load(); I had to create an empty 'player.obj.manifest', otherwise it would complain, and everything worked. All good here but when I try to load the same exact OBJ but converted into a .babylon file (I am doing this just because I need to import some animations), the mesh seems to be loaded but nothing gets displayed. I removed the 'BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true;' as it would not be needed and changed the filename to 'player.babylon. I tried testing it out on some playgrounds but still nothing. Are there other changes needed? Also, is there a way to just simply load an OBJ with animations without having to convert it to a babylon file? That would definitely save me tons of time... I have attached here the mesh I am using. Goku.babylon
  8. Hello! I'm importing an obj model, and I want to tweak the visibility of it, or just dispose it when I click a button... var loader = new BABYLON.AssetsManager(scene); var leg = loader.addMeshTask("leg", "", "", "leg.obj"); BABYLON.SceneLoader.ImportMesh("", "", "leg.obj", scene, function (newMesh) { BABYLON.SceneLoader.Load("", "leg.obj", engine, function (newScene) { }); }); $('#quadril_bt').click(function () { //........ something to dispose the mesh, or make it invisible }); Can't seem to find a way to do it!
  9. There is a lot of documentation about how to export from different formats and platforms to babylon. I didn't find the reverse so far, and at this point I don't know if it's because there isn't or there are too many results from obj to babylon, so I can't find them. I want my App to be able to give me a full 3D freeze scene, like a screenshot, of the scene the users/players creates. For sure I can take all meshes from my scene, diving in the documentation and build my own obj file, but before reinventing the wheel I hope there is already a good library for this. Thanks for your time.
  10. Hi all, Are there any way to set my import mesh (obj) to height of ground? I have done something similar with SPS but in this case I have to do this with differents meshes which have been imported to scene. Thanks!
  11. Hi, i would like to import an OBJ file into my scene and I have got it. However, I don't get change the position and scale of the mesh. ¿How could I do it? This is my code: var loader = new BABYLON.AssetsManager(scene); var edificioB4 = loader.addMeshTask("A2", "", "http://localhost:8080/modelos/A2/", "A2.obj"); BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; loader.load(); Thanks, JuanMa J.R.
  12. Hello everyone, First of all, thanks for all the amazing contents I managed to find here. It really helped me to understand better how BJS works. Background : I am much more a back-end developer, so excuse me if I lack (too much) knowledge about front-end or 3D modeling. Anyway, I learned some Unity and Unreal by myself and built several Unity applications (no games, regular mobile apps, Augmented Reality apps, ...) so I understand a bit how 3D modeling works (textures, UV maps, normal maps, materials, baking, ...). I am thinking about using BJS, but can't set a tech stack until I am sure that it can answer all my needs. That's why I started building some POCs with BJS. The need : To make it quick : I have an application where I want to integrate a frame with a single 3D object (with BJS). I want to interact with this object and change its look just by clicking on a button in the interface (in less than a second would be great). The objects will be multiparts : for example, the obj of a table would include a feet part and a top part. I want to be able to change the top part and the feet part textures/mats separately. I need the result to be in very high quality and to display fast enough (but since I don't want to build a full world, just a single object, I hope this will be OK). What I understood / What I tried : Thanks to some tutorials/samples, I loaded some models from .babylon or .obj files , in the Sandbox or in a local application. I managed to change mats for these meshes using some code of the "rabbit sample" (glass, metal, ... materials). If I'm not wrong, I'll be able to change textures (with a .jpg or .tga file), the behaviour of light (to create metalic, glass, wood or plastic behaviour), the color, ... with something like : mesh.material.diffuseTexture = new BABYLON.Texture(texture, scene); or var mat = new BABYLON.PBRMaterial("clay", scene); mat.cameraExposure = exposure; mat.cameraContrast = contrast; mat.microSurface = 0.06; mat.reflectivityColor = new BABYLON.Color3(0.5, 0.9, 0.9); mat.albedoColor = new BABYLON.Color3(0.5, 0.5, 1); Plus, if I understood well, I can "isolate" my mesh after it's instanciation with a "onSuccess" event, to be able to access it easily after loading the page (or loading a new item). I am planning to create a scene from scratch and add just a simple background and lights to make the object looks great by itself :). Here is what I didn't understood (or not sure about that) : Q1 : what's the good way to load an object and to identify every sub-part of it ? For example, if my (lovely and friendly) graphical artists build and export an .obj "object1" with 2 sub-parts called "obPart1" and "obPart2" with Maya or 3DSMax, what's the best way to interact with obPart1 and obPart2 after loading object1 in BJS ? Q2: Am I forced to play with many maps for one object, or can I obtain sufficient result using multi-part object and a BABYLON.PBRMaterial for each sub-part ? Q3 : What's the main difference between using a .obj or a .babylon ? I would clearly prefer to directly use .obj files (to stay closer to standards and avoid to use plugins) but would I miss something that I couldn't replace in my BJS scene (like a light...) ? Q4 : If I am smart enough (crossing fingers), I should be able to display a glossy wood and a not glossy one with only one .jpg texture, just by having 2 different BABYLON.PBRMaterial, right ? Am I wrong if I am thinking about doing the same thing to have a blue wood and a pink one (erm ... why not ?) ? Q5 : Last but not least : if I am smart enough (crossing fingers to death), I could build a back-office where I can upload .obj or .babylon, identify sub-parts of it, chose wich texture/mat can be applied on which sub-part, and use all of this in the "display" part of the application. I may be a dreamer (but i'm not the only one ...) but if I didn't miss some main specifications, I believe that this could be achieved with a clever architecture. Am I mad to think about that ? I (really) searched in this forum (and some others) and in the documentation, sorry if I missed the answers (or didn't understood the words I read). I am much more used to back-end technologies so I may have not been as efficient as I use to be, but I'll learn fast ;). Feel free to tell me if I understood some parts wrong. Thanks a lot for your experience and answers :).
  13. Hey guys, We just released a new loader for Babylon.js to read OBJ (and MTL) files. This loader is now part of Babylon 2.2 (but it's working on 2.1). As it's a loader, it is an external file that should be included in your project in you want to use it (as explained here) Here is a demo: give it some time, we tried to load BIG files Can you guess which game these assets are coming from ? I hope you will like it! Cheers
  14. Hello, I purchased a 3d scene in the file format of obj, as well as some texture files. The obj file has 187 MB. I tried using the following code to load the obj file (I tested my code with other obj sample files, works ok). However, after a while of loading, my webpage crashes afterwards. I uploaded the screenshot of the webpage after it crashes. I use babylon.2.4.js, babylon.objFileLoader.js, node.js for my web service and IIS for the server. I was wondering can anyone help me with this issue? Thank you so much!!! Yours Sincerely, Chi Xiao var camera, scene; window.addEventListener('DOMContentLoaded', function() { var canvas = document.getElementById('renderCanvas'); var engine = new BABYLON.Engine(canvas, true); engine.enableOfflineSupport = false; BABYLON.SceneLoader.Load("http://127.0.0.1:8082/scenes/kc8/", "kc8.obj", engine, function (newScene) { camera = new BABYLON.ArcRotateCamera("Camera", 3 * Math.PI / 2, Math.PI / 8, 50, BABYLON.Vector3.Zero(), newScene); camera.attachControl(canvas, true); var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), newScene); light.diffuse = new BABYLON.Color3(1, 1, 1); light.specular = new BABYLON.Color3(1, 1, 1); light.groundColor = new BABYLON.Color3(0, 0, 0); engine.runRenderLoop(function() { newScene.render(); }); window.addEventListener('resize', function() { engine.resize(); }); }); });
  15. hi, I have a problem. when i import obj mesh and auto load texture from obj file, I can't load the texture. this problem occurs some obj file. the first image is using Babylonjs, second is using Threejs. sources: BABYLON.SceneLoader.ImportMesh("", "/model/load/", "turbosonic.obj", scene, function (meshes) { }); help..
  16. After I import the mesh, if I don't change his position and if I don't change the camera's position, all is well. But I want after loading the mesh entirely intermeddle in screen, without zooming with the mouse wheel. If I change the mesh position it becomes impossible to twist the mouse. mesh.onSuccess = function (task) { m = task.loadedMeshes; for(var i = 1; i < m.length; i++) { m.position = new BABYLON.Vector3(25, -250, -40); } If I change the camera position also becomes impossible to twist the mouse. var cam = new BABYLON.ArcRotateCamera("ArcRotateCamera", 0, 1.8, 5, new BABYLON.Vector3(170, -50, 10), scene); Working option but the mesh won't fit in the screen. http://178.62.253.28/ test page After the change of position of the mesh loaded it does not work normally turn the mouse. http://178.62.253.28/pos_mesh test page http://178.62.253.28/st/z_pm.js If you change the camera's position is also that the mesh can't be controlled. http://178.62.253.28/pos_cam test page http://178.62.253.28/st/z_pc.js
  17. I'm trying out the .OBJ loader and comparing it with the standard .babylon loader. I noticed that the .OBJ will show the UV seams. Does anyone know how to prevent this happening? I also get a bunch of console errors with .OBJ: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. Unable to compile effect with current defines. Trying next fallback. Vertex shader:default Fragment shader:default This is the .babylon loader (no seams) http://www.punkoffice.com/sandy/ This is the .OBJ loader (seams) http://www.punkoffice.com/sandy/?format=obj
  18. I load the mesh .obj, does not have .mtl, and then assign texture. var mesh = loader.addMeshTask("mesh1", "", "/file/", "mesh.obj"); mesh.onSuccess = function (task) { var m = task.loadedMeshes[0]; m.position = new BABYLON.Vector3(100, 500, 100); m.material = new BABYLON.StandardMaterial("texture1", scene); m.material.diffuseTexture = new BABYLON.Texture( "/file/diffuse.png", scene); m.material.specularTexture = new BABYLON.Texture( "/file/specular.png", scene); m.material.ambientTexture = new BABYLON.Texture( "/file/ambient.png", scene); m.material.bumpTexture = new BABYLON.Texture( "/file/bump.png", scene); } But the texture is not assigned to an object. Am I doing something wrong or this may be a problem with the mesh ?
  19. Hey guys, i get this error message SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data if i run this code <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Babylon.js sample code</title> <!-- Babylon.js --> <script src="http://www.babylonjs.com/hand.minified-1.2.js"></script> <script src="http://www.babylonjs.com/cannon.js"></script> <script src="http://www.babylonjs.com/oimo.js"></script> <script src="http://www.babylonjs.com/babylon.js"></script> //<script src="Babylon.js"></script> <script src="babylon.stlFileLoader.js"></script> //<script src="babylon.objFileLoader.js"></script> <style> html, body { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; } #renderCanvas { width: 100%; height: 100%; touch-action: none; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script> // Erstelle Canvas und Engine var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { // This creates a Babylon Scene object (not a shape/mesh) var scene = new BABYLON.Scene(engine); // This creates and positions an free camera var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); // This targets the camera to scene origin camera.setTarget(new BABYLON.Vector3.Zero()); // This attaches the camera to the canvas camera.attachControl(canvas, false); // This creates a light - aimed 0,1,0 - to the sky. var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); // Dim the light a small amount light.intensity = .5; // Leave this function return scene; }; // Erstelle Scene var scene = createScene(); // Lade .STL ein BABYLON.SceneLoader.Load("/samples/", "ship.stl", engine, scene); /*BABYLON.SceneLoader.Load("", "ship.stl", engine, function (newScene) { newScene.activeCamera.attachControl(canvas, false); engine.runRenderLoop(function () { newScene.render(); }); });*/ // Zeichne engine.runRenderLoop(function () { scene.render(); }); // Resize window.addEventListener("resize", function () { engine.resize(); }); </script> </body> </html> in FireFox. I just want to load and show a stl or obj File.
  20. Hi all, My name is Xander and i have a problem with not knowing how to import a mesh by searching a .obj file on your pc with babylonjs. my project is running on this url: minegame.nl please take a look. its already possible to search a file. Please help, Thank you, Xander
  21. There is a problem with obj loader. It return meshes before materials (mtl file) are loaded. That's because it doesn't wait for _loadMTL (https://github.com/BabylonJS/Babylon.js/blob/master/loaders/OBJ/babylon.objFileLoader.js#L696) callback to be finished. So inside my loadMesh task i have undefined materials and i cannot manipulate with them. This is sad
  22. Hi all - am loading meshes from single OBJ files into Babylon running in Chrome and am seeing what looks like a hard limit on the max number of facets somewhere between 400,000 and 500,000. Don't get me wrong - to be able to get anywhere near that number in a browser is absolutely astonishing, but am curious whether anyone knows where the limit's coming from. Can load the same models into MeshLab and my own DirectX code, so it isn't RAM (I've got 32GB) or the graphics card (GTX 690); is the code limiting it in some way, or could I get round it by segmenting the meshes and loading multiple models? All suggestions welcome!
  23. Hi, Im new to Babylon.js but it seems fun, I have a simple question about the code below. It imports models and places them in random positions, whats the most efficient way to re-randomise the positions every second? I tried with setTimeout(function(){ window.location.reload(1); }, 5000); but this was a bit heavy, is there a way to just call the randomise bit again. Also is this the most efficient way to load multiple models, the hardware I'm targeting is slow so anything I can do to get a bit more performance is best- maybe I should clone the objects? Thanks <!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/> <title>Babylon Test</title> <!--- link to the last version of babylon ---> <script src="babylon.2.2.js"></script> <script src="babylon.objFileLoader.js"></script> <style> html, body { overflow: hidden; width : 100%; height : 100%; margin : 0; padding : 0; } #renderCanvas { width : 100%; height : 100%; touch-action: none; } </style></head><body> <canvas id="renderCanvas"></canvas> <script> window.addEventListener('DOMContentLoaded', function(){ // get the canvas DOM element var canvas = document.getElementById('renderCanvas'); // load the 3D engine var engine = new BABYLON.Engine(canvas, true); // createScene function that creates and return the scene var createScene = function() { // create a basic BJS Scene object var scene = new BABYLON.Scene(engine); // create a FreeCamera, and set its position to (x:-10, y:10, z:-10) var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(10, 10,-10), scene); camera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA; camera.orthoTop = 2.5; camera.orthoBottom = -2.5; camera.orthoLeft = -5; camera.orthoRight = 5; // target the camera to scene origin camera.setTarget(BABYLON.Vector3.Zero()); // attach the camera to the canvas camera.attachControl(canvas, false); // create a basic light, aiming 0,1,0 - meaning, to the sky var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), scene); // create a built-in "sphere" shape; its constructor takes 5 params: name, width, depth, subdivisions, scene var loader = new BABYLON.AssetsManager(scene); var meshNames = ["hex.obj", "cross.obj"]; var noOfMeshesToBuild = 6; var boundingBox = new BABYLON.Vector3(4,4,6); for (var i = 0; i < noOfMeshesToBuild; i++){ var cross = loader.addMeshTask("mesh" + i, "", "assets/", meshNames[Math.floor(Math.random() * meshNames.length)]); cross.onSuccess = function (task) { task.loadedMeshes[0].position = new BABYLON.Vector3((Math.random() -0.5) * boundingBox.x, (Math.random() -0.5) * boundingBox.x, (Math.random() -0.5) * boundingBox.x); }; }; loader.onFinish = function() { engine.runRenderLoop(function () { scene.render(); }); }; loader.load(); // return the created scene return scene; } // Now, call the createScene function that you just finished creating 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(); }); }); }); </script></body></html>
  24. Hi all, am trying to convert my obj and fbx model with the online converter which i found here http://www.babylonjs.com/converter.html am trying few days,i can convert the model as .babylon format, but after that am trying to load my model on the babylon.js but i can't see any textures applied to my converted model, what is wrong ? what i have to do here ? am struggling here with the last 3 days, but no clue attached is my `iPhone5_FBX.zip` which is my source file and output(1).zip is my output file which i got from the converter page iPhone5_FBX.zip output(1).zip