shaharyar.ahmed Posted January 19, 2014 Share Posted January 19, 2014 I've exported my scene from 3Dsmax. Now I want to get individual meshes and want to do something with them. How can I select a mesh in the scene? with its name or ID... ? Quote Link to comment Share on other sites More sharing options...
Nico Posted January 19, 2014 Share Posted January 19, 2014 I'm not sure to understand what you need, but if you want to import specifics meshes from file, you can use BABYLON.SceneLoader.ImportMesh method.BABYLON.SceneLoader.ImportMesh(meshesNames, rootUrl, sceneFilename, scene, then, progressCallBack)meshesNames can be a simple string (to import only one mesh) or an array of string.rootUrl is the path to the file.sceneFilename is ... the file name.scene is your existing BABYLON.Scene (you need to create it manually)then(meshes, particleSystems, skeletons) then is the callback, where you will receive added meshes (always an array of meshes). Quote Link to comment Share on other sites More sharing options...
shaharyar.ahmed Posted January 19, 2014 Author Share Posted January 19, 2014 I've already loaded the scene from the file. Here is the code: if (BABYLON.Engine.isSupported()) { var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true);var newScene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Load("", "bui4.babylon", engine, function (newScene) { newScene.executeWhenReady(function () {//now here I want to select some meshes from the active scene engine.runRenderLoop(function() { newScene.render(); }); }); }, function (progress) { }); }I want to select some meshes from the active scene, for hide, unhide, change textures etc. Quote Link to comment Share on other sites More sharing options...
Denis2222 Posted January 19, 2014 Share Posted January 19, 2014 Use : newScene.executeWhenReady(function () { newScene.meshes[0].position.x = 10; // Mesh 0 newScene.meshes[1].position.z = -10; // Mesh 1 newScene.meshes[2].isVisible = false; // Hide mesh engine.runRenderLoop(function() { newScene.render(); //For move something while rendering newScene.meshes[0].position.x += 1; }); } Quote Link to comment Share on other sites More sharing options...
Nico Posted January 19, 2014 Share Posted January 19, 2014 Ok use one of this method :yourScene.getMeshByID(meshId);yourScene.getMeshByName(meshName);You will receive a BABYLON.Mesh cpu_sam and Jaskar 2 Quote Link to comment Share on other sites More sharing options...
Nico Posted January 19, 2014 Share Posted January 19, 2014 This line is useless var newScene = new BABYLON.Scene(engine);Your "newScene" variable is not linked to this line :BABYLON.SceneLoader.Load("", "bui4.babylon", engine, function (newScene)If you want to access to your scene outside the "Load" scope you need to do this, the "Load" method create a new scene with specified engine :var scene;BABYLON.SceneLoader.Load("", "bui4.babylon", engine, function (newScene){ scene = newScene; //Do what you want}); GameMonetize and gwenael 2 Quote Link to comment Share on other sites More sharing options...
babaorhum Posted March 28, 2017 Share Posted March 28, 2017 On 19/01/2014 at 4:18 PM, Nico said: yourScene.getMeshByID(meshId);yourScene.getMeshByName(meshName); Hello every one, I'd love to know the end of this topic regarding how to pick a mesh from an imported one Here an example : http://babylonjs-playground.com/#1QJUDF Now imagine that I want it to a parent of something or bind to a canvas2D How do I do such thing? Thx again Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 28, 2017 Share Posted March 28, 2017 Not sure to understand. You have all in the PG already:http://babylonjs-playground.com/#1QJUDF#1 Quote Link to comment Share on other sites More sharing options...
babaorhum Posted March 29, 2017 Share Posted March 29, 2017 It seams that all I can do is scaling rotating or position changing, anyway to get it call from outside that particular function? like a simple box, first you create it and then you call it in this PG, I cannot have a array of newMeshes in the console, or has it call outside the function or do I have to write everything I want this mesh to interact with into that specific function? Hope I'm clear, thx for your time, btw Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 29, 2017 Share Posted March 29, 2017 You have to wait for the meshes to be loaded hence the need to run your code in the callback function Quote Link to comment Share on other sites More sharing options...
babaorhum Posted March 30, 2017 Share Posted March 30, 2017 Well it seems I do BABYLON.SceneLoader.ImportMesh("", "Content/", "structura.babylon", scene, function (newMeshes) { var pipesLittleChimney = newMeshes[0]; var bigStructure = newMeshes[1]; var littleStructure = newMeshes[2]; var chimney = newMeshes[5]; var suflante = newMeshes[6]; // new Meshes match are found in console.log(newMeshes[i].name) }); Also I'm intrigued why one of my meshes keeps up side down but no way to have a look from it on sanbox even if I rotate it on 3DsMax If I want to link those meshes to lines and planes, I'll have to do inside the callback function? Thank you for your time Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 31, 2017 Share Posted March 31, 2017 everything will have to happen in the callback because you'll be too early in the party:) For the upside down mesh, can you try to ensure it is not build with mirror and make sure your reset xform on it 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.