We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

assignMat for second time fails?

Home Forums Bug Reports and Feature Requests assignMat for second time fails?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41965
    precismo
    Customer

    Hi Verge!

    First of all, thank you for great version 3.7! I am very happy with all new functionality!

    Im trying to make custom configurator for our customers running through iframe. I tried to mimic demos simple configurator and Recliner which are doing exactly what I need. Triggering geometry through puzzle is working, however when I try to change material on some objects via assignMat in visual_logic.js it works only the first time i make this change. Any change of material for the second time fails and does not happen. Seems bit odd to me.

    Relevant lines 594 in my visual_logic:

    
    eventHTMLElem('click', 'button1', true, function(event) {
      listMaterials();
    
      assignMat('Sphere', 'zlato');    
      assignMat('Cube2', 'zlato');    
      assignMat('Cube', 'zlato');    
      /*console.log(getObjectMaterial('Sphere'))
    
      if(getObjectMaterial('Sphere')=='zlatonormal2'){
        assignMat('Sphere', 'zlato');
      } else {
        assignMat('Sphere', 'zlatonormal2');
      }*/
    });
    
    ...     
    
    eventHTMLElem('click', 'button3', true, function(event) {
        assignMat('Sphere', 'zlatonormal2');
        assignMat('Cube2', 'zlatonormal2');
        assignMat('Cube', 'zlatonormal2');
        listMaterials();
    });
    

    Im attaching full demo as zip – plrease refer to index.html which is nesting configurator.html in iframe.

    It seems like material is not visible second time it is attached to the object: function assignMat returns on this line:

        var mat = v3d.SceneUtils.getMaterialByName(appInstance, matName);
        if (!mat)
            return

    This does not happen first time material is attached though.

    Please can you help me resolve this issue?

    #41975
    precismo
    Customer

    Attachement was blocked, here is link to it: http://skygazer.eu/precismo/configurator/configurator.zip

    #42040

    Because zlato2 material exist only on the sphere and you replace it by zlato material it just not present anymore on the scene. Assign all materials to a simple invisible object that you will always keep unchanged.

    Co-founder and lead graphics specialist at Soft8Soft.

    #42347
    precismo
    Customer

    Understand, thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.