<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=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@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;
mso-fareast-language:EN-US;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@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:345328022;
mso-list-type:hybrid;
mso-list-template-ids:861470294 134807573 134807577 134807579 134807567 134807577 134807579 134807567 134807577 134807579;}
@list l0:level1
{mso-level-number-format:alpha-upper;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1
{mso-list-id:908736765;
mso-list-type:hybrid;
mso-list-template-ids:-287265234 134807567 134807577 134807579 134807567 134807577 134807579 134807567 134807577 134807579;}
@list l1:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
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="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><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><p class=MsoNormal><o:p> </o:p></p><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><p class=MsoNormal><o:p> </o:p></p><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><p class=MsoNormal><o:p> </o:p></p><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><p class=MsoNormal><o:p> </o:p></p><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><p class=MsoNormal><o:p> </o:p></p><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><p class=MsoNormal><o:p> </o:p></p><ol style='margin-top:0cm' start=1 type=1><li class=MsoListParagraph style='margin-left: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-left:0cm;mso-list:l1 level1 lfo1'>Is the ordering clearly specified in the standard?<o:p></o:p></li></ol><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b><u>EXECUTION ORDER<o:p></o:p></u></b></p><p class=MsoNormal><b><u><o:p><span style='text-decoration:none'> </span></o:p></u></b></p><ol style='margin-top:0cm' start=1 type=A><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo2'>Instantiate top level ProtoInstance<u><o:p></o:p></u></li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo2'>Instantiate nested level ProtoInstance<u><o:p></o:p></u></li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo2'>Call Script initialize function in nested level ProtoInstance<u><o:p></o:p></u></li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo2'>Call Script initialize function in top level ProtoInstance<u><o:p></o:p></u></li><li class=MsoListParagraph style='margin-left:0cm;mso-list:l0 level1 lfo2'>Present Scene to browser.<u><o:p></o:p></u></li></ol><p class=MsoNormal><u><o:p><span style='text-decoration:none'> </span></o:p></u></p><p class=MsoNormal>Thank you in advance for your comments,<o:p></o:p></p><p class=MsoNormal>Roy<o:p></o:p></p></div></body></html>