| 1 |
#X3D V3.0 utf8 |
| 2 |
PROFILE Interchange |
| 3 |
|
| 4 |
# All VRML versions allow non-unique node names. |
| 5 |
# Each DEF XXX overrides all previous ("previous" in lexical sense, |
| 6 |
# i.e. normal order of tokens in the file) DEF XXX with the same XXX, |
| 7 |
# thus hiding previous node name "XXX". |
| 8 |
# X3D doesn't advice it, but it's still allowed. |
| 9 |
# |
| 10 |
# One problem with non-unique names |
| 11 |
# is when saving: you have to be very careful about the order of ROUTE, PROTO, |
| 12 |
# normal nodes' declarations and pretty much everything else. |
| 13 |
# Almost everything can use some node name. Even PROTOs interface |
| 14 |
# declarations, or Script/shaders interface declarations depend |
| 15 |
# on current node binding, as default values for SFNode/MFNode |
| 16 |
# fields may modify/use node name binding by DEF/USE. |
| 17 |
# |
| 18 |
# This means that when reading and then writing VRML file, we have to be |
| 19 |
# careful to use the same order, otherwise it could be impossible |
| 20 |
# to keep the same DEF/USE sharing of nodes. (And for ROUTEs, it could |
| 21 |
# be impossible at all to save them, since ROUTE always must be specified |
| 22 |
# when appropriate node names are bound). |
| 23 |
|
| 24 |
# ---------------------------------------------------------------------------- |
| 25 |
# Define yellow sphere under XXX name |
| 26 |
|
| 27 |
DEF XXXTransform Transform { |
| 28 |
children [ |
| 29 |
|
| 30 |
Transform { |
| 31 |
translation 0 2 0 |
| 32 |
children [ |
| 33 |
DEF XXXTouch TouchSensor { } |
| 34 |
Shape { geometry Text { string "yellow" } } |
| 35 |
] |
| 36 |
} |
| 37 |
|
| 38 |
DEF XXX Shape { |
| 39 |
geometry Sphere { } |
| 40 |
appearance Appearance { material DEF XXXMat Material { diffuseColor 1 1 0 } } |
| 41 |
} |
| 42 |
] |
| 43 |
} |
| 44 |
|
| 45 |
# This isn't really any sensible ROUTE, it's just to test keeping proper binding. |
| 46 |
ROUTE XXXTouch.hitPoint_changed TO XXXTransform.translation |
| 47 |
|
| 48 |
# ---------------------------------------------------------------------------- |
| 49 |
# Use yellow sphere from XXX name |
| 50 |
|
| 51 |
PROTO YellowSphereByDefault [ |
| 52 |
inputOutput MFNode node USE XXX |
| 53 |
] { |
| 54 |
Group { children IS node } |
| 55 |
} |
| 56 |
|
| 57 |
# ---------------------------------------------------------------------------- |
| 58 |
# Define blue sphere under the same XXX name |
| 59 |
# (should override previous name) |
| 60 |
|
| 61 |
DEF XXXTransform Transform { |
| 62 |
translation 4 0 0 |
| 63 |
children [ |
| 64 |
|
| 65 |
Transform { |
| 66 |
translation 0 2 0 |
| 67 |
children [ |
| 68 |
DEF XXXTouch TouchSensor { } |
| 69 |
Shape { geometry Text { string "blue" } } |
| 70 |
] |
| 71 |
} |
| 72 |
|
| 73 |
DEF XXX Shape { |
| 74 |
geometry Sphere { } |
| 75 |
appearance Appearance { material Material { diffuseColor 0 0 1 } } |
| 76 |
} |
| 77 |
] |
| 78 |
} |
| 79 |
|
| 80 |
# This isn't really any sensible ROUTE, it's just to test keeping proper binding. |
| 81 |
ROUTE XXXTouch.hitPoint_changed TO XXXTransform.translation |
| 82 |
|
| 83 |
# ---------------------------------------------------------------------------- |
| 84 |
# Use blue sphere from XXX name |
| 85 |
|
| 86 |
PROTO BlueSphereByDefault [ |
| 87 |
inputOutput MFNode node USE XXX |
| 88 |
] { |
| 89 |
Group { children IS node } |
| 90 |
} |
| 91 |
|
| 92 |
# ---------------------------------------------------------------------------- |
| 93 |
# Test PROTOs using XXX name |
| 94 |
|
| 95 |
Transform { |
| 96 |
translation 8 0 0 |
| 97 |
children [ |
| 98 |
|
| 99 |
Transform { |
| 100 |
translation 0 2 0 |
| 101 |
children Shape { geometry Text { string "yellow" } } |
| 102 |
} |
| 103 |
|
| 104 |
YellowSphereByDefault { } |
| 105 |
] |
| 106 |
} |
| 107 |
|
| 108 |
Transform { |
| 109 |
translation 12 0 0 |
| 110 |
children [ |
| 111 |
|
| 112 |
Transform { |
| 113 |
translation 0 2 0 |
| 114 |
children Shape { geometry Text { string "blue" } } |
| 115 |
} |
| 116 |
|
| 117 |
BlueSphereByDefault { } |
| 118 |
] |
| 119 |
} |