#VRML V2.0 utf8 Proto Tree3 with textures, Evgeny Demidov, 4 Dec 2000 NavigationInfo{ type "EXAMINE" } Background{ skyColor .5 .5 1} PROTO Tree3[ field SFInt32 order 3 field SFVec3f TrunkSc 1 1 1 field SFVec3f BranchSc .5 .5 .5 field SFRotation Rot 1 0 0 1 ]{ DEF ROOT Transform{ scale 4 4 4 translation 0 -4 0 children[]} DEF Polyhedron Script { eventOut MFNode new_f field SFNode ROOT USE ROOT field SFInt32 MaxIt IS order field SFRotation Rot IS Rot field SFVec3f TrunkSc IS TrunkSc field SFVec3f BranchSc IS BranchSc directOutput TRUE url ["javascript: function initialize(){ str = 'DEF L0 Shape{ appearance Appearance{ material Material{} '+ 'texture ImageTexture{ url \"leaf.png\" }} '+ 'geometry IndexedFaceSet{ solid FALSE '+ 'coord Coordinate{ point[0 1 0,.7 1.5 -.5,0 2 -1,-.7 1.5 -.5]} '+ 'texCoord TextureCoordinate{ point[0 0,1 0,1 1,0 1]} coordIndex[0 1 2 3]}} '+ 'Transform{ rotation 0 1 0 3.14 translation 0 1 0 children USE L0} '+ 'DEF B0 Shape{ appearance Appearance{ material Material{ emissiveColor .5 .5 0}} '+ 'geometry IndexedLineSet{ coord Coordinate{ point[0 0 0,0 2 0]} '+ 'coordIndex[0 1]}}'; for ( i= 1; i<=MaxIt; i++) str = 'Transform{ translation 0 1 0 children '+ 'DEF s'+i+' Transform{ scale '+BranchSc+' children[ '+ str + ']} } Transform{ scale .5 .5 .5 children trunk{}} '+ 'DEF g'+i+' Transform{ rotation '+Rot+' translation 0 1 0 children USE s'+i+'} '+ 'Transform{ rotation 0 1 0 2.09 children USE g'+i+'} '+ 'Transform{ rotation 0 1 0 -2.09 children USE g'+i+'}'; new_f = Browser.createVrmlFromString( 'PROTO trunk[]{Transform{ scale '+TrunkSc+' children[ '+ 'Shape{ appearance Appearance{ material Material{ diffuseColor 1 1 1} '+ 'texture ImageTexture{ url \"birch.png\" } } '+ 'geometry IndexedFaceSet{ coord Coordinate{ '+ 'point[.2 0 0,.1 0 -.17,-.1 0 -.17,-.2 0 0,-.1 0 .17,.1 0 .17, '+ '.1 2 0,.05 2 -.09,-.05 2 -.09,-.1 2 0,-.05 2 .09,.05 2 .09]} '+ 'coordIndex[0 1 7 6 -1 1 2 8 7 -1 2 3 9 8 -1 3 4 10 9 -1 4 5 11 10 -1 5 0 6 11] '+ 'texCoord TextureCoordinate{ '+ 'point[0 0,.2 0,.3 0,.4 0,.6 0,.8 0,1 0, 0 1,.2 1,.3 1,.4 1,.6 1,.8 1,1 1]} '+ 'texCoordIndex[0 1 8 7 -1 1 2 9 8 -1 2 3 10 9 -1 3 4 11 10 -1 4 5 12 11 -1 5 6 13 12] '+ ' creaseAngle 2}}]}} ' + str ); ROOT.addChildren = new_f; } "]} } Tree3{order 5 }