Jump to content

[solved] how to get append a mesh index???


MinsuKim
 Share

Recommended Posts

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 

Link to comment
Share on other sites

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); 
}); 

 

Link to comment
Share on other sites

@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!!

 

Link to comment
Share on other sites

  • 4 weeks later...

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
                }
            })
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • MinsuKim changed the title to [solved] how to get append a mesh index???

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...