<<VRML 2.0 - An Introductory view by examples
Reuse and Prototyping
Prototypes allow users to extent the set of VRML nodes types.
Their definition can be included in the file in which they are used
or they can be defined externally. It allows the encapsulation and
parametrization
of geometry, attributes, behaviors, or some combination thereof.
Usage
Prototype definition and use have the following formats :
- definition format :
- PROTO prototypename [ parameters : list of public eventsIN/Out, fields, exposedFields]
{prototype definition containing Nodes, Routes, others
prototypes. The IS statement can be used.
}
- calling format :
- prototypename {parameters : fields values}
- [example] [run]
External prototype files are defined as follows :
- definition format : uses the same format above and is located somewhere (see the URL address in the example)
- definition example , usage example , run
- definition : PROTO prototypename [parameters] {nodes definition}
- usage : EXTERNPROTO extern-prototypename [parameters] "http://........."
The IS statement is used inside a Prototype definition to associate
a prototype definition parameter to a node parameter. See example.
Instantiation in VRML is accomplished by using the DEF / USE
keywords. This mechanism allows a node to be referenced in a VRML file
multiple times.
Usage
- definition format :
- [DEF (name)] (node type) { (body) }
- calling format : USE name or in a ROUTE statement.
- [example] [run]