Remove unnecessary callback from info panel calculation.
This commit is contained in:
parent
7c5a1d263b
commit
921c2a9040
@ -96,7 +96,7 @@ OV.InfoPanel = class
|
||||
});
|
||||
}
|
||||
|
||||
FillWithModelInfo (info, getMaterialInfo, callbacks)
|
||||
FillWithModelInfo (info, callbacks)
|
||||
{
|
||||
function AddCounter (parent, name, value)
|
||||
{
|
||||
@ -124,10 +124,10 @@ OV.InfoPanel = class
|
||||
|
||||
let materialItems = [];
|
||||
for (let i = 0; i < info.usedMaterials.length; i++) {
|
||||
let materialInfo = getMaterialInfo (info.usedMaterials[i]);
|
||||
let usedMaterial = info.usedMaterials[i];
|
||||
materialItems.push ({
|
||||
name : OV.GetMaterialName (materialInfo.name),
|
||||
color : OV.ColorToHexString (materialInfo.diffuse)
|
||||
name : OV.GetMaterialName (usedMaterial.name),
|
||||
color : OV.ColorToHexString (usedMaterial.diffuse)
|
||||
});
|
||||
}
|
||||
|
||||
@ -136,10 +136,11 @@ OV.InfoPanel = class
|
||||
this.CreateButton (contentDiv, materialsText, function (button) {
|
||||
obj.popup = OV.ShowListPopup (button, materialItems, {
|
||||
onClick : function (index) {
|
||||
callbacks.onMaterialSelect (info.usedMaterials[index]);
|
||||
let usedMaterial = info.usedMaterials[index];
|
||||
callbacks.onMaterialSelect (usedMaterial.index);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CreateButton (parentDiv, buttonText, onClick)
|
||||
|
||||
@ -221,11 +221,7 @@ OV.Menu = class
|
||||
let obj = this;
|
||||
if (this.selection === null) {
|
||||
let modelInfo = this.callbacks.getModelInformation ();
|
||||
modelInfo.usedMaterials = [];
|
||||
for (let i = 0; i < this.modelData.MaterialCount (); i++) {
|
||||
modelInfo.usedMaterials.push (i);
|
||||
}
|
||||
this.infoPanel.FillWithModelInfo (modelInfo, this.callbacks.getMaterialInformation, {
|
||||
this.infoPanel.FillWithModelInfo (modelInfo, {
|
||||
onMaterialSelect : function (materialIndex) {
|
||||
obj.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
|
||||
}
|
||||
@ -243,7 +239,7 @@ OV.Menu = class
|
||||
});
|
||||
} else if (this.selection.type === OV.SelectionType.Mesh) {
|
||||
let meshInfo = this.callbacks.getMeshInformation (this.selection.index);
|
||||
this.infoPanel.FillWithModelInfo (meshInfo, this.callbacks.getMaterialInformation, {
|
||||
this.infoPanel.FillWithModelInfo (meshInfo, {
|
||||
onMaterialSelect : function (materialIndex) {
|
||||
obj.SetSelection (new OV.Selection (OV.SelectionType.Material, materialIndex));
|
||||
}
|
||||
|
||||
@ -423,6 +423,16 @@ OV.Website = class
|
||||
return materialInfo;
|
||||
}
|
||||
|
||||
function GetMaterialReferenceInfo (model, materialIndex)
|
||||
{
|
||||
const material = model.GetMaterial (materialIndex);
|
||||
return {
|
||||
index : materialIndex,
|
||||
name : material.name,
|
||||
diffuse : material.diffuse.Clone ()
|
||||
};
|
||||
}
|
||||
|
||||
function GetMeshInfo (viewer, model, meshIndex)
|
||||
{
|
||||
let result = {
|
||||
@ -439,8 +449,14 @@ OV.Website = class
|
||||
result.triangleCount = mesh.TriangleCount ();
|
||||
|
||||
let userData = GetMeshUserData (viewer, meshIndex);
|
||||
result.usedMaterials = userData.originalMaterials;
|
||||
result.usedMaterials.sort ();
|
||||
result.usedMaterials = [];
|
||||
for (let i = 0; i < userData.originalMaterials.length; i++) {
|
||||
const materialIndex = userData.originalMaterials[i];
|
||||
result.usedMaterials.push (GetMaterialReferenceInfo (model, materialIndex));
|
||||
}
|
||||
result.usedMaterials.sort (function (a, b) {
|
||||
return a.index - b.index;
|
||||
});
|
||||
|
||||
let boundingBox = viewer.GetBoundingBox (function (meshUserData) {
|
||||
return meshUserData.originalMeshIndex === meshIndex;
|
||||
@ -461,6 +477,10 @@ OV.Website = class
|
||||
let boundingBox = viewer.GetBoundingBox (function (meshUserData) {
|
||||
return true;
|
||||
});
|
||||
result.usedMaterials = [];
|
||||
for (let materialIndex = 0; materialIndex < model.MaterialCount (); materialIndex++) {
|
||||
result.usedMaterials.push (GetMaterialReferenceInfo (model, materialIndex));
|
||||
}
|
||||
result.boundingBox = GetBoundingBoxInfo (boundingBox);
|
||||
return result;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user