Search the Community

Showing results for tags 'assetsmanager'.

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

  1. I've made a mesh in Blender and I've exported it to a .babylon file. I've also tried exporting the mesh as a .obj file but the problem persisted. I've checked my network tab in Chrome (on Mac OS btw) and I can see that the file has been downloaded so it's not a wrong path. Also, I get errors that the system couldn't find the .manifest file but I've found that that's not the issue. This is the error: Unable to import meshes from ./testObject.babylon: 0 This is the code I've been using: var loader = new BABYLON.AssetsManager(scene); house = loader.addMeshTask("pillar", "", "./", "testObject.babylon"); house.onSuccess = function (task) { console.log('---> DONE', task) task.loadedMeshes.forEach(function (m) { console.log('added'); m.position = BABYLON.Vector3.Zero(); m.scaling = new BABYLON.Vector3(0.2, 0.2, 0.2); shadowGenerator.getShadowMap().renderList.push(m); }); } house.onError = function() { console.log('ERROR', arguments); } loader.load();
  2. Hello 3D guru, According to the docs, we can load objects from *.babylon files this way: var assetsManager = new BABYLON.AssetsManager(scene); var meshTask = assetsManager.addMeshTask("skull task", "", "scenes/", "skull.babylon"); ... assetsManager.load(); Imagine, that *.babylon file contains many objects and I load these files dynamically, one by one. Later I want to delete/dispose all objects loaded from the specific file - how do I do that? Is there a built in way? Probably I could store all mesh names in a dictionary where keys are *.babylon file names, then in a loop go through the dict key values and dispose meshes. But maybe there is a shorter and more beautiful way?!
  3. Hello, Below is a PG for a scene I'm having problems with: I have a list of material definitions in JSON which I load with assetsManager, once this is loaded.. I then load a .babylon file. We then loop through each of the materials in the JSON file and if the material name matches that in the scene, it then change that material. Problem is, the scene displays before all the textures have loaded.. more noticable if you throttle the speed. In an ideal world, the spinning loading screen would show right up to the point that everything is ready, but I can't quite work out what I need to do. Yes, the textures & AO map are large, but this is really just to illustrate the problem better. Any help would be gratefully received. Thank you
  4. Hey I'd would like know when the texture is loaded on PBR glTF workflow, I did this code : assetsManager = new BABYLON.AssetsManager(scene); var textureTask = assetsManager.addTextureTask("albedoTexture texture", "assets/test/lambert1_baseColor.jpg", true, false); albedoTextureTask.onSuccess = function(task) { console.log(task.texture); meshes.material.albedoTexture = task.texture; } assetsManager.load(); The material assignation does nothing here thanks
  5. 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.
  6. 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,
  7. What's the difference between assetsManager and ImportMesh for importing custom meshes? thanks very much
  8. Hey everyone I just have two simple question I cannot find an answer too. First Question: The SpriteManager needs a capacity parameter, but why does it need this? Why can I not change this during runtime? What does it actually do (in the background) (except for just not showing any sprites that exceed the capacity)? Does it hurt performance at all if I just put a 'crazy' high number? Can the manager not just +1 the capacity by itself in the background whenever an instance of the sprite is created? It just seems so odd that I have to give it a number and I feel like I'm missing something here. My second question is how to exactly use the AssetsManager for sprites. The documentation gives this example: var imageTask = assetsManager.addImageTask("image task", "img.jpg"); imageTask.onSuccess = function(task) { console.log(task.image.width); } But that doesn't explain how to use it with a Sprite since the task returns an image, and a SpriteManager only requires an image url. Thank you in advance!
  9. Hello, I have a problem with get information how many percent of all mesh/textures were loaded, while I use AssetsManager. I have seen a similar topic, but there SceneLoader is used. Is it possible to get those information about loading progress, while I use AssetsManager?
  10. Hi, this is my code: for(var t = 0; t < edificios_texto.length; t++){ var loader = new BABYLON.AssetsManager(scene); //console.log(edificios_texto[n]); var edificio = loader.addMeshTask(t, "", "http://localhost:8080/modelos2/"+edificios_texto[t]+"/",edificios_texto[t]+".obj"); edificio.onSuccess = function (task) { //console.log(task.loadedMeshes.length); console.log(; task.loadedMeshes.forEach(function(b) { b.scaling = new BABYLON.Vector3(5,5, 5); b.rotation.y = Math.PI; // cambiar las X 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); for (var i = 0; i < edificios.length; i++) { // console.log(edificios[i].texto); // console.log(t); if(edificios[i].texto == edificios_texto[t]){ var utmPlaceZ = edificios[i].x; var utmPlaceX = edificios[i].z; var utmPlaceXFromCentre = utmPlaceX - mapCentreX; var utmPlaceZFromCentre = utmPlaceZ - mapCentreZ; var x = utmPlaceXFromCentre/scaleX; var z = utmPlaceZFromCentre/scaleZ; b.position.x = x; b.position.z = z; break; } } }); } /* edificio.onFinish = function() { engine.runRenderLoop(function () { scene.render(); }); }; */ loader.load(); } I have to use the var edificios_texto[t] inside this function, How can I do it? JuanMa J.R
  11. Hello, I have a small problem that I do not understand with addMeshTask(). If I do this, it does not work. (I have no error in the console and I get out the value of 'key') // Not Work $.getJSON(, function(json) { $.each(json, function (key, val) { addTask(key); }); }); function addTask(key) { =, "", "../../scene/"+key+"/", key+".babylon"); = function(task) { task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0); } } But if I do this, it works: // Work function addTask(key) { =, "", "../../scene/"+key+"/", key+".babylon"); = function(task) { task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0); } } addTask("scene_name"); I would like to load multiple scene with addMeshTask() from a list of json file, but it does not work. Why ? Thank you for your help.
  12. I try to clone the same mesh, but for some reason, the mesh is cloned once. How to clone the same mesh many? var loader = new BABYLON.AssetsManager(scene); dom1mesh = loader.addMeshTask('dom1', "", "/static/game/dom1/", "dom2.babylon"); mesh = new BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh.position = new BABYLON.Vector3( 5, 1, 5); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0]; nm.position = new BABYLON.Vector3(10, 1, 10); nm.parent = mesh; }; mesh1 = BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh1.position = new BABYLON.Vector3( 15, 1, 15); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0].clone('2'); nm.parent = mesh1; }; mesh2 = BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh2.position = new BABYLON.Vector3( 25, 1, 25); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0].clone('3'); nm.parent = mesh2; }; mesh3 = BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh3.position = new BABYLON.Vector3( 35, 1, 35); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0].clone('4'); nm.parent = mesh3; };
  13. 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>
  14. I want to clone the already loaded model and inserted into another location on the map. At the end of the time. var loader = new BABYLON.AssetsManager(scene);var taskMesh = loader.addMeshTask('t3', "", "game/t3/", "t.babylon");taskMesh.onSuccess = function (task) { task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0); task.loadedMeshes[0].parent = camera;};I have not found. Maybe something like this? taskMesh.loadedMeshes[0].clone();
  15. AssetsManager and CubeTexture

    Hello, I would like to use the assetsManager to load asynchronously a BABYLON.CubeTexture, is it possible ? Thank you for your responses ! Jérémy