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 30 results

  1. 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
  2. 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. https://www.babylonjs-playground.com/#28YUR5) 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,
  3. 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: https://drive.google.com/file/d/0B8vm3FpJ3vqJT1RlNFIxTldLcU0/view?usp=sharing
  4. 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 : http://babylontesting.epizy.com/loader/main.php This happens with the OBJ version of the Object as well. http://babylontesting.epizy.com/loader/models/deciduous/01/deciduous01/deciduous01.obj I also can't get the textures to load. I have them in the same folder... http://babylontesting.epizy.com/loader/models/deciduous/01/deciduous01/ view-source:http://babylontesting.epizy.com/loader/app/main.js line 180 is where LoadEntity ( ) is called inside http://babylontesting.epizy.com/loader/plugins/BabylonLib/BabylonLib.js , 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
  5. 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?
  6. 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?
  7. 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
  8. 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
  9. 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!
  10. 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[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!
  11. 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!
  12. 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; }
  13. 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
  14. 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!
  15. 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.
  16. 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!
  17. 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.
  18. 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 :).
  19. 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
  20. 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(); }); }); });
  21. 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..
  22. 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
  23. 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
  24. 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 ?
  25. stl/obj file loader

    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.