Jump to content

Using ImportMesh with a String


Cole Watson
 Share

Recommended Posts

Hi Everyone! I am new to Babylon and had a question about the ImportMesh function of the SceneLoader.

For my use case I am downloading obj files from and endpoint using our custom headers before making the ImportMesh call. When we download the OBJ files we get a string containing everything in that OBJ file. I am aware that in the sceneFilename parameter we are able to pass in the "stringified" version of the obj file. But I cant seem to get it to work. I get the error: 

core.umd.js:1487 ERROR Error: Uncaught (in promise): TypeError: First argument to DataView constructor must be an ArrayBuffer
TypeError: First argument to DataView constructor must be an ArrayBuffer
    at new DataView (<anonymous>)
    at r.isBinary (babylonjs.loaders.min.js:1)
    at r.importMesh (babylonjs.loaders.min.js:1)
    at babylon.js:35
    at m (babylon.js:35)
    at Function.i._loadData (babylon.js:35)
    at Function.i.ImportMesh (babylon.js:35)

Here is an example of the call being made:

BABYLON.SceneLoader.ImportMesh(
   'Some_Name',
   '',
   'Data: string version of obj file...',
   scene,
   this.onSuccess,
   this.onProgress,
   this.onError,
   '.stl'
);

If anyone has any idea of what I am doing wrong here that would be hugely helpful! 

Link to comment
Share on other sites

try this :

BABYLON.SceneLoader.ImportMesh(
   '',
   '',
   'Data: string version of obj file...',
   scene,
   this.onSuccess,
   this.onProgress,
   this.onError,
   '.stl'
);

When we add a name it creates problems every time.

I do not find this parameter very useful.

Link to comment
Share on other sites

ImportMesh () is good for importing a single mesh. If there are more you have to use Append () how can ImportMesh import several meshes?

I noticed that for the name in ImportMesh if we do not give the correct name existing in the file, it creates a bug.

I still do not understand the utility of the name in ImportMesh that is made to import a mesh. Append () is to import more than one.

The name ImportMesh very regularly misleads users who enter a different name from the one existing in the file.

Link to comment
Share on other sites

The preoperty name is meshNames which literally means you can only import a single mesh (or many of them but not all) from a scene file.

If you want to import all of the scene, just use AppendScene

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