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.

How to call a V3D function from outside the iframe?

Home Forums Programming How to call a V3D function from outside the iframe?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #19783
    D3Pixel
    Customer

    Hi

    How can i access Verge3D functions from the parent doc outside the Verge3D iFrame?

    I thought I could do:

    
     var myWebGL = document.getElementById("iFrame");
     var win = myWebGL.contentWindow;
     var object = win.app.scene.getObjectByName("Box01");
    
    

    This doesn’t work though.
    Thanks for any help.

    3D Animation and Web3D services - www.d3pixel.co.uk

    #19786

    You can access app methods via v3d:

    var object = win.v3d.apps[0].scene.getObjectByName("Box01");

    Chief 3D Verger | LinkedIn | Twitter

    #19788
    D3Pixel
    Customer

    Brill, thanks so much for the quick answer Yuri!
    :yahoo:

    3D Animation and Web3D services - www.d3pixel.co.uk

    #19795
    D3Pixel
    Customer

    Object now works but object.material is undefined.

    var object = win.v3d.apps[0].scene.getObjectByName("Load Cell Main Body FULL");
    var mat = object.material;
    
      // var index = mat.nodeRGBMap['RGB']; 
      // mat.nodeRGB[index] = new v3d.Vector4(1, 0, 0, 1); 
      // mat.needsUpdate = true;

    I have R.G.B. values from HTML and just want to change the color node “RGB” of a Principled material whenever my color picker event fires.

    Or I could call a visual_logic.js function from outside the iFrame somehow? as that contains function setMaterialColor(matName, colName, r, g, b)

    Sorry to ask these questions, next time I will start with a code template and go from there.

    3D Animation and Web3D services - www.d3pixel.co.uk

    #19799

    Hi,

    is the object “Load Cell Main Body FULL” contains multiple materials? If so, you need to check the object’s children to get yours.

    With regard to the Puzzles functions, I have good news for you. Starting from Verge3D 2.15 you can execute any Puzzles procedures right from the v3d namespace:

    win.v3d.puzzles.procedures.YOUR_FUNCTION_NAME()

    or if it contains spaces:

    win.v3d.puzzles.procedures["YOUR FUNCTION NAME"]()

    Soft8Soft Tech Chief
    X | FB | LinkedIn

    #19804
    D3Pixel
    Customer

    Ah, yes, it contains 3 materials. I will look at how to get the one I want.

    I also tried calling the new puzzle function (assuming you mean one in visual_logic.js)
    win.v3d.puzzles.procedures.setMaterialColor("Mainbody_Black", "RGB",1,0,0);
    and that gave:
    Uncaught TypeError: win.v3d.puzzles.procedures.setMaterialColor is not a function

    I am using: Verge3D 2.15.0 (WebGL 2.0)

    3D Animation and Web3D services - www.d3pixel.co.uk

    #19805
    D3Pixel
    Customer

    Got it.

    var mat = object.children[0].material;

    Not sure how to call visual_logic puzzle functions as you mentioned though.

    3D Animation and Web3D services - www.d3pixel.co.uk

    #19806
    D3Pixel
    Customer

    Anyway, I got it working using the v3d app methods and it seems nice and quick.

    Demo
    https://www.d3pixel.co.uk/web3d.html

    3D Animation and Web3D services - www.d3pixel.co.uk

    #19820

    Glad you worked it out! The app looks great! :good:

    Chief 3D Verger | LinkedIn | Twitter

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