@xeokit/xeokit-sdk 2.5.2-beta-22 → 2.5.2-beta-24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.5.2-beta-22",
3
+ "version": "2.5.2-beta-24",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -223,8 +223,8 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
223
223
  const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
224
224
  const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
225
225
  const canvasTopEdge = canvasBoundRect.top + scrollTop;
226
- this._markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
227
- this._markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
226
+ this.markerDiv.style.marginLeft = `${canvasLeftEdge + canvasPos[0] - 5}px`;
227
+ this.markerDiv.style.marginTop = `${canvasTopEdge + canvasPos[1] - 5}px`;
228
228
  break;
229
229
  case MOUSE_FINDING_CORNER:
230
230
  if (this._currentAngleMeasurement) {
@@ -387,7 +387,7 @@ export class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
387
387
  if (this.pointerLens) {
388
388
  this.pointerLens.visible = false;
389
389
  }
390
- if (this._markerDiv) {
390
+ if (this.markerDiv) {
391
391
  this._destroyMarkerDiv()
392
392
  }
393
393
  this.reset();
@@ -18,7 +18,7 @@ const MAX_VERTICES = 500000; // TODO: Rough estimate
18
18
  *
19
19
  * ## Summary
20
20
  *
21
- * * Loads [LAS 1.4 Format](https://www.asprs.org/divisions-committees/lidar-division/laser-las-file-format-exchange-activities) from both *.las* and *.laz* files.
21
+ * * Loads [LAS Formats](https://www.asprs.org/divisions-committees/lidar-division/laser-las-file-format-exchange-activities) up to v1.3 from both *.las* and *.laz* files. It does not support LAS v1.4.
22
22
  * * Loads lidar point cloud positions, colors and intensities.
23
23
  * * Supports 32 and 64-bit positions.
24
24
  * * Supports 8 and 16-bit color depths.
@@ -0,0 +1,206 @@
1
+ import {utils} from '../../utils.js';
2
+
3
+ /**
4
+ * @desc Creates a 3D polyline {@link Geometry}.
5
+ *
6
+ * ## Usage
7
+ *
8
+ * In the example below we'll create a {@link Mesh} with a polyline {@link ReadableGeometry} that has lines primitives.
9
+ *
10
+ * [[Run this example](/examples/#geometry_builders_buildPolylineGeometry)]
11
+ *
12
+ * ````javascript
13
+ * //------------------------------------------------------------------------------------------------------------------
14
+ * // Import the modules we need for this example
15
+ * //------------------------------------------------------------------------------------------------------------------
16
+ *
17
+ * import {buildPolylineGeometry, Viewer, Mesh, ReadableGeometry, PhongMaterial} from "../../dist/xeokit-sdk.min.es.js";
18
+ *
19
+ * //------------------------------------------------------------------------------------------------------------------
20
+ * // Create a Viewer and arrange the camera
21
+ * //------------------------------------------------------------------------------------------------------------------
22
+ *
23
+ * const viewer = new Viewer({
24
+ * canvasId: "myCanvas"
25
+ * });
26
+ *
27
+ * viewer.camera.eye = [0, 0, 8];
28
+ * viewer.camera.look = [0, 0, 0];
29
+ * viewer.camera.up = [0, 1, 0];
30
+ *
31
+ * //------------------------------------------------------------------------------------------------------------------
32
+ * // Create a mesh with polyline shape
33
+ * //------------------------------------------------------------------------------------------------------------------
34
+ *
35
+ * new Mesh(viewer.scene, {
36
+ * geometry: new ReadableGeometry(viewer.scene, buildPolylineGeometry({
37
+ * points: [
38
+ * 0, 2.83654, 0,
39
+ * -0.665144, 1.152063, 0,
40
+ * -2.456516, 1.41827, 0,
41
+ * -1.330288, 0, 0,
42
+ * -2.456516, -1.41827, 0,
43
+ * -0.665144, -1.152063, 0,
44
+ * 0, -2.83654, 0,
45
+ * 0.665144, -1.152063, 0,
46
+ * 2.456516, -1.41827, 0,
47
+ * 1.330288, 0, 0,
48
+ * 2.456516, 1.41827, 0,
49
+ * 0.665144, 1.152063, 0,
50
+ * 0, 2.83654, 0,
51
+ * ]
52
+ * })),
53
+ * material: new PhongMaterial(viewer.scene, {
54
+ * emissive: [0, 1,]
55
+ * })
56
+ * });
57
+ * ````
58
+ *
59
+ * @function buildPolylineGeometry
60
+ * @param {*} [cfg] Configs
61
+ * @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
62
+ * @param {Number[]} [cfg.points] 3D points indicating vertices position.
63
+ * @returns {Object} Configuration for a {@link Geometry} subtype.
64
+ */
65
+ function buildPolylineGeometry(cfg = {}) {
66
+
67
+ if (cfg.points.length % 3 !== 0) {
68
+ throw "Size of points array for given polyline should be divisible by 3";
69
+ }
70
+ let numberOfPoints = cfg.points.length / 3;
71
+ if (numberOfPoints < 2) {
72
+ throw "There should be at least 2 points to create a polyline";
73
+ }
74
+ let indices = [];
75
+ for (let i = 0; i < numberOfPoints - 1; i++) {
76
+ indices.push(i);
77
+ indices.push(i + 1);
78
+ }
79
+
80
+ return utils.apply(cfg, {
81
+ primitive: "lines",
82
+ positions: cfg.points,
83
+ indices: indices,
84
+ });
85
+ }
86
+
87
+ /**
88
+ * @desc Creates a 3D polyline from curve {@link Geometry}.
89
+ *
90
+ * ## Usage
91
+ *
92
+ * In the example below we'll create a {@link Mesh} with a polyline {@link ReadableGeometry} created from curves.
93
+ *
94
+ * [[Run this example](/examples/#geometry_builders_buildPolylineGeometryFromCurve)]
95
+ *
96
+ * ````javascript
97
+ * //------------------------------------------------------------------------------------------------------------------
98
+ * // Import the modules we need for this example
99
+ * //------------------------------------------------------------------------------------------------------------------
100
+ *
101
+ * import {buildPolylineGeometryFromCurve, Viewer, Mesh, PhongMaterial, NavCubePlugin, CubicBezierCurve, SplineCurve, QuadraticBezierCurve, ReadableGeometry} from "../../dist/xeokit-sdk.min.es.js";
102
+ *
103
+ * //------------------------------------------------------------------------------------------------------------------
104
+ * // Create a Viewer and arrange the camera
105
+ * //------------------------------------------------------------------------------------------------------------------
106
+ *
107
+ * const viewer = new Viewer({
108
+ * canvasId: "myCanvas"
109
+ * });
110
+ *
111
+ * new NavCubePlugin(viewer, {
112
+ * canvasId: "myNavCubeCanvas",
113
+ * visible: true,
114
+ * size: 250,
115
+ * alignment: "bottomRight",
116
+ * bottomMargin: 100,
117
+ * rightMargin: 10
118
+ * });
119
+ *
120
+ * viewer.camera.eye = [0, -250, 1];
121
+ * viewer.camera.look = [0, 0, 0];
122
+ * viewer.camera.up = [0, 1, 0];
123
+ *
124
+ * //------------------------------------------------------------------------------------------------------------------
125
+ * // Create a mesh with polyline shape from Spline
126
+ * //------------------------------------------------------------------------------------------------------------------
127
+ *
128
+ * new Mesh(viewer.scene, {
129
+ * geometry: new ReadableGeometry(viewer.scene, buildPolylineGeometryFromCurve({
130
+ * id: "SplineCurve",
131
+ * curve: new SplineCurve(viewer.scene, {
132
+ * points: [
133
+ * [-65.77614, 0, -88.881992],
134
+ * [90.020852, 0, -61.589088],
135
+ * [-67.766247, 0, -22.071238],
136
+ * [93.148164, 0, -13.826507],
137
+ * [-14.033343, 0, 3.231558],
138
+ * [32.592034, 0, 9.20188],
139
+ * [3.309023, 0, 22.848332],
140
+ * [23.210098, 0, 28.818655],
141
+ * ],
142
+ * }),
143
+ * divisions: 100,
144
+ * })),
145
+ * material: new PhongMaterial(viewer.scene, {
146
+ * emissive: [1, 0, 0]
147
+ * })
148
+ * });
149
+ *
150
+ * //------------------------------------------------------------------------------------------------------------------
151
+ * // Create a mesh with polyline shape from CubicBezier
152
+ * //------------------------------------------------------------------------------------------------------------------
153
+ *
154
+ * new Mesh(viewer.scene, {
155
+ * geometry: new ReadableGeometry(viewer.scene, buildPolylineGeometryFromCurve({
156
+ * id: "CubicBezierCurve",
157
+ * curve: new CubicBezierCurve(viewer.scene, {
158
+ * v0: [120, 0, 100],
159
+ * v1: [120, 0, 0],
160
+ * v2: [80, 0, 100],
161
+ * v3: [80, 0, 0],
162
+ * }),
163
+ * divisions: 50,
164
+ * })),
165
+ * material: new PhongMaterial(viewer.scene, {
166
+ * emissive: [0, 1, 0]
167
+ * })
168
+ * });
169
+ *
170
+ * //------------------------------------------------------------------------------------------------------------------
171
+ * // Create a mesh with polyline shape from QuadraticBezier
172
+ * //------------------------------------------------------------------------------------------------------------------
173
+ *
174
+ * new Mesh(viewer.scene, {
175
+ * geometry: new ReadableGeometry(viewer.scene, buildPolylineGeometryFromCurve({
176
+ * id: "QuadraticBezierCurve",
177
+ * curve: new QuadraticBezierCurve(viewer.scene, {
178
+ * v0: [-100, 0, 100],
179
+ * v1: [-50, 0, 150],
180
+ * v2: [-50, 0, 0],
181
+ * }),
182
+ * divisions: 20,
183
+ * })),
184
+ * material: new PhongMaterial(viewer.scene, {
185
+ * emissive: [0, 0, 1]
186
+ * })
187
+ * });
188
+ * ````
189
+ *
190
+ * @function buildPolylineGeometryFromCurve
191
+ * @param {*} [cfg] Configs
192
+ * @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
193
+ * @param {Object} [cfg.curve] Curve for which polyline will be created.
194
+ * @param {Number} [cfg.divisions] The number of divisions.
195
+ * @returns {Object} Configuration for a {@link Geometry} subtype.
196
+ */
197
+ function buildPolylineGeometryFromCurve(cfg = {}) {
198
+
199
+ let polylinePoints = cfg.curve.getPoints(cfg.divisions).map(a => [...a]).flat();
200
+ return buildPolylineGeometry({
201
+ id: cfg.id,
202
+ points: polylinePoints
203
+ });
204
+ }
205
+
206
+ export {buildPolylineGeometry, buildPolylineGeometryFromCurve};
@@ -13,10 +13,25 @@ export declare type buildBoxLinesGeometryConfiguration = {
13
13
  zSize?: number;
14
14
  };
15
15
 
16
+ export declare type buildBoxLinesGeometryFromAABBConfiguration = {
17
+ /* Optional ID for the {@link Geometry}, unique among all components in the parent {@link Scene}, generated automatically when omitted. */
18
+ id?: string;
19
+ /* AABB for which box will be created. */
20
+ aabb?: number[];
21
+ };
22
+
16
23
  /**
17
24
  * @desc Creates a box-shaped lines {@link Geometry}.
18
25
  *
19
26
  * @param {buildBoxLinesGeometryConfiguration} [cfg] Configs
20
27
  * @returns {Object} Configuration for a {@link Geometry} subtype.
21
28
  */
22
- export function buildBoxLinesGeometry(cfg: buildBoxLinesGeometryConfiguration): Geometry;
29
+ export function buildBoxLinesGeometry(cfg: buildBoxLinesGeometryConfiguration): Geometry;
30
+
31
+ /**
32
+ * @desc Creates a box-shaped lines {@link Geometry} from AABB.
33
+ *
34
+ * @param {buildBoxLinesGeometryConfiguration} [cfg] Configs
35
+ * @returns {Object} Configuration for a {@link Geometry} subtype.
36
+ */
37
+ export function buildBoxLinesGeometryFromAABB(cfg: buildBoxLinesGeometryFromAABBConfiguration): Geometry;
@@ -0,0 +1,16 @@
1
+ import { Geometry } from "../Geometry";
2
+
3
+ export declare type buildPolylineGeometryConfiguration = {
4
+ /* Optional ID for the {@link Geometry}, unique among all components in the parent {@link Scene}, generated automatically when omitted. */
5
+ id?: string;
6
+ /* 3D points indicating vertices position. */
7
+ points?: number[];
8
+ };
9
+
10
+ /**
11
+ * @desc Creates a 3D polyline {@link Geometry}.
12
+ *
13
+ * @param {buildBoxLinesGeometryConfiguration} [cfg] Configs
14
+ * @returns {Object} Configuration for a {@link Geometry} subtype.
15
+ */
16
+ export function buildPolylineGeometry(cfg: buildPolylineGeometryConfiguration): Geometry;