@xeokit/xeokit-sdk 2.6.54 → 2.6.55

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.6.54",
3
+ "version": "2.6.55",
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",
@@ -820,6 +820,13 @@ class CameraControl extends Component {
820
820
  new KeyboardPanRotateDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates)
821
821
  ];
822
822
 
823
+ this._cursors = {
824
+ dollyForward: "zoom-in",
825
+ dollyBackward: "zoom-out",
826
+ rotate: 'grabbing',
827
+ pan: 'move',
828
+ }
829
+
823
830
  // Applies scheduled updates to the Camera on each Scene "tick" event
824
831
 
825
832
  this._cameraUpdater = new CameraUpdater(this.scene, this._controllers, this._configs, this._states, this._updates);
@@ -1181,6 +1188,37 @@ class CameraControl extends Component {
1181
1188
  this._configs.pointerEnabled = !!value;
1182
1189
  }
1183
1190
 
1191
+ /**
1192
+ * Sets the cursor to be used when a particular action is being performed.
1193
+ *
1194
+ * Accepted actions are:
1195
+ *
1196
+ * * "dollyForward" - when the camera is dollying in the forward direction
1197
+ * * "dollyBackward" - when the camera is dollying in the backward direction
1198
+ * * "pan" - when the camera is being panned
1199
+ * * "rotate" - when the camera is being rotated
1200
+ *
1201
+ * @param {String} action
1202
+ * @param {String} style
1203
+ */
1204
+ setCursorStyle(action, style) {
1205
+ if (Object.prototype.hasOwnProperty.call(this._cursors, action)) {
1206
+ this._cursors = { ...this._cursors, [action]: style };
1207
+ }
1208
+ else
1209
+ console.warn(`Action '${action}' is not valid for cursor styles.`);
1210
+ }
1211
+
1212
+ /**
1213
+ * Gets the current style for a particular action.
1214
+ *
1215
+ * @param {String} action To get the style for
1216
+ * @returns {String} style set on the cursor for action
1217
+ */
1218
+ getCursorStyle(action) {
1219
+ return this._cursors[action] || null;
1220
+ }
1221
+
1184
1222
  _reset() {
1185
1223
  for (let i = 0, len = this._handlers.length; i < len; i++) {
1186
1224
  const handler = this._handlers[i];
@@ -18,6 +18,7 @@ class CameraUpdater {
18
18
  const pickController = controllers.pickController;
19
19
  const pivotController = controllers.pivotController;
20
20
  const panController = controllers.panController;
21
+ const cameraControl = controllers.cameraControl;
21
22
 
22
23
  let countDown = SCALE_DOLLY_EACH_FRAME; // Decrements on each tick
23
24
  let dollyDistFactor = 1.0; // Calculated when countDown is zero
@@ -142,7 +143,7 @@ class CameraUpdater {
142
143
  updates.rotateDeltaX *= configs.rotationInertia;
143
144
  updates.rotateDeltaY *= configs.rotationInertia;
144
145
 
145
- cursorType = "grabbing";
146
+ cursorType = cameraControl._cursors.rotate;
146
147
  }
147
148
 
148
149
  //----------------------------------------------------------------------------------------------------------
@@ -208,7 +209,7 @@ class CameraUpdater {
208
209
  camera.pan(vec);
209
210
  }
210
211
 
211
- cursorType = "grabbing";
212
+ cursorType = cameraControl._cursors.pan;
212
213
  }
213
214
 
214
215
  updates.panDeltaX *= configs.panInertia;
@@ -222,9 +223,9 @@ class CameraUpdater {
222
223
  if (dollyDeltaForDist !== 0) {
223
224
 
224
225
  if (dollyDeltaForDist < 0) {
225
- cursorType = "zoom-in";
226
+ cursorType = cameraControl._cursors.dollyForward;
226
227
  } else {
227
- cursorType = "zoom-out";
228
+ cursorType = cameraControl._cursors.dollyBackward;
228
229
  }
229
230
 
230
231
  if (configs.firstPerson) {
@@ -26,10 +26,6 @@ class KeyboardPanRotateDollyHandler {
26
26
  return;
27
27
  }
28
28
  keyDownMap[keyCode] = true;
29
-
30
- if (keyCode === input.KEY_SHIFT) {
31
- canvas.style.cursor = "move";
32
- }
33
29
  });
34
30
 
35
31
  this._onSceneKeyUp = input.on("keyup", (keyCode) => {
@@ -38,10 +34,6 @@ class KeyboardPanRotateDollyHandler {
38
34
  }
39
35
  keyDownMap[keyCode] = false;
40
36
 
41
- if (keyCode === input.KEY_SHIFT) {
42
- canvas.style.cursor = null;
43
- }
44
-
45
37
  if (controllers.pivotController.getPivoting()) {
46
38
  controllers.pivotController.endPivot()
47
39
  }
@@ -78,7 +78,6 @@ class MousePanRotateDollyHandler {
78
78
  });
79
79
 
80
80
  function setMousedownState(pick = true) {
81
- canvas.style.cursor = "move";
82
81
  setMousedownPositions();
83
82
  if (pick) {
84
83
  setMousedownPick();
@@ -334,7 +334,7 @@ export class VBOInstancingTrianglesLayer {
334
334
  state.indicesBuf = new ArrayBuf(gl, gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(geometry.indices), geometry.indices.length, 1, gl.STATIC_DRAW);
335
335
  state.numIndices = geometry.indices.length;
336
336
  }
337
- if (geometry.primitive === "triangles" || geometry.primitive === "solid" || geometry.primitive === "surface") {
337
+ if (geometry.edgeIndices && geometry.edgeIndices.length > 0) {
338
338
  state.edgeIndicesBuf = new ArrayBuf(gl, gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(geometry.edgeIndices), geometry.edgeIndices.length, 1, gl.STATIC_DRAW);
339
339
  }
340
340
 
@@ -526,6 +526,29 @@ export declare class CameraControl extends Component {
526
526
  */
527
527
  get pointerEnabled(): boolean;
528
528
 
529
+ /**
530
+ * Sets the cursor to be used when a particular action is being performed.
531
+ *
532
+ * Accepted actions are:
533
+ *
534
+ * * "dollyForward" - when the camera is dollying in the forward direction
535
+ * * "dollyBackward" - when the camera is dollying in the backward direction
536
+ * * "pan" - when the camera is being panned
537
+ * * "rotate" - when the camera is being rotated
538
+ *
539
+ * @param {String} action
540
+ * @param {String} style
541
+ */
542
+ setCursorStyle(action: string, style: string): void;
543
+
544
+ /**
545
+ * Gets the current style for a particular action.
546
+ *
547
+ * @param {String} action To get the style for
548
+ * @returns {String} style set on the cursor for action
549
+ */
550
+ getCursorStyle(action: string): string | null;
551
+
529
552
  /**
530
553
  * Sets how much the {@link Camera} dollys each second with keyboard input.
531
554
  *