Making an interactive 3D Web App with Armory?

Would it be possible to integrate Armory into an existing HTML/Javascript website in an interactive way?

As an example, let’s assume that my website has a dropdown menu and a 3d viewport that runs my armory scene. If the user selects an item from the dropdown menu, a javascript function is called that should in turn trigger some action in the 3d viewport.

How would I do this? Can I implement a haxe function in armory, that can be called by javascript? Would it work with logic nodes? Or do I have to somehow mess with the kha.js file?

Best regards
-Sebastian

1 Like

Nevermind, I got it working!
If someone else is having the same question: It’s incredibly simple. All you need to do is to to mark whatever class you want to access in Javascript using the @:expose compiler flag. Here is an altered version of the BoxGenerator.hx of the script_genmesh example (armory_examples-master\script_genmesh\Sources\arm): BoxGenerator.hx (3.0 KB)

now, in your index.html or your webbrowser’s console, all you have to do is to write:
var MyTester = new arm.BoxGenerator();
MyTester.test();
This will spawn a new cube.

see also: https://haxe.org/manual/target-javascript-expose.html

I’m completely blown away by all this haxe / kha / armory stuff :slight_smile: .

4 Likes