#VRML V2.0 utf8

# prototype for a diffuse RGB image textured surface
PROTO RGBTexturedDiffuseSurface [
  exposedField SFNode texture NULL
  exposedField SFNode textureTransform NULL
  exposedField SFNode textureProjection NULL
] {
   PROTO DiffuseRed [] {
      PROTO red [] { PhBLxySpectrum { xy 0.64 0.33 } }
      PhBHomogeneousSurface {
	 bsdf [ PhBSimpleBSDF { spectrum red {}   scatterer PhBDiffuseReflector {} } ]
      }
   }
   PROTO DiffuseGreen [] {
      PROTO green [] { PhBLxySpectrum { xy 0.29 0.60 } }
      PhBHomogeneousSurface {
	 bsdf [ PhBSimpleBSDF { spectrum green {}  scatterer PhBDiffuseReflector {} } ]
      }
   }
   PROTO DiffuseBlue [] {
      PROTO blue  [] { PhBLxySpectrum { xy 0.15 0.06 } }
      PhBHomogeneousSurface {
	 bsdf [ PhBSimpleBSDF { spectrum blue {}   scatterer PhBDiffuseReflector {} } ]
      }
   }
   PhBTexturedSurface {
      texture IS texture
      surfaces [ DiffuseRed {}, DiffuseGreen {}, DiffuseBlue {}]
      textureTransform IS textureTransform
      textureProjection IS textureProjection
   }
}

# use it like this:
Transform {
   children [  Shape {
      appearance DEF text1 PhBAppearance {
	 surface RGBTexturedDiffuseSurface {
	    texture PhBImageTexture { url "file:image.gif" }
	 }
      }
      geometry Sphere {}
   }, Transform {
      children Shape {
	 appearance USE text1
	 geometry Box {}
      } 
      translation 5 0 0
   } ]
}
