Minor modifications.

This commit is contained in:
kovacsv 2021-12-12 08:43:21 +01:00
parent b186608e69
commit f722723bca
5 changed files with 19 additions and 17 deletions

View File

@ -1,4 +1,5 @@
OV.Eps = 0.00000001; OV.Eps = 0.00000001;
OV.BigEps = 0.0001;
OV.RadDeg = 57.29577951308232; OV.RadDeg = 57.29577951308232;
OV.DegRad = 0.017453292519943; OV.DegRad = 0.017453292519943;

View File

@ -72,7 +72,7 @@ OV.MeasureTool = class
const bNormal = this.GetFaceWorldNormal (b); const bNormal = this.GetFaceWorldNormal (b);
result.pointsDistance = a.point.distanceTo (b.point); result.pointsDistance = a.point.distanceTo (b.point);
result.facesAngle = aNormal.angleTo (bNormal); result.facesAngle = aNormal.angleTo (bNormal);
if (OV.IsEqual (result.facesAngle, 0.0) || OV.IsEqual (result.facesAngle, Math.PI)) { if (OV.IsEqualEps (result.facesAngle, 0.0, OV.BigEps) || OV.IsEqualEps (result.facesAngle, Math.PI, OV.BigEps)) {
let aPlane = new THREE.Plane ().setFromNormalAndCoplanarPoint (aNormal, a.point); let aPlane = new THREE.Plane ().setFromNormalAndCoplanarPoint (aNormal, a.point);
result.parallelFacesDistance = Math.abs (aPlane.distanceToPoint (b.point)); result.parallelFacesDistance = Math.abs (aPlane.distanceToPoint (b.point));
} }

View File

@ -1,6 +1,6 @@
OV.Sidebar = class OV.Sidebar = class
{ {
constructor (mainDiv, splitterDiv, settings) constructor (mainDiv, splitterDiv, settings, measureTool)
{ {
this.mainDiv = mainDiv; this.mainDiv = mainDiv;
this.splitterDiv = splitterDiv; this.splitterDiv = splitterDiv;
@ -8,7 +8,7 @@ OV.Sidebar = class
this.detailsPanel = new OV.SidebarDetailsPanel (this.panelSet.GetContentDiv ()); this.detailsPanel = new OV.SidebarDetailsPanel (this.panelSet.GetContentDiv ());
this.settingsPanel = new OV.SidebarSettingsPanel (this.panelSet.GetContentDiv (), settings); this.settingsPanel = new OV.SidebarSettingsPanel (this.panelSet.GetContentDiv (), settings);
this.measurePanel = new OV.SidebarMeasurePanel (this.panelSet.GetContentDiv ()); this.measurePanel = new OV.SidebarMeasurePanel (this.panelSet.GetContentDiv (), measureTool);
this.panelSet.AddPanel (this.detailsPanel); this.panelSet.AddPanel (this.detailsPanel);
this.panelSet.AddPanel (this.settingsPanel); this.panelSet.AddPanel (this.settingsPanel);
@ -73,9 +73,9 @@ OV.Sidebar = class
this.settingsPanel.UpdateSettings (hasDefaultMaterial); this.settingsPanel.UpdateSettings (hasDefaultMaterial);
} }
UpdateMeasureTool (measureTool) UpdateMeasureTool ()
{ {
this.measurePanel.UpdateMeasureTool (measureTool); this.measurePanel.UpdateMeasureTool ();
} }
Resize (height) Resize (height)

View File

@ -1,9 +1,10 @@
OV.SidebarMeasurePanel = class extends OV.SidebarPanel OV.SidebarMeasurePanel = class extends OV.SidebarPanel
{ {
constructor (parentDiv) constructor (parentDiv, measureTool)
{ {
super (parentDiv); super (parentDiv);
this.measureTool = measureTool;
this.helpSection = null; this.helpSection = null;
this.resultSection = null; this.resultSection = null;
} }
@ -42,7 +43,7 @@ OV.SidebarMeasurePanel = class extends OV.SidebarPanel
this.helpSection.innerHTML = this.GetDefaultHelpText (); this.helpSection.innerHTML = this.GetDefaultHelpText ();
} }
UpdateMeasureTool (measureTool) UpdateMeasureTool ()
{ {
OV.ClearDomElement (this.helpSection); OV.ClearDomElement (this.helpSection);
OV.ClearDomElement (this.resultSection); OV.ClearDomElement (this.resultSection);
@ -50,8 +51,8 @@ OV.SidebarMeasurePanel = class extends OV.SidebarPanel
OV.ShowDomElement (this.helpSection, true); OV.ShowDomElement (this.helpSection, true);
OV.ShowDomElement (this.resultSection, false); OV.ShowDomElement (this.resultSection, false);
if (measureTool.IsActive ()) { if (this.measureTool.IsActive ()) {
let markerCount = measureTool.GetMarkerCount (); let markerCount = this.measureTool.GetMarkerCount ();
if (markerCount === 0) { if (markerCount === 0) {
this.helpSection.innerHTML = 'Click on a model point to start measure.'; this.helpSection.innerHTML = 'Click on a model point to start measure.';
} else if (markerCount === 1) { } else if (markerCount === 1) {
@ -60,12 +61,12 @@ OV.SidebarMeasurePanel = class extends OV.SidebarPanel
OV.ShowDomElement (this.helpSection, false); OV.ShowDomElement (this.helpSection, false);
OV.ShowDomElement (this.resultSection, true); OV.ShowDomElement (this.resultSection, true);
let calculatedValues = measureTool.Calculate (); let calculatedValues = this.measureTool.Calculate ();
OV.AddDiv (this.resultSection, 'ov_sidebar_measure_name', 'Distance of points'); OV.AddDiv (this.resultSection, 'ov_sidebar_measure_name', 'Distance of points');
let pointsDistanceStr = calculatedValues.pointsDistance.toLocaleString (undefined, { let pointsDistanceStr = calculatedValues.pointsDistance.toLocaleString (undefined, {
minimumFractionDigits: 2, minimumFractionDigits: 2,
maximumFractionDigits: 6 maximumFractionDigits: 4
}); });
OV.AddDiv (this.resultSection, 'ov_sidebar_measure_value', pointsDistanceStr); OV.AddDiv (this.resultSection, 'ov_sidebar_measure_value', pointsDistanceStr);
@ -73,7 +74,7 @@ OV.SidebarMeasurePanel = class extends OV.SidebarPanel
if (calculatedValues.parallelFacesDistance !== null) { if (calculatedValues.parallelFacesDistance !== null) {
let facesDistanceStr = calculatedValues.parallelFacesDistance.toLocaleString (undefined, { let facesDistanceStr = calculatedValues.parallelFacesDistance.toLocaleString (undefined, {
minimumFractionDigits: 2, minimumFractionDigits: 2,
maximumFractionDigits: 6 maximumFractionDigits: 4
}); });
OV.AddDiv (this.resultSection, 'ov_sidebar_measure_value', facesDistanceStr); OV.AddDiv (this.resultSection, 'ov_sidebar_measure_value', facesDistanceStr);
} else { } else {
@ -84,7 +85,7 @@ OV.SidebarMeasurePanel = class extends OV.SidebarPanel
let facesAngleDegree = calculatedValues.facesAngle * OV.RadDeg; let facesAngleDegree = calculatedValues.facesAngle * OV.RadDeg;
let facesAngleStr = facesAngleDegree.toLocaleString (undefined, { let facesAngleStr = facesAngleDegree.toLocaleString (undefined, {
minimumFractionDigits: 2, minimumFractionDigits: 2,
maximumFractionDigits: 6 maximumFractionDigits: 4
}); });
OV.AddDiv (this.resultSection, 'ov_sidebar_measure_value', facesAngleStr + '°'); OV.AddDiv (this.resultSection, 'ov_sidebar_measure_value', facesAngleStr + '°');

View File

@ -18,7 +18,7 @@ OV.Website = class
this.cookieHandler = new OV.CookieHandler (); this.cookieHandler = new OV.CookieHandler ();
this.toolbar = new OV.Toolbar (this.parameters.toolbarDiv); this.toolbar = new OV.Toolbar (this.parameters.toolbarDiv);
this.navigator = new OV.Navigator (this.parameters.navigatorDiv, this.parameters.navigatorSplitterDiv); this.navigator = new OV.Navigator (this.parameters.navigatorDiv, this.parameters.navigatorSplitterDiv);
this.sidebar = new OV.Sidebar (this.parameters.sidebarDiv, this.parameters.sidebarSplitterDiv, this.settings); this.sidebar = new OV.Sidebar (this.parameters.sidebarDiv, this.parameters.sidebarSplitterDiv, this.settings, this.measureTool);
this.eventHandler = new OV.EventHandler (this.parameters.eventHandler); this.eventHandler = new OV.EventHandler (this.parameters.eventHandler);
this.modelLoaderUI = new OV.ThreeModelLoaderUI (); this.modelLoaderUI = new OV.ThreeModelLoaderUI ();
this.themeHandler = new OV.ThemeHandler (); this.themeHandler = new OV.ThemeHandler ();
@ -143,7 +143,7 @@ OV.Website = class
this.sidebar.Clear (); this.sidebar.Clear ();
this.measureTool.Clear (); this.measureTool.Clear ();
this.sidebar.UpdateMeasureTool (this.measureTool); this.sidebar.UpdateMeasureTool ();
} }
OnModelLoaded (importResult, threeObject) OnModelLoaded (importResult, threeObject)
@ -165,7 +165,7 @@ OV.Website = class
if (this.measureTool.IsActive ()) { if (this.measureTool.IsActive ()) {
this.measureTool.Click (mouseCoordinates); this.measureTool.Click (mouseCoordinates);
this.sidebar.UpdateMeasureTool (this.measureTool); this.sidebar.UpdateMeasureTool ();
return; return;
} }
@ -596,7 +596,7 @@ OV.Website = class
} else { } else {
this.measureTool.SetActive (false); this.measureTool.SetActive (false);
} }
this.sidebar.UpdateMeasureTool (this.measureTool); this.sidebar.UpdateMeasureTool ();
}, },
onResize : () => { onResize : () => {
this.Resize (); this.Resize ();