Change 3D model file after click button

Hello everyone :wave:

I’am pretty new in Babylon and i have one problem. I want to change 3d model file when click button my button:

<button onclick="changeModel('prostokat.babylon')">test</button>

Function changeModel

var modelName = "kolo.babylon";

    function changeModel(renameModel){
       modelName = "untitled.babylon";
       delayCreateScene();
    }

Babylon

function delayCreateScene() {
  console.log(modelName);
  var scene = new BABYLON.Scene(engine);
  var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 0, new BABYLON.Vector3(0, 0, 0), scene);
  BABYLON.SceneLoader.Append("http://atma.com.pl/babylon2/", modelName, scene, function 
  (meshes) {
.....
 }
}

If i click on the button, my function run but model is not replaced :expressionless:

This is because you are creating a new scene instead of adding to your current one

Thank for help. I fix my code but i create spaghetti code :stuck_out_tongue:

It is possible create this in the simplest way?

My code :point_down: :point_down: :point_down:

This is not working (http vs https)

Sorry :wink: i fix that
In page (i didn’t put it playground since it is in html body) i have two button who change 3d model:

<button onclick="changeScene(0)">Version 1</button>
<button onclick="changeScene(1)">Version 2</button>

can you share the fixed link?

Where is your button? Please create a working repro :smiley: