Zephos Posted October 15, 2018 Share Posted October 15, 2018 Hi all, EDIT: Issue solved. See bottom of post. I am trying to use assetManager and everything seems to be fine but the onSuccess callback is called and passed a task object that has no meshes in loadedMeshes. Here is the relevant code: export default class GameAssetManager{ constructor(gameManager, gamePackage){ this.initialized = false; this.gameManager = gameManager; this.assetScene = gameManager.gameDisplay.scene;//new BABYLON.Scene(gameManager.gameDisplay.engine); this.assetsManager = new BABYLON.AssetsManager(this.assetScene); this.gamePackage = gamePackage; this.baseMeshesForCloning = {}; this.gamePackage.fleets.forEach((fleet)=> {fleet.forEach((ship)=>{this.baseMeshesForCloning[ship.shipSpec.mesh.meshID] = ship.shipSpec.mesh; })}); } initialize(){ this.GetAllMeshesForCloning(); this.assetsManager.load(); } GetAllMeshesForCloning(){ for (const key of Object.keys(this.baseMeshesForCloning)) { let mesh = this.baseMeshesForCloning[key]; //load in mesh from specified root and filename. let task = this.assetsManager.addMeshTask("mesh_" + mesh.meshID, mesh.meshID, mesh.directory, mesh.filename ); task.onSuccess = function(task) { mesh["mesh"] = task.loadedMeshes[0]; } task.onError = function (task, message, exception) { console.log(message, exception); } var textTask = this.assetsManager.addTextFileTask("text task", "build/msg.txt"); textTask.onSuccess = function(task) { console.log(task.text); } } } ) The odd part is that in my network tab in dev tools the obj files are loaded successfully and the addTextFileTask works fine. The loadedMeshes array is just empty for some odd reason. The files I am loading are here: https://raw.githubusercontent.com/WriterZephos/files/master/Fighter.obj https://raw.githubusercontent.com/WriterZephos/files/master/Fighter.mtl Any help would be greatly appreciated. EDIT: I solved the issue! I didn't realize what the meshNames argument was... though it was just giving a name to the mesh or something, but it was actually looking for a mesh by that name! Wow I am such a noob at this. Thanks. Quote Link to comment Share on other sites More sharing options...
ssaket Posted October 15, 2018 Share Posted October 15, 2018 Hey there ! Could you create a playground for the same ? I know it's a trivial thing but it gets lot more easier for us to debug and solve the problem quickly. Meanwhile, the boilerplate is working fine for me, have a look (https://www.babylonjs-playground.com/#ZJYNY#90) Quote Link to comment Share on other sites More sharing options...
Guest Posted October 15, 2018 Share Posted October 15, 2018 Wonderful ssaket 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.