import jnius_config
jnius_config.add_options('-Xss1024m')
jnius_config.set_classpath('.', '../../../jars/X3DJSAIL.3.3.full.jar')
from jnius import autoclass
from X3Dautoclass import *
X3D0 = X3D() \
   .setProfile("Immersive") \
   .setVersion("3.3") \
   .setHead(head() \
    .addComponent(component() \
     .setLevel(3) \
     .setName("EnvironmentalEffects") \
    ) \
    .addMeta(meta() \
     .setContent("TextureBackgroundCube.x3d") \
     .setName("title") \
    ) \
    .addMeta(meta() \
     .setContent("TextureBackground containing ImageTexture nodes, with labeled side images and wide field-of-view (FOV) Viewpoints, suitable for scene-orientation testing. Includes transparency interpolator test and also LoadSensor Script console to log events of interest.") \
     .setName("description") \
    ) \
    .addMeta(meta() \
     .setContent("1 May 2017") \
     .setName("created") \
    ) \
    .addMeta(meta() \
     .setContent("1 May 2017") \
     .setName("modified") \
    ) \
    .addMeta(meta() \
     .setContent("Don Brutzman") \
     .setName("creator") \
    ) \
    .addMeta(meta() \
     .setContent("BackgroundCube.x3d.") \
     .setName("reference") \
    ) \
    .addMeta(meta() \
     .setContent("../GeometricShapes/CubeWithLabeledSides.x3d") \
     .setName("reference") \
    ) \
    .addMeta(meta() \
     .setContent("../Animation/CubeWithLabeledSidesViewpointSequencer.x3d") \
     .setName("reference") \
    ) \
    .addMeta(meta() \
     .setContent("../Animation/CubeWithLabeledSidesViewpointSequencer.png") \
     .setName("Image") \
    ) \
    .addMeta(meta() \
     .setContent("http://x3dGraphics.com/examples/X3dForAdvancedModeling/Visualization/BackgroundCube.x3d") \
     .setName("identifier") \
    ) \
    .addMeta(meta() \
     .setContent("http://www.web3d.org/x3d/content/examples/license.html") \
     .setName("license") \
    ) \
    .addMeta(meta() \
     .setContent("X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit") \
     .setName("generator") \
    ) \
   ) \
   .setScene(Scene() \
    .addChild(TextureBackground() \
     .setDEF("TransparentBackground") \
     .setBackTexture(ImageTexture() \
      .setDEF("backTexture") \
      .setUrl(["../GeometricShapes/images/back.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/back.png"]) \
     ) \
     .setBottomTexture(ImageTexture() \
      .setDEF("bottomTexture") \
      .setUrl(["../GeometricShapes/images/bottom.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/bottom.png"]) \
     ) \
     .setFrontTexture(ImageTexture() \
      .setDEF("frontTexture") \
      .setUrl(["../GeometricShapes/images/front.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/front.png"]) \
     ) \
     .setLeftTexture(ImageTexture() \
      .setDEF("leftTexture") \
      .setUrl(["../GeometricShapes/images/left.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/left.png"]) \
     ) \
     .setRightTexture(ImageTexture() \
      .setDEF("rightTexture") \
      .setUrl(["../GeometricShapes/images/right.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/right.png"]) \
     ) \
     .setTopTexture(ImageTexture() \
      .setDEF("topTexture") \
      .setUrl(["../GeometricShapes/images/top.png","http://x3dGraphics.com/examples/X3dForAdvancedModeling/GeometricShapes/images/top.png"]) \
     ) \
    ) \
    .addChild(ScalarInterpolator() \
     .setDEF("TransparencyAnimator") \
     .setKey([0,0.5,1]) \
     .setKeyValue([0,1,0]) \
    ) \
    .addChild(ROUTE() \
     .setFromField("value_changed") \
     .setFromNode("TransparencyAnimator") \
     .setToField("transparency") \
     .setToNode("TransparentBackground") \
    ) \
    .addChild(TimeSensor() \
     .setDEF("Clock") \
     .setCycleInterval(6) \
     .setLoop(True) \
    ) \
    .addChild(ROUTE() \
     .setFromField("fraction_changed") \
     .setFromNode("Clock") \
     .setToField("set_fraction") \
     .setToNode("TransparencyAnimator") \
    ) \
    .addChild(LoadSensor() \
     .setDEF("ImageLoadSensor") \
     .setWatchList(ImageTexture() \
      .setUSE("backTexture") \
     ) \
     .setWatchList(ImageTexture() \
      .setUSE("bottomTexture") \
     ) \
     .setWatchList(ImageTexture() \
      .setUSE("frontTexture") \
     ) \
     .setWatchList(ImageTexture() \
      .setUSE("leftTexture") \
     ) \
     .setWatchList(ImageTexture() \
      .setUSE("rightTexture") \
     ) \
     .setWatchList(ImageTexture() \
      .setUSE("topTexture") \
     ) \
    ) \
    .addChild(Script() \
     .setDEF("LoadSensorReportScript") \
     .addField(field() \
      .setAccessType("inputOnly") \
      .setName("isActiveUpdate") \
      .setType("SFBool") \
     ) \
     .addField(field() \
      .setAccessType("inputOnly") \
      .setName("isLoadedUpdate") \
      .setType("SFBool") \
     ) \
     .addField(field() \
      .setAccessType("inputOnly") \
      .setName("progressUpdate") \
      .setType("SFFloat") \
     ) \
     .addField(field() \
      .setAccessType("inputOnly") \
      .setName("loadTimeUpdate") \
      .setType("SFTime") \
     ) \
     .addField(field() \
      .setAccessType("inputOnly") \
      .setName("transparencyUpdate") \
      .setType("SFFloat") \
     ) \
.setSourceCode('''\n"+
"ecmascript:\n"+
"\n"+
"function isActiveUpdate (eventValue)\n"+
"{\n"+
"   Browser.println('TextureBackgroundCube LoadSensorReportScript: isActiveUpdate=' + eventValue);\n"+
"}\n"+
"\n"+
"function isLoadedUpdate (eventValue)\n"+
"{\n"+
"   Browser.println('TextureBackgroundCube LoadSensorReportScript: isLoadedUpdate=' + eventValue);\n"+
"}\n"+
"\n"+
"function loadTimeUpdate (eventValue)\n"+
"{\n"+
"   Browser.println('TextureBackgroundCube LoadSensorReportScript: loadTimeUpdate=' + eventValue);\n"+
"}\n"+
"\n"+
"function progressUpdate (eventValue)\n"+
"{\n"+
"   Browser.println('TextureBackgroundCube LoadSensorReportScript: progressUpdate=' + eventValue);\n"+
"}\n"+
"\n"+
"function transparencyUpdate (eventValue)\n"+
"{\n"+
"// pretty busy interpolator\n"+
"// Browser.println('TextureBackgroundCube LoadSensorReportScript: transparencyUpdate=' + eventValue);\n"+
"}\n"+
"''')
    ) \
    .addChild(ROUTE() \
     .setFromField("isActive") \
     .setFromNode("ImageLoadSensor") \
     .setToField("isActiveUpdate") \
     .setToNode("LoadSensorReportScript") \
    ) \
    .addChild(ROUTE() \
     .setFromField("isLoaded") \
     .setFromNode("ImageLoadSensor") \
     .setToField("isLoadedUpdate") \
     .setToNode("LoadSensorReportScript") \
    ) \
    .addChild(ROUTE() \
     .setFromField("loadTime") \
     .setFromNode("ImageLoadSensor") \
     .setToField("loadTimeUpdate") \
     .setToNode("LoadSensorReportScript") \
    ) \
    .addChild(ROUTE() \
     .setFromField("progress") \
     .setFromNode("ImageLoadSensor") \
     .setToField("progressUpdate") \
     .setToNode("LoadSensorReportScript") \
    ) \
    .addChild(ROUTE() \
     .setFromField("value_changed") \
     .setFromNode("TransparencyAnimator") \
     .setToField("transparencyUpdate") \
     .setToNode("LoadSensorReportScript") \
    ) \
    .addChild(Viewpoint() \
     .setDescription("Front image of TextureBackground seen from origin") \
     .setFieldOfView(1.570796) \
     .setPosition([0,0,0]) \
    ) \
    .addChild(Viewpoint() \
     .setDescription("Left image of TextureBackground seen from origin") \
     .setFieldOfView(1.570796) \
     .setOrientation([0,1,0,-1.570796]) \
     .setPosition([0,0,0]) \
    ) \
    .addChild(Viewpoint() \
     .setDescription("Top image of TextureBackground seen from origin") \
     .setFieldOfView(1.570796) \
     .setOrientation([1,0,0,1.570796]) \
     .setPosition([0,0,0]) \
    ) \
    .addChild(Viewpoint() \
     .setDescription("Back image of TextureBackground seen from origin") \
     .setFieldOfView(1.570796) \
     .setOrientation([0,1,0,3.141593]) \
     .setPosition([0,0,0]) \
    ) \
    .addChild(Viewpoint() \
     .setDescription("Right image of TextureBackground seen from origin") \
     .setFieldOfView(1.570796) \
     .setOrientation([0,1,0,1.570796]) \
     .setPosition([0,0,0]) \
    ) \
    .addChild(Viewpoint() \
     .setDescription("Bottom image of TextureBackground seen from origin") \
     .setFieldOfView(1.570796) \
     .setOrientation([1,0,0,-1.570796]) \
     .setPosition([0,0,0]) \
    ) \
   ) \

X3D0.toFileX3D("/x3d-code/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/Visualization//TextureBackgroundCube.newf.x3d")
