diff --git a/website/include/importerapp.js b/website/include/importerapp.js index 24e48e9..5f768b4 100644 --- a/website/include/importerapp.js +++ b/website/include/importerapp.js @@ -468,11 +468,7 @@ ImporterApp.prototype.SetView = function (viewType) ImporterApp.prototype.ShowHideMesh = function (meshIndex) { this.meshVisibility[meshIndex] = !this.meshVisibility[meshIndex]; - if (this.meshVisibility[meshIndex]) { - this.viewer.ShowMesh (meshIndex); - } else { - this.viewer.HideMesh (meshIndex); - } + this.viewer.ShowMesh (meshIndex, this.meshVisibility[meshIndex]); return this.meshVisibility[meshIndex]; }; @@ -544,18 +540,27 @@ ImporterApp.prototype.RegisterCanvasClick = function (canvasName) ImporterApp.prototype.HighlightMesh = function (meshIndex) { - var i, menuItem; + function HighlightMeshInModel (viewer, meshIndex, highlight) + { + viewer.HighlightMesh (meshIndex, highlight); + } + + var i, menuItem, highlight; for (i = 0; i < this.meshMenuItems.length; i++) { menuItem = this.meshMenuItems[i]; + highlight = false; if (i == meshIndex) { if (!menuItem.IsHighlighted ()) { menuItem.Highlight (true); menuItem.menuItemDiv.get (0).scrollIntoView (); + HighlightMeshInModel (this.viewer, i, true); } else { menuItem.Highlight (false); + HighlightMeshInModel (this.viewer, i, false); } - } else { + } else if (menuItem.IsHighlighted ()) { menuItem.Highlight (false); + HighlightMeshInModel (this.viewer, i, false); } } }; diff --git a/website/include/importerviewer.js b/website/include/importerviewer.js index 3b8d4de..e7a7471 100644 --- a/website/include/importerviewer.js +++ b/website/include/importerviewer.js @@ -83,26 +83,34 @@ ImporterViewer.prototype.GetMeshesUnderPosition = function (x, y) return meshes; }; -ImporterViewer.prototype.ShowMesh = function (index) +ImporterViewer.prototype.ShowMesh = function (index, show) { var myThis = this; this.viewer.scene.traverse (function (current) { if (current instanceof THREE.Mesh) { if (current.originalJsonIndex == index) { - myThis.viewer.ShowMesh (current); + if (show) { + myThis.viewer.ShowMesh (current); + } else { + myThis.viewer.HideMesh (current); + } } } }); this.viewer.Draw (); }; -ImporterViewer.prototype.HideMesh = function (index) +ImporterViewer.prototype.HighlightMesh = function (index, highlight) { var myThis = this; this.viewer.scene.traverse (function (current) { if (current instanceof THREE.Mesh) { if (current.originalJsonIndex == index) { - myThis.viewer.HideMesh (current); + if (highlight) { + current.material.emissive.setHex (0x555555); + } else { + current.material.emissive.setHex (0); + } } } });