From 1fac311c92c8cac8af1ff54651f25ce0e5e01afb Mon Sep 17 00:00:00 2001 From: ijlal99 Date: Sat, 7 Sep 2024 15:59:55 +0500 Subject: [PATCH] Update classes to be documentation friendly --- .../DistanceMeasurement.js | 26 ++++++++++++++++--- .../StoreyViewsPlugin/StoreyViewsPlugin.js | 8 +++++- .../DistanceMeasurement.d.ts | 14 ++++++++++ .../StoreyViewsPlugin/StoreyViewsPlugin.d.ts | 10 +++---- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js b/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js index 3d02a5d13..b96d5a0e9 100644 --- a/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +++ b/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js @@ -240,6 +240,7 @@ class DistanceMeasurement extends Component { this._visible = false; this._originVisible = false; this._targetVisible = false; + this._useRotationAdjustment = false; this._wireVisible = false; this._axisVisible = false; this._xAxisVisible = false; @@ -316,7 +317,7 @@ class DistanceMeasurement extends Component { this.lengthLabelEnabled = cfg.lengthLabelEnabled; this.labelsVisible = cfg.labelsVisible; this.labelsOnWires = cfg.labelsOnWires; - this.useRotationAdjustment = cfg.useRotationAdjustment; + this._useRotationAdjustment = cfg.useRotationAdjustment; /** * @type {number[]} @@ -378,7 +379,7 @@ class DistanceMeasurement extends Component { this._factors = math.transformVec3(this._axesBasis, delta); this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 0); - if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment){ + if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) { this._wp[0] = this._originWorld[0]; this._wp[1] = this._originWorld[1]; this._wp[2] = this._originWorld[2]; @@ -589,7 +590,7 @@ class DistanceMeasurement extends Component { } if (!this._zAxisLabelCulled) { - if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment) { + if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) { this._zAxisLabel.setPrefix(""); this._zAxisLabel.setText(tilde + Math.abs(math.lenVec3(math.subVec3(this._targetWorld, [this._originWorld[0], this._targetWorld[1], this._originWorld[2]], distVec3)) * scale).toFixed(2) + unitAbbrev); } @@ -784,6 +785,25 @@ class DistanceMeasurement extends Component { return this._targetVisible; } + /** + * Sets if the measurement is adjusted based on rotation + * + * @type {Boolean} + */ + set useRotationAdjustment(value) { + value = value !== undefined ? Boolean(value) : this.plugin.useRotationAdjustment; + this._useRotationAdjustment = value; + } + + /** + * Gets if the measurement is adjusted based on rotation + * + * @type {Boolean} + */ + get useRotationAdjustment() { + return this._useRotationAdjustment; + } + /** * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled. * diff --git a/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js b/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js index b2e891777..a86f8a0e0 100644 --- a/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +++ b/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js @@ -702,7 +702,13 @@ class StoreyViewsPlugin extends Plugin { return null; } - isPositionAboveOrBelowBuilding(worldPos){ + /** + * Returns whether a position is above or below a building + * + * @param {Number[]} worldPos 3D World-space position. + * @returns {String} ID of the lowest/highest story or null. + */ + isPositionAboveOrBelowBuilding(worldPos) { const keys = Object.keys(this.storeys); const ids = [keys[0], keys[keys.length-1]]; if(worldPos[1] < this.storeys[ids[0]].storeyAABB[1]) diff --git a/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts b/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts index c02fb687f..a1814d4d4 100644 --- a/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts +++ b/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts @@ -103,6 +103,20 @@ export declare class DistanceMeasurement extends Component { */ get targetVisible(): boolean; + /** + * Sets if the measurement is adjusted based on rotation + * + * @type {Boolean} + */ + set useRotationAdjustment(arg: boolean); + + /** + * Gets if the measurement is adjusted based on rotation + * + * @type {Boolean} + */ + get useRotationAdjustment(): boolean; + /** * Sets if the direct point-to-point wire between {@link DistanceMeasurement.origin} and {@link DistanceMeasurement.target} is visible. * diff --git a/types/plugins/StoreyViewsPlugin/StoreyViewsPlugin.d.ts b/types/plugins/StoreyViewsPlugin/StoreyViewsPlugin.d.ts index 40717208f..93fb56e4a 100644 --- a/types/plugins/StoreyViewsPlugin/StoreyViewsPlugin.d.ts +++ b/types/plugins/StoreyViewsPlugin/StoreyViewsPlugin.d.ts @@ -128,11 +128,11 @@ export declare class StoreyViewsPlugin extends Plugin { /** - * Gets the ID of the storey that contains the given 3D World-space position. - *. - * @param {Number[]} worldPos 3D World-space position. - * @returns {String} ID of the storey containing the position, or null if the position falls outside all the storeys. - */ + * Returns whether a position is above or below a building + * + * @param {Number[]} worldPos 3D World-space position. + * @returns {String} ID of the lowest/highest story or null. + */ isPositionAboveOrBelowBuilding(worldPos: number[]): string; /**