Instead of inlining an object, the VRML designer can turn the object into a prototype. The PROTO node allows the designer to convert an object into a node, with fields that allow the designer to manipulate the object. The prototype can be in the main file or in another file and referenced to just like the Inline node. The main difference between the PROTO and Inline options is that the Inline node doesn't allow the designer to change anything about the object. If you inline a helicopter that has it's blades rotating and the entire object moves in a wide circle, that's all it will do. You can place the Inline node as a child of a Transform node and manipulate the Transform node to change the direction or position of the whole copter and its circular route, but you can't redefine the route itself. The Transform node acts on the entire file.
If you turn that same helicopter into a PROTO node, you can change the route, the copter's angle, or even stop the blades from spinning. You would have to define fields that relate to the fields of the manipulating nodes located in the helicopter file. Let's turn our previous moving box into a prototype:
PROTO Moving Box
[ exposedField SFTime speed 4 ]
{ # the nodes of the prototype follows DEF BlueBox Transform
{ rotation 0 1 0 .78
children Shape
{ appearance Appearance
{ material Material
{ diffuseColor 0 0 1 }
} # end Appearance node
geometry Box {size 2 3 5 }
} # end of Shape node
} # end Transform BlueBox DEF BoxTime TimeSensor
{ cycleInterval IS speed
loop TRUE
stopTime -1
} # end TimeSensor BoxTime DEF BoxMovement PositionInterpolator
{ key [ 0, .5, .6, 1]
keyValue [0 0 0, 10 0 0, 10 0 0, 0 0 0]
} # end PositionInterpolator BoxMovement ROUTE BoxTime.fraction TO BoxMovement.fraction
ROUTE BoxMovement.value TO BlueBox.translation
} # end proto node implementation
The box is now a prototype. Note the cycleInterval field in the TimeSensor node. The IS keyword is used to connect the field to the PROTO nodes new userdefined field (speed). This is how you access the fields inside the PROTO node. The field types must match and if the PROTO node has eventIn fields, then they will have to match values in a Script node. To access and manipulate the box prototype, declare a new node of the type of the name that you called the PROTO node. Example:
DEF NewBox MovingBox { speed 10 }
This gives the name NewBox to the node of type MovingBox. By declaring the speed field 10, the box will move very slow. Make the speed 1 and the box will move very fast. Both the PROTO node and the NewBox node are in the same file. But you can put the PROTO node in another file and still reference it. Your main file will now look like this:
EXTERNPROTO MovingBox
[exposedField SFTime speed]
"MovingBox.wrl"
DEF NewBox MovingBox
{ speed 10 }
You now identify the node as EXTERNPROTO and just list the fields. Don't include the initial values for the fields. You then identify the file where there is a PROTO node. The name of the EXTERNPROTO doesn't have to match the name of the PROTO node in the external file. The browser will look up the file you identify and if the node it finds doesn't match field-by-field, it will send an error message. Prototypes are not that hard once you get the hang of it. This box is a very simple example - more advanced prototypes utilize the Script node to implement various coded functions.