@xeokit/xeokit-sdk 2.6.34 → 2.6.36

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.
Files changed (23) hide show
  1. package/dist/xeokit-sdk.cjs.js +1060 -370
  2. package/dist/xeokit-sdk.es.js +1060 -370
  3. package/dist/xeokit-sdk.es5.js +126 -87
  4. package/dist/xeokit-sdk.min.cjs.js +3 -3
  5. package/dist/xeokit-sdk.min.es.js +4 -4
  6. package/dist/xeokit-sdk.min.es5.js +4 -4
  7. package/package.json +1 -1
  8. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +2 -4
  9. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +2 -4
  10. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +21 -6
  11. package/src/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.js +9 -11
  12. package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +8 -0
  13. package/src/plugins/XKTLoaderPlugin/parsers/ParserV11.js +657 -0
  14. package/src/plugins/ZonesPlugin/ZonesPlugin.js +3 -3
  15. package/src/plugins/lib/ui/index.js +1 -1
  16. package/src/viewer/Viewer.js +3 -0
  17. package/src/viewer/scene/CameraControl/CameraControl.js +22 -1
  18. package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +1 -1
  19. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickDepthRenderer.js +10 -6
  20. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickMeshRenderer.js +14 -8
  21. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsFlatRenderer.js +13 -8
  22. package/src/viewer/scene/model/dtx/triangles/renderers/DTXTrianglesPickNormalsRenderer.js +7 -10
  23. package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesDepthRenderer.js +0 -11
