<html 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:"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:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Yes, I am concerned about evaluating arbitrary JS, and would prefer a totally declarative approach.   Or I could look into creating a JS sandbox, but I’m not sure what the best one is, or if they really work.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m kind of stuck by the standard, and not having a sandbox or my own JS implementation.</p><p class=MsoNormal><br>What does X_ITE do?</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:andreasplesch@gmail.com">Andreas Plesch</a><br><b>Sent: </b>Saturday, August 4, 2018 3:09 PM<br><b>To: </b><a href="mailto:yottzumm@gmail.com">John Carlson</a><br><b>Cc: </b><a href="mailto:vmarchetti@kshell.com">Vincent Marchetti</a>; <a href="mailto:x3d-public@web3d.org">X3D Graphics public mailing list</a>; <a href="mailto:x3dom-users@lists.sourceforge.net">x3dom mlist</a><br><b>Subject: </b>Re: [x3d-public] good example for ECMAScripting and Protos?</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On Sat, Aug 4, 2018 at 1:47 PM John Carlson <yottzumm@gmail.com> wrote:</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> I belive in this case, it’s the node and not the field we are trying to get the point field value from.   The problem is that getFieldValue is not defined because I am pretty sure that the node wasn’t processed by X3DOM????</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The script dom node is not processed by x3dom at all, yes. To start</p><p class=MsoNormal>doing that it would be safest to introduce a x3dscript node in lieu of</p><p class=MsoNormal>a script node, to exclude any interference at the cost of x3d</p><p class=MsoNormal>compliance. In the end, there will need to be an eval of arbitrary js</p><p class=MsoNormal>code which is questionable but perhaps ok since any server side system</p><p class=MsoNormal>has to assume anyways that anything can happen on the client.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> To change X3DOM, we would probably need a script tag and a way to handle the script fields. I believe these particular nodes are USEd elsewhere, so they should be active as nodes.  Hmm.</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> Probably requires more investigation on my part.</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> In this case, the nodes are coordinate and normal nodes.</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> On Sat, Aug 4, 2018 at 8:53 AM Andreas Plesch <andreasplesch@gmail.com> wrote:</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> On Sat, Aug 4, 2018 at 4:56 AM John Carlson <yottzumm@gmail.com> wrote:</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > I have a problem with this file in X3DOM, because as far as I can tell, the SFNode fields (the node, not the field) do not have getFieldValue for point etc. as a function, for example (but one can double check me).  In other words, I don’t think this node is an X3DOM node.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> I think you are referring to X3DOM's dom element method getFieldValue</p><p class=MsoNormal>>> and that it does not work for SFNode type fields. For example:</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> shapeDomNode.getFieldValue('Appearance')</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> does not return anything.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> I do not think this will be fixed soon.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> You can try this instead</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> shapeDomNode._x3domNode._cf.appearance</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> with something like</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> dom._x3domNode._cf[field.toLowerCase]</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> which gives you an x3domNode object.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Thus I cannot take a reasonable length in the script.  One would have to parse the string.</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > That’s as clear as I can get.  I think this might be because x3dom does not process scripts correctly. We would need a script tag handler, and a field handler inside that.</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Can you help Andreas?  I’ve created a script tag before, but that code is lost. It might be in my GitHub repository somewhere, not sure.</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > We just need a script tag that has fields, but doesn’t execute its CDATA section.  I am pretty sure</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> If you add a type='text/x3dscript' (or anything) attribute, the</p><p class=MsoNormal>>> browser will not try to execute the script.</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > How is V4.0 handling this?</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Alternatively, I can change my nodeUtil code to look at the type and do the right thing converting a string to the correct type.   Suggestions are welcome.</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Thanks for the great example, Vince,</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Should I adapt my code to deal with this failing in X3DOM, or should we change X3DOM?</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> What needs to be changed in x3dom ? The getFieldValue method ?</p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> -Andreas</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > John</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Sent from Mail for Windows 10</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > From: vmarchetti@kshell.com</p><p class=MsoNormal>>> > Sent: Wednesday, August 1, 2018 9:04 PM</p><p class=MsoNormal>>> > To: John Carlson; X3D-Public</p><p class=MsoNormal>>> > Subject: Re: [x3d-public] good example for ECMAScripting and Protos?</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > See</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > http://www.kshell.com/pages/pointcloudvisualization/SphereDirectedPointSet.x3d</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > It is a X3D file with with a Prototype + ecmascript definition of a point cloud, with a vector attached to each point of the cloud.</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Example used is just points randomly distributed on sphere with directs pointed radially outward.</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Potential uses would be to implement the scanning design pattern at http://x3dgraphics.com/examples/X3dForAdvancedModeling/Scanning/X3dMeshDesignPatternIndex.html , or</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > visualizing fluid flow or  electromagnetic field</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > On Jul 31, 2018, at 10:30 PM, John Carlson <yottzumm@gmail.com> wrote:</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Is there a good example of ECMAScripting in X3D that I can use to test my X3D JSON ECMAScript preprocessor?  Preferably with Protos</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > Thanks!</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > John</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> > _______________________________________________</p><p class=MsoNormal>>> > x3d-public mailing list</p><p class=MsoNormal>>> > x3d-public@web3d.org</p><p class=MsoNormal>>> > http://web3d.org/mailman/listinfo/x3d-public_web3d.org</p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>> ></p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>><o:p> </o:p></p><p class=MsoNormal>>> --</p><p class=MsoNormal>>> Andreas Plesch</p><p class=MsoNormal>>> Waltham, MA 02453</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>-- </p><p class=MsoNormal>Andreas Plesch</p><p class=MsoNormal>Waltham, MA 02453</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>