MinsuKim Posted May 15, 2018 Share Posted May 15, 2018 hi i started newbie developer my question is how to get mesh index number mesh index means is below my code BABYLON.SceneLoader.Append("/", "aaa.stl", Scene, function (Scene) { Scene.executeWhenReady(function () { //need to dynamic index but how to get index?.? var currnetIndex = something Code; Scene.meshes[currentIndex].position = new BABYLON.Vector3(10,-2,0); Scene.meshes[currentIndex].scaling = new BABYLON.Vector3(0.03,0.03,0.03); console.log("image load"+Scene.meshes[currentIndex]); }); }, function (progress) { // To do: give progress feedback to user }, function (error){ alert(error); }); i want get currentIndex but i'm failed! TT i need help! tell me about guardians for me sorry about.. my english level very lower Quote Link to comment Share on other sites More sharing options...
Guest Posted May 15, 2018 Share Posted May 15, 2018 Hello and welcome!! BABYLON.SceneLoader.Append("/", "aaa.stl", Scene, function (Scene) { Scene.executeWhenReady(function () { //need to dynamic index but how to get index?.? for (var currentIndex = 0; currentIndex < Scene.meshes.length; currentIndex++) { Scene.meshes[currentIndex].position = new BABYLON.Vector3(10,-2,0); Scene.meshes[currentIndex].scaling = new BABYLON.Vector3(0.03,0.03,0.03); console.log("image load"+Scene.meshes[currentIndex]); }); }, function (progress) { // To do: give progress feedback to user }, function (error){ alert(error); }); MinsuKim 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 15, 2018 Share Posted May 15, 2018 Hiya MK, welcome to the forum. Thx DK... quick gun! :) Another option... var whichMesh = scene.getMeshByName("someName"); whichMesh.position = whatever; whichMesh.rotation = whatever; // etc. Party on. MinsuKim 1 Quote Link to comment Share on other sites More sharing options...
MinsuKim Posted May 16, 2018 Author Share Posted May 16, 2018 @Deltakosh OMG my teather! thank you for your reply from my question. i know your solution but no dynamic because Scene.meshes.length <<<< maybe all meshe from scene i dont all meshe controll. i want just load(stl,obj,etc..) meshes anything solution?? today i try best thing then catch Idea!! Quote Link to comment Share on other sites More sharing options...
MinsuKim Posted May 16, 2018 Author Share Posted May 16, 2018 @Wingnut OMG my star! thank you for your reply from my question. i already see your code from other topic. currently i think it is the answer. var whichMesh = scene.getMeshByName("someName"); one problem is meshes naming convention.. i try..!! i will try then reply best solution! thank you GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
MinsuKim Posted June 11, 2018 Author Share Posted June 11, 2018 i many thing this issue then clear i take to this code is not correct answer But I think it is the best. thankyou @Deltakosh @Wingnut my answer below see the code 1. name each mesh for (var i = 0; i < randomNum; i++) { var machineinfo = new LayoutMachineInfo(); var dynamicName = "yourName#" + i; var box = BABYLON.MeshBuilder.CreateBox(dynamicName, boxOptions, scene); console.log(box + " Object Created!"); } 2. get a name then cording yourDataObject.forEach(meshData =>{ var dynamicName = "Machine#" + meshData.mMachineNo; let temp = idx.mScene.getMeshByName(dynamicName); if(temp != null){ //todo } }) GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted June 11, 2018 Share Posted June 11, 2018 Hi MinsuKim, good to see you again. Thanks for sharing your solution, and I am glad that your BJS project is advancing. JS is very flexible. It allows us to try multiple solutions. That is sometimes good, and sometimes time-consuming. :) Be well! 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.