[x3d-public] working on JavaScript SAI example, without an SAI
John Carlson
yottzumm at gmail.com
Tue Jan 14 21:28:50 PST 2020
So I've been thinking about the constructors for all the X3D nodes. I
have, I think, the beginnings of code generation. Each constructor can be
created in this way (just for the SF fields):
node.nodeName+" = function(options) { for (opt in options) { if (typeof
options[opt] === 'string') { options[opt] = '\"'+options[opt]+'\"'; }
this['@'+opt] = options[opt]; }}\n";
Note that the code will be placed in a object (this.fcode) with the
node.nodeName key (for now).
This will produce the following (for the head):
head = function(options) { for (opt in options) { if (typeof options[opt]
=== 'string') { options[opt] = '"'+options[opt]+'"'; } this['@'+opt] =
options[opt]; }}
Extension contributions to the construction generator are welcome!
Probably I could do this with VSCode, as Andreas said. Unfortunately, I
use vim, and I'm not for repeating GUI functions over and over again.
ECMAScript is my Swiss Army Knife. If I can program VSCode to do the
repeated operations without stopping at each class, great! Please instruct
me! I can easily look up field types in fieldTypes.js if necessary for
typechecking of field values.
Next on the todo list I think is multiple MFNodes in a node.
Thanks,
John
On Tue, Jan 14, 2020 at 2:16 PM Andreas Plesch <andreasplesch at gmail.com>
wrote:
> Server side, node.js based x3d generation would be useful. It is
> certainly already possible, either with xml and perhaps a virtual dom
> (https://www.npmjs.com/package/jsdom) with d3 (or just dom methods) or
> xml processing (https://www.npmjs.com/package/xmlbuilder), or with
> json since it is a Javascript Object Notation. But a dedicated Scene
> Generator Interface would have many benefits, as pointed out.
>
> Since there is the JSON encoding, I think the natural assumption would
> be that the generated x3d is a javascript object and that a simple
> JSON.stringify(x3dobject) would produce valid json encoded x3d.
> Similarly, a simple JSON.parse(x3dJsonString) would produce a x3d
> javascript object which can be manipulated by the Interface, or which
> the Interface could reproduce.
>
> Trying some lines ...
>
> x3d = require('x3dSGI');
> myshape = new x3d.Shape(); // default Shape, is object with json properties
> myshape["-geometry"] = new x3d.Box({ size: new x3d.SFVec3f( [1, 2, 3]
> ) }); // with constructor option; would @size work better ?
> myShapeClone = myshape.deepObjectCopy(); // .deepObjectCopy from elsewhere
> myAppearance = new x3d.Appearance(); //
> myAppearance["-material'] = new x3d.Material({ diffuseColor: new
> x3d.SFColor( [0.1, 1, 1] ) }); // would @diffuseColor work better to
> directly create json encoding ?
> myShapeClone["-appearance"] = myAppearance;
> myGroup = new x3d.Group( { children: [ myshape, myShapeClone ] } ); //
> "-children" ?
>
> x3djson = JSON.stringify(myGroup);
> x3dxml = x3d.toXML (myGroup);
>
> So this works pretty well, except for the decorations from the json
> encoding which would be required for stringify. I guess there needs to
> be a dedicated x3d.toJSON function.
>
> Typescript and typings would let smart IDE like VSCode provide
> automatically a lot of functionality.
>
> some thoughts, -Andreas
>
>
>
>
>
>
>
>
> On Tue, Jan 14, 2020 at 1:13 PM Don Brutzman <brutzman at nps.edu> wrote:
> >
> > John, thanks for looking at this.
> >
> > It certainly is interesting to consider that scene graph construction
> using JavaScript really is... approximately the same as the JSON encoding,
> which we already have. Hello World example:
> >
> >
> https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorldIndex.html
> >
> https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.x3d
> >
> https://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01TechnicalOverview/HelloWorld.json
> >
> > Still I could see where some JavaScript programmers might want something
> along the lines you are laying out. We chould add predifined enumerations
> (e.g. COMPONENT_NAME_NAVIGATION) and so forth. Could also add type
> checking and consistency checking to the getter/setter methods, similar to
> what exists already in the autogenerated Java and Python language
> implementations provided by X3DJSAIL and X3DPSAIL. Those certainly can
> help during programmatic construction. Could also add utility methods for
> import/export, again similar to other libraries.
> >
> > Use case: server-side JavaScript programming, for example using node.js
> as server or command line. Not a use case: rendering or interaction.
> >
> > If we get the example syntax well defined, such as what you have below,
> then it is relatively straightforward for me to adapt our current XSLT
> stylesheets to autogenerate such an API, along with a X3dToJavaScript.xslt
> converter. Adding a few small switches might make that further adaptable
> as a X3dToTypeScript.xslt converter.
> >
> > Looking at X3DOM and X_ITE is certainly good, examining good practices,
> but we are not "choosing" or adapting to either because they have different
> goals.
> >
> > So maybe the main idea is an X3D JavaScript library of Plain Old
> JavaScript Object (POJO) classes...
> > https://masteringjs.io/tutorials/fundamentals/pojo
> >
> > Would that be useful, and used?
> >
> > On 1/13/2020 7:09 PM, John Carlson wrote:
> > > Okay, I see a lot of problems straight off the bat. There's this
> thing called the execution context which I am not too familiar with as the
> first parameter on the constructors. I'm not quite sure where I'm going to
> get that from. Please start editing the code below to give me a flavor of
> what I have to do.
> > >
> > > On Mon, Jan 13, 2020 at 6:38 PM John Carlson <yottzumm at gmail.com
> <mailto:yottzumm at gmail.com>> wrote:
> > >
> > > Here's the current scenegraph as JavaScript:
> > >
> > > I'm going to download the latest from X_ITE.
> > >
> > > John
> > >
> > >
> > > X3D = require('X3Dautoclass');
> > > var X3D0 = new X3D({profile:"Immersive",version:"3.3"}
> > > /* x3dVersionComparisonTest for this model:
> supportsX3dVersion(X3DObject.VERSION_3_0)=true */
> > > ,
> > > new head({}
> > > /* comment #1 */
> > >
> > > /* comment #2 */
> > >
> > > /* comment #3 */
> > >
> > > /* comment #4 */
> > > ,
> > > new component({name:"Navigation",level:3}),
> > > new component({name:"Shaders",level:1}),
> > > new component({name:"CADGeometry",level:2}),
> > > new component({name:"DIS",level:2}),
> > > new component({name:"H-Anim",level:1}),
> > > new component({name:"Grouping",level:1}),
> > > new component({name:"Layering",level:1}),
> > > new
> unit({name:"AngleUnitConversion",category:"angle",conversionFactor:1.0}),
> > > new
> unit({name:"LengthUnitConversion",category:"length",conversionFactor:1.0}),
> > > new
> unit({name:"ForceFromPoundsToNewtons",category:"force",conversionFactor:4.4482}),
> > > new
> meta({content:"HelloWorldProgramOutput.x3d",name:"title"}),
> > > new meta({content:"continued development and testing in
> progress",name:"info"}),
> > > new meta({content:"Example HelloWorldProgram creates an
> X3D model using the X3D Java Scene Access Interface Library
> (X3DJSAIL)",name:"description"}),
> > > new meta({content:"
> https://www.web3d.org/specifications/java/X3DJSAIL.html
> ",name:"reference"}),
> > > new
> meta({content:"HelloWorldProgramOutput.java",name:"generator"}),
> > > new meta({content:"6 September 2016",name:"created"}),
> > > new meta({content:"12 January 2020",name:"modified"}),
> > > new meta({content:"X3D Java Scene Access Interface
> Library (X3DJSAIL)",name:"generator"}),
> > > new meta({content:"
> https://www.web3d.org/specifications/java/examples/HelloWorldProgram.java
> ",name:"generator"}),
> > > new meta({content:"Netbeans http://www.netbeans.org
> ",name:"generator"}),
> > > new meta({content:"Don Brutzman",name:"creator"}),
> > > new meta({content:"
> https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.x3d
> ",name:"reference"}),
> > > new meta({content:"Console output, ClassicVRML encoding,
> VRML97 encoding and pretty-print documentation:",name:"reference"}),
> > > new
> meta({content:"HelloWorldProgramOutput.txt",name:"reference"}),
> > > new
> meta({content:"HelloWorldProgramOutput.x3dv",name:"reference"}),
> > > new
> meta({content:"HelloWorldProgramOutput.wrl",name:"reference"}),
> > > new
> meta({content:"HelloWorldProgramOutput.html",name:"reference"}),
> > > new meta({content:"
> https://savage.nps.edu/X3dValidator?url=https://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d
> ",name:"reference"}),
> > > new meta({content:"
> https://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d
> ",name:"identifier"}),
> > > new meta({content:"../license.html",name:"license"})),
> > > new Scene({},
> > > new ViewpointGroup({description:"Available viewpoints"},
> > > new Viewpoint({DEF:"DefaultView",description:"Hello
> X3DJSAIL"}),
> > > new Viewpoint({DEF:"TopDownView",description:"top-down
> view from above",orientation:[1,0,0,-1.570796],position:[0,100,0]})),
> > > new
> NavigationInfo({type:["EXAMINE","FLY","ANY"],avatarSize:[0.25,1.6,0.75],transitionType:["LINEAR"]}),
> > > new
> WorldInfo({DEF:"WorldInfoDEF",title:"HelloWorldProgram produced by X3D Java
> SAI Library (X3DJSAIL)"}),
> > > new WorldInfo({USE:"WorldInfoDEF"}),
> > > new WorldInfo({USE:"WorldInfoDEF"}),
> > > new
> MetadataString({DEF:"scene.addChildMetadata",name:"test",value:["Top-level
> root Metadata node beneath Scene needs to be one of '-children' in JSON
> encoding"]}),
> > > new
> LayerSet({DEF:"scene.addChildLayerSetTest",order:[0]}),
> > > new
> Transform({DEF:"LogoGeometryTransform",translation:[0,1.5,0]},
> > > new Anchor({description:"select for X3D Java SAI
> Library (X3DJSAIL) description",url:["../X3DJSAIL.html","
> https://www.web3d.org/specifications/java/X3DJSAIL.html"]},
> > > new Shape({DEF:"BoxShape"},
> > > new Appearance({},
> > > new
> Material({DEF:"GreenMaterial",diffuseColor:[0,1,1],emissiveColor:[0.8,0,0],transparency:0.1}),
> > > new
> ImageTexture({url:["images/X3dJavaSceneAccessInterfaceSaiLibrary.png","
> https://www.web3d.org/specifications/java/examples/images/X3dJavaSceneAccessInterfaceSaiLibrary.png
> "]})),
> > > new
> Box({DEF:"test-NMTOKEN_regex.0123456789",cssClass:"untextured"})))),
> > > new Shape({DEF:"LineShape"},
> > > new Appearance({},
> > > new Material({emissiveColor:[0.6,0.19607843,0.8]})),
> > > new IndexedLineSet({coordIndex:[0,1,2,3,4,0]}
> > > /* Coordinate 3-tuple point count: 6 */
> > > ,
> > > new
> Coordinate({point:[0,1.5,0,2,1.5,0,2,1.5,-2,-2,1.5,-2,-2,1.5,0,0,1.5,0]}))),
> > > new
> PositionInterpolator({DEF:"BoxPathAnimator",key:[0,0.125,0.375,0.625,0.875,1],keyValue:[0,1.5,0,2,1.5,0,2,1.5,-2,-2,1.5,-2,-2,1.5,0,0,1.5,0]}),
> > > new
> TimeSensor({DEF:"OrbitClock",cycleInterval:8.0,loop:true}),
> > > new
> ROUTE({fromField:"fraction_changed",fromNode:"OrbitClock",toField:"set_fraction",toNode:"BoxPathAnimator"}),
> > > new
> ROUTE({fromField:"value_changed",fromNode:"BoxPathAnimator",toField:"set_translation",toNode:"LogoGeometryTransform"}),
> > > new
> Transform({DEF:"TextTransform",translation:[0,-1.5,0]},
> > > new Shape({},
> > > new Appearance({},
> > > new Material({USE:"GreenMaterial"})),
> > > new Text({string:["X3D Java","SAI
> Library","X3DJSAIL"]}
> > > /* Comment example A, plain quotation marks: He
> said, \"Immel did it!\" */
> > >
> > > /* Comment example B, XML character entities: He
> said, "Immel did it!" */
> > > ,
> > > new
> MetadataSet({name:"EscapedQuotationMarksMetadataSet"},
> > > new
> MetadataString({name:"quotesTestC",value:["MFString example C,
> backslash-escaped quotes: He said, \"Immel did it!\""]}),
> > > new
> MetadataString({name:"extraChildTest",value:["checks MetadataSetObject
> addValue() method"]})),
> > > new
> FontStyle({family:["SERIF"],justify:["MIDDLE","MIDDLE"]}))),
> > > new Collision({}
> > > /* test containerField='proxy' */
> > > ,
> > > new Shape({DEF:"ProxyShape"}
> > > /* alternative XML encoding: Text string='\"One,
> Two, Comment\" \"\" \"He said, \\"Immel did it!\\"\"' */
> > >
> > > /* alternative XML encoding: Text string='\"One,
> Two, Comment\" \"\" \"He said, \\"Immel did it!\\"\" \"\"' */
> > >
> > > /* alternative Java source: .setString(new String
> [] {\"One, Two, Comment\", \"\", \"He said, \\\"Immel did it!\\\"\"}) */
> > >
> > > /* reference:
> https://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/StringArrayEncodingExamplesIndex.html
> */
> > > ,
> > > new Text({string:["One, Two, Text","","He said,
> \"Immel did it!\" \"\""]})))
> > > /* It's a beautiful world */
> > >
> > > /* ... for you! */
> > >
> > > /*
> https://en.wikipedia.org/wiki/Beautiful_World_(Devo_song) */
> > > )
> > > /* repeatedly spin 180 degrees as a readable special
> effect */
> > > ,
> > > new
> OrientationInterpolator({DEF:"SpinInterpolator",key:[0,0.5,1],keyValue:[0,1,0,4.712389,0,1,0,0,0,1,0,1.5707964]}),
> > > new
> TimeSensor({DEF:"SpinClock",cycleInterval:5.0,loop:true}),
> > > new
> ROUTE({fromField:"fraction_changed",fromNode:"SpinClock",toField:"set_fraction",toNode:"SpinInterpolator"}),
> > > new
> ROUTE({fromField:"value_changed",fromNode:"SpinInterpolator",toField:"rotation",toNode:"TextTransform"}),
> > > new Group({DEF:"BackgroundGroup"},
> > > new Background({DEF:"GradualBackground"}),
> > > new Script({DEF:"colorTypeConversionScript"},
> > > new
> field({type:field.TYPE_SFCOLOR,name:"colorInput",accessType:field.ACCESSTYPE_INPUTONLY}),
> > > new
> field({type:field.TYPE_MFCOLOR,name:"colorsOutput",accessType:field.ACCESSTYPE_OUTPUTONLY}),
> > >
> > > `
> > > ecmascript:
> > >
> > > function colorInput (eventValue) // Example source code
> > > {
> > > colorsOutput = new MFColor(eventValue); // assigning value
> sends output event
> > > // Browser.print('colorInput=' + eventValue + ', colorsOutput=' +
> colorsOutput + '\\n');
> > > }
> > >
> > > `),
> > > new
> ColorInterpolator({DEF:"ColorAnimator",key:[0,0.5,1],keyValue:[0.9411765,1,1,0.29411766,0,0.50980395,0.9411765,1,1]}
> > > /* AZURE to INDIGO and back again */
> > > ),
> > > new
> TimeSensor({DEF:"ColorClock",cycleInterval:60.0,loop:true}),
> > > new
> ROUTE({fromField:"colorsOutput",fromNode:"colorTypeConversionScript",toField:"skyColor",toNode:"GradualBackground"}),
> > > new
> ROUTE({fromField:"value_changed",fromNode:"ColorAnimator",toField:"colorInput",toNode:"colorTypeConversionScript"}),
> > > new
> ROUTE({fromField:"fraction_changed",fromNode:"ColorClock",toField:"set_fraction",toNode:"ColorAnimator"})),
> > > new
> ProtoDeclare({name:"ArtDeco01Material",appinfo:"tooltip: ArtDeco01Material
> prototype is a Material node"},
> > > new ProtoInterface({},
> > > new
> field({type:field.TYPE_SFSTRING,name:"description",accessType:field.ACCESSTYPE_INPUTOUTPUT,appinfo:"tooltip
> for descriptionField",value:"ArtDeco01Material prototype is a Material
> node"}),
> > > new
> field({type:field.TYPE_SFBOOL,name:"enabled",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"true"})),
> > > new ProtoBody({}
> > > /* Initial node of ProtoBody determines prototype
> node type */
> > > ,
> > > new
> Material({ambientIntensity:0.25,diffuseColor:[0.282435,0.085159,0.134462],shininess:0.127273,specularColor:[0.276305,0.11431,0.139857]})
> > > /* [HelloWorldProgram diagnostic] should be connected
> to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\" */
> > >
> > > /* presence of follow-on TouchSensor shows that
> additional nodes are allowed in ProtoBody after initial node, regardless of
> node types */
> > > ,
> > > new TouchSensor({description:"within ProtoBody"},
> > > new IS({},
> > > new
> connect({nodeField:"description",protoField:"description"}),
> > > new
> connect({nodeField:"enabled",protoField:"enabled"}))))),
> > > new
> ExternProtoDeclare({name:"ArtDeco02Material",appinfo:"this is a different
> Material node",url:["
> http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ArtDecoPrototypesExcerpt.x3d#ArtDeco02Material
> ","
> http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ArtDecoPrototypesExcerpt.x3dv#ArtDeco02Material
> "]}
> > > /* [HelloWorldProgram diagnostic]
> artDeco02ExternProtoDeclare.getNodeType()=\"ERROR_UNKNOWN_EXTERNPROTODECLARE_NODE_TYPE:
> ExternProtoDeclare name='ArtDeco02Material' type cannot be remotely
> accessed at run time. TODO X3DJSAIL needs to add further capability that
> retrieves the ExternProtoDeclare file.\" */
> > > ,
> > > new
> field({type:field.TYPE_SFSTRING,name:"description",accessType:field.ACCESSTYPE_INPUTOUTPUT,appinfo:"tooltip
> for descriptionField"}))
> > > /* Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance
> for improper node type when ProtoInstance is added in wrong place */
> > > ,
> > > new Shape({DEF:"TestShape1"},
> > > new Appearance({DEF:"TestAppearance1"}
> > > /* ArtDeco01Material prototype goes here... TODO
> ensure setContainerField is handled in exported Java */
> > > ,
> > > new ProtoInstance({name:"ArtDeco01Material"}
> > > /* [HelloWorldProgram diagnostic]
> ArtDeco01ProtoInstance.getNodeType()=\"Material\" */
> > > ,
> > > new
> fieldValue({name:"description",value:"ArtDeco01Material can substitute for
> a Material node"}))),
> > > new Sphere({radius:0.001})),
> > > new Shape({DEF:"TestShape2"},
> > > new Appearance({DEF:"TestAppearance2"}
> > > /* ArtDeco02Material prototype goes here... TODO
> ensure setContainerField is handled in exported Java */
> > > ,
> > > new
> ProtoInstance({DEF:"ArtDeco02MaterialDEF",name:"ArtDeco02Material"}
> > > /* [HelloWorldProgram diagnostic]
> ArtDeco02ProtoInstance.getNodeType()=\"ERROR_UNKNOWN_EXTERNPROTODECLARE_NODE_TYPE:
> ExternProtoDeclare name='ArtDeco02Material' type cannot be remotely
> accessed at run time. TODO X3DJSAIL needs to add further capability that
> retrieves the ExternProtoDeclare file.\" */
> > > ,
> > > new
> fieldValue({name:"description",value:"ArtDeco02Material can substitute for
> another Material node"}))),
> > > new Cone({bottomRadius:0.001,height:0.001})),
> > > new Shape({DEF:"TestShape3"},
> > > new Appearance({DEF:"TestAppearance3"}
> > > /* ArtDeco02Material ProtoInstance USE goes here.
> Note that name field is NOT defined as part of ProtoInstance USE. */
> > > ,
> > > new ProtoInstance({USE:"ArtDeco02MaterialDEF"})),
> > > new Cylinder({height:0.001,radius:0.001})),
> > > new
> Inline({DEF:"inlineSceneDef",url:["someOtherScene.x3d","
> https://www.web3d.org/specifications/java/examples/someOtherScene.x3d"]}),
> > > new
> IMPORT({AS:"WorldInfoDEF2",importedDEF:"WorldInfoDEF",inlineDEF:"inlineSceneDef"}),
> > > new EXPORT({AS:"WorldInfoDEF3",localDEF:"WorldInfoDEF"}),
> > > new ProtoDeclare({name:"MaterialModulator",appinfo:"mimic
> a Material node and modulate fields as an animation effect",documentation:"
> http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html
> "},
> > > new ProtoInterface({},
> > > new
> field({type:field.TYPE_SFBOOL,name:"enabled",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"true"}),
> > > new
> field({type:field.TYPE_SFCOLOR,name:"diffuseColor",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"0
> 0 0"}),
> > > new
> field({type:field.TYPE_SFCOLOR,name:"emissiveColor",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"0.05
> 0.05 0.5"}),
> > > new
> field({type:field.TYPE_SFCOLOR,name:"specularColor",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"0
> 0 0"}),
> > > new
> field({type:field.TYPE_SFFLOAT,name:"transparency",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"0.0"}),
> > > new
> field({type:field.TYPE_SFFLOAT,name:"shininess",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"0.0"}),
> > > new
> field({type:field.TYPE_SFFLOAT,name:"ambientIntensity",accessType:field.ACCESSTYPE_INPUTOUTPUT,value:"0.0"})),
> > > new ProtoBody({},
> > > new Material({DEF:"MaterialNode"},
> > > new IS({},
> > > new
> connect({nodeField:"diffuseColor",protoField:"diffuseColor"}),
> > > new
> connect({nodeField:"emissiveColor",protoField:"emissiveColor"}),
> > > new
> connect({nodeField:"specularColor",protoField:"specularColor"}),
> > > new
> connect({nodeField:"transparency",protoField:"transparency"}),
> > > new
> connect({nodeField:"shininess",protoField:"shininess"}),
> > > new
> connect({nodeField:"ambientIntensity",protoField:"ambientIntensity"})))
> > > /* Only first node (the node type) is renderable,
> others are along for the ride */
> > > ,
> > > new Script({DEF:"MaterialModulatorScript"},
> > > new
> field({type:field.TYPE_SFBOOL,name:"enabled",accessType:field.ACCESSTYPE_INPUTOUTPUT}),
> > > new
> field({type:field.TYPE_SFCOLOR,name:"diffuseColor",accessType:field.ACCESSTYPE_INPUTOUTPUT}),
> > > new
> field({type:field.TYPE_SFCOLOR,name:"newColor",accessType:field.ACCESSTYPE_OUTPUTONLY}),
> > > new
> field({type:field.TYPE_SFTIME,name:"clockTrigger",accessType:field.ACCESSTYPE_INPUTONLY}),
> > > new IS({},
> > > new
> connect({nodeField:"enabled",protoField:"enabled"}),
> > > new
> connect({nodeField:"diffuseColor",protoField:"diffuseColor"})),
> > >
> > > `
> > > ecmascript:
> > > function initialize ()
> > > {
> > > newColor = diffuseColor; // start with correct color
> > > }
> > > function set_enabled (newValue)
> > > {
> > > enabled = newValue;
> > > }
> > > function clockTrigger (timeValue)
> > > {
> > > if (!enabled) return;
> > > red = newColor.r;
> > > green = newColor.g;
> > > blue = newColor.b;
> > >
> > > // note different modulation rates for each color component,
> % is modulus operator
> > > newColor = new SFColor ((red + 0.02) % 1, (green + 0.03) % 1,
> (blue + 0.04) % 1);
> > > if (enabled)
> > > {
> > > Browser.print ('diffuseColor=(' + red + ',' + green + ',' + blue +
> ') newColor=' + newColor.toString() + '\\n');
> > > }
> > > }
> > >
> > > `)))
> > > /* Test success: declarative statement
> createDeclarativeShapeTests() */
> > > ,
> > > new Group({DEF:"DeclarativeGroupExample"},
> > > new Shape({},
> > > new
> MetadataString({DEF:"FindableMetadataStringTest",name:"findThisNameValue",value:["test
> case"]}),
> > > new Appearance({DEF:"DeclarativeAppearanceExample"}
> > > /* DeclarativeMaterialExample gets overridden by
> subsequently added MaterialModulator ProtoInstance */
> > > ,
> > > new
> ProtoInstance({DEF:"MyMaterialModulator",name:"MaterialModulator"})),
> > > new Cone({bottom:false,bottomRadius:0.05,height:0.1}))
> > > /* Test success: declarativeGroup.addChild() singleton
> pipeline method */
> > > )
> > > /* Test success: declarative statement addChild() */
> > >
> > > /* Test success:
> x3dModel.findNodeByDEF(DeclarativeAppearanceExample) = <Appearance
> DEF='DeclarativeAppearanceExample'/> i.e. <Appearance
> DEF='DeclarativeAppearanceExample'> <!- - DeclarativeMaterialExample gets
> overridden by subsequently added MaterialModulator ProtoInstance - ->
> <ProtoInstance DEF='MyMaterialModulator' name='MaterialModulator'
> containerField='material'/> </Appearance> */
> > >
> > > /* Test success:
> x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString
> DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test
> case\"'/> */
> > >
> > > /* Test success:
> x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\")
> found */
> > >
> > > /* Test success:
> x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\")
> found */
> > >
> > > /* Test success:
> x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\")
> found */
> > > ,
> > > new Group({DEF:"TestFieldObjectsGroup"}
> > > /* testFieldObjects() results */
> > >
> > > /* SFBool default=true, true=true, false=false,
> negate()=true */
> > >
> > > /* MFBool default=, initial=true false true,
> negate()=false true false */
> > >
> > > /* SFFloat default=0.0, initial=1.0, setValue(2)=2.0,
> setValue(3.0f)=3.0, setValue(4.0)=4.0 */
> > >
> > > /* MFFloat default=, initial=1 2 3, append(5)=1 2 3 5,
> inserts(3,4)(0,0)=0 1 2 3 4 5, append(6)=0 1 2 3 4 5 6, size()=7 */
> > >
> > > /* ... get1Value[3]=3.0, remove[1]=0 2 3 4 5 6,
> set1Value(0,10)=10 2 3 4 5 6, multiply(2)=20 4 6 8 10 12, clear= */
> > >
> > > /* SFVec3f default=0 0 0, initial=1 2 3, setValue=4 5
> 6, multiply(2)=8 10 12, normalize()=0.45584232 0.5698029 0.68376344, regex
> matches()=true */
> > >
> > > /* regex test SFVec3f().matches(\"1 2 3\")=true, regex
> test SFVec3f().matches(\"1 2 3 4\")=false, regex test
> (SFRotationObject.matches(\"0 0 0 0\")=true, failure detecting illegal
> (zero axis) rotation value */
> > > ),
> > > new Sound({location:[0,1.6,0]}
> > > /* set sound-ellipsoid location height at 1.6m to match
> typical avatar height */
> > > ,
> > > new AudioClip({description:"chimes",url:["chimes.wav","
> https://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/chimes.wav
> "]}
> > > /* Scene example fragment from
> https://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/default.x3d
> */
> > > )),
> > > new Sound({location:[0,1.6,0]}
> > > /* set sound-ellipsoid location height at 1.6m to match
> typical avatar height */
> > > ,
> > > new MovieTexture({description:"mpgsys.mpg from
> ConformanceNist suite",url:["mpgsys.mpg","
> https://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpgsys.mpg
> "]}
> > > /* Scene example fragment from
> https://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpeg1-systems.x3d
> */
> > >
> > > /* Expected containerField='source', allowed
> containerField values=\"texture\" \"source\" \"back\" \"bottom\" \"front\"
> \"left\" \"right\" \"top\" \"backTexture\" \"bottomTexture\"
> \"frontTexture\" \"leftTexture\" \"rightTexture\" \"topTexture\"
> \"watchList\" */
> > > ))
> > > /* Test success: AnchorObject.isNode()=true,
> siteAnchor.isNode()=true */
> > >
> > > /* Test success: AnchorObject.isStatement()=false,
> siteAnchor.isStatement()=false */
> > >
> > > /* Test success: ROUTEObject.isNode()=false,
> orbitPositionROUTE.isNode()=false */
> > >
> > > /* Test success: ROUTEObject.isStatement()=true,
> orbitPositionROUTE.isStatement()=true */
> > >
> > > /* Test success: CommentsBlock.isNode()=false,
> testComments.isNode()=false */
> > >
> > > /* Test failure: CommentsBlock.isStatement()=true,
> testComments.isStatement()=true */
> > > ,
> > > new Shape({DEF:"ExtrusionShape"}
> > > /* ExampleExtrusion isCrossSectionClosed()=true,
> crossSection='[1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0]' */
> > >
> > > /* ExampleExtrusion isSpineClosed()=false, spine='[0.0,
> 0.0, 0.0, 0.0, 1.0, 0.0]' */
> > > ,
> > > new Appearance({DEF:"TransparentAppearance"},
> > > new Material({transparency:1.0})),
> > > new Extrusion({DEF:"ExampleExtrusion"})),
> > > new Group({}
> > > /* Test MFNode children array as an ordered list
> consisting of comments, statements, ProtoInstance and nodes */
> > > ,
> > > new ProtoDeclare({name:"NewWorldInfo"},
> > > new ProtoInterface({},
> > > new
> field({type:field.TYPE_SFSTRING,name:"description",accessType:field.ACCESSTYPE_INITIALIZEONLY})),
> > > new ProtoBody({},
> > > new WorldInfo({}))),
> > > new ProtoInstance({DEF:"Proto1",name:"NewWorldInfo"},
> > > new fieldValue({name:"description",value:"testing 1 2
> 3"})),
> > > new Group({DEF:"Node2"}
> > > /* intentionally empty */
> > > ),
> > > new ProtoInstance({DEF:"Proto3",name:"NewWorldInfo"}),
> > > new Transform({DEF:"Node4"}
> > > /* intentionally empty */
> > > )
> > > /* Test satisfactorily creates MFNode children array as
> an ordered list with mixed content */
> > > ),
> > > new ProtoDeclare({name:"ShaderProto"},
> > > new ProtoBody({},
> > > new ProgramShader({}))),
> > > new Shape({},
> > > new Appearance({}
> > > /* Test MFNode shaders array as an ordered list
> consisting of comments, ProtoInstance and nodes */
> > >
> > > /* Test satisfactorily creates MFNode shaders array
> as an ordered list with mixed content */
> > > ,
> > > new ProgramShader({DEF:"TestShader1"},
> > > new ShaderProgram({DEF:"TestShader2"})),
> > > new
> ProtoInstance({DEF:"TestShader3",name:"ShaderProto"}),
> > > new ComposedShader({DEF:"TestShader4"},
> > > new ShaderPart({DEF:"TestShader5"})))),
> > > new Transform({DEF:"SpecialtyNodes"},
> > > new CADLayer({},
> > > new CADAssembly({},
> > > new CADPart({},
> > > new CADFace({})))),
> > > new EspduTransform({geoSystem:["GD","WE"]}),
> > > new ReceiverPdu({geoSystem:["GD","WE"]}),
> > > new SignalPdu({geoSystem:["GD","WE"]}),
> > > new TransmitterPdu({geoSystem:["GD","WE"]}),
> > > new DISEntityManager({},
> > > new DISEntityTypeMapping({}))))) ;
> > > X3D0.toFileX3D("examples/HelloWorldProgramOutput.new.x3d");
> > > X3D0.toFileJSON("examples/HelloWorldProgramOutput.new.json");
> > >
> > > On Mon, Jan 13, 2020 at 3:40 PM John Carlson <yottzumm at gmail.com
> <mailto:yottzumm at gmail.com>> wrote:
> > >
> > > Ant build script (All found on X3D sourceforge project):
> > >
> > > www.web3d.org/x3d/stylesheets/node/build.xml <
> http://www.web3d.org/x3d/stylesheets/node/build.xml>
> > >
> > > (recommend "all" target). In that folder, run
> > >
> > > ant all to compile and run the test, but first, look at hand
> generated example:
> > >
> > > Example for those creating the node.js SAI library: (very
> buggy)
> > >
> www.web3d.org/x3d/stylesheets/node/examples/HelloWorldProgramOutput.js <
> http://www.web3d.org/x3d/stylesheets/node/examples/HelloWorldProgramOutput.js
> >
> > >
> > > Code that ultimately needs work:
> > >
> > > www.web3d.org/x3d/stylesheets/node/JavaScriptSerializer.js <
> http://www.web3d.org/x3d/stylesheets/node/JavaScriptSerializer.js>
> > >
> > > Discussion:
> > > Does this look like a good style in the examples file?
> > > Does the style match the standard JavaScript SAI?
> > > What is needed to standardize JavaScript SAI for X3Dv4?
> > > How fast can we get a Hello World roundtrip working?
> > >
> > > This is primarily a build integration release. Please
> integrate the build.xml all target with the stylesheets build.xml. Thanks,
> Don!
> > >
> > > Don, I see your way ahead of me, integrating this into
> everything.
> > >
> > > Can someone point me at a working JavaScript SAI?
> > >
> > > Thanks,
> > >
> > > John
> > >
> >
> >
> > all the best, Don
> > --
> > Don Brutzman Naval Postgraduate School, Code USW/Br
> brutzman at nps.edu
> > Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA
> +1.831.656.2149
> > X3D graphics, virtual worlds, navy robotics
> http://faculty.nps.edu/brutzman
>
>
>
> --
> Andreas Plesch
> Waltham, MA 02453
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200114/1d1a0b89/attachment-0001.html>
More information about the x3d-public
mailing list