diff --git a/source/model/meshinstance.js b/source/model/meshinstance.js index 768df9b..a0c8546 100644 --- a/source/model/meshinstance.js +++ b/source/model/meshinstance.js @@ -17,7 +17,7 @@ OV.MeshInstanceId = class } }; -OV.MeshInstance = class extends OV.Object3D +OV.MeshInstance = class extends OV.ModelObject3D { constructor (node, mesh) { @@ -79,6 +79,21 @@ OV.MeshInstance = class extends OV.Object3D } } + PropertyGroupCount () + { + return this.mesh.PropertyGroupCount (); + } + + AddPropertyGroup (propertyGroup) + { + return this.mesh.AddPropertyGroup (propertyGroup); + } + + GetPropertyGroup (index) + { + return this.mesh.GetPropertyGroup (index); + } + GetTransformedMesh () { let transformation = this.node.GetWorldTransformation (); diff --git a/source/model/model.js b/source/model/model.js index fa8f80b..7c7f85d 100644 --- a/source/model/model.js +++ b/source/model/model.js @@ -116,6 +116,26 @@ OV.Model = class extends OV.ModelObject3D return this.meshes[index]; } + GetMeshInstance (instanceId) + { + let foundNode = null; + this.root.Enumerate ((node) => { + if (node.GetId () === instanceId.nodeId) { + foundNode = node; + } + }); + if (foundNode === null) { + return null; + } + // TODO: check it when every model is hierarchical + // const nodeMeshIndices = foundNode.GetMeshIndices (); + // if (nodeMeshIndices.indexOf (instanceId.meshIndex) === -1) { + // return null; + // } + let foundMesh = this.GetMesh (instanceId.meshIndex); + return new OV.MeshInstance (foundNode, foundMesh); + } + EnumerateMeshes (onMesh) { for (const mesh of this.meshes) { diff --git a/website/o3dv/js/treeview.js b/website/o3dv/js/treeview.js index eb4c309..ca1ac19 100644 --- a/website/o3dv/js/treeview.js +++ b/website/o3dv/js/treeview.js @@ -66,9 +66,13 @@ OV.TreeViewSingleItem = class extends OV.TreeViewItem this.selected = selected; if (this.selected) { this.mainElement.addClass ('selected'); - this.parent.ShowChildren (true, () => { - OV.ScrollToView (this.mainElement); - }); + let parent = this.parent; + while (parent !== null) { + parent.ShowChildren (true, () => { + OV.ScrollToView (this.mainElement); + }); + parent = parent.parent; + } } else { this.mainElement.removeClass ('selected'); } diff --git a/website/o3dv/js/website.js b/website/o3dv/js/website.js index d67a74c..d1ee3a1 100644 --- a/website/o3dv/js/website.js +++ b/website/o3dv/js/website.js @@ -697,7 +697,8 @@ OV.Website = class this.detailsPanel.AddObject3DProperties (this.model); }, onMeshSelected : (meshInstanceId) => { - this.detailsPanel.AddObject3DProperties (this.model.GetMesh (meshInstanceId.meshIndex)); + let meshInstance = this.model.GetMeshInstance (meshInstanceId); + this.detailsPanel.AddObject3DProperties (meshInstance); }, onMaterialSelected : (materialIndex) => { this.detailsPanel.AddMaterialProperties (this.model.GetMaterial (materialIndex));