Jump to content

Unable to import mesh SceneLoader.importmesh


KevinK
 Share

Recommended Posts

I am getting the following errors when calling ImportMesh. 

BJS - [14:34:00]: Unable to import meshes from data:# Blender v2.79 (sub 0) OBJ File: ''

: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse

I am using beta 1 version of Babylon and loaders because of babylonjs.loaders.module.d.ts with 3.2.0-beta.3 reported

Following code give me the error

import * as BABYLON from 'babylonjs';

import 'babylonjs-loaders';

uploadSaveFiles(files: File[]) {

      files.map((file, i) => {
       let reader = new FileReader();
    if (isImage(file)) {
         reader.readAsDataURL(file);
       } else if (isObj(file)) {
         reader.readAsText(file);
       } else if (isMtl(file)) {
         reader.readAsText(file);
       } else {
         console.log("File not supported!");
       }
     
       let data = reader.result;
      if( isObj(file)) {
          BABYLON.SceneLoader.ImportMesh("", "", 'data:' + data, scene, function (meshes: BABYLON.AbstractMesh[]) {
            meshes.forEach((mesh) => {   console.log(mesh);  });
       }); 
    }
 }
}

I am trying to load a Obj file from disk. The obj file has accompanying mtl and images files. I currently have a interface where the user drags and drops all appropriate files. Not sure if this is the best way. Do the accompanying files need to be in uploaded first before I can load obj file? If there is a better way to upload obj and material files  let me know

Thanks

 

Link to comment
Share on other sites

  • 7 months later...

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