@@ -343,7 +343,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) {
343
343
  const copyCanvasPos = (event, vec2) => {
344
344
  vec2[0] = event.clientX;
345
345
  vec2[1] = event.clientY;
346
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
346
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
347
347
  return vec2;
348
348
  };
349
349
 
@@ -418,7 +418,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
418
418
  const copyCanvasPos = (event, vec2) => {
419
419
  vec2[0] = event.clientX;
420
420
  vec2[1] = event.clientY;
421
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
421
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
422
422
  return vec2;
423
423
  };
424
424
 
@@ -1735,7 +1735,7 @@ export class ZoneTranslateControl extends Component {
1735
1735
  const copyCanvasPos = (event, vec2) => {
1736
1736
  vec2[0] = event.clientX;
1737
1737
  vec2[1] = event.clientY;
1738
- transformToNode(canvas.ownerDocument.body, canvas, vec2);
1738
+ transformToNode(canvas.ownerDocument.documentElement, canvas, vec2);
1739
1739
  return vec2;
1740
1740
  };
1741
1741
 
@@ -117,7 +117,7 @@ export function activateDraggableDot(dot, cfg) {
117
117
 
118
118
  const onChange = event => {
119
119
  const canvasPos = math.vec2([ event.clientX, event.clientY ]);
120
- transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
120
+ transformToNode(canvas.ownerDocument.documentElement, canvas, canvasPos);
121
121
  onMove(canvasPos, pickWorldPos(canvasPos));
122
122
  };
123
123
 
@@ -377,6 +377,9 @@ class Viewer {
377
377
  }
378
378
  }
379
379
 
380
+ // firing "rendering" is necessary to trigger DTX{Lines,Triangles}Layer::_uploadDeferredFlags
381
+ this.scene.fire("rendering", { }, true);
382
+
380
383
  this.scene._renderer.renderSnapshot();
381
384
 
382
385
  const imageDataURI = this.scene._renderer.readSnapshot(params);
@@ -644,7 +644,8 @@ class CameraControl extends Component {
644
644
  constrainVertical: false,
645
645
  smartPivot: false,
646
646
  doubleClickTimeFrame: 250,
647
-
647
+ zoomOnMouseWheel: true,
648
+
648
649
  snapToVertex: DEFAULT_SNAP_VERTEX,
649
650
  snapToEdge: DEFAULT_SNAP_EDGE,
650
651
  snapRadius: DEFAULT_SNAP_PICK_RADIUS,
@@ -1735,6 +1736,26 @@ class CameraControl extends Component {
1735
1736
  return this._configs.doubleClickTimeFrame;
1736
1737
  }
1737
1738
 
1739
+ /**
1740
+ * Sets whether to zoom the camera on mouse wheel
1741
+ *
1742
+ * Default is ````true````
1743
+ *
1744
+ * @param {Boolean} enabled
1745
+ */
1746
+ set zoomOnMouseWheel(enabled) {
1747
+ this._configs.zoomOnMouseWheel = !!enabled;
1748
+ }
1749
+
1750
+ /**
1751
+ * Gets whether to zoom the camera on mouse wheel
1752
+ *
1753
+ * @returns {Boolean}
1754
+ */
1755
+ get zoomOnMouseWheel() {
1756
+ return this._configs.zoomOnMouseWheel;
1757
+ }
1758
+
1738
1759
  /**
1739
1760
  * Destroys this ````CameraControl````.
1740
1761
  * @private
@@ -296,7 +296,7 @@ class MousePanRotateDollyHandler {
296
296
  let secsNowLast = null;
297
297
 
298
298
  canvas.addEventListener("wheel", this._mouseWheelHandler = (e) => {
299
- if (!(configs.active && configs.pointerEnabled)) {
299
+ if (!(configs.active && configs.pointerEnabled && configs.zoomOnMouseWheel)) {
300
300
  return;
301
301
  }
302
302
  const secsNow = performance.now() / 1000.0;
@@ -37,7 +37,11 @@ export class DTXTrianglesPickDepthRenderer {
37
37
  const textureState = state.textureState;
38
38
  const origin = dataTextureLayer._state.origin;
39
39
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
40
+
40
41
  const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
42
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
43
+ const eye = frameCtx.pickOrigin || camera.eye;
44
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
41
45
 
42
46
  if (!this._program) {
43
47
  this._allocate();
@@ -77,15 +81,15 @@ export class DTXTrianglesPickDepthRenderer {
77
81
  rtcOrigin[2] += position[2];
78
82
  rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a);
79
83
  rtcCameraEye = tempVec3c;
80
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
81
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
82
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
84
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
85
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
86
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
83
87
  frameCtx.snapPickOrigin[0] = rtcOrigin[0];
84
88
  frameCtx.snapPickOrigin[1] = rtcOrigin[1];
85
89
  frameCtx.snapPickOrigin[2] = rtcOrigin[2];
86
90
  } else {
87
91
  rtcViewMatrix = viewMatrix;
88
- rtcCameraEye = camera.eye;
92
+ rtcCameraEye = eye;
89
93
  frameCtx.snapPickOrigin[0] = 0;
90
94
  frameCtx.snapPickOrigin[1] = 0;
91
95
  frameCtx.snapPickOrigin[2] = 0;
@@ -100,9 +104,9 @@ export class DTXTrianglesPickDepthRenderer {
100
104
  gl.uniform1f(this._uPickZFar, frameCtx.pickZFar);
101
105
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
102
106
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
103
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
107
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
104
108
  if (scene.logarithmicDepthBufferEnabled) {
105
- const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
109
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
106
110
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
107
111
  }
108
112
 
@@ -45,6 +45,12 @@ export class DTXTrianglesPickMeshRenderer {
45
45
  const textureState = state.textureState;
46
46
  const origin = dataTextureLayer._state.origin;
47
47
  const {position, rotationMatrix, rotationMatrixConjugate} = model;
48
+
49
+ const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
50
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
51
+ const eye = frameCtx.pickOrigin || camera.eye;
52
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
53
+
48
54
  textureState.bindCommonTextures(
49
55
  this._program,
50
56
  this.uTexturePerObjectPositionsDecodeMatrix,
@@ -71,24 +77,24 @@ export class DTXTrianglesPickMeshRenderer {
71
77
  rtcOrigin[0] += position[0];
72
78
  rtcOrigin[1] += position[1];
73
79
  rtcOrigin[2] += position[2];
74
- rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a);
80
+ rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a);
75
81
  rtcCameraEye = tempVec3c;
76
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
77
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
78
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
82
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
83
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
84
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
79
85
  } else {
80
- rtcViewMatrix = camera.viewMatrix;
81
- rtcCameraEye = camera.eye;
86
+ rtcViewMatrix = viewMatrix;
87
+ rtcCameraEye = eye;
82
88
  }
83
89
  gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
84
90
  gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
85
91
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
86
92
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
87
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
93
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
88
94
  gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye);
89
95
  gl.uniform1i(this._uRenderPass, renderPass);
90
96
  if (scene.logarithmicDepthBufferEnabled) {
91
- const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far from pick project matrix?
97
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
92
98
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
93
99
  }
94
100
  const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
@@ -55,6 +55,11 @@ export class DTXTrianglesPickNormalsFlatRenderer {
55
55
  this._bindProgram(frameCtx, state);
56
56
  }
57
57
 
58
+ const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
59
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
60
+ const eye = frameCtx.pickOrigin || camera.eye;
61
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
62
+
58
63
  textureState.bindCommonTextures(
59
64
  this._program,
60
65
  this.uTexturePerObjectPositionsDecodeMatrix,
@@ -83,24 +88,24 @@ export class DTXTrianglesPickNormalsFlatRenderer {
83
88
  rtcOrigin[0] += position[0];
84
89
  rtcOrigin[1] += position[1];
85
90
  rtcOrigin[2] += position[2];
86
- rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a);
91
+ rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a);
87
92
  rtcCameraEye = tempVec3c;
88
- rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0];
89
- rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1];
90
- rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2];
93
+ rtcCameraEye[0] = eye[0] - rtcOrigin[0];
94
+ rtcCameraEye[1] = eye[1] - rtcOrigin[1];
95
+ rtcCameraEye[2] = eye[2] - rtcOrigin[2];
91
96
  } else {
92
- rtcViewMatrix = camera.viewMatrix; // TODO: make pickMatrix
93
- rtcCameraEye = camera.eye;
97
+ rtcViewMatrix = viewMatrix;
98
+ rtcCameraEye = eye;
94
99
  }
95
100
  gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos);
96
101
  gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
97
102
  gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate);
98
103
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
99
- gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); // TODO: pickProjMatrix
104
+ gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix);
100
105
  gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye);
101
106
  gl.uniform1i(this._uRenderPass, renderPass);
102
107
  if (scene.logarithmicDepthBufferEnabled) {
103
- const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2);
108
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2);
104
109
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
105
110
  }
106
111
  const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes();
@@ -33,6 +33,11 @@ export class DTXTrianglesPickNormalsRenderer {
33
33
  const textureState = state.textureState;
34
34
  const origin = dataTextureLayer._state.origin;
35
35
 
36
+ const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix;
37
+ const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix;
38
+ const eye = frameCtx.pickOrigin || camera.eye;
39
+ const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far;
40
+
36
41
  if (!this._program) {
37
42
  this._allocate(dataTextureLayer);
38
43
  }
@@ -50,15 +55,7 @@ export class DTXTrianglesPickNormalsRenderer {
50
55
  this._uTexturePerObjectMatrix
51
56
  );
52
57
 
53
- let cameraEye = camera.eye;
54
-
55
- // if (frameCtx.pickViewMatrix) {
56
- // textureState.bindPickCameraTexture(
57
- // this._program,
58
- // this._uTextureCameraMatrices
59
- // );
60
- // cameraEye = frameCtx.pickOrigin || cameraEye;
61
- // }
58
+ let cameraEye = eye;
62
59
 
63
60
  const originCameraEye = [
64
61
  cameraEye[0] - origin[0],
@@ -77,7 +74,7 @@ export class DTXTrianglesPickNormalsRenderer {
77
74
  gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight);
78
75
 
79
76
  if (scene.logarithmicDepthBufferEnabled) {
80
- const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far should be from projection objectInstanceMatrix?
77
+ const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2); // TODO: Far should be from projection objectInstanceMatrix?
81
78
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
82
79
  }
83
80
 
@@ -89,17 +89,6 @@ export class TrianglesDepthRenderer extends TrianglesBatchingRenderer {
89
89
  src.push("uniform vec3 sectionPlaneDir" + i + ";");
90
90
  }
91
91
  }
92
- src.push("const float packUpScale = 256. / 255.;");
93
- src.push("const float unpackDownscale = 255. / 256.;");
94
- src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");
95
- src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");
96
- src.push("const float shiftRight8 = 1.0 / 256.;");
97
-
98
- src.push("vec4 packDepthToRGBA( const in float v ) {");
99
- src.push(" vec4 r = vec4( fract( v * packFactors ), v );");
100
- src.push(" r.yzw -= r.xyz * shiftRight8;");
101
- src.push(" return r * packUpScale;");
102
- src.push("}");
103
92
  src.push("in vec2 vHighPrecisionZW;");
104
93
  src.push("out vec4 outColor;");
105
94
  src.push("void main(void) {");