Calculate geometric values based on mesh instances.

This commit is contained in:
kovacsv 2021-10-26 18:54:51 +02:00
parent 7eac7dee43
commit ad132b2eed
4 changed files with 45 additions and 5 deletions

View File

@ -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 ();

View File

@ -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) {

View File

@ -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');
}

View File

@ -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));