Home › Forums › General Questions › Change variable value
- This topic has 6 replies, 3 voices, and was last updated 2 years, 2 months ago by dbratko.
-
AuthorPosts
-
2022-09-14 at 5:45 am #55802dbratkoParticipant
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.
2022-09-14 at 9:54 am #55837Yuri KovelenovStaffPlease check out this Manual page: https://www.soft8soft.com/docs/manual/en/introduction/Using-JavaScript.html
2022-09-14 at 2:11 pm #55842dbratkoParticipantThank 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.
2022-09-14 at 7:10 pm #55851kdvParticipantDo 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 coding. 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 the meaning at all.
2022-09-14 at 9:40 pm #55854dbratkoParticipantThank 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.2022-09-15 at 12:40 am #55859kdvParticipantYou 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 functionwindow.addListener
, below this line});
.Like this
Puzzles and JS coding. 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 the meaning at all.
2022-09-15 at 6:28 pm #55880dbratkoParticipantThank 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. -
AuthorPosts
- You must be logged in to reply to this topic.