run:
HelloWorldProgramOutput.java console output
===========================================
Validation results for this scene graph:
no errors detected.
===========================================
===========================================
#X3D V3.3 utf8
PROFILE Immersive
# head
COMPONENT Navigation:3
COMPONENT Layering:1
UNIT angle AngleUnitConversion 1.0
UNIT length LengthUnitConversion 1.0
META "title" "HelloWorldProgramOutput.x3d"
META "description" "Example HelloWorldProgram creates an X3D model using the X3D Java Scene Access Interface (SAI) Library"
META "reference" "http://www.web3d.org/specifications/java/X3DJSAIL.html"
META "generator" "HelloWorldProgramOutput.java"
META "created" "6 September 2016"
META "modified" "31 October 2017"
META "generator" "X3D Java Scene Access Interface Library (X3DJSAIL)"
META "generator" "http://www.web3d.org/specifications/java/examples/HelloWorldProgram.java"
META "generator" "Netbeans http://www.netbeans.org"
META "creator" "Don Brutzman"
META "reference" "https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.x3d"
META "reference" "Console output, ClassicVRML encoding, VRML97 encoding and pretty-print documentation:"
META "reference" "HelloWorldProgramOutput.txt"
META "reference" "HelloWorldProgramOutput.x3dv"
META "reference" "HelloWorldProgramOutput.wrl"
META "reference" "HelloWorldProgramOutput.html"
META "X3dValidator" "https://savage.nps.edu/X3dValidator?url=http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
META "identifier" "http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
META "license" "../license.html"
META "SpecialTest" "tested sat: name value cannot contain embedded space character"
# comment #1
# comment #2
# comment #3
# comment #4
# Scene
ViewpointGroup {
description "Available viewpoints"
children [
DEF DefaultView Viewpoint {
description "Hello X3DJSAIL"
}
DEF TopDownView Viewpoint {
description "top-down view from above"
orientation 1 0 0 -1.570796
position 0 100 0
}
]
}
DEF WorldInfoDEF WorldInfo {
title "HelloWorldProgram produced by X3D Java SAI Library (X3DJSAIL)"
}
USE WorldInfoDEF
USE WorldInfoDEF
DEF scene.addChildMetadataObject MetadataString {
name "test"
}
DEF scene.addChildLayerSetObjectTest LayerSet {
order [ 0 ]
}
DEF LogoGeometryTransform Transform {
translation 0 1.5 0
children [
Anchor {
description "select for X3D Java SAI Library (X3DJSAIL) description"
url [ "../X3DJSAIL.html" "http://www.web3d.org/specifications/java/X3DJSAIL.html" ]
children [
DEF BoxShape Shape {
appearance Appearance {
material DEF GreenMaterial Material {
diffuseColor 0 1 1
emissiveColor 0.8 0 0
transparency 0.1
}
texture ImageTexture {
url [ "images/X3dJavaSceneAccessInterfaceSaiLibrary.png" "http://www.web3d.org/specifications/java/examples/images/X3dJavaSceneAccessInterfaceSaiLibrary.png" ]
}
}
geometry DEF test-NMTOKEN_regex.0123456789 Box {
# class "textured"
}
}
]
}
]
}
DEF LineShape Shape {
appearance Appearance {
material Material {
emissiveColor 0.6 0.19607843 0.8
}
}
geometry IndexedLineSet {
coordIndex [ 0 1 2 3 4 0 ]
coord 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 ]
}
}
}
DEF BoxPathAnimator PositionInterpolator {
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 ]
}
DEF OrbitClock TimeSensor {
cycleInterval 8.0
loop true
}
ROUTE OrbitClock.fraction_changed TO BoxPathAnimator.set_fraction
ROUTE BoxPathAnimator.value_changed TO LogoGeometryTransform.set_translation
DEF TextTransform Transform {
translation 0 -1.5 0
children [
Shape {
appearance Appearance {
material USE GreenMaterial
}
geometry Text {
string [ "X3D Java" "SAI Library" "X3DJSAIL" ]
fontStyle FontStyle {
family [ "SERIF" ]
justify [ "MIDDLE" "MIDDLE" ]
}
metadata MetadataSet {
name "EscapedQuotationMarksMetadataSet"
value [
MetadataString {
name "escapedQuotesTest1"
value [ "escaped quotation marks example 1: He said, \"Immel did it!\"" ]
}
MetadataString {
name "escapedQuotesTest2"
value [ "escaped quotation marks example 2: He said, "Immel did it!"" ]
}
]
}
# escaped quotation marks example 3: He said, "Immel did it!"
# escaped quotation marks example 4: He said, "Immel did it!"
}
}
Collision {
children [
# test containerField='proxy'
]
proxy DEF ProxyShape Shape {
geometry Text {
string [ "One, Two, Three" "" "He said, \"Immel did it!\"" ]
}
# alternative XML encoding: Text string='"One, Two, Three" "" "He said, \"Immel did it!\""'
# alternative Java source: .setString(new String [] {"One, Two, Three", "", "He said, \"Immel did it!\""})
# reference: http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/StringArrayEncodingExamplesIndex.html
}
}
# It's a beautiful world
# ... for you!
# https://en.wikipedia.org/wiki/Beautiful_World_(Devo_song)
]
}
# repeatedly spin 180 degrees as a readable special effect
DEF SpinInterpolator OrientationInterpolator {
key [ 0 0.5 1 ]
keyValue [ 0 1 0 4.712389 0 1 0 0 0 1 0 1.5707964 ]
}
DEF SpinClock TimeSensor {
cycleInterval 5.0
loop true
}
ROUTE SpinClock.fraction_changed TO SpinInterpolator.set_fraction
ROUTE SpinInterpolator.value_changed TO TextTransform.rotation
DEF BackgroundGroup Group {
children [
DEF GradualBackground Background {
}
DEF colorTypeConversionScript Script {
inputOnly SFColor colorInput
outputOnly MFColor colorsOutput url [ "ecmascript:
function colorInput (eventValue) // Example source code
{
colorsOutput = new MFColor(eventValue); // assigning value sends output event
// Browser.print('colorInput=' + eventValue + ', colorsOutput=' + colorsOutput + '\n');
}
" ]
}
DEF ColorAnimator ColorInterpolator {
key [ 0 0.5 1 ]
keyValue [ 0.9411765 1 1 0.29411766 0 0.50980395 0.9411765 1 1 ]
# AZURE to INDIGO and back again
}
DEF ColorClock TimeSensor {
cycleInterval 60.0
loop true
}
ROUTE colorTypeConversionScript.colorsOutput TO GradualBackground.skyColor
ROUTE ColorAnimator.value_changed TO colorTypeConversionScript.colorInput
ROUTE ColorClock.fraction_changed TO ColorAnimator.set_fraction
]
}
PROTO ArtDeco01Material [
# [appinfo] "tooltip: ArtDeco01 prototype is a Material node"
# ProtoInterface
inputOutput SFString description "ArtDeco01 prototype is a Material node" # [appinfo] "tooltip for descriptionField"
inputOutput SFBool enabled true] {
# ProtoBody
# 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
}
# [HelloWorldProgram diagnostic] should be connected to scene graph: ArtDeco01ProtoDeclare.getNodeType()="Material"
# presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types
TouchSensor {
description IS description
enabled IS enabled
}
}
EXTERNPROTO ArtDeco02Material [
# [appinfo] "this is a different Material node"
url [ "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ArtDecoPrototypesExcerpt.x3d#ArtDeco02" "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ArtDecoPrototypesExcerpt.x3dv#ArtDeco02" ]
inputOutput SFString description # [appinfo] "tooltip for descriptionField"
# [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."
]
# Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place
DEF TestShape1 Shape {
appearance DEF TestAppearance1 Appearance {
material ArtDeco01 { name "ArtDeco01"
description ArtDeco01 can substitute for a Material node# [HelloWorldProgram diagnostic] ArtDeco01ProtoInstance.getNodeType()="ERROR_UNKNOWN_PROTOINSTANCE_NODE_TYPE: ProtoInstance name='ArtDeco01' has no corresponding ProtoDeclareObject or ExternProtoDeclareObject to provide type."
}
# ArtDeco01 Material prototype goes here...
}
geometry Sphere {
radius 0.001
}
}
DEF TestShape2 Shape {
appearance DEF TestAppearance2 Appearance {
material ArtDeco02 { name "ArtDeco02"
description ArtDeco02 can substitute for another Material node# [HelloWorldProgram diagnostic] ArtDeco02ProtoInstance.getNodeType()="ERROR_UNKNOWN_PROTOINSTANCE_NODE_TYPE: ProtoInstance name='ArtDeco02' has no corresponding ProtoDeclareObject or ExternProtoDeclareObject to provide type."
}
# ArtDeco02 Material prototype goes here...
}
geometry Cone {
bottomRadius 0.001
height 0.001
}
}
DEF inlineSceneDef Inline {
url [ "someOtherScene.x3d" ]
}
IMPORT inlineSceneDef.WorldInfoDEF AS WorldInfoDEF2
EXPORT WorldInfoDEF AS WorldInfoDEF3
PROTO MaterialModulator [
# [appinfo] "mimic a Material node and modulate fields as an animation effect"
# [documentation] "http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html"
# ProtoInterface
inputOutput SFBool enabled true
inputOutput SFColor diffuseColor 0 0 0
inputOutput SFColor emissiveColor 0.05 0.05 0.5
inputOutput SFColor specularColor 0 0 0
inputOutput SFFloat transparency 0.0
inputOutput SFFloat shininess 0.0
inputOutput SFFloat ambientIntensity 0.0] {
# ProtoBody
DEF MaterialNode Material {
ambientIntensity IS ambientIntensity
diffuseColor IS diffuseColor
emissiveColor IS emissiveColor
shininess IS shininess
specularColor IS specularColor
transparency IS transparency
}
# Only first node (the node type) is renderable, others are along for the ride
DEF MaterialModulatorScript Script {
inputOutput SFBool enabled
inputOutput SFColor diffuseColor
outputOnly SFColor newColor
inputOnly SFTime clockTrigger url [ "ecmascript:
function initialize ()
{
newColor = diffuseColor; // start with correct color
}
function set_enabled (newValue)
{
enabled = newValue;
}
function clockTrigger (timeValue)
{
if (!enabled) return;
red = newColor.r;
green = newColor.g;
blue = newColor.b;
// note different modulation rates for each color component, % is modulus operator
newColor = new SFColor ((red + 0.02) % 1, (green + 0.03) % 1, (blue + 0.04) % 1);
if (enabled)
{
Browser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');
}
}
" ]
}
}
# Test success: declarative statement createDeclarativeShapeTests()
DEF DeclarativeGroupExample Group {
children [
Shape {
appearance DEF DeclarativeAppearanceExample Appearance {
material DEF MyMaterialModulator MaterialModulator { name "MaterialModulator"
}
# DeclarativeMaterialExample gets overridden by subsequently added MaterialModulator ProtoInstance
}
geometry Cone {
bottom false
bottomRadius 0.05
height 0.1
}
metadata DEF FindableMetadataStringTest MetadataString {
name "findThisNameValue"
value [ "test case" ]
}
}
# Test success: declarativeGroup.addChild() singleton pipeline method
]
}
# Test success: declarative statement addChild()
# Test success: x3dModel.findNodeByDEF(DeclarativeAppearanceExample) = i.e.
#
#
#
#
# Test success: x3dModel.findElementByNameValue(findThisNameValue) =
# Test success: x3dModel.findElementByNameValue("ArtDeco01Material", "ProtoDeclare") found
# Test success: x3dModel.findElementByNameValue("MaterialModulator", "ProtoDeclare") found
# Test success: x3dModel.findElementByNameValue("MaterialModulator", "ProtoInstance") found
DEF TestFieldObjectsGroup Group {
children [
# testFieldObjects() results
# SFBool default=true, true=true, false=false, negate()=true
# MFBool default=, initial=true false true, negate()=false true false
# SFFloat default=0.0, initial=1.0, setValue(2)=2.0, setValue(3.0f)=3.0, setValue(4.0)=4.0
# MFFloat default=, initial=1 2 3, append(5)=1 2 3 5, inserts(3,4)(0,0)=0 1 2 3 4 5, append(6)=0 1 2 3 4 5 6, size()=7
# ... get1Value[3]=3.0, remove[1]=0 2 3 4 5 6, set1Value(0,10)=10 2 3 4 5 6, multiply(2)=20 4 6 8 10 12, clear=
# SFVec3f default=0 0 0, initial=1 2 3, setValue=4 5 6, multiply(2)=8 10 12, normalize()=0.45584232 0.5698029 0.68376344
]
}
Sound {
source AudioClip {
url [ "chimes.wav" "http://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/chimes.wav" ]
}
# Scene example fragment from http://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/default.x3d
}
Sound {
source MovieTexture {
url [ "mpgsys.mpg" "http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpgsys.mpg" ]
}
# Scene example fragment from http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpeg1-systems.x3d
# Expected containerField='source', allowed containerField values="texture" "source" "back" "bottom" "front" "left" "right" "top" "backTexture" "bottomTexture" "frontTexture" "leftTexture" "rightTexture" "topTexture"
}
# Test success: AnchorObject.isNode()=true, siteAnchor.isNode()=true
# Test success: AnchorObject.isStatement()=false, siteAnchor.isStatement()=false
# Test success: ROUTEObject.isNode()=false, orbitPositionROUTE.isNode()=false
# Test success: ROUTEObject.isStatement()=true, orbitPositionROUTE.isStatement()=true
# Test success: CommentsBlock.isNode()=false, testComments.isNode()=false
# Test success: CommentsBlock.isStatement()=false, testComments.isStatement()=false
DEF ExtrusionShape Shape {
appearance DEF TransparentAppearance Appearance {
material Material {
transparency 1.0
}
}
geometry DEF ExampleExtrusion Extrusion {
}
# ExampleExtrusion isCrossSectionClosed()=true, crossSection='[1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0]'
# ExampleExtrusion isSpineClosed()=false, spine='[0.0, 0.0, 0.0, 0.0, 1.0, 0.0]'
}
===========================================
#VRML V2.0 utf8
#PROFILE Immersive
# head
#COMPONENT Navigation:3
#COMPONENT Layering:1
#UNIT angle AngleUnitConversion 1.0
#UNIT length LengthUnitConversion 1.0
#META "title" "HelloWorldProgramOutput.x3d"
#META "description" "Example HelloWorldProgram creates an X3D model using the X3D Java Scene Access Interface (SAI) Library"
#META "reference" "http://www.web3d.org/specifications/java/X3DJSAIL.html"
#META "generator" "HelloWorldProgramOutput.java"
#META "created" "6 September 2016"
#META "modified" "31 October 2017"
#META "generator" "X3D Java Scene Access Interface Library (X3DJSAIL)"
#META "generator" "http://www.web3d.org/specifications/java/examples/HelloWorldProgram.java"
#META "generator" "Netbeans http://www.netbeans.org"
#META "creator" "Don Brutzman"
#META "reference" "https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/java/examples/HelloWorldProgramOutput.x3d"
#META "reference" "Console output, ClassicVRML encoding, VRML97 encoding and pretty-print documentation:"
#META "reference" "HelloWorldProgramOutput.txt"
#META "reference" "HelloWorldProgramOutput.x3dv"
#META "reference" "HelloWorldProgramOutput.wrl"
#META "reference" "HelloWorldProgramOutput.html"
#META "X3dValidator" "https://savage.nps.edu/X3dValidator?url=http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
#META "identifier" "http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
#META "license" "../license.html"
#META "SpecialTest" "tested sat: name value cannot contain embedded space character"
# comment #1
# comment #2
# comment #3
# comment #4
# Scene
ViewpointGroup {
description "Available viewpoints"
children [
DEF DefaultView Viewpoint {
description "Hello X3DJSAIL"
}
DEF TopDownView Viewpoint {
description "top-down view from above"
orientation 1 0 0 -1.570796
position 0 100 0
}
]
}
DEF WorldInfoDEF WorldInfo {
title "HelloWorldProgram produced by X3D Java SAI Library (X3DJSAIL)"
}
USE WorldInfoDEF
USE WorldInfoDEF
DEF scene.addChildMetadataObject MetadataString {
name "test"
}
DEF scene.addChildLayerSetObjectTest LayerSet {
order [ 0 ]
}
DEF LogoGeometryTransform Transform {
translation 0 1.5 0
children [
Anchor {
description "select for X3D Java SAI Library (X3DJSAIL) description"
url [ "../X3DJSAIL.html" "http://www.web3d.org/specifications/java/X3DJSAIL.html" ]
children [
DEF BoxShape Shape {
appearance Appearance {
material DEF GreenMaterial Material {
diffuseColor 0 1 1
emissiveColor 0.8 0 0
transparency 0.1
}
texture ImageTexture {
url [ "images/X3dJavaSceneAccessInterfaceSaiLibrary.png" "http://www.web3d.org/specifications/java/examples/images/X3dJavaSceneAccessInterfaceSaiLibrary.png" ]
}
}
geometry DEF test-NMTOKEN_regex.0123456789 Box {
# class "textured"
}
}
]
}
]
}
DEF LineShape Shape {
appearance Appearance {
material Material {
emissiveColor 0.6 0.19607843 0.8
}
}
geometry IndexedLineSet {
coordIndex [ 0 1 2 3 4 0 ]
coord 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 ]
}
}
}
DEF BoxPathAnimator PositionInterpolator {
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 ]
}
DEF OrbitClock TimeSensor {
cycleInterval 8.0
loop true
}
ROUTE OrbitClock.fraction_changed TO BoxPathAnimator.set_fraction
ROUTE BoxPathAnimator.value_changed TO LogoGeometryTransform.set_translation
DEF TextTransform Transform {
translation 0 -1.5 0
children [
Shape {
appearance Appearance {
material USE GreenMaterial
}
geometry Text {
string [ "X3D Java" "SAI Library" "X3DJSAIL" ]
fontStyle FontStyle {
family [ "SERIF" ]
justify [ "MIDDLE" "MIDDLE" ]
}
metadata MetadataSet {
name "EscapedQuotationMarksMetadataSet"
value [
MetadataString {
name "escapedQuotesTest1"
value [ "escaped quotation marks example 1: He said, \"Immel did it!\"" ]
}
MetadataString {
name "escapedQuotesTest2"
value [ "escaped quotation marks example 2: He said, "Immel did it!"" ]
}
]
}
# escaped quotation marks example 3: He said, "Immel did it!"
# escaped quotation marks example 4: He said, "Immel did it!"
}
}
Collision {
children [
# test containerField='proxy'
]
proxy DEF ProxyShape Shape {
geometry Text {
string [ "One, Two, Three" "" "He said, \"Immel did it!\"" ]
}
# alternative XML encoding: Text string='"One, Two, Three" "" "He said, \"Immel did it!\""'
# alternative Java source: .setString(new String [] {"One, Two, Three", "", "He said, \"Immel did it!\""})
# reference: http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/StringArrayEncodingExamplesIndex.html
}
}
# It's a beautiful world
# ... for you!
# https://en.wikipedia.org/wiki/Beautiful_World_(Devo_song)
]
}
# repeatedly spin 180 degrees as a readable special effect
DEF SpinInterpolator OrientationInterpolator {
key [ 0 0.5 1 ]
keyValue [ 0 1 0 4.712389 0 1 0 0 0 1 0 1.5707964 ]
}
DEF SpinClock TimeSensor {
cycleInterval 5.0
loop true
}
ROUTE SpinClock.fraction_changed TO SpinInterpolator.set_fraction
ROUTE SpinInterpolator.value_changed TO TextTransform.rotation
DEF BackgroundGroup Group {
children [
DEF GradualBackground Background {
}
DEF colorTypeConversionScript Script {
inputOnly SFColor colorInput
outputOnly MFColor colorsOutput url [ "ecmascript:
function colorInput (eventValue) // Example source code
{
colorsOutput = new MFColor(eventValue); // assigning value sends output event
// Browser.print('colorInput=' + eventValue + ', colorsOutput=' + colorsOutput + '\n');
}
" ]
}
DEF ColorAnimator ColorInterpolator {
key [ 0 0.5 1 ]
keyValue [ 0.9411765 1 1 0.29411766 0 0.50980395 0.9411765 1 1 ]
# AZURE to INDIGO and back again
}
DEF ColorClock TimeSensor {
cycleInterval 60.0
loop true
}
ROUTE colorTypeConversionScript.colorsOutput TO GradualBackground.skyColor
ROUTE ColorAnimator.value_changed TO colorTypeConversionScript.colorInput
ROUTE ColorClock.fraction_changed TO ColorAnimator.set_fraction
]
}
PROTO ArtDeco01Material [
# [appinfo] "tooltip: ArtDeco01 prototype is a Material node"
# ProtoInterface
inputOutput SFString description "ArtDeco01 prototype is a Material node" # [appinfo] "tooltip for descriptionField"
inputOutput SFBool enabled true] {
# ProtoBody
# 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
}
# [HelloWorldProgram diagnostic] should be connected to scene graph: ArtDeco01ProtoDeclare.getNodeType()="Material"
# presence of follow-on TouchSensor shows that additional nodes are allowed in ProtoBody after initial node, regardless of node types
TouchSensor {
description IS description
enabled IS enabled
}
}
EXTERNPROTO ArtDeco02Material [
# [appinfo] "this is a different Material node"
url [ "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ArtDecoPrototypesExcerpt.x3d#ArtDeco02" "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ArtDecoPrototypesExcerpt.x3dv#ArtDeco02" ]
inputOutput SFString description # [appinfo] "tooltip for descriptionField"
# [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."
]
# Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node type when ProtoInstance is added in wrong place
DEF TestShape1 Shape {
appearance DEF TestAppearance1 Appearance {
material ArtDeco01 { name "ArtDeco01"
description ArtDeco01 can substitute for a Material node# [HelloWorldProgram diagnostic] ArtDeco01ProtoInstance.getNodeType()="ERROR_UNKNOWN_PROTOINSTANCE_NODE_TYPE: ProtoInstance name='ArtDeco01' has no corresponding ProtoDeclareObject or ExternProtoDeclareObject to provide type."
}
# ArtDeco01 Material prototype goes here...
}
geometry Sphere {
radius 0.001
}
}
DEF TestShape2 Shape {
appearance DEF TestAppearance2 Appearance {
material ArtDeco02 { name "ArtDeco02"
description ArtDeco02 can substitute for another Material node# [HelloWorldProgram diagnostic] ArtDeco02ProtoInstance.getNodeType()="ERROR_UNKNOWN_PROTOINSTANCE_NODE_TYPE: ProtoInstance name='ArtDeco02' has no corresponding ProtoDeclareObject or ExternProtoDeclareObject to provide type."
}
# ArtDeco02 Material prototype goes here...
}
geometry Cone {
bottomRadius 0.001
height 0.001
}
}
DEF inlineSceneDef Inline {
url [ "someOtherScene.x3d" ]
}
IMPORT inlineSceneDef.WorldInfoDEF AS WorldInfoDEF2
EXPORT WorldInfoDEF AS WorldInfoDEF3
PROTO MaterialModulator [
# [appinfo] "mimic a Material node and modulate fields as an animation effect"
# [documentation] "http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorIndex.html"
# ProtoInterface
inputOutput SFBool enabled true
inputOutput SFColor diffuseColor 0 0 0
inputOutput SFColor emissiveColor 0.05 0.05 0.5
inputOutput SFColor specularColor 0 0 0
inputOutput SFFloat transparency 0.0
inputOutput SFFloat shininess 0.0
inputOutput SFFloat ambientIntensity 0.0] {
# ProtoBody
DEF MaterialNode Material {
ambientIntensity IS ambientIntensity
diffuseColor IS diffuseColor
emissiveColor IS emissiveColor
shininess IS shininess
specularColor IS specularColor
transparency IS transparency
}
# Only first node (the node type) is renderable, others are along for the ride
DEF MaterialModulatorScript Script {
inputOutput SFBool enabled
inputOutput SFColor diffuseColor
outputOnly SFColor newColor
inputOnly SFTime clockTrigger url [ "ecmascript:
function initialize ()
{
newColor = diffuseColor; // start with correct color
}
function set_enabled (newValue)
{
enabled = newValue;
}
function clockTrigger (timeValue)
{
if (!enabled) return;
red = newColor.r;
green = newColor.g;
blue = newColor.b;
// note different modulation rates for each color component, % is modulus operator
newColor = new SFColor ((red + 0.02) % 1, (green + 0.03) % 1, (blue + 0.04) % 1);
if (enabled)
{
Browser.print ('diffuseColor=(' + red + ',' + green + ',' + blue + ') newColor=' + newColor.toString() + '\n');
}
}
" ]
}
}
# Test success: declarative statement createDeclarativeShapeTests()
DEF DeclarativeGroupExample Group {
children [
Shape {
appearance DEF DeclarativeAppearanceExample Appearance {
material DEF MyMaterialModulator MaterialModulator { name "MaterialModulator"
}
# DeclarativeMaterialExample gets overridden by subsequently added MaterialModulator ProtoInstance
}
geometry Cone {
bottom false
bottomRadius 0.05
height 0.1
}
metadata DEF FindableMetadataStringTest MetadataString {
name "findThisNameValue"
value [ "test case" ]
}
}
# Test success: declarativeGroup.addChild() singleton pipeline method
]
}
# Test success: declarative statement addChild()
# Test success: x3dModel.findNodeByDEF(DeclarativeAppearanceExample) = i.e.
#
#
#
#
# Test success: x3dModel.findElementByNameValue(findThisNameValue) =
# Test success: x3dModel.findElementByNameValue("ArtDeco01Material", "ProtoDeclare") found
# Test success: x3dModel.findElementByNameValue("MaterialModulator", "ProtoDeclare") found
# Test success: x3dModel.findElementByNameValue("MaterialModulator", "ProtoInstance") found
DEF TestFieldObjectsGroup Group {
children [
# testFieldObjects() results
# SFBool default=true, true=true, false=false, negate()=true
# MFBool default=, initial=true false true, negate()=false true false
# SFFloat default=0.0, initial=1.0, setValue(2)=2.0, setValue(3.0f)=3.0, setValue(4.0)=4.0
# MFFloat default=, initial=1 2 3, append(5)=1 2 3 5, inserts(3,4)(0,0)=0 1 2 3 4 5, append(6)=0 1 2 3 4 5 6, size()=7
# ... get1Value[3]=3.0, remove[1]=0 2 3 4 5 6, set1Value(0,10)=10 2 3 4 5 6, multiply(2)=20 4 6 8 10 12, clear=
# SFVec3f default=0 0 0, initial=1 2 3, setValue=4 5 6, multiply(2)=8 10 12, normalize()=0.45584232 0.5698029 0.68376344
]
}
Sound {
source AudioClip {
url [ "chimes.wav" "http://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/chimes.wav" ]
}
# Scene example fragment from http://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/default.x3d
}
Sound {
source MovieTexture {
url [ "mpgsys.mpg" "http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpgsys.mpg" ]
}
# Scene example fragment from http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpeg1-systems.x3d
# Expected containerField='source', allowed containerField values="texture" "source" "back" "bottom" "front" "left" "right" "top" "backTexture" "bottomTexture" "frontTexture" "leftTexture" "rightTexture" "topTexture"
}
# Test success: AnchorObject.isNode()=true, siteAnchor.isNode()=true
# Test success: AnchorObject.isStatement()=false, siteAnchor.isStatement()=false
# Test success: ROUTEObject.isNode()=false, orbitPositionROUTE.isNode()=false
# Test success: ROUTEObject.isStatement()=true, orbitPositionROUTE.isStatement()=true
# Test success: CommentsBlock.isNode()=false, testComments.isNode()=false
# Test success: CommentsBlock.isStatement()=false, testComments.isStatement()=false
DEF ExtrusionShape Shape {
appearance DEF TransparentAppearance Appearance {
material Material {
transparency 1.0
}
}
geometry DEF ExampleExtrusion Extrusion {
}
# ExampleExtrusion isCrossSectionClosed()=true, crossSection='[1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0]'
# ExampleExtrusion isSpineClosed()=false, spine='[0.0, 0.0, 0.0, 0.0, 1.0, 0.0]'
}
===========================================
Create X3D XML Encoding of model
helloWorldObject.toFileX3D("HelloWorldProgramOutput.x3d") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.x3d
===========================================
Create X3D ClassicVRML Encoding of model
helloWorldObject.toFileClassicVRML("HelloWorldProgramOutput.x3dv") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.x3dv
===========================================
Create VRML97 Encoding of model
helloWorldObject.toFileVRML97("HelloWorldProgramOutput.wrl") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.wrl
===========================================
Create pretty-print HTML documentation of model using XSLT_ENGINE_saxon=saxon9he.jar and stylesheet X3dToXhtml.xslt
helloWorldObject.toFileDocumentationHTML("HelloWorldProgramOutput.html") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.html
===========================================
Create concise Java source of model using stylesheet X3dToJava.xslt
helloWorldObject.toFileJava("HelloWorldProgramOutput.java") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.java
===========================================
Create JSON Encoding of model using stylesheet X3dToJson.xslt
Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
helloWorldObject.toFileJSON("HelloWorldProgramOutput.json") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.json
===========================================
Create displayable scene page rendered with X3DOM using stylesheet X3dToX3dom.xslt
helloWorldObject.toFileX3DOM("HelloWorldProgramOutputX3dom.xhtml") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutputX3dom.xhtml
===========================================
Create displayable scene page rendered with X_ITE (formerly Cobweb) using stylesheet X3dToX3dom.xslt
helloWorldObject.toFileX3DOM("HelloWorldProgramOutputX_ITE.html") success: true
C:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutputX_ITE.html
===========================================
Reload and provide text output using Java DOM, which includes default attribute values
===========================================
Test success: x3dLoader.loadX3DfromXML(HelloWorldProgramOutput.x3d), x3dLoader.getX3dObjectTree()
===========================================
===========================================
Test success: x3dLoader.loadX3DfromXML(HelloWorldProgramOutput.x3d), x3dLoader.getDomDocument() and x3dLoader.toStringX3D(domDocument)
===========================================
Test success: x3dLoader.toX3dObjectTree(domDocument), save HelloWorldProgramOutput.Reloaded.x3d
x3dLoader validation result: no issues reported.
===========================================
Test toStringJSON()
Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode
{ "X3D": {
"encoding":"UTF-8",
"@profile":"Immersive",
"@version":"3.3",
"@xsd:noNamespaceSchemaLocation":"http://www.web3d.org/specifications/x3d-3.3.xsd",
"JSON schema":"http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
"head": {
"component": [
{
"@name":"Navigation",
"@level":3
},
{
"@name":"Layering",
"@level":1
}
],
"unit": [
{
"@name":"AngleUnitConversion",
"@category":"angle",
"@conversionFactor":1.0
},
{
"@name":"LengthUnitConversion",
"@category":"length",
"@conversionFactor":1.0
}
],
"meta": [
{
"@name":"title",
"@content":"HelloWorldProgramOutput.x3d"
},
{
"@name":"description",
"@content":"Example HelloWorldProgram creates an X3D model using the X3D Java Scene
Access Interface (SAI) Library"
},
{
"@name":"reference",
"@content":"http://www.web3d.org/specifications/java/X3DJSAIL.html"
},
{
"@name":"generator",
"@content":"HelloWorldProgramOutput.java"
},
{
"@name":"created",
"@content":"6 September 2016"
},
{
"@name":"modified",
"@content":"31 October 2017"
},
{
"@name":"generator",
"@content":"X3D Java Scene Access Interface Library (X3DJSAIL)"
},
{
"@name":"generator",
"@content":"http://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":"X3dValidator",
"@content":"https://savage.nps.edu/X3dValidator?url=http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
},
{
"@name":"identifier",
"@content":"http://www.web3d.org/specifications/java/examples/HelloWorldProgramOutput.x3d"
},
{
"@name":"license",
"@content":"../license.html"
},
{
"@name":"SpecialTest",
"@content":"tested sat: name value cannot contain embedded space character"
},
{
"@name":"translated",
"@content":"31 October 2017"
},
{
"@name":"generator",
"@content":"X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
},
{
"@name":"reference",
"@content":"X3D JSON encoding: http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
}
],
"-children":[
{
"#comment":"comment #1"
},
{
"#comment":"comment #2"
},
{
"#comment":"comment #3"
},
{
"#comment":"comment #4"
}
]
},
"Scene": {
"-children":[
{ "ViewpointGroup":
{
"@description":"Available viewpoints",
"-children":[
{ "Viewpoint":
{
"@DEF":"DefaultView",
"@description":"Hello X3DJSAIL"
}
},
{ "Viewpoint":
{
"@DEF":"TopDownView",
"@description":"top-down view from above",
"@orientation":[1,0,0,-1.570796],
"@position":[0,100,0]
}
}
]
}
},
{ "WorldInfo":
{
"@DEF":"WorldInfoDEF",
"@title":"HelloWorldProgram produced by X3D Java SAI Library (X3DJSAIL)"
}
},
{ "WorldInfo":
{
"@USE":"WorldInfoDEF"
}
},
{ "WorldInfo":
{
"@USE":"WorldInfoDEF"
}
},
{ "LayerSet":
{
"@DEF":"scene.addChildLayerSetObjectTest"
}
},
{ "Transform":
{
"@DEF":"LogoGeometryTransform",
"@translation":[0,1.5,0],
"-children":[
{ "Anchor":
{
"@description":"select for X3D Java SAI Library (X3DJSAIL) description",
"@url":["../X3DJSAIL.html","http://www.web3d.org/specifications/java/X3DJSAIL.html"],
"-children":[
{ "Shape":
{
"@DEF":"BoxShape",
"-appearance":
{ "Appearance":
{
"-material":
{ "Material":
{
"@DEF":"GreenMaterial",
"@diffuseColor":[0,1,1],
"@emissiveColor":[0.8,0,0],
"@transparency":0.1
}
},
"-texture":
{ "ImageTexture":
{
"@url":["images/X3dJavaSceneAccessInterfaceSaiLibrary.png","http://www.web3d.org/specifications/java/examples/images/X3dJavaSceneAccessInterfaceSaiLibrary.png"]
}
}
}
},
"-geometry":
{ "Box":
{
"@DEF":"test-NMTOKEN_regex.0123456789",
"@class":"textured"
}
}
}
}
]
}
}
]
}
},
{ "Shape":
{
"@DEF":"LineShape",
"-appearance":
{ "Appearance":
{
"-material":
{ "Material":
{
"@emissiveColor":[0.6,0.19607843,0.8]
}
}
}
},
"-geometry":
{ "IndexedLineSet":
{
"@coordIndex":[0,1,2,3,4,0],
"-coord":
{ "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]
}
}
}
}
}
},
{ "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]
}
},
{ "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"
}
},
{ "Transform":
{
"@DEF":"TextTransform",
"@translation":[0,-1.5,0],
"-children":[
{ "Shape":
{
"-appearance":
{ "Appearance":
{
"-material":
{ "Material":
{
"@USE":"GreenMaterial"
}
}
}
},
"-geometry":
{ "Text":
{
"@string":["X3D Java","SAI Library","X3DJSAIL"],
"-metadata":
{ "MetadataSet":
{
"@name":"EscapedQuotationMarksMetadataSet",
"-value":[
{ "MetadataString":
{
"@name":"escapedQuotesTest1",
"@value":["escaped quotation marks example 1: He said, \"Immel did it!\""]
}
},
{ "MetadataString":
{
"@name":"escapedQuotesTest2",
"@value":["escaped quotation marks example 2: He said, "Immel did it!""]
}
}
]
}
},
"-fontStyle":
{ "FontStyle":
{
"@justify":["MIDDLE","MIDDLE"]
}
},
"-children":[
{
"#comment":"escaped quotation marks example 3: He said, \"Immel did it!\""
},
{
"#comment":"escaped quotation marks example 4: He said, "Immel did it!""
}
]
}
}
}
},
{ "Collision":
{
"-children":[
{
"#comment":"test containerField='proxy'"
}
],
"-proxy":
{ "Shape":
{
"@DEF":"ProxyShape",
"-geometry":
{ "Text":
{
"@string":["One, Two, Three","","He said, \"Immel did it!\""]
}
},
"-children":[
{
"#comment":"alternative XML encoding: Text string='\"One, Two, Three\" \"\" \"He said,
\\"Immel did it!\\"\"'"
},
{
"#comment":"alternative Java source: .setString(new String [] {\"One, Two, Three\",
\"\", \"He said, \\\"Immel did it!\\\"\"})"
},
{
"#comment":"reference: http://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/StringArrayEncodingExamplesIndex.html"
}
]
}
}
}
},
{
"#comment":"It's a beautiful world"
},
{
"#comment":"... for you!"
},
{
"#comment":"https://en.wikipedia.org/wiki/Beautiful_World_(Devo_song)"
}
]
}
},
{
"#comment":"repeatedly spin 180 degrees as a readable special effect"
},
{ "OrientationInterpolator":
{
"@DEF":"SpinInterpolator",
"@key":[0,0.5,1],
"@keyValue":[0,1,0,4.712389,0,1,0,0,0,1,0,1.5707964]
}
},
{ "TimeSensor":
{
"@DEF":"SpinClock",
"@cycleInterval":5.0,
"@loop":true
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"SpinClock",
"@toField":"set_fraction",
"@toNode":"SpinInterpolator"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"SpinInterpolator",
"@toField":"rotation",
"@toNode":"TextTransform"
}
},
{ "Group":
{
"@DEF":"BackgroundGroup",
"-children":[
{ "Background":
{
"@DEF":"GradualBackground"
}
},
{ "Script":
{
"@DEF":"colorTypeConversionScript",
"field": [
{
"@name":"colorInput",
"@accessType":"inputOnly",
"@type":"SFColor"
},
{
"@name":"colorsOutput",
"@accessType":"outputOnly",
"@type":"MFColor"
}
],
"#sourceText":[
"ecmascript:",
"",
"function colorInput (eventValue) // Example source code",
"{",
" colorsOutput = new MFColor(eventValue); // assigning value sends output event",
"// Browser.print('colorInput=' + eventValue + ', colorsOutput=' + colorsOutput +
'\n');",
"}"
]
}
},
{ "ColorInterpolator":
{
"@DEF":"ColorAnimator",
"@key":[0,0.5,1],
"@keyValue":[0.9411765,1,1,0.29411766,0,0.50980395,0.9411765,1,1],
"-children":[
{
"#comment":"AZURE to INDIGO and back again"
}
]
}
},
{ "TimeSensor":
{
"@DEF":"ColorClock",
"@cycleInterval":60.0,
"@loop":true
}
},
{ "ROUTE":
{
"@fromField":"colorsOutput",
"@fromNode":"colorTypeConversionScript",
"@toField":"skyColor",
"@toNode":"GradualBackground"
}
},
{ "ROUTE":
{
"@fromField":"value_changed",
"@fromNode":"ColorAnimator",
"@toField":"colorInput",
"@toNode":"colorTypeConversionScript"
}
},
{ "ROUTE":
{
"@fromField":"fraction_changed",
"@fromNode":"ColorClock",
"@toField":"set_fraction",
"@toNode":"ColorAnimator"
}
}
]
}
},
{ "ProtoDeclare":
{
"@name":"ArtDeco01Material",
"@appinfo":"tooltip: ArtDeco01 prototype is a Material node",
"ProtoInterface": {
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString",
"@value":"ArtDeco01 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#ArtDeco02","http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14Prototypes/ArtDecoPrototypesExcerpt.x3dv#ArtDeco02"],
"field": [
{
"@name":"description",
"@accessType":"inputOutput",
"@appinfo":"tooltip for descriptionField",
"@type":"SFString"
}
],
"-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.\""
}
]
}
},
{
"#comment":"Tested ArtDeco01ProtoInstance, ArtDeco02ProtoInstance for improper node
type when ProtoInstance is added in wrong place"
},
{ "Shape":
{
"@DEF":"TestShape1",
"-appearance":
{ "Appearance":
{
"@DEF":"TestAppearance1",
"-material":
{ "ProtoInstance":
{
"@name":"ArtDeco01",
"fieldValue": [
{
"@name":"description",
"@value":"ArtDeco01 can substitute for a Material node"
}
],
"-children":[
{
"#comment":"[HelloWorldProgram diagnostic] ArtDeco01ProtoInstance.getNodeType()=\"ERROR_UNKNOWN_PROTOINSTANCE_NODE_TYPE:
ProtoInstance name='ArtDeco01' has no corresponding ProtoDeclareObject or ExternProtoDeclareObject
to provide type.\""
}
]
}
},
"-children":[
{
"#comment":"ArtDeco01 Material prototype goes here..."
}
]
}
},
"-geometry":
{ "Sphere":
{
"@radius":0.001
}
}
}
},
{ "Shape":
{
"@DEF":"TestShape2",
"-appearance":
{ "Appearance":
{
"@DEF":"TestAppearance2",
"-material":
{ "ProtoInstance":
{
"@name":"ArtDeco02",
"fieldValue": [
{
"@name":"description",
"@value":"ArtDeco02 can substitute for another Material node"
}
],
"-children":[
{
"#comment":"[HelloWorldProgram diagnostic] ArtDeco02ProtoInstance.getNodeType()=\"ERROR_UNKNOWN_PROTOINSTANCE_NODE_TYPE:
ProtoInstance name='ArtDeco02' has no corresponding ProtoDeclareObject or ExternProtoDeclareObject
to provide type.\""
}
]
}
},
"-children":[
{
"#comment":"ArtDeco02 Material prototype goes here..."
}
]
}
},
"-geometry":
{ "Cone":
{
"@bottomRadius":0.001,
"@height":0.001
}
}
}
},
{ "Inline":
{
"@DEF":"inlineSceneDef",
"@url":["someOtherScene.x3d"]
}
},
{ "IMPORT":
{
"@AS":"WorldInfoDEF2",
"@importedDEF":"WorldInfoDEF",
"@inlineDEF":"inlineSceneDef"
}
},
{ "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"
}
]
},
"#sourceText":[
"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()"
},
{ "Group":
{
"@DEF":"DeclarativeGroupExample",
"-children":[
{ "Shape":
{
"-metadata":
{ "MetadataString":
{
"@name":"findThisNameValue",
"@DEF":"FindableMetadataStringTest",
"@value":["test case"]
}
},
"-appearance":
{ "Appearance":
{
"@DEF":"DeclarativeAppearanceExample",
"-material":
{ "ProtoInstance":
{
"@name":"MaterialModulator",
"@DEF":"MyMaterialModulator"
}
},
"-children":[
{
"#comment":"DeclarativeMaterialExample gets overridden by subsequently added MaterialModulator
ProtoInstance"
}
]
}
},
"-geometry":
{ "Cone":
{
"@bottom":false,
"@bottomRadius":0.05,
"@height":0.1
}
}
}
},
{
"#comment":"Test success: declarativeGroup.addChild() singleton pipeline method"
}
]
}
},
{
"#comment":"Test success: declarative statement addChild()"
},
{
"#comment":"Test success: x3dModel.findNodeByDEF(DeclarativeAppearanceExample) = <Appearance
DEF='DeclarativeAppearanceExample'/> i.e. <Appearance DEF='DeclarativeAppearanceExample'>
<ProtoInstance DEF='MyMaterialModulator' name='MaterialModulator' containerField='material'/>
<!- - DeclarativeMaterialExample gets overridden by subsequently added MaterialModulator
ProtoInstance - -> </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"
},
{ "Group":
{
"@DEF":"TestFieldObjectsGroup",
"-children":[
{
"#comment":"testFieldObjects() results"
},
{
"#comment":"SFBool default=true, true=true, false=false, negate()=true"
},
{
"#comment":"MFBool default=, initial=true false true, negate()=false true false"
},
{
"#comment":"SFFloat default=0.0, initial=1.0, setValue(2)=2.0, setValue(3.0f)=3.0,
setValue(4.0)=4.0"
},
{
"#comment":"MFFloat default=, initial=1 2 3, append(5)=1 2 3 5, inserts(3,4)(0,0)=0
1 2 3 4 5, append(6)=0 1 2 3 4 5 6, size()=7"
},
{
"#comment":"... get1Value[3]=3.0, remove[1]=0 2 3 4 5 6, set1Value(0,10)=10 2 3 4
5 6, multiply(2)=20 4 6 8 10 12, clear="
},
{
"#comment":"SFVec3f default=0 0 0, initial=1 2 3, setValue=4 5 6, multiply(2)=8 10
12, normalize()=0.45584232 0.5698029 0.68376344"
}
]
}
},
{ "Sound":
{
"-source":
{ "AudioClip":
{
"@url":["chimes.wav","http://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/chimes.wav"]
}
},
"-children":[
{
"#comment":"Scene example fragment from http://www.web3d.org/x3d/content/examples/ConformanceNist/Sounds/AudioClip/default.x3d"
}
]
}
},
{ "Sound":
{
"-source":
{ "MovieTexture":
{
"@url":["mpgsys.mpg","http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpgsys.mpg"]
}
},
"-children":[
{
"#comment":"Scene example fragment from http://www.web3d.org/x3d/content/examples/ConformanceNist/Appearance/MovieTexture/mpeg1-systems.x3d"
},
{
"#comment":"Expected containerField='source', allowed containerField values=\"texture\"
\"source\" \"back\" \"bottom\" \"front\" \"left\" \"right\" \"top\" \"backTexture\"
\"bottomTexture\" \"frontTexture\" \"leftTexture\" \"rightTexture\" \"topTexture\""
}
]
}
},
{
"#comment":"Test success: AnchorObject.isNode()=true, siteAnchor.isNode()=true"
},
{
"#comment":"Test success: AnchorObject.isStatement()=false, siteAnchor.isStatement()=false"
},
{
"#comment":"Test success: ROUTEObject.isNode()=false, orbitPositionROUTE.isNode()=false"
},
{
"#comment":"Test success: ROUTEObject.isStatement()=true, orbitPositionROUTE.isStatement()=true"
},
{
"#comment":"Test success: CommentsBlock.isNode()=false, testComments.isNode()=false"
},
{
"#comment":"Test success: CommentsBlock.isStatement()=false, testComments.isStatement()=false"
},
{ "Shape":
{
"@DEF":"ExtrusionShape",
"-appearance":
{ "Appearance":
{
"@DEF":"TransparentAppearance",
"-material":
{ "Material":
{
"@transparency":1.0
}
}
}
},
"-geometry":
{ "Extrusion":
{
"@DEF":"ExampleExtrusion"
}
},
"-children":[
{
"#comment":"ExampleExtrusion isCrossSectionClosed()=true, crossSection='[1.0, 1.0,
1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0]'"
},
{
"#comment":"ExampleExtrusion isSpineClosed()=false, spine='[0.0, 0.0, 0.0, 0.0, 1.0,
0.0]'"
}
]
}
}
]
}
}
}
===========================================
Source file HelloWorldProgramOutput.x3d 19946 bytes
===========================================
Test toFileEXI()
[not yet implemented]
===========================================
Test toFileGZIP()
HelloWorldProgramOutput.gz filesize 5069 bytes, compression 25.41% of original
===========================================
Test toFileZip()
HelloWorldProgramOutput.zip filesize 5317 bytes, compression 26.66% of original
===========================================
Test CommandLine invocations
CommandLine [-help]
Usage: java -classpath X3DJSAIL.*.jar [sourceModel.x3d | -help | -page | -resources | -tooltips]
[-tofile [resultFile.*]] [-validate]
[-toX3D | -toXML | -toClassicVrml | -toJSON | -toVRML97 | -toX3DOM | -toX_ITE | -toEXI | -toGZIP | -toZIP]
===========================================
CommandLine [HelloWorldProgramOutput.x3d, -toX3D, -file, HelloWorldProgramOutput.cl.x3d]
parameter: source file HelloWorldProgramOutput.x3d filesize 19946 bytes
parameter: "-toX3D" for conversion to X3D encoding
parameter: "-file" "HelloWorldProgramOutput.cl.x3d" for result file name root HelloWorldProgramOutput.cl
convert to X3D:
file conversion successful: HelloWorldProgramOutput.cl.x3d (19659 bytes)
===========================================
CommandLine [HelloWorldProgramOutput.x3d, -toGZIP, -file, HelloWorldProgramOutput.cl.x3d.gz]
parameter: source file HelloWorldProgramOutput.x3d filesize 19946 bytes
parameter: "-toGZIP" for conversion to compressed GZIP containing model
parameter: "-file" "HelloWorldProgramOutput.cl.x3d.gz" for result file name root HelloWorldProgramOutput.cl.x3d
convert to GZIP:
source: HelloWorldProgramOutput.x3d filesize 19946 bytes
result: HelloWorldProgramOutput.cl.x3d.gz filesize 5045 bytes, compression 25.29% of original
===========================================
CommandLine [HelloWorldProgramOutput.x3d, -toZIP, -file, HelloWorldProgramOutput.cl.x3d.zip]
parameter: source file HelloWorldProgramOutput.x3d filesize 19946 bytes
parameter: "-toZIP" for conversion to compressed ZIP containing model
parameter: "-file" "HelloWorldProgramOutput.cl.x3d.zip" for result file name root HelloWorldProgramOutput.cl.x3d
convert to ZIP:
source: HelloWorldProgramOutput.x3d filesize 19946 bytes
result: HelloWorldProgramOutput.cl.x3d.zip filesize 5293 bytes, compression 26.54% of original
===========================================
HelloWorldProgram complete.
BUILD SUCCESSFUL (total time: 8 seconds)