Home › Forums › Programming › How to call a V3D function from outside the iframe?
- This topic has 8 replies, 3 voices, and was last updated 4 years, 11 months ago by
Yuri Kovelenov.
-
AuthorPosts
-
2019-10-03 at 1:05 pm #19783
D3Pixel
CustomerHi
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
2019-10-03 at 1:19 pm #19786Yuri Kovelenov
Staff2019-10-03 at 1:27 pm #19788D3Pixel
CustomerBrill, thanks so much for the quick answer Yuri!
3D Animation and Web3D services - www.d3pixel.co.uk
2019-10-03 at 2:09 pm #19795D3Pixel
CustomerObject 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
2019-10-03 at 2:33 pm #19799Alexander Kovelenov
StaffHi,
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"]()
2019-10-03 at 2:45 pm #19804D3Pixel
CustomerAh, 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
2019-10-03 at 2:57 pm #19805D3Pixel
CustomerGot 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
2019-10-03 at 3:18 pm #19806D3Pixel
CustomerAnyway, I got it working using the v3d app methods and it seems nice and quick.
Demo
https://www.d3pixel.co.uk/web3d.html3D Animation and Web3D services - www.d3pixel.co.uk
2019-10-04 at 6:23 am #19820Yuri Kovelenov
Staff -
AuthorPosts
- You must be logged in to reply to this topic.