@xeokit/xeokit-sdk 2.6.90 → 2.6.91

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.90",
3
+ "version": "2.6.91",
4
4
  "description": "3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -52,10 +52,10 @@
52
52
  },
53
53
  "homepage": "https://xeokit.io",
54
54
  "dependencies": {
55
- "@loaders.gl/core": "^4.3.3",
56
- "@loaders.gl/gltf": "^4.3.3",
57
- "@loaders.gl/las": "^4.3.3",
58
- "html2canvas": "^1.4.1"
55
+ "@loaders.gl/core": "4.3.4",
56
+ "@loaders.gl/gltf": "4.3.4",
57
+ "@loaders.gl/las": "4.3.4",
58
+ "html2canvas": "1.4.1"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@babel/core": "^7.18.6",
@@ -0,0 +1,4 @@
1
+ export { parse } from "@loaders.gl/core";
2
+ export { GLTFLoader, postProcessGLTF } from "@loaders.gl/gltf";
3
+ export { LASLoader } from "@loaders.gl/las";
4
+ export { default as html2canvas } from "html2canvas/dist/html2canvas.esm.js";
package/src/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from "./extras/index.js";
2
2
  export * from "./plugins/index.js";
3
- export * from "./viewer/index.js";
3
+ export * from "./viewer/index.js";
@@ -1,5 +1,5 @@
1
- import { parse } from '@loaders.gl/core';
2
- import { GLTFLoader, postProcessGLTF } from '@loaders.gl/gltf';
1
+ import { parse } from "../../external.js";
2
+ import { GLTFLoader, postProcessGLTF } from "../../external.js";
3
3
  import { sRGBEncoding } from "../../viewer/scene/constants/constants.js";
4
4
  import { core } from "../../viewer/scene/core.js";
5
5
  import { math } from "../../viewer/scene/math/math.js";
@@ -3,9 +3,9 @@ import {SceneModel} from "../../viewer/scene/model/index.js";
3
3
  import {Plugin} from "../../viewer/Plugin.js";
4
4
  import {LASDefaultDataSource} from "./LASDefaultDataSource.js";
5
5
  import {math} from "../../viewer/index.js";
6
- import {parse} from '@loaders.gl/core';
7
- import {LASLoader} from '@loaders.gl/las';
8
- import {loadLASHeader} from "./loadLASHeader";
6
+ import {parse} from "../../external.js";
7
+ import {LASLoader} from "../../external.js";
8
+ import {loadLASHeader} from "./loadLASHeader.js";
9
9
 
10
10
  const MAX_VERTICES = 500000; // TODO: Rough estimate
11
11
 
@@ -3,7 +3,7 @@ import {CameraFlightAnimation} from "./scene/camera/CameraFlightAnimation.js";
3
3
  import {CameraControl} from "./scene/CameraControl/CameraControl.js";
4
4
  import {MetaScene} from "./metadata/MetaScene.js";
5
5
  import {LocaleService} from "./localization/LocaleService.js";
6
- import html2canvas from 'html2canvas/dist/html2canvas.esm.js';
6
+ import {html2canvas} from '../external.js';
7
7
  import {math} from "./scene/math/math.js";
8
8
  import {transformToNode} from "../plugins/lib/ui/index.js";
9
9
 
@@ -20,6 +20,7 @@ class MouseMiscHandler {
20
20
 
21
21
  document.addEventListener("mousemove", this._mouseMoveHandler = (e) => {
22
22
  getCanvasPosFromEvent(e, canvas, states.pointerCanvasPos);
23
+ states.mouseover = true; // Added to fix XCD-386: The zoom speed slows down when zooming into an empty space for the first time on a relatively large model, and it cannot be reset without reloading
23
24
  });
24
25
 
25
26
  canvas.addEventListener("mousedown", this._mouseDownHandler = (e) => {
@@ -5,26 +5,15 @@ import {math} from "../../../math/math.js";
5
5
 
6
6
  const canvasPos = math.vec2();
7
7
 
8
- const getCanvasPosFromEvent = function (event, canvasPos) {
8
+ const getCanvasPosFromEvent = function(event, canvas, canvasPos) {
9
9
  if (!event) {
10
10
  event = window.event;
11
11
  canvasPos[0] = event.x;
12
12
  canvasPos[1] = event.y;
13
13
  } else {
14
- let element = event.target;
15
- let totalOffsetLeft = 0;
16
- let totalOffsetTop = 0;
17
- let totalScrollX = 0;
18
- let totalScrollY = 0;
19
- while (element.offsetParent) {
20
- totalOffsetLeft += element.offsetLeft;
21
- totalOffsetTop += element.offsetTop;
22
- totalScrollX += element.scrollLeft;
23
- totalScrollY += element.scrollTop;
24
- element = element.offsetParent;
25
- }
26
- canvasPos[0] = event.pageX + totalScrollX - totalOffsetLeft;
27
- canvasPos[1] = event.pageY + totalScrollY - totalOffsetTop;
14
+ const canvasRect = canvas.getBoundingClientRect();
15
+ canvasPos[0] = event.clientX - canvasRect.left;
16
+ canvasPos[1] = event.clientY - canvasRect.top;
28
17
  }
29
18
  return canvasPos;
30
19
  };
@@ -296,7 +285,7 @@ class MousePanRotateDollyHandler {
296
285
  }
297
286
  switch (e.which) {
298
287
  case 3: // Right button
299
- getCanvasPosFromEvent(e, canvasPos);
288
+ getCanvasPosFromEvent(e, canvas, canvasPos);
300
289
  const x = canvasPos[0];
301
290
  const y = canvasPos[1];
302
291
  if (Math.abs(x - lastXDown) < 3 && Math.abs(y - lastYDown) < 3) {
@@ -347,6 +336,10 @@ class MousePanRotateDollyHandler {
347
336
  updates.dollyDelta += -normalizedDelta * secsElapsed * configs.mouseWheelDollyRate;
348
337
 
349
338
  if (mouseMovedOnCanvasSinceLastWheel) {
339
+ if ((states.pointerCanvasPos[0] === 0) && (states.pointerCanvasPos[1] === 0)) {
340
+ // Dirty fix to initiate states.pointerCanvasPos if a wheel over an empty space is the first action in a scene
341
+ getCanvasPosFromEvent(e, canvas, states.pointerCanvasPos); // Added to fix XCD-386: The zoom speed slows down when zooming into an empty space for the first time on a relatively large model, and it cannot be reset without reloading
342
+ }
350
343
  states.followPointerDirty = true;
351
344
  mouseMovedOnCanvasSinceLastWheel = false;
352
345
  }
@@ -1,21 +1,14 @@
1
1
  import {math} from "../../../math/math.js";
2
2
 
3
- const getCanvasPosFromEvent = function (event, canvasPos) {
3
+ const getCanvasPosFromEvent = function(event, canvas, canvasPos) {
4
4
  if (!event) {
5
5
  event = window.event;
6
6
  canvasPos[0] = event.x;
7
7
  canvasPos[1] = event.y;
8
8
  } else {
9
- let element = event.target;
10
- let totalOffsetLeft = 0;
11
- let totalOffsetTop = 0;
12
- while (element.offsetParent) {
13
- totalOffsetLeft += element.offsetLeft;
14
- totalOffsetTop += element.offsetTop;
15
- element = element.offsetParent;
16
- }
17
- canvasPos[0] = event.pageX - totalOffsetLeft;
18
- canvasPos[1] = event.pageY - totalOffsetTop;
9
+ const canvasRect = canvas.getBoundingClientRect();
10
+ canvasPos[0] = event.clientX - canvasRect.left;
11
+ canvasPos[1] = event.clientY - canvasRect.top;
19
12
  }
20
13
  return canvasPos;
21
14
  };
@@ -69,7 +62,7 @@ class TouchPanRotateAndDollyHandler {
69
62
 
70
63
  tapStartTime = states.touchStartTime;
71
64
 
72
- getCanvasPosFromEvent(touches[0], tapStartCanvasPos);
65
+ getCanvasPosFromEvent(touches[0], canvas, tapStartCanvasPos);
73
66
 
74
67
  if (configs.followPointer) {
75
68
 
@@ -111,7 +104,7 @@ class TouchPanRotateAndDollyHandler {
111
104
  }
112
105
 
113
106
  for (let i = 0, len = touches.length; i < len; ++i) {
114
- getCanvasPosFromEvent(touches[i], lastCanvasTouchPosList[i]);
107
+ getCanvasPosFromEvent(touches[i], canvas, lastCanvasTouchPosList[i]);
115
108
  }
116
109
 
117
110
  numTouches = touches.length;
@@ -159,7 +152,7 @@ class TouchPanRotateAndDollyHandler {
159
152
 
160
153
  if (numTouches === 1) {
161
154
 
162
- getCanvasPosFromEvent(touches[0], tapCanvasPos0);
155
+ getCanvasPosFromEvent(touches[0], canvas, tapCanvasPos0);
163
156
 
164
157
  //-----------------------------------------------------------------------------------------------
165
158
  // Drag rotation
@@ -220,8 +213,8 @@ class TouchPanRotateAndDollyHandler {
220
213
  const touch0 = touches[0];
221
214
  const touch1 = touches[1];
222
215
 
223
- getCanvasPosFromEvent(touch0, tapCanvasPos0);
224
- getCanvasPosFromEvent(touch1, tapCanvasPos1);
216
+ getCanvasPosFromEvent(touch0, canvas, tapCanvasPos0);
217
+ getCanvasPosFromEvent(touch1, canvas, tapCanvasPos1);
225
218
 
226
219
  const lastMiddleTouch = math.geometricMeanVec2(lastCanvasTouchPosList[0], lastCanvasTouchPosList[1]);
227
220
  const currentMiddleTouch = math.geometricMeanVec2(tapCanvasPos0, tapCanvasPos1);
@@ -243,6 +236,7 @@ class TouchPanRotateAndDollyHandler {
243
236
  const dollyDelta = (d2 - d1) * configs.touchDollyRate;
244
237
 
245
238
  updates.dollyDelta = dollyDelta;
239
+ states.followPointerDirty = true; // Added to fix XCD-386: The zoom speed slows down when zooming into an empty space for the first time on a relatively large model, and it cannot be reset without reloading
246
240
 
247
241
  if (Math.abs(dollyDelta) < 1.0) {
248
242
 
@@ -269,7 +263,7 @@ class TouchPanRotateAndDollyHandler {
269
263
  }
270
264
 
271
265
  for (let i = 0; i < numTouches; ++i) {
272
- getCanvasPosFromEvent(touches[i], lastCanvasTouchPosList[i]);
266
+ getCanvasPosFromEvent(touches[i], canvas, lastCanvasTouchPosList[i]);
273
267
  }
274
268
  });
275
269
  }
@@ -51,8 +51,8 @@ export declare type ViewerConfiguration = {
51
51
  alphaDepthMask?: boolean;
52
52
  /** Whether to enable {@link Entity.offset}. For best performance, only set this ````true```` when you need to use {@link Entity.offset}. */
53
53
  entityOffsetsEnabled?: boolean;
54
- /** Whether to enable full-precision accuracy when surface picking with {@link Scene.pick}. */
55
- pickSurfacePrecisionEnabled?: boolean;
54
+ /** Whether to enable full-precision accuracy when surface picking with {@link Scene#pick}. Note that when ````true````, this configuration will increase the amount of browser memory used by the Viewer. The ````pickSurfacePrecision```` option for ````Scene#pick```` only works if this is set ````true````. */
55
+ readableGeometryEnabled?: boolean;
56
56
  /** Whether to enable logarithmic depth buffer. */
57
57
  logarithmicDepthBufferEnabled?: boolean;
58
58
  /** Whether to enable base color texture rendering. */