Carharttguy Posted July 27, 2017 Share Posted July 27, 2017 Hello I'm learning the AssetsManager, but I bump into this problem: Quote var meshtask = this._assetManager.addMeshTask(name, "", rooturl, fileName); meshtask.onSuccess = function (task) { task.loadedMeshes[0].position = BABYLON.Vector3.Zero(); } But one way or another, task.loadedMeshes doesn't exist. How is this possible? Edit: I also should call .load first, but I don't think that's the problem here. Thanks! Quote Link to comment Share on other sites More sharing options...
davrous Posted July 27, 2017 Share Posted July 27, 2017 Hello, What do you mean loadedMeshes doesn't exist? Is it undefined? Here's the doc: http://doc.babylonjs.com/tutorials/how_to_use_assetsmanager containing a sample on the PG: http://www.babylonjs-playground.com/#ZJYNY#0 Davod Quote Link to comment Share on other sites More sharing options...
Carharttguy Posted July 27, 2017 Author Share Posted July 27, 2017 Hi @davrous, thanks for your fast answer. I found the problem. The error shown was something like this: TS2099: loadedMeshes not found on IAssetTask. So i figured I should've defined the type of 'task' this way: Quote meshtask.onSuccess = function (task: BABYLON.MeshAssetTask) { task.loadedMeshes[0].position = BABYLON.Vector3.Zero(); } And this works. Wouldn't it be an idea to also have TypeScript examples in the docs? So the reader can choose which code examples are shown? I'm willing to translate the parts I can. Also poking @Deltakosh for this. Quote Link to comment Share on other sites More sharing options...
Carharttguy Posted July 27, 2017 Author Share Posted July 27, 2017 Little side question: Why are the loadedMeshes abstract meshes? Is it safe to typecast them to meshes? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 27, 2017 Share Posted July 27, 2017 Yes it could be a good idea and actually we could even do it already.If you want you can initiate some: https://github.com/BabylonJS/Documentation 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.