joeBImagine Posted September 27, 2017 Share Posted September 27, 2017 Hello Babylon aficionados!! I was hoping you all would be able to help. I am not sure what I am doing wrong, but I am trying to attach a custom texture to a babylon file I exported from 3ds max. This is the error in the console: babylon.js:3 BJS - [06:55:16]: Babylon.js engine (v3.0) launched babylon.js:3 BJS - [06:55:17]: Material not found for mesh fc4bd914-849c-4954-9f0c-8c25b763cecb t._WarnEnabled @ babylon.js:3 importMesh @ babylon.js:28 m @ babylon.js:28 (anonymous) @ babylon.js:28 a.oncomplete @ babylon.js:29 babylon.js:3 BJS - [06:55:17]: Material not found for mesh 6569d8e7-4fbc-478c-af4f-dbe31c4db185 t._WarnEnabled @ babylon.js:3 importMesh @ babylon.js:28 m @ babylon.js:28 (anonymous) @ babylon.js:28 a.oncomplete @ babylon.js:29 Which I understand, but I do not understand why using Babylon.Standardmaterial is not working. Here is the javascript code. Let me know if anything else is needed to diagnose!! var canvas, engine, createScene, scene, light, camera, sphere, box; canvas = document.querySelector("#renderCanvas"); engine = new BABYLON.Engine(canvas, true); createScene = function() { scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(0.85, 0.85, 0.85); scene.ambientColor = new BABYLON.Color3(0.75, 0.75, 0.75); //var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); camera = new BABYLON.ArcRotateCamera("camera1", 0, 0, 10, new BABYLON.Vector3.Zero(0, 0, 0), scene); //camera.radius = 5000; camera.setPosition(new BABYLON.Vector3(0, 5000, -10)); camera.setTarget(BABYLON.Vector3.Zero(0, 5000, 0)); camera.attachControl(canvas, true); camera.wheelPrecision = .1; light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); light.intensity = 1.0; sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 500, scene); //var box = BABYLON.Mesh.CreateBox("box", 6.0, scene, false, BABYLON.Mesh.DEFAULTSIDE); sphere.position.y = 1; //var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene); var meshVar = BABYLON.SceneLoader.ImportMesh("","scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/", "ElliotMicrofiber2PieceSectionalSofa.babylon", scene, function(newMeshes) { camera.target = newMeshes[0]; var customMaterial = new BABYLON.StandardMaterial("customMaterial", scene); customMaterial.diffuseTexture = new BABYLON.Texture("scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/fabric.dif.jpg", scene); var customTexture = scene.meshes[0]; customTexture.material = customMaterial; } ); sphere.dispose(); return scene; }; scene = createScene(); engine.runRenderLoop(function() { scene.render(); }); window.addEventListener("resize", function() { engine.resize(); }); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 27, 2017 Share Posted September 27, 2017 Hello! The warnings come from the loader which is not finding specific material for meshes in your .babylon file. But I do not think it is related to your issue. Can you make sure that the meshes[0] is the right mesh? you can use scene.debugLayer.show() to help you debugging it Quote Link to comment Share on other sites More sharing options...
joeBImagine Posted September 27, 2017 Author Share Posted September 27, 2017 Hello Deltakosh!! Thank you for the reply. I have installed the debugger and I am getting this as the names under mesh (the first name is the group/parent): 31375_ElliotFabricMicrofiber2PieceSectionalSofa ElliotFabricMicrofiber2PieceSectionalSofa_Graphite_Legs001 ElliotFabricMicrofiber2PieceSectionalSofa_Graphite_Base001 I've updated the code to reflect the name in the debugger: var meshVar = BABYLON.SceneLoader.ImportMesh("","scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/", "ElliotMicrofiber2PieceSectionalSofa.babylon", scene, function(newMeshes) { camera.target = newMeshes[0]; var customMaterial1 = new BABYLON.StandardMaterial("fabric", scene); customMaterial1.diffuseTexture = new BABYLON.Texture("scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/fabric.dif.jpg", scene); ElliotFabricMicrofiber2PieceSectionalSofa_Graphite_Base001.material = customMaterial1; } ); I've even tried: meshVar.material = customMaterial1; But still nothing. The texture is definitely there however: I am not sure what I am doing wrong and/or missing. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 27, 2017 Share Posted September 27, 2017 can you make sure there is no 404 on your texture? using the f12 network tab Quote Link to comment Share on other sites More sharing options...
joeBImagine Posted September 27, 2017 Author Share Posted September 27, 2017 No error message: Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 27, 2017 Share Posted September 27, 2017 I will need to see a live repro to help then Quote Link to comment Share on other sites More sharing options...
joeBImagine Posted September 27, 2017 Author Share Posted September 27, 2017 I finally got it!! it should have been: newMeshes[2].material = customMaterial1; as the function newMeshes was the array where my meshes were being held!! var meshVar = BABYLON.SceneLoader.ImportMesh("","scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/", "ElliotMicrofiber2PieceSectionalSofa.babylon", scene, function(newMeshes) { camera.target = newMeshes[0]; var customMaterial1 = new BABYLON.StandardMaterial("fabric", scene); customMaterial1.diffuseTexture = new BABYLON.Texture("scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/fabric.dif.jpg", scene); newMeshes[2].material= customMaterial1; } ); Thank you again for the help!! In the future if a live repo is needed, would I need to add the code to a github repo? Or an actual live server? Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 28, 2017 Share Posted September 28, 2017 You can host it anywhere you wish, as long as it is public and can be accessed. We do need to be able to see what we are solving Quote Link to comment Share on other sites More sharing options...
joeBImagine Posted September 28, 2017 Author Share Posted September 28, 2017 Good to know thank you!! I am still green to this!! But I am loving babylon! 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.