Jump to content

Using asset manager or mesh import task fails to load


J girl
 Share

Recommended Posts

Hello everyone!! New to babylon.js

I have tried several different ways to load a 3D model into my browser, trying babylon and OBJ files. They always fail in the console, with no clear error message as to why. All the GET requests are fine, and the model appears on the web page and the code runs fine, but I cannot move it's position or do anything with it in the code because it has not completely loaded, failing.  I cannot move it's position by using model.position.x or anything of that sort. I need to eventually be able to get its vertices.. that is my end goal, but I can't even do simple altercations. 

Here is the code, onTaskError always gets called despite the model being visible on the screen: 

var assetsManager = new BABYLON.AssetsManager(scene);


        var meshTask = assetsManager.addMeshTask("human", "", "models/", "human.babylon");
        // You can handle success and error on a per-task basis (onSuccess, onError)
        meshTask.onSuccess = function (task) {
            task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0);
            human =  task.loadedMeshes[0];
        }
         assetsManager.onTaskError = function (task) {
            console.log("error while loading " + task.name);

        }

 

In the console it says "error while loading " + task.name, and nothing else.

 

I added mime types to the browser, I made sure the HTTP request went through.. 

I would appreciate anyone's guidance on how to import a 3d model into the browser, I don't need an entire scene, I just need 2 models/objects in total, and I want to know how to move them and manipulate their vertices..

 

Thanks

J

Link to comment
Share on other sites

Hello again @Deltakosh 

 

Ok, I think I have got it to load after making it on playground then exporting it as a zip on my local computer. The one problem is that when loading the model this way is that I cannot reference the model outside of this block of code in the script because it says it's undefined.  And the code will not run.. 

  BABYLON.SceneLoader.ImportMesh("", "scenes/", "skull.babylon", scene, function (newMeshes) {
        // Set the target of the camera to the first imported mesh
        camera.target = newMeshes[0];
        model = newMeshes[0];
        var positions = model.getVerticesData(BABYLON.VertexBuffer.PositionKind);

}

 

  model.position.y += 100;

In the console: 

ReferenceError: model is not defined[Learn More]

How can I move the model dynamically then

 

Thanks in advance

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...