0

I have function which is called onclick event, but inside I have for loop and I would like to store a counter value, so on each click I will be able to iterate to another file

 var canvas;
 var viewer = new JSC3D.Viewer(canvas);

  function loadModel()
  {
    var filename = document.getElementById("hidden_file_path").innerHTML;
      var components=['something1.stl', 'something2.stl'];
       for  ( var i=0; i<components.length; i++  ) 
       {
         viewer.replaceSceneFromUrl(components[i]);
       }
    viewer.update();
  }
1
  • 1
    What is your question ? Commented Sep 3, 2015 at 8:40

1 Answer 1

3

I am assumin that you call loadModel on click.

var canvas;
var viewer = new JSC3D.Viewer(canvas);
var counter = 0;
var filename = document.getElementById("hidden_file_path").innerHTML; // where are you using filename?
var components=['something1.stl', 'something2.stl']; 

  function loadModel()
  {
    viewer.replaceSceneFromUrl(components[counter]);
    counter++;
    viewer.update();
  }

Hope this solves the problem

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.