[x3d-public] good example for ECMAScripting and Protos?

vmarchetti at kshell.com vmarchetti at kshell.com
Sat Aug 4 19:36:05 PDT 2018


I have modified the example I put up at http://www.kshell.com/pages/pointcloudvisualization/SphereDirectedPointSet.x3d <http://www.kshell.com/pages/pointcloudvisualization/SphereDirectedPointSet.x3d> , to put the Script code inside a CDATA section.

I don't know if it's relevant, but in the example, I've specified the accessType of the coord and normal fields to "initializeOnly", while in the standard X3D nodes corresponding fields for Coordinate and Normal data are specified inputOutput. I have to add some extra Javascript code in the Protobody script to implement input output events; and I wonder if doing that will make it more compatible with X3DOM.

> On Aug 4, 2018, at 3:23 PM, John Carlson <yottzumm at gmail.com> wrote:
> 
> Would doing the below be the same as creating an x3dscript node?  How would I also support X_ITE with similar code?
>  
> >> If you add a type='text/x3dscript' (or anything) attribute, the
> >> browser will not try to execute the script.
>  
>  
> Vince, is it okay to add this type='text/x3dscript' to the original, and I will add it to my copy?

That's fine; I'm distributing under Creative Commons license (as declared in header) so add and modify away. I'd like to keep the example at the URL above as X3D conforming.
The example passes the X3D Validator and works in InstantReality, Octaga, BS Contact, and X_ITE (see X-ITE page at http://www.kshell.com/pages/pointcloudvisualization/index.html <http://www.kshell.com/pages/pointcloudvisualization/index.html> )








> Thanks,
>  
> John
>  
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>  
> From: Andreas Plesch <mailto:andreasplesch at gmail.com>
> Sent: Saturday, August 4, 2018 3:09 PM
> To: John Carlson <mailto:yottzumm at gmail.com>
> Cc: Vincent Marchetti <mailto:vmarchetti at kshell.com>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>; x3dom mlist <mailto:x3dom-users at lists.sourceforge.net>
> Subject: Re: [x3d-public] good example for ECMAScripting and Protos?
>  
> On Sat, Aug 4, 2018 at 1:47 PM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
> > 
> > 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????
>  
> The script dom node is not processed by x3dom at all, yes. To start
> doing that it would be safest to introduce a x3dscript node in lieu of
> a script node, to exclude any interference at the cost of x3d
> compliance. In the end, there will need to be an eval of arbitrary js
> code which is questionable but perhaps ok since any server side system
> has to assume anyways that anything can happen on the client.
>  
> > 
> > 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.
> > 
> > Probably requires more investigation on my part.
> > 
> > In this case, the nodes are coordinate and normal nodes.
> > 
> > On Sat, Aug 4, 2018 at 8:53 AM Andreas Plesch <andreasplesch at gmail.com <mailto:andreasplesch at gmail.com>> wrote:
> >> 
> >> On Sat, Aug 4, 2018 at 4:56 AM John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
> >> >
> >> > 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.
> >> 
> >> I think you are referring to X3DOM's dom element method getFieldValue
> >> and that it does not work for SFNode type fields. For example:
> >> 
> >> shapeDomNode.getFieldValue('Appearance')
> >> 
> >> does not return anything.
> >> 
> >> I do not think this will be fixed soon.
> >> 
> >> You can try this instead
> >> 
> >> shapeDomNode._x3domNode._cf.appearance
> >> 
> >> with something like
> >> 
> >> dom._x3domNode._cf[field.toLowerCase]
> >> 
> >> which gives you an x3domNode object.
> >> 
> >> >
> >> > Thus I cannot take a reasonable length in the script.  One would have to parse the string.
> >> >
> >> >
> >> > 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.
> >> >
> >> >
> >> >
> >> > 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.
> >> >
> >> >
> >> >
> >> > We just need a script tag that has fields, but doesn’t execute its CDATA section.  I am pretty sure
> >> 
> >> If you add a type='text/x3dscript' (or anything) attribute, the
> >> browser will not try to execute the script.
> >> 
> >> >
> >> > How is V4.0 handling this?
> >> >
> >> >
> >> >
> >> > 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.
> >> >
> >> >
> >> >
> >> > Thanks for the great example, Vince,
> >> >
> >> >
> >> >
> >> > Should I adapt my code to deal with this failing in X3DOM, or should we change X3DOM?
> >> 
> >> What needs to be changed in x3dom ? The getFieldValue method ?
> >> 
> >> -Andreas
> >> >
> >> >
> >> >
> >> > John
> >> >
> >> >
> >> >
> >> > Sent from Mail for Windows 10
> >> >
> >> >
> >> >
> >> > From: vmarchetti at kshell.com <mailto:vmarchetti at kshell.com>
> >> > Sent: Wednesday, August 1, 2018 9:04 PM
> >> > To: John Carlson; X3D-Public
> >> > Subject: Re: [x3d-public] good example for ECMAScripting and Protos?
> >> >
> >> >
> >> >
> >> > See
> >> >
> >> > http://www.kshell.com/pages/pointcloudvisualization/SphereDirectedPointSet.x3d <http://www.kshell.com/pages/pointcloudvisualization/SphereDirectedPointSet.x3d>
> >> >
> >> >
> >> >
> >> > 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.
> >> >
> >> > Example used is just points randomly distributed on sphere with directs pointed radially outward.
> >> >
> >> >
> >> >
> >> > Potential uses would be to implement the scanning design pattern at http://x3dgraphics.com/examples/X3dForAdvancedModeling/Scanning/X3dMeshDesignPatternIndex.html <http://x3dgraphics.com/examples/X3dForAdvancedModeling/Scanning/X3dMeshDesignPatternIndex.html> , or
> >> >
> >> > visualizing fluid flow or  electromagnetic field
> >> >
> >> >
> >> >
> >> > On Jul 31, 2018, at 10:30 PM, John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
> >> >
> >> >
> >> >
> >> > Is there a good example of ECMAScripting in X3D that I can use to test my X3D JSON ECMAScript preprocessor?  Preferably with Protos
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > Thanks!
> >> >
> >> >
> >> >
> >> > John
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > x3d-public mailing list
> >> > x3d-public at web3d.org <mailto:x3d-public at web3d.org>
> >> > http://web3d.org/mailman/listinfo/x3d-public_web3d.org <http://web3d.org/mailman/listinfo/x3d-public_web3d.org>
> >> >
> >> >
> >> >
> >> >
> >> 
> >> 
> >> 
> >> --
> >> Andreas Plesch
> >> Waltham, MA 02453
>  
> --
> Andreas Plesch
> Waltham, MA 02453

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180804/3619a3a5/attachment-0001.html>


More information about the x3d-public mailing list