BlackMojito Posted October 31, 2017 Share Posted October 31, 2017 Hi Folks, What is the recommended way to import the content of an OBJ/STL into an existing scene? I need the meshes and the materials as well. Below are the three ways I found in the official tutorials. I think that the first one cannot be used in my case as it creates a new scene. So besides the first one, what is the difference between the second one and third one? Can they import the associated materials as well? BABYLON.SceneLoader.Load("/assets/", "batman.obj", engine, function (newScene) { // ... }); var loader = new BABYLON.AssetsManager(scene); var batman = loader.addMeshTask("batman", "", "assets/", "batman.obj"); BABYLON.SceneLoader.ImportMesh("batmanface", "batman.obj", scene, function (meshes) { // ... }); Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 31, 2017 Share Posted October 31, 2017 I would say it depends on how you want them loaded. The AssetManager can be used to, for example, have a splash screen that shows the assets load progress before starting your scene you can be sure that you have all your assets. It has an onFinished event you can handle (https://doc.babylonjs.com/classes/3.1/assetsmanager#onfinish-tasks-iassettask-gt-void). The SceneLoader.ImportMesh (https://doc.babylonjs.com/classes/3.1/sceneloader#static-importmesh-meshnames-rooturl-scenefilename-scene-onsuccess-onprogress-onerror-rarr-void) has also a progress method, but I would say it's more useful dynamically. If you have materials on your obj, then you will see the material files being loaded asynchronously. Watch for timing issues on materials. 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.