Tomm Huth Posted October 23, 2018 Share Posted October 23, 2018 I'm trying to load a simple obj file exported from Blender, but I'm having a hard time and the docs aren't really helping. I've tried SceneLoader.ImportMesh(["rock1"], "./","rock1.obj", scene, function (meshes) { console.log(meshes) }); But what are the params supposed to be here? I have one single file named "rock1.obj" located at root "/". But then Babylonjs tries to get this: GET http://localhost:3000/rock1.obj.manifest?1540314526858 GET http://localhost:3000/rock1.mtl Even when SceneLoader.IsPluginForExtensionAvailable(".obj") return true. I dont want to automatically add the mesh just get it and store it for future use. Also am I forced to load scenes for every object? The same thing happens when I use let loader = new AssetsManager(scene); loader.useDefaultLoadingScreen = false; // Set to false to remove the default loading let mesh_loaded_task = loader.addMeshTask("s", "rock1.obj", "/", "rock1.obj"); mesh_loaded_task.onSuccess = function (task) { task.loadedMeshes.forEach(function(m) { console.log("Loaded!"); m.position = BABYLON.Vector3.Zero(); }); }; mesh_loaded_task.onError = console.error loader.load() But what is the last parameter of addMeshTask supposed to be -- sceneFilename?? Quote Link to comment Share on other sites More sharing options...
trevordev Posted October 23, 2018 Share Posted October 23, 2018 You can use the asset container to load a mesh without it being added to the scene by default. http://playground.babylonjs.com/#L6IE5L#1 I obj's can have a manifest and mtl file associated with them so the obj plugin will look for those and if it doesn't find them it should still load the obj. You shouldn't need to create a new scene for every object but you should have at least one scene. Quote Link to comment Share on other sites More sharing options...
Tomm Huth Posted October 23, 2018 Author Share Posted October 23, 2018 @trevordev see my last edit. Babylon never hits my rock1.obj file at all, and fails with the following error "Unable to import meshes from ./: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse" SyntaxError: Unexpected token < in JSON at position 0 Quote Link to comment Share on other sites More sharing options...
Tomm Huth Posted October 23, 2018 Author Share Posted October 23, 2018 You're example also uses a glb file type, is that interchangeable with obj? If not how do i convert it? Quote Link to comment Share on other sites More sharing options...
Tomm Huth Posted October 23, 2018 Author Share Posted October 23, 2018 @trevordev ah looks like SceneLoader.LoadAssetContainerAsync does the trick but my mesh is still added to the scene, any ways of stopping that? Quote Link to comment Share on other sites More sharing options...
Tomm Huth Posted October 23, 2018 Author Share Posted October 23, 2018 Seems like there is a bug here with SceneLoader.LoadAssetContainerAsync The promise never resolves, but somehow the mesh is added to my scene (I haven't even passed thru my scene anywhere, so don't know how it knows that). It also complains alot about not finding the mtl file Quote Link to comment Share on other sites More sharing options...
trevordev Posted October 23, 2018 Share Posted October 23, 2018 Can you provide a playground http://playground.babylonjs.com/ for what you are seeing for me to take a look? 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.