Search the Community

Showing results for tags 'obj'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


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

Found 38 results

  1. Hello, I'm importing a new OBJ file with the MTL and texture into my scene every 30 seconds. When I import, I dispose of an existing OBJ and MTL, and declare their variable (array) as null. But my frame rate continues to drop as I add and dispose of objects - even though there is only 20 heads at a time in the scene - never more. But my fps drops from over 40fps to under 20fps once I add less than 10 new heads and dispose of an equal amount. I've even forced dispose, but fps still drops. Thanks, DB
  2. Hello folks, i try load an .obj file and modify the material/texture scaling. Loading goes well, but not scaling of the textures When i try to access the material object i get a undefined error. meshes[0].material is undefined, in the screen shot you can see the property is there. I dont know what i do wrong // first param: ["myMesh1", "myMesh2"] // BABYLON.SceneLoader.ImportMesh("", "./assets/temp/house/", "restaurant.obj", game.scene, function (meshes, particleSystems, skeletons) { // do something with the meshes and skeletons // particleSystems are always null for glTF assets //console.log(meshes, particleSystems, skeletons); console.log(meshes[0]); });
  3. Hello, I hope someone knows how to do this - I need to have a scene running, and also a scanner beside it. As scanned heads are added to the scene as OBJ files, I need them loaded and rendered in the scene without disposing of the scene. The paths to the new files must be added to an array. I currently have a test scene online, and am loading 2 heads at the start. Then I have a left mouse event add a new file path and folder to the array - but don't know how to tell the loader to load again from the new path. I can delete any path in the array which has already had an OBJ loaded from it, as the path will only be used once. The online scene is below - it might need to be loaded twice the first time. The main JS code is as follows: I appreciate it if you can assist. Thanks, DB
  4. Hi, I´m new to BJS and trying to get along with a 3D visualization for warehouses. The 2D visualization already work pretty well, the coordinates are stored in a DB running on a remote server. Target is to provide a library of rack elements (frames and beams) of different dimensions (height, width, length). I can provide a JSON from server-side Java-application with all the necessary data (rack id, rack type, coordinates, etc.) I´m using OBJFileLoader for importing obj and mtl which works fine as well. This is 2D visualization of a warehouse: Every blue rectangle is a warehouse rack consisting of two frames an a bunch of beam pairs: Both elements, frame and beam, come from separate obj-files. In the end of the day, i want to have something like this: The displayed meshes are kind of super simple, but perfect for playing around with BJS (i´ve all models in high poly as well). For some reason I can´t move (or change) meshes imported by this method: I can specify the mesh position while importing like this (works for the sphere btw.): var loader = new BABYLON.AssetsManager(scene); var pos = function(t){ t.loadedMeshes.forEach(function(m){ var meshName =; var meshID =; m.position.z = 5; m.position.x = 7; }); }; var steher1 = loader.addMeshTask("steher_2500_900_120", "", "http://localhost:8080/MagllanMain/Babylon/Cyril/", "steher_2500_900_120.obj"); steher1.onSuccess = pos; var sphere = BABYLON.Mesh.CreateSphere("sphere", 0.5, 0.5, scene); var simpleMaterial = new BABYLON.StandardMaterial("texture2", scene); simpleMaterial.diffuseColor = new BABYLON.Color3(0, 1, 0);//Green sphere.material=simpleMaterial; sphere.position.x = Math.floor((Math.random() * 2) ); sphere.position.y = Math.floor((Math.random() * 2) ); sphere.position.z=3; BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; loader.load(); // Begin of User interaction via button event $("#move_z").click(function(){ //scene.meshes.forEach(function(k) {alert(;}); pilot.position.z = pilot.position.z + 1; sphere.position.z = sphere.position.z + 0.4; scene.getMeshByName('steher_2500_900_120').position.z +=10; }); Funny thing is, i can move all other meshed via click-event. In general, I´ve been asking myself if I´m using the best way of doing this (import-method, file-types: obj and mtl). The workflow should be like this: 1) get JSON from server with an array of IDs and their coordinates (e.g.: ID="10012", ID_name="rack_012", ID_pos_x="130", ID_pos_y="120", etc.); 2) Importing the rack elements that belong to a specific ID into existing BJS scene; 3) Every rack element uses the same obj-file(s) (meshes) because all racks shall be of the same rack type, but with different IDs in BJS; I don´t know how to give imported meshes their own unique, custom IDs so that I can access them in the scene. More in general: I have my server-side array and i need a client-side array as well. When i change the position of let´s say 10 of 2000 racks in my layout / scene, I need to know which meshes i have to "move" on client-side. If there are any other weak points my way of trying to achieve this, please tell me. Any help appreciated !!! Topper
  5. Hello, I've not been working in BJS for a while now, and am back on a job. I've imported loads of OBJ files into babylon.js, and never had an issue. However, I must have forgotten everything already. I need to have the OBJ file into babylon.js tomorrow, and m stuck. I know it's an idiot issue, but I'm too stupid to sort out why this OBJ won't load. Thanks, DB Or better yet - if I import an OBJ file into Blender, the mesh imports as a completely black material with no texture. How do I correct this? It all imorts fine into Maya, which is what I normally use. However, it seems that I'm the only one using Maya in WebGL production, and there is no compatibility between Maya and babylon.js - not that I've ever found reliable. Could someone PLEASE write a reliable FBX converter to babylon.js? Everyone's been asking for this for many years now. I wish I had the skills to write it and support it.
  6. Hey, I have an issue with loading textures using an .obj and .mtl file. There's over 300 textures that need to be loaded in. I've checked the developer console in chrome and it appears that BabylonJS does indeed load them in, but they're still appearing as black textures in the view-port. Check below for image: I've seen that this is a common issue with .obj and .mtl files. Just wondering if anyone actually has a solution for this? Pete.
  7. Hello, I'm looking for a way to change a loaded mesh texture after it been loaded, without fetching new obj file. for example - I have the same chair in different textures, when the user does something I want to change the chair's texture. I can create a different .mtl file for each variant, but is it possible to load just the .mtl file after the obj already been loaded? Thanks, Tomer.
  8. Scaling Uploaded OBJ mesh

    Hi, I am loading an obj file and trying to scale it as shown below. The mesh is loaded but the scaling does not work. What am I doing wrong? var maraca = loader.addMeshTask("maraca", "", "assets/", "Maraca.obj"); maraca.scaling = new BABYLON.Vector3(0.1, 0.1, 0.1); Thanks!
  9. OBJ Exporter help?

    So, with some googling i found this... the problem is, it's in TypeScript (I don't know what this is even)... I don't know how to implement this any time i try using this i get unexpected identifiers. (I also noticed this TypeScript language is really similar to c# lol). So how would i use this... I know this is very nooby but meh
  10. Any imported .OBJ have this box collisions. How i can set to the object the correct collisions or use the collision=mesh ? Maybe is there any function to force the correct collision in case are bad loaded or something ¿? . I don't know if there is something wrong on my .OBJ, the plugin or simply babylon v2.6 not accept the collision and just draw a box? Here is the .obj i'm using:
  11. I'm new to babylonJS, so please forgive if this question is stupid. I'd like to use the playground and import an OBJ from my computer into the scene. I've looked at the documentation, but it seems to indicate I need a special loader. The sample of which does not work on my computer/Chrome or IE browser (i.e. And the other way seems to be to just use playground and use Assetsmanager. But the forums seem to indicate that Assetsmanager is for loading scenes or .babylon file and/or you "simply cant' do that, the OBJ must be on the web") I'm a little unclear on this. It seems a simple request, to be able to load an OBJ into playground and then save it off again as a zip (babylon scene, I assume, or perhaps just a zip of html code). I even saw someone try using loader.addMeshTask("A2", "", "http://localhost:8080/A2/", "a2.obj"); Which apparently works for them, but again, not me (though perhaps one must somehow set up one's computer to act like a localhost? ) Also, the docs seem limited on this...if I'm missing something (other than the Assetsmanager tutorial and page, obj loader page, and link already provided) could someone point me at the docs I need? Much appreciated,
  12. Hi folks. Can someone please tell me why my tree model "deciduous01.dae" is not loading correctly? It loads, but then it gives an error "BJS - [06:39:35]: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse" This is the demo : This happens with the OBJ version of the Object as well. I also can't get the textures to load. I have them in the same folder... view-source: line 180 is where LoadEntity ( ) is called inside , is where the function LoadEntity ( ) is created on line 138 --------------- I just want this model to load correctly... Thank you all so kindly! <3 Mythros
  13. I have encountered a problem with the lighting of my imported obj. Testing models (both lambert and phong materials) both have the same effect: my lighting doesn't work on the loaded models, but works perfectly fine on the default spheres. Directional lights don't work at all (they might as well not exist) and hemisphere lights make a minimal difference on the brightness of the model. I'm not exactly sure if this is a bug, because I read that in the documentation, it states that the obj loader does not support illumination. If that's the problem, then well, does anyone know of a workaround?
  14. Hi there, I have one single OBJ file with several objects within. Each element has its unique name. Is it possible to load each object as a single mesh? Tried to do this: var parts = []; obj.onSuccess = function (task) { for(var i = 0; i < task.loadedMeshes.length; i++){ parts.push(task.loadedMeshes[i]); parts[parts - 1].material = uniqueMat; ... } } But it seems that each next mesh / geometry has all previous ones like an avalanche. Loading OBJ with 5 similar spheres as a test Geometry {delayLoadState: 0, _totalVertices: 266, _isDisposed: false, id: "c0d23769-a422-47c5-8060-fabd67a55b1a", _engine: Engine…} main.js:254 Geometry {delayLoadState: 0, _totalVertices: 532, _isDisposed: false, id: "e83a4890-a107-425d-969c-eea1f356e200", _engine: Engine…} main.js:254 Geometry {delayLoadState: 0, _totalVertices: 798, _isDisposed: false, id: "19b85286-2066-4ef7-9e95-bba19d906e71", _engine: Engine…} main.js:254 Geometry {delayLoadState: 0, _totalVertices: 1064, _isDisposed: false, id: "22bc102d-1acc-4fa8-9576-77a9915e666f", _engine: Engine…} main.js:254 Geometry {delayLoadState: 0, _totalVertices: 1330, _isDisposed: false, id: "3eb8eab7-1871-4fed-b484-c18fc881cb23", _engine: Engine…} main.js:234 0
  15. Import Zip Obj

    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
  16. 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!
  17. SPS with different models

    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[]){ 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[]]; 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!
  18. 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. Am I missing someting? Thanks!
  19. 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: You can see it in the console output. Is there another way to load an OBJ in the playground?
  20. Babylon objects to .obj file

    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; }
  21. 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
  22. 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!
  23. SET position of OBJ object

    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!
  24. 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 :).
  25. Importing OBJ file

    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.