Skip to content

Commit 99c76dd

Browse files
authored
Keep original object and material names in Web Viewer (AcademySoftwareFoundation#2445)
Previously, object names were taken directly from the three.js scene. However, three.js enforces specific constraints for object names (e.g. spaces, braces and so on are replaced with `_`). This renaming breaks DAG matching for geom expressions, as the compared name might not be right. three.js keeps the original name around though, so this PR makes sure the original name is used for path matching instead of the in-scene name. The PR also sets the material name properly from the `materialassign` instead of keeping it empty.
1 parent c33985f commit 99c76dd

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

javascript/MaterialXView/source/viewer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export class Scene
313313
{
314314
const rootNode = this.#_rootNode;
315315

316-
let path = [node.name];
316+
let path = [node.userData?.name || node.name];
317317
while (node.parent)
318318
{
319319
node = node.parent;
@@ -324,7 +324,7 @@ export class Scene
324324
{
325325
break;
326326
}
327-
path.unshift(node.name);
327+
path.unshift(node.userData?.name || node.name);
328328
}
329329
}
330330
return path;
@@ -900,7 +900,7 @@ export class Material
900900
assigned += viewer.getScene().updateMaterial(matassign);
901901
matassign.setGeometry(temp);
902902
assignedSolo = true;
903-
break
903+
break;
904904
}
905905
}
906906
else
@@ -993,7 +993,8 @@ export class Material
993993
blendEquation: THREE.AddEquation,
994994
blendSrc: THREE.OneMinusSrcAlphaFactor,
995995
blendDst: THREE.SrcAlphaFactor,
996-
side: THREE.DoubleSide
996+
side: THREE.DoubleSide,
997+
name: elem.getName(),
997998
});
998999

9991000
if (logDetailedTime)

0 commit comments

Comments
 (0)