From ed768b1344d913481a5562ba383c5d0f5d596451 Mon Sep 17 00:00:00 2001 From: Michael Leuschel <leuschel@uni-duesseldorf.de> Date: Wed, 15 Jun 2022 10:52:27 +0200 Subject: [PATCH] add 3D example for Button2 Signed-off-by: Michael Leuschel <leuschel@uni-duesseldorf.de> --- Button/button2.mch | 3 ++- Button/button2_3d.json | 43 ++++++++++++++++++++++++++++++++++++++++ Button/x3dom_button.html | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 Button/button2_3d.json create mode 100644 Button/x3dom_button.html diff --git a/Button/button2.mch b/Button/button2.mch index da3522c..e66194d 100644 --- a/Button/button2.mch +++ b/Button/button2.mch @@ -2,7 +2,8 @@ MACHINE button2 // a version of button with just two events DEFINITIONS "LibraryMeta.def"; - VISB_JSON_FILE == "button2.json" + VISB_JSON_FILE == "button2.json"; + VISB_JSON_FILE2 == "button2_3d.json" VARIABLES button INVARIANT diff --git a/Button/button2_3d.json b/Button/button2_3d.json new file mode 100644 index 0000000..b57a72b --- /dev/null +++ b/Button/button2_3d.json @@ -0,0 +1,43 @@ +{ + "svg": "x3dom_button.html", + "model": "button2.mch", + "model-name": "button2", + + "items": [ + { + "id": "button_%0", + "attr": "visible", + "value": "IF button=%0 THEN \"true\" ELSE \"false\" END", + "repeat": [ "TRUE", "FALSE" ] + }, + { + "id": "box_col", + "attr": "diffuseColor", + "value": "IF button=TRUE THEN \"1 0 0\" ELSE \"0 1 0\" END" + } + ], + "events": [ + { + "id": "button", + "event": "press_button", + "hovers": [{ "id":"hover_message", + "attr":"text", "enter":"Press", "leave":""}] + }, + { + "id": "button", + "event": "release_button" + }, + { + "id": "button_TRUE", + "event": "", + "hovers": [{ "id":"hover_message", + "attr":"text", "enter":"Button=TRUE", "leave":""}] + }, + { + "id": "button_FALSE", + "event": "", + "hovers": [{ "id":"hover_message", + "attr":"text", "enter":"Button=FALSE", "leave":""}] + } + ] +} diff --git a/Button/x3dom_button.html b/Button/x3dom_button.html new file mode 100644 index 0000000..754c920 --- /dev/null +++ b/Button/x3dom_button.html @@ -0,0 +1,38 @@ + <script type='text/javascript' src='https://www.x3dom.org/download/x3dom.js'> </script> + <link rel='stylesheet' type='text/css' href='https://www.x3dom.org/download/x3dom.css'></link> + + <h1>Using X3DOM for VisB</h1> + <p> + This illustrates how one can use VisB to manipulated 3D Objects + </p> + <x3d width='500px' height='400px'> + <scene> + <transform id="box_trans" translation='0 0 0'> + <shape id="button"> + <appearance> + <material id="box_col" diffuseColor='1 0 0'></material> + </appearance> + <box></box> + </shape> + <transform translation='-3 0 0'> + <shape id = "button_TRUE"> + <appearance> + <material diffuseColor='0 1 0'></material> + </appearance> + <cone></cone> + </shape> + </transform> + <transform id="sphere_trans" translation='3 0 0'> + <shape id = "button_FALSE"> + <appearance> + <material id="sphere_col" diffuseColor='0 0 1'></material> + </appearance> + <sphere></sphere> + </shape> + </transform> + </scene> + </x3d> +<ul> +<li>Message: <b><span id="hover_message"></span></b> +</li> +</ul> \ No newline at end of file -- GitLab