<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.apple-tab-span
        {mso-style-name:apple-tab-span;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:156657444;
        mso-list-template-ids:1099853882;}
@list l0:level1
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:36.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:72.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:108.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level4
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:144.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:180.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:216.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level7
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:252.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:288.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-number-format:alpha-upper;
        mso-level-tab-stop:324.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1
        {mso-list-id:1652830787;
        mso-list-template-ids:-8985244;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Thank you Holger. However, with respect, that does not answer the questions I posed.<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>I will indeed try along the lines you suggested – I did in fact try once and failed, but I probably made a mistake (as usual), and plan to try again.<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'>Roy<o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US>From:</span></b><span lang=EN-US> Holger Seelig <holger.seelig@yahoo.de> <br><b>Sent:</b> 16 December 2021 18:36<br><b>To:</b> roy.walmsley@gmail.com<br><b>Cc:</b> X3D <x3d-public@web3d.org><br><b>Subject:</b> Re: [x3d-public] Nested prototypes with scripts execution ordering query<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If you set a field in a Script node and want the proto to react on field changes the field must be an inputOutput field and in the  Script also, and then create a field handler with ’set_fieldName’.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Example:<o:p></o:p></p></div><div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>PROTO Door [<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>                </span>inputOutput SFVec2f doorSize 1 1<o:p></o:p></p></div><div><p class=MsoNormal>]<o:p></o:p></p></div><div><p class=MsoNormal>{<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>                </span>Script {<o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>                                </span><span style='color:black'>inputOutput SFVec2f doorSize IS dooSize</span><o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span><span style='color:black'>                                </span></span><span style='color:black'>url „</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='color:black'>function set_doorSize (value, time)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='color:black'>{</span><o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span><span style='color:black'>                </span></span><span style='color:black'>// handle change</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='color:black'>}</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='color:black'>"</span><o:p></o:p></p></div><div><p class=MsoNormal><span class=apple-tab-span>                </span>}<o:p></o:p></p></div><div><p class=MsoNormal>}<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Holger<o:p></o:p></p></div><div><div><p class=MsoNormal><br><br><o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal>Am 16.12.2021 um 14:42 schrieb <a href="mailto:roy.walmsley@gmail.com">roy.walmsley@gmail.com</a>:<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Hi,<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>I would like to clarify the order of execution to be expected with nested prototypes and scripts. To clarify, here is an example about a kitchen cabinet.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>I have a top-level X3D file that has an EXTERNPROTO defined for a DoubleFloorCabinet. I have a field in the prototype definition (among others) named cabinetWidth that is used to pass the width of the cabinet. I create a ProtoInstance of DoubleFloorCabinet, and specify the desired width in the field cabinetWidth.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>I have a second X3D file that contains the DoubleFloorCabinet prototype. This has a Script node, with a field cabinetWidth, with IS Connected to the prototype field cabinetWidth. The initialize function of this Script node calculates the required translations, rotations, sizes, etc., of all the Box nodes required to draw the cabinet at the desired width. This all works fine.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>Now, I want my cabinet to have doors, which might have different appearances, hence doors are drawn with a separate prototype. So my DoubleFloorCabinet has an EXTERNPROTO defined for CabinetDoor. I then create prototype instances, as necessary, and the previously mentioned Script calculates the door sizes, and hinge locations, etc., as required for the size of cabinet requested. So the CabinetDoor prototype has a SFVec2f field for doorSize, which is set by the Script during its initialize function.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>Finally, I have a third file CabinetDoor to draw a single door, which defines the CabinetDoor prototype. This draws a single door, at the requested size, and with the specified hinge location, etc.. All necessary calculations are currently carried out in the initialize function of this Script, and the appropriate transforms, extrusions, boxes, etc., are adjusted to draw the door as requested.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>Does it work? The door will be drawn the correct size if there is only one level of prototyping involved. However, with nested prototypes it fails, simply drawing the door, in the right place, but only at the default size. I’m assuming this may be because of the order of execution of the initialize functions in the Scripts in the nested prototypes. So:<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><ol style='margin-top:0cm' start=1 type=1><li class=MsoListParagraph style='margin-top:0cm;margin-bottom:0cm;mso-list:l1 level1 lfo1'>Is the execution order as follows? If not, what is it?<o:p></o:p></li><li class=MsoListParagraph style='margin-top:0cm;margin-bottom:0cm;mso-list:l1 level1 lfo1'>Is the ordering clearly specified in the standard?<o:p></o:p></li></ol><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal><b><u>EXECUTION ORDER</u></b><o:p></o:p></p></div><div><p class=MsoNormal><b> </b><o:p></o:p></p></div><ol style='margin-top:0cm' start=1 type=A><li class=MsoListParagraph style='margin-top:0cm;margin-bottom:0cm;mso-list:l0 level1 lfo2'>Instantiate top level ProtoInstance<o:p></o:p></li><li class=MsoListParagraph style='margin-top:0cm;margin-bottom:0cm;mso-list:l0 level1 lfo2'>Instantiate nested level ProtoInstance<o:p></o:p></li><li class=MsoListParagraph style='margin-top:0cm;margin-bottom:0cm;mso-list:l0 level1 lfo2'>Call Script initialize function in nested level ProtoInstance<o:p></o:p></li><li class=MsoListParagraph style='margin-top:0cm;margin-bottom:0cm;mso-list:l0 level1 lfo2'>Call Script initialize function in top level ProtoInstance<o:p></o:p></li><li class=MsoListParagraph style='margin-top:0cm;margin-bottom:0cm;mso-list:l0 level1 lfo2'>Present Scene to browser.<o:p></o:p></li></ol><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>Thank you in advance for your comments,<o:p></o:p></p></div><div><p class=MsoNormal>Roy<o:p></o:p></p></div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Helvetica",sans-serif'>_______________________________________________<br>x3d-public mailing list<br></span><a href="mailto:x3d-public@web3d.org"><span style='font-size:9.0pt;font-family:"Helvetica",sans-serif'>x3d-public@web3d.org</span></a><span style='font-size:9.0pt;font-family:"Helvetica",sans-serif'><br></span><a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org"><span style='font-size:9.0pt;font-family:"Helvetica",sans-serif'>http://web3d.org/mailman/listinfo/x3d-public_web3d.org</span></a><o:p></o:p></p></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></div></body></html>