Skip to content

Commit

Permalink
Merge pull request #1657 from xeokit/update-documentation
Browse files Browse the repository at this point in the history
Update classes to be documentation friendly
  • Loading branch information
xeolabs authored Sep 7, 2024
2 parents 86ebeb4 + 1fac311 commit f5f5f97
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
26 changes: 23 additions & 3 deletions src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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[]}
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
*
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
14 changes: 14 additions & 0 deletions types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 5 additions & 5 deletions types/plugins/StoreyViewsPlugin/StoreyViewsPlugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down

0 comments on commit f5f5f97

Please sign in to comment.