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.

Call Puzzle procedure from external JS ?

Home Forums Programming Call Puzzle procedure from external JS ?

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #39073
    psykokwak
    Participant

    Hi 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:
    #39077

    Hi,

    you can trigger procedure puzzles from JavaScript as shown here
    https://www.soft8soft.com/docs/manual/en/introduction/Using-JavaScript.html

    Chief 3D Verger | LinkedIn | X

    #39079
    psykokwak
    Participant

    Thanks for your answer.
    But how access to the “PROC” from parent frame javascript ?

    #39138
    psykokwak
    Participant

    OK. 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.

    #39139

    Hi, You can surely execute the procedure from the external iframe. See here for more info.

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #39141
    psykokwak
    Participant

    Hello 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.

    #39151
    Crunch
    Customer

    try

    document.getElementById(“verge3diframe”).contentWindow.v3d.puzzles.procedures.abc();

    where “abc” is the name of your procedure in puzzles.

    #39152
    Crunch
    Customer

    line 50

    Attachments:
    #39165
    psykokwak
    Participant

    Ahhh :yahoo:
    Thanks a lot. It’s exactly what I looking for.

    #82927
    c4cc
    Customer

    sorry 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

    • This reply was modified 1 month, 2 weeks ago by c4cc.
    • This reply was modified 1 month, 2 weeks ago by c4cc.
    #82930

    Basically, 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:

    puzzles to handle fullscreenchange envent

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #82933
    c4cc
    Customer

    Thanks. 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.
    #82937
    c4cc
    Customer

    I tried to implement this into my iframe, but unfortunately for fullscreen, my desired objects went slower instead of faster

    My fullscreen javascript:

    Fullscreen HTML:

    My puzzles:

    • This reply was modified 1 month, 2 weeks ago by c4cc.
    • This reply was modified 1 month, 2 weeks ago by c4cc.
    #82940
    c4cc
    Customer

    Basically, 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

    • This reply was modified 1 month, 2 weeks ago by c4cc.
    • This reply was modified 1 month, 2 weeks ago by c4cc.
    • This reply was modified 1 month, 2 weeks ago by c4cc.
    #82942
    bigmike814
    Customer

    you 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.
Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.