Search the Community

Showing results for tags 'assetsmanager'.



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

  1. 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?
  2. 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(edificio.name); 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
  3. 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(global.game.nameProjet, function(json) { $.each(json, function (key, val) { addTask(key); }); }); function addTask(key) { global.game.meshTask = global.game.assetsManager.addMeshTask(key, "", "../../scene/"+key+"/", key+".babylon"); global.game.meshTask.onSuccess = function(task) { task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0); } } But if I do this, it works: // Work function addTask(key) { global.game.meshTask = global.game.assetsManager.addMeshTask(key, "", "../../scene/"+key+"/", key+".babylon"); global.game.meshTask.onSuccess = 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.
  4. 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; };
  5. 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>
  6. 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();
  7. 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