} else if ("node".equals(parent) && "instance_geometry".equals(name)) {
String geometryInstanceUrl = attributes.getValue("url");
if (geometryInstanceUrl.startsWith("#")) {
final String geometryInstanceAnchor = geometryInstanceUrl.substring(1);
final String nodeName = attributes.getValue("name");
final Group parentGroup = new Group();
this.parentGroups.peek().addChild(parentGroup);
this.parentGroups.push(parentGroup);
this.postProcessingBinders.add(new Runnable() {
public void run() {
int nameSuffix = 0;
// Resolve URL at the end of the document
for (Geometry geometry : geometries.get(geometryInstanceAnchor)) {
Shape3D shape = new Shape3D(geometry);
parentGroup.addChild(shape);
// Give a name to shape
if (nodeName != null) {
if (nameSuffix == 0) {
scene.addNamedObject(nodeName, shape);
} else {
scene.addNamedObject(nodeName + "_" + nameSuffix, shape);
}
nameSuffix++;
}
}
}
});
}
} else if ("instance_node".equals(name)) {
String nodeInstanceUrl = attributes.getValue("url");
if (nodeInstanceUrl.startsWith("#")) {
final String nodeInstanceAnchor = nodeInstanceUrl.substring(1);
final Group parentTransformGroup = this.parentGroups.peek();
this.postProcessingBinders.add(new Runnable() {
public void run() {
// Resolve URL at the end of the document
SharedGroup sharedGroup = instantiatedNodes.get(nodeInstanceAnchor);
if (sharedGroup == null) {
sharedGroup = new SharedGroup();
sharedGroup.addChild(nodes.get(nodeInstanceAnchor));
instantiatedNodes.put(nodeInstanceAnchor, sharedGroup);
}
parentTransformGroup.addChild(new Link(sharedGroup));
}
});
}
} else if ("instance_material".equals(name) && !this.parentGroups.empty()) {
String materialInstanceTarget = attributes.getValue("target");
if (materialInstanceTarget.startsWith("#")) {
final String materialInstanceAnchor = materialInstanceTarget.substring(1);
final String materialInstanceSymbol = attributes.getValue("symbol");
final Group group = this.parentGroups.peek();
this.postProcessingBinders.add(new Runnable() {
public void run() {
updateShapeAppearance(group,
effectAppearances.get(materialEffects.get(materialInstanceAnchor)));
}