Cole Watson Posted June 7, 2018 Share Posted June 7, 2018 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! Quote Link to comment Share on other sites More sharing options...
Guest Posted June 7, 2018 Share Posted June 7, 2018 Hello and welcome I'm seeing .stl in the extension. Is that expected? Quote Link to comment Share on other sites More sharing options...
Cole Watson Posted June 8, 2018 Author Share Posted June 8, 2018 I have tried .obj and .stl to no avail... Quote Link to comment Share on other sites More sharing options...
Guest Posted June 8, 2018 Share Posted June 8, 2018 Can you repro the issue in the PG then? Your code looks good but I would like to test it Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 8, 2018 Share Posted June 8, 2018 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. Quote Link to comment Share on other sites More sharing options...
Cole Watson Posted June 8, 2018 Author Share Posted June 8, 2018 I am able to get the obj loaded when using the .Append function but not using the Import Mesh function https://playground.babylonjs.com/#5336A5#3 Quote Link to comment Share on other sites More sharing options...
Cole Watson Posted June 8, 2018 Author Share Posted June 8, 2018 @Dad72 removing the name worked for me! Thanks! Not sure why that is but it got it all working well. https://playground.babylonjs.com/#5336A5#5 Quote Link to comment Share on other sites More sharing options...
Guest Posted June 8, 2018 Share Posted June 8, 2018 name is the name of the mesh to import from the datasource. Not providing it means that you will import all meshes Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 8, 2018 Share Posted June 8, 2018 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. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 8, 2018 Share Posted June 8, 2018 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 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 8, 2018 Share Posted June 8, 2018 Ok, i see. Quote Link to comment Share on other sites More sharing options...
RaananW Posted June 11, 2018 Share Posted June 11, 2018 Hi @Cole Watson, I just pushed a fix for STLs too. it will probably take a bit of time until it will be available in the pplayground. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 11, 2018 Share Posted June 11, 2018 Should be available by tonight (PST) 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.