Home › Forums › Programming › Call Puzzle procedure from external JS ?
- This topic has 14 replies, 6 voices, and was last updated 1 month, 2 weeks ago by
bigmike814.
-
AuthorPosts
-
2021-03-03 at 7:39 am #39073
psykokwak
ParticipantHi all,
I embbed my V3D app into an iframe and I would like to call a custom procedure puzzle from the parent javascript.For exemple doing something like that :
var iframe = document.getElementById("verge3diframe").contentWindow; iframe.v3d.apps[0].CameraMoveToGlobal();
Thanks.
Attachments:
2021-03-03 at 10:05 am #39077Yuri Kovelenov
StaffHi,
you can trigger procedure puzzles from JavaScript as shown here
https://www.soft8soft.com/docs/manual/en/introduction/Using-JavaScript.html2021-03-03 at 10:12 am #39079psykokwak
ParticipantThanks for your answer.
But how access to the “PROC” from parent frame javascript ?2021-03-04 at 10:31 am #39138psykokwak
ParticipantOK. I copied all the usefull code from visual_logic.js to my own js library. It works but it make a lot of code redundancy.
2021-03-04 at 12:40 pm #39139Alexander Kovelenov
Staff2021-03-04 at 2:05 pm #39141psykokwak
ParticipantHello Alexander,
Thanks for your help.
But I’m sorry but it does not work.I can access to the iframe v3d context from my parent document using :
var iframe = document.getElementById("verge3diframe").contentWindow;
But I don’t know how to access to my visual_logic (= my puzzles) from there.
Your documentation says we can use PROC to access to puzzles procedures but it works only on “exec script” puzzle.
2021-03-04 at 7:44 pm #39151Crunch
Customertry
document.getElementById(“verge3diframe”).contentWindow.v3d.puzzles.procedures.abc();
where “abc” is the name of your procedure in puzzles.
2021-03-04 at 7:49 pm #39152Crunch
Customerline 50
Attachments:
2021-03-05 at 8:56 am #39165psykokwak
ParticipantAhhh
Thanks a lot. It’s exactly what I looking for.2025-07-11 at 5:14 pm #82927c4cc
Customersorry for replying to a late question, but to Alex or Yuri, what is this puzzle named as a function()? (e.g., initfullscreen() ? )
Intended code:
function defscrdis() { document.getElementById("gamescreen").contentWindow.v3d.puzzles.**(); }
Basically, I’m trying to reduce distance number of objects when window screen, and increase distance number when fullscreen. I’m trying to apply the below method to my app, to trigger puzzles when javascript is first.
line 50
2025-07-11 at 6:22 pm #82930Alexander Kovelenov
StaffBasically, I’m trying to reduce distance number of objects when window screen, and increase distance number when fullscreen.
No, the “init fullscreen” puzzle is used to make a custom HTML element behave as fullscreen button. What you really need is to register event handler for “fullscreenchange” event. Upon entering the window.document.fullscreenElement property would be non-nullish, so you can use this fact to distinct enter/exit actions. Check out the following example:
-
This reply was modified 1 month, 2 weeks ago by
Alexander Kovelenov.
2025-07-11 at 6:36 pm #82933c4cc
CustomerThanks. So how do I change distance value for number puzzles whenever external javascript is triggered for fullscreen?-
This reply was modified 1 month, 2 weeks ago by
c4cc.
2025-07-11 at 7:36 pm #82937c4cc
Customer2025-07-12 at 8:35 am #82940c4cc
CustomerBasically, my custom fullscreen button exists outside the verge3d iframe, as an html element. So how do I get change distance value of certain puzzles in verge3d when fullscreen?
The HTML, javascript and puzzles are in my above post.
How to reference a Verge 3d varible in a Javascript Code Puzzle
2025-07-12 at 4:20 pm #82942bigmike814
Customeryou can call puzzle functions from outside of visual_logic with v3d.puzzles.procedures.myFunction
I don’t know that it will work through an iFrame though.
edit: the guy above posted your answer a long time ago.function runaPuzzle() {
document.getElementById(“my_iframe”) .contentWindow.v3d.puzzles.procedures.hidedacube();
}-
This reply was modified 1 month, 2 weeks ago by
bigmike814.
-
AuthorPosts
- You must be logged in to reply to this topic.