[x3d-public] [SOLVED] Re: [x3d:tickets] #10 JSON schema errors that start to make sense. Need X3dToJson.xslt updates to create MFString arrays.
John Carlson
yottzumm at gmail.com
Tue Jan 18 06:22:52 PST 2022
Sorry, Third message in attempt. Here's how I think I'm currently running
the stylesheet (in X3DJSONLD/src/main/shell/several.sh)
java net.coderextreme.RunSaxon --- ---overwrite
--${STYLESHEETDIR}/X3dToJson.xslt -json
followed by X3D XML files.
Here's a concrete example:
X3DJSONLD/src/main $ java -cp "java;../../saxon-he-10.6.jar"
net.coderextreme.RunSaxon --- ---overwrite --/x3d-code/
www.web3d.org/x3d/stylesheets/X3dToJson.xslt -json
data/HelloWorldProgramOutput.x3d
BEGIN data/HelloWorldProgramOutput.x3d > json, Script
DEF=colorTypeConversionScript contains CDATA source-code text, copied as
"#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=colorTypeConversionScript contains CDATA source-code text,
copied as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
END data/HelloWorldProgramOutput.x3d
data/HelloWorldProgramOutput.json
I will try another stylesheet processor, hang on. Here it is. Attaching
xslt output to this email as a txt. Basically, the output file is very
corrupted. As you can see from the below log. Please fix if possible.
$ ../../../node_modules/.bin/xslt3 -xsl:/c/x3d-code/
www.web3d.org/x3d/stylesheets/X3dToJson.xslt
-s:../data/HelloWorldProgramOutput.x3d -o:foo.txt
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Viewpoint, DEF=DefaultView, $parentName=ViewpointGroup
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Viewpoint, DEF=TopDownView, $parentName=ViewpointGroup
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Anchor, DEF=siteAnchor, $parentName=Transform
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Shape, DEF=BoxShape, $parentName=Anchor
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Appearance, $parentName=Shape
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Material, DEF=GreenMaterial, $parentName=Appearance
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=ImageTexture, $parentName=Appearance
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Box, DEF=test-NMTOKEN_regex.0123456789, $parentName=Shape
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Appearance, $parentName=Shape
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Material, $parentName=Appearance
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=IndexedLineSet, $parentName=Shape
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Error: IllegalChildNodeFieldNameNotFound no containerField or field name
found for the X3D JSON object. Check spelling of node.
$elementName=Coordinate, $parentName=IndexedLineSet
Please report this error to x3d-public at web3d.org - thanks for your help
improving X3D Quality Assurance (QA).
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied
as "#sourceCode" using "strings" mode
So I'm not seeing that a correct NavigationInfo.type field as a JSON array
is being produced. The type field is a JSON string.
I am not sure why my results are different. My best guess is that a version
of X3dToJson.xslt did not get checked in.
The next step is to compare X3dToJson.xslt. Got it, I think. There are
significant difference between these two files:
$ diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToJson.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToJson.xslt
[snip, run on your system[
Indeed, there are many differences:
$ diff /c/x3d-code/www.web3d.org/x3d/stylesheets/ /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/|grep ^diff
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dTidy.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dTidy.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToES5.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToES5.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToHtml.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToHtml.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToJava.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToJava.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToJson.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToJson.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToNodeJS.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToNodeJS.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToPython.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToPython.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToVrml97.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToVrml97.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToX3dom.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToX3dom.xslt
diff /c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToXhtml.xslt /c/x3d-code/
www.web3d.org/x3d/stylesheets/java/lib/stylesheets/X3dToXhtml.xslt
Copying the lib/stylesheets to a local X3DJSONLD file fixed the problem!
John
On Tue, Jan 18, 2022 at 7:36 AM John Carlson <yottzumm at gmail.com> wrote:
> Sorry for two messages. I don't know what's happening either. Is
> SourceForge up-to-date with X3dToJson.xslt? This is a very long standing
> issue for me.
>
> I think we're all onboard with NavigationInfo.type being a JSON array and
> not a JSON string? I am trying to pursue why I am getting a JSON string
> from X3dToJson.xslt. But recently builds of x3d/stylesheets/java/examples
> on my system have shown that that tree may have issues too, not just
> X3DJSONLD.
>
> Here is a nearly current NavigationInfo from a very recently generated
> file (ball.json in X3DJSONLD). I still may need update X3dToJson.xslt at
> this point. I will attempt to do that. Done.
>
> { "NavigationInfo":
> {
> "@type":"\"ANY\" \"EXAMINE\" \"FLY\" \"LOOKAT\""
> }
> },
>
> I think the problem may have been that I had an X3dToJson.sef.json file.
> That is not it, AFAIK. I removed that file
>
> We have nearly identical X3dToJson.xslt files as far as I can tell. Here
> are the differences:
> $ diff !:2 !:3
> diff ../lib/stylesheets/X3dToJson.xslt /c/x3d-code/
> www.web3d.org/x3d/stylesheets/X3dToJson.xslt
> 3c3
> < Copyright (c) 2001-2021 held by the author(s). All rights reserved.
> ---
> > Copyright (c) 2001-2022 held by the author(s). All rights reserved.
>
> This appears to be something we can work from:
>
>
> https://www.web3d.org/x3d/content/examples/ConformanceNist/BindableNodes/NavigationInfo/jumpcut_loadurl.json
>
> This file shows NavigationInfo.type and url fields as correct in my mind.
>
> So there's an issue on my system somewhere perhaps--AFAIK, my system is a
> fresh install. Please show a recent JSON conversion output (web version
> is okay, but NavigationInfo.type from the recently created JSON file would
> be great).
>
> Please check on your system:
>
> x3d/stylesheets/java/examples/HelloWorldProgramOutput.json
>
> { "NavigationInfo":
> {
> "@type":"\"EXAMINE\" \"FLY\" \"ANY\""
> }
> },
>
> Is what I see. A JSON string. Hmmm
>
> Could it be we have a different stylesheet inside the X3DJSAIL jar? I use
> my own Java stylesheet processor (Saxon-based).
>
> Thanks for your time pursuing this. For me, the online version is
> correct. and the HelloWorld version is incorrect. I will try to regenerate
> the HelloWorld version now
>
> /x3d/stylesheets/java
> $ ant all
> Buildfile: C:\x3d-code\www.web3d.org\x3d\stylesheets\java\build.xml
>
> compile.examples:
> [echo] $java.examples.dir=C:\x3d-code\www.web3d.org
> \x3d\stylesheets\java\examples
> [echo] compile.examples complete
>
> run.examples:
> [java] Exception in thread "main" java.lang.NoClassDefFoundError:
> net/sf/saxon/s9api/SaxonApiException
> [java] at HelloWorldProgram.<clinit>(HelloWorldProgram.java:64)
> [java] Caused by: java.lang.ClassNotFoundException:
> *net.sf.saxon.s9api.SaxonApiException*
> [java] at
> java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
> [java] at
> java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
> [java] at
> java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
> [java] ... 1 more
> [java] Java Result: 1
> [echo] run.examples complete
>
> all:
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
>
>
> Tortoise SVN:
>
> Command: Update
> Updating: C:\x3d-code\www.web3d.org from svn://
> svn.code.sf.net/p/x3d/code/www.web3d.org
> Completed: At revision: 32884
>
> I am a bit lost without command line svn diff, I have reverted everything
> with TortoiseSVN in www.web3d.org sourceforge copy
>
> -rw-r--r-- 1 john 197609 94346 Jan 18 07:13 HelloWorldProgramOutput.json
>
> I'm pretty much puzzled as you at this point. After reverting, I will
> diff the stylesheets again. Essentially the same diff.
>
> So I'm guessing it may have something to do with the X3DJSAIL jar? Please
> generate the HelloWorldProgramOutput.json and see what you get for
> NavigationInfo.
>
> Thank you for all your time spent on this. We need some kind of Hail Mary
> at this point. Maybe I'll wake up with a fresh idea.
>
> I think the first step may be to get Don's X3DJSAIL
> java/examples/HelloWorldProgramOutput.json passing XMLSpy validation.
>
> John
>
> On Tue, Jan 18, 2022 at 6:28 AM John Carlson <yottzumm at gmail.com> wrote:
>
>> Check any current X3D JSON file with NavigationInfo.type against a
>> current X3D JSON Schema. Send the NavigationInfo section of the X3D JSON
>> file to me, so we can coordinate. Please send a snapshot of XMLSpy
>> validation success on the X3D JSON file.
>>
>> I apologize for missing the meeting.
>>
>> I have read the pages you posted and the working draft. I even read the
>> below inclusion.
>>
>> Why are two different MFStrings (URLs and NavigationInfo.type) handled
>> differently? Please show me an example of a different MFString field
>> encoded in JSON.
>>
>> Let’s get very concrete in this discussion, thanks. There may be a big
>> aha after we look at things concretely.
>>
>> Thanks!
>>
>>
>> John
>>
>>
>> On Mon, Jan 17, 2022 at 11:37 PM Brutzman, Donald (Don) (CIV) <
>> brutzman at nps.edu> wrote:
>>
>>> Hi John. What is happening?
>>>
>>>
>>>
>>> Regarding proposed handing of X3D MFString in JSON: I’ve let you know
>>> in email, telephone call and issue tracker that JSON MFString is documented
>>> on the following page, which we produced together. There are also
>>> thousands of X3D Examples online that each include JSON encoding.
>>>
>>>
>>>
>>> - X3D to JSON Stylesheet Converter
>>> - https://www.web3d.org/x3d/stylesheets/X3dToJson.html
>>>
>>>
>>>
>>> If you scroll down that page to JSON strings, you will find an
>>> unambiguous JSON-produced railroad-track diagram and following table
>>> entry. Seems simple.
>>>
>>>
>>>
>>> - https://www.web3d.org/x3d/stylesheets/X3dToJson.html#strings
>>>
>>>
>>>
>>> *X3D scene graph*
>>>
>>> *JSON representation*
>>>
>>> SFString is unquoted XML attribute value
>>>
>>> JSON value of *string* type. Backslash *\* (reverse solidus) characters
>>> get escaped with an adjacent backslash *\* character, resulting in *\\*
>>> value.
>>> Similarly " (quotation mark) characters get escaped with an adjacent
>>> backslash as *\"* value.
>>>
>>> MFString is array of quoted SFString (XML attribute) values
>>>
>>> JSON array of *string* type
>>>
>>>
>>>
>>> Are you now OK with what is stated and demonstrated regarding X3D
>>> MFString as JSON arrays of string type?
>>>
>>>
>>>
>>> Meanwhile it is not clear from the issue whether the entry is about JSON
>>> schema, X3dToJSON.xslt, MFString, JSON string, JSON string arrays, or
>>> what. Apologies but I’m not tracking your concern.
>>>
>>>
>>>
>>> You cite working draft (ISO-IEC19776-5, WD) but that document is in
>>> private Web3D github, unreviewed by working group, and not public. Our
>>> group is not ready to review that yet.
>>>
>>>
>>>
>>> - https://www.web3d.org/standards
>>>
>>>
>>>
>>> Have tried reading tracker issue #10 a few times but am still not sure
>>> what the issue is asking. Now you are cross-threading the sourceforge
>>> issue tracker and the x3d-public mailing list... ouch. Color me “lost” on
>>> this one.
>>>
>>>
>>>
>>> You might be thinking about the use of an XML attribute without extra
>>> quotation marks, such as <Text string=’hey now’/> which is common. The
>>> Java and Python APIs are forgiving of such type mismatches, most of our
>>> XML-handling tools are, ClassicVRML is forgiving, it will no doubt be
>>> explicit in each of next spec versions.
>>>
>>>
>>>
>>> Please let’s dial it back and get focused.
>>>
>>> - An issue tracker is good for simple fixable issues: point out
>>> specific problem, give a repeatable example. If possible note reference
>>> and suggested solution.
>>> - Mailing lists are good for announcements and general discussion.
>>>
>>>
>>>
>>> A favorite quote: “Brevity is the soul of wit” – *Hamlet*, William
>>> Shakespeare.
>>>
>>>
>>>
>>> Your efforts are appreciated but, in the midst of hugely tremendous X3D
>>> detail, we must be precise and focused. Hope this helps.
>>>
>>>
>>>
>>> Have Fun with X3D! Or Else! 8)
>>>
>>>
>>>
>>> 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 https://
>>> faculty.nps.edu/brutzman
>>>
>>>
>>>
>>> *From:* x3d-public <x3d-public-bounces at web3d.org> *On Behalf Of *
>>> vmarchetti at kshell.com
>>> *Sent:* Sunday, January 16, 2022 4:19 PM
>>> *To:* John Carlson <yottzumm at gmail.com>
>>> *Cc:* X3D-Public <x3d-public at web3d.org>
>>> *Subject:* Re: [x3d-public] [x3d:tickets] #10 JSON schema errors that
>>> start to make sense. Need X3dToJson.xslt updates to create MFString arrays.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Jan 16, 2022, at 4:30 PM, John Carlson <yottzumm at gmail.com> wrote:
>>>
>>>
>>>
>>> *[tickets:#10]
>>> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fp%2Fx3d%2Ftickets%2F10%2F&data=04%7C01%7Cbrutzman%40nps.edu%7C056d678e0d2747cead9108d9d94f126b%7C6d936231a51740ea9199f7578963378e%7C0%7C0%7C637779756351904802%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=s5CLp5otd5aZaJFMlezFeZ3aZ0sxxCQHGhN%2BmLqNvOE%3D&reserved=0>
>>> JSON schema errors that start to make sense. Need X3dToJson.xslt updates to
>>> create MFString arrays.*
>>>
>>> *Discussion leading towards enlightenment whether MFStrings should be
>>> arrays or strings in JSON (or both?).*
>>>
>>> Vince, I added you here because I thought you would want to advocate for
>>> a single string MFString being a string and not an arrray.
>>>
>>>
>>>
>>>
>>>
>>> John
>>>
>>>
>>>
>>> Thank you for including me, but I would actually advocate for the
>>> opposite, that any value typed as MFString be encoded as an MFString of 0,
>>> 1, or N>1 elements, by whatever syntax is appropriate for that encoding.
>>>
>>>
>>>
>>> Vince
>>>
>>>
>>>
>>>
>>>
>>> John
>>>
>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20220118/fc8c5ea7/attachment-0001.html>
-------------- next part --------------
{ "X3D": {
"encoding":"UTF-8",
"@class":"x3dModel.class",
"@profile":"Full",
"@style":"x3dModel.style",
"@version":"4.0",
"@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-4.0.xsd",
"JSON schema":"https://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
"-children":[
{
"#comment":"x3dVersionComparisonTest for this model: supportsX3dVersion(X3D.VERSION_3_0)=true"
}
],
"head": {
"-children":[
{
"#comment":"comment #1"
},
{
"#comment":"comment #2"
},
{
"#comment":"comment #3"
},
{
"#comment":"comment #4"
}
],
"component": [
{
"@name":"Navigation",
"@level":3
},
{
"@name":"Shaders",
"@level":1
},
{
"@name":"CADGeometry",
"@level":2
},
{
"@name":"DIS",
"@level":2
},
{
"@name":"H-Anim",
"@level":1
},
{
"@name":"Grouping",
"@level":1
},
{
"@name":"Layering",
"@level":1
}
],
"unit": [
{
"@name":"AngleUnitConversion",
"@category":"angle",
"@conversionFactor":1.0
},
{
"@name":"LengthUnitConversion",
"@category":"length",
"@conversionFactor":1.0
},
{
"@name":"ForceFromPoundsToNewtons",
"@category":"force",
"@conversionFactor":4.4482
}
],
"meta": [
{
"@name":"title",
"@content":"HelloWorldProgramOutput.x3d"
},
{
"@name":"info",
"@content":"continued development and testing in progress"
},
{
"@name":"description",
"@content":"Example HelloWorldProgram creates an X3D model using the X3D Java Scene Access Interface Library (X3DJSAIL)"
},
{
"@name":"reference",
"@content":"https://www.web3d.org/specifications/java/X3DJSAIL.html"
},
{
"@name":"generator",
"@content":"HelloWorldProgramOutput.java"
},
{
"@name":"created",
"@content":"6 September 2016"
},
{
"@name":"modified",
"@content":"9 January 2022"
},
{
"@name":"generator",
"@content":"X3D Java Scene Access Interface Library (X3DJSAIL)"
},
{
"@name":"generator",
"@content":"https://www.web3d.org/specifications/java/examples/HelloWorldProgram.java"
},
{
"@name":"generator",
"@content":"Netbeans http://www.netbeans.org"
},
{
"@name":"creator",
"@content":"Don Brutzman"
},
{
"@name":"reference",
"@content":"https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.x3d"
},
{
"@name":"reference",
"@content":"Console output, ClassicVRML encoding, VRML97 encoding and pretty-print documentation:"
},
{
"@name":"reference",
"@content":"HelloWorldProgramOutput.txt"
},
{
"@name":"reference",
"@content":"HelloWorldProgramOutput.x3dv"
},
{
"@name":"reference",
"@content":"HelloWorldProgramOutput.wrl"
},
{
"@name":"reference",
"@content":"HelloWorldProgramOutput.html"
},
{
"@name":"reference",
"@content":"https://savage.nps.edu/X3dValidator?url=https://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
},
{
"@name":"identifier",
"@content":"https://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
},
{
"@name":"license",
"@content":"../license.html"
},
{
"@name":"translated",
"@content":"18 January 2022"
},
{
"@name":"generator",
"@content":"X3dToJson.xslt, https://www.web3d.org/x3d/stylesheets/X3dToJson.html"
},
{
"@name":"reference",
"@content":"X3D JSON encoding: https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
}
]
},
"Scene": {
"-children":[
{ "MetadataSet":
{
"@name":"topLevelSceneMetadata"
}
},
{ "MetadataString":
{
"@name":"test",
"@DEF":"scene.addChildMetadata",
"@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "ViewpointGroup":
{
"@description":"Available viewpoints",
"-IllegalChildNodeFieldNameNotFound":[
{ "Viewpoint":
{
"@DEF":"DefaultView",
"@description":"Hello X3DJSAIL"
}
}
],
"-IllegalChildNodeFieldNameNotFound":[
{ "Viewpoint":
{
"@DEF":"TopDownView",
"@description":"top-down view from above",
"@orientation":[1,0,0,-1.570796],
"@position":[0,100,0]
}
}
]
}
},
{ "MetadataString":
{
"@name":"test",
"@DEF":"scene.addChildMetadata",
"@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "NavigationInfo":
{
"@type":"\"EXAMINE\" \"FLY\" \"ANY\""
}
},
{ "MetadataString":
{
"@name":"test",
"@DEF":"scene.addChildMetadata",
"@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "WorldInfo":
{
"@DEF":"WorldInfoDEF",
"@class":"worldInfoNode.class",
"@style":"worldInfoNode.style",
"@title":"HelloWorldProgram produced by X3D Java SAI Library (X3DJSAIL)"
}
},
{ "MetadataString":
{
"@name":"test",
"@DEF":"scene.addChildMetadata",
"@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "WorldInfo":
{
"@USE":"WorldInfoDEF"
}
},
{ "MetadataString":
{
"@name":"test",
"@DEF":"scene.addChildMetadata",
"@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "WorldInfo":
{
"@USE":"WorldInfoDEF"
}
},
{ "MetadataString":
{
"@name":"test",
"@DEF":"scene.addChildMetadata",
"@value":["Top-level root Metadata node beneath Scene needs to be one of '-children' in JSON encoding"]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "LayerSet":
{
"@DEF":"scene.addChildLayerSetTest"
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "Transform":
{
"@DEF":"LogoGeometryTransform",
"@translation":[0,1.5,0],
"-IllegalChildNodeFieldNameNotFound":[
{ "Anchor":
{
"@DEF":"siteAnchor",
"@description":"select for X3D Java SAI Library (X3DJSAIL) description",
"@url":["../X3DJSAIL.html","https://www.web3d.org/specifications/java/X3DJSAIL.html"],
"-IllegalChildNodeFieldNameNotFound":[
{ "Shape":
{
"@DEF":"BoxShape",
"-IllegalChildNodeFieldNameNotFound":[
{ "Appearance":
"-IllegalChildNodeFieldNameNotFound":[
{ "Material":
{
"@DEF":"GreenMaterial",
"@diffuseColor":[0,1,1],
"@emissiveColor":[0.8,0,0],
"@transparency":0.1
}
}
],
"-IllegalChildNodeFieldNameNotFound":[
{ "ImageTexture":
{
"@url":["images/X3dJavaSceneAccessInterfaceSaiLibrary.png","https://www.web3d.org/specifications/java/examples/images/X3dJavaSceneAccessInterfaceSaiLibrary.png"]
}
}
]
}
],
"-IllegalChildNodeFieldNameNotFound":[
{ "Box":
{
"@DEF":"test-NMTOKEN_regex.0123456789",
"@class":"untextured"
}
}
]
}
}
]
}
}
]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "Shape":
{
"@DEF":"LineShape",
"-IllegalChildNodeFieldNameNotFound":[
{ "Appearance":
"-IllegalChildNodeFieldNameNotFound":[
{ "Material":
{
"@emissiveColor":[0.6,0.19607843,0.8]
}
}
]
}
],
"-IllegalChildNodeFieldNameNotFound":[
{ "IndexedLineSet":
{
"@coordIndex":[0,1,2,3,4,0],
"-children":[
{
"#comment":"Coordinate 3-tuple point count: 6"
}
],
"-IllegalChildNodeFieldNameNotFound":[
{ "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]
}
}
]
}
}
]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "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]
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "TimeSensor":
{
"@DEF":"OrbitClock",
"@cycleInterval":8.0,
"@loop":true
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
],
"-children":[
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"OrbitClock",
"@toField":"set_fraction",
"@toNode":"BoxPathAnimator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"BoxPathAnimator",
"@toField":"set_translation",
"@toNode":"LogoGeometryTransform"
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01Material prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01Material prototype is a Material node"
},
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
}
]
},
"ProtoBody": {
"-children":[
{
"#comment":"Initial node of ProtoBody determines prototype node type"
},
{ "Material":
{
"@ambientIntensity":0.25,
"@diffuseColor":[0.282435,0.085159,0.134462],
"@shininess":0.127273,
"@specularColor":[0.276305,0.11431,0.139857]
}
},
{
"#comment":"[HelloWorldProgram diagnostic] should be connected to scene graph: artDeco01ProtoDeclare.getNodeType()=\"Material\""
},
{
"#comment":"presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types"
},
{ "TouchSensor":
{
"@description":"within ProtoBody",
"IS": {
"connect": [
{
"@nodeField":"description",
"@protoField":"description"
},
{
"@nodeField":"enabled",
"@protoField":"enabled"
}
]
}
}
}
]
}
}
},
{ "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"],
"-children":[
{
"#comment":"[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.\""
}
],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place"
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineScene"
}
},
{ "EXPORT":
{
"@AS":"WorldInfoDEF3",
"@localDEF":"WorldInfoDEF"
}
},
{ "ProtoDeclare":
{
"@name":"MaterialModulator",
"@appinfo":"mimic a Material node and modulate fields as an animation effect",
"@documentation":"http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html",
"ProtoInterface": {
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool",
"@value":true
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"emissiveColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0.05,0.05,0.5]
},
{
"@name":"specularColor",
"@accessType":"inputOutput",
"@type":"SFColor",
"@value":[0,0,0]
},
{
"@name":"transparency",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"shininess",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
},
{
"@name":"ambientIntensity",
"@accessType":"inputOutput",
"@type":"SFFloat",
"@value":0.0
}
]
},
"ProtoBody": {
"-children":[
{ "Material":
{
"@DEF":"MaterialNode",
"IS": {
"connect": [
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
},
{
"@nodeField":"emissiveColor",
"@protoField":"emissiveColor"
},
{
"@nodeField":"specularColor",
"@protoField":"specularColor"
},
{
"@nodeField":"transparency",
"@protoField":"transparency"
},
{
"@nodeField":"shininess",
"@protoField":"shininess"
},
{
"@nodeField":"ambientIntensity",
"@protoField":"ambientIntensity"
}
]
}
}
},
{
"#comment":"Only first node (the node type) is renderable, others are along for the ride"
},
{ "Script":
{
"@DEF":"MaterialModulatorScript",
"field": [
{
"@name":"enabled",
"@accessType":"inputOutput",
"@type":"SFBool"
},
{
"@name":"diffuseColor",
"@accessType":"inputOutput",
"@type":"SFColor"
},
{
"@name":"newColor",
"@accessType":"outputOnly",
"@type":"SFColor"
},
{
"@name":"clockTrigger",
"@accessType":"inputOnly",
"@type":"SFTime"
}
],
"IS": {
"connect": [
{
"@nodeField":"enabled",
"@protoField":"enabled"
},
{
"@nodeField":"diffuseColor",
"@protoField":"diffuseColor"
}
]
},
"#sourceCode":[
"",
"",
"ecmascript:",
"function initialize ()",
"{",
" newColor = diffuseColor; // start with correct color",
"}",
"function set_enabled (newValue)",
"{",
"\tenabled = 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);",
"\tif (enabled)",
"\t{",
"\t\tBrowser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');",
"\t}",
"}",
"",
""
]
}
}
]
}
}
},
{
"#comment":"Test success: declarative statement createDeclarativeShapeTests()"
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"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>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(findThisNameValue) = <MetadataString DEF='FindableMetadataStringTest' name='findThisNameValue' value='\"test case\"'/>"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"ArtDeco01Material\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoDeclare\") found"
},
{
"#comment":"Test success: x3dModel.findElementByNameValue(\"MaterialModulator\", \"ProtoInstance\") found"
},
{
"#comment":"Test success: Anchor.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: Anchor.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTE.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTE.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true"
},
{ "ProtoDeclare":
{
"@name":"ShaderProto",
"ProtoBody": {
"-children":[
{ "ProgramShader":
}
]
}
}
}
]
}
}
}
More information about the x3d-public
mailing list