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?

  • This topic has 6 replies, 4 voices, and was last updated 2 years ago by kdv.
Viewing 7 posts - 1 through 7 (of 7 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!

    #50138
    precismo
    Customer

    Note to anyone having this issue: materials are assigned to meshes in scene. Once replaced they do not exist anywhere else, thus just got deleted by garbage collector. Solution is to pick all materials manually to some array for further use.

    #50183
    AVerge3Der
    Participant

    If in Blender click the Fake User button.

    Attachments:
    You must be logged in to view attached files.
    #51346
    kdv
    Participant

    If in Blender click the Fake User button.

    it doesn’t work. only hidden primitives help to save materials from being eliminated by GC )))

    Puzzles and JS. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of meaning at all.

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