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.

Change variable value

Home Forums General Questions Change variable value

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #55802
    dbratko
    Participant

    I have model with some objects on it.
    I have created variable for each object which I would like to manipulated.
    And I have created app logic, if variable has value 1 then change color of object.
    Now, my idea is to call JS function (which I would somehow insert to wherever it has to be inserted) which would then change color of a object.
    How and where I can insert my own JS function for that purpose?

    Or if there is other way how I should do it, give me a clue.

    Thanks in advance.

    #55837
    #55842
    dbratko
    Participant

    Thank you for your feedback.

    Yes, I have already saw this article, and have tried method 3. But when implementing it, this function is not visible in outter scope since functions are declared inside IIFE.
    And what I assume that even if js function would be visible, would it be possible to update value of variable defined trough editor? Would variable be visible to the function (are they on the same scope)?

    Some example would be great for me, as I’m very much new in Verge3D world.

    Thank you for your assistance.

    #55851
    kdv
    Participant

    Do you want you control your model from somewhere outside? v3d.puzzles can help you to access any procedure created in the puzzle editor https://www.soft8soft.com/topic/accessing-puzzles-variable-from-separate-script-running-inside-child-iframe/

    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.

    #55854
    dbratko
    Participant

    Thank you again for your feedback.

    I have done as attached pictures. But still I got error “Uncaught ReferenceError: B4J2wv is not defined in https://cdn.soft8soft.com/… (Line: 1)”

    What am I doing wrong?

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

    You should use a procedure to change visibility. Your if else works only once on the app loading. Place it inside a procedure and call this procedure. And your function must be declared outside the function window.addListener, below this line });.

    Like this

    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.

    #55880
    dbratko
    Participant

    Thank you for your help.
    Just for those who will need to solve simmilar problem … this is how I did it:

    See picture for puzzles part.

    And in AppName.js I have put this code:

    function B4J2wv(p1) {
    v3d.puzzles.procedures.DoRed(p1);
    }

    This will color object to red which is referenced with name by calling a js function B4J2wv.

    Hope this helps.

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