Change Billboard_Mode from NONE to ALL at runtime?

Hey @All - I wonder if it is possible to change a meshes billboard_mode at runtime without forcing my page to reload? :slight_smile:

I attached Labels to Meshes and noticed that a User might want them to behave differently. So I tried to write a quick function to get them to, and know I can easily switch the billboard_mode from ALL to NONE in a second, but still I have to reload the site if I want them to change back from NONE to ALL :smiley:

Edit: So the Switch from NONE to ALL seems not to work for me at runtime, my workaround just reloads the scene with the original implementation of actualmesh.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL; I have in my code when I instance my Labels before.

 var myLabelMesh = scene.getMeshByName(abstractmesh_Id);

try{
  console.log("try to change billboardmode");
  console.log("meshes billboasrd_mode is: " + myLabelMesh.billboardMode);

  if(myLabelMesh.billboardMode==0){
    try{
      console.log("change billboradmode from NONE to ALL");
    myLabelMesh.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL;
    location.reload();
    }catch{
      console.log("billboardmode set to BABYLON.Mesh.BILLBOARDMODE_ALL failed");
    }
  }

  if(myLabelMesh.billboardMode==7){
    myLabelMesh.billboardMode = BABYLON.Mesh.BILLBOARDMODE_NONE;
  }

}catch{
    console.log("changing billboard mode failed");
}
  }

Any Suggestions how to fix? :slight_smile:

That seems strange to me…

Could you put your code in a playground (https://playground.babylonjs.com/), it will be easier to look for what’s going on?

1 Like

I actually found my problem - after resetting the BillboardMode of course I have to leave the function by returning billboardMode (or something), to prevent my lower if-stuff to overwrite the changes I created in the upper one ^^

if(myLabelMesh.billboardMode==0){
    try{
      console.log("change billboradmode from NONE to ALL");
    myLabelMesh.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL;
   return myLabelMesh.billboardMode;
    }catch{
      console.log("billboardmode set to BABYLON.Mesh.BILLBOARDMODE_ALL failed");
    }
  }

if(myLabelMesh.billboardMode==7){
//stuff here simply overwrote upper code :) 
}
1 Like