InitialObjectDescriptor {
  objectDescriptorID 1
  ODProfileLevelIndication 0xFF
  sceneProfileLevelIndication 0xFE
  audioProfileLevelIndication 0xFF
  visualProfileLevelIndication 0xFF
  graphicsProfileLevelIndication 0xFE

  esdescr [
    ES_Descriptor {
      es_id 1
      decConfigDescr DecoderConfigDescriptor {
				streamType 3
				decSpecificInfo BIFSConfig {
				  isCommandStream true
				  pixelMetric true
				  pixelWidth 400
				  pixelHeight 200
				}
      }
    }
  ]
}

OrderedGroup { 
 children [

  Background2D {url "./../auxiliary_files/sky.jpg" }

  WorldInfo {
   title "Layer3D test"
   info ["This shows a Layer3D using the entire window" "and layer2D/layer3D defining a 2D control panel" "" "GPAC Regression Tests" "$Date: 2008-11-24 14:58:25 $ - $Revision: 1.5 $" "(C) 2002-2004 GPAC Team"]
  }

	Shape {
		appearance Appearance { material DEF M2D Material2D {filled TRUE emissiveColor 0 1 0} }
  	geometry Rectangle { size 150 150 }
	}

	Switch {
	  whichChoice 0
		choice [
     Layer3D {
			size 400 200
			navigationInfo DEF NAV NavigationInfo {type ["Walk","ANY"] }
			children [
				DEF BACK Background {frontUrl "./../auxiliary_files/logo.png" }
				Inline {url "./../auxiliary_files/nefertiti.wrl"}
		  ]
		 }
		]
	}
	Layer2D {
		size -1 -1
		children [
			Transform2D {
				translation 0 100
				children [
					Shape {
						appearance DEF TXTAPP Appearance {material Material2D { emissiveColor 0 0 0 filled TRUE } }
						geometry Text {
							string ["This is a Layer3D displaying" "an inline scene with a Layer2D interface"]
							fontStyle DEF FS FontStyle {
								size 18
								justify ["MIDDLE", "BEGIN"]
							}
						}
					}
				]
			}
			Transform2D {
				translation -150 -60
				children [
					Shape {
						appearance Appearance { material DEF MAT_NAV Material2D {filled TRUE emissiveColor 1 0 0} }
						geometry Rectangle { size 20 20 }
					}
					DEF TS_NAV TouchSensor {}
					Transform2D {
						scale 0.8 0.8
						translation 0 -20
						children [
							Shape {
								appearance USE TXTAPP
								geometry DEF TXT_NAV Text {
									string ["Walk"]
									fontStyle USE FS
								}
							}
						]
					}
				]
			}
			Transform2D {
				translation 150 -60
				children [
					Layer3D {
						size 40 40
    				navigationInfo NavigationInfo {type ["Examine"] }
    				viewpoint Viewpoint {position 0 0 40}
						children [
						  Background2D {backColor 1 0 0}
							DEF TR Transform {
								children [
									Shape {
										appearance Appearance { 
#										 material Material { emissiveColor 0 1 0}
                     texture ImageTexture { url "./../auxiliary_files/logo.jpg"}
                    }
										geometry Box { size 20 20 20}
									}
									DEF TS_BACK TouchSensor {}
								]
							}
						]
					}
					Transform2D {
						scale 0.8 0.8
						translation 0 -20
						children [
							Shape {
								appearance USE TXTAPP
								geometry DEF TXT_BACK Text {
									string ["Background Off"]
									fontStyle USE FS
								}
							}
						]
					}
				]
			}
		]
	}

	DEF SC Script {
		eventIn SFBool set_nav
		eventIn SFBool set_back
		field SFNode the_nav USE NAV 
		field SFNode the_back USE BACK
		field SFNode navmat USE MAT_NAV 
		field SFNode navtxt USE TXT_NAV 
		field SFNode backtxt USE TXT_BACK
		url "javascript:
		function initialize(value) {
			nav_set = 0;
			back_set = 0;
		}
		function set_nav(value) {
			if (!value) return;
			if (nav_set) {
				nav_set = 0;
  			navmat.emissiveColor = new SFColor(1, 0, 0);
				navtxt.string[0] = 'Walk';
				the_nav.type[0] = 'Walk';
			} else {
				navmat.emissiveColor = new SFColor(0, 1, 0);
				navtxt.string[0] = 'Examine';
				the_nav.type[0] = 'Examine';
				nav_set = 1;
			}
		}
		function set_back(value) {
			if (!value) return;
			if (back_set) {
				the_back.set_bind = false;
				backtxt.string[0] = 'Background Off';
				back_set = 0;
			} else {
				backtxt.string[0] = 'Background On';
				the_back.set_bind = true;
				back_set = 1;
			}
		}
		"
	}
	
  DEF TIME TimeSensor { cycleInterval 2.0 loop TRUE }
  DEF OI OrientationInterpolator  {
  	key [0 0.5 1]
  	keyValue [1 1 1 0, 1 1 1 3.14, 1 1 1 6.26]
 	}
 ]
}


ROUTE TS_NAV.isActive TO SC.set_nav
ROUTE TS_BACK.isActive TO SC.set_back
ROUTE TIME.fraction_changed TO OI.set_fraction
ROUTE OI.value_changed TO TR.rotation
ROUTE TIME.fraction_changed TO M2D.transparency


AT 100 { REPLACE BACK.set_bind BY 0 }
