@xeokit/xeokit-sdk 2.5.2-beta-20 → 2.5.2-beta-21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +180 -6
- package/dist/xeokit-sdk.es.js +180 -7
- package/dist/xeokit-sdk.es5.js +133 -6
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +43 -6
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +4 -0
- package/src/viewer/scene/geometry/builders/buildBoxLinesGeometry.js +133 -1
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.d.ts +14 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +4 -0
package/package.json
CHANGED
|
@@ -241,6 +241,7 @@ class DistanceMeasurement extends Component {
|
|
|
241
241
|
this._zAxisVisible = false;
|
|
242
242
|
this._axisEnabled = true;
|
|
243
243
|
this._labelsVisible = false;
|
|
244
|
+
this._labelsOnWires = false;
|
|
244
245
|
this._clickable = false;
|
|
245
246
|
|
|
246
247
|
this._originMarker.on("worldPos", (value) => {
|
|
@@ -300,6 +301,7 @@ class DistanceMeasurement extends Component {
|
|
|
300
301
|
this.yAxisVisible = cfg.yAxisVisible;
|
|
301
302
|
this.zAxisVisible = cfg.zAxisVisible;
|
|
302
303
|
this.labelsVisible = cfg.labelsVisible;
|
|
304
|
+
this.labelsOnWires = cfg.labelsOnWires;
|
|
303
305
|
}
|
|
304
306
|
|
|
305
307
|
_update() {
|
|
@@ -451,9 +453,19 @@ class DistanceMeasurement extends Component {
|
|
|
451
453
|
|
|
452
454
|
this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);
|
|
453
455
|
|
|
454
|
-
this.
|
|
455
|
-
|
|
456
|
-
|
|
456
|
+
if (this.labelsOnWires) {
|
|
457
|
+
this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
|
|
458
|
+
this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
|
|
459
|
+
this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
|
|
460
|
+
} else {
|
|
461
|
+
const labelOffset = 35;
|
|
462
|
+
let currentLabelOffset = labelOffset;
|
|
463
|
+
this._xAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
|
|
464
|
+
currentLabelOffset += labelOffset;
|
|
465
|
+
this._yAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
|
|
466
|
+
currentLabelOffset += labelOffset;
|
|
467
|
+
this._zAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
|
|
468
|
+
}
|
|
457
469
|
|
|
458
470
|
const tilde = this._approximate ? " ~ " : " = ";
|
|
459
471
|
|
|
@@ -466,9 +478,15 @@ class DistanceMeasurement extends Component {
|
|
|
466
478
|
|
|
467
479
|
const labelMinAxisLength = this.plugin.labelMinAxisLength;
|
|
468
480
|
|
|
469
|
-
this.
|
|
470
|
-
|
|
471
|
-
|
|
481
|
+
if (this.labelsOnWires){
|
|
482
|
+
this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
|
|
483
|
+
this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
|
|
484
|
+
this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
|
|
485
|
+
} else {
|
|
486
|
+
this._xAxisLabelCulled = false;
|
|
487
|
+
this._yAxisLabelCulled = false;
|
|
488
|
+
this._zAxisLabelCulled = false;
|
|
489
|
+
}
|
|
472
490
|
|
|
473
491
|
if (!this._xAxisLabelCulled) {
|
|
474
492
|
this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
|
|
@@ -869,6 +887,25 @@ class DistanceMeasurement extends Component {
|
|
|
869
887
|
return this._labelsVisible;
|
|
870
888
|
}
|
|
871
889
|
|
|
890
|
+
/**
|
|
891
|
+
* Sets if labels should be positioned on the wires.
|
|
892
|
+
*
|
|
893
|
+
* @type {Boolean}
|
|
894
|
+
*/
|
|
895
|
+
set labelsOnWires(value) {
|
|
896
|
+
value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsOnWires;
|
|
897
|
+
this._labelsOnWires = value;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Gets if labels should be positioned on the wires.
|
|
902
|
+
*
|
|
903
|
+
* @type {Boolean}
|
|
904
|
+
*/
|
|
905
|
+
get labelsOnWires() {
|
|
906
|
+
return this._labelsOnWires;
|
|
907
|
+
}
|
|
908
|
+
|
|
872
909
|
/**
|
|
873
910
|
* Sets if this DistanceMeasurement appears highlighted.
|
|
874
911
|
* @param highlighted
|
|
@@ -242,6 +242,7 @@ class DistanceMeasurementsPlugin extends Plugin {
|
|
|
242
242
|
* @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
|
|
243
243
|
* @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
|
|
244
244
|
* @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
|
|
245
|
+
* @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
|
|
245
246
|
* @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
|
|
246
247
|
*/
|
|
247
248
|
constructor(viewer, cfg = {}) {
|
|
@@ -269,6 +270,7 @@ class DistanceMeasurementsPlugin extends Plugin {
|
|
|
269
270
|
this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
|
|
270
271
|
this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
|
|
271
272
|
this.zIndex = cfg.zIndex || 10000;
|
|
273
|
+
this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
|
|
272
274
|
|
|
273
275
|
this._onMouseOver = (event, measurement) => {
|
|
274
276
|
this.fire("mouseOver", {
|
|
@@ -391,6 +393,7 @@ class DistanceMeasurementsPlugin extends Plugin {
|
|
|
391
393
|
* @param {Boolean} [params.zAxisVisible=true] Whether to initially show the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
|
|
392
394
|
* @param {Boolean} [params.labelsVisible=true] Whether to initially show the labels.
|
|
393
395
|
* @param {string} [params.color] The color of the length dot, wire and label.
|
|
396
|
+
* @param {Boolean} [params.labelsOnWires=true] Determines if labels will be set on wires or one below the other.
|
|
394
397
|
* @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
|
|
395
398
|
*/
|
|
396
399
|
createMeasurement(params = {}) {
|
|
@@ -422,6 +425,7 @@ class DistanceMeasurementsPlugin extends Plugin {
|
|
|
422
425
|
originVisible: params.originVisible,
|
|
423
426
|
targetVisible: params.targetVisible,
|
|
424
427
|
color: params.color,
|
|
428
|
+
labelsOnWires: params.labelsOnWires !== false && this.defaultLabelsOnWires !== false,
|
|
425
429
|
onMouseOver: this._onMouseOver,
|
|
426
430
|
onMouseLeave: this._onMouseLeave,
|
|
427
431
|
onContextMenu: this._onContextMenu
|
|
@@ -103,4 +103,136 @@ function buildBoxLinesGeometry(cfg = {}) {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
/**
|
|
107
|
+
* @desc Creates a box-shaped lines {@link Geometry} from AABB.
|
|
108
|
+
*
|
|
109
|
+
* ## Usage
|
|
110
|
+
*
|
|
111
|
+
* In the example below we'll create a {@link Mesh} with a box-shaped {@link ReadableGeometry} that has lines primitives.
|
|
112
|
+
* This box will be created from AABB of a model.
|
|
113
|
+
*
|
|
114
|
+
* [[Run this example](/examples/#geometry_builders_buildBoxLinesGeometryFromAABB)]
|
|
115
|
+
*
|
|
116
|
+
* ````javascript
|
|
117
|
+
* import {Viewer, Mesh, Node, buildBoxGeometry, buildBoxLinesGeometryFromAABB, ReadableGeometry, PhongMaterial} from "../../dist/xeokit-sdk.min.es.js";
|
|
118
|
+
*
|
|
119
|
+
* const viewer = new Viewer({
|
|
120
|
+
* canvasId: "myCanvas"
|
|
121
|
+
* });
|
|
122
|
+
*
|
|
123
|
+
* viewer.scene.camera.eye = [-21.80, 4.01, 6.56];
|
|
124
|
+
* viewer.scene.camera.look = [0, -5.75, 0];
|
|
125
|
+
* viewer.scene.camera.up = [0.37, 0.91, -0.11];
|
|
126
|
+
*
|
|
127
|
+
* const boxGeometry = new ReadableGeometry(viewer.scene, buildBoxGeometry({
|
|
128
|
+
* xSize: 1,
|
|
129
|
+
* ySize: 1,
|
|
130
|
+
* zSize: 1
|
|
131
|
+
* }));
|
|
132
|
+
*
|
|
133
|
+
* new Node(viewer.scene, {
|
|
134
|
+
* id: "table",
|
|
135
|
+
* isModel: true, // <--------------------- Node represents a model
|
|
136
|
+
* rotation: [0, 50, 0],
|
|
137
|
+
* position: [0, 0, 0],
|
|
138
|
+
* scale: [1, 1, 1],
|
|
139
|
+
*
|
|
140
|
+
* children: [
|
|
141
|
+
*
|
|
142
|
+
* new Mesh(viewer.scene, { // Red table leg
|
|
143
|
+
* id: "redLeg",
|
|
144
|
+
* isObject: true, // <---------- Node represents an object
|
|
145
|
+
* position: [-4, -6, -4],
|
|
146
|
+
* scale: [1, 3, 1],
|
|
147
|
+
* rotation: [0, 0, 0],
|
|
148
|
+
* geometry: boxGeometry,
|
|
149
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
150
|
+
* diffuse: [1, 0.3, 0.3]
|
|
151
|
+
* })
|
|
152
|
+
* }),
|
|
153
|
+
*
|
|
154
|
+
* new Mesh(viewer.scene, { // Green table leg
|
|
155
|
+
* id: "greenLeg",
|
|
156
|
+
* isObject: true, // <---------- Node represents an object
|
|
157
|
+
* position: [4, -6, -4],
|
|
158
|
+
* scale: [1, 3, 1],
|
|
159
|
+
* rotation: [0, 0, 0],
|
|
160
|
+
* geometry: boxGeometry,
|
|
161
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
162
|
+
* diffuse: [0.3, 1.0, 0.3]
|
|
163
|
+
* })
|
|
164
|
+
* }),
|
|
165
|
+
*
|
|
166
|
+
* new Mesh(viewer.scene, {// Blue table leg
|
|
167
|
+
* id: "blueLeg",
|
|
168
|
+
* isObject: true, // <---------- Node represents an object
|
|
169
|
+
* position: [4, -6, 4],
|
|
170
|
+
* scale: [1, 3, 1],
|
|
171
|
+
* rotation: [0, 0, 0],
|
|
172
|
+
* geometry: boxGeometry,
|
|
173
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
174
|
+
* diffuse: [0.3, 0.3, 1.0]
|
|
175
|
+
* })
|
|
176
|
+
* }),
|
|
177
|
+
*
|
|
178
|
+
* new Mesh(viewer.scene, { // Yellow table leg
|
|
179
|
+
* id: "yellowLeg",
|
|
180
|
+
* isObject: true, // <---------- Node represents an object
|
|
181
|
+
* position: [-4, -6, 4],
|
|
182
|
+
* scale: [1, 3, 1],
|
|
183
|
+
* rotation: [0, 0, 0],
|
|
184
|
+
* geometry: boxGeometry,
|
|
185
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
186
|
+
* diffuse: [1.0, 1.0, 0.0]
|
|
187
|
+
* })
|
|
188
|
+
* }),
|
|
189
|
+
*
|
|
190
|
+
* new Mesh(viewer.scene, { // Purple table top
|
|
191
|
+
* id: "tableTop",
|
|
192
|
+
* isObject: true, // <---------- Node represents an object
|
|
193
|
+
* position: [0, -3, 0],
|
|
194
|
+
* scale: [6, 0.5, 6],
|
|
195
|
+
* rotation: [0, 0, 0],
|
|
196
|
+
* geometry: boxGeometry,
|
|
197
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
198
|
+
* diffuse: [1.0, 0.3, 1.0]
|
|
199
|
+
* })
|
|
200
|
+
* })
|
|
201
|
+
* ]
|
|
202
|
+
* });
|
|
203
|
+
*
|
|
204
|
+
* let aabb = viewer.scene.aabb;
|
|
205
|
+
* console.log(aabb);
|
|
206
|
+
*
|
|
207
|
+
* new Mesh(viewer.scene, {
|
|
208
|
+
* geometry: new ReadableGeometry(viewer.scene, buildBoxLinesGeometryFromAABB({
|
|
209
|
+
* id: "aabb",
|
|
210
|
+
* aabb: aabb,
|
|
211
|
+
* })),
|
|
212
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
213
|
+
* emissive: [0, 1,]
|
|
214
|
+
* })
|
|
215
|
+
* });
|
|
216
|
+
* ````
|
|
217
|
+
*
|
|
218
|
+
* @function buildBoxLinesGeometryFromAABB
|
|
219
|
+
* @param {*} [cfg] Configs
|
|
220
|
+
* @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
|
|
221
|
+
* @param {Number[]} [cfg.aabb] AABB for which box will be created.
|
|
222
|
+
* @returns {Object} Configuration for a {@link Geometry} subtype.
|
|
223
|
+
*/
|
|
224
|
+
function buildBoxLinesGeometryFromAABB(cfg = {}){
|
|
225
|
+
return buildBoxLinesGeometry({
|
|
226
|
+
id: cfg.id,
|
|
227
|
+
center: [
|
|
228
|
+
(cfg.aabb[0] + cfg.aabb[3]) / 2.0,
|
|
229
|
+
(cfg.aabb[1] + cfg.aabb[4]) / 2.0,
|
|
230
|
+
(cfg.aabb[2] + cfg.aabb[5]) / 2.0,
|
|
231
|
+
],
|
|
232
|
+
xSize: (Math.abs(cfg.aabb[3] - cfg.aabb[0])) / 2.0,
|
|
233
|
+
ySize: (Math.abs(cfg.aabb[4] - cfg.aabb[1])) / 2.0,
|
|
234
|
+
zSize: (Math.abs(cfg.aabb[5] - cfg.aabb[2])) / 2.0,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export {buildBoxLinesGeometry, buildBoxLinesGeometryFromAABB};
|
|
@@ -134,4 +134,18 @@ export declare class DistanceMeasurement extends Component {
|
|
|
134
134
|
* @type {String}
|
|
135
135
|
*/
|
|
136
136
|
get color(): string;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Sets if labels should be positioned on the wires.
|
|
140
|
+
*
|
|
141
|
+
* @type {Boolean}
|
|
142
|
+
*/
|
|
143
|
+
set labelsOnWires(arg: boolean);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Gets if labels should be positioned on the wires.
|
|
147
|
+
*
|
|
148
|
+
* @type {Boolean}
|
|
149
|
+
*/
|
|
150
|
+
get labelsOnWires() : boolean;
|
|
137
151
|
}
|
|
@@ -21,6 +21,8 @@ export declare type DistanceMeasurementsPluginConfiguration = {
|
|
|
21
21
|
defaultAxisVisible?: boolean;
|
|
22
22
|
/** The default color of the length dots, wire and label. */
|
|
23
23
|
defaultColor?: string;
|
|
24
|
+
/** The default value of the DistanceMeasurements `labelsOnWires` property. */
|
|
25
|
+
defaultLabelsOnWires?: boolean;
|
|
24
26
|
/** If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels). */
|
|
25
27
|
zIndex?: number;
|
|
26
28
|
};
|
|
@@ -86,6 +88,7 @@ export declare class DistanceMeasurementsPlugin extends Plugin {
|
|
|
86
88
|
* @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement.origin} and {@link DistanceMeasurement.target}.
|
|
87
89
|
* @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement.origin} and {@link DistanceMeasurement.target}.
|
|
88
90
|
* @param {string} [params.color] The color of the length dot, wire and label.
|
|
91
|
+
* @param {Boolean} [params.labelsOnWires=true] Determines if labels will be set on wires or one below the other.
|
|
89
92
|
* @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
|
|
90
93
|
*/
|
|
91
94
|
createMeasurement(params?: {
|
|
@@ -104,6 +107,7 @@ export declare class DistanceMeasurementsPlugin extends Plugin {
|
|
|
104
107
|
wireVisible?: boolean;
|
|
105
108
|
axisVisible?: boolean;
|
|
106
109
|
color?: string;
|
|
110
|
+
labelsOnWires?: boolean;
|
|
107
111
|
}): DistanceMeasurement;
|
|
108
112
|
|
|
109
113
|
/**
